mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 15:44:56 +00:00
string_view refactor
This commit is contained in:
@@ -7,7 +7,7 @@ namespace urde
|
||||
static logvisor::Module Log("URDE::ProjectManager");
|
||||
ProjectManager* ProjectManager::g_SharedManager = nullptr;
|
||||
|
||||
CToken ProjectResourcePool::GetObj(const char* name)
|
||||
CToken ProjectResourcePool::GetObj(std::string_view name)
|
||||
{
|
||||
CToken ret = CSimplePool::GetObj(name);
|
||||
if (ret)
|
||||
@@ -22,7 +22,7 @@ CToken ProjectResourcePool::GetObj(const char* name)
|
||||
return {};
|
||||
}
|
||||
|
||||
CToken ProjectResourcePool::GetObj(const char* name, const CVParamTransfer& pvxfer)
|
||||
CToken ProjectResourcePool::GetObj(std::string_view name, const CVParamTransfer& pvxfer)
|
||||
{
|
||||
CToken ret = CSimplePool::GetObj(name, pvxfer);
|
||||
if (ret)
|
||||
@@ -49,16 +49,16 @@ ProjectManager::ProjectManager(ViewManager &vm)
|
||||
g_SharedManager = this;
|
||||
}
|
||||
|
||||
bool ProjectManager::newProject(const hecl::SystemString& path)
|
||||
bool ProjectManager::newProject(hecl::SystemStringView path)
|
||||
{
|
||||
hecl::ProjectRootPath projPath = hecl::SearchForProject(path);
|
||||
if (projPath)
|
||||
{
|
||||
Log.report(logvisor::Warning, _S("project already exists at '%s'"), path.c_str());
|
||||
Log.report(logvisor::Warning, _S("project already exists at '%s'"), path.data());
|
||||
return false;
|
||||
}
|
||||
|
||||
hecl::MakeDir(path.c_str());
|
||||
hecl::MakeDir(path.data());
|
||||
m_proj.reset(new hecl::Database::Project(path));
|
||||
if (!*m_proj)
|
||||
{
|
||||
@@ -79,13 +79,13 @@ bool ProjectManager::newProject(const hecl::SystemString& path)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProjectManager::openProject(const hecl::SystemString& path)
|
||||
bool ProjectManager::openProject(hecl::SystemStringView path)
|
||||
{
|
||||
hecl::SystemString subPath;
|
||||
hecl::ProjectRootPath projPath = hecl::SearchForProject(path, subPath);
|
||||
if (!projPath)
|
||||
{
|
||||
Log.report(logvisor::Warning, _S("project doesn't exist at '%s'"), path.c_str());
|
||||
Log.report(logvisor::Warning, _S("project doesn't exist at '%s'"), path.data());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ makeProj:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProjectManager::extractGame(const hecl::SystemString& path)
|
||||
bool ProjectManager::extractGame(hecl::SystemStringView path)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -204,9 +204,9 @@ bool ProjectManager::saveProject()
|
||||
|
||||
hecl::ProjectPath newSpacesPath(*m_proj, _S(".hecl/urde_spaces.yaml"));
|
||||
|
||||
hecl::Unlink(newSpacesPath.getAbsolutePath().c_str());
|
||||
hecl::Rename(oldSpacesPath.getAbsolutePath().c_str(),
|
||||
newSpacesPath.getAbsolutePath().c_str());
|
||||
hecl::Unlink(newSpacesPath.getAbsolutePath().data());
|
||||
hecl::Rename(oldSpacesPath.getAbsolutePath().data(),
|
||||
newSpacesPath.getAbsolutePath().data());
|
||||
|
||||
m_vm.pushRecentProject(m_proj->getProjectRootPath().getAbsolutePath());
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ class ProjectResourcePool : public CSimplePool
|
||||
public:
|
||||
ProjectResourcePool(IFactory& factory, ProjectManager& parent)
|
||||
: CSimplePool(factory), m_parent(parent) {}
|
||||
CToken GetObj(const char*);
|
||||
CToken GetObj(const char*, const CVParamTransfer&);
|
||||
CToken GetObj(std::string_view);
|
||||
CToken GetObj(std::string_view, const CVParamTransfer&);
|
||||
};
|
||||
|
||||
class ProjectManager
|
||||
@@ -45,12 +45,12 @@ public:
|
||||
ProjectResourcePool& objectStore() {return m_objStore;}
|
||||
ProjectResourceFactoryMP1& resourceFactoryMP1() {return m_factoryMP1;}
|
||||
MP1::CMain* gameMain() {return m_mainMP1 ? &*m_mainMP1 : nullptr;}
|
||||
SObjectTag TagFromPath(const hecl::SystemChar* path) const
|
||||
SObjectTag TagFromPath(hecl::SystemStringView path) const
|
||||
{ return m_factoryMP1.ProjectResourceFactoryBase::TagFromPath(path); }
|
||||
|
||||
bool newProject(const hecl::SystemString& path);
|
||||
bool openProject(const hecl::SystemString& path);
|
||||
bool extractGame(const hecl::SystemString& path);
|
||||
bool newProject(hecl::SystemStringView path);
|
||||
bool openProject(hecl::SystemStringView path);
|
||||
bool extractGame(hecl::SystemStringView path);
|
||||
bool saveProject();
|
||||
|
||||
void mainUpdate();
|
||||
|
||||
@@ -20,7 +20,7 @@ void ProjectResourceFactoryBase::BeginBackgroundIndex
|
||||
|
||||
bool ProjectResourceFactoryBase::SyncCook(const hecl::ProjectPath& working)
|
||||
{
|
||||
Log.report(logvisor::Warning, _S("sync-cooking %s"), working.getRelativePath().c_str());
|
||||
Log.report(logvisor::Warning, _S("sync-cooking %s"), working.getRelativePath().data());
|
||||
return m_clientProc.syncCook(working, m_cookSpec.get(), hecl::SharedBlenderToken);
|
||||
}
|
||||
|
||||
@@ -42,13 +42,13 @@ CFactoryFnReturn ProjectResourceFactoryBase::BuildSync(const SObjectTag& tag,
|
||||
CFactoryFnReturn ret =
|
||||
m_factoryMgr.MakeObjectFromMemory(tag, std::move(memBuf), length, false, paramXfer, selfRef);
|
||||
Log.report(logvisor::Info, "sync-built %.4s %08X",
|
||||
tag.type.toString().c_str(), u32(tag.id.Value()));
|
||||
tag.type.getChars(), u32(tag.id.Value()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
CFactoryFnReturn ret = m_factoryMgr.MakeObject(tag, *fr, paramXfer, selfRef);
|
||||
Log.report(logvisor::Info, "sync-built %.4s %08X",
|
||||
tag.type.toString().c_str(), u32(tag.id.Value()));
|
||||
tag.type.getChars(), u32(tag.id.Value()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ void ProjectResourceFactoryBase::AsyncTask::EnsurePath(const urde::SObjectTag& t
|
||||
if (!path.isFileOrGlob())
|
||||
{
|
||||
Log.report(logvisor::Error, _S("unable to find resource path '%s'"),
|
||||
path.getRelativePath().c_str());
|
||||
path.getRelativePath().data());
|
||||
m_failed = true;
|
||||
return;
|
||||
}
|
||||
@@ -80,8 +80,8 @@ void ProjectResourceFactoryBase::AsyncTask::EnsurePath(const urde::SObjectTag& t
|
||||
if (verifyTag.type != tag.type)
|
||||
{
|
||||
Log.report(logvisor::Error, _S("%s: expected type '%.4s', found '%.4s'"),
|
||||
path.getRelativePath().c_str(),
|
||||
tag.type.toString().c_str(), verifyTag.type.toString().c_str());
|
||||
path.getRelativePath().data(),
|
||||
tag.type.getChars(), verifyTag.type.getChars());
|
||||
m_failed = true;
|
||||
return;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ void ProjectResourceFactoryBase::AsyncTask::CookComplete()
|
||||
if (fr.hasError())
|
||||
{
|
||||
Log.report(logvisor::Error, _S("unable to open cooked resource path '%s'"),
|
||||
m_cookedPath.getAbsolutePath().c_str());
|
||||
m_cookedPath.getAbsolutePath().data());
|
||||
m_failed = true;
|
||||
return;
|
||||
}
|
||||
@@ -214,7 +214,7 @@ ProjectResourceFactoryBase::PrepForReadSync(const SObjectTag& tag,
|
||||
if (!path.isFileOrGlob())
|
||||
{
|
||||
Log.report(logvisor::Error, _S("unable to find resource path '%s'"),
|
||||
path.getAbsolutePath().c_str());
|
||||
path.getAbsolutePath().data());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -230,8 +230,8 @@ ProjectResourceFactoryBase::PrepForReadSync(const SObjectTag& tag,
|
||||
if (verifyTag.type != tag.type)
|
||||
{
|
||||
Log.report(logvisor::Error, _S("%s: expected type '%.4s', found '%.4s'"),
|
||||
path.getRelativePath().c_str(),
|
||||
tag.type.toString().c_str(), verifyTag.type.toString().c_str());
|
||||
path.getRelativePath().data(),
|
||||
tag.type.getChars(), verifyTag.type.getChars());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ ProjectResourceFactoryBase::PrepForReadSync(const SObjectTag& tag,
|
||||
if (!SyncCook(path))
|
||||
{
|
||||
Log.report(logvisor::Error, _S("unable to cook resource path '%s'"),
|
||||
path.getAbsolutePath().c_str());
|
||||
path.getAbsolutePath().data());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -257,7 +257,7 @@ ProjectResourceFactoryBase::PrepForReadSync(const SObjectTag& tag,
|
||||
if (fr->hasError())
|
||||
{
|
||||
Log.report(logvisor::Error, _S("unable to open cooked resource path '%s'"),
|
||||
cooked.getAbsolutePath().c_str());
|
||||
cooked.getAbsolutePath().data());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ std::unique_ptr<urde::IObj> ProjectResourceFactoryBase::Build(const urde::SObjec
|
||||
CObjectReference* selfRef)
|
||||
{
|
||||
if (!tag.id.IsValid())
|
||||
Log.report(logvisor::Fatal, "attempted to access null id on type '%s'", tag.type.toString().c_str());
|
||||
Log.report(logvisor::Fatal, "attempted to access null id on type '%.4s'", tag.type.getChars());
|
||||
|
||||
const hecl::ProjectPath* resPath = nullptr;
|
||||
if (!WaitForTagReady(tag, resPath))
|
||||
@@ -301,7 +301,7 @@ std::unique_ptr<urde::IObj> ProjectResourceFactoryBase::Build(const urde::SObjec
|
||||
|
||||
//*task.xc_targetObjPtr = newObj.get();
|
||||
Log.report(logvisor::Warning, "spin-built %.4s %08X",
|
||||
task.x0_tag.type.toString().c_str(), u32(task.x0_tag.id.Value()));
|
||||
task.x0_tag.type.getChars(), u32(task.x0_tag.id.Value()));
|
||||
|
||||
_RemoveTask(asyncSearch);
|
||||
return newObj;
|
||||
@@ -309,12 +309,12 @@ std::unique_ptr<urde::IObj> ProjectResourceFactoryBase::Build(const urde::SObjec
|
||||
else if (task.m_complete)
|
||||
{
|
||||
Log.report(logvisor::Error, "unable to spin-build %.4s %08X; Resource requested as cook-only",
|
||||
task.x0_tag.type.toString().c_str(), u32(task.x0_tag.id.Value()));
|
||||
task.x0_tag.type.getChars(), u32(task.x0_tag.id.Value()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.report(logvisor::Error, "unable to spin-build %.4s %08X",
|
||||
task.x0_tag.type.toString().c_str(), u32(task.x0_tag.id.Value()));
|
||||
task.x0_tag.type.getChars(), u32(task.x0_tag.id.Value()));
|
||||
}
|
||||
|
||||
_RemoveTask(asyncSearch);
|
||||
@@ -342,7 +342,7 @@ void ProjectResourceFactoryBase::BuildAsync(const urde::SObjectTag& tag,
|
||||
CObjectReference* selfRef)
|
||||
{
|
||||
if (!tag.id.IsValid())
|
||||
Log.report(logvisor::Fatal, "attempted to access null id on type '%s'", tag.type.toString().c_str());
|
||||
Log.report(logvisor::Fatal, "attempted to access null id on type '%.4s'", tag.type.getChars());
|
||||
|
||||
BuildAsyncInternal(tag, paramXfer, objOut, selfRef);
|
||||
}
|
||||
@@ -350,7 +350,7 @@ void ProjectResourceFactoryBase::BuildAsync(const urde::SObjectTag& tag,
|
||||
u32 ProjectResourceFactoryBase::ResourceSize(const SObjectTag& tag)
|
||||
{
|
||||
if (!tag.id.IsValid())
|
||||
Log.report(logvisor::Fatal, "attempted to access null id on type '%s'", tag.type.toString().c_str());
|
||||
Log.report(logvisor::Fatal, "attempted to access null id on type '%.4s'", tag.type.getChars());
|
||||
|
||||
/* Ensure resource at requested path is indexed and not cooking */
|
||||
const hecl::ProjectPath* resPath = nullptr;
|
||||
@@ -455,7 +455,7 @@ bool ProjectResourceFactoryBase::CanBuild(const urde::SObjectTag& tag)
|
||||
return false;
|
||||
}
|
||||
|
||||
const urde::SObjectTag* ProjectResourceFactoryBase::GetResourceIdByName(const char* name) const
|
||||
const urde::SObjectTag* ProjectResourceFactoryBase::GetResourceIdByName(std::string_view name) const
|
||||
{
|
||||
return static_cast<DataSpec::SpecBase&>(*m_cookSpec).getResourceIdByName(name);
|
||||
}
|
||||
@@ -471,7 +471,7 @@ void ProjectResourceFactoryBase::EnumerateResources(const std::function<bool(con
|
||||
}
|
||||
|
||||
void ProjectResourceFactoryBase::EnumerateNamedResources(
|
||||
const std::function<bool(const std::string&, const SObjectTag&)>& lambda) const
|
||||
const std::function<bool(std::string_view, const SObjectTag&)>& lambda) const
|
||||
{
|
||||
return static_cast<DataSpec::SpecBase&>(*m_cookSpec).enumerateNamedResources(lambda);
|
||||
}
|
||||
@@ -486,8 +486,8 @@ bool ProjectResourceFactoryBase::AsyncPumpTask(ItType& it)
|
||||
{
|
||||
if (!static_cast<DataSpec::SpecBase&>(*m_cookSpec).backgroundIndexRunning())
|
||||
{
|
||||
Log.report(logvisor::Error, _S("unable to find async load resource (%s, %08X)"),
|
||||
task.x0_tag.type.toString().c_str(), task.x0_tag.id);
|
||||
Log.report(logvisor::Error, _S("unable to find async load resource (%.4s, %08X)"),
|
||||
task.x0_tag.type.getChars(), task.x0_tag.id);
|
||||
it = _RemoveTask(it);
|
||||
}
|
||||
return true;
|
||||
@@ -518,7 +518,7 @@ bool ProjectResourceFactoryBase::AsyncPumpTask(ItType& it)
|
||||
|
||||
*task.xc_targetObjPtr = std::move(newObj);
|
||||
Log.report(logvisor::Info, "async-built %.4s %08X",
|
||||
task.x0_tag.type.toString().c_str(),
|
||||
task.x0_tag.type.getChars(),
|
||||
u32(task.x0_tag.id.Value()));
|
||||
}
|
||||
else if (task.xc_targetDataPtr)
|
||||
@@ -526,14 +526,14 @@ bool ProjectResourceFactoryBase::AsyncPumpTask(ItType& it)
|
||||
/* Buffer only */
|
||||
*task.xc_targetDataPtr = std::move(task.x10_loadBuffer);
|
||||
Log.report(logvisor::Info, "async-loaded %.4s %08X",
|
||||
task.x0_tag.type.toString().c_str(),
|
||||
task.x0_tag.type.getChars(),
|
||||
u32(task.x0_tag.id.Value()));
|
||||
}
|
||||
else if (task.xc_targetDataRawPtr)
|
||||
{
|
||||
/* Buffer only raw */
|
||||
Log.report(logvisor::Info, "async-loaded %.4s %08X",
|
||||
task.x0_tag.type.toString().c_str(),
|
||||
task.x0_tag.type.getChars(),
|
||||
u32(task.x0_tag.id.Value()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
void BuildAsync(const urde::SObjectTag&, const urde::CVParamTransfer&, std::unique_ptr<urde::IObj>*, CObjectReference* selfRef);
|
||||
void CancelBuild(const urde::SObjectTag&);
|
||||
bool CanBuild(const urde::SObjectTag&);
|
||||
const urde::SObjectTag* GetResourceIdByName(const char*) const;
|
||||
const urde::SObjectTag* GetResourceIdByName(std::string_view) const;
|
||||
FourCC GetResourceTypeById(CAssetId id) const;
|
||||
hecl::ProjectPath GetCookedPath(const hecl::ProjectPath& working, bool pcTarget) const
|
||||
{
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
}
|
||||
|
||||
void EnumerateResources(const std::function<bool(const SObjectTag&)>& lambda) const;
|
||||
void EnumerateNamedResources(const std::function<bool(const std::string&, const SObjectTag&)>& lambda) const;
|
||||
void EnumerateNamedResources(const std::function<bool(std::string_view, const SObjectTag&)>& lambda) const;
|
||||
|
||||
u32 ResourceSize(const SObjectTag& tag);
|
||||
std::shared_ptr<urde::IDvdRequest> LoadResourceAsync(const urde::SObjectTag& tag, void* target);
|
||||
@@ -174,7 +174,7 @@ public:
|
||||
void Shutdown() { CancelBackgroundIndex(); }
|
||||
bool IsBusy() const { return m_asyncLoadMap.size() != 0; }
|
||||
|
||||
SObjectTag TagFromPath(const hecl::SystemChar* path) const
|
||||
SObjectTag TagFromPath(hecl::SystemStringView path) const
|
||||
{
|
||||
return TagFromPath(hecl::ProjectPath(*(hecl::Database::Project*)m_proj, path),
|
||||
hecl::SharedBlenderToken);
|
||||
|
||||
@@ -55,34 +55,34 @@ class ResourceBrowser : public Space, public specter::IPathButtonsBinding
|
||||
size_t columnCount() const {return 3;}
|
||||
size_t rowCount() const {return m_entries.size();}
|
||||
|
||||
const std::string* header(size_t cIdx) const
|
||||
std::string_view header(size_t cIdx) const
|
||||
{
|
||||
switch (cIdx)
|
||||
{
|
||||
case 0:
|
||||
return &m_nameCol;
|
||||
return m_nameCol;
|
||||
case 1:
|
||||
return &m_typeCol;
|
||||
return m_typeCol;
|
||||
case 2:
|
||||
return &m_sizeCol;
|
||||
return m_sizeCol;
|
||||
default: break;
|
||||
}
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
|
||||
const std::string* cell(size_t cIdx, size_t rIdx) const
|
||||
std::string_view cell(size_t cIdx, size_t rIdx) const
|
||||
{
|
||||
switch (cIdx)
|
||||
{
|
||||
case 0:
|
||||
return &m_entries.at(rIdx).m_name;
|
||||
return m_entries.at(rIdx).m_name;
|
||||
case 1:
|
||||
return &m_entries.at(rIdx).m_type;
|
||||
return m_entries.at(rIdx).m_type;
|
||||
case 2:
|
||||
return &m_entries.at(rIdx).m_size;
|
||||
return m_entries.at(rIdx).m_size;
|
||||
default: break;
|
||||
}
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
|
||||
bool columnSplitResizeAllowed() const {return true;}
|
||||
@@ -107,7 +107,7 @@ class ResourceBrowser : public Space, public specter::IPathButtonsBinding
|
||||
m_entries.emplace_back();
|
||||
Entry& ent = m_entries.back();
|
||||
ent.m_path = d.m_path;
|
||||
hecl::SystemUTF8View nameUtf8(d.m_name);
|
||||
hecl::SystemUTF8Conv nameUtf8(d.m_name);
|
||||
ent.m_name = nameUtf8.str();
|
||||
if (d.m_isDir)
|
||||
{
|
||||
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
struct SpaceSelectBind : specter::IButtonBinding
|
||||
{
|
||||
Space& m_space;
|
||||
const char* name(const specter::Control* control) const {return SpaceMenuNode::s_text.c_str();}
|
||||
std::string_view name(const specter::Control* control) const {return SpaceMenuNode::s_text;}
|
||||
|
||||
MenuStyle menuStyle(const specter::Button* button) const {return MenuStyle::Primary;}
|
||||
std::unique_ptr<specter::View> buildMenu(const specter::Button* button);
|
||||
@@ -384,7 +384,7 @@ class TestSpace : public Space
|
||||
specter::IButtonBinding* m_binding;
|
||||
|
||||
public:
|
||||
TestSpace(ViewManager& vm, Space* parent, const std::string& content, const std::string& button,
|
||||
TestSpace(ViewManager& vm, Space* parent, std::string_view content, std::string_view button,
|
||||
specter::IButtonBinding* binding)
|
||||
: Space(vm, Class::TestSpace, parent), m_contentStr(content), m_buttonStr(button), m_binding(binding)
|
||||
{}
|
||||
|
||||
@@ -41,9 +41,9 @@ SplashScreen::SplashScreen(ViewManager& vm, specter::ViewResources& res)
|
||||
GIT_BRANCH[0] != '\0')
|
||||
{
|
||||
m_buildInfoStr = hecl::Format("%s: %s\n%s: %s\n%s: %s",
|
||||
vm.translateOr("branch", "Branch").c_str(), GIT_BRANCH,
|
||||
vm.translateOr("commit", "Commit").c_str(), GIT_COMMIT_HASH,
|
||||
vm.translateOr("date", "Date").c_str(), GIT_COMMIT_DATE);
|
||||
vm.translateOr("branch", "Branch").data(), GIT_BRANCH,
|
||||
vm.translateOr("commit", "Commit").data(), GIT_COMMIT_HASH,
|
||||
vm.translateOr("date", "Date").data(), GIT_COMMIT_DATE);
|
||||
}
|
||||
|
||||
m_openProjBind.m_openRecentMenuRoot.m_text = vm.translateOr("recent_projects", "Recent Projects");
|
||||
|
||||
@@ -41,15 +41,15 @@ class SplashScreen : public specter::ModalWindow
|
||||
SplashScreen& m_splash;
|
||||
hecl::SystemString m_deferPath;
|
||||
NewProjBinding(SplashScreen& splash) : m_splash(splash) {}
|
||||
const char* name(const specter::Control* control) const {return m_splash.m_newString.c_str();}
|
||||
const char* help(const specter::Control* control) const {return "Creates an empty project at selected path";}
|
||||
std::string_view name(const specter::Control* control) const {return m_splash.m_newString.c_str();}
|
||||
std::string_view help(const specter::Control* control) const {return "Creates an empty project at selected path";}
|
||||
void activated(const specter::Button* button, const boo::SWindowCoord& coord)
|
||||
{
|
||||
m_splash.m_fileBrowser.m_view.reset(
|
||||
new specter::FileBrowser(m_splash.rootView().viewRes(),
|
||||
m_splash, m_splash.m_newString,
|
||||
specter::FileBrowser::Type::NewHECLProject,
|
||||
[&](bool ok, const hecl::SystemString& path)
|
||||
[&](bool ok, hecl::SystemStringView path)
|
||||
{
|
||||
if (ok)
|
||||
m_deferPath = path;
|
||||
@@ -64,15 +64,15 @@ class SplashScreen : public specter::ModalWindow
|
||||
SplashScreen& m_splash;
|
||||
hecl::SystemString m_deferPath;
|
||||
OpenProjBinding(SplashScreen& splash) : m_splash(splash), m_openRecentMenuRoot(*this) {}
|
||||
const char* name(const specter::Control* control) const {return m_splash.m_openString.c_str();}
|
||||
const char* help(const specter::Control* control) const {return "Opens an existing project at selected path";}
|
||||
std::string_view name(const specter::Control* control) const {return m_splash.m_openString.c_str();}
|
||||
std::string_view help(const specter::Control* control) const {return "Opens an existing project at selected path";}
|
||||
void activated(const specter::Button* button, const boo::SWindowCoord& coord)
|
||||
{
|
||||
m_splash.m_fileBrowser.m_view.reset(
|
||||
new specter::FileBrowser(m_splash.rootView().viewRes(),
|
||||
m_splash, m_splash.m_openString,
|
||||
specter::FileBrowser::Type::OpenHECLProject,
|
||||
[&](bool ok, const hecl::SystemString& path)
|
||||
[&](bool ok, hecl::SystemStringView path)
|
||||
{
|
||||
if (ok)
|
||||
m_deferPath = path;
|
||||
@@ -108,7 +108,7 @@ class SplashScreen : public specter::ModalWindow
|
||||
{
|
||||
std::vector<hecl::SystemString> pathComps = specter::FileBrowser::PathComponents(path);
|
||||
if (pathComps.size())
|
||||
m_text = hecl::SystemUTF8View(pathComps.back()).str();
|
||||
m_text = hecl::SystemUTF8Conv(pathComps.back()).str();
|
||||
}
|
||||
};
|
||||
std::vector<OpenRecentMenuItem> m_items;
|
||||
@@ -142,15 +142,15 @@ class SplashScreen : public specter::ModalWindow
|
||||
SplashScreen& m_splash;
|
||||
hecl::SystemString m_deferPath;
|
||||
ExtractProjBinding(SplashScreen& splash) : m_splash(splash) {}
|
||||
const char* name(const specter::Control* control) const {return m_splash.m_extractString.c_str();}
|
||||
const char* help(const specter::Control* control) const {return "Extracts game image as project at selected path";}
|
||||
std::string_view name(const specter::Control* control) const {return m_splash.m_extractString.c_str();}
|
||||
std::string_view help(const specter::Control* control) const {return "Extracts game image as project at selected path";}
|
||||
void activated(const specter::Button* button, const boo::SWindowCoord& coord)
|
||||
{
|
||||
m_splash.m_fileBrowser.m_view.reset(
|
||||
new specter::FileBrowser(m_splash.rootView().viewRes(),
|
||||
m_splash, m_splash.m_extractString,
|
||||
specter::FileBrowser::Type::OpenFile,
|
||||
[&](bool ok, const hecl::SystemString& path)
|
||||
[&](bool ok, hecl::SystemStringView path)
|
||||
{
|
||||
if (ok)
|
||||
m_deferPath = path;
|
||||
|
||||
@@ -121,8 +121,8 @@ void ViewManager::DismissSplash()
|
||||
ViewManager::ViewManager(hecl::Runtime::FileStoreManager& fileMgr, hecl::CVarManager& cvarMgr)
|
||||
: m_fileStoreManager(fileMgr), m_cvarManager(cvarMgr), m_projManager(*this),
|
||||
m_fontCache(fileMgr), m_translator(urde::SystemLocaleOrEnglish()),
|
||||
m_recentProjectsPath(hecl::SysFormat(_S("%s/recent_projects.txt"), fileMgr.getStoreRoot().c_str())),
|
||||
m_recentFilesPath(hecl::SysFormat(_S("%s/recent_files.txt"), fileMgr.getStoreRoot().c_str()))
|
||||
m_recentProjectsPath(hecl::SysFormat(_S("%s/recent_projects.txt"), fileMgr.getStoreRoot().data())),
|
||||
m_recentFilesPath(hecl::SysFormat(_S("%s/recent_files.txt"), fileMgr.getStoreRoot().data()))
|
||||
{
|
||||
Space::SpaceMenuNode::InitializeStrings(*this);
|
||||
char path[2048];
|
||||
@@ -135,9 +135,9 @@ ViewManager::ViewManager(hecl::Runtime::FileStoreManager& fileMgr, hecl::CVarMan
|
||||
{
|
||||
std::string pathStr(path);
|
||||
pathStr.pop_back();
|
||||
hecl::SystemStringView pathStrView(pathStr);
|
||||
hecl::SystemStringConv pathStrView(pathStr);
|
||||
if (!hecl::Stat(pathStrView.c_str(), &theStat) && S_ISDIR(theStat.st_mode))
|
||||
m_recentProjects.push_back(pathStrView);
|
||||
m_recentProjects.emplace_back(pathStrView.sys_str());
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
@@ -149,9 +149,9 @@ ViewManager::ViewManager(hecl::Runtime::FileStoreManager& fileMgr, hecl::CVarMan
|
||||
{
|
||||
std::string pathStr(path);
|
||||
pathStr.pop_back();
|
||||
hecl::SystemStringView pathStrView(pathStr);
|
||||
hecl::SystemStringConv pathStrView(pathStr);
|
||||
if (!hecl::Stat(pathStrView.c_str(), &theStat) && S_ISDIR(theStat.st_mode))
|
||||
m_recentFiles.push_back(pathStrView);
|
||||
m_recentFiles.emplace_back(pathStrView.sys_str());
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
@@ -159,36 +159,36 @@ ViewManager::ViewManager(hecl::Runtime::FileStoreManager& fileMgr, hecl::CVarMan
|
||||
|
||||
ViewManager::~ViewManager() {}
|
||||
|
||||
void ViewManager::pushRecentProject(const hecl::SystemString& path)
|
||||
void ViewManager::pushRecentProject(hecl::SystemStringView path)
|
||||
{
|
||||
for (hecl::SystemString& testPath : m_recentProjects)
|
||||
{
|
||||
if (path == testPath)
|
||||
return;
|
||||
}
|
||||
m_recentProjects.push_back(path);
|
||||
m_recentProjects.emplace_back(path);
|
||||
FILE* fp = hecl::Fopen(m_recentProjectsPath.c_str(), _S("w"), hecl::FileLockType::Write);
|
||||
if (fp)
|
||||
{
|
||||
for (hecl::SystemString& pPath : m_recentProjects)
|
||||
fprintf(fp, "%s\n", hecl::SystemUTF8View(pPath).c_str());
|
||||
fprintf(fp, "%s\n", hecl::SystemUTF8Conv(pPath).c_str());
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewManager::pushRecentFile(const hecl::SystemString& path)
|
||||
void ViewManager::pushRecentFile(hecl::SystemStringView path)
|
||||
{
|
||||
for (hecl::SystemString& testPath : m_recentFiles)
|
||||
{
|
||||
if (path == testPath)
|
||||
return;
|
||||
}
|
||||
m_recentFiles.push_back(path);
|
||||
m_recentFiles.emplace_back(path);
|
||||
FILE* fp = hecl::Fopen(m_recentFilesPath.c_str(), _S("w"), hecl::FileLockType::Write);
|
||||
if (fp)
|
||||
{
|
||||
for (hecl::SystemString& pPath : m_recentFiles)
|
||||
fprintf(fp, "%s\n", hecl::SystemUTF8View(pPath).c_str());
|
||||
fprintf(fp, "%s\n", hecl::SystemUTF8Conv(pPath).c_str());
|
||||
fclose(fp);
|
||||
}}
|
||||
|
||||
|
||||
@@ -175,10 +175,10 @@ public:
|
||||
}
|
||||
|
||||
const std::vector<hecl::SystemString>* recentProjects() const {return &m_recentProjects;}
|
||||
void pushRecentProject(const hecl::SystemString& path);
|
||||
void pushRecentProject(hecl::SystemStringView path);
|
||||
|
||||
const std::vector<hecl::SystemString>* recentFiles() const {return &m_recentFiles;}
|
||||
void pushRecentFile(const hecl::SystemString& path);
|
||||
void pushRecentFile(hecl::SystemStringView path);
|
||||
|
||||
void init(boo::IApplication* app);
|
||||
const boo::SystemChar* platformName() { return m_mainPlatformName; }
|
||||
|
||||
@@ -18,27 +18,29 @@ extern "C" size_t L_ja_JP_SZ;
|
||||
namespace urde
|
||||
{
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
static const specter::Locale Locales[] =
|
||||
{
|
||||
{"en_US", "US English", L_en_US, L_en_US_SZ},
|
||||
{"en_GB", "British English", L_en_GB, L_en_GB_SZ},
|
||||
{"ja_JP", "Japanese", L_ja_JP, L_ja_JP_SZ}
|
||||
{"en_US"sv, "US English"sv, L_en_US, L_en_US_SZ},
|
||||
{"en_GB"sv, "British English"sv, L_en_GB, L_en_GB_SZ},
|
||||
{"ja_JP"sv, "Japanese"sv, L_ja_JP, L_ja_JP_SZ}
|
||||
};
|
||||
|
||||
std::vector<std::pair<const std::string*, const std::string*>> ListLocales()
|
||||
std::vector<std::pair<std::string_view, std::string_view>> ListLocales()
|
||||
{
|
||||
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
|
||||
std::vector<std::pair<const std::string*, const std::string*>> ret;
|
||||
std::vector<std::pair<std::string_view, std::string_view>> ret;
|
||||
ret.reserve(localeCount);
|
||||
for (size_t i=0 ; i<localeCount ; ++i)
|
||||
{
|
||||
const specter::Locale& l = Locales[i];
|
||||
ret.emplace_back(&l.name(), &l.fullName());
|
||||
ret.emplace_back(l.name(), l.fullName());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const specter::Locale* LookupLocale(const std::string& name)
|
||||
const specter::Locale* LookupLocale(std::string_view name)
|
||||
{
|
||||
constexpr size_t localeCount = std::extent<decltype(Locales)>::value;
|
||||
for (size_t i=0 ; i<localeCount ; ++i)
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
namespace urde
|
||||
{
|
||||
|
||||
std::vector<std::pair<const std::string*, const std::string*>> ListLocales();
|
||||
const specter::Locale* LookupLocale(const std::string& name);
|
||||
std::vector<std::pair<std::string_view, std::string_view>> ListLocales();
|
||||
const specter::Locale* LookupLocale(std::string_view name);
|
||||
const specter::Locale* SystemLocaleOrEnglish();
|
||||
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ struct Application : boo::IApplicationCallback
|
||||
{
|
||||
if (arg.find(_S("--verbosity=")) == 0 || arg.find(_S("-v=")) == 0)
|
||||
{
|
||||
hecl::SystemUTF8View utf8Arg(arg.substr(arg.find_last_of('=') + 1));
|
||||
hecl::SystemUTF8Conv utf8Arg(arg.substr(arg.find_last_of('=') + 1));
|
||||
hecl::VerbosityLevel = atoi(utf8Arg.c_str());
|
||||
hecl::LogModule.report(logvisor::Info, "Set verbosity level to %i", hecl::VerbosityLevel);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user