Remove ImGuiFileDialog integration and replace with FileDialogWrapper in assembly and tile editors
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
#include "graphics_editor.h"
|
||||
|
||||
#include "ImGuiFileDialog/ImGuiFileDialog.h"
|
||||
#include <filesystem>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "app/core/platform/clipboard.h"
|
||||
#include "app/core/platform/file_dialog.h"
|
||||
#include "app/core/platform/renderer.h"
|
||||
#include "app/editor/graphics/palette_editor.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
@@ -514,22 +516,19 @@ absl::Status GraphicsEditor::DrawCgxImport() {
|
||||
gui::TextWithSeparators("Cgx Import");
|
||||
InputInt("BPP", ¤t_bpp_);
|
||||
|
||||
InputText("##CGXFile", cgx_file_name_, sizeof(cgx_file_name_));
|
||||
InputText("##CGXFile", &cgx_file_name_);
|
||||
SameLine();
|
||||
|
||||
gui::FileDialogPipeline("ImportCgxKey", ".CGX,.cgx\0", "Open CGX", [this]() {
|
||||
strncpy(cgx_file_path_,
|
||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||
sizeof(cgx_file_path_));
|
||||
strncpy(cgx_file_name_,
|
||||
ImGuiFileDialog::Instance()->GetCurrentFileName().c_str(),
|
||||
sizeof(cgx_file_name_));
|
||||
if (ImGui::Button("Open CGX")) {
|
||||
auto filename = core::FileDialogWrapper::ShowOpenFileDialog();
|
||||
cgx_file_name_ = filename;
|
||||
cgx_file_path_ = std::filesystem::absolute(filename).string();
|
||||
is_open_ = true;
|
||||
cgx_loaded_ = true;
|
||||
});
|
||||
}
|
||||
|
||||
if (ImGui::Button("Copy CGX Path")) {
|
||||
ImGui::SetClipboardText(cgx_file_path_);
|
||||
ImGui::SetClipboardText(cgx_file_path_.c_str());
|
||||
}
|
||||
|
||||
if (ImGui::Button("Load CGX Data")) {
|
||||
@@ -547,19 +546,15 @@ absl::Status GraphicsEditor::DrawCgxImport() {
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::DrawScrImport() {
|
||||
InputText("##ScrFile", scr_file_name_, sizeof(scr_file_name_));
|
||||
InputText("##ScrFile", &scr_file_name_);
|
||||
|
||||
gui::FileDialogPipeline(
|
||||
"ImportScrKey", ".SCR,.scr,.BAK\0", "Open SCR", [this]() {
|
||||
strncpy(scr_file_path_,
|
||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||
sizeof(scr_file_path_));
|
||||
strncpy(scr_file_name_,
|
||||
ImGuiFileDialog::Instance()->GetCurrentFileName().c_str(),
|
||||
sizeof(scr_file_name_));
|
||||
is_open_ = true;
|
||||
scr_loaded_ = true;
|
||||
});
|
||||
if (ImGui::Button("Open SCR")) {
|
||||
auto filename = core::FileDialogWrapper::ShowOpenFileDialog();
|
||||
scr_file_name_ = filename;
|
||||
scr_file_path_ = std::filesystem::absolute(filename).string();
|
||||
is_open_ = true;
|
||||
scr_loaded_ = true;
|
||||
}
|
||||
|
||||
InputInt("SCR Mod", &scr_mod_value_);
|
||||
|
||||
@@ -583,38 +578,35 @@ absl::Status GraphicsEditor::DrawScrImport() {
|
||||
|
||||
absl::Status GraphicsEditor::DrawPaletteControls() {
|
||||
gui::TextWithSeparators("COL Import");
|
||||
InputText("##ColFile", col_file_name_, sizeof(col_file_name_));
|
||||
InputText("##ColFile", &col_file_name_);
|
||||
SameLine();
|
||||
|
||||
gui::FileDialogPipeline(
|
||||
"ImportColKey", ".COL,.col,.BAK,.bak\0", "Open COL", [this]() {
|
||||
strncpy(col_file_path_,
|
||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||
sizeof(col_file_path_));
|
||||
strncpy(col_file_name_,
|
||||
ImGuiFileDialog::Instance()->GetCurrentFileName().c_str(),
|
||||
sizeof(col_file_name_));
|
||||
status_ = temp_rom_.LoadFromFile(col_file_path_,
|
||||
/*z3_load=*/false);
|
||||
auto col_data_ = gfx::GetColFileData(temp_rom_.mutable_data());
|
||||
if (col_file_palette_group_.size() != 0) {
|
||||
col_file_palette_group_.clear();
|
||||
}
|
||||
auto col_file_palette_group_status =
|
||||
gfx::CreatePaletteGroupFromColFile(col_data_);
|
||||
if (col_file_palette_group_status.ok()) {
|
||||
col_file_palette_group_ = col_file_palette_group_status.value();
|
||||
}
|
||||
col_file_palette_ = gfx::SnesPalette(col_data_);
|
||||
if (ImGui::Button("Open COL")) {
|
||||
auto filename = core::FileDialogWrapper::ShowOpenFileDialog();
|
||||
col_file_name_ = filename;
|
||||
col_file_path_ = std::filesystem::absolute(filename).string();
|
||||
status_ = temp_rom_.LoadFromFile(col_file_path_,
|
||||
/*z3_load=*/false);
|
||||
auto col_data_ = gfx::GetColFileData(temp_rom_.mutable_data());
|
||||
if (col_file_palette_group_.size() != 0) {
|
||||
col_file_palette_group_.clear();
|
||||
}
|
||||
auto col_file_palette_group_status =
|
||||
gfx::CreatePaletteGroupFromColFile(col_data_);
|
||||
if (col_file_palette_group_status.ok()) {
|
||||
col_file_palette_group_ = col_file_palette_group_status.value();
|
||||
}
|
||||
col_file_palette_ = gfx::SnesPalette(col_data_);
|
||||
|
||||
// gigaleak dev format based code
|
||||
decoded_col_ = gfx::scad_format::DecodeColFile(col_file_path_);
|
||||
col_file_ = true;
|
||||
is_open_ = true;
|
||||
});
|
||||
// gigaleak dev format based code
|
||||
decoded_col_ = gfx::scad_format::DecodeColFile(col_file_path_);
|
||||
col_file_ = true;
|
||||
is_open_ = true;
|
||||
}
|
||||
HOVER_HINT(".COL, .BAK");
|
||||
|
||||
if (ImGui::Button("Copy Col Path")) {
|
||||
ImGui::SetClipboardText(col_file_path_);
|
||||
ImGui::SetClipboardText(col_file_path_.c_str());
|
||||
}
|
||||
|
||||
if (rom()->is_loaded()) {
|
||||
@@ -635,17 +627,17 @@ absl::Status GraphicsEditor::DrawPaletteControls() {
|
||||
absl::Status GraphicsEditor::DrawObjImport() {
|
||||
gui::TextWithSeparators("OBJ Import");
|
||||
|
||||
InputText("##ObjFile", obj_file_path_, sizeof(obj_file_path_));
|
||||
InputText("##ObjFile", &obj_file_path_);
|
||||
SameLine();
|
||||
|
||||
gui::FileDialogPipeline(
|
||||
"ImportObjKey", ".obj,.OBJ,.bak,.BAK\0", "Open OBJ", [this]() {
|
||||
strncpy(file_path_,
|
||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||
sizeof(file_path_));
|
||||
status_ = temp_rom_.LoadFromFile(file_path_);
|
||||
is_open_ = true;
|
||||
});
|
||||
if (ImGui::Button("Open OBJ")) {
|
||||
auto filename = core::FileDialogWrapper::ShowOpenFileDialog();
|
||||
obj_file_path_ = std::filesystem::absolute(filename).string();
|
||||
status_ = temp_rom_.LoadFromFile(obj_file_path_);
|
||||
is_open_ = true;
|
||||
obj_loaded_ = true;
|
||||
}
|
||||
HOVER_HINT(".OBJ, .BAK");
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
@@ -653,23 +645,22 @@ absl::Status GraphicsEditor::DrawObjImport() {
|
||||
absl::Status GraphicsEditor::DrawTilemapImport() {
|
||||
gui::TextWithSeparators("Tilemap Import");
|
||||
|
||||
InputText("##TMapFile", tilemap_file_path_, sizeof(tilemap_file_path_));
|
||||
InputText("##TMapFile", &tilemap_file_path_);
|
||||
SameLine();
|
||||
|
||||
gui::FileDialogPipeline(
|
||||
"ImportTilemapKey", ".DAT,.dat,.BIN,.bin,.hex,.HEX\0", "Open Tilemap",
|
||||
[this]() {
|
||||
strncpy(tilemap_file_path_,
|
||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||
sizeof(tilemap_file_path_));
|
||||
status_ = tilemap_rom_.LoadFromFile(tilemap_file_path_);
|
||||
if (ImGui::Button("Open Tilemap")) {
|
||||
auto filename = core::FileDialogWrapper::ShowOpenFileDialog();
|
||||
tilemap_file_path_ = std::filesystem::absolute(filename).string();
|
||||
status_ = tilemap_rom_.LoadFromFile(tilemap_file_path_);
|
||||
status_ = tilemap_rom_.LoadFromFile(tilemap_file_path_);
|
||||
|
||||
// Extract the high and low bytes from the file.
|
||||
auto decomp_sheet = gfx::lc_lz2::DecompressV2(
|
||||
tilemap_rom_.data(), gfx::lc_lz2::kNintendoMode1);
|
||||
tilemap_loaded_ = true;
|
||||
is_open_ = true;
|
||||
});
|
||||
// Extract the high and low bytes from the file.
|
||||
auto decomp_sheet = gfx::lc_lz2::DecompressV2(tilemap_rom_.data(),
|
||||
gfx::lc_lz2::kNintendoMode1);
|
||||
tilemap_loaded_ = true;
|
||||
is_open_ = true;
|
||||
}
|
||||
HOVER_HINT(".DAT, .BIN, .HEX");
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
@@ -677,30 +668,30 @@ absl::Status GraphicsEditor::DrawTilemapImport() {
|
||||
absl::Status GraphicsEditor::DrawFileImport() {
|
||||
gui::TextWithSeparators("BIN Import");
|
||||
|
||||
InputText("##ROMFile", file_path_, sizeof(file_path_));
|
||||
InputText("##ROMFile", &file_path_);
|
||||
SameLine();
|
||||
|
||||
gui::FileDialogPipeline("ImportDlgKey", ".bin,.hex\0", "Open BIN", [this]() {
|
||||
strncpy(file_path_, ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||
sizeof(file_path_));
|
||||
if (ImGui::Button("Open BIN")) {
|
||||
auto filename = core::FileDialogWrapper::ShowOpenFileDialog();
|
||||
file_path_ = filename;
|
||||
status_ = temp_rom_.LoadFromFile(file_path_);
|
||||
is_open_ = true;
|
||||
});
|
||||
}
|
||||
HOVER_HINT(".BIN, .HEX");
|
||||
|
||||
if (Button("Copy File Path")) {
|
||||
ImGui::SetClipboardText(file_path_);
|
||||
ImGui::SetClipboardText(file_path_.c_str());
|
||||
}
|
||||
|
||||
gui::InputHex("BIN Offset", ¤t_offset_);
|
||||
gui::InputHex("BIN Size", &bin_size_);
|
||||
|
||||
if (Button("Decompress BIN")) {
|
||||
if (strlen(file_path_) > 0) {
|
||||
RETURN_IF_ERROR(DecompressImportData(bin_size_))
|
||||
} else {
|
||||
if (file_path_.empty()) {
|
||||
return absl::InvalidArgumentError(
|
||||
"Please select a file before importing.");
|
||||
"Please select a file before decompressing.");
|
||||
}
|
||||
RETURN_IF_ERROR(DecompressImportData(bin_size_))
|
||||
}
|
||||
|
||||
return absl::OkStatus();
|
||||
@@ -739,13 +730,12 @@ absl::Status GraphicsEditor::DrawClipboardImport() {
|
||||
absl::Status GraphicsEditor::DrawExperimentalFeatures() {
|
||||
gui::TextWithSeparators("Experimental");
|
||||
if (Button("Decompress Super Donkey Full")) {
|
||||
if (strlen(file_path_) > 0) {
|
||||
RETURN_IF_ERROR(DecompressSuperDonkey())
|
||||
} else {
|
||||
if (file_path_.empty()) {
|
||||
return absl::InvalidArgumentError(
|
||||
"Please select `super_donkey_1.bin` before "
|
||||
"importing.");
|
||||
}
|
||||
RETURN_IF_ERROR(DecompressSuperDonkey())
|
||||
}
|
||||
ImGui::SetItemTooltip(
|
||||
"Requires `super_donkey_1.bin` to be imported under the "
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
#include <stack>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "app/editor/graphics/palette_editor.h"
|
||||
#include "app/editor/editor.h"
|
||||
#include "app/editor/graphics/palette_editor.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/gui/modules/asset_browser.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/modules/asset_browser.h"
|
||||
#include "app/rom.h"
|
||||
#include "app/zelda3/overworld/overworld.h"
|
||||
#include "imgui/imgui.h"
|
||||
@@ -142,16 +142,16 @@ class GraphicsEditor : public SharedRom, public Editor {
|
||||
bool obj_loaded_ = false;
|
||||
bool tilemap_loaded_ = false;
|
||||
|
||||
char file_path_[256] = "";
|
||||
char col_file_path_[256] = "";
|
||||
char col_file_name_[256] = "";
|
||||
char cgx_file_path_[256] = "";
|
||||
char cgx_file_name_[256] = "";
|
||||
char scr_file_path_[256] = "";
|
||||
char scr_file_name_[256] = "";
|
||||
char obj_file_path_[256] = "";
|
||||
char tilemap_file_path_[256] = "";
|
||||
char tilemap_file_name_[256] = "";
|
||||
std::string file_path_ = "";
|
||||
std::string col_file_path_ = "";
|
||||
std::string col_file_name_ = "";
|
||||
std::string cgx_file_path_ = "";
|
||||
std::string cgx_file_name_ = "";
|
||||
std::string scr_file_path_ = "";
|
||||
std::string scr_file_name_ = "";
|
||||
std::string obj_file_path_ = "";
|
||||
std::string tilemap_file_path_ = "";
|
||||
std::string tilemap_file_name_ = "";
|
||||
|
||||
gui::GfxSheetAssetBrowser asset_browser_;
|
||||
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "ImGuiFileDialog/ImGuiFileDialog.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "app/core/platform/file_dialog.h"
|
||||
#include "app/core/platform/renderer.h"
|
||||
#include "app/editor/graphics/palette_editor.h"
|
||||
#include "app/editor/editor.h"
|
||||
#include "app/editor/graphics/palette_editor.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
@@ -363,16 +363,10 @@ absl::Status Tile16Editor::UpdateTile16Transfer() {
|
||||
absl::Status Tile16Editor::UpdateTransferTileCanvas() {
|
||||
// Create a button for loading another ROM
|
||||
if (Button("Load ROM")) {
|
||||
ImGuiFileDialog::Instance()->OpenDialog(
|
||||
"ChooseTransferFileDlgKey", "Open Transfer ROM", ".sfc,.smc", ".");
|
||||
auto file_name = core::FileDialogWrapper::ShowOpenFileDialog();
|
||||
transfer_status_ = transfer_rom_.LoadFromFile(file_name);
|
||||
transfer_started_ = true;
|
||||
}
|
||||
gui::FileDialogPipeline(
|
||||
"ChooseTransferFileDlgKey", ".sfc,.smc", std::nullopt, [&]() {
|
||||
std::string filePathName =
|
||||
ImGuiFileDialog::Instance()->GetFilePathName();
|
||||
transfer_status_ = transfer_rom_.LoadFromFile(filePathName);
|
||||
transfer_started_ = true;
|
||||
});
|
||||
|
||||
// TODO: Implement tile16 transfer
|
||||
if (transfer_started_ && !transfer_blockset_loaded_) {
|
||||
|
||||
Reference in New Issue
Block a user