[Scummvm-git-logs] scummvm master -> 3f41556117225c5edf998f1ffb89e1bdb68b0f41
mgerhardy
martin.gerhardy at gmail.com
Wed Nov 18 19:30:33 UTC 2020
This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
becdd25646 TWINE: allow to leave a menu with esc
bf407a06d9 TWINE: added mouse cursor hovering helper function to input code
d2277d0c22 TWINE: prepare for mouse ui support
c9dfcf2474 TWINE: inlined constant
dbe7f30f93 TWINE: reduced scope
b46ab6d686 TWINE: fixed segfault
3f41556117 TWINE: allow to disable all actors in a scene but one
Commit: becdd256469b11f761f4f90a14a5661cbd5bd3ab
https://github.com/scummvm/scummvm/commit/becdd256469b11f761f4f90a14a5661cbd5bd3ab
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-18T20:29:43+01:00
Commit Message:
TWINE: allow to leave a menu with esc
Changed paths:
engines/twine/menu.cpp
engines/twine/menu.h
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index 38e93f6925..30bbbcf56a 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -518,6 +518,14 @@ int32 Menu::processMenu(MenuSettings *menuSettings) {
if (_engine->shouldQuit()) {
return kQuitEngine;
}
+ if (_engine->_input->toggleActionIfActive(TwinEActionType::UIAbort)) {
+ for (int i = 0; i < menuSettings->getButtonCount(); ++i) {
+ const int16 textId = menuSettings->getButtonTextId(i);
+ if (textId == TextId::kReturnMenu || textId == TextId::kReturnGame || textId == TextId::kContinue) {
+ return textId;
+ }
+ }
+ }
_engine->_system->delayMillis(10);
} while (!_engine->_input->toggleActionIfActive(TwinEActionType::UIEnter));
diff --git a/engines/twine/menu.h b/engines/twine/menu.h
index 91dd952488..e245f9c6a8 100644
--- a/engines/twine/menu.h
+++ b/engines/twine/menu.h
@@ -51,11 +51,11 @@ private:
Common::String _buttonTexts[MAX_BUTTONS];
int8 _activeButtonIdx = 0;
+public:
int16 getButtonTextId(int buttonIndex) const {
return _settings[MenuSettings_FirstButton + buttonIndex * 2];
}
-public:
void reset() {
for (int32 i = 0; i < MAX_BUTTONS; ++i) {
_buttonTexts[i] = "";
Commit: bf407a06d964ea25a30670a7796d83b274856a08
https://github.com/scummvm/scummvm/commit/bf407a06d964ea25a30670a7796d83b274856a08
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-18T20:29:43+01:00
Commit Message:
TWINE: added mouse cursor hovering helper function to input code
Changed paths:
engines/twine/input.cpp
engines/twine/input.h
diff --git a/engines/twine/input.cpp b/engines/twine/input.cpp
index dcf2dd8404..c3ea39196d 100644
--- a/engines/twine/input.cpp
+++ b/engines/twine/input.cpp
@@ -238,4 +238,9 @@ void Input::getMousePositions(MouseStatusStruct *mouseData) {
mouseData->y = point.y;
}
+bool Input::isMouseHovering(int32 left, int32 top, int32 right, int32 bottom) const {
+ Common::Point point = g_system->getEventManager()->getMousePos();
+ return point.x >= left && point.x <= right && point.y >= top && point.y <= bottom;
+}
+
} // namespace TwinE
diff --git a/engines/twine/input.h b/engines/twine/input.h
index 15d6e3aaeb..9aaf9339be 100644
--- a/engines/twine/input.h
+++ b/engines/twine/input.h
@@ -129,6 +129,8 @@ public:
*/
bool isActionActive(TwinEActionType actionType, bool onlyFirstTime = true) const;
+ bool isMouseHovering(int32 left, int32 top, int32 right, int32 bottom) const;
+
/**
* @brief If the action is active, the internal state is reset and a following call of this method won't return
* @c true anymore
Commit: d2277d0c22ee0c81f8fb4c79497bd3dd992c2ed0
https://github.com/scummvm/scummvm/commit/d2277d0c22ee0c81f8fb4c79497bd3dd992c2ed0
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-18T20:29:43+01:00
Commit Message:
TWINE: prepare for mouse ui support
Changed paths:
engines/twine/menu.cpp
engines/twine/menu.h
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index 30bbbcf56a..7594d79955 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -55,8 +55,6 @@ namespace TwinE {
Used when returning from credit sequence to redraw the main menu background image */
static const uint32 kPlasmaEffectFilesize = 262176;
-/** Menu buttons width */
-static const uint16 kMainMenuButtonWidth = 320;
/** Used to calculate the spanning between button and screen */
static const uint16 kMainMenuButtonSpan = 550;
@@ -243,14 +241,7 @@ void Menu::drawBox(int32 left, int32 top, int32 right, int32 bottom) {
_engine->_interface->drawLine(left + 1, bottom, right, bottom, 73); // bottom line
}
-void Menu::drawButtonGfx(const MenuSettings *menuSettings, int32 width, int32 topheight, int32 buttonId, const char *dialText, bool hover) {
- const int32 left = width - kMainMenuButtonSpan / 2;
- const int32 right = width + kMainMenuButtonSpan / 2;
-
- // topheight is the center Y pos of the button
- const int32 top = topheight - 25; // this makes the button be 50 height
- const int32 bottom = topheight + 25;
-
+void Menu::drawButtonGfx(const MenuSettings *menuSettings, int32 left, int32 top, int32 right, int32 bottom, int32 buttonId, const char *dialText, bool hover) {
if (hover) {
if (menuSettings == &volumeMenuState && buttonId <= MenuButtonTypes::kMasterVolume && buttonId >= MenuButtonTypes::kMusicVolume) {
int32 newWidth = 0;
@@ -303,12 +294,12 @@ void Menu::drawButtonGfx(const MenuSettings *menuSettings, int32 width, int32 to
_engine->_text->setFontColor(15);
_engine->_text->setFontParameters(2, 8);
const int32 textSize = _engine->_text->getTextSize(dialText);
- _engine->_text->drawText(width - (textSize / 2), topheight - 18, dialText);
+ _engine->_text->drawText((SCREEN_WIDTH / 2) - (textSize / 2), top + 7, dialText);
_engine->copyBlockPhys(left, top, right, bottom);
}
-void Menu::drawButtons(MenuSettings *menuSettings, bool hover) {
+int16 Menu::drawButtons(MenuSettings *menuSettings, bool hover) {
int16 buttonNumber = menuSettings->getActiveButton();
const int32 maxButton = menuSettings->getButtonCount();
int32 topHeight = menuSettings->getButtonBoxHeight();
@@ -320,9 +311,11 @@ void Menu::drawButtons(MenuSettings *menuSettings, bool hover) {
}
if (maxButton <= 0) {
- return;
+ return -1;
}
+ int16 mouseActiveButton = -1;
+
for (int16 i = 0; i < maxButton; ++i) {
if (menuSettings == &advOptionsMenuState) {
int16 id = menuSettings->getButtonState(i);
@@ -365,20 +358,28 @@ void Menu::drawButtons(MenuSettings *menuSettings, bool hover) {
}
const int32 menuItemId = menuSettings->getButtonState(i);
const char *text = menuSettings->getButtonText(_engine->_text, i);
+ const int32 left = (SCREEN_WIDTH / 2) - kMainMenuButtonSpan / 2;
+ const int32 right = (SCREEN_WIDTH / 2) + kMainMenuButtonSpan / 2;
+ const int32 top = topHeight - 25;
+ const int32 bottom = topHeight + 25;
if (hover) {
if (i == buttonNumber) {
- drawButtonGfx(menuSettings, kMainMenuButtonWidth, topHeight, menuItemId, text, hover);
+ drawButtonGfx(menuSettings, left, top, right, bottom, menuItemId, text, hover);
}
} else {
if (i == buttonNumber) {
- drawButtonGfx(menuSettings, kMainMenuButtonWidth, topHeight, menuItemId, text, true);
+ drawButtonGfx(menuSettings, left, top, right, bottom, menuItemId, text, true);
} else {
- drawButtonGfx(menuSettings, kMainMenuButtonWidth, topHeight, menuItemId, text, false);
+ drawButtonGfx(menuSettings, left, top, right, bottom, menuItemId, text, false);
}
}
+ if (_engine->_input->isMouseHovering(left, top, right, bottom)) {
+ mouseActiveButton = i;
+ }
topHeight += 56; // increase button top height
}
+ return mouseActiveButton;
}
int32 Menu::processMenu(MenuSettings *menuSettings) {
@@ -509,12 +510,19 @@ int32 Menu::processMenu(MenuSettings *menuSettings) {
menuSettings->setActiveButton(currentButton);
// draw all buttons
- drawButtons(menuSettings, false);
+ const int16 mouseButtonHovered = drawButtons(menuSettings, false);
+ if (mouseButtonHovered != -1) {
+ currentButton = mouseButtonHovered;
+ }
buttonsNeedRedraw = false;
}
// draw plasma effect for the current selected button
- drawButtons(menuSettings, true);
+ const int16 mouseButtonHovered = drawButtons(menuSettings, true);
+ if (mouseButtonHovered != -1) {
+ currentButton = mouseButtonHovered;
+ }
+
if (_engine->shouldQuit()) {
return kQuitEngine;
}
diff --git a/engines/twine/menu.h b/engines/twine/menu.h
index e245f9c6a8..05239b8d3f 100644
--- a/engines/twine/menu.h
+++ b/engines/twine/menu.h
@@ -146,20 +146,18 @@ private:
/**
* Draws main menu button
- * @param width menu button width
- * @param topheight is the height between the top of the screen and the first button
* @param buttonId current button identification from menu settings
* @param dialText
* @param hover flag to know if should draw as a hover button or not
*/
- void drawButtonGfx(const MenuSettings *menuSettings, int32 width, int32 topheight, int32 buttonId, const char *dialText, bool hover);
+ void drawButtonGfx(const MenuSettings *menuSettings, int32 left, int32 top, int32 right, int32 bottom, int32 buttonId, const char *dialText, bool hover);
void plasmaEffectRenderFrame();
/**
* Process the menu button draw
* @param data menu settings array
* @param mode flag to know if should draw as a hover button or not
*/
- void drawButtons(MenuSettings *menuSettings, bool hover);
+ int16 drawButtons(MenuSettings *menuSettings, bool hover);
/** Used to run the advanced options menu */
int32 advoptionsMenu();
/** Used to run the volume menu */
Commit: c9dfcf24745ce133aba05b0ccca5ff49824f06dc
https://github.com/scummvm/scummvm/commit/c9dfcf24745ce133aba05b0ccca5ff49824f06dc
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-18T20:29:43+01:00
Commit Message:
TWINE: inlined constant
Changed paths:
engines/twine/menu.cpp
diff --git a/engines/twine/menu.cpp b/engines/twine/menu.cpp
index 7594d79955..e29800b458 100644
--- a/engines/twine/menu.cpp
+++ b/engines/twine/menu.cpp
@@ -55,9 +55,6 @@ namespace TwinE {
Used when returning from credit sequence to redraw the main menu background image */
static const uint32 kPlasmaEffectFilesize = 262176;
-/** Used to calculate the spanning between button and screen */
-static const uint16 kMainMenuButtonSpan = 550;
-
namespace MenuButtonTypes {
enum _MenuButtonTypes {
kMusicVolume = 1,
@@ -358,10 +355,12 @@ int16 Menu::drawButtons(MenuSettings *menuSettings, bool hover) {
}
const int32 menuItemId = menuSettings->getButtonState(i);
const char *text = menuSettings->getButtonText(_engine->_text, i);
- const int32 left = (SCREEN_WIDTH / 2) - kMainMenuButtonSpan / 2;
- const int32 right = (SCREEN_WIDTH / 2) + kMainMenuButtonSpan / 2;
- const int32 top = topHeight - 25;
- const int32 bottom = topHeight + 25;
+ const uint16 mainMenuButtonWidthHalf = 550 / 2;
+ const uint16 mainMenuButtonHeightHalf = 50 / 2;
+ const int32 left = (SCREEN_WIDTH / 2) - mainMenuButtonWidthHalf;
+ const int32 right = (SCREEN_WIDTH / 2) + mainMenuButtonWidthHalf;
+ const int32 top = topHeight - mainMenuButtonHeightHalf;
+ const int32 bottom = topHeight + mainMenuButtonHeightHalf;
if (hover) {
if (i == buttonNumber) {
drawButtonGfx(menuSettings, left, top, right, bottom, menuItemId, text, hover);
Commit: dbe7f30f9302855936b29182c061cd271ff199f9
https://github.com/scummvm/scummvm/commit/dbe7f30f9302855936b29182c061cd271ff199f9
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-18T20:29:43+01:00
Commit Message:
TWINE: reduced scope
Changed paths:
engines/twine/text.cpp
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index 7cc7d013fb..f99dd03889 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -303,9 +303,8 @@ void Text::initInventoryDialogueBox() { // SecondInitDialWindow
// TODO: refactor this code
void Text::initText(int32 index) {
- printTextVar13 = 0;
-
if (!getText(index)) {
+ printTextVar13 = 0;
return;
}
@@ -777,14 +776,13 @@ void Text::textClipSmall() { // newGame4
}
void Text::drawAskQuestion(int32 index) {
- int32 textStatus = 1;
-
// get right VOX entry index
initVoxToPlay(index);
initText(index);
initDialogueBox();
+ int32 textStatus = 1;
do {
_engine->readKeys();
textStatus = printText10();
Commit: b46ab6d686736e1338c827cd86bcba00f671f153
https://github.com/scummvm/scummvm/commit/b46ab6d686736e1338c827cd86bcba00f671f153
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-18T20:29:43+01:00
Commit Message:
TWINE: fixed segfault
Changed paths:
engines/twine/sound.cpp
diff --git a/engines/twine/sound.cpp b/engines/twine/sound.cpp
index 2b501ee3dd..855af41ed3 100644
--- a/engines/twine/sound.cpp
+++ b/engines/twine/sound.cpp
@@ -69,7 +69,7 @@ void Sound::playFlaSample(int32 index, int32 frequency, int32 repeat, int32 x, i
return;
}
- uint8 *sampPtr;
+ uint8 *sampPtr = nullptr;
const int32 sampSize = HQR::getAllocEntry(&sampPtr, Resources::HQR_FLASAMP_FILE, index);
if (sampSize == 0) {
warning("Failed to load %s", Resources::HQR_FLASAMP_FILE);
Commit: 3f41556117225c5edf998f1ffb89e1bdb68b0f41
https://github.com/scummvm/scummvm/commit/3f41556117225c5edf998f1ffb89e1bdb68b0f41
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-18T20:29:43+01:00
Commit Message:
TWINE: allow to disable all actors in a scene but one
this allows easier debugging of actor behaviours
Changed paths:
engines/twine/console.cpp
engines/twine/console.h
engines/twine/debug_scene.h
engines/twine/scene.cpp
engines/twine/scene.h
diff --git a/engines/twine/console.cpp b/engines/twine/console.cpp
index 6f738929b2..cc6c186c67 100644
--- a/engines/twine/console.cpp
+++ b/engines/twine/console.cpp
@@ -39,6 +39,7 @@ TwinEConsole::TwinEConsole(TwinEEngine *engine) : _engine(engine), GUI::Debugger
registerCmd("toggle_zones", WRAP_METHOD(TwinEConsole, doToggleZoneRendering));
registerCmd("toggle_freecamera", WRAP_METHOD(TwinEConsole, doToggleFreeCamera));
registerCmd("toggle_scenechanges", WRAP_METHOD(TwinEConsole, doToggleSceneChanges));
+ registerCmd("scene_actor", WRAP_METHOD(TwinEConsole, doSkipSceneActorsBut));
}
TwinEConsole::~TwinEConsole() {
@@ -64,6 +65,17 @@ bool TwinEConsole::doToggleZoneRendering(int argc, const char **argv) {
return true;
}
+bool TwinEConsole::doSkipSceneActorsBut(int argc, const char **argv) {
+ if (argc < 2) {
+ debug("Usage: give actor id of scene or -1 to disable");
+ return false;
+ }
+ const int16 actorIdx = atoi(argv[1]);
+ debug("Only load actor %d in the next scene", actorIdx);
+ _engine->_debugScene->onlyLoadActor = actorIdx;
+ return true;
+}
+
bool TwinEConsole::doToggleFreeCamera(int argc, const char **argv) {
TOGGLE_DEBUG(_engine->_debugGrid->useFreeCamera, "free camera movement")
return true;
diff --git a/engines/twine/console.h b/engines/twine/console.h
index 454c1a1dc1..4b41171e5a 100644
--- a/engines/twine/console.h
+++ b/engines/twine/console.h
@@ -42,6 +42,7 @@ private:
bool doToggleZoneRendering(int argc, const char **argv);
bool doToggleFreeCamera(int argc, const char **argv);
bool doToggleSceneChanges(int argc, const char **argv);
+ bool doSkipSceneActorsBut(int argc, const char **argv);
public:
TwinEConsole(TwinEEngine *engine);
~TwinEConsole() override;
diff --git a/engines/twine/debug_scene.h b/engines/twine/debug_scene.h
index 89c0405795..2c1ea8fb94 100644
--- a/engines/twine/debug_scene.h
+++ b/engines/twine/debug_scene.h
@@ -40,6 +40,7 @@ public:
DebugScene(TwinEEngine *engine);
bool showingZones = false;
int32 typeZones = 127; // all zones on as default
+ int16 onlyLoadActor = -1;
void displayZones();
};
diff --git a/engines/twine/scene.cpp b/engines/twine/scene.cpp
index 41cdb7af15..1fd03fadc5 100644
--- a/engines/twine/scene.cpp
+++ b/engines/twine/scene.cpp
@@ -27,6 +27,7 @@
#include "twine/actor.h"
#include "twine/animations.h"
#include "twine/debug_grid.h"
+#include "twine/debug_scene.h"
#include "twine/extra.h"
#include "twine/gamestate.h"
#include "twine/grid.h"
@@ -178,7 +179,8 @@ bool Scene::loadSceneLBA1() {
stream.skip(sceneHero->lifeScriptSize);
sceneNumActors = stream.readUint16LE();
- for (int32 i = 1; i < sceneNumActors; i++) {
+ int cnt = 1;
+ for (int32 i = 1; i < sceneNumActors; i++, cnt++) {
_engine->_actor->resetActor(i);
ActorStruct* act = &_sceneActors[i];
@@ -218,6 +220,11 @@ bool Scene::loadSceneLBA1() {
act->lifeScriptSize = stream.readUint16LE();
act->lifeScript = currentScene + stream.pos();
stream.skip(act->lifeScriptSize);
+
+ if (_engine->_debugScene->onlyLoadActor != -1 && _engine->_debugScene->onlyLoadActor != cnt) {
+ sceneNumActors--;
+ i--;
+ }
}
sceneNumZones = stream.readUint16LE();
diff --git a/engines/twine/scene.h b/engines/twine/scene.h
index 445eae97a6..28d65c855d 100644
--- a/engines/twine/scene.h
+++ b/engines/twine/scene.h
@@ -236,6 +236,25 @@ enum LBA1SceneId {
#define IS_HERO(x) (x) == OWN_ACTOR_SCENE_INDEX
class TwinEEngine;
+
+/**
+ * scene 0: 23 actors
+ *
+ * scene 1: 14 actors
+ * actor 1 - car
+ * actor 2 - elephant
+ * actor 3 - soldier at the house
+ * actor 4 - patrolling soldier before gate
+ * actor 5 - soldier after gate
+ * actor 6 - ??
+ * actor 7 - ??
+ * actor 8 - left gate
+ * actor 9 - ??
+ * actor 10 - door after leaving truck
+ * actor 11 - door subway
+ * actor 12 - guy at rubbish
+ * actor 13 - ??
+ */
class Scene {
private:
TwinEEngine *_engine;
More information about the Scummvm-git-logs
mailing list