Add CgxViewer, update GraphicsEditor
This commit is contained in:
@@ -19,31 +19,37 @@ namespace app {
|
||||
namespace editor {
|
||||
|
||||
absl::Status GraphicsEditor::Update() {
|
||||
if (ImGui::BeginTable("#gfxEditTable", 2, gfx_edit_flags, ImVec2(0, 0))) {
|
||||
ImGui::TableSetupColumn("Bin Importer", ImGuiTableColumnFlags_WidthStretch,
|
||||
ImGui::GetContentRegionAvail().x);
|
||||
ImGui::TableSetupColumn("Graphics Manager");
|
||||
ImGui::TableHeadersRow();
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
RETURN_IF_ERROR(DrawImport())
|
||||
BEGIN_TABLE("#gfxEditTable", 2, gfx_edit_flags)
|
||||
SETUP_COLUMN("Bin Importer")
|
||||
SETUP_COLUMN("Graphics Manager")
|
||||
TABLE_HEADERS()
|
||||
NEXT_COLUMN()
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
TAB_BAR("##GfxTabBar")
|
||||
TAB_ITEM("File Import")
|
||||
RETURN_IF_ERROR(DrawFileImport())
|
||||
END_TAB_ITEM()
|
||||
TAB_ITEM("Clipboard Import")
|
||||
RETURN_IF_ERROR(DrawClipboardImport())
|
||||
END_TAB_ITEM()
|
||||
END_TAB_BAR()
|
||||
ImGui::Text("Graphics");
|
||||
ImGui::Separator();
|
||||
RETURN_IF_ERROR(DrawDecompressedData())
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
NEXT_COLUMN()
|
||||
RETURN_IF_ERROR(DrawMemoryEditor())
|
||||
END_TABLE()
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::DrawImport() {
|
||||
absl::Status GraphicsEditor::DrawFileImport() {
|
||||
static int size = 0;
|
||||
static char filePath[256] = "";
|
||||
static bool open = false;
|
||||
|
||||
ImGui::SetNextItemWidth(350.f);
|
||||
ImGui::InputText("File", filePath, sizeof(filePath));
|
||||
|
||||
ImGui::InputText("File", file_path_, sizeof(file_path_));
|
||||
ImGui::SameLine();
|
||||
// Open the file dialog when the user clicks the "Browse" button
|
||||
if (ImGui::Button("Browse")) {
|
||||
ImGuiFileDialog::Instance()->OpenDialog("ImportDlgKey", "Choose File",
|
||||
@@ -52,35 +58,33 @@ absl::Status GraphicsEditor::DrawImport() {
|
||||
|
||||
// Draw the file dialog
|
||||
if (ImGuiFileDialog::Instance()->Display("ImportDlgKey")) {
|
||||
// If the user made a selection, copy the filename to the filePath buffer
|
||||
// If the user made a selection, copy the filename to the file_path_ buffer
|
||||
if (ImGuiFileDialog::Instance()->IsOk()) {
|
||||
strncpy(filePath, ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||
sizeof(filePath));
|
||||
RETURN_IF_ERROR(temp_rom_.LoadFromFile(filePath))
|
||||
open = true;
|
||||
strncpy(file_path_,
|
||||
ImGuiFileDialog::Instance()->GetFilePathName().c_str(),
|
||||
sizeof(file_path_));
|
||||
RETURN_IF_ERROR(temp_rom_.LoadFromFile(file_path_))
|
||||
is_open_ = true;
|
||||
}
|
||||
|
||||
// Close the modal
|
||||
ImGuiFileDialog::Instance()->Close();
|
||||
}
|
||||
|
||||
if (open) {
|
||||
static MemoryEditor mem_edit;
|
||||
mem_edit.DrawWindow(filePath, (void *)&temp_rom_, temp_rom_.size());
|
||||
}
|
||||
|
||||
gui::InputHex("Offset", ¤t_offset_);
|
||||
gui::InputHex("Size ", &size);
|
||||
gui::InputHex("Palette ", ¤t_palette_);
|
||||
|
||||
if (ImGui::Button("Super Donkey")) {
|
||||
if (ImGui::Button("Super Donkey Offsets")) {
|
||||
current_offset_ = 0x98219;
|
||||
size = 0x30000;
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Import")) {
|
||||
if (strlen(filePath) > 0) {
|
||||
// Add your importing code here, using filePath and offset as parameters
|
||||
if (strlen(file_path_) > 0) {
|
||||
// Add your importing code here, using file_path_ and offset as parameters
|
||||
RETURN_IF_ERROR(DecompressImportData(size))
|
||||
} else {
|
||||
// Show an error message if no file has been selected
|
||||
@@ -88,6 +92,32 @@ absl::Status GraphicsEditor::DrawImport() {
|
||||
}
|
||||
}
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::DrawClipboardImport() {
|
||||
static Bytes clipboard_data;
|
||||
|
||||
if (!is_open_) {
|
||||
clipboard_data.resize(0x1000);
|
||||
for (int i = 0; i < 0x1000; i++) clipboard_data.push_back(0x00);
|
||||
RETURN_IF_ERROR(temp_rom_.LoadFromBytes(clipboard_data))
|
||||
is_open_ = true;
|
||||
}
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::DrawMemoryEditor() {
|
||||
std::string title = "Memory Editor";
|
||||
if (is_open_) {
|
||||
static MemoryEditor mem_edit;
|
||||
mem_edit.DrawWindow(title.data(), (void *)&temp_rom_, temp_rom_.size());
|
||||
}
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::DrawDecompressedData() {
|
||||
if (ImGuiID child_id = ImGui::GetID((void *)(intptr_t)2);
|
||||
ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
||||
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
||||
@@ -99,17 +129,16 @@ absl::Status GraphicsEditor::DrawImport() {
|
||||
import_canvas_.DrawOverlay();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::DecompressImportData(int size) {
|
||||
ASSIGN_OR_RETURN(import_data_, temp_rom_.Decompress(current_offset_, size))
|
||||
std::cout << "Size of import data" << import_data_.size() << std::endl;
|
||||
std::cout << "Size of import data " << import_data_.size() << std::endl;
|
||||
|
||||
Bytes new_sheet;
|
||||
bitmap_.Create(core::kTilesheetWidth, 0x2000, core::kTilesheetDepth,
|
||||
import_data_.data(), 0x1000);
|
||||
import_data_.data(), size);
|
||||
|
||||
if (rom_.isLoaded()) {
|
||||
auto palette_group = rom_.GetPaletteGroup("ow_main");
|
||||
|
||||
Reference in New Issue
Block a user