Skip to content

Commit 4f6ce60

Browse files
committed
Fixed includes loading with UI Styles
1 parent 690ffbf commit 4f6ce60

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

src/xrCore/XML/XMLDocument.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "stdafx.h"
2-
#pragma hdrstop
32

43
#include "XMLDocument.hpp"
54

6-
pcstr UI_PATH = "ui";
5+
pcstr UI_PATH = UI_PATH_DEFAULT;
6+
pcstr UI_PATH_WITH_DELIMITER = UI_PATH_DEFAULT_WITH_DELIMITER;
77

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

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

src/xrCore/XML/XMLDocument.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
// XXX: interesting idea is to have variable configs folder. Need we?
1717
static constexpr pcstr CONFIG_PATH = _game_config_;
1818
static constexpr pcstr UI_PATH_DEFAULT = "ui";
19+
static constexpr pcstr UI_PATH_DEFAULT_WITH_DELIMITER = "ui" DELIMITER;
1920
XRCORE_API extern pcstr UI_PATH;
21+
XRCORE_API extern pcstr UI_PATH_WITH_DELIMITER;
2022

2123
class XML_NODE
2224
{

src/xrGame/GamePersistent.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ void SetupUIStyle()
8585
strconcat(sizeof(selectedStylePath), selectedStylePath, UI_PATH, DELIMITER "styles" DELIMITER, selectedStyle);
8686

8787
UI_PATH = xr_strdup(selectedStylePath);
88+
89+
strconcat(sizeof(selectedStylePath), selectedStylePath, selectedStylePath, DELIMITER);
90+
UI_PATH_WITH_DELIMITER = xr_strdup(selectedStylePath);
91+
8892
defaultUIStyle = false;
8993
}
9094

@@ -97,7 +101,10 @@ void CleanupUIStyleToken()
97101
}
98102
UIStyleToken.clear();
99103
if (!defaultUIStyle)
104+
{
100105
xr_free(UI_PATH);
106+
xr_free(UI_PATH_WITH_DELIMITER);
107+
}
101108
}
102109

103110
CGamePersistent::CGamePersistent(void)

src/xrUICore/XML/xrUIXmlParser.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ shared_str CUIXml::correct_file_name(pcstr path, pcstr fn)
1212
{
1313
return UI().get_xml_name(fn);
1414
}
15-
else
16-
return fn;
17-
#else
18-
return fn;
1915
#endif
16+
17+
return fn;
2018
}
2119

2220
CUIXml::CUIXml()

src/xrUICore/ui_base.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "pch.hpp"
22
#include "ui_base.h"
33
#include "Cursor/UICursor.h"
4+
#include "xrCore/XML/XMLDocument.hpp"
45

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

294-
if (NULL == FS.exist(str_, "$game_config$", "ui" DELIMITER , str))
295+
if (NULL == FS.exist(str_, "$game_config$", UI_PATH_WITH_DELIMITER, str))
295296
{
296297
xr_sprintf(str, "%s", fn);
297298
if (NULL == strext(fn))

0 commit comments

Comments
 (0)