Add SaveRom to MasterEditor, rename Rom::isLoaded to is_loaded

This commit is contained in:
scawful
2024-01-22 03:29:18 -05:00
parent b69c1f3ef3
commit 7d28d35e5d
9 changed files with 29 additions and 22 deletions

View File

@@ -29,8 +29,7 @@ using ImGui::TableNextRow;
using ImGui::TableSetupColumn;
absl::Status DungeonEditor::Update() {
if (!is_loaded_ && rom()->isLoaded()) {
// 295 - 256 = 39
if (!is_loaded_ && rom()->is_loaded()) {
for (int i = 0; i < 0x100 + 40; i++) {
rooms_.emplace_back(zelda3::dungeon::Room(i));
rooms_[i].LoadHeader();
@@ -91,9 +90,6 @@ absl::Status DungeonEditor::Update() {
// Room with address 0x0A8000
rooms_[roomId].set_room_size(0x00);
}
// Load a color from the palette for the room to use with the color
// button
}
}
@@ -271,7 +267,7 @@ void DungeonEditor::DrawToolset() {
}
void DungeonEditor::DrawRoomSelector() {
if (rom()->isLoaded()) {
if (rom()->is_loaded()) {
gui::InputHexWord("Room ID", &current_room_id_);
gui::InputHex("Palette ID", &current_palette_id_);

View File

@@ -64,13 +64,13 @@ absl::Status GraphicsEditor::UpdateGfxEdit() {
status_ = UpdateGfxSheetList();
NEXT_COLUMN();
if (rom()->isLoaded()) {
if (rom()->is_loaded()) {
DrawGfxEditToolset();
status_ = UpdateGfxTabView();
}
NEXT_COLUMN();
if (rom()->isLoaded()) {
if (rom()->is_loaded()) {
status_ = UpdatePaletteColumn();
}
}
@@ -319,7 +319,7 @@ absl::Status GraphicsEditor::UpdatePaletteColumn() {
auto palette = palette_group[edit_palette_index_];
if (rom()->isLoaded()) {
if (rom()->is_loaded()) {
gui::TextWithSeparators("ROM Palette");
ImGui::SetNextItemWidth(100.f);
ImGui::Combo("Palette Group", (int*)&edit_palette_group_name_index_,
@@ -543,7 +543,7 @@ absl::Status GraphicsEditor::DrawPaletteControls() {
gui::ButtonPipe("Copy COL Path",
[this]() { ImGui::SetClipboardText(col_file_path_); });
if (rom()->isLoaded()) {
if (rom()->is_loaded()) {
gui::TextWithSeparators("ROM Palette");
gui::InputHex("Palette Index", &current_palette_index_);
ImGui::Combo("Palette", &current_palette_, kPaletteGroupAddressesKeys,
@@ -648,7 +648,7 @@ absl::Status GraphicsEditor::DrawClipboardImport() {
gui::InputHex("Num Sheets", &num_sheets_to_load_);
gui::ButtonPipe("Decompress Clipboard Data", [this]() {
if (temp_rom_.isLoaded()) {
if (temp_rom_.is_loaded()) {
status_ = DecompressImportData(0x40000);
} else {
status_ = absl::InvalidArgumentError(
@@ -694,7 +694,7 @@ absl::Status GraphicsEditor::DecompressImportData(int size) {
bin_bitmap_.Create(core::kTilesheetWidth, 0x2000, core::kTilesheetDepth,
converted_sheet);
if (rom()->isLoaded()) {
if (rom()->is_loaded()) {
auto palette_group = rom()->palette_group("ow_main");
z3_rom_palette_ = palette_group[current_palette_];
if (col_file_) {

View File

@@ -130,7 +130,7 @@ absl::Status MasterEditor::Update() {
DrawAboutPopup();
DrawInfoPopup();
if (rom()->isLoaded() && !rom_assets_loaded_) {
if (rom()->is_loaded() && !rom_assets_loaded_) {
// Initialize overworld graphics, maps, and palettes
RETURN_IF_ERROR(overworld_editor_.LoadGraphics());
rom_assets_loaded_ = true;
@@ -307,10 +307,10 @@ void MasterEditor::DrawFileMenu() {
ImGui::EndMenu();
}
MENU_ITEM2("Save", "Ctrl+S") { status_ = rom()->SaveToFile(backup_rom_); }
MENU_ITEM2("Save", "Ctrl+S") { SaveRom(); }
MENU_ITEM("Save As..") { save_as_menu = true; }
if (rom()->isLoaded()) {
if (rom()->is_loaded()) {
MENU_ITEM("Reload") { status_ = rom()->Reload(); }
MENU_ITEM("Close") { status_ = rom()->Close(); }
}
@@ -336,6 +336,7 @@ void MasterEditor::DrawFileMenu() {
&mutable_flags()->kSaveWithChangeQueue);
ImGui::Checkbox("Draw Dungeon Room Graphics",
&mutable_flags()->kDrawDungeonRoomGraphics);
ImGui::Checkbox("Save Dungeon Maps", &mutable_flags()->kSaveDungeonMaps);
ImGui::EndMenu();
}
@@ -353,7 +354,7 @@ void MasterEditor::DrawFileMenu() {
ImGui::Begin("Save As..", &save_as_menu, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::InputText("Filename", &save_as_filename);
if (ImGui::Button("Save", gui::kDefaultModalSize)) {
status_ = rom()->SaveToFile(backup_rom_, save_as_filename);
SaveRom();
save_as_menu = false;
}
ImGui::SameLine();
@@ -479,6 +480,14 @@ void MasterEditor::DrawHelpMenu() {
}
}
void MasterEditor::SaveRom() {
if (flags()->kSaveDungeonMaps) {
status_ = screen_editor_.SaveDungeonMaps();
PRINT_IF_ERROR(status_);
}
status_ = rom()->SaveToFile(backup_rom_);
}
} // namespace editor
} // namespace app
} // namespace yaze
} // namespace yaze

View File

@@ -55,6 +55,8 @@ class MasterEditor : public SharedROM,
void DrawViewMenu();
void DrawHelpMenu();
void SaveRom();
bool about_ = false;
bool rom_info_ = false;
bool backup_rom_ = true;

View File

@@ -215,8 +215,6 @@ void DrawPaletteFromPaletteGroup(gfx::SNESPalette &palette) {
} // namespace
void GfxGroupEditor::DrawPaletteViewer() {
// TODO: Implement palette viewer
static PaletteEditor palette_editor;
static uint8_t selected_paletteset = 0;
gui::InputHexByte("Selected Paletteset", &selected_paletteset);

View File

@@ -47,6 +47,8 @@ class GfxGroupEditor : public SharedROM {
uint8_t selected_roomset_ = 0;
uint8_t selected_spriteset_ = 0;
PaletteEditor palette_editor_;
gui::Canvas blockset_canvas_;
gui::Canvas roomset_canvas_;
gui::Canvas spriteset_canvas_;

View File

@@ -91,7 +91,7 @@ void PaletteEditor::ResetColorToOriginal(
}
absl::Status PaletteEditor::DrawPaletteGroup(int category) {
if (!rom()->isLoaded()) {
if (!rom()->is_loaded()) {
return absl::NotFoundError("ROM not open, no palettes to display");
}

View File

@@ -13,7 +13,7 @@ using ImGui::TableSetupColumn;
using ImGui::Text;
absl::Status SpriteEditor::Update() {
if (rom()->isLoaded() && !sheets_loaded_) {
if (rom()->is_loaded() && !sheets_loaded_) {
// Load the values for current_sheets_ array
sheets_loaded_ = true;

View File

@@ -437,7 +437,7 @@ class ROM : public core::ExperimentFlags {
auto push_back(uint8_t byte) { rom_data_.push_back(byte); }
auto vector() const { return rom_data_; }
auto filename() const { return filename_; }
auto isLoaded() const { return is_loaded_; }
auto is_loaded() const { return is_loaded_; }
auto version() const { return version_; }
uchar& operator[](int i) {