2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 13:44:56 +00:00

Massive fmtlib refactor

This commit is contained in:
Jack Andersen
2019-07-19 18:27:21 -10:00
parent e38a3ece89
commit 7a3da1f7a6
228 changed files with 2071 additions and 2116 deletions

View File

@@ -97,7 +97,6 @@ target_compile_definitions(urde PUBLIC URDE_DLPACKAGE="${URDE_DLPACKAGE}")
target_include_directories(urde PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR})
target_link_libraries(urde
UrdeLocales
UrdeIcons
UrdeBadging
RuntimeCommon

View File

@@ -48,7 +48,7 @@ ProjectManager::ProjectManager(ViewManager& vm)
bool ProjectManager::newProject(hecl::SystemStringView path) {
hecl::ProjectRootPath projPath = hecl::SearchForProject(path);
if (projPath) {
Log.report(logvisor::Warning, _SYS_STR("project already exists at '%s'"), path.data());
Log.report(logvisor::Warning, fmt(_SYS_STR("project already exists at '{}'")), path);
return false;
}
@@ -63,9 +63,8 @@ bool ProjectManager::newProject(hecl::SystemStringView path) {
m_vm.SetupEditorView();
saveProject();
hecl::SystemString windowTitle(m_proj->getProjectRootPath().getLastComponent());
windowTitle += _SYS_STR(" - URDE [") + hecl::SystemString(m_vm.platformName()) + _SYS_STR("]");
m_vm.m_mainWindow->setTitle(windowTitle.c_str());
m_vm.m_mainWindow->setTitle(fmt::format(fmt(_SYS_STR("{} - URDE [{}]")),
m_proj->getProjectRootPath().getLastComponent(), m_vm.platformName()));
m_vm.DismissSplash();
m_vm.FadeInEditors();
@@ -76,7 +75,7 @@ bool ProjectManager::openProject(hecl::SystemStringView path) {
hecl::SystemString subPath;
hecl::ProjectRootPath projPath = hecl::SearchForProject(path, subPath);
if (!projPath) {
Log.report(logvisor::Warning, _SYS_STR("project doesn't exist at '%s'"), path.data());
Log.report(logvisor::Warning, fmt(_SYS_STR("project doesn't exist at '{}'")), path);
return false;
}
@@ -126,11 +125,8 @@ makeProj:
if (needsSave)
saveProject();
{
hecl::SystemString windowTitle(m_proj->getProjectRootPath().getLastComponent());
windowTitle += _SYS_STR(" - URDE [") + hecl::SystemString(m_vm.platformName()) + _SYS_STR("]");
m_vm.m_mainWindow->setTitle(windowTitle.c_str());
}
m_vm.m_mainWindow->setTitle(fmt::format(fmt(_SYS_STR("{} - URDE [{}]")),
m_proj->getProjectRootPath().getLastComponent(), m_vm.platformName()));
m_vm.DismissSplash();
m_vm.FadeInEditors();
m_vm.pushRecentProject(m_proj->getProjectRootPath().getAbsolutePath());

View File

@@ -19,7 +19,7 @@ void ProjectResourceFactoryBase::BeginBackgroundIndex(hecl::Database::Project& p
}
bool ProjectResourceFactoryBase::SyncCook(const hecl::ProjectPath& working) {
Log.report(logvisor::Warning, _SYS_STR("sync-cooking %s"), working.getRelativePath().data());
Log.report(logvisor::Warning, fmt(_SYS_STR("sync-cooking {}")), working.getRelativePath());
return m_clientProc.syncCook(working, m_cookSpec.get(), hecl::blender::SharedBlenderToken, false, false);
}
@@ -35,12 +35,12 @@ CFactoryFnReturn ProjectResourceFactoryBase::BuildSync(const SObjectTag& tag, co
u32 length = fr->length();
std::unique_ptr<u8[]> memBuf = fr->readUBytes(length);
CFactoryFnReturn ret = m_factoryMgr.MakeObjectFromMemory(tag, std::move(memBuf), length, false, paramXfer, selfRef);
Log.report(logvisor::Info, "sync-built %.4s %08X", tag.type.getChars(), u32(tag.id.Value()));
Log.report(logvisor::Info, fmt("sync-built {}"), tag);
return ret;
}
CFactoryFnReturn ret = m_factoryMgr.MakeObject(tag, *fr, paramXfer, selfRef);
Log.report(logvisor::Info, "sync-built %.4s %08X", tag.type.getChars(), u32(tag.id.Value()));
Log.report(logvisor::Info, fmt("sync-built {}"), tag);
return ret;
}
@@ -50,7 +50,7 @@ void ProjectResourceFactoryBase::AsyncTask::EnsurePath(const urde::SObjectTag& t
/* Ensure requested resource is on the filesystem */
if (!path.isFileOrGlob()) {
Log.report(logvisor::Error, _SYS_STR("unable to find resource path '%s'"), path.getRelativePath().data());
Log.report(logvisor::Error, fmt(_SYS_STR("unable to find resource path '{}'")), path.getRelativePath());
m_failed = true;
return;
}
@@ -63,8 +63,8 @@ void ProjectResourceFactoryBase::AsyncTask::EnsurePath(const urde::SObjectTag& t
/* Last chance type validation */
urde::SObjectTag verifyTag = m_parent.TagFromPath(path);
if (verifyTag.type != tag.type) {
Log.report(logvisor::Error, _SYS_STR("%s: expected type '%.4s', found '%.4s'"), path.getRelativePath().data(),
tag.type.getChars(), verifyTag.type.getChars());
Log.report(logvisor::Error, fmt(_SYS_STR("{}: expected type '{}', found '{}'")), path.getRelativePath(),
tag.type, verifyTag.type);
m_failed = true;
return;
}
@@ -88,8 +88,7 @@ void ProjectResourceFactoryBase::AsyncTask::CookComplete() {
/* Ensure cooked rep is on the filesystem */
athena::io::FileReader fr(m_cookedPath.getAbsolutePath(), 32 * 1024, false);
if (fr.hasError()) {
Log.report(logvisor::Error, _SYS_STR("unable to open cooked resource path '%s'"),
m_cookedPath.getAbsolutePath().data());
Log.report(logvisor::Error, fmt(_SYS_STR("unable to open cooked resource path '{}'")), m_cookedPath.getAbsolutePath());
m_failed = true;
return;
}
@@ -169,7 +168,7 @@ bool ProjectResourceFactoryBase::PrepForReadSync(const SObjectTag& tag, const he
std::optional<athena::io::FileReader>& fr) {
/* Ensure requested resource is on the filesystem */
if (!path.isFileOrGlob()) {
Log.report(logvisor::Error, _SYS_STR("unable to find resource path '%s'"), path.getAbsolutePath().data());
Log.report(logvisor::Error, fmt(_SYS_STR("unable to find resource path '{}'")), path.getAbsolutePath());
return false;
}
@@ -181,8 +180,8 @@ bool ProjectResourceFactoryBase::PrepForReadSync(const SObjectTag& tag, const he
/* Last chance type validation */
urde::SObjectTag verifyTag = TagFromPath(path);
if (verifyTag.type != tag.type) {
Log.report(logvisor::Error, _SYS_STR("%s: expected type '%.4s', found '%.4s'"), path.getRelativePath().data(),
tag.type.getChars(), verifyTag.type.getChars());
Log.report(logvisor::Error, fmt(_SYS_STR("{}: expected type '{}', found '{}'")), path.getRelativePath(),
tag.type, verifyTag.type);
return false;
}
@@ -193,7 +192,7 @@ bool ProjectResourceFactoryBase::PrepForReadSync(const SObjectTag& tag, const he
if (!cooked.isFile() || cooked.getModtime() < path.getModtime()) {
/* Do a blocking cook here */
if (!SyncCook(path)) {
Log.report(logvisor::Error, _SYS_STR("unable to cook resource path '%s'"), path.getAbsolutePath().data());
Log.report(logvisor::Error, fmt(_SYS_STR("unable to cook resource path '{}'")), path.getAbsolutePath());
return false;
}
}
@@ -202,7 +201,7 @@ bool ProjectResourceFactoryBase::PrepForReadSync(const SObjectTag& tag, const he
/* Ensure cooked rep is on the filesystem */
fr.emplace(cooked.getAbsolutePath(), 32 * 1024, false);
if (fr->hasError()) {
Log.report(logvisor::Error, _SYS_STR("unable to open cooked resource path '%s'"), cooked.getAbsolutePath().data());
Log.report(logvisor::Error, fmt(_SYS_STR("unable to open cooked resource path '{}'")), cooked.getAbsolutePath());
return false;
}
@@ -213,7 +212,7 @@ std::unique_ptr<urde::IObj> ProjectResourceFactoryBase::Build(const urde::SObjec
const urde::CVParamTransfer& paramXfer,
CObjectReference* selfRef) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id on type '%.4s'", tag.type.getChars());
Log.report(logvisor::Fatal, fmt("attempted to access null id on type '{}'"), tag.type);
const hecl::ProjectPath* resPath = nullptr;
if (!WaitForTagReady(tag, resPath))
@@ -241,16 +240,14 @@ 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.getChars(), u32(task.x0_tag.id.Value()));
Log.report(logvisor::Warning, fmt("spin-built {}"), task.x0_tag);
_RemoveTask(asyncSearch);
return newObj;
} else if (task.m_complete) {
Log.report(logvisor::Error, "unable to spin-build %.4s %08X; Resource requested as cook-only",
task.x0_tag.type.getChars(), u32(task.x0_tag.id.Value()));
Log.report(logvisor::Error, fmt("unable to spin-build {}; Resource requested as cook-only"), task.x0_tag);
} else {
Log.report(logvisor::Error, "unable to spin-build %.4s %08X", task.x0_tag.type.getChars(),
u32(task.x0_tag.id.Value()));
Log.report(logvisor::Error, fmt("unable to spin-build {}"), task.x0_tag);
}
_RemoveTask(asyncSearch);
@@ -273,14 +270,14 @@ std::shared_ptr<AsyncTask> ProjectResourceFactoryBase::BuildAsyncInternal(const
void ProjectResourceFactoryBase::BuildAsync(const urde::SObjectTag& tag, const urde::CVParamTransfer& paramXfer,
std::unique_ptr<urde::IObj>* objOut, CObjectReference* selfRef) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id on type '%.4s'", tag.type.getChars());
Log.report(logvisor::Fatal, fmt("attempted to access null id on type '{}'"), tag.type);
BuildAsyncInternal(tag, paramXfer, objOut, selfRef);
}
u32 ProjectResourceFactoryBase::ResourceSize(const SObjectTag& tag) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id on type '%.4s'", tag.type.getChars());
Log.report(logvisor::Fatal, fmt("attempted to access null id on type '{}'"), tag.type);
/* Ensure resource at requested path is indexed and not cooking */
const hecl::ProjectPath* resPath = nullptr;
@@ -298,7 +295,7 @@ u32 ProjectResourceFactoryBase::ResourceSize(const SObjectTag& tag) {
std::shared_ptr<urde::IDvdRequest> ProjectResourceFactoryBase::LoadResourceAsync(const urde::SObjectTag& tag,
void* target) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id");
Log.report(logvisor::Fatal, fmt("attempted to access null id"));
if (m_asyncLoadMap.find(tag) != m_asyncLoadMap.end())
return {};
return std::static_pointer_cast<urde::IDvdRequest>(
@@ -308,7 +305,7 @@ std::shared_ptr<urde::IDvdRequest> ProjectResourceFactoryBase::LoadResourceAsync
std::shared_ptr<urde::IDvdRequest> ProjectResourceFactoryBase::LoadResourcePartAsync(const urde::SObjectTag& tag,
u32 off, u32 size, void* target) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id");
Log.report(logvisor::Fatal, fmt("attempted to access null id"));
if (m_asyncLoadMap.find(tag) != m_asyncLoadMap.end())
return {};
return std::static_pointer_cast<urde::IDvdRequest>(
@@ -317,7 +314,7 @@ std::shared_ptr<urde::IDvdRequest> ProjectResourceFactoryBase::LoadResourcePartA
std::unique_ptr<u8[]> ProjectResourceFactoryBase::LoadResourceSync(const urde::SObjectTag& tag) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id");
Log.report(logvisor::Fatal, fmt("attempted to access null id"));
/* Ensure resource at requested path is indexed and not cooking */
const hecl::ProjectPath* resPath = nullptr;
@@ -335,7 +332,7 @@ std::unique_ptr<u8[]> ProjectResourceFactoryBase::LoadResourceSync(const urde::S
std::unique_ptr<u8[]> ProjectResourceFactoryBase::LoadNewResourcePartSync(const urde::SObjectTag& tag, u32 off,
u32 size) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id");
Log.report(logvisor::Fatal, fmt("attempted to access null id"));
/* Ensure resource at requested path is indexed and not cooking */
const hecl::ProjectPath* resPath = nullptr;
@@ -354,7 +351,7 @@ std::unique_ptr<u8[]> ProjectResourceFactoryBase::LoadNewResourcePartSync(const
std::shared_ptr<AsyncTask> ProjectResourceFactoryBase::CookResourceAsync(const urde::SObjectTag& tag) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id");
Log.report(logvisor::Fatal, fmt("attempted to access null id"));
if (m_asyncLoadMap.find(tag) != m_asyncLoadMap.end())
return {};
return _AddTask(std::make_shared<AsyncTask>(*this, tag));
@@ -364,7 +361,7 @@ void ProjectResourceFactoryBase::CancelBuild(const urde::SObjectTag& tag) { _Rem
bool ProjectResourceFactoryBase::CanBuild(const urde::SObjectTag& tag) {
if (!tag.id.IsValid())
Log.report(logvisor::Fatal, "attempted to access null id");
Log.report(logvisor::Fatal, fmt("attempted to access null id"));
const hecl::ProjectPath* resPath = nullptr;
if (!WaitForTagReady(tag, resPath))
@@ -400,8 +397,7 @@ bool ProjectResourceFactoryBase::AsyncPumpTask(ItType& it) {
hecl::ProjectPath path = static_cast<DataSpec::SpecBase&>(*m_cookSpec).pathFromTag(task.x0_tag);
if (!path) {
if (!static_cast<DataSpec::SpecBase&>(*m_cookSpec).backgroundIndexRunning()) {
Log.report(logvisor::Error, _SYS_STR("unable to find async load resource (%.4s, %08X)"),
task.x0_tag.type.getChars(), task.x0_tag.id);
Log.report(logvisor::Error, fmt(_SYS_STR("unable to find async load resource ({})")), task.x0_tag);
it = _RemoveTask(it);
}
return true;
@@ -424,14 +420,14 @@ bool ProjectResourceFactoryBase::AsyncPumpTask(ItType& it) {
}
*task.xc_targetObjPtr = std::move(newObj);
Log.report(logvisor::Info, "async-built %.4s %08X", task.x0_tag.type.getChars(), u32(task.x0_tag.id.Value()));
Log.report(logvisor::Info, fmt("async-built {}"), task.x0_tag);
} else if (task.xc_targetDataPtr) {
/* Buffer only */
*task.xc_targetDataPtr = std::move(task.x10_loadBuffer);
Log.report(logvisor::Info, "async-loaded %.4s %08X", task.x0_tag.type.getChars(), u32(task.x0_tag.id.Value()));
Log.report(logvisor::Info, fmt("async-loaded {}"), task.x0_tag);
} else if (task.xc_targetDataRawPtr) {
/* Buffer only raw */
Log.report(logvisor::Info, "async-loaded %.4s %08X", task.x0_tag.type.getChars(), u32(task.x0_tag.id.Value()));
Log.report(logvisor::Info, fmt("async-loaded {}"), task.x0_tag);
}
}

View File

@@ -125,12 +125,12 @@ class ResourceBrowser : public Space, public specter::IPathButtonsBinding {
void rowActivated(size_t rIdx) {}
ResListingDataBind(ResourceBrowser& rb, const specter::IViewManager& vm) : m_rb(rb) {
m_nameCol = vm.translateOr("name", "Name");
m_typeCol = vm.translateOr("type", "Type");
m_sizeCol = vm.translateOr("size", "Size");
m_dirStr = vm.translateOr("directory", "Directory");
m_projStr = vm.translateOr("hecl_project", "HECL Project");
m_fileStr = vm.translateOr("file", "File");
m_nameCol = vm.translate<locale::name>();
m_typeCol = vm.translate<locale::type>();
m_sizeCol = vm.translate<locale::size>();
m_dirStr = vm.translate<locale::directory>();
m_projStr = vm.translate<locale::hecl_project>();
m_fileStr = vm.translate<locale::file>();
}
} m_resListingBind;

View File

@@ -39,28 +39,39 @@ specter::View* Space::buildSpaceView(specter::ViewResources& res) {
std::vector<Space::SpaceMenuNode::SubNodeData> Space::SpaceMenuNode::s_subNodeDats = {
{Class::ResourceBrowser,
"resource_browser",
"Resource Browser",
GetIcon(SpaceIcon::ResourceBrowser),
{0.0f, 1.0f, 0.0f, 1.0f}},
{Class::EffectEditor,
"effect_editor",
"Effect Editor",
GetIcon(SpaceIcon::ParticleEditor),
{1.0f, 0.5f, 0.0f, 1.0f}},
{Class::ModelViewer, "model_viewer", "Model Viewer", GetIcon(SpaceIcon::ModelViewer), {0.95f, 0.95f, 0.95f, 1.0f}},
{Class::ModelViewer, "Model Viewer", GetIcon(SpaceIcon::ModelViewer), {0.95f, 0.95f, 0.95f, 1.0f}},
{Class::InformationCenter,
"information_center",
"Information Center",
GetIcon(SpaceIcon::InformationCenter),
{0.0f, 1.0f, 1.0f, 1.0f}},
{Class::GameMode, "game_mode", "Game Mode", GetIcon(SpaceIcon::GameMode), {}}};
{Class::GameMode, "Game Mode", GetIcon(SpaceIcon::GameMode), {}}};
std::string Space::SpaceMenuNode::s_text = "Space Types";
template <typename Key>
static void RecurseTranslations(ViewManager& vm, std::vector<Space::SpaceMenuNode::SubNodeData>::iterator it) {
it->m_text = vm.translate<Key>();
}
template <typename Key, typename Key2, typename... RemKeys>
static void RecurseTranslations(ViewManager& vm, std::vector<Space::SpaceMenuNode::SubNodeData>::iterator it) {
RecurseTranslations<Key>(vm, it);
RecurseTranslations<Key2, RemKeys...>(vm, ++it);
}
void Space::SpaceMenuNode::InitializeStrings(ViewManager& vm) {
s_text = vm.translateOr("space_types", s_text.c_str());
for (SubNodeData& sn : s_subNodeDats)
sn.m_text = vm.translateOr(sn.m_key, sn.m_text.c_str());
s_text = vm.translate<locale::space_types>();
RecurseTranslations<locale::resource_browser,
locale::effect_editor,
locale::model_viewer,
locale::information_center,
locale::game_mode>(vm, s_subNodeDats.begin());
}
std::unique_ptr<specter::View> Space::SpaceSelectBind::buildMenu(const specter::Button* button) {
@@ -89,7 +100,7 @@ specter::View* SplitSpace::buildContentView(specter::ViewResources& res) {
void SplitSpace::setChildSlot(unsigned slot, std::unique_ptr<Space>&& space) {
if (slot > 1)
Log.report(logvisor::Fatal, "invalid slot %u for SplitView", slot);
Log.report(logvisor::Fatal, fmt("invalid slot {} for SplitView"), slot);
m_slots[slot] = std::move(space);
m_slots[slot]->m_parent = this;
}
@@ -151,7 +162,7 @@ std::unique_ptr<Space> RootSpace::exchangeSpaceSplitJoin(Space* removeSpace, std
m_spaceTree.swap(ret);
m_spaceTree->m_parent = this;
} else
Log.report(logvisor::Fatal, "RootSpace::exchangeSpaceSplitJoin() failure");
Log.report(logvisor::Fatal, fmt("RootSpace::exchangeSpaceSplitJoin() failure"));
return ret;
}
@@ -166,7 +177,7 @@ std::unique_ptr<Space> SplitSpace::exchangeSpaceSplitJoin(Space* removeSpace, st
m_slots[1].swap(ret);
m_slots[1]->m_parent = this;
} else
Log.report(logvisor::Fatal, "SplitSpace::exchangeSpaceSplitJoin() failure");
Log.report(logvisor::Fatal, fmt("SplitSpace::exchangeSpaceSplitJoin() failure"));
return ret;
}

View File

@@ -51,15 +51,14 @@ public:
struct SpaceMenuNode final : specter::IMenuNode {
struct SubNodeData final : specter::IMenuNode {
Class m_cls;
std::string m_key;
std::string m_text;
specter::Icon& m_icon;
zeus::CColor m_color;
const std::string* text() const { return &m_text; }
void activated(const boo::SWindowCoord& coord) {}
SubNodeData(Class cls, const char* key, const char* text, specter::Icon& icon, const zeus::CColor& color)
: m_cls(cls), m_key(key), m_text(text), m_icon(icon), m_color(color) {}
SubNodeData(Class cls, const char* text, specter::Icon& icon, const zeus::CColor& color)
: m_cls(cls), m_text(text), m_icon(icon), m_color(color) {}
};
static std::vector<SubNodeData> s_subNodeDats;

View File

@@ -27,26 +27,26 @@ SplashScreen::SplashScreen(ViewManager& vm, specter::ViewResources& res)
, m_vm(vm)
, m_textColor(res.themeData().uiText())
, m_textColorClear(m_textColor)
, m_newString(m_vm.translateOr("new_project", "New Project"))
, m_openString(m_vm.translateOr("open_project", "Open Project"))
, m_extractString(m_vm.translateOr("extract_game", "Extract Game"))
, m_newString(m_vm.translate<locale::new_project>())
, m_openString(m_vm.translate<locale::open_project>())
, m_extractString(m_vm.translate<locale::extract_game>())
, m_newProjBind(*this)
, m_openProjBind(*this)
, m_extractProjBind(*this) {
if (GIT_COMMIT_DATE[0] != '\0' && GIT_COMMIT_HASH[0] != '\0' && GIT_BRANCH[0] != '\0') {
#ifdef URDE_DLPACKAGE
if ((URDE_DLPACKAGE)[0])
m_buildInfoStr = hecl::Format("%s: %s\n%s: %s\n%s: %s", vm.translateOr("release", "Release").data(),
URDE_DLPACKAGE, vm.translateOr("commit", "Commit").data(), GIT_COMMIT_HASH,
vm.translateOr("date", "Date").data(), GIT_COMMIT_DATE);
m_buildInfoStr = fmt::format(fmt("{}: {}\n{}: {}\n{}: {}"), vm.translate<locale::release>(),
URDE_DLPACKAGE, vm.translate<locale::commit>(), GIT_COMMIT_HASH,
vm.translate<locale::date>(), GIT_COMMIT_DATE);
else
#endif
m_buildInfoStr = hecl::Format("%s: %s\n%s: %s\n%s: %s", vm.translateOr("branch", "Branch").data(), GIT_BRANCH,
vm.translateOr("commit", "Commit").data(), GIT_COMMIT_HASH,
vm.translateOr("date", "Date").data(), GIT_COMMIT_DATE);
m_buildInfoStr = fmt::format(fmt("{}: {}\n{}: {}\n{}: {}"), vm.translate<locale::branch>(), GIT_BRANCH,
vm.translate<locale::commit>(), GIT_COMMIT_HASH,
vm.translate<locale::date>(), GIT_COMMIT_DATE);
}
m_openProjBind.m_openRecentMenuRoot.m_text = vm.translateOr("recent_projects", "Recent Projects");
m_openProjBind.m_openRecentMenuRoot.m_text = vm.translate<locale::recent_projects>();
m_textColorClear[3] = 0.0;
}
@@ -65,15 +65,15 @@ void SplashScreen::think() {
m_openButt.m_view->think();
if (m_newProjBind.m_deferPath.size()) {
Log.report(logvisor::Info, _SYS_STR("Making project '%s'"), m_newProjBind.m_deferPath.c_str());
Log.report(logvisor::Info, fmt(_SYS_STR("Making project '{}'")), m_newProjBind.m_deferPath);
m_vm.projectManager().newProject(m_newProjBind.m_deferPath);
m_newProjBind.m_deferPath.clear();
} else if (m_openProjBind.m_deferPath.size()) {
Log.report(logvisor::Info, _SYS_STR("Opening project '%s'"), m_openProjBind.m_deferPath.c_str());
Log.report(logvisor::Info, fmt(_SYS_STR("Opening project '{}'")), m_openProjBind.m_deferPath);
m_vm.projectManager().openProject(m_openProjBind.m_deferPath);
m_openProjBind.m_deferPath.clear();
} else if (m_extractProjBind.m_deferPath.size()) {
Log.report(logvisor::Info, _SYS_STR("Extracting game '%s'"), m_extractProjBind.m_deferPath.c_str());
Log.report(logvisor::Info, fmt(_SYS_STR("Extracting game '{}'")), m_extractProjBind.m_deferPath);
m_vm.projectManager().extractGame(m_extractProjBind.m_deferPath);
m_extractProjBind.m_deferPath.clear();
}

View File

@@ -72,20 +72,20 @@ void ViewManager::TestGameView::think() {
const hecl::CVar* worldInfo = hecl::CVarManager::instance()->findCVar("debugOverlay.worldInfo");
const hecl::CVar* areaInfo = hecl::CVarManager::instance()->findCVar("debugOverlay.areaInfo");
if (showFrameIdx && showFrameIdx->toBoolean())
overlayText += hecl::Format("Frame: %d\n", g_StateManager->GetUpdateFrameIndex());
overlayText += fmt::format(fmt("Frame: {}\n"), g_StateManager->GetUpdateFrameIndex());
if (g_StateManager->Player() && playerInfo && playerInfo->toBoolean()) {
const CPlayer& pl = g_StateManager->GetPlayer();
const zeus::CQuaternion plQ = zeus::CQuaternion(pl.GetTransform().getRotation().buildMatrix3f());
const zeus::CTransform camXf = g_StateManager->GetCameraManager()->GetCurrentCameraTransform(*g_StateManager);
const zeus::CQuaternion camQ = zeus::CQuaternion(camXf.getRotation().buildMatrix3f());
overlayText += hecl::Format(
"Player Position: x %f, y %f, z %f\n"
" Roll: %f, Pitch: %f, Yaw: %f\n"
" Momentum: x %f, y: %f, z: %f\n"
" Velocity: x %f, y: %f, z: %f\n"
"Camera Position: x %f, y %f, z %f\n"
" Roll: %f, Pitch: %f, Yaw: %f\n",
overlayText += fmt::format(fmt(
"Player Position: x {}, y {}, z {}\n"
" Roll: {}, Pitch: {}, Yaw: {}\n"
" Momentum: x {}, y: {}, z: {}\n"
" Velocity: x {}, y: {}, z: {}\n"
"Camera Position: x {}, y {}, z {}\n"
" Roll: {}, Pitch: {}, Yaw: {}\n"),
pl.GetTranslation().x(), pl.GetTranslation().y(), pl.GetTranslation().z(),
zeus::radToDeg(plQ.roll()), zeus::radToDeg(plQ.pitch()), zeus::radToDeg(plQ.yaw()),
pl.GetMomentum().x(), pl.GetMomentum().y(), pl.GetMomentum().z(),
@@ -97,8 +97,8 @@ void ViewManager::TestGameView::think() {
TLockedToken<CStringTable> tbl =
g_SimplePool->GetObj({FOURCC('STRG'), g_StateManager->GetWorld()->IGetStringTableAssetId()});
const urde::TAreaId aId = g_GameState->CurrentWorldState().GetCurrentAreaId();
overlayText += hecl::Format("World: 0x%08X%s, Area: %i\n", u32(g_GameState->CurrentWorldAssetId().Value()),
(tbl.IsLoaded() ? (" " + hecl::Char16ToUTF8(tbl->GetString(0))).c_str() : ""), aId);
overlayText += fmt::format(fmt("World: 0x{}{}, Area: {}\n"), g_GameState->CurrentWorldAssetId(),
(tbl.IsLoaded() ? (" " + hecl::Char16ToUTF8(tbl->GetString(0))).c_str() : ""), aId);
}
const urde::TAreaId aId = g_GameState->CurrentWorldState().GetCurrentAreaId();
@@ -114,11 +114,11 @@ void ViewManager::TestGameView::think() {
} else
layerBits += "0";
}
overlayText += hecl::Format(
"Area AssetId: 0x%08X, Total Objects: %i\n"
"Active Layer bits: %s\n",
(unsigned int)g_StateManager->WorldNC()->GetArea(aId)->GetAreaAssetId().Value(),
g_StateManager->GetAllObjectList().size(), layerBits.c_str());
overlayText += fmt::format(fmt(
"Area AssetId: 0x{}, Total Objects: {}\n"
"Active Layer bits: {}\n"),
g_StateManager->WorldNC()->GetArea(aId)->GetAreaAssetId(),
g_StateManager->GetAllObjectList().size(), layerBits);
}
if (!overlayText.empty())
@@ -191,9 +191,9 @@ ViewManager::ViewManager(hecl::Runtime::FileStoreManager& fileMgr, hecl::CVarMan
, m_cvarManager(cvarMgr)
, m_projManager(*this)
, m_fontCache(fileMgr)
, m_translator(urde::SystemLocaleOrEnglish())
, m_recentProjectsPath(hecl::SysFormat(_SYS_STR("%s/recent_projects.txt"), fileMgr.getStoreRoot().data()))
, m_recentFilesPath(hecl::SysFormat(_SYS_STR("%s/recent_files.txt"), fileMgr.getStoreRoot().data())) {
, m_locale(locale::SystemLocaleOrEnglish())
, m_recentProjectsPath(fmt::format(fmt(_SYS_STR("{}/recent_projects.txt")), fileMgr.getStoreRoot()))
, m_recentFilesPath(fmt::format(fmt(_SYS_STR("{}/recent_files.txt")), fileMgr.getStoreRoot())) {
Space::SpaceMenuNode::InitializeStrings(*this);
char path[2048];
hecl::Sstat theStat;
@@ -234,7 +234,7 @@ void ViewManager::pushRecentProject(hecl::SystemStringView path) {
FILE* fp = hecl::Fopen(m_recentProjectsPath.c_str(), _SYS_STR("w"), hecl::FileLockType::Write);
if (fp) {
for (hecl::SystemString& pPath : m_recentProjects)
fprintf(fp, "%s\n", hecl::SystemUTF8Conv(pPath).c_str());
fmt::print(fp, fmt("{}\n"), hecl::SystemUTF8Conv(pPath));
fclose(fp);
}
}
@@ -248,7 +248,7 @@ void ViewManager::pushRecentFile(hecl::SystemStringView path) {
FILE* fp = hecl::Fopen(m_recentFilesPath.c_str(), _SYS_STR("w"), hecl::FileLockType::Write);
if (fp) {
for (hecl::SystemString& pPath : m_recentFiles)
fprintf(fp, "%s\n", hecl::SystemUTF8Conv(pPath).c_str());
fmt::print(fp, fmt("{}\n"), hecl::SystemUTF8Conv(pPath));
fclose(fp);
}
}
@@ -264,7 +264,7 @@ void ViewManager::init(boo::IApplication* app) {
m_pipelineConv = hecl::NewPipelineConverter(m_mainBooFactory);
hecl::conv = m_pipelineConv.get();
m_mainPlatformName = m_mainBooFactory->platformName();
m_mainWindow->setTitle(_SYS_STR("URDE [") + hecl::SystemString(m_mainPlatformName) + _SYS_STR("]"));
m_mainWindow->setTitle(fmt::format(fmt(_SYS_STR("URDE [{}]")), m_mainPlatformName));
m_mainCommandQueue = m_mainWindow->getCommandQueue();
m_viewResources.init(m_mainBooFactory, &m_fontCache, &m_themeData, pixelFactor);
InitializeIcons(m_viewResources);

View File

@@ -41,7 +41,7 @@ class ViewManager final : public specter::IViewManager {
specter::FontCache m_fontCache;
specter::DefaultThemeData m_themeData;
specter::ViewResources m_viewResources;
specter::Translator m_translator;
locale::ELocale m_locale = locale::ELocale::en_US;
boo::IGraphicsDataFactory* m_mainBooFactory = nullptr;
boo::IGraphicsCommandQueue* m_mainCommandQueue = nullptr;
std::unique_ptr<hecl::PipelineConverterBase> m_pipelineConv;
@@ -166,7 +166,7 @@ public:
ProjectManager& projectManager() { return m_projManager; }
hecl::Database::Project* project() { return m_projManager.project(); }
const specter::Translator* getTranslator() const { return &m_translator; }
locale::ELocale getTranslatorLocale() const { return m_locale; }
void deferSpaceSplit(specter::ISpaceController* split, specter::SplitView::Axis axis, int thisSlot,
const boo::SWindowCoord& coord) {

View File

@@ -14,7 +14,7 @@ void InitializeBadging(specter::ViewResources& viewRes) {
size_t fmt = r.readUint32Big();
if (fmt != 16)
Log.report(logvisor::Fatal, "incorrect icon texture format");
Log.report(logvisor::Fatal, fmt("incorrect icon texture format"));
size_t width = r.readUint16Big();
size_t height = r.readUint16Big();
size_t mips = r.readUint32Big();
@@ -24,7 +24,7 @@ void InitializeBadging(specter::ViewResources& viewRes) {
uLongf destSz = decompSz;
size_t pos = r.position();
if (uncompress(texels.get(), &destSz, URDE_BADGE + pos, URDE_BADGE_SZ - pos) != Z_OK)
Log.report(logvisor::Fatal, "unable to decompress badge");
Log.report(logvisor::Fatal, fmt("unable to decompress badge"));
viewRes.m_factory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) {
specter::IconAtlas<1, 1> atlas;

View File

@@ -14,7 +14,7 @@ void InitializeIcons(specter::ViewResources& viewRes) {
athena::io::MemoryReader r(URDE_ICONS, URDE_ICONS_SZ);
size_t fmt = r.readUint32Big();
if (fmt != 16)
Log.report(logvisor::Fatal, "incorrect icon texture format");
Log.report(logvisor::Fatal, fmt("incorrect icon texture format"));
size_t width = r.readUint16Big();
size_t height = r.readUint16Big();
size_t mips = r.readUint32Big();
@@ -24,7 +24,7 @@ void InitializeIcons(specter::ViewResources& viewRes) {
uLongf destSz = decompSz;
size_t pos = r.position();
if (uncompress(texels.get(), &destSz, URDE_ICONS + pos, URDE_ICONS_SZ - pos) != Z_OK)
Log.report(logvisor::Fatal, "unable to decompress icons");
Log.report(logvisor::Fatal, fmt("unable to decompress icons"));
viewRes.m_factory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) {
g_IconAtlas.initializeAtlas(ctx.newStaticTexture(width, height, mips, boo::TextureFormat::RGBA8,

View File

@@ -9,11 +9,9 @@
#include "hecl/Console.hpp"
static logvisor::Module AthenaLog("Athena");
static void AthenaExc(athena::error::Level level, const char* file, const char*, int line, const char* fmt, ...) {
va_list ap;
va_start(ap, fmt);
AthenaLog.report(logvisor::Level(level), fmt, ap);
va_end(ap);
static void AthenaExc(athena::error::Level level, const char* file, const char*, int line,
fmt::string_view fmt, fmt::format_args args) {
AthenaLog.vreport(logvisor::Level(level), fmt, args);
}
namespace urde {
@@ -93,16 +91,16 @@ struct Application : boo::IApplicationCallback {
if (arg.find(_SYS_STR("--verbosity=")) == 0 || arg.find(_SYS_STR("-v=")) == 0) {
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);
hecl::LogModule.report(logvisor::Info, fmt("Set verbosity level to {}"), hecl::VerbosityLevel);
}
}
m_cvarManager.parseCommandLine(app->getArgs());
const zeus::CPUInfo& cpuInf = zeus::cpuFeatures();
Log.report(logvisor::Info, "CPU Name: %s", cpuInf.cpuBrand);
Log.report(logvisor::Info, "CPU Vendor: %s", cpuInf.cpuVendor);
Log.report(logvisor::Info, _SYS_STR("CPU Features: %s"), CPUFeatureString(cpuInf).c_str());
Log.report(logvisor::Info, fmt("CPU Name: {}"), cpuInf.cpuBrand);
Log.report(logvisor::Info, fmt("CPU Vendor: {}"), cpuInf.cpuVendor);
Log.report(logvisor::Info, fmt(_SYS_STR("CPU Features: {}")), CPUFeatureString(cpuInf));
}
std::string getGraphicsApi() const { return m_cvarCommons.getGraphicsApi(); }
@@ -139,14 +137,12 @@ static void SetupBasics(bool logging) {
auto result = zeus::validateCPU();
if (!result.first) {
#if _WIN32 && !WINDOWS_STORE
char* msg;
asprintf(&msg, "ERROR: This build of URDE requires the following CPU features:\n%s\n",
urde::CPUFeatureString(result.second).c_str());
MessageBoxA(nullptr, msg, "CPU error", MB_OK | MB_ICONERROR);
free(msg);
std::string msg = fmt::format(fmt("ERROR: This build of URDE requires the following CPU features:\n{}\n"),
urde::CPUFeatureString(result.second));
MessageBoxA(nullptr, msg.c_str(), "CPU error", MB_OK | MB_ICONERROR);
#else
fprintf(stderr, "ERROR: This build of URDE requires the following CPU features:\n%s\n",
urde::CPUFeatureString(result.second).c_str());
fmt::print(stderr, fmt("ERROR: This build of URDE requires the following CPU features:\n{}\n"),
urde::CPUFeatureString(result.second));
#endif
exit(1);
}
@@ -172,7 +168,7 @@ int main(int argc, const boo::SystemChar** argv)
#endif
{
if (argc > 1 && !hecl::StrCmp(argv[1], _SYS_STR("--dlpackage"))) {
printf("%s\n", URDE_DLPACKAGE);
fmt::print(fmt("{}\n"), URDE_DLPACKAGE);
return 100;
}