From a9787b70555a1f5ccad4755f3e7aac92644f3882 Mon Sep 17 00:00:00 2001 From: scawful Date: Tue, 28 May 2024 13:04:39 -0400 Subject: [PATCH] add rom filename command line arg LoadFromFile --- src/app/core/controller.cc | 2 +- src/app/core/controller.h | 2 +- src/app/editor/master_editor.cc | 6 +++++- src/app/editor/master_editor.h | 3 ++- src/app/yaze.cc | 5 +++++ 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/app/core/controller.cc b/src/app/core/controller.cc index 1f08a429..54516e0f 100644 --- a/src/app/core/controller.cc +++ b/src/app/core/controller.cc @@ -190,7 +190,7 @@ void HandleMouseMovement(int &wheel) { } // namespace -absl::Status Controller::OnEntry() { +absl::Status Controller::OnEntry(std::string filename) { RETURN_IF_ERROR(CreateSDL_Window()) RETURN_IF_ERROR(CreateRenderer()) RETURN_IF_ERROR(CreateGuiContext()) diff --git a/src/app/core/controller.h b/src/app/core/controller.h index 486b675a..c3c6e70f 100644 --- a/src/app/core/controller.h +++ b/src/app/core/controller.h @@ -31,7 +31,7 @@ namespace core { class Controller : public ExperimentFlags { public: bool IsActive() const { return active_; } - absl::Status OnEntry(); + absl::Status OnEntry(std::string filename = ""); void OnInput(); void OnLoad(); void DoRender() const; diff --git a/src/app/editor/master_editor.cc b/src/app/editor/master_editor.cc index e97ec586..5662c71d 100644 --- a/src/app/editor/master_editor.cc +++ b/src/app/editor/master_editor.cc @@ -122,9 +122,13 @@ using ImGui::Checkbox; using ImGui::MenuItem; using ImGui::Text; -void MasterEditor::SetupScreen(std::shared_ptr renderer) { +void MasterEditor::SetupScreen(std::shared_ptr renderer, + std::string filename) { sdl_renderer_ = renderer; rom()->SetupRenderer(renderer); + if (!filename.empty()) { + rom()->LoadFromFile(filename); + } overworld_editor_.InitializeZeml(); } diff --git a/src/app/editor/master_editor.h b/src/app/editor/master_editor.h index acea503f..53908bff 100644 --- a/src/app/editor/master_editor.h +++ b/src/app/editor/master_editor.h @@ -58,7 +58,8 @@ class MasterEditor : public SharedRom, public: MasterEditor() { current_editor_ = &overworld_editor_; } - void SetupScreen(std::shared_ptr renderer); + void SetupScreen(std::shared_ptr renderer, + std::string filename = ""); absl::Status Update(); void Shutdown() { overworld_editor_.Shutdown(); } diff --git a/src/app/yaze.cc b/src/app/yaze.cc index b7b784aa..7dfbb55c 100644 --- a/src/app/yaze.cc +++ b/src/app/yaze.cc @@ -25,6 +25,11 @@ int main(int argc, char** argv) { options.alarm_on_failure_secs = true; absl::InstallFailureSignalHandler(options); + std::string rom_filename; + if (argc > 1) { + rom_filename = argv[1]; + } + core::Controller controller; EXIT_IF_ERROR(controller.OnEntry())