Add "Load Last ROM" shortcut and streamline ROM asset loading in EditorManager
This commit is contained in:
@@ -39,7 +39,7 @@ struct Project {
|
|||||||
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
absl::Status Open(const std::string &project_path);
|
absl::Status Open(const std::string& project_path);
|
||||||
absl::Status Save();
|
absl::Status Save();
|
||||||
|
|
||||||
bool project_opened_ = false;
|
bool project_opened_ = false;
|
||||||
@@ -128,6 +128,14 @@ class RecentFilesManager {
|
|||||||
std::vector<std::string> recent_files_;
|
std::vector<std::string> recent_files_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class VersionControlManager {
|
||||||
|
absl::Status Commit(const std::string& message);
|
||||||
|
absl::Status Pull();
|
||||||
|
absl::Status Push();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string repository_path_;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|
||||||
|
|||||||
@@ -102,6 +102,15 @@ void EditorManager::Initialize(const std::string &filename) {
|
|||||||
"Find", {ImGuiKey_F, ImGuiMod_Ctrl},
|
"Find", {ImGuiKey_F, ImGuiMod_Ctrl},
|
||||||
[&]() { status_ = current_editor_->Find(); });
|
[&]() { status_ = current_editor_->Find(); });
|
||||||
|
|
||||||
|
context_.shortcut_manager.RegisterShortcut(
|
||||||
|
"Load Last ROM", {ImGuiKey_R, ImGuiMod_Ctrl}, [&]() {
|
||||||
|
manager.Load();
|
||||||
|
if (!manager.GetRecentFiles().empty()) {
|
||||||
|
auto front = manager.GetRecentFiles().front();
|
||||||
|
OpenRomOrProject(front);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
context_.shortcut_manager.RegisterShortcut("F1", ImGuiKey_F1,
|
context_.shortcut_manager.RegisterShortcut("F1", ImGuiKey_F1,
|
||||||
[&]() { about_ = true; });
|
[&]() { about_ = true; });
|
||||||
|
|
||||||
@@ -195,29 +204,10 @@ void EditorManager::Initialize(const std::string &filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
absl::Status EditorManager::Update() {
|
absl::Status EditorManager::Update() {
|
||||||
ExecuteShortcuts(context_.shortcut_manager);
|
|
||||||
context_.command_manager.ShowWhichKey();
|
|
||||||
|
|
||||||
// If CMD + R is pressed, reload the top result of recent files
|
|
||||||
if (IsKeyDown(ImGuiKey_R) && GetIO().KeyCtrl) {
|
|
||||||
static RecentFilesManager manager("recent_files.txt");
|
|
||||||
manager.Load();
|
|
||||||
if (!manager.GetRecentFiles().empty()) {
|
|
||||||
auto front = manager.GetRecentFiles().front();
|
|
||||||
OpenRomOrProject(front);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawMenuBar();
|
DrawMenuBar();
|
||||||
DrawPopups();
|
DrawPopups();
|
||||||
|
ExecuteShortcuts(context_.shortcut_manager);
|
||||||
if (rom()->is_loaded() && !rom_assets_loaded_) {
|
context_.command_manager.ShowWhichKey();
|
||||||
auto &sheet_manager = GraphicsSheetManager::GetInstance();
|
|
||||||
ASSIGN_OR_RETURN(*sheet_manager.mutable_gfx_sheets(),
|
|
||||||
LoadAllGraphicsData(*rom()))
|
|
||||||
RETURN_IF_ERROR(overworld_editor_.LoadGraphics());
|
|
||||||
rom_assets_loaded_ = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!current_rom_) {
|
if (!current_rom_) {
|
||||||
DrawHomepage();
|
DrawHomepage();
|
||||||
@@ -651,6 +641,16 @@ void EditorManager::LoadRom() {
|
|||||||
manager.Load();
|
manager.Load();
|
||||||
manager.AddFile(file_name);
|
manager.AddFile(file_name);
|
||||||
manager.Save();
|
manager.Save();
|
||||||
|
auto load_rom_assets = [&]() -> absl::Status {
|
||||||
|
auto &sheet_manager = GraphicsSheetManager::GetInstance();
|
||||||
|
ASSIGN_OR_RETURN(*sheet_manager.mutable_gfx_sheets(),
|
||||||
|
LoadAllGraphicsData(*rom()))
|
||||||
|
RETURN_IF_ERROR(overworld_editor_.LoadGraphics());
|
||||||
|
return absl::OkStatus();
|
||||||
|
};
|
||||||
|
if (!load_rom_assets().ok()) {
|
||||||
|
status_ = load_rom_assets();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,8 +75,12 @@ class EditorManager : public SharedRom {
|
|||||||
bool about_ = false;
|
bool about_ = false;
|
||||||
bool rom_info_ = false;
|
bool rom_info_ = false;
|
||||||
bool backup_rom_ = false;
|
bool backup_rom_ = false;
|
||||||
bool save_new_auto_ = true;
|
|
||||||
bool save_as_menu_ = false;
|
bool save_as_menu_ = false;
|
||||||
|
bool save_new_auto_ = true;
|
||||||
|
bool open_rom_help = false;
|
||||||
|
bool open_manage_project = false;
|
||||||
|
bool open_supported_features = false;
|
||||||
|
|
||||||
bool show_emulator_ = false;
|
bool show_emulator_ = false;
|
||||||
bool show_memory_editor_ = false;
|
bool show_memory_editor_ = false;
|
||||||
bool show_asm_editor_ = false;
|
bool show_asm_editor_ = false;
|
||||||
@@ -84,10 +88,6 @@ class EditorManager : public SharedRom {
|
|||||||
bool show_imgui_demo_ = false;
|
bool show_imgui_demo_ = false;
|
||||||
bool show_palette_editor_ = false;
|
bool show_palette_editor_ = false;
|
||||||
bool show_resource_label_manager = false;
|
bool show_resource_label_manager = false;
|
||||||
bool open_supported_features = false;
|
|
||||||
bool open_rom_help = false;
|
|
||||||
bool open_manage_project = false;
|
|
||||||
bool rom_assets_loaded_ = false;
|
|
||||||
|
|
||||||
std::string version_ = "";
|
std::string version_ = "";
|
||||||
|
|
||||||
|
|||||||
@@ -537,5 +537,4 @@ void Emulator::RenderCpuInstructionLog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace emu
|
} // namespace emu
|
||||||
|
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
Reference in New Issue
Block a user