Implemented overlay command and api (#289)

* Added overlay command

* Moved Overlays to GameOverlay

* Added custom text size calculation

* Fixed string cvar load and added fipps font
This commit is contained in:
KiritoDev 2022-05-11 12:35:03 -05:00 committed by GitHub
commit fe3e534938
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 259 additions and 2 deletions

View file

@ -421,6 +421,14 @@ template <typename Numeric> bool is_number(const std::string& s) {
return ((std::istringstream(s) >> n >> std::ws).eof());
}
char* Strdup(const char* src) {
const unsigned len = strlen(src) + 1;
char* newstr = static_cast<char*>(malloc(len));
if (newstr)
memcpy(newstr, src, len);
return newstr;
}
void DebugConsole_LoadCVars()
{
if (File::Exists("cvars.cfg")) {
@ -431,7 +439,9 @@ void DebugConsole_LoadCVars()
if (line.empty()) continue;
if (cfg.size() < 2) continue;
if (cfg[1].find("\"") != std::string::npos) {
CVar_SetString(cfg[0].c_str(), const_cast<char*>(cfg[1].c_str()));
std::string value(cfg[1]);
value.erase(std::ranges::remove(value, '\"').begin(), value.end());
CVar_SetString(cfg[0].c_str(), Strdup(value.c_str()));
}
if (is_number<float>(cfg[1])) {
CVar_SetFloat(cfg[0].c_str(), std::stof(cfg[1]));