Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 3e6bacc

Browse files
committed
Fix crash when trying to load custom BuyMenu skins
1 parent c382bbe commit 3e6bacc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

GUI/GUISkin.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ bool GUISkin::Load(const std::string &directory, const std::string &fileName) {
3838
// Destroy any previous instances
3939
Destroy();
4040

41-
m_Directory = g_PresetMan.FullModulePath(!directory.empty() ? (directory + "/") : "");
41+
if (!directory.empty()) {
42+
m_Directory = g_PresetMan.FullModulePath(directory) + "/";
43+
} else {
44+
// Empty directory means file can be loaded from anywhere in the working directory so need to figure out in what data directory the file actually is from fileName.
45+
std::string fileFullPath = g_PresetMan.FullModulePath(fileName);
46+
m_Directory = fileFullPath.substr(0, fileFullPath.find_first_of("/\\") + 1);
47+
}
4248

4349
GUIReader skinFile;
4450
if (skinFile.Create(m_Directory + fileName) == -1) {

0 commit comments

Comments
 (0)