refactor: Enhance Assembly Editor with Language Definition and Toolset Integration
- Introduced a new language definition for the 65816 assembly language, improving syntax highlighting and code editing capabilities. - Updated the AssemblyEditor to utilize the new language definition and integrated a toolset for file management actions, enhancing user experience. - Refactored the file handling logic to support dynamic file opening and saving, ensuring better resource management within the editor. - Removed deprecated tab view code, transitioning to a more modular card-based layout for active files, improving UI responsiveness and organization.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "gui/ui_helpers.h"
|
||||
#include "util/file_util.h"
|
||||
#include "app/core/window.h"
|
||||
#include "app/gfx/arena.h"
|
||||
@@ -47,25 +48,63 @@ void GraphicsEditor::Initialize() {}
|
||||
absl::Status GraphicsEditor::Load() { return absl::OkStatus(); }
|
||||
|
||||
absl::Status GraphicsEditor::Update() {
|
||||
if (ImGui::BeginTabBar("##TabBar")) {
|
||||
DrawToolset();
|
||||
gui::VerticalSpacing(2.0f);
|
||||
|
||||
static gui::EditorCard sheet_editor_card("Sheet Editor", ICON_MD_EDIT);
|
||||
static gui::EditorCard sheet_browser_card("Sheet Browser", ICON_MD_VIEW_LIST);
|
||||
static gui::EditorCard player_anims_card("Player Animations", ICON_MD_PERSON);
|
||||
static gui::EditorCard prototype_card("Prototype Viewer", ICON_MD_CONSTRUCTION);
|
||||
|
||||
if (show_sheet_editor_ && sheet_editor_card.Begin(&show_sheet_editor_)) {
|
||||
status_ = UpdateGfxEdit();
|
||||
if (ImGui::BeginTabItem("Sheet Browser")) {
|
||||
if (asset_browser_.Initialized == false) {
|
||||
asset_browser_.Initialize(gfx::Arena::Get().gfx_sheets());
|
||||
}
|
||||
asset_browser_.Draw(gfx::Arena::Get().gfx_sheets());
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
status_ = UpdateScadView();
|
||||
status_ = UpdateLinkGfxView();
|
||||
ImGui::EndTabBar();
|
||||
sheet_editor_card.End();
|
||||
}
|
||||
|
||||
if (show_sheet_browser_ && sheet_browser_card.Begin(&show_sheet_browser_)) {
|
||||
if (asset_browser_.Initialized == false) {
|
||||
asset_browser_.Initialize(gfx::Arena::Get().gfx_sheets());
|
||||
}
|
||||
asset_browser_.Draw(gfx::Arena::Get().gfx_sheets());
|
||||
sheet_browser_card.End();
|
||||
}
|
||||
|
||||
if (show_player_animations_ && player_anims_card.Begin(&show_player_animations_)) {
|
||||
status_ = UpdateLinkGfxView();
|
||||
player_anims_card.End();
|
||||
}
|
||||
|
||||
if (show_prototype_viewer_ && prototype_card.Begin(&show_prototype_viewer_)) {
|
||||
status_ = UpdateScadView();
|
||||
prototype_card.End();
|
||||
}
|
||||
|
||||
CLEAR_AND_RETURN_STATUS(status_)
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
void GraphicsEditor::DrawToolset() {
|
||||
static gui::Toolset toolbar;
|
||||
toolbar.Begin();
|
||||
|
||||
if (toolbar.AddAction(ICON_MD_EDIT, "Sheet Editor")) {
|
||||
show_sheet_editor_ = !show_sheet_editor_;
|
||||
}
|
||||
if (toolbar.AddAction(ICON_MD_VIEW_LIST, "Sheet Browser")) {
|
||||
show_sheet_browser_ = !show_sheet_browser_;
|
||||
}
|
||||
if (toolbar.AddAction(ICON_MD_PERSON, "Player Animations")) {
|
||||
show_player_animations_ = !show_player_animations_;
|
||||
}
|
||||
if (toolbar.AddAction(ICON_MD_CONSTRUCTION, "Prototype Viewer")) {
|
||||
show_prototype_viewer_ = !show_prototype_viewer_;
|
||||
}
|
||||
|
||||
toolbar.End();
|
||||
}
|
||||
|
||||
|
||||
absl::Status GraphicsEditor::UpdateGfxEdit() {
|
||||
if (ImGui::BeginTabItem("Sheet Editor")) {
|
||||
if (ImGui::BeginTable("##GfxEditTable", 3, kGfxEditTableFlags,
|
||||
ImVec2(0, 0))) {
|
||||
for (const auto& name :
|
||||
@@ -89,8 +128,6 @@ absl::Status GraphicsEditor::UpdateGfxEdit() {
|
||||
}
|
||||
ImGui::EndTable();
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
@@ -405,8 +442,6 @@ absl::Status GraphicsEditor::UpdatePaletteColumn() {
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::UpdateLinkGfxView() {
|
||||
TAB_ITEM("Player Animations")
|
||||
|
||||
if (ImGui::BeginTable("##PlayerAnimationTable", 3, kGfxEditTableFlags,
|
||||
ImVec2(0, 0))) {
|
||||
for (const auto& name : {"Canvas", "Animation Steps", "Properties"})
|
||||
@@ -448,14 +483,11 @@ absl::Status GraphicsEditor::UpdateLinkGfxView() {
|
||||
}
|
||||
ImGui::EndTable();
|
||||
|
||||
END_TAB_ITEM()
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::UpdateScadView() {
|
||||
TAB_ITEM("Prototype")
|
||||
|
||||
RETURN_IF_ERROR(DrawToolset())
|
||||
DrawToolset();
|
||||
|
||||
if (open_memory_editor_) {
|
||||
ImGui::Begin("Memory Editor", &open_memory_editor_);
|
||||
@@ -513,31 +545,6 @@ absl::Status GraphicsEditor::UpdateScadView() {
|
||||
}
|
||||
END_TABLE()
|
||||
|
||||
END_TAB_ITEM()
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status GraphicsEditor::DrawToolset() {
|
||||
static constexpr absl::string_view kGfxToolsetColumnNames[] = {
|
||||
"#memoryEditor",
|
||||
};
|
||||
|
||||
if (ImGui::BeginTable("GraphicsToolset", 1, ImGuiTableFlags_SizingFixedFit,
|
||||
ImVec2(0, 0))) {
|
||||
for (const auto& name : kGfxToolsetColumnNames)
|
||||
ImGui::TableSetupColumn(name.data());
|
||||
|
||||
TableNextColumn();
|
||||
if (Button(absl::StrCat(ICON_MD_MEMORY, "Open Memory Editor").c_str())) {
|
||||
if (!open_memory_editor_) {
|
||||
open_memory_editor_ = true;
|
||||
} else {
|
||||
open_memory_editor_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/editor_layout.h"
|
||||
#include "app/gui/modules/asset_browser.h"
|
||||
#include "app/rom.h"
|
||||
#include "app/zelda3/overworld/overworld.h"
|
||||
@@ -105,7 +106,7 @@ class GraphicsEditor : public Editor {
|
||||
absl::Status DrawTilemapImport();
|
||||
|
||||
// Other Functions
|
||||
absl::Status DrawToolset();
|
||||
void DrawToolset();
|
||||
absl::Status DrawPaletteControls();
|
||||
absl::Status DrawClipboardImport();
|
||||
absl::Status DrawExperimentalFeatures();
|
||||
@@ -115,6 +116,12 @@ class GraphicsEditor : public Editor {
|
||||
absl::Status DecompressSuperDonkey();
|
||||
|
||||
// Member Variables
|
||||
// Card visibility
|
||||
bool show_sheet_editor_ = true;
|
||||
bool show_sheet_browser_ = false;
|
||||
bool show_player_animations_ = false;
|
||||
bool show_prototype_viewer_ = false;
|
||||
|
||||
ImVec4 current_color_;
|
||||
uint16_t current_sheet_ = 0;
|
||||
uint8_t tile_size_ = 0x01;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "app/gui/color.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "app/gui/input.h"
|
||||
#include "app/gui/ui_helpers.h"
|
||||
#include "imgui/imgui.h"
|
||||
#include "util/hex.h"
|
||||
#include "util/macro.h"
|
||||
@@ -64,22 +65,63 @@ absl::Status ScreenEditor::Load() {
|
||||
}
|
||||
|
||||
absl::Status ScreenEditor::Update() {
|
||||
if (ImGui::BeginTabBar("##ScreenEditorTabBar")) {
|
||||
if (ImGui::BeginTabItem("Dungeon Maps")) {
|
||||
DrawDungeonMapsEditor();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
DrawInventoryMenuEditor();
|
||||
DrawOverworldMapEditor();
|
||||
DrawTitleScreenEditor();
|
||||
DrawNamingScreenEditor();
|
||||
ImGui::EndTabBar();
|
||||
DrawToolset();
|
||||
gui::VerticalSpacing(2.0f);
|
||||
|
||||
static gui::EditorCard dungeon_maps_card("Dungeon Maps", ICON_MD_MAP);
|
||||
static gui::EditorCard inventory_menu_card("Inventory Menu", ICON_MD_INVENTORY);
|
||||
static gui::EditorCard overworld_map_card("Overworld Map", ICON_MD_PUBLIC);
|
||||
static gui::EditorCard title_screen_card("Title Screen", ICON_MD_TITLE);
|
||||
static gui::EditorCard naming_screen_card("Naming Screen", ICON_MD_EDIT_ATTRIBUTES);
|
||||
|
||||
if (show_dungeon_maps_ && dungeon_maps_card.Begin(&show_dungeon_maps_)) {
|
||||
DrawDungeonMapsEditor();
|
||||
dungeon_maps_card.End();
|
||||
}
|
||||
if (show_inventory_menu_ && inventory_menu_card.Begin(&show_inventory_menu_)) {
|
||||
DrawInventoryMenuEditor();
|
||||
inventory_menu_card.End();
|
||||
}
|
||||
if (show_overworld_map_ && overworld_map_card.Begin(&show_overworld_map_)) {
|
||||
DrawOverworldMapEditor();
|
||||
overworld_map_card.End();
|
||||
}
|
||||
if (show_title_screen_ && title_screen_card.Begin(&show_title_screen_)) {
|
||||
DrawTitleScreenEditor();
|
||||
title_screen_card.End();
|
||||
}
|
||||
if (show_naming_screen_ && naming_screen_card.Begin(&show_naming_screen_)) {
|
||||
DrawNamingScreenEditor();
|
||||
naming_screen_card.End();
|
||||
}
|
||||
|
||||
return status_;
|
||||
}
|
||||
|
||||
void ScreenEditor::DrawToolset() {
|
||||
static gui::Toolset toolbar;
|
||||
toolbar.Begin();
|
||||
|
||||
if (toolbar.AddAction(ICON_MD_MAP, "Dungeon Maps")) {
|
||||
show_dungeon_maps_ = !show_dungeon_maps_;
|
||||
}
|
||||
if (toolbar.AddAction(ICON_MD_INVENTORY, "Inventory Menu")) {
|
||||
show_inventory_menu_ = !show_inventory_menu_;
|
||||
}
|
||||
if (toolbar.AddAction(ICON_MD_PUBLIC, "Overworld Map")) {
|
||||
show_overworld_map_ = !show_overworld_map_;
|
||||
}
|
||||
if (toolbar.AddAction(ICON_MD_TITLE, "Title Screen")) {
|
||||
show_title_screen_ = !show_title_screen_;
|
||||
}
|
||||
if (toolbar.AddAction(ICON_MD_EDIT_ATTRIBUTES, "Naming Screen")) {
|
||||
show_naming_screen_ = !show_naming_screen_;
|
||||
}
|
||||
|
||||
toolbar.End();
|
||||
}
|
||||
|
||||
void ScreenEditor::DrawInventoryMenuEditor() {
|
||||
if (ImGui::BeginTabItem("Inventory Menu")) {
|
||||
static bool create = false;
|
||||
if (!create && rom()->is_loaded()) {
|
||||
status_ = inventory_.Create();
|
||||
@@ -91,7 +133,7 @@ void ScreenEditor::DrawInventoryMenuEditor() {
|
||||
|
||||
if (ImGui::BeginTable("InventoryScreen", 3, ImGuiTableFlags_Resizable)) {
|
||||
ImGui::TableSetupColumn("Canvas");
|
||||
ImGui::TableSetupColumn("Tiles");
|
||||
ImGui::TableSetupColumn("Tilesheet");
|
||||
ImGui::TableSetupColumn("Palette");
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
@@ -115,8 +157,6 @@ void ScreenEditor::DrawInventoryMenuEditor() {
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::Separator();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenEditor::DrawInventoryToolset() {
|
||||
@@ -504,24 +544,15 @@ void ScreenEditor::LoadBinaryGfx() {
|
||||
}
|
||||
|
||||
void ScreenEditor::DrawTitleScreenEditor() {
|
||||
if (ImGui::BeginTabItem("Title Screen")) {
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenEditor::DrawNamingScreenEditor() {
|
||||
if (ImGui::BeginTabItem("Naming Screen")) {
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenEditor::DrawOverworldMapEditor() {
|
||||
if (ImGui::BeginTabItem("Overworld Map")) {
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenEditor::DrawToolset() {
|
||||
void ScreenEditor::DrawDungeonMapToolset() {
|
||||
static bool show_bg1 = true;
|
||||
static bool show_bg2 = true;
|
||||
static bool show_bg3 = true;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "app/rom.h"
|
||||
#include "app/zelda3/screen/dungeon_map.h"
|
||||
#include "app/zelda3/screen/inventory.h"
|
||||
#include "app/gui/editor_layout.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
namespace yaze {
|
||||
@@ -58,6 +59,7 @@ class ScreenEditor : public Editor {
|
||||
|
||||
void DrawInventoryMenuEditor();
|
||||
void DrawToolset();
|
||||
void DrawDungeonMapToolset();
|
||||
void DrawInventoryToolset();
|
||||
|
||||
absl::Status LoadDungeonMapTile16(const std::vector<uint8_t>& gfx_data,
|
||||
@@ -75,6 +77,13 @@ class ScreenEditor : public Editor {
|
||||
|
||||
EditingMode current_mode_ = EditingMode::DRAW;
|
||||
|
||||
// Card visibility
|
||||
bool show_dungeon_maps_ = true;
|
||||
bool show_inventory_menu_ = false;
|
||||
bool show_overworld_map_ = false;
|
||||
bool show_title_screen_ = false;
|
||||
bool show_naming_screen_ = false;
|
||||
|
||||
bool binary_gfx_loaded_ = false;
|
||||
|
||||
uint8_t selected_room = 0;
|
||||
|
||||
Reference in New Issue
Block a user