From c2a8a0c2c4192eab5ff8cdf855a561755c957356 Mon Sep 17 00:00:00 2001 From: Nipun Garg Date: Fri, 16 Aug 2019 14:20:29 +0530 Subject: HDB: Fix PPC Double Click code --- engines/hdb/hdb.cpp | 19 ------------------- engines/hdb/input.cpp | 24 ++++++++++++++++++++++-- 2 files changed, 22 insertions(+), 21 deletions(-) (limited to 'engines') diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp index 4b4bc86c21..68f505b931 100644 --- a/engines/hdb/hdb.cpp +++ b/engines/hdb/hdb.cpp @@ -408,25 +408,6 @@ void HDBGame::setTargetXY(int x, int y) { if (p->touchpWait) return; - // Double-Clicking on the player to open inventory? - if (g_hdb->isPPC()) { - if (x == px && y == py) { - static uint32 dblClickTimer = 0; - - if (dblClickTimer) { - debug("Double Click Timer: %d", dblClickTimer); - debug("Click Timer Diff: %d", (int)(g_system->getMillis() - dblClickTimer)); - } - - if (dblClickTimer && ((int)(g_system->getMillis() - dblClickTimer) < (int)(kGameFPS * 5 * 1000 / 60))) { - g_hdb->_window->openInventory(); - dblClickTimer = 0; - } else - dblClickTimer = g_system->getMillis(); - return; - } - } - // If we're attacking...don't do anything else AIState stateList[] = { STATE_ATK_CLUB_UP, STATE_ATK_CLUB_DOWN, STATE_ATK_CLUB_LEFT, STATE_ATK_CLUB_RIGHT, diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp index 0a3cfb2d23..333c227d64 100644 --- a/engines/hdb/input.cpp +++ b/engines/hdb/input.cpp @@ -376,10 +376,30 @@ void Input::stylusDown(int x, int y) { return; } - // Toggle Walk Speed if we clicked Player - static uint32 lastRunning = g_system->getMillis(); + // Double-Clicking on the player to open inventory? int nx, ny; g_hdb->_ai->getPlayerXY(&nx, &ny); + if (g_hdb->isPPC()) { + if (nx == worldX && ny == worldY) { + static uint32 dblClickTimer = 0; + + if (dblClickTimer && ((int)(g_system->getMillis() - dblClickTimer) < (int)(kGameFPS * 1000 / 60))) { + g_hdb->_window->openInventory(); + dblClickTimer = 0; + g_hdb->_ai->togglePlayerRunning(); + if (g_hdb->_ai->playerRunning()) + g_hdb->_window->centerTextOut("Running Speed", g_hdb->_screenHeight - 32, kRunToggleDelay * kGameFPS); + else + g_hdb->_window->centerTextOut("Walking Speed", g_hdb->_screenHeight - 32, kRunToggleDelay * kGameFPS); + g_hdb->_sound->playSound(SND_SWITCH_USE); + return; + } else + dblClickTimer = g_system->getMillis(); + } + } + + // Toggle Walk Speed if we clicked Player + static uint32 lastRunning = g_system->getMillis(); if (nx == worldX && ny == worldY) { if (lastRunning > g_system->getMillis()) return; -- cgit v1.2.3