Add EditorContext, refactor utils, add system managers
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "app/editor/editor.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
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
|
||||
// ImGui window with a list of the available key commands which can be used.
|
||||
void CommandManager::ShowWhichKey(EditorLayoutParams *editor_layout) {
|
||||
if (commands_.empty()) {
|
||||
InitializeDefaults();
|
||||
}
|
||||
|
||||
void CommandManager::ShowWhichKey() {
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_Space)) {
|
||||
ImGui::OpenPopup("WhichKey");
|
||||
}
|
||||
@@ -117,20 +112,8 @@ void CommandManager::ShowWhichKey(EditorLayoutParams *editor_layout) {
|
||||
}
|
||||
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) {
|
||||
std::ofstream out(filepath);
|
||||
if (out.is_open()) {
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "app/editor/editor.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
namespace yaze {
|
||||
@@ -65,9 +64,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void ShowWhichKey(EditorLayoutParams *editor_layout = nullptr);
|
||||
|
||||
void InitializeDefaults();
|
||||
void ShowWhichKey();
|
||||
|
||||
void SaveKeybindings(const std::string &filepath);
|
||||
void LoadKeybindings(const std::string &filepath);
|
||||
|
||||
@@ -2,19 +2,7 @@
|
||||
#define YAZE_APP_EDITOR_SYSTEM_CONSTANT_MANAGER_H
|
||||
|
||||
#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 "imgui/imgui.h"
|
||||
|
||||
@@ -86,4 +74,4 @@ class ConstantManager {
|
||||
} // namespace app
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_APP_EDITOR_SYSTEM_CONSTANT_MANAGER_H
|
||||
#endif // YAZE_APP_EDITOR_SYSTEM_CONSTANT_MANAGER_H
|
||||
|
||||
64
src/app/editor/system/flags.h
Normal file
64
src/app/editor/system/flags.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifndef YAZE_APP_EDITOR_UTILS_FLAGS_H
|
||||
#define YAZE_APP_EDITOR_UTILS_FLAGS_H
|
||||
|
||||
#include "core/common.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
namespace editor {
|
||||
|
||||
using ImGui::BeginMenu;
|
||||
using ImGui::Checkbox;
|
||||
using ImGui::EndMenu;
|
||||
using ImGui::MenuItem;
|
||||
using ImGui::Separator;
|
||||
|
||||
struct FlagsMenu : public core::ExperimentFlags {
|
||||
void Draw() {
|
||||
if (BeginMenu("Overworld Flags")) {
|
||||
Checkbox("Enable Overworld Sprites",
|
||||
&mutable_flags()->overworld.kDrawOverworldSprites);
|
||||
Separator();
|
||||
Checkbox("Save Overworld Maps",
|
||||
&mutable_flags()->overworld.kSaveOverworldMaps);
|
||||
Checkbox("Save Overworld Entrances",
|
||||
&mutable_flags()->overworld.kSaveOverworldEntrances);
|
||||
Checkbox("Save Overworld Exits",
|
||||
&mutable_flags()->overworld.kSaveOverworldExits);
|
||||
Checkbox("Save Overworld Items",
|
||||
&mutable_flags()->overworld.kSaveOverworldItems);
|
||||
Checkbox("Save Overworld Properties",
|
||||
&mutable_flags()->overworld.kSaveOverworldProperties);
|
||||
Checkbox("Load Custom Overworld",
|
||||
&mutable_flags()->overworld.kLoadCustomOverworld);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (BeginMenu("Dungeon Flags")) {
|
||||
Checkbox("Draw Dungeon Room Graphics",
|
||||
&mutable_flags()->kDrawDungeonRoomGraphics);
|
||||
Separator();
|
||||
Checkbox("Save Dungeon Maps", &mutable_flags()->kSaveDungeonMaps);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
Checkbox("Use built-in file dialog",
|
||||
&mutable_flags()->kNewFileDialogWrapper);
|
||||
Checkbox("Enable Console Logging", &mutable_flags()->kLogToConsole);
|
||||
Checkbox("Enable Texture Streaming",
|
||||
&mutable_flags()->kLoadTexturesAsStreaming);
|
||||
Checkbox("Log Instructions to Debugger",
|
||||
&mutable_flags()->kLogInstructions);
|
||||
Checkbox("Save All Palettes", &mutable_flags()->kSaveAllPalettes);
|
||||
Checkbox("Save Gfx Groups", &mutable_flags()->kSaveGfxGroups);
|
||||
Checkbox("Save Graphics Sheets", &mutable_flags()->kSaveGraphicsSheet);
|
||||
Checkbox("Use New ImGui Input", &mutable_flags()->kUseNewImGuiInput);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace editor
|
||||
} // namespace app
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_APP_EDITOR_UTILS_FLAGS_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 "absl/status/status.h"
|
||||
#include "app/editor/utils/flags.h"
|
||||
#include "app/editor/system/flags.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
namespace yaze {
|
||||
|
||||
Reference in New Issue
Block a user