diff --git a/story-editor/imgui.ini b/story-editor/imgui.ini index ef62650..5add485 100644 --- a/story-editor/imgui.ini +++ b/story-editor/imgui.ini @@ -1,6 +1,6 @@ [Window][WindowOverViewport_11111111] Pos=60,26 -Size=1343,777 +Size=1220,694 Collapsed=0 [Window][Debug##Default] @@ -9,32 +9,32 @@ Size=400,400 Collapsed=0 [Window][Library Manager] -Pos=714,26 -Size=689,465 +Pos=435,26 +Size=845,388 Collapsed=0 DockId=0x00000003,0 [Window][Console] -Pos=60,533 -Size=672,270 +Pos=60,450 +Size=610,270 Collapsed=0 DockId=0x00000004,0 [Window][Emulator] -Pos=714,26 -Size=689,465 +Pos=435,26 +Size=845,388 Collapsed=0 DockId=0x00000003,5 [Window][Code viewer] -Pos=714,26 -Size=689,465 +Pos=435,26 +Size=845,388 Collapsed=0 DockId=0x00000003,4 [Window][Resources] -Pos=714,26 -Size=689,465 +Pos=435,26 +Size=845,388 Collapsed=0 DockId=0x00000003,1 @@ -50,36 +50,36 @@ Size=150,42 Collapsed=0 [Window][Variables] -Pos=734,533 -Size=669,270 +Pos=672,450 +Size=608,270 Collapsed=0 DockId=0x00000005,0 [Window][CPU] -Pos=714,26 -Size=689,465 +Pos=435,26 +Size=845,388 Collapsed=0 DockId=0x00000003,2 [Window][RAM view] -Pos=714,26 -Size=689,465 +Pos=435,26 +Size=845,388 Collapsed=0 DockId=0x00000003,3 [Window][Properties] -Pos=714,493 -Size=689,38 +Pos=435,416 +Size=845,32 Collapsed=0 DockId=0x00000006,0 [Window][ToolBar] Pos=0,26 -Size=60,777 +Size=60,694 Collapsed=0 [Window][QuitConfirm] -Pos=569,353 +Pos=508,312 Size=264,96 Collapsed=0 @@ -90,13 +90,13 @@ Collapsed=0 [Window][Module editor] Pos=60,26 -Size=652,505 +Size=373,422 Collapsed=0 DockId=0x00000001,0 [Window][Story editor] Pos=60,26 -Size=652,505 +Size=373,422 Collapsed=0 DockId=0x00000001,1 @@ -142,10 +142,10 @@ RefScale=20 Column 0 Sort=0v [Docking][Data] -DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=60,26 Size=1343,777 Split=Y +DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=60,26 Size=1220,694 Split=Y DockNode ID=0x00000007 Parent=0x08BD597D SizeRef=1220,422 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=0x00000001 Parent=0x00000007 SizeRef=373,694 CentralNode=1 Selected=0x93ADCAAB + DockNode ID=0x00000002 Parent=0x00000007 SizeRef=845,694 Split=Y Selected=0x52EB28B5 DockNode ID=0x00000003 Parent=0x00000002 SizeRef=718,388 Selected=0x63869CAF DockNode ID=0x00000006 Parent=0x00000002 SizeRef=718,32 Selected=0x8C72BEA8 DockNode ID=0x00000008 Parent=0x08BD597D SizeRef=1220,270 Split=X Selected=0xEA83D666 diff --git a/story-editor/src/app/app_controller.cpp b/story-editor/src/app/app_controller.cpp index f43871c..1d52c25 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 c27f25b..0068016 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 bbca984..ed05f84 100644 --- a/story-editor/src/events/all_events.h +++ b/story-editor/src/events/all_events.h @@ -62,6 +62,8 @@ public: { Open, 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/gui.cpp b/story-editor/src/gui.cpp index 8ce794a..ab90b25 100644 --- a/story-editor/src/gui.cpp +++ b/story-editor/src/gui.cpp @@ -629,7 +629,6 @@ void Gui::ApplyTheme() ImVec4* colors = ImGui::GetStyle().Colors; ImGuiStyle & style = ImGui::GetStyle(); - colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f); @@ -663,11 +662,19 @@ void Gui::ApplyTheme() colors[ImGuiCol_ResizeGrip] = ImVec4(0.13f, 0.75f, 0.55f, 0.40f); colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.13f, 0.75f, 0.75f, 0.60f); colors[ImGuiCol_ResizeGripActive] = ImVec4(0.13f, 0.75f, 1.00f, 0.80f); - colors[ImGuiCol_Tab] = ImVec4(0.13f, 0.75f, 0.55f, 0.80f); - colors[ImGuiCol_TabHovered] = ImVec4(0.13f, 0.75f, 0.75f, 0.80f); - colors[ImGuiCol_TabActive] = ImVec4(0.13f, 0.75f, 1.00f, 0.80f); - colors[ImGuiCol_TabUnfocused] = ImVec4(0.18f, 0.18f, 0.18f, 1.00f); - colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.36f, 0.36f, 0.36f, 0.54f); + + // ===== AMÉLIORATION DES ONGLETS ===== + // Onglet inactif (non sélectionné) + colors[ImGuiCol_Tab] = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); + // Onglet survolé + colors[ImGuiCol_TabHovered] = ImVec4(0.25f, 0.60f, 0.80f, 1.00f); + // Onglet actif (sélectionné) - couleur vive et contrastée + colors[ImGuiCol_TabActive] = ImVec4(0.20f, 0.65f, 0.85f, 1.00f); + // Onglet inactif dans une fenêtre non-focusée + colors[ImGuiCol_TabUnfocused] = ImVec4(0.12f, 0.12f, 0.12f, 1.00f); + // Onglet actif dans une fenêtre non-focusée + colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.18f, 0.45f, 0.60f, 1.00f); + colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); @@ -684,6 +691,8 @@ void Gui::ApplyTheme() colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); + colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.38f, 0.38f, 0.38f, 1.00f); + colors[ImGuiCol_DockingPreview] = ImVec4(0.20f, 0.65f, 0.85f, 0.50f); style.ChildRounding = 4.0f; style.FrameBorderSize = 1.0f; @@ -692,103 +701,12 @@ void Gui::ApplyTheme() style.PopupRounding = 2.0f; style.ScrollbarRounding = 12.0f; style.ScrollbarSize = 13.0f; - style.TabBorderSize = 1.0f; - style.TabRounding = 0.0f; + style.TabBorderSize = 0.0f; // Pas de bordure autour des onglets + style.TabRounding = 4.0f; // Coins arrondis pour les onglets style.WindowRounding = 4.0f; - -/* - /// 0 = FLAT APPEARENCE - /// 1 = MORE "3D" LOOK - int is3D = 1; - - colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); - colors[ImGuiCol_TextDisabled] = ImVec4(0.40f, 0.40f, 0.40f, 1.00f); - colors[ImGuiCol_ChildBg] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); - colors[ImGuiCol_WindowBg] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); - colors[ImGuiCol_PopupBg] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); - colors[ImGuiCol_Border] = ImVec4(0.12f, 0.12f, 0.12f, 0.71f); - colors[ImGuiCol_BorderShadow] = ImVec4(1.00f, 1.00f, 1.00f, 0.06f); - colors[ImGuiCol_FrameBg] = ImVec4(0.42f, 0.42f, 0.42f, 0.54f); - colors[ImGuiCol_FrameBgHovered] = ImVec4(0.42f, 0.42f, 0.42f, 0.40f); - colors[ImGuiCol_FrameBgActive] = ImVec4(0.56f, 0.56f, 0.56f, 0.67f); - colors[ImGuiCol_TitleBg] = ImVec4(0.19f, 0.19f, 0.19f, 1.00f); - colors[ImGuiCol_TitleBgActive] = ImVec4(0.22f, 0.22f, 0.22f, 1.00f); - colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.17f, 0.17f, 0.17f, 0.90f); - colors[ImGuiCol_MenuBarBg] = ImVec4(0.335f, 0.335f, 0.335f, 1.000f); - colors[ImGuiCol_ScrollbarBg] = ImVec4(0.24f, 0.24f, 0.24f, 0.53f); - colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f); - colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.52f, 0.52f, 0.52f, 1.00f); - colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.76f, 0.76f, 0.76f, 1.00f); - colors[ImGuiCol_CheckMark] = ImVec4(0.65f, 0.65f, 0.65f, 1.00f); - colors[ImGuiCol_SliderGrab] = ImVec4(0.52f, 0.52f, 0.52f, 1.00f); - colors[ImGuiCol_SliderGrabActive] = ImVec4(0.64f, 0.64f, 0.64f, 1.00f); - colors[ImGuiCol_Button] = ImVec4(0.54f, 0.54f, 0.54f, 0.35f); - colors[ImGuiCol_ButtonHovered] = ImVec4(0.52f, 0.52f, 0.52f, 0.59f); - colors[ImGuiCol_ButtonActive] = ImVec4(0.76f, 0.76f, 0.76f, 1.00f); - colors[ImGuiCol_Header] = ImVec4(0.38f, 0.38f, 0.38f, 1.00f); - colors[ImGuiCol_HeaderHovered] = ImVec4(0.47f, 0.47f, 0.47f, 1.00f); - colors[ImGuiCol_HeaderActive] = ImVec4(0.76f, 0.76f, 0.76f, 0.77f); - colors[ImGuiCol_Separator] = ImVec4(0.000f, 0.000f, 0.000f, 0.137f); - colors[ImGuiCol_SeparatorHovered] = ImVec4(0.700f, 0.671f, 0.600f, 0.290f); - colors[ImGuiCol_SeparatorActive] = ImVec4(0.702f, 0.671f, 0.600f, 0.674f); - colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.25f); - colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); - colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); - colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); - colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); - colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); - colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); - colors[ImGuiCol_TextSelectedBg] = ImVec4(0.73f, 0.73f, 0.73f, 0.35f); - colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); - colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); - colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); - colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); - colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); - - style.PopupRounding = 3; - - style.WindowPadding = ImVec2(4, 4); - style.FramePadding = ImVec2(6, 4); - style.ItemSpacing = ImVec2(6, 2); - - style.ScrollbarSize = 18; - - style.WindowBorderSize = 1; - style.ChildBorderSize = 1; - style.PopupBorderSize = 1; - style.FrameBorderSize = is3D; - - style.WindowRounding = 3; - style.ChildRounding = 3; - style.FrameRounding = 3; - style.ScrollbarRounding = 2; - style.GrabRounding = 3; - - - style.TabBorderSize = is3D; - style.TabRounding = 3; - - colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.38f, 0.38f, 0.38f, 1.00f); - colors[ImGuiCol_Tab] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); - colors[ImGuiCol_TabHovered] = ImVec4(0.40f, 0.40f, 0.40f, 1.00f); - colors[ImGuiCol_TabActive] = ImVec4(0.33f, 0.33f, 0.33f, 1.00f); - colors[ImGuiCol_TabUnfocused] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); - colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.33f, 0.33f, 0.33f, 1.00f); - colors[ImGuiCol_DockingPreview] = ImVec4(0.85f, 0.85f, 0.85f, 0.28f); - - if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable) - { - style.WindowRounding = 0.0f; - style.Colors[ImGuiCol_WindowBg].w = 1.0f; - } - - */ - } - - namespace ImGui { void LoadingIndicatorCircle(const char* label, const float indicator_radius, const ImVec4& main_color, const ImVec4& backdrop_color, diff --git a/story-editor/src/main_window.cpp b/story-editor/src/main_window.cpp index 8f22941..870eb9b 100644 --- a/story-editor/src/main_window.cpp +++ b/story-editor/src/main_window.cpp @@ -100,6 +100,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); } }); } @@ -411,45 +416,80 @@ void MainWindow::DrawToolBar(float topPadding) ImGuiWindowFlags_NoDocking; // Définit la taille et la position de la barre d'outils - ImVec2 size = ImVec2(60, ImGui::GetIO().DisplaySize.y - topPadding); // Largeur de 60 pixels et hauteur égale à celle de l'écran + ImVec2 size = ImVec2(60, ImGui::GetIO().DisplaySize.y - topPadding); ImGui::SetNextWindowSize(size); - ImGui::SetNextWindowPos(ImVec2(0, topPadding)); // Positionné à gauche et en haut + ImGui::SetNextWindowPos(ImVec2(0, topPadding)); + // Style pour les coins arrondis des boutons + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 6.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 4)); + // 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 - float old_size = ImGui::GetFont()->Scale; - ImGui::GetFont()->Scale *= 2.5; - - ImGui::PushFont(ImGui::GetFont()); - - // Ajouter des boutons à la barre d'outils - if (ImGui::Button(ICON_MDI_SPEAKER_STOP "##stop_sound", ImVec2(-1, 50))) { // Le bouton prend toute la largeur de la fenêtre et a une hauteur de 50 pixels - m_appController.StopAudio(); - } - - if (ImGui::Button(ICON_MDI_HAMMER "##build_project", ImVec2(-1, 50))) { // Le bouton prend toute la largeur de la fenêtre et a une hauteur de 50 pixels + if (ImGui::Begin("ToolBar", nullptr, window_flags)) + { + // Taille réduite des boutons + float buttonSize = 36.0f; + float windowWidth = ImGui::GetContentRegionAvail().x; + float offsetX = (windowWidth - buttonSize) * 0.5f; - // Compile story if window focused, otherwise module - if (m_nodeEditorWindow.IsFocused()) - { - m_appController.CompileNodes(IStoryProject::PROJECT_TYPE_STORY); + // Style pour les couleurs des boutons + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.2f, 0.2f, 0.2f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.3f, 0.3f, 0.3f, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.15f, 0.15f, 0.15f, 1.0f)); + + // Taille de fonte réduite pour les icônes + float old_size = ImGui::GetFont()->Scale; + ImGui::GetFont()->Scale *= 1.2f; + ImGui::PushFont(ImGui::GetFont()); + + // Bouton Stop Sound + ImGui::SetCursorPosX(ImGui::GetCursorPosX() + offsetX); + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.9f, 0.3f, 0.3f, 1.0f)); + if (ImGui::Button(ICON_MDI_SPEAKER_STOP "##stop_sound", ImVec2(buttonSize, buttonSize))) { + m_appController.StopAudio(); } - else - { - m_appController.CompileNodes(IStoryProject::PROJECT_TYPE_MODULE); + ImGui::PopStyleColor(); + + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Stop Sound"); } + + // Espacement vertical + ImGui::Dummy(ImVec2(0, 8)); + + // Bouton Build + ImGui::SetCursorPosX(ImGui::GetCursorPosX() + offsetX); + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.3f, 0.8f, 0.9f, 1.0f)); + if (ImGui::Button(ICON_MDI_HAMMER "##build_project", ImVec2(buttonSize, buttonSize))) { + // Compile story if window focused, otherwise module + if (m_nodeEditorWindow.IsFocused()) + { + m_appController.CompileNodes(IStoryProject::PROJECT_TYPE_STORY); + } + else + { + m_appController.CompileNodes(IStoryProject::PROJECT_TYPE_MODULE); + } + } + ImGui::PopStyleColor(); + + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Build Project"); + } + + // Restaurer le scale de la fonte + ImGui::GetFont()->Scale = old_size; + ImGui::PopFont(); + + // Pop les couleurs des boutons + ImGui::PopStyleColor(3); // Button, ButtonHovered, ButtonActive + + // Fermeture de la fenêtre ImGui + ImGui::End(); } - - ImGui::GetFont()->Scale = old_size; - ImGui::PopFont(); - ImGui::PopStyleColor(); - - - // Fermeture de la fenêtre ImGui - ImGui::End(); + // Pop les styles de frame + ImGui::PopStyleVar(2); // FrameRounding, FramePadding } #include "imgui_internal.h" diff --git a/story-editor/src/node_editor/node_editor_page.h b/story-editor/src/node_editor/node_editor_page.h index 8dd4e49..59a08e7 100644 --- a/story-editor/src/node_editor/node_editor_page.h +++ b/story-editor/src/node_editor/node_editor_page.h @@ -132,7 +132,7 @@ struct NodeEditorPage : public ImFlow::BaseNode , m_name(name) { - mINF.setSize({500, 500}); + mINF.setSize({0, 0}); } ~NodeEditorPage() { diff --git a/story-editor/src/node_editor/print_node_widget.cpp b/story-editor/src/node_editor/print_node_widget.cpp index dae3d66..e43e7eb 100644 --- a/story-editor/src/node_editor/print_node_widget.cpp +++ b/story-editor/src/node_editor/print_node_widget.cpp @@ -13,6 +13,12 @@ PrintNodeWidget::PrintNodeWidget(IStoryManager &manager, std::shared_ptr(node); + // Create defaut one input and one output + // AddInputs(2); + // SetInputPinName(0, ">"); + // SetInputPinName(1, "Argument 1"); + // AddOutputs(1); + // SetOutPinName(0, ">"); } void PrintNodeWidget::Initialize()