Add EditorContext, refactor utils, add system managers
This commit is contained in:
@@ -8,14 +8,13 @@
|
|||||||
#include "app/editor/code/assembly_editor.h"
|
#include "app/editor/code/assembly_editor.h"
|
||||||
#include "app/editor/code/memory_editor.h"
|
#include "app/editor/code/memory_editor.h"
|
||||||
#include "app/editor/dungeon/dungeon_editor.h"
|
#include "app/editor/dungeon/dungeon_editor.h"
|
||||||
|
#include "app/editor/editor.h"
|
||||||
#include "app/editor/graphics/graphics_editor.h"
|
#include "app/editor/graphics/graphics_editor.h"
|
||||||
#include "app/editor/graphics/palette_editor.h"
|
#include "app/editor/graphics/palette_editor.h"
|
||||||
#include "app/editor/graphics/screen_editor.h"
|
#include "app/editor/graphics/screen_editor.h"
|
||||||
#include "app/editor/music/music_editor.h"
|
#include "app/editor/music/music_editor.h"
|
||||||
#include "app/editor/overworld/overworld_editor.h"
|
#include "app/editor/overworld/overworld_editor.h"
|
||||||
#include "app/editor/sprite/sprite_editor.h"
|
#include "app/editor/sprite/sprite_editor.h"
|
||||||
#include "app/editor/editor.h"
|
|
||||||
#include "app/editor/utils/gfx_context.h"
|
|
||||||
#include "app/emu/emulator.h"
|
#include "app/emu/emulator.h"
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ set(
|
|||||||
app/editor/graphics/palette_editor.cc
|
app/editor/graphics/palette_editor.cc
|
||||||
app/editor/graphics/tile16_editor.cc
|
app/editor/graphics/tile16_editor.cc
|
||||||
app/editor/graphics/gfx_group_editor.cc
|
app/editor/graphics/gfx_group_editor.cc
|
||||||
app/editor/utils/gfx_context.cc
|
|
||||||
app/editor/overworld/entity.cc
|
app/editor/overworld/entity.cc
|
||||||
app/editor/system/settings_editor.cc
|
app/editor/system/settings_editor.cc
|
||||||
app/editor/system/command_manager.cc
|
app/editor/system/command_manager.cc
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
#ifndef YAZE_APP_CORE_EDITOR_H
|
#ifndef YAZE_APP_CORE_EDITOR_H
|
||||||
#define YAZE_APP_CORE_EDITOR_H
|
#define YAZE_APP_CORE_EDITOR_H
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
|
#include "app/editor/system/command_manager.h"
|
||||||
|
#include "app/editor/system/constant_manager.h"
|
||||||
|
#include "app/editor/system/extension_manager.h"
|
||||||
|
#include "app/editor/system/history_manager.h"
|
||||||
|
#include "app/editor/system/resource_manager.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
@@ -12,6 +19,14 @@ namespace app {
|
|||||||
*/
|
*/
|
||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
|
struct EditorContext {
|
||||||
|
static ConstantManager constant_manager;
|
||||||
|
static CommandManager command_manager;
|
||||||
|
static ExtensionManager extension_manager;
|
||||||
|
static HistoryManager history_manager;
|
||||||
|
static ResourceManager resource_manager;
|
||||||
|
};
|
||||||
|
|
||||||
enum class EditorType {
|
enum class EditorType {
|
||||||
kAssembly,
|
kAssembly,
|
||||||
kDungeon,
|
kDungeon,
|
||||||
@@ -25,7 +40,7 @@ enum class EditorType {
|
|||||||
kSettings,
|
kSettings,
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr std::array<const char*, 10> kEditorNames = {
|
constexpr std::array<const char *, 10> kEditorNames = {
|
||||||
"Assembly", "Dungeon", "Graphics", "Music", "Overworld",
|
"Assembly", "Dungeon", "Graphics", "Music", "Overworld",
|
||||||
"Palette", "Screen", "Sprite", "Message", "Settings",
|
"Palette", "Screen", "Sprite", "Message", "Settings",
|
||||||
};
|
};
|
||||||
@@ -37,7 +52,7 @@ constexpr std::array<const char*, 10> kEditorNames = {
|
|||||||
* Provides basic editing operations that each editor should implement.
|
* Provides basic editing operations that each editor should implement.
|
||||||
*/
|
*/
|
||||||
class Editor {
|
class Editor {
|
||||||
public:
|
public:
|
||||||
Editor() = default;
|
Editor() = default;
|
||||||
virtual ~Editor() = default;
|
virtual ~Editor() = default;
|
||||||
|
|
||||||
@@ -54,8 +69,9 @@ class Editor {
|
|||||||
|
|
||||||
EditorType type() const { return type_; }
|
EditorType type() const { return type_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EditorType type_;
|
EditorType type_;
|
||||||
|
EditorContext context_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,8 +98,8 @@ typedef struct EditorLayoutParams {
|
|||||||
|
|
||||||
absl::Status DrawEditor(EditorLayoutParams *params);
|
absl::Status DrawEditor(EditorLayoutParams *params);
|
||||||
|
|
||||||
} // namespace editor
|
} // namespace editor
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|
||||||
#endif // YAZE_APP_CORE_EDITOR_H
|
#endif // YAZE_APP_CORE_EDITOR_H
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include "app/editor/music/music_editor.h"
|
#include "app/editor/music/music_editor.h"
|
||||||
#include "app/editor/overworld/overworld_editor.h"
|
#include "app/editor/overworld/overworld_editor.h"
|
||||||
#include "app/editor/sprite/sprite_editor.h"
|
#include "app/editor/sprite/sprite_editor.h"
|
||||||
#include "app/editor/utils/flags.h"
|
#include "app/editor/system/flags.h"
|
||||||
#include "app/emu/emulator.h"
|
#include "app/emu/emulator.h"
|
||||||
#include "app/gui/icons.h"
|
#include "app/gui/icons.h"
|
||||||
#include "app/gui/input.h"
|
#include "app/gui/input.h"
|
||||||
@@ -54,6 +54,7 @@ void EditorManager::SetupScreen(std::string filename) {
|
|||||||
PRINT_IF_ERROR(rom()->LoadFromFile(filename));
|
PRINT_IF_ERROR(rom()->LoadFromFile(filename));
|
||||||
}
|
}
|
||||||
overworld_editor_.InitializeZeml();
|
overworld_editor_.InitializeZeml();
|
||||||
|
InitializeCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
absl::Status EditorManager::Update() {
|
absl::Status EditorManager::Update() {
|
||||||
@@ -246,14 +247,13 @@ void EditorManager::ManageActiveEditors() {
|
|||||||
absl::Status EditorManager::DrawDynamicLayout() {
|
absl::Status EditorManager::DrawDynamicLayout() {
|
||||||
// Dynamic layout for multiple editors to be open at once
|
// Dynamic layout for multiple editors to be open at once
|
||||||
// Allows for tiling and resizing of editors using ImGui
|
// Allows for tiling and resizing of editors using ImGui
|
||||||
|
|
||||||
return DrawEditor(&root_layout_);
|
return DrawEditor(&root_layout_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManager::ManageKeyboardShortcuts() {
|
void EditorManager::ManageKeyboardShortcuts() {
|
||||||
bool ctrl_or_super = (GetIO().KeyCtrl || GetIO().KeySuper);
|
bool ctrl_or_super = (GetIO().KeyCtrl || GetIO().KeySuper);
|
||||||
|
|
||||||
command_manager_.ShowWhichKey();
|
editor_context_.command_manager.ShowWhichKey();
|
||||||
|
|
||||||
// If CMD + R is pressed, reload the top result of recent files
|
// If CMD + R is pressed, reload the top result of recent files
|
||||||
if (IsKeyDown(ImGuiKey_R) && ctrl_or_super) {
|
if (IsKeyDown(ImGuiKey_R) && ctrl_or_super) {
|
||||||
@@ -313,7 +313,7 @@ void EditorManager::InitializeCommands() {
|
|||||||
if (root_layout_.editor == nullptr) {
|
if (root_layout_.editor == nullptr) {
|
||||||
root_layout_.editor = &overworld_editor_;
|
root_layout_.editor = &overworld_editor_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// New editor popup for window management commands
|
// New editor popup for window management commands
|
||||||
static EditorLayoutParams new_layout;
|
static EditorLayoutParams new_layout;
|
||||||
if (ImGui::BeginPopup("NewEditor")) {
|
if (ImGui::BeginPopup("NewEditor")) {
|
||||||
@@ -362,25 +362,26 @@ void EditorManager::InitializeCommands() {
|
|||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
command_manager_.RegisterPrefix("window", 'w', "window management", "");
|
editor_context_.command_manager.RegisterPrefix("window", 'w',
|
||||||
command_manager_.RegisterSubcommand(
|
"window management", "");
|
||||||
|
editor_context_.command_manager.RegisterSubcommand(
|
||||||
"window", "vsplit", '/', "vertical split",
|
"window", "vsplit", '/', "vertical split",
|
||||||
"split windows vertically and place editor in new window", [this]() {
|
"split windows vertically and place editor in new window", [this]() {
|
||||||
ImGui::OpenPopup("NewEditor");
|
ImGui::OpenPopup("NewEditor");
|
||||||
root_layout_.v_split = true;
|
root_layout_.v_split = true;
|
||||||
});
|
});
|
||||||
command_manager_.RegisterSubcommand(
|
editor_context_.command_manager.RegisterSubcommand(
|
||||||
"window", "hsplit", '-', "horizontal split",
|
"window", "hsplit", '-', "horizontal split",
|
||||||
"split windows horizontally and place editor in new window", [this]() {
|
"split windows horizontally and place editor in new window", [this]() {
|
||||||
ImGui::OpenPopup("NewEditor");
|
ImGui::OpenPopup("NewEditor");
|
||||||
root_layout_.h_split = true;
|
root_layout_.h_split = true;
|
||||||
});
|
});
|
||||||
command_manager_.RegisterSubcommand("window", "close", 'd', "close",
|
editor_context_.command_manager.RegisterSubcommand(
|
||||||
"close the current editor", [this]() {
|
"window", "close", 'd', "close", "close the current editor", [this]() {
|
||||||
if (root_layout_.editor != nullptr) {
|
if (root_layout_.editor != nullptr) {
|
||||||
root_layout_.editor = nullptr;
|
root_layout_.editor = nullptr;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManager::DrawStatusPopup() {
|
void EditorManager::DrawStatusPopup() {
|
||||||
|
|||||||
@@ -15,14 +15,10 @@
|
|||||||
#include "app/editor/music/music_editor.h"
|
#include "app/editor/music/music_editor.h"
|
||||||
#include "app/editor/overworld/overworld_editor.h"
|
#include "app/editor/overworld/overworld_editor.h"
|
||||||
#include "app/editor/sprite/sprite_editor.h"
|
#include "app/editor/sprite/sprite_editor.h"
|
||||||
#include "app/editor/system/command_manager.h"
|
|
||||||
#include "app/editor/system/constant_manager.h"
|
|
||||||
#include "app/editor/system/extension_manager.h"
|
|
||||||
#include "app/editor/system/settings_editor.h"
|
#include "app/editor/system/settings_editor.h"
|
||||||
#include "app/emu/emulator.h"
|
#include "app/emu/emulator.h"
|
||||||
#include "app/gui/input.h"
|
#include "app/gui/input.h"
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
#include "yaze.h"
|
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
@@ -33,18 +29,11 @@ namespace editor {
|
|||||||
* @brief The EditorManager controls the main editor window and manages the
|
* @brief The EditorManager controls the main editor window and manages the
|
||||||
* various editor classes.
|
* various editor classes.
|
||||||
*
|
*
|
||||||
* This class inherits from SharedRom and ExperimentFlags, and
|
|
||||||
* provides functionality for setting up the screen, updating the editor, and
|
|
||||||
* shutting down the editor. It also includes methods for drawing various menus
|
|
||||||
* and popups, saving the Rom, and managing editor-specific flags.
|
|
||||||
*
|
|
||||||
* The EditorManager class contains instances of various editor classes such as
|
* The EditorManager class contains instances of various editor classes such as
|
||||||
* AssemblyEditor, DungeonEditor, GraphicsEditor, MusicEditor, OverworldEditor,
|
* AssemblyEditor, DungeonEditor, GraphicsEditor, MusicEditor, OverworldEditor,
|
||||||
* PaletteEditor, ScreenEditor, and SpriteEditor. The current_editor_ member
|
* PaletteEditor, ScreenEditor, and SpriteEditor. The current_editor_ member
|
||||||
* variable points to the currently active editor in the tab view.
|
* variable points to the currently active editor in the tab view.
|
||||||
*
|
*
|
||||||
* @note This class assumes the presence of an SDL_Renderer object for rendering
|
|
||||||
* graphics.
|
|
||||||
*/
|
*/
|
||||||
class EditorManager : public SharedRom, public core::ExperimentFlags {
|
class EditorManager : public SharedRom, public core::ExperimentFlags {
|
||||||
public:
|
public:
|
||||||
@@ -101,13 +90,12 @@ class EditorManager : public SharedRom, public core::ExperimentFlags {
|
|||||||
std::vector<Editor *> active_editors_;
|
std::vector<Editor *> active_editors_;
|
||||||
std::vector<EditorLayoutParams> active_layouts_;
|
std::vector<EditorLayoutParams> active_layouts_;
|
||||||
|
|
||||||
|
EditorLayoutParams root_layout_;
|
||||||
|
|
||||||
Project current_project_;
|
Project current_project_;
|
||||||
CommandManager command_manager_;
|
EditorContext editor_context_;
|
||||||
ConstantManager constant_manager_;
|
|
||||||
ExtensionManager extension_manager_;
|
|
||||||
|
|
||||||
Editor *current_editor_ = nullptr;
|
Editor *current_editor_ = nullptr;
|
||||||
EditorLayoutParams root_layout_;
|
|
||||||
AssemblyEditor assembly_editor_;
|
AssemblyEditor assembly_editor_;
|
||||||
DungeonEditor dungeon_editor_;
|
DungeonEditor dungeon_editor_;
|
||||||
GraphicsEditor graphics_editor_;
|
GraphicsEditor graphics_editor_;
|
||||||
@@ -119,8 +107,6 @@ class EditorManager : public SharedRom, public core::ExperimentFlags {
|
|||||||
SettingsEditor settings_editor_;
|
SettingsEditor settings_editor_;
|
||||||
MessageEditor message_editor_;
|
MessageEditor message_editor_;
|
||||||
MemoryEditorWithDiffChecker memory_editor_;
|
MemoryEditorWithDiffChecker memory_editor_;
|
||||||
|
|
||||||
yaze_editor_context editor_context_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace editor
|
} // namespace editor
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
#include "app/gui/canvas.h"
|
#include "app/gui/canvas.h"
|
||||||
#include "app/gui/color.h"
|
#include "app/gui/color.h"
|
||||||
|
#include "app/gui/icons.h"
|
||||||
#include "app/gui/input.h"
|
#include "app/gui/input.h"
|
||||||
#include "app/gui/modules/asset_browser.h"
|
#include "app/gui/modules/asset_browser.h"
|
||||||
#include "app/gui/style.h"
|
#include "app/gui/style.h"
|
||||||
|
|||||||
@@ -398,6 +398,23 @@ void ScreenEditor::DrawDungeonMapsEditor() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui::BeginTable("##DungeonMapToolset", 2, ImGuiTableFlags_SizingFixedFit)) {
|
||||||
|
ImGui::TableSetupColumn("Draw Mode");
|
||||||
|
ImGui::TableSetupColumn("Edit Mode");
|
||||||
|
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
if (ImGui::Button(ICON_MD_DRAW)) {
|
||||||
|
current_mode_ = EditingMode::DRAW;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
if (ImGui::Button(ICON_MD_EDIT)) {
|
||||||
|
current_mode_ = EditingMode::EDIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
|
||||||
static std::vector<std::string> dungeon_names = {
|
static std::vector<std::string> dungeon_names = {
|
||||||
"Sewers/Sanctuary", "Hyrule Castle", "Eastern Palace",
|
"Sewers/Sanctuary", "Hyrule Castle", "Eastern Palace",
|
||||||
"Desert Palace", "Tower of Hera", "Agahnim's Tower",
|
"Desert Palace", "Tower of Hera", "Agahnim's Tower",
|
||||||
@@ -483,13 +500,20 @@ void ScreenEditor::DrawDungeonMapsEditor() {
|
|||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
tilemap_canvas_.DrawBackground(ImVec2(128 * 2 + 2, (192 * 2) + 4));
|
tilemap_canvas_.DrawBackground();
|
||||||
tilemap_canvas_.DrawContextMenu();
|
tilemap_canvas_.DrawContextMenu();
|
||||||
tilemap_canvas_.DrawTileSelector(8.f);
|
if (tilemap_canvas_.DrawTileSelector(16.f)) {
|
||||||
|
// Get the tile8 ID to use for the tile16 drawing above
|
||||||
|
selected_tile8_ = tilemap_canvas_.GetTileIdFromMousePos();
|
||||||
|
}
|
||||||
tilemap_canvas_.DrawBitmapTable(sheets_);
|
tilemap_canvas_.DrawBitmapTable(sheets_);
|
||||||
tilemap_canvas_.DrawGrid();
|
tilemap_canvas_.DrawGrid();
|
||||||
tilemap_canvas_.DrawOverlay();
|
tilemap_canvas_.DrawOverlay();
|
||||||
|
|
||||||
|
ImGui::Text("Selected tile8: %d", selected_tile8_);
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
ImGui::Text("For use with custom inserted graphics assembly patches.");
|
||||||
if (ImGui::Button("Load GFX from BIN file")) LoadBinaryGfx();
|
if (ImGui::Button("Load GFX from BIN file")) LoadBinaryGfx();
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "app/core/common.h"
|
#include "app/core/common.h"
|
||||||
#include "app/editor/graphics/palette_editor.h"
|
#include "app/editor/graphics/palette_editor.h"
|
||||||
#include "app/editor/utils/gfx_context.h"
|
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
@@ -20,7 +19,7 @@ namespace editor {
|
|||||||
/**
|
/**
|
||||||
* @brief Popup window to edit Tile16 data
|
* @brief Popup window to edit Tile16 data
|
||||||
*/
|
*/
|
||||||
class Tile16Editor : public context::GfxContext, public SharedRom {
|
class Tile16Editor : public GfxContext, public SharedRom {
|
||||||
public:
|
public:
|
||||||
absl::Status InitBlockset(const gfx::Bitmap& tile16_blockset_bmp,
|
absl::Status InitBlockset(const gfx::Bitmap& tile16_blockset_bmp,
|
||||||
const gfx::Bitmap& current_gfx_bmp,
|
const gfx::Bitmap& current_gfx_bmp,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "app/editor/overworld/entity.h"
|
#include "app/editor/overworld/entity.h"
|
||||||
|
|
||||||
|
#include "app/gui/icons.h"
|
||||||
#include "app/gui/input.h"
|
#include "app/gui/input.h"
|
||||||
#include "app/gui/style.h"
|
#include "app/gui/style.h"
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,11 @@
|
|||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/status/statusor.h"
|
#include "absl/status/statusor.h"
|
||||||
#include "absl/strings/str_format.h"
|
#include "absl/strings/str_format.h"
|
||||||
|
#include "app/editor/editor.h"
|
||||||
#include "app/editor/graphics/gfx_group_editor.h"
|
#include "app/editor/graphics/gfx_group_editor.h"
|
||||||
#include "app/editor/graphics/palette_editor.h"
|
#include "app/editor/graphics/palette_editor.h"
|
||||||
#include "app/editor/graphics/tile16_editor.h"
|
#include "app/editor/graphics/tile16_editor.h"
|
||||||
#include "app/editor/overworld/entity.h"
|
#include "app/editor/overworld/entity.h"
|
||||||
#include "app/editor/editor.h"
|
|
||||||
#include "app/editor/utils/gfx_context.h"
|
|
||||||
#include "app/gfx/bitmap.h"
|
#include "app/gfx/bitmap.h"
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
@@ -111,7 +110,7 @@ class EntranceContext {
|
|||||||
class OverworldEditor : public Editor,
|
class OverworldEditor : public Editor,
|
||||||
public SharedRom,
|
public SharedRom,
|
||||||
public EntranceContext,
|
public EntranceContext,
|
||||||
public context::GfxContext,
|
public GfxContext,
|
||||||
public core::ExperimentFlags {
|
public core::ExperimentFlags {
|
||||||
public:
|
public:
|
||||||
OverworldEditor() { type_ = EditorType::kOverworld; }
|
OverworldEditor() { type_ = EditorType::kOverworld; }
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include "app/editor/editor.h"
|
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
@@ -74,11 +73,7 @@ ImGuiKey MapKeyToImGuiKey(char key) {
|
|||||||
|
|
||||||
// When the player presses Space, a popup will appear fixed to the bottom of the
|
// When the player presses Space, a popup will appear fixed to the bottom of the
|
||||||
// ImGui window with a list of the available key commands which can be used.
|
// ImGui window with a list of the available key commands which can be used.
|
||||||
void CommandManager::ShowWhichKey(EditorLayoutParams *editor_layout) {
|
void CommandManager::ShowWhichKey() {
|
||||||
if (commands_.empty()) {
|
|
||||||
InitializeDefaults();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui::IsKeyPressed(ImGuiKey_Space)) {
|
if (ImGui::IsKeyPressed(ImGuiKey_Space)) {
|
||||||
ImGui::OpenPopup("WhichKey");
|
ImGui::OpenPopup("WhichKey");
|
||||||
}
|
}
|
||||||
@@ -117,20 +112,8 @@ void CommandManager::ShowWhichKey(EditorLayoutParams *editor_layout) {
|
|||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the user presses the shortcut key, execute the command
|
|
||||||
// or if it is a subcommand prefix, wait for the next key
|
|
||||||
// to determine the subcommand
|
|
||||||
static bool subcommand_section = false;
|
|
||||||
for (const auto &[shortcut, info] : commands_) {
|
|
||||||
if (ImGui::IsKeyPressed(MapKeyToImGuiKey(shortcut[0]))) {
|
|
||||||
info.command_info.command();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandManager::InitializeDefaults() {}
|
|
||||||
|
|
||||||
void CommandManager::SaveKeybindings(const std::string &filepath) {
|
void CommandManager::SaveKeybindings(const std::string &filepath) {
|
||||||
std::ofstream out(filepath);
|
std::ofstream out(filepath);
|
||||||
if (out.is_open()) {
|
if (out.is_open()) {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "app/editor/editor.h"
|
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
@@ -65,9 +64,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowWhichKey(EditorLayoutParams *editor_layout = nullptr);
|
void ShowWhichKey();
|
||||||
|
|
||||||
void InitializeDefaults();
|
|
||||||
|
|
||||||
void SaveKeybindings(const std::string &filepath);
|
void SaveKeybindings(const std::string &filepath);
|
||||||
void LoadKeybindings(const std::string &filepath);
|
void LoadKeybindings(const std::string &filepath);
|
||||||
|
|||||||
@@ -2,19 +2,7 @@
|
|||||||
#define YAZE_APP_EDITOR_SYSTEM_CONSTANT_MANAGER_H
|
#define YAZE_APP_EDITOR_SYSTEM_CONSTANT_MANAGER_H
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
|
||||||
#include <memory>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
|
||||||
#include "app/editor/utils/gfx_context.h"
|
|
||||||
#include "app/gfx/bitmap.h"
|
|
||||||
#include "app/gfx/snes_palette.h"
|
|
||||||
#include "app/gfx/snes_tile.h"
|
|
||||||
#include "app/rom.h"
|
|
||||||
#include "app/zelda3/common.h"
|
|
||||||
#include "app/zelda3/overworld/overworld.h"
|
|
||||||
#include "app/zelda3/overworld/overworld_map.h"
|
#include "app/zelda3/overworld/overworld_map.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
@@ -86,4 +74,4 @@ class ConstantManager {
|
|||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|
||||||
#endif // YAZE_APP_EDITOR_SYSTEM_CONSTANT_MANAGER_H
|
#endif // YAZE_APP_EDITOR_SYSTEM_CONSTANT_MANAGER_H
|
||||||
|
|||||||
32
src/app/editor/system/history_manager.h
Normal file
32
src/app/editor/system/history_manager.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef YAZE_APP_EDITOR_SYSTEM_HISTORY_MANAGER_H
|
||||||
|
#define YAZE_APP_EDITOR_SYSTEM_HISTORY_MANAGER_H
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <stack>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace yaze {
|
||||||
|
namespace app {
|
||||||
|
namespace editor {
|
||||||
|
|
||||||
|
// System history manager, undo and redo.
|
||||||
|
class HistoryManager {
|
||||||
|
public:
|
||||||
|
HistoryManager() = default;
|
||||||
|
~HistoryManager() = default;
|
||||||
|
|
||||||
|
void Add(const char* data);
|
||||||
|
void Undo();
|
||||||
|
void Redo();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<const char*> history_;
|
||||||
|
std::stack<const char*> undo_;
|
||||||
|
std::stack<const char*> redo_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace editor
|
||||||
|
} // namespace app
|
||||||
|
} // namespace yaze
|
||||||
|
|
||||||
|
#endif // YAZE_APP_EDITOR_SYSTEM_HISTORY_MANAGER_H
|
||||||
19
src/app/editor/system/popup_manager.cc
Normal file
19
src/app/editor/system/popup_manager.cc
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include "popup_manager.h"
|
||||||
|
|
||||||
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
|
namespace yaze {
|
||||||
|
namespace app {
|
||||||
|
namespace editor {
|
||||||
|
|
||||||
|
PopupManager::PopupManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
PopupManager::~PopupManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace editor
|
||||||
|
} // namespace app
|
||||||
|
} // namespace yaze
|
||||||
21
src/app/editor/system/popup_manager.h
Normal file
21
src/app/editor/system/popup_manager.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef YAZE_APP_EDITOR_POPUP_MANAGER_H
|
||||||
|
#define YAZE_APP_EDITOR_POPUP_MANAGER_H
|
||||||
|
|
||||||
|
namespace yaze {
|
||||||
|
namespace app {
|
||||||
|
namespace editor {
|
||||||
|
|
||||||
|
// ImGui popup manager.
|
||||||
|
class PopupManager {
|
||||||
|
public:
|
||||||
|
PopupManager();
|
||||||
|
~PopupManager();
|
||||||
|
|
||||||
|
void Show(const char* name);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace editor
|
||||||
|
} // namespace app
|
||||||
|
} // namespace yaze
|
||||||
|
|
||||||
|
#endif // YAZE_APP_EDITOR_POPUP_MANAGER_H
|
||||||
30
src/app/editor/system/resource_manager.h
Normal file
30
src/app/editor/system/resource_manager.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef YAZE_APP_EDITOR_SYSTEM_RESOURCE_MANAGER_H
|
||||||
|
#define YAZE_APP_EDITOR_SYSTEM_RESOURCE_MANAGER_H
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
namespace yaze {
|
||||||
|
namespace app {
|
||||||
|
namespace editor {
|
||||||
|
|
||||||
|
// System resource manager.
|
||||||
|
class ResourceManager {
|
||||||
|
public:
|
||||||
|
ResourceManager();
|
||||||
|
~ResourceManager();
|
||||||
|
|
||||||
|
void Load(const char* path);
|
||||||
|
void Unload(const char* path);
|
||||||
|
void UnloadAll();
|
||||||
|
|
||||||
|
size_t Count() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
size_t count_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace editor
|
||||||
|
} // namespace app
|
||||||
|
} // namespace yaze
|
||||||
|
|
||||||
|
#endif // YAZE_APP_EDITOR_SYSTEM_RESOURCE_MANAGER_H
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "app/editor/system/settings_editor.h"
|
#include "app/editor/system/settings_editor.h"
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "app/editor/utils/flags.h"
|
#include "app/editor/system/flags.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
#include "app/editor/utils/gfx_context.h"
|
|
||||||
|
|
||||||
#include "imgui/imgui.h"
|
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
#include "app/editor/graphics/palette_editor.h"
|
|
||||||
#include "app/editor/editor.h"
|
|
||||||
#include "app/gfx/bitmap.h"
|
|
||||||
#include "app/gfx/snes_palette.h"
|
|
||||||
#include "app/gfx/snes_tile.h"
|
|
||||||
#include "app/gui/canvas.h"
|
|
||||||
#include "app/gui/icons.h"
|
|
||||||
#include "app/rom.h"
|
|
||||||
|
|
||||||
namespace yaze {
|
|
||||||
namespace app {
|
|
||||||
namespace editor {
|
|
||||||
namespace context {
|
|
||||||
|
|
||||||
std::unordered_map<uint8_t, gfx::Paletteset> GfxContext::palettesets_;
|
|
||||||
|
|
||||||
}
|
|
||||||
} // namespace editor
|
|
||||||
} // namespace app
|
|
||||||
} // namespace yaze
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
#ifndef YAZE_APP_EDITOR_VRAM_CONTEXT_H
|
|
||||||
#define YAZE_APP_EDITOR_VRAM_CONTEXT_H
|
|
||||||
|
|
||||||
#include "imgui/imgui.h"
|
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "app/editor/editor.h"
|
|
||||||
#include "app/gfx/bitmap.h"
|
|
||||||
#include "app/gfx/snes_palette.h"
|
|
||||||
#include "app/gfx/snes_tile.h"
|
|
||||||
#include "app/gui/canvas.h"
|
|
||||||
#include "app/gui/icons.h"
|
|
||||||
#include "app/rom.h"
|
|
||||||
|
|
||||||
namespace yaze {
|
|
||||||
namespace app {
|
|
||||||
namespace editor {
|
|
||||||
namespace context {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Shared graphical context across editors.
|
|
||||||
*/
|
|
||||||
class GfxContext {
|
|
||||||
protected:
|
|
||||||
// Palettesets for the tile16 individual tiles
|
|
||||||
static std::unordered_map<uint8_t, gfx::Paletteset> palettesets_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace context
|
|
||||||
} // namespace editor
|
|
||||||
} // namespace app
|
|
||||||
} // namespace yaze
|
|
||||||
|
|
||||||
#endif // YAZE_APP_EDITOR_VRAM_CONTEXT_H
|
|
||||||
@@ -351,5 +351,6 @@ absl::Status LoadAllPalettes(const std::vector<uint8_t> &rom_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace gfx
|
} // namespace gfx
|
||||||
|
std::unordered_map<uint8_t, gfx::Paletteset> GfxContext::palettesets_;
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
@@ -405,7 +405,17 @@ struct Paletteset {
|
|||||||
gfx::SnesPalette composite; /**< The composite palette. */
|
gfx::SnesPalette composite; /**< The composite palette. */
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace gfx
|
} // namespace gfx
|
||||||
|
/**
|
||||||
|
* @brief Shared graphical context across editors.
|
||||||
|
*/
|
||||||
|
class GfxContext {
|
||||||
|
protected:
|
||||||
|
// Palettesets for the tile16 individual tiles
|
||||||
|
static std::unordered_map<uint8_t, gfx::Paletteset> palettesets_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,12 @@
|
|||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "app/editor/utils/gfx_context.h"
|
|
||||||
#include "app/gfx/bitmap.h"
|
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
#include "app/zelda3/overworld/overworld.h"
|
#include "app/zelda3/overworld/overworld.h"
|
||||||
#include "imgui/imgui.h"
|
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "app/editor/utils/gfx_context.h"
|
|
||||||
#include "app/gfx/snes_palette.h"
|
#include "app/gfx/snes_palette.h"
|
||||||
#include "app/gfx/snes_tile.h"
|
#include "app/gfx/snes_tile.h"
|
||||||
#include "app/rom.h"
|
#include "app/rom.h"
|
||||||
@@ -60,7 +59,7 @@ constexpr int OverworldCustomTileGFXGroupEnabled = 0x140148;
|
|||||||
/**
|
/**
|
||||||
* @brief Represents a single Overworld map screen.
|
* @brief Represents a single Overworld map screen.
|
||||||
*/
|
*/
|
||||||
class OverworldMap : public editor::context::GfxContext {
|
class OverworldMap : public GfxContext {
|
||||||
public:
|
public:
|
||||||
OverworldMap() = default;
|
OverworldMap() = default;
|
||||||
OverworldMap(int index, Rom& rom, bool load_custom_data = false);
|
OverworldMap(int index, Rom& rom, bool load_custom_data = false);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ add_executable(
|
|||||||
app/rom.cc
|
app/rom.cc
|
||||||
app/core/common.cc
|
app/core/common.cc
|
||||||
app/core/project.cc
|
app/core/project.cc
|
||||||
app/editor/utils/gfx_context.cc
|
|
||||||
app/core/platform/file_path.mm
|
app/core/platform/file_path.mm
|
||||||
${YAZE_APP_EMU_SRC}
|
${YAZE_APP_EMU_SRC}
|
||||||
${YAZE_APP_GFX_SRC}
|
${YAZE_APP_GFX_SRC}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ add_executable(
|
|||||||
test/zelda3/sprite_builder_test.cc
|
test/zelda3/sprite_builder_test.cc
|
||||||
app/rom.cc
|
app/rom.cc
|
||||||
app/core/common.cc
|
app/core/common.cc
|
||||||
app/editor/utils/gfx_context.cc
|
|
||||||
${ASAR_STATIC_SRC}
|
${ASAR_STATIC_SRC}
|
||||||
${YAZE_APP_CORE_SRC}
|
${YAZE_APP_CORE_SRC}
|
||||||
${YAZE_APP_EMU_SRC}
|
${YAZE_APP_EMU_SRC}
|
||||||
|
|||||||
Reference in New Issue
Block a user