diff --git a/packages/soundboard/workflows/soundboard_flow.json b/packages/soundboard/workflows/soundboard_flow.json index ae3b58c..9876136 100644 --- a/packages/soundboard/workflows/soundboard_flow.json +++ b/packages/soundboard/workflows/soundboard_flow.json @@ -63,8 +63,7 @@ "begin_frame": { "main": [ [ - { "node": "catalog_scan", "type": "main", "index": 0 }, - { "node": "render_frame", "type": "main", "index": 0 } + { "node": "catalog_scan", "type": "main", "index": 0 } ] ] }, @@ -78,7 +77,8 @@ "gui_render": { "main": [ [ - { "node": "audio_dispatch", "type": "main", "index": 0 } + { "node": "audio_dispatch", "type": "main", "index": 0 }, + { "node": "render_frame", "type": "main", "index": 0 } ] ] }, diff --git a/src/services/impl/render_coordinator_service.cpp b/src/services/impl/render_coordinator_service.cpp index 580099b..6a1d43c 100644 --- a/src/services/impl/render_coordinator_service.cpp +++ b/src/services/impl/render_coordinator_service.cpp @@ -222,9 +222,19 @@ void RenderCoordinatorService::RenderFrameInternal(float time, if (guiService_) { auto extent = graphicsService_->GetSwapchainExtent(); if (guiCommands) { + if (logger_) { + logger_->Trace("RenderCoordinatorService", "RenderFrame", + "guiCommands=" + std::to_string(guiCommands->size()), + "Using workflow GUI commands"); + } guiService_->PrepareFrame(*guiCommands, extent.first, extent.second); } else if (guiScriptService_ && guiScriptService_->HasGuiCommands()) { auto scriptCommands = guiScriptService_->LoadGuiCommands(); + if (logger_) { + logger_->Trace("RenderCoordinatorService", "RenderFrame", + "guiCommands=" + std::to_string(scriptCommands.size()), + "Using script GUI commands"); + } guiService_->PrepareFrame(scriptCommands, extent.first, extent.second); } } diff --git a/src/services/impl/soundboard_state_service.cpp b/src/services/impl/soundboard_state_service.cpp index 15baad9..184d6d6 100644 --- a/src/services/impl/soundboard_state_service.cpp +++ b/src/services/impl/soundboard_state_service.cpp @@ -1,5 +1,7 @@ #include "soundboard_state_service.hpp" +#include + namespace sdl3cpp::services::impl { SoundboardStateService::SoundboardStateService(std::shared_ptr logger) diff --git a/src/services/impl/workflow_number_add_step.hpp b/src/services/impl/workflow_number_add_step.hpp new file mode 100644 index 0000000..41d28b7 --- /dev/null +++ b/src/services/impl/workflow_number_add_step.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include "../interfaces/i_logger.hpp" +#include "../interfaces/i_workflow_step.hpp" + +#include + +namespace sdl3cpp::services::impl { + +class WorkflowNumberAddStep final : public IWorkflowStep { +public: + explicit WorkflowNumberAddStep(std::shared_ptr logger); + + std::string GetPluginId() const override; + void Execute(const WorkflowStepDefinition& step, WorkflowContext& context) override; + +private: + std::shared_ptr logger_; +}; + +} // namespace sdl3cpp::services::impl diff --git a/src/services/impl/workflow_soundboard_audio_step.cpp b/src/services/impl/workflow_soundboard_audio_step.cpp index 00a675b..d995314 100644 --- a/src/services/impl/workflow_soundboard_audio_step.cpp +++ b/src/services/impl/workflow_soundboard_audio_step.cpp @@ -4,6 +4,7 @@ #include #include +#include namespace sdl3cpp::services::impl { diff --git a/src/services/impl/workflow_soundboard_catalog_scan_step.cpp b/src/services/impl/workflow_soundboard_catalog_scan_step.cpp index 3cf1e7f..4509fff 100644 --- a/src/services/impl/workflow_soundboard_catalog_scan_step.cpp +++ b/src/services/impl/workflow_soundboard_catalog_scan_step.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include namespace sdl3cpp::services::impl { diff --git a/src/services/impl/workflow_soundboard_gui_step.cpp b/src/services/impl/workflow_soundboard_gui_step.cpp index 0f62a24..9619433 100644 --- a/src/services/impl/workflow_soundboard_gui_step.cpp +++ b/src/services/impl/workflow_soundboard_gui_step.cpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace sdl3cpp::services::impl { namespace { @@ -164,6 +165,10 @@ void WorkflowSoundboardGuiStep::Execute(const WorkflowStepDefinition& step, Work void WorkflowSoundboardGuiStep::EnsureConfigLoaded() { if (!cachedConfig_) { cachedConfig_ = LoadConfig(); + if (logger_) { + logger_->Trace("WorkflowSoundboardGuiStep", "EnsureConfigLoaded", + "title=" + cachedConfig_->title); + } } } @@ -322,6 +327,10 @@ std::vector WorkflowSoundboardGuiStep::BuildCommands( } } + if (justReleased && !activeWidget_.empty()) { + activeWidget_.clear(); + } + const float statusY = rect.y + rect.height - config.statusOffsetY; commands.push_back(BuildTextCommand(statusMessage, rect.x + config.panelPaddingX, statusY, config.statusFontSize, diff --git a/src/services/impl/workflow_value_copy_step.cpp b/src/services/impl/workflow_value_copy_step.cpp new file mode 100644 index 0000000..e9e965d --- /dev/null +++ b/src/services/impl/workflow_value_copy_step.cpp @@ -0,0 +1,35 @@ +#include "workflow_value_copy_step.hpp" +#include "workflow_step_io_resolver.hpp" + +#include +#include + +namespace sdl3cpp::services::impl { + +WorkflowValueCopyStep::WorkflowValueCopyStep(std::shared_ptr logger) + : logger_(std::move(logger)) {} + +std::string WorkflowValueCopyStep::GetPluginId() const { + return "value.copy"; +} + +void WorkflowValueCopyStep::Execute(const WorkflowStepDefinition& step, WorkflowContext& context) { + WorkflowStepIoResolver resolver; + const std::string inputKey = resolver.GetRequiredInputKey(step, "value"); + const std::string outputKey = resolver.GetRequiredOutputKey(step, "value"); + + const auto* value = context.TryGetAny(inputKey); + if (!value) { + throw std::runtime_error("value.copy missing input '" + inputKey + "'"); + } + + context.Set(outputKey, *value); + + if (logger_) { + logger_->Trace("WorkflowValueCopyStep", "Execute", + "input=" + inputKey + ", output=" + outputKey, + "Copied workflow value"); + } +} + +} // namespace sdl3cpp::services::impl diff --git a/src/services/impl/workflow_value_copy_step.hpp b/src/services/impl/workflow_value_copy_step.hpp new file mode 100644 index 0000000..752f99d --- /dev/null +++ b/src/services/impl/workflow_value_copy_step.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include "../interfaces/i_logger.hpp" +#include "../interfaces/i_workflow_step.hpp" + +#include + +namespace sdl3cpp::services::impl { + +class WorkflowValueCopyStep final : public IWorkflowStep { +public: + explicit WorkflowValueCopyStep(std::shared_ptr logger); + + std::string GetPluginId() const override; + void Execute(const WorkflowStepDefinition& step, WorkflowContext& context) override; + +private: + std::shared_ptr logger_; +}; + +} // namespace sdl3cpp::services::impl diff --git a/src/services/impl/workflow_value_default_step.cpp b/src/services/impl/workflow_value_default_step.cpp new file mode 100644 index 0000000..d6c03e1 --- /dev/null +++ b/src/services/impl/workflow_value_default_step.cpp @@ -0,0 +1,39 @@ +#include "workflow_value_default_step.hpp" +#include "workflow_step_io_resolver.hpp" + +#include +#include + +namespace sdl3cpp::services::impl { + +WorkflowValueDefaultStep::WorkflowValueDefaultStep(std::shared_ptr logger) + : logger_(std::move(logger)) {} + +std::string WorkflowValueDefaultStep::GetPluginId() const { + return "value.default"; +} + +void WorkflowValueDefaultStep::Execute(const WorkflowStepDefinition& step, WorkflowContext& context) { + WorkflowStepIoResolver resolver; + const std::string primaryKey = resolver.GetRequiredInputKey(step, "primary"); + const std::string fallbackKey = resolver.GetRequiredInputKey(step, "fallback"); + const std::string outputKey = resolver.GetRequiredOutputKey(step, "value"); + + const auto* primary = context.TryGetAny(primaryKey); + const auto* fallback = context.TryGetAny(fallbackKey); + if (!primary && !fallback) { + throw std::runtime_error("value.default missing inputs '" + primaryKey + "' and '" + fallbackKey + "'"); + } + + const char* source = primary ? "primary" : "fallback"; + context.Set(outputKey, primary ? *primary : *fallback); + + if (logger_) { + logger_->Trace("WorkflowValueDefaultStep", "Execute", + "source=" + std::string(source) + + ", output=" + outputKey, + "Selected default workflow value"); + } +} + +} // namespace sdl3cpp::services::impl diff --git a/src/services/impl/workflow_value_default_step.hpp b/src/services/impl/workflow_value_default_step.hpp new file mode 100644 index 0000000..08d7ab4 --- /dev/null +++ b/src/services/impl/workflow_value_default_step.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include "../interfaces/i_logger.hpp" +#include "../interfaces/i_workflow_step.hpp" + +#include + +namespace sdl3cpp::services::impl { + +class WorkflowValueDefaultStep final : public IWorkflowStep { +public: + explicit WorkflowValueDefaultStep(std::shared_ptr logger); + + std::string GetPluginId() const override; + void Execute(const WorkflowStepDefinition& step, WorkflowContext& context) override; + +private: + std::shared_ptr logger_; +}; + +} // namespace sdl3cpp::services::impl diff --git a/src/services/interfaces/workflow_context.hpp b/src/services/interfaces/workflow_context.hpp index eebb122..d2e035b 100644 --- a/src/services/interfaces/workflow_context.hpp +++ b/src/services/interfaces/workflow_context.hpp @@ -27,6 +27,14 @@ public: return std::any_cast(&it->second); } + const std::any* TryGetAny(const std::string& key) const { + auto it = values_.find(key); + if (it == values_.end()) { + return nullptr; + } + return &it->second; + } + private: std::unordered_map values_; };