add GEODE_HIDDEN to _spr

This commit is contained in:
altalk23 2023-09-12 21:07:53 +03:00
parent 93482eb7c2
commit 9a28e58639
3 changed files with 10 additions and 4 deletions

View file

@ -398,6 +398,6 @@ namespace geode {
}; };
} }
inline char const* operator"" _spr(char const* str, size_t) { GEODE_HIDDEN inline char const* operator"" _spr(char const* str, size_t) {
return geode::Mod::get()->expandSpriteName(str); return geode::Mod::get()->expandSpriteName(str);
} }

View file

@ -572,14 +572,13 @@ ghc::filesystem::path Mod::Impl::getConfigDir(bool create) const {
} }
char const* Mod::Impl::expandSpriteName(char const* name) { char const* Mod::Impl::expandSpriteName(char const* name) {
static std::unordered_map<std::string, char const*> expanded = {}; if (m_expandedSprites.count(name)) return m_expandedSprites[name];
if (expanded.count(name)) return expanded[name];
auto exp = new char[strlen(name) + 2 + m_metadata.getID().size()]; auto exp = new char[strlen(name) + 2 + m_metadata.getID().size()];
auto exps = m_metadata.getID() + "/" + name; auto exps = m_metadata.getID() + "/" + name;
memcpy(exp, exps.c_str(), exps.size() + 1); memcpy(exp, exps.c_str(), exps.size() + 1);
expanded[name] = exp; m_expandedSprites[name] = exp;
return exp; return exp;
} }

View file

@ -57,6 +57,13 @@ namespace geode {
* Whether the mod resources are loaded or not * Whether the mod resources are loaded or not
*/ */
bool m_resourcesLoaded = false; bool m_resourcesLoaded = false;
/**
* Whether logging is enabled for this mod
*/
bool m_loggingEnabled = true;
std::unordered_map<std::string, char const*> m_expandedSprites;
ModRequestedAction m_requestedAction = ModRequestedAction::None; ModRequestedAction m_requestedAction = ModRequestedAction::None;