From 4582a18f53b0f168da4507656a162b221316867e Mon Sep 17 00:00:00 2001 From: scawful Date: Fri, 19 Jul 2024 23:07:04 -0400 Subject: [PATCH] Move GfxContext to editor/utils, update CMakeLists.txt --- src/CMakeLists.txt | 2 +- src/app/editor/code/memory_editor.h | 2 +- src/app/editor/context/entrance_context.h | 42 ------------------- src/app/editor/graphics/tile16_editor.h | 2 +- src/app/editor/master_editor.h | 2 +- src/app/editor/overworld_editor.h | 27 ++++++++++-- .../editor/{context => utils}/gfx_context.cc | 2 +- .../editor/{context => utils}/gfx_context.h | 0 src/app/zelda3/overworld/overworld_map.cc | 2 +- src/app/zelda3/overworld/overworld_map.h | 2 +- test/CMakeLists.txt | 2 +- 11 files changed, 32 insertions(+), 53 deletions(-) delete mode 100644 src/app/editor/context/entrance_context.h rename src/app/editor/{context => utils}/gfx_context.cc (92%) rename src/app/editor/{context => utils}/gfx_context.h (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8e5bdb9b..d3954b73 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,7 +18,7 @@ set( app/editor/graphics/palette_editor.cc app/editor/graphics/tile16_editor.cc app/editor/graphics/gfx_group_editor.cc - app/editor/context/gfx_context.cc + app/editor/utils/gfx_context.cc ) set( diff --git a/src/app/editor/code/memory_editor.h b/src/app/editor/code/memory_editor.h index 48d388b3..194ff4a0 100644 --- a/src/app/editor/code/memory_editor.h +++ b/src/app/editor/code/memory_editor.h @@ -12,7 +12,7 @@ #include "app/core/project.h" #include "app/editor/code/assembly_editor.h" #include "app/editor/code/memory_editor.h" -#include "app/editor/context/gfx_context.h" +#include "app/editor/utils/gfx_context.h" #include "app/editor/dungeon_editor.h" #include "app/editor/graphics/graphics_editor.h" #include "app/editor/graphics/palette_editor.h" diff --git a/src/app/editor/context/entrance_context.h b/src/app/editor/context/entrance_context.h deleted file mode 100644 index 9a57ffe5..00000000 --- a/src/app/editor/context/entrance_context.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef YAZE_APP_EDITOR_CONTEXT_ENTRANCE_CONTEXT_H_ -#define YAZE_APP_EDITOR_CONTEXT_ENTRANCE_CONTEXT_H_ - -#include -#include - -#include "absl/status/status.h" -#include "app/rom.h" - -namespace yaze { -namespace app { -namespace editor { -namespace context { - -class EntranceContext { - public: - absl::Status LoadEntranceTileTypes(Rom& rom) { - int offset_low = 0xDB8BF; - int offset_high = 0xDB917; - - for (int i = 0; i < 0x2C; i++) { - // Load entrance tile types - ASSIGN_OR_RETURN(auto value_low, rom.ReadWord(offset_low + i)); - entrance_tile_types_low_.push_back(value_low); - ASSIGN_OR_RETURN(auto value_high, rom.ReadWord(offset_high + i)); - entrance_tile_types_low_.push_back(value_high); - } - - return absl::OkStatus(); - } - - private: - std::vector entrance_tile_types_low_; - std::vector entrance_tile_types_high_; -}; - -} // namespace context -} // namespace editor -} // namespace app -} // namespace yaze - -#endif // YAZE_APP_EDITOR_CONTEXT_ENTRANCE_CONTEXT_H_ \ No newline at end of file diff --git a/src/app/editor/graphics/tile16_editor.h b/src/app/editor/graphics/tile16_editor.h index bba51450..0eff06a6 100644 --- a/src/app/editor/graphics/tile16_editor.h +++ b/src/app/editor/graphics/tile16_editor.h @@ -7,7 +7,7 @@ #include "absl/status/status.h" #include "absl/status/statusor.h" -#include "app/editor/context/gfx_context.h" +#include "app/editor/utils/gfx_context.h" #include "app/editor/graphics/palette_editor.h" #include "app/editor/utils/editor.h" #include "app/gfx/bitmap.h" diff --git a/src/app/editor/master_editor.h b/src/app/editor/master_editor.h index ecc2ee4e..d24aad7d 100644 --- a/src/app/editor/master_editor.h +++ b/src/app/editor/master_editor.h @@ -15,7 +15,6 @@ #include "app/core/project.h" #include "app/editor/code/assembly_editor.h" #include "app/editor/code/memory_editor.h" -#include "app/editor/context/gfx_context.h" #include "app/editor/dungeon_editor.h" #include "app/editor/graphics/graphics_editor.h" #include "app/editor/graphics/palette_editor.h" @@ -23,6 +22,7 @@ #include "app/editor/music/music_editor.h" #include "app/editor/overworld_editor.h" #include "app/editor/sprite/sprite_editor.h" +#include "app/editor/utils/gfx_context.h" #include "app/emu/emulator.h" #include "app/gfx/snes_palette.h" #include "app/gfx/snes_tile.h" diff --git a/src/app/editor/overworld_editor.h b/src/app/editor/overworld_editor.h index 29f2db1f..226b10e9 100644 --- a/src/app/editor/overworld_editor.h +++ b/src/app/editor/overworld_editor.h @@ -12,8 +12,7 @@ #include "absl/status/statusor.h" #include "absl/strings/str_format.h" #include "app/core/common.h" -#include "app/editor/context/entrance_context.h" -#include "app/editor/context/gfx_context.h" +#include "app/editor/utils/gfx_context.h" #include "app/editor/graphics/gfx_group_editor.h" #include "app/editor/graphics/palette_editor.h" #include "app/editor/graphics/tile16_editor.h" @@ -63,6 +62,28 @@ constexpr absl::string_view kTileSelectorTab = "##TileSelectorTabBar"; constexpr absl::string_view kOWEditTable = "##OWEditTable"; constexpr absl::string_view kOWMapTable = "#MapSettingsTable"; +class EntranceContext { + public: + absl::Status LoadEntranceTileTypes(Rom& rom) { + int offset_low = 0xDB8BF; + int offset_high = 0xDB917; + + for (int i = 0; i < 0x2C; i++) { + // Load entrance tile types + ASSIGN_OR_RETURN(auto value_low, rom.ReadWord(offset_low + i)); + entrance_tile_types_low_.push_back(value_low); + ASSIGN_OR_RETURN(auto value_high, rom.ReadWord(offset_high + i)); + entrance_tile_types_low_.push_back(value_high); + } + + return absl::OkStatus(); + } + + private: + std::vector entrance_tile_types_low_; + std::vector entrance_tile_types_high_; +}; + /** * @class OverworldEditor * @brief Manipulates the Overworld and OverworldMap data in a Rom. @@ -82,7 +103,7 @@ constexpr absl::string_view kOWMapTable = "#MapSettingsTable"; class OverworldEditor : public Editor, public SharedRom, public context::GfxContext, - public context::EntranceContext, + public EntranceContext, public core::ExperimentFlags { public: OverworldEditor() { type_ = EditorType::kOverworld; } diff --git a/src/app/editor/context/gfx_context.cc b/src/app/editor/utils/gfx_context.cc similarity index 92% rename from src/app/editor/context/gfx_context.cc rename to src/app/editor/utils/gfx_context.cc index e544f860..dd8d7cef 100644 --- a/src/app/editor/context/gfx_context.cc +++ b/src/app/editor/utils/gfx_context.cc @@ -1,4 +1,4 @@ -#include "app/editor/context/gfx_context.h" +#include "app/editor/utils/gfx_context.h" #include diff --git a/src/app/editor/context/gfx_context.h b/src/app/editor/utils/gfx_context.h similarity index 100% rename from src/app/editor/context/gfx_context.h rename to src/app/editor/utils/gfx_context.h diff --git a/src/app/zelda3/overworld/overworld_map.cc b/src/app/zelda3/overworld/overworld_map.cc index 80815be5..72321c88 100644 --- a/src/app/zelda3/overworld/overworld_map.cc +++ b/src/app/zelda3/overworld/overworld_map.cc @@ -9,7 +9,7 @@ #include #include "app/core/common.h" -#include "app/editor/context/gfx_context.h" +#include "app/editor/utils/gfx_context.h" #include "app/gfx/bitmap.h" #include "app/gfx/snes_tile.h" #include "app/rom.h" diff --git a/src/app/zelda3/overworld/overworld_map.h b/src/app/zelda3/overworld/overworld_map.h index f84e785c..f2e9ce08 100644 --- a/src/app/zelda3/overworld/overworld_map.h +++ b/src/app/zelda3/overworld/overworld_map.h @@ -11,7 +11,7 @@ #include "absl/status/status.h" #include "app/core/common.h" -#include "app/editor/context/gfx_context.h" +#include "app/editor/utils/gfx_context.h" #include "app/gfx/bitmap.h" #include "app/gfx/snes_palette.h" #include "app/gfx/snes_tile.h" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d92b2525..b22d9112 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -32,7 +32,7 @@ add_executable( ../src/app/emu/audio/dsp.cc ../src/app/emu/audio/spc700.cc ../src/app/emu/memory/memory.cc - ../src/app/editor/context/gfx_context.cc + ../src/app/editor/utils/gfx_context.cc ../src/app/gfx/bitmap.cc ../src/app/gfx/snes_tile.cc ../src/app/gfx/snes_color.cc