57 Star 302 Fork 106

sb500/kys-cpp

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Font.h 1.21 KB
一键复制 编辑 原始数据 按行查看 历史
sb500 提交于 2022-12-07 17:27 +08:00 . 行简劝尔酒,停杯听我辞
#pragma once
#include "Engine.h"
#include <map>
#include <string>
#include <unordered_map>
#include "GameUtil.h"
class Font
{
private:
Font();
std::string fontnamec_;
std::string fontnamee_;
int stat_message_ = 0;
int simplified_ = 1;
std::map<uint32_t, std::map<int, BP_Texture*>> buffer_; //缓存画过的字体
std::unordered_map<std::string, std::string> t2s_buffer_; //缓存繁体转简体的结果
public:
static Font* getInstance()
{
static Font f;
return &f;
}
static BP_Rect getBoxSize(int textLen, int size, int x, int y);
void setStatMessage(int s) { stat_message_ = s; }
void draw(const std::string& text, int size, int x, int y, BP_Color color = { 255, 255, 255, 255 }, uint8_t alpha = 255);
void drawWithBox(const std::string& text, int size, int x, int y, BP_Color color = { 255, 255, 255, 255 }, uint8_t alpha = 255, uint8_t alpha_box = 255);
void drawText(const std::string& fontname, std::string& text, int size, int x, int y, uint8_t alpha, int align, BP_Color c);
void clearBuffer();
int getBufferSize();
static int getTextDrawSize(const std::string& text);
void setSimplified(int s) { simplified_ = s; }
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C/C++
1
https://gitee.com/scarsty/kys-cpp.git
git@gitee.com:scarsty/kys-cpp.git
scarsty
kys-cpp
kys-cpp
master

搜索帮助