Housekeeping

This commit is contained in:
scawful
2023-12-17 21:02:28 -05:00
parent 10785357ef
commit 20515d2f0b
11 changed files with 66 additions and 73 deletions

View File

@@ -112,6 +112,8 @@ class RecentFilesManager {
} // namespace
using ImGui::BeginMenu;
using ImGui::MenuItem;
using ImGui::Text;
void MasterEditor::SetupScreen(std::shared_ptr<SDL_Renderer> renderer) {
@@ -275,8 +277,8 @@ void MasterEditor::DrawYazeMenu() {
void MasterEditor::DrawFileMenu() {
static bool save_as_menu = false;
if (ImGui::BeginMenu("File")) {
if (ImGui::MenuItem("Open", "Ctrl+O")) {
if (BeginMenu("File")) {
if (MenuItem("Open", "Ctrl+O")) {
if (flags()->kNewFileDialogWrapper) {
auto file_name = FileDialogWrapper::ShowOpenFileDialog();
PRINT_IF_ERROR(rom()->LoadFromFile(file_name));
@@ -290,14 +292,14 @@ void MasterEditor::DrawFileMenu() {
}
}
if (ImGui::BeginMenu("Open Recent")) {
if (BeginMenu("Open Recent")) {
static RecentFilesManager manager("recent_files.txt");
manager.Load();
if (manager.GetRecentFiles().empty()) {
ImGui::MenuItem("No Recent Files", nullptr, false, false);
MenuItem("No Recent Files", nullptr, false, false);
} else {
for (const auto& filePath : manager.GetRecentFiles()) {
if (ImGui::MenuItem(filePath.c_str())) {
if (MenuItem(filePath.c_str())) {
status_ = rom()->LoadFromFile(filePath);
}
}
@@ -315,8 +317,8 @@ void MasterEditor::DrawFileMenu() {
ImGui::Separator();
if (ImGui::BeginMenu("Options")) {
ImGui::MenuItem("Backup ROM", "", &backup_rom_);
if (BeginMenu("Options")) {
MenuItem("Backup ROM", "", &backup_rom_);
ImGui::Separator();
Text("Experiment Flags");
ImGui::Checkbox("Enable Texture Streaming",
@@ -339,7 +341,7 @@ void MasterEditor::DrawFileMenu() {
ImGui::Separator();
if (ImGui::MenuItem("Quit", "Ctrl+Q")) {
if (MenuItem("Quit", "Ctrl+Q")) {
// TODO: Implement quit confirmation dialog.
}
@@ -363,7 +365,7 @@ void MasterEditor::DrawFileMenu() {
}
void MasterEditor::DrawEditMenu() {
if (ImGui::BeginMenu("Edit")) {
if (BeginMenu("Edit")) {
MENU_ITEM2("Undo", "Ctrl+Z") { status_ = current_editor_->Undo(); }
MENU_ITEM2("Redo", "Ctrl+Y") { status_ = current_editor_->Redo(); }
ImGui::Separator();
@@ -439,23 +441,23 @@ void MasterEditor::DrawViewMenu() {
ImGui::End();
}
if (ImGui::BeginMenu("View")) {
ImGui::MenuItem("Emulator", nullptr, &show_emulator);
ImGui::MenuItem("HEX Editor", nullptr, &show_memory_editor);
ImGui::MenuItem("ASM Editor", nullptr, &show_asm_editor);
ImGui::MenuItem("Palette Editor", nullptr, &show_palette_editor);
ImGui::MenuItem("Memory Viewer", nullptr, &show_memory_viewer);
ImGui::MenuItem("ImGui Demo", nullptr, &show_imgui_demo);
ImGui::MenuItem("ImGui Metrics", nullptr, &show_imgui_metrics);
if (BeginMenu("View")) {
MenuItem("Emulator", nullptr, &show_emulator);
MenuItem("HEX Editor", nullptr, &show_memory_editor);
MenuItem("ASM Editor", nullptr, &show_asm_editor);
MenuItem("Palette Editor", nullptr, &show_palette_editor);
MenuItem("Memory Viewer", nullptr, &show_memory_viewer);
MenuItem("ImGui Demo", nullptr, &show_imgui_demo);
MenuItem("ImGui Metrics", nullptr, &show_imgui_metrics);
ImGui::EndMenu();
}
}
void MasterEditor::DrawHelpMenu() {
static bool open_rom_help = false;
if (ImGui::BeginMenu("Help")) {
if (ImGui::MenuItem("How to open a ROM")) open_rom_help = true;
if (ImGui::MenuItem("About")) about_ = true;
if (BeginMenu("Help")) {
if (MenuItem("How to open a ROM")) open_rom_help = true;
if (MenuItem("About")) about_ = true;
ImGui::EndMenu();
}

View File

@@ -62,7 +62,7 @@ absl::Status GfxGroupEditor::Update() {
auto &sheet = *rom()->bitmap_manager()[sheet_id];
if (sheet_id != last_sheet_id_) {
last_sheet_id_ = sheet_id;
auto palette_group = rom()->GetPaletteGroup("ow_main");
auto palette_group = rom()->palette_group("ow_main");
auto palette = palette_group[preview_palette_id_];
sheet.ApplyPalette(palette);
rom()->UpdateBitmap(&sheet);

View File

@@ -96,8 +96,8 @@ absl::Status PaletteEditor::DrawPaletteGroup(int category) {
}
const auto size =
rom()->GetPaletteGroup(kPaletteGroupNames[category].data()).size();
auto palettes = rom()->GetPaletteGroup(kPaletteGroupNames[category].data());
rom()->palette_group(kPaletteGroupNames[category].data()).size();
auto palettes = rom()->palette_group(kPaletteGroupNames[category].data());
static bool edit_color = false;
for (int j = 0; j < size; j++) {
ImGui::Text("%d", j);

View File

@@ -112,7 +112,7 @@ absl::Status Tile16Editor::UpdateBlockset() {
if (notify_tile16.modified()) {
current_tile16_bmp_ = tile16_individual_[notify_tile16];
current_tile16_bmp_.ApplyPalette(
rom()->GetPaletteGroup("ow_main")[current_palette_]);
rom()->palette_group("ow_main")[current_palette_]);
rom()->RenderBitmap(&current_tile16_bmp_);
}
}
@@ -163,9 +163,9 @@ void Tile16Editor::DrawTileEditControls() {
notify_palette.apply_changes();
if (notify_palette.modified()) {
current_gfx_bmp_.ApplyPalette(
rom()->GetPaletteGroup("ow_main")[notify_palette.get()]);
rom()->palette_group("ow_main")[notify_palette.get()]);
current_tile16_bmp_.ApplyPalette(
rom()->GetPaletteGroup("ow_main")[notify_palette.get()]);
rom()->palette_group("ow_main")[notify_palette.get()]);
rom()->UpdateBitmap(&current_gfx_bmp_);
}
@@ -250,7 +250,7 @@ absl::Status Tile16Editor::LoadTile8() {
current_gfx_individual_.emplace_back();
current_gfx_individual_[index].Create(0x08, 0x08, 0x80, tile_data);
current_gfx_individual_[index].ApplyPalette(
rom()->GetPaletteGroup("ow_main")[current_palette_]);
rom()->palette_group("ow_main")[current_palette_]);
rom()->RenderBitmap(&current_gfx_individual_[index]);
};
@@ -272,7 +272,7 @@ absl::Status Tile16Editor::LoadTile8() {
// for (int i = 0; i < 128; i++) {
// std::vector<uint8_t> tile_data(0x40, 0x00);
// // Copy the pixel data for the current tile into the vector
// Copy the pixel data for the current tile into the vector
// for (int ty = 0; ty < 8; ty++) {
// for (int tx = 0; tx < 8; tx++) {
// int position = tx + (ty * 0x10);
@@ -287,7 +287,7 @@ absl::Status Tile16Editor::LoadTile8() {
// current_gfx_individual_.emplace_back();
// current_gfx_individual_[i].Create(0x08, 0x08, 0x80, tile_data);
// current_gfx_individual_[i].ApplyPalette(
// rom()->GetPaletteGroup("ow_main")[current_palette_]);
// rom()->palette_group("ow_main")[current_palette_]);
// rom()->RenderBitmap(&current_gfx_individual_[i]);
// }
return absl::OkStatus();

View File

@@ -466,6 +466,8 @@ void OverworldEditor::DrawOverworldCanvas() {
DrawOverworldMapSettings();
Separator();
}
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
if (ImGuiID child_id = ImGui::GetID((void *)(intptr_t)7);
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar |
@@ -486,6 +488,7 @@ void OverworldEditor::DrawOverworldCanvas() {
ow_map_canvas_.DrawOverlay();
}
ImGui::EndChild();
ImGui::PopStyleVar(2);
}
// ----------------------------------------------------------------------------