Proliferate use of SharedROM
This commit is contained in:
@@ -1,6 +1,13 @@
|
|||||||
#include "dungeon_editor.h"
|
#include "dungeon_editor.h"
|
||||||
|
|
||||||
|
#include <imgui/imgui.h>
|
||||||
|
|
||||||
|
#include "app/core/common.h"
|
||||||
|
#include "app/gui/canvas.h"
|
||||||
#include "app/gui/icons.h"
|
#include "app/gui/icons.h"
|
||||||
|
#include "app/rom.h"
|
||||||
|
#include "app/zelda3/dungeon/room_names.h"
|
||||||
|
#include "zelda3/dungeon/room.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
@@ -10,13 +17,27 @@ void DungeonEditor::Update() {
|
|||||||
DrawToolset();
|
DrawToolset();
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if (ImGui::BeginTable("#DungeonEditTable", 2, toolset_table_flags_,
|
if (ImGui::BeginTable("#DungeonEditTable", 3, toolset_table_flags_,
|
||||||
ImVec2(0, 0))) {
|
ImVec2(0, 0))) {
|
||||||
|
ImGui::TableSetupColumn("Room Selector");
|
||||||
|
|
||||||
ImGui::TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch,
|
ImGui::TableSetupColumn("Canvas", ImGuiTableColumnFlags_WidthStretch,
|
||||||
ImGui::GetContentRegionAvail().x);
|
ImGui::GetContentRegionAvail().x);
|
||||||
ImGui::TableSetupColumn("Object Selector");
|
ImGui::TableSetupColumn("Object Selector");
|
||||||
ImGui::TableHeadersRow();
|
ImGui::TableHeadersRow();
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
if (rom()->isLoaded()) {
|
||||||
|
if (ImGuiID child_id = ImGui::GetID((void *)(intptr_t)9);
|
||||||
|
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
||||||
|
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
||||||
|
for (const auto each_room_name : zelda3::dungeon::kRoomNames) {
|
||||||
|
ImGui::Button(each_room_name.data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::EndChild();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
DrawDungeonCanvas();
|
DrawDungeonCanvas();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
|||||||
@@ -6,12 +6,13 @@
|
|||||||
#include "app/core/common.h"
|
#include "app/core/common.h"
|
||||||
#include "app/gui/canvas.h"
|
#include "app/gui/canvas.h"
|
||||||
#include "app/gui/icons.h"
|
#include "app/gui/icons.h"
|
||||||
#include "rom.h"
|
#include "app/rom.h"
|
||||||
#include "zelda3/dungeon/room.h"
|
#include "zelda3/dungeon/room.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
class DungeonEditor : public SharedROM {
|
class DungeonEditor : public SharedROM {
|
||||||
public:
|
public:
|
||||||
void Update();
|
void Update();
|
||||||
@@ -31,8 +32,11 @@ class DungeonEditor : public SharedROM {
|
|||||||
|
|
||||||
gui::Canvas canvas_;
|
gui::Canvas canvas_;
|
||||||
gui::Canvas room_gfx_canvas_;
|
gui::Canvas room_gfx_canvas_;
|
||||||
ImGuiTableFlags toolset_table_flags_ = ImGuiTableFlags_SizingFixedFit;
|
ImGuiTableFlags toolset_table_flags_ = ImGuiTableFlags_SizingFixedFit |
|
||||||
|
ImGuiTableFlags_Reorderable |
|
||||||
|
ImGuiTableFlags_Resizable;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace editor
|
} // namespace editor
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ absl::Status GraphicsEditor::Update() {
|
|||||||
for (int i = 0; i < graphics_bin_.size(); i++) {
|
for (int i = 0; i < graphics_bin_.size(); i++) {
|
||||||
graphics_bin_[i].ApplyPalette(
|
graphics_bin_[i].ApplyPalette(
|
||||||
col_file_palette_group_[current_palette_index_]);
|
col_file_palette_group_[current_palette_index_]);
|
||||||
rom_.UpdateBitmap(&graphics_bin_[i]);
|
rom()->UpdateBitmap(&graphics_bin_[i]);
|
||||||
}
|
}
|
||||||
refresh_graphics_ = false;
|
refresh_graphics_ = false;
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ absl::Status GraphicsEditor::DrawCgxImport() {
|
|||||||
cgx_bitmap_.Create(0x80, 0x200, 8, decoded_cgx_);
|
cgx_bitmap_.Create(0x80, 0x200, 8, decoded_cgx_);
|
||||||
if (col_file_) {
|
if (col_file_) {
|
||||||
cgx_bitmap_.ApplyPalette(decoded_col_);
|
cgx_bitmap_.ApplyPalette(decoded_col_);
|
||||||
rom_.RenderBitmap(&cgx_bitmap_);
|
rom()->RenderBitmap(&cgx_bitmap_);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -140,16 +140,17 @@ absl::Status GraphicsEditor::DrawCgxImport() {
|
|||||||
absl::Status GraphicsEditor::DrawScrImport() {
|
absl::Status GraphicsEditor::DrawScrImport() {
|
||||||
ImGui::InputText("##ScrFile", scr_file_name_, sizeof(scr_file_name_));
|
ImGui::InputText("##ScrFile", scr_file_name_, sizeof(scr_file_name_));
|
||||||
|
|
||||||
core::FileDialogPipeline("ImportScrKey", ".SCR,.scr\0", "Open SCR", [this]() {
|
core::FileDialogPipeline(
|
||||||
strncpy(scr_file_path_,
|
"ImportScrKey", ".SCR,.scr,.BAK\0", "Open SCR", [this]() {
|
||||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
strncpy(scr_file_path_,
|
||||||
sizeof(scr_file_path_));
|
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||||
strncpy(scr_file_name_,
|
sizeof(scr_file_path_));
|
||||||
ImGuiFileDialog::Instance()->GetCurrentFileName().c_str(),
|
strncpy(scr_file_name_,
|
||||||
sizeof(scr_file_name_));
|
ImGuiFileDialog::Instance()->GetCurrentFileName().c_str(),
|
||||||
is_open_ = true;
|
sizeof(scr_file_name_));
|
||||||
scr_loaded_ = true;
|
is_open_ = true;
|
||||||
});
|
scr_loaded_ = true;
|
||||||
|
});
|
||||||
|
|
||||||
ImGui::InputInt("SCR Mod", &scr_mod_value_);
|
ImGui::InputInt("SCR Mod", &scr_mod_value_);
|
||||||
|
|
||||||
@@ -163,7 +164,7 @@ absl::Status GraphicsEditor::DrawScrImport() {
|
|||||||
scr_bitmap_.Create(0x100, 0x100, 8, decoded_scr_data_);
|
scr_bitmap_.Create(0x100, 0x100, 8, decoded_scr_data_);
|
||||||
if (scr_loaded_) {
|
if (scr_loaded_) {
|
||||||
scr_bitmap_.ApplyPalette(decoded_col_);
|
scr_bitmap_.ApplyPalette(decoded_col_);
|
||||||
rom_.RenderBitmap(&scr_bitmap_);
|
rom()->RenderBitmap(&scr_bitmap_);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -201,7 +202,7 @@ absl::Status GraphicsEditor::DrawPaletteControls() {
|
|||||||
core::ButtonPipe("Copy COL Path",
|
core::ButtonPipe("Copy COL Path",
|
||||||
[this]() { ImGui::SetClipboardText(col_file_path_); });
|
[this]() { ImGui::SetClipboardText(col_file_path_); });
|
||||||
|
|
||||||
if (rom_.isLoaded()) {
|
if (rom()->isLoaded()) {
|
||||||
gui::TextWithSeparators("ROM Palette");
|
gui::TextWithSeparators("ROM Palette");
|
||||||
gui::InputHex("Palette Index", ¤t_palette_index_);
|
gui::InputHex("Palette Index", ¤t_palette_index_);
|
||||||
ImGui::Combo("Palette", ¤t_palette_, kPaletteGroupAddressesKeys,
|
ImGui::Combo("Palette", ¤t_palette_, kPaletteGroupAddressesKeys,
|
||||||
@@ -311,8 +312,8 @@ absl::Status GraphicsEditor::DecompressImportData(int size) {
|
|||||||
bitmap_.Create(core::kTilesheetWidth, 0x2000, core::kTilesheetDepth,
|
bitmap_.Create(core::kTilesheetWidth, 0x2000, core::kTilesheetDepth,
|
||||||
converted_sheet.data(), size);
|
converted_sheet.data(), size);
|
||||||
|
|
||||||
if (rom_.isLoaded()) {
|
if (rom()->isLoaded()) {
|
||||||
auto palette_group = rom_.GetPaletteGroup("ow_main");
|
auto palette_group = rom()->GetPaletteGroup("ow_main");
|
||||||
palette_ = palette_group[current_palette_];
|
palette_ = palette_group[current_palette_];
|
||||||
if (col_file_) {
|
if (col_file_) {
|
||||||
bitmap_.ApplyPalette(col_file_palette_);
|
bitmap_.ApplyPalette(col_file_palette_);
|
||||||
@@ -321,7 +322,7 @@ absl::Status GraphicsEditor::DecompressImportData(int size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rom_.RenderBitmap(&bitmap_);
|
rom()->RenderBitmap(&bitmap_);
|
||||||
gfx_loaded_ = true;
|
gfx_loaded_ = true;
|
||||||
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
@@ -345,12 +346,12 @@ absl::Status GraphicsEditor::DecompressSuperDonkey() {
|
|||||||
} else {
|
} else {
|
||||||
// ROM palette
|
// ROM palette
|
||||||
auto palette_group =
|
auto palette_group =
|
||||||
rom_.GetPaletteGroup(kPaletteGroupAddressesKeys[current_palette_]);
|
rom()->GetPaletteGroup(kPaletteGroupAddressesKeys[current_palette_]);
|
||||||
palette_ = palette_group[current_palette_index_];
|
palette_ = palette_group[current_palette_index_];
|
||||||
graphics_bin_[i].ApplyPalette(palette_);
|
graphics_bin_[i].ApplyPalette(palette_);
|
||||||
}
|
}
|
||||||
|
|
||||||
rom_.RenderBitmap(&graphics_bin_[i]);
|
rom()->RenderBitmap(&graphics_bin_[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,12 +371,12 @@ absl::Status GraphicsEditor::DecompressSuperDonkey() {
|
|||||||
} else {
|
} else {
|
||||||
// ROM palette
|
// ROM palette
|
||||||
auto palette_group =
|
auto palette_group =
|
||||||
rom_.GetPaletteGroup(kPaletteGroupAddressesKeys[current_palette_]);
|
rom()->GetPaletteGroup(kPaletteGroupAddressesKeys[current_palette_]);
|
||||||
palette_ = palette_group[current_palette_index_];
|
palette_ = palette_group[current_palette_index_];
|
||||||
graphics_bin_[i].ApplyPalette(palette_);
|
graphics_bin_[i].ApplyPalette(palette_);
|
||||||
}
|
}
|
||||||
|
|
||||||
rom_.RenderBitmap(&graphics_bin_[i]);
|
rom()->RenderBitmap(&graphics_bin_[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
super_donkey_ = true;
|
super_donkey_ = true;
|
||||||
|
|||||||
@@ -59,10 +59,9 @@ constexpr ImGuiTableFlags kGfxEditFlags = ImGuiTableFlags_Reorderable |
|
|||||||
ImGuiTableFlags_Resizable |
|
ImGuiTableFlags_Resizable |
|
||||||
ImGuiTableFlags_SizingStretchSame;
|
ImGuiTableFlags_SizingStretchSame;
|
||||||
|
|
||||||
class GraphicsEditor {
|
class GraphicsEditor : public SharedROM {
|
||||||
public:
|
public:
|
||||||
absl::Status Update();
|
absl::Status Update();
|
||||||
void SetupROM(ROM& rom) { rom_ = rom; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
absl::Status DrawToolset();
|
absl::Status DrawToolset();
|
||||||
@@ -113,7 +112,6 @@ class GraphicsEditor {
|
|||||||
char scr_file_path_[256] = "";
|
char scr_file_path_[256] = "";
|
||||||
char scr_file_name_[256] = "";
|
char scr_file_name_[256] = "";
|
||||||
|
|
||||||
ROM rom_;
|
|
||||||
ROM temp_rom_;
|
ROM temp_rom_;
|
||||||
Bytes import_data_;
|
Bytes import_data_;
|
||||||
Bytes graphics_buffer_;
|
Bytes graphics_buffer_;
|
||||||
|
|||||||
@@ -59,12 +59,7 @@ bool BeginCentered(const char *name) {
|
|||||||
|
|
||||||
void MasterEditor::SetupScreen(std::shared_ptr<SDL_Renderer> renderer) {
|
void MasterEditor::SetupScreen(std::shared_ptr<SDL_Renderer> renderer) {
|
||||||
sdl_renderer_ = renderer;
|
sdl_renderer_ = renderer;
|
||||||
rom_.SetupRenderer(renderer);
|
rom()->SetupRenderer(renderer);
|
||||||
overworld_editor_.SetupROM(rom_);
|
|
||||||
graphics_editor_.SetupROM(rom_);
|
|
||||||
screen_editor_.SetupROM(rom_);
|
|
||||||
palette_editor_.SetupROM(rom_);
|
|
||||||
music_editor_.SetupROM(rom_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterEditor::UpdateScreen() {
|
void MasterEditor::UpdateScreen() {
|
||||||
@@ -94,7 +89,7 @@ void MasterEditor::DrawFileDialog() {
|
|||||||
[&]() {
|
[&]() {
|
||||||
std::string filePathName =
|
std::string filePathName =
|
||||||
ImGuiFileDialog::Instance()->GetFilePathName();
|
ImGuiFileDialog::Instance()->GetFilePathName();
|
||||||
status_ = rom_.LoadFromFile(filePathName);
|
status_ = rom()->LoadFromFile(filePathName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,8 +136,8 @@ void MasterEditor::DrawInfoPopup() {
|
|||||||
if (rom_info_) ImGui::OpenPopup("ROM Information");
|
if (rom_info_) ImGui::OpenPopup("ROM Information");
|
||||||
if (ImGui::BeginPopupModal("ROM Information", nullptr,
|
if (ImGui::BeginPopupModal("ROM Information", nullptr,
|
||||||
ImGuiWindowFlags_AlwaysAutoResize)) {
|
ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
ImGui::Text("Title: %s", rom_.title());
|
ImGui::Text("Title: %s", rom()->title());
|
||||||
ImGui::Text("ROM Size: %ld", rom_.size());
|
ImGui::Text("ROM Size: %ld", rom()->size());
|
||||||
|
|
||||||
if (ImGui::Button("Close", gui::kDefaultModalSize)) {
|
if (ImGui::Button("Close", gui::kDefaultModalSize)) {
|
||||||
rom_info_ = false;
|
rom_info_ = false;
|
||||||
@@ -170,7 +165,7 @@ void MasterEditor::DrawFileMenu() {
|
|||||||
".sfc,.smc", ".");
|
".sfc,.smc", ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
MENU_ITEM2("Save", "Ctrl+S") { status_ = rom_.SaveToFile(backup_rom_); }
|
MENU_ITEM2("Save", "Ctrl+S") { status_ = rom()->SaveToFile(backup_rom_); }
|
||||||
MENU_ITEM("Save As..") { save_as_menu = true; }
|
MENU_ITEM("Save As..") { save_as_menu = true; }
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
@@ -187,7 +182,7 @@ void MasterEditor::DrawFileMenu() {
|
|||||||
ImGui::Begin("Save As..", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
|
ImGui::Begin("Save As..", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
|
||||||
ImGui::InputText("Filename", &save_as_filename);
|
ImGui::InputText("Filename", &save_as_filename);
|
||||||
if (ImGui::Button("Save", gui::kDefaultModalSize)) {
|
if (ImGui::Button("Save", gui::kDefaultModalSize)) {
|
||||||
status_ = rom_.SaveToFile(backup_rom_, save_as_filename);
|
status_ = rom()->SaveToFile(backup_rom_, save_as_filename);
|
||||||
}
|
}
|
||||||
if (ImGui::Button("Cancel", gui::kDefaultModalSize)) {
|
if (ImGui::Button("Cancel", gui::kDefaultModalSize)) {
|
||||||
save_as_menu = false;
|
save_as_menu = false;
|
||||||
@@ -227,7 +222,7 @@ void MasterEditor::DrawViewMenu() {
|
|||||||
|
|
||||||
if (show_memory_editor) {
|
if (show_memory_editor) {
|
||||||
static MemoryEditor mem_edit;
|
static MemoryEditor mem_edit;
|
||||||
mem_edit.DrawWindow("Memory Editor", (void *)&rom_, rom_.size());
|
mem_edit.DrawWindow("Memory Editor", (void *)&(*rom()), rom()->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_imgui_demo) {
|
if (show_imgui_demo) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace yaze {
|
|||||||
namespace app {
|
namespace app {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
class MasterEditor {
|
class MasterEditor : public SharedROM {
|
||||||
public:
|
public:
|
||||||
void SetupScreen(std::shared_ptr<SDL_Renderer> renderer);
|
void SetupScreen(std::shared_ptr<SDL_Renderer> renderer);
|
||||||
void UpdateScreen();
|
void UpdateScreen();
|
||||||
@@ -72,7 +72,6 @@ class MasterEditor {
|
|||||||
PaletteEditor palette_editor_;
|
PaletteEditor palette_editor_;
|
||||||
ScreenEditor screen_editor_;
|
ScreenEditor screen_editor_;
|
||||||
SpriteEditor sprite_editor_;
|
SpriteEditor sprite_editor_;
|
||||||
ROM rom_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace editor
|
} // namespace editor
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ void MusicEditor::DrawToolset() {
|
|||||||
BUTTON_COLUMN(ICON_MD_FAST_FORWARD)
|
BUTTON_COLUMN(ICON_MD_FAST_FORWARD)
|
||||||
BUTTON_COLUMN(ICON_MD_VOLUME_UP)
|
BUTTON_COLUMN(ICON_MD_VOLUME_UP)
|
||||||
if (ImGui::Button(ICON_MD_ACCESS_TIME)) {
|
if (ImGui::Button(ICON_MD_ACCESS_TIME)) {
|
||||||
music_tracker_.LoadSongs(rom_);
|
music_tracker_.LoadSongs(*rom());
|
||||||
}
|
}
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::SliderInt("Volume", ¤t_volume, 0, 100);
|
ImGui::SliderInt("Volume", ¤t_volume, 0, 100);
|
||||||
|
|||||||
@@ -54,10 +54,9 @@ static const char* kGameSongs[] = {"Title",
|
|||||||
static constexpr absl::string_view kSongNotes[] = {
|
static constexpr absl::string_view kSongNotes[] = {
|
||||||
"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C",
|
"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C",
|
||||||
"C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C"};
|
"C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C"};
|
||||||
class MusicEditor {
|
class MusicEditor : public SharedROM {
|
||||||
public:
|
public:
|
||||||
void Update();
|
void Update();
|
||||||
void SetupROM(ROM& rom) { rom_ = rom; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DrawChannels();
|
void DrawChannels();
|
||||||
@@ -67,7 +66,6 @@ class MusicEditor {
|
|||||||
void DrawToolset();
|
void DrawToolset();
|
||||||
|
|
||||||
zelda3::Tracker music_tracker_;
|
zelda3::Tracker music_tracker_;
|
||||||
ROM rom_;
|
|
||||||
|
|
||||||
// Mix_Music* current_song_ = NULL;
|
// Mix_Music* current_song_ = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace editor {
|
|||||||
|
|
||||||
absl::Status OverworldEditor::Update() {
|
absl::Status OverworldEditor::Update() {
|
||||||
// Initialize overworld graphics, maps, and palettes
|
// Initialize overworld graphics, maps, and palettes
|
||||||
if (rom_.isLoaded() && !all_gfx_loaded_) {
|
if (rom()->isLoaded() && !all_gfx_loaded_) {
|
||||||
RETURN_IF_ERROR(LoadGraphics())
|
RETURN_IF_ERROR(LoadGraphics())
|
||||||
all_gfx_loaded_ = true;
|
all_gfx_loaded_ = true;
|
||||||
}
|
}
|
||||||
@@ -289,21 +289,21 @@ void OverworldEditor::DrawTileSelector() {
|
|||||||
|
|
||||||
absl::Status OverworldEditor::LoadGraphics() {
|
absl::Status OverworldEditor::LoadGraphics() {
|
||||||
// Load all of the graphics data from the game.
|
// Load all of the graphics data from the game.
|
||||||
PRINT_IF_ERROR(rom_.LoadAllGraphicsData())
|
PRINT_IF_ERROR(rom()->LoadAllGraphicsData())
|
||||||
graphics_bin_ = rom_.GetGraphicsBin();
|
graphics_bin_ = rom()->GetGraphicsBin();
|
||||||
|
|
||||||
// Load the Link to the Past overworld.
|
// Load the Link to the Past overworld.
|
||||||
RETURN_IF_ERROR(overworld_.Load(rom_))
|
RETURN_IF_ERROR(overworld_.Load(*rom()))
|
||||||
palette_ = overworld_.AreaPalette();
|
palette_ = overworld_.AreaPalette();
|
||||||
|
|
||||||
// Create the area graphics image
|
// Create the area graphics image
|
||||||
core::BuildAndRenderBitmapPipeline(0x80, 0x200, 0x40,
|
core::BuildAndRenderBitmapPipeline(0x80, 0x200, 0x40,
|
||||||
overworld_.AreaGraphics(), rom_,
|
overworld_.AreaGraphics(), *rom(),
|
||||||
current_gfx_bmp_, palette_);
|
current_gfx_bmp_, palette_);
|
||||||
|
|
||||||
// Create the tile16 blockset image
|
// Create the tile16 blockset image
|
||||||
core::BuildAndRenderBitmapPipeline(0x80, 0x2000, 0x80,
|
core::BuildAndRenderBitmapPipeline(0x80, 0x2000, 0x80,
|
||||||
overworld_.Tile16Blockset(), rom_,
|
overworld_.Tile16Blockset(), *rom(),
|
||||||
tile16_blockset_bmp_, palette_);
|
tile16_blockset_bmp_, palette_);
|
||||||
map_blockset_loaded_ = true;
|
map_blockset_loaded_ = true;
|
||||||
|
|
||||||
@@ -333,7 +333,7 @@ absl::Status OverworldEditor::LoadGraphics() {
|
|||||||
for (int id = 0; id < 4096; id++) {
|
for (int id = 0; id < 4096; id++) {
|
||||||
tile16_individual_.emplace_back();
|
tile16_individual_.emplace_back();
|
||||||
core::BuildAndRenderBitmapPipeline(0x10, 0x10, 0x80,
|
core::BuildAndRenderBitmapPipeline(0x10, 0x10, 0x80,
|
||||||
tile16_individual_data_[id], rom_,
|
tile16_individual_data_[id], *rom(),
|
||||||
tile16_individual_[id], palette_);
|
tile16_individual_[id], palette_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ absl::Status OverworldEditor::LoadGraphics() {
|
|||||||
overworld_.SetCurrentMap(i);
|
overworld_.SetCurrentMap(i);
|
||||||
auto palette = overworld_.AreaPalette();
|
auto palette = overworld_.AreaPalette();
|
||||||
core::BuildAndRenderBitmapPipeline(0x200, 0x200, 0x200,
|
core::BuildAndRenderBitmapPipeline(0x200, 0x200, 0x200,
|
||||||
overworld_.BitmapData(), rom_,
|
overworld_.BitmapData(), *rom(),
|
||||||
maps_bmp_[i], palette);
|
maps_bmp_[i], palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,7 +359,7 @@ absl::Status OverworldEditor::LoadSpriteGraphics() {
|
|||||||
auto spr_gfx = sprite.PreviewGraphics();
|
auto spr_gfx = sprite.PreviewGraphics();
|
||||||
sprite_previews_[sprite.id()].Create(width, height, depth, spr_gfx);
|
sprite_previews_[sprite.id()].Create(width, height, depth, spr_gfx);
|
||||||
sprite_previews_[sprite.id()].ApplyPalette(palette_);
|
sprite_previews_[sprite.id()].ApplyPalette(palette_);
|
||||||
rom_.RenderBitmap(&(sprite_previews_[sprite.id()]));
|
rom()->RenderBitmap(&(sprite_previews_[sprite.id()]));
|
||||||
}
|
}
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,11 +63,6 @@ class OverworldEditor : public Editor, public SharedROM {
|
|||||||
absl::Status Copy() { return absl::UnimplementedError("Copy"); }
|
absl::Status Copy() { return absl::UnimplementedError("Copy"); }
|
||||||
absl::Status Paste() { return absl::UnimplementedError("Paste"); }
|
absl::Status Paste() { return absl::UnimplementedError("Paste"); }
|
||||||
|
|
||||||
void SetupROM(ROM &rom) {
|
|
||||||
rom_ = rom;
|
|
||||||
shared_rom_ = std::make_shared<ROM>(rom_);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
absl::Status DrawToolset();
|
absl::Status DrawToolset();
|
||||||
void DrawOverworldMapSettings();
|
void DrawOverworldMapSettings();
|
||||||
@@ -105,7 +100,6 @@ class OverworldEditor : public Editor, public SharedROM {
|
|||||||
std::vector<Bytes> tile16_individual_data_;
|
std::vector<Bytes> tile16_individual_data_;
|
||||||
std::vector<gfx::Bitmap> tile16_individual_;
|
std::vector<gfx::Bitmap> tile16_individual_;
|
||||||
|
|
||||||
ROM rom_;
|
|
||||||
PaletteEditor palette_editor_;
|
PaletteEditor palette_editor_;
|
||||||
zelda3::Overworld overworld_;
|
zelda3::Overworld overworld_;
|
||||||
|
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ absl::Status PaletteEditor::Update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
absl::Status PaletteEditor::DrawPaletteGroup(int i) {
|
absl::Status PaletteEditor::DrawPaletteGroup(int i) {
|
||||||
auto size = rom_.GetPaletteGroup(kPaletteGroupNames[i].data()).size();
|
auto size = rom()->GetPaletteGroup(kPaletteGroupNames[i].data()).size();
|
||||||
auto palettes = rom_.GetPaletteGroup(kPaletteGroupNames[i].data());
|
auto palettes = rom()->GetPaletteGroup(kPaletteGroupNames[i].data());
|
||||||
for (int j = 0; j < size; j++) {
|
for (int j = 0; j < size; j++) {
|
||||||
ImGui::Text("%d", j);
|
ImGui::Text("%d", j);
|
||||||
|
|
||||||
@@ -73,8 +73,8 @@ absl::Status PaletteEditor::DrawPaletteGroup(int i) {
|
|||||||
if (ImGui::ColorEdit4(
|
if (ImGui::ColorEdit4(
|
||||||
"Edit Color", col.data(),
|
"Edit Color", col.data(),
|
||||||
ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoAlpha)) {
|
ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoAlpha)) {
|
||||||
RETURN_IF_ERROR(rom_.UpdatePaletteColor(kPaletteGroupNames[i].data(),
|
RETURN_IF_ERROR(rom()->UpdatePaletteColor(
|
||||||
j, n, palette[n]))
|
kPaletteGroupNames[i].data(), j, n, palette[n]))
|
||||||
}
|
}
|
||||||
if (ImGui::Button("Copy as..", ImVec2(-1, 0))) ImGui::OpenPopup("Copy");
|
if (ImGui::Button("Copy as..", ImVec2(-1, 0))) ImGui::OpenPopup("Copy");
|
||||||
if (ImGui::BeginPopup("Copy")) {
|
if (ImGui::BeginPopup("Copy")) {
|
||||||
|
|||||||
@@ -5,9 +5,10 @@
|
|||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
#include "app/rom.h"
|
|
||||||
#include "app/gui/canvas.h"
|
#include "app/gui/canvas.h"
|
||||||
#include "app/gui/icons.h"
|
#include "app/gui/icons.h"
|
||||||
|
#include "app/rom.h"
|
||||||
|
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
@@ -25,22 +26,18 @@ static constexpr absl::string_view kPaletteGroupNames[] = {
|
|||||||
"ow_aux", "global_sprites", "dungeon_main", "ow_mini_map",
|
"ow_aux", "global_sprites", "dungeon_main", "ow_mini_map",
|
||||||
"ow_mini_map", "3d_object", "3d_object"};
|
"ow_mini_map", "3d_object", "3d_object"};
|
||||||
|
|
||||||
|
class PaletteEditor : public SharedROM {
|
||||||
class PaletteEditor {
|
|
||||||
public:
|
public:
|
||||||
absl::Status Update();
|
absl::Status Update();
|
||||||
void DisplayPalette(gfx::SNESPalette& palette, bool loaded);
|
void DisplayPalette(gfx::SNESPalette& palette, bool loaded);
|
||||||
|
|
||||||
void DrawPortablePalette(gfx::SNESPalette& palette);
|
void DrawPortablePalette(gfx::SNESPalette& palette);
|
||||||
|
|
||||||
auto SetupROM(ROM& rom) { rom_ = rom; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
absl::Status DrawPaletteGroup(int i);
|
absl::Status DrawPaletteGroup(int i);
|
||||||
|
|
||||||
ImVec4 saved_palette_[256] = {};
|
ImVec4 saved_palette_[256] = {};
|
||||||
ImVec4 current_color_;
|
ImVec4 current_color_;
|
||||||
ROM rom_;
|
|
||||||
|
|
||||||
ImGuiColorEditFlags palette_button_flags =
|
ImGuiColorEditFlags palette_button_flags =
|
||||||
ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoTooltip;
|
ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoTooltip;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ void ScreenEditor::DrawInventoryMenuEditor() {
|
|||||||
TAB_ITEM("Inventory Menu")
|
TAB_ITEM("Inventory Menu")
|
||||||
|
|
||||||
static bool create = false;
|
static bool create = false;
|
||||||
if (!create && rom_.isLoaded()) {
|
if (!create && rom()->isLoaded()) {
|
||||||
inventory_.Create();
|
inventory_.Create();
|
||||||
palette_ = inventory_.Palette();
|
palette_ = inventory_.Palette();
|
||||||
create = true;
|
create = true;
|
||||||
|
|||||||
@@ -21,13 +21,9 @@ namespace editor {
|
|||||||
|
|
||||||
using MosaicArray = std::array<int, core::kNumOverworldMaps>;
|
using MosaicArray = std::array<int, core::kNumOverworldMaps>;
|
||||||
|
|
||||||
class ScreenEditor {
|
class ScreenEditor : public SharedROM {
|
||||||
public:
|
public:
|
||||||
ScreenEditor();
|
ScreenEditor();
|
||||||
void SetupROM(ROM &rom) {
|
|
||||||
rom_ = rom;
|
|
||||||
inventory_.SetupROM(rom_);
|
|
||||||
}
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -44,7 +40,6 @@ class ScreenEditor {
|
|||||||
|
|
||||||
char mosaic_tiles_[core::kNumOverworldMaps];
|
char mosaic_tiles_[core::kNumOverworldMaps];
|
||||||
|
|
||||||
ROM rom_;
|
|
||||||
Bytes all_gfx_;
|
Bytes all_gfx_;
|
||||||
zelda3::Inventory inventory_;
|
zelda3::Inventory inventory_;
|
||||||
gfx::SNESPalette palette_;
|
gfx::SNESPalette palette_;
|
||||||
|
|||||||
@@ -388,5 +388,7 @@ uint32_t ROM::GetPaletteAddress(const std::string& groupName,
|
|||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<ROM> SharedROM::shared_rom_ = nullptr;
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
@@ -127,6 +127,7 @@ class ROM {
|
|||||||
auto end() { return rom_data_.end(); }
|
auto end() { return rom_data_.end(); }
|
||||||
auto data() { return rom_data_.data(); }
|
auto data() { return rom_data_.data(); }
|
||||||
auto vector() const { return rom_data_; }
|
auto vector() const { return rom_data_; }
|
||||||
|
auto filename() const { return filename_; }
|
||||||
auto isLoaded() const { return is_loaded_; }
|
auto isLoaded() const { return is_loaded_; }
|
||||||
auto char_data() { return reinterpret_cast<char*>(rom_data_.data()); }
|
auto char_data() { return reinterpret_cast<char*>(rom_data_.data()); }
|
||||||
|
|
||||||
@@ -199,8 +200,23 @@ class SharedROM {
|
|||||||
SharedROM() = default;
|
SharedROM() = default;
|
||||||
virtual ~SharedROM() = default;
|
virtual ~SharedROM() = default;
|
||||||
|
|
||||||
protected:
|
std::shared_ptr<ROM> shared_rom() {
|
||||||
std::shared_ptr<ROM> shared_rom_;
|
if (!shared_rom_) {
|
||||||
|
shared_rom_ = std::make_shared<ROM>();
|
||||||
|
}
|
||||||
|
return shared_rom_;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto rom() {
|
||||||
|
if (!shared_rom_) {
|
||||||
|
shared_rom_ = std::make_shared<ROM>();
|
||||||
|
}
|
||||||
|
ROM *rom = shared_rom_.get();
|
||||||
|
return rom;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static std::shared_ptr<ROM> shared_rom_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|||||||
Reference in New Issue
Block a user