Skip to content

Commit

Permalink
Fixed includes loading with UI Styles
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Oct 17, 2018
1 parent 690ffbf commit 4f6ce60
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/xrCore/XML/XMLDocument.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "stdafx.h"
#pragma hdrstop

#include "XMLDocument.hpp"

pcstr UI_PATH = "ui";
pcstr UI_PATH = UI_PATH_DEFAULT;
pcstr UI_PATH_WITH_DELIMITER = UI_PATH_DEFAULT_WITH_DELIMITER;

XMLDocument::XMLDocument() : m_root(), m_pLocalRoot() {}

Expand All @@ -28,11 +28,11 @@ void ParseFile(pcstr path, CMemoryWriter& W, IReader* F, XMLDocument* xml)
while (char* sep = strchr(inc_name, '\\')) *sep = '/';
#endif
IReader* I = nullptr;
if (inc_name == strstr(inc_name, "ui" DELIMITER ))
if (inc_name == strstr(inc_name, UI_PATH_DEFAULT_WITH_DELIMITER))
{
shared_str fn = xml->correct_file_name("ui", strchr(inc_name, _DELIMITER) + 1);
shared_str fn = xml->correct_file_name(UI_PATH, strchr(inc_name, _DELIMITER) + 1);
string_path buff;
strconcat(sizeof buff, buff, "ui" DELIMITER , fn.c_str());
strconcat(sizeof buff, buff, UI_PATH_WITH_DELIMITER, fn.c_str());
I = FS.r_open(path, buff);
}

Expand Down
2 changes: 2 additions & 0 deletions src/xrCore/XML/XMLDocument.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
// XXX: interesting idea is to have variable configs folder. Need we?
static constexpr pcstr CONFIG_PATH = _game_config_;
static constexpr pcstr UI_PATH_DEFAULT = "ui";
static constexpr pcstr UI_PATH_DEFAULT_WITH_DELIMITER = "ui" DELIMITER;
XRCORE_API extern pcstr UI_PATH;
XRCORE_API extern pcstr UI_PATH_WITH_DELIMITER;

class XML_NODE
{
Expand Down
7 changes: 7 additions & 0 deletions src/xrGame/GamePersistent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ void SetupUIStyle()
strconcat(sizeof(selectedStylePath), selectedStylePath, UI_PATH, DELIMITER "styles" DELIMITER, selectedStyle);

UI_PATH = xr_strdup(selectedStylePath);

strconcat(sizeof(selectedStylePath), selectedStylePath, selectedStylePath, DELIMITER);
UI_PATH_WITH_DELIMITER = xr_strdup(selectedStylePath);

defaultUIStyle = false;
}

Expand All @@ -97,7 +101,10 @@ void CleanupUIStyleToken()
}
UIStyleToken.clear();
if (!defaultUIStyle)
{
xr_free(UI_PATH);
xr_free(UI_PATH_WITH_DELIMITER);
}
}

CGamePersistent::CGamePersistent(void)
Expand Down
6 changes: 2 additions & 4 deletions src/xrUICore/XML/xrUIXmlParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ shared_str CUIXml::correct_file_name(pcstr path, pcstr fn)
{
return UI().get_xml_name(fn);
}
else
return fn;
#else
return fn;
#endif

return fn;
}

CUIXml::CUIXml()
Expand Down
3 changes: 2 additions & 1 deletion src/xrUICore/ui_base.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "pch.hpp"
#include "ui_base.h"
#include "Cursor/UICursor.h"
#include "xrCore/XML/XMLDocument.hpp"

CUICursor& GetUICursor() { return GEnv.UI->GetUICursor(); }
UICore& UI() { return *GEnv.UI; }
Expand Down Expand Up @@ -291,7 +292,7 @@ shared_str UICore::get_xml_name(LPCSTR fn)
else
xr_sprintf(str, "%s_16", fn);

if (NULL == FS.exist(str_, "$game_config$", "ui" DELIMITER , str))
if (NULL == FS.exist(str_, "$game_config$", UI_PATH_WITH_DELIMITER, str))
{
xr_sprintf(str, "%s", fn);
if (NULL == strext(fn))
Expand Down

0 comments on commit 4f6ce60

Please sign in to comment.