From 31e76ce6d71bc1fdf7cf4116895b552645f772c8 Mon Sep 17 00:00:00 2001 From: Anthony Rabine Date: Wed, 1 Oct 2025 17:38:52 +0200 Subject: [PATCH] fix build of modules --- story-editor/imgui.ini | 40 +++++++++---------- story-editor/src/app/app_controller.cpp | 8 ++-- story-editor/src/app/app_controller.h | 2 + story-editor/src/events/all_events.h | 10 +++++ story-editor/src/main_window.cpp | 9 ++++- .../src/node_editor/print_node_widget.cpp | 7 ++-- 6 files changed, 46 insertions(+), 30 deletions(-) diff --git a/story-editor/imgui.ini b/story-editor/imgui.ini index a68d4ea..60cfd9e 100644 --- a/story-editor/imgui.ini +++ b/story-editor/imgui.ini @@ -9,8 +9,8 @@ Size=400,400 Collapsed=0 [Window][Library Manager] -Pos=591,26 -Size=689,224 +Pos=597,26 +Size=683,350 Collapsed=0 DockId=0x00000003,0 @@ -21,20 +21,20 @@ Collapsed=0 DockId=0x00000004,0 [Window][Emulator] -Pos=591,26 -Size=689,224 +Pos=597,26 +Size=683,350 Collapsed=0 DockId=0x00000003,5 [Window][Code viewer] -Pos=591,26 -Size=689,224 +Pos=597,26 +Size=683,350 Collapsed=0 DockId=0x00000003,4 [Window][Resources] -Pos=591,26 -Size=689,224 +Pos=597,26 +Size=683,350 Collapsed=0 DockId=0x00000003,1 @@ -56,20 +56,20 @@ Collapsed=0 DockId=0x00000005,0 [Window][CPU] -Pos=591,26 -Size=689,224 +Pos=597,26 +Size=683,350 Collapsed=0 DockId=0x00000003,2 [Window][RAM view] -Pos=591,26 -Size=689,224 +Pos=597,26 +Size=683,350 Collapsed=0 DockId=0x00000003,3 [Window][Properties] -Pos=591,252 -Size=689,279 +Pos=597,378 +Size=683,153 Collapsed=0 DockId=0x00000006,0 @@ -90,13 +90,13 @@ Collapsed=0 [Window][Module editor] Pos=60,26 -Size=529,505 +Size=535,505 Collapsed=0 DockId=0x00000001,1 [Window][Story editor] Pos=60,26 -Size=529,505 +Size=535,505 Collapsed=0 DockId=0x00000001,0 @@ -144,10 +144,10 @@ Column 0 Sort=0v [Docking][Data] DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=60,26 Size=1220,694 Split=Y DockNode ID=0x00000007 Parent=0x08BD597D SizeRef=1220,505 Split=X - DockNode ID=0x00000001 Parent=0x00000007 SizeRef=721,694 CentralNode=1 Selected=0x93ADCAAB - DockNode ID=0x00000002 Parent=0x00000007 SizeRef=689,694 Split=Y Selected=0x52EB28B5 - DockNode ID=0x00000003 Parent=0x00000002 SizeRef=718,224 Selected=0x63869CAF - DockNode ID=0x00000006 Parent=0x00000002 SizeRef=718,279 Selected=0x8C72BEA8 + DockNode ID=0x00000001 Parent=0x00000007 SizeRef=535,694 CentralNode=1 Selected=0x93ADCAAB + DockNode ID=0x00000002 Parent=0x00000007 SizeRef=683,694 Split=Y Selected=0x52EB28B5 + DockNode ID=0x00000003 Parent=0x00000002 SizeRef=718,452 Selected=0x63869CAF + DockNode ID=0x00000006 Parent=0x00000002 SizeRef=718,197 Selected=0x8C72BEA8 DockNode ID=0x00000008 Parent=0x08BD597D SizeRef=1220,187 Split=X Selected=0xEA83D666 DockNode ID=0x00000004 Parent=0x00000008 SizeRef=610,192 Selected=0xEA83D666 DockNode ID=0x00000005 Parent=0x00000008 SizeRef=608,192 Selected=0x6DE9B20C diff --git a/story-editor/src/app/app_controller.cpp b/story-editor/src/app/app_controller.cpp index 9a9bd3a..7073377 100644 --- a/story-editor/src/app/app_controller.cpp +++ b/story-editor/src/app/app_controller.cpp @@ -247,10 +247,6 @@ void AppController::CompileNodes(IStoryProject::Type type) { if (m_story->GenerateScript(m_storyAssembly)) { - // La GUI (DebuggerWindow) doit être notifiée de cette mise à jour. - // Au lieu de appeler m_debuggerWindow.SetScript(m_storyAssembly); directement, - // AppController pourrait émettre un événement ou un callback. - // Pour l'instant, on suppose une notification ou que la GUI tire les données. m_logger.Log("Nodes script generated for story."); Build(true); // Compile seulement par défaut } @@ -261,9 +257,11 @@ void AppController::CompileNodes(IStoryProject::Type type) } else if (type == IStoryProject::Type::PROJECT_TYPE_MODULE && m_module) { - if (m_module->GenerateScript(m_storyAssembly)) + if (m_module->GenerateScript(m_moduleAssembly)) { m_logger.Log("Nodes script generated for module."); + m_eventBus.Emit(std::make_shared(ModuleEvent::Type::BuildSuccess, m_module->GetUuid())); + Build(true); // Compile seulement par défaut } else { diff --git a/story-editor/src/app/app_controller.h b/story-editor/src/app/app_controller.h index 5971d05..4366bc0 100644 --- a/story-editor/src/app/app_controller.h +++ b/story-editor/src/app/app_controller.h @@ -104,6 +104,8 @@ public: void ProcessStory(); void StepInstruction(); void StopAudio() { m_player.Stop(); } + std::string GetModuleAssembly() const { return m_moduleAssembly; } + std::string GetStoryAssembly() const { return m_storyAssembly; } bool IsLibraryManagerInitialized() const { return m_libraryManager.IsInitialized(); } diff --git a/story-editor/src/events/all_events.h b/story-editor/src/events/all_events.h index 946641b..55d99bc 100644 --- a/story-editor/src/events/all_events.h +++ b/story-editor/src/events/all_events.h @@ -62,6 +62,8 @@ public: { Opened, Closed, + BuildSuccess, + BuildFailure }; ModuleEvent(Type type, const std::string &uuid) @@ -70,9 +72,17 @@ public: Type GetType() const { return m_type; } const std::string& GetUuid() const { return m_uuid; } + const std::string& GetScript() const { return m_script; } + bool IsSuccess() const { return success; } + + void SetScript(const std::string& script) { m_script = script; } + void SetSuccess(bool s) { success = s; } + private: Type m_type; std::string m_uuid; + std::string m_script; + bool success{false}; }; #endif // ALL_EVENTS_H \ No newline at end of file diff --git a/story-editor/src/main_window.cpp b/story-editor/src/main_window.cpp index 5205274..3c77427 100644 --- a/story-editor/src/main_window.cpp +++ b/story-editor/src/main_window.cpp @@ -71,6 +71,11 @@ MainWindow::MainWindow(ILogger& logger, EventBus& eventBus, AppController& appCo OpenModule(event.GetUuid()); } else if (event.GetType() == ModuleEvent::Type::Closed) { CloseModule(); + } else if (event.GetType() == ModuleEvent::Type::BuildSuccess) { + m_toastNotifier.addToast("Module", "Module built successfully", ToastType::Success); + m_debuggerWindow.SetScript(m_appController.GetModuleAssembly()); + } else if (event.GetType() == ModuleEvent::Type::BuildFailure) { + m_toastNotifier.addToast("Module", "Module build failed", ToastType::Error); } }); } @@ -388,7 +393,7 @@ void MainWindow::DrawToolBar(float topPadding) // Création de la fenêtre pour la barre d'outils ImGui::Begin("ToolBar", nullptr, window_flags); - ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); // rouge + // ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); // rouge float old_size = ImGui::GetFont()->Scale; ImGui::GetFont()->Scale *= 2.5; @@ -415,7 +420,7 @@ void MainWindow::DrawToolBar(float topPadding) ImGui::GetFont()->Scale = old_size; ImGui::PopFont(); - ImGui::PopStyleColor(); + // ImGui::PopStyleColor(); // Fermeture de la fenêtre ImGui diff --git a/story-editor/src/node_editor/print_node_widget.cpp b/story-editor/src/node_editor/print_node_widget.cpp index de651aa..a1446fe 100644 --- a/story-editor/src/node_editor/print_node_widget.cpp +++ b/story-editor/src/node_editor/print_node_widget.cpp @@ -15,10 +15,11 @@ PrintNodeWidget::PrintNodeWidget(IStoryManager &manager, std::shared_ptr(node); // Create defaut one input and one output - AddInputs(1); - SetInputPinName(0, ""); + AddInputs(2); + SetInputPinName(0, ">"); + SetInputPinName(1, "Argument 1"); AddOutputs(1); - SetOutPinName(0, ""); + SetOutPinName(0, ">"); } void PrintNodeWidget::Initialize()