Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/CGUI.cpp
Show First 20 Lines • Show All 852 Lines • ▼ Show 20 Lines | |||||
void CGUI::Xeromyces_ReadScript(XMBElement Element, CXeromyces* pFile, std::unordered_set<VfsPath>& Paths) | void CGUI::Xeromyces_ReadScript(XMBElement Element, CXeromyces* pFile, std::unordered_set<VfsPath>& Paths) | ||||
{ | { | ||||
// Check for a 'file' parameter | // Check for a 'file' parameter | ||||
CStrW file(Element.GetAttributes().GetNamedItem(pFile->GetAttributeID("file")).FromUTF8()); | CStrW file(Element.GetAttributes().GetNamedItem(pFile->GetAttributeID("file")).FromUTF8()); | ||||
// If there is a file specified, open and execute it | // If there is a file specified, open and execute it | ||||
if (!file.empty()) | if (!file.empty()) | ||||
{ | { | ||||
if (!VfsPath(file).IsDirectory()) | |||||
{ | |||||
Paths.insert(file); | Paths.insert(file); | ||||
m_ScriptInterface->LoadGlobalScriptFile(file); | m_ScriptInterface->LoadGlobalScriptFile(file); | ||||
} | } | ||||
else | |||||
LOGERROR("GUI: Script path %s is not a file path", file.ToUTF8().c_str()); | |||||
} | |||||
// If it has a directory attribute, read all JS files in that directory | // If it has a directory attribute, read all JS files in that directory | ||||
CStrW directory(Element.GetAttributes().GetNamedItem(pFile->GetAttributeID("directory")).FromUTF8()); | CStrW directory(Element.GetAttributes().GetNamedItem(pFile->GetAttributeID("directory")).FromUTF8()); | ||||
if (!directory.empty()) | if (!directory.empty()) | ||||
{ | { | ||||
if (VfsPath(directory).IsDirectory()) | |||||
{ | |||||
VfsPaths pathnames; | VfsPaths pathnames; | ||||
vfs::GetPathnames(g_VFS, directory, L"*.js", pathnames); | vfs::GetPathnames(g_VFS, directory, L"*.js", pathnames); | ||||
for (const VfsPath& path : pathnames) | for (const VfsPath& path : pathnames) | ||||
{ | { | ||||
// Only load new files (so when the insert succeeds) | // Only load new files (so when the insert succeeds) | ||||
if (Paths.insert(path).second) | if (Paths.insert(path).second) | ||||
m_ScriptInterface->LoadGlobalScriptFile(path); | m_ScriptInterface->LoadGlobalScriptFile(path); | ||||
} | } | ||||
} | } | ||||
else | |||||
LOGERROR("GUI: Script path %s is not a directory path", directory.ToUTF8().c_str()); | |||||
} | |||||
CStr code(Element.GetText()); | CStr code(Element.GetText()); | ||||
if (!code.empty()) | if (!code.empty()) | ||||
m_ScriptInterface->LoadGlobalScript(L"Some XML file", code.FromUTF8()); | m_ScriptInterface->LoadGlobalScript(L"Some XML file", code.FromUTF8()); | ||||
} | } | ||||
void CGUI::Xeromyces_ReadSprite(XMBElement Element, CXeromyces* pFile) | void CGUI::Xeromyces_ReadSprite(XMBElement Element, CXeromyces* pFile) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 363 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator