add logging for gd::string and fix version comparisons being inverted

This commit is contained in:
HJfod 2023-04-27 18:50:45 +03:00
parent 2dbad94e52
commit e7ab46cfdb
3 changed files with 10 additions and 4 deletions

View file

@ -33,7 +33,7 @@ namespace geode {
GEODE_DLL std::string parse(cocos2d::CCRect const&);
GEODE_DLL std::string parse(cocos2d::CCSize const&);
GEODE_DLL std::string parse(Mod*);
GEODE_DLL std::string parse(gd::string const&);
template <class T>
requires std::convertible_to<T*, cocos2d::CCNode*>

View file

@ -199,13 +199,15 @@ namespace geode {
return false;
}
// the comparison works invertedly as a version like "v1.2.0"
// should return true for "<=v1.3.0"
switch (m_compare) {
case VersionCompare::LessEq:
return m_version <= version;
return version <= m_version;
case VersionCompare::MoreEq:
return m_version >= version;
return version >= m_version;
default:
return m_version == version;
return version == m_version;
}
}

View file

@ -85,6 +85,10 @@ std::string log::parse(cocos2d::ccColor4B const& col) {
return fmt::format("rgba({}, {}, {}, {})", col.r, col.g, col.b, col.a);
}
std::string log::parse(gd::string const& str) {
return fmt::format("{}", std::string(str));
}
// Log
Log::Log(Mod* mod, Severity sev) : m_sender(mod), m_time(log_clock::now()), m_severity(sev) {}