15#ifndef DL_DISABLE_RENDER
16#include <unordered_map>
50 std::string_view path_image =
"image/",
51 std::string_view path_model =
"model/",
52 std::string_view path_binary =
"binary/",
53 std::string_view path_temp =
"temp/")
61 _mapPathImage[
""] = path_image;
62 _strPathModel = path_model;
63 _strPathBinary = path_binary;
64 _strPathTemp = path_temp;
82 log_err(
"请在调用SetPath之前添加图像路径:{},{}", path, name);
85 auto iter = _mapPathImage.find(name);
86 if (iter != _mapPathImage.end())
88 log_err(
"重复添加图像路径:{},{}", path, name);
91 _mapPathImage[std::string{ name }] = path;
98 void LoadModel(std::string_view path_name, std::string_view name =
"");
105 return _mapPathImage[
""];
112 return _strPathVoice;
120 return _strPathBinary;
127 return _strPathBinary + std::string{
STR_PATH_3D };
134 return _strPathBinary + std::string{
STR_PATH_2D };
149 std::string ret = str_fmt.empty() ?
150 fmt::format(
"{}{}", _strPathTemp, _idTemp) :
151 fmt::format(
"{}{}.{}", _strPathTemp, _idTemp, str_fmt);
187 std::string_view name,
188 std::size_t index = 0);
218 std::string_view name,
220 std::size_t index = 0);
348 txt->_fontId, txt->_fontSize[0], txt->_col[0],
349 txt->_fontSize[1], txt->_col[1],
350 txt->_fontSize[2], txt->_col[2]);
352 ret->_layout = txt->_layout;
353 ret->_order = txt->_order;
354 ret->_bFormat = txt->_bFormat;
421 _vecPickupSprite.push_back(spr);
425 _vecPickupText.push_back(txt);
430 _vecPickupSprite.clear();
431 _vecPickupText.clear();
441 std::unordered_map<std::string, std::string, string_hash, std::equal_to<>> _mapPathImage;
442 std::string _strPathModel;
443 std::string _strPathVoice;
444 std::string _strPathBinary;
445 std::string _strPathTemp;
448 bool _bOrderPickupShow;
454 std::unordered_map<std::string, Color> _hashTagColor;
457 std::vector<Sprite*> _vecPickupSprite;
458 std::vector<Text*> _vecPickupText;
461 std::unordered_map<std::string, AnimationInfo, string_hash, std::equal_to<>> _mapAnimationInfo;
464 std::vector<gcSprite> _vecSprite;
465 std::vector<gcText> _vecText;
466 std::vector<gcAnimation> _vecAnimation;
469 void _clear_render();
473 void _init_defualt_res();
479 void _load_animation();
481 void _load_sprite_binary();
483 void _load_sprite_sub(std::string_view path, std::string_view name, std::string_view path_out);
void SetParent(Coor *coor)
bool RegisterSprite(std::string_view name, size_t index, Image *img, const Position &anchor={})
注册一个精灵(动态)
gcText CloneText(gcText txt, bool copy_str=true)
复制一个文本
SpriteID GetSpriteId(std::string_view name, size_t index)
返回精灵的id
std::string GetPathBinary3D()
返回3d资源缓存目录,例如"binary/3d/"
std::string GetPathBinary()
返回资源缓存目录,例如"binary/"
gcSprite CreateSprite(std::string_view name, std::size_t index=0)
创建一个精灵
size_t GetFontSize()
返回加载的字体数量
float CreateSpriteChar(const CharInfo &info, gcSprite &spr)
std::string GetPathNameTemp(std::string_view str_fmt="")
返回临时文件名,例如"temp/1"
float CreateSpriteChar(const CharInfo &info, gcSprite &spr, gcSprite &spr_outline)
创建一个字符精灵
Color GetSpriteColor(gcSprite &spr)
gcSprite CreateSprite(const SpriteID &spr_id)
创建一个精灵
gcAnimation RenderAnimation(std::string_view name, std::string_view state, unsigned dir=0)
gcText RenderText()
创建临时文本,并绘制
Color GetSpriteColor(const SpriteID &spr_id)
返回精灵的默认颜色
std::string GetPathBinary2D()
返回2d资源缓存目录,例如"binary/2d/"
void SetOrderPickupShow(bool show)
size_t LoadFont(std::string_view path_name)
加载字体
Position GetSpriteAnchor(gcSprite &spr)
gcSprite CloneSprite(gcSprite &spr)
复制一个精灵
void SetOrderPickup(float order)
设置拾取ui的当前order
void SetPath(std::string_view path_image="image/", std::string_view path_model="model/", std::string_view path_binary="binary/", std::string_view path_temp="temp/")
设置 各种路径
void RegisterImagePath(std::string_view path, std::string_view name)
注册图像加载路径
Coor * GetRootCoor(size_t i)
返回根坐标系
void LoadModel(std::string_view path_name, std::string_view name="")
加载模型文件
gcSprite RenderSprite(std::string_view name, size_t index=0)
创建临时精灵,并绘制
void AddColor(std::string_view name, const Color &col)
添加一个颜色
void _add_pickup_sprite(Sprite *spr)
gcText CreateText(size_t font_id=0, unsigned font_size=16, const Color &col=ColorDef::WHITE, unsigned font_outline=0, const Color &col_outline=ColorDef::BLACK, unsigned font_shadow=0, const Color &col_shadow=ColorDef::BLACK)
创建一个文本
size_t GetSpriteSheetNum(std::string_view name)
返回精灵的sheet有多少张
Camera * GetCamera()
返回相机(3d)
gcActor CreateActor(std::string_view name)
创建一个演员,通过指定模型文件
bool HasSprite(std::string_view name)
检测精灵是否存在
std::string GetPathImage()
返回图像目录
std::string GetSpriteName(const SpriteID &spr_id)
返回精灵的名字
std::vector< std::string > GetFolderAllSpriteName(std::string_view folder_name)
返回一个文件夹下的所有精灵
std::string GetPathVoice()
返回音效目录
gcAnimation CloneAnimation(gcAnimation ani)
Position GetSpriteAnchor(const SpriteID &spr_id)
返回精灵的默认锚点
gcAnimation CreateAnimation(std::string_view name, std::string_view state, unsigned dir=0)
创建精灵动画
CharImage * GetChar(const CharInfo &info)
获得字符图像
void _render_sprite(Sprite *spr)
gcSprite CloneSprite(const gcSprite &spr)
std::string GetPathTemp()
返回临时文件路径,例如"temp/"
bool GetOrderPickupShow()
Size GetSpriteTexSize(const SpriteID &spr_id)
返回精灵的纹理大小
gcText CreateTextDefault()
void SetReleaseMode()
设置发布模式,使用binary资源
void DeleteBinary(bool b_all, bool b_2d, bool b_3d)
删除输出目录内容
gcSprite RenderSpriteDefault()
void LoadColorCsv(std::string_view name)
从文件加载颜色标签
std::vector< gcSprite > CreateSpriteMulti(std::string_view name, std::size_t num=0, std::size_t index=0)
创建多个精灵,从已加载的精灵表复制
std::string GetSpriteName(gcSprite &spr)
gcSprite CreateSpriteDefault(const Color &col=ColorDef::WHITE)
创建默认精灵
std::optional< Color > GetColorCheck(std::string_view name)
返回一个颜色,会检查
Size GetSpriteTexSize(gcSprite &spr)
void ExportTexture2D()
导出所有2d纹理
void _add_pickup_text(Text *txt)
gcSprite CreateSpriteRandom(std::string_view name)
创建一个精灵,随机选中下标
Color GetColor(std::string_view name)
返回一个颜色
T * GetPointer()
直接获取指针,注意生命周期
static size_t SizeT(size_t min, size_t max)
返回[min,max]区间的 size_t型整数
bool SetString(std::string_view str)
设置内容
void SetBackground(bool open, const Color &col=ColorDef::TEXT_BG)
设置背景精灵
constexpr std::string_view STR_PATH_2D
constexpr Size SIZE_SPRITE_DEFAULT
GC< Animation > gcAnimation
Vector2< uint32_t, unsigned > Image
void log_damage0(std::string_view str, const std::source_location location=std::source_location::current())
constexpr std::string_view STR_PATH_3D