From 619d4f143ebd0c20db86c8b3e7ab5a0005478b54 Mon Sep 17 00:00:00 2001 From: shweet Date: Fri, 10 Apr 2026 19:36:36 -0400 Subject: [PATCH] update to end sequence --- src/state/play.cpp | 56 +++++++++++++++++++++++----- src/state/play.hpp | 2 + src/state/play/character_manager.cpp | 9 +++++ src/state/play/character_manager.hpp | 1 + src/state/play/debug.cpp | 5 +++ src/state/play/debug.hpp | 2 + src/state/play/item_manager.cpp | 18 +++++++++ src/state/play/item_manager.hpp | 1 + src/state/play/menu.cpp | 2 + src/state/play/menu.hpp | 1 + 10 files changed, 88 insertions(+), 9 deletions(-) diff --git a/src/state/play.cpp b/src/state/play.cpp index 5ca3e11..6ca7da2 100644 --- a/src/state/play.cpp +++ b/src/state/play.cpp @@ -41,6 +41,33 @@ namespace game::state : World::CENTER; } + void Play::start_sequence_begin() + { + auto& dialogue = character.data.dialogue; + if (!dialogue.start.is_valid()) return; + + character.queue_play({.animation = dialogue.start.animation, .isInterruptible = false}); + character.tick(); + text.entry = nullptr; + text.isEnabled = false; + isWindows = false; + isStart = true; + isStartBegin = false; + isStartEnd = false; + } + + void Play::end_sequence_begin() + { + auto& dialogue = character.data.dialogue; + if (!dialogue.end.is_valid()) return; + + text.entry = nullptr; + text.isEnabled = false; + isEnd = true; + isEndBegin = false; + isEndEnd = false; + } + void Play::set(Resources& resources, int selectedCharacterIndex, enum Game game) { auto& data = resources.character_get(selectedCharacterIndex); @@ -128,14 +155,7 @@ namespace game::state worldCanvas.size_set(imgui::to_vec2(ImGui::GetMainViewport()->Size)); world.set(character, worldCanvas, focus_get()); - if (game == NEW_GAME && dialogue.start.is_valid()) - { - character.queue_play({.animation = dialogue.start.animation, .isInterruptible = false}); - character.tick(); - isStart = true; - isStartBegin = false; - isStartEnd = false; - } + if (game == NEW_GAME && dialogue.start.is_valid()) start_sequence_begin(); if (isPostgame) { @@ -230,8 +250,27 @@ namespace game::state tools.update(character, cursor, world, focus, worldCanvas); info.update(resources, character); toasts.update(); + +#if DEBUG + if (menu.isDebugOpen && ImGui::IsKeyPressed(ImGuiKey_F8, false)) end_sequence_begin(); +#endif + + if (menu.debug.isStartSequenceRequested) + { + menu.debug.isStartSequenceRequested = false; + start_sequence_begin(); + } + if (menu.debug.isEndSequenceRequested) + { + menu.debug.isEndSequenceRequested = false; + end_sequence_begin(); + } } + auto isEndSequenceActive = isEndBegin && !isEndEnd; + itemManager.isDisabled = isEndSequenceActive; + characterManager.isDisabled = isEndSequenceActive; + if (text.isEnabled) text.update(character); if (isStart) @@ -274,7 +313,6 @@ namespace game::state menu.isOpen = false; character.calories = 0; character.digestionProgress = 0; - itemManager.items.clear(); itemManager.heldItemIndex = -1; world.character_focus(character, worldCanvas, focus_get()); } diff --git a/src/state/play.hpp b/src/state/play.hpp index 65fe283..d18de5a 100644 --- a/src/state/play.hpp +++ b/src/state/play.hpp @@ -67,5 +67,7 @@ namespace game::state void render(Resources&, Canvas&); void save(Resources&); play::World::Focus focus_get(); + void start_sequence_begin(); + void end_sequence_begin(); }; }; diff --git a/src/state/play/character_manager.cpp b/src/state/play/character_manager.cpp index 453d382..920b3e9 100644 --- a/src/state/play/character_manager.cpp +++ b/src/state/play/character_manager.cpp @@ -39,6 +39,15 @@ namespace game::state::play auto isMouseLeftReleased = ImGui::IsMouseReleased(ImGuiMouseButton_Left); auto isImguiCaptureMouse = ImGui::GetIO().WantCaptureMouse; + if (isDisabled) + { + isInteracting = false; + isHoldInteracting = false; + isHovering = false; + interactAreaID = -1; + return; + } + isInteractingPrevious = isInteracting; isHoveringPrevious = isHovering; isHoldInteractingPrevious = isHoldInteracting; diff --git a/src/state/play/character_manager.hpp b/src/state/play/character_manager.hpp index 479165f..4abf06d 100644 --- a/src/state/play/character_manager.hpp +++ b/src/state/play/character_manager.hpp @@ -9,6 +9,7 @@ namespace game::state::play class CharacterManager { public: + bool isDisabled{}; bool isInteracting{}; bool isHovering{}; bool isInteractingPrevious{}; diff --git a/src/state/play/debug.cpp b/src/state/play/debug.cpp index 51f857e..9581d3c 100644 --- a/src/state/play/debug.cpp +++ b/src/state/play/debug.cpp @@ -38,6 +38,11 @@ namespace game::state::play ImGui::SeparatorText("Dialogue"); + if (character.data.dialogue.start.is_valid()) + if (WIDGET_FX(ImGui::Button("Play Start Sequence"))) isStartSequenceRequested = true; + if (character.data.dialogue.end.is_valid()) + if (WIDGET_FX(ImGui::Button("Play End Sequence"))) isEndSequenceRequested = true; + if (ImGui::BeginChild("##Dialogue", childSize, ImGuiChildFlags_Borders)) { for (int i = 0; i < (int)character.data.dialogue.entries.size(); i++) diff --git a/src/state/play/debug.hpp b/src/state/play/debug.hpp index bab232e..8502a41 100644 --- a/src/state/play/debug.hpp +++ b/src/state/play/debug.hpp @@ -14,6 +14,8 @@ namespace game::state::play { public: bool isBoundsDisplay{}; + bool isStartSequenceRequested{}; + bool isEndSequenceRequested{}; void update(entity::Character&, entity::Cursor&, ItemManager&, Canvas&, Text&); }; diff --git a/src/state/play/item_manager.cpp b/src/state/play/item_manager.cpp index b5fdbd5..20698a8 100644 --- a/src/state/play/item_manager.cpp +++ b/src/state/play/item_manager.cpp @@ -57,6 +57,24 @@ namespace game::state::play auto& io = ImGui::GetIO(); + if (isDisabled) + { + if (heldItemIndex != -1) + { + heldItemIndex = -1; + isJustItemHeldStopped = true; + } + isItemHovered = false; + isItemHeld = false; + isJustItemHeld = false; + isMouseLeftClicked = false; + isMouseLeftDown = false; + isMouseLeftReleased = false; + isMouseRightClicked = false; + isMouseRightDown = false; + isImguiCaptureMouse = true; + } + if (isJustItemHoveredStopped) { cursor.queue_default_animation(); diff --git a/src/state/play/item_manager.hpp b/src/state/play/item_manager.hpp index 03d6fd4..ece4e2b 100644 --- a/src/state/play/item_manager.hpp +++ b/src/state/play/item_manager.hpp @@ -14,6 +14,7 @@ namespace game::state::play public: static constexpr auto LIMIT = 100; + bool isDisabled{}; std::vector items{}; int heldItemIndex{-1}; int queuedRemoveItemIndex{-1}; diff --git a/src/state/play/menu.cpp b/src/state/play/menu.cpp index 88d9c30..b487dc9 100644 --- a/src/state/play/menu.cpp +++ b/src/state/play/menu.cpp @@ -29,6 +29,7 @@ namespace game::state::play auto style = ImGui::GetStyle(); auto& io = ImGui::GetIO(); + isDebugOpen = false; slide.update(isOpen, io.DeltaTime); @@ -93,6 +94,7 @@ namespace game::state::play #if DEBUG if (WIDGET_FX(ImGui::BeginTabItem("Debug"))) { + isDebugOpen = true; debug.update(character, cursor, itemManager, canvas, text); ImGui::EndTabItem(); } diff --git a/src/state/play/menu.hpp b/src/state/play/menu.hpp index e54e303..c538ec6 100644 --- a/src/state/play/menu.hpp +++ b/src/state/play/menu.hpp @@ -35,6 +35,7 @@ namespace game::state::play #endif bool isOpen{true}; + bool isDebugOpen{}; util::imgui::WindowSlide slide{}; void tick();