diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fbbfcfcb..ae699463 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,6 +17,7 @@ set( set( YAZE_UTIL_SRC util/bps.cc + util/flag.cc util/hex.cc ) @@ -133,8 +134,7 @@ if (YAZE_BUILD_LIB) FILES incl/yaze.h incl/zelda.h - incl/snes_tile.h - incl/snes_color.h + incl/snes.h incl/overworld.h incl/dungeon.h DESTINATION diff --git a/src/app/editor/editor.h b/src/app/editor/editor.h index 442681e8..b487dd41 100644 --- a/src/app/editor/editor.h +++ b/src/app/editor/editor.h @@ -8,7 +8,6 @@ #include "app/editor/system/constant_manager.h" #include "app/editor/system/extension_manager.h" #include "app/editor/system/history_manager.h" -#include "app/editor/system/resource_manager.h" namespace yaze { @@ -23,7 +22,6 @@ struct EditorContext { CommandManager command_manager; ExtensionManager extension_manager; HistoryManager history_manager; - ResourceManager resource_manager; }; enum class EditorType { diff --git a/src/app/editor/system/resource_manager.h b/src/app/editor/system/resource_manager.h deleted file mode 100644 index 69ea03ba..00000000 --- a/src/app/editor/system/resource_manager.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef YAZE_APP_EDITOR_SYSTEM_RESOURCE_MANAGER_H -#define YAZE_APP_EDITOR_SYSTEM_RESOURCE_MANAGER_H - -#include - -namespace yaze { -namespace editor { - -// System resource manager. -class ResourceManager { - public: - ResourceManager() : count_(0) {} - ~ResourceManager() = default; - - void Load(const char* path); - void Unload(const char* path); - void UnloadAll(); - - size_t Count() const; - - private: - size_t count_; -}; - -} // namespace editor -} // namespace yaze - -#endif // YAZE_APP_EDITOR_SYSTEM_RESOURCE_MANAGER_H diff --git a/src/util/flag.cc b/src/util/flag.cc new file mode 100644 index 00000000..d34e9f95 --- /dev/null +++ b/src/util/flag.cc @@ -0,0 +1,50 @@ +#include "flag.h" + +namespace yaze { +namespace util { + +void FlagParser::Parse(std::vector* tokens) { + std::vector leftover; + leftover.reserve(tokens->size()); + + for (size_t i = 0; i < tokens->size(); i++) { + const std::string& token = (*tokens)[i]; + if (token.rfind("--", 0) == 0) { + // Found a token that starts with "--". + std::string flag_name; + std::string value_string; + if (!ExtractFlagAndValue(token, &flag_name, &value_string)) { + // If no value found after '=', see if next token is a value. + if ((i + 1) < tokens->size()) { + const std::string& next_token = (*tokens)[i + 1]; + // If next token is NOT another flag, treat it as the value. + if (next_token.rfind("--", 0) != 0) { + value_string = next_token; + i++; + } else { + // If no explicit value, treat it as boolean 'true'. + value_string = "true"; + } + } else { + value_string = "true"; + } + flag_name = token; + } + + // Attempt to parse the flag (strip leading dashes in the registry). + IFlag* flag_ptr = registry_->GetFlag(flag_name); + if (!flag_ptr) { + throw std::runtime_error("Unrecognized flag: " + flag_name); + } + + // Set the parsed value on the matching flag. + flag_ptr->ParseValue(value_string); + } else { + leftover.push_back(token); + } + } + *tokens = leftover; +} + +} // namespace util +} // namespace yaze \ No newline at end of file diff --git a/src/util/flag.h b/src/util/flag.h index a3977fa3..b3ce41a0 100644 --- a/src/util/flag.h +++ b/src/util/flag.h @@ -129,48 +129,7 @@ class FlagParser { // Parses flags out of the given token list. Recognizes forms: // --flag=value or --flag value // Any token not recognized as a flag is left in `leftover`. - void Parse(std::vector* tokens) { - std::vector leftover; - leftover.reserve(tokens->size()); - - for (size_t i = 0; i < tokens->size(); i++) { - const std::string& token = (*tokens)[i]; - if (token.rfind("--", 0) == 0) { - // Found a token that starts with "--". - std::string flag_name; - std::string value_string; - if (!ExtractFlagAndValue(token, &flag_name, &value_string)) { - // If no value found after '=', see if next token is a value. - if ((i + 1) < tokens->size()) { - const std::string& next_token = (*tokens)[i + 1]; - // If next token is NOT another flag, treat it as the value. - if (next_token.rfind("--", 0) != 0) { - value_string = next_token; - i++; - } else { - // If no explicit value, treat it as boolean 'true'. - value_string = "true"; - } - } else { - value_string = "true"; - } - flag_name = token; - } - - // Attempt to parse the flag (strip leading dashes in the registry). - IFlag* flag_ptr = registry_->GetFlag(flag_name); - if (!flag_ptr) { - throw std::runtime_error("Unrecognized flag: " + flag_name); - } - - // Set the parsed value on the matching flag. - flag_ptr->ParseValue(value_string); - } else { - leftover.push_back(token); - } - } - *tokens = leftover; - } + void Parse(std::vector* tokens); private: FlagRegistry* registry_;