Move GfxContext to editor/utils, update CMakeLists.txt

This commit is contained in:
scawful
2024-07-19 23:07:04 -04:00
parent f2d582c9c6
commit 4582a18f53
11 changed files with 32 additions and 53 deletions

View File

@@ -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(

View File

@@ -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"

View File

@@ -1,42 +0,0 @@
#ifndef YAZE_APP_EDITOR_CONTEXT_ENTRANCE_CONTEXT_H_
#define YAZE_APP_EDITOR_CONTEXT_ENTRANCE_CONTEXT_H_
#include <cstdint>
#include <vector>
#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<uint16_t> entrance_tile_types_low_;
std::vector<uint16_t> entrance_tile_types_high_;
};
} // namespace context
} // namespace editor
} // namespace app
} // namespace yaze
#endif // YAZE_APP_EDITOR_CONTEXT_ENTRANCE_CONTEXT_H_

View File

@@ -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"

View File

@@ -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"

View File

@@ -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<uint16_t> entrance_tile_types_low_;
std::vector<uint16_t> 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; }

View File

@@ -1,4 +1,4 @@
#include "app/editor/context/gfx_context.h"
#include "app/editor/utils/gfx_context.h"
#include <imgui/imgui.h>

View File

@@ -9,7 +9,7 @@
#include <vector>
#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"

View File

@@ -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"

View File

@@ -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