Editor housekeeping
This commit is contained in:
@@ -159,7 +159,7 @@ void BitmapCanvasPipeline(gui::Canvas& canvas, const gfx::Bitmap& bitmap,
|
|||||||
void BuildAndRenderBitmapPipeline(int width, int height, int depth, Bytes data,
|
void BuildAndRenderBitmapPipeline(int width, int height, int depth, Bytes data,
|
||||||
ROM& z3_rom, gfx::Bitmap& bitmap,
|
ROM& z3_rom, gfx::Bitmap& bitmap,
|
||||||
gfx::SNESPalette& palette) {
|
gfx::SNESPalette& palette) {
|
||||||
PRINT_IF_ERROR(bitmap.InitializeFromData(width, height, depth, data));
|
bitmap.Create(width, height, depth, data);
|
||||||
bitmap.ApplyPalette(palette);
|
bitmap.ApplyPalette(palette);
|
||||||
z3_rom.RenderBitmap(&bitmap);
|
z3_rom.RenderBitmap(&bitmap);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,8 +164,8 @@ absl::Status GraphicsEditor::DrawCgxImport() {
|
|||||||
core::ButtonPipe("Load CGX Data", [this]() {
|
core::ButtonPipe("Load CGX Data", [this]() {
|
||||||
status_ = gfx::LoadCgx(current_bpp_, cgx_file_path_, cgx_data_,
|
status_ = gfx::LoadCgx(current_bpp_, cgx_file_path_, cgx_data_,
|
||||||
decoded_cgx_, extra_cgx_data_);
|
decoded_cgx_, extra_cgx_data_);
|
||||||
PRINT_IF_ERROR(
|
|
||||||
cgx_bitmap_.InitializeFromData(0x80, 0x200, 8, decoded_cgx_));
|
cgx_bitmap_.InitializeFromData(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_);
|
||||||
@@ -198,8 +198,8 @@ absl::Status GraphicsEditor::DrawScrImport() {
|
|||||||
decoded_scr_data_.resize(0x100 * 0x100);
|
decoded_scr_data_.resize(0x100 * 0x100);
|
||||||
status_ = gfx::DrawScrWithCgx(current_bpp_, scr_data_, decoded_scr_data_,
|
status_ = gfx::DrawScrWithCgx(current_bpp_, scr_data_, decoded_scr_data_,
|
||||||
decoded_cgx_);
|
decoded_cgx_);
|
||||||
PRINT_IF_ERROR(
|
|
||||||
scr_bitmap_.InitializeFromData(0x100, 0x100, 8, decoded_scr_data_));
|
scr_bitmap_.InitializeFromData(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_);
|
||||||
@@ -389,7 +389,7 @@ absl::Status GraphicsEditor::DecompressImportData(int size) {
|
|||||||
|
|
||||||
auto converted_sheet = gfx::SnesTo8bppSheet(import_data_, 3);
|
auto converted_sheet = gfx::SnesTo8bppSheet(import_data_, 3);
|
||||||
bin_bitmap_.Create(core::kTilesheetWidth, 0x2000, core::kTilesheetDepth,
|
bin_bitmap_.Create(core::kTilesheetWidth, 0x2000, core::kTilesheetDepth,
|
||||||
converted_sheet.data(), size);
|
converted_sheet);
|
||||||
|
|
||||||
if (rom()->isLoaded()) {
|
if (rom()->isLoaded()) {
|
||||||
auto palette_group = rom()->GetPaletteGroup("ow_main");
|
auto palette_group = rom()->GetPaletteGroup("ow_main");
|
||||||
|
|||||||
@@ -112,12 +112,14 @@ class RecentFilesManager {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
using ImGui::Text;
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterEditor::UpdateScreen() {
|
absl::Status MasterEditor::Update() {
|
||||||
NewMasterFrame();
|
NewMasterFrame();
|
||||||
|
|
||||||
DrawYazeMenu();
|
DrawYazeMenu();
|
||||||
@@ -128,39 +130,27 @@ void MasterEditor::UpdateScreen() {
|
|||||||
|
|
||||||
TAB_BAR("##TabBar")
|
TAB_BAR("##TabBar")
|
||||||
|
|
||||||
TAB_ITEM("Overworld")
|
gui::RenderTabItem("Overworld", [&]() {
|
||||||
current_editor_ = &overworld_editor_;
|
current_editor_ = &overworld_editor_;
|
||||||
status_ = overworld_editor_.Update();
|
status_ = overworld_editor_.Update();
|
||||||
END_TAB_ITEM()
|
});
|
||||||
|
|
||||||
TAB_ITEM("Dungeon")
|
gui::RenderTabItem("Dungeon", [&]() {
|
||||||
current_editor_ = &dungeon_editor_;
|
current_editor_ = &dungeon_editor_;
|
||||||
status_ = dungeon_editor_.Update();
|
status_ = dungeon_editor_.Update();
|
||||||
END_TAB_ITEM()
|
});
|
||||||
|
|
||||||
TAB_ITEM("Graphics")
|
|
||||||
status_ = graphics_editor_.Update();
|
|
||||||
END_TAB_ITEM()
|
|
||||||
|
|
||||||
TAB_ITEM("Sprites")
|
|
||||||
status_ = sprite_editor_.Update();
|
|
||||||
END_TAB_ITEM()
|
|
||||||
|
|
||||||
TAB_ITEM("Palettes")
|
|
||||||
status_ = palette_editor_.Update();
|
|
||||||
END_TAB_ITEM()
|
|
||||||
|
|
||||||
TAB_ITEM("Screens")
|
|
||||||
screen_editor_.Update();
|
|
||||||
END_TAB_ITEM()
|
|
||||||
|
|
||||||
TAB_ITEM("Music")
|
|
||||||
music_editor_.Update();
|
|
||||||
END_TAB_ITEM()
|
|
||||||
|
|
||||||
|
gui::RenderTabItem("Graphics",
|
||||||
|
[&]() { status_ = graphics_editor_.Update(); });
|
||||||
|
gui::RenderTabItem("Sprites", [&]() { status_ = sprite_editor_.Update(); });
|
||||||
|
gui::RenderTabItem("Palettes", [&]() { status_ = palette_editor_.Update(); });
|
||||||
|
gui::RenderTabItem("Screens", [&]() { screen_editor_.Update(); });
|
||||||
|
gui::RenderTabItem("Music", [&]() { music_editor_.Update(); });
|
||||||
END_TAB_BAR()
|
END_TAB_BAR()
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MasterEditor::DrawFileDialog() {
|
void MasterEditor::DrawFileDialog() {
|
||||||
@@ -189,7 +179,7 @@ void MasterEditor::DrawStatusPopup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (show_status_ && (BeginCentered("StatusWindow"))) {
|
if (show_status_ && (BeginCentered("StatusWindow"))) {
|
||||||
ImGui::Text("%s", prev_status_.ToString().c_str());
|
Text("%s", prev_status_.ToString().c_str());
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
ImGui::Columns(1);
|
ImGui::Columns(1);
|
||||||
@@ -207,10 +197,10 @@ void MasterEditor::DrawAboutPopup() {
|
|||||||
if (about_) ImGui::OpenPopup("About");
|
if (about_) ImGui::OpenPopup("About");
|
||||||
if (ImGui::BeginPopupModal("About", nullptr,
|
if (ImGui::BeginPopupModal("About", nullptr,
|
||||||
ImGuiWindowFlags_AlwaysAutoResize)) {
|
ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
ImGui::Text("Yet Another Zelda3 Editor - v0.05");
|
Text("Yet Another Zelda3 Editor - v0.05");
|
||||||
ImGui::Text("Written by: scawful");
|
Text("Written by: scawful");
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
ImGui::Text("Special Thanks: Zarby89, JaredBrian");
|
Text("Special Thanks: Zarby89, JaredBrian");
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
if (ImGui::Button("Close", gui::kDefaultModalSize)) {
|
if (ImGui::Button("Close", gui::kDefaultModalSize)) {
|
||||||
@@ -225,8 +215,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());
|
Text("Title: %s", rom()->title());
|
||||||
ImGui::Text("ROM Size: %ld", rom()->size());
|
Text("ROM Size: %ld", rom()->size());
|
||||||
|
|
||||||
if (ImGui::Button("Close", gui::kDefaultModalSize)) {
|
if (ImGui::Button("Close", gui::kDefaultModalSize)) {
|
||||||
rom_info_ = false;
|
rom_info_ = false;
|
||||||
@@ -259,7 +249,7 @@ void MasterEditor::DrawYazeMenu() {
|
|||||||
}
|
}
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
|
|
||||||
ImGui::Text(absl::StrCat("yaze v", core::kYazeVersion).c_str());
|
Text(absl::StrCat("yaze v", core::kYazeVersion).c_str());
|
||||||
|
|
||||||
END_MENU_BAR()
|
END_MENU_BAR()
|
||||||
|
|
||||||
@@ -273,7 +263,7 @@ void MasterEditor::DrawYazeMenu() {
|
|||||||
if (show_command_line_interface) {
|
if (show_command_line_interface) {
|
||||||
ImGui::Begin("Command Line Interface", &show_command_line_interface,
|
ImGui::Begin("Command Line Interface", &show_command_line_interface,
|
||||||
ImGuiWindowFlags_None);
|
ImGuiWindowFlags_None);
|
||||||
ImGui::Text("Enter a command:");
|
Text("Enter a command:");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -331,7 +321,7 @@ void MasterEditor::DrawFileMenu() {
|
|||||||
if (ImGui::BeginMenu("Options")) {
|
if (ImGui::BeginMenu("Options")) {
|
||||||
ImGui::MenuItem("Backup ROM", "", &backup_rom_);
|
ImGui::MenuItem("Backup ROM", "", &backup_rom_);
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Text("Experiment Flags");
|
Text("Experiment Flags");
|
||||||
ImGui::Checkbox("Enable Overworld Sprites",
|
ImGui::Checkbox("Enable Overworld Sprites",
|
||||||
&mutable_flags()->kDrawOverworldSprites);
|
&mutable_flags()->kDrawOverworldSprites);
|
||||||
ImGui::Checkbox("Use Bitmap Manager",
|
ImGui::Checkbox("Use Bitmap Manager",
|
||||||
@@ -441,7 +431,7 @@ void MasterEditor::DrawViewMenu() {
|
|||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
for (int column = 0; column < 3; column++) {
|
for (int column = 0; column < 3; column++) {
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text("Cell %d,%d", column, row);
|
Text("Cell %d,%d", column, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
@@ -473,12 +463,12 @@ void MasterEditor::DrawHelpMenu() {
|
|||||||
if (open_rom_help) ImGui::OpenPopup("Open a ROM");
|
if (open_rom_help) ImGui::OpenPopup("Open a ROM");
|
||||||
if (ImGui::BeginPopupModal("Open a ROM", nullptr,
|
if (ImGui::BeginPopupModal("Open a ROM", nullptr,
|
||||||
ImGuiWindowFlags_AlwaysAutoResize)) {
|
ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
ImGui::Text("File -> Open");
|
Text("File -> Open");
|
||||||
ImGui::Text("Select a ROM file to open");
|
Text("Select a ROM file to open");
|
||||||
ImGui::Text("Supported ROMs (headered or unheadered):");
|
Text("Supported ROMs (headered or unheadered):");
|
||||||
ImGui::Text("The Legend of Zelda: A Link to the Past");
|
Text("The Legend of Zelda: A Link to the Past");
|
||||||
ImGui::Text("US Version 1.0");
|
Text("US Version 1.0");
|
||||||
ImGui::Text("JP Version 1.0");
|
Text("JP Version 1.0");
|
||||||
|
|
||||||
if (ImGui::Button("Close", gui::kDefaultModalSize)) {
|
if (ImGui::Button("Close", gui::kDefaultModalSize)) {
|
||||||
open_rom_help = false;
|
open_rom_help = false;
|
||||||
|
|||||||
@@ -33,8 +33,11 @@ namespace editor {
|
|||||||
|
|
||||||
class MasterEditor : public SharedROM, public core::ExperimentFlags {
|
class MasterEditor : public SharedROM, public core::ExperimentFlags {
|
||||||
public:
|
public:
|
||||||
|
MasterEditor() { current_editor_ = &overworld_editor_; }
|
||||||
|
|
||||||
void SetupScreen(std::shared_ptr<SDL_Renderer> renderer);
|
void SetupScreen(std::shared_ptr<SDL_Renderer> renderer);
|
||||||
void UpdateScreen();
|
absl::Status Update();
|
||||||
|
|
||||||
void Shutdown() { overworld_editor_.Shutdown(); }
|
void Shutdown() { overworld_editor_.Shutdown(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -60,7 +63,6 @@ class MasterEditor : public SharedROM, public core::ExperimentFlags {
|
|||||||
std::shared_ptr<SDL_Renderer> sdl_renderer_;
|
std::shared_ptr<SDL_Renderer> sdl_renderer_;
|
||||||
|
|
||||||
emu::Emulator emulator_;
|
emu::Emulator emulator_;
|
||||||
Editor *current_editor_ = nullptr;
|
|
||||||
|
|
||||||
AssemblyEditor assembly_editor_;
|
AssemblyEditor assembly_editor_;
|
||||||
DungeonEditor dungeon_editor_;
|
DungeonEditor dungeon_editor_;
|
||||||
@@ -70,6 +72,8 @@ class MasterEditor : public SharedROM, public core::ExperimentFlags {
|
|||||||
PaletteEditor palette_editor_;
|
PaletteEditor palette_editor_;
|
||||||
ScreenEditor screen_editor_;
|
ScreenEditor screen_editor_;
|
||||||
SpriteEditor sprite_editor_;
|
SpriteEditor sprite_editor_;
|
||||||
|
|
||||||
|
Editor *current_editor_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace editor
|
} // namespace editor
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ absl::Status OverworldEditor::Update() {
|
|||||||
// Initialize overworld graphics, maps, and palettes
|
// Initialize overworld graphics, maps, and palettes
|
||||||
RETURN_IF_ERROR(LoadGraphics())
|
RETURN_IF_ERROR(LoadGraphics())
|
||||||
RETURN_IF_ERROR(tile16_editor_.InitBlockset(
|
RETURN_IF_ERROR(tile16_editor_.InitBlockset(
|
||||||
tile16_blockset_bmp_, tile16_individual_, tile8_individual_));
|
tile16_blockset_bmp_, current_gfx_bmp_, tile16_individual_));
|
||||||
gfx_group_editor_.InitBlockset(tile16_blockset_bmp_);
|
gfx_group_editor_.InitBlockset(tile16_blockset_bmp_);
|
||||||
all_gfx_loaded_ = true;
|
all_gfx_loaded_ = true;
|
||||||
} else if (!rom()->isLoaded() && all_gfx_loaded_) {
|
} else if (!rom()->isLoaded() && all_gfx_loaded_) {
|
||||||
|
|||||||
Reference in New Issue
Block a user