Skip to content

Commit

Permalink
ShoC style texture description reading
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Nov 9, 2018
1 parent 9396cc2 commit ca1b93b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/xrGame/ScriptXMLInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ void _attach_child(CUIWindow* _child, CUIWindow* _parent)
}

void CScriptXmlInit::ParseFile(LPCSTR xml_file) { m_xml.Load(CONFIG_PATH, UI_PATH, UI_PATH_DEFAULT, xml_file); }

void CScriptXmlInit::ParseShTexInfo(pcstr xml_file)
{
CUITextureMaster::ParseShTexInfo(xml_file);
}

void CScriptXmlInit::InitWindow(LPCSTR path, int index, CUIWindow* pWnd)
{
CUIXmlInit::InitWindow(m_xml, path, index, pWnd);
Expand Down Expand Up @@ -251,6 +257,7 @@ SCRIPT_EXPORT(CScriptXmlInit, (), {
module(luaState)[class_<CScriptXmlInit>("CScriptXmlInit")
.def(constructor<>())
.def("ParseFile", &CScriptXmlInit::ParseFile)
.def("ParseShTexInfo", &CScriptXmlInit::ParseShTexInfo)
.def("InitWindow", &CScriptXmlInit::InitWindow)
.def("InitFrame", &CScriptXmlInit::InitFrame)
.def("InitFrameLine", &CScriptXmlInit::InitFrameLine)
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/ScriptXMLInit.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class CScriptXmlInit
{
public:
void ParseFile(LPCSTR xml_file);
void ParseShTexInfo(pcstr xml_file);
void InitWindow(LPCSTR path, int index, CUIWindow* pWnd);
CUIFrameWindow* InitFrame(LPCSTR path, CUIWindow* parent);
CUIFrameLineWnd* InitFrameLine(LPCSTR path, CUIWindow* parent);
Expand Down
26 changes: 26 additions & 0 deletions src/xrUICore/XML/UITextureMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,32 @@ void CUITextureMaster::ParseShTexInfo(pcstr path, pcstr xml_file)
}
}

void CUITextureMaster::ParseShTexInfo(pcstr xml_file)
{
CUIXml xml;
xml.Load(CONFIG_PATH, UI_PATH, xml_file);
const shared_str file = xml.Read("file_name", 0, "");

const int num = xml.GetNodesNum("", 0, "texture");
for (int i = 0; i < num; i++)
{
TEX_INFO info;

info.file = file;

info.rect.x1 = xml.ReadAttribFlt("texture", i, "x");
info.rect.x2 = xml.ReadAttribFlt("texture", i, "width") + info.rect.x1;
info.rect.y1 = xml.ReadAttribFlt("texture", i, "y");
info.rect.y2 = xml.ReadAttribFlt("texture", i, "height") + info.rect.y1;
shared_str id = xml.ReadAttrib("texture", i, "id");

if (m_textures.find(id) == m_textures.end())
m_textures.emplace(id, info);
else
m_textures[id] = info;
}
}

bool CUITextureMaster::IsSh(const shared_str& texture_name)
{
return strstr(texture_name.c_str(), DELIMITER) ? false : true;
Expand Down
1 change: 1 addition & 0 deletions src/xrUICore/XML/UITextureMaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct sh_pair
class XRUICORE_API CUITextureMaster
{
public:
static void ParseShTexInfo(pcstr xml_file);
static void ParseShTexInfo(pcstr path, pcstr xml_file);
static void FreeTexInfo();
static void FreeCachedShaders();
Expand Down

1 comment on commit ca1b93b

@Xottab-DUTY
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to #392

Please sign in to comment.