From c5346fa0d2e45daf4b028353a973792e47e01ba4 Mon Sep 17 00:00:00 2001 From: scemino Date: Thu, 18 Apr 2024 17:07:40 +0200 Subject: [PATCH] TWP: Fix sound position --- engines/twp/debugtools.cpp | 19 +++++++++++-------- engines/twp/twp.cpp | 11 ++--------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/engines/twp/debugtools.cpp b/engines/twp/debugtools.cpp index a5c46db3103..d61973214c1 100644 --- a/engines/twp/debugtools.cpp +++ b/engines/twp/debugtools.cpp @@ -19,10 +19,9 @@ * */ +#include "twp/debugtools.h" #include "backends/imgui/imgui.h" #include "common/debug-channels.h" -#include "twp/twp.h" -#include "twp/debugtools.h" #include "twp/detection.h" #include "twp/dialog.h" #include "twp/hud.h" @@ -35,6 +34,7 @@ #include "twp/squtil.h" #include "twp/thread.h" #include "twp/tsv.h" +#include "twp/twp.h" namespace Twp { @@ -58,7 +58,7 @@ typedef struct ImGuiState { int _selectedObject = 0; } ImGuiState; -ImGuiState* _state = nullptr; +ImGuiState *_state = nullptr; ImVec4 gray(0.6f, 0.6f, 0.6f, 1.f); @@ -90,7 +90,7 @@ static void drawThreads() { ImGui::TableNextColumn(); ImGui::Text("%-56s", thread->getName().c_str()); ImGui::TableNextColumn(); - if(thread->getId() != g_twp->_cutscene.id) { + if (thread->getId() != g_twp->_cutscene.id) { ImGui::Text("%-6s", thread->isGlobal() ? "global" : "local"); } else { ImGui::Text("%-6s", "cutscene"); @@ -311,7 +311,7 @@ static void drawAudio() { ImGui::Text("# sounds: %d/%d", count, NUM_AUDIO_SLOTS); ImGui::Separator(); - if (ImGui::BeginTable("Threads", 7, ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg)) { + if (ImGui::BeginTable("Threads", 8, ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg)) { ImGui::TableSetupColumn(""); ImGui::TableSetupColumn("Id"); ImGui::TableSetupColumn("Category"); @@ -319,6 +319,7 @@ static void drawAudio() { ImGui::TableSetupColumn("Loops"); ImGui::TableSetupColumn("Volume"); ImGui::TableSetupColumn("Pan"); + ImGui::TableSetupColumn("Object"); ImGui::TableHeadersRow(); for (int i = 0; i < NUM_AUDIO_SLOTS; i++) { @@ -345,6 +346,9 @@ static void drawAudio() { if (ImGui::SmallButton("STOP")) { g_twp->_audio->stop(sound.id); } + ImGui::TableNextColumn(); + Common::SharedPtr obj(sqobj(sound.objId)); + ImGui::Text("%s", obj ? g_twp->getTextDb().getText(obj->getName()).c_str() : "(none)"); } } @@ -365,7 +369,7 @@ static void drawGeneral() { ImGui::Text("%lld", size); ImGui::TextColored(gray, "Cutscene:"); ImGui::SameLine(); - if(g_twp->_cutscene.id) { + if (g_twp->_cutscene.id) { Common::SharedPtr cutscene(sqthread(g_twp->_cutscene.id)); ImGui::Text("%s", cutscene->getName().c_str()); } else { @@ -452,8 +456,7 @@ static void drawGeneral() { ImGui::TextColored(gray, "moving:"); ImGui::SameLine(); ImGui::Text("%s", g_twp->_camera->isMoving() ? "yes" : "no"); - auto halfScreenSize = g_twp->_room->getScreenSize() / 2.0f; - auto camPos = g_twp->cameraPos() - halfScreenSize; + auto camPos = g_twp->cameraPos(); if (ImGui::DragFloat2("Camera pos", camPos.getData())) { g_twp->follow(nullptr); g_twp->cameraAt(camPos); diff --git a/engines/twp/twp.cpp b/engines/twp/twp.cpp index 331bc0e7c84..86fe6648c76 100644 --- a/engines/twp/twp.cpp +++ b/engines/twp/twp.cpp @@ -488,9 +488,9 @@ void TwpEngine::update(float elapsed) { // if cursor is in the margin of the screen and if camera can move again // then show a left arrow or right arrow Math::Vector2d screenSize = _room->getScreenSize(); - if ((scrPos.getX() < SCREEN_MARGIN) && (cameraPos().getX() >= 1.f)) { + if ((scrPos.getX() < SCREEN_MARGIN) && (_gfx.cameraPos().getX() >= 1.f)) { _inputState.setCursorShape(CursorShape::Left); - } else if ((scrPos.getX() > (SCREEN_WIDTH - SCREEN_MARGIN)) && cameraPos().getX() < (_room->_roomSize.getX() - screenSize.getX())) { + } else if ((scrPos.getX() > (SCREEN_WIDTH - SCREEN_MARGIN)) && _gfx.cameraPos().getX() < (_room->_roomSize.getX() - screenSize.getX())) { _inputState.setCursorShape(CursorShape::Right); } else if (_room->_fullscreen == FULLSCREENROOM && _noun1) { // if the object is a door, it has a flag indicating its direction: left, right, front, back @@ -876,7 +876,6 @@ Common::Error TwpEngine::run() { Common::Event e; uint time = _system->getMillis(); while (!shouldQuit()) { - Math::Vector2d camPos = _gfx.cameraPos(); while (_system->getEventManager()->pollEvent(e)) { switch (e.type) { case Common::EVENT_CUSTOM_ENGINE_ACTION_START: { @@ -1025,8 +1024,6 @@ Common::Error TwpEngine::run() { } } - _gfx.cameraPos(camPos); - uint32 newTime = _system->getMillis(); uint32 delta = newTime - time; time = newTime; @@ -1497,10 +1494,6 @@ void TwpEngine::cameraAt(const Math::Vector2d &at) { } Math::Vector2d TwpEngine::cameraPos() { - if (_room) { - Math::Vector2d screenSize = _room->getScreenSize(); - return _camera->getAt() + screenSize / 2.0f; - } return _camera->getAt(); }