[Scummvm-git-logs] scummvm master -> 4563a2b938c3704cdf226c2bd95f5a17adf1b531
sev-
noreply at scummvm.org
Tue Dec 1 00:04:49 UTC 2026
This automated email contains information about 170 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
891f101813 NGI: Log the tremble items with the scenelogic debug flag
8909065619 NGI: Create the stub objects for the PHYSICS, PHYSOBJ, SELECTION, MOVEANI and MOTIONCONTROLLER elements
96f6da33cc NGI: Let a tap walk and interact in every scene of an XML project
e5efe9e74b NGI: Start the scene 3 logic for XML projects
c3d1f735b1 NGI: Port the Android differences of the scene 3 controller
13122b9cd2 NGI: Move the Full Pipe specific files to fullpipe/
79c309f156 NGI: Load the lift passages and number the lift buttons as the Android game does
cfc2583919 NGI: Add the lift button panel of the Android game
000b62a559 NGI: Start the scene 4 logic for XML projects
38b29ebe0b NGI: Run the spring of scene 4 once per 83 ms on Android
f05880ed97 NGI: Add the progress bar GUI element of the Android game
75252c54a1 NGI: Add the text GUI elements and the text printing of the Android game
6151f5100e NGI: Show the notebook bonus texts through the GUI elements
1fccd3f259 NGI: Show the inventory buttons in every scene of the Android game
5006e9ebff NGI: Add the arcade interface of the Android game
ce66494847 NGI: Port the arcade of scene 4 of the Android game
3e709227c9 NGI: Place the bottle under the hand as the Android game does
1e43331a5c NGI: Add the test mode with the ImGui Info window
8326c930c0 NGI: Walk to the hero point of an interaction exactly as the GO_MCTL command does
e66a3711a6 NGI: Warn when an Android movement is stopped before its last frame
441fc3c847 NGI: Show the Android Full Pipe on a wide screen
57a423b872 NGI: Scene 4 camera, ladder hint and the arcade button as in the Android controller
65fab4fcaa NGI: Draw the black bars of the scene edges as CFPController::OnRenderTop does
6c79c1d718 NGI: Mark the Android constants
fb9d323a87 NGI: Draw the widescreen bars as CRender::DrawWidescreenOfs does
1e15ae4307 NGI: Show the widescreen bars per scene as CRender::SetSrcRect decides
fbaf5f20a9 NGI: Start the camera of a scrolling scene at the widescreen margin as CFPController::OnShow does
45bd8f2899 NGI: Add FPController with the camera, touch scrolling and swipe walking of CFPController
c6c8c83d48 NGI: Add ISceneController and the controller classes of the scenes, replace the scene hooks with virtual methods
78bea7877a NGI: Make SkipArcade and ExecuteUserCmd virtual controller methods, derive Sc19Controller from Sc18Controller
812d6cca4d NGI: Add the scene stack of CGame, CChapterController as a pushed scene and CFader
f416e495e9 NGI: Make CNotebookController a controller of its pushed scene, drop the modal notebook
51b415a25a NGI: Add CInventoryController with OnGuiEvent, CFPController::OnGuiEvent and CSc01Controller::OnGuiEvent
f3a44cc668 NGI: Add CLift and CLiftController, the lift view is a pushed scene, CFPController::OnMessage for the lift messages
753990757e NGI: Queue the door commands of CLift::CloseDoorAndGo so the door closes before the ride
c0c28c27d0 NGI: Port CAniObject::SetStatic, the Android copy constructor, CScene::RemoveCopies, CScene::Message, ExecuteUserCmd sce
e94a782cf9 NGI: Add SoundManager with the scene sound pause of PushScene/PopScene and the scene of MessageQueue
a2311bc4d1 NGI: Add the Android cursor model of CCursorController (position, object, hit objects) and use it for the camera and the
065630710b NGI: Renames in class Inventory
ac401375e5 NGI: Renames in class NGIEngine
ffd239458d NGI: Port CXmlNode, CInventoryItem and CInventory (Android inventory scene, not wired yet)
5a63e3db6f NGI: Read the older XML font format of CFont (dlg.xml, dbg.xml)
264b0343f4 NGI: Use the Android CInventory scene, CursorController::Render and CInventoryController for the XML projects
aa8a792872 NGI: Port CSc01Controller::IsInventoryEnabled and drop the Windows inventory scroll stubs
5029d45732 NGI: CLift::SwitchToBigView calls CInventory::TakeFromCursor with 0, 0
b2a03281f1 NGI: Port CTutorial and CTutorialManager, read tutorials.xml as a tree
f6c240b46b NGI: Port CExit and CExitManager, drive them from FPController, port CSc01Controller::OnGuiEvent exits
0a0d30bd68 NGI: Use named constants for the exit arrows, the tutorial marker and the scene ids
e157cc4599 NGI: Port CTutorialController (not wired yet: the CheckTutorial state machines of the scenes are next)
410661c611 NGI: Wire the tutorials: CheckTutorial of scenes 1 to 3 and the notebook, the tutorial controller replaces ModalTutorial
2720e82d55 NGI: Tutorial man idles again, arrows show, the boot of scene 3 can be picked
162061c1e1 NGI: Tutorial: the scene below keeps running, the man is pulled up, arrows shake, the tap shows the react shine
d6a874d922 NGI: Do not delete the animations that belong to another scene when a scene goes away
2fc75898e6 NGI: Tutorial: place the cloud by the top left of the man, also when he is mirrored
6c3ca0107f NGI: GameObject::getPosition and setPosition (top left of the texture), the tutorial uses them
00a3af1991 NGI: Android movement control flow: reverse, cycled, startFrame, no queue bail-out, the rest of a stopped movement plays
6ca53bcab6 NGI: CRegion
f27764fbf2 NGI: Scene::runQueue with the interrupt state, MessageQueue::canInterrupt, Command::getParamFloat, BehaviorMove::setEnab
01d74f3352 NGI: FPController hooks for the ported controllers (controllerRunsSceneLogic, OnSceneInit, random helpers), arcade tutor
badbdf564e NGI: Object names used by the ported controllers
a29b13254b NGI: Scene 4 controller ported
ef17e67929 NGI: Scene 6 controller ported
0671fc3aed NGI: Scene 8 controller ported
b675481c33 NGI: Scene 9 controller ported
ce07ebae6c NGI: Scene 11 controller ported
2bc6106862 NGI: Scene 14 controller ported
eaeda9ab8b NGI: Scene 17 controller ported
23fb53fd66 NGI: Scene 27 controller ported
da453c06b0 NGI: Scene 29 controller ported
0572df3111 NGI: Scene 38 controller ported
e65ec3dc68 NGI: AniObject::setStatic with the mirror, MoveToStatic (linked movement chain), GetCurFrame/SetCurFrame, GameObject::is
bce67c7c7a NGI: MessageQueue::stop and setObjectCopyAll, Command::setParamFloat, Scene::runQueueObject and stopAllQueues
faced66d8a NGI: Shared helpers of the scene controllers (command builders, HideAction, stubs)
87605fe3a8 NGI: Scene 4 controller uses the shared helpers
84d8ecb805 NGI: Scene 6 controller uses the shared helpers
70d40598f8 NGI: Scene 8 controller uses the shared helpers
8463a0473c NGI: Scene 9 controller uses the shared helpers
f36d4b907e NGI: Scene 11 controller uses the shared helpers
d026f6031f NGI: Scene 14 controller uses the shared helpers
7103c6730e NGI: Scene 27 controller uses the shared helpers
ae55c429ca NGI: Scene 29 controller uses the shared helpers
dd1bfade89 NGI: Scene 38 controller uses the shared helpers
2998f8b8f8 NGI: Scene 1 controller in its own file
0c2666a19b NGI: Scene 2 controller in its own file
7117d62124 NGI: Scene 3 controller in its own file
61bc979dc7 NGI: Scene 4 controller methods of scene04.cpp in sc04controller.cpp
814c8c5e21 NGI: testmode moved to debugger/
84dd2afc6c NGI: NGI_TEST_SETUP: states, items and the camera for a test run
48c58c233c NGI: Scene 4 tutorial follows the arcade that the scene handler runs
98ccddc8b9 NGI: The test setup comes from --start-movie, no getenv
2d25e46e7d BASE: --start-movie also for the NGI engine (the test setup)
e265166c7a NGI: FPGuiController (CFPGuiController)
df16fd8b88 NGI: Map (CMap), the state of the map of the game
5594239455 NGI: MainMenuController (CMainMenu)
774217209a NGI: MapWindowController (CMapWindow), the TUTORIAL_USE_MAP zone
079fdb490c NGI: ObjHelperManager, ObjHelperHint and ObjHelper (the object helper)
f9adfd72cb NGI: HintManager (CHintManager) and the hints of the controllers
0df9c0ac98 NGI: Help (CHelp, CHelpItem, CHelpController)
28c9ed8109 NGI: NoActionLogger (CNoActionLogger)
1ebf41ad5f NGI: The lift tutorials and the EXTRA_TUTORIAL_SEE_EXTRA_HELP zone
ed8f599c10 NGI: Scene 4 controller sets the map object of the third scene
349168857c NGI: Draw 8 bit textures with their palette, scaled ones without rotation, and skip those that have none
d567c4e38e NGI: A pending scene replaces the whole stack of scenes, every one of them is hidden (CGame::DoSetScene)
f3e9d9373a NGI: SHOW of the Android build does not look at the queue of the object
23274f18e5 NGI: Log TUTORIAL ready when the bubble of a tutorial is shown
cc361c8cbc NGI: Hero queue id in the info line of the test mode
b70c4a80cb NGI: Notebook: the label Task, the tab numbers and the check mark as in RenderBookMarks, BitmapFont::printRotate
6436acd45c NGI: AchievementsManager and Achievement (CAchievementsManager), the banner and the ScummVM achievements
a5bafce508 NGI: The item on the cursor is hidden in the inventory and has a green outline over what it can be used on (CFPControlle
8edb096c70 NGI: Sc01Controller (CSc01Controller): all methods, MSG_DISABLE_EXIT_MANAGER reaches it through the chapter controller
6ffb381370 NGI: Sc02Controller (CSc02Controller): all methods
7b0191d113 NGI: Sc03Controller (CSc03Controller): all methods
2b118d0739 NGI: WaitScreen (CWaitScreen, CWaitScreenController): the crawling screen while the textures of a scene load
a377c6893c NGI: CUtils::SetManSpeed: the walk, the ladders and the pipes of the hero are faster
c4adf618b9 NGI: Time of the movements and of the hero in the debug output
3ccaa54425 NGI: WaitScreen shows the bar before a load and services events while it draws
3a8d2b0b2f NGI: GameProject shows the wait screen before it loads a scene
c49287c4a8 NGI: Wait screen steps per picture and animation like CScene::LoadPictures and LoadAnis
fb183a06f7 NGI: PreloadManager (CPreloadManager): the textures of the scenes are loaded and freed with the scene stack
554373bcfc NGI: Texture loads and unloads with a load count (CRenderResources), PictureObject::load and unload
6b0326244a NGI: GuiManager loads and unloads the textures of its elements (CGuiManager::Load, Unload)
0c0fcbe7f5 NGI: Movement and AniObject load and unload their textures (CMovement::Load, CAniObject::Load, LoadMovement, PushToPrelo
b8a5d9c5f4 NGI: Scene loads and unloads its pictures, animations and roamings (CScene::LoadPictures to UnloadRoamings, GetLoadingPe
4d6c458a7f NGI: XML scenes: the PRELOAD items go to the PreloadManager and the textures are read when the scene is loaded
c551143e2b NGI: WaitScreen: the load of the bar and the percent come from the PreloadManager
62c8f6896e NGI: DoSetScene, PushScene, PopScene and the start of the game use the PreloadManager; debug flag skipIntro
499c069bd9 NGI: Test mode: the visit action, the walks and the interrupted movements in the INFO log
2cc212258e NGI: GUI pictures and buttons take their size from the texture when it is loaded (CGuiPicture::Load, CGuiButton::Load)
a23294c895 NGI: The textures of the second intro scene are loaded with the first, its skip button works again
6d6f37a32c NGI: AniObject::setCurFrame loads the texture of the phase it goes to, so the bar of the wait screen grows
fc40ba45ac NGI: The queue ids of the animations are cleared when the global queues are cleared (D30 mitigation)
535b2aaec4 NGI: INFO log of the interactions that are refused
a2ded47673 NGI: A tap walks Dude only without an object in the cursor (CFPController::OnMouseLKeyUp), INFO log of the drop of an it
343756bf27 NGI: Sc01Controller runs the scene logic of scene 1 (CSc01Controller diffed against the assembly)
fd47d49c8e NGI: Sc02Controller runs the scene logic of scene 2 (VisitScene and SetStatic as in the assembly)
c25ab7a473 NGI: Sc03Controller runs the scene logic of scene 3 (lift buttons, MSG_SC3_MOVEEGGEATER as in the assembly)
3bde420e99 NGI: The scenes 1 to 3 run from their controllers, no sceneHandler hook
ab2f0ffd6e NGI: StateManager (CStateManager): the states of the objects and the activity of the interactions
46bae777c3 NGI: A tap walks Dude and interrupts his interruptible queue (CFPController::CanInterruptManQueue, MctlStartMove), INFO
d8d92f7a58 NGI: MessageQueue has the Android state machine (CMessageQueue: Next, Update and the UpdateCmd polls, Stop, Interrupt, S
f0a50ab114 NGI: Scene owns and polls its queues (CScene::RunQueue, RunQueueWithAni, Update order, StopAllQueues, TryInterruptQueues
d804222319 NGI: AniObject keeps its queue as a pointer and tells nobody when a movement stops (CVisibleObject::SetQueue)
4581baead7 NGI: The walk queues are made as CMctrlMessageQueue and run through RunQueueWithAni
988d905056 NGI: Interactions and the inventory run their queues in the scene of the animation
d70f794b9a NGI: Loader, engine and XML project: queues stay with their scene, queue ids only for the Windows handlers
969257d9c3 NGI: FPController mctlStartMove, interruptManQueue and MSG_RESETDEST as in the original; the scene controllers use the n
18434a20df NGI: Test mode: the INFO log follows the new queues
73282a6a8f NGI: MSG_SC3_MOVEEGGEATER puts the egg eater at the position of the XML, not behind the box
33b622ab42 NGI: Port CInteract and CInteractionController of Android
dbe8146f6b NGI: Port the interaction queues and INTERACT messages of CMessageQueue
c7e3921b6a NGI: Port CScene interaction queues and OnMouseLKeyUp tail
3b597d5241 NGI: Port CAniObject linked movements and exact stop for interactions
45ba6d70ea NGI: Parse INTERACTION nodes like Android and route taps to the scene
c17a038dfe NGI: Port CFPController interaction walk (GO_MCTL, OnMouseLKeyUp) and drop the interaction stand-ins
6d0a69f640 NGI: Tutorial finish runs the rise queue with interrupt state 3
652c4f902c NGI: Log the state of Egggulper in the test mode info
966a19203a NGI: Run XML movements without phases like CAniObject::StartMovement
84494f486a NGI: Port CAniHandler::GetNumCycles frame counting
4e1ea92f1f NGI: Keep the last started movement id of an animation (CAniObject +168)
1f6a3d82bb NGI: Port CMctlLadder heights, stop and RunQueue, last movement id for the walk direction
be6cf427ad NGI: Make GameObject::setPos virtual so SetCenter keeps the movement of an animation in step
c5b68a5639 NGI: Port CMctlGraph::ResetObjMove for the failed walks of the 2015 build
68cc061cd7 NGI: The ladder turn commands of the 2015 build wait like CCommand(START_MOVEMENT, 1)
7ebbb78858 NGI: Port CMctlLadder::MakeQueue(ani, index, from, to)
1610fe2775 NGI: Test mode action ladder=STEP at MS for the ladder of scene 4
7c7ba57eea NGI: Say what of the scene 4 ladder was played in the STUB warning
870fad9c23 NGI: Debug flag noRandom for repeatable test runs
33280eb1e5 BASE: SURFACESDL: Initialize _numDirtyRects
4a483365a4 NGI: Fix compiler warnings
4563a2b938 NGI: Shorten comments
Commit: 891f101813ba0c53e1b80359efd815da8bc39227
https://github.com/scummvm/scummvm/commit/891f101813ba0c53e1b80359efd815da8bc39227
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Log the tremble items with the scenelogic debug flag
Changed paths:
engines/ngi/tremble.cpp
diff --git a/engines/ngi/tremble.cpp b/engines/ngi/tremble.cpp
index 2c4a64f180e..0e4d96b6d9e 100644
--- a/engines/ngi/tremble.cpp
+++ b/engines/ngi/tremble.cpp
@@ -176,6 +176,7 @@ TrembleItem *Tremble::addItem(GameObject *object) {
Common::Point offset;
if (_offsets.contains(object->_id))
offset = _offsets[object->_id];
+ debugC(2, kDebugSceneLogic, "Tremble::addItem: object %d (%s), offset %d, %d", object->_id, object->_title.c_str(), offset.x, offset.y);
TrembleItem *item = new TrembleItem(*scene, object, new AniObject(source), offset.x, offset.y);
_items.push_back(item);
return item;
@@ -251,6 +252,8 @@ void Tremble::repopulateItems() {
if (!scene || !g_ngi->_gameLoader || !getGameLoaderInteractionController())
return;
+ debugC(5, kDebugSceneLogic, "Tremble::repopulateItems: scene %d, %u int objects, %u vis objects", scene->_sceneId, _interactionObjects.size(), _visibleObjects.size());
+
getGameLoaderInteractionController()->getAllRunnableInteractions(scene, _interactions);
// an item that has neither an interaction that makes it shake nor a listed object goes away, one per call
Commit: 8909065619bab2e9f8074ff587eecd1d3a9eb9f7
https://github.com/scummvm/scummvm/commit/8909065619bab2e9f8074ff587eecd1d3a9eb9f7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Create the stub objects for the PHYSICS, PHYSOBJ, SELECTION, MOVEANI and MOTIONCONTROLLER elements
Changed paths:
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 0db9e1d56aa..4ff455cd4be 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -29,6 +29,7 @@
#include "ngi/statics.h"
#include "ngi/messages.h"
#include "ngi/physics.h"
+#include "ngi/sceneobjects.h"
#include "ngi/zcontroller.h"
#include "ngi/motion.h"
#include "ngi/gameloader.h"
@@ -266,6 +267,11 @@ Scene::~Scene() {
_aniObjects.clear();
+ for (PhysicalObject *object : _physicalObjects)
+ delete object;
+ for (Selection *selection : _selections)
+ delete selection;
+
g_ngi->_globalPalette = &g_ngi->_defaultPalette;
// delete _field_BC;
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index f218264ef31..4b2a04f4f70 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -37,6 +37,9 @@ class GameProject;
class BehaviorController;
class MctlCompound;
class PhysListener;
+class PhysicalObject;
+class Selection;
+class Motion8Controller;
class ZController;
struct Exit {
@@ -78,6 +81,12 @@ class Scene : public Background {
Common::ScopedPtr<GuiManager> _guiManager;
/** XML PHYSICS (CScene+56): the Box2D world, drawn between the layers; not implemented yet (physics.h) */
Common::ScopedPtr<PhysListener> _physListener;
+ /** XML PHYSOBJ / PHYSGROUND, owned (stubs, physics.h) */
+ Common::Array<PhysicalObject *> _physicalObjects;
+ /** XML SELECTION, owned (stubs, sceneobjects.h) */
+ Common::Array<Selection *> _selections;
+ /** XML MOTIONCONTROLLER (CScene+68, stub) */
+ Common::ScopedPtr<Motion8Controller> _motion8Controller;
/** XML ZCONTROLLER (CScene+72) */
Common::ScopedPtr<ZController> _zController;
/** CScNNController::OnRender: what the logic of the scene draws between the layers (CScene::Render, controller slot 25) */
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index b428011121f..28ace51d8bc 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -30,6 +30,8 @@
#include "ngi/objectnames.h"
#include "ngi/gameloader.h"
#include "ngi/behavior.h"
+#include "ngi/physics.h"
+#include "ngi/sceneobjects.h"
#include "ngi/tremble.h"
#include "ngi/zcontroller.h"
#include "ngi/constants.h"
@@ -914,32 +916,51 @@ private:
return true;
}
+ // CSelection::Init: the object is kept (stub methods, sceneobjects.h), the subtree is skipped
bool parserCallback_SELECTION(ParserNode *node) {
+ Common::ScopedPtr<Selection> selection(new Selection(&_scene));
+ if (!parseObject(*selection, *node))
+ return false;
+ _scene._selections.push_back(selection.release());
warning("STUB: XML <SELECTION>");
node->ignore = true;
return true;
}
+ // IObjectBuilder::CreateBaseObjects MOVEANI / MOVELINEANI
bool parserCallback_MOVEANI(ParserNode *node) {
- warning("STUB: XML <MOVEANI>");
- node->ignore = true;
- return true;
+ return addMoveAni(new MoveAniObject(&_scene), node, "MOVEANI");
}
bool parserCallback_MOVELINEANI(ParserNode *node) {
- warning("STUB: XML <MOVELINEANI>");
+ return addMoveAni(new MoveLineAniObject(&_scene), node, "MOVELINEANI");
+ }
+
+ bool addMoveAni(MoveAniObject *animation, ParserNode *node, const char *name) {
+ _scene.addAni(animation, true);
+ if (!parseObject(*animation, *node))
+ return false;
+ animation->_sceneId = _scene._sceneId;
+ warning("STUB: XML <%s>", name);
node->ignore = true;
return true;
}
+ // CPhysicalObject::Init / CPhysGround::Init: no Box2D world or geometries (physics.h)
bool parserCallback_PHYSOBJ(ParserNode *node) {
- warning("STUB: XML <PHYSOBJ>");
- node->ignore = true;
- return true;
+ return addPhysicalObject(new PhysicalObject(&_scene), node, "PHYSOBJ");
}
bool parserCallback_PHYSGROUND(ParserNode *node) {
- warning("STUB: XML <PHYSGROUND>");
+ return addPhysicalObject(new PhysGround(&_scene), node, "PHYSGROUND");
+ }
+
+ bool addPhysicalObject(PhysicalObject *object, ParserNode *node, const char *name) {
+ Common::ScopedPtr<PhysicalObject> owned(object);
+ if (!parseObject(*owned, *node))
+ return false;
+ _scene._physicalObjects.push_back(owned.release());
+ warning("STUB: XML <%s>", name);
node->ignore = true;
return true;
}
@@ -969,13 +990,17 @@ private:
return true;
}
+ // CScene::Init MOTIONCONTROLLER: the 8 direction grid controller (sceneobjects.h, stub)
bool parserCallback_MOTIONCONTROLLER(ParserNode *node) {
+ _scene._motion8Controller.reset(new Motion8Controller(&_scene, nullptr));
warning("STUB: XML <MOTIONCONTROLLER>");
node->ignore = true;
return true;
}
+ // CScene::Init PHYSICS: the Box2D world of the scene (physics.h, stub); its MATERIALS are skipped
bool parserCallback_PHYSICS(ParserNode *node) {
+ _scene._physListener.reset(new PhysListener(&_scene));
warning("STUB: XML <PHYSICS>");
node->ignore = true;
return true;
Commit: 96f6da33cc4a781759732c9f3069a72ca09b4a95
https://github.com/scummvm/scummvm/commit/96f6da33cc4a781759732c9f3069a72ca09b4a95
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Let a tap walk and interact in every scene of an XML project
Changed paths:
engines/ngi/fpcontroller.cpp
engines/ngi/fullpipe/scene01.cpp
engines/ngi/fullpipe/sceneTutorial.cpp
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/scenes.h
diff --git a/engines/ngi/fpcontroller.cpp b/engines/ngi/fpcontroller.cpp
index 560af6b2ac8..73baab1161a 100644
--- a/engines/ngi/fpcontroller.cpp
+++ b/engines/ngi/fpcontroller.cpp
@@ -24,6 +24,9 @@
#include "ngi/ngi.h"
#include "ngi/messages.h"
+#include "ngi/motion.h"
+#include "ngi/objectnames.h"
+#include "ngi/constants.h"
#include "ngi/gameloader.h"
#include "ngi/interaction.h"
#include "ngi/objects.h"
@@ -335,6 +338,48 @@ void sceneCamera_update(Scene &scene, uint32 elapsed) {
g_ngi->_sceneRect.moveTo(scene._x, scene._y);
}
+// CFPController::OnMouseLKeyUp (a tap) of every scene of an XML project: an interaction of the object under the finger, else the hero
+// walks to the point. The scene 1 queue and the upper pipe of scene 1 are the only scene specific parts.
+bool sceneController_click(Common::Point pos) {
+ Scene &scene = *g_ngi->_currentScene;
+ AniObject *hero = g_ngi->_aniMan;
+ if (!hero || hero->_messageQueueId || !scene._motionController)
+ return false;
+ for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList)
+ if (queue->_queueId == QU_SC1_ENTER && !queue->_isFinished)
+ return false;
+ pos += Common::Point(scene._x, scene._y);
+ PictureObject *picture = scene.findPictureObjectAtPos(pos.x, pos.y);
+ AniObject *actor = scene.findAniObjectAtPos(pos.x, pos.y);
+ GameObject *target = picture;
+ if (actor && (!picture || actor->_z < picture->_z))
+ target = actor;
+ if (target) {
+ uint32 upperPipe;
+ if (g_ngi->_gameProject->_objectIds.findId("PIC_SC1_UTRUBA", upperPipe) && upperPipe == (uint16)target->_id)
+ target = scene.findPictureObjectById(PIC_SC1_LADDER, 0);
+ const int item = getGameLoaderInventory()->getCursorPictureId();
+ if (target && canInteractAny(hero, target, item)) {
+ if (target->_objtype == kObjTypePictureObject && g_ngi->getGameLoaderGameVar()->getSubVarAsInt("Scene1ExitsDisabled"))
+ return false;
+ return handleObjectInteraction(hero, target, item);
+ }
+ }
+ // CFPController::TrySwipeMan (a tap): only while the hero is on the graph; when the point cannot be walked to, the nearest
+ // point of the graph is tried
+ MotionController *controller = scene._motionController.get();
+ if (g_ngi->_gameVersion >= 201509 && !controller->checkPoint(hero->_x, hero->_y))
+ return false;
+ if (controller->startMove(hero, pos.x, pos.y, 0, 0))
+ return true;
+ if (g_ngi->_gameVersion < 201509)
+ return false;
+ const Common::Point nearest = controller->getNearestWalkPoint(pos.x, pos.y);
+ if (nearest.x == -1 && nearest.y == -1)
+ return false;
+ return controller->startMove(hero, nearest.x, nearest.y, 0, 0) != nullptr;
+}
+
// CFPController::OnRenderBottom
void renderSceneBottom(Scene &scene) {
if (g_ngi->_tremble)
diff --git a/engines/ngi/fullpipe/scene01.cpp b/engines/ngi/fullpipe/scene01.cpp
index 8f439635642..53ba56ad0f6 100644
--- a/engines/ngi/fullpipe/scene01.cpp
+++ b/engines/ngi/fullpipe/scene01.cpp
@@ -105,46 +105,6 @@ void scene01_initScene(Scene *sc, int entrance) {
}
}
-bool scene01_click(Common::Point pos) {
- Scene &scene = *g_ngi->_currentScene;
- AniObject *hero = g_ngi->_aniMan;
- if (!hero || hero->_messageQueueId || !scene._motionController)
- return false;
- for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList)
- if (queue->_queueId == QU_SC1_ENTER && !queue->_isFinished)
- return false;
- pos += Common::Point(scene._x, scene._y);
- PictureObject *picture = scene.findPictureObjectAtPos(pos.x, pos.y);
- AniObject *actor = scene.findAniObjectAtPos(pos.x, pos.y);
- GameObject *target = picture;
- if (actor && (!picture || actor->_z < picture->_z))
- target = actor;
- if (target) {
- uint32 upperPipe;
- if (g_ngi->_gameProject->_objectIds.findId("PIC_SC1_UTRUBA", upperPipe) && upperPipe == (uint16)target->_id)
- target = scene.findPictureObjectById(PIC_SC1_LADDER, 0);
- const int item = getGameLoaderInventory()->getCursorPictureId();
- if (target && canInteractAny(hero, target, item)) {
- if (target->_objtype == kObjTypePictureObject && g_ngi->getGameLoaderGameVar()->getSubVarAsInt("Scene1ExitsDisabled"))
- return false;
- return handleObjectInteraction(hero, target, item);
- }
- }
- // CFPController::TrySwipeMan (a tap): only while the hero is on the graph; when the point cannot be walked to, the nearest
- // point of the graph is tried
- MotionController *controller = scene._motionController.get();
- if (g_ngi->_gameVersion >= 201509 && !controller->checkPoint(hero->_x, hero->_y))
- return false;
- if (controller->startMove(hero, pos.x, pos.y, 0, 0))
- return true;
- if (g_ngi->_gameVersion < 201509)
- return false;
- const Common::Point nearest = controller->getNearestWalkPoint(pos.x, pos.y);
- if (nearest.x == -1 && nearest.y == -1)
- return false;
- return controller->startMove(hero, nearest.x, nearest.y, 0, 0) != nullptr;
-}
-
int sceneHandler01(Command *cmd) {
int res = 0;
diff --git a/engines/ngi/fullpipe/sceneTutorial.cpp b/engines/ngi/fullpipe/sceneTutorial.cpp
index f5c36b07036..2e828f459ae 100644
--- a/engines/ngi/fullpipe/sceneTutorial.cpp
+++ b/engines/ngi/fullpipe/sceneTutorial.cpp
@@ -232,7 +232,7 @@ public:
if (!picture || picture->_id != pipe)
return false;
root->setSubVarAsInt("Scene1ExitsDisabled", 0);
- if (!scene01_click(pos)) {
+ if (!sceneController_click(pos)) {
root->setSubVarAsInt("Scene1ExitsDisabled", 1);
return false;
}
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 8c4ab220f89..92c10ed7250 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -342,8 +342,8 @@ bool NGIEngine::handleGuiEvent(const Common::Event &event) {
}
}
if (event.type == Common::EVENT_LBUTTONUP && (!manager || !manager->hit(event.mouse)) &&
- usesXMLProject() && _currentScene->_sceneId == SC_1)
- return scene01_click(event.mouse);
+ usesXMLProject() && _currentScene->_sceneId != SC_INTRO1)
+ return sceneController_click(event.mouse);
if (!manager)
return false;
GuiManager &gui = *manager;
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 1a93f9458ba..96a451d2f7e 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -135,6 +135,8 @@ void renderSceneTop(Scene &scene);
/** The camera of the Android scenes (CFPController::DefaultScroll, TestScroll, LimitScroll, CheckBorders) */
void sceneCamera_onShow(Scene &scene, int entranceId);
void sceneCamera_update(Scene &scene, uint32 elapsed);
+/** CFPController::OnMouseLKeyUp: a tap on the scene (interaction or walking), true when it was handled */
+bool sceneController_click(Common::Point pos);
class NGIEngine : public ::Engine {
diff --git a/engines/ngi/scenes.h b/engines/ngi/scenes.h
index 0b3d4c72f14..0fa2c5a6e40 100644
--- a/engines/ngi/scenes.h
+++ b/engines/ngi/scenes.h
@@ -71,7 +71,6 @@ int sceneIntroDemo_updateCursor();
void sceneIntroDemo_initScene(Scene *sc);
int sceneHandlerIntroDemo(Command *cmd);
-bool scene01_click(Common::Point pos);
void scene01_fixEntrance();
void scene01_initScene(Scene *sc, int entrance);
void scene01_initObjects(Scene *sc, int entrance, bool eggUncracked);
Commit: e5efe9e74bc01b51b1c1f9271055104963fcdb88
https://github.com/scummvm/scummvm/commit/e5efe9e74bc01b51b1c1f9271055104963fcdb88
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Start the scene 3 logic for XML projects
Changed paths:
engines/ngi/fullpipe/scene03.cpp
engines/ngi/scenes.cpp
diff --git a/engines/ngi/fullpipe/scene03.cpp b/engines/ngi/fullpipe/scene03.cpp
index 61ecb0cc234..f56f9747312 100644
--- a/engines/ngi/fullpipe/scene03.cpp
+++ b/engines/ngi/fullpipe/scene03.cpp
@@ -34,12 +34,20 @@
namespace NGI {
-void NGIEngine::setSwallowedEggsState() {
- GameVar *v = _gameLoader->_gameVar->getSubVarByName("OBJSTATES")->getSubVarByName(sO_GulpedEggs);
+// the egg states: Windows keeps them under the object, Android under ENUMSTATES (GetLogicStatePtr)
+static GameVar *scene03_eggVariable(const char *name) {
+ GameVar *v = g_ngi->_gameLoader->_gameVar->getSubVarByName("OBJSTATES")->getSubVarByName(sO_GulpedEggs);
- g_vars->swallowedEgg1 = v->getSubVarByName(sO_Egg1);
- g_vars->swallowedEgg2 = v->getSubVarByName(sO_Egg2);
- g_vars->swallowedEgg3 = v->getSubVarByName(sO_Egg3);
+ if (g_ngi->isAndroidFullPipe())
+ v = v->getSubVarByName("ENUMSTATES");
+
+ return v->getSubVarByName(name);
+}
+
+void NGIEngine::setSwallowedEggsState() {
+ g_vars->swallowedEgg1 = scene03_eggVariable(sO_Egg1);
+ g_vars->swallowedEgg2 = scene03_eggVariable(sO_Egg2);
+ g_vars->swallowedEgg3 = scene03_eggVariable(sO_Egg3);
g_vars->swallowedEgg1->_value.intValue = 0;
g_vars->swallowedEgg2->_value.intValue = 0;
@@ -62,11 +70,9 @@ void scene03_initScene(Scene *sc) {
g_vars->scene03_eggeater = sc->findAniObjectById(ANI_EGGEATER, -1);
g_vars->scene03_domino = sc->findAniObjectById(ANI_DOMINO_3, -1);
- GameVar *v = g_ngi->_gameLoader->_gameVar->getSubVarByName("OBJSTATES")->getSubVarByName(sO_GulpedEggs);
-
- g_vars->swallowedEgg1 = v->getSubVarByName(sO_Egg1);
- g_vars->swallowedEgg2 = v->getSubVarByName(sO_Egg2);
- g_vars->swallowedEgg3 = v->getSubVarByName(sO_Egg3);
+ g_vars->swallowedEgg1 = scene03_eggVariable(sO_Egg1);
+ g_vars->swallowedEgg2 = scene03_eggVariable(sO_Egg2);
+ g_vars->swallowedEgg3 = scene03_eggVariable(sO_Egg3);
g_ngi->lift_setButton(sO_Level2, ST_LBN_2N);
@@ -304,6 +310,10 @@ int sceneHandler03(Command *ex) {
{
int res = 0;
+ // Android: CFPController scrolls, Scene::update drives behaviors and audio.
+ if (g_ngi->isAndroidFullPipe())
+ break;
+
if (g_ngi->_aniMan2) {
if (g_ngi->_aniMan2->_x < g_ngi->_sceneRect.left + 200)
g_ngi->_currentScene->_x = g_ngi->_aniMan2->_x - g_ngi->_sceneRect.left - 300;
diff --git a/engines/ngi/scenes.cpp b/engines/ngi/scenes.cpp
index 219e57a88c0..8dc0b88faa6 100644
--- a/engines/ngi/scenes.cpp
+++ b/engines/ngi/scenes.cpp
@@ -580,6 +580,10 @@ bool NGIEngine::initSceneLogic(Scene *scene, int entranceId) {
scene02_initScene(scene);
addMessageHandler(sceneHandler02, 2);
return true;
+ case SC_3:
+ scene03_initScene(scene);
+ addMessageHandler(sceneHandler03, 2);
+ return true;
default:
return false;
}
Commit: c3d1f735b1987c86acc93853079f1558c037042c
https://github.com/scummvm/scummvm/commit/c3d1f735b1987c86acc93853079f1558c037042c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Port the Android differences of the scene 3 controller
Changed paths:
engines/ngi/behavior.cpp
engines/ngi/behavior.h
engines/ngi/fullpipe/scene03.cpp
engines/ngi/scenes.cpp
engines/ngi/scenes.h
diff --git a/engines/ngi/behavior.cpp b/engines/ngi/behavior.cpp
index 6fc4b6ffb1a..3ca04ff1ca4 100644
--- a/engines/ngi/behavior.cpp
+++ b/engines/ngi/behavior.cpp
@@ -334,6 +334,23 @@ bool BehaviorController::enableAni(AniObject *obj, int aniId, int quId, int flag
return true;
}
+void BehaviorController::enableMoves(AniObject *ani, int queueId, bool enable) {
+ for (BehaviorAni &behavior : _behaviors) {
+ if (behavior._ani != ani)
+ continue;
+ for (BehaviorAnim &anim : behavior._behaviorAnims) {
+ for (BehaviorMove &move : anim._behaviorMoves) {
+ if (move._queueId != queueId && move._movementId != queueId)
+ continue;
+ if (enable)
+ move._flags &= 0xFFFFFFFE;
+ else
+ move._flags |= 1;
+ }
+ }
+ }
+}
+
void BehaviorController::enableAllQueuesForAni(AniObject *ani, int flag) {
for (uint i = 0; i < _behaviors.size(); i++) {
BehaviorAni &beh = _behaviors[i];
diff --git a/engines/ngi/behavior.h b/engines/ngi/behavior.h
index fa60f7ba195..7f98735d308 100644
--- a/engines/ngi/behavior.h
+++ b/engines/ngi/behavior.h
@@ -114,6 +114,8 @@ class BehaviorController : public CObject {
void updateStaticAniBehavior(AniObject &ani, int delay, const BehaviorAnim &beh);
bool enableAni(AniObject *obj, int aniId, int quId, int flag);
+ /** CBehaviorController::EnableAni -> CBehaviorAni::EnableMove */
+ void enableMoves(AniObject *ani, int queueId, bool enable);
void enableAllQueuesForAni(AniObject *ani, int flag);
diff --git a/engines/ngi/fullpipe/scene03.cpp b/engines/ngi/fullpipe/scene03.cpp
index f56f9747312..a1b655c6404 100644
--- a/engines/ngi/fullpipe/scene03.cpp
+++ b/engines/ngi/fullpipe/scene03.cpp
@@ -31,6 +31,9 @@
#include "ngi/interaction.h"
#include "ngi/behavior.h"
+#include "ngi/chaptermanager.h"
+#include "ngi/font.h"
+#include "ngi/taskmanager.h"
namespace NGI {
@@ -44,6 +47,35 @@ static GameVar *scene03_eggVariable(const char *name) {
return v->getSubVarByName(name);
}
+// Android: hint over the scene with the eggs still needed (CSc03Controller +244 time, +248 text)
+static const int kEatenHintDuration = 4000;
+
+// CSc03Controller::OnRender: a cloud with the text at a fixed place of the screen
+static void scene03_render(Scene &scene) {
+ if (g_vars->scene03_hintTimer <= 0 || !g_vars->scene03_hintFont)
+ return;
+
+ if (PictureObject *cloud = scene.findPictureObjectById(23509, 0)) // 0x5BD5
+ cloud->_picture->blitTo(g_ngi->_backgroundSurface, Common::Point(500, 200));
+ g_vars->scene03_hintFont->drawCentered(g_ngi->_backgroundSurface, Common::Rect(520, 215, 520 + 113, 215 + 71), g_vars->scene03_hintText);
+}
+
+static void scene03_showEatenHint(const char *stringId) {
+ const Common::Path directory(Common::String("data/res_") + g_ngi->getResourceLocale());
+ if (!g_vars->scene03_hintFont) {
+ g_vars->scene03_hintFont = new BitmapFont();
+ if (!g_vars->scene03_hintFont->load(directory.join("Fonts/task_dlg_19.fnt"))) {
+ delete g_vars->scene03_hintFont;
+ g_vars->scene03_hintFont = nullptr;
+ }
+ }
+
+ TextContainer strings;
+ strings.load(directory);
+ g_vars->scene03_hintText = strings.getText(stringId);
+ g_vars->scene03_hintTimer = 0;
+}
+
void NGIEngine::setSwallowedEggsState() {
g_vars->swallowedEgg1 = scene03_eggVariable(sO_Egg1);
g_vars->swallowedEgg2 = scene03_eggVariable(sO_Egg2);
@@ -74,7 +106,17 @@ void scene03_initScene(Scene *sc) {
g_vars->swallowedEgg2 = scene03_eggVariable(sO_Egg2);
g_vars->swallowedEgg3 = scene03_eggVariable(sO_Egg3);
- g_ngi->lift_setButton(sO_Level2, ST_LBN_2N);
+ if (g_ngi->isAndroidFullPipe()) {
+ uint32 buttonId;
+ if (g_ngi->_gameProject->_objectIds.findId("ST_LBN_2N", buttonId))
+ g_ngi->lift_setButton(sO_Level2, buttonId);
+ // CSc03Controller::OnShow: the hint over the scene is hidden
+ g_vars->scene03_hintTimer = -1;
+ g_vars->scene03_hintText.clear();
+ sc->_renderHook = scene03_render;
+ } else {
+ g_ngi->lift_setButton(sO_Level2, ST_LBN_2N);
+ }
g_ngi->lift_init(sc, QU_SC3_ENTERLIFT, QU_SC3_EXITLIFT);
@@ -84,6 +126,17 @@ void scene03_initScene(Scene *sc) {
void scene03_setEaterState() {
if (g_ngi->getStateId(sO_EggGulperGaveCoin) == g_ngi->getStateValue(sO_EggGulperGaveCoin, sO_Yes)) {
+ if (g_ngi->isAndroidFullPipe()) {
+ // CSc03Controller::UpdateBehavior: queues QU_EGTR_SLIMSHOW, QU_EGTR_MD1_SHOW, QU_EGTR_MD2_SHOW
+ BehaviorController *behavior = g_ngi->_currentScene->_behaviorController.get();
+ if (behavior) {
+ behavior->enableMoves(g_vars->scene03_eggeater, QU_EGTR_SLIMSHOW, false);
+ behavior->enableMoves(g_vars->scene03_eggeater, QU_EGTR_MD1_SHOW, false);
+ behavior->enableMoves(g_vars->scene03_eggeater, QU_EGTR_MD2_SHOW, false);
+ }
+ return;
+ }
+
g_ngi->_behaviorManager->enableAni(g_vars->scene03_eggeater, ST_EGTR_SLIM, QU_EGTR_SLIMSHOW, 0);
g_ngi->_behaviorManager->enableAni(g_vars->scene03_eggeater, ST_EGTR_MID1, QU_EGTR_MD1_SHOW, 0);
g_ngi->_behaviorManager->enableAni(g_vars->scene03_eggeater, ST_EGTR_MID2, QU_EGTR_MD2_SHOW, 0);
@@ -114,9 +167,13 @@ void sceneHandler03_addLastEaten(int item) {
if (!g_vars->swallowedEgg1->_value.intValue) {
g_vars->swallowedEgg1->_value.intValue = item;
+ if (g_ngi->isAndroidFullPipe())
+ scene03_showEatenHint("STR_SC3_GIVE_ONE_EGG");
debugC(2, kDebugSceneLogic, "scene03: setting egg1: %d", g_vars->swallowedEgg1->_value.intValue);
} else if (!g_vars->swallowedEgg2->_value.intValue) {
g_vars->swallowedEgg2->_value.intValue = item;
+ if (g_ngi->isAndroidFullPipe())
+ scene03_showEatenHint("STR_SC3_GIVE_TWO_EGG");
debugC(2, kDebugSceneLogic, "scene03: setting egg2: %d", g_vars->swallowedEgg2->_value.intValue);
} else if (!g_vars->swallowedEgg3->_value.intValue) {
g_vars->swallowedEgg3->_value.intValue = item;
@@ -207,6 +264,9 @@ void sceneHandler03_doTakeEgg(Command *ex) {
if (egg1 && ex0) {
ex0->_parentId = egg1;
sceneHandler03_pushEggStack();
+ // CSc03Controller::DoTakeEgg: giving the glass egg back completes the hint 2_03
+ if (g_ngi->isAndroidFullPipe() && egg1 == ANI_INV_EGGGLS)
+ g_ngi->setState("\xcf\xee\xe4\xf1\xea\xe0\xe7\xea\xe0\x5f\x32\x5f\x30\x33", 0);
}
if ( g_vars->swallowedEgg1->_value.intValue == ANI_INV_EGGAPL
@@ -218,11 +278,44 @@ void sceneHandler03_doTakeEgg(Command *ex) {
ObjstateCommand *com = static_cast<ObjstateCommand *>(ex1);
com->_value = g_ngi->getStateValue(sO_EggGulper, sO_WantsNothing);
+ } else if (ex1->_cmd == kCmdSetLogic) {
+ // the XML SET_LOGIC command keeps the state in the message number
+ ex1->_messageNum = g_ngi->getStateValue(sO_EggGulper, sO_WantsNothing);
}
}
}
}
+// CSc03Controller::OnTakeCoin: the egg eater wants nothing more, its coin queue stops
+static void sceneHandler03_onTakeCoin() {
+ g_ngi->setState(sO_EggGulper, g_ngi->getStateValue(sO_EggGulper, sO_WantsNothing));
+
+ BehaviorController *behavior = g_ngi->_currentScene->_behaviorController.get();
+ if (behavior)
+ behavior->enableMoves(g_vars->scene03_eggeater, 5334, false); // 0x14D6
+
+ g_ngi->_taskManager->deactivateTask("FIND_COIN_SC3");
+ g_ngi->_taskManager->activateTask("FIND_EXIT_BOTLE_SC4");
+}
+
+// The messages that the Android scene 3 identifies by name (CSc03Controller::OnMessage)
+static bool sceneHandler03_namedMessage(const Common::String &name) {
+ Scene *scene = g_ngi->_currentScene;
+ if (name == "MSG_SC3_MOVEEGGEATER") {
+ g_vars->scene03_eggeater->setPos(609, 424);
+ g_vars->scene03_eggeater->_z = 60;
+ return true;
+ }
+ if (name == "MSG_SC4_HIDEBOOT" || name == "MSG_HIDE_BOX") {
+ // ids 0x40B, 0x3FC
+ AniObject *ani = scene->findAniObjectById(name == "MSG_SC4_HIDEBOOT" ? 1035 : 1020, 0);
+ if (ani)
+ ani->_flags &= ~4;
+ return true;
+ }
+ return false;
+}
+
int sceneHandler03(Command *ex) {
if (ex->_cmd != kCmdMessage && ex->_messageNum != kMsgUpdate)
debugC(3, kDebugSceneLogic, "scene03: got message: kind %d, num: %d", ex->_cmd, ex->_messageNum);
@@ -233,6 +326,9 @@ int sceneHandler03(Command *ex) {
return 0;
}
+ if (g_ngi->isAndroidFullPipe() && !ex->_messageName.empty() && sceneHandler03_namedMessage(ex->_messageName))
+ return 0;
+
switch (ex->_messageNum) {
case MSG_LIFT_EXITLIFT:
g_ngi->lift_exitSeq(ex);
@@ -243,7 +339,10 @@ int sceneHandler03(Command *ex) {
break;
case MSG_SC3_ONTAKECOIN:
- sceneHandler03_eaterFat();
+ if (g_ngi->isAndroidFullPipe())
+ sceneHandler03_onTakeCoin();
+ else
+ sceneHandler03_eaterFat();
break;
case MSG_LIFT_STARTEXITQUEUE:
@@ -251,7 +350,10 @@ int sceneHandler03(Command *ex) {
break;
case MSG_SC3_RELEASEEGG:
- sceneHandler03_releaseEgg();
+ if (g_ngi->isAndroidFullPipe())
+ g_vars->scene03_eggeater->_flags |= 4; // CSc03Controller::PrepareReleaseEgg
+ else
+ sceneHandler03_releaseEgg();
break;
case MSG_LIFT_CLICKBUTTON:
@@ -310,9 +412,14 @@ int sceneHandler03(Command *ex) {
{
int res = 0;
- // Android: CFPController scrolls, Scene::update drives behaviors and audio.
- if (g_ngi->isAndroidFullPipe())
+ // Android: CFPController scrolls, Scene::update runs behaviors; CSc03Controller::OnUpdate: hint
+ if (g_ngi->isAndroidFullPipe()) {
+ if (g_vars->scene03_hintTimer != -1 && sceneTutorial_isCompleted()) {
+ const int time = g_vars->scene03_hintTimer + (int)ex->_param;
+ g_vars->scene03_hintTimer = time < kEatenHintDuration ? time : -1;
+ }
break;
+ }
if (g_ngi->_aniMan2) {
if (g_ngi->_aniMan2->_x < g_ngi->_sceneRect.left + 200)
diff --git a/engines/ngi/scenes.cpp b/engines/ngi/scenes.cpp
index 8dc0b88faa6..945eb784c60 100644
--- a/engines/ngi/scenes.cpp
+++ b/engines/ngi/scenes.cpp
@@ -34,6 +34,7 @@
#include "ngi/constants.h"
#include "ngi/objectnames.h"
#include "ngi/scenes.h"
+#include "ngi/font.h"
#include "ngi/tremble.h"
#include "ngi/interaction.h"
@@ -76,6 +77,10 @@ void Fader::update(uint32 elapsed) {
} while (active() && !_durations[_stage]);
}
+Vars::~Vars() {
+ delete scene03_hintFont;
+}
+
Vars::Vars() {
sceneIntro_aniin1man = nullptr;
sceneIntro_needSleep = true;
@@ -96,6 +101,8 @@ Vars::Vars() {
scene02_boxOpen = false;
scene03_eggeater = nullptr;
+ scene03_hintTimer = -1;
+ scene03_hintFont = nullptr;
scene03_domino = nullptr;
scene04_bottle = nullptr;
diff --git a/engines/ngi/scenes.h b/engines/ngi/scenes.h
index 0fa2c5a6e40..29755947af9 100644
--- a/engines/ngi/scenes.h
+++ b/engines/ngi/scenes.h
@@ -25,6 +25,7 @@
namespace NGI {
struct Bat;
+class BitmapFont;
struct BehaviorMove;
struct Hanger;
class AniHandler;
@@ -244,6 +245,7 @@ int sceneHandlerDbgMenu(Command *cmd);
class Vars {
public:
Vars();
+ ~Vars();
GameVar *swallowedEgg1;
GameVar *swallowedEgg2;
@@ -265,6 +267,10 @@ public:
bool scene02_boxOpen;
AniObject *scene03_eggeater;
+ // Android: the hint over the scene that says how many eggs the egg eater still wants (CSc03Controller +244 the time, +248 the text)
+ Common::String scene03_hintText;
+ int scene03_hintTimer;
+ BitmapFont *scene03_hintFont;
AniObject *scene03_domino;
PictureObject *scene04_bottle;
Commit: 13122b9cd2645a06e8ce2bddc9a3227a4301613e
https://github.com/scummvm/scummvm/commit/13122b9cd2645a06e8ce2bddc9a3227a4301613e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Move the Full Pipe specific files to fullpipe/
Changed paths:
A engines/ngi/fullpipe/achievements.cpp
A engines/ngi/fullpipe/achievements.h
A engines/ngi/fullpipe/chaptermanager.cpp
A engines/ngi/fullpipe/chaptermanager.h
A engines/ngi/fullpipe/constants.h
A engines/ngi/fullpipe/floaters.cpp
A engines/ngi/fullpipe/floaters.h
A engines/ngi/fullpipe/fpcontroller.cpp
A engines/ngi/fullpipe/lift.cpp
A engines/ngi/fullpipe/notebook.cpp
A engines/ngi/fullpipe/notebook.h
A engines/ngi/fullpipe/objectnames.h
A engines/ngi/fullpipe/scenes.cpp
A engines/ngi/fullpipe/scenes.h
A engines/ngi/fullpipe/taskmanager.cpp
A engines/ngi/fullpipe/taskmanager.h
A engines/ngi/fullpipe/tremble.cpp
A engines/ngi/fullpipe/tremble.h
R engines/ngi/achievements.cpp
R engines/ngi/achievements.h
R engines/ngi/chaptermanager.cpp
R engines/ngi/chaptermanager.h
R engines/ngi/constants.h
R engines/ngi/floaters.cpp
R engines/ngi/floaters.h
R engines/ngi/fpcontroller.cpp
R engines/ngi/lift.cpp
R engines/ngi/notebook.cpp
R engines/ngi/notebook.h
R engines/ngi/objectnames.h
R engines/ngi/scenes.cpp
R engines/ngi/scenes.h
R engines/ngi/taskmanager.cpp
R engines/ngi/taskmanager.h
R engines/ngi/tremble.cpp
R engines/ngi/tremble.h
engines/ngi/console.cpp
engines/ngi/fullpipe/scene01.cpp
engines/ngi/fullpipe/scene02.cpp
engines/ngi/fullpipe/scene03.cpp
engines/ngi/fullpipe/scene04.cpp
engines/ngi/fullpipe/scene05.cpp
engines/ngi/fullpipe/scene06.cpp
engines/ngi/fullpipe/scene07.cpp
engines/ngi/fullpipe/scene08.cpp
engines/ngi/fullpipe/scene09.cpp
engines/ngi/fullpipe/scene10.cpp
engines/ngi/fullpipe/scene11.cpp
engines/ngi/fullpipe/scene12.cpp
engines/ngi/fullpipe/scene13.cpp
engines/ngi/fullpipe/scene14.cpp
engines/ngi/fullpipe/scene15.cpp
engines/ngi/fullpipe/scene16.cpp
engines/ngi/fullpipe/scene17.cpp
engines/ngi/fullpipe/scene18and19.cpp
engines/ngi/fullpipe/scene20.cpp
engines/ngi/fullpipe/scene21.cpp
engines/ngi/fullpipe/scene22.cpp
engines/ngi/fullpipe/scene23.cpp
engines/ngi/fullpipe/scene24.cpp
engines/ngi/fullpipe/scene25.cpp
engines/ngi/fullpipe/scene26.cpp
engines/ngi/fullpipe/scene27.cpp
engines/ngi/fullpipe/scene28.cpp
engines/ngi/fullpipe/scene29.cpp
engines/ngi/fullpipe/scene30.cpp
engines/ngi/fullpipe/scene31.cpp
engines/ngi/fullpipe/scene32.cpp
engines/ngi/fullpipe/scene33.cpp
engines/ngi/fullpipe/scene34.cpp
engines/ngi/fullpipe/scene35.cpp
engines/ngi/fullpipe/scene36.cpp
engines/ngi/fullpipe/scene37.cpp
engines/ngi/fullpipe/scene38.cpp
engines/ngi/fullpipe/sceneChapter.cpp
engines/ngi/fullpipe/sceneDbg.cpp
engines/ngi/fullpipe/sceneFinal.cpp
engines/ngi/fullpipe/sceneIntro.cpp
engines/ngi/fullpipe/sceneIntroDemo.cpp
engines/ngi/fullpipe/sceneNotebook.cpp
engines/ngi/fullpipe/sceneTutorial.cpp
engines/ngi/gameloader.cpp
engines/ngi/init.cpp
engines/ngi/input.cpp
engines/ngi/messagehandlers.cpp
engines/ngi/modal.cpp
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/scene.cpp
engines/ngi/stateloader.cpp
engines/ngi/statics.cpp
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/console.cpp b/engines/ngi/console.cpp
index e43264ccf55..2498b1ed1a2 100644
--- a/engines/ngi/console.cpp
+++ b/engines/ngi/console.cpp
@@ -20,7 +20,7 @@
*/
#include "ngi/console.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/ngi.h"
#include "ngi/gameloader.h"
#include "ngi/scene.h"
diff --git a/engines/ngi/achievements.cpp b/engines/ngi/fullpipe/achievements.cpp
similarity index 99%
rename from engines/ngi/achievements.cpp
rename to engines/ngi/fullpipe/achievements.cpp
index ac51c731466..ae2a3b20012 100644
--- a/engines/ngi/achievements.cpp
+++ b/engines/ngi/fullpipe/achievements.cpp
@@ -23,7 +23,7 @@
#include "common/hashmap.h"
#include "ngi/ngi.h"
-#include "ngi/achievements.h"
+#include "ngi/fullpipe/achievements.h"
namespace NGI {
diff --git a/engines/ngi/achievements.h b/engines/ngi/fullpipe/achievements.h
similarity index 100%
rename from engines/ngi/achievements.h
rename to engines/ngi/fullpipe/achievements.h
diff --git a/engines/ngi/chaptermanager.cpp b/engines/ngi/fullpipe/chaptermanager.cpp
similarity index 98%
rename from engines/ngi/chaptermanager.cpp
rename to engines/ngi/fullpipe/chaptermanager.cpp
index b32e7490f16..acb3e95a087 100644
--- a/engines/ngi/chaptermanager.cpp
+++ b/engines/ngi/fullpipe/chaptermanager.cpp
@@ -30,10 +30,10 @@
#include "ngi/gameloader.h"
#include "ngi/objects.h"
#include "ngi/anihandler.h"
-#include "ngi/chaptermanager.h"
+#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/messages.h"
-#include "ngi/scenes.h"
-#include "ngi/taskmanager.h"
+#include "ngi/fullpipe/scenes.h"
+#include "ngi/fullpipe/taskmanager.h"
namespace NGI {
diff --git a/engines/ngi/chaptermanager.h b/engines/ngi/fullpipe/chaptermanager.h
similarity index 100%
rename from engines/ngi/chaptermanager.h
rename to engines/ngi/fullpipe/chaptermanager.h
diff --git a/engines/ngi/constants.h b/engines/ngi/fullpipe/constants.h
similarity index 100%
rename from engines/ngi/constants.h
rename to engines/ngi/fullpipe/constants.h
diff --git a/engines/ngi/floaters.cpp b/engines/ngi/fullpipe/floaters.cpp
similarity index 98%
rename from engines/ngi/floaters.cpp
rename to engines/ngi/fullpipe/floaters.cpp
index 12d59a5118e..ce85df08612 100644
--- a/engines/ngi/floaters.cpp
+++ b/engines/ngi/fullpipe/floaters.cpp
@@ -20,14 +20,14 @@
*/
#include "ngi/ngi.h"
-#include "ngi/floaters.h"
+#include "ngi/fullpipe/floaters.h"
#include "ngi/utils.h"
#include "ngi/objects.h"
#include "ngi/motion.h"
#include "ngi/statics.h"
#include "ngi/scene.h"
-#include "ngi/constants.h"
-#include "ngi/objectnames.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/objectnames.h"
namespace NGI {
diff --git a/engines/ngi/floaters.h b/engines/ngi/fullpipe/floaters.h
similarity index 100%
rename from engines/ngi/floaters.h
rename to engines/ngi/fullpipe/floaters.h
diff --git a/engines/ngi/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
similarity index 99%
rename from engines/ngi/fpcontroller.cpp
rename to engines/ngi/fullpipe/fpcontroller.cpp
index 73baab1161a..5a56cba742f 100644
--- a/engines/ngi/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -25,16 +25,16 @@
#include "ngi/ngi.h"
#include "ngi/messages.h"
#include "ngi/motion.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/interaction.h"
#include "ngi/objects.h"
#include "ngi/gfx.h"
#include "ngi/statics.h"
#include "ngi/scene.h"
-#include "ngi/taskmanager.h"
-#include "ngi/tremble.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tremble.h"
namespace NGI {
diff --git a/engines/ngi/lift.cpp b/engines/ngi/fullpipe/lift.cpp
similarity index 99%
rename from engines/ngi/lift.cpp
rename to engines/ngi/fullpipe/lift.cpp
index f7868a17133..0bcbc2fbdae 100644
--- a/engines/ngi/lift.cpp
+++ b/engines/ngi/fullpipe/lift.cpp
@@ -22,8 +22,8 @@
#include "ngi/ngi.h"
#include "ngi/objects.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/scene.h"
#include "ngi/statics.h"
diff --git a/engines/ngi/notebook.cpp b/engines/ngi/fullpipe/notebook.cpp
similarity index 99%
rename from engines/ngi/notebook.cpp
rename to engines/ngi/fullpipe/notebook.cpp
index 4b18e19dcf0..62a59594404 100644
--- a/engines/ngi/notebook.cpp
+++ b/engines/ngi/fullpipe/notebook.cpp
@@ -27,13 +27,13 @@
#include "ngi/gameloader.h"
#include "ngi/objects.h"
#include "ngi/anihandler.h"
-#include "ngi/chaptermanager.h"
+#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/guimanager.h"
-#include "ngi/notebook.h"
+#include "ngi/fullpipe/notebook.h"
#include "ngi/scene.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/sound.h"
-#include "ngi/taskmanager.h"
+#include "ngi/fullpipe/taskmanager.h"
namespace NGI {
diff --git a/engines/ngi/notebook.h b/engines/ngi/fullpipe/notebook.h
similarity index 100%
rename from engines/ngi/notebook.h
rename to engines/ngi/fullpipe/notebook.h
diff --git a/engines/ngi/objectnames.h b/engines/ngi/fullpipe/objectnames.h
similarity index 100%
rename from engines/ngi/objectnames.h
rename to engines/ngi/fullpipe/objectnames.h
diff --git a/engines/ngi/fullpipe/scene01.cpp b/engines/ngi/fullpipe/scene01.cpp
index 53ba56ad0f6..c693581738e 100644
--- a/engines/ngi/fullpipe/scene01.cpp
+++ b/engines/ngi/fullpipe/scene01.cpp
@@ -20,15 +20,15 @@
*/
#include "ngi/ngi.h"
-#include "ngi/chaptermanager.h"
-#include "ngi/taskmanager.h"
+#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/taskmanager.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene02.cpp b/engines/ngi/fullpipe/scene02.cpp
index a23faaa0e96..f4c59f355a5 100644
--- a/engines/ngi/fullpipe/scene02.cpp
+++ b/engines/ngi/fullpipe/scene02.cpp
@@ -21,17 +21,17 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
#include "ngi/behavior.h"
-#include "ngi/floaters.h"
+#include "ngi/fullpipe/floaters.h"
namespace NGI {
diff --git a/engines/ngi/fullpipe/scene03.cpp b/engines/ngi/fullpipe/scene03.cpp
index a1b655c6404..5e6cda8ede5 100644
--- a/engines/ngi/fullpipe/scene03.cpp
+++ b/engines/ngi/fullpipe/scene03.cpp
@@ -21,19 +21,19 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
#include "ngi/behavior.h"
-#include "ngi/chaptermanager.h"
+#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/font.h"
-#include "ngi/taskmanager.h"
+#include "ngi/fullpipe/taskmanager.h"
namespace NGI {
diff --git a/engines/ngi/fullpipe/scene04.cpp b/engines/ngi/fullpipe/scene04.cpp
index 3ff76a4e468..ead925511c2 100644
--- a/engines/ngi/fullpipe/scene04.cpp
+++ b/engines/ngi/fullpipe/scene04.cpp
@@ -21,13 +21,13 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/utils.h"
#include "ngi/gfx.h"
#include "ngi/messages.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/scene.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene05.cpp b/engines/ngi/fullpipe/scene05.cpp
index 6d6d3a26bdb..892185d2cce 100644
--- a/engines/ngi/fullpipe/scene05.cpp
+++ b/engines/ngi/fullpipe/scene05.cpp
@@ -23,14 +23,14 @@
#include "ngi/gameloader.h"
#include "ngi/objects.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/statics.h"
#include "ngi/scene.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/messages.h"
-#include "ngi/floaters.h"
+#include "ngi/fullpipe/floaters.h"
#include "ngi/behavior.h"
namespace NGI {
diff --git a/engines/ngi/fullpipe/scene06.cpp b/engines/ngi/fullpipe/scene06.cpp
index 428768671f2..b23b1bb42dc 100644
--- a/engines/ngi/fullpipe/scene06.cpp
+++ b/engines/ngi/fullpipe/scene06.cpp
@@ -22,11 +22,11 @@
#include "ngi/ngi.h"
#include "ngi/objects.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gfx.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/scene.h"
#include "ngi/messages.h"
diff --git a/engines/ngi/fullpipe/scene07.cpp b/engines/ngi/fullpipe/scene07.cpp
index 8bfa35ed79a..4323cf85324 100644
--- a/engines/ngi/fullpipe/scene07.cpp
+++ b/engines/ngi/fullpipe/scene07.cpp
@@ -22,10 +22,10 @@
#include "ngi/ngi.h"
#include "ngi/objects.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/scene.h"
#include "ngi/statics.h"
#include "ngi/messages.h"
diff --git a/engines/ngi/fullpipe/scene08.cpp b/engines/ngi/fullpipe/scene08.cpp
index d9fbb942aaa..4a2f027b1dc 100644
--- a/engines/ngi/fullpipe/scene08.cpp
+++ b/engines/ngi/fullpipe/scene08.cpp
@@ -22,13 +22,13 @@
#include "ngi/ngi.h"
#include "ngi/objects.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/scene.h"
#include "ngi/statics.h"
-#include "ngi/floaters.h"
+#include "ngi/fullpipe/floaters.h"
#include "ngi/gameloader.h"
#include "ngi/behavior.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene09.cpp b/engines/ngi/fullpipe/scene09.cpp
index 1674dd8bd1f..7b130f414e9 100644
--- a/engines/ngi/fullpipe/scene09.cpp
+++ b/engines/ngi/fullpipe/scene09.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene10.cpp b/engines/ngi/fullpipe/scene10.cpp
index e13c39bd769..766f3decad9 100644
--- a/engines/ngi/fullpipe/scene10.cpp
+++ b/engines/ngi/fullpipe/scene10.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/behavior.h"
diff --git a/engines/ngi/fullpipe/scene11.cpp b/engines/ngi/fullpipe/scene11.cpp
index 6c8f1560459..32b0005c6e5 100644
--- a/engines/ngi/fullpipe/scene11.cpp
+++ b/engines/ngi/fullpipe/scene11.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene12.cpp b/engines/ngi/fullpipe/scene12.cpp
index 685fc539214..5ef38688fcc 100644
--- a/engines/ngi/fullpipe/scene12.cpp
+++ b/engines/ngi/fullpipe/scene12.cpp
@@ -22,12 +22,12 @@
#include "ngi/ngi.h"
#include "ngi/objects.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/scene.h"
-#include "ngi/floaters.h"
+#include "ngi/fullpipe/floaters.h"
#include "ngi/messages.h"
#include "ngi/statics.h"
#include "ngi/behavior.h"
diff --git a/engines/ngi/fullpipe/scene13.cpp b/engines/ngi/fullpipe/scene13.cpp
index 7d63c82d8a5..bdf60316617 100644
--- a/engines/ngi/fullpipe/scene13.cpp
+++ b/engines/ngi/fullpipe/scene13.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene14.cpp b/engines/ngi/fullpipe/scene14.cpp
index c6145b4fe2b..fd5b2bae66e 100644
--- a/engines/ngi/fullpipe/scene14.cpp
+++ b/engines/ngi/fullpipe/scene14.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene15.cpp b/engines/ngi/fullpipe/scene15.cpp
index 6d07298737f..1af62562c3e 100644
--- a/engines/ngi/fullpipe/scene15.cpp
+++ b/engines/ngi/fullpipe/scene15.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene16.cpp b/engines/ngi/fullpipe/scene16.cpp
index 9b11c569429..d0c0b25fa62 100644
--- a/engines/ngi/fullpipe/scene16.cpp
+++ b/engines/ngi/fullpipe/scene16.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene17.cpp b/engines/ngi/fullpipe/scene17.cpp
index 09ec13f13b3..2dcf9588381 100644
--- a/engines/ngi/fullpipe/scene17.cpp
+++ b/engines/ngi/fullpipe/scene17.cpp
@@ -21,17 +21,17 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
#include "ngi/behavior.h"
-#include "ngi/floaters.h"
+#include "ngi/fullpipe/floaters.h"
namespace NGI {
diff --git a/engines/ngi/fullpipe/scene18and19.cpp b/engines/ngi/fullpipe/scene18and19.cpp
index 9c563aa5e9b..1f9ff8e3e93 100644
--- a/engines/ngi/fullpipe/scene18and19.cpp
+++ b/engines/ngi/fullpipe/scene18and19.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene20.cpp b/engines/ngi/fullpipe/scene20.cpp
index 75f3d5edfd2..38ced23175f 100644
--- a/engines/ngi/fullpipe/scene20.cpp
+++ b/engines/ngi/fullpipe/scene20.cpp
@@ -21,17 +21,17 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
#include "ngi/behavior.h"
-#include "ngi/floaters.h"
+#include "ngi/fullpipe/floaters.h"
namespace NGI {
diff --git a/engines/ngi/fullpipe/scene21.cpp b/engines/ngi/fullpipe/scene21.cpp
index beb49d6eac0..5a3b0f92afd 100644
--- a/engines/ngi/fullpipe/scene21.cpp
+++ b/engines/ngi/fullpipe/scene21.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene22.cpp b/engines/ngi/fullpipe/scene22.cpp
index d371372fd61..7f2a9d3ab66 100644
--- a/engines/ngi/fullpipe/scene22.cpp
+++ b/engines/ngi/fullpipe/scene22.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene23.cpp b/engines/ngi/fullpipe/scene23.cpp
index 294e538caa3..d410d794691 100644
--- a/engines/ngi/fullpipe/scene23.cpp
+++ b/engines/ngi/fullpipe/scene23.cpp
@@ -21,17 +21,17 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
#include "ngi/behavior.h"
-#include "ngi/floaters.h"
+#include "ngi/fullpipe/floaters.h"
namespace NGI {
diff --git a/engines/ngi/fullpipe/scene24.cpp b/engines/ngi/fullpipe/scene24.cpp
index 8bcb0546722..31c3daed6b2 100644
--- a/engines/ngi/fullpipe/scene24.cpp
+++ b/engines/ngi/fullpipe/scene24.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene25.cpp b/engines/ngi/fullpipe/scene25.cpp
index a876a3716f4..0eba3b35e82 100644
--- a/engines/ngi/fullpipe/scene25.cpp
+++ b/engines/ngi/fullpipe/scene25.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene26.cpp b/engines/ngi/fullpipe/scene26.cpp
index 029421753b7..689be4b9df0 100644
--- a/engines/ngi/fullpipe/scene26.cpp
+++ b/engines/ngi/fullpipe/scene26.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene27.cpp b/engines/ngi/fullpipe/scene27.cpp
index 45577295331..810f782fc41 100644
--- a/engines/ngi/fullpipe/scene27.cpp
+++ b/engines/ngi/fullpipe/scene27.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene28.cpp b/engines/ngi/fullpipe/scene28.cpp
index 3c75f99ff0d..6e40cde18da 100644
--- a/engines/ngi/fullpipe/scene28.cpp
+++ b/engines/ngi/fullpipe/scene28.cpp
@@ -21,17 +21,17 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
#include "ngi/behavior.h"
-#include "ngi/floaters.h"
+#include "ngi/fullpipe/floaters.h"
namespace NGI {
diff --git a/engines/ngi/fullpipe/scene29.cpp b/engines/ngi/fullpipe/scene29.cpp
index 40ca1fc551f..c463cd40574 100644
--- a/engines/ngi/fullpipe/scene29.cpp
+++ b/engines/ngi/fullpipe/scene29.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene30.cpp b/engines/ngi/fullpipe/scene30.cpp
index d561c217b18..5c44b70a86f 100644
--- a/engines/ngi/fullpipe/scene30.cpp
+++ b/engines/ngi/fullpipe/scene30.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene31.cpp b/engines/ngi/fullpipe/scene31.cpp
index c252b2f8b17..0d55730e5a5 100644
--- a/engines/ngi/fullpipe/scene31.cpp
+++ b/engines/ngi/fullpipe/scene31.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene32.cpp b/engines/ngi/fullpipe/scene32.cpp
index b231bb80528..7583ac7a01f 100644
--- a/engines/ngi/fullpipe/scene32.cpp
+++ b/engines/ngi/fullpipe/scene32.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene33.cpp b/engines/ngi/fullpipe/scene33.cpp
index 952ceb3f5df..98e142d7bb6 100644
--- a/engines/ngi/fullpipe/scene33.cpp
+++ b/engines/ngi/fullpipe/scene33.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene34.cpp b/engines/ngi/fullpipe/scene34.cpp
index 999410152d7..3bbead06d26 100644
--- a/engines/ngi/fullpipe/scene34.cpp
+++ b/engines/ngi/fullpipe/scene34.cpp
@@ -21,17 +21,17 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
#include "ngi/behavior.h"
-#include "ngi/floaters.h"
+#include "ngi/fullpipe/floaters.h"
namespace NGI {
diff --git a/engines/ngi/fullpipe/scene35.cpp b/engines/ngi/fullpipe/scene35.cpp
index 821e10aa77b..714867e3d23 100644
--- a/engines/ngi/fullpipe/scene35.cpp
+++ b/engines/ngi/fullpipe/scene35.cpp
@@ -21,18 +21,18 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
#include "ngi/behavior.h"
-#include "ngi/floaters.h"
+#include "ngi/fullpipe/floaters.h"
namespace NGI {
diff --git a/engines/ngi/fullpipe/scene36.cpp b/engines/ngi/fullpipe/scene36.cpp
index 6af2de13767..0c8b4ad4f23 100644
--- a/engines/ngi/fullpipe/scene36.cpp
+++ b/engines/ngi/fullpipe/scene36.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene37.cpp b/engines/ngi/fullpipe/scene37.cpp
index 4f88afafeca..43404ad4802 100644
--- a/engines/ngi/fullpipe/scene37.cpp
+++ b/engines/ngi/fullpipe/scene37.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/scene38.cpp b/engines/ngi/fullpipe/scene38.cpp
index 074b1326c3e..632b8f12dc9 100644
--- a/engines/ngi/fullpipe/scene38.cpp
+++ b/engines/ngi/fullpipe/scene38.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/sceneChapter.cpp b/engines/ngi/fullpipe/sceneChapter.cpp
index 52757c31bcd..6dcf4cefcd6 100644
--- a/engines/ngi/fullpipe/sceneChapter.cpp
+++ b/engines/ngi/fullpipe/sceneChapter.cpp
@@ -20,14 +20,14 @@
*/
#include "ngi/ngi.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/font.h"
#include "ngi/gameloader.h"
#include "ngi/modal.h"
#include "ngi/anihandler.h"
#include "backends/keymapper/keymapper.h"
-#include "ngi/scenes.h"
-#include "ngi/chaptermanager.h"
+#include "ngi/fullpipe/scenes.h"
+#include "ngi/fullpipe/chaptermanager.h"
#include "common/file.h"
#include "common/formats/xmlparser.h"
diff --git a/engines/ngi/fullpipe/sceneDbg.cpp b/engines/ngi/fullpipe/sceneDbg.cpp
index bd5b39f089a..83f06aa149f 100644
--- a/engines/ngi/fullpipe/sceneDbg.cpp
+++ b/engines/ngi/fullpipe/sceneDbg.cpp
@@ -21,11 +21,11 @@
#include "ngi/ngi.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/input.h"
diff --git a/engines/ngi/fullpipe/sceneFinal.cpp b/engines/ngi/fullpipe/sceneFinal.cpp
index 819f9ccf084..da6aeb08237 100644
--- a/engines/ngi/fullpipe/sceneFinal.cpp
+++ b/engines/ngi/fullpipe/sceneFinal.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/fullpipe/sceneIntro.cpp b/engines/ngi/fullpipe/sceneIntro.cpp
index e892c54a36a..ff67923c16a 100644
--- a/engines/ngi/fullpipe/sceneIntro.cpp
+++ b/engines/ngi/fullpipe/sceneIntro.cpp
@@ -21,12 +21,12 @@
#include "ngi/ngi.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/behavior.h"
-#include "ngi/chaptermanager.h"
+#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/modal.h"
#include "ngi/statics.h"
diff --git a/engines/ngi/fullpipe/sceneIntroDemo.cpp b/engines/ngi/fullpipe/sceneIntroDemo.cpp
index b4504d16d5f..6b2006d8680 100644
--- a/engines/ngi/fullpipe/sceneIntroDemo.cpp
+++ b/engines/ngi/fullpipe/sceneIntroDemo.cpp
@@ -21,10 +21,10 @@
#include "ngi/ngi.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/modal.h"
#include "ngi/statics.h"
diff --git a/engines/ngi/fullpipe/sceneNotebook.cpp b/engines/ngi/fullpipe/sceneNotebook.cpp
index 48e1b0b530f..2a461096582 100644
--- a/engines/ngi/fullpipe/sceneNotebook.cpp
+++ b/engines/ngi/fullpipe/sceneNotebook.cpp
@@ -21,16 +21,16 @@
#include "ngi/ngi.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/font.h"
#include "ngi/gameloader.h"
#include "ngi/modal.h"
#include "ngi/anihandler.h"
-#include "ngi/chaptermanager.h"
+#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/guimanager.h"
-#include "ngi/notebook.h"
-#include "ngi/scenes.h"
-#include "ngi/taskmanager.h"
+#include "ngi/fullpipe/notebook.h"
+#include "ngi/fullpipe/scenes.h"
+#include "ngi/fullpipe/taskmanager.h"
namespace NGI {
diff --git a/engines/ngi/fullpipe/sceneTutorial.cpp b/engines/ngi/fullpipe/sceneTutorial.cpp
index 2e828f459ae..1d1f025d9cf 100644
--- a/engines/ngi/fullpipe/sceneTutorial.cpp
+++ b/engines/ngi/fullpipe/sceneTutorial.cpp
@@ -22,12 +22,12 @@
#include "math/utils.h"
#include "ngi/ngi.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/font.h"
#include "ngi/gameloader.h"
#include "ngi/modal.h"
#include "ngi/motion.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "common/formats/xmlparser.h"
diff --git a/engines/ngi/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
similarity index 99%
rename from engines/ngi/scenes.cpp
rename to engines/ngi/fullpipe/scenes.cpp
index 945eb784c60..3c3053ebe0e 100644
--- a/engines/ngi/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -28,14 +28,14 @@
#include "ngi/motion.h"
#include "ngi/input.h"
#include "ngi/behavior.h"
-#include "ngi/floaters.h"
-#include "ngi/taskmanager.h"
+#include "ngi/fullpipe/floaters.h"
+#include "ngi/fullpipe/taskmanager.h"
-#include "ngi/constants.h"
-#include "ngi/objectnames.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/font.h"
-#include "ngi/tremble.h"
+#include "ngi/fullpipe/tremble.h"
#include "ngi/interaction.h"
namespace NGI {
diff --git a/engines/ngi/scenes.h b/engines/ngi/fullpipe/scenes.h
similarity index 99%
rename from engines/ngi/scenes.h
rename to engines/ngi/fullpipe/scenes.h
index 29755947af9..101e12cf359 100644
--- a/engines/ngi/scenes.h
+++ b/engines/ngi/fullpipe/scenes.h
@@ -267,7 +267,7 @@ public:
bool scene02_boxOpen;
AniObject *scene03_eggeater;
- // Android: the hint over the scene that says how many eggs the egg eater still wants (CSc03Controller +244 the time, +248 the text)
+ // Android: hint over the scene with the eggs still wanted (CSc03Controller +244 time, +248 text)
Common::String scene03_hintText;
int scene03_hintTimer;
BitmapFont *scene03_hintFont;
diff --git a/engines/ngi/taskmanager.cpp b/engines/ngi/fullpipe/taskmanager.cpp
similarity index 99%
rename from engines/ngi/taskmanager.cpp
rename to engines/ngi/fullpipe/taskmanager.cpp
index 72c5d819c98..e39d6c06c8d 100644
--- a/engines/ngi/taskmanager.cpp
+++ b/engines/ngi/fullpipe/taskmanager.cpp
@@ -30,10 +30,10 @@
#include "ngi/gameloader.h"
#include "ngi/objects.h"
#include "ngi/anihandler.h"
-#include "ngi/chaptermanager.h"
-#include "ngi/notebook.h"
-#include "ngi/scenes.h"
-#include "ngi/taskmanager.h"
+#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/notebook.h"
+#include "ngi/fullpipe/scenes.h"
+#include "ngi/fullpipe/taskmanager.h"
namespace NGI {
diff --git a/engines/ngi/taskmanager.h b/engines/ngi/fullpipe/taskmanager.h
similarity index 100%
rename from engines/ngi/taskmanager.h
rename to engines/ngi/fullpipe/taskmanager.h
diff --git a/engines/ngi/tremble.cpp b/engines/ngi/fullpipe/tremble.cpp
similarity index 99%
rename from engines/ngi/tremble.cpp
rename to engines/ngi/fullpipe/tremble.cpp
index 0e4d96b6d9e..e67eecbe8ab 100644
--- a/engines/ngi/tremble.cpp
+++ b/engines/ngi/fullpipe/tremble.cpp
@@ -31,8 +31,8 @@
#include "ngi/scene.h"
#include "ngi/statics.h"
#include "ngi/gameloader.h"
-#include "ngi/constants.h"
-#include "ngi/tremble.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/tremble.h"
namespace NGI {
diff --git a/engines/ngi/tremble.h b/engines/ngi/fullpipe/tremble.h
similarity index 100%
rename from engines/ngi/tremble.h
rename to engines/ngi/fullpipe/tremble.h
diff --git a/engines/ngi/gameloader.cpp b/engines/ngi/gameloader.cpp
index 63d59605ce5..889761bd848 100644
--- a/engines/ngi/gameloader.cpp
+++ b/engines/ngi/gameloader.cpp
@@ -27,9 +27,9 @@
#include "ngi/statics.h"
#include "ngi/interaction.h"
#include "ngi/motion.h"
-#include "ngi/constants.h"
-#include "ngi/scenes.h"
-#include "ngi/floaters.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/scenes.h"
+#include "ngi/fullpipe/floaters.h"
namespace NGI {
diff --git a/engines/ngi/init.cpp b/engines/ngi/init.cpp
index 3d4d84b67df..abdd532b270 100644
--- a/engines/ngi/init.cpp
+++ b/engines/ngi/init.cpp
@@ -23,10 +23,10 @@
#include "ngi/objects.h"
#include "ngi/gameloader.h"
-#include "ngi/objectnames.h"
+#include "ngi/fullpipe/objectnames.h"
#include "ngi/input.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/constants.h"
namespace NGI {
diff --git a/engines/ngi/input.cpp b/engines/ngi/input.cpp
index 865375c8150..cd9cbb134db 100644
--- a/engines/ngi/input.cpp
+++ b/engines/ngi/input.cpp
@@ -28,7 +28,7 @@
#include "ngi/gameloader.h"
#include "ngi/statics.h"
#include "ngi/interaction.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/constants.h"
namespace NGI {
diff --git a/engines/ngi/messagehandlers.cpp b/engines/ngi/messagehandlers.cpp
index 27e08614676..fb9f8f8105b 100644
--- a/engines/ngi/messagehandlers.cpp
+++ b/engines/ngi/messagehandlers.cpp
@@ -28,7 +28,7 @@
#include "ngi/motion.h"
#include "ngi/input.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/constants.h"
namespace NGI {
diff --git a/engines/ngi/modal.cpp b/engines/ngi/modal.cpp
index fed9707fac4..8c61e199bc6 100644
--- a/engines/ngi/modal.cpp
+++ b/engines/ngi/modal.cpp
@@ -22,13 +22,13 @@
#include "engines/metaengine.h"
#include "ngi/ngi.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/gameloader.h"
#include "ngi/messages.h"
#include "ngi/modal.h"
#include "ngi/motion.h"
-#include "ngi/objectnames.h"
-#include "ngi/scenes.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/statics.h"
#include "engines/savestate.h"
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 09cfbd93106..e286997433d 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -1,14 +1,10 @@
MODULE := engines/ngi
MODULE_OBJS = \
- achievements.o \
anihandler.o \
behavior.o \
- chaptermanager.o \
console.o \
- floaters.o \
font.o \
- fpcontroller.o \
gameloader.o \
gfx.o \
guimanager.o \
@@ -16,7 +12,6 @@ MODULE_OBJS = \
input.o \
interaction.o \
inventory.o \
- lift.o \
messagehandlers.o \
messages.o \
metaengine.o \
@@ -24,17 +19,13 @@ MODULE_OBJS = \
motion.o \
ngi.o \
ngiarchive.o \
- notebook.o \
physics.o \
scene.o \
sceneobjects.o \
- scenes.o \
sound.o \
stateloader.o \
statesaver.o \
statics.o \
- taskmanager.o \
- tremble.o \
utils.o \
xmlproject.o \
zcontroller.o \
@@ -83,6 +74,12 @@ MODULE_OBJS = \
box2d/Dynamics/b2World.o \
box2d/Dynamics/b2WorldCallbacks.o \
box2d/Rope/b2Rope.o \
+ fullpipe/achievements.o \
+ fullpipe/chaptermanager.o \
+ fullpipe/floaters.o \
+ fullpipe/fpcontroller.o \
+ fullpipe/lift.o \
+ fullpipe/notebook.o \
fullpipe/scene01.o \
fullpipe/scene02.o \
fullpipe/scene03.o \
@@ -126,7 +123,10 @@ MODULE_OBJS = \
fullpipe/sceneIntro.o \
fullpipe/sceneIntroDemo.o \
fullpipe/sceneNotebook.o \
- fullpipe/sceneTutorial.o
+ fullpipe/sceneTutorial.o \
+ fullpipe/scenes.o \
+ fullpipe/taskmanager.o \
+ fullpipe/tremble.o
# This module can be built as a plugin
ifeq ($(ENABLE_NGI), DYNAMIC_PLUGIN)
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 92c10ed7250..95dfdd8b3b7 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -32,10 +32,10 @@
#include "graphics/surface.h"
#include "ngi/ngi.h"
-#include "ngi/chaptermanager.h"
-#include "ngi/notebook.h"
-#include "ngi/taskmanager.h"
-#include "ngi/tremble.h"
+#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/notebook.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tremble.h"
#include "ngi/detection.h"
#include "ngi/gameloader.h"
#include "ngi/messages.h"
@@ -44,10 +44,10 @@
#include "ngi/input.h"
#include "ngi/motion.h"
#include "ngi/statics.h"
-#include "ngi/scenes.h"
-#include "ngi/floaters.h"
+#include "ngi/fullpipe/scenes.h"
+#include "ngi/fullpipe/floaters.h"
#include "ngi/console.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/constants.h"
namespace NGI {
NGIEngine *g_ngi = nullptr;
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 4ff455cd4be..e584506bd14 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -34,7 +34,7 @@
#include "ngi/motion.h"
#include "ngi/gameloader.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/constants.h"
#include "common/algorithm.h"
#include "common/debug-channels.h"
diff --git a/engines/ngi/stateloader.cpp b/engines/ngi/stateloader.cpp
index eef8f45d877..197c63e80b7 100644
--- a/engines/ngi/stateloader.cpp
+++ b/engines/ngi/stateloader.cpp
@@ -21,7 +21,7 @@
#include "ngi/ngi.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/detection.h"
#include "ngi/gameloader.h"
#include "ngi/interaction.h"
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index dd9fdcbbc78..fb7ac93a05e 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -28,8 +28,8 @@
#include "ngi/interaction.h"
#include "ngi/motion.h"
-#include "ngi/constants.h"
-#include "ngi/objectnames.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/objectnames.h"
namespace NGI {
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 28ace51d8bc..d79e741a16c 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -27,14 +27,14 @@
#include "common/formats/xmlparser.h"
#include "ngi/ngi.h"
-#include "ngi/objectnames.h"
+#include "ngi/fullpipe/objectnames.h"
#include "ngi/gameloader.h"
#include "ngi/behavior.h"
#include "ngi/physics.h"
#include "ngi/sceneobjects.h"
-#include "ngi/tremble.h"
+#include "ngi/fullpipe/tremble.h"
#include "ngi/zcontroller.h"
-#include "ngi/constants.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/detection.h"
#include "ngi/messages.h"
#include "ngi/motion.h"
@@ -43,9 +43,9 @@
#include "ngi/utils.h"
#include "ngi/scene.h"
#include "ngi/statics.h"
-#include "ngi/chaptermanager.h"
-#include "ngi/notebook.h"
-#include "ngi/taskmanager.h"
+#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/notebook.h"
+#include "ngi/fullpipe/taskmanager.h"
namespace NGI {
Commit: 79c309f1563460e8954601ed0f9f8d3c9aa1a5a4
https://github.com/scummvm/scummvm/commit/79c309f1563460e8954601ed0f9f8d3c9aa1a5a4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Load the lift passages and number the lift buttons as the Android game does
Changed paths:
engines/ngi/fullpipe/lift.cpp
engines/ngi/ngi.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/lift.cpp b/engines/ngi/fullpipe/lift.cpp
index 0bcbc2fbdae..0d1920cb3bd 100644
--- a/engines/ngi/fullpipe/lift.cpp
+++ b/engines/ngi/fullpipe/lift.cpp
@@ -33,7 +33,18 @@
namespace NGI {
+// Button statics: 23070 (scene) or 23040 (big view) + 3 * n: normal, pushed (+1), hilite (+2)
+static const int kLiftButtonBase = 23070;
+static const int kLiftButtonCount = 10;
+
+static bool lift_isAndroidButton(int objid) {
+ return objid >= kLiftButtonBase && objid < kLiftButtonBase + 3 * kLiftButtonCount;
+}
+
int NGIEngine::lift_getButtonIdP(int objid) {
+ if (isAndroidFullPipe())
+ return lift_isAndroidButton(objid) ? objid + 1 : 0;
+
switch (objid) {
case ST_LBN_0N:
return ST_LBN_0P;
@@ -71,6 +82,9 @@ int NGIEngine::lift_getButtonIdP(int objid) {
}
int NGIEngine::lift_getButtonIdH(int objid) {
+ if (isAndroidFullPipe())
+ return lift_isAndroidButton(objid) ? objid + 1 : 0;
+
switch (objid) {
case ST_LBN_0P:
return ST_LBN_0H;
@@ -108,6 +122,9 @@ int NGIEngine::lift_getButtonIdH(int objid) {
}
int NGIEngine::lift_getButtonIdN(int objid) {
+ if (isAndroidFullPipe())
+ return lift_isAndroidButton(objid) ? kLiftButtonBase + (objid - kLiftButtonBase) / 3 * 3 : 0;
+
switch (objid) {
case ST_LBN_0H:
case ST_LBN_0N:
@@ -164,11 +181,46 @@ int NGIEngine::lift_getButtonIdN(int objid) {
}
}
-void NGIEngine::lift_setButton(const char *name, int state) {
+// the states of the object "Ðнопки лиÑÑа": one per floor, the value is the statics of the button
+static GameVar *lift_buttonStates() {
GameVar *var = g_ngi->getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->getSubVarByName(sO_LiftButtons);
+ if (var && g_ngi->isAndroidFullPipe())
+ var = var->getSubVarByName("ENUMSTATES");
+
+ return var;
+}
+
+// the Windows scene code names the normal statics (ST_LBN_2N ...), Android counts from 23070
+static int lift_androidButton(int windowsStaticsId) {
+ static const int normal[10] = { ST_LBN_0N, ST_LBN_1N, ST_LBN_2N, ST_LBN_3N, ST_LBN_4N, ST_LBN_5N, ST_LBN_6N, ST_LBN_7N, ST_LBN_8N, ST_LBN_9N };
+
+ for (int floor = 0; floor < 10; ++floor) {
+ if (normal[floor] == windowsStaticsId)
+ return kLiftButtonBase + 3 * (floor == 0 ? 9 : floor - 1);
+ }
+
+ return windowsStaticsId;
+}
+
+void NGIEngine::lift_setButton(const char *name, int state) {
+ GameVar *var = lift_buttonStates();
+
if (var)
- var->setSubVarAsInt(name, state);
+ var->setSubVarAsInt(name, isAndroidFullPipe() ? lift_androidButton(state) : state);
+}
+
+// CLift::ResetButtons (CStateManager::SetStartStates): every button starts pushed
+void NGIEngine::lift_resetButtons() {
+ GameVar *var = lift_buttonStates();
+
+ if (!var || !isAndroidFullPipe())
+ return;
+
+ static const char *const floors[10] = { sO_Level0, sO_Level1, sO_Level2, sO_Level3, sO_Level4, sO_Level5, sO_Level6, sO_Level7, sO_Level8, sO_Level9 };
+
+ for (int floor = 0; floor < 10; ++floor)
+ var->setSubVarAsInt(floors[floor], kLiftButtonBase + 3 * (floor == 0 ? 9 : floor - 1) + 1);
}
void NGIEngine::lift_init(Scene *sc, int enterSeq, int exitSeq) {
@@ -200,7 +252,7 @@ void NGIEngine::lift_init(Scene *sc, int enterSeq, int exitSeq) {
ani->_statics = ani->getStatic(lift_getButtonIdP(ani->_statics->_staticsId));
}
- GameVar *var = getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->getSubVarByName(sO_LiftButtons);
+ GameVar *var = lift_buttonStates();
if (var) {
for (var = var->_subVars; var; var = var->_nextVarObj) {
for (uint i = 0; i < sc->_aniObjects.size(); i++) {
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 96a451d2f7e..adbc7986d04 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -393,6 +393,7 @@ public:
int lift_getButtonIdH(int objid);
int lift_getButtonIdN(int objid);
void lift_setButton(const char *name, int state);
+ void lift_resetButtons();
void lift_init(Scene *sc, int qu1, int qu2);
void lift_setButtonStatics(Scene *sc, int buttonId);
void lift_exitSeq(Command *ex);
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index d79e741a16c..38c1bba9c0a 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -153,6 +153,51 @@ private:
}
};
+// data.xml PASSAGES (CLift::OnGo): kept as preload items of the Windows game
+class XMLPassageParser : public Common::XMLParser {
+public:
+ XMLPassageParser(PreloadItems &items, const ObjectIdList &ids) : _items(items), _ids(ids) {}
+
+private:
+ PreloadItems &_items;
+ const ObjectIdList &_ids;
+
+ CUSTOM_XML_PARSER(XMLPassageParser) {
+ XML_KEY(DATA)
+ KEY_END()
+ } PARSER_END()
+
+ bool parserCallback_DATA(ParserNode *) { return true; }
+
+ bool handleUnknownKey(ParserNode *node) override {
+ const ParserNode *parent = getParentNode(node);
+ node->layout = _XMLkeys;
+ if (!parent)
+ return false;
+ if (node->name == "PASSAGE" && parent->name == "PASSAGES") {
+ uint32 source;
+ uint32 button;
+ uint32 destination;
+ uint32 hint;
+ if (_ids.findId(node->values.getValOrDefault("srcScene"), source) && _ids.findId(node->values.getValOrDefault("srcHint"), button) &&
+ _ids.findId(node->values.getValOrDefault("destScene"), destination) && _ids.findId(node->values.getValOrDefault("destHint"), hint)) {
+ PreloadItem item;
+ item.preloadId1 = source;
+ item.preloadId2 = button;
+ item.sceneId = destination;
+ item.param = hint;
+ _items.push_back(item);
+ } else {
+ warning("Unknown id in PASSAGE %s -> %s", node->values.getValOrDefault("srcScene").c_str(), node->values.getValOrDefault("destScene").c_str());
+ }
+ return true;
+ }
+ // everything but the PASSAGES of data.xml is read by XMLSceneDataParser
+ node->ignore = node->name != "PASSAGES";
+ return true;
+ }
+};
+
// data.xml: per-scene data (flies, cursors, scroll borders). It is stored in the layout of the Windows game
// variables (SC_N / Fliers / flyIdleRegion ...) so the shared scene code reads it unchanged.
class XMLSceneDataParser : public Common::XMLParser {
@@ -1712,6 +1757,12 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
XMLSceneDataParser sceneDataParser(*_gameVar);
if (!sceneDataParser.loadFile("data/data.xml") || !sceneDataParser.parse())
return Common::Error(Common::kNoGameDataFoundError, "Could not read the scene data");
+ if (g_ngi->_gameVersion >= 201509) {
+ XMLPassageParser passageParser(_preloadItems, project._objectIds);
+ if (!passageParser.loadFile("data/data.xml") || !passageParser.parse())
+ return Common::Error(Common::kNoGameDataFoundError, "Could not read the lift passages");
+ }
+ g_ngi->lift_resetButtons();
_gameVar->addSubVarAsInt("CHAPTERS", 0);
if (g_ngi->_gameVersion >= 201509) { // tasks.xml is known from the 2015 revision on
g_ngi->_chapterManager.reset(new ChapterManager);
Commit: cfc2583919808e6f487cf003e8942d71e89bbb32
https://github.com/scummvm/scummvm/commit/cfc2583919808e6f487cf003e8942d71e89bbb32
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Add the lift button panel of the Android game
Changed paths:
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/lift.cpp
engines/ngi/ngi.h
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 5a56cba742f..fffecec1d00 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -354,6 +354,12 @@ bool sceneController_click(Common::Point pos) {
GameObject *target = picture;
if (actor && (!picture || actor->_z < picture->_z))
target = actor;
+ debugC(2, kDebugSceneLogic, "sceneController_click: %d,%d picture %d (z %d) actor %d (z %d)", pos.x, pos.y, picture ? picture->_id : 0, picture ? picture->_z : 0,
+ actor ? actor->_id : 0, actor ? actor->_z : 0);
+ // CLift::OnButtonUp: the lift door and the areas GD_SC3_LIFT ... GD_SC38_LIFT open the panel of the lift buttons
+ if (target && g_ngi->isAndroidFullPipe() && (target->_id == ANI_LIFT || (target->_id >= 23116 && target->_id <= 23125)) && g_ngi->lift_switchToBigView())
+ return true;
+
if (target) {
uint32 upperPipe;
if (g_ngi->_gameProject->_objectIds.findId("PIC_SC1_UTRUBA", upperPipe) && upperPipe == (uint16)target->_id)
diff --git a/engines/ngi/fullpipe/lift.cpp b/engines/ngi/fullpipe/lift.cpp
index 0d1920cb3bd..cad63eba934 100644
--- a/engines/ngi/fullpipe/lift.cpp
+++ b/engines/ngi/fullpipe/lift.cpp
@@ -29,6 +29,7 @@
#include "ngi/statics.h"
#include "ngi/messages.h"
#include "ngi/gameloader.h"
+#include "ngi/modal.h"
#include "ngi/motion.h"
namespace NGI {
@@ -203,6 +204,159 @@ static int lift_androidButton(int windowsStaticsId) {
return windowsStaticsId;
}
+namespace {
+
+// CLiftController (the scene SC_LIFT, pushed over the scene by CLift::SwitchToBigView): a panel with a big copy of every lift button of the
+// scene. A tap on an enabled button lights it (CLiftController::OnMouseLKeyUp), 100 ms later its button of the scene is pressed
+// (CLift::OnButtonUpBig, lift_animateButton) and the panel closes; a tap anywhere else closes it.
+class ModalLiftView : public BaseModalObject {
+public:
+ explicit ModalLiftView(Scene &view) : _view(view) {}
+
+ ~ModalLiftView() override {
+ for (const Button &button : _buttons) {
+ _view.removeAni(button.big);
+ delete button.big;
+ }
+ }
+
+ // CLift::SwitchToBigView + CLiftController::SortButtons
+ bool open() {
+ _background = _view.findPictureObjectById(23038, 0); // PIC_LIFT_BGR
+ AniObject *bigButton = _view.findAniObjectById(23039, 0); // ANI_LIFTBUTTON_BIG
+ if (!_background || !bigButton) {
+ debugC(2, kDebugSceneLogic, "ModalLiftView: background %p, big button %p", (void *)_background, (void *)bigButton);
+ return false;
+ }
+
+ Common::Array<AniObject *> small;
+ for (AniObject *ani : g_ngi->_currentScene->_renderableAnis) {
+ if (ani->_id == ANI_LIFTBUTTON && ani->_statics)
+ small.push_back(ani);
+ }
+ // LiftButtonSort: by y, equal y by x
+ for (uint i = 1; i < small.size(); ++i) {
+ for (uint j = i; j > 0; --j) {
+ const AniObject *a = small[j - 1];
+ const AniObject *b = small[j];
+ if (!(a->_y == b->_y ? a->_x > b->_x : a->_y > b->_y))
+ break;
+ SWAP(small[j - 1], small[j]);
+ }
+ }
+ if (small.empty()) {
+ debugC(2, kDebugSceneLogic, "ModalLiftView: the scene has no lift buttons");
+ return false;
+ }
+
+ for (uint i = 0; i < small.size(); ++i) {
+ AniObject *big = new AniObject(bigButton);
+ _view.addAni(big, true);
+ big->_flags |= 4;
+ big->_statics = big->getStatic(small[i]->_statics->_staticsId - 30);
+ Common::Point center(_background->_x + 52 + (i & 1) * 65, _background->_y + 64 + (i >> 1) * 85);
+ if (i + 1 == small.size() && small[i]->_x > small[0]->_x)
+ center.x = _background->_x + 52 + 65;
+ big->setCenter(center);
+
+ Button button;
+ button.big = big;
+ button.small = small[i];
+ _buttons.push_back(button);
+ }
+
+ return true;
+ }
+
+ bool init(int elapsed) override {
+ if (_finished)
+ return false;
+ if (_selected) {
+ _time += elapsed;
+ if (_time > 100) {
+ g_ngi->lift_animateButton(_selected->small);
+ return false;
+ }
+ }
+ return true;
+ }
+
+ void update() override {
+ g_ngi->_currentScene->render();
+ if (g_ngi->_inventoryScene && g_ngi->_inventoryScene->_guiManager)
+ g_ngi->_inventoryScene->_guiManager->render(g_ngi->_backgroundSurface);
+ _background->render();
+ for (const Button &button : _buttons)
+ button.big->render();
+ }
+
+ bool handleMessage(Command *cmd) override {
+ if (cmd->_cmd != kCmdMessage || cmd->_messageNum != kMsgLButtonUp)
+ return false;
+ if (_selected)
+ return true;
+
+ AniObject *hit = _view.findAniObjectAtPos(cmd->_x, cmd->_y);
+ if (hit && hit->_id == 23039 && hit->_statics && (hit->_statics->_staticsId - 23040) % 3 == 0) {
+ for (Button &button : _buttons) {
+ if (button.big == hit)
+ _selected = &button;
+ }
+ }
+ if (!_selected) {
+ _finished = true;
+ return true;
+ }
+
+ g_ngi->playSound(SND_CMN_032, 0);
+ hit->_statics = hit->getStatic(hit->_statics->_staticsId + 2); // CLiftController::GetStaticsHilite
+ return true;
+ }
+
+ bool pollEvent() override { return true; }
+ void saveload() override {}
+
+private:
+ struct Button {
+ AniObject *big = nullptr;
+ AniObject *small = nullptr;
+ };
+
+ Scene &_view;
+ PictureObject *_background = nullptr;
+ Common::Array<Button> _buttons;
+ Button *_selected = nullptr;
+ int _time = 0;
+ bool _finished = false;
+};
+
+} // End of anonymous namespace
+
+// CLift::OnButtonUp (the tap on the lift door or on a GD_SCn_LIFT area of the scene): CLift::SwitchToBigView
+bool NGIEngine::lift_switchToBigView() {
+ uint32 viewId;
+ if (!_lift || !_liftEnterMQ || _modalObject || !_aniMan || !_aniMan->isIdle() || !getGameLoaderInteractionController()->_enabled ||
+ !_gameProject->_objectIds.findId("SC_LIFT", viewId)) {
+ debugC(2, kDebugSceneLogic, "lift_switchToBigView: not now (lift %p, enter queue %p, modal %p, idle %d)", (void *)_lift, (void *)_liftEnterMQ,
+ (void *)_modalObject, _aniMan ? _aniMan->isIdle() : -1);
+ return false;
+ }
+
+ Scene *view = findScene(viewId);
+ if (!view) {
+ debugC(2, kDebugSceneLogic, "lift_switchToBigView: scene %d is not loaded", viewId);
+ return false;
+ }
+
+ Common::ScopedPtr<ModalLiftView> modal(new ModalLiftView(*view));
+ if (!modal->open())
+ return false;
+
+ modal->_parentObj = _modalObject;
+ _modalObject = modal.release();
+ return true;
+}
+
void NGIEngine::lift_setButton(const char *name, int state) {
GameVar *var = lift_buttonStates();
@@ -245,8 +399,11 @@ void NGIEngine::lift_init(Scene *sc, int enterSeq, int exitSeq) {
_lift = sc->findAniObjectById(ANI_LIFT, -1);
- for (uint i = 0; i < sc->_aniObjects.size(); i++) {
- AniObject *ani = sc->_aniObjects[i];
+ // Android: the buttons are copies of the animation of the common scene (ADDANI) and only in the list of the drawn animations
+ Common::Array<AniObject *> &anis = isAndroidFullPipe() ? sc->_renderableAnis : sc->_aniObjects;
+
+ for (uint i = 0; i < anis.size(); i++) {
+ AniObject *ani = anis[i];
if (ani->_id == ANI_LIFTBUTTON)
ani->_statics = ani->getStatic(lift_getButtonIdP(ani->_statics->_staticsId));
@@ -255,8 +412,8 @@ void NGIEngine::lift_init(Scene *sc, int enterSeq, int exitSeq) {
GameVar *var = lift_buttonStates();
if (var) {
for (var = var->_subVars; var; var = var->_nextVarObj) {
- for (uint i = 0; i < sc->_aniObjects.size(); i++) {
- AniObject *ani = sc->_aniObjects[i];
+ for (uint i = 0; i < anis.size(); i++) {
+ AniObject *ani = anis[i];
if (ani->_id == ANI_LIFTBUTTON) {
int id = lift_getButtonIdN(ani->_statics->_staticsId);
@@ -467,9 +624,14 @@ void NGIEngine::lift_goAnimation() {
mq->addCommandToEnd(ex);
- ex = new Command(parentId, kCmdMessage, kMsgPreloadScene, 0, 0, 0, 1, 0, 0, 0);
+ if (isAndroidFullPipe()) {
+ // CLift::OnGo: the SETSC command names the destination scene and its entrance (the data.xml PASSAGE)
+ ex = new Command(pre.sceneId, kCmdSetScene, pre.param, 0, 0, 0, 1, 0, 0, 0);
+ } else {
+ ex = new Command(parentId, kCmdMessage, kMsgPreloadScene, 0, 0, 0, 1, 0, 0, 0);
- ex->_param = buttonId;
+ ex->_param = buttonId;
+ }
ex->_excFlags |= 3;
mq->addCommandToEnd(ex);
@@ -547,7 +709,7 @@ void NGIEngine::lift_hoverButton(Command *cmd) {
}
bool NGIEngine::lift_checkButton(const char *varName) {
- GameVar *var = g_ngi->getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->getSubVarByName(sO_LiftButtons);
+ GameVar *var = lift_buttonStates();
if (var)
return lift_getButtonIdP(var->getSubVarByName(varName)->_value.intValue) > 0;
@@ -556,8 +718,10 @@ bool NGIEngine::lift_checkButton(const char *varName) {
}
void NGIEngine::lift_setButtonStatics(Scene *sc, int buttonId) {
- for (uint i = 0; i < sc->_aniObjects.size(); i++) {
- AniObject *ani = sc->_aniObjects[i];
+ Common::Array<AniObject *> &anis = isAndroidFullPipe() ? sc->_renderableAnis : sc->_aniObjects;
+
+ for (uint i = 0; i < anis.size(); i++) {
+ AniObject *ani = anis[i];
if (ani->_id == ANI_LIFTBUTTON) {
int id = lift_getButtonIdN(ani->_statics->_staticsId);
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index adbc7986d04..5fcda9aa126 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -394,6 +394,8 @@ public:
int lift_getButtonIdN(int objid);
void lift_setButton(const char *name, int state);
void lift_resetButtons();
+ /** Android: opens the panel with the buttons of the lift of the scene (CLift::SwitchToBigView) */
+ bool lift_switchToBigView();
void lift_init(Scene *sc, int qu1, int qu2);
void lift_setButtonStatics(Scene *sc, int buttonId);
void lift_exitSeq(Command *ex);
Commit: 000b62a559839690d0488e86154f926f7a8e1ce5
https://github.com/scummvm/scummvm/commit/000b62a559839690d0488e86154f926f7a8e1ce5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Start the scene 4 logic for XML projects
Changed paths:
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/scene04.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/scene.h
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index fffecec1d00..945f6739641 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -348,6 +348,8 @@ bool sceneController_click(Common::Point pos) {
for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList)
if (queue->_queueId == QU_SC1_ENTER && !queue->_isFinished)
return false;
+ if (scene._clickHook && scene._clickHook(pos))
+ return true;
pos += Common::Point(scene._x, scene._y);
PictureObject *picture = scene.findPictureObjectAtPos(pos.x, pos.y);
AniObject *actor = scene.findAniObjectAtPos(pos.x, pos.y);
diff --git a/engines/ngi/fullpipe/scene04.cpp b/engines/ngi/fullpipe/scene04.cpp
index ead925511c2..cef4b813211 100644
--- a/engines/ngi/fullpipe/scene04.cpp
+++ b/engines/ngi/fullpipe/scene04.cpp
@@ -45,6 +45,7 @@ static const int scene04_speakerPhases[] = {
};
void sceneHandler04_putKozyawkaBack(AniObject *ani);
+static bool scene04_click(Common::Point pos);
void scene04_speakerCallback(int *phase) {
if (g_vars->scene04_soundPlaying) {
@@ -157,7 +158,9 @@ void scene04_initScene(Scene *sc) {
if (koz) {
debugC(2, kDebugSceneLogic, "scene04: We're in koz");
- koz->loadMovements();
+ // Android: the PNG phases are loaded with the scene
+ if (!g_ngi->isAndroidFullPipe())
+ koz->loadMovements();
koz->_statics = koz->getStatic(ST_KZW_EMPTY);
koz->setPos(0, 0);
@@ -218,6 +221,9 @@ void scene04_initScene(Scene *sc) {
g_vars->scene04_musicStage = 0;
g_ngi->initArcadeKeys("SC_4");
+
+ if (g_ngi->isAndroidFullPipe())
+ sc->_clickHook = scene04_click;
}
bool sceneHandler04_friesAreWalking() {
@@ -1356,6 +1362,44 @@ void sceneHandler04_doWinArcade() {
}
}
+// CSc04Controller::OnMouseLKeyUp: the ladder, the plank, the hero on the ladder
+static bool scene04_click(Common::Point pos) {
+ Scene &scene = *g_ngi->_currentScene;
+ const int x = pos.x + scene._x;
+ const int y = pos.y + scene._y;
+ const int picid = scene.getPictureObjectIdAtPos(x, y);
+
+ if (g_vars->scene04_dudeInBottle) {
+ sceneHandler04_animOutOfBottle(nullptr);
+ return true;
+ }
+
+ if (picid == PIC_SC4_LADDER) {
+ if (!g_vars->scene04_kozyawkaOnLadder) {
+ g_vars->scene04_sceneClickX = x;
+ g_vars->scene04_sceneClickY = y;
+ sceneHandler04_clickLadder();
+ } else {
+ sceneHandler04_gotoLadder(nullptr);
+ }
+ return true;
+ }
+
+ AniObject *ani = scene.findAniObjectAtPos(x, y);
+ if ((ani && ani->_id == ANI_PLANK) || picid == PIC_SC4_PLANK) {
+ sceneHandler04_clickPlank();
+ return true;
+ }
+
+ if (g_vars->scene04_dudeOnLadder) {
+ Command click(0, kCmdMessage, kMsgLButtonDown, pos.x, pos.y, 0, 1, x, y, 0);
+ sceneHandler04_leaveLadder(&click);
+ return click._cmd == kCmdNone;
+ }
+
+ return false;
+}
+
int sceneHandler04(Command *ex) {
if (ex->_cmd != kCmdMessage)
return 0;
@@ -1434,6 +1478,25 @@ int sceneHandler04(Command *ex) {
int res = 0;
+ // Android: CFPController scrolls (UpdateScroll for the ladder), Scene::update drives behaviors
+ if (g_ngi->isAndroidFullPipe()) {
+ sceneHandler04_springWobble();
+
+ if (g_vars->scene04_var07 && !g_vars->scene04_handIsDown)
+ sceneHandler04_leaveScene();
+
+ if (g_vars->scene04_bottleIsDropped)
+ sceneHandler04_liftBottle();
+
+ if (g_vars->scene04_dudeInBottle && g_vars->scene04_hand->_movement)
+ sceneHandler04_animOutOfBottle(nullptr);
+
+ if (g_vars->scene04_coinPut && g_vars->scene04_clockCanGo && !g_vars->scene04_handIsDown && !g_vars->scene04_soundPlaying)
+ sceneHandler04_goClock();
+
+ break;
+ }
+
if (g_ngi->_aniMan2) {
if (g_ngi->_aniMan->_x < g_ngi->_sceneRect.left + 200) {
g_ngi->_currentScene->_x = g_ngi->_aniMan->_x - g_ngi->_sceneRect.left - 300;
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index 3c3053ebe0e..c4e75ae3f71 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -591,6 +591,10 @@ bool NGIEngine::initSceneLogic(Scene *scene, int entranceId) {
scene03_initScene(scene);
addMessageHandler(sceneHandler03, 2);
return true;
+ case SC_4:
+ scene04_initScene(scene);
+ addMessageHandler(sceneHandler04, 2);
+ return true;
default:
return false;
}
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 4b2a04f4f70..fab6c06f7dc 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -91,6 +91,8 @@ class Scene : public Background {
Common::ScopedPtr<ZController> _zController;
/** CScNNController::OnRender: what the logic of the scene draws between the layers (CScene::Render, controller slot 25) */
void (*_renderHook)(Scene &) = nullptr;
+ /** CScNNController::OnMouseLKeyUp before the tap handler of CFPController: true when the scene handled the tap (position in screen coordinates) */
+ bool (*_clickHook)(Common::Point) = nullptr;
void (*_guiEventHandler)(Scene &, const Common::String &, const Common::String &) = nullptr;
void onGuiEvent(const Common::String &id, const Common::String &event);
Common::Array<MessageQueue *> _messageQueues;
Commit: 38b29ebe0be1e782d2ebae2a09fd63639a31798e
https://github.com/scummvm/scummvm/commit/38b29ebe0be1e782d2ebae2a09fd63639a31798e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Run the spring of scene 4 once per 83 ms on Android
Changed paths:
engines/ngi/fullpipe/scene04.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/fullpipe/scenes.h
diff --git a/engines/ngi/fullpipe/scene04.cpp b/engines/ngi/fullpipe/scene04.cpp
index cef4b813211..9230d1a25d0 100644
--- a/engines/ngi/fullpipe/scene04.cpp
+++ b/engines/ngi/fullpipe/scene04.cpp
@@ -1480,7 +1480,13 @@ int sceneHandler04(Command *ex) {
// Android: CFPController scrolls (UpdateScroll for the ladder), Scene::update drives behaviors
if (g_ngi->isAndroidFullPipe()) {
- sceneHandler04_springWobble();
+ // CSc04Controller::RecalcSpring: one tick per update when 83 ms have passed, jar on the spring
+ g_vars->scene04_tickTime += ex->_param;
+ if (g_vars->scene04_tickTime > 83) {
+ g_vars->scene04_tickTime -= 83;
+ if (!g_vars->scene04_bottleIsDropped && g_ngi->getStateId(sO_Jar_4) == g_ngi->getStateValue(sO_Jar_4, sO_OnTheSpring))
+ sceneHandler04_springWobble();
+ }
if (g_vars->scene04_var07 && !g_vars->scene04_handIsDown)
sceneHandler04_leaveScene();
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index c4e75ae3f71..64fd32638b9 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -148,6 +148,7 @@ Vars::Vars() {
scene04_springOffset = 0;
scene04_lastKozyawka = nullptr;
scene04_springDelay = 0;
+ scene04_tickTime = 0;
scene04_bottleY = 0;
scene04_ladderOffset = 0;
diff --git a/engines/ngi/fullpipe/scenes.h b/engines/ngi/fullpipe/scenes.h
index 101e12cf359..628d660e960 100644
--- a/engines/ngi/fullpipe/scenes.h
+++ b/engines/ngi/fullpipe/scenes.h
@@ -325,6 +325,7 @@ public:
int scene04_springOffset;
AniObject *scene04_lastKozyawka;
int scene04_springDelay;
+ uint32 scene04_tickTime; // Android: milliseconds not yet used by a Windows tick (83 ms)
int scene04_musicStage;
Commit: f05880ed9706288d15b0e43081455106bba8e29d
https://github.com/scummvm/scummvm/commit/f05880ed9706288d15b0e43081455106bba8e29d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Add the progress bar GUI element of the Android game
Changed paths:
engines/ngi/guimanager.cpp
engines/ngi/guimanager.h
diff --git a/engines/ngi/guimanager.cpp b/engines/ngi/guimanager.cpp
index d813b09a0b5..31c850f370d 100644
--- a/engines/ngi/guimanager.cpp
+++ b/engines/ngi/guimanager.cpp
@@ -82,6 +82,66 @@ public:
}
};
+GuiProgressBar::GuiProgressBar(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids) :
+ GuiElement(scene, attrs, ids) {
+ _visId = resourceId(attrs, "vis", ids);
+ _fraction = atof(attrs.getValOrDefault("perc", "1.0").c_str());
+ _center = atof(attrs.getValOrDefault("cent", "0.5").c_str());
+ _horizontal = guiFlag(attrs, "horiz", true);
+ _lowBegin = guiFlag(attrs, "lb", true);
+}
+
+void GuiProgressBar::load(GameProject &project) {
+ GuiElement::load(project);
+ Scene *source = project.findScene(_sourceScene);
+ _vis = source && _visId ? source->findPictureObjectById(_visId, 0) : nullptr;
+ if (_vis) {
+ if (!_hasX)
+ _pos.x = _vis->_x;
+ if (!_hasY)
+ _pos.y = _vis->_y;
+ _size = _vis->getFullSize();
+ }
+}
+
+void GuiProgressBar::unload() {
+ GuiElement::unload();
+ _vis = nullptr;
+}
+
+void GuiProgressBar::render(Graphics::ManagedSurface &target) const {
+ if (!_visible || !_vis || !_vis->_picture)
+ return;
+
+ // two parts, [0, cut start] and [cut end, 1]: one keeps its place, the other moves by the cut
+ const float start = _fraction * _center;
+ const float end = 1.0f - _fraction * (1.0f - _center);
+ const Common::Point size = _vis->getFullSize();
+ const int cut = _horizontal ? static_cast<int>(end * size.x) - static_cast<int>(start * size.x)
+ : static_cast<int>(end * size.y) - static_cast<int>(start * size.y);
+
+ RenderParams first;
+ RenderParams second;
+ if (_horizontal) {
+ first.right = start;
+ second.left = end;
+ } else {
+ first.bottom = start;
+ second.top = end;
+ }
+
+ const Common::Point pos = screenPos();
+ const Common::Point shift = _horizontal ? Common::Point(cut, 0) : Common::Point(0, cut);
+ // horizontal + lowBegin or vertical + not lowBegin: the first part stays, the second moves back
+ if (_horizontal == _lowBegin) {
+ _vis->_picture->blitTo(target, pos, first);
+ _vis->_picture->blitTo(target, pos - shift, second);
+ } else {
+ _vis->_picture->blitTo(target, pos, second);
+ _vis->_picture->blitTo(target, pos + shift, first);
+ }
+}
+
class GuiButton : public GuiElement {
public:
GuiButton(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids);
@@ -209,8 +269,10 @@ void GuiManager::createElement(const Common::String &type, const Common::StringM
addGuiElement(new GuiButton(_scene, attrs, ids));
else if (type == "PICTURE")
addGuiElement(new GuiPicture(_scene, attrs, ids));
+ else if (type == "PROGRESSBAR")
+ addGuiElement(new GuiProgressBar(_scene, attrs, ids));
else if (type == "TEXT" || type == "TEXTBUTTON" || type == "SLIDER" ||
- type == "CHECKBOX" || type == "PROGRESSBAR") {
+ type == "CHECKBOX") {
warning("STUB: %s", type.c_str());
addGuiElement(new GuiElementStub(_scene, attrs, ids));
} else
diff --git a/engines/ngi/guimanager.h b/engines/ngi/guimanager.h
index cd2bd2b62d1..d2639d8ce18 100644
--- a/engines/ngi/guimanager.h
+++ b/engines/ngi/guimanager.h
@@ -73,6 +73,25 @@ protected:
Common::Point screenPos() const;
};
+// CGuiProgressBar: the picture "vis" with a part cut out so that the fraction "perc" is left
+class GuiProgressBar : public GuiElement {
+public:
+ GuiProgressBar(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids);
+ void load(GameProject &project) override;
+ void unload() override;
+ void render(Graphics::ManagedSurface &target) const override;
+ /** CArcadeInterface::Update sets the fraction to this (0..1) */
+ void setFraction(float perc) { _fraction = perc; }
+
+private:
+ int _visId;
+ PictureObject *_vis = nullptr;
+ float _fraction;
+ float _center;
+ bool _horizontal;
+ bool _lowBegin;
+};
+
class GuiManager {
public:
explicit GuiManager(Scene &scene) : _scene(scene) {}
Commit: 75252c54a1c323c1cd282fea5941f6917c61fe85
https://github.com/scummvm/scummvm/commit/75252c54a1c323c1cd282fea5941f6917c61fe85
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Add the text GUI elements and the text printing of the Android game
Changed paths:
engines/ngi/font.cpp
engines/ngi/font.h
engines/ngi/guimanager.cpp
engines/ngi/guimanager.h
engines/ngi/ngi.h
diff --git a/engines/ngi/font.cpp b/engines/ngi/font.cpp
index 9ec9ff3e2c5..cf4b1e26a8d 100644
--- a/engines/ngi/font.cpp
+++ b/engines/ngi/font.cpp
@@ -28,6 +28,25 @@
namespace NGI {
+Common::String NGIEngine::getText(const Common::String &id) {
+ if (!_textContainer) {
+ _textContainer.reset(new TextContainer());
+ if (!_textContainer->load(Common::Path(Common::String("data/res_") + getResourceLocale())))
+ warning("Could not load the texts of the game");
+ }
+ return _textContainer->getText(id);
+}
+
+const BitmapFont *NGIEngine::getFont(const Common::String &name) {
+ if (!_fonts.contains(name)) {
+ Common::SharedPtr<BitmapFont> font(new BitmapFont());
+ if (!font->load(Common::Path(Common::String("data/res_") + getResourceLocale()).join("Fonts").join(name)))
+ font.reset();
+ _fonts[name] = font;
+ }
+ return _fonts[name].get();
+}
+
class TextContainer::Loader : public Common::XMLParser {
public:
explicit Loader(Common::StringMap &strings) : _strings(strings) {}
@@ -280,50 +299,104 @@ float BitmapFont::lineWidth(const Common::String &line) const {
return width;
}
-void BitmapFont::drawCentered(Graphics::ManagedSurface &target, const Common::Rect &bounds, const Common::String &text) const {
+// CFont::DivideString: breaks at "%n" and at the last space before the line gets too wide
+Common::Array<Common::String> BitmapFont::divideString(const Common::String &text, float width) const {
Common::Array<Common::String> lines;
uint start = 0;
- float width = 0;
+ float lineSize = 0;
for (uint i = 0; i < text.size(); ++i) {
if (text[i] == '%' && i + 1 < text.size() && text[i + 1] == 'n') {
lines.push_back(text.substr(start, i - start));
++i;
start = i + 1;
- width = 0;
+ lineSize = 0;
continue;
}
- width += getCharAdvance((byte)text[i]);
- if (width >= bounds.width()) {
+ lineSize += getCharAdvance((byte)text[i]);
+ if (lineSize >= width) {
// DivideString breaks at a preceding space and resumes measuring after the next letter.
for (uint j = i; j > start; --j) {
if (text[j - 1] == ' ' && text[j] != 'n') {
lines.push_back(text.substr(start, j - 1 - start));
start = j;
i = j;
- width = 0;
+ lineSize = 0;
break;
}
}
}
}
lines.push_back(text.substr(start));
+ return lines;
+}
+
+// CFont::Print (one line): x left edge, top of the glyphs; spaceExtra widens spaces (justified)
+void BitmapFont::printLine(Graphics::ManagedSurface &target, const Common::String &line, float x, float top, float spaceExtra) const {
+ const int y = (int)roundf(top);
+ float pen = x;
+ for (uint i = 0; i < line.size(); i++) {
+ if (i)
+ pen += getKerningOffset((byte)line[i - 1], (byte)line[i]);
+ drawChar(&target, (byte)line[i], (int)roundf(pen), y, 0);
+ pen += getCharAdvance((byte)line[i]) + (line[i] == ' ' ? spaceExtra : 0);
+ }
+}
+
+void BitmapFont::printAligned(Graphics::ManagedSurface &target, const Common::String &line, float x, float y, int align, float width) const {
+ const float lineSize = lineWidth(line);
+ float spaceExtra = 0;
+ switch (align) {
+ case kAlignCenter:
+ x -= lineSize * 0.5f;
+ y -= lineHeight(line) * 0.5f;
+ break;
+ case kAlignRight:
+ x -= lineSize;
+ break;
+ case kAlignJustify: {
+ int spaces = 0;
+ for (uint i = 0; i < line.size(); i++)
+ spaces += line[i] == ' ';
+ if (spaces) {
+ // the spaces get wider, but not more than five times
+ const float space = getCharAdvance(' ');
+ const float wider = (width - lineSize) / spaces;
+ if (wider <= space * 4)
+ spaceExtra = wider;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ printLine(target, line, x, y, spaceExtra);
+}
+
+void BitmapFont::print(Graphics::ManagedSurface &target, const Common::String &text, float x, float y, float width, float height, int align, int verticalAlign) const {
+ const Common::Array<Common::String> lines = divideString(text, width);
+ if (align == kAlignRight)
+ x += width;
+ else if (align == kAlignCenter)
+ x += width * 0.5f;
+
float totalHeight = 0;
for (const Common::String &line : lines)
totalHeight += lineHeight(line);
- float y = bounds.top + (bounds.height() - totalHeight) * 0.5f;
+ if (verticalAlign == kVerticalCenter)
+ y += (height - totalHeight) * 0.5f;
+ else if (verticalAlign == kVerticalBottom)
+ y += height - totalHeight;
+
for (const Common::String &line : lines) {
- float pen = bounds.left + (bounds.width() - lineWidth(line)) * 0.5f;
- const int top = (int)roundf(y - lineHeight(line) * 0.5f);
- for (uint i = 0; i < line.size(); i++) {
- if (i)
- pen += getKerningOffset((byte)line[i - 1], (byte)line[i]);
- drawChar(&target, (byte)line[i], (int)roundf(pen), top, 0);
- pen += getCharAdvance((byte)line[i]);
- }
- y += (float)totalHeight / lines.size();
+ printAligned(target, line, x, y, align, width);
+ y += totalHeight / lines.size();
if (line == " ")
y += _extraLineSpacing;
}
}
+void BitmapFont::drawCentered(Graphics::ManagedSurface &target, const Common::Rect &bounds, const Common::String &text) const {
+ print(target, text, bounds.left, bounds.top, bounds.width(), bounds.height(), kAlignCenter, kVerticalCenter);
+}
+
} // End of namespace NGI
diff --git a/engines/ngi/font.h b/engines/ngi/font.h
index da644cce2cf..4d11459d40f 100644
--- a/engines/ngi/font.h
+++ b/engines/ngi/font.h
@@ -46,8 +46,16 @@ private:
class BitmapFont : public Graphics::Font {
public:
+ // The values of the original (CGuiText "align" and "vertical_align")
+ enum Align { kAlignLeft = 0, kAlignRight = 1, kAlignCenter = 2, kAlignJustify = 3 };
+ enum VerticalAlign { kVerticalCenter = 2, kVerticalTop = 4, kVerticalBottom = 5 };
+
bool load(const Common::Path &path);
void drawCentered(Graphics::ManagedSurface &target, const Common::Rect &bounds, const Common::String &text) const;
+ /** CFont::Print with the vertical alignment */
+ void print(Graphics::ManagedSurface &target, const Common::String &text, float x, float y, float width, float height, int align, int verticalAlign) const;
+ /** CFont::PrintAligned: one line, x is its left, right or center */
+ void printAligned(Graphics::ManagedSurface &target, const Common::String &line, float x, float y, int align, float width) const;
int getFontHeight() const override { return _lineHeight; }
int getMaxCharWidth() const override { return _maxWidth; }
@@ -70,6 +78,8 @@ private:
const Glyph &glyph(uint32 chr) const;
float lineHeight(const Common::String &line) const;
float lineWidth(const Common::String &line) const;
+ Common::Array<Common::String> divideString(const Common::String &text, float width) const;
+ void printLine(Graphics::ManagedSurface &target, const Common::String &line, float x, float top, float spaceExtra) const;
Common::HashMap<int, Glyph> _glyphs;
Common::HashMap<int, int> _kerning;
Common::Array<Common::SharedPtr<Texture>> _pages;
diff --git a/engines/ngi/guimanager.cpp b/engines/ngi/guimanager.cpp
index 31c850f370d..6ea2faea078 100644
--- a/engines/ngi/guimanager.cpp
+++ b/engines/ngi/guimanager.cpp
@@ -20,6 +20,7 @@
*/
#include "ngi/guimanager.h"
+#include "ngi/font.h"
#include "ngi/ngi.h"
#include "ngi/scene.h"
@@ -154,7 +155,7 @@ public:
bool onMouseLKeyDown(Common::Point pos) override;
bool onMouseLKeyUp(Common::Point pos) override;
-private:
+protected:
enum State { kDisabled, kPressed, kSelected, kNumStates };
int _pictureIds[kNumStates];
PictureObject *_pictures[kNumStates] = {};
@@ -218,6 +219,96 @@ void GuiButton::render(Graphics::ManagedSurface &target) const {
_picture->_picture->blitTo(target, screenPos());
}
+static int guiAlign(const Common::String &name, int fallback) {
+ if (name == "LEFT")
+ return BitmapFont::kAlignLeft;
+ if (name == "RIGHT")
+ return BitmapFont::kAlignRight;
+ if (name == "CENTER")
+ return BitmapFont::kAlignCenter;
+ if (name == "JUSTIFY")
+ return BitmapFont::kAlignJustify;
+ return fallback;
+}
+
+static void guiWarnColor(const Common::StringMap &attrs, const Common::String &id) {
+ if (attrs.contains("color") || attrs.contains("color_r"))
+ warning("STUB/untested: the text colour of the GUI element %s is not used (the fonts are drawn as they are)", id.c_str());
+}
+
+GuiText::GuiText(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids) :
+ GuiElement(scene, attrs, ids) {
+ _font = g_ngi->getFont(attrs.getValOrDefault("font", "dlg.xml"));
+ _text = g_ngi->getText(attrs.getValOrDefault("text"));
+ _width = atof(attrs.getValOrDefault("w").c_str());
+ _height = atof(attrs.getValOrDefault("h").c_str());
+ _separate = guiFlag(attrs, "separate", false);
+ _align = guiAlign(attrs.getValOrDefault("align", "LEFT"), BitmapFont::kAlignLeft);
+ const Common::String vertical = attrs.getValOrDefault("vertical_align", "TOP");
+ _verticalAlign = vertical == "CENTER" ? BitmapFont::kVerticalCenter : vertical == "BOTTOM" ? BitmapFont::kVerticalBottom : BitmapFont::kVerticalTop;
+ guiWarnColor(attrs, _id);
+}
+
+void GuiText::setText(const Common::String &id) {
+ // CTextContainer::GetText returns the id itself when it is not a game text
+ _text = g_ngi->getText(id);
+ if (_text.empty())
+ _text = id;
+}
+
+void GuiText::render(Graphics::ManagedSurface &target) const {
+ if (!_visible || !_font)
+ return;
+ const Common::Point pos = screenPos();
+ if (_separate)
+ _font->print(target, _text, pos.x, pos.y, _width, _height, _align, _verticalAlign);
+ else
+ _font->printAligned(target, _text, pos.x, pos.y, _align, _width);
+}
+
+// CGuiTextButton: up to ten lines of text (text0..text9), centered by default
+class GuiTextButton : public GuiButton {
+public:
+ GuiTextButton(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids);
+ void render(Graphics::ManagedSurface &target) const override;
+
+private:
+ struct Line {
+ Common::String text;
+ int y;
+ };
+ Common::Array<Line> _lines;
+ const BitmapFont *_font;
+ int _align;
+};
+
+GuiTextButton::GuiTextButton(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids) :
+ GuiButton(scene, attrs, ids) {
+ for (char digit = '0'; digit <= '9'; ++digit) {
+ const Common::String key = Common::String("text") + digit;
+ if (!attrs.contains(key))
+ continue;
+ Line line;
+ line.text = g_ngi->getText(attrs.getValOrDefault(key));
+ line.y = atoi(attrs.getValOrDefault(Common::String("txt") + digit + "_y", "-1").c_str());
+ _lines.push_back(line);
+ }
+ _font = g_ngi->getFont(attrs.getValOrDefault("font", "dbg.xml"));
+ _align = guiAlign(attrs.getValOrDefault("align", "CENTER"), BitmapFont::kAlignCenter);
+ guiWarnColor(attrs, _id);
+}
+
+void GuiTextButton::render(Graphics::ManagedSurface &target) const {
+ GuiButton::render(target);
+ if (!_visible || !_font)
+ return;
+ const Common::Point pos = screenPos();
+ for (uint i = 0; i < _lines.size(); ++i) {
+ const float y = _lines[i].y == -1 ? (float)((i + 1) * _size.y) / (_lines.size() + 1) : _lines[i].y;
+ _font->printAligned(target, _lines[i].text, pos.x + _size.x * 0.5f, pos.y + y, _align, 0);
+ }
+}
+
bool GuiButton::hit(Common::Point pos) const {
pos -= screenPos();
return _visible && pos.x > 0 && pos.y > 0 && pos.x < _size.x && pos.y < _size.y;
@@ -271,8 +362,11 @@ void GuiManager::createElement(const Common::String &type, const Common::StringM
addGuiElement(new GuiPicture(_scene, attrs, ids));
else if (type == "PROGRESSBAR")
addGuiElement(new GuiProgressBar(_scene, attrs, ids));
- else if (type == "TEXT" || type == "TEXTBUTTON" || type == "SLIDER" ||
- type == "CHECKBOX") {
+ else if (type == "TEXT")
+ addGuiElement(new GuiText(_scene, attrs, ids));
+ else if (type == "TEXTBUTTON")
+ addGuiElement(new GuiTextButton(_scene, attrs, ids));
+ else if (type == "SLIDER" || type == "CHECKBOX") {
warning("STUB: %s", type.c_str());
addGuiElement(new GuiElementStub(_scene, attrs, ids));
} else
diff --git a/engines/ngi/guimanager.h b/engines/ngi/guimanager.h
index d2639d8ce18..82dddfbe833 100644
--- a/engines/ngi/guimanager.h
+++ b/engines/ngi/guimanager.h
@@ -92,6 +92,26 @@ private:
bool _lowBegin;
};
+class BitmapFont;
+
+// CGuiText: a line (aligned to x) or, with "separate", text wrapped into the box w x h
+class GuiText : public GuiElement {
+public:
+ GuiText(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids);
+ void render(Graphics::ManagedSurface &target) const override;
+ /** CGuiText::SetText: the id of a text of the game, or a string that is shown as it is */
+ void setText(const Common::String &id);
+
+private:
+ Common::String _text;
+ const BitmapFont *_font;
+ float _width;
+ float _height;
+ int _align;
+ int _verticalAlign;
+ bool _separate;
+};
+
class GuiManager {
public:
explicit GuiManager(Scene &scene) : _scene(scene) {}
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 5fcda9aa126..dd7d52da999 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -87,6 +87,8 @@ class Command;
class FlyPack;
class TaskManager;
class Tremble;
+class BitmapFont;
+class TextContainer;
class ChapterManager;
class Notebook;
class GameProject;
@@ -173,6 +175,10 @@ public:
bool isDemo();
Common::Language getLanguage() const;
const char *getResourceLocale() const;
+ /** CTextContainer::GetText: the string of the game language (empty when there is none) */
+ Common::String getText(const Common::String &id);
+ /** CFontController::GetFont: the font file of res_<locale>/Fonts, loaded once; null on failure */
+ const BitmapFont *getFont(const Common::String &name);
Common::Platform getPlatform() const;
const char *getGameId() const;
int getGameGID() const;
@@ -419,6 +425,9 @@ public:
GameObjHMap _gameObjH;
+ Common::SharedPtr<TextContainer> _textContainer;
+ Common::HashMap<Common::String, Common::SharedPtr<BitmapFont> > _fonts;
+
public:
bool _isSaveAllowed;
Commit: 6151f5100e472d322aaf73cc3f5fb841b02e78e9
https://github.com/scummvm/scummvm/commit/6151f5100e472d322aaf73cc3f5fb841b02e78e9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Show the notebook bonus texts through the GUI elements
Changed paths:
engines/ngi/fullpipe/notebook.cpp
engines/ngi/fullpipe/notebook.h
engines/ngi/fullpipe/sceneNotebook.cpp
diff --git a/engines/ngi/fullpipe/notebook.cpp b/engines/ngi/fullpipe/notebook.cpp
index 62a59594404..849909625e7 100644
--- a/engines/ngi/fullpipe/notebook.cpp
+++ b/engines/ngi/fullpipe/notebook.cpp
@@ -171,6 +171,21 @@ void Notebook::setElementVisible(const char *id, bool visible) {
}
}
+// TEXT_BONUS and TEXT_BONUS_COUNT of the notebook scene; the count is the bonuses left
+void Notebook::setBonusesVisible(bool visible) {
+ setElementVisible("TEXT_BONUS", visible);
+ setElementVisible("TEXT_BONUS_COUNT", visible);
+ if (visible)
+ updateBonusCount();
+}
+
+void Notebook::updateBonusCount() {
+ if (!_scene || !_scene->_guiManager)
+ return;
+ if (GuiText *count = static_cast<GuiText *>(_scene->_guiManager->getElement("TEXT_BONUS_COUNT")))
+ count->setText(Common::String::format("%d", g_ngi->_taskManager->getBonuses()));
+}
+
Task *Notebook::currentTask() const {
return _current >= 0 && _current < (int)_tasks.size() ? _tasks[_current] : nullptr;
}
@@ -359,8 +374,9 @@ void Notebook::showHint(int index) {
play(kSndHintShown);
if (tasks.getBonuses() > 0) {
unblockNextHint();
+ updateBonusCount();
} else {
- _bonusVisible = false;
+ setBonusesVisible(false);
tasks.startTimer();
blockHints();
showGiveButtonHint(isTimerShowing());
@@ -396,12 +412,12 @@ void Notebook::updateBookMarks() {
const Task *task = currentTask();
if (!_tasks.empty() && _page == kPageTask && _current != -1) {
const bool showBonuses = g_ngi->_taskManager->getBonuses() > 0 && task && task->_state <= Task::kStateSeen && sceneTutorial_isCompleted();
- _bonusVisible = showBonuses;
+ setBonusesVisible(showBonuses);
setElementVisible("BTN_TASK_PREV", true);
setElementVisible("BTN_TASK_NEXT", true);
} else {
setElementVisible("GIVE_HINT", false);
- _bonusVisible = false;
+ setBonusesVisible(false);
const bool paged = _page == kPageCatalog; // the pages of the catalog (CCatalogManager is not ported)
setElementVisible("BTN_TASK_PREV", paged);
setElementVisible("BTN_TASK_NEXT", paged);
diff --git a/engines/ngi/fullpipe/notebook.h b/engines/ngi/fullpipe/notebook.h
index 6c4142341f0..f6e28c72f79 100644
--- a/engines/ngi/fullpipe/notebook.h
+++ b/engines/ngi/fullpipe/notebook.h
@@ -55,8 +55,10 @@ public:
// CFoil::NextPoint(uint): the zigzag; false when nothing is left
bool nextPoint(uint32 elapsed);
- int _x, _y;
- int _columns, _rows;
+ int _x;
+ int _y;
+ int _columns;
+ int _rows;
Common::Rect _area;
Common::Array<bool> _covered;
Common::Array<int> _angles; // degrees
@@ -129,7 +131,6 @@ public:
int _pulseStep = 0; // flashing of the first hint in steps of a second
int _blinkTimer = -1; // flashing of the timer (CNotebookController +100)
int _blinkStep = 0;
- bool _bonusVisible = false; // the hint bonuses are shown (TEXT_BONUS, TEXT_BONUS_COUNT)
Common::Array<Common::Rect> _bookmarks; // hit areas of the bookmarks (60, 117 + 45 * i)
private:
@@ -145,6 +146,8 @@ private:
void clearHints();
void removeFoil(uint32 elapsed);
void setElementVisible(const char *id, bool visible);
+ void setBonusesVisible(bool visible);
+ void updateBonusCount();
void setBonusVisible(bool visible);
void play(int soundId);
};
diff --git a/engines/ngi/fullpipe/sceneNotebook.cpp b/engines/ngi/fullpipe/sceneNotebook.cpp
index 2a461096582..ab85d633d33 100644
--- a/engines/ngi/fullpipe/sceneNotebook.cpp
+++ b/engines/ngi/fullpipe/sceneNotebook.cpp
@@ -230,11 +230,6 @@ private:
plainText(_texts.getText(task->getHintText(notebook._foilHints[i]))));
}
}
-
- if (notebook._bonusVisible) {
- text(_font, Common::Rect(460, 505, 660, 535), _texts.getText("STR_BONUSES"));
- text(_headingFont, Common::Rect(660, 505, 720, 535), Common::String::format("%d", g_ngi->_taskManager->getBonuses()));
- }
}
// CNotebookController::OnRenderTopMenuTask and CFoil::Render
Commit: 1fccd3f25915f40aaf59dd36ac72826b7073c208
https://github.com/scummvm/scummvm/commit/1fccd3f25915f40aaf59dd36ac72826b7073c208
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Show the inventory buttons in every scene of the Android game
Changed paths:
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/scene01.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/fullpipe/scenes.h
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 945f6739641..fee4709966d 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -33,11 +33,39 @@
#include "ngi/gfx.h"
#include "ngi/statics.h"
#include "ngi/scene.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/guimanager.h"
+#include "ngi/inventory.h"
#include "ngi/fullpipe/tremble.h"
namespace NGI {
+static void inventory_onGuiEvent(Scene &inventory, const Common::String &id, const Common::String &event) {
+ if (event != "unpress")
+ return;
+ if (id == "BTN_SKIP") {
+ GameVar *root = g_ngi->getGameLoaderGameVar();
+ root->setSubVarAsInt("TutorialDisabled", 1);
+ root->setSubVarAsInt("Scene1ExitsDisabled", 0);
+ g_ngi->_currentScene->setExitState(0, 1);
+ inventory._guiManager->getElement(id)->hideAndDeactivate();
+ } else if (id == "PIC_INV_TASK") {
+ sceneNotebook_show();
+ } else {
+ warning("STUB: Inventory::onGuiEvent(%s, %s)", id.c_str(), event.c_str());
+ }
+}
+
+// CInventoryController, inventory.xml
+void sceneController_initInventory() {
+ g_ngi->_inventoryScene = g_ngi->findScene(SC_INV);
+ if (g_ngi->_inventoryScene) {
+ g_ngi->_inventoryScene->_guiEventHandler = inventory_onGuiEvent;
+ getGameLoaderInventory()->recalcItemPos();
+ }
+}
+
// The Android scene controllers (CFPController, the base class of all CScNNController) execute the USER commands
// of the message queues: CMessageQueue::ExecuteUserCmd picks the scene (parameter "sc", else the scene of the
// queue) and calls its controller, CFPController::ExecuteUserCmd dispatches on the "type" parameter. SET_LOGIC and
diff --git a/engines/ngi/fullpipe/scene01.cpp b/engines/ngi/fullpipe/scene01.cpp
index c693581738e..dbb5022acfc 100644
--- a/engines/ngi/fullpipe/scene01.cpp
+++ b/engines/ngi/fullpipe/scene01.cpp
@@ -67,30 +67,9 @@ void scene01_initObjects(Scene *sc, int entrance, bool eggUncracked) {
}
}
-static void scene01_onGuiEvent(Scene &inventory, const Common::String &id, const Common::String &event) {
- if (event != "unpress")
- return;
- if (id == "BTN_SKIP") {
- GameVar *root = g_ngi->getGameLoaderGameVar();
- root->setSubVarAsInt("TutorialDisabled", 1);
- root->setSubVarAsInt("Scene1ExitsDisabled", 0);
- g_ngi->_currentScene->setExitState(0, 1);
- inventory._guiManager->getElement(id)->hideAndDeactivate();
- } else if (id == "PIC_INV_TASK") {
- sceneNotebook_show();
- } else {
- warning("STUB: Inventory::onGuiEvent(%s, %s)", id.c_str(), event.c_str());
- }
-}
-
void scene01_initScene(Scene *sc, int entrance) {
scene01_initObjects(sc, entrance, g_ngi->getStateId(sO_EggCracker) == g_ngi->getStateValue(sO_EggCracker, sO_DidNotCrackEgg));
if (g_ngi->isAndroidFullPipe()) {
- g_ngi->_inventoryScene = g_ngi->findScene(SC_INV);
- if (g_ngi->_inventoryScene) {
- g_ngi->_inventoryScene->_guiEventHandler = scene01_onGuiEvent;
- getGameLoaderInventory()->recalcItemPos();
- }
uint32 buttonId;
if (g_ngi->_gameProject->_objectIds.findId("ST_LBN_2N", buttonId))
g_ngi->lift_setButton(sO_Level2, buttonId);
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index 64fd32638b9..d728cb9d9cf 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -733,6 +733,8 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
sceneIntro_initMan(*scene);
addMessageHandler(sceneHandlerIntro, 2);
} else {
+ if (isAndroidFullPipe())
+ sceneController_initInventory();
if (!initSceneLogic(scene, entrance._id))
debugC(1, kDebugLoading, "Scene %d has no scene logic yet", scene->_sceneId);
// Every scene controller of the original ends its OnShow with CTaskManager::VisitScene
diff --git a/engines/ngi/fullpipe/scenes.h b/engines/ngi/fullpipe/scenes.h
index 628d660e960..5f514e587ee 100644
--- a/engines/ngi/fullpipe/scenes.h
+++ b/engines/ngi/fullpipe/scenes.h
@@ -56,6 +56,7 @@ void sceneTutorial_check();
class BaseModalObject;
BaseModalObject *sceneNotebook_create();
void sceneNotebook_show();
+void sceneController_initInventory();
bool sceneTutorial_isCompleted();
class Chapter;
void sceneChapter_show(Chapter &chapter, bool isStart);
Commit: 5006e9ebff1486fe61e3d6d7b1d5c62a2a23c83b
https://github.com/scummvm/scummvm/commit/5006e9ebff1486fe61e3d6d7b1d5c62a2a23c83b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Add the arcade interface of the Android game
Changed paths:
A engines/ngi/fullpipe/arcadeinterface.cpp
A engines/ngi/fullpipe/arcadeinterface.h
engines/ngi/fullpipe/scene04.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/guimanager.h
engines/ngi/inventory.cpp
engines/ngi/inventory.h
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
diff --git a/engines/ngi/fullpipe/arcadeinterface.cpp b/engines/ngi/fullpipe/arcadeinterface.cpp
new file mode 100644
index 00000000000..b8766f06ea2
--- /dev/null
+++ b/engines/ngi/fullpipe/arcadeinterface.cpp
@@ -0,0 +1,281 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+#include "common/formats/xmlparser.h"
+
+#include "ngi/ngi.h"
+#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/guimanager.h"
+#include "ngi/inventory.h"
+#include "ngi/objects.h"
+#include "ngi/scene.h"
+#include "ngi/sound.h"
+#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/constants.h"
+
+namespace NGI {
+
+namespace {
+
+const int kPicPassive = 23154; // PIC_ARC_PASSIVE
+const int kPicActive = 23155; // PIC_ARC_ACTIVE
+const int kSoundSkipBlink = 23542; // SND_CMN_084
+const int kBlinkTime = 1250; // the highlight of the skip button blinks for this long
+const int kBlinkPeriod = 250;
+const float kScrollSpeed = 0.1f; // pixels per millisecond
+const float kScrollDistance = 100.0f;
+
+// skip.xml: <ARCADE id="SC_4" counter="60"/> the seconds of an arcade until it can be skipped
+class SkipParser : public Common::XMLParser {
+public:
+ explicit SkipParser(Common::HashMap<int, float> &limits) : _limits(limits) {}
+
+private:
+ Common::HashMap<int, float> &_limits;
+
+ CUSTOM_XML_PARSER(SkipParser) {
+ XML_KEY(ARCADES)
+ XML_KEY(ARCADE)
+ XML_PROP(id, true)
+ XML_PROP(counter, false)
+ KEY_END()
+ KEY_END()
+ } PARSER_END()
+
+ bool parserCallback_ARCADES(ParserNode *) { return true; }
+
+ bool parserCallback_ARCADE(ParserNode *node) {
+ uint32 id;
+ if (!g_ngi->_gameProject->_objectIds.findId(node->values["id"], id))
+ return true;
+ _limits[static_cast<int16>(id)] = atof(node->values.getValOrDefault("counter", "120").c_str()) * 1000.0f;
+ return true;
+ }
+};
+
+} // End of anonymous namespace
+
+// CArcadeInterface::CArcadeInterface
+ArcadeInterface::ArcadeInterface() {
+ uint32 commonId;
+ if (g_ngi->_gameProject->_objectIds.findId("SC_COMMON", commonId)) {
+ if (Scene *common = g_ngi->findScene(static_cast<int16>(commonId))) {
+ _passive = common->findPictureObjectById(kPicPassive, 0);
+ _full = common->findPictureObjectById(kPicActive, 0);
+ }
+ }
+
+ // the elements of the inventory scene
+ _skipButton = getElement("BTN_SKIP_ARCADE");
+ _skipProgress = static_cast<GuiProgressBar *>(getElement("PRG_SKIP_ARCADE"));
+ _skipBackground = getElement("BGR_SKIP_ARCADE");
+ _skipHighlight = getElement("HLT_SKIP_ARCADE");
+
+ loadLimits();
+}
+
+GuiElement *ArcadeInterface::getElement(const char *id) const {
+ Scene *scene = getGameLoaderInventory() ? getGameLoaderInventory()->getScene() : nullptr;
+ return scene && scene->_guiManager ? scene->_guiManager->getElement(id) : nullptr;
+}
+
+void ArcadeInterface::loadLimits() {
+ SkipParser parser(_limits);
+ if (!parser.loadFile("data/skip.xml") || !parser.parse())
+ warning("Could not read skip.xml");
+}
+
+// CArcadeInterface::Init. The original moves the icons by the black bars of the screen when they are close to the edge, there are none here.
+void ArcadeInterface::init(float x, float y, float stepX, float stepY, int total, int active, bool vertical) {
+ _x = x;
+ _y = y;
+ _stepX = stepX;
+ _stepY = stepY;
+ _total = total;
+ _active = active;
+ _speedX = vertical ? 0.0f : kScrollSpeed;
+ _speedY = vertical ? kScrollSpeed : 0.0f;
+}
+
+void ArcadeInterface::render(Common::Point scroll) {
+ if (_state == kHidden)
+ return;
+
+ for (int i = 0; i < _total; i++) {
+ PictureObject *icon = i < _active ? _full : _passive;
+ if (!icon || !icon->_picture)
+ continue;
+ const float x = (_x - _offsetX) - scroll.x + i * _stepX;
+ const float y = (_y - _offsetY) - scroll.y + i * _stepY;
+ icon->_picture->blitTo(g_ngi->_backgroundSurface, Common::Point((int)x, (int)y));
+ }
+}
+
+void ArcadeInterface::incCounter() {
+ if (_active < _total)
+ _active++;
+}
+
+void ArcadeInterface::decCounter() {
+ if (_active)
+ _active--;
+}
+
+void ArcadeInterface::update(uint32 elapsed) {
+ if (_arcadeSceneId) {
+ float &progress = _progress[_arcadeSceneId];
+ const float limit = _limits[_arcadeSceneId];
+ if (progress >= 0) {
+ if (limit > progress) {
+ progress += elapsed;
+ if (limit > progress) {
+ if (_skipProgress)
+ _skipProgress->setFraction(progress / limit);
+ _blinkTime = 0;
+ } else {
+ // the time is up: the skip button works
+ if (_skipProgress)
+ _skipProgress->hide();
+ if (_skipButton)
+ _skipButton->activate();
+ }
+ } else if (_blinkTime < kBlinkTime) {
+ _blinkTime += elapsed;
+ if ((_blinkTime / kBlinkPeriod) & 1) {
+ if (_skipHighlight)
+ _skipHighlight->hide();
+ } else {
+ if (_skipHighlight)
+ _skipHighlight->show();
+ const Sound *sound = g_ngi->findSound(kSoundSkipBlink);
+ if (sound && !sound->isPlaying())
+ g_ngi->playSound(kSoundSkipBlink, 0);
+ }
+ }
+ }
+ }
+
+ if (_state == kShown || _state == kHidden)
+ return;
+
+ if (_state == kScrollingIn) {
+ _offsetX -= elapsed * _speedX;
+ _offsetY -= elapsed * _speedY;
+ if (ABS(_offsetX) > kScrollDistance || ABS(_offsetY) > kScrollDistance) {
+ _offsetX = _offsetX != 0 ? -kScrollDistance : 0;
+ _offsetY = _offsetY != 0 ? -kScrollDistance : 0;
+ _state = kShown;
+ }
+ } else {
+ _offsetX += elapsed * _speedX;
+ _offsetY += elapsed * _speedY;
+ if (_offsetX > 0 || _offsetY > 0) {
+ _offsetX = 0;
+ _offsetY = 0;
+ _state = kHidden;
+ }
+ }
+}
+
+void ArcadeInterface::scrollIn() {
+ if (_state != kShown) {
+ _state = kScrollingIn;
+ getGameLoaderInventory()->scrollOut();
+ }
+
+ _arcadeSceneId = g_ngi->_currentScene->_sceneId;
+ if (!_progress.contains(_arcadeSceneId))
+ _progress[_arcadeSceneId] = 0;
+
+ const bool timeIsUp = _limits[_arcadeSceneId] <= _progress[_arcadeSceneId];
+ if (timeIsUp) {
+ if (_skipButton)
+ _skipButton->activate();
+ if (_skipProgress)
+ _skipProgress->hide();
+ } else {
+ if (_skipButton)
+ _skipButton->deactivate();
+ if (_skipProgress)
+ _skipProgress->show();
+ }
+
+ const float x = _arcadeSceneId == SC_8 ? 73.0f : 13.0f;
+ GuiElement *positioned[] = { _skipButton, _skipProgress, _skipHighlight };
+ for (GuiElement *element : positioned) {
+ if (element)
+ element->setPos(Common::Point((int)x, 11));
+ }
+ if (_skipBackground)
+ _skipBackground->setPos(Common::Point((int)(x - 13.0f), 0));
+
+ if (_skipButton)
+ _skipButton->show();
+ if (_skipBackground)
+ _skipBackground->show();
+ if (_skipHighlight)
+ _skipHighlight->hide();
+}
+
+void ArcadeInterface::scrollOut() {
+ if (_state != kHidden) {
+ _state = kScrollingOut;
+ getGameLoaderInventory()->scrollIn();
+ GuiElement *hidden[] = { _skipButton, _skipProgress, _skipBackground, _skipHighlight };
+ for (GuiElement *element : hidden) {
+ if (element)
+ element->hide();
+ }
+ }
+ _arcadeSceneId = 0;
+}
+
+// CArcadeInterface::GetXmlData and SetXmlData: <ARCADES><ARCADE id counter/></ARCADES>
+void ArcadeInterface::syncProgress(Common::Serializer &s) {
+ uint32 count = _progress.size();
+ s.syncAsUint32LE(count);
+ if (s.isSaving()) {
+ for (const auto &entry : _progress) {
+ int id = entry._key;
+ float time = entry._value;
+ s.syncAsSint32LE(id);
+ s.syncAsFloatLE(time);
+ }
+ } else {
+ _progress.clear();
+ for (uint32 i = 0; i < count; i++) {
+ int id = 0;
+ float time = 0;
+ s.syncAsSint32LE(id);
+ s.syncAsFloatLE(time);
+ _progress[id] = time;
+ }
+ }
+}
+
+void ArcadeInterface::cleanProgress() {
+ _progress.clear();
+ _arcadeSceneId = 0;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/arcadeinterface.h b/engines/ngi/fullpipe/arcadeinterface.h
new file mode 100644
index 00000000000..349721c0c28
--- /dev/null
+++ b/engines/ngi/fullpipe/arcadeinterface.h
@@ -0,0 +1,93 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+#ifndef NGI_ARCADEINTERFACE_H
+#define NGI_ARCADEINTERFACE_H
+
+#include "common/hashmap.h"
+#include "common/rect.h"
+#include "common/serializer.h"
+
+namespace NGI {
+
+class GuiElement;
+class GuiProgressBar;
+class PictureObject;
+
+/** CArcadeInterface: the row of icons (lives, hits, balls) and the skip button of an arcade */
+class ArcadeInterface {
+public:
+ enum State { kScrollingIn, kShown, kScrollingOut, kHidden };
+
+ ArcadeInterface();
+
+ /** x, y: the first icon, step: to the next; `active` of `total` icons are full */
+ void init(float x, float y, float stepX, float stepY, int total, int active, bool vertical);
+ void render(Common::Point scroll = Common::Point());
+ void update(uint32 elapsed);
+ void scrollIn();
+ void scrollOut();
+
+ void incCounter();
+ void decCounter();
+ void setCounter(int active) { _active = active; }
+ int getCounter() const { return _active; }
+ State getState() const { return _state; }
+
+ /** CArcadeInterface::GetXmlData / SetXmlData (arcades.sav), not hooked into the savegames yet */
+ void syncProgress(Common::Serializer &s);
+ /** CArcadeInterface::CleanXml */
+ void cleanProgress();
+
+private:
+ typedef Common::HashMap<int, float> TimeMap;
+
+ GuiElement *getElement(const char *id) const;
+ void loadLimits();
+
+ float _x = 0;
+ float _y = 0;
+ float _stepX = 0;
+ float _stepY = 0;
+ float _offsetX = 0;
+ float _offsetY = 0;
+ float _speedX = 0;
+ float _speedY = 0;
+ State _state = kHidden;
+ int _total = 0;
+ int _active = 0;
+ PictureObject *_passive = nullptr;
+ PictureObject *_full = nullptr;
+
+ GuiElement *_skipButton = nullptr;
+ GuiProgressBar *_skipProgress = nullptr;
+ GuiElement *_skipHighlight = nullptr;
+ GuiElement *_skipBackground = nullptr;
+ int _blinkTime = 0;
+ int _arcadeSceneId = 0; // the scene of the arcade that is shown, 0: none
+ TimeMap _progress; // the milliseconds spent in an arcade (by the id of its scene)
+ TimeMap _limits; // the milliseconds until it can be skipped
+};
+
+} // End of namespace NGI
+
+#endif
diff --git a/engines/ngi/fullpipe/scene04.cpp b/engines/ngi/fullpipe/scene04.cpp
index 9230d1a25d0..184a31c1bc0 100644
--- a/engines/ngi/fullpipe/scene04.cpp
+++ b/engines/ngi/fullpipe/scene04.cpp
@@ -21,6 +21,7 @@
#include "ngi/ngi.h"
+#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/utils.h"
@@ -46,6 +47,7 @@ static const int scene04_speakerPhases[] = {
void sceneHandler04_putKozyawkaBack(AniObject *ani);
static bool scene04_click(Common::Point pos);
+static void scene04_render(Scene &scene);
void scene04_speakerCallback(int *phase) {
if (g_vars->scene04_soundPlaying) {
@@ -222,8 +224,15 @@ void scene04_initScene(Scene *sc) {
g_ngi->initArcadeKeys("SC_4");
- if (g_ngi->isAndroidFullPipe())
+ if (g_ngi->isAndroidFullPipe()) {
sc->_clickHook = scene04_click;
+ sc->_renderHook = scene04_render;
+ }
+}
+
+// CSc04Controller::OnRender: the arcade interface over the scene
+static void scene04_render(Scene &scene) {
+ g_ngi->arcadeInterface().render();
}
bool sceneHandler04_friesAreWalking() {
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index d728cb9d9cf..b11206b1db3 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -28,6 +28,7 @@
#include "ngi/motion.h"
#include "ngi/input.h"
#include "ngi/behavior.h"
+#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/floaters.h"
#include "ngi/fullpipe/taskmanager.h"
@@ -612,6 +613,9 @@ void NGIEngine::updateSceneLogic(uint32 elapsed) {
}
if (_taskManager)
_taskManager->onUpdate(elapsed);
+ // CInventoryController::OnUpdate runs the arcade interface
+ if (_arcadeInterface)
+ _arcadeInterface->update(elapsed);
if (_currentScene && _currentScene->_sceneId != SC_INTRO1)
sceneCamera_update(*_currentScene, elapsed);
diff --git a/engines/ngi/guimanager.h b/engines/ngi/guimanager.h
index 82dddfbe833..f1d2e394a89 100644
--- a/engines/ngi/guimanager.h
+++ b/engines/ngi/guimanager.h
@@ -58,6 +58,10 @@ public:
virtual void activate() { _active = true; }
void showAndActivate() { _visible = true; activate(); }
void hideAndDeactivate() { _visible = _active = _selected = false; }
+ // CGuiElement::Deactivate, Show and Hide (the flags separately)
+ void deactivate() { _active = _selected = false; }
+ void show() { _visible = true; }
+ void hide() { _visible = _selected = false; }
void setPos(Common::Point pos) { _pos = pos; }
Common::String _id;
diff --git a/engines/ngi/inventory.cpp b/engines/ngi/inventory.cpp
index a59c6741d17..78ec7dab0cd 100644
--- a/engines/ngi/inventory.cpp
+++ b/engines/ngi/inventory.cpp
@@ -422,6 +422,15 @@ void Inventory::slideOut() {
ex->postMessage();
}
+// CInventoryController::ScrollOut and ScrollIn: its state machine moves the bar (1.5 pixels per millisecond, up to 100) and the items
+void Inventory::scrollOut() {
+ warning("STUB/untested: CInventoryController::ScrollOut: the inventory bar does not leave the screen");
+}
+
+void Inventory::scrollIn() {
+ warning("STUB/untested: CInventoryController::ScrollIn: the inventory bar does not come back");
+}
+
bool Inventory::onMouseLKeyDown(Command *cmd) {
if (!_isInventoryOut)
return false;
diff --git a/engines/ngi/inventory.h b/engines/ngi/inventory.h
index 805cb5bf254..5f26e996cf5 100644
--- a/engines/ngi/inventory.h
+++ b/engines/ngi/inventory.h
@@ -123,6 +123,9 @@ class Inventory : public InventoryData {
int getItemAtPos(Common::Point *point);
void slideIn();
void slideOut();
+ /** CInventoryController::ScrollOut / ScrollIn (Android): the bar leaves the screen for an arcade and comes back */
+ void scrollOut();
+ void scrollIn();
bool onMouseLKeyDown(Command *cmd);
int putOnCursor(int itemId);
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index e286997433d..ae90d2d05c3 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -75,6 +75,7 @@ MODULE_OBJS = \
box2d/Dynamics/b2WorldCallbacks.o \
box2d/Rope/b2Rope.o \
fullpipe/achievements.o \
+ fullpipe/arcadeinterface.o \
fullpipe/chaptermanager.o \
fullpipe/floaters.o \
fullpipe/fpcontroller.o \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 95dfdd8b3b7..8f8058b0ef5 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -32,6 +32,7 @@
#include "graphics/surface.h"
#include "ngi/ngi.h"
+#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/taskmanager.h"
@@ -619,9 +620,16 @@ bool NGIEngine::updateEvents() {
return redraw;
}
+ArcadeInterface &NGIEngine::arcadeInterface() {
+ if (!_arcadeInterface)
+ _arcadeInterface.reset(new ArcadeInterface());
+ return *_arcadeInterface;
+}
+
void NGIEngine::freeGameLoader() {
// the effects of the tremble items belong to the scenes that are destroyed with the loader
_tremble.reset();
+ _arcadeInterface.reset();
setCursor(0);
_floaters->deleteAllFlies();
_gameLoader.reset();
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index dd7d52da999..facdd80023e 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -87,6 +87,7 @@ class Command;
class FlyPack;
class TaskManager;
class Tremble;
+class ArcadeInterface;
class BitmapFont;
class TextContainer;
class ChapterManager;
@@ -175,6 +176,8 @@ public:
bool isDemo();
Common::Language getLanguage() const;
const char *getResourceLocale() const;
+ /** CSingleton<CArcadeInterface>::GetInst: created when first needed */
+ ArcadeInterface &arcadeInterface();
/** CTextContainer::GetText: the string of the game language (empty when there is none) */
Common::String getText(const Common::String &id);
/** CFontController::GetFont: the font file of res_<locale>/Fonts, loaded once; null on failure */
@@ -290,6 +293,7 @@ public:
// 2015 revision (CSingleton<CTaskManager>, CSingleton<CChapterManager>); null in older builds
Common::ScopedPtr<TaskManager> _taskManager;
Common::ScopedPtr<Tremble> _tremble;
+ Common::ScopedPtr<ArcadeInterface> _arcadeInterface;
Common::ScopedPtr<ChapterManager> _chapterManager;
Common::ScopedPtr<Notebook> _notebook;
Common::ScopedPtr<AniHandler> _aniHandler;
Commit: ce66494847fe9d47eb3245d078c3cdf5251e76d4
https://github.com/scummvm/scummvm/commit/ce66494847fe9d47eb3245d078c3cdf5251e76d4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Port the arcade of scene 4 of the Android game
Changed paths:
engines/ngi/behavior.cpp
engines/ngi/behavior.h
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/scene04.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/fullpipe/scenes.h
diff --git a/engines/ngi/behavior.cpp b/engines/ngi/behavior.cpp
index 3ca04ff1ca4..c57fbd33ee3 100644
--- a/engines/ngi/behavior.cpp
+++ b/engines/ngi/behavior.cpp
@@ -52,6 +52,14 @@ void BehaviorController::enableAllMusic() {
track._enabled = true;
}
+void BehaviorController::disableAllMusic() {
+ for (BehaviorSound &track : _music) {
+ if (Sound *sound = g_ngi->findSound(track._soundId))
+ sound->stop();
+ track._enabled = false;
+ }
+}
+
BehaviorAni &BehaviorController::addAni(int16 objectId, int16 sceneId, int flags) {
_behaviors.push_back(BehaviorAni());
BehaviorAni &behavior = _behaviors.back();
diff --git a/engines/ngi/behavior.h b/engines/ngi/behavior.h
index 7f98735d308..961933e78dd 100644
--- a/engines/ngi/behavior.h
+++ b/engines/ngi/behavior.h
@@ -107,6 +107,8 @@ class BehaviorController : public CObject {
void addSound(const BehaviorSound &sound, bool music);
void enableAllMusic();
+ /** CBehaviorController::DisableAllMusic: stops the tracks and switches them off */
+ void disableAllMusic();
BehaviorAni &addAni(int16 objectId, int16 sceneId, int flags);
void onShow(Scene &scene);
bool update(uint32 elapsed = 1);
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index fee4709966d..450fd5db85b 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -41,6 +41,18 @@
namespace NGI {
+// CFPController::SkipArcade, a method of every arcade scene controller
+void sceneController_skipArcade() {
+ switch (g_ngi->_currentScene->_sceneId) {
+ case SC_4:
+ scene04_skipArcade();
+ break;
+ default:
+ warning("STUB/untested: skipping the arcade of scene %d", g_ngi->_currentScene->_sceneId);
+ break;
+ }
+}
+
static void inventory_onGuiEvent(Scene &inventory, const Common::String &id, const Common::String &event) {
if (event != "unpress")
return;
@@ -52,6 +64,8 @@ static void inventory_onGuiEvent(Scene &inventory, const Common::String &id, con
inventory._guiManager->getElement(id)->hideAndDeactivate();
} else if (id == "PIC_INV_TASK") {
sceneNotebook_show();
+ } else if (id == "BTN_SKIP_ARCADE") {
+ sceneController_skipArcade();
} else {
warning("STUB: Inventory::onGuiEvent(%s, %s)", id.c_str(), event.c_str());
}
diff --git a/engines/ngi/fullpipe/scene04.cpp b/engines/ngi/fullpipe/scene04.cpp
index 184a31c1bc0..9e137ba5626 100644
--- a/engines/ngi/fullpipe/scene04.cpp
+++ b/engines/ngi/fullpipe/scene04.cpp
@@ -34,6 +34,10 @@
#include "ngi/interaction.h"
#include "ngi/gameloader.h"
#include "ngi/behavior.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/sound.h"
+
+#include "common/formats/xmlparser.h"
#include "audio/mixer.h"
@@ -48,6 +52,55 @@ static const int scene04_speakerPhases[] = {
void sceneHandler04_putKozyawkaBack(AniObject *ani);
static bool scene04_click(Common::Point pos);
static void scene04_render(Scene &scene);
+static void scene04_startArcade();
+static void scene04_stopArcade();
+static void scene04_winArcade();
+static void scene04_speedUpBall();
+
+// Ids of the Android arcade (obj.h)
+static const int kQueueGoLamps = 23151; // QU_SC4_GOLAMPS
+static const int kMovLampsToRed = 23149; // MV_SC4_LAMPS_TORED
+static const int kMovKozawToPlank = 497; // MV_KZW_TOPLANK
+static const int kAniLamps = 23146; // ANI_SC4_LAMPS
+static const int kAniBigBall = 4923;
+static const int kQueueBallWalkRight = 4919; // QU_BALL_WALKR
+static const int kQueueBallWalkLeft = 4920;
+static const int kSoundStart = 63310; // SND_MUS_SC04_START, _LOOP, _STOP1, _STOP2
+static const int kSoundLoop = 63311;
+static const int kSoundStop1 = 63312;
+static const int kSoundStop2 = 63313;
+// the hint 1_05 ("ÐодÑказка_1_05") is on while the arcade runs
+#define SC4_HINT_STATE "\xcf\xee\xe4\xf1\xea\xe0\xe7\xea\xe0\x5f\x31\x5f\x30\x35"
+#define SC4_HINT_ON "\xc2\xea\xeb\xfe\xf7\xe5\xed\xe0"
+
+// sc_4_settings.xml (CSc04Controller::ReadSettingsXml)
+class Scene04SettingsParser : public Common::XMLParser {
+private:
+ CUSTOM_XML_PARSER(Scene04SettingsParser) {
+ XML_KEY(SETTINGS)
+ XML_KEY(KOZAWKA)
+ XML_PROP(frameDelayK, false)
+ XML_PROP(startDelay, false)
+ KEY_END()
+ XML_KEY(CLOCK)
+ XML_PROP(frameDelayK, false)
+ KEY_END()
+ KEY_END()
+ } PARSER_END()
+
+ bool parserCallback_SETTINGS(ParserNode *) { return true; }
+
+ bool parserCallback_KOZAWKA(ParserNode *node) {
+ g_vars->scene04_kozawDelayK = atof(node->values.getValOrDefault("frameDelayK", "1.0").c_str());
+ g_vars->scene04_kozawStartDelay = atof(node->values.getValOrDefault("startDelay", "0.0").c_str());
+ return true;
+ }
+
+ bool parserCallback_CLOCK(ParserNode *node) {
+ g_vars->scene04_clockDelayK = atof(node->values.getValOrDefault("frameDelayK", "1.0").c_str());
+ return true;
+ }
+};
void scene04_speakerCallback(int *phase) {
if (g_vars->scene04_soundPlaying) {
@@ -227,6 +280,13 @@ void scene04_initScene(Scene *sc) {
if (g_ngi->isAndroidFullPipe()) {
sc->_clickHook = scene04_click;
sc->_renderHook = scene04_render;
+ g_vars->scene04_lamps = sc->findAniObjectById(kAniLamps, 0);
+ g_vars->scene04_musicStopped = false;
+ g_vars->scene04_ballFromRight = false;
+
+ Scene04SettingsParser settings;
+ if (!settings.loadFile("data/sc_4_settings.xml") || !settings.parse())
+ warning("Could not read sc_4_settings.xml");
}
}
@@ -933,6 +993,11 @@ void sceneHandler04_doShowCoin() {
}
void sceneHandler04_stopSound() {
+ if (g_ngi->isAndroidFullPipe()) {
+ scene04_stopArcade();
+ return;
+ }
+
g_vars->scene04_soundPlaying = false;
g_ngi->stopSoundStream2();
@@ -1126,6 +1191,11 @@ void updateSound() {
}
void sceneHandler04_goClock() {
+ if (g_ngi->isAndroidFullPipe()) {
+ scene04_startArcade();
+ return;
+ }
+
sceneHandler04_walkKozyawka();
runQueue(QU_SC4_GOCLOCK, 0);
g_vars->scene04_soundPlaying = true;
@@ -1205,6 +1275,8 @@ void sceneHandler04_leaveLadder(Command *ex) {
g_vars->scene04_ladder = nullptr;
g_vars->scene04_dudeOnLadder = 0;
+ if (g_ngi->isAndroidFullPipe())
+ scene04_speedUpBall(); // CSc04Controller::AfterLadder
ex->_cmd = kCmdNone;
@@ -1244,6 +1316,10 @@ void sceneHandler04_handTake() {
void sceneHandler04_putKozyawkaBack(AniObject *ani) {
debugC(2, kDebugSceneLogic, "scene04: putKozyawkaBack");
+ // CSc04Controller::PutKozawToBottle
+ if (g_ngi->isAndroidFullPipe())
+ g_ngi->arcadeInterface().incCounter();
+
g_vars->scene04_bottleObjList.push_back(ani);
g_vars->scene04_kozyawkiAni.push_back(ani);
@@ -1345,6 +1421,11 @@ void sceneHandler04_updateBottle() {
}
void sceneHandler04_doWinArcade() {
+ if (g_ngi->isAndroidFullPipe()) {
+ scene04_winArcade();
+ return;
+ }
+
if (g_ngi->getStateId(sO_LowerPipe) == g_ngi->getStateValue(sO_LowerPipe, sO_IsClosed)
&& g_vars->scene04_soundPlaying) {
g_vars->scene04_clock->setStatic(ST_CLK_CLOSED);
@@ -1409,10 +1490,230 @@ static bool scene04_click(Common::Point pos) {
return false;
}
+// ---- The arcade of the Android game (CSc04Controller) ----
+
+static bool scene04_isPlaying(int soundId) {
+ const Sound *sound = g_ngi->findSound(soundId);
+ return sound && sound->isPlaying();
+}
+
+static void scene04_stopSoundById(int soundId) {
+ if (Sound *sound = g_ngi->findSound(soundId))
+ sound->stop();
+}
+
+static void scene04_setMovementDelay(AniObject *ani, int movementId, int delay) {
+ if (!ani)
+ return;
+ if (Movement *movement = ani->getMovement(movementId))
+ movement->_loopDelay = delay;
+}
+
+// CMessageQueue::Stop of the running copies of a queue
+static void scene04_stopQueue(int queueId) {
+ GlobalMessageQueueList &queues = *g_ngi->_globalMessageQueueList;
+ for (uint i = 0; i < queues.size(); i++) {
+ if (queues[i]->_queueId == queueId)
+ queues.disableQueueById(queues[i]->_id);
+ }
+}
+
+// CSc04Controller::StartKozawka: the last waiting kozawka walks to the plank, the first at once
+static void scene04_startKozawka(bool first) {
+ if (g_vars->scene04_kozyawkiObjList.empty())
+ return;
+
+ AniObject *koz = g_vars->scene04_kozyawkiObjList.back();
+ g_vars->scene04_kozyawkiObjList.pop_back();
+ g_vars->scene04_walkingKozyawka = koz;
+
+ MessageQueue *mq = new MessageQueue(g_ngi->_currentScene->findMessageQueue(QU_KOZAW_WALK), 0, 1);
+ mq->setObjectCopy(-1, koz->_copyId);
+ if (!first && mq->getCount())
+ mq->getCommandByIndex(0)->_messageNum = static_cast<int>(g_vars->scene04_kozawStartDelay * 1000);
+ mq->run(nullptr);
+
+ const int delay = static_cast<int>(g_vars->scene04_kozawDelayK * 83);
+ scene04_setMovementDelay(koz, kMovKozawToPlank, delay);
+ scene04_setMovementDelay(koz, MV_KZW_WALKPLANK, delay);
+ scene04_setMovementDelay(koz, MV_KZW_TOHOLERV, delay);
+ scene04_setMovementDelay(g_vars->scene04_plank, MV_PNK_WEIGHTRIGHT, delay);
+}
+
+// CSc04Controller::DoStartArcade: the clock starts. Not ported: the analytics event and the
+// catalog item ANI_KOZAWKA
+static void scene04_startArcade() {
+ scene04_startKozawka(true);
+
+ const int clockDelay = static_cast<int>(g_vars->scene04_clockDelayK * 83);
+ scene04_setMovementDelay(g_vars->scene04_clock, MV_CLK_GO, clockDelay);
+ runQueue(QU_SC4_GOCLOCK, 0);
+ scene04_setMovementDelay(g_vars->scene04_lamps, kMovLampsToRed, clockDelay);
+ runQueue(kQueueGoLamps, 0);
+
+ g_vars->scene04_soundPlaying = true;
+ g_vars->scene04_coinPut = false;
+
+ if (g_ngi->_currentScene->_behaviorController)
+ g_ngi->_currentScene->_behaviorController->disableAllMusic();
+ g_ngi->playSound(kSoundStart, 0);
+
+ g_ngi->setState(SC4_HINT_STATE, g_ngi->getStateValue(SC4_HINT_STATE, SC4_HINT_ON));
+ g_vars->scene04_bigBallCounter = 0;
+}
+
+// CSc04Controller::DoStopArcade. Not ported: a kozawka in mid-walk on the plank is not finished
+static void scene04_stopArcade() {
+ g_ngi->arcadeInterface().scrollOut();
+
+ if (g_vars->scene04_walkingKozyawka && g_vars->scene04_walkingKozyawka != g_vars->scene04_lastKozyawka)
+ warning("STUB/untested: CSc04Controller::DoStopArcade: the kozawka on the plank is not stopped");
+
+ g_vars->scene04_soundPlaying = false;
+ g_vars->scene04_musicStopped = false;
+ g_ngi->setState(SC4_HINT_STATE, 0);
+ if (g_vars->scene04_lamps)
+ g_vars->scene04_lamps->_flags &= ~4;
+}
+
+// the task and the interaction of the bottle are done with the arcade (DoWinArcade and SkipArcade)
+static void scene04_finishArcadeTask() {
+ g_ngi->_taskManager->deactivateTask("FIND_EXIT_BOTLE_SC4");
+ if (Interact *interaction = getGameLoaderInteractionController()->findInteraction(PIC_SC4_MASK, 0, 0))
+ interaction->_activity = 0;
+}
+
+// CSc04Controller::DoWinArcade
+static void scene04_winArcade() {
+ if (g_ngi->getStateId(sO_LowerPipe) != g_ngi->getStateValue(sO_LowerPipe, sO_IsClosed) || !g_vars->scene04_soundPlaying)
+ return;
+
+ g_vars->scene04_clock->setStatic(ST_CLK_CLOSED);
+ g_vars->scene04_hand->setStatic(ST_HND_EMPTY);
+ runQueue(QU_HND_TAKEBOTTLE, 0);
+
+ if (g_vars->scene04_walkingKozyawka) {
+ g_vars->scene04_kozyawkiObjList.push_back(g_vars->scene04_walkingKozyawka);
+ g_vars->scene04_walkingKozyawka->setStatic(ST_KZW_EMPTY);
+ g_vars->scene04_walkingKozyawka->hide();
+ g_vars->scene04_walkingKozyawka = nullptr;
+ }
+
+ g_vars->scene04_objectIsTaken = false;
+ g_vars->scene04_soundPlaying = false;
+ getGameLoaderInteractionController()->enable();
+ scene04_finishArcadeTask();
+}
+
+// CSc04Controller::SkipArcade (the skip button): the clock closes, the hand takes the bottle and the arcade stops
+void scene04_skipArcade() {
+ g_ngi->arcadeInterface().scrollOut();
+ g_vars->scene04_clock->setStatic(ST_CLK_CLOSED);
+ scene04_stopQueue(QU_SC4_GOCLOCK);
+
+ // MSG_STOP_MUS
+ g_vars->scene04_musicStopped = true;
+ scene04_stopSoundById(kSoundLoop);
+ g_ngi->playSound(kSoundStop2, 0);
+ if (g_vars->scene04_lamps)
+ g_vars->scene04_lamps->_flags &= ~4;
+
+ scene04_finishArcadeTask();
+ runQueue(QU_HND_TAKEBOTTLE, 0);
+ scene04_stopArcade();
+}
+
+// CSc04Controller::SlowDownBall / SpeedUpBall: frame delay of 73 ms for the big ball movements
+static void scene04_slowDownBall() {
+ if (AniObject *ball = g_ngi->_currentScene->findAniObjectById(kAniBigBall, 0)) {
+ for (Movement *movement : ball->_movements)
+ movement->_loopDelay = 73;
+ }
+ g_vars->scene04_ballSlow = true;
+}
+
+static void scene04_speedUpBall() {
+ if (!g_vars->scene04_ballSlow)
+ return;
+ if (AniObject *ball = g_ngi->_currentScene->findAniObjectById(kAniBigBall, 0)) {
+ for (Movement *movement : ball->_movements)
+ movement->_loopDelay = 0;
+ }
+ g_vars->scene04_ballSlow = false;
+}
+
+// CSc04Controller::TryBall: a big ball rolls in now and then while the hero is on the ladder
+static void scene04_tryBall() {
+ AniObject *ball = g_ngi->_currentScene->findAniObjectById(kAniBigBall, 0);
+ if (!g_vars->scene04_dudeOnLadder || (ball && (ball->_flags & 4)) || !g_vars->scene04_ladder)
+ return;
+ if (g_vars->scene04_ladder->getCurrentStep(g_ngi->_aniMan) <= 3 || g_ngi->_rnd.getRandomNumber(49) != 0)
+ return;
+
+ runQueue(g_vars->scene04_ballFromRight ? kQueueBallWalkRight : kQueueBallWalkLeft, 0);
+ g_vars->scene04_ballFromRight = !g_vars->scene04_ballFromRight;
+ scene04_slowDownBall();
+ g_vars->scene04_bigBallCounter = 0;
+}
+
+// CSc04Controller::OnUpdate: the arcade music (start, loop until MSG_STOP_MUS, stop) and the balls
+static void scene04_updateArcade(uint32 elapsed) {
+ if (g_vars->scene04_soundPlaying) {
+ if (!scene04_isPlaying(kSoundStart) && !scene04_isPlaying(kSoundLoop) && !scene04_isPlaying(kSoundStop1) &&
+ !scene04_isPlaying(kSoundStop2) && !g_vars->scene04_musicStopped)
+ g_ngi->playSound(kSoundLoop, 1);
+ } else if (!scene04_isPlaying(kSoundStop2) && !scene04_isPlaying(kSoundLoop) && g_ngi->_currentScene->_behaviorController) {
+ g_ngi->_currentScene->_behaviorController->enableAllMusic();
+ }
+
+ if (g_vars->scene04_dudeOnLadder && g_vars->scene04_soundPlaying) {
+ g_vars->scene04_bigBallCounter += elapsed;
+ if (g_vars->scene04_bigBallCounter > 24600)
+ scene04_tryBall();
+ }
+}
+
+// The messages that the Android scene 4 identifies by name (CSc04Controller::OnMessage)
+static bool sceneHandler04_namedMessage(const Common::String &name) {
+ if (name == "MSG_STOP_MUS") {
+ g_vars->scene04_musicStopped = true;
+ scene04_stopSoundById(kSoundLoop);
+ g_ngi->playSound(kSoundStop2, 0);
+ if (g_vars->scene04_lamps)
+ g_vars->scene04_lamps->_flags &= ~4;
+ return true;
+ }
+ if (name == "MSG_DO_START_ARCADE") {
+ if (g_vars->scene04_soundPlaying)
+ scene04_stopArcade();
+ scene04_startArcade();
+ return true;
+ }
+ if (name == "MSG_SC4_NEXT_LAMP") {
+ // the lamps light up one by one while the red movement runs
+ AniObject *lamps = g_vars->scene04_lamps;
+ if (lamps && lamps->_movement && lamps->_movement->_id == kMovLampsToRed &&
+ lamps->_movement->_curFrame < (int)lamps->_movement->_phases.size() - 1)
+ lamps->_movement->setCurFrame(lamps->_movement->_curFrame + 1);
+ return true;
+ }
+ if (name == "MSG_SC4_SHOW_HINT") {
+ // the three icons of the arcade; the hint of the hint manager is not ported
+ warning("STUB/untested: CHintManager::ShowHint (MSG_SC4_SHOW_HINT)");
+ g_ngi->arcadeInterface().init(400, -100, -64, 0, 3, 0, true);
+ g_ngi->arcadeInterface().scrollIn();
+ return true;
+ }
+ return false;
+}
+
int sceneHandler04(Command *ex) {
if (ex->_cmd != kCmdMessage)
return 0;
+ if (g_ngi->isAndroidFullPipe() && !ex->_messageName.empty() && sceneHandler04_namedMessage(ex->_messageName))
+ return 0;
+
switch (ex->_messageNum) {
case MSG_UPDATEBOTTLE:
sceneHandler04_updateBottle();
@@ -1467,8 +1768,12 @@ int sceneHandler04(Command *ex) {
g_vars->scene04_walkingKozyawka = nullptr;
}
- if (g_vars->scene04_soundPlaying)
- sceneHandler04_walkKozyawka();
+ if (g_vars->scene04_soundPlaying) {
+ if (g_ngi->isAndroidFullPipe())
+ scene04_startKozawka(false);
+ else
+ sceneHandler04_walkKozyawka();
+ }
break;
@@ -1489,6 +1794,8 @@ int sceneHandler04(Command *ex) {
// Android: CFPController scrolls (UpdateScroll for the ladder), Scene::update drives behaviors
if (g_ngi->isAndroidFullPipe()) {
+ scene04_updateArcade(ex->_param);
+
// CSc04Controller::RecalcSpring: one tick per update when 83 ms have passed, jar on the spring
g_vars->scene04_tickTime += ex->_param;
if (g_vars->scene04_tickTime > 83) {
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index b11206b1db3..cc48150624b 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -150,6 +150,13 @@ Vars::Vars() {
scene04_lastKozyawka = nullptr;
scene04_springDelay = 0;
scene04_tickTime = 0;
+ scene04_kozawDelayK = 1.0f;
+ scene04_kozawStartDelay = 0.0f;
+ scene04_clockDelayK = 1.0f;
+ scene04_musicStopped = false;
+ scene04_ballFromRight = false;
+ scene04_ballSlow = false;
+ scene04_lamps = nullptr;
scene04_bottleY = 0;
scene04_ladderOffset = 0;
diff --git a/engines/ngi/fullpipe/scenes.h b/engines/ngi/fullpipe/scenes.h
index 5f514e587ee..790b6aa031c 100644
--- a/engines/ngi/fullpipe/scenes.h
+++ b/engines/ngi/fullpipe/scenes.h
@@ -57,6 +57,7 @@ class BaseModalObject;
BaseModalObject *sceneNotebook_create();
void sceneNotebook_show();
void sceneController_initInventory();
+void sceneController_skipArcade();
bool sceneTutorial_isCompleted();
class Chapter;
void sceneChapter_show(Chapter &chapter, bool isStart);
@@ -88,6 +89,7 @@ int sceneHandler03(Command *cmd);
int scene04_updateCursor();
void scene04_initScene(Scene *sc);
+void scene04_skipArcade();
int sceneHandler04(Command *cmd);
void scene05_initScene(Scene *sc);
@@ -326,6 +328,14 @@ public:
int scene04_springOffset;
AniObject *scene04_lastKozyawka;
int scene04_springDelay;
+ // Android arcade (CSc04Controller)
+ float scene04_kozawDelayK; // sc_4_settings.xml: KOZAWKA frameDelayK, startDelay, CLOCK frameDelayK
+ float scene04_kozawStartDelay;
+ float scene04_clockDelayK;
+ bool scene04_musicStopped; // MSG_STOP_MUS: the stop jingle plays, the loop must not restart
+ bool scene04_ballFromRight; // the next big ball comes from the right
+ bool scene04_ballSlow;
+ AniObject *scene04_lamps;
uint32 scene04_tickTime; // Android: milliseconds not yet used by a Windows tick (83 ms)
int scene04_musicStage;
Commit: 3e709227c9dcb6fc7e8063e6da7943cf43b03e3f
https://github.com/scummvm/scummvm/commit/3e709227c9dcb6fc7e8063e6da7943cf43b03e3f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Place the bottle under the hand as the Android game does
Changed paths:
engines/ngi/fullpipe/scene04.cpp
diff --git a/engines/ngi/fullpipe/scene04.cpp b/engines/ngi/fullpipe/scene04.cpp
index 9e137ba5626..1fd9aa8080e 100644
--- a/engines/ngi/fullpipe/scene04.cpp
+++ b/engines/ngi/fullpipe/scene04.cpp
@@ -1406,6 +1406,17 @@ void sceneHandler04_testPlank(Command *ex) {
}
void sceneHandler04_updateBottle() {
+ if (g_ngi->isAndroidFullPipe()) {
+ // CSc04Controller::DoUpdateBottlePosition: the spring center is 108 px under the hand frame
+ const Common::Rect hand = g_vars->scene04_hand->getBounds();
+ const Common::Rect spring = g_vars->scene04_spring->getBounds();
+ const int delta = hand.bottom + 108 - (spring.top + spring.height() / 2);
+
+ sceneHandler04_bottleUpdateObjects(delta);
+ g_vars->scene04_spring->setPos(g_vars->scene04_spring->_x, g_vars->scene04_spring->_y + delta);
+ return;
+ }
+
int yoff;
if (g_vars->scene04_hand->_movement)
Commit: 1e43331a5c1fbb1268f391a9715a38061d6daadc
https://github.com/scummvm/scummvm/commit/1e43331a5c1fbb1268f391a9715a38061d6daadc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Add the test mode with the ImGui Info window
Changed paths:
A engines/ngi/debugger/debugtools.cpp
A engines/ngi/debugger/debugtools.h
A engines/ngi/debugger/dt-internal.h
A engines/ngi/fullpipe/testmode.cpp
A engines/ngi/fullpipe/testmode.h
engines/ngi/configure.engine
engines/ngi/detection.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
diff --git a/engines/ngi/configure.engine b/engines/ngi/configure.engine
index a3518cb474d..efc8a1cde38 100644
--- a/engines/ngi/configure.engine
+++ b/engines/ngi/configure.engine
@@ -1,3 +1,3 @@
# This file is included from the main "configure" script
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] [components]
-add_engine ngi "Nikita Game Interface" yes "" "" "16bit highres" "indeo45"
+add_engine ngi "Nikita Game Interface" yes "" "" "16bit highres" "imgui indeo45"
diff --git a/engines/ngi/debugger/debugtools.cpp b/engines/ngi/debugger/debugtools.cpp
new file mode 100644
index 00000000000..b3db07b8c8c
--- /dev/null
+++ b/engines/ngi/debugger/debugtools.cpp
@@ -0,0 +1,121 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+#include "backends/imgui/imgui.h"
+
+#include "common/debug.h"
+#include "common/system.h"
+
+#include "ngi/ngi.h"
+#include "ngi/fullpipe/testmode.h"
+
+#include "ngi/debugger/debugtools.h"
+#include "ngi/debugger/dt-internal.h"
+
+namespace NGI {
+
+namespace DT {
+
+ImGuiState *_state = nullptr;
+
+static void showInfo() {
+ if (!_state->_showInfo)
+ return;
+
+ TestInfo info;
+ testmode_getInfo(info);
+
+ // beside the game window, not over the game
+ const ImGuiViewport *viewport = ImGui::GetMainViewport();
+ ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x + viewport->Size.x + 10, viewport->Pos.y), ImGuiCond_FirstUseEver);
+ ImGui::SetNextWindowSize(ImVec2(440, MIN(420.0f, viewport->Size.y)), ImGuiCond_FirstUseEver);
+ if (ImGui::Begin("Info", &_state->_showInfo)) {
+ ImGui::Text("Frame %d step %u ms%s", info.frame, info.step, info.fast ? " (FAST: 6 updates per frame)" : "");
+ if (!info.pendingSpot.empty())
+ ImGui::TextColored(ImVec4(1.0f, 0.8f, 0.2f, 1.0f), "Dude goes to: %s", info.pendingSpot.c_str());
+
+ ImGui::SeparatorText("Scene");
+ ImGui::Text("%s", info.sceneName.c_str());
+ ImGui::Text("Camera %d, %d", info.camera.x, info.camera.y);
+ ImGui::Text("Mouse %d, %d (scene %d, %d)", info.mouse.x, info.mouse.y, info.mouseInScene.x, info.mouseInScene.y);
+
+ ImGui::SeparatorText("Dude");
+ if (!info.hero) {
+ ImGui::TextDisabled("not in the scene");
+ } else {
+ ImGui::Text("Position %d, %d z %d", info.heroPos.x, info.heroPos.y, info.heroZ);
+ ImGui::Text("Flags 0x%02x%s%s", info.heroFlags, (info.heroFlags & 4) ? " visible" : "", info.heroMirror ? " MIRROR" : "");
+ ImGui::Text("%s %s", info.heroMoving ? "Movement" : "Statics", info.heroAction.c_str());
+ if (info.heroMoving) {
+ ImGui::ProgressBar(info.phases > 1 ? (float)info.phase / (info.phases - 1) : 0.0f, ImVec2(-FLT_MIN, 0),
+ Common::String::format("phase %d / %d", info.phase, info.phases).c_str());
+ ImGui::Text("Movement position %d, %d frame delay %d ms", info.movementPos.x, info.movementPos.y, info.loopDelay);
+ }
+ ImGui::Text("Size %d x %d anchor %d, %d", info.size.x, info.size.y, info.anchor.x, info.anchor.y);
+ ImGui::Text("Quad %d, %d - %d, %d", info.quad.left, info.quad.top, info.quad.right, info.quad.bottom);
+ }
+
+ ImGui::SeparatorText(Common::String::format("Queues running: %u", info.queues.size()).c_str());
+ for (const Common::String &queue : info.queues)
+ ImGui::BulletText("%s", queue.c_str());
+ }
+ ImGui::End();
+}
+
+void onImGuiInit() {
+ _state = new ImGuiState();
+ // the test mode (the fast flag or a boot spot) opens the Info window by itself
+ _state->_showInfo = testmode_active();
+}
+
+void onImGuiRender() {
+ if (!debugChannelSet(-1, kDebugImGui)) {
+ ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange | ImGuiConfigFlags_NoMouse;
+ return;
+ }
+
+ if (!_state)
+ return;
+
+ ImGui::GetIO().ConfigFlags &= ~(ImGuiConfigFlags_NoMouseCursorChange | ImGuiConfigFlags_NoMouse);
+
+ if (ImGui::BeginMainMenuBar()) {
+ if (ImGui::BeginMenu("View")) {
+ ImGui::SeparatorText("Windows");
+
+ ImGui::MenuItem("Info", nullptr, &_state->_showInfo);
+ ImGui::EndMenu();
+ }
+ ImGui::EndMainMenuBar();
+ }
+
+ showInfo();
+}
+
+void onImGuiCleanup() {
+ delete _state;
+ _state = nullptr;
+}
+
+} // namespace DT
+
+} // namespace NGI
diff --git a/engines/ngi/debugger/debugtools.h b/engines/ngi/debugger/debugtools.h
new file mode 100644
index 00000000000..0d9cd67e1b5
--- /dev/null
+++ b/engines/ngi/debugger/debugtools.h
@@ -0,0 +1,34 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+#ifndef NGI_DEBUGTOOLS_H
+#define NGI_DEBUGTOOLS_H
+
+namespace NGI {
+namespace DT {
+void onImGuiInit();
+void onImGuiRender();
+void onImGuiCleanup();
+} // namespace DT
+} // namespace NGI
+
+#endif
diff --git a/engines/ngi/debugger/dt-internal.h b/engines/ngi/debugger/dt-internal.h
new file mode 100644
index 00000000000..d93b698e265
--- /dev/null
+++ b/engines/ngi/debugger/dt-internal.h
@@ -0,0 +1,38 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+#ifndef NGI_DT_INTERNAL_H
+#define NGI_DT_INTERNAL_H
+
+namespace NGI {
+namespace DT {
+
+typedef struct ImGuiState {
+ bool _showInfo = false;
+} ImGuiState;
+
+extern ImGuiState *_state;
+
+} // namespace DT
+} // namespace NGI
+
+#endif
diff --git a/engines/ngi/detection.cpp b/engines/ngi/detection.cpp
index d47563c0095..7c12aecdabb 100644
--- a/engines/ngi/detection.cpp
+++ b/engines/ngi/detection.cpp
@@ -40,6 +40,8 @@ static const DebugChannelDef debugFlagList[] = {
{NGI::kDebugInteractions, "interactions", "Interactions"},
{NGI::kDebugXML, "xml", "XML"},
{NGI::kDebugBounds, "bounds", "Outlines of the objects, hit regions and z controller"},
+ {NGI::kDebugInfo, "info", "Log the state of Dude (movement, phase, position) whenever it changes"},
+ {NGI::kDebugFast, "fast", "Six times faster game, for test runs"},
DEBUG_CHANNEL_END
};
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index cc48150624b..9e2947b2bcb 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -31,6 +31,7 @@
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/floaters.h"
#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/testmode.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/objectnames.h"
@@ -620,6 +621,7 @@ void NGIEngine::updateSceneLogic(uint32 elapsed) {
}
if (_taskManager)
_taskManager->onUpdate(elapsed);
+ testmode_update(elapsed);
// CInventoryController::OnUpdate runs the arcade interface
if (_arcadeInterface)
_arcadeInterface->update(elapsed);
diff --git a/engines/ngi/fullpipe/testmode.cpp b/engines/ngi/fullpipe/testmode.cpp
new file mode 100644
index 00000000000..fc4acb69e4b
--- /dev/null
+++ b/engines/ngi/fullpipe/testmode.cpp
@@ -0,0 +1,200 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+#include "common/debug-channels.h"
+#include "common/hash-str.h"
+
+#include "ngi/ngi.h"
+#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/messages.h"
+#include "ngi/motion.h"
+#include "ngi/objects.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/testmode.h"
+
+namespace NGI {
+
+namespace {
+
+// Places for Dude (scene id, spot, x, y): the spot 1 and the following are near the exits of the scene
+struct Spot {
+ int sceneId;
+ int spot;
+ int x;
+ int y;
+ int cameraX; // the camera: the exit that is tested has to be on the screen
+ const char *name;
+};
+
+const Spot kSpots[] = {
+ { SC_4, 1, 1150, 476, 800, "scene 4: before the right tube" },
+ { SC_4, 2, 260, 476, 0, "scene 4: before the left tube" },
+ { SC_3, 1, 450, 440, 0, "scene 3: in front of the lift" },
+};
+
+int g_frame = 0;
+int g_spot = 0;
+int g_idleFrames = 0;
+uint32 g_elapsed = 0;
+uint g_lastHeroState = 0;
+
+const Spot *findSpot(int sceneId, int spot) {
+ for (const Spot &candidate : kSpots) {
+ if (candidate.sceneId == sceneId && candidate.spot == spot)
+ return &candidate;
+ }
+ return nullptr;
+}
+
+Common::String name(int id) {
+ if (!g_ngi->_gameProject)
+ return Common::String::format("%d", id);
+ Common::String symbol = g_ngi->_gameProject->_objectIds.findName(id);
+ return symbol.empty() ? Common::String::format("%d", id) : Common::String::format("%d %s", id, symbol.c_str());
+}
+
+Common::String heroState(const TestInfo &info) {
+ if (!info.hero)
+ return "no hero";
+ Common::String state = Common::String::format("hero %d,%d z %d flags %02x%s | %s %s", info.heroPos.x, info.heroPos.y, info.heroZ, info.heroFlags,
+ info.heroMirror ? " MIRROR" : "", info.heroMoving ? "movement" : "statics", info.heroAction.c_str());
+ if (info.heroMoving)
+ state += Common::String::format(" phase %d/%d mov xy %d,%d", info.phase, info.phases, info.movementPos.x, info.movementPos.y);
+ state += Common::String::format(" size %dx%d anchor %d,%d | quad %d,%d - %d,%d", info.size.x, info.size.y, info.anchor.x, info.anchor.y,
+ info.quad.left, info.quad.top, info.quad.right, info.quad.bottom);
+ return state;
+}
+
+} // End of anonymous namespace
+
+bool testmode_active() {
+ return g_spot || testmode_updatesPerFrame() > 1;
+}
+
+int testmode_updatesPerFrame() {
+ return DebugMan.isDebugChannelEnabled(kDebugFast) ? 6 : 1;
+}
+
+void testmode_setSpot(int spot) {
+ g_spot = spot;
+ g_idleFrames = 0;
+}
+
+void testmode_getInfo(TestInfo &info) {
+ info.frame = g_frame;
+ info.step = g_elapsed;
+ info.fast = testmode_updatesPerFrame() > 1;
+ if (g_spot && g_ngi->_currentScene) {
+ const Spot *spot = findSpot(g_ngi->_currentScene->_sceneId, g_spot);
+ info.pendingSpot = spot ? spot->name : Common::String::format("no spot %d", g_spot);
+ }
+
+ Scene *scene = g_ngi->_currentScene;
+ if (!scene)
+ return;
+ info.sceneId = scene->_sceneId;
+ info.sceneName = name(scene->_sceneId);
+ info.camera = Common::Point(scene->_x, scene->_y);
+ info.mouse = g_ngi->_mouseScreenPos;
+ info.mouseInScene = info.mouse + info.camera;
+
+ for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList) {
+ if (!queue->_isFinished)
+ info.queues.push_back(name(queue->_queueId));
+ }
+
+ AniObject *hero = g_ngi->_aniMan;
+ if (!hero)
+ return;
+ info.hero = true;
+ info.heroPos = Common::Point(hero->_x, hero->_y);
+ info.heroZ = hero->_z;
+ info.heroFlags = hero->_flags;
+ info.heroMirror = (hero->_flags & 8) != 0;
+ if (hero->_movement) {
+ const Movement *movement = hero->_movement;
+ info.heroMoving = true;
+ info.heroAction = name(movement->_id);
+ info.phase = movement->_curFrame;
+ info.phases = movement->_phases.size();
+ info.loopDelay = movement->_loopDelay;
+ info.movementPos = Common::Point(movement->_x, movement->_y);
+ if (movement->_curPhase) {
+ const Dims size = movement->_curPhase->getDimensions();
+ info.size = Common::Point(size.x, size.y);
+ info.anchor = Common::Point(movement->_curPhase->_someX, movement->_curPhase->_someY);
+ }
+ } else if (hero->_statics) {
+ info.heroAction = name(hero->_statics->_staticsId);
+ const Dims size = hero->_statics->getDimensions();
+ info.size = Common::Point(size.x, size.y);
+ info.anchor = Common::Point(hero->_statics->_someX, hero->_statics->_someY);
+ }
+ info.quad = hero->getBounds();
+}
+
+void testmode_update(uint32 elapsed) {
+ g_frame++;
+ g_elapsed = elapsed;
+
+ AniObject *hero = g_ngi->_aniMan;
+
+ // --debugflags=info: a log line whenever Dude's movement or phase changes
+ if (DebugMan.isDebugChannelEnabled(kDebugInfo) && g_ngi->_currentScene) {
+ TestInfo info;
+ testmode_getInfo(info);
+ const Common::String state = heroState(info);
+ const uint stateHash = Common::hashit(state.c_str());
+ if (stateHash != g_lastHeroState) {
+ g_lastHeroState = stateHash;
+ debugC(1, kDebugInfo, "INFO f %d scene %d %s", g_frame, info.sceneId, state.c_str());
+ }
+ }
+
+ if (!g_spot || !hero || !g_ngi->_currentScene)
+ return;
+
+ // Dude has to stand after the entrance queue
+ g_idleFrames = hero->_movement || hero->_messageQueueId ? 0 : g_idleFrames + 1;
+ if (g_idleFrames < 10)
+ return;
+
+ const Spot *spot = findSpot(g_ngi->_currentScene->_sceneId, g_spot);
+ if (!spot) {
+ warning("TESTMODE: no spot %d in scene %d", g_spot, g_ngi->_currentScene->_sceneId);
+ } else {
+ warning("TESTMODE: Dude goes to %s (%d, %d)", spot->name, spot->x, spot->y);
+ Scene &scene = *g_ngi->_currentScene;
+ // the motion controller must know where Dude is
+ if (!scene._motionController || !scene._motionController->setPosImmediate(hero, spot->x, spot->y))
+ hero->setPos(spot->x, spot->y);
+ scene._x = CLIP(spot->cameraX, 0, MAX(0, scene._dims.x - 800));
+ scene._y = 0;
+ g_ngi->_sceneRect.moveTo(scene._x, scene._y);
+ }
+ g_spot = 0;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/testmode.h b/engines/ngi/fullpipe/testmode.h
new file mode 100644
index 00000000000..0e4aa4016e6
--- /dev/null
+++ b/engines/ngi/fullpipe/testmode.h
@@ -0,0 +1,84 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+#ifndef NGI_TESTMODE_H
+#define NGI_TESTMODE_H
+
+#include "common/array.h"
+#include "common/rect.h"
+#include "common/str.h"
+
+namespace NGI {
+
+/**
+ * Troubleshooting aids of the Android game, all switched on from the command line (docs/test-mode.md):
+ * --debugflags=imgui the ImGui debugger (debugger/debugtools.cpp), with the Info window: the state of the game
+ * --debugflags=info the state of Dude is logged as INFO lines (with -d1) whenever his movement or phase changes, no ImGui needed
+ * --debugflags=fast the game runs six times faster (six updates of 42 ms per frame, no waiting), for test runs
+ * --boot-param=N N = scene + 100 * spot: the scene N % 100, and Dude is moved to the spot (see testmode.cpp) as soon as he stands
+ * after the entrance queue, with the camera on the spot: the walk to a place that is tested is skipped
+ * In the test mode (the fast flag or a spot) the Info window of the ImGui debugger is open from the start.
+ */
+struct TestInfo {
+ int frame = 0;
+ uint32 step = 0;
+ bool fast = false;
+ Common::String pendingSpot;
+
+ int sceneId = 0;
+ Common::String sceneName;
+ Common::Point camera;
+ Common::Point mouse;
+ Common::Point mouseInScene;
+
+ bool hero = false;
+ Common::Point heroPos;
+ int heroZ = 0;
+ uint heroFlags = 0;
+ bool heroMirror = false;
+ bool heroMoving = false; // a movement, else statics
+ Common::String heroAction; // the name of the statics or the movement
+ int phase = 0;
+ int phases = 0;
+ int loopDelay = 0;
+ Common::Point size;
+ Common::Point anchor;
+ Common::Point movementPos;
+ Common::Rect quad;
+
+ Common::Array<Common::String> queues;
+};
+
+/** the fast flag or a spot: the Info window opens by itself */
+bool testmode_active();
+/** the number of updates that are simulated for one frame (1 when the fast mode is off) */
+int testmode_updatesPerFrame();
+/** the spot of the boot parameter, 0: none */
+void testmode_setSpot(int spot);
+/** every update of the scene logic */
+void testmode_update(uint32 elapsed);
+/** the state for the Info window */
+void testmode_getInfo(TestInfo &info);
+
+} // End of namespace NGI
+
+#endif
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index ae90d2d05c3..f92a4a1c86f 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -127,8 +127,14 @@ MODULE_OBJS = \
fullpipe/sceneTutorial.o \
fullpipe/scenes.o \
fullpipe/taskmanager.o \
+ fullpipe/testmode.o \
fullpipe/tremble.o
+ifdef USE_IMGUI
+MODULE_OBJS += \
+ debugger/debugtools.o
+endif
+
# This module can be built as a plugin
ifeq ($(ENABLE_NGI), DYNAMIC_PLUGIN)
PLUGIN := 1
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 8f8058b0ef5..1341bb5f418 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -20,6 +20,7 @@
*/
#include "base/plugins.h"
+#include "backends/imgui/imgui.h"
#include "backends/keymapper/keymapper.h"
#include "common/archive.h"
@@ -36,6 +37,8 @@
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/testmode.h"
+#include "ngi/debugger/debugtools.h"
#include "ngi/fullpipe/tremble.h"
#include "ngi/detection.h"
#include "ngi/gameloader.h"
@@ -414,7 +417,9 @@ Common::Error NGIEngine::run() {
int startEntranceId = 0;
startSceneId = start->_sceneId;
if (ConfMan.getInt("boot_param")) {
- startSceneId = convertScene(ConfMan.getInt("boot_param"));
+ // scene + 100 * spot: testmode.h
+ testmode_setSpot(ConfMan.getInt("boot_param") / 100);
+ startSceneId = convertScene(ConfMan.getInt("boot_param") % 100);
const Scene *bootScene = _gameProject->findScene(startSceneId);
if (bootScene && !bootScene->_entrances.empty())
startEntranceId = bootScene->_entrances.front()._id;
@@ -439,8 +444,25 @@ Common::Error NGIEngine::run() {
debugC(1, kDebugDrawing, "Presented first Full Pipe frame for %s", start->_tag.c_str());
}
+#ifdef USE_IMGUI
+ ImGuiCallbacks callbacks;
+ bool drawImGui = debugChannelSet(-1, kDebugImGui);
+ callbacks.init = DT::onImGuiInit;
+ callbacks.render = drawImGui ? DT::onImGuiRender : nullptr;
+ callbacks.cleanup = DT::onImGuiCleanup;
+ _system->setImGuiCallbacks(callbacks);
+#endif
+
uint32 lastUpdate = _system->getMillis();
while (!shouldQuit()) {
+#ifdef USE_IMGUI
+ // For performance reasons, disable the renderer callback if the ImGui debug flag isn't set
+ if (debugChannelSet(-1, kDebugImGui) != drawImGui) {
+ drawImGui = !drawImGui;
+ callbacks.render = drawImGui ? DT::onImGuiRender : nullptr;
+ _system->setImGuiCallbacks(callbacks);
+ }
+#endif
const bool redraw = updateEvents();
if (shouldQuit())
break;
@@ -455,6 +477,14 @@ Common::Error NGIEngine::run() {
result = updateScreen(step, brightness, redraw);
if (result.getCode() != Common::kNoError)
break;
+ // --debugflags=fast: more updates per frame (movements advance one phase per update)
+ for (int i = 1; usesXMLProject() && i < testmode_updatesPerFrame(); i++) {
+ result = updateScreen(42, brightness, false);
+ if (result.getCode() != Common::kNoError)
+ break;
+ }
+ if (result.getCode() != Common::kNoError)
+ break;
}
if (!timedUpdates && _needRestart) {
delete _modalObject;
@@ -468,9 +498,13 @@ Common::Error NGIEngine::run() {
}
_system->updateScreen();
- _system->delayMillis(timedUpdates ? 10 : 5);
+ _system->delayMillis(testmode_updatesPerFrame() > 1 ? 1 : timedUpdates ? 10 : 5);
}
+#ifdef USE_IMGUI
+ _system->setImGuiCallbacks(ImGuiCallbacks());
+#endif
+
if (usesXMLProject()) {
deleteModalObject();
clearMessages();
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index facdd80023e..77884935303 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -54,6 +54,8 @@ enum {
kDebugInteractions,
kDebugXML,
kDebugBounds,
+ kDebugInfo,
+ kDebugFast,
};
enum NGIActions {
Commit: 8326c930c0befe6370afc5e9ce892cbe046a6bbb
https://github.com/scummvm/scummvm/commit/8326c930c0befe6370afc5e9ce892cbe046a6bbb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Walk to the hero point of an interaction exactly as the GO_MCTL command does
Changed paths:
engines/ngi/interaction.cpp
diff --git a/engines/ngi/interaction.cpp b/engines/ngi/interaction.cpp
index 079ecbf52dc..9d00f17b6ff 100644
--- a/engines/ngi/interaction.cpp
+++ b/engines/ngi/interaction.cpp
@@ -119,7 +119,12 @@ bool InteractionController::handleInteraction(AniObject *subj, GameObject *obj,
y += size.y / 2 - anchor.y;
}
if (x != subj->_x || y != subj->_y) {
- queue.reset(getCurrSceneSc2MotionController()->makeQueue(subj, x, y, 0, action->_heroStaticId, action->_heroMirror));
+ // CFPController::ExecCmdMctl (the GO_MCTL command of the interaction) walks with the fuzzy flag set: the point has to be on the
+ // graph (within 3 pixels of a link) and Dude arrives exactly there, the last walk is stretched to it
+ MotionController *controller = getCurrSceneSc2MotionController();
+ queue.reset(controller->makeQueue(subj, x, y, 1, action->_heroStaticId, action->_heroMirror));
+ if (!queue)
+ queue.reset(controller->makeQueue(subj, x, y, 0, action->_heroStaticId, action->_heroMirror));
if (!queue)
return false;
}
Commit: e66a3711a6bd587ba96888e468e5e622743b0d94
https://github.com/scummvm/scummvm/commit/e66a3711a6bd587ba96888e468e5e622743b0d94
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Warn when an Android movement is stopped before its last frame
Changed paths:
engines/ngi/statics.cpp
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index fb7ac93a05e..2cc5e834d25 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -941,6 +941,14 @@ void AniObject::stopMovement() {
Common::Point point;
if (_movement) {
+ if (g_ngi->_gameVersion >= 201509 && !(_flags & 0x40)) {
+ // CAniObject::StopMovement plays the rest of the movement (CMovement::SetCurFrame to the end frame, running the phase commands
+ // unless the sounds are kept) before CMovement::Stop; here the object stops where it is
+ const int endFrame = _targetFrame >= 0 ? _targetFrame : (int)_movement->_phases.size() - 1;
+ if (_movement->_curFrame < endFrame)
+ warning("STUB/untested: AniObject::stopMovement(%d) before the end of the movement %d (frame %d of %d)", _id, _movement->_id, _movement->_curFrame, endFrame);
+ }
+
setPos(_movement->_x, _movement->_y);
if (_flags & 0x40) {
Commit: 441fc3c847045e0355a2a2d38df8c790195b9793
https://github.com/scummvm/scummvm/commit/441fc3c847045e0355a2a2d38df8c790195b9793
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Show the Android Full Pipe on a wide screen
Changed paths:
engines/ngi/detection.cpp
engines/ngi/detection.h
engines/ngi/fullpipe/arcadeinterface.cpp
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/sceneTutorial.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/fullpipe/testmode.cpp
engines/ngi/gfx.cpp
engines/ngi/guimanager.cpp
engines/ngi/guimanager.h
engines/ngi/metaengine.cpp
engines/ngi/modal.cpp
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/detection.cpp b/engines/ngi/detection.cpp
index 7c12aecdabb..5b30252ff34 100644
--- a/engines/ngi/detection.cpp
+++ b/engines/ngi/detection.cpp
@@ -268,7 +268,7 @@ static const NGIGameDescription gameDescriptions[] = {
Common::UNK_LANG,
Common::kPlatformAndroid,
ADGF_UNSTABLE,
- GUIO1(GUIO_NOMIDI)
+ GUIO2(GUIO_NOMIDI, GAMEOPTION_WIDESCREEN)
},
GID_FULLPIPE, 201509
},
diff --git a/engines/ngi/detection.h b/engines/ngi/detection.h
index ccdead8f473..a9bc3a1af61 100644
--- a/engines/ngi/detection.h
+++ b/engines/ngi/detection.h
@@ -24,6 +24,8 @@
#include "engines/advancedDetector.h"
+#define GAMEOPTION_WIDESCREEN GUIO_GAMEOPTIONS1
+
namespace NGI {
enum NGIGameId {
diff --git a/engines/ngi/fullpipe/arcadeinterface.cpp b/engines/ngi/fullpipe/arcadeinterface.cpp
index b8766f06ea2..2d93b408fe9 100644
--- a/engines/ngi/fullpipe/arcadeinterface.cpp
+++ b/engines/ngi/fullpipe/arcadeinterface.cpp
@@ -105,8 +105,12 @@ void ArcadeInterface::loadLimits() {
warning("Could not read skip.xml");
}
-// CArcadeInterface::Init. The original moves the icons by the black bars of the screen when they are close to the edge, there are none here.
+// CArcadeInterface::Init: icons near an edge move out to the widescreen edge
void ArcadeInterface::init(float x, float y, float stepX, float stepY, int total, int active, bool vertical) {
+ if (x > g_ngi->gameWidth() - 200.0f)
+ x += g_ngi->_wideOfs;
+ else if (x < 200.0f)
+ x -= g_ngi->_wideOfs;
_x = x;
_y = y;
_stepX = stepX;
@@ -220,7 +224,12 @@ void ArcadeInterface::scrollIn() {
_skipProgress->show();
}
- const float x = _arcadeSceneId == SC_8 ? 73.0f : 13.0f;
+ // CArcadeInterface::ScrollIn: the skip button follows the side of the screen the icons are on
+ float x = _arcadeSceneId == SC_8 ? 73.0f : 13.0f;
+ if (_x > g_ngi->gameWidth() - 200.0f)
+ x += g_ngi->_wideOfs;
+ else if (_x < 200.0f)
+ x -= g_ngi->_wideOfs;
GuiElement *positioned[] = { _skipButton, _skipProgress, _skipHighlight };
for (GuiElement *element : positioned) {
if (element)
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 450fd5db85b..a9390a97488 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -110,17 +110,18 @@ static void execScroll(Scene *scene, Command *cmd) {
float x = floatArg(cmd, "x", 0.0f);
float y = floatArg(cmd, "y", 0.0f);
const Dims sceneSize = scene->_dims;
- const int viewWidth = g_ngi->_backgroundSurface.w;
+ const int viewWidth = g_ngi->gameWidth();
const int viewHeight = g_ngi->_backgroundSurface.h;
- // Same order as the original; its render offsets (CRender 24 and 28, not identified yet) are taken as 0
+ // Same order as the original. The widescreen margin (CRender +24, vertical +28 is 0) keeps the whole screen inside the scene
if (viewWidth < sceneSize.x) {
- if (x < 0.0f)
- x = 0.0f;
+ const float marginX = g_ngi->_wideOfs;
+ if (x < marginX)
+ x = marginX;
if (y < 0.0f)
y = 0.0f;
- if (x > sceneSize.x - viewWidth)
- x = sceneSize.x - viewWidth;
+ if (x > sceneSize.x - viewWidth - marginX)
+ x = sceneSize.x - viewWidth - marginX;
if (y > sceneSize.y - viewHeight)
y = sceneSize.y - viewHeight;
}
@@ -192,7 +193,8 @@ void executeUserCommand(Command *cmd) {
// The camera of the Android scenes (CFPController::OnUpdate/UpdateScroll/DefaultScroll/LimitScroll/TestScroll/CheckBorders). The scene
// position (CScene +40/+44, Scene::_x/_y) is the camera. DefaultScroll sets a scroll target (CFPController +52/+56) from the hero and
// the cursor, TestScroll moves the camera towards it by 3 pixels every 10 ms. The touch variants (TouchScroll, MoveBorders: dragging the
-// scene, tapping a border to walk) are not ported; the render offsets of CRender (+24/+28, widescreen) are 0.
+// scene, tapping a border to walk) are not ported. The widescreen margin of CRender (+24, the vertical +28 is 0) is added where the original
+// does: a scrolling scene keeps the whole screen inside the scene, the camera is the position of the middle 800x600 area.
namespace {
struct Camera {
@@ -210,24 +212,28 @@ struct Camera {
Camera g_camera;
-float cameraViewWidth() { return g_ngi->_backgroundSurface.w; }
+float cameraViewWidth() { return g_ngi->gameWidth(); }
float cameraViewHeight() { return g_ngi->_backgroundSurface.h; }
-bool isScrollXScene(const Scene &scene) { return scene._dims.x > g_ngi->_backgroundSurface.w; }
+// CRender +24 as the scroll functions read it: only a scene wider than the game area scrolls
+float cameraMarginX(const Scene &scene) { return scene._dims.x > g_ngi->gameWidth() ? static_cast<float>(g_ngi->_wideOfs) : 0.0f; }
+
+bool isScrollXScene(const Scene &scene) { return scene._dims.x > g_ngi->gameWidth(); }
bool isScrollYScene(const Scene &scene) { return scene._dims.y > g_ngi->_backgroundSurface.h; }
// CFPController::LimitScroll
void limitScroll(Scene &scene) {
- if (scene._x < 0) {
- scene._x = 0;
+ const float marginX = cameraMarginX(scene);
+ if (scene._x < marginX) {
+ scene._x = marginX;
g_camera.targetX = 0;
}
if (scene._y < 0) {
scene._y = 0;
g_camera.targetY = 0;
}
- if (scene._x > scene._dims.x - cameraViewWidth()) {
- scene._x = scene._dims.x - cameraViewWidth();
+ if (scene._x > scene._dims.x - cameraViewWidth() - marginX) {
+ scene._x = scene._dims.x - cameraViewWidth() - marginX;
g_camera.targetX = 0;
}
if (scene._y > scene._dims.y - cameraViewHeight()) {
@@ -238,9 +244,10 @@ void limitScroll(Scene &scene) {
// CFPController::CheckBorders: 1 when the cursor is at the right edge and the scene goes on, -1 at the left edge (not on the top bar)
int checkBorders(const Scene &scene, float cursorX, float cursorY) {
- if (scene._x + cameraViewWidth() - cursorX < 47.0f && scene._x + cameraViewWidth() < scene._dims.x - 1)
+ const float marginX = cameraMarginX(scene);
+ if (scene._x + cameraViewWidth() - cursorX < 47.0f && scene._x + cameraViewWidth() + marginX < scene._dims.x - 1)
return 1;
- if (cursorX - scene._x < 47.0f && scene._x > 0.0f)
+ if (cursorX - scene._x < 47.0f && scene._x - marginX > 0.0f)
return cursorY > 60.0f ? -1 : 0;
return 0;
}
@@ -257,21 +264,22 @@ void defaultScroll(Scene &scene) {
const float cursorX = g_ngi->_mouseScreenPos.x + scene._x;
const float cursorY = g_ngi->_mouseScreenPos.y + scene._y;
const bool free = scene._motionController && !g_ngi->_currSelectedInventoryItemId;
+ const float marginX = cameraMarginX(scene);
bool edge = false;
const int border = checkBorders(scene, cursorX, cursorY);
if (border == 1) {
- if (scene._x + cameraViewWidth() - center.x < 500.0f && free) {
+ if (scene._x + cameraViewWidth() - marginX - center.x < 500.0f && free) {
g_camera.targetX += 3.0f;
- if (g_camera.targetX + scene._x + cameraViewWidth() >= scene._dims.x)
+ if (g_camera.targetX + scene._x + cameraViewWidth() + marginX >= scene._dims.x)
g_camera.targetX = 0;
}
edge = true;
}
if (border == -1) {
- if (center.x - scene._x < 500.0f && free) {
+ if (center.x - scene._x + marginX < 500.0f && free) {
g_camera.targetX -= 3.0f;
- if (g_camera.targetX + scene._x <= 0.0f)
+ if (g_camera.targetX + scene._x <= marginX)
g_camera.targetX = 0;
}
limitScroll(scene);
@@ -283,11 +291,11 @@ void defaultScroll(Scene &scene) {
}
if (g_camera.scrollX && isScrollXScene(scene)) {
- if (center.x >= scene._x + g_camera.marginX) {
- if (center.x > scene._x + cameraViewWidth() - g_camera.marginX)
- g_camera.targetX = center.x - (scene._x + cameraViewWidth()) + g_camera.offsetX;
+ if (center.x >= scene._x - marginX + g_camera.marginX) {
+ if (center.x > scene._x + cameraViewWidth() + marginX - g_camera.marginX)
+ g_camera.targetX = center.x - (scene._x + cameraViewWidth() + marginX) + g_camera.offsetX;
} else {
- g_camera.targetX = center.x - scene._x - g_camera.offsetX;
+ g_camera.targetX = center.x - scene._x + marginX - g_camera.offsetX;
}
}
if (g_camera.scrollY && isScrollYScene(scene)) {
@@ -308,8 +316,9 @@ void testScroll(Scene &scene) {
float dx = 0.0f;
float dy = 0.0f;
+ const float marginX = cameraMarginX(scene);
if (g_camera.targetX > 0.0f) {
- if (scene._x + cameraViewWidth() == scene._dims.x)
+ if (scene._x + cameraViewWidth() + marginX == scene._dims.x)
g_camera.targetX = 0;
dx = g_camera.targetX;
if (dx >= 3.0f) {
@@ -319,7 +328,7 @@ void testScroll(Scene &scene) {
g_camera.targetX = 0;
}
} else if (g_camera.targetX < 0.0f) {
- if (scene._x == 0)
+ if (scene._x == marginX)
g_camera.targetX = 0;
dx = g_camera.targetX;
if (dx <= -3.0f) {
@@ -446,13 +455,15 @@ void renderSceneTop(Scene &scene) {
warning("STUB/untested: CAchievementsManager::OnRender (the achievement banner) is not drawn");
}
+ // The bars start at the scene's edges (translated by the widescreen margin) and end at the edge of the screen
Graphics::ManagedSurface &target = g_ngi->_backgroundSurface;
const float scroll = scene._x;
+ const int ofs = g_ngi->_wideOfs;
if (scroll < 0.0f)
- target.fillRect(Common::Rect(0, 0, MIN<int>(-scroll, target.w), target.h), 0);
+ target.fillRect(Common::Rect(0, 0, MIN<int>(ofs - scroll, target.w), target.h), 0);
const int sceneWidth = scene._dims.x; // CScene::GetSceneDims
- if (static_cast<float>(sceneWidth - target.w) < scroll)
- target.fillRect(Common::Rect(sceneWidth - static_cast<int>(scroll), 0, target.w, target.h), 0);
+ if (static_cast<float>(sceneWidth - g_ngi->gameWidth()) < scroll)
+ target.fillRect(Common::Rect(MAX<int>(ofs + sceneWidth - static_cast<int>(scroll), 0), 0, target.w, target.h), 0);
if (g_ngi->_tremble)
g_ngi->_tremble->postRender();
diff --git a/engines/ngi/fullpipe/sceneTutorial.cpp b/engines/ngi/fullpipe/sceneTutorial.cpp
index 1d1f025d9cf..1851499d06d 100644
--- a/engines/ngi/fullpipe/sceneTutorial.cpp
+++ b/engines/ngi/fullpipe/sceneTutorial.cpp
@@ -85,6 +85,12 @@ private:
_angle = number(node, "angle");
_hasArrow = attrs.getValOrDefault("is") == "true";
_arrow = Common::Point(number(node, "posX"), number(node, "posY"));
+ // CTutorial::Init: "fitTo" sticks the arrow to an edge of the widescreen
+ const Common::String fitTo = attrs.getValOrDefault("fitTo");
+ if (fitTo == "left")
+ _arrow.x -= g_ngi->_wideOfs;
+ else if (fitTo == "right")
+ _arrow.x += g_ngi->_wideOfs;
} else {
node->ignore = true;
}
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index 9e2947b2bcb..6cdebcb67f2 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -742,7 +742,7 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
if (common && !scene->_exits.empty())
scene->initExits(*common);
if (intro2) {
- sceneIntro_initGui(*scene, *intro2, _backgroundSurface.w);
+ sceneIntro_initGui(*scene, *intro2, gameWidth());
sceneIntro_initMan(*scene);
addMessageHandler(sceneHandlerIntro, 2);
} else {
diff --git a/engines/ngi/fullpipe/testmode.cpp b/engines/ngi/fullpipe/testmode.cpp
index fc4acb69e4b..964f1d4b661 100644
--- a/engines/ngi/fullpipe/testmode.cpp
+++ b/engines/ngi/fullpipe/testmode.cpp
@@ -190,7 +190,8 @@ void testmode_update(uint32 elapsed) {
// the motion controller must know where Dude is
if (!scene._motionController || !scene._motionController->setPosImmediate(hero, spot->x, spot->y))
hero->setPos(spot->x, spot->y);
- scene._x = CLIP(spot->cameraX, 0, MAX(0, scene._dims.x - 800));
+ const int margin = scene._dims.x > g_ngi->gameWidth() ? g_ngi->_wideOfs : 0;
+ scene._x = CLIP(spot->cameraX, margin, MAX(margin, scene._dims.x - g_ngi->gameWidth() - margin));
scene._y = 0;
g_ngi->_sceneRect.moveTo(scene._x, scene._y);
}
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index 2a92d391871..7f61ca197d7 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -555,20 +555,26 @@ void Texture::loadPNG(const Common::Path &path, const Dims &sizeHint) {
debugC(2, kDebugLoading, "Loaded scene texture %s (%d x %d)", path.toString().c_str(), _width, _height);
}
+// the game is drawn shifted by the widescreen margin (CRender::DrawTexQuad adds the CRender offset)
+static Common::Point screenPosition(const Graphics::ManagedSurface &target, const Common::Point &position) {
+ return &target == &g_ngi->_backgroundSurface ? position + Common::Point(g_ngi->_wideOfs, 0) : position;
+}
+
void Texture::blitTo(Graphics::ManagedSurface &target, const Common::Point &position, bool mirror, int angle) const {
if (!_bitmap || !_bitmap->_surface)
return;
+ const Common::Point origin = screenPosition(target, position);
if (angle) {
const Graphics::ManagedSurface &surface = *_bitmap->_surface;
Graphics::TransformStruct transform;
transform._angle = angle;
transform._hotspot = Common::Point(surface.w / 2, surface.h / 2);
Common::ScopedPtr<Graphics::ManagedSurface> rotated(surface.rotoscale(transform));
- target.blitFrom(*rotated, position + transform._hotspot - Common::Point(rotated->w / 2, rotated->h / 2));
+ target.blitFrom(*rotated, origin + transform._hotspot - Common::Point(rotated->w / 2, rotated->h / 2));
} else if (mirror)
- target.simpleBlitFrom(*_bitmap->_surface, position, Graphics::FLIP_H, true);
+ target.simpleBlitFrom(*_bitmap->_surface, origin, Graphics::FLIP_H, true);
else
- target.blitFrom(*_bitmap->_surface, position);
+ target.blitFrom(*_bitmap->_surface, origin);
}
// CTexture::Render (no rotation) and CTexture::RenderRotate: the quad is texture size times the scale, positioned by its top left
@@ -576,8 +582,9 @@ void Texture::blitTo(Graphics::ManagedSurface &target, const Common::Point &posi
void Texture::blitTo(Graphics::ManagedSurface &target, const Common::Point &position, const RenderParams ¶ms) const {
if (!_bitmap || !_bitmap->_surface)
return;
+ const Common::Point screenPos = screenPosition(target, position);
if (params.isDefault()) {
- target.blitFrom(*_bitmap->_surface, position);
+ target.blitFrom(*_bitmap->_surface, screenPos);
return;
}
@@ -588,7 +595,7 @@ void Texture::blitTo(Graphics::ManagedSurface &target, const Common::Point &posi
if (window.isEmpty())
return;
- Common::Point origin = position;
+ Common::Point origin = screenPos;
// the window starts at its own texture coordinates, so the quad is shifted by them
origin.x += static_cast<int>(window.left * params.scaleX);
origin.y += static_cast<int>(window.top * params.scaleY);
@@ -694,7 +701,7 @@ void Texture::setAOIDs() {
void Texture::blitTo(Graphics::ManagedSurface &target, const Common::Rect &source, const Common::Point &position) const {
if (_bitmap && _bitmap->_surface)
- target.blitFrom(*_bitmap->_surface, source, position);
+ target.blitFrom(*_bitmap->_surface, source, screenPosition(target, position));
}
void Texture::init() {
diff --git a/engines/ngi/guimanager.cpp b/engines/ngi/guimanager.cpp
index 6ea2faea078..43e2c3dce4b 100644
--- a/engines/ngi/guimanager.cpp
+++ b/engines/ngi/guimanager.cpp
@@ -19,6 +19,8 @@
*
*/
+#include "common/tokenizer.h"
+
#include "ngi/guimanager.h"
#include "ngi/font.h"
#include "ngi/ngi.h"
@@ -42,6 +44,19 @@ GuiElement::GuiElement(Scene &scene, const Common::StringMap &attrs, const Objec
_pos = Common::Point(atoi(attrs.getValOrDefault("x").c_str()), atoi(attrs.getValOrDefault("y").c_str()));
_hasX = attrs.contains("x");
_hasY = attrs.contains("y");
+ // CGuiElement "fitTo": sticks the element to a screen edge, the widescreen margin moves it
+ Common::StringTokenizer fitTo(attrs.getValOrDefault("fitTo"), " ");
+ while (!fitTo.empty()) {
+ const Common::String side = fitTo.nextToken();
+ if (side == "left")
+ _fitShift.x -= g_ngi->_wideOfs;
+ else if (side == "right")
+ _fitShift.x += g_ngi->_wideOfs;
+ }
+ if (_hasX)
+ _pos.x += _fitShift.x;
+ if (_hasY)
+ _pos.y += _fitShift.y;
_cursor = atoi(attrs.getValOrDefault("cursor", "1").c_str());
_z = atoi(attrs.getValOrDefault("z").c_str());
_active = guiFlag(attrs, "active", true);
@@ -56,9 +71,9 @@ void GuiElement::load(GameProject &project) {
_picture = source && _pictureId ? source->findPictureObjectById(_pictureId, 0) : nullptr;
if (_picture) {
if (!_hasX)
- _pos.x = _picture->_x;
+ _pos.x = _picture->_x + _fitShift.x;
if (!_hasY)
- _pos.y = _picture->_y;
+ _pos.y = _picture->_y + _fitShift.y;
_size = _picture->getFullSize();
}
}
@@ -206,7 +221,7 @@ void GuiButton::unload() {
void GuiButton::activate() {
GuiElement::activate();
- onMouseMove(g_system->getEventManager()->getMousePos());
+ onMouseMove(g_system->getEventManager()->getMousePos() - Common::Point(g_ngi->_wideOfs, 0));
}
void GuiButton::render(Graphics::ManagedSurface &target) const {
diff --git a/engines/ngi/guimanager.h b/engines/ngi/guimanager.h
index f1d2e394a89..8e25cdfb4a0 100644
--- a/engines/ngi/guimanager.h
+++ b/engines/ngi/guimanager.h
@@ -72,6 +72,7 @@ public:
protected:
Scene &_scene;
bool _scrolling, _hasX, _hasY;
+ Common::Point _fitShift; // fitTo: the widescreen margin of the edge the element sticks to
int _sourceScene, _pictureId;
PictureObject *_picture = nullptr;
Common::Point screenPos() const;
diff --git a/engines/ngi/metaengine.cpp b/engines/ngi/metaengine.cpp
index 4bc467b3f5c..de7a787963b 100644
--- a/engines/ngi/metaengine.cpp
+++ b/engines/ngi/metaengine.cpp
@@ -70,12 +70,35 @@ int NGIEngine::getGameGID() const {
} // End of namspace Fullpipe
+namespace NGI {
+
+static const ADExtraGuiOptionsMap optionsList[] = {
+ {
+ GAMEOPTION_WIDESCREEN,
+ {
+ _s("Widescreen mode"),
+ _s("Show a 16:9 screen with more of the scenery on both sides instead of the 4:3 game area"),
+ "widescreen",
+ true,
+ 0,
+ 0
+ }
+ },
+ AD_EXTRA_GUI_OPTIONS_TERMINATOR
+};
+
+} // End of namespace NGI
+
class NGIMetaEngine : public AdvancedMetaEngine<NGI::NGIGameDescription> {
public:
const char *getName() const override {
return "ngi";
}
+ const ADExtraGuiOptionsMap *getAdvancedExtraGuiOptions() const override {
+ return NGI::optionsList;
+ }
+
bool hasFeature(MetaEngineFeature f) const override;
int getMaximumSaveSlot() const override { return 99; }
diff --git a/engines/ngi/modal.cpp b/engines/ngi/modal.cpp
index 8c61e199bc6..1c97f284b0d 100644
--- a/engines/ngi/modal.cpp
+++ b/engines/ngi/modal.cpp
@@ -711,7 +711,7 @@ void MapWindow::initMap() {
_picI03->_flags &= 0xFFFB;
}
- g_system->warpMouse(400, 300);
+ g_system->warpMouse(400 + g_ngi->_wideOfs, 300);
g_ngi->_mouseScreenPos.x = 400;
g_ngi->_mouseScreenPos.y = 300;
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 1341bb5f418..eeca3b68822 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -295,7 +295,7 @@ Common::Error NGIEngine::initGame() {
loadAllScenes();
#endif
- _system->warpMouse(400, 300);
+ _system->warpMouse(400 + _wideOfs, 300);
return Common::kNoError;
}
@@ -401,11 +401,16 @@ Common::Error NGIEngine::run() {
_gameProject = _gameLoader->_gameProject.get();
}
- initGraphics(width, height, nullptr);
+ // The Android revision shows a wide screen: the 800x600 area stays in the middle, the margins
+ // show more scenery (backgrounds go up to 159 pixels beyond it); 1066 x 600 is 16:9
+ _wideOfs = 0;
+ if (usesXMLProject() && _gameVersion >= 201509 && (!ConfMan.hasKey("widescreen") || ConfMan.getBool("widescreen")))
+ _wideOfs = kWideMargin;
+ initGraphics(width + 2 * _wideOfs, height, nullptr);
const Graphics::PixelFormat format = _system->getScreenFormat();
if (format.isCLUT8())
return Common::kUnsupportedColorMode;
- _backgroundSurface.create(width, height, format);
+ _backgroundSurface.create(width + 2 * _wideOfs, height, format);
_isSaveAllowed = false;
if (usesXMLProject()) {
@@ -439,7 +444,7 @@ Common::Error NGIEngine::run() {
_currentScene->render();
else
_backgroundSurface.clear(0);
- _system->copyRectToScreen(_backgroundSurface.getPixels(), _backgroundSurface.pitch, 0, 0, width, height);
+ _system->copyRectToScreen(_backgroundSurface.getPixels(), _backgroundSurface.pitch, 0, 0, _backgroundSurface.w, height);
_system->updateScreen();
debugC(1, kDebugDrawing, "Presented first Full Pipe frame for %s", start->_tag.c_str());
}
@@ -535,6 +540,8 @@ bool NGIEngine::updateEvents() {
bool redraw = false;
while (eventMan->pollEvent(event)) {
+ // the game works in the coordinates of its 800x600 area, not of the widescreen
+ event.mouse.x -= _wideOfs;
if (_gameVersion >= 201509) {
redraw |= handleGuiEvent(event);
continue;
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 77884935303..e108e3b47d8 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -144,6 +144,11 @@ void sceneCamera_update(Scene &scene, uint32 elapsed);
bool sceneController_click(Common::Point pos);
+/** Pixels beyond each side of the 800x600 area on a 16:9 screen (CRender::AdjustSize) */
+enum {
+ kWideMargin = 133
+};
+
class NGIEngine : public ::Engine {
protected:
@@ -196,6 +201,10 @@ public:
bool updateEvents();
Graphics::ManagedSurface _backgroundSurface;
+ /** Widescreen (CRender offsets 8 and 24): extra pixels per side beyond 800x600, 0 at base size */
+ int _wideOfs = 0;
+ /** The width of the game area (the screen without the widescreen margins) */
+ int gameWidth() const { return _backgroundSurface.w - 2 * _wideOfs; }
Common::ScopedPtr<GameLoader> _gameLoader;
GameProject *_gameProject;
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 38c1bba9c0a..27598995c82 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -25,6 +25,7 @@
#include "common/debug-channels.h"
#include "common/file.h"
#include "common/formats/xmlparser.h"
+#include "common/tokenizer.h"
#include "ngi/ngi.h"
#include "ngi/fullpipe/objectnames.h"
@@ -916,7 +917,7 @@ private:
if (node->values.contains("hero") && !node->values["hero"].empty() && !readId(node->values["hero"], _scene._heroId))
return parserError("Unknown scene hero");
_scene._sceneName = node->values.getValOrDefault("title");
- _scene._dims = Dims(atoi(node->values.getValOrDefault("width", Common::String::format("%d", g_ngi->_backgroundSurface.w)).c_str()),
+ _scene._dims = Dims(atoi(node->values.getValOrDefault("width", Common::String::format("%d", g_ngi->gameWidth())).c_str()),
atoi(node->values.getValOrDefault("height", Common::String::format("%d", g_ngi->_backgroundSurface.h)).c_str()));
_scene._x = strtod(node->values.getValOrDefault("scrollX").c_str(), nullptr);
_scene._y = strtod(node->values.getValOrDefault("scrollY").c_str(), nullptr);
@@ -930,7 +931,17 @@ private:
bool parserCallback_INVENTORY(ParserNode *node) {
Common::Rect area(atoi(node->values.getValOrDefault("w", "1024").c_str()),
atoi(node->values.getValOrDefault("h", "100").c_str()));
- area.translate(intProperty(*node, "x"), intProperty(*node, "y"));
+ // CInventory::Init: "fitTo" moves the item area by the widescreen margin
+ int x = intProperty(*node, "x");
+ Common::StringTokenizer fitTo(node->values.getValOrDefault("fitTo"), " ");
+ while (!fitTo.empty()) {
+ const Common::String side = fitTo.nextToken();
+ if (side == "left")
+ x -= g_ngi->_wideOfs;
+ else if (side == "right")
+ x += g_ngi->_wideOfs;
+ }
+ area.translate(x, intProperty(*node, "y"));
getGameLoaderInventory()->setItemArea(_scene._sceneId, area, atoi(node->values.getValOrDefault("interval", "10").c_str()));
return true;
}
Commit: 57a423b87284b716ef631171145316ba6c091ea5
https://github.com/scummvm/scummvm/commit/57a423b87284b716ef631171145316ba6c091ea5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Scene 4 camera, ladder hint and the arcade button as in the Android controller
Changed paths:
engines/ngi/fullpipe/constants.h
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/scene04.cpp
engines/ngi/fullpipe/scenes.h
engines/ngi/fullpipe/testmode.cpp
engines/ngi/messages.cpp
engines/ngi/messages.h
engines/ngi/ngi.h
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index ac8244ba358..1aed60d2b69 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -510,6 +510,7 @@ namespace NGI {
#define PIC_SC4_BOTTLE2 2936
#define PIC_SC4_DOWNTRUBA 619
#define PIC_SC4_LADDER 1438
+#define PIC_SC_4_ARROW_1 23534
#define PIC_SC4_LRTRUBA 616
#define PIC_SC4_MASK 585
#define PIC_SC4_PLANK 5183
@@ -1738,4 +1739,8 @@ namespace NGI {
} // End of namespace NGI
+// scene 4: the object state "Demo-scroll" (cp1251) is "Byl" (was) once the camera has shown the scene
+#define SC4_DEMO_SCROLL_STATE "\xc4\xe5\xec\xee\x2d\xf1\xea\xf0\xee\xeb\xeb"
+#define SC4_DEMO_SCROLL_DONE "\xc1\xfb\xeb"
+
#endif /* NGI_CONSTANTS_H */
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index a9390a97488..fd979017727 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -102,6 +102,8 @@ static bool boolArg(const Command *cmd, const char *name) {
return value == "1" || value.equalsIgnoreCase("true");
}
+static void cameraScrollTo(float dx, float dy);
+
// CFPController::ExecCmdScroll
static void execScroll(Scene *scene, Command *cmd) {
if (scene->_pictureObjects.empty())
@@ -126,11 +128,15 @@ static void execScroll(Scene *scene, Command *cmd) {
y = sceneSize.y - viewHeight;
}
- // With scroll=1 the original scrolls smoothly (CFPController::UpdateScroll); the camera jumps here
- scene->_x = (int)x;
- scene->_y = (int)y;
- if (scene == g_ngi->_currentScene)
- g_ngi->_sceneRect.moveTo((int)x, (int)y);
+ if (boolArg(cmd, "scroll") && scene == g_ngi->_currentScene) {
+ // the camera moves towards the point (CFPController +52/+56), 3 pixels every 10 ms, see sceneCamera_update
+ cameraScrollTo(x - scene->_x, y - scene->_y);
+ } else {
+ scene->_x = (int)x;
+ scene->_y = (int)y;
+ if (scene == g_ngi->_currentScene)
+ g_ngi->_sceneRect.moveTo((int)x, (int)y);
+ }
cmd->_args["x"] = Common::String::format("%d", (int)x);
cmd->_args["y"] = Common::String::format("%d", (int)y);
@@ -203,6 +209,8 @@ struct Camera {
uint32 elapsed = 0; // CFPController +68: the time that is not used yet, 10 ms per step
bool scrollX = true; // +64
bool scrollY = true; // +65
+ bool followHero = true; // +60: the object the camera follows (the hero), 0 while a scene controller moves the camera itself
+ bool smooth = false; // +188: a SET_SCROLL command with scroll=1 is moving the camera
// the margins of the scene controllers (CSc02Controller::CSc02Controller ...): +36, +40, +44, +48
float marginX = 300;
float marginY = 200;
@@ -212,6 +220,34 @@ struct Camera {
Camera g_camera;
+} // End of anonymous namespace
+
+static void cameraScrollTo(float dx, float dy) {
+ g_camera.targetX = dx;
+ g_camera.targetY = dy;
+ g_camera.smooth = true;
+}
+
+void sceneCamera_setFollowHero(bool follow) {
+ g_camera.followHero = follow;
+}
+
+void sceneCamera_setScrollTarget(float dx) {
+ g_camera.smooth = true;
+ g_camera.targetX = dx;
+}
+
+// CFPController::UpdateCmdScroll: true while the camera is still on its way to the point of the SET_SCROLL command
+bool sceneCamera_updateCmdScroll(const Command *cmd) {
+ const Scene *scene = g_ngi->_currentScene;
+ if (fabsf(scene->_x - floatArg(cmd, "x", 0.0f)) >= 3.0f || fabsf(scene->_y - floatArg(cmd, "y", 0.0f)) >= 3.0f)
+ return true;
+ g_camera.smooth = false;
+ return false;
+}
+
+namespace {
+
float cameraViewWidth() { return g_ngi->gameWidth(); }
float cameraViewHeight() { return g_ngi->_backgroundSurface.h; }
@@ -373,6 +409,16 @@ void sceneCamera_onShow(Scene &scene, int entranceId) {
scene._y = 0;
}
g_ngi->_sceneRect.moveTo(scene._x, scene._y);
+
+ // CFPController::EnableArcadeButton(IsCheater): the "Arcade" button of scenes 4, 8 and 11 is only there for a cheater (there is no cheat mode here)
+ if (PictureObject *button = scene.findPictureObjectById(PIC_SC8_ARCADENOW, 0))
+ button->_flags &= ~4;
+}
+
+// CFPController::UpdateScroll: the camera follows the hero unless a scene controller took it over (no tutorial or dragging here)
+void sceneCamera_updateScroll(Scene &scene) {
+ if (g_camera.followHero)
+ defaultScroll(scene);
}
// CFPController::OnUpdate, the camera part
@@ -382,7 +428,11 @@ void sceneCamera_update(Scene &scene, uint32 elapsed) {
const int oldY = scene._y;
while (g_camera.elapsed > 10) {
g_camera.elapsed -= 10;
- defaultScroll(scene); // UpdateScroll: the default scroll when no scroll command and no dragging is active
+ // CFPController::UpdateScroll (virtual: CSc04Controller::UpdateScroll ...), then TestScroll
+ if (scene._scrollHook)
+ scene._scrollHook(scene);
+ else
+ sceneCamera_updateScroll(scene);
testScroll(scene);
}
if (scene._x != oldX || scene._y != oldY)
diff --git a/engines/ngi/fullpipe/scene04.cpp b/engines/ngi/fullpipe/scene04.cpp
index 1fd9aa8080e..6c8efce7c9b 100644
--- a/engines/ngi/fullpipe/scene04.cpp
+++ b/engines/ngi/fullpipe/scene04.cpp
@@ -52,6 +52,7 @@ static const int scene04_speakerPhases[] = {
void sceneHandler04_putKozyawkaBack(AniObject *ani);
static bool scene04_click(Common::Point pos);
static void scene04_render(Scene &scene);
+static void scene04_updateScroll(Scene &scene);
static void scene04_startArcade();
static void scene04_stopArcade();
static void scene04_winArcade();
@@ -280,6 +281,16 @@ void scene04_initScene(Scene *sc) {
if (g_ngi->isAndroidFullPipe()) {
sc->_clickHook = scene04_click;
sc->_renderHook = scene04_render;
+ sc->_scrollHook = scene04_updateScroll;
+ g_vars->scene04_cameraLocked = false;
+ g_vars->scene04_demoScroll = false;
+ g_vars->scene04_hintPending = false;
+ g_vars->scene04_kozawInBottle = false;
+ g_vars->scene04_ladderActed = false;
+ g_vars->scene04_ladderArrow = sc->findPictureObjectById(PIC_SC_4_ARROW_1, 0);
+ g_vars->scene04_ladderTimer = -1;
+ g_vars->scene04_blinkTimer = -1;
+ g_vars->scene04_blinkToggle = false;
g_vars->scene04_lamps = sc->findAniObjectById(kAniLamps, 0);
g_vars->scene04_musicStopped = false;
g_vars->scene04_ballFromRight = false;
@@ -295,6 +306,28 @@ static void scene04_render(Scene &scene) {
g_ngi->arcadeInterface().render();
}
+// CSc04Controller::UpdateScroll: while the arcade runs or the hand moves, the camera is held at x 380 (the jar, the plank and the ladder
+// are in view); the camera follows the hero again when neither the ladder nor the arcade are used and no demo scroll is running
+static void scene04_updateScroll(Scene &scene) {
+ if (!g_vars->scene04_dudeOnLadder && !g_vars->scene04_soundPlaying)
+ g_vars->scene04_cameraLocked = false;
+
+ const bool handMoves = g_vars->scene04_hand && (g_vars->scene04_hand->_flags & 4) && g_vars->scene04_hand->_movement;
+ if (handMoves)
+ g_vars->scene04_cameraLocked = true;
+
+ if (g_vars->scene04_cameraLocked) {
+ if (handMoves || (g_vars->scene04_soundPlaying && g_ngi->_aniMan)) {
+ sceneCamera_setFollowHero(false);
+ if (fabsf(scene._x - 380.0f) > 3.0f)
+ sceneCamera_setScrollTarget(380.0f - scene._x);
+ }
+ } else if (!g_vars->scene04_demoScroll) {
+ sceneCamera_setFollowHero(true);
+ }
+ sceneCamera_updateScroll(scene);
+}
+
bool sceneHandler04_friesAreWalking() {
if (g_vars->scene04_dudeOnLadder && g_ngi->_aniMan->isIdle() && !(g_ngi->_aniMan->_flags & 0x100)) {
int col = g_vars->scene04_ladder->getCurrentStep(g_ngi->_aniMan);
@@ -374,8 +407,38 @@ void sceneHandler04_clickButton() {
}
}
+static Command *scene04_addCommand(MessageQueue *mq, const char *name, bool user) {
+ Command *cmd = new Command();
+ cmd->_cmd = user ? kCmdUser : kCmdMessage;
+ cmd->_messageName = name;
+ cmd->_wait = 0;
+ cmd->_excFlags = 2;
+ mq->addCommandToEnd(cmd);
+ return cmd;
+}
+
+// CSc04Controller::DoWalkLadder
void sceneHandler04_downLadder(int x, int y) {
- g_vars->scene04_ladder->startMove(g_ngi->_aniMan, x + g_vars->scene04_ladder->_entryOffsetX, y + g_vars->scene04_ladder->_entryOffsetY, 0, 0);
+ if (!g_ngi->isAndroidFullPipe()) {
+ g_vars->scene04_ladder->startMove(g_ngi->_aniMan, x + g_vars->scene04_ladder->_entryOffsetX, y + g_vars->scene04_ladder->_entryOffsetY, 0, 0);
+ return;
+ }
+
+ g_vars->scene04_cameraLocked = true;
+ MessageQueue *mq = g_vars->scene04_ladder->startMove(g_ngi->_aniMan, x + g_vars->scene04_ladder->_entryOffsetX, y + g_vars->scene04_ladder->_entryOffsetY, 0, 0);
+ if (!mq)
+ return; // the original lets the hero jump here (ManCanJump, DoManJump): not ported
+
+ if (g_vars->scene04_kozawInBottle) {
+ g_vars->scene04_kozawInBottle = false;
+ scene04_addCommand(mq, "MSG_KOZAWRESTART", false);
+ }
+ Command *rotate = scene04_addCommand(mq, "EXIT_ROTATE", true);
+ rotate->_args["picId"] = "GD_SC4_LADDER";
+ rotate->_args["where"] = "MSG_TOLADDER";
+ if (g_vars->scene04_hintPending)
+ scene04_addCommand(mq, "MSG_SC4_SHOW_HINT", false);
+ scene04_addCommand(mq, "MSG_SC4_START_LADDER_TIMER", false);
}
void sceneHandler04_walkClimbLadder(Command *ex) {
@@ -1317,8 +1380,10 @@ void sceneHandler04_putKozyawkaBack(AniObject *ani) {
debugC(2, kDebugSceneLogic, "scene04: putKozyawkaBack");
// CSc04Controller::PutKozawToBottle
- if (g_ngi->isAndroidFullPipe())
+ if (g_ngi->isAndroidFullPipe()) {
g_ngi->arcadeInterface().incCounter();
+ g_vars->scene04_kozawInBottle = true;
+ }
g_vars->scene04_bottleObjList.push_back(ani);
g_vars->scene04_kozyawkiAni.push_back(ani);
@@ -1564,6 +1629,9 @@ static void scene04_startArcade() {
g_vars->scene04_soundPlaying = true;
g_vars->scene04_coinPut = false;
+ g_vars->scene04_kozawInBottle = false;
+ g_vars->scene04_hintPending = true;
+ g_vars->scene04_ladderActed = false;
if (g_ngi->_currentScene->_behaviorController)
g_ngi->_currentScene->_behaviorController->disableAllMusic();
@@ -1581,8 +1649,10 @@ static void scene04_stopArcade() {
warning("STUB/untested: CSc04Controller::DoStopArcade: the kozawka on the plank is not stopped");
g_vars->scene04_soundPlaying = false;
- g_vars->scene04_musicStopped = false;
+ g_vars->scene04_cameraLocked = false;
+ g_vars->scene04_hintPending = false;
g_ngi->setState(SC4_HINT_STATE, 0);
+ g_vars->scene04_musicStopped = false;
if (g_vars->scene04_lamps)
g_vars->scene04_lamps->_flags &= ~4;
}
@@ -1612,6 +1682,7 @@ static void scene04_winArcade() {
g_vars->scene04_objectIsTaken = false;
g_vars->scene04_soundPlaying = false;
+ g_vars->scene04_cameraLocked = false;
getGameLoaderInteractionController()->enable();
scene04_finishArcadeTask();
}
@@ -1682,10 +1753,31 @@ static void scene04_updateArcade(uint32 elapsed) {
if (g_vars->scene04_bigBallCounter > 24600)
scene04_tryBall();
}
+
+ // the arrow of the ladder: shown after 5 seconds, then it wiggles every 174 ms
+ if (g_vars->scene04_ladderTimer != -1) {
+ g_vars->scene04_ladderTimer += elapsed;
+ if (g_vars->scene04_ladderTimer > 4999) {
+ g_vars->scene04_ladderTimer = -1;
+ if (g_vars->scene04_ladderArrow)
+ g_vars->scene04_ladderArrow->_flags |= 4;
+ g_vars->scene04_blinkTimer = 0;
+ }
+ }
+ if (g_vars->scene04_blinkTimer != -1 && g_vars->scene04_ladderArrow) {
+ g_vars->scene04_blinkTimer += elapsed;
+ if (g_vars->scene04_blinkTimer > 174) {
+ g_vars->scene04_blinkTimer = 0;
+ g_vars->scene04_blinkToggle = !g_vars->scene04_blinkToggle;
+ const int dir = g_vars->scene04_blinkToggle ? 1 : -1;
+ g_vars->scene04_ladderArrow->_x -= dir;
+ g_vars->scene04_ladderArrow->_y += 2 * dir;
+ }
+ }
}
// The messages that the Android scene 4 identifies by name (CSc04Controller::OnMessage)
-static bool sceneHandler04_namedMessage(const Common::String &name) {
+static bool sceneHandler04_namedMessage(const Common::String &name, Command *ex) {
if (name == "MSG_STOP_MUS") {
g_vars->scene04_musicStopped = true;
scene04_stopSoundById(kSoundLoop);
@@ -1708,8 +1800,53 @@ static bool sceneHandler04_namedMessage(const Common::String &name) {
lamps->_movement->setCurFrame(lamps->_movement->_curFrame + 1);
return true;
}
+ if (name == "MSG_SC4_DEMO_SCROLL") {
+ // end of QU_SC4_ENTER: on the first visit the camera shows the scene, right end and back
+ MessageQueue *queue = g_ngi->_globalMessageQueueList->getMessageQueueById(ex->_parId);
+ if (g_ngi->getStateId(SC4_DEMO_SCROLL_STATE) == g_ngi->getStateValue(SC4_DEMO_SCROLL_STATE, SC4_DEMO_SCROLL_DONE)) {
+ g_vars->scene04_demoScroll = false;
+ sceneCamera_setFollowHero(true);
+ while (queue && queue->getCount())
+ queue->removeCommand(queue->getCount() - 1, true);
+ } else {
+ g_vars->scene04_demoScroll = true;
+ sceneCamera_setFollowHero(false);
+ g_ngi->setState(SC4_DEMO_SCROLL_STATE, g_ngi->getStateValue(SC4_DEMO_SCROLL_STATE, SC4_DEMO_SCROLL_DONE));
+ if (queue) {
+ for (const char *x : { "800", "0" }) {
+ Command *scroll = new Command();
+ scroll->_cmd = kCmdUser;
+ scroll->_messageName = "SET_SCROLL";
+ scroll->_args["x"] = x;
+ scroll->_args["y"] = "0";
+ scroll->_args["scroll"] = "1";
+ scroll->_wait = 1;
+ scroll->_excFlags = 2;
+ queue->addCommandToEnd(scroll);
+ }
+ Command *end = new Command();
+ end->_cmd = kCmdMessage;
+ end->_messageName = "MSG_SC4_DEMO_SCROLL_END";
+ end->_excFlags = 2;
+ queue->addCommandToEnd(end);
+ }
+ }
+ return true;
+ }
+ if (name == "MSG_SC4_START_LADDER_TIMER") {
+ // the arrow of the ladder shows up when the hero stays on it for 5 seconds while the arcade runs
+ if (g_vars->scene04_ladderTimer == -1 && g_vars->scene04_dudeOnLadder && g_vars->scene04_soundPlaying && !g_vars->scene04_ladderActed)
+ g_vars->scene04_ladderTimer = 0;
+ return true;
+ }
+ if (name == "MSG_SC4_DEMO_SCROLL_END") {
+ g_vars->scene04_demoScroll = false;
+ sceneCamera_setFollowHero(true);
+ return true;
+ }
if (name == "MSG_SC4_SHOW_HINT") {
// the three icons of the arcade; the hint of the hint manager is not ported
+ g_vars->scene04_hintPending = false;
warning("STUB/untested: CHintManager::ShowHint (MSG_SC4_SHOW_HINT)");
g_ngi->arcadeInterface().init(400, -100, -64, 0, 3, 0, true);
g_ngi->arcadeInterface().scrollIn();
@@ -1722,7 +1859,7 @@ int sceneHandler04(Command *ex) {
if (ex->_cmd != kCmdMessage)
return 0;
- if (g_ngi->isAndroidFullPipe() && !ex->_messageName.empty() && sceneHandler04_namedMessage(ex->_messageName))
+ if (g_ngi->isAndroidFullPipe() && !ex->_messageName.empty() && sceneHandler04_namedMessage(ex->_messageName, ex))
return 0;
switch (ex->_messageNum) {
@@ -1747,6 +1884,14 @@ int sceneHandler04(Command *ex) {
g_vars->scene04_handIsDown = true;
g_vars->scene04_coinPut = false;
+ if (g_ngi->isAndroidFullPipe() && g_vars->scene04_ladderArrow) {
+ // CSc04Controller::DoStartHand: the arrow of the ladder is not needed any more
+ g_vars->scene04_ladderArrow->_flags &= ~4;
+ g_vars->scene04_ladderTimer = -1;
+ g_vars->scene04_blinkTimer = -1;
+ g_vars->scene04_ladderActed = true;
+ }
+
if (g_vars->scene04_dudeInBottle)
sceneHandler04_animOutOfBottle(nullptr);
diff --git a/engines/ngi/fullpipe/scenes.h b/engines/ngi/fullpipe/scenes.h
index 790b6aa031c..20b7950526d 100644
--- a/engines/ngi/fullpipe/scenes.h
+++ b/engines/ngi/fullpipe/scenes.h
@@ -298,6 +298,15 @@ public:
bool scene04_coinPut;
bool scene04_soundPlaying;
bool scene04_dudeOnLadder;
+ bool scene04_cameraLocked; // CSc04Controller +581: camera held at x 380 (arcade or hand)
+ bool scene04_demoScroll; // +764: the camera shows the scene when it is entered the first time
+ bool scene04_hintPending; // +741: show the three arcade icons when the hero climbs the ladder
+ bool scene04_kozawInBottle; // +740: a kozawka was put into the bottle
+ bool scene04_ladderActed; // +757: the hero jumped or the hand started, no more ladder arrow
+ PictureObject *scene04_ladderArrow; // +744: PIC_SC_4_ARROW_1, hero idle on the ladder
+ int scene04_ladderTimer; // +748: milliseconds since the hero stopped on the ladder, -1 stopped
+ int scene04_blinkTimer; // +752: the arrow wiggles every 174 ms, -1 stopped
+ bool scene04_blinkToggle; // +756
int scene04_dynamicPhaseIndex;
int scene04_sceneClickX;
diff --git a/engines/ngi/fullpipe/testmode.cpp b/engines/ngi/fullpipe/testmode.cpp
index 964f1d4b661..7690cc5a737 100644
--- a/engines/ngi/fullpipe/testmode.cpp
+++ b/engines/ngi/fullpipe/testmode.cpp
@@ -26,6 +26,7 @@
#include "ngi/ngi.h"
#include "ngi/gameloader.h"
#include "ngi/gfx.h"
+#include "ngi/inventory.h"
#include "ngi/messages.h"
#include "ngi/motion.h"
#include "ngi/objects.h"
@@ -46,12 +47,14 @@ struct Spot {
int y;
int cameraX; // the camera: the exit that is tested has to be on the screen
const char *name;
+ int item; // an inventory item that Dude gets (0: none)
};
const Spot kSpots[] = {
- { SC_4, 1, 1150, 476, 800, "scene 4: before the right tube" },
- { SC_4, 2, 260, 476, 0, "scene 4: before the left tube" },
- { SC_3, 1, 450, 440, 0, "scene 3: in front of the lift" },
+ { SC_4, 1, 1150, 476, 800, "scene 4: before the right tube", 0 },
+ { SC_4, 2, 260, 476, 0, "scene 4: before the left tube", 0 },
+ { SC_3, 1, 450, 440, 0, "scene 3: in front of the lift", 0 },
+ { SC_4, 3, 1150, 476, 800, "scene 4: with the coin for the horn", ANI_INV_COIN },
};
int g_frame = 0;
@@ -194,6 +197,14 @@ void testmode_update(uint32 elapsed) {
scene._x = CLIP(spot->cameraX, margin, MAX(margin, scene._dims.x - g_ngi->gameWidth() - margin));
scene._y = 0;
g_ngi->_sceneRect.moveTo(scene._x, scene._y);
+ // a test run does not wait for the demo scroll of scene 4
+ if (spot->sceneId == SC_4)
+ g_ngi->setState(SC4_DEMO_SCROLL_STATE, g_ngi->getStateValue(SC4_DEMO_SCROLL_STATE, SC4_DEMO_SCROLL_DONE));
+ if (spot->item) {
+ Inventory *inventory = getGameLoaderInventory();
+ inventory->addItem(spot->item, 1);
+ inventory->recalcItemPos();
+ }
}
g_spot = 0;
}
diff --git a/engines/ngi/messages.cpp b/engines/ngi/messages.cpp
index 830b7c1213a..f8734ecd7d6 100644
--- a/engines/ngi/messages.cpp
+++ b/engines/ngi/messages.cpp
@@ -496,7 +496,10 @@ void MessageQueue::next() {
_flags |= 4;
if (ex->_cmd == kCmdPause && ex->_wait && g_ngi->_gameVersion >= 201509)
_pauseCommand.reset(ex);
- else
+ else if (ex->_cmd == kCmdUser && ex->_wait && ex->_messageName == "SET_SCROLL" && g_ngi->_gameVersion >= 201509) {
+ executeUserCommand(ex);
+ _userCommand.reset(ex);
+ } else
ex->sendMessage();
} else if (_counter <= 0) {
_isFinished = 1;
@@ -517,6 +520,15 @@ bool MessageQueue::updateCmdPause(uint32 elapsed) {
return true;
}
+// CFPController::UpdateUserCmd: the queue goes on when the camera has reached the point
+bool MessageQueue::updateCmdUser() {
+ if (!_userCommand || sceneCamera_updateCmdScroll(_userCommand.get()))
+ return false;
+ _userCommand.reset();
+ update();
+ return true;
+}
+
bool MessageQueue::checkGlobalExCommandList1() {
Command *ex, *ex1;
diff --git a/engines/ngi/messages.h b/engines/ngi/messages.h
index 48875d1a54d..a295be00598 100644
--- a/engines/ngi/messages.h
+++ b/engines/ngi/messages.h
@@ -199,6 +199,8 @@ class MessageQueue : public CObject {
private:
Common::List<Command *> _commands;
Common::ScopedPtr<Command> _pauseCommand;
+ /** CMessageQueue::UpdateUserCmd: a user command that the queue waits for (SET_SCROLL with wait) */
+ Common::ScopedPtr<Command> _userCommand;
public:
MessageQueue();
@@ -228,6 +230,7 @@ class MessageQueue : public CObject {
void update();
void next();
bool updateCmdPause(uint32 elapsed);
+ bool updateCmdUser();
void finish();
void messageQueueCallback1(int par);
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index e108e3b47d8..ac5adb3d8cd 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -140,6 +140,13 @@ void renderSceneTop(Scene &scene);
/** The camera of the Android scenes (CFPController::DefaultScroll, TestScroll, LimitScroll, CheckBorders) */
void sceneCamera_onShow(Scene &scene, int entranceId);
void sceneCamera_update(Scene &scene, uint32 elapsed);
+/** CFPController::UpdateScroll, what the UpdateScroll of a scene controller calls at its end */
+void sceneCamera_updateScroll(Scene &scene);
+/** The camera fields of CFPController that the scene controllers change: +60 (follow the hero), +52 (the scroll target) */
+void sceneCamera_setFollowHero(bool follow);
+void sceneCamera_setScrollTarget(float dx);
+/** CFPController::UpdateCmdScroll: true while the camera has not reached the point of the SET_SCROLL command yet */
+bool sceneCamera_updateCmdScroll(const Command *cmd);
/** CFPController::OnMouseLKeyUp: a tap on the scene (interaction or walking), true when it was handled */
bool sceneController_click(Common::Point pos);
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index e584506bd14..869a9f5fb58 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -865,6 +865,8 @@ bool Scene::update(int counterdiff) {
changed |= _behaviorController->update(counterdiff);
for (MessageQueue *queue : *g_ngi->_globalMessageQueueList)
changed |= queue->updateCmdPause(counterdiff);
+ for (MessageQueue *queue : *g_ngi->_globalMessageQueueList)
+ changed |= queue->updateCmdUser();
processMessages();
if (g_ngi->_modalObject || this != g_ngi->_currentScene)
return true;
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index fab6c06f7dc..1f87d6ab43e 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -93,6 +93,8 @@ class Scene : public Background {
void (*_renderHook)(Scene &) = nullptr;
/** CScNNController::OnMouseLKeyUp before the tap handler of CFPController: true when the scene handled the tap (position in screen coordinates) */
bool (*_clickHook)(Common::Point) = nullptr;
+ /** CScNNController::UpdateScroll: replaces the default scroll of CFPController, it ends with sceneCamera_updateScroll() */
+ void (*_scrollHook)(Scene &) = nullptr;
void (*_guiEventHandler)(Scene &, const Common::String &, const Common::String &) = nullptr;
void onGuiEvent(const Common::String &id, const Common::String &event);
Common::Array<MessageQueue *> _messageQueues;
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 27598995c82..4cd5ec53ff6 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -1374,7 +1374,9 @@ private:
} else if (kind == "USER" || kind == "12" || kind == "SET_STATIC" || kind == "25" || kind == "SET_ACTIVE_INTERACTION") {
cmd->_cmd = kCmdUser;
cmd->_messageName = node->values.getValOrDefault("type", kind);
- cmd->_wait = 0;
+ // only SET_SCROLL waits (CFPController::UpdateCmdScroll); GO_MCTL (UpdateCmdMctl) is not ported
+ if (cmd->_messageName != "SET_SCROLL")
+ cmd->_wait = 0;
} else if (kind == "START_MOVEMENT" || kind == "3") {
cmd->_cmd = kCmdStartMovement;
cmd->_mirror = boolProperty(*node, "mirror");
Commit: 65fab4fcaae65feef1a65080ff39e4c5a14b0eb3
https://github.com/scummvm/scummvm/commit/65fab4fcaae65feef1a65080ff39e4c5a14b0eb3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Draw the black bars of the scene edges as CFPController::OnRenderTop does
Changed paths:
engines/ngi/fullpipe/fpcontroller.cpp
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index fd979017727..75756b3be9d 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -505,15 +505,15 @@ void renderSceneTop(Scene &scene) {
warning("STUB/untested: CAchievementsManager::OnRender (the achievement banner) is not drawn");
}
- // The bars start at the scene's edges (translated by the widescreen margin) and end at the edge of the screen
+ // two DrawQuad calls: [0, -scroll] and [sceneWidth - scroll, scroll], shifted by the margin
Graphics::ManagedSurface &target = g_ngi->_backgroundSurface;
const float scroll = scene._x;
const int ofs = g_ngi->_wideOfs;
if (scroll < 0.0f)
- target.fillRect(Common::Rect(0, 0, MIN<int>(ofs - scroll, target.w), target.h), 0);
+ target.fillRect(Common::Rect(ofs, 0, ofs + static_cast<int>(-scroll), target.h), 0);
const int sceneWidth = scene._dims.x; // CScene::GetSceneDims
if (static_cast<float>(sceneWidth - g_ngi->gameWidth()) < scroll)
- target.fillRect(Common::Rect(MAX<int>(ofs + sceneWidth - static_cast<int>(scroll), 0), 0, target.w, target.h), 0);
+ target.fillRect(Common::Rect(ofs + sceneWidth - static_cast<int>(scroll), 0, ofs + sceneWidth, target.h), 0);
if (g_ngi->_tremble)
g_ngi->_tremble->postRender();
Commit: 6c79c1d7182a0ad9024d8960a337149dd0255b9c
https://github.com/scummvm/scummvm/commit/6c79c1d7182a0ad9024d8960a337149dd0255b9c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Mark the Android constants
Changed paths:
engines/ngi/fullpipe/constants.h
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index 1aed60d2b69..986ff3a9c9a 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -240,7 +240,7 @@ namespace NGI {
#define SC_36 2070
#define SC_37 2071
#define SC_38 2072
-#define SC_CHAPTER 10006
+#define SC_CHAPTER 10006 // Android
#define SC_COMMON 321
#define SC_DBGMENU 726
#define SC_FINAL1 4999
@@ -374,8 +374,8 @@ namespace NGI {
#define PIC_POST_BUTTON 5398
#define SND_CMN_069 4969
-// Chapter dialog
-#define SND_CHAPTER_DLG 23272
+// Chapter dialog (Android)
+#define SND_CHAPTER_DLG 23272 // Android
// Intro
#define ANI_IN1MAN 5110
@@ -395,7 +395,7 @@ namespace NGI {
#define MSG_SC1_SHOWOSK2 468
#define MSG_SC1_UTRUBACLICK 1100
#define PIC_SC1_KUCHKA 1321
-#define QU_SC1_ENTER 320
+#define QU_SC1_ENTER 320 // Android
#define PIC_SC1_LADDER 1091
#define PIC_SC1_OSK 1018
#define PIC_SC1_OSK2 2932
@@ -510,7 +510,7 @@ namespace NGI {
#define PIC_SC4_BOTTLE2 2936
#define PIC_SC4_DOWNTRUBA 619
#define PIC_SC4_LADDER 1438
-#define PIC_SC_4_ARROW_1 23534
+#define PIC_SC_4_ARROW_1 23534 // Android
#define PIC_SC4_LRTRUBA 616
#define PIC_SC4_MASK 585
#define PIC_SC4_PLANK 5183
@@ -1739,8 +1739,8 @@ namespace NGI {
} // End of namespace NGI
-// scene 4: the object state "Demo-scroll" (cp1251) is "Byl" (was) once the camera has shown the scene
-#define SC4_DEMO_SCROLL_STATE "\xc4\xe5\xec\xee\x2d\xf1\xea\xf0\xee\xeb\xeb"
-#define SC4_DEMO_SCROLL_DONE "\xc1\xfb\xeb"
+// Android: scene 4, the state "Demo-scroll" (cp1251) is "Byl" once the camera has shown the scene
+#define SC4_DEMO_SCROLL_STATE "\xc4\xe5\xec\xee\x2d\xf1\xea\xf0\xee\xeb\xeb" // Android
+#define SC4_DEMO_SCROLL_DONE "\xc1\xfb\xeb" // Android
#endif /* NGI_CONSTANTS_H */
Commit: fb9d323a8727f7906e26396dea21de0be366c523
https://github.com/scummvm/scummvm/commit/fb9d323a8727f7906e26396dea21de0be366c523
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Draw the widescreen bars as CRender::DrawWidescreenOfs does
Changed paths:
engines/ngi/gfx.cpp
engines/ngi/ngi.cpp
engines/ngi/ngi.h
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index 7f61ca197d7..7acbffdde2e 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -1423,6 +1423,23 @@ void NGIEngine::drawAlphaRectangle(int x1, int y1, int x2, int y2, int alpha) {
}
}
+// CRender::DrawWidescreenOfs: with a horizontal margin (CRender +24 > 0) two opaque black quads, translated by the margin like every quad:
+// from x -2 * margin and from x 800 (the width of the game area), each 2 * margin wide and as high as the game area. The margin is
+// only horizontal here (+28, the vertical one, is 0 with adjust="height"), so there is no top and bottom pair.
+void NGIEngine::drawWidescreenBars() {
+ if (_wideOfs <= 0)
+ return;
+
+ const Common::Rect screen(_backgroundSurface.w, _backgroundSurface.h);
+ const int width = 2 * _wideOfs;
+ Common::Rect left(-width + _wideOfs, 0, _wideOfs, _backgroundSurface.h);
+ Common::Rect right(gameWidth() + _wideOfs, 0, gameWidth() + _wideOfs + width, _backgroundSurface.h);
+ left.clip(screen);
+ right.clip(screen);
+ _backgroundSurface.fillRect(left, 0);
+ _backgroundSurface.fillRect(right, 0);
+}
+
void NGIEngine::sceneFade(Scene *sc, bool direction) {
for (int dim = 0; dim < 255; dim += 20) {
int ticks = g_ngi->_system->getMillis();
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index eeca3b68822..02c7f38e669 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -770,8 +770,10 @@ Common::Error NGIEngine::updateScreen(uint32 elapsed, byte &brightness, bool red
}
if (timedUpdates) {
- if (redraw)
+ if (redraw) {
+ drawWidescreenBars();
_system->copyRectToScreen(_backgroundSurface.getPixels(), _backgroundSurface.pitch, 0, 0, _backgroundSurface.w, _backgroundSurface.h);
+ }
} else {
_inputController->render(_mouseScreenPos.x, _mouseScreenPos.y);
}
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index ac5adb3d8cd..ed5d7596a21 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -362,6 +362,8 @@ public:
int (*_updateCursorCallback)();
void drawAlphaRectangle(int x1, int y1, int x2, int y2, int alpha);
+ /** CRender::DrawWidescreenOfs, end of CGame::Render: black quads over the margins */
+ void drawWidescreenBars();
void sceneFade(Scene *sc, bool direction);
int _cursorId;
Commit: 1e15ae430754a030e0ec5ef9bd4a951b9ef2de12
https://github.com/scummvm/scummvm/commit/1e15ae430754a030e0ec5ef9bd4a951b9ef2de12
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Show the widescreen bars per scene as CRender::SetSrcRect decides
Changed paths:
engines/ngi/fullpipe/lift.cpp
engines/ngi/fullpipe/sceneChapter.cpp
engines/ngi/fullpipe/sceneNotebook.cpp
engines/ngi/fullpipe/sceneTutorial.cpp
engines/ngi/gfx.cpp
engines/ngi/modal.h
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/lift.cpp b/engines/ngi/fullpipe/lift.cpp
index cad63eba934..11b14975f8e 100644
--- a/engines/ngi/fullpipe/lift.cpp
+++ b/engines/ngi/fullpipe/lift.cpp
@@ -213,6 +213,8 @@ class ModalLiftView : public BaseModalObject {
public:
explicit ModalLiftView(Scene &view) : _view(view) {}
+ const Scene *getScene() const override { return &_view; }
+
~ModalLiftView() override {
for (const Button &button : _buttons) {
_view.removeAni(button.big);
diff --git a/engines/ngi/fullpipe/sceneChapter.cpp b/engines/ngi/fullpipe/sceneChapter.cpp
index 6dcf4cefcd6..ba8944eb808 100644
--- a/engines/ngi/fullpipe/sceneChapter.cpp
+++ b/engines/ngi/fullpipe/sceneChapter.cpp
@@ -119,6 +119,8 @@ class ModalChapter : public BaseModalObject {
public:
ModalChapter(Scene &scene, const Chapter &chapter) : _scene(scene), _chapter(chapter), _settings(chapter) {}
+ const Scene *getScene() const override { return &_scene; }
+
~ModalChapter() override {
if (_shown) {
if (_scene._soundList)
diff --git a/engines/ngi/fullpipe/sceneNotebook.cpp b/engines/ngi/fullpipe/sceneNotebook.cpp
index ab85d633d33..ebac19f4557 100644
--- a/engines/ngi/fullpipe/sceneNotebook.cpp
+++ b/engines/ngi/fullpipe/sceneNotebook.cpp
@@ -63,6 +63,8 @@ class ModalNotebook : public BaseModalObject {
public:
explicit ModalNotebook(Scene &scene) : _scene(scene) {}
+ const Scene *getScene() const override { return &_scene; }
+
~ModalNotebook() override {
if (_opened) {
_scene._guiEventHandler = nullptr;
diff --git a/engines/ngi/fullpipe/sceneTutorial.cpp b/engines/ngi/fullpipe/sceneTutorial.cpp
index 1851499d06d..3c2c7558405 100644
--- a/engines/ngi/fullpipe/sceneTutorial.cpp
+++ b/engines/ngi/fullpipe/sceneTutorial.cpp
@@ -104,6 +104,8 @@ private:
class ModalTutorial : public BaseModalObject {
public:
+ const Scene *getScene() const override { return &_scene; }
+
ModalTutorial(Scene &scene, TutorialStep step) : _scene(scene), _step(step), _layout(tutorialIds[step]) {}
bool open() {
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index 7acbffdde2e..d00b33ce812 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -23,6 +23,7 @@
#include "ngi/objects.h"
#include "ngi/gfx.h"
+#include "ngi/modal.h"
#include "ngi/statics.h"
#include "ngi/scene.h"
#include "ngi/interaction.h"
@@ -1423,11 +1424,15 @@ void NGIEngine::drawAlphaRectangle(int x1, int y1, int x2, int y2, int alpha) {
}
}
-// CRender::DrawWidescreenOfs: with a horizontal margin (CRender +24 > 0) two opaque black quads, translated by the margin like every quad:
-// from x -2 * margin and from x 800 (the width of the game area), each 2 * margin wide and as high as the game area. The margin is
-// only horizontal here (+28, the vertical one, is 0 with adjust="height"), so there is no top and bottom pair.
+// CRender::DrawWidescreenOfs (flag from Scene::hasWidescreenBars): with a margin (+24 > 0) two
+// black quads, from x -2 * margin and x 800, 2 * margin wide, as high as the game area. No top and
+// bottom pair: the vertical margin (+28) is 0 with adjust="height"
void NGIEngine::drawWidescreenBars() {
- if (_wideOfs <= 0)
+ // the flag belongs to the scene shown last (DoSetScene, PushScene, PopScene: CRender::SetSrcRect)
+ const Scene *scene = _modalObject ? _modalObject->getScene() : nullptr;
+ if (!scene)
+ scene = _currentScene;
+ if (_wideOfs <= 0 || !scene || !scene->hasWidescreenBars())
return;
const Common::Rect screen(_backgroundSurface.w, _backgroundSurface.h);
diff --git a/engines/ngi/modal.h b/engines/ngi/modal.h
index e534867aad6..9b323b68ede 100644
--- a/engines/ngi/modal.h
+++ b/engines/ngi/modal.h
@@ -26,6 +26,7 @@
namespace NGI {
+class Scene;
class PictureObject;
class Texture;
class Sound;
@@ -58,6 +59,9 @@ class BaseModalObject {
virtual void update() = 0;
virtual void saveload() = 0;
+
+ /** The scene of a dialog that is a scene of the original (CGame::PushScene), else null */
+ virtual const Scene *getScene() const { return nullptr; }
};
class ModalIntro : public BaseModalObject {
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 869a9f5fb58..55c19297d9d 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -613,6 +613,19 @@ void Scene::sortRenderables(Common::Array<T *> &list, uint startIndex) {
}
}
+// CRender::SetSrcRect (widescreen flag, CRender +32): a horizontal margin (+24 > 0) turns it on,
+// a wider scene turns it off; the scene's drawOffset decides if given (0: no bars)
+bool Scene::hasWidescreenBars() const {
+ if (g_ngi->_wideOfs <= 0)
+ return false;
+ bool bars = true;
+ if (_dims.x > g_ngi->gameWidth())
+ bars = false;
+ if (_drawOffset != -1)
+ bars = _drawOffset != 0;
+ return bars;
+}
+
void Scene::render(bool clear) {
debugC(6, kDebugDrawing, ">>>>> Scene::render()");
if (clear)
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 1f87d6ab43e..04a96bd8c9e 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -78,6 +78,10 @@ class Scene : public Background {
int16 _heroId = 0;
/** CScene::GetSceneDims (CScene+312): the SCENE attributes width and height, the screen size when missing (Android) */
Dims _dims;
+ /** +348 (drawOffset): 0 draws into the widescreen margins, else black bars; -1 decides by width */
+ int _drawOffset = -1;
+ /** The widescreen flag of CRender::SetSrcRect (CRender +32): black bars over the margins */
+ bool hasWidescreenBars() const;
Common::ScopedPtr<GuiManager> _guiManager;
/** XML PHYSICS (CScene+56): the Box2D world, drawn between the layers; not implemented yet (physics.h) */
Common::ScopedPtr<PhysListener> _physListener;
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 4cd5ec53ff6..ae257b406f7 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -917,6 +917,7 @@ private:
if (node->values.contains("hero") && !node->values["hero"].empty() && !readId(node->values["hero"], _scene._heroId))
return parserError("Unknown scene hero");
_scene._sceneName = node->values.getValOrDefault("title");
+ _scene._drawOffset = node->values.contains("drawOffset") ? atoi(node->values["drawOffset"].c_str()) : -1;
_scene._dims = Dims(atoi(node->values.getValOrDefault("width", Common::String::format("%d", g_ngi->gameWidth())).c_str()),
atoi(node->values.getValOrDefault("height", Common::String::format("%d", g_ngi->_backgroundSurface.h)).c_str()));
_scene._x = strtod(node->values.getValOrDefault("scrollX").c_str(), nullptr);
Commit: fbaf5f20a9da1f5cb77cd58e9740163280ac84a5
https://github.com/scummvm/scummvm/commit/fbaf5f20a9da1f5cb77cd58e9740163280ac84a5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Start the camera of a scrolling scene at the widescreen margin as CFPController::OnShow does
Changed paths:
engines/ngi/fullpipe/fpcontroller.cpp
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 75756b3be9d..d592841dbc5 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -401,11 +401,12 @@ void testScroll(Scene &scene) {
} // End of anonymous namespace
-// CFPController::OnShow, the camera part: a scene entered through an entrance starts at its top left corner
+// CFPController::OnShow, the camera part: a scene entered through an entrance starts at its top left corner, a scene wider than the game
+// area at the widescreen margin (CRender +24, +28), so the whole screen is inside the scene
void sceneCamera_onShow(Scene &scene, int entranceId) {
g_camera = Camera();
if (entranceId) {
- scene._x = 0;
+ scene._x = cameraMarginX(scene);
scene._y = 0;
}
g_ngi->_sceneRect.moveTo(scene._x, scene._y);
@@ -435,8 +436,10 @@ void sceneCamera_update(Scene &scene, uint32 elapsed) {
sceneCamera_updateScroll(scene);
testScroll(scene);
}
- if (scene._x != oldX || scene._y != oldY)
+ if (scene._x != oldX || scene._y != oldY) {
+ debugC(2, kDebugSceneLogic, "camera %d -> %d (target %g, follow %d)", oldX, scene._x, g_camera.targetX, g_camera.followHero);
g_ngi->_sceneRect.moveTo(scene._x, scene._y);
+ }
}
// CFPController::OnMouseLKeyUp (a tap) of every scene of an XML project: an interaction of the object under the finger, else the hero
Commit: 45bd8f2899bac2b786ebb013bbf46b683cb7079a
https://github.com/scummvm/scummvm/commit/45bd8f2899bac2b786ebb013bbf46b683cb7079a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Add FPController with the camera, touch scrolling and swipe walking of CFPController
Changed paths:
A engines/ngi/fullpipe/fpcontroller.h
engines/ngi/anihandler.h
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/scene04.cpp
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/scene.cpp
engines/ngi/scene.h
diff --git a/engines/ngi/anihandler.h b/engines/ngi/anihandler.h
index ba096dbfab7..eea9e2d807c 100644
--- a/engines/ngi/anihandler.h
+++ b/engines/ngi/anihandler.h
@@ -97,6 +97,8 @@ public:
void attachObject(int objId);
void resetData(int objId);
int getIndex(int objId);
+ /** CAniHandler::IsObjectAttached */
+ bool isObjectAttached(int objId) { return getIndex(objId) >= 0; }
MessageQueue *makeRunQueue(MakeQueueStruct *mkQueue);
void putObjectToStatic(AniObject *ani, int staticsId);
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index d592841dbc5..52fa41061c0 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -35,6 +35,7 @@
#include "ngi/scene.h"
#include "ngi/fullpipe/scenes.h"
#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/fpcontroller.h"
#include "ngi/guimanager.h"
#include "ngi/inventory.h"
#include "ngi/fullpipe/tremble.h"
@@ -102,46 +103,6 @@ static bool boolArg(const Command *cmd, const char *name) {
return value == "1" || value.equalsIgnoreCase("true");
}
-static void cameraScrollTo(float dx, float dy);
-
-// CFPController::ExecCmdScroll
-static void execScroll(Scene *scene, Command *cmd) {
- if (scene->_pictureObjects.empty())
- return;
-
- float x = floatArg(cmd, "x", 0.0f);
- float y = floatArg(cmd, "y", 0.0f);
- const Dims sceneSize = scene->_dims;
- const int viewWidth = g_ngi->gameWidth();
- const int viewHeight = g_ngi->_backgroundSurface.h;
-
- // Same order as the original. The widescreen margin (CRender +24, vertical +28 is 0) keeps the whole screen inside the scene
- if (viewWidth < sceneSize.x) {
- const float marginX = g_ngi->_wideOfs;
- if (x < marginX)
- x = marginX;
- if (y < 0.0f)
- y = 0.0f;
- if (x > sceneSize.x - viewWidth - marginX)
- x = sceneSize.x - viewWidth - marginX;
- if (y > sceneSize.y - viewHeight)
- y = sceneSize.y - viewHeight;
- }
-
- if (boolArg(cmd, "scroll") && scene == g_ngi->_currentScene) {
- // the camera moves towards the point (CFPController +52/+56), 3 pixels every 10 ms, see sceneCamera_update
- cameraScrollTo(x - scene->_x, y - scene->_y);
- } else {
- scene->_x = (int)x;
- scene->_y = (int)y;
- if (scene == g_ngi->_currentScene)
- g_ngi->_sceneRect.moveTo((int)x, (int)y);
- }
-
- cmd->_args["x"] = Common::String::format("%d", (int)x);
- cmd->_args["y"] = Common::String::format("%d", (int)y);
-}
-
// CMessageQueue::ExecuteCmdSetActiveInteraction
static void execSetActiveInteraction(Command *cmd) {
getGameLoaderInteractionController()->setActive(cmd->_args.getValOrDefault("int"), findId(cmd->_args.getValOrDefault("sc")),
@@ -167,7 +128,7 @@ void executeUserCommand(Command *cmd) {
return;
if (type == "SET_SCROLL") {
- execScroll(scene, cmd);
+ sceneController(*scene).execCmdScroll(cmd);
} else if (type == "SET_EXIT_STATE") {
const int id = findId(cmd->_args.getValOrDefault("picId"));
if (id)
@@ -196,250 +157,683 @@ void executeUserCommand(Command *cmd) {
}
}
-// The camera of the Android scenes (CFPController::OnUpdate/UpdateScroll/DefaultScroll/LimitScroll/TestScroll/CheckBorders). The scene
-// position (CScene +40/+44, Scene::_x/_y) is the camera. DefaultScroll sets a scroll target (CFPController +52/+56) from the hero and
-// the cursor, TestScroll moves the camera towards it by 3 pixels every 10 ms. The touch variants (TouchScroll, MoveBorders: dragging the
-// scene, tapping a border to walk) are not ported. The widescreen margin of CRender (+24, the vertical +28 is 0) is added where the original
-// does: a scrolling scene keeps the whole screen inside the scene, the camera is the position of the middle 800x600 area.
+// the camera is the scene position (CScene +40/+44), widescreen margin as in CRender +24
+
namespace {
-struct Camera {
- float targetX = 0; // CFPController +52
- float targetY = 0; // +56
- uint32 elapsed = 0; // CFPController +68: the time that is not used yet, 10 ms per step
- bool scrollX = true; // +64
- bool scrollY = true; // +65
- bool followHero = true; // +60: the object the camera follows (the hero), 0 while a scene controller moves the camera itself
- bool smooth = false; // +188: a SET_SCROLL command with scroll=1 is moving the camera
- // the margins of the scene controllers (CSc02Controller::CSc02Controller ...): +36, +40, +44, +48
- float marginX = 300;
- float marginY = 200;
- float offsetX = 400;
- float offsetY = 300;
+// The scenes whose controllers set the margins and offsets of the camera in their constructors (CSc02Controller::CSc02Controller ...): 300, 200, 400, 300
+const int kScrollingControllers[] = {
+ SC_2, SC_3, SC_4, SC_6, SC_9, SC_11, SC_13, SC_16, SC_18, SC_19, SC_21, SC_22, SC_27, SC_28, SC_29, SC_32, SC_33, SC_34, SC_35, SC_37, SC_38
};
-Camera g_camera;
+// CFPController::ExecCmdScroll helper
+float floatParam(const Command *cmd, const char *name, float defaultValue) {
+ return cmd->_args.contains(name) ? strtof(cmd->_args[name].c_str(), nullptr) : defaultValue;
+}
+
+bool boolParam(const Command *cmd, const char *name) {
+ const Common::String value = cmd->_args.getValOrDefault(name);
+ return value == "1" || value.equalsIgnoreCase("true");
+}
} // End of anonymous namespace
-static void cameraScrollTo(float dx, float dy) {
- g_camera.targetX = dx;
- g_camera.targetY = dy;
- g_camera.smooth = true;
+FPController &sceneController(Scene &scene) {
+ if (!scene._fpController)
+ scene._fpController = new FPController(scene);
+ return *scene._fpController;
}
-void sceneCamera_setFollowHero(bool follow) {
- g_camera.followHero = follow;
+FPController::FPController(Scene &scene) : _scene(scene) {
+ for (int id : kScrollingControllers) {
+ if (id == scene._sceneId) {
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+ }
+ }
+ initBorders();
}
-void sceneCamera_setScrollTarget(float dx) {
- g_camera.smooth = true;
- g_camera.targetX = dx;
+AniObject *FPController::hero() const {
+ return g_ngi->_aniMan;
}
-// CFPController::UpdateCmdScroll: true while the camera is still on its way to the point of the SET_SCROLL command
-bool sceneCamera_updateCmdScroll(const Command *cmd) {
- const Scene *scene = g_ngi->_currentScene;
- if (fabsf(scene->_x - floatArg(cmd, "x", 0.0f)) >= 3.0f || fabsf(scene->_y - floatArg(cmd, "y", 0.0f)) >= 3.0f)
- return true;
- g_camera.smooth = false;
- return false;
+// CCursorController +72, +76: the position of the cursor in scene coordinates
+float FPController::cursorX() const {
+ return g_ngi->_mouseScreenPos.x + _scene._x;
}
-namespace {
-
-float cameraViewWidth() { return g_ngi->gameWidth(); }
-float cameraViewHeight() { return g_ngi->_backgroundSurface.h; }
+float FPController::cursorY() const {
+ return g_ngi->_mouseScreenPos.y + _scene._y;
+}
// CRender +24 as the scroll functions read it: only a scene wider than the game area scrolls
-float cameraMarginX(const Scene &scene) { return scene._dims.x > g_ngi->gameWidth() ? static_cast<float>(g_ngi->_wideOfs) : 0.0f; }
+float FPController::marginX() const {
+ return _scene._dims.x > g_ngi->gameWidth() ? static_cast<float>(g_ngi->_wideOfs) : 0.0f;
+}
-bool isScrollXScene(const Scene &scene) { return scene._dims.x > g_ngi->gameWidth(); }
-bool isScrollYScene(const Scene &scene) { return scene._dims.y > g_ngi->_backgroundSurface.h; }
+bool FPController::isScrollXScene() const {
+ return _scene._dims.x > g_ngi->gameWidth();
+}
+
+bool FPController::isScrollYScene() const {
+ return _scene._dims.y > g_ngi->_backgroundSurface.h;
+}
+
+// CFPController::OnShow, camera part; not ported: ResetSwipeParams, flurry, hints, GUI helpers
+void FPController::onShow(int entranceId) {
+ _follow = hero();
+ if (entranceId) {
+ _scene._x = marginX();
+ _scene._y = 0;
+ }
+ _targetX = 0;
+ _targetY = 0;
+ _smooth = false;
+ _touching = false;
+ _dragged = false;
+ resetSwipeParams();
+ g_ngi->_sceneRect.moveTo(_scene._x, _scene._y);
+
+ if (PictureObject *button = _scene.findPictureObjectById(PIC_SC8_ARCADENOW, 0))
+ button->_flags &= ~4;
+}
+
+// CFPController::ResetSwipeParams
+void FPController::resetSwipeParams() {
+ _touching = false;
+ _dragged = false;
+ _touchOffsetX = _touchOffsetY = -1;
+ _touchCameraX = _touchCameraY = -1;
+ _touchStartCameraX = _touchStartCameraY = -1;
+ _touchX = _touchY = -1;
+}
+
+// CFPController::InitBorders: the points of the BORDER of the scene in data.xml
+void FPController::initBorders() {
+ _hasLeftBorder = _hasRightBorder = false;
+ GameVar *scenes = g_ngi->getGameLoaderGameVar();
+ GameVar *sceneVar = scenes ? scenes->getSubVarByName(g_ngi->gameIdToStr(_scene._sceneId)) : nullptr;
+ GameVar *border = sceneVar ? sceneVar->getSubVarByName("BORDER") : nullptr;
+ if (!border)
+ return;
+ for (GameVar *item = border->_subVars; item; item = item->_nextVarObj) {
+ const int x = item->getSubVarAsInt("x");
+ const int y = item->getSubVarAsInt("y");
+ if (item->_varName == "LeftBorder") {
+ _hasLeftBorder = true;
+ _leftBorderX = x;
+ _leftBorderY = y;
+ } else if (item->_varName == "RightBorder") {
+ _hasRightBorder = true;
+ _rightBorderX = x;
+ _rightBorderY = y;
+ }
+ }
+}
+
+// CFPController::ExecCmdScroll
+void FPController::execCmdScroll(Command *cmd) {
+ if (_scene._pictureObjects.empty())
+ return;
+
+ float x = floatParam(cmd, "x", 0.0f);
+ float y = floatParam(cmd, "y", 0.0f);
+ const Dims sceneSize = _scene._dims;
+ const int viewWidth = g_ngi->gameWidth();
+ const int viewHeight = g_ngi->_backgroundSurface.h;
+
+ // same order as the original; the widescreen margin keeps the whole screen inside the scene
+ if (viewWidth < sceneSize.x) {
+ const float margin = g_ngi->_wideOfs;
+ if (x < margin)
+ x = margin;
+ if (y < 0.0f)
+ y = 0.0f;
+ if (x > sceneSize.x - viewWidth - margin)
+ x = sceneSize.x - viewWidth - margin;
+ if (y > sceneSize.y - viewHeight)
+ y = sceneSize.y - viewHeight;
+ }
+
+ if (boolParam(cmd, "scroll") && &_scene == g_ngi->_currentScene) {
+ // the camera moves towards the point (+52/+56), 3 pixels every 10 ms, see updateCamera
+ scrollTo(x - _scene._x, y - _scene._y);
+ } else {
+ _scene._x = (int)x;
+ _scene._y = (int)y;
+ if (&_scene == g_ngi->_currentScene)
+ g_ngi->_sceneRect.moveTo((int)x, (int)y);
+ }
+
+ cmd->_args["x"] = Common::String::format("%d", (int)x);
+ cmd->_args["y"] = Common::String::format("%d", (int)y);
+}
+
+// CFPController::UpdateCmdScroll
+bool FPController::updateCmdScroll(const Command *cmd) {
+ if (fabsf(_scene._x - floatParam(cmd, "x", 0.0f)) >= 3.0f || fabsf(_scene._y - floatParam(cmd, "y", 0.0f)) >= 3.0f)
+ return true;
+ _smooth = false;
+ return false;
+}
// CFPController::LimitScroll
-void limitScroll(Scene &scene) {
- const float marginX = cameraMarginX(scene);
- if (scene._x < marginX) {
- scene._x = marginX;
- g_camera.targetX = 0;
+void FPController::limitScroll() {
+ const float margin = marginX();
+ if (_scene._x < margin) {
+ _scene._x = margin;
+ _targetX = 0;
}
- if (scene._y < 0) {
- scene._y = 0;
- g_camera.targetY = 0;
+ if (_scene._y < 0) {
+ _scene._y = 0;
+ _targetY = 0;
}
- if (scene._x > scene._dims.x - cameraViewWidth() - marginX) {
- scene._x = scene._dims.x - cameraViewWidth() - marginX;
- g_camera.targetX = 0;
+ if (_scene._x > _scene._dims.x - g_ngi->gameWidth() - margin) {
+ _scene._x = _scene._dims.x - g_ngi->gameWidth() - margin;
+ _targetX = 0;
}
- if (scene._y > scene._dims.y - cameraViewHeight()) {
- scene._y = scene._dims.y - cameraViewHeight();
- g_camera.targetY = 0;
+ if (_scene._y > _scene._dims.y - g_ngi->_backgroundSurface.h) {
+ _scene._y = _scene._dims.y - g_ngi->_backgroundSurface.h;
+ _targetY = 0;
}
}
// CFPController::CheckBorders: 1 when the cursor is at the right edge and the scene goes on, -1 at the left edge (not on the top bar)
-int checkBorders(const Scene &scene, float cursorX, float cursorY) {
- const float marginX = cameraMarginX(scene);
- if (scene._x + cameraViewWidth() - cursorX < 47.0f && scene._x + cameraViewWidth() + marginX < scene._dims.x - 1)
+int FPController::checkBorders(float cursorX, float cursorY) const {
+ if (_swiped)
+ return 0;
+ const float margin = marginX();
+ if (_scene._x + g_ngi->gameWidth() - cursorX < 47.0f && _scene._x + g_ngi->gameWidth() + margin < _scene._dims.x - 1)
return 1;
- if (cursorX - scene._x < 47.0f && scene._x - marginX > 0.0f)
+ if (cursorX - _scene._x < 47.0f && _scene._x - margin > 0.0f)
return cursorY > 60.0f ? -1 : 0;
return 0;
}
+// CFPController::UpdateScroll (virtual, the scene controllers call it at their end)
+void FPController::updateScroll() {
+ if (_follow && (_follow != hero() || _smooth || !touchScroll()) && !_touching && !_swiped)
+ defaultScroll();
+}
+
// CFPController::DefaultScroll
-void defaultScroll(Scene &scene) {
- const AniObject *hero = g_ngi->_aniMan;
- if (!hero) {
- limitScroll(scene);
+void FPController::defaultScroll() {
+ if (!_follow) {
+ limitScroll();
return;
}
- const Common::Point center = hero->getCenter();
- const float cursorX = g_ngi->_mouseScreenPos.x + scene._x;
- const float cursorY = g_ngi->_mouseScreenPos.y + scene._y;
- const bool free = scene._motionController && !g_ngi->_currSelectedInventoryItemId;
- const float marginX = cameraMarginX(scene);
+ const float margin = marginX();
+ const Common::Point center = _follow->getCenter();
+ _heroCenterX = center.x;
+ _heroCenterY = center.y;
+ const float cx = cursorX();
+ const float cy = cursorY();
+ const bool free = _scene._motionController && !g_ngi->_currSelectedInventoryItemId;
bool edge = false;
+ const int viewWidth = g_ngi->gameWidth();
+ const int viewHeight = g_ngi->_backgroundSurface.h;
- const int border = checkBorders(scene, cursorX, cursorY);
+ const int border = checkBorders(cx, cy);
if (border == 1) {
- if (scene._x + cameraViewWidth() - marginX - center.x < 500.0f && free) {
- g_camera.targetX += 3.0f;
- if (g_camera.targetX + scene._x + cameraViewWidth() + marginX >= scene._dims.x)
- g_camera.targetX = 0;
+ if (_scene._x + viewWidth - margin - _heroCenterX < 500.0f && free) {
+ _targetX += 3.0f;
+ if (_targetX + _scene._x + viewWidth + margin >= _scene._dims.x)
+ _targetX = 0;
}
edge = true;
}
if (border == -1) {
- if (center.x - scene._x + marginX < 500.0f && free) {
- g_camera.targetX -= 3.0f;
- if (g_camera.targetX + scene._x <= marginX)
- g_camera.targetX = 0;
+ if (_heroCenterX - _scene._x + margin < 500.0f && free) {
+ _targetX -= 3.0f;
+ if (_targetX + _scene._x <= margin)
+ _targetX = 0;
}
- limitScroll(scene);
+ limitScroll();
return;
}
if (edge) {
- limitScroll(scene);
+ limitScroll();
return;
}
- if (g_camera.scrollX && isScrollXScene(scene)) {
- if (center.x >= scene._x - marginX + g_camera.marginX) {
- if (center.x > scene._x + cameraViewWidth() + marginX - g_camera.marginX)
- g_camera.targetX = center.x - (scene._x + cameraViewWidth() + marginX) + g_camera.offsetX;
+ if (_scrollX && isScrollXScene()) {
+ if (_heroCenterX >= _scene._x - margin + _marginX) {
+ if (_heroCenterX > _scene._x + viewWidth + margin - _marginX)
+ _targetX = _heroCenterX - (_scene._x + viewWidth + margin) + _offsetX;
} else {
- g_camera.targetX = center.x - scene._x + marginX - g_camera.offsetX;
+ _targetX = _heroCenterX - _scene._x + margin - _offsetX;
}
}
- if (g_camera.scrollY && isScrollYScene(scene)) {
- if (center.y >= scene._y + g_camera.marginY) {
- if (center.y > scene._y + cameraViewHeight() - g_camera.marginY)
- g_camera.targetY = center.y - (scene._y + cameraViewHeight()) + g_camera.offsetY;
+ if (_scrollY && isScrollYScene()) {
+ if (_heroCenterY >= _scene._y + _marginY) {
+ if (_heroCenterY > _scene._y + viewHeight - _marginY)
+ _targetY = _heroCenterY - (_scene._y + viewHeight) + _offsetY;
} else {
- g_camera.targetY = center.y - scene._y - g_camera.offsetY;
+ _targetY = _heroCenterY - _scene._y - _offsetY;
+ }
+ }
+ limitScroll();
+}
+
+// CFPController::TouchScroll
+bool FPController::touchScroll() {
+ if (_touching) {
+ _targetX = _scene._x;
+ _targetY = _scene._y;
+ const float screenX = cursorX() - _scene._x;
+ const float screenY = cursorY() - _scene._y;
+ if (isScrollXScene()) {
+ const float dx = screenX - _touchOffsetX;
+ if (fabsf(dx) > fabsf(screenY - _touchOffsetY))
+ _targetX = _touchCameraX - dx;
}
+ if (fabsf(_scene._x - _targetX) > 0.0f)
+ _dragged = true;
+ if (_targetX >= 0.0f && !(_scene._dims.x < _targetX + g_ngi->gameWidth())) {
+ _scene._x = (int)_targetX;
+ _scene._y = (int)_targetY;
+ } else {
+ const float dx = _targetX - _scene._x;
+ const float dy = _targetY - _scene._y;
+ _targetX = _scene._x + dx / (g_ngi->gameWidth() / 102.0f);
+ _targetY = dy + _scene._y;
+ _scene._x = (int)_targetX;
+ _scene._y = (int)_targetY;
+ _touchOffsetX = screenX;
+ _touchOffsetY = screenY;
+ _touchCameraX = _scene._x;
+ _touchCameraY = _scene._y;
+ }
+ _targetX = 0;
+ _targetY = 0;
+ return true;
+ }
+
+ float limit = _scene._dims.x;
+ float lowest = 0;
+ if (g_ngi->gameWidth() < _scene._dims.x) {
+ lowest = g_ngi->_wideOfs + 0.0f;
+ limit -= g_ngi->_wideOfs;
}
- limitScroll(scene);
+ if (limit < _scene._x + g_ngi->gameWidth()) {
+ float step = (fabsf(_scene._x - limit + g_ngi->gameWidth()) * 5.0f) / 102.0f;
+ if (step < 0.5f)
+ step = 0.5f;
+ _scene._x = (int)(_scene._x - step);
+ _targetX = 0;
+ if (_scene._x < limit - g_ngi->gameWidth())
+ _scene._x = (int)(limit - g_ngi->gameWidth());
+ return true;
+ }
+ if (_scene._x < lowest) {
+ float step = (fabsf(_scene._x - lowest) * 5.0f) / 102.0f;
+ if (step < 0.5f)
+ step = 0.5f;
+ _scene._x = (int)(_scene._x + step);
+ _targetX = 0;
+ if (_scene._x > lowest)
+ _scene._x = (int)lowest;
+ return true;
+ }
+ return false;
}
// CFPController::TestScroll: at most 3 pixels towards the target, the camera stops at the ends of the scene
-void testScroll(Scene &scene) {
- if (g_camera.targetX == 0.0f && g_camera.targetY == 0.0f)
+void FPController::testScroll() {
+ if (_targetX == 0.0f && _targetY == 0.0f)
return;
float dx = 0.0f;
float dy = 0.0f;
- const float marginX = cameraMarginX(scene);
- if (g_camera.targetX > 0.0f) {
- if (scene._x + cameraViewWidth() + marginX == scene._dims.x)
- g_camera.targetX = 0;
- dx = g_camera.targetX;
+ const float margin = marginX();
+ if (_targetX > 0.0f) {
+ if (_scene._x + g_ngi->gameWidth() + margin == _scene._dims.x)
+ _targetX = 0;
+ dx = _targetX;
if (dx >= 3.0f) {
dx = 3.0f;
- g_camera.targetX -= 3.0f;
+ _targetX -= 3.0f;
} else {
- g_camera.targetX = 0;
+ _targetX = 0;
}
- } else if (g_camera.targetX < 0.0f) {
- if (scene._x == marginX)
- g_camera.targetX = 0;
- dx = g_camera.targetX;
+ } else if (_targetX < 0.0f) {
+ if (_scene._x == margin)
+ _targetX = 0;
+ dx = _targetX;
if (dx <= -3.0f) {
dx = -3.0f;
- g_camera.targetX += 3.0f;
+ _targetX += 3.0f;
} else {
- g_camera.targetX = 0;
+ _targetX = 0;
}
}
- if (g_camera.targetY > 0.0f) {
- if (scene._y + cameraViewHeight() == scene._dims.y)
- g_camera.targetY = 0;
- if (g_camera.targetY >= 3.0f) {
+ if (_targetY > 0.0f) {
+ if (_scene._y + g_ngi->_backgroundSurface.h == _scene._dims.y)
+ _targetY = 0;
+ if (_targetY >= 3.0f) {
dy = 3.0f;
- g_camera.targetY -= 3.0f;
+ _targetY -= 3.0f;
} else {
- g_camera.targetY = 0;
+ _targetY = 0;
}
- } else if (g_camera.targetY < 0.0f) {
- if (scene._y == 0)
- g_camera.targetY = 0;
- if (g_camera.targetY <= -3.0f) {
+ } else if (_targetY < 0.0f) {
+ if (_scene._y == 0)
+ _targetY = 0;
+ if (_targetY <= -3.0f) {
dy = -3.0f;
- g_camera.targetY += 3.0f;
+ _targetY += 3.0f;
} else {
- g_camera.targetY = 0;
+ _targetY = 0;
}
}
- scene._x += static_cast<int>(dx);
- scene._y += static_cast<int>(dy);
+ _scene._x += static_cast<int>(dx);
+ _scene._y += static_cast<int>(dy);
}
-} // End of anonymous namespace
+// CFPController::OnUpdate, the camera part: every 10 ms UpdateScroll, TestScroll unless touching
+void FPController::updateCamera(uint32 elapsed) {
+ checkQueues();
+ _elapsed += elapsed;
+ const int oldX = _scene._x;
+ const int oldY = _scene._y;
+ while (_elapsed > 10) {
+ _elapsed -= 10;
+ // virtual UpdateScroll of the scene controller
+ if (_scene._scrollHook)
+ _scene._scrollHook(_scene);
+ else
+ updateScroll();
+ if (_follow != hero() || _smooth || (!_touching && !_swiped))
+ testScroll();
+ }
+ testSwipe();
+ if (_scene._x != oldX || _scene._y != oldY) {
+ debugC(2, kDebugSceneLogic, "camera %d -> %d (target %g, follow %d)", oldX, _scene._x, _targetX, _follow != nullptr);
+ g_ngi->_sceneRect.moveTo(_scene._x, _scene._y);
+ }
+}
-// CFPController::OnShow, the camera part: a scene entered through an entrance starts at its top left corner, a scene wider than the game
-// area at the widescreen margin (CRender +24, +28), so the whole screen is inside the scene
-void sceneCamera_onShow(Scene &scene, int entranceId) {
- g_camera = Camera();
- if (entranceId) {
- scene._x = cameraMarginX(scene);
- scene._y = 0;
+// CFPController::CanInterruptManQueue; not ported: CMessageQueue::CanInterrupt (interrupt state)
+bool FPController::canInterruptManQueue() const {
+ return hero() && !hero()->_messageQueueId;
+}
+
+// CFPController::CheckQueues (hero's queue part: +72, +76, +88, +192) and the swipe flag (+212)
+void FPController::checkQueues() {
+ if (hero() && !hero()->_messageQueueId) {
+ _lastTargetX = 0;
+ _lastTargetY = 0;
+ _interactObjectId = 0;
+ _swipeDirection = 0;
+ _swiped = false;
}
- g_ngi->_sceneRect.moveTo(scene._x, scene._y);
+}
- // CFPController::EnableArcadeButton(IsCheater): the "Arcade" button of scenes 4, 8 and 11 is only there for a cheater (there is no cheat mode here)
- if (PictureObject *button = scene.findPictureObjectById(PIC_SC8_ARCADENOW, 0))
- button->_flags &= ~4;
+// CFPController::CheckTry
+bool FPController::checkTry() const {
+ return !g_ngi->_currSelectedInventoryItemId && hero() && g_ngi->_aniHandler->isObjectAttached(hero()->_id) && canInterruptManQueue();
}
-// CFPController::UpdateScroll: the camera follows the hero unless a scene controller took it over (no tutorial or dragging here)
-void sceneCamera_updateScroll(Scene &scene) {
- if (g_camera.followHero)
- defaultScroll(scene);
+// CFPController::MctlStartMove
+MessageQueue *FPController::mctlStartMove(int x, int y, bool fuzzy, int staticsId, bool mirror) {
+ checkQueues();
+ MotionController *controller = _scene._motionController.get();
+ if (controller && (fuzzy || controller->_isEnabled) && canInterruptManQueue()) {
+ MessageQueue *queue = controller->startMove(hero(), x, y, fuzzy, staticsId, mirror);
+ if (queue) {
+ _lastTargetX = x;
+ _lastTargetY = y;
+ return queue;
+ }
+ _failedTargetX = x;
+ _failedTargetY = y;
+ }
+ return nullptr;
}
-// CFPController::OnUpdate, the camera part
-void sceneCamera_update(Scene &scene, uint32 elapsed) {
- g_camera.elapsed += elapsed;
- const int oldX = scene._x;
- const int oldY = scene._y;
- while (g_camera.elapsed > 10) {
- g_camera.elapsed -= 10;
- // CFPController::UpdateScroll (virtual: CSc04Controller::UpdateScroll ...), then TestScroll
- if (scene._scrollHook)
- scene._scrollHook(scene);
+// CFPController::TrySwipeMan: when the point is not reachable, goes to the nearest one on the graph
+bool FPController::trySwipeMan(float x, float y, bool nearest) {
+ if ((x != _lastTargetX || y != _lastTargetY) && checkTry()) {
+ const Common::Point center = hero()->getCenter();
+ if (_scene._motionController->checkPoint(center.x, center.y)) {
+ if (mctlStartMove((int)x, (int)y, false, 0, false))
+ return true;
+ if (nearest) {
+ const Common::Point point = _scene._motionController->getNearestWalkPoint((int)x, (int)y);
+ if (point.x != -1 && point.y != -1)
+ return mctlStartMove(point.x, point.y, false, 0, false) != nullptr;
+ }
+ }
+ }
+ return false;
+}
+
+// CFPController::CalcFinPoint
+void FPController::calcFinPoint(float &outX, float &outY) {
+ MotionController *controller = _scene._motionController.get();
+ float x = 0;
+ float y = 0;
+ float px = 0;
+ const int viewWidth = g_ngi->gameWidth();
+ const int viewHeight = g_ngi->_backgroundSurface.h;
+ auto nearestPoint = [&](float nx, float ny) {
+ const Common::Point point = controller->getNearestWalkPoint((int)nx, (int)ny);
+ return point;
+ };
+
+ if (_scene._x >= 0.0f) {
+ if (_scene._dims.x >= _scene._x + viewWidth) {
+ // the scene is not at its right end: the middle of the screen
+ const Common::Point point = nearestPoint(_scene._x + viewWidth * 0.5f, _scene._y + viewHeight * 0.5f);
+ px = point.x;
+ y = point.y;
+ _swipeDirection = 0;
+ } else {
+ if (!_hasRightBorder) {
+ const Common::Point point = nearestPoint(_scene._dims.x, _scene._y + viewHeight * 0.5f);
+ px = point.x;
+ y = point.y;
+ } else {
+ x = _rightBorderX;
+ y = _rightBorderY;
+ px = x - 1.0f;
+ }
+ _swipeDirection = 1;
+ }
+ } else {
+ if (!_hasLeftBorder) {
+ const Common::Point point = nearestPoint(0, _scene._y + viewHeight * 0.5f);
+ px = point.x;
+ y = point.y;
+ } else {
+ x = _leftBorderX;
+ y = _leftBorderY;
+ px = x + 1.0f;
+ }
+ _swipeDirection = -1;
+ }
+ const Common::Point point = nearestPoint(px, y);
+ outX = point.x;
+ outY = point.y;
+}
+
+// CFPController::MoveBorders
+bool FPController::moveBorders(float x, float y) {
+ if (!_follow)
+ return false;
+ const Common::Point center = _follow->getCenter();
+ _heroCenterX = center.x;
+ _heroCenterY = center.y;
+ MotionController *controller = _scene._motionController.get();
+ const bool active = controller && controller->_isEnabled && !g_ngi->_currSelectedInventoryItemId;
+ if (x <= _heroCenterX) {
+ if (_leftBorderX < x || _leftBorderX < _heroCenterX) {
+ if (y > 60.0f && active)
+ return mctlStartMove((int)_leftBorderX, (int)_leftBorderY, false, 0, false) != nullptr;
+ }
+ return false;
+ }
+ if (!(_rightBorderX > x) && !(_rightBorderX > _heroCenterX))
+ return false;
+ if (!active)
+ return false;
+ return mctlStartMove((int)_rightBorderX, (int)_rightBorderY, false, 0, false) != nullptr;
+}
+
+// CFPController::TryStartInteractMan (SwipeState)
+bool FPController::tryStartInteractMan() {
+ const float margin = marginX();
+ if (!checkTry())
+ return false;
+ if (_swipeDirection == -1) {
+ if (!(margin > _scene._x))
+ return false;
+ } else if (_swipeDirection == 1) {
+ if (!(_scene._x + g_ngi->gameWidth() > _scene._dims.x - margin))
+ return false;
+ } else {
+ return false;
+ }
+ const Common::Point center = hero()->getCenter();
+ const float x = _swipeDirection == -1 ? 2.0f : _scene._dims.x - 2.0f;
+ // CInteractionController::FindInteraction(x, y), CInteract::Run: the object at the edge is handled like a tap on it
+ GameObject *target = _scene.findPictureObjectAtPos((int)x, center.y);
+ AniObject *actor = _scene.findAniObjectAtPos((int)x, center.y);
+ if (actor && (!target || actor->_z < target->_z))
+ target = actor;
+ if (!target || !canInteractAny(hero(), target, 0))
+ return false;
+ if (target->_id != _interactObjectId)
+ handleObjectInteraction(hero(), target, 0);
+ _interactObjectId = target->_id;
+ _swipeDirection = _swipeDirection == -1 ? -2 : 2;
+ _swipeWalking = true;
+ return true;
+}
+
+// CFPController::TestSwipe
+void FPController::testSwipe() {
+ if (_scene._sceneId != g_ngi->_currentScene->_sceneId)
+ return;
+ // CanSwipeMan (virtual, true in the base class)
+ if (_scene._canSwipeManHook && !_scene._canSwipeManHook())
+ return;
+ if (!hero())
+ return;
+ if (_swipeDirection >= -1 && _swipeDirection <= 1) {
+ const Common::Point center = hero()->getCenter();
+ if (_swipeThreshold > fabsf(static_cast<float>(center.x)))
+ _swipeDirection = -1;
+ else if (_swipeThreshold > fabsf(static_cast<float>(_scene._dims.x - center.x)))
+ _swipeDirection = 1;
else
- sceneCamera_updateScroll(scene);
- testScroll(scene);
+ _swipeDirection = 0;
}
- if (scene._x != oldX || scene._y != oldY) {
- debugC(2, kDebugSceneLogic, "camera %d -> %d (target %g, follow %d)", oldX, scene._x, g_camera.targetX, g_camera.followHero);
- g_ngi->_sceneRect.moveTo(scene._x, scene._y);
+ if (_swipeDirection == 0) {
+ if (_scene._x < 0.0f || _scene._dims.x < _scene._x + g_ngi->gameWidth())
+ _swipeWalking = false;
}
+ if (!_swipeWalking && _touching) {
+ if (fabsf(_touchX - cursorX()) > 5.0f || fabsf(_touchStartCameraX - _scene._x) > 5.0f)
+ tryStartInteractMan();
+ }
+}
+
+// CFPController::OnMouseLKeyDown, the part after the exit manager and the achievements: the touch starts (CanSwipeMan)
+bool FPController::onMouseLKeyDown(float x, float y) {
+ if (_scene._canSwipeManHook && !_scene._canSwipeManHook())
+ return false;
+ _touching = true;
+ _swipeWalking = false;
+ _touchOffsetX = x - _scene._x;
+ _touchOffsetY = y - _scene._y;
+ _touchCameraX = _scene._x;
+ _touchCameraY = _scene._y;
+ _touchX = x;
+ _touchY = y;
+ _touchStartCameraX = _scene._x;
+ _touchStartCameraY = _scene._y;
+ return true;
+}
+
+// CFPController::OnMouseLKeyUp, the last part: a tap on the scene when no interaction is under the cursor and no item is on the cursor. At the
+// edge of the screen the hero goes to the border of the scene (CheckBorders, MoveBorders), else to the point, when it is more than 30 pixels
+// from the last target (CFPController::MctlStartMove with fuzzy 0, the motion controller decides what is reachable).
+bool FPController::onTapWalk(float x, float y) {
+ MotionController *controller = _scene._motionController.get();
+ if (_swiped || !controller || !controller->_isEnabled || g_ngi->_currSelectedInventoryItemId || _interactObjectId)
+ return false;
+ if (checkBorders(x, y) != 0)
+ return moveBorders(x, y);
+ if (fabsf(x - _lastTargetX) > 30.0f || fabsf(y - _lastTargetY) > 30.0f)
+ return mctlStartMove((int)x, (int)y, false, 0, false) != nullptr;
+ return false;
+}
+
+// CFPController::OnMouseLKeyUp, the first part: after a drag of the scene beyond 5 pixels the hero is sent to the point at the end of the scene
+// (CalcFinPoint, TrySwipeMan); the touch is over. The result is true when the touch was a scroll or a swipe, so no tap follows.
+bool FPController::onMouseLKeyUpSwipe(float x, float y) {
+ bool handled = false;
+ if (!_scene._canSwipeManHook || _scene._canSwipeManHook()) {
+ if (_follow != hero() || _smooth || g_ngi->_currSelectedInventoryItemId) {
+ handled = false;
+ } else {
+ if (fabsf(_touchStartCameraX - _scene._x) > 5.0f && !_interactObjectId) {
+ if (g_ngi->gameWidth() < _scene._dims.x) {
+ _swiped = true;
+ // CTutorialManager::FinishTutorial("EXTRA_TUTORIAL_USE_SWIPE") is not ported
+ float px = 0;
+ float py = 0;
+ calcFinPoint(px, py);
+ if (fabsf(px - _lastTargetX) > 50.0f)
+ _swipeWalking = trySwipeMan(px, py, true);
+ }
+ }
+ handled = _dragged;
+ }
+ _touchOffsetX = _touchOffsetY = -1;
+ _touchCameraX = _touchCameraY = -1;
+ _touchStartCameraX = _touchStartCameraY = -1;
+ _touchX = _touchY = -1;
+ }
+ _touching = false;
+ _dragged = false;
+ return handled;
+}
+
+void FPController::setFollowHero(bool follow) {
+ _follow = follow ? hero() : nullptr;
+}
+
+// the functions of the scene controllers and the engine, for the current scene
+void sceneCamera_onShow(Scene &scene, int entranceId) {
+ sceneController(scene).onShow(entranceId);
+}
+
+void sceneCamera_update(Scene &scene, uint32 elapsed) {
+ sceneController(scene).updateCamera(elapsed);
+}
+
+void sceneCamera_updateScroll(Scene &scene) {
+ sceneController(scene).updateScroll();
+}
+
+void sceneCamera_setFollowHero(bool follow) {
+ sceneController(*g_ngi->_currentScene).setFollowHero(follow);
+}
+
+void sceneCamera_setScrollTarget(float dx) {
+ sceneController(*g_ngi->_currentScene).setScrollTarget(dx);
+}
+
+bool sceneCamera_updateCmdScroll(const Command *cmd) {
+ return sceneController(*g_ngi->_currentScene).updateCmdScroll(cmd);
}
// CFPController::OnMouseLKeyUp (a tap) of every scene of an XML project: an interaction of the object under the finger, else the hero
@@ -454,6 +848,7 @@ bool sceneController_click(Common::Point pos) {
return false;
if (scene._clickHook && scene._clickHook(pos))
return true;
+ FPController &fp = sceneController(scene);
pos += Common::Point(scene._x, scene._y);
PictureObject *picture = scene.findPictureObjectAtPos(pos.x, pos.y);
AniObject *actor = scene.findAniObjectAtPos(pos.x, pos.y);
@@ -477,19 +872,7 @@ bool sceneController_click(Common::Point pos) {
return handleObjectInteraction(hero, target, item);
}
}
- // CFPController::TrySwipeMan (a tap): only while the hero is on the graph; when the point cannot be walked to, the nearest
- // point of the graph is tried
- MotionController *controller = scene._motionController.get();
- if (g_ngi->_gameVersion >= 201509 && !controller->checkPoint(hero->_x, hero->_y))
- return false;
- if (controller->startMove(hero, pos.x, pos.y, 0, 0))
- return true;
- if (g_ngi->_gameVersion < 201509)
- return false;
- const Common::Point nearest = controller->getNearestWalkPoint(pos.x, pos.y);
- if (nearest.x == -1 && nearest.y == -1)
- return false;
- return controller->startMove(hero, nearest.x, nearest.y, 0, 0) != nullptr;
+ return fp.onTapWalk(pos.x, pos.y);
}
// CFPController::OnRenderBottom
diff --git a/engines/ngi/fullpipe/fpcontroller.h b/engines/ngi/fullpipe/fpcontroller.h
new file mode 100644
index 00000000000..99c79d262a5
--- /dev/null
+++ b/engines/ngi/fullpipe/fpcontroller.h
@@ -0,0 +1,142 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_FPCONTROLLER_H
+#define NGI_FULLPIPE_FPCONTROLLER_H
+
+#include "common/scummsys.h"
+
+namespace NGI {
+
+class AniObject;
+class Command;
+class MessageQueue;
+class Scene;
+
+/** CFPController: base of the scene controllers; offsets in the comments are the original's */
+class FPController {
+public:
+ explicit FPController(Scene &scene);
+ virtual ~FPController() {}
+
+ // CFPController::OnShow, the camera part, and EnableArcadeButton
+ void onShow(int entranceId);
+ // CFPController::OnUpdate, the camera loop: UpdateScroll, TestScroll every 10 ms, then TestSwipe
+ void updateCamera(uint32 elapsed);
+
+ // the camera
+ void updateScroll();
+ void defaultScroll();
+ bool touchScroll();
+ void testScroll();
+ void limitScroll();
+ int checkBorders(float cursorX, float cursorY) const;
+ bool isScrollXScene() const;
+ bool isScrollYScene() const;
+ /** CFPController::ExecCmdScroll */
+ void execCmdScroll(Command *cmd);
+ /** CFPController::UpdateCmdScroll: true while the camera moves to the command's point */
+ bool updateCmdScroll(const Command *cmd);
+
+ // swipe walking (touch)
+ void resetSwipeParams();
+ void testSwipe();
+ bool trySwipeMan(float x, float y, bool nearest);
+ bool tryStartInteractMan();
+ bool checkTry() const;
+ /** CFPController::CheckQueues: forgets targets and interaction when the hero has no queue */
+ void checkQueues();
+ bool canInterruptManQueue() const;
+ bool moveBorders(float x, float y);
+ void calcFinPoint(float &x, float &y);
+ void initBorders();
+ /** CFPController::MctlStartMove */
+ MessageQueue *mctlStartMove(int x, int y, bool fuzzy, int staticsId, bool mirror);
+
+ // mouse (the touch of the original: the position is in scene coordinates)
+ bool onMouseLKeyDown(float x, float y);
+ /** The swipe part of CFPController::OnMouseLKeyUp; true when the touch was a swipe or a scroll and must not be handled as a tap */
+ bool onMouseLKeyUpSwipe(float x, float y);
+ /** The last part of CFPController::OnMouseLKeyUp: the tap walks the hero */
+ bool onTapWalk(float x, float y);
+
+ /** The camera fields that a scene controller changes (CSc04Controller::UpdateScroll ...) */
+ void setFollowHero(bool follow);
+ void setScrollTarget(float dx) { _smooth = true; _targetX = dx; }
+ void scrollTo(float dx, float dy) { _targetX = dx; _targetY = dy; _smooth = true; }
+ bool isTouching() const { return _touching; }
+ bool wasDragged() const { return _dragged; }
+
+private:
+ AniObject *hero() const;
+ float cursorX() const;
+ float cursorY() const;
+ float marginX() const;
+
+ Scene &_scene;
+
+ float _heroCenterX = 0; // +28
+ float _heroCenterY = 0; // +32
+ // +36..+48: margins and offsets set by the scene controllers, 0 in the base
+ float _marginX = 0;
+ float _marginY = 0;
+ float _offsetX = 0;
+ float _offsetY = 0;
+ float _targetX = 0; // +52: the scroll target, relative to the camera
+ float _targetY = 0; // +56
+ AniObject *_follow = nullptr; // +60: camera target (the hero), 0 when a scene moves the camera
+ bool _scrollX = true; // +64
+ bool _scrollY = true; // +65
+ uint32 _elapsed = 0; // +68: the time that is not used yet, 10 ms per step
+ float _lastTargetX = 0; // +72: where the hero was sent last
+ float _lastTargetY = 0; // +76
+ float _failedTargetX = 0; // +80: where the hero could not be sent
+ float _failedTargetY = 0; // +84
+ int _interactObjectId = 0; // +88: the object of the interaction under the cursor
+ bool _hasLeftBorder = false; // +120: swipe target points of the borders (key -1 left, 1 right)
+ bool _hasRightBorder = false;
+ float _leftBorderX = 0;
+ float _leftBorderY = 0;
+ float _rightBorderX = 0;
+ float _rightBorderY = 0;
+ bool _touching = false; // +150: the button is down
+ bool _dragged = false; // +151: the camera was moved while the button was down
+ float _touchOffsetX = -1; // +152, +156: the touch relative to the camera
+ float _touchOffsetY = -1;
+ float _touchCameraX = -1; // +160, +164: the camera when the button went down
+ float _touchCameraY = -1;
+ float _touchX = -1; // +168, +172: the touch (scene coordinates)
+ float _touchY = -1;
+ float _touchStartCameraX = -1; // +176, +180
+ float _touchStartCameraY = -1;
+ float _swipeThreshold = 310; // +184
+ bool _smooth = false; // +188: a SET_SCROLL command with scroll=1 is moving the camera
+ bool _swipeWalking = false; // +189: the hero walks to the end of the scene
+ int _swipeDirection = 0; // +192: -1 left, 1 right, 0 none
+ bool _swiped = false; // +212: a swipe was made, the tap is not handled
+};
+
+/** The controller of the scene (created when needed) */
+FPController &sceneController(Scene &scene);
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_FPCONTROLLER_H
diff --git a/engines/ngi/fullpipe/scene04.cpp b/engines/ngi/fullpipe/scene04.cpp
index 6c8efce7c9b..33fb3e06053 100644
--- a/engines/ngi/fullpipe/scene04.cpp
+++ b/engines/ngi/fullpipe/scene04.cpp
@@ -53,6 +53,7 @@ void sceneHandler04_putKozyawkaBack(AniObject *ani);
static bool scene04_click(Common::Point pos);
static void scene04_render(Scene &scene);
static void scene04_updateScroll(Scene &scene);
+static bool scene04_canSwipeMan();
static void scene04_startArcade();
static void scene04_stopArcade();
static void scene04_winArcade();
@@ -282,6 +283,7 @@ void scene04_initScene(Scene *sc) {
sc->_clickHook = scene04_click;
sc->_renderHook = scene04_render;
sc->_scrollHook = scene04_updateScroll;
+ sc->_canSwipeManHook = scene04_canSwipeMan;
g_vars->scene04_cameraLocked = false;
g_vars->scene04_demoScroll = false;
g_vars->scene04_hintPending = false;
@@ -306,6 +308,11 @@ static void scene04_render(Scene &scene) {
g_ngi->arcadeInterface().render();
}
+// CSc04Controller::CanSwipeMan: not while the camera is held
+static bool scene04_canSwipeMan() {
+ return !g_vars->scene04_cameraLocked;
+}
+
// CSc04Controller::UpdateScroll: while the arcade runs or the hand moves, the camera is held at x 380 (the jar, the plank and the ladder
// are in view); the camera follows the hero again when neither the ladder nor the arcade are used and no demo scroll is running
static void scene04_updateScroll(Scene &scene) {
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 02c7f38e669..93714732573 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -34,6 +34,7 @@
#include "ngi/ngi.h"
#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/fpcontroller.h"
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/taskmanager.h"
@@ -300,6 +301,15 @@ Common::Error NGIEngine::initGame() {
}
bool NGIEngine::handleGuiEvent(const Common::Event &event) {
+ // CCursorController::OnMouseMove: the cursor is the last touch (no hover on the device),
+ // updated while the button is down; the scene controllers read it
+ if (event.type == Common::EVENT_LBUTTONDOWN)
+ _touchDown = true;
+ if (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_LBUTTONUP || event.type == Common::EVENT_RBUTTONDOWN ||
+ event.type == Common::EVENT_RBUTTONUP || (event.type == Common::EVENT_MOUSEMOVE && _touchDown))
+ _mouseScreenPos = event.mouse;
+ if (event.type == Common::EVENT_LBUTTONUP)
+ _touchDown = false;
if (event.type == Common::EVENT_SCREEN_CHANGED) {
return true;
} else if (_modalObject) {
@@ -345,9 +355,15 @@ bool NGIEngine::handleGuiEvent(const Common::Event &event) {
}
}
}
- if (event.type == Common::EVENT_LBUTTONUP && (!manager || !manager->hit(event.mouse)) &&
- usesXMLProject() && _currentScene->_sceneId != SC_INTRO1)
- return sceneController_click(event.mouse);
+ // CFPController::OnMouseLKeyDown/Up: the touch scrolls the scene or sends the hero to its end
+ const bool sceneTouch = usesXMLProject() && _currentScene->_sceneId != SC_INTRO1;
+ if (sceneTouch && event.type == Common::EVENT_LBUTTONDOWN && (!manager || !manager->hit(event.mouse)))
+ sceneController(*_currentScene).onMouseLKeyDown(event.mouse.x + _currentScene->_x, event.mouse.y + _currentScene->_y);
+ bool swiped = false;
+ if (sceneTouch && event.type == Common::EVENT_LBUTTONUP)
+ swiped = sceneController(*_currentScene).onMouseLKeyUpSwipe(event.mouse.x + _currentScene->_x, event.mouse.y + _currentScene->_y);
+ if (event.type == Common::EVENT_LBUTTONUP && (!manager || !manager->hit(event.mouse)) && sceneTouch)
+ return !swiped && sceneController_click(event.mouse);
if (!manager)
return false;
GuiManager &gui = *manager;
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index ed5d7596a21..dc1a35c8928 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -302,6 +302,7 @@ public:
int _mouseVirtX;
int _mouseVirtY;
Common::Point _mouseScreenPos;
+ bool _touchDown = false; // Android: the left button is down (the touch)
Common::ScopedPtr<BehaviorController> _behaviorManager;
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 55c19297d9d..db1e5e0bb1b 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -22,6 +22,7 @@
#include "math/utils.h"
#include "ngi/ngi.h"
+#include "ngi/fullpipe/fpcontroller.h"
#include "ngi/objects.h"
#include "ngi/behavior.h"
@@ -252,6 +253,8 @@ void Scene::onGuiEvent(const Common::String &id, const Common::String &event) {
}
Scene::~Scene() {
+ delete _fpController;
+
if (_guiManager)
_guiManager->unload();
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 04a96bd8c9e..f4e0058b3e8 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -99,6 +99,10 @@ class Scene : public Background {
bool (*_clickHook)(Common::Point) = nullptr;
/** CScNNController::UpdateScroll: replaces the default scroll of CFPController, it ends with sceneCamera_updateScroll() */
void (*_scrollHook)(Scene &) = nullptr;
+ /** CScNNController::CanSwipeMan: false while the scene controller does not want the touch to scroll or swipe */
+ bool (*_canSwipeManHook)() = nullptr;
+ /** CFPController, created by sceneController() */
+ class FPController *_fpController = nullptr;
void (*_guiEventHandler)(Scene &, const Common::String &, const Common::String &) = nullptr;
void onGuiEvent(const Common::String &id, const Common::String &event);
Common::Array<MessageQueue *> _messageQueues;
Commit: c6c8c83d48646033d18540e5e3201cf8c71ce9dc
https://github.com/scummvm/scummvm/commit/c6c8c83d48646033d18540e5e3201cf8c71ce9dc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Add ISceneController and the controller classes of the scenes, replace the scene hooks with virtual methods
Changed paths:
A engines/ngi/fullpipe/sc03controller.h
A engines/ngi/fullpipe/sc04controller.h
A engines/ngi/fullpipe/scenecontrollers.cpp
A engines/ngi/fullpipe/scenecontrollers.h
A engines/ngi/scenecontroller.cpp
A engines/ngi/scenecontroller.h
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/fpcontroller.h
engines/ngi/fullpipe/scene03.cpp
engines/ngi/fullpipe/scene04.cpp
engines/ngi/fullpipe/sceneTutorial.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/messages.cpp
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/physics.cpp
engines/ngi/scene.cpp
engines/ngi/scene.h
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 52fa41061c0..bdbff63d712 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -161,11 +161,6 @@ void executeUserCommand(Command *cmd) {
namespace {
-// The scenes whose controllers set the margins and offsets of the camera in their constructors (CSc02Controller::CSc02Controller ...): 300, 200, 400, 300
-const int kScrollingControllers[] = {
- SC_2, SC_3, SC_4, SC_6, SC_9, SC_11, SC_13, SC_16, SC_18, SC_19, SC_21, SC_22, SC_27, SC_28, SC_29, SC_32, SC_33, SC_34, SC_35, SC_37, SC_38
-};
-
// CFPController::ExecCmdScroll helper
float floatParam(const Command *cmd, const char *name, float defaultValue) {
return cmd->_args.contains(name) ? strtof(cmd->_args[name].c_str(), nullptr) : defaultValue;
@@ -178,21 +173,15 @@ bool boolParam(const Command *cmd, const char *name) {
} // End of anonymous namespace
+// CGame::AssignController; made at first use of the scene (the original: all at the start)
FPController &sceneController(Scene &scene) {
- if (!scene._fpController)
- scene._fpController = new FPController(scene);
- return *scene._fpController;
-}
-
-FPController::FPController(Scene &scene) : _scene(scene) {
- for (int id : kScrollingControllers) {
- if (id == scene._sceneId) {
- _marginX = 300;
- _marginY = 200;
- _offsetX = 400;
- _offsetY = 300;
- }
- }
+ if (!scene._controller)
+ createSceneController(scene._sceneId); // registers itself in the scene
+ return static_cast<FPController &>(*scene._controller);
+}
+
+// CFPController::CFPController; margins and offsets (+36 ... +48) are set by each OnShow
+FPController::FPController(int sceneId) : ISceneController(sceneId) {
initBorders();
}
@@ -202,32 +191,32 @@ AniObject *FPController::hero() const {
// CCursorController +72, +76: the position of the cursor in scene coordinates
float FPController::cursorX() const {
- return g_ngi->_mouseScreenPos.x + _scene._x;
+ return g_ngi->_mouseScreenPos.x + _scene->_x;
}
float FPController::cursorY() const {
- return g_ngi->_mouseScreenPos.y + _scene._y;
+ return g_ngi->_mouseScreenPos.y + _scene->_y;
}
// CRender +24 as the scroll functions read it: only a scene wider than the game area scrolls
float FPController::marginX() const {
- return _scene._dims.x > g_ngi->gameWidth() ? static_cast<float>(g_ngi->_wideOfs) : 0.0f;
+ return _scene->_dims.x > g_ngi->gameWidth() ? static_cast<float>(g_ngi->_wideOfs) : 0.0f;
}
bool FPController::isScrollXScene() const {
- return _scene._dims.x > g_ngi->gameWidth();
+ return _scene->_dims.x > g_ngi->gameWidth();
}
bool FPController::isScrollYScene() const {
- return _scene._dims.y > g_ngi->_backgroundSurface.h;
+ return _scene->_dims.y > g_ngi->_backgroundSurface.h;
}
// CFPController::OnShow, camera part; not ported: ResetSwipeParams, flurry, hints, GUI helpers
-void FPController::onShow(int entranceId) {
+void FPController::onShow() {
_follow = hero();
- if (entranceId) {
- _scene._x = marginX();
- _scene._y = 0;
+ if (_scene->_currentEntranceId) { // CScene::GetCurrentEntranceId
+ _scene->_x = marginX();
+ _scene->_y = 0;
}
_targetX = 0;
_targetY = 0;
@@ -235,9 +224,9 @@ void FPController::onShow(int entranceId) {
_touching = false;
_dragged = false;
resetSwipeParams();
- g_ngi->_sceneRect.moveTo(_scene._x, _scene._y);
+ g_ngi->_sceneRect.moveTo(_scene->_x, _scene->_y);
- if (PictureObject *button = _scene.findPictureObjectById(PIC_SC8_ARCADENOW, 0))
+ if (PictureObject *button = _scene->findPictureObjectById(PIC_SC8_ARCADENOW, 0))
button->_flags &= ~4;
}
@@ -255,7 +244,7 @@ void FPController::resetSwipeParams() {
void FPController::initBorders() {
_hasLeftBorder = _hasRightBorder = false;
GameVar *scenes = g_ngi->getGameLoaderGameVar();
- GameVar *sceneVar = scenes ? scenes->getSubVarByName(g_ngi->gameIdToStr(_scene._sceneId)) : nullptr;
+ GameVar *sceneVar = scenes ? scenes->getSubVarByName(g_ngi->gameIdToStr(_scene->_sceneId)) : nullptr;
GameVar *border = sceneVar ? sceneVar->getSubVarByName("BORDER") : nullptr;
if (!border)
return;
@@ -276,12 +265,12 @@ void FPController::initBorders() {
// CFPController::ExecCmdScroll
void FPController::execCmdScroll(Command *cmd) {
- if (_scene._pictureObjects.empty())
+ if (_scene->_pictureObjects.empty())
return;
float x = floatParam(cmd, "x", 0.0f);
float y = floatParam(cmd, "y", 0.0f);
- const Dims sceneSize = _scene._dims;
+ const Dims sceneSize = _scene->_dims;
const int viewWidth = g_ngi->gameWidth();
const int viewHeight = g_ngi->_backgroundSurface.h;
@@ -298,13 +287,13 @@ void FPController::execCmdScroll(Command *cmd) {
y = sceneSize.y - viewHeight;
}
- if (boolParam(cmd, "scroll") && &_scene == g_ngi->_currentScene) {
+ if (boolParam(cmd, "scroll") && _scene == g_ngi->_currentScene) {
// the camera moves towards the point (+52/+56), 3 pixels every 10 ms, see updateCamera
- scrollTo(x - _scene._x, y - _scene._y);
+ scrollTo(x - _scene->_x, y - _scene->_y);
} else {
- _scene._x = (int)x;
- _scene._y = (int)y;
- if (&_scene == g_ngi->_currentScene)
+ _scene->_x = (int)x;
+ _scene->_y = (int)y;
+ if (_scene == g_ngi->_currentScene)
g_ngi->_sceneRect.moveTo((int)x, (int)y);
}
@@ -314,7 +303,7 @@ void FPController::execCmdScroll(Command *cmd) {
// CFPController::UpdateCmdScroll
bool FPController::updateCmdScroll(const Command *cmd) {
- if (fabsf(_scene._x - floatParam(cmd, "x", 0.0f)) >= 3.0f || fabsf(_scene._y - floatParam(cmd, "y", 0.0f)) >= 3.0f)
+ if (fabsf(_scene->_x - floatParam(cmd, "x", 0.0f)) >= 3.0f || fabsf(_scene->_y - floatParam(cmd, "y", 0.0f)) >= 3.0f)
return true;
_smooth = false;
return false;
@@ -323,20 +312,20 @@ bool FPController::updateCmdScroll(const Command *cmd) {
// CFPController::LimitScroll
void FPController::limitScroll() {
const float margin = marginX();
- if (_scene._x < margin) {
- _scene._x = margin;
+ if (_scene->_x < margin) {
+ _scene->_x = margin;
_targetX = 0;
}
- if (_scene._y < 0) {
- _scene._y = 0;
+ if (_scene->_y < 0) {
+ _scene->_y = 0;
_targetY = 0;
}
- if (_scene._x > _scene._dims.x - g_ngi->gameWidth() - margin) {
- _scene._x = _scene._dims.x - g_ngi->gameWidth() - margin;
+ if (_scene->_x > _scene->_dims.x - g_ngi->gameWidth() - margin) {
+ _scene->_x = _scene->_dims.x - g_ngi->gameWidth() - margin;
_targetX = 0;
}
- if (_scene._y > _scene._dims.y - g_ngi->_backgroundSurface.h) {
- _scene._y = _scene._dims.y - g_ngi->_backgroundSurface.h;
+ if (_scene->_y > _scene->_dims.y - g_ngi->_backgroundSurface.h) {
+ _scene->_y = _scene->_dims.y - g_ngi->_backgroundSurface.h;
_targetY = 0;
}
}
@@ -346,9 +335,9 @@ int FPController::checkBorders(float cursorX, float cursorY) const {
if (_swiped)
return 0;
const float margin = marginX();
- if (_scene._x + g_ngi->gameWidth() - cursorX < 47.0f && _scene._x + g_ngi->gameWidth() + margin < _scene._dims.x - 1)
+ if (_scene->_x + g_ngi->gameWidth() - cursorX < 47.0f && _scene->_x + g_ngi->gameWidth() + margin < _scene->_dims.x - 1)
return 1;
- if (cursorX - _scene._x < 47.0f && _scene._x - margin > 0.0f)
+ if (cursorX - _scene->_x < 47.0f && _scene->_x - margin > 0.0f)
return cursorY > 60.0f ? -1 : 0;
return 0;
}
@@ -372,24 +361,24 @@ void FPController::defaultScroll() {
_heroCenterY = center.y;
const float cx = cursorX();
const float cy = cursorY();
- const bool free = _scene._motionController && !g_ngi->_currSelectedInventoryItemId;
+ const bool free = _scene->_motionController && !g_ngi->_currSelectedInventoryItemId;
bool edge = false;
const int viewWidth = g_ngi->gameWidth();
const int viewHeight = g_ngi->_backgroundSurface.h;
const int border = checkBorders(cx, cy);
if (border == 1) {
- if (_scene._x + viewWidth - margin - _heroCenterX < 500.0f && free) {
+ if (_scene->_x + viewWidth - margin - _heroCenterX < 500.0f && free) {
_targetX += 3.0f;
- if (_targetX + _scene._x + viewWidth + margin >= _scene._dims.x)
+ if (_targetX + _scene->_x + viewWidth + margin >= _scene->_dims.x)
_targetX = 0;
}
edge = true;
}
if (border == -1) {
- if (_heroCenterX - _scene._x + margin < 500.0f && free) {
+ if (_heroCenterX - _scene->_x + margin < 500.0f && free) {
_targetX -= 3.0f;
- if (_targetX + _scene._x <= margin)
+ if (_targetX + _scene->_x <= margin)
_targetX = 0;
}
limitScroll();
@@ -401,19 +390,19 @@ void FPController::defaultScroll() {
}
if (_scrollX && isScrollXScene()) {
- if (_heroCenterX >= _scene._x - margin + _marginX) {
- if (_heroCenterX > _scene._x + viewWidth + margin - _marginX)
- _targetX = _heroCenterX - (_scene._x + viewWidth + margin) + _offsetX;
+ if (_heroCenterX >= _scene->_x - margin + _marginX) {
+ if (_heroCenterX > _scene->_x + viewWidth + margin - _marginX)
+ _targetX = _heroCenterX - (_scene->_x + viewWidth + margin) + _offsetX;
} else {
- _targetX = _heroCenterX - _scene._x + margin - _offsetX;
+ _targetX = _heroCenterX - _scene->_x + margin - _offsetX;
}
}
if (_scrollY && isScrollYScene()) {
- if (_heroCenterY >= _scene._y + _marginY) {
- if (_heroCenterY > _scene._y + viewHeight - _marginY)
- _targetY = _heroCenterY - (_scene._y + viewHeight) + _offsetY;
+ if (_heroCenterY >= _scene->_y + _marginY) {
+ if (_heroCenterY > _scene->_y + viewHeight - _marginY)
+ _targetY = _heroCenterY - (_scene->_y + viewHeight) + _offsetY;
} else {
- _targetY = _heroCenterY - _scene._y - _offsetY;
+ _targetY = _heroCenterY - _scene->_y - _offsetY;
}
}
limitScroll();
@@ -422,61 +411,61 @@ void FPController::defaultScroll() {
// CFPController::TouchScroll
bool FPController::touchScroll() {
if (_touching) {
- _targetX = _scene._x;
- _targetY = _scene._y;
- const float screenX = cursorX() - _scene._x;
- const float screenY = cursorY() - _scene._y;
+ _targetX = _scene->_x;
+ _targetY = _scene->_y;
+ const float screenX = cursorX() - _scene->_x;
+ const float screenY = cursorY() - _scene->_y;
if (isScrollXScene()) {
const float dx = screenX - _touchOffsetX;
if (fabsf(dx) > fabsf(screenY - _touchOffsetY))
_targetX = _touchCameraX - dx;
}
- if (fabsf(_scene._x - _targetX) > 0.0f)
+ if (fabsf(_scene->_x - _targetX) > 0.0f)
_dragged = true;
- if (_targetX >= 0.0f && !(_scene._dims.x < _targetX + g_ngi->gameWidth())) {
- _scene._x = (int)_targetX;
- _scene._y = (int)_targetY;
+ if (_targetX >= 0.0f && !(_scene->_dims.x < _targetX + g_ngi->gameWidth())) {
+ _scene->_x = (int)_targetX;
+ _scene->_y = (int)_targetY;
} else {
- const float dx = _targetX - _scene._x;
- const float dy = _targetY - _scene._y;
- _targetX = _scene._x + dx / (g_ngi->gameWidth() / 102.0f);
- _targetY = dy + _scene._y;
- _scene._x = (int)_targetX;
- _scene._y = (int)_targetY;
+ const float dx = _targetX - _scene->_x;
+ const float dy = _targetY - _scene->_y;
+ _targetX = _scene->_x + dx / (g_ngi->gameWidth() / 102.0f);
+ _targetY = dy + _scene->_y;
+ _scene->_x = (int)_targetX;
+ _scene->_y = (int)_targetY;
_touchOffsetX = screenX;
_touchOffsetY = screenY;
- _touchCameraX = _scene._x;
- _touchCameraY = _scene._y;
+ _touchCameraX = _scene->_x;
+ _touchCameraY = _scene->_y;
}
_targetX = 0;
_targetY = 0;
return true;
}
- float limit = _scene._dims.x;
+ float limit = _scene->_dims.x;
float lowest = 0;
- if (g_ngi->gameWidth() < _scene._dims.x) {
+ if (g_ngi->gameWidth() < _scene->_dims.x) {
lowest = g_ngi->_wideOfs + 0.0f;
limit -= g_ngi->_wideOfs;
}
- if (limit < _scene._x + g_ngi->gameWidth()) {
- float step = (fabsf(_scene._x - limit + g_ngi->gameWidth()) * 5.0f) / 102.0f;
+ if (limit < _scene->_x + g_ngi->gameWidth()) {
+ float step = (fabsf(_scene->_x - limit + g_ngi->gameWidth()) * 5.0f) / 102.0f;
if (step < 0.5f)
step = 0.5f;
- _scene._x = (int)(_scene._x - step);
+ _scene->_x = (int)(_scene->_x - step);
_targetX = 0;
- if (_scene._x < limit - g_ngi->gameWidth())
- _scene._x = (int)(limit - g_ngi->gameWidth());
+ if (_scene->_x < limit - g_ngi->gameWidth())
+ _scene->_x = (int)(limit - g_ngi->gameWidth());
return true;
}
- if (_scene._x < lowest) {
- float step = (fabsf(_scene._x - lowest) * 5.0f) / 102.0f;
+ if (_scene->_x < lowest) {
+ float step = (fabsf(_scene->_x - lowest) * 5.0f) / 102.0f;
if (step < 0.5f)
step = 0.5f;
- _scene._x = (int)(_scene._x + step);
+ _scene->_x = (int)(_scene->_x + step);
_targetX = 0;
- if (_scene._x > lowest)
- _scene._x = (int)lowest;
+ if (_scene->_x > lowest)
+ _scene->_x = (int)lowest;
return true;
}
return false;
@@ -491,7 +480,7 @@ void FPController::testScroll() {
float dy = 0.0f;
const float margin = marginX();
if (_targetX > 0.0f) {
- if (_scene._x + g_ngi->gameWidth() + margin == _scene._dims.x)
+ if (_scene->_x + g_ngi->gameWidth() + margin == _scene->_dims.x)
_targetX = 0;
dx = _targetX;
if (dx >= 3.0f) {
@@ -501,7 +490,7 @@ void FPController::testScroll() {
_targetX = 0;
}
} else if (_targetX < 0.0f) {
- if (_scene._x == margin)
+ if (_scene->_x == margin)
_targetX = 0;
dx = _targetX;
if (dx <= -3.0f) {
@@ -513,7 +502,7 @@ void FPController::testScroll() {
}
if (_targetY > 0.0f) {
- if (_scene._y + g_ngi->_backgroundSurface.h == _scene._dims.y)
+ if (_scene->_y + g_ngi->_backgroundSurface.h == _scene->_dims.y)
_targetY = 0;
if (_targetY >= 3.0f) {
dy = 3.0f;
@@ -522,7 +511,7 @@ void FPController::testScroll() {
_targetY = 0;
}
} else if (_targetY < 0.0f) {
- if (_scene._y == 0)
+ if (_scene->_y == 0)
_targetY = 0;
if (_targetY <= -3.0f) {
dy = -3.0f;
@@ -532,30 +521,26 @@ void FPController::testScroll() {
}
}
- _scene._x += static_cast<int>(dx);
- _scene._y += static_cast<int>(dy);
+ _scene->_x += static_cast<int>(dx);
+ _scene->_y += static_cast<int>(dy);
}
// CFPController::OnUpdate, the camera part: every 10 ms UpdateScroll, TestScroll unless touching
-void FPController::updateCamera(uint32 elapsed) {
+void FPController::onUpdate(uint32 elapsed) {
checkQueues();
_elapsed += elapsed;
- const int oldX = _scene._x;
- const int oldY = _scene._y;
+ const int oldX = _scene->_x;
+ const int oldY = _scene->_y;
while (_elapsed > 10) {
_elapsed -= 10;
- // virtual UpdateScroll of the scene controller
- if (_scene._scrollHook)
- _scene._scrollHook(_scene);
- else
- updateScroll();
+ updateScroll(); // virtual: the scene controllers replace it
if (_follow != hero() || _smooth || (!_touching && !_swiped))
testScroll();
}
testSwipe();
- if (_scene._x != oldX || _scene._y != oldY) {
- debugC(2, kDebugSceneLogic, "camera %d -> %d (target %g, follow %d)", oldX, _scene._x, _targetX, _follow != nullptr);
- g_ngi->_sceneRect.moveTo(_scene._x, _scene._y);
+ if (_scene->_x != oldX || _scene->_y != oldY) {
+ debugC(2, kDebugSceneLogic, "camera %d -> %d (target %g, follow %d)", oldX, _scene->_x, _targetX, _follow != nullptr);
+ g_ngi->_sceneRect.moveTo(_scene->_x, _scene->_y);
}
}
@@ -583,7 +568,7 @@ bool FPController::checkTry() const {
// CFPController::MctlStartMove
MessageQueue *FPController::mctlStartMove(int x, int y, bool fuzzy, int staticsId, bool mirror) {
checkQueues();
- MotionController *controller = _scene._motionController.get();
+ MotionController *controller = _scene->_motionController.get();
if (controller && (fuzzy || controller->_isEnabled) && canInterruptManQueue()) {
MessageQueue *queue = controller->startMove(hero(), x, y, fuzzy, staticsId, mirror);
if (queue) {
@@ -601,11 +586,11 @@ MessageQueue *FPController::mctlStartMove(int x, int y, bool fuzzy, int staticsI
bool FPController::trySwipeMan(float x, float y, bool nearest) {
if ((x != _lastTargetX || y != _lastTargetY) && checkTry()) {
const Common::Point center = hero()->getCenter();
- if (_scene._motionController->checkPoint(center.x, center.y)) {
+ if (_scene->_motionController->checkPoint(center.x, center.y)) {
if (mctlStartMove((int)x, (int)y, false, 0, false))
return true;
if (nearest) {
- const Common::Point point = _scene._motionController->getNearestWalkPoint((int)x, (int)y);
+ const Common::Point point = _scene->_motionController->getNearestWalkPoint((int)x, (int)y);
if (point.x != -1 && point.y != -1)
return mctlStartMove(point.x, point.y, false, 0, false) != nullptr;
}
@@ -616,7 +601,7 @@ bool FPController::trySwipeMan(float x, float y, bool nearest) {
// CFPController::CalcFinPoint
void FPController::calcFinPoint(float &outX, float &outY) {
- MotionController *controller = _scene._motionController.get();
+ MotionController *controller = _scene->_motionController.get();
float x = 0;
float y = 0;
float px = 0;
@@ -627,16 +612,16 @@ void FPController::calcFinPoint(float &outX, float &outY) {
return point;
};
- if (_scene._x >= 0.0f) {
- if (_scene._dims.x >= _scene._x + viewWidth) {
+ if (_scene->_x >= 0.0f) {
+ if (_scene->_dims.x >= _scene->_x + viewWidth) {
// the scene is not at its right end: the middle of the screen
- const Common::Point point = nearestPoint(_scene._x + viewWidth * 0.5f, _scene._y + viewHeight * 0.5f);
+ const Common::Point point = nearestPoint(_scene->_x + viewWidth * 0.5f, _scene->_y + viewHeight * 0.5f);
px = point.x;
y = point.y;
_swipeDirection = 0;
} else {
if (!_hasRightBorder) {
- const Common::Point point = nearestPoint(_scene._dims.x, _scene._y + viewHeight * 0.5f);
+ const Common::Point point = nearestPoint(_scene->_dims.x, _scene->_y + viewHeight * 0.5f);
px = point.x;
y = point.y;
} else {
@@ -648,7 +633,7 @@ void FPController::calcFinPoint(float &outX, float &outY) {
}
} else {
if (!_hasLeftBorder) {
- const Common::Point point = nearestPoint(0, _scene._y + viewHeight * 0.5f);
+ const Common::Point point = nearestPoint(0, _scene->_y + viewHeight * 0.5f);
px = point.x;
y = point.y;
} else {
@@ -670,7 +655,7 @@ bool FPController::moveBorders(float x, float y) {
const Common::Point center = _follow->getCenter();
_heroCenterX = center.x;
_heroCenterY = center.y;
- MotionController *controller = _scene._motionController.get();
+ MotionController *controller = _scene->_motionController.get();
const bool active = controller && controller->_isEnabled && !g_ngi->_currSelectedInventoryItemId;
if (x <= _heroCenterX) {
if (_leftBorderX < x || _leftBorderX < _heroCenterX) {
@@ -692,19 +677,19 @@ bool FPController::tryStartInteractMan() {
if (!checkTry())
return false;
if (_swipeDirection == -1) {
- if (!(margin > _scene._x))
+ if (!(margin > _scene->_x))
return false;
} else if (_swipeDirection == 1) {
- if (!(_scene._x + g_ngi->gameWidth() > _scene._dims.x - margin))
+ if (!(_scene->_x + g_ngi->gameWidth() > _scene->_dims.x - margin))
return false;
} else {
return false;
}
const Common::Point center = hero()->getCenter();
- const float x = _swipeDirection == -1 ? 2.0f : _scene._dims.x - 2.0f;
+ const float x = _swipeDirection == -1 ? 2.0f : _scene->_dims.x - 2.0f;
// CInteractionController::FindInteraction(x, y), CInteract::Run: the object at the edge is handled like a tap on it
- GameObject *target = _scene.findPictureObjectAtPos((int)x, center.y);
- AniObject *actor = _scene.findAniObjectAtPos((int)x, center.y);
+ GameObject *target = _scene->findPictureObjectAtPos((int)x, center.y);
+ AniObject *actor = _scene->findAniObjectAtPos((int)x, center.y);
if (actor && (!target || actor->_z < target->_z))
target = actor;
if (!target || !canInteractAny(hero(), target, 0))
@@ -719,10 +704,9 @@ bool FPController::tryStartInteractMan() {
// CFPController::TestSwipe
void FPController::testSwipe() {
- if (_scene._sceneId != g_ngi->_currentScene->_sceneId)
+ if (_scene->_sceneId != g_ngi->_currentScene->_sceneId)
return;
- // CanSwipeMan (virtual, true in the base class)
- if (_scene._canSwipeManHook && !_scene._canSwipeManHook())
+ if (!canSwipeMan(cursorX(), cursorY()))
return;
if (!hero())
return;
@@ -730,35 +714,35 @@ void FPController::testSwipe() {
const Common::Point center = hero()->getCenter();
if (_swipeThreshold > fabsf(static_cast<float>(center.x)))
_swipeDirection = -1;
- else if (_swipeThreshold > fabsf(static_cast<float>(_scene._dims.x - center.x)))
+ else if (_swipeThreshold > fabsf(static_cast<float>(_scene->_dims.x - center.x)))
_swipeDirection = 1;
else
_swipeDirection = 0;
}
if (_swipeDirection == 0) {
- if (_scene._x < 0.0f || _scene._dims.x < _scene._x + g_ngi->gameWidth())
+ if (_scene->_x < 0.0f || _scene->_dims.x < _scene->_x + g_ngi->gameWidth())
_swipeWalking = false;
}
if (!_swipeWalking && _touching) {
- if (fabsf(_touchX - cursorX()) > 5.0f || fabsf(_touchStartCameraX - _scene._x) > 5.0f)
+ if (fabsf(_touchX - cursorX()) > 5.0f || fabsf(_touchStartCameraX - _scene->_x) > 5.0f)
tryStartInteractMan();
}
}
// CFPController::OnMouseLKeyDown, the part after the exit manager and the achievements: the touch starts (CanSwipeMan)
-bool FPController::onMouseLKeyDown(float x, float y) {
- if (_scene._canSwipeManHook && !_scene._canSwipeManHook())
+bool FPController::onMouseLKeyDown(uint32 id, float x, float y) {
+ if (!canSwipeMan(x, y))
return false;
_touching = true;
_swipeWalking = false;
- _touchOffsetX = x - _scene._x;
- _touchOffsetY = y - _scene._y;
- _touchCameraX = _scene._x;
- _touchCameraY = _scene._y;
+ _touchOffsetX = x - _scene->_x;
+ _touchOffsetY = y - _scene->_y;
+ _touchCameraX = _scene->_x;
+ _touchCameraY = _scene->_y;
_touchX = x;
_touchY = y;
- _touchStartCameraX = _scene._x;
- _touchStartCameraY = _scene._y;
+ _touchStartCameraX = _scene->_x;
+ _touchStartCameraY = _scene->_y;
return true;
}
@@ -766,7 +750,7 @@ bool FPController::onMouseLKeyDown(float x, float y) {
// edge of the screen the hero goes to the border of the scene (CheckBorders, MoveBorders), else to the point, when it is more than 30 pixels
// from the last target (CFPController::MctlStartMove with fuzzy 0, the motion controller decides what is reachable).
bool FPController::onTapWalk(float x, float y) {
- MotionController *controller = _scene._motionController.get();
+ MotionController *controller = _scene->_motionController.get();
if (_swiped || !controller || !controller->_isEnabled || g_ngi->_currSelectedInventoryItemId || _interactObjectId)
return false;
if (checkBorders(x, y) != 0)
@@ -780,12 +764,12 @@ bool FPController::onTapWalk(float x, float y) {
// (CalcFinPoint, TrySwipeMan); the touch is over. The result is true when the touch was a scroll or a swipe, so no tap follows.
bool FPController::onMouseLKeyUpSwipe(float x, float y) {
bool handled = false;
- if (!_scene._canSwipeManHook || _scene._canSwipeManHook()) {
+ if (canSwipeMan(x, y)) {
if (_follow != hero() || _smooth || g_ngi->_currSelectedInventoryItemId) {
handled = false;
} else {
- if (fabsf(_touchStartCameraX - _scene._x) > 5.0f && !_interactObjectId) {
- if (g_ngi->gameWidth() < _scene._dims.x) {
+ if (fabsf(_touchStartCameraX - _scene->_x) > 5.0f && !_interactObjectId) {
+ if (g_ngi->gameWidth() < _scene->_dims.x) {
_swiped = true;
// CTutorialManager::FinishTutorial("EXTRA_TUTORIAL_USE_SWIPE") is not ported
float px = 0;
@@ -811,51 +795,42 @@ void FPController::setFollowHero(bool follow) {
_follow = follow ? hero() : nullptr;
}
-// the functions of the scene controllers and the engine, for the current scene
-void sceneCamera_onShow(Scene &scene, int entranceId) {
- sceneController(scene).onShow(entranceId);
-}
-
-void sceneCamera_update(Scene &scene, uint32 elapsed) {
- sceneController(scene).updateCamera(elapsed);
-}
-
-void sceneCamera_updateScroll(Scene &scene) {
- sceneController(scene).updateScroll();
-}
-
-void sceneCamera_setFollowHero(bool follow) {
- sceneController(*g_ngi->_currentScene).setFollowHero(follow);
-}
-
-void sceneCamera_setScrollTarget(float dx) {
- sceneController(*g_ngi->_currentScene).setScrollTarget(dx);
+// CFPController::OnMouseLKeyUp: the swipe part, then the tap (the scene controllers that react to the tap before the hero walks do so between
+// the two: ADAPTATION, in the original the tap is a part of this function and the scene controller runs after the base call)
+bool FPController::onMouseLKeyUp(uint32 id, float x, float y) {
+ if (onMouseLKeyUpSwipe(x, y))
+ return true;
+ return onTap(x, y);
}
-bool sceneCamera_updateCmdScroll(const Command *cmd) {
- return sceneController(*g_ngi->_currentScene).updateCmdScroll(cmd);
+// CFPController::UpdateUserCmd: SET_SCROLL waits until the camera is there; GO_MCTL (UpdateCmdMctl) is not ported yet
+bool FPController::updateUserCmd(Command *cmd, uint32 elapsed) {
+ const Common::String type = cmd->_args.getValOrDefault("type");
+ if (type == "GO_MCTL")
+ warning("STUB/untested: CFPController::UpdateCmdMctl");
+ if (type == "SET_SCROLL")
+ return updateCmdScroll(cmd);
+ return false;
}
// CFPController::OnMouseLKeyUp (a tap) of every scene of an XML project: an interaction of the object under the finger, else the hero
-// walks to the point. The scene 1 queue and the upper pipe of scene 1 are the only scene specific parts.
-bool sceneController_click(Common::Point pos) {
- Scene &scene = *g_ngi->_currentScene;
+// walks to the point. The scene 1 queue and the upper pipe of scene 1 are the only scene specific parts. ADAPTATION: the original finds
+// the interaction with CInteractionController::FindInteraction and starts it with CInteract::Run (RunInteractionWithMouse).
+bool FPController::onTap(float tapX, float tapY) {
+ Scene &scene = *_scene;
AniObject *hero = g_ngi->_aniMan;
if (!hero || hero->_messageQueueId || !scene._motionController)
return false;
for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList)
if (queue->_queueId == QU_SC1_ENTER && !queue->_isFinished)
return false;
- if (scene._clickHook && scene._clickHook(pos))
- return true;
- FPController &fp = sceneController(scene);
- pos += Common::Point(scene._x, scene._y);
+ const Common::Point pos(tapX, tapY);
PictureObject *picture = scene.findPictureObjectAtPos(pos.x, pos.y);
AniObject *actor = scene.findAniObjectAtPos(pos.x, pos.y);
GameObject *target = picture;
if (actor && (!picture || actor->_z < picture->_z))
target = actor;
- debugC(2, kDebugSceneLogic, "sceneController_click: %d,%d picture %d (z %d) actor %d (z %d)", pos.x, pos.y, picture ? picture->_id : 0, picture ? picture->_z : 0,
+ debugC(2, kDebugSceneLogic, "FPController::onTap: %d,%d picture %d (z %d) actor %d (z %d)", pos.x, pos.y, picture ? picture->_id : 0, picture ? picture->_z : 0,
actor ? actor->_id : 0, actor ? actor->_z : 0);
// CLift::OnButtonUp: the lift door and the areas GD_SC3_LIFT ... GD_SC38_LIFT open the panel of the lift buttons
if (target && g_ngi->isAndroidFullPipe() && (target->_id == ANI_LIFT || (target->_id >= 23116 && target->_id <= 23125)) && g_ngi->lift_switchToBigView())
@@ -872,18 +847,18 @@ bool sceneController_click(Common::Point pos) {
return handleObjectInteraction(hero, target, item);
}
}
- return fp.onTapWalk(pos.x, pos.y);
+ return onTapWalk(pos.x, pos.y);
}
// CFPController::OnRenderBottom
-void renderSceneBottom(Scene &scene) {
+void FPController::onRenderBottom(Common::Point) {
if (g_ngi->_tremble)
g_ngi->_tremble->preRender();
}
// CFPController::OnRenderTop: the exit labels and the achievements (not implemented), black bars where the camera leaves the scene,
// then the tremble effect
-void renderSceneTop(Scene &scene) {
+void FPController::onRenderTop(Common::Point scroll) {
// CExitManager::OnRender draws the title of every exit that has one (CExit +64), none of the 2015 data sets it
static bool warned = false;
if (!warned) {
@@ -893,13 +868,13 @@ void renderSceneTop(Scene &scene) {
// two DrawQuad calls: [0, -scroll] and [sceneWidth - scroll, scroll], shifted by the margin
Graphics::ManagedSurface &target = g_ngi->_backgroundSurface;
- const float scroll = scene._x;
+ const float scrollX = scroll.x;
const int ofs = g_ngi->_wideOfs;
- if (scroll < 0.0f)
- target.fillRect(Common::Rect(ofs, 0, ofs + static_cast<int>(-scroll), target.h), 0);
- const int sceneWidth = scene._dims.x; // CScene::GetSceneDims
- if (static_cast<float>(sceneWidth - g_ngi->gameWidth()) < scroll)
- target.fillRect(Common::Rect(ofs + sceneWidth - static_cast<int>(scroll), 0, ofs + sceneWidth, target.h), 0);
+ if (scrollX < 0.0f)
+ target.fillRect(Common::Rect(ofs, 0, ofs + static_cast<int>(-scrollX), target.h), 0);
+ const int sceneWidth = _scene->_dims.x; // CScene::GetSceneDims
+ if (static_cast<float>(sceneWidth - g_ngi->gameWidth()) < scrollX)
+ target.fillRect(Common::Rect(ofs + sceneWidth - static_cast<int>(scrollX), 0, ofs + sceneWidth, target.h), 0);
if (g_ngi->_tremble)
g_ngi->_tremble->postRender();
diff --git a/engines/ngi/fullpipe/fpcontroller.h b/engines/ngi/fullpipe/fpcontroller.h
index 99c79d262a5..3c933f2bc66 100644
--- a/engines/ngi/fullpipe/fpcontroller.h
+++ b/engines/ngi/fullpipe/fpcontroller.h
@@ -24,30 +24,39 @@
#include "common/scummsys.h"
+#include "ngi/scenecontroller.h"
+
namespace NGI {
class AniObject;
-class Command;
-class MessageQueue;
-class Scene;
/** CFPController: base of the scene controllers; offsets in the comments are the original's */
-class FPController {
+class FPController : public ISceneController {
public:
- explicit FPController(Scene &scene);
- virtual ~FPController() {}
-
- // CFPController::OnShow, the camera part, and EnableArcadeButton
- void onShow(int entranceId);
- // CFPController::OnUpdate, the camera loop: UpdateScroll, TestScroll every 10 ms, then TestSwipe
- void updateCamera(uint32 elapsed);
-
- // the camera
- void updateScroll();
- void defaultScroll();
- bool touchScroll();
+ explicit FPController(int sceneId);
+
+ // ISceneController overrides of CFPController
+ /** CFPController::OnShow (camera part), EnableArcadeButton */
+ void onShow() override;
+ /** CFPController::OnUpdate: UpdateScroll, TestScroll every 10 ms, TestSwipe */
+ void onUpdate(uint32 elapsed) override;
+ void onRenderBottom(Common::Point scroll) override;
+ void onRenderTop(Common::Point scroll) override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ /** The swipe part of CFPController::OnMouseLKeyUp, then the tap (onTap) unless the touch was a swipe or a scroll */
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ bool updateUserCmd(Command *cmd, uint32 elapsed) override;
+ /** The tap of CFPController::OnMouseLKeyUp (position in scene coordinates): an interaction of the object under the finger, else the hero walks to the point */
+ bool onTap(float x, float y);
+
+ // virtual methods that CFPController adds (vtable slots from 0x2DE258)
+ virtual bool canSwipeMan(float x, float y) { return true; }
+ virtual void updateScroll();
+ virtual void limitScroll();
+ virtual void defaultScroll();
+ virtual bool touchScroll();
+
void testScroll();
- void limitScroll();
int checkBorders(float cursorX, float cursorY) const;
bool isScrollXScene() const;
bool isScrollYScene() const;
@@ -71,12 +80,6 @@ public:
/** CFPController::MctlStartMove */
MessageQueue *mctlStartMove(int x, int y, bool fuzzy, int staticsId, bool mirror);
- // mouse (the touch of the original: the position is in scene coordinates)
- bool onMouseLKeyDown(float x, float y);
- /** The swipe part of CFPController::OnMouseLKeyUp; true when the touch was a swipe or a scroll and must not be handled as a tap */
- bool onMouseLKeyUpSwipe(float x, float y);
- /** The last part of CFPController::OnMouseLKeyUp: the tap walks the hero */
- bool onTapWalk(float x, float y);
/** The camera fields that a scene controller changes (CSc04Controller::UpdateScroll ...) */
void setFollowHero(bool follow);
@@ -85,14 +88,17 @@ public:
bool isTouching() const { return _touching; }
bool wasDragged() const { return _dragged; }
-private:
+protected:
+ /** The swipe part of CFPController::OnMouseLKeyUp: true when the touch was a swipe or a scroll and must not be handled as a tap */
+ bool onMouseLKeyUpSwipe(float x, float y);
+ /** The last part of the tap: the hero walks */
+ bool onTapWalk(float x, float y);
+
AniObject *hero() const;
float cursorX() const;
float cursorY() const;
float marginX() const;
- Scene &_scene;
-
float _heroCenterX = 0; // +28
float _heroCenterY = 0; // +32
// +36..+48: margins and offsets set by the scene controllers, 0 in the base
@@ -134,7 +140,10 @@ private:
bool _swiped = false; // +212: a swipe was made, the tap is not handled
};
-/** The controller of the scene (created when needed) */
+/** CSplashScreenController::CreateControllers for one scene */
+void createSceneController(int sceneId);
+
+/** CGame::AssignController: the controller of the scene, CFPController for the others */
FPController &sceneController(Scene &scene);
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sc03controller.h b/engines/ngi/fullpipe/sc03controller.h
new file mode 100644
index 00000000000..6322d260587
--- /dev/null
+++ b/engines/ngi/fullpipe/sc03controller.h
@@ -0,0 +1,40 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SC03CONTROLLER_H
+#define NGI_FULLPIPE_SC03CONTROLLER_H
+
+#include "ngi/fullpipe/fpcontroller.h"
+
+namespace NGI {
+
+/** Android: CSc03Controller. Only the parts that are ported: OnShow (the camera margins) and OnRender (the hint over the scene) */
+class Sc03Controller : public FPController {
+public:
+ explicit Sc03Controller(int sceneId) : FPController(sceneId) {}
+
+ void onShow() override;
+ void onRender(Common::Point scroll) override;
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SC03CONTROLLER_H
diff --git a/engines/ngi/fullpipe/sc04controller.h b/engines/ngi/fullpipe/sc04controller.h
new file mode 100644
index 00000000000..244c3ad0c4e
--- /dev/null
+++ b/engines/ngi/fullpipe/sc04controller.h
@@ -0,0 +1,44 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SC04CONTROLLER_H
+#define NGI_FULLPIPE_SC04CONTROLLER_H
+
+#include "ngi/fullpipe/fpcontroller.h"
+
+namespace NGI {
+
+/** Android: CSc04Controller. Only the parts that are ported: OnShow (the camera margins), OnRender (the arcade interface), CanSwipeMan,
+ * UpdateScroll and OnMouseLKeyUp (the ladder, the plank); the rest of the scene logic is still in scene04.cpp */
+class Sc04Controller : public FPController {
+public:
+ explicit Sc04Controller(int sceneId) : FPController(sceneId) {}
+
+ void onShow() override;
+ void onRender(Common::Point scroll) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ bool canSwipeMan(float x, float y) override;
+ void updateScroll() override;
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SC04CONTROLLER_H
diff --git a/engines/ngi/fullpipe/scene03.cpp b/engines/ngi/fullpipe/scene03.cpp
index 5e6cda8ede5..81eeb4e5824 100644
--- a/engines/ngi/fullpipe/scene03.cpp
+++ b/engines/ngi/fullpipe/scene03.cpp
@@ -34,6 +34,7 @@
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/font.h"
#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/sc03controller.h"
namespace NGI {
@@ -50,12 +51,21 @@ static GameVar *scene03_eggVariable(const char *name) {
// Android: hint over the scene with the eggs still needed (CSc03Controller +244 time, +248 text)
static const int kEatenHintDuration = 4000;
+// CSc03Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera (the rest is in scene03_initScene)
+void Sc03Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
// CSc03Controller::OnRender: a cloud with the text at a fixed place of the screen
-static void scene03_render(Scene &scene) {
+void Sc03Controller::onRender(Common::Point) {
if (g_vars->scene03_hintTimer <= 0 || !g_vars->scene03_hintFont)
return;
- if (PictureObject *cloud = scene.findPictureObjectById(23509, 0)) // 0x5BD5
+ if (PictureObject *cloud = _scene->findPictureObjectById(23509, 0)) // 0x5BD5
cloud->_picture->blitTo(g_ngi->_backgroundSurface, Common::Point(500, 200));
g_vars->scene03_hintFont->drawCentered(g_ngi->_backgroundSurface, Common::Rect(520, 215, 520 + 113, 215 + 71), g_vars->scene03_hintText);
}
@@ -113,7 +123,6 @@ void scene03_initScene(Scene *sc) {
// CSc03Controller::OnShow: the hint over the scene is hidden
g_vars->scene03_hintTimer = -1;
g_vars->scene03_hintText.clear();
- sc->_renderHook = scene03_render;
} else {
g_ngi->lift_setButton(sO_Level2, ST_LBN_2N);
}
diff --git a/engines/ngi/fullpipe/scene04.cpp b/engines/ngi/fullpipe/scene04.cpp
index 33fb3e06053..5b760615e77 100644
--- a/engines/ngi/fullpipe/scene04.cpp
+++ b/engines/ngi/fullpipe/scene04.cpp
@@ -35,6 +35,7 @@
#include "ngi/gameloader.h"
#include "ngi/behavior.h"
#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/sc04controller.h"
#include "ngi/sound.h"
#include "common/formats/xmlparser.h"
@@ -51,9 +52,12 @@ static const int scene04_speakerPhases[] = {
void sceneHandler04_putKozyawkaBack(AniObject *ani);
static bool scene04_click(Common::Point pos);
-static void scene04_render(Scene &scene);
-static void scene04_updateScroll(Scene &scene);
-static bool scene04_canSwipeMan();
+
+// the camera follows the hero (CFPController +60) or not
+static void scene04_followHero(bool follow) {
+ sceneController(*g_ngi->_currentScene).setFollowHero(follow);
+}
+
static void scene04_startArcade();
static void scene04_stopArcade();
static void scene04_winArcade();
@@ -280,10 +284,6 @@ void scene04_initScene(Scene *sc) {
g_ngi->initArcadeKeys("SC_4");
if (g_ngi->isAndroidFullPipe()) {
- sc->_clickHook = scene04_click;
- sc->_renderHook = scene04_render;
- sc->_scrollHook = scene04_updateScroll;
- sc->_canSwipeManHook = scene04_canSwipeMan;
g_vars->scene04_cameraLocked = false;
g_vars->scene04_demoScroll = false;
g_vars->scene04_hintPending = false;
@@ -303,19 +303,38 @@ void scene04_initScene(Scene *sc) {
}
}
+// CSc04Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera (the rest is in scene04_initScene)
+void Sc04Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
// CSc04Controller::OnRender: the arcade interface over the scene
-static void scene04_render(Scene &scene) {
+void Sc04Controller::onRender(Common::Point) {
g_ngi->arcadeInterface().render();
}
// CSc04Controller::CanSwipeMan: not while the camera is held
-static bool scene04_canSwipeMan() {
+bool Sc04Controller::canSwipeMan(float, float) {
return !g_vars->scene04_cameraLocked;
}
+// CSc04Controller::OnMouseLKeyUp: the ladder, the plank and the hero on the ladder, between the swipe and the tap of the base class
+// (ADAPTATION: in the original the base call comes first and includes the tap, see FPController::onMouseLKeyUp)
+bool Sc04Controller::onMouseLKeyUp(uint32 id, float x, float y) {
+ if (onMouseLKeyUpSwipe(x, y))
+ return true;
+ if (scene04_click(Common::Point(x - _scene->_x, y - _scene->_y)))
+ return true;
+ return onTap(x, y);
+}
+
// CSc04Controller::UpdateScroll: while the arcade runs or the hand moves, the camera is held at x 380 (the jar, the plank and the ladder
// are in view); the camera follows the hero again when neither the ladder nor the arcade are used and no demo scroll is running
-static void scene04_updateScroll(Scene &scene) {
+void Sc04Controller::updateScroll() {
if (!g_vars->scene04_dudeOnLadder && !g_vars->scene04_soundPlaying)
g_vars->scene04_cameraLocked = false;
@@ -325,14 +344,14 @@ static void scene04_updateScroll(Scene &scene) {
if (g_vars->scene04_cameraLocked) {
if (handMoves || (g_vars->scene04_soundPlaying && g_ngi->_aniMan)) {
- sceneCamera_setFollowHero(false);
- if (fabsf(scene._x - 380.0f) > 3.0f)
- sceneCamera_setScrollTarget(380.0f - scene._x);
+ setFollowHero(false);
+ if (fabsf(_scene->_x - 380.0f) > 3.0f)
+ setScrollTarget(380.0f - _scene->_x);
}
} else if (!g_vars->scene04_demoScroll) {
- sceneCamera_setFollowHero(true);
+ setFollowHero(true);
}
- sceneCamera_updateScroll(scene);
+ FPController::updateScroll();
}
bool sceneHandler04_friesAreWalking() {
@@ -1812,12 +1831,12 @@ static bool sceneHandler04_namedMessage(const Common::String &name, Command *ex)
MessageQueue *queue = g_ngi->_globalMessageQueueList->getMessageQueueById(ex->_parId);
if (g_ngi->getStateId(SC4_DEMO_SCROLL_STATE) == g_ngi->getStateValue(SC4_DEMO_SCROLL_STATE, SC4_DEMO_SCROLL_DONE)) {
g_vars->scene04_demoScroll = false;
- sceneCamera_setFollowHero(true);
+ scene04_followHero(true);
while (queue && queue->getCount())
queue->removeCommand(queue->getCount() - 1, true);
} else {
g_vars->scene04_demoScroll = true;
- sceneCamera_setFollowHero(false);
+ scene04_followHero(false);
g_ngi->setState(SC4_DEMO_SCROLL_STATE, g_ngi->getStateValue(SC4_DEMO_SCROLL_STATE, SC4_DEMO_SCROLL_DONE));
if (queue) {
for (const char *x : { "800", "0" }) {
@@ -1848,7 +1867,7 @@ static bool sceneHandler04_namedMessage(const Common::String &name, Command *ex)
}
if (name == "MSG_SC4_DEMO_SCROLL_END") {
g_vars->scene04_demoScroll = false;
- sceneCamera_setFollowHero(true);
+ scene04_followHero(true);
return true;
}
if (name == "MSG_SC4_SHOW_HINT") {
diff --git a/engines/ngi/fullpipe/sceneTutorial.cpp b/engines/ngi/fullpipe/sceneTutorial.cpp
index 3c2c7558405..45e3cce432e 100644
--- a/engines/ngi/fullpipe/sceneTutorial.cpp
+++ b/engines/ngi/fullpipe/sceneTutorial.cpp
@@ -28,6 +28,7 @@
#include "ngi/modal.h"
#include "ngi/motion.h"
#include "ngi/fullpipe/scenes.h"
+#include "ngi/fullpipe/fpcontroller.h"
#include "ngi/statics.h"
#include "common/formats/xmlparser.h"
@@ -240,7 +241,8 @@ public:
if (!picture || picture->_id != pipe)
return false;
root->setSubVarAsInt("Scene1ExitsDisabled", 0);
- if (!sceneController_click(pos)) {
+ Scene &scene = *g_ngi->_currentScene;
+ if (!sceneController(scene).onTap(pos.x + scene._x, pos.y + scene._y)) {
root->setSubVarAsInt("Scene1ExitsDisabled", 1);
return false;
}
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
new file mode 100644
index 00000000000..74f30ca3d24
--- /dev/null
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -0,0 +1,465 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/ngi.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/scenecontrollers.h"
+#include "ngi/fullpipe/sc03controller.h"
+#include "ngi/fullpipe/sc04controller.h"
+
+namespace NGI {
+
+// CSc01Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc01Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc02Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc02Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc05Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc05Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc06Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc06Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc07Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc07Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc08Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc08Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc09Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc09Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc10Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc10Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc11Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc11Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc12Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc12Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc13Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc13Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc15Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc15Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc16Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc16Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc17Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc17Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc18Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc18Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc19Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc19Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc20Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc20Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc21Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc21Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc22Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc22Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc23Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc23Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc24Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc24Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc25Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc25Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc26Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc26Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc27Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc27Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc28Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc28Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc29Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc29Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc30Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc30Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc31Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc31Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc32Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc32Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc33Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc33Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc34Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc34Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc35Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc35Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc36Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc36Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc37Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc37Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc38Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+void Sc38Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSplashScreenController::CreateControllers: the class of the scene number, else CFPController
+void createSceneController(int sceneId) {
+ switch (sceneId) {
+ case SC_1:
+ new Sc01Controller(sceneId);
+ break;
+ case SC_2:
+ new Sc02Controller(sceneId);
+ break;
+ case SC_3:
+ new Sc03Controller(sceneId);
+ break;
+ case SC_4:
+ new Sc04Controller(sceneId);
+ break;
+ case SC_5:
+ new Sc05Controller(sceneId);
+ break;
+ case SC_6:
+ new Sc06Controller(sceneId);
+ break;
+ case SC_7:
+ new Sc07Controller(sceneId);
+ break;
+ case SC_8:
+ new Sc08Controller(sceneId);
+ break;
+ case SC_9:
+ new Sc09Controller(sceneId);
+ break;
+ case SC_10:
+ new Sc10Controller(sceneId);
+ break;
+ case SC_11:
+ new Sc11Controller(sceneId);
+ break;
+ case SC_12:
+ new Sc12Controller(sceneId);
+ break;
+ case SC_13:
+ new Sc13Controller(sceneId);
+ break;
+ case SC_15:
+ new Sc15Controller(sceneId);
+ break;
+ case SC_16:
+ new Sc16Controller(sceneId);
+ break;
+ case SC_17:
+ new Sc17Controller(sceneId);
+ break;
+ case SC_18:
+ new Sc18Controller(sceneId);
+ break;
+ case SC_19:
+ new Sc19Controller(sceneId);
+ break;
+ case SC_20:
+ new Sc20Controller(sceneId);
+ break;
+ case SC_21:
+ new Sc21Controller(sceneId);
+ break;
+ case SC_22:
+ new Sc22Controller(sceneId);
+ break;
+ case SC_23:
+ new Sc23Controller(sceneId);
+ break;
+ case SC_24:
+ new Sc24Controller(sceneId);
+ break;
+ case SC_25:
+ new Sc25Controller(sceneId);
+ break;
+ case SC_26:
+ new Sc26Controller(sceneId);
+ break;
+ case SC_27:
+ new Sc27Controller(sceneId);
+ break;
+ case SC_28:
+ new Sc28Controller(sceneId);
+ break;
+ case SC_29:
+ new Sc29Controller(sceneId);
+ break;
+ case SC_30:
+ new Sc30Controller(sceneId);
+ break;
+ case SC_31:
+ new Sc31Controller(sceneId);
+ break;
+ case SC_32:
+ new Sc32Controller(sceneId);
+ break;
+ case SC_33:
+ new Sc33Controller(sceneId);
+ break;
+ case SC_34:
+ new Sc34Controller(sceneId);
+ break;
+ case SC_35:
+ new Sc35Controller(sceneId);
+ break;
+ case SC_36:
+ new Sc36Controller(sceneId);
+ break;
+ case SC_37:
+ new Sc37Controller(sceneId);
+ break;
+ case SC_38:
+ new Sc38Controller(sceneId);
+ break;
+ default:
+ new FPController(sceneId);
+ break;
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/scenecontrollers.h b/engines/ngi/fullpipe/scenecontrollers.h
new file mode 100644
index 00000000000..16f2cd4f195
--- /dev/null
+++ b/engines/ngi/fullpipe/scenecontrollers.h
@@ -0,0 +1,244 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SCENECONTROLLERS_H
+#define NGI_FULLPIPE_SCENECONTROLLERS_H
+
+#include "ngi/fullpipe/fpcontroller.h"
+
+namespace NGI {
+
+// The controllers of the scenes (CScNNController). Generated by scripts/ngi_gen_scene_controllers.py, then maintained by hand as the logic
+// of the scenes moves into them. Scenes 3 and 4 are in sc03controller.h and sc04controller.h.
+
+class Sc01Controller : public FPController {
+public:
+ explicit Sc01Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc02Controller : public FPController {
+public:
+ explicit Sc02Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc05Controller : public FPController {
+public:
+ explicit Sc05Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc06Controller : public FPController {
+public:
+ explicit Sc06Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc07Controller : public FPController {
+public:
+ explicit Sc07Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc08Controller : public FPController {
+public:
+ explicit Sc08Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc09Controller : public FPController {
+public:
+ explicit Sc09Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc10Controller : public FPController {
+public:
+ explicit Sc10Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc11Controller : public FPController {
+public:
+ explicit Sc11Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc12Controller : public FPController {
+public:
+ explicit Sc12Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc13Controller : public FPController {
+public:
+ explicit Sc13Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc15Controller : public FPController {
+public:
+ explicit Sc15Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc16Controller : public FPController {
+public:
+ explicit Sc16Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc17Controller : public FPController {
+public:
+ explicit Sc17Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc18Controller : public FPController {
+public:
+ explicit Sc18Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc19Controller : public FPController {
+public:
+ explicit Sc19Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc20Controller : public FPController {
+public:
+ explicit Sc20Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc21Controller : public FPController {
+public:
+ explicit Sc21Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc22Controller : public FPController {
+public:
+ explicit Sc22Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc23Controller : public FPController {
+public:
+ explicit Sc23Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc24Controller : public FPController {
+public:
+ explicit Sc24Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc25Controller : public FPController {
+public:
+ explicit Sc25Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc26Controller : public FPController {
+public:
+ explicit Sc26Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc27Controller : public FPController {
+public:
+ explicit Sc27Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc28Controller : public FPController {
+public:
+ explicit Sc28Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc29Controller : public FPController {
+public:
+ explicit Sc29Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc30Controller : public FPController {
+public:
+ explicit Sc30Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc31Controller : public FPController {
+public:
+ explicit Sc31Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc32Controller : public FPController {
+public:
+ explicit Sc32Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc33Controller : public FPController {
+public:
+ explicit Sc33Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc34Controller : public FPController {
+public:
+ explicit Sc34Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc35Controller : public FPController {
+public:
+ explicit Sc35Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc36Controller : public FPController {
+public:
+ explicit Sc36Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc37Controller : public FPController {
+public:
+ explicit Sc37Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+class Sc38Controller : public FPController {
+public:
+ explicit Sc38Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SCENECONTROLLERS_H
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index 6cdebcb67f2..340eda83cb7 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -36,6 +36,7 @@
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/scenes.h"
+#include "ngi/fullpipe/fpcontroller.h"
#include "ngi/font.h"
#include "ngi/fullpipe/tremble.h"
#include "ngi/interaction.h"
@@ -627,7 +628,7 @@ void NGIEngine::updateSceneLogic(uint32 elapsed) {
_arcadeInterface->update(elapsed);
if (_currentScene && _currentScene->_sceneId != SC_INTRO1)
- sceneCamera_update(*_currentScene, elapsed);
+ sceneController(*_currentScene).onUpdate(elapsed);
const MessageHandler *handler = getMessageHandlerById(2);
if (!handler || !_currentScene || _currentScene->_sceneId == SC_INTRO1)
@@ -733,8 +734,10 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
if (_currentScene && _currentScene->_guiManager)
_currentScene->_guiManager->onHide();
_currentScene = scene;
+ scene->_currentEntranceId = entrance._id;
+ FPController &controller = sceneController(*scene);
if (scene->_sceneId != SC_INTRO1)
- sceneCamera_onShow(*scene, entrance._id);
+ controller.onShow();
if (_aniMan && scene->_motionController) {
scene->_motionController->attachObject(_aniMan);
scene->_motionController->activate();
diff --git a/engines/ngi/messages.cpp b/engines/ngi/messages.cpp
index f8734ecd7d6..e5238bddf88 100644
--- a/engines/ngi/messages.cpp
+++ b/engines/ngi/messages.cpp
@@ -24,6 +24,8 @@
#include "ngi/objects.h"
#include "ngi/messages.h"
#include "ngi/modal.h"
+#include "ngi/scene.h"
+#include "ngi/scenecontroller.h"
#include "ngi/statics.h"
#include "ngi/gameloader.h"
@@ -522,7 +524,8 @@ bool MessageQueue::updateCmdPause(uint32 elapsed) {
// CFPController::UpdateUserCmd: the queue goes on when the camera has reached the point
bool MessageQueue::updateCmdUser() {
- if (!_userCommand || sceneCamera_updateCmdScroll(_userCommand.get()))
+ if (!_userCommand || !g_ngi->_currentScene || !g_ngi->_currentScene->_controller ||
+ g_ngi->_currentScene->_controller->updateUserCmd(_userCommand.get(), 0))
return false;
_userCommand.reset();
update();
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index f92a4a1c86f..ca73bbd0ec7 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -21,6 +21,7 @@ MODULE_OBJS = \
ngiarchive.o \
physics.o \
scene.o \
+ scenecontroller.o \
sceneobjects.o \
sound.o \
stateloader.o \
@@ -125,6 +126,7 @@ MODULE_OBJS = \
fullpipe/sceneIntroDemo.o \
fullpipe/sceneNotebook.o \
fullpipe/sceneTutorial.o \
+ fullpipe/scenecontrollers.o \
fullpipe/scenes.o \
fullpipe/taskmanager.o \
fullpipe/testmode.o \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 93714732573..56996f7c896 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -357,13 +357,18 @@ bool NGIEngine::handleGuiEvent(const Common::Event &event) {
}
// CFPController::OnMouseLKeyDown/Up: the touch scrolls the scene or sends the hero to its end
const bool sceneTouch = usesXMLProject() && _currentScene->_sceneId != SC_INTRO1;
- if (sceneTouch && event.type == Common::EVENT_LBUTTONDOWN && (!manager || !manager->hit(event.mouse)))
- sceneController(*_currentScene).onMouseLKeyDown(event.mouse.x + _currentScene->_x, event.mouse.y + _currentScene->_y);
- bool swiped = false;
- if (sceneTouch && event.type == Common::EVENT_LBUTTONUP)
- swiped = sceneController(*_currentScene).onMouseLKeyUpSwipe(event.mouse.x + _currentScene->_x, event.mouse.y + _currentScene->_y);
- if (event.type == Common::EVENT_LBUTTONUP && (!manager || !manager->hit(event.mouse)) && sceneTouch)
- return !swiped && sceneController_click(event.mouse);
+ const bool onGui = manager && manager->hit(event.mouse);
+ FPController &controller = sceneController(*_currentScene);
+ const float sceneX = event.mouse.x + _currentScene->_x;
+ const float sceneY = event.mouse.y + _currentScene->_y;
+ if (sceneTouch && event.type == Common::EVENT_LBUTTONDOWN && !onGui)
+ controller.onMouseLKeyDown(0, sceneX, sceneY);
+ if (sceneTouch && event.type == Common::EVENT_LBUTTONUP) {
+ if (onGui)
+ controller.resetSwipeParams(); // the touch started on the scene and ended over a button
+ else
+ return controller.onMouseLKeyUp(0, sceneX, sceneY);
+ }
if (!manager)
return false;
GuiManager &gui = *manager;
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index dc1a35c8928..77295777c4e 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -134,21 +134,6 @@ int global_messageHandler3(Command *cmd);
int global_messageHandler4(Command *cmd);
void global_messageHandler_handleSound(Command *cmd);
void executeUserCommand(Command *cmd);
-/** CFPController::OnRenderBottom / OnRenderTop: what every scene draws around its objects */
-void renderSceneBottom(Scene &scene);
-void renderSceneTop(Scene &scene);
-/** The camera of the Android scenes (CFPController::DefaultScroll, TestScroll, LimitScroll, CheckBorders) */
-void sceneCamera_onShow(Scene &scene, int entranceId);
-void sceneCamera_update(Scene &scene, uint32 elapsed);
-/** CFPController::UpdateScroll, what the UpdateScroll of a scene controller calls at its end */
-void sceneCamera_updateScroll(Scene &scene);
-/** The camera fields of CFPController that the scene controllers change: +60 (follow the hero), +52 (the scroll target) */
-void sceneCamera_setFollowHero(bool follow);
-void sceneCamera_setScrollTarget(float dx);
-/** CFPController::UpdateCmdScroll: true while the camera has not reached the point of the SET_SCROLL command yet */
-bool sceneCamera_updateCmdScroll(const Command *cmd);
-/** CFPController::OnMouseLKeyUp: a tap on the scene (interaction or walking), true when it was handled */
-bool sceneController_click(Common::Point pos);
/** Pixels beyond each side of the 800x600 area on a 16:9 screen (CRender::AdjustSize) */
diff --git a/engines/ngi/physics.cpp b/engines/ngi/physics.cpp
index 4f1d45982bf..4a1f80a3e24 100644
--- a/engines/ngi/physics.cpp
+++ b/engines/ngi/physics.cpp
@@ -830,7 +830,6 @@ void PhysDebugDraw::drawAABB(float *arg2, int *arg3) {
}
PhysController::PhysController() {
- stub("PhysController::PhysController");
}
PhysRegistrator::PhysRegistrator() {
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index db1e5e0bb1b..d67cb282dd9 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -22,6 +22,7 @@
#include "math/utils.h"
#include "ngi/ngi.h"
+#include "ngi/scenecontroller.h"
#include "ngi/fullpipe/fpcontroller.h"
#include "ngi/objects.h"
@@ -253,8 +254,6 @@ void Scene::onGuiEvent(const Common::String &id, const Common::String &event) {
}
Scene::~Scene() {
- delete _fpController;
-
if (_guiManager)
_guiManager->unload();
@@ -652,7 +651,8 @@ void Scene::render(bool clear) {
// CScene::Render: the controller draws its bottom layer, then come the objects with z >= 0 (sorted from the back to the
// front), the scene hook (OnRender), the GUI, the physics, the objects with z < 0 and the top layer of the controller
- renderSceneBottom(*this);
+ if (_controller)
+ _controller->onRenderBottom(Common::Point(_x, _y));
bool renderedLayer = false;
for (GameObject *object : visibleObjects) {
if (!renderedLayer && object->_z < 0) {
@@ -666,7 +666,8 @@ void Scene::render(bool clear) {
}
if (!renderedLayer)
renderMiddleLayer();
- renderSceneTop(*this);
+ if (_controller)
+ _controller->onRenderTop(Common::Point(_x, _y));
if (DebugMan.isDebugChannelEnabled(kDebugBounds))
renderDebug();
return;
@@ -727,9 +728,15 @@ void Scene::renderDebug() {
// CMotion8Controller::RenderDbg (the grid) has no counterpart yet
}
+// CScene::SetController: the scene keeps the controller, the controller its scene
+void Scene::setController(ISceneController *controller) {
+ _controller.reset(controller);
+ controller->_scene = this;
+}
+
void Scene::renderMiddleLayer() {
- if (_renderHook)
- _renderHook(*this);
+ if (_controller)
+ _controller->onRender(Common::Point(_x, _y));
if (_guiManager)
_guiManager->render(g_ngi->_backgroundSurface);
if (_physListener)
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index f4e0058b3e8..b565300b723 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -93,16 +93,11 @@ class Scene : public Background {
Common::ScopedPtr<Motion8Controller> _motion8Controller;
/** XML ZCONTROLLER (CScene+72) */
Common::ScopedPtr<ZController> _zController;
- /** CScNNController::OnRender: what the logic of the scene draws between the layers (CScene::Render, controller slot 25) */
- void (*_renderHook)(Scene &) = nullptr;
- /** CScNNController::OnMouseLKeyUp before the tap handler of CFPController: true when the scene handled the tap (position in screen coordinates) */
- bool (*_clickHook)(Common::Point) = nullptr;
- /** CScNNController::UpdateScroll: replaces the default scroll of CFPController, it ends with sceneCamera_updateScroll() */
- void (*_scrollHook)(Scene &) = nullptr;
- /** CScNNController::CanSwipeMan: false while the scene controller does not want the touch to scroll or swipe */
- bool (*_canSwipeManHook)() = nullptr;
- /** CFPController, created by sceneController() */
- class FPController *_fpController = nullptr;
+ /** CScene +48 (SetController): the logic of the scene, owned here */
+ Common::ScopedPtr<class ISceneController> _controller;
+ void setController(ISceneController *controller);
+ /** CScene +392 (GetCurrentEntranceId): the entrance the scene was shown through, 0 if none */
+ int _currentEntranceId = 0;
void (*_guiEventHandler)(Scene &, const Common::String &, const Common::String &) = nullptr;
void onGuiEvent(const Common::String &id, const Common::String &event);
Common::Array<MessageQueue *> _messageQueues;
diff --git a/engines/ngi/scenecontroller.cpp b/engines/ngi/scenecontroller.cpp
new file mode 100644
index 00000000000..5e04651dace
--- /dev/null
+++ b/engines/ngi/scenecontroller.cpp
@@ -0,0 +1,39 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/debug.h"
+
+#include "ngi/ngi.h"
+#include "ngi/scene.h"
+#include "ngi/scenecontroller.h"
+
+namespace NGI {
+
+// ISceneController::ISceneController
+ISceneController::ISceneController(int sceneId) {
+ Scene *scene = g_ngi->findScene(sceneId);
+ if (scene)
+ scene->setController(this);
+ else
+ warning("Error during assigning scene controller, wrond scene.");
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/scenecontroller.h b/engines/ngi/scenecontroller.h
new file mode 100644
index 00000000000..73828763931
--- /dev/null
+++ b/engines/ngi/scenecontroller.h
@@ -0,0 +1,94 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_SCENECONTROLLER_H
+#define NGI_SCENECONTROLLER_H
+
+#include "common/str.h"
+#include "common/rect.h"
+
+#include "ngi/physics.h"
+
+namespace NGI {
+
+class Command;
+class MessageQueue;
+class Scene;
+
+/** ISceneController, the logic of a scene (CFPController and the scene controllers derive it) */
+class ISceneController : public PhysController {
+public:
+ /** CScene::SetController; the original logs an error for a wrong scene */
+ explicit ISceneController(int sceneId);
+ ~ISceneController() override {}
+
+ virtual void onUpdate(uint32 elapsed) {}
+ virtual void onUpdateTop(uint32 elapsed) {}
+ virtual void onLostDevice() {}
+ virtual void onResetRender() {}
+ virtual void onRender(Common::Point scroll) {}
+ virtual void onRenderTop(Common::Point scroll) {}
+ virtual void onRenderBottom(Common::Point scroll) {}
+ virtual void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {}
+ virtual void onShow() {}
+ virtual void onHide() {}
+ virtual void onSceneInit() {}
+ virtual void onKeyDown(uint32 key) {}
+ virtual void onChar(char ch) {}
+ virtual void onKeyUp(uint32 key) {}
+ virtual bool onMouseLKeyDown(uint32 id, float x, float y) { return false; }
+ virtual bool onMouseRKeyDown(uint32 id, float x, float y) { return false; }
+ virtual bool onMouseLKeyUp(uint32 id, float x, float y) { return false; }
+ virtual bool onMouseRKeyUp(uint32 id, float x, float y) { return false; }
+ virtual bool onMouseLKeyDownTop(uint32 id, float x, float y) { return false; }
+ virtual bool onMouseRKeyDownTop(uint32 id, float x, float y) { return false; }
+ virtual bool onMouseLKeyUpTop(uint32 id, float x, float y) { return false; }
+ virtual bool onMouseRKeyUpTop(uint32 id, float x, float y) { return false; }
+ virtual bool onMouseMove(uint32 id, float x, float y) { return false; }
+ virtual bool onMouseMoveTop(uint32 id, float x, float y) { return false; }
+ virtual void onGuiEvent(const Common::String &id, const Common::String &event) {}
+ virtual int getCursorType(float x, float y) { return -1; }
+ virtual int getCursorTypeTop(float x, float y) { return -1; }
+ virtual bool isCursorObjectRender(float x, float y) { return true; }
+ virtual bool isFinished() { return false; }
+ virtual void suspend() {}
+ virtual void resume() {}
+ virtual void executeUserCmd(Command *cmd, MessageQueue *queue) {}
+ /** True while the command still waits (CMessageQueue::UpdateUserCmd goes on when it returns 0) */
+ virtual bool updateUserCmd(Command *cmd, uint32 elapsed) { return false; }
+ virtual bool loadAdditional() { return false; }
+ virtual bool unloadAdditional() { return false; }
+ virtual bool isInventoryEnabled() { return false; }
+ virtual bool isInventoryRendered() { return false; }
+ virtual Common::String getInventorySavePath() { return Common::String(); }
+ virtual bool hit(uint32 x, uint32 y) { return false; }
+ virtual void onStartQueue(uint32 queueId, uint32 sceneId) {}
+ virtual void onStopQueue() {}
+ virtual bool createCustomGui() { return false; }
+ virtual void onRemoveCopies() {}
+
+ Scene *_scene = nullptr; // +8, set by CScene::SetController
+ bool _field5 = false; // +5
+};
+
+} // End of namespace NGI
+
+#endif // NGI_SCENECONTROLLER_H
Commit: 78bea7877a11091ea1c892b439412b5db738ff9e
https://github.com/scummvm/scummvm/commit/78bea7877a11091ea1c892b439412b5db738ff9e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Make SkipArcade and ExecuteUserCmd virtual controller methods, derive Sc19Controller from Sc18Controller
Changed paths:
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/fpcontroller.h
engines/ngi/fullpipe/sc04controller.h
engines/ngi/fullpipe/scene04.cpp
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/scenecontrollers.h
engines/ngi/fullpipe/scenes.h
engines/ngi/messagehandlers.cpp
engines/ngi/messages.cpp
engines/ngi/ngi.h
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index bdbff63d712..0e961d6271e 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -42,18 +42,6 @@
namespace NGI {
-// CFPController::SkipArcade, a method of every arcade scene controller
-void sceneController_skipArcade() {
- switch (g_ngi->_currentScene->_sceneId) {
- case SC_4:
- scene04_skipArcade();
- break;
- default:
- warning("STUB/untested: skipping the arcade of scene %d", g_ngi->_currentScene->_sceneId);
- break;
- }
-}
-
static void inventory_onGuiEvent(Scene &inventory, const Common::String &id, const Common::String &event) {
if (event != "unpress")
return;
@@ -66,7 +54,7 @@ static void inventory_onGuiEvent(Scene &inventory, const Common::String &id, con
} else if (id == "PIC_INV_TASK") {
sceneNotebook_show();
} else if (id == "BTN_SKIP_ARCADE") {
- sceneController_skipArcade();
+ sceneController(*g_ngi->_currentScene).skipArcade();
} else {
warning("STUB: Inventory::onGuiEvent(%s, %s)", id.c_str(), event.c_str());
}
@@ -109,10 +97,11 @@ static void execSetActiveInteraction(Command *cmd) {
findId(cmd->_args.getValOrDefault("obj")), floatArg(cmd, "act", 1.0f), floatArg(cmd, "add", 0.0f));
}
-void executeUserCommand(Command *cmd) {
- const Common::String &type = cmd->_messageName;
-
- if (type == "SET_ACTIVE_INTERACTION") {
+// CMessageQueue::ExecuteUserCmd: the scene of the command (parameter "sc", else the scene of the queue) and its controller run it.
+// ADAPTATIONS: there is no scene stack ("sceneInStack") and the queue does not know its scene, the current scene is taken instead; the
+// original executes SET_ACTIVE_INTERACTION (kind 0xB) as a command kind of its own, ScummVM maps it to the user commands.
+void executeUserCommand(Command *cmd, MessageQueue *queue) {
+ if (cmd->_messageName == "SET_ACTIVE_INTERACTION") {
execSetActiveInteraction(cmd);
return;
}
@@ -123,12 +112,17 @@ void executeUserCommand(Command *cmd) {
if (Scene *target = g_ngi->findScene(findId(sceneName)))
scene = target;
}
- // The original also takes "sceneInStack" (an index into the CGame scene stack), there is no scene stack yet
- if (!scene)
- return;
+ if (scene && scene->_controller)
+ scene->_controller->executeUserCmd(cmd, queue);
+}
+
+// CFPController::ExecuteUserCmd
+void FPController::executeUserCmd(Command *cmd, MessageQueue *queue) {
+ const Common::String &type = cmd->_messageName;
+ Scene *scene = _scene;
if (type == "SET_SCROLL") {
- sceneController(*scene).execCmdScroll(cmd);
+ execCmdScroll(cmd);
} else if (type == "SET_EXIT_STATE") {
const int id = findId(cmd->_args.getValOrDefault("picId"));
if (id)
@@ -150,7 +144,7 @@ void executeUserCommand(Command *cmd) {
static Common::HashMap<Common::String, bool> reported;
if (!reported.contains(type)) {
reported[type] = true;
- warning("Android user command %s is not implemented yet", type.c_str());
+ warning("STUB/untested: Android user command %s is not implemented yet", type.c_str());
}
} else {
debugC(1, kDebugEvents, "Android user command %s is ignored (not handled by CFPController)", type.c_str());
diff --git a/engines/ngi/fullpipe/fpcontroller.h b/engines/ngi/fullpipe/fpcontroller.h
index 3c933f2bc66..8db15c39711 100644
--- a/engines/ngi/fullpipe/fpcontroller.h
+++ b/engines/ngi/fullpipe/fpcontroller.h
@@ -45,11 +45,15 @@ public:
bool onMouseLKeyDown(uint32 id, float x, float y) override;
/** The swipe part of CFPController::OnMouseLKeyUp, then the tap (onTap) unless the touch was a swipe or a scroll */
bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ void executeUserCmd(Command *cmd, MessageQueue *queue) override;
bool updateUserCmd(Command *cmd, uint32 elapsed) override;
/** The tap of CFPController::OnMouseLKeyUp (position in scene coordinates): an interaction of the object under the finger, else the hero walks to the point */
bool onTap(float x, float y);
// virtual methods that CFPController adds (vtable slots from 0x2DE258)
+ virtual bool canShowHelp() { return true; }
+ /** CFPController::SkipArcade clears +213; the controllers of the arcade scenes override it */
+ virtual void skipArcade() { _skipArcade = false; }
virtual bool canSwipeMan(float x, float y) { return true; }
virtual void updateScroll();
virtual void limitScroll();
@@ -138,6 +142,7 @@ protected:
bool _swipeWalking = false; // +189: the hero walks to the end of the scene
int _swipeDirection = 0; // +192: -1 left, 1 right, 0 none
bool _swiped = false; // +212: a swipe was made, the tap is not handled
+ bool _skipArcade = false; // +213
};
/** CSplashScreenController::CreateControllers for one scene */
diff --git a/engines/ngi/fullpipe/sc04controller.h b/engines/ngi/fullpipe/sc04controller.h
index 244c3ad0c4e..b0313fac9de 100644
--- a/engines/ngi/fullpipe/sc04controller.h
+++ b/engines/ngi/fullpipe/sc04controller.h
@@ -36,6 +36,7 @@ public:
void onRender(Common::Point scroll) override;
bool onMouseLKeyUp(uint32 id, float x, float y) override;
bool canSwipeMan(float x, float y) override;
+ void skipArcade() override;
void updateScroll() override;
};
diff --git a/engines/ngi/fullpipe/scene04.cpp b/engines/ngi/fullpipe/scene04.cpp
index 5b760615e77..4e83c60fccd 100644
--- a/engines/ngi/fullpipe/scene04.cpp
+++ b/engines/ngi/fullpipe/scene04.cpp
@@ -1714,7 +1714,7 @@ static void scene04_winArcade() {
}
// CSc04Controller::SkipArcade (the skip button): the clock closes, the hand takes the bottle and the arcade stops
-void scene04_skipArcade() {
+void Sc04Controller::skipArcade() {
g_ngi->arcadeInterface().scrollOut();
g_vars->scene04_clock->setStatic(ST_CLK_CLOSED);
scene04_stopQueue(QU_SC4_GOCLOCK);
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index 74f30ca3d24..e23e68e56e5 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -162,9 +162,10 @@ void Sc18Controller::onShow() {
_offsetY = 300;
}
-// CSc19Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+// CSc19Controller::OnShow: after CSc18Controller::OnShow the margins and offsets of the camera
void Sc19Controller::onShow() {
- FPController::onShow();
+ Sc18Controller::onShow();
+ _follow = nullptr; // +60: set by CSc19Controller::OnShow, the camera does not follow the hero
_marginX = 300;
_marginY = 200;
_offsetX = 400;
diff --git a/engines/ngi/fullpipe/scenecontrollers.h b/engines/ngi/fullpipe/scenecontrollers.h
index 16f2cd4f195..ef171965b9e 100644
--- a/engines/ngi/fullpipe/scenecontrollers.h
+++ b/engines/ngi/fullpipe/scenecontrollers.h
@@ -119,9 +119,9 @@ public:
void onShow() override;
};
-class Sc19Controller : public FPController {
+class Sc19Controller : public Sc18Controller {
public:
- explicit Sc19Controller(int sceneId) : FPController(sceneId) {}
+ explicit Sc19Controller(int sceneId) : Sc18Controller(sceneId) {}
void onShow() override;
};
diff --git a/engines/ngi/fullpipe/scenes.h b/engines/ngi/fullpipe/scenes.h
index 20b7950526d..d8533cbab08 100644
--- a/engines/ngi/fullpipe/scenes.h
+++ b/engines/ngi/fullpipe/scenes.h
@@ -57,7 +57,6 @@ class BaseModalObject;
BaseModalObject *sceneNotebook_create();
void sceneNotebook_show();
void sceneController_initInventory();
-void sceneController_skipArcade();
bool sceneTutorial_isCompleted();
class Chapter;
void sceneChapter_show(Chapter &chapter, bool isStart);
@@ -89,7 +88,6 @@ int sceneHandler03(Command *cmd);
int scene04_updateCursor();
void scene04_initScene(Scene *sc);
-void scene04_skipArcade();
int sceneHandler04(Command *cmd);
void scene05_initScene(Scene *sc);
diff --git a/engines/ngi/messagehandlers.cpp b/engines/ngi/messagehandlers.cpp
index fb9f8f8105b..36867b32524 100644
--- a/engines/ngi/messagehandlers.cpp
+++ b/engines/ngi/messagehandlers.cpp
@@ -774,7 +774,7 @@ int global_messageHandler4(Command *cmd) {
case kCmdUser:
if (g_ngi->_gameVersion < 201509)
return 0;
- executeUserCommand(cmd);
+ executeUserCommand(cmd, g_ngi->_globalMessageQueueList->getMessageQueueById(cmd->_parId));
break;
case kCmdUnused11:
diff --git a/engines/ngi/messages.cpp b/engines/ngi/messages.cpp
index e5238bddf88..e961a5cdad6 100644
--- a/engines/ngi/messages.cpp
+++ b/engines/ngi/messages.cpp
@@ -499,7 +499,7 @@ void MessageQueue::next() {
if (ex->_cmd == kCmdPause && ex->_wait && g_ngi->_gameVersion >= 201509)
_pauseCommand.reset(ex);
else if (ex->_cmd == kCmdUser && ex->_wait && ex->_messageName == "SET_SCROLL" && g_ngi->_gameVersion >= 201509) {
- executeUserCommand(ex);
+ executeUserCommand(ex, this);
_userCommand.reset(ex);
} else
ex->sendMessage();
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 77295777c4e..58003750311 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -133,7 +133,7 @@ int global_messageHandler2(Command *cmd);
int global_messageHandler3(Command *cmd);
int global_messageHandler4(Command *cmd);
void global_messageHandler_handleSound(Command *cmd);
-void executeUserCommand(Command *cmd);
+void executeUserCommand(Command *cmd, MessageQueue *queue = nullptr);
/** Pixels beyond each side of the 800x600 area on a 16:9 screen (CRender::AdjustSize) */
Commit: 812d6cca4da20c04dc18d61ec56a1a54250cfcad
https://github.com/scummvm/scummvm/commit/812d6cca4da20c04dc18d61ec56a1a54250cfcad
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Add the scene stack of CGame, CChapterController as a pushed scene and CFader
Changed paths:
A engines/ngi/fader.cpp
A engines/ngi/fader.h
A engines/ngi/fullpipe/chaptercontroller.cpp
A engines/ngi/fullpipe/chaptercontroller.h
R engines/ngi/fullpipe/sceneChapter.cpp
engines/ngi/behavior.cpp
engines/ngi/fullpipe/chaptermanager.cpp
engines/ngi/fullpipe/sceneIntro.cpp
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/fullpipe/scenes.h
engines/ngi/gfx.cpp
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/behavior.cpp b/engines/ngi/behavior.cpp
index c57fbd33ee3..5974833d1ad 100644
--- a/engines/ngi/behavior.cpp
+++ b/engines/ngi/behavior.cpp
@@ -91,6 +91,8 @@ void BehaviorController::onShow(Scene &scene) {
behavior._elapsed = 0;
}
}
+ if (scene._putPrev) // CBehaviorController::OnShow: music only for a replacing scene (+37 == 0)
+ return;
for (int i = 0; i < g_ngi->_currSoundListCount; ++i) {
SoundList &list = *g_ngi->_currSoundList1[i];
for (int j = 0; j < list.getCount(); ++j) {
diff --git a/engines/ngi/fader.cpp b/engines/ngi/fader.cpp
new file mode 100644
index 00000000000..2a43550b9a6
--- /dev/null
+++ b/engines/ngi/fader.cpp
@@ -0,0 +1,175 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/ngi.h"
+#include "ngi/fader.h"
+
+namespace NGI {
+
+// CFader::StopFade
+void Fader::stopFade() {
+ _elapsed = 0;
+ _state = kIdle;
+}
+
+// CFader::SetState
+void Fader::setState(int state) {
+ _state = state;
+ _elapsed = 0;
+ switch (state) {
+ case kIdle:
+ _duration = 0;
+ break;
+ case kFadeIn:
+ _duration = _delayIn;
+ break;
+ case kWait:
+ _duration = _delayWait;
+ break;
+ case kFadeOut:
+ _duration = _delayOut;
+ break;
+ default:
+ break;
+ }
+}
+
+// CFader::SetFadeParams
+void Fader::setFadeParams(int state, float alpha, int delayIn, int delayOut, int delayWait) {
+ _state = state;
+ _alpha = alpha;
+ _delayIn = delayIn;
+ _delayOut = delayOut;
+ _delayWait = delayWait;
+ switch (state) {
+ case kIdle:
+ _duration = 0;
+ _elapsed = 0;
+ break;
+ case kFadeIn:
+ _duration = delayIn;
+ _elapsed = (int)((float)delayIn * (1.0f - alpha));
+ break;
+ case kWait:
+ _duration = delayWait;
+ _elapsed = 0;
+ break;
+ case kFadeOut:
+ _duration = delayOut;
+ _elapsed = (int)((float)delayOut * alpha);
+ break;
+ default:
+ break;
+ }
+}
+
+// CFader::StartFade
+void Fader::startFade(int delayIn, int delayWait, int delayOut) {
+ _delayOut = delayOut;
+ _delayIn = delayIn;
+ _delayWait = delayWait;
+ _state = kIdle;
+ setNextState();
+}
+
+// CFader::SetNextState
+void Fader::setNextState() {
+ _elapsed = 0;
+ switch (_state) {
+ case kIdle:
+ _alpha = 1.0f;
+ _state = kFadeIn;
+ _duration = _delayIn;
+ break;
+ case kFadeIn:
+ _alpha = 0;
+ _state = kWait;
+ _duration = _delayWait;
+ if (_duration == 0) {
+ if (_delayOut != 0) {
+ _state = kFadeOut;
+ _duration = _delayOut;
+ } else {
+ _state = kIdle;
+ }
+ }
+ break;
+ case kWait:
+ _alpha = 0;
+ _state = kFadeOut;
+ _duration = _delayOut;
+ if (_duration == 0)
+ _state = kIdle;
+ break;
+ case kFadeOut:
+ _alpha = 1.0f;
+ _duration = 0;
+ _state = kIdle;
+ break;
+ default:
+ break;
+ }
+}
+
+// CFader::CheckState
+void Fader::checkState(uint32 elapsed) {
+ if (_duration >= 0) {
+ _elapsed += elapsed;
+ if (_elapsed >= _duration) {
+ _elapsed = _duration;
+ setNextState();
+ }
+ }
+}
+
+// CFader::OnUpdate
+int Fader::onUpdate(uint32 elapsed) {
+ switch (_state) {
+ case kWait:
+ checkState(elapsed);
+ _alpha = 0;
+ return _state;
+ case kFadeOut:
+ _alpha = (float)_elapsed / (float)_duration;
+ checkState(elapsed);
+ break;
+ case kFadeIn:
+ _alpha = (float)(_duration - _elapsed) / (float)_duration;
+ checkState(elapsed);
+ break;
+ default:
+ break;
+ }
+ return _state;
+}
+
+// CFader::OnRender
+void Fader::onRender() {
+ if (_state != kIdle && _state != kFadeIn && _state != kFadeOut)
+ return;
+ const Graphics::ManagedSurface &frame = g_ngi->_backgroundSurface;
+ // the quad covers the widescreen margins; drawAlphaRectangle's brightness is inverse to opacity
+ const int brightness = CLIP<int>((int)(255.0f * (1.0f - _alpha)), 0, 255);
+ if (brightness < 255)
+ g_ngi->drawAlphaRectangle(0, 0, frame.w, frame.h, brightness);
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fader.h b/engines/ngi/fader.h
new file mode 100644
index 00000000000..a0772dfe915
--- /dev/null
+++ b/engines/ngi/fader.h
@@ -0,0 +1,75 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FADER_H
+#define NGI_FADER_H
+
+#include "common/scummsys.h"
+
+namespace NGI {
+
+/** CFader: fade to black and back (kFadeIn, kWait, kFadeOut, kIdle); intro and chapter dialog */
+class Fader {
+public:
+ enum State {
+ kIdle = 0,
+ kFadeIn = 1,
+ kWait = 2,
+ kFadeOut = 3
+ };
+
+ Fader() {}
+
+ /** CFader::StartFade: fade in for delayIn ms, wait for delayWait, fade out for delayOut */
+ void startFade(int delayIn, int delayWait, int delayOut);
+ void stopFade();
+ void setState(int state);
+ int getState() const { return _state; }
+ void setAlpha(float alpha) { _alpha = alpha; }
+ float getAlpha() const { return _alpha; }
+ void setDelayIn(int delay) { _delayIn = delay; }
+ int getDelayIn() const { return _delayIn; }
+ void setDelayWait(int delay) { _delayWait = delay; }
+ int getDelayWait() const { return _delayWait; }
+ void setDelayOut(int delay) { _delayOut = delay; }
+ int getDelayOut() const { return _delayOut; }
+ void setFadeParams(int state, float alpha, int delayIn, int delayOut, int delayWait);
+ /** CFader::OnUpdate: advances the fade and returns the state */
+ int onUpdate(uint32 elapsed);
+ /** CFader::OnRender: the black quad over the screen (opacity = alpha) in states 0, 1, 3 */
+ void onRender();
+
+private:
+ void setNextState();
+ void checkState(uint32 elapsed);
+
+ int _elapsed = 0; // +8: the time in the current state
+ int _delayIn = 0; // +12
+ int _delayWait = 0; // +16
+ int _delayOut = 0; // +20
+ int _duration = 0; // +24: the length of the current state
+ float _alpha = 0; // +28: the opacity of the black
+ int _state = kIdle; // +32
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FADER_H
diff --git a/engines/ngi/fullpipe/chaptercontroller.cpp b/engines/ngi/fullpipe/chaptercontroller.cpp
new file mode 100644
index 00000000000..2ce62f7e1ab
--- /dev/null
+++ b/engines/ngi/fullpipe/chaptercontroller.cpp
@@ -0,0 +1,224 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/debug.h"
+#include "common/formats/xmlparser.h"
+
+#include "ngi/ngi.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/chaptercontroller.h"
+#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/font.h"
+#include "ngi/scene.h"
+#include "ngi/sound.h"
+
+namespace NGI {
+
+namespace {
+
+// CChapterController::ReadSettingsXml: the CHAPTER_CONTROLLER node of chapter.xml
+class ChapterSettings : public Common::XMLParser {
+public:
+ int _fadeIn = 1025;
+ int _fadeOut = 1025;
+ int _soundDelay = 4500;
+ int _charDelay = 123;
+ bool _textAppearance = false;
+
+private:
+ CUSTOM_XML_PARSER(ChapterSettings) {
+ XML_KEY(CHAPTERS)
+ XML_KEY(CHAPTER)
+ XML_PROP(id, true)
+ XML_PROP(countShow, false)
+ XML_KEY(START)
+ XML_PROP(text_id, true)
+ KEY_END()
+ KEY_END()
+ KEY_END()
+ XML_KEY(CHAPTER_CONTROLLER)
+ XML_PROP(text_appearance, false)
+ XML_PROP(char_delay, false)
+ XML_PROP(fadein_delay, false)
+ XML_PROP(fadeout_delay, false)
+ XML_PROP(sound_delay, false)
+ KEY_END()
+ } PARSER_END()
+
+ bool parserCallback_CHAPTERS(ParserNode *) { return true; }
+ bool parserCallback_CHAPTER(ParserNode *) { return true; }
+ bool parserCallback_START(ParserNode *) { return true; }
+
+ static int delay(ParserNode *node, const char *key, int defaultValue) {
+ if (!node->values.contains(key))
+ return defaultValue;
+ return MAX(0, atoi(node->values[key].c_str()));
+ }
+
+ bool parserCallback_CHAPTER_CONTROLLER(ParserNode *node) {
+ const Common::String &appearance = node->values.getValOrDefault("text_appearance");
+ _textAppearance = appearance.equalsIgnoreCase("true") || appearance == "1";
+ _charDelay = delay(node, "char_delay", _charDelay);
+ _soundDelay = delay(node, "sound_delay", _soundDelay);
+ _fadeIn = delay(node, "fadein_delay", _fadeIn);
+ _fadeOut = delay(node, "fadeout_delay", _fadeOut);
+ return true;
+ }
+
+ bool handleUnknownKey(ParserNode *node) override {
+ if (!getParentNode(node))
+ return false;
+ node->layout = _XMLkeys;
+ node->ignore = true;
+ return true;
+ }
+};
+
+} // End of anonymous namespace
+
+// CChapterController::CChapterController
+ChapterController::ChapterController(int sceneId) : ISceneController(sceneId) {
+ const Common::Path fonts = Common::Path(Common::String("data/res_") + g_ngi->getResourceLocale()).join("Fonts");
+ if (!_fontFinal.load(fonts.join("task_dlg_25.fnt")) || !_fontText.load(fonts.join("task_dlg_30.fnt")) || !_fontTitleRu.load(fonts.join("task_dlg_38.fnt")))
+ warning("Could not load the fonts of the chapter dialog");
+}
+
+// CChapterController::ShowDialog
+void ChapterController::showDialog(Chapter *chapter, bool isStart) {
+ _chapter = chapter;
+ chapter->_isStart = isStart; // CChapter::SetIsStart selects the text of the dialog
+ chapter->_countShow = isStart ? 1 : 2; // CChapter::SetCountShow(!isStart + 1)
+}
+
+// CChapterController::ReadSettingsXml
+void ChapterController::readSettingsXml() {
+ ChapterSettings settings;
+ if (!settings.loadFile("data/chapter.xml") || !settings.parse())
+ return;
+ _textAppearance = settings._textAppearance;
+ _charDelay = settings._charDelay;
+ _fadeIn = settings._fadeIn;
+ _fadeOut = settings._fadeOut;
+ _soundDelay = settings._soundDelay;
+}
+
+// CChapterController::OnShow
+void ChapterController::onShow() {
+ readSettingsXml();
+ _charElapsed = 0;
+
+ TextContainer texts;
+ if (!texts.load(Common::Path(Common::String("data/res_") + g_ngi->getResourceLocale())))
+ warning("Could not read the texts of the chapter dialog");
+ if (_chapter->isFinal()) {
+ _fullTitle = texts.getText("STR_CHAPTER_FINAL_1");
+ } else {
+ _fullTitle = texts.getText("STR_CHAPTER");
+ _fullTitle += Common::String::format("%d", _chapter->_number);
+ }
+ _fullText = texts.getText(_chapter->getTextId());
+ if (_textAppearance) {
+ _title.clear();
+ _text.clear();
+ } else {
+ _title = _fullTitle;
+ _text = _fullText;
+ }
+ _charCount = 0;
+ _titleShown = false;
+
+ const int soundTime = MAX(0, _soundDelay - (_fadeIn + _fadeOut));
+ const int textTime = (int)(_fullText.size() + _fullTitle.size()) * _charDelay;
+ g_ngi->_fader.startFade(_fadeIn, MAX(soundTime, textTime), _fadeOut);
+ debugC(2, kDebugSceneLogic, "ChapterController::onShow: %s, hold %d ms", _chapter->_id.c_str(), MAX(soundTime, textTime));
+ // CSoundManager::Play(0x5AE8)
+ if (_scene->_soundList) {
+ if (Sound *sound = _scene->_soundList->getSound(SND_CHAPTER_DLG))
+ sound->play(0);
+ }
+}
+
+// CChapterController::OnUpdate
+void ChapterController::onUpdate(uint32 elapsed) {
+ Fader &fader = g_ngi->_fader;
+ fader.onUpdate(elapsed);
+ if (fader.getState() == Fader::kIdle) {
+ g_ngi->popScene();
+ return;
+ }
+
+ _charElapsed += elapsed;
+ if (_charElapsed >= _charDelay) {
+ _charCount++;
+ _charElapsed = 0;
+ if (_title.size() != _fullTitle.size()) {
+ _title = _fullTitle.substr(0, _charCount);
+ if (_title.size() == _fullTitle.size()) {
+ _titleShown = true;
+ _charCount = 0;
+ }
+ }
+ if (_titleShown && _text.size() != _fullText.size())
+ _text = _fullText.substr(0, _charCount);
+ }
+}
+
+// CChapterController::OnRender: the fade over the scene, then the title and the text
+void ChapterController::onRender(Common::Point) {
+ g_ngi->_fader.onRender();
+
+ Graphics::ManagedSurface &frame = g_ngi->_backgroundSurface;
+ if (_chapter->isFinal()) {
+ _fontFinal.drawCentered(frame, Common::Rect(130, 300, 360, 385), _title);
+ _fontFinal.drawCentered(frame, Common::Rect(440, 180, 685, 495), _text);
+ } else if (Common::String(g_ngi->getResourceLocale()) == "ru") {
+ _fontTitleRu.drawCentered(frame, Common::Rect(130, 300, 360, 385), _title);
+ _fontText.drawCentered(frame, Common::Rect(440, 180, 685, 495), _text);
+ } else {
+ _fontText.drawCentered(frame, Common::Rect(130, 300, 360, 405), _title);
+ _fontText.drawCentered(frame, Common::Rect(440, 180, 685, 505), _text);
+ }
+}
+
+// CChapterController::TrySkip
+void ChapterController::trySkip() {
+ _title = _fullTitle;
+ _text = _fullText;
+ if (g_ngi->_fader.getState() != Fader::kFadeOut)
+ g_ngi->_fader.setState(Fader::kFadeOut);
+}
+
+bool ChapterController::onMouseLKeyUp(uint32 id, float x, float y) {
+ trySkip();
+ return true;
+}
+
+void ChapterController::onKeyUp(uint32 key) {
+ if ((key & 0xFFFFFF7F) == 4)
+ trySkip();
+}
+
+// CChapterController::OnMessage: the messages go to the first scene of the stack (CScene::Message); the messages of this build are
+// delivered to the scene handlers directly, there is nothing to forward
+void ChapterController::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/chaptercontroller.h b/engines/ngi/fullpipe/chaptercontroller.h
new file mode 100644
index 00000000000..e04bb8522f9
--- /dev/null
+++ b/engines/ngi/fullpipe/chaptercontroller.h
@@ -0,0 +1,77 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_CHAPTERCONTROLLER_H
+#define NGI_FULLPIPE_CHAPTERCONTROLLER_H
+
+#include "common/ptr.h"
+#include "common/str.h"
+
+#include "ngi/font.h"
+#include "ngi/scenecontroller.h"
+
+namespace NGI {
+
+class Chapter;
+
+/** CChapterController: the scene SC_CHAPTER (title and text); field offsets as in the original */
+class ChapterController : public ISceneController {
+public:
+ explicit ChapterController(int sceneId);
+
+ /** CChapterController::ShowDialog */
+ void showDialog(Chapter *chapter, bool isStart);
+
+ void onShow() override;
+ void onUpdate(uint32 elapsed) override;
+ void onRender(Common::Point scroll) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ void onKeyUp(uint32 key) override;
+ int getCursorType(float x, float y) override { return 6; }
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+
+private:
+ /** CChapterController::ReadSettingsXml: CHAPTER_CONTROLLER of chapter.xml */
+ void readSettingsXml();
+ /** CChapterController::TrySkip: everything is shown and the fade out starts */
+ void trySkip();
+
+ BitmapFont _fontFinal; // +12: task_dlg_25.fnt
+ BitmapFont _fontText; // +16: task_dlg_30.fnt
+ BitmapFont _fontTitleRu; // +20: task_dlg_38.fnt
+ Chapter *_chapter = nullptr; // +24
+ Common::String _title; // +28: the shown part of the title
+ Common::String _fullTitle; // +32
+ Common::String _text; // +36: the shown part of the text
+ Common::String _fullText; // +40
+ int _charElapsed = 0; // +44
+ int _charCount = 0; // +48
+ bool _titleShown = false; // +52
+ bool _textAppearance = false; // +53
+ int _fadeIn = 1025; // +56
+ int _fadeOut = 1025; // +60
+ int _soundDelay = 4500; // +64
+ int _charDelay = 123; // +68
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_CHAPTERCONTROLLER_H
diff --git a/engines/ngi/fullpipe/chaptermanager.cpp b/engines/ngi/fullpipe/chaptermanager.cpp
index acb3e95a087..c713cdc1b77 100644
--- a/engines/ngi/fullpipe/chaptermanager.cpp
+++ b/engines/ngi/fullpipe/chaptermanager.cpp
@@ -31,6 +31,10 @@
#include "ngi/objects.h"
#include "ngi/anihandler.h"
#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/chaptercontroller.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/fpcontroller.h"
+#include "ngi/scene.h"
#include "ngi/messages.h"
#include "ngi/fullpipe/scenes.h"
#include "ngi/fullpipe/taskmanager.h"
@@ -210,8 +214,17 @@ void ChapterManager::showChapterDialog(const Common::String &id, bool isStart) {
return;
}
- if ((chapter->_countShow != 1 || !isStart) && (chapter->_countShow != 2 || isStart))
- sceneChapter_show(*chapter, isStart);
+ if ((chapter->_countShow == 1 && isStart) || (chapter->_countShow == 2 && !isStart))
+ return;
+
+ // the controller of the scene SC_CHAPTER gets the chapter, then the scene is pushed
+ Scene *scene = g_ngi->findScene(SC_CHAPTER);
+ if (!scene)
+ return;
+ if (!scene->_controller)
+ createSceneController(SC_CHAPTER);
+ static_cast<ChapterController *>(scene->_controller.get())->showDialog(chapter, isStart);
+ g_ngi->pushScene(SC_CHAPTER);
}
// CChapterManager::GetXmlData / SetXmlData
diff --git a/engines/ngi/fullpipe/sceneChapter.cpp b/engines/ngi/fullpipe/sceneChapter.cpp
deleted file mode 100644
index ba8944eb808..00000000000
--- a/engines/ngi/fullpipe/sceneChapter.cpp
+++ /dev/null
@@ -1,248 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "ngi/ngi.h"
-#include "ngi/fullpipe/constants.h"
-#include "ngi/font.h"
-#include "ngi/gameloader.h"
-#include "ngi/modal.h"
-#include "ngi/anihandler.h"
-#include "backends/keymapper/keymapper.h"
-#include "ngi/fullpipe/scenes.h"
-#include "ngi/fullpipe/chaptermanager.h"
-#include "common/file.h"
-#include "common/formats/xmlparser.h"
-
-namespace NGI {
-
-namespace {
-
-// CChapterController::ReadSettingsXml (CHAPTER_CONTROLLER of chapter.xml) and the texts of the dialog
-class ChapterSettings : public Common::XMLParser {
-public:
- explicit ChapterSettings(const Chapter &chapter) : _chapter(chapter) {}
-
- bool load(const Common::Path &directory) {
- if (!loadFile("data/chapter.xml") || !parse())
- return false;
- close();
-
- TextContainer texts;
- if (!texts.load(directory))
- return false;
- // CChapterController::OnShow: "STR_CHAPTER" and the number, the last chapter has a title of its own
- if (_chapter.isFinal()) {
- _title = texts.getText("STR_CHAPTER_FINAL_1");
- } else {
- _title = texts.getText("STR_CHAPTER");
- if (!_title.empty())
- _title += Common::String::format("%d", _chapter._number);
- }
- _text = texts.getText(_chapter.getTextId());
- return !_title.empty() && !_text.empty();
- }
-
- Common::String _title, _text;
- int _fadeIn = 1025, _fadeOut = 1025, _soundDelay = 4500, _charDelay = 123;
- bool _textAppearance = false;
-
-private:
- const Chapter &_chapter;
-
- CUSTOM_XML_PARSER(ChapterSettings) {
- XML_KEY(CHAPTERS)
- XML_KEY(CHAPTER)
- XML_PROP(id, true)
- XML_PROP(countShow, false)
- XML_KEY(START)
- XML_PROP(text_id, true)
- KEY_END()
- KEY_END()
- KEY_END()
- XML_KEY(CHAPTER_CONTROLLER)
- XML_PROP(text_appearance, false)
- XML_PROP(char_delay, false)
- XML_PROP(fadein_delay, false)
- XML_PROP(fadeout_delay, false)
- XML_PROP(sound_delay, false)
- KEY_END()
- } PARSER_END()
-
- bool parserCallback_CHAPTERS(ParserNode *) { return true; }
- bool parserCallback_CHAPTER(ParserNode *) { return true; }
- bool parserCallback_START(ParserNode *) { return true; }
-
- static int delay(ParserNode *node, const char *key, int defaultValue) {
- if (!node->values.contains(key))
- return defaultValue;
- return MAX(0, atoi(node->values[key].c_str()));
- }
-
- bool parserCallback_CHAPTER_CONTROLLER(ParserNode *node) {
- const Common::String &appearance = node->values.getValOrDefault("text_appearance");
- _textAppearance = appearance.equalsIgnoreCase("true") || appearance == "1";
- _charDelay = delay(node, "char_delay", _charDelay);
- _soundDelay = delay(node, "sound_delay", _soundDelay);
- _fadeIn = delay(node, "fadein_delay", _fadeIn);
- _fadeOut = delay(node, "fadeout_delay", _fadeOut);
- return true;
- }
-
- bool handleUnknownKey(ParserNode *node) override {
- if (!getParentNode(node))
- return false;
- node->layout = _XMLkeys;
- node->ignore = true;
- return true;
- }
-};
-
-class ModalChapter : public BaseModalObject {
-public:
- ModalChapter(Scene &scene, const Chapter &chapter) : _scene(scene), _chapter(chapter), _settings(chapter) {}
-
- const Scene *getScene() const override { return &_scene; }
-
- ~ModalChapter() override {
- if (_shown) {
- if (_scene._soundList)
- _scene.stopAllSounds();
- setModal(false);
- }
- }
-
- bool open() {
- const Common::String locale = g_ngi->getResourceLocale();
- const Common::Path directory("data/res_" + locale);
- const Common::Path fonts = directory.join("Fonts");
- if (!_settings.load(directory)) {
- warning("Could not read Android chapter settings or text for %s", locale.c_str());
- return false;
- }
- // CChapterController::OnRender: the last chapter uses task_dlg_25 for both the title and the text, the other
- // chapters task_dlg_30, with task_dlg_38 for the title in Russian
- if (!_font.load(fonts.join(_chapter.isFinal() ? "task_dlg_25.fnt" : "task_dlg_30.fnt")))
- return false;
- if (locale == "ru" && !_chapter.isFinal()) {
- _titleFont.reset(new BitmapFont());
- if (!_titleFont->load(fonts.join("task_dlg_38.fnt")))
- return false;
- }
-
- const uint length = _settings._title.size() + _settings._text.size();
- _visibleChars = _settings._textAppearance ? 0 : length;
- const int64 soundTime = (int64)_settings._soundDelay - _settings._fadeIn - _settings._fadeOut;
- const int64 textTime = (int64)length * _settings._charDelay;
- const uint32 hold = MIN<int64>(UINT32_MAX, MAX(soundTime, textTime));
- _shown = true;
- setModal(true);
- _fader.startFade(_settings._fadeIn, hold, _settings._fadeOut);
- if (_scene._soundList) {
- Sound *sound = _scene._soundList->getSound(SND_CHAPTER_DLG);
- if (sound)
- sound->play(0);
- }
- debugC(2, kDebugSceneLogic, "Opened Android chapter dialog (%s, %u ms hold)", locale.c_str(), hold);
- return true;
- }
-
- bool pollEvent() override { return true; }
- void saveload() override {}
-
- bool handleMessage(Command *message) override {
- if (message->_cmd != kCmdMessage || (message->_messageNum != kMsgLButtonUp &&
- !(message->_messageNum == kMsgKeyUp && message->_param == kActionCloseDialog)))
- return false;
- _visibleChars = _settings._title.size() + _settings._text.size();
- _fader.fadeOut();
- return true;
- }
-
- bool init(int elapsed) override {
- _fader.update(elapsed);
- if (!_fader.active()) {
- debugC(2, kDebugSceneLogic, "Closed Android chapter dialog");
- return false;
- }
- if (_visibleChars < _settings._title.size() + _settings._text.size()) {
- _charElapsed += elapsed;
- if (_charElapsed >= (uint)_settings._charDelay) {
- ++_visibleChars;
- _charElapsed = 0;
- }
- }
- return true;
- }
-
- void update() override {
- Graphics::ManagedSurface &frame = g_ngi->_backgroundSurface;
- _scene.render();
- if (_fader.brightness() < 255)
- g_ngi->drawAlphaRectangle(0, 0, frame.w, frame.h, _fader.brightness());
- const BitmapFont &titleFont = _titleFont ? *_titleFont : _font;
- const bool small = _titleFont || _chapter.isFinal(); // the rectangles of CChapterController::OnRender
- titleFont.drawCentered(frame, Common::Rect(130, 300, 360, small ? 385 : 405),
- _settings._title.substr(0, _visibleChars));
- if (_visibleChars > _settings._title.size())
- _font.drawCentered(frame, Common::Rect(440, 180, 685, small ? 495 : 505),
- _settings._text.substr(0, _visibleChars - _settings._title.size()));
- }
-
-private:
- void setModal(bool active) {
- Common::Keymapper *mapper = g_system->getEventManager()->getKeymapper();
- mapper->setGameKeymapState("ngi-default", !active);
- mapper->setGameKeymapState("dialog", active);
- for (int i = 0; i < g_ngi->_currSoundListCount; ++i) {
- SoundList &sounds = *g_ngi->_currSoundList1[i];
- for (int j = 0; j < sounds.getCount(); ++j)
- sounds.getSoundByIndex(j).pause(active);
- }
- }
-
- bool _shown = false;
- Scene &_scene;
- const Chapter &_chapter;
- ChapterSettings _settings;
- BitmapFont _font;
- Common::ScopedPtr<BitmapFont> _titleFont;
- Fader _fader;
- uint _visibleChars = 0;
- uint32 _charElapsed = 0;
-};
-
-} // End of anonymous namespace
-
-// CChapterController::ShowDialog and CGame::PushScene(SC_CHAPTER): the dialog counts as shown (start: 1, finish: 2)
-void sceneChapter_show(Chapter &chapter, bool isStart) {
- Scene *scene = g_ngi->findScene(SC_CHAPTER);
- if (!scene)
- return;
- chapter._isStart = isStart; // selects the text of the dialog
- Common::ScopedPtr<ModalChapter> dialog(new ModalChapter(*scene, chapter));
- if (dialog->open()) {
- chapter._countShow = isStart ? 1 : 2;
- dialog->_parentObj = g_ngi->_modalObject;
- g_ngi->_modalObject = dialog.release();
- }
-}
-
-} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sceneIntro.cpp b/engines/ngi/fullpipe/sceneIntro.cpp
index ff67923c16a..b0116fb535c 100644
--- a/engines/ngi/fullpipe/sceneIntro.cpp
+++ b/engines/ngi/fullpipe/sceneIntro.cpp
@@ -67,7 +67,7 @@ void sceneIntro_initMan(Scene &scene) {
g_vars->sceneIntro_needSleep = true;
g_vars->sceneIntro_needGetup = false;
g_vars->sceneIntro_playing = true;
- g_vars->sceneIntro_fader.startFade(1025, 0, 0);
+ g_ngi->_fader.startFade(1025, 0, 0);
}
static bool sceneIntro_updateMan() {
@@ -88,12 +88,14 @@ bool sceneIntro_updateAndroid(uint32 elapsed, byte &brightness) {
if (!g_vars->sceneIntro_playing)
return false;
- Fader &fader = g_vars->sceneIntro_fader;
- if (fader.active()) {
- fader.update(elapsed);
- const bool changed = brightness != fader.brightness();
- brightness = fader.brightness();
- if (!fader.active()) {
+ // D08: CScIntoController::OnUpdate / OnRender run the fader; brightness = opposite of its alpha
+ Fader &fader = g_ngi->_fader;
+ if (fader.getState() != Fader::kIdle) {
+ fader.onUpdate(elapsed);
+ const byte level = fader.getState() == Fader::kIdle ? 255 : CLIP<int>((int)(255.0f * (1.0f - fader.getAlpha())), 0, 255);
+ const bool changed = brightness != level;
+ brightness = level;
+ if (fader.getState() == Fader::kIdle) {
if (GuiElement *button = skipButton(*g_ngi->_currentScene))
button->showAndActivate();
runQueue(QU_INTR_STARTINTRO, 0);
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index e23e68e56e5..5af8eebc070 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -24,6 +24,7 @@
#include "ngi/fullpipe/scenecontrollers.h"
#include "ngi/fullpipe/sc03controller.h"
#include "ngi/fullpipe/sc04controller.h"
+#include "ngi/fullpipe/chaptercontroller.h"
namespace NGI {
@@ -457,6 +458,9 @@ void createSceneController(int sceneId) {
case SC_38:
new Sc38Controller(sceneId);
break;
+ case SC_CHAPTER:
+ new ChapterController(sceneId);
+ break;
default:
new FPController(sceneId);
break;
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index 340eda83cb7..b80ba1b3864 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -43,43 +43,6 @@
namespace NGI {
-void Fader::startFade(uint32 fadeIn, uint32 hold, uint32 fadeOut) {
- _durations[kFadeIn] = fadeIn;
- _durations[kHold] = hold;
- _durations[kFadeOut] = fadeOut;
- _stage = kFadeIn;
- _elapsed = 0;
- _brightness = 0;
-}
-
-void Fader::fadeOut() {
- if (active() && _stage != kFadeOut) {
- _stage = kFadeOut;
- _elapsed = 0;
- }
-}
-
-void Fader::update(uint32 elapsed) {
- if (!active())
- return;
- const uint32 duration = _durations[_stage];
- if (elapsed < duration - _elapsed) {
- // CFader samples the current alpha before advancing its timer.
- if (_stage != kHold) {
- const byte level = (uint64)_elapsed * 255 / duration;
- _brightness = _stage == kFadeIn ? level : 255 - level;
- }
- _elapsed += elapsed;
- return;
- }
-
- _brightness = _stage == kFadeOut ? 0 : 255;
- _elapsed = 0;
- do {
- _stage = (Stage)(_stage + 1);
- } while (active() && !_durations[_stage]);
-}
-
Vars::~Vars() {
delete scene03_hintFont;
}
@@ -617,7 +580,7 @@ void NGIEngine::updateSceneLogic(uint32 elapsed) {
// CFPController::OnUpdate
if (_tremble && _currentScene) {
// the hint only shakes when nothing else is going on: the tutorial is completed and none is shown
- const bool idle = sceneTutorial_isCompleted() && !_modalObject;
+ const bool idle = sceneTutorial_isCompleted() && !isDialogShown();
_tremble->onUpdate(elapsed, idle);
}
if (_taskManager)
@@ -734,6 +697,9 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
if (_currentScene && _currentScene->_guiManager)
_currentScene->_guiManager->onHide();
_currentScene = scene;
+ // CGame::DoSetScene: the stack holds the scene only
+ _sceneStack.clear();
+ _sceneStack.push_back(scene);
scene->_currentEntranceId = entrance._id;
FPController &controller = sceneController(*scene);
if (scene->_sceneId != SC_INTRO1)
diff --git a/engines/ngi/fullpipe/scenes.h b/engines/ngi/fullpipe/scenes.h
index d8533cbab08..241ffc8a58d 100644
--- a/engines/ngi/fullpipe/scenes.h
+++ b/engines/ngi/fullpipe/scenes.h
@@ -35,22 +35,6 @@ class AniObject;
struct Swinger;
struct WalkingBearder;
-class Fader {
-public:
- void startFade(uint32 fadeIn, uint32 hold, uint32 fadeOut);
- void update(uint32 elapsed);
- void fadeOut();
- bool active() const { return _stage != kDone; }
- byte brightness() const { return _brightness; }
-
-private:
- enum Stage { kFadeIn, kHold, kFadeOut, kDone };
- Stage _stage = kDone;
- uint32 _durations[3] = {};
- uint32 _elapsed = 0;
- byte _brightness = 255;
-};
-
int defaultUpdateCursor();
void sceneTutorial_check();
class BaseModalObject;
@@ -59,7 +43,6 @@ void sceneNotebook_show();
void sceneController_initInventory();
bool sceneTutorial_isCompleted();
class Chapter;
-void sceneChapter_show(Chapter &chapter, bool isStart);
int sceneIntro_updateCursor();
void sceneIntro_initScene(Scene *sc);
@@ -254,7 +237,6 @@ public:
AniObject *sceneIntro_aniin1man;
bool sceneIntro_needSleep;
- Fader sceneIntro_fader;
bool sceneIntro_needGetup;
bool sceneIntro_skipIntro;
bool sceneIntro_playing;
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index d00b33ce812..98b5e4637b0 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -1431,7 +1431,7 @@ void NGIEngine::drawWidescreenBars() {
// the flag belongs to the scene shown last (DoSetScene, PushScene, PopScene: CRender::SetSrcRect)
const Scene *scene = _modalObject ? _modalObject->getScene() : nullptr;
if (!scene)
- scene = _currentScene;
+ scene = getCurrentScene();
if (_wideOfs <= 0 || !scene || !scene->hasWidescreenBars())
return;
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index ca73bbd0ec7..202d1990053 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -4,6 +4,7 @@ MODULE_OBJS = \
anihandler.o \
behavior.o \
console.o \
+ fader.o \
font.o \
gameloader.o \
gfx.o \
@@ -77,6 +78,7 @@ MODULE_OBJS = \
box2d/Rope/b2Rope.o \
fullpipe/achievements.o \
fullpipe/arcadeinterface.o \
+ fullpipe/chaptercontroller.o \
fullpipe/chaptermanager.o \
fullpipe/floaters.o \
fullpipe/fpcontroller.o \
@@ -119,7 +121,6 @@ MODULE_OBJS = \
fullpipe/scene36.o \
fullpipe/scene37.o \
fullpipe/scene38.o \
- fullpipe/sceneChapter.o \
fullpipe/sceneDbg.o \
fullpipe/sceneFinal.o \
fullpipe/sceneIntro.o \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 56996f7c896..c4ffbcbaf64 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -33,6 +33,7 @@
#include "graphics/surface.h"
#include "ngi/ngi.h"
+#include "ngi/scenecontroller.h"
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/fpcontroller.h"
#include "ngi/fullpipe/chaptermanager.h"
@@ -312,6 +313,9 @@ bool NGIEngine::handleGuiEvent(const Common::Event &event) {
_touchDown = false;
if (event.type == Common::EVENT_SCREEN_CHANGED) {
return true;
+ } else if (_sceneStack.size() > 1) {
+ // the dialogs of the Android build are scenes on the stack (CGame::OnMouse*)
+ return handleSceneStackEvent(event);
} else if (_modalObject) {
const bool back = (event.type == Common::EVENT_KEYUP &&
(event.kbd.keycode == Common::KEYCODE_ESCAPE || event.kbd.keycode == Common::KEYCODE_AC_BACK)) ||
@@ -730,14 +734,23 @@ Common::Error NGIEngine::updateScreen(uint32 elapsed, byte &brightness, bool red
_mouseVirtY = _mouseScreenPos.y + _sceneRect.top;
Scene *scene = _currentScene;
- const bool hadModal = _modalObject != nullptr;
+ // Android dialogs are scenes on the stack: while one is on top the scene below does not run
+ const bool hadDialog = timedUpdates && _sceneStack.size() > 1;
+ const bool hadModal = _modalObject != nullptr || hadDialog;
+ if (hadDialog) {
+ Scene *top = getCurrentScene();
+ top->update(elapsed);
+ if (top == getCurrentScene() && top->_controller)
+ top->_controller->onUpdate(elapsed);
+ redraw = true;
+ }
if (!hadModal && (timedUpdates || _flgGameIsRunning)) {
redraw |= _gameLoader->updateContent(elapsed);
- if (usesXMLProject() && !_modalObject && scene == _currentScene && scene->_sceneId == SC_INTRO1)
+ if (usesXMLProject() && !isDialogShown() && scene == _currentScene && scene->_sceneId == SC_INTRO1)
redraw |= sceneIntro_updateAndroid(elapsed, brightness);
if (timedUpdates)
processMessages();
- if (usesXMLProject() && !_modalObject && !_gameLoader->_preloadSceneId) {
+ if (usesXMLProject() && !isDialogShown() && !_gameLoader->_preloadSceneId) {
updateSceneLogic(elapsed);
sceneTutorial_check();
}
@@ -762,7 +775,7 @@ Common::Error NGIEngine::updateScreen(uint32 elapsed, byte &brightness, bool red
debugC(2, kDebugDrawing, "Switched scene from %d to %d", scene->_sceneId, _currentScene->_sceneId);
redraw = true;
}
- if (timedUpdates && !_modalObject && _gameLoader->_preloadSceneId) {
+ if (timedUpdates && !isDialogShown() && _gameLoader->_preloadSceneId) {
if (!_gameLoader->setScene(_gameLoader->_preloadSceneId, _gameLoader->_preloadEntranceId))
return Common::Error(Common::kNoGameDataFoundError, "Could not enter the requested scene");
_gameLoader->_preloadSceneId = _gameLoader->_preloadEntranceId = 0;
@@ -773,6 +786,11 @@ Common::Error NGIEngine::updateScreen(uint32 elapsed, byte &brightness, bool red
if (_modalObject) {
if (timedUpdates || _flgGameIsRunning)
_modalObject->update();
+ } else if (timedUpdates && _sceneStack.size() > 1) {
+ // CGame::Render over the stack of scenes
+ renderSceneStack();
+ if (brightness < 255)
+ drawAlphaRectangle(0, 0, _backgroundSurface.w, _backgroundSurface.h, brightness);
} else if (_currentScene && (timedUpdates ? redraw : renderScene)) {
_currentScene->render();
if (_inventoryScene) {
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 58003750311..98641d17238 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -34,6 +34,7 @@
#include "engines/engine.h"
#include "ngi/console.h"
+#include "ngi/fader.h"
namespace Audio {
class SoundHandle;
@@ -343,6 +344,8 @@ public:
int32 _lastButtonUpTicks;
BaseModalObject *_modalObject;
+ /** CFader (CSingleton<CFader> in the original) */
+ Fader _fader;
int (*_updateScreenCallback)();
int (*_updateCursorCallback)();
@@ -372,6 +375,26 @@ public:
void updateSceneLogic(uint32 elapsed);
bool doSetScene(const Entrance &entrance);
Scene *findScene(int sceneId);
+
+ // CGame +72: the stack of scenes; PushScene puts dialogs over it. _currentScene is its first scene
+ Common::Array<Scene *> _sceneStack;
+ Scene *getCurrentScene();
+ Scene *getSceneInStack(uint index);
+ bool isSceneInStack(int sceneId) const;
+ void removeSceneInStack(uint index);
+ void pushScene(int sceneId);
+ void popScene();
+ /** CGame::IsInventoryRendered / IsInventoryEnabled: asked of the current scene controller */
+ bool isInventoryRendered();
+ bool isInventoryEnabled();
+ /** CGame::Render for a stack with dialogs: the scenes visible through the ones above (putPrev) */
+ void renderSceneStack();
+ /** CGame::OnMouse*, OnKeyUp for the current scene of a stack with dialogs */
+ bool handleSceneStackEvent(const Common::Event &event);
+ /** Pauses or resumes the sounds of the scenes (CSoundManager::PauseAll / ResumeInScene) */
+ void pauseSceneSounds(bool pause);
+ /** A dialog is shown over the scene: a modal object, or (Android) a scene pushed on the stack */
+ bool isDialogShown() const { return _modalObject || _sceneStack.size() > 1; }
void setSceneMusicParameters(GameVar *var);
int convertScene(int scene);
int getSceneEntrance(int scene);
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index d67cb282dd9..29a677259aa 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -35,6 +35,9 @@
#include "ngi/zcontroller.h"
#include "ngi/motion.h"
#include "ngi/gameloader.h"
+#include "ngi/sound.h"
+#include "ngi/guimanager.h"
+#include "backends/keymapper/keymapper.h"
#include "ngi/fullpipe/constants.h"
@@ -48,6 +51,145 @@ Scene *NGIEngine::findScene(int sceneId) {
return _gameProject->findScene(sceneId);
}
+// CGame::GetCurrentScene: the last scene of the stack
+Scene *NGIEngine::getCurrentScene() {
+ return _sceneStack.empty() ? _currentScene : _sceneStack.back();
+}
+
+// CGame::GetSceneInStack
+Scene *NGIEngine::getSceneInStack(uint index) {
+ if (index < _sceneStack.size())
+ return _sceneStack[index];
+ if (index == 0 && _currentScene)
+ return _currentScene;
+ warning("No current scene.");
+ return nullptr;
+}
+
+// CGame::IsSceneInStack
+bool NGIEngine::isSceneInStack(int sceneId) const {
+ for (const Scene *scene : _sceneStack) {
+ if (scene->_sceneId == sceneId)
+ return true;
+ }
+ return false;
+}
+
+// CGame::RemoveSceneInStack
+void NGIEngine::removeSceneInStack(uint index) {
+ if (index < _sceneStack.size())
+ _sceneStack.remove_at(index);
+ else
+ warning("No current scene.");
+}
+
+// CGame::IsInventoryRendered
+bool NGIEngine::isInventoryRendered() {
+ return _inventoryScene && !_sceneStack.empty() && getCurrentScene()->isInventoryRendered();
+}
+
+// CGame::IsInventoryEnabled
+bool NGIEngine::isInventoryEnabled() {
+ return _inventoryScene && isInventoryRendered() && !_sceneStack.empty() && getCurrentScene()->isInventoryEnabled();
+}
+
+// CSoundManager::PauseAll / ResumeInScene: ADAPTATION, the sounds of all the lists of the shown scenes
+void NGIEngine::pauseSceneSounds(bool pause) {
+ for (int i = 0; i < _currSoundListCount; ++i) {
+ SoundList &sounds = *_currSoundList1[i];
+ for (int j = 0; j < sounds.getCount(); ++j)
+ sounds.getSoundByIndex(j).pause(pause);
+ }
+}
+
+// CGame::PushScene: the scene goes on the stack, the sounds below pause
+void NGIEngine::pushScene(int sceneId) {
+ Scene *scene = findScene(sceneId);
+ if (!scene) {
+ warning("Can't find scene");
+ return;
+ }
+ if (_sceneStack.empty() && _currentScene)
+ _sceneStack.push_back(_currentScene);
+ _sceneStack.push_back(scene);
+ // CPreloadManager::PushScene and CScene::ResetCurrLoadingObj (the loading of the scenes) do not exist here
+ pauseSceneSounds(true);
+ // the dialogs use another keymap (the back button closes the dialog)
+ Common::Keymapper *mapper = _system->getEventManager()->getKeymapper();
+ mapper->setGameKeymapState("ngi-default", false);
+ mapper->setGameKeymapState("dialog", true);
+ scene->onShow();
+}
+
+// CGame::PopScene: the current scene is hidden and removed, its sounds stop, those of the scene below go on
+void NGIEngine::popScene() {
+ Scene *scene = getCurrentScene();
+ if (!scene || _sceneStack.size() < 2) {
+ warning("No scene to pop");
+ return;
+ }
+ scene->onHide();
+ if (scene->_soundList)
+ scene->stopAllSounds();
+ _sceneStack.pop_back();
+ pauseSceneSounds(false);
+ if (_sceneStack.size() < 2) {
+ Common::Keymapper *mapper = _system->getEventManager()->getKeymapper();
+ mapper->setGameKeymapState("ngi-default", true);
+ mapper->setGameKeymapState("dialog", false);
+ }
+}
+
+// CGame::Render with a scene stack: a scene draws when all above it are putPrev,
+// the inventory after the last scene that shows it
+void NGIEngine::renderSceneStack() {
+ int inventoryAfter = (int)_sceneStack.size() - 1;
+ for (uint i = 0; i < _sceneStack.size(); i++) {
+ if (!_sceneStack[i]->isInventoryRendered())
+ inventoryAfter = (int)i - 1;
+ }
+ bool first = true;
+ for (uint i = 0; i < _sceneStack.size(); i++) {
+ bool visible = true;
+ for (uint j = i + 1; j < _sceneStack.size(); j++)
+ visible = visible && _sceneStack[j]->_putPrev;
+ if (visible) {
+ _sceneStack[i]->render(first);
+ first = false;
+ }
+ if (inventoryAfter == (int)i && isInventoryRendered() && _inventoryScene) {
+ getGameLoaderInventory()->render();
+ if (_inventoryScene->_guiManager)
+ _inventoryScene->_guiManager->render(_backgroundSurface);
+ }
+ }
+}
+
+// CGame::OnMouse*, OnKeyUp: events go to the current scene; dialog back button = key 4 on Android
+bool NGIEngine::handleSceneStackEvent(const Common::Event &event) {
+ Scene *scene = getCurrentScene();
+ if (!scene)
+ return false;
+ switch (event.type) {
+ case Common::EVENT_LBUTTONDOWN:
+ return scene->onMouseLKeyDown(0, event.mouse.x, event.mouse.y);
+ case Common::EVENT_LBUTTONUP:
+ return scene->onMouseLKeyUp(0, event.mouse.x, event.mouse.y);
+ case Common::EVENT_RBUTTONDOWN:
+ return scene->onMouseRKeyDown(0, event.mouse.x, event.mouse.y);
+ case Common::EVENT_RBUTTONUP:
+ return scene->onMouseRKeyUp(0, event.mouse.x, event.mouse.y);
+ case Common::EVENT_MOUSEMOVE:
+ return scene->onMouseMove(0, event.mouse.x, event.mouse.y);
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_END:
+ if (event.customType == kActionCloseDialog)
+ scene->onKeyUp(4); // AKEYCODE_BACK
+ return true;
+ default:
+ return false;
+ }
+}
+
Scene *GameProject::findScene(int sceneId) {
for (SceneTag &tag : *_sceneTagList) {
if (tag._sceneId != sceneId)
@@ -728,6 +870,101 @@ void Scene::renderDebug() {
// CMotion8Controller::RenderDbg (the grid) has no counterpart yet
}
+// CScene::OnShow (the parts that are ported): the controller, the behaviors
+void Scene::onShow() {
+ if (_behaviorController)
+ _behaviorController->onShow(*this);
+ if (_controller)
+ _controller->onShow();
+}
+
+// CScene::OnHide (the parts that are ported): the controller and the GUI
+void Scene::onHide() {
+ if (_controller)
+ _controller->onHide();
+ // CBehaviorController::OnHide (stops the behavior sounds) and CPhysListener::OnHide are not ported
+ if (_guiManager)
+ _guiManager->onHide();
+}
+
+// CScene::OnMouseLKeyDown: controller (Top), GUI, controller
+bool Scene::onMouseLKeyDown(uint32 id, float x, float y) {
+ const float sceneX = x + _x;
+ const float sceneY = y + _y;
+ if (!_controller || !_controller->onMouseLKeyDownTop(id, sceneX, sceneY)) {
+ if (!_guiManager || !_guiManager->onMouseLKeyDown(Common::Point(x, y))) {
+ if (_controller)
+ _controller->onMouseLKeyDown(id, sceneX, sceneY);
+ }
+ }
+ return false;
+}
+
+// CScene::OnMouseLKeyUp: the same order; when none of them handles it the interaction under the cursor starts (CInteractionController::FindInteraction
+// and TryStartInteract: not ported here, the controllers of the scenes do it, see FPController::onTap)
+bool Scene::onMouseLKeyUp(uint32 id, float x, float y) {
+ const float sceneX = x + _x;
+ const float sceneY = y + _y;
+ if (!_controller || !_controller->onMouseLKeyUpTop(id, sceneX, sceneY)) {
+ if (!_guiManager || !_guiManager->onMouseLKeyUp(Common::Point(x, y))) {
+ if (_controller)
+ _controller->onMouseLKeyUp(id, sceneX, sceneY);
+ }
+ }
+ return false;
+}
+
+bool Scene::onMouseRKeyDown(uint32 id, float x, float y) {
+ const float sceneX = x + _x;
+ const float sceneY = y + _y;
+ if (!_controller || !_controller->onMouseRKeyDownTop(id, sceneX, sceneY)) {
+ if (!_guiManager || !_guiManager->onMouseRKeyDown(Common::Point(x, y))) {
+ if (_controller)
+ _controller->onMouseRKeyDown(id, sceneX, sceneY);
+ }
+ }
+ return false;
+}
+
+bool Scene::onMouseRKeyUp(uint32 id, float x, float y) {
+ const float sceneX = x + _x;
+ const float sceneY = y + _y;
+ if (!_controller || !_controller->onMouseRKeyUpTop(id, sceneX, sceneY)) {
+ if (!_guiManager || !_guiManager->onMouseRKeyUp(Common::Point(x, y))) {
+ if (_controller)
+ _controller->onMouseRKeyUp(id, sceneX, sceneY);
+ }
+ }
+ return false;
+}
+
+bool Scene::onMouseMove(uint32 id, float x, float y) {
+ const float sceneX = x + _x;
+ const float sceneY = y + _y;
+ if (!_controller || !_controller->onMouseMoveTop(id, sceneX, sceneY)) {
+ if (_guiManager)
+ _guiManager->onMouseMove(Common::Point(x, y));
+ if (_controller)
+ _controller->onMouseMove(id, sceneX, sceneY);
+ }
+ return false;
+}
+
+// CScene::OnKeyUp: the controller
+void Scene::onKeyUp(uint32 key) {
+ if (_controller)
+ _controller->onKeyUp(key);
+}
+
+// CScene::IsInventoryRendered / IsInventoryEnabled: the controller decides
+bool Scene::isInventoryRendered() const {
+ return _controller && _controller->isInventoryRendered();
+}
+
+bool Scene::isInventoryEnabled() const {
+ return _controller && _controller->isInventoryEnabled();
+}
+
// CScene::SetController: the scene keeps the controller, the controller its scene
void Scene::setController(ISceneController *controller) {
_controller.reset(controller);
@@ -891,7 +1128,7 @@ bool Scene::update(int counterdiff) {
for (MessageQueue *queue : *g_ngi->_globalMessageQueueList)
changed |= queue->updateCmdUser();
processMessages();
- if (g_ngi->_modalObject || this != g_ngi->_currentScene)
+ if (g_ngi->_modalObject || this != g_ngi->getCurrentScene())
return true;
}
if (_guiManager)
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index b565300b723..fad31fdbdfc 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -98,6 +98,20 @@ class Scene : public Background {
void setController(ISceneController *controller);
/** CScene +392 (GetCurrentEntranceId): the entrance the scene was shown through, 0 if none */
int _currentEntranceId = 0;
+ /** CScene +37 (SCENE putPrev): the scene is drawn over the one below it instead of replacing it */
+ bool _putPrev = false;
+ /** CScene::OnShow / OnHide: the parts that the controllers, the behaviors and the GUI need */
+ void onShow();
+ void onHide();
+ /** CScene::OnMouseLKeyDown ...: controller (Top), GUI, controller */
+ bool onMouseLKeyDown(uint32 id, float x, float y);
+ bool onMouseLKeyUp(uint32 id, float x, float y);
+ bool onMouseRKeyDown(uint32 id, float x, float y);
+ bool onMouseRKeyUp(uint32 id, float x, float y);
+ bool onMouseMove(uint32 id, float x, float y);
+ void onKeyUp(uint32 key);
+ bool isInventoryRendered() const;
+ bool isInventoryEnabled() const;
void (*_guiEventHandler)(Scene &, const Common::String &, const Common::String &) = nullptr;
void onGuiEvent(const Common::String &id, const Common::String &event);
Common::Array<MessageQueue *> _messageQueues;
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index ae257b406f7..b5c6f79c6e6 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -918,6 +918,7 @@ private:
return parserError("Unknown scene hero");
_scene._sceneName = node->values.getValOrDefault("title");
_scene._drawOffset = node->values.contains("drawOffset") ? atoi(node->values["drawOffset"].c_str()) : -1;
+ _scene._putPrev = node->values.getValOrDefault("putPrev") == "true" || node->values.getValOrDefault("putPrev") == "1";
_scene._dims = Dims(atoi(node->values.getValOrDefault("width", Common::String::format("%d", g_ngi->gameWidth())).c_str()),
atoi(node->values.getValOrDefault("height", Common::String::format("%d", g_ngi->_backgroundSurface.h)).c_str()));
_scene._x = strtod(node->values.getValOrDefault("scrollX").c_str(), nullptr);
Commit: f416e495e9b105dbd478ebd8fea4b7893ba8de7c
https://github.com/scummvm/scummvm/commit/f416e495e9b105dbd478ebd8fea4b7893ba8de7c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:02+01:00
Commit Message:
NGI: Make CNotebookController a controller of its pushed scene, drop the modal notebook
Changed paths:
R engines/ngi/fullpipe/sceneNotebook.cpp
engines/ngi/fullpipe/constants.h
engines/ngi/fullpipe/fpcontroller.h
engines/ngi/fullpipe/notebook.cpp
engines/ngi/fullpipe/notebook.h
engines/ngi/fullpipe/sc03controller.h
engines/ngi/fullpipe/scene03.cpp
engines/ngi/fullpipe/sceneTutorial.cpp
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/scenes.h
engines/ngi/fullpipe/taskmanager.cpp
engines/ngi/module.mk
engines/ngi/ngi.h
engines/ngi/scene.cpp
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index 986ff3a9c9a..7405a8eed8a 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -240,7 +240,11 @@ namespace NGI {
#define SC_36 2070
#define SC_37 2071
#define SC_38 2072
+#define SC_HELP 10002 // Android
+#define SC_LIFT 10003 // Android
+#define SC_NOTEBOOK 10005 // Android
#define SC_CHAPTER 10006 // Android
+#define SC_TUTORIAL 11000 // Android
#define SC_COMMON 321
#define SC_DBGMENU 726
#define SC_FINAL1 4999
diff --git a/engines/ngi/fullpipe/fpcontroller.h b/engines/ngi/fullpipe/fpcontroller.h
index 8db15c39711..c9fd4072b37 100644
--- a/engines/ngi/fullpipe/fpcontroller.h
+++ b/engines/ngi/fullpipe/fpcontroller.h
@@ -47,6 +47,8 @@ public:
bool onMouseLKeyUp(uint32 id, float x, float y) override;
void executeUserCmd(Command *cmd, MessageQueue *queue) override;
bool updateUserCmd(Command *cmd, uint32 elapsed) override;
+ bool isInventoryEnabled() override { return true; }
+ bool isInventoryRendered() override { return true; }
/** The tap of CFPController::OnMouseLKeyUp (position in scene coordinates): an interaction of the object under the finger, else the hero walks to the point */
bool onTap(float x, float y);
diff --git a/engines/ngi/fullpipe/notebook.cpp b/engines/ngi/fullpipe/notebook.cpp
index 849909625e7..2d63a81391c 100644
--- a/engines/ngi/fullpipe/notebook.cpp
+++ b/engines/ngi/fullpipe/notebook.cpp
@@ -29,6 +29,7 @@
#include "ngi/anihandler.h"
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/guimanager.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/notebook.h"
#include "ngi/scene.h"
#include "ngi/fullpipe/scenes.h"
@@ -57,6 +58,27 @@ enum {
kPicBookmark = 23246 // PIC_INV_BOOKMARK_L
};
+enum {
+ kPicStamp = 23244, // PIC_INV_COMPL_TASK_P: the "completed" stamp, tilted
+ kPicCheck = 23243, // PIC_INV_COMPL_TASK: the check mark on the bookmark of a closed task
+ kPicBookmarkGreen = 23247, // PIC_INV_BOOKMARK_G
+ kPicScratchText = 23261, // PIC_FOLGA_TEXT
+ kPicScratchAlpha = 23262, // PIC_FOLGA_TEXT_ALPHA
+ kPicBlocked = 23263, // PIC_HINT_BLOCKED
+ kPicFoil = 23265, // PIC_TASK_FOIL
+ kPicFoilBack = 23266, // PIC_TASK_FOIL_BACK
+ kPicLine = 23271 // PIC_TASK_LINE
+};
+
+// CHyperText marks the words that open the catalog with [command]; the links are not ported
+Common::String plainText(Common::String text) {
+ while (text.contains("[command]")) {
+ const uint at = text.find("[command]");
+ text.erase(at, 9);
+ }
+ return text;
+}
+
void warnOnce(const char *what) {
static Common::HashMap<Common::String, bool> reported;
if (!reported.contains(what)) {
@@ -145,15 +167,19 @@ bool Foil::nextPoint(uint32 elapsed) {
return getCleanPercent() < 1.0f;
}
-Notebook::Notebook() {
+// CNotebookController::CNotebookController: the controller is also the notebook of the engine
+Notebook::Notebook(int sceneId) : ISceneController(sceneId) {
+ g_ngi->_notebook = this;
}
Notebook::~Notebook() {
clearHints();
+ if (g_ngi->_notebook == this)
+ g_ngi->_notebook = nullptr;
}
-void Notebook::onSceneInit(Scene &scene) {
- _scene = &scene;
+// CNotebookController::OnSceneInit
+void Notebook::onSceneInit() {
}
void Notebook::play(int soundId) {
@@ -435,13 +461,20 @@ void Notebook::updateBuyPage(int page) {
}
void Notebook::onShow() {
+ // the texts and the fonts (CFontController::GetFont, CTextContainer)
+ _russian = g_ngi->getResourceLocale() == Common::String("ru");
+ const Common::Path directory(Common::String("data/res_") + g_ngi->getResourceLocale());
+ const Common::Path fonts = directory.join("Fonts");
+ if (!_texts.load(directory) || !_headingFont.load(fonts.join("task_dlg_29.fnt")) || !_font.load(fonts.join("task_dlg_25.fnt")) ||
+ !_hintFont.load(fonts.join(_russian ? "task_dlg_19.fnt" : "task_dlg_17_smile.fnt")))
+ warning("Could not load the texts or fonts of the notebook");
+
// (the original scrolls the inventory out of the way here, CInventoryController::ScrollOut)
_current = -1;
_pressed = false;
_blinkTimer = -1;
_pulse = _pulseStep = _pulseWait = 0;
_blinkStep = 0;
- _closeRequested = false;
_autoFoil = false;
_autoFoilHint = -1;
@@ -513,14 +546,14 @@ void Notebook::removeFoil(uint32 elapsed) {
_autoFoil = false;
}
-void Notebook::onMessage(const Common::String &name, const Common::String ¶m) {
+void Notebook::onMessage(const Common::String &name, const Common::String ¶m, MessageQueue *queue) {
if (name == "TASK_STATE_CHANGED") {
showGiveButtonHint(isTimerShowing());
updateChapterTasks(param);
updateCurrentTask();
if (isTimerShowing() && !_tasks.empty())
blockHints();
- if (_open) {
+ if (g_ngi->isSceneInStack(SC_NOTEBOOK)) {
updateBookMarks();
updateHints();
}
@@ -535,25 +568,28 @@ void Notebook::onMessage(const Common::String &name, const Common::String ¶m
}
}
-void Notebook::onMouseLKeyDown(Common::Point pos) {
+bool Notebook::onMouseLKeyDown(uint32 id, float x, float y) {
+ const Common::Point pos(x, y);
_pressed = true;
const Task *task = currentTask();
if (!task || _page == kPageCatalog)
- return;
+ return false;
if (g_ngi->_taskManager->getTime() != -1 && task->_state != Task::kStateClosed)
- return;
+ return false;
for (uint i = 0; i < _foils.size(); i++) {
if (_foils[i]->hit(pos) && !task->isHintShowing(_foilHints[i]) && !task->isHintBlocked(_foilHints[i])) {
_foils[i]->onMouseLKeyDown(pos);
- return;
+ return false;
}
}
+ return false;
}
-void Notebook::onMouseMove(Common::Point pos) {
+bool Notebook::onMouseMove(uint32 id, float x, float y) {
+ const Common::Point pos(x, y);
const Task *task = currentTask();
if (!task || _page == kPageCatalog)
- return;
+ return false;
for (uint i = 0; i < _foils.size(); i++) {
if (!_foils[i]->hit(pos) || task->isHintBlocked(_foilHints[i]))
continue;
@@ -561,11 +597,13 @@ void Notebook::onMouseMove(Common::Point pos) {
if (_pressed && (g_ngi->_taskManager->getTime() == -1 || task->_state == Task::kStateClosed) &&
_foils[i]->isEnd() && !task->isHintShowing(_foilHints[i]))
showHint(_foilHints[i]);
- return;
+ return false;
}
+ return false;
}
-void Notebook::onMouseLKeyUp(Common::Point pos) {
+bool Notebook::onMouseLKeyUp(uint32 id, float x, float y) {
+ const Common::Point pos(x, y);
// A click outside of the book closes it
bool onBook = false;
if (_scene) {
@@ -576,8 +614,8 @@ void Notebook::onMouseLKeyUp(Common::Point pos) {
onBook |= _bookmarks[i].contains(pos);
if (!onBook) {
updateBuyPage(kPageTask);
- _closeRequested = true;
- return;
+ g_ngi->popScene(); // CGame::PopScene
+ return true;
}
for (uint i = 0; i < _bookmarks.size(); i++) {
@@ -592,7 +630,7 @@ void Notebook::onMouseLKeyUp(Common::Point pos) {
updateBookMarks();
}
_pressed = false;
- return;
+ return true;
}
if (_page != kPageCatalog) {
@@ -611,6 +649,26 @@ void Notebook::onMouseLKeyUp(Common::Point pos) {
}
}
_pressed = false;
+ return true;
+}
+
+// CNotebookController::OnKeyUp: the back button presses the button of the page that is shown
+void Notebook::onKeyUp(uint32 key) {
+ if (key != 4)
+ return;
+ switch (_page) {
+ case kPageTask:
+ onGuiEvent("BTN_SC_NOTEBOOK_CLOSE", "unpress");
+ break;
+ case kPageBuy:
+ onGuiEvent("BTN_MENU_BAY_BACK", "unpress");
+ break;
+ case kPageCatalog:
+ onGuiEvent("BTN_MARK_CATALOG", "unpress");
+ break;
+ default:
+ break;
+ }
}
// CNotebookController::OnGuiEvent: the buttons of the notebook
@@ -641,8 +699,151 @@ void Notebook::onGuiEvent(const Common::String &id, const Common::String &event)
updateBuyPage(kPageCatalog);
} else if (id == "BTN_SC_NOTEBOOK_CLOSE") {
updateBuyPage(kPageTask);
- _closeRequested = true;
+ g_ngi->popScene(); // CGame::PopScene
+ }
+}
+
+void Notebook::blit(int id, int x, int y, int angle) const {
+ PictureObject *picture = _scene->findPictureObjectById(id, 0);
+ if (picture && picture->_picture)
+ picture->_picture->blitTo(g_ngi->_backgroundSurface, Common::Point(x, y), false, angle);
+}
+
+Dims Notebook::size(int id) const {
+ PictureObject *picture = _scene->findPictureObjectById(id, 0);
+ return picture ? picture->getFullSize() : Dims();
+}
+
+void Notebook::text(const BitmapFont &font, const Common::Rect &bounds, const Common::String &string) const {
+ font.drawCentered(g_ngi->_backgroundSurface, bounds, string);
+}
+
+
+// CNotebookController::RenderBookMarks. The labels of the tabs are printed rotated by a quarter turn in the original;
+// they are not drawn here, only the numbers (horizontally).
+void Notebook::renderBookmarks() const {
+ const Notebook ¬ebook = *this;
+ bool green = false;
+ for (int pass = 0; pass < 2; pass++) { // the tab that is open on top
+ for (uint i = 0; i < notebook._tasks.size(); i++) {
+ const bool selected = (int)i == notebook._current && notebook._page == Notebook::kPageTask;
+ if (selected != (pass == 1))
+ continue;
+ int picture = kPicBookmark;
+ if (selected) {
+ picture = kPicBookmarkActive;
+ } else if (notebook._page == Notebook::kPageTask && green) {
+ picture = kPicBookmarkGreen;
+ }
+ if (!selected && notebook._page == Notebook::kPageTask)
+ green = !green;
+ const int x = 60;
+ const int y = 117 + 45 * i;
+ blit(picture, x, y);
+ if (notebook._tasks[i]->_state == Task::kStateClosed) {
+ const int offset = selected ? 8 : ((notebook._current == -1 || (int)i <= notebook._current) ? 6 : 75);
+ blit(kPicCheck, x + 8, y + offset);
+ }
+ const Dims bookmark = size(picture);
+ text(_font, Common::Rect(x, y, x + bookmark.x, y + bookmark.y), Common::String::format("%d", i + 1));
+ }
+ }
+}
+
+
+// CNotebookController::OnRenderMenuTask
+void Notebook::renderTaskPage() const {
+ const Notebook ¬ebook = *this;
+ const Task *task = notebook.currentTask();
+ if (!task) {
+ text(_font, Common::Rect(130, 210, 380, 360), _texts.getText("STR_TASK_CONTROLLER_NO_TASK"));
+ return;
}
+
+ // Headings: the task, and the hints while the task is open
+ text(_headingFont, Common::Rect(177, 121, 327, 151), _texts.getText("STR_TASK_CONTROLLER_QUESTION"));
+ if (task->_state != Task::kStateClosed && sceneTutorial_isCompleted())
+ text(_headingFont, Common::Rect(507, 121, 657, 151), _texts.getText("STR_TASK_CONTROLLER_HINT"));
+
+ text(_font, Common::Rect(130, 240, 380, 360), plainText(_texts.getText(task->_textId)));
+ if (task->_state == Task::kStateClosed) {
+ const int angle = notebook._current < (int)notebook._angles.size() ? (int)notebook._angles[notebook._current] : 0;
+ blit(kPicStamp, 180, 380, angle);
+ }
+ blit(kPicLine, 130, 185);
+
+ if (notebook.isTimerShowing() && task->_state != Task::kStateClosed && notebook._blinkTimer + 199 <= 398) {
+ const int time = g_ngi->_taskManager->getTime();
+ const Common::String clock = Common::String::format("%02d : %02d", time / 60000, (time - 60000 * (time / 60000)) / 1000);
+ const int top = 490 - (_russian ? 5 : 0);
+ text(_russian ? _headingFont : _font, Common::Rect(455, top, 680, top + 74), clock);
+ }
+
+ if (task->_state != Task::kStateClosed) {
+ for (uint i = 0; i < notebook._foils.size(); i++) {
+ text(_font, Common::Rect(438, 200 + 110 * i - 15, 478, 200 + 110 * i + 15), Common::String::format("%d", i + 1));
+ text(_hintFont, Common::Rect(479, 180 + 110 * i, 479 + 221, 180 + 110 * i + 90),
+ plainText(_texts.getText(task->getHintText(notebook._foilHints[i]))));
+ }
+ }
+}
+
+
+// CNotebookController::OnRenderTopMenuTask and CFoil::Render
+void Notebook::renderFoils() const {
+ const Notebook ¬ebook = *this;
+ const Task *task = notebook.currentTask();
+ if (!task || notebook._page != Notebook::kPageTask || task->_state == Task::kStateClosed)
+ return;
+
+ const Dims piece = size(kPicFoil);
+ for (uint i = 0; i < notebook._foils.size(); i++) {
+ const Foil &foil = *notebook._foils[i];
+ blit(kPicFoilBack, foil._area.left + 4, foil._area.top + 4);
+ for (int column = 0; column < foil._columns; column++) {
+ for (int row = 0; row < foil._rows; row++) {
+ const int index = column + row * foil._columns;
+ if (foil._covered[index])
+ blit(kPicFoil, foil._x + column * Foil::kPiece - piece.x / 2, foil._y + row * Foil::kPiece - piece.y / 2, foil._angles[index]);
+ }
+ }
+ }
+ for (uint i = 0; i < notebook._foils.size(); i++) {
+ const Foil &foil = *notebook._foils[i];
+ if (!foil.isStart())
+ continue;
+ const int centerX = (foil._area.left + foil._area.right) / 2;
+ const int centerY = (foil._area.top + foil._area.bottom) / 2;
+ int picture = kPicBlocked;
+ if (!task->isHintBlocked(notebook._foilHints[i]))
+ picture = notebook._pulse <= 499 ? kPicScratchAlpha : kPicScratchText; // flashes
+ const Dims marker = size(picture);
+ blit(picture, centerX - marker.x / 2, centerY - marker.y / 2);
+ }
+}
+
+// CNotebookController::OnRender: the page that is shown, then the bookmarks
+void Notebook::onRender(Common::Point) {
+ switch (_page) {
+ case kPageBuy:
+ warnOnce("CNotebookController::OnRenderMenuBuy is not ported");
+ break;
+ case kPageCatalog:
+ warnOnce("CCatalogManager::OnRenderCatalogInfo is not ported");
+ break;
+ case kPageTask:
+ renderTaskPage();
+ break;
+ default:
+ break;
+ }
+ renderBookmarks();
+}
+
+// CNotebookController::OnRenderTop: the foils over the hints of the task page
+void Notebook::onRenderTop(Common::Point) {
+ if (_page == kPageTask)
+ renderFoils();
}
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/notebook.h b/engines/ngi/fullpipe/notebook.h
index f6e28c72f79..98bf932b297 100644
--- a/engines/ngi/fullpipe/notebook.h
+++ b/engines/ngi/fullpipe/notebook.h
@@ -27,9 +27,11 @@
#include "common/rect.h"
#include "common/str.h"
+#include "ngi/font.h"
+#include "ngi/scenecontroller.h"
+
namespace NGI {
-class Scene;
class Task;
// A cover over a hint that is scratched off with the pointer (CFoil): a grid of 18 pixel pieces. The hint counts as
@@ -73,30 +75,30 @@ private:
int _timer = -410;
};
-// The logic of the notebook (CNotebookController): the tasks of the active chapter, the page that is shown, the
-// hints with their foils and the hint bonuses and timer. The pages are drawn by the dialog (fullpipe/sceneNotebook.cpp).
-class Notebook {
+/** CNotebookController: SC_NOTEBOOK (0x2715), pushed over the game by CGame::PushScene */
+class Notebook : public ISceneController {
public:
enum Page { kPageTask = 0, kPageBuy = 1, kPageCatalog = 2 };
- Notebook();
- ~Notebook();
-
- // The scene of the notebook (SC_NOTEBOOK); the GUI elements of its GUIMNGR are switched from here
- void onSceneInit(Scene &scene);
- void onShow();
- void onHide();
- void onUpdate(uint32 elapsed);
- void onMessage(const Common::String &name, const Common::String ¶m);
- void onGuiEvent(const Common::String &id, const Common::String &event);
- void onMouseLKeyDown(Common::Point pos);
- void onMouseLKeyUp(Common::Point pos);
- void onMouseMove(Common::Point pos);
+ explicit Notebook(int sceneId);
+ ~Notebook() override;
+
+ void onSceneInit() override;
+ void onShow() override;
+ void onHide() override;
+ void onUpdate(uint32 elapsed) override;
+ void onRender(Common::Point scroll) override;
+ void onRenderTop(Common::Point scroll) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+ void onGuiEvent(const Common::String &id, const Common::String &event) override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ bool onMouseMove(uint32 id, float x, float y) override;
+ void onKeyUp(uint32 key) override;
+ bool isInventoryRendered() override { return true; }
+ bool isInventoryEnabled() override { return true; }
void setTutorial(bool tutorial) { _tutorial = tutorial; }
- void setOpen(bool open) { _open = open; }
- bool isOpen() const { return _open; }
- bool wantsClose() const { return _closeRequested; }
// Task lists
void sortTasks();
@@ -134,11 +136,8 @@ public:
Common::Array<Common::Rect> _bookmarks; // hit areas of the bookmarks (60, 117 + 45 * i)
private:
- Scene *_scene = nullptr;
- bool _open = false;
bool _tutorial = false;
bool _pressed = false;
- bool _closeRequested = false;
bool _autoFoil = false;
int _autoFoilHint = -1;
int _pulseWait = 0;
@@ -150,6 +149,20 @@ private:
void updateBonusCount();
void setBonusVisible(bool visible);
void play(int soundId);
+
+ // CNotebookController::OnRender / OnRenderTop and what they call
+ void blit(int id, int x, int y, int angle = 0) const;
+ Dims size(int id) const;
+ void text(const BitmapFont &font, const Common::Rect &bounds, const Common::String &string) const;
+ void renderBookmarks() const;
+ void renderTaskPage() const;
+ void renderFoils() const;
+
+ TextContainer _texts;
+ BitmapFont _headingFont; // task_dlg_29.fnt
+ BitmapFont _font; // task_dlg_25.fnt
+ BitmapFont _hintFont; // task_dlg_19.fnt (ru) or task_dlg_17_smile.fnt
+ bool _russian = false;
};
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sc03controller.h b/engines/ngi/fullpipe/sc03controller.h
index 6322d260587..e7e30dd7ee3 100644
--- a/engines/ngi/fullpipe/sc03controller.h
+++ b/engines/ngi/fullpipe/sc03controller.h
@@ -33,6 +33,7 @@ public:
void onShow() override;
void onRender(Common::Point scroll) override;
+ bool isInventoryEnabled() override;
};
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/scene03.cpp b/engines/ngi/fullpipe/scene03.cpp
index 81eeb4e5824..0d96df15cd3 100644
--- a/engines/ngi/fullpipe/scene03.cpp
+++ b/engines/ngi/fullpipe/scene03.cpp
@@ -60,6 +60,11 @@ void Sc03Controller::onShow() {
_offsetY = 300;
}
+// CSc03Controller::IsInventoryEnabled: CTutorialManager::IsTutorialCompleted
+bool Sc03Controller::isInventoryEnabled() {
+ return sceneTutorial_isCompleted();
+}
+
// CSc03Controller::OnRender: a cloud with the text at a fixed place of the screen
void Sc03Controller::onRender(Common::Point) {
if (g_vars->scene03_hintTimer <= 0 || !g_vars->scene03_hintFont)
diff --git a/engines/ngi/fullpipe/sceneNotebook.cpp b/engines/ngi/fullpipe/sceneNotebook.cpp
deleted file mode 100644
index ebac19f4557..00000000000
--- a/engines/ngi/fullpipe/sceneNotebook.cpp
+++ /dev/null
@@ -1,291 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-#include "ngi/ngi.h"
-#include "ngi/fullpipe/constants.h"
-#include "ngi/font.h"
-#include "ngi/gameloader.h"
-#include "ngi/modal.h"
-#include "ngi/anihandler.h"
-#include "ngi/fullpipe/chaptermanager.h"
-#include "ngi/guimanager.h"
-#include "ngi/fullpipe/notebook.h"
-#include "ngi/fullpipe/scenes.h"
-#include "ngi/fullpipe/taskmanager.h"
-
-namespace NGI {
-
-namespace {
-
-enum {
- kPicStamp = 23244, // PIC_INV_COMPL_TASK_P: the "completed" stamp, tilted
- kPicCheck = 23243, // PIC_INV_COMPL_TASK: the check mark on the bookmark of a closed task
- kPicBookmark = 23246, // PIC_INV_BOOKMARK_L
- kPicBookmarkGreen = 23247, // PIC_INV_BOOKMARK_G
- kPicBookmarkActive = 23245, // PIC_INV_BOOKMARK_ACT
- kPicScratchText = 23261, // PIC_FOLGA_TEXT
- kPicScratchAlpha = 23262, // PIC_FOLGA_TEXT_ALPHA
- kPicBlocked = 23263, // PIC_HINT_BLOCKED
- kPicFoil = 23265, // PIC_TASK_FOIL
- kPicFoilBack = 23266, // PIC_TASK_FOIL_BACK
- kPicLine = 23271 // PIC_TASK_LINE
-};
-
-// CHyperText marks the words that open the catalog with [command]; the links are not ported
-Common::String plainText(Common::String text) {
- while (text.contains("[command]")) {
- const uint at = text.find("[command]");
- text.erase(at, 9);
- }
- return text;
-}
-
-class ModalNotebook : public BaseModalObject {
-public:
- explicit ModalNotebook(Scene &scene) : _scene(scene) {}
-
- const Scene *getScene() const override { return &_scene; }
-
- ~ModalNotebook() override {
- if (_opened) {
- _scene._guiEventHandler = nullptr;
- g_ngi->_notebook->onHide();
- g_ngi->_notebook->setOpen(false);
- }
- }
-
- bool open() {
- const bool russian = g_ngi->getResourceLocale() == Common::String("ru");
- const Common::Path directory(Common::String("data/res_") + g_ngi->getResourceLocale());
- const Common::Path fonts = directory.join("Fonts");
- if (!_texts.load(directory) || !_headingFont.load(fonts.join("task_dlg_29.fnt")) || !_font.load(fonts.join("task_dlg_25.fnt")) ||
- !_hintFont.load(fonts.join(russian ? "task_dlg_19.fnt" : "task_dlg_17_smile.fnt")) || !_scene._guiManager)
- return false;
- _russian = russian;
-
- Notebook ¬ebook = *g_ngi->_notebook;
- notebook.onSceneInit(_scene);
- _scene._guiEventHandler = onGuiEvent;
- notebook.setOpen(true);
- notebook.onShow();
- _opened = true;
- return true;
- }
-
- bool pollEvent() override { return true; }
- void saveload() override {}
-
- bool init(int elapsed) override {
- Notebook ¬ebook = *g_ngi->_notebook;
- notebook.onUpdate(elapsed);
- _scene.update(elapsed);
- return !notebook.wantsClose();
- }
-
- bool handleMessage(Command *cmd) override {
- if (cmd->_cmd != kCmdMessage)
- return false;
- Notebook ¬ebook = *g_ngi->_notebook;
- const Common::Point pos(cmd->_x, cmd->_y);
- GuiManager &gui = *_scene._guiManager;
- switch (cmd->_messageNum) {
- case kMsgMouseMove:
- gui.onMouseMove(pos);
- notebook.onMouseMove(pos);
- return true;
- case kMsgLButtonDown:
- gui.onMouseMove(pos);
- gui.onMouseLKeyDown(pos);
- notebook.onMouseLKeyDown(pos);
- return true;
- case kMsgLButtonUp: {
- gui.onMouseMove(pos);
- const bool onButton = gui.hit(pos);
- gui.onMouseLKeyUp(pos);
- if (!onButton)
- notebook.onMouseLKeyUp(pos);
- return true;
- }
- case kMsgKeyUp:
- // CNotebookController::OnKeyUp: back presses the button of the page that is shown
- if (cmd->_param == kActionCloseDialog) {
- notebook.onGuiEvent(notebook._page == Notebook::kPageTask ? "BTN_SC_NOTEBOOK_CLOSE" :
- (notebook._page == Notebook::kPageBuy ? "BTN_MENU_BAY_BACK" : "BTN_MARK_CATALOG"), "unpress");
- return true;
- }
- return false;
- default:
- return false;
- }
- }
-
- void update() override {
- g_ngi->_currentScene->render();
- _scene.render(false);
- renderBookmarks();
- if (g_ngi->_notebook->_page == Notebook::kPageTask)
- renderTaskPage();
- renderFoils();
- }
-
-private:
- static void onGuiEvent(Scene &, const Common::String &id, const Common::String &event) {
- g_ngi->_notebook->onGuiEvent(id, event);
- }
-
- void blit(int id, int x, int y, int angle = 0) const {
- PictureObject *picture = _scene.findPictureObjectById(id, 0);
- if (picture && picture->_picture)
- picture->_picture->blitTo(g_ngi->_backgroundSurface, Common::Point(x, y), false, angle);
- }
-
- Dims size(int id) const {
- PictureObject *picture = _scene.findPictureObjectById(id, 0);
- return picture ? picture->getFullSize() : Dims();
- }
-
- void text(const BitmapFont &font, const Common::Rect &bounds, const Common::String &string) const {
- font.drawCentered(g_ngi->_backgroundSurface, bounds, string);
- }
-
- // CNotebookController::RenderBookMarks. The labels of the tabs are printed rotated by a quarter turn in the original;
- // they are not drawn here, only the numbers (horizontally).
- void renderBookmarks() const {
- const Notebook ¬ebook = *g_ngi->_notebook;
- bool green = false;
- for (int pass = 0; pass < 2; pass++) { // the tab that is open on top
- for (uint i = 0; i < notebook._tasks.size(); i++) {
- const bool selected = (int)i == notebook._current && notebook._page == Notebook::kPageTask;
- if (selected != (pass == 1))
- continue;
- int picture = kPicBookmark;
- if (selected) {
- picture = kPicBookmarkActive;
- } else if (notebook._page == Notebook::kPageTask && green) {
- picture = kPicBookmarkGreen;
- }
- if (!selected && notebook._page == Notebook::kPageTask)
- green = !green;
- const int x = 60, y = 117 + 45 * i;
- blit(picture, x, y);
- if (notebook._tasks[i]->_state == Task::kStateClosed) {
- const int offset = selected ? 8 : ((notebook._current == -1 || (int)i <= notebook._current) ? 6 : 75);
- blit(kPicCheck, x + 8, y + offset);
- }
- const Dims bookmark = size(picture);
- text(_font, Common::Rect(x, y, x + bookmark.x, y + bookmark.y), Common::String::format("%d", i + 1));
- }
- }
- }
-
- // CNotebookController::OnRenderMenuTask
- void renderTaskPage() const {
- const Notebook ¬ebook = *g_ngi->_notebook;
- const Task *task = notebook.currentTask();
- if (!task) {
- text(_font, Common::Rect(130, 210, 380, 360), _texts.getText("STR_TASK_CONTROLLER_NO_TASK"));
- return;
- }
-
- // Headings: the task, and the hints while the task is open
- text(_headingFont, Common::Rect(177, 121, 327, 151), _texts.getText("STR_TASK_CONTROLLER_QUESTION"));
- if (task->_state != Task::kStateClosed && sceneTutorial_isCompleted())
- text(_headingFont, Common::Rect(507, 121, 657, 151), _texts.getText("STR_TASK_CONTROLLER_HINT"));
-
- text(_font, Common::Rect(130, 240, 380, 360), plainText(_texts.getText(task->_textId)));
- if (task->_state == Task::kStateClosed) {
- const int angle = notebook._current < (int)notebook._angles.size() ? (int)notebook._angles[notebook._current] : 0;
- blit(kPicStamp, 180, 380, angle);
- }
- blit(kPicLine, 130, 185);
-
- if (notebook.isTimerShowing() && task->_state != Task::kStateClosed && notebook._blinkTimer + 199 <= 398) {
- const int time = g_ngi->_taskManager->getTime();
- const Common::String clock = Common::String::format("%02d : %02d", time / 60000, (time - 60000 * (time / 60000)) / 1000);
- const int top = 490 - (_russian ? 5 : 0);
- text(_russian ? _headingFont : _font, Common::Rect(455, top, 680, top + 74), clock);
- }
-
- if (task->_state != Task::kStateClosed) {
- for (uint i = 0; i < notebook._foils.size(); i++) {
- text(_font, Common::Rect(438, 200 + 110 * i - 15, 478, 200 + 110 * i + 15), Common::String::format("%d", i + 1));
- text(_hintFont, Common::Rect(479, 180 + 110 * i, 479 + 221, 180 + 110 * i + 90),
- plainText(_texts.getText(task->getHintText(notebook._foilHints[i]))));
- }
- }
- }
-
- // CNotebookController::OnRenderTopMenuTask and CFoil::Render
- void renderFoils() const {
- const Notebook ¬ebook = *g_ngi->_notebook;
- const Task *task = notebook.currentTask();
- if (!task || notebook._page != Notebook::kPageTask || task->_state == Task::kStateClosed)
- return;
-
- const Dims piece = size(kPicFoil);
- for (uint i = 0; i < notebook._foils.size(); i++) {
- const Foil &foil = *notebook._foils[i];
- blit(kPicFoilBack, foil._area.left + 4, foil._area.top + 4);
- for (int column = 0; column < foil._columns; column++) {
- for (int row = 0; row < foil._rows; row++) {
- const int index = column + row * foil._columns;
- if (foil._covered[index])
- blit(kPicFoil, foil._x + column * Foil::kPiece - piece.x / 2, foil._y + row * Foil::kPiece - piece.y / 2, foil._angles[index]);
- }
- }
- }
- for (uint i = 0; i < notebook._foils.size(); i++) {
- const Foil &foil = *notebook._foils[i];
- if (!foil.isStart())
- continue;
- const int centerX = (foil._area.left + foil._area.right) / 2;
- const int centerY = (foil._area.top + foil._area.bottom) / 2;
- int picture = kPicBlocked;
- if (!task->isHintBlocked(notebook._foilHints[i]))
- picture = notebook._pulse <= 499 ? kPicScratchAlpha : kPicScratchText; // flashes
- const Dims marker = size(picture);
- blit(picture, centerX - marker.x / 2, centerY - marker.y / 2);
- }
- }
-
- Scene &_scene;
- TextContainer _texts;
- BitmapFont _headingFont, _font, _hintFont;
- bool _russian = false;
- bool _opened = false;
-};
-
-} // End of anonymous namespace
-
-// The dialog of the notebook scene, or null when it cannot be opened
-BaseModalObject *sceneNotebook_create() {
- uint32 sceneId = 0;
- if (!g_ngi->_notebook || !g_ngi->_gameProject->_objectIds.findId("SC_NOTEBOOK", sceneId))
- return nullptr;
- Scene *scene = g_ngi->findScene(sceneId);
- if (!scene)
- return nullptr;
- Common::ScopedPtr<ModalNotebook> notebook(new ModalNotebook(*scene));
- return notebook->open() ? notebook.release() : nullptr;
-}
-
-} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sceneTutorial.cpp b/engines/ngi/fullpipe/sceneTutorial.cpp
index 45e3cce432e..0c14fa31195 100644
--- a/engines/ngi/fullpipe/sceneTutorial.cpp
+++ b/engines/ngi/fullpipe/sceneTutorial.cpp
@@ -287,14 +287,13 @@ void showTutorial(TutorialStep step) {
} // End of anonymous namespace
+// CTaskManager::ShowActiveTaskDialog: CGame::PushScene(SC_NOTEBOOK)
void sceneNotebook_show() {
- BaseModalObject *notebook = sceneNotebook_create();
- if (notebook) {
- notebook->_parentObj = g_ngi->_modalObject;
- g_ngi->_modalObject = notebook;
- if (g_ngi->getGameLoaderGameVar()->getSubVarAsInt("TutorialStep") == kUseTask)
- showTutorial(kUseTask);
- }
+ if (!g_ngi->_notebook)
+ return;
+ g_ngi->pushScene(SC_NOTEBOOK);
+ if (g_ngi->getGameLoaderGameVar()->getSubVarAsInt("TutorialStep") == kUseTask)
+ showTutorial(kUseTask);
}
// CTutorialManager::IsTutorialCompleted
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index 5af8eebc070..f3d1f3cfd15 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -25,6 +25,7 @@
#include "ngi/fullpipe/sc03controller.h"
#include "ngi/fullpipe/sc04controller.h"
#include "ngi/fullpipe/chaptercontroller.h"
+#include "ngi/fullpipe/notebook.h"
namespace NGI {
@@ -461,6 +462,9 @@ void createSceneController(int sceneId) {
case SC_CHAPTER:
new ChapterController(sceneId);
break;
+ case SC_NOTEBOOK:
+ new Notebook(sceneId);
+ break;
default:
new FPController(sceneId);
break;
diff --git a/engines/ngi/fullpipe/scenes.h b/engines/ngi/fullpipe/scenes.h
index 241ffc8a58d..c72fa07cf46 100644
--- a/engines/ngi/fullpipe/scenes.h
+++ b/engines/ngi/fullpipe/scenes.h
@@ -38,7 +38,6 @@ struct WalkingBearder;
int defaultUpdateCursor();
void sceneTutorial_check();
class BaseModalObject;
-BaseModalObject *sceneNotebook_create();
void sceneNotebook_show();
void sceneController_initInventory();
bool sceneTutorial_isCompleted();
diff --git a/engines/ngi/fullpipe/taskmanager.cpp b/engines/ngi/fullpipe/taskmanager.cpp
index e39d6c06c8d..8b911c7fe42 100644
--- a/engines/ngi/fullpipe/taskmanager.cpp
+++ b/engines/ngi/fullpipe/taskmanager.cpp
@@ -149,7 +149,7 @@ private:
// CScene::Message to the notebook scene: its controller (CNotebookController::OnMessage) keeps the task list
void notifyNotebook(const char *message, const Common::String ¶m) {
if (g_ngi->_notebook)
- g_ngi->_notebook->onMessage(message, param);
+ g_ngi->_notebook->onMessage(message, param, nullptr);
}
// CTask::LoadParam
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 202d1990053..de895dcfe05 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -125,7 +125,6 @@ MODULE_OBJS = \
fullpipe/sceneFinal.o \
fullpipe/sceneIntro.o \
fullpipe/sceneIntroDemo.o \
- fullpipe/sceneNotebook.o \
fullpipe/sceneTutorial.o \
fullpipe/scenecontrollers.o \
fullpipe/scenes.o \
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 98641d17238..02f65f67d77 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -300,7 +300,8 @@ public:
Common::ScopedPtr<Tremble> _tremble;
Common::ScopedPtr<ArcadeInterface> _arcadeInterface;
Common::ScopedPtr<ChapterManager> _chapterManager;
- Common::ScopedPtr<Notebook> _notebook;
+ /** CNotebookController, owned by its scene (SC_NOTEBOOK) */
+ Notebook *_notebook = nullptr;
Common::ScopedPtr<AniHandler> _aniHandler;
Common::Array<Common::Point> _arcadeKeys;
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 29a677259aa..30dbe8ed42d 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -37,6 +37,7 @@
#include "ngi/gameloader.h"
#include "ngi/sound.h"
#include "ngi/guimanager.h"
+#include "ngi/inventory.h"
#include "backends/keymapper/keymapper.h"
#include "ngi/fullpipe/constants.h"
@@ -170,6 +171,32 @@ bool NGIEngine::handleSceneStackEvent(const Common::Event &event) {
Scene *scene = getCurrentScene();
if (!scene)
return false;
+
+ // CGame::OnMouse*: the inventory goes first when the controller of the scene enables it (CInventory::Hit)
+ if (isInventoryEnabled() && _inventoryScene) {
+ if (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_LBUTTONUP) {
+ Common::Point pos = event.mouse;
+ if (const int item = getGameLoaderInventory()->getItemAtPos(&pos)) {
+ if (event.type == Common::EVENT_LBUTTONDOWN)
+ getGameLoaderInventory()->putOnCursor(item);
+ return true;
+ }
+ }
+ GuiManager *gui = _inventoryScene->_guiManager.get();
+ if (gui && gui->hit(event.mouse)) {
+ gui->onMouseMove(event.mouse);
+ if (event.type == Common::EVENT_LBUTTONDOWN)
+ gui->onMouseLKeyDown(event.mouse);
+ else if (event.type == Common::EVENT_LBUTTONUP)
+ gui->onMouseLKeyUp(event.mouse);
+ else if (event.type == Common::EVENT_RBUTTONDOWN)
+ gui->onMouseRKeyDown(event.mouse);
+ else if (event.type == Common::EVENT_RBUTTONUP)
+ gui->onMouseRKeyUp(event.mouse);
+ return true;
+ }
+ }
+
switch (event.type) {
case Common::EVENT_LBUTTONDOWN:
return scene->onMouseLKeyDown(0, event.mouse.x, event.mouse.y);
@@ -391,6 +418,8 @@ void Scene::updateExitInput(Common::Point pos, Common::EventType type) {
}
void Scene::onGuiEvent(const Common::String &id, const Common::String &event) {
+ if (_controller)
+ _controller->onGuiEvent(id, event);
if (_guiEventHandler)
_guiEventHandler(*this, id, event);
}
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index b5c6f79c6e6..7dd0067f199 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -28,6 +28,7 @@
#include "common/tokenizer.h"
#include "ngi/ngi.h"
+#include "ngi/fullpipe/fpcontroller.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/gameloader.h"
#include "ngi/behavior.h"
@@ -1744,6 +1745,7 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
_gameProject.reset(new GameProject());
GameProject &project = *_gameProject;
+ g_ngi->_gameProject = _gameProject.get(); // the controllers find their scenes while the data loads
XMLTextureSizeParser(project).loadSizes();
if (!project._objectIds.load("data/obj.h"))
return Common::Error(Common::kNoGameDataFoundError, "Could not read the Full Pipe object IDs");
@@ -1784,7 +1786,7 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
if (!g_ngi->_chapterManager->init("data/chapter.xml"))
return Common::Error(Common::kNoGameDataFoundError, "Could not read the chapters");
g_ngi->_taskManager.reset(new TaskManager);
- g_ngi->_notebook.reset(new Notebook);
+ createSceneController(SC_NOTEBOOK); // CNotebookController
if (!g_ngi->_taskManager->init("data/tasks.xml", project._objectIds))
return Common::Error(Common::kNoGameDataFoundError, "Could not read the tasks");
g_ngi->_taskManager->onShow();
Commit: 51b415a25a66835eac2ceba6d073792e93e4d897
https://github.com/scummvm/scummvm/commit/51b415a25a66835eac2ceba6d073792e93e4d897
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Add CInventoryController with OnGuiEvent, CFPController::OnGuiEvent and CSc01Controller::OnGuiEvent
Changed paths:
A engines/ngi/fullpipe/inventorycontroller.cpp
A engines/ngi/fullpipe/inventorycontroller.h
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/fpcontroller.h
engines/ngi/fullpipe/notebook.cpp
engines/ngi/fullpipe/scene01.cpp
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/scenecontrollers.h
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 0e961d6271e..dab2ec0be86 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -42,29 +42,13 @@
namespace NGI {
-static void inventory_onGuiEvent(Scene &inventory, const Common::String &id, const Common::String &event) {
- if (event != "unpress")
- return;
- if (id == "BTN_SKIP") {
- GameVar *root = g_ngi->getGameLoaderGameVar();
- root->setSubVarAsInt("TutorialDisabled", 1);
- root->setSubVarAsInt("Scene1ExitsDisabled", 0);
- g_ngi->_currentScene->setExitState(0, 1);
- inventory._guiManager->getElement(id)->hideAndDeactivate();
- } else if (id == "PIC_INV_TASK") {
- sceneNotebook_show();
- } else if (id == "BTN_SKIP_ARCADE") {
- sceneController(*g_ngi->_currentScene).skipArcade();
- } else {
- warning("STUB: Inventory::onGuiEvent(%s, %s)", id.c_str(), event.c_str());
- }
-}
-
// CInventoryController, inventory.xml
void sceneController_initInventory() {
g_ngi->_inventoryScene = g_ngi->findScene(SC_INV);
if (g_ngi->_inventoryScene) {
- g_ngi->_inventoryScene->_guiEventHandler = inventory_onGuiEvent;
+ if (!g_ngi->_inventoryScene->_controller)
+ createSceneController(SC_INV); // CInventoryController
+ g_ngi->_inventoryScene->_controller->onShow();
getGameLoaderInventory()->recalcItemPos();
}
}
@@ -797,6 +781,17 @@ bool FPController::onMouseLKeyUp(uint32 id, float x, float y) {
return onTap(x, y);
}
+// CFPController::OnGuiEvent
+void FPController::onGuiEvent(const Common::String &id, const Common::String &event) {
+ if (event == "unpress" && id == "BTN_SKIP_ARCADE") {
+ skipArcade();
+ if (g_ngi->_inventoryScene && g_ngi->_inventoryScene->_guiManager) {
+ if (GuiElement *button = g_ngi->_inventoryScene->_guiManager->getElement(id))
+ button->hideAndDeactivate();
+ }
+ }
+}
+
// CFPController::UpdateUserCmd: SET_SCROLL waits until the camera is there; GO_MCTL (UpdateCmdMctl) is not ported yet
bool FPController::updateUserCmd(Command *cmd, uint32 elapsed) {
const Common::String type = cmd->_args.getValOrDefault("type");
diff --git a/engines/ngi/fullpipe/fpcontroller.h b/engines/ngi/fullpipe/fpcontroller.h
index c9fd4072b37..bc3bc7d9c9b 100644
--- a/engines/ngi/fullpipe/fpcontroller.h
+++ b/engines/ngi/fullpipe/fpcontroller.h
@@ -40,6 +40,8 @@ public:
void onShow() override;
/** CFPController::OnUpdate: UpdateScroll, TestScroll every 10 ms, TestSwipe */
void onUpdate(uint32 elapsed) override;
+ /** CFPController::OnGuiEvent: BTN_SKIP_ARCADE skips the arcade and hides the button */
+ void onGuiEvent(const Common::String &id, const Common::String &event) override;
void onRenderBottom(Common::Point scroll) override;
void onRenderTop(Common::Point scroll) override;
bool onMouseLKeyDown(uint32 id, float x, float y) override;
diff --git a/engines/ngi/fullpipe/inventorycontroller.cpp b/engines/ngi/fullpipe/inventorycontroller.cpp
new file mode 100644
index 00000000000..4106e38faaa
--- /dev/null
+++ b/engines/ngi/fullpipe/inventorycontroller.cpp
@@ -0,0 +1,120 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/debug.h"
+
+#include "ngi/ngi.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/inventorycontroller.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/guimanager.h"
+#include "ngi/scene.h"
+
+namespace NGI {
+
+namespace {
+
+void warnOnce(const char *what) {
+ static Common::HashMap<Common::String, bool> reported;
+ if (!reported.contains(what)) {
+ reported[what] = true;
+ warning("STUB/untested: %s", what);
+ }
+}
+
+} // End of anonymous namespace
+
+InventoryController::InventoryController(int sceneId) : ISceneController(sceneId) {
+}
+
+// CInventoryController::OnShow: the buttons of the map, the menu and the notebook are 60 x 80
+void InventoryController::onShow() {
+ static const char *const buttons[] = { "PIC_INV_MAP", "PIC_INV_ESC", "PIC_INV_TASK", "PIC_INV_TASK_PRESSED" };
+ if (!_scene->_guiManager)
+ return;
+ for (const char *button : buttons) {
+ if (GuiElement *element = _scene->_guiManager->getElement(button))
+ element->_size = Common::Point(60, 80);
+ }
+}
+
+// CInventoryController::OnGuiEvent. The map (SC_MAP), the main menu (SC_MAINMENU) and the hint helper are not ported (STUB warnings), the
+// tutorial is not a scene on the stack yet (the case of SC_TUTORIAL in the original pops it first).
+void InventoryController::onGuiEvent(const Common::String &id, const Common::String &event) {
+ if (event != "unpress")
+ return;
+
+ Scene *current = g_ngi->getCurrentScene();
+ if (id == "PIC_INV_MAP") {
+ if (current->_sceneId == SC_TUTORIAL)
+ g_ngi->popScene();
+ current = g_ngi->getCurrentScene();
+ if (current->_sceneId == SC_NOTEBOOK)
+ g_ngi->popScene();
+ warnOnce("CGame::PushScene(SC_MAP): the map is not ported");
+ return;
+ }
+ if (id == "PIC_INV_ESC") {
+ if (current->_sceneId == SC_TUTORIAL)
+ g_ngi->popScene();
+ warnOnce("CGame::PushScene(SC_MAINMENU): the main menu of the Android build is not ported");
+ return;
+ }
+ if (id == "PIC_INV_HELPER_ACTIONS" || id == "PIC_INV_HELPER_BUBBLE") {
+ warnOnce("CObjHelperManager::ShowObjHelperActionMessage: the object helper is not ported");
+ return;
+ }
+ if (id == "PIC_INV_TASK" || id == "PIC_INV_TASK_PRESSED") {
+ // the active tutorial (CTutorialManager::FindActiveTutorial) is not a scene yet: only the notebook toggles
+ current = g_ngi->getCurrentScene();
+ if (current->_sceneId == SC_NOTEBOOK)
+ g_ngi->popScene();
+ else if (g_ngi->_taskManager)
+ g_ngi->_taskManager->showActiveTaskDialog(false);
+
+ // PIC_INV_TASK while the notebook is closed, PIC_INV_TASK_PRESSED while it is open
+ const bool pressed = id == "PIC_INV_TASK";
+ if (_scene->_guiManager) {
+ if (GuiElement *task = _scene->_guiManager->getElement("PIC_INV_TASK")) {
+ if (!pressed)
+ task->show();
+ else
+ task->hide();
+ }
+ if (GuiElement *taskPressed = _scene->_guiManager->getElement("PIC_INV_TASK_PRESSED")) {
+ if (pressed)
+ taskPressed->show();
+ else
+ taskPressed->hide();
+ }
+ }
+ }
+ // the skip buttons belong to the controller of the current scene (CScene::OnGuiEvent)
+ if (id == "BTN_SKIP") {
+ current->onGuiEvent(id, event);
+ } else if (id == "BTN_SKIP_ARCADE") {
+ if (g_ngi->arcadeInterface().getState() == ArcadeInterface::kShown)
+ current->onGuiEvent(id, event);
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/inventorycontroller.h b/engines/ngi/fullpipe/inventorycontroller.h
new file mode 100644
index 00000000000..a8ee7ca0d4e
--- /dev/null
+++ b/engines/ngi/fullpipe/inventorycontroller.h
@@ -0,0 +1,44 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_INVENTORYCONTROLLER_H
+#define NGI_FULLPIPE_INVENTORYCONTROLLER_H
+
+#include "ngi/scenecontroller.h"
+
+namespace NGI {
+
+/**
+ * Android: CInventoryController (ISceneController), the controller of the inventory scene (SC_INV): the bar over the game scenes with the items and
+ * the buttons of the map, the menu, the notebook and the skip buttons. Ported so far: OnShow and OnGuiEvent. The scroll animation of the bar
+ * (OnUpdate, ScrollIn, ScrollOut, UpdateTaskButtons), OnRenderBottom/Top and the hit test are still done by the Inventory class and the engine loop.
+ */
+class InventoryController : public ISceneController {
+public:
+ explicit InventoryController(int sceneId);
+
+ void onShow() override;
+ void onGuiEvent(const Common::String &id, const Common::String &event) override;
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_INVENTORYCONTROLLER_H
diff --git a/engines/ngi/fullpipe/notebook.cpp b/engines/ngi/fullpipe/notebook.cpp
index 2d63a81391c..aac3577619c 100644
--- a/engines/ngi/fullpipe/notebook.cpp
+++ b/engines/ngi/fullpipe/notebook.cpp
@@ -496,6 +496,13 @@ void Notebook::onShow() {
}
void Notebook::onHide() {
+ // the notebook button of the inventory is released: PIC_INV_TASK shows, PIC_INV_TASK_PRESSED hides
+ if (g_ngi->_inventoryScene && g_ngi->_inventoryScene->_guiManager) {
+ if (GuiElement *task = g_ngi->_inventoryScene->_guiManager->getElement("PIC_INV_TASK"))
+ task->show();
+ if (GuiElement *pressed = g_ngi->_inventoryScene->_guiManager->getElement("PIC_INV_TASK_PRESSED"))
+ pressed->hide();
+ }
// (the original scrolls the inventory back in, hides the catalog and resets the buy page)
_autoFoil = false;
_autoFoilHint = -1;
diff --git a/engines/ngi/fullpipe/scene01.cpp b/engines/ngi/fullpipe/scene01.cpp
index dbb5022acfc..058d9fa61b4 100644
--- a/engines/ngi/fullpipe/scene01.cpp
+++ b/engines/ngi/fullpipe/scene01.cpp
@@ -22,6 +22,8 @@
#include "ngi/ngi.h"
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/scenecontrollers.h"
+#include "ngi/guimanager.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/constants.h"
@@ -67,6 +69,23 @@ void scene01_initObjects(Scene *sc, int entrance, bool eggUncracked) {
}
}
+// CSc01Controller::OnGuiEvent: the skip button of the tutorial (BTN_SKIP of the inventory) deactivates the tutorial, hides itself and opens the exits
+// of the scenes 1 and 3. ADAPTATIONS: CTutorialManager::Deactivate is the TutorialDisabled variable, the exits are the ones of Scene::_exits
+// (D10, CExitManager) and the flag that the original clears in the inventory controller (+12) is not ported.
+void Sc01Controller::onGuiEvent(const Common::String &id, const Common::String &event) {
+ FPController::onGuiEvent(id, event);
+ if (event != "unpress" || id != "BTN_SKIP")
+ return;
+ GameVar *root = g_ngi->getGameLoaderGameVar();
+ root->setSubVarAsInt("TutorialDisabled", 1);
+ root->setSubVarAsInt("Scene1ExitsDisabled", 0);
+ if (g_ngi->_inventoryScene && g_ngi->_inventoryScene->_guiManager) {
+ if (GuiElement *button = g_ngi->_inventoryScene->_guiManager->getElement(id))
+ button->hideAndDeactivate();
+ }
+ _scene->setExitState(0, 1);
+}
+
void scene01_initScene(Scene *sc, int entrance) {
scene01_initObjects(sc, entrance, g_ngi->getStateId(sO_EggCracker) == g_ngi->getStateValue(sO_EggCracker, sO_DidNotCrackEgg));
if (g_ngi->isAndroidFullPipe()) {
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index f3d1f3cfd15..823751d3d72 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -26,6 +26,7 @@
#include "ngi/fullpipe/sc04controller.h"
#include "ngi/fullpipe/chaptercontroller.h"
#include "ngi/fullpipe/notebook.h"
+#include "ngi/fullpipe/inventorycontroller.h"
namespace NGI {
@@ -465,6 +466,9 @@ void createSceneController(int sceneId) {
case SC_NOTEBOOK:
new Notebook(sceneId);
break;
+ case SC_INV:
+ new InventoryController(sceneId);
+ break;
default:
new FPController(sceneId);
break;
diff --git a/engines/ngi/fullpipe/scenecontrollers.h b/engines/ngi/fullpipe/scenecontrollers.h
index ef171965b9e..b9392ca3863 100644
--- a/engines/ngi/fullpipe/scenecontrollers.h
+++ b/engines/ngi/fullpipe/scenecontrollers.h
@@ -33,6 +33,7 @@ class Sc01Controller : public FPController {
public:
explicit Sc01Controller(int sceneId) : FPController(sceneId) {}
void onShow() override;
+ void onGuiEvent(const Common::String &id, const Common::String &event) override;
};
class Sc02Controller : public FPController {
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index de895dcfe05..457aada0a52 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -82,6 +82,7 @@ MODULE_OBJS = \
fullpipe/chaptermanager.o \
fullpipe/floaters.o \
fullpipe/fpcontroller.o \
+ fullpipe/inventorycontroller.o \
fullpipe/lift.o \
fullpipe/notebook.o \
fullpipe/scene01.o \
Commit: f3a44cc668dd50a617e533f91a1bb2238aef0174
https://github.com/scummvm/scummvm/commit/f3a44cc668dd50a617e533f91a1bb2238aef0174
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Add CLift and CLiftController, the lift view is a pushed scene, CFPController::OnMessage for the lift messages
Changed paths:
A engines/ngi/fullpipe/lift.h
A engines/ngi/fullpipe/liftcontroller.cpp
A engines/ngi/fullpipe/liftcontroller.h
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/fpcontroller.h
engines/ngi/fullpipe/lift.cpp
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/messages.cpp
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/scene.cpp
engines/ngi/scene.h
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index dab2ec0be86..a58ff76b4cb 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -36,6 +36,7 @@
#include "ngi/fullpipe/scenes.h"
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/fpcontroller.h"
+#include "ngi/fullpipe/lift.h"
#include "ngi/guimanager.h"
#include "ngi/inventory.h"
#include "ngi/fullpipe/tremble.h"
@@ -781,6 +782,30 @@ bool FPController::onMouseLKeyUp(uint32 id, float x, float y) {
return onTap(x, y);
}
+// CFPController::OnMessage. Ported: the messages of the lift (CLift), MSG_SET_SAVING (CBaseSettings::SetSaving is a STUB) and the lift part of MSG_RESETDEST.
+// Not ported: the rest of MSG_RESETDEST (the hero's queue), INVENTORY_ITEM_*, INTERACT_*, CHEATER_*, the tutorial and the other messages.
+void FPController::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (message == "MSG_LIFT_CLICKBUTTON") {
+ g_ngi->lift().onClickButton();
+ } else if (message == "MSG_LIFT_CLOSEDOOR") {
+ g_ngi->lift().closeDoorAndGo();
+ } else if (message == "MSG_LIFT_GO") {
+ g_ngi->lift().onGo();
+ } else if (message == "MSG_LIFT_EXITLIFT") {
+ g_ngi->lift().exitLift(queue);
+ } else if (message == "MSG_LIFT_STARTEXITQUEUE") {
+ g_ngi->lift().startExitQueue();
+ } else if (message == "MSG_SET_SAVING") {
+ static bool warned = false;
+ if (!warned) {
+ warned = true;
+ warning("STUB/untested: CBaseSettings::SetSaving (the saves are not blocked while the lift moves)");
+ }
+ } else if (message == "MSG_RESETDEST") {
+ g_ngi->lift().onResetDest(queue);
+ }
+}
+
// CFPController::OnGuiEvent
void FPController::onGuiEvent(const Common::String &id, const Common::String &event) {
if (event == "unpress" && id == "BTN_SKIP_ARCADE") {
@@ -816,13 +841,11 @@ bool FPController::onTap(float tapX, float tapY) {
const Common::Point pos(tapX, tapY);
PictureObject *picture = scene.findPictureObjectAtPos(pos.x, pos.y);
AniObject *actor = scene.findAniObjectAtPos(pos.x, pos.y);
- GameObject *target = picture;
- if (actor && (!picture || actor->_z < picture->_z))
- target = actor;
+ GameObject *target = scene.findGameObjectAtPos(pos.x, pos.y);
debugC(2, kDebugSceneLogic, "FPController::onTap: %d,%d picture %d (z %d) actor %d (z %d)", pos.x, pos.y, picture ? picture->_id : 0, picture ? picture->_z : 0,
actor ? actor->_id : 0, actor ? actor->_z : 0);
// CLift::OnButtonUp: the lift door and the areas GD_SC3_LIFT ... GD_SC38_LIFT open the panel of the lift buttons
- if (target && g_ngi->isAndroidFullPipe() && (target->_id == ANI_LIFT || (target->_id >= 23116 && target->_id <= 23125)) && g_ngi->lift_switchToBigView())
+ if (target && g_ngi->isAndroidFullPipe() && (target->_id == ANI_LIFT || (target->_id >= 23116 && target->_id <= 23125)) && g_ngi->lift().onButtonUp(target))
return true;
if (target) {
diff --git a/engines/ngi/fullpipe/fpcontroller.h b/engines/ngi/fullpipe/fpcontroller.h
index bc3bc7d9c9b..6838fd330e5 100644
--- a/engines/ngi/fullpipe/fpcontroller.h
+++ b/engines/ngi/fullpipe/fpcontroller.h
@@ -40,6 +40,8 @@ public:
void onShow() override;
/** CFPController::OnUpdate: UpdateScroll, TestScroll every 10 ms, TestSwipe */
void onUpdate(uint32 elapsed) override;
+ /** CFPController::OnMessage: lift messages, MSG_SET_SAVING, MSG_RESETDEST only */
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
/** CFPController::OnGuiEvent: BTN_SKIP_ARCADE skips the arcade and hides the button */
void onGuiEvent(const Common::String &id, const Common::String &event) override;
void onRenderBottom(Common::Point scroll) override;
diff --git a/engines/ngi/fullpipe/lift.cpp b/engines/ngi/fullpipe/lift.cpp
index 11b14975f8e..72d42ddabf1 100644
--- a/engines/ngi/fullpipe/lift.cpp
+++ b/engines/ngi/fullpipe/lift.cpp
@@ -31,6 +31,11 @@
#include "ngi/gameloader.h"
#include "ngi/modal.h"
#include "ngi/motion.h"
+#include "ngi/fullpipe/fpcontroller.h"
+#include "ngi/fullpipe/lift.h"
+#include "ngi/fullpipe/liftcontroller.h"
+#include "ngi/guimanager.h"
+#include "ngi/interaction.h"
namespace NGI {
@@ -204,182 +209,38 @@ static int lift_androidButton(int windowsStaticsId) {
return windowsStaticsId;
}
-namespace {
-
-// CLiftController (the scene SC_LIFT, pushed over the scene by CLift::SwitchToBigView): a panel with a big copy of every lift button of the
-// scene. A tap on an enabled button lights it (CLiftController::OnMouseLKeyUp), 100 ms later its button of the scene is pressed
-// (CLift::OnButtonUpBig, lift_animateButton) and the panel closes; a tap anywhere else closes it.
-class ModalLiftView : public BaseModalObject {
-public:
- explicit ModalLiftView(Scene &view) : _view(view) {}
-
- const Scene *getScene() const override { return &_view; }
-
- ~ModalLiftView() override {
- for (const Button &button : _buttons) {
- _view.removeAni(button.big);
- delete button.big;
- }
- }
-
- // CLift::SwitchToBigView + CLiftController::SortButtons
- bool open() {
- _background = _view.findPictureObjectById(23038, 0); // PIC_LIFT_BGR
- AniObject *bigButton = _view.findAniObjectById(23039, 0); // ANI_LIFTBUTTON_BIG
- if (!_background || !bigButton) {
- debugC(2, kDebugSceneLogic, "ModalLiftView: background %p, big button %p", (void *)_background, (void *)bigButton);
- return false;
- }
-
- Common::Array<AniObject *> small;
- for (AniObject *ani : g_ngi->_currentScene->_renderableAnis) {
- if (ani->_id == ANI_LIFTBUTTON && ani->_statics)
- small.push_back(ani);
- }
- // LiftButtonSort: by y, equal y by x
- for (uint i = 1; i < small.size(); ++i) {
- for (uint j = i; j > 0; --j) {
- const AniObject *a = small[j - 1];
- const AniObject *b = small[j];
- if (!(a->_y == b->_y ? a->_x > b->_x : a->_y > b->_y))
- break;
- SWAP(small[j - 1], small[j]);
- }
- }
- if (small.empty()) {
- debugC(2, kDebugSceneLogic, "ModalLiftView: the scene has no lift buttons");
- return false;
- }
-
- for (uint i = 0; i < small.size(); ++i) {
- AniObject *big = new AniObject(bigButton);
- _view.addAni(big, true);
- big->_flags |= 4;
- big->_statics = big->getStatic(small[i]->_statics->_staticsId - 30);
- Common::Point center(_background->_x + 52 + (i & 1) * 65, _background->_y + 64 + (i >> 1) * 85);
- if (i + 1 == small.size() && small[i]->_x > small[0]->_x)
- center.x = _background->_x + 52 + 65;
- big->setCenter(center);
-
- Button button;
- button.big = big;
- button.small = small[i];
- _buttons.push_back(button);
- }
-
- return true;
- }
-
- bool init(int elapsed) override {
- if (_finished)
- return false;
- if (_selected) {
- _time += elapsed;
- if (_time > 100) {
- g_ngi->lift_animateButton(_selected->small);
- return false;
- }
- }
- return true;
- }
-
- void update() override {
- g_ngi->_currentScene->render();
- if (g_ngi->_inventoryScene && g_ngi->_inventoryScene->_guiManager)
- g_ngi->_inventoryScene->_guiManager->render(g_ngi->_backgroundSurface);
- _background->render();
- for (const Button &button : _buttons)
- button.big->render();
- }
-
- bool handleMessage(Command *cmd) override {
- if (cmd->_cmd != kCmdMessage || cmd->_messageNum != kMsgLButtonUp)
- return false;
- if (_selected)
- return true;
-
- AniObject *hit = _view.findAniObjectAtPos(cmd->_x, cmd->_y);
- if (hit && hit->_id == 23039 && hit->_statics && (hit->_statics->_staticsId - 23040) % 3 == 0) {
- for (Button &button : _buttons) {
- if (button.big == hit)
- _selected = &button;
- }
- }
- if (!_selected) {
- _finished = true;
- return true;
- }
-
- g_ngi->playSound(SND_CMN_032, 0);
- hit->_statics = hit->getStatic(hit->_statics->_staticsId + 2); // CLiftController::GetStaticsHilite
- return true;
- }
-
- bool pollEvent() override { return true; }
- void saveload() override {}
-
-private:
- struct Button {
- AniObject *big = nullptr;
- AniObject *small = nullptr;
- };
-
- Scene &_view;
- PictureObject *_background = nullptr;
- Common::Array<Button> _buttons;
- Button *_selected = nullptr;
- int _time = 0;
- bool _finished = false;
-};
-
-} // End of anonymous namespace
-
-// CLift::OnButtonUp (the tap on the lift door or on a GD_SCn_LIFT area of the scene): CLift::SwitchToBigView
-bool NGIEngine::lift_switchToBigView() {
- uint32 viewId;
- if (!_lift || !_liftEnterMQ || _modalObject || !_aniMan || !_aniMan->isIdle() || !getGameLoaderInteractionController()->_enabled ||
- !_gameProject->_objectIds.findId("SC_LIFT", viewId)) {
- debugC(2, kDebugSceneLogic, "lift_switchToBigView: not now (lift %p, enter queue %p, modal %p, idle %d)", (void *)_lift, (void *)_liftEnterMQ,
- (void *)_modalObject, _aniMan ? _aniMan->isIdle() : -1);
- return false;
- }
-
- Scene *view = findScene(viewId);
- if (!view) {
- debugC(2, kDebugSceneLogic, "lift_switchToBigView: scene %d is not loaded", viewId);
- return false;
- }
-
- Common::ScopedPtr<ModalLiftView> modal(new ModalLiftView(*view));
- if (!modal->open())
- return false;
-
- modal->_parentObj = _modalObject;
- _modalObject = modal.release();
- return true;
+// CSingleton<CLift>::GetInst
+Lift &NGIEngine::lift() {
+ if (!_liftManager)
+ _liftManager.reset(new Lift());
+ return *_liftManager;
}
void NGIEngine::lift_setButton(const char *name, int state) {
+ // the scene code of the Windows game passes the normal statics of the button of the floor
+ if (isAndroidFullPipe()) {
+ lift().enableButton(name, lift_androidButton(state));
+ return;
+ }
+
GameVar *var = lift_buttonStates();
if (var)
- var->setSubVarAsInt(name, isAndroidFullPipe() ? lift_androidButton(state) : state);
+ var->setSubVarAsInt(name, state);
}
// CLift::ResetButtons (CStateManager::SetStartStates): every button starts pushed
void NGIEngine::lift_resetButtons() {
- GameVar *var = lift_buttonStates();
-
- if (!var || !isAndroidFullPipe())
- return;
-
- static const char *const floors[10] = { sO_Level0, sO_Level1, sO_Level2, sO_Level3, sO_Level4, sO_Level5, sO_Level6, sO_Level7, sO_Level8, sO_Level9 };
-
- for (int floor = 0; floor < 10; ++floor)
- var->setSubVarAsInt(floors[floor], kLiftButtonBase + 3 * (floor == 0 ? 9 : floor - 1) + 1);
+ if (isAndroidFullPipe())
+ lift().resetButtons();
}
void NGIEngine::lift_init(Scene *sc, int enterSeq, int exitSeq) {
+ if (isAndroidFullPipe()) {
+ lift().initLift(sc, _aniMan, enterSeq, exitSeq);
+ return;
+ }
+
_lastLiftButton = nullptr;
_liftEnterMQ = sc->findMessageQueue(enterSeq);
@@ -401,8 +262,7 @@ void NGIEngine::lift_init(Scene *sc, int enterSeq, int exitSeq) {
_lift = sc->findAniObjectById(ANI_LIFT, -1);
- // Android: the buttons are copies of the animation of the common scene (ADDANI) and only in the list of the drawn animations
- Common::Array<AniObject *> &anis = isAndroidFullPipe() ? sc->_renderableAnis : sc->_aniObjects;
+ Common::Array<AniObject *> &anis = sc->_aniObjects;
for (uint i = 0; i < anis.size(); i++) {
AniObject *ani = anis[i];
@@ -430,6 +290,10 @@ void NGIEngine::lift_init(Scene *sc, int enterSeq, int exitSeq) {
}
void NGIEngine::lift_exitSeq(Command *cmd) {
+ // Android: CFPController::OnMessage (CLift) gets the lift messages, the scene handlers too
+ if (isAndroidFullPipe())
+ return;
+
if (cmd) {
MessageQueue *mq = _globalMessageQueueList->getMessageQueueById(cmd->_parId);
@@ -493,6 +357,10 @@ void NGIEngine::lift_exitSeq(Command *cmd) {
}
void NGIEngine::lift_closedoorSeq() {
+ // Android: CFPController::OnMessage (CLift) gets the lift messages, the scene handlers too
+ if (isAndroidFullPipe())
+ return;
+
if (_lift->_movement) {
if (_lift->_movement->_id == MV_LFT_CLOSE) {
_lift->setQueue(nullptr);
@@ -512,7 +380,7 @@ void NGIEngine::lift_closedoorSeq() {
_lift->startMovement(MV_LFT_CLOSE, 0, -1);
}
} else {
- if (_lift->_statics->_staticsId == ST_LFT_CLOSED ) {
+ if (_lift->_statics->_staticsId == ST_LFT_CLOSED) {
_lift->setStatic(ST_LFT_CLOSED);
} else {
_lift->startMovement(MV_LFT_CLOSE, 0, -1);
@@ -530,6 +398,10 @@ void NGIEngine::lift_closedoorSeq() {
}
void NGIEngine::lift_walkAndGo() {
+ // Android: CFPController::OnMessage (CLift) gets the lift messages, the scene handlers too
+ if (isAndroidFullPipe())
+ return;
+
MessageQueue *mq;
Command *ex;
@@ -573,6 +445,10 @@ void NGIEngine::lift_walkAndGo() {
}
void NGIEngine::lift_openLift() {
+ // Android: CFPController::OnMessage (CLift) gets the lift messages, the scene handlers too
+ if (isAndroidFullPipe())
+ return;
+
if (_lift->_movement) {
if (_lift->_movement->_id == MV_LFT_OPEN) {
_lift->setQueue(nullptr);
@@ -598,11 +474,19 @@ void NGIEngine::lift_openLift() {
}
void NGIEngine::lift_clickButton() {
+ // Android: CFPController::OnMessage (CLift) gets the lift messages, the scene handlers too
+ if (isAndroidFullPipe())
+ return;
+
if (_lastLiftButton)
lift_walkAndGo();
}
void NGIEngine::lift_goAnimation() {
+ // Android: CFPController::OnMessage (CLift) gets the lift messages, the scene handlers too
+ if (isAndroidFullPipe())
+ return;
+
if (_lastLiftButton) {
int parentId = _currentScene->_sceneId;
int buttonId = lift_getButtonIdN(_lastLiftButton->_statics->_staticsId);
@@ -626,14 +510,9 @@ void NGIEngine::lift_goAnimation() {
mq->addCommandToEnd(ex);
- if (isAndroidFullPipe()) {
- // CLift::OnGo: the SETSC command names the destination scene and its entrance (the data.xml PASSAGE)
- ex = new Command(pre.sceneId, kCmdSetScene, pre.param, 0, 0, 0, 1, 0, 0, 0);
- } else {
- ex = new Command(parentId, kCmdMessage, kMsgPreloadScene, 0, 0, 0, 1, 0, 0, 0);
+ ex = new Command(parentId, kCmdMessage, kMsgPreloadScene, 0, 0, 0, 1, 0, 0, 0);
- ex->_param = buttonId;
- }
+ ex->_param = buttonId;
ex->_excFlags |= 3;
mq->addCommandToEnd(ex);
@@ -659,6 +538,10 @@ void NGIEngine::lift_goAnimation() {
}
void NGIEngine::lift_animateButton(AniObject *button) {
+ // Android: CFPController::OnMessage (CLift) gets the lift messages, the scene handlers too
+ if (isAndroidFullPipe())
+ return;
+
int butId = lift_getButtonIdP(button->_statics->_staticsId);
if (butId && butId != button->_statics->_staticsId) {
@@ -696,12 +579,20 @@ void NGIEngine::lift_animateButton(AniObject *button) {
}
void NGIEngine::lift_startExitQueue() {
+ // Android: CFPController::OnMessage (CLift) gets the lift messages, the scene handlers too
+ if (isAndroidFullPipe())
+ return;
+
MessageQueue *mq = new MessageQueue(_liftExitMQ, 0, 0);
mq->run(nullptr);
}
void NGIEngine::lift_hoverButton(Command *cmd) {
+ // Android: CFPController::OnMessage (CLift) gets the lift messages, the scene handlers too
+ if (isAndroidFullPipe())
+ return;
+
if (_lastLiftButton) {
if (!(cmd->_param & 2) || _liftX != cmd->_x || _liftY != cmd->_y) {
_lastLiftButton->_statics = _lastLiftButton->getStatic(lift_getButtonIdN(_lastLiftButton->_statics->_staticsId));
@@ -711,6 +602,9 @@ void NGIEngine::lift_hoverButton(Command *cmd) {
}
bool NGIEngine::lift_checkButton(const char *varName) {
+ if (isAndroidFullPipe())
+ return lift().isButtonEnabled(varName);
+
GameVar *var = lift_buttonStates();
if (var)
@@ -720,7 +614,12 @@ bool NGIEngine::lift_checkButton(const char *varName) {
}
void NGIEngine::lift_setButtonStatics(Scene *sc, int buttonId) {
- Common::Array<AniObject *> &anis = isAndroidFullPipe() ? sc->_renderableAnis : sc->_aniObjects;
+ if (isAndroidFullPipe()) {
+ lift().enableButton(sc, buttonId);
+ return;
+ }
+
+ Common::Array<AniObject *> &anis = sc->_aniObjects;
for (uint i = 0; i < anis.size(); i++) {
AniObject *ani = anis[i];
@@ -734,5 +633,367 @@ void NGIEngine::lift_setButtonStatics(Scene *sc, int buttonId) {
}
}
+// ---- Android: CLift ----
+
+namespace {
+
+void warnOnce(const char *what) {
+ static Common::HashMap<Common::String, bool> reported;
+ if (!reported.contains(what)) {
+ reported[what] = true;
+ warning("STUB/untested: %s", what);
+ }
+}
+
+// the name of the message goes to the controllers (CScene::Message), its id to the scene handlers
+Command *messageCommand(const char *name) {
+ uint32 id = 0;
+ g_ngi->_gameProject->_objectIds.findId(name, id);
+ Command *command = new Command(0, kCmdMessage, id, 0, 0, 0, 1, 0, 0, 0);
+ command->_messageName = name;
+ command->_excFlags |= 3;
+ return command;
+}
+
+Command *movementCommand(const AniObject *ani, int movementId) {
+ Command *command = new Command(ani->_id, kCmdStartMovement, movementId, 0, 0, 0, 1, 0, 0, 0);
+ command->_param = ani->_copyId;
+ command->_excFlags |= 2;
+ return command;
+}
+
+// LiftButtonSort: by the position (y, then x)
+bool liftButtonSort(const AniObject *a, const AniObject *b) {
+ return a->_y == b->_y ? a->_x < b->_x : a->_y < b->_y;
+}
+
+} // End of anonymous namespace
+
+// CLift::CLift: the controller of the lift view is the one of the scene 0x2713
+Lift::Lift() {
+ Scene *view = g_ngi->findScene(SC_LIFT);
+ if (view) {
+ if (!view->_controller)
+ createSceneController(SC_LIFT);
+ _controller = static_cast<LiftController *>(view->_controller.get());
+ }
+}
+
+// CLift::InitLift
+void Lift::initLift(Scene *scene, AniObject *hero, int enterQueueId, int exitQueueId) {
+ _scene = scene;
+ _selected = nullptr;
+ _hero = hero;
+ _enterQueue = scene->findMessageQueue(enterQueueId);
+ if (!_enterQueue)
+ return;
+ _exitQueue = scene->findMessageQueue(exitQueueId);
+ if (!_exitQueue)
+ return;
+
+ Command *first = _enterQueue->getCommandByIndex(0);
+ if (!first)
+ return;
+ _x = first->_x;
+ _y = first->_y;
+ _lift = scene->findAniObjectById(ANI_LIFT, 1);
+
+ // the buttons are the copies 1, 2 ... of ANI_LIFTBUTTON (ADDANI of SC_COMMON), all start pushed
+ _buttons.clear();
+ for (int copy = 1; AniObject *button = scene->findAniObjectById(ANI_LIFTBUTTON, copy); ++copy) {
+ button->_statics = button->getStatic(_controller->getStaticsPushed(button->_statics->_staticsId, false));
+ _buttons[button->_statics->_staticsId] = button;
+ }
+
+ // the state of "lift buttons" per floor: its value is the button's statics when enabled
+ GameVar *states = g_ngi->getGameLoaderGameVar()->getSubVarByName("OBJSTATES");
+ states = states ? states->getSubVarByName(sO_LiftButtons) : nullptr;
+ states = states ? states->getSubVarByName("ENUMSTATES") : nullptr;
+ if (!states)
+ return;
+ for (GameVar *state = states->_subVars; state; state = state->_nextVarObj) {
+ for (int copy = 1; AniObject *button = scene->findAniObjectById(ANI_LIFTBUTTON, copy); ++copy) {
+ if (_controller->getStaticsNormal(button->_statics->_staticsId, false) == state->_value.intValue)
+ button->_statics = button->getStatic(state->_value.intValue);
+ }
+ }
+}
+
+// CLift::OpenDoor. The original starts the opening from the frame that mirrors the closing one (the start frame argument of StartMovement), here the frame
+// is set after the start like the Windows game does.
+void Lift::openDoor() {
+ if (_lift->_movement) {
+ if (_lift->_movement->_id == MV_LFT_OPEN)
+ return;
+ if (_lift->_movement->_id == MV_LFT_CLOSE) {
+ const int frame = _lift->_movement->_curFrame;
+ _lift->setStatic(ST_LFT_CLOSED);
+ _lift->startMovement(MV_LFT_OPEN, 0, -1);
+ if (_lift->_movement->_currMovement)
+ _lift->_movement->setCurFrame(_lift->_movement->_currMovement->_phases.size() - frame);
+ else
+ _lift->_movement->setCurFrame(_lift->_movement->_phases.size() - frame);
+ } else {
+ _lift->setStatic(ST_LFT_CLOSED);
+ _lift->startMovement(MV_LFT_OPEN, 0, -1);
+ }
+ } else if (_lift->_statics->_staticsId == ST_LFT_OPEN_NEW) {
+ _lift->setStatic(ST_LFT_OPEN_NEW);
+ } else {
+ _lift->startMovement(MV_LFT_OPEN, 0, -1);
+ }
+}
+
+// CLift::EnableButton(scene, statics)
+void Lift::enableButton(Scene *scene, int staticsId) {
+ for (int copy = 1; copy <= 10; ++copy) {
+ AniObject *button = scene->findAniObjectById(ANI_LIFTBUTTON, copy);
+ if (button && _controller->getStaticsNormal(button->_statics->_staticsId, false) == staticsId)
+ button->_statics = button->getStatic(staticsId);
+ }
+}
+
+// the state of "lift buttons" with its name (CStateManager::GetObjStatePtr)
+static GameVar *liftStates() {
+ GameVar *states = g_ngi->getGameLoaderGameVar()->getSubVarByName("OBJSTATES");
+ states = states ? states->getSubVarByName(sO_LiftButtons) : nullptr;
+ return states ? states->getSubVarByName("ENUMSTATES") : nullptr;
+}
+
+// CLift::EnableButton(name, state)
+void Lift::enableButton(const Common::String &name, int state) {
+ if (GameVar *states = liftStates())
+ states->setSubVarAsInt(name, state);
+}
+
+// CLift::IsButtonEnabled
+bool Lift::isButtonEnabled(const Common::String &name) {
+ GameVar *states = liftStates();
+ GameVar *state = states ? states->getSubVarByName(name) : nullptr;
+ return state && _controller->isStaticsNormal(state->_value.intValue, false);
+}
+
+// CLift::ResetButtons: the floors 0 ... 9 have the pushed statics 23098, 23071, 23074 ... 23095
+void Lift::resetButtons() {
+ static const char *const floors[10] = { sO_Level0, sO_Level1, sO_Level2, sO_Level3, sO_Level4, sO_Level5, sO_Level6, sO_Level7, sO_Level8, sO_Level9 };
+
+ GameVar *states = liftStates();
+ if (!states)
+ return;
+ for (int floor = 0; floor < 10; ++floor)
+ states->setSubVarAsInt(floors[floor], 23070 + 3 * (floor == 0 ? 9 : floor - 1) + 1);
+}
+
+// CLift::OnResetDest: the walk to the lift was interrupted, the button comes up
+void Lift::onResetDest(MessageQueue *queue) {
+ if (_selected && queue && queue->_title == "lift_mctl_queue") {
+ _selected->_statics = _selected->getStatic(_controller->getStaticsNormal(_selected->_statics->_staticsId, false));
+ _selected = nullptr;
+ }
+}
+
+// CLift::GetCursorType: over the areas GD_SCn_LIFT (23116 ... 23125)
+bool Lift::getCursorType(float x, float y) {
+ GameObject *hit = g_ngi->_currentScene->findGameObjectAtPos(x, y);
+ return hit && hit->_id >= 23116 && hit->_id <= 23125;
+}
+
+// CLift::OnButtonDown: over a lift button of the scene
+bool Lift::onButtonDown(float x, float y) {
+ GameObject *hit = g_ngi->_currentScene->findGameObjectAtPos(x, y);
+ return hit && hit->_id == ANI_LIFTBUTTON;
+}
+
+// CLift::OnButtonUp(x, y): the door of the lift (982) and the areas GD_SCn_LIFT
+bool Lift::onButtonUp(float x, float y) {
+ GameObject *hit = g_ngi->_currentScene->findGameObjectAtPos(x, y);
+ if (!hit || (hit->_id != ANI_LIFT && (hit->_id < 23116 || hit->_id > 23125)))
+ return false;
+ return onButtonUp(hit);
+}
+
+// CLift::OnButtonUp(ani)
+bool Lift::onButtonUp(GameObject *) {
+ if (!_controller || !_controller->canInterruptManQueue())
+ return false;
+ if (!getGameLoaderInteractionController()->_enabled)
+ return false;
+ switchToBigView();
+ return true;
+}
+
+// CLift::SwitchToBigView: the cursor item goes back (CInventory::TakeFromCursor), SC_LIFT is pushed
+void Lift::switchToBigView() {
+ getGameLoaderInventory()->unselectItem(false);
+ g_ngi->pushScene(SC_LIFT);
+
+ Common::Array<AniObject *> buttons;
+ for (Common::HashMap<int, AniObject *>::iterator it = _buttons.begin(); it != _buttons.end(); ++it)
+ buttons.push_back(it->_value);
+ Common::sort(buttons.begin(), buttons.end(), liftButtonSort);
+ _controller->sortButtons(buttons);
+}
+
+// CLift::OnButtonUpBig: the matching button of the scene is pressed, the hero goes into the lift
+bool Lift::onButtonUpBig(AniObject *button) {
+ const int pushed = _controller->getStaticsPushed(button->_statics->_staticsId, false);
+ if (pushed == 0 || pushed == button->_statics->_staticsId)
+ return false;
+
+ if (button == _selected) {
+ g_ngi->playSound(SND_CMN_032, 0);
+ return false;
+ }
+ if (_selected) {
+ const int normal = _controller->getStaticsNormal(_selected->_statics->_staticsId, false);
+ if (normal)
+ _selected->_statics = _selected->getStatic(normal);
+ _selected = nullptr;
+ }
+ if (!_controller->canInterruptManQueue())
+ return false;
+
+ _selected = button;
+ button->_statics = button->getStatic(pushed);
+ const int hilite = _controller->getStaticsHilite(_selected->_statics->_staticsId, false);
+ if (!hilite)
+ return false;
+ _selected->_statics = _selected->getStatic(hilite);
+ enterLift();
+ return true;
+}
+
+// CLift::EnterLift: the hero walks to the lift and the door opens, or it stands there already
+void Lift::enterLift() {
+ warnOnce("CBaseSettings::SetSaving (the saves are not blocked while the lift moves)");
+ const Common::Point center = _hero->getCenter();
+ if (fabsf(_x - center.x) > 3.0f || fabsf(_y - center.y) > 3.0f || _hero->_movement || _hero->_statics->_staticsId != ST_MAN_UP) {
+ MessageQueue *queue = sceneController(*_scene).mctlStartMove(_x, _y, true, ST_MAN_UP, false);
+ if (queue) {
+ queue->_title = "lift_mctl_queue";
+ queue->addCommandToEnd(messageCommand("MSG_LIFT_CLICKBUTTON"));
+ }
+ return;
+ }
+
+ openDoor();
+ MessageQueue *queue = new MessageQueue(_enterQueue, 0, 0);
+ Command *pause = new Command(0, kCmdPause, 1245, 0, 0, 0, 1, 0, 0, 0);
+ queue->addCommandToFront(pause);
+ Command *show = new Command(_hero->_id, kCmdShow, -1, 0, 0, 0, 1, 0, 0, 0);
+ show->_param = _hero->_copyId;
+ show->_z = _lift->_z + 1;
+ show->_x = -1;
+ show->_y = -1;
+ show->_excFlags |= 3;
+ queue->addCommandToEnd(show);
+ queue->addCommandToEnd(messageCommand("MSG_LIFT_CLOSEDOOR"));
+ if (!queue->run(_hero))
+ delete queue;
+}
+
+// CLift::OnClickButton (MSG_LIFT_CLICKBUTTON): the hero is at the lift
+void Lift::onClickButton() {
+ if (_selected)
+ enterLift();
+}
+
+// CLift::CloseDoorAndGo (MSG_LIFT_CLOSEDOOR). ADAPTATION: the original puts the statics and the movement of the door into the queue (a movement that is
+// already running gets a start frame), here they are started at once, like the Windows game does.
+void Lift::closeDoorAndGo() {
+ if (_lift->_movement) {
+ if (_lift->_movement->_id != MV_LFT_CLOSE) {
+ const int frame = _lift->_movement->_curFrame;
+ if (_lift->_movement->_id == MV_LFT_OPEN) {
+ _lift->setStatic(ST_LFT_OPEN_NEW);
+ _lift->startMovement(MV_LFT_CLOSE, 0, -1);
+ if (_lift->_movement->_currMovement)
+ _lift->_movement->setCurFrame(_lift->_movement->_currMovement->_phases.size() - frame);
+ else
+ _lift->_movement->setCurFrame(_lift->_movement->_phases.size() - frame);
+ } else {
+ _lift->setStatic(ST_LFT_OPEN_NEW);
+ _lift->startMovement(MV_LFT_CLOSE, 0, -1);
+ }
+ }
+ } else if (_lift->_statics->_staticsId == ST_LFT_CLOSED) {
+ _lift->setStatic(ST_LFT_CLOSED);
+ } else {
+ _lift->startMovement(MV_LFT_CLOSE, 0, -1);
+ }
+
+ MessageQueue *queue = new MessageQueue(g_ngi->_globalMessageQueueList->compact());
+ queue->addCommandToEnd(messageCommand("MSG_LIFT_GO"));
+ if (!queue->run(_hero))
+ delete queue;
+}
+
+// CLift::ExitLift (MSG_LIFT_EXITLIFT): the door opens, the hero comes out
+void Lift::exitLift(MessageQueue *queue) {
+ _lift->setStatic(ST_LFT_CLOSED);
+ MessageQueue *exitQueue = new MessageQueue(g_ngi->_globalMessageQueueList->compact());
+ if (!queue)
+ exitQueue->addCommandToEnd(new Command(0, kCmdPause, 3320, 0, 0, 0, 1, 0, 0, 0));
+ exitQueue->addCommandToEnd(movementCommand(_lift, MV_LFT_OPEN));
+ exitQueue->addCommandToEnd(movementCommand(_hero, MV_MAN_STARTD));
+ Command *show = new Command(_hero->_id, kCmdShow, -1, 0, 0, 0, 1, 0, 0, 0);
+ show->_param = _hero->_copyId;
+ show->_z = 10;
+ show->_x = -1;
+ show->_y = -1;
+ show->_excFlags |= 3;
+ exitQueue->addCommandToEnd(show);
+ exitQueue->addCommandToEnd(messageCommand("MSG_LIFT_STARTEXITQUEUE"));
+ exitQueue->addCommandToEnd(movementCommand(_lift, MV_LFT_CLOSE));
+ if (!exitQueue->run(_hero))
+ delete exitQueue;
+}
+
+// CLift::OnGo (MSG_LIFT_GO): the hero rides to the pressed button's floor (PASSAGE of data.xml)
+void Lift::onGo() {
+ if (_selected) {
+ const int button = _controller->getStaticsNormal(_selected->_statics->_staticsId, false);
+ if (button) {
+ for (const PreloadItem &passage : g_ngi->_gameLoader->_preloadItems) {
+ if (passage.preloadId2 != button || passage.preloadId1 != _scene->_sceneId)
+ continue;
+ MessageQueue *queue = new MessageQueue(g_ngi->_globalMessageQueueList->compact());
+ Command *ride = new Command(ANI_MAN, kCmdStartMovement, passage.param != LiftDown ? MV_MAN_LIFTDOWN : MV_MAN_LIFTUP, 0, 0, 0, 1, 0, 0, 0);
+ ride->_param = -1;
+ ride->_wait = 1;
+ ride->_excFlags |= 2;
+ queue->addCommandToEnd(ride);
+ Command *scene = new Command(passage.sceneId, kCmdSetScene, passage.param, 0, 0, 0, 1, 0, 0, 0);
+ scene->_excFlags |= 3;
+ queue->addCommandToEnd(scene);
+ Command *achievement = new Command(0, kCmdUser, 0, 0, 0, 0, 1, 0, 0, 0);
+ achievement->_messageName = "ADD_ACHIEVEMENT_ACTIVITY";
+ achievement->_args["type"] = "ADD_ACHIEVEMENT_ACTIVITY";
+ achievement->_args["achievementId"] = "ACHIEVEMENT_LIFT";
+ achievement->_args["procent"] = "12";
+ achievement->_args["item"] = g_ngi->_gameProject->_objectIds.findName(passage.sceneId);
+ achievement->_wait = 0;
+ queue->addCommandToEnd(achievement);
+ if (!queue->run(_hero))
+ delete queue;
+ return;
+ }
+ }
+ }
+
+ exitLift(nullptr);
+ if (_selected) {
+ _selected->_statics = _selected->getStatic(_controller->getStaticsNormal(_selected->_statics->_staticsId, false));
+ _selected = nullptr;
+ }
+}
+
+// CLift::StartExitQueue (MSG_LIFT_STARTEXITQUEUE): the exit queue, then MSG_SET_SAVING
+void Lift::startExitQueue() {
+ MessageQueue *queue = new MessageQueue(_exitQueue, 0, 0);
+ queue->addCommandToEnd(messageCommand("MSG_SET_SAVING"));
+ if (!queue->run(nullptr))
+ delete queue;
+}
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/lift.h b/engines/ngi/fullpipe/lift.h
new file mode 100644
index 00000000000..52c3350983f
--- /dev/null
+++ b/engines/ngi/fullpipe/lift.h
@@ -0,0 +1,81 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_LIFT_H
+#define NGI_FULLPIPE_LIFT_H
+
+#include "common/hashmap.h"
+#include "common/str.h"
+
+namespace NGI {
+
+class AniObject;
+class GameObject;
+class LiftController;
+class MessageQueue;
+class Scene;
+
+/** CLift (CSingleton, NGIEngine::lift()): buttons, door, walk in/out, SC_LIFT big buttons view */
+class Lift {
+public:
+ Lift();
+
+ /** CLift::InitLift: the lift scene, the hero, the ids of the walk in and out queues */
+ void initLift(Scene *scene, AniObject *hero, int enterQueueId, int exitQueueId);
+ void openDoor();
+ /** CLift::EnableButton(scene, statics): shows the buttons whose normal statics it is */
+ void enableButton(Scene *scene, int staticsId);
+ /** CLift::EnableButton(name, state): the state of the object "lift buttons" of the floor */
+ void enableButton(const Common::String &name, int state);
+ bool isButtonEnabled(const Common::String &name);
+ void resetButtons();
+ void onResetDest(MessageQueue *queue);
+ bool getCursorType(float x, float y);
+ bool onButtonDown(float x, float y);
+ bool onButtonDownBig() { return false; }
+ /** CLift::OnButtonUp(ani): a tap on the lift door or area opens the big buttons view */
+ bool onButtonUp(GameObject *object);
+ bool onButtonUp(float x, float y);
+ bool onButtonUpBig(AniObject *button);
+ void switchToBigView();
+ void enterLift();
+ void onClickButton();
+ void closeDoorAndGo();
+ void exitLift(MessageQueue *queue);
+ void onGo();
+ void startExitQueue();
+
+private:
+ AniObject *_selected = nullptr; // +8: the button that was pressed
+ float _x = 0; // +12: where the hero stands to enter
+ float _y = 0; // +16
+ MessageQueue *_enterQueue = nullptr; // +20
+ MessageQueue *_exitQueue = nullptr; // +24
+ AniObject *_lift = nullptr; // +28
+ Scene *_scene = nullptr; // +32
+ AniObject *_hero = nullptr; // +36
+ Common::HashMap<int, AniObject *> _buttons; // +40: the buttons of the scene by their statics
+ LiftController *_controller = nullptr; // +64: the controller of the scene SC_LIFT
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_LIFT_H
diff --git a/engines/ngi/fullpipe/liftcontroller.cpp b/engines/ngi/fullpipe/liftcontroller.cpp
new file mode 100644
index 00000000000..b5006cce359
--- /dev/null
+++ b/engines/ngi/fullpipe/liftcontroller.cpp
@@ -0,0 +1,163 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/debug.h"
+
+#include "ngi/ngi.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/lift.h"
+#include "ngi/fullpipe/liftcontroller.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+
+namespace NGI {
+
+namespace {
+
+enum {
+ kPicLiftBackground = 23038, // PIC_LIFT_BGR (0x59FE)
+ kAniLiftButtonBig = 23039, // ANI_LIFTBUTTON_BIG (0x59FF)
+ kBigStatics = 23040, // CLiftController::GetStaticsNormal(big)
+ kSceneStatics = 23070
+};
+
+void warnOnce(const char *what) {
+ static Common::HashMap<Common::String, bool> reported;
+ if (!reported.contains(what)) {
+ reported[what] = true;
+ warning("STUB/untested: %s", what);
+ }
+}
+
+} // End of anonymous namespace
+
+// CLiftController::CLiftController
+LiftController::LiftController(int sceneId) : FPController(sceneId) {
+}
+
+// CLiftController::GetStaticsNormal
+int LiftController::getStaticsNormal(int staticsId, bool big) const {
+ const int base = big ? kBigStatics : kSceneStatics;
+ return 3 * ((staticsId - base) / 3) + base;
+}
+
+// CLiftController::IsStaticsNormal
+bool LiftController::isStaticsNormal(int staticsId, bool big) const {
+ const int base = big ? kBigStatics : kSceneStatics;
+ return (staticsId - base) % 3 == 0;
+}
+
+// CLiftController::CountStaticNormal: the big buttons that are enabled
+int LiftController::countStaticNormal() const {
+ int count = 0;
+ for (const Button &button : _buttons)
+ count += isStaticsNormal(button.big->_statics->_staticsId, true);
+ return count;
+}
+
+// CLiftController::SortButtons: a big ANI_LIFTBUTTON_BIG copy for every button, two in a row
+void LiftController::sortButtons(const Common::Array<AniObject *> &buttons) {
+ _selected = nullptr;
+ _time = 0;
+ PictureObject *background = _scene->findPictureObjectById(kPicLiftBackground, 0);
+ AniObject *original = _scene->findAniObjectById(kAniLiftButtonBig, 0);
+ if (!background || !original) {
+ warning("The scene of the lift view lacks its background or the big button");
+ return;
+ }
+
+ for (uint i = 0; i < buttons.size(); ++i) {
+ AniObject *big = new AniObject(original);
+ _scene->addAni(big, true);
+ big->_flags |= 4; // CVisibleObject +8 |= 1: visible
+ const float x = background->_x + 52.0f + (i & 1) * 65.0f;
+ const float y = background->_y + 64.0f + (i >> 1) * 85.0f;
+ // ADAPTATION: the center depends on the size of the statics here, so the statics comes first (the original sets the center first)
+ big->_statics = big->getStatic(buttons[i]->_statics->_staticsId - 30);
+ big->setCenter(Common::Point(x, y));
+ if (i + 1 == buttons.size() && buttons[i]->_x > buttons[0]->_x)
+ big->setCenter(Common::Point(background->_x + 52 + 65, y));
+
+ Button button;
+ button.big = big;
+ button.small = buttons[i];
+ _buttons.push_back(button);
+ }
+
+ // the tutorials of the lift (CTutorialManager::ActivateTutorial ADDITIONAL_TUTORIAL_LIFT in the scenes 3 and 38) are not ported
+ const int sceneId = g_ngi->getSceneInStack(0)->_sceneId;
+ if ((sceneId == SC_3 && countStaticNormal() == 1) || (sceneId == SC_38 && countStaticNormal() <= 2))
+ warnOnce("CLiftController::SortButtons: the additional lift tutorials are not ported");
+}
+
+// CLiftController::OnHide: the big buttons go away. ADAPTATION: CScene::RemoveCopies removes every copy of the scene, these are the ones that
+// SortButtons made. CInventory::SetItemsState(0) and the hint of the scene 3 (CHintManager::HideHint) are not ported.
+void LiftController::onHide() {
+ for (const Button &button : _buttons) {
+ _scene->removeAni(button.big);
+ delete button.big;
+ }
+ _buttons.clear();
+ _selected = nullptr;
+ _time = 0;
+ if (g_ngi->getSceneInStack(0)->_sceneId == SC_3)
+ warnOnce("CHintManager::HideHint (the scene 3 hint) is not ported");
+}
+
+// CLiftController::OnUpdate: the scene below goes on (CScene::Update); 100 ms after a button
+// was lit it is pressed in the scene and the view closes
+void LiftController::onUpdate(uint32 elapsed) {
+ g_ngi->getSceneInStack(0)->update(elapsed);
+ if (!_selected)
+ return;
+ _time += elapsed;
+ if (_time > 100) {
+ for (const Button &button : _buttons) {
+ if (button.big == _selected) {
+ g_ngi->lift().onButtonUpBig(button.small);
+ break;
+ }
+ }
+ g_ngi->popScene();
+ }
+}
+
+// CLiftController::OnMouseLKeyUp: an enabled big button is lit, a tap anywhere else closes the view
+bool LiftController::onMouseLKeyUp(uint32 id, float x, float y) {
+ AniObject *hit = _scene->findAniObjectAtPos(x, y);
+ if (hit && hit->_id == kAniLiftButtonBig && hit->_statics && isStaticsNormal(hit->_statics->_staticsId, true)) {
+ _selected = hit;
+ g_ngi->playSound(SND_CMN_032, 0); // CSoundManager::Play(0xDBD)
+ _selected->_statics = _selected->getStatic(getStaticsHilite(_selected->_statics->_staticsId, true));
+ } else {
+ g_ngi->popScene();
+ }
+ return true;
+}
+
+// CLiftController::GetCursorType: the hand over an enabled big button. Cursors of pushed scenes
+// are not driven by controllers yet (D11); the cursor 4 list check is not ported
+int LiftController::getCursorType(float x, float y) {
+ AniObject *hit = _scene->findAniObjectAtPos(x, y);
+ return hit && hit->_id == kAniLiftButtonBig && hit->_statics && isStaticsNormal(hit->_statics->_staticsId, true);
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/liftcontroller.h b/engines/ngi/fullpipe/liftcontroller.h
new file mode 100644
index 00000000000..526a6781daa
--- /dev/null
+++ b/engines/ngi/fullpipe/liftcontroller.h
@@ -0,0 +1,65 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_LIFTCONTROLLER_H
+#define NGI_FULLPIPE_LIFTCONTROLLER_H
+
+#include "common/array.h"
+
+#include "ngi/fullpipe/fpcontroller.h"
+
+namespace NGI {
+
+class AniObject;
+
+/** CLiftController: SC_LIFT, the big view of the lift buttons (CLift::SwitchToBigView) */
+class LiftController : public FPController {
+public:
+ explicit LiftController(int sceneId);
+
+ /** the statics of the buttons go by three (normal, pushed, hilite) from 23070, big view 23040 */
+ int getStaticsPushed(int staticsId, bool big) const { return staticsId + 1; }
+ int getStaticsNormal(int staticsId, bool big) const;
+ int getStaticsHilite(int staticsId, bool big) const { return getStaticsNormal(staticsId, big) + 2; }
+ bool isStaticsNormal(int staticsId, bool big) const;
+ int countStaticNormal() const;
+ /** CLiftController::SortButtons: a big button for every button of the scene (sorted) */
+ void sortButtons(const Common::Array<AniObject *> &buttons);
+
+ void onHide() override;
+ void onUpdate(uint32 elapsed) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ int getCursorType(float x, float y) override;
+ bool isInventoryRendered() override { return true; }
+
+private:
+ struct Button {
+ AniObject *big;
+ AniObject *small;
+ };
+ Common::Array<Button> _buttons; // +216: the big button and the button of the scene it belongs to
+ AniObject *_selected = nullptr; // +240
+ int _time = 0; // +244
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_LIFTCONTROLLER_H
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index 823751d3d72..50060f21298 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -27,6 +27,7 @@
#include "ngi/fullpipe/chaptercontroller.h"
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/inventorycontroller.h"
+#include "ngi/fullpipe/liftcontroller.h"
namespace NGI {
@@ -466,6 +467,9 @@ void createSceneController(int sceneId) {
case SC_NOTEBOOK:
new Notebook(sceneId);
break;
+ case SC_LIFT:
+ new LiftController(sceneId);
+ break;
case SC_INV:
new InventoryController(sceneId);
break;
diff --git a/engines/ngi/messages.cpp b/engines/ngi/messages.cpp
index e961a5cdad6..9f111ccc6d9 100644
--- a/engines/ngi/messages.cpp
+++ b/engines/ngi/messages.cpp
@@ -150,6 +150,11 @@ bool Command::handleMessage() {
for (MessageHandler *m = g_ngi->_messageHandlers; m; m = m->nextItem)
cnt += m->callback(this);
+ // CMessageQueue::ExecuteCmdMsg: a message of the Android build goes by its name to the controller of the scene (CScene::Message). ADAPTATION: the scene
+ // is the current one, the original sends it to the first scene of the stack.
+ if (_cmd == kCmdMessage && !_messageName.empty() && g_ngi->_gameVersion >= 201509 && g_ngi->_currentScene && g_ngi->_currentScene->_controller)
+ g_ngi->_currentScene->_controller->onMessage(_messageName, Common::String(), g_ngi->_globalMessageQueueList->getMessageQueueById(_parId));
+
if (_cmd == kCmdMessage || (_excFlags & 1)) {
if (_parId) {
MessageQueue *mq = g_ngi->_globalMessageQueueList->getMessageQueueById(_parId);
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 457aada0a52..0c787d48d69 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -84,6 +84,7 @@ MODULE_OBJS = \
fullpipe/fpcontroller.o \
fullpipe/inventorycontroller.o \
fullpipe/lift.o \
+ fullpipe/liftcontroller.o \
fullpipe/notebook.o \
fullpipe/scene01.o \
fullpipe/scene02.o \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index c4ffbcbaf64..43934f33359 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -34,6 +34,7 @@
#include "ngi/ngi.h"
#include "ngi/scenecontroller.h"
+#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/fpcontroller.h"
#include "ngi/fullpipe/chaptermanager.h"
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 02f65f67d77..a1a4eae5bec 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -422,6 +422,7 @@ public:
void getAllInventory();
+ Common::ScopedPtr<class Lift> _liftManager;
AniObject *_lastLiftButton;
MessageQueue *_liftEnterMQ;
MessageQueue *_liftExitMQ;
@@ -435,7 +436,8 @@ public:
void lift_setButton(const char *name, int state);
void lift_resetButtons();
/** Android: opens the panel with the buttons of the lift of the scene (CLift::SwitchToBigView) */
- bool lift_switchToBigView();
+ /** CSingleton<CLift>::GetInst (Android; the Windows game has the lift_ functions) */
+ class Lift &lift();
void lift_init(Scene *sc, int qu1, int qu2);
void lift_setButtonStatics(Scene *sc, int buttonId);
void lift_exitSeq(Command *ex);
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 30dbe8ed42d..fa32a67740b 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -1082,6 +1082,14 @@ void Scene::updateScrolling2() {
}
}
+GameObject *Scene::findGameObjectAtPos(int x, int y) {
+ PictureObject *picture = findPictureObjectAtPos(x, y);
+ AniObject *actor = findAniObjectAtPos(x, y);
+ if (actor && (!picture || actor->_z < picture->_z))
+ return actor;
+ return picture;
+}
+
AniObject *Scene::findAniObjectAtPos(int x, int y) {
AniObject *res = nullptr;
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index fad31fdbdfc..5e175ab629c 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -165,6 +165,8 @@ class Scene : public Background {
AniObject *findAniObjectAtPos(int x, int y);
PictureObject *findPictureObjectAtPos(int x, int y);
int getPictureObjectIdAtPos(int x, int y);
+ /** The object under a point: the animation unless a picture is in front of it */
+ GameObject *findGameObjectAtPos(int x, int y);
void initObjectCursors(const char *name);
Commit: 753990757ea10e2e13926f05ff2233f6fa25ae8f
https://github.com/scummvm/scummvm/commit/753990757ea10e2e13926f05ff2233f6fa25ae8f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Queue the door commands of CLift::CloseDoorAndGo so the door closes before the ride
Changed paths:
engines/ngi/fullpipe/lift.cpp
diff --git a/engines/ngi/fullpipe/lift.cpp b/engines/ngi/fullpipe/lift.cpp
index 72d42ddabf1..7bef7e82221 100644
--- a/engines/ngi/fullpipe/lift.cpp
+++ b/engines/ngi/fullpipe/lift.cpp
@@ -662,6 +662,13 @@ Command *movementCommand(const AniObject *ani, int movementId) {
return command;
}
+Command *staticCommand(const AniObject *ani, int staticsId) {
+ Command *command = new Command(ani->_id, kCmdSetStatic, staticsId, 0, 0, 0, 1, 0, 0, 0);
+ command->_param = ani->_copyId;
+ command->_excFlags |= 3;
+ return command;
+}
+
// LiftButtonSort: by the position (y, then x)
bool liftButtonSort(const AniObject *a, const AniObject *b) {
return a->_y == b->_y ? a->_x < b->_x : a->_y < b->_y;
@@ -898,31 +905,25 @@ void Lift::onClickButton() {
enterLift();
}
-// CLift::CloseDoorAndGo (MSG_LIFT_CLOSEDOOR). ADAPTATION: the original puts the statics and the movement of the door into the queue (a movement that is
-// already running gets a start frame), here they are started at once, like the Windows game does.
+// CLift::CloseDoorAndGo (MSG_LIFT_CLOSEDOOR): the door closes, then MSG_LIFT_GO
void Lift::closeDoorAndGo() {
- if (_lift->_movement) {
- if (_lift->_movement->_id != MV_LFT_CLOSE) {
- const int frame = _lift->_movement->_curFrame;
- if (_lift->_movement->_id == MV_LFT_OPEN) {
- _lift->setStatic(ST_LFT_OPEN_NEW);
- _lift->startMovement(MV_LFT_CLOSE, 0, -1);
- if (_lift->_movement->_currMovement)
- _lift->_movement->setCurFrame(_lift->_movement->_currMovement->_phases.size() - frame);
- else
- _lift->_movement->setCurFrame(_lift->_movement->_phases.size() - frame);
- } else {
- _lift->setStatic(ST_LFT_OPEN_NEW);
- _lift->startMovement(MV_LFT_CLOSE, 0, -1);
- }
+ MessageQueue *queue = new MessageQueue(g_ngi->_globalMessageQueueList->compact());
+ if (!_lift->_movement) {
+ if (_lift->_statics->_staticsId == ST_LFT_CLOSED)
+ queue->addCommandToEnd(staticCommand(_lift, ST_LFT_CLOSED));
+ else
+ queue->addCommandToEnd(movementCommand(_lift, MV_LFT_CLOSE));
+ } else if (_lift->_movement->_id != MV_LFT_CLOSE) {
+ if (_lift->_movement->_id == MV_LFT_OPEN) {
+ Command *close = movementCommand(_lift, MV_LFT_CLOSE);
+ const Movement *movement = _lift->_movement->_currMovement ? _lift->_movement->_currMovement : _lift->_movement;
+ close->_z = movement->_phases.size() - _lift->_movement->_curFrame; // the start frame
+ queue->addCommandToEnd(close);
+ } else {
+ queue->addCommandToEnd(staticCommand(_lift, ST_LFT_OPEN_NEW));
+ queue->addCommandToEnd(movementCommand(_lift, MV_LFT_CLOSE));
}
- } else if (_lift->_statics->_staticsId == ST_LFT_CLOSED) {
- _lift->setStatic(ST_LFT_CLOSED);
- } else {
- _lift->startMovement(MV_LFT_CLOSE, 0, -1);
}
-
- MessageQueue *queue = new MessageQueue(g_ngi->_globalMessageQueueList->compact());
queue->addCommandToEnd(messageCommand("MSG_LIFT_GO"));
if (!queue->run(_hero))
delete queue;
Commit: c0c28c27d02b808c3c6834d22b494fdbc7d2a526
https://github.com/scummvm/scummvm/commit/c0c28c27d02b808c3c6834d22b494fdbc7d2a526
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Port CAniObject::SetStatic, the Android copy constructor, CScene::RemoveCopies, CScene::Message, ExecuteUserCmd scene choice and CLift::OpenDoor exactly
Changed paths:
engines/ngi/fullpipe/chaptercontroller.cpp
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/lift.cpp
engines/ngi/fullpipe/liftcontroller.cpp
engines/ngi/messages.cpp
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/statics.cpp
diff --git a/engines/ngi/fullpipe/chaptercontroller.cpp b/engines/ngi/fullpipe/chaptercontroller.cpp
index 2ce62f7e1ab..31e024d11ae 100644
--- a/engines/ngi/fullpipe/chaptercontroller.cpp
+++ b/engines/ngi/fullpipe/chaptercontroller.cpp
@@ -216,9 +216,9 @@ void ChapterController::onKeyUp(uint32 key) {
trySkip();
}
-// CChapterController::OnMessage: the messages go to the first scene of the stack (CScene::Message); the messages of this build are
-// delivered to the scene handlers directly, there is nothing to forward
+// CChapterController::OnMessage (147B44)
void ChapterController::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ g_ngi->getSceneInStack(0)->message(message, param, queue);
}
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index a58ff76b4cb..91dc7192d71 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -82,21 +82,26 @@ static void execSetActiveInteraction(Command *cmd) {
findId(cmd->_args.getValOrDefault("obj")), floatArg(cmd, "act", 1.0f), floatArg(cmd, "add", 0.0f));
}
-// CMessageQueue::ExecuteUserCmd: the scene of the command (parameter "sc", else the scene of the queue) and its controller run it.
-// ADAPTATIONS: there is no scene stack ("sceneInStack") and the queue does not know its scene, the current scene is taken instead; the
-// original executes SET_ACTIVE_INTERACTION (kind 0xB) as a command kind of its own, ScummVM maps it to the user commands.
+// CMessageQueue::ExecuteUserCmd (10E68C): the scene is the one of the parameter "sc"; the parameter "sceneInStack" (default -1, clamped to the last scene of the
+// stack) replaces it with that scene of the stack; without any the scene of the queue (+20) is taken, then its controller runs the command. OPEN QUESTION:
+// MessageQueue does not know its scene (+20) yet, the current scene is used for that case.
void executeUserCommand(Command *cmd, MessageQueue *queue) {
if (cmd->_messageName == "SET_ACTIVE_INTERACTION") {
execSetActiveInteraction(cmd);
return;
}
- Scene *scene = g_ngi->_currentScene;
+ Scene *scene = nullptr;
const Common::String sceneName = cmd->_args.getValOrDefault("sc");
- if (!sceneName.empty()) {
- if (Scene *target = g_ngi->findScene(findId(sceneName)))
- scene = target;
- }
+ if (!sceneName.empty())
+ scene = g_ngi->findScene(findId(sceneName));
+ int sceneInStack = cmd->_args.contains("sceneInStack") ? atoi(cmd->_args["sceneInStack"].c_str()) : -1;
+ if ((int)g_ngi->_sceneStack.size() <= sceneInStack)
+ sceneInStack = (int)g_ngi->_sceneStack.size() - 1;
+ if (sceneInStack >= 0 && (int)g_ngi->_sceneStack.size() > sceneInStack)
+ scene = g_ngi->getSceneInStack(sceneInStack);
+ if (!scene)
+ scene = g_ngi->getCurrentScene();
if (scene && scene->_controller)
scene->_controller->executeUserCmd(cmd, queue);
}
diff --git a/engines/ngi/fullpipe/lift.cpp b/engines/ngi/fullpipe/lift.cpp
index 7bef7e82221..75dd0c3ab2e 100644
--- a/engines/ngi/fullpipe/lift.cpp
+++ b/engines/ngi/fullpipe/lift.cpp
@@ -708,7 +708,7 @@ void Lift::initLift(Scene *scene, AniObject *hero, int enterQueueId, int exitQue
// the buttons are the copies 1, 2 ... of ANI_LIFTBUTTON (ADDANI of SC_COMMON), all start pushed
_buttons.clear();
for (int copy = 1; AniObject *button = scene->findAniObjectById(ANI_LIFTBUTTON, copy); ++copy) {
- button->_statics = button->getStatic(_controller->getStaticsPushed(button->_statics->_staticsId, false));
+ button->setStatic(_controller->getStaticsPushed(button->_statics->_staticsId, false));
_buttons[button->_statics->_staticsId] = button;
}
@@ -721,25 +721,21 @@ void Lift::initLift(Scene *scene, AniObject *hero, int enterQueueId, int exitQue
for (GameVar *state = states->_subVars; state; state = state->_nextVarObj) {
for (int copy = 1; AniObject *button = scene->findAniObjectById(ANI_LIFTBUTTON, copy); ++copy) {
if (_controller->getStaticsNormal(button->_statics->_staticsId, false) == state->_value.intValue)
- button->_statics = button->getStatic(state->_value.intValue);
+ button->setStatic(state->_value.intValue);
}
}
}
-// CLift::OpenDoor. The original starts the opening from the frame that mirrors the closing one (the start frame argument of StartMovement), here the frame
-// is set after the start like the Windows game does.
+// CLift::OpenDoor (153990): a closing door opens from the mirrored frame; another movement
+// is replaced by the closed statics and the opening; a door at rest in ST_LFT_OPEN_NEW likewise
void Lift::openDoor() {
if (_lift->_movement) {
if (_lift->_movement->_id == MV_LFT_OPEN)
return;
if (_lift->_movement->_id == MV_LFT_CLOSE) {
- const int frame = _lift->_movement->_curFrame;
- _lift->setStatic(ST_LFT_CLOSED);
- _lift->startMovement(MV_LFT_OPEN, 0, -1);
- if (_lift->_movement->_currMovement)
- _lift->_movement->setCurFrame(_lift->_movement->_currMovement->_phases.size() - frame);
- else
- _lift->_movement->setCurFrame(_lift->_movement->_phases.size() - frame);
+ const Movement *movement = _lift->_movement->_currMovement ? _lift->_movement->_currMovement : _lift->_movement;
+ const int startFrame = movement->_phases.size() - _lift->_movement->_curFrame;
+ _lift->startMovement(MV_LFT_OPEN, 0, startFrame);
} else {
_lift->setStatic(ST_LFT_CLOSED);
_lift->startMovement(MV_LFT_OPEN, 0, -1);
@@ -756,7 +752,7 @@ void Lift::enableButton(Scene *scene, int staticsId) {
for (int copy = 1; copy <= 10; ++copy) {
AniObject *button = scene->findAniObjectById(ANI_LIFTBUTTON, copy);
if (button && _controller->getStaticsNormal(button->_statics->_staticsId, false) == staticsId)
- button->_statics = button->getStatic(staticsId);
+ button->setStatic(staticsId);
}
}
@@ -794,7 +790,7 @@ void Lift::resetButtons() {
// CLift::OnResetDest: the walk to the lift was interrupted, the button comes up
void Lift::onResetDest(MessageQueue *queue) {
if (_selected && queue && queue->_title == "lift_mctl_queue") {
- _selected->_statics = _selected->getStatic(_controller->getStaticsNormal(_selected->_statics->_staticsId, false));
+ _selected->setStatic(_controller->getStaticsNormal(_selected->_statics->_staticsId, false));
_selected = nullptr;
}
}
@@ -854,18 +850,18 @@ bool Lift::onButtonUpBig(AniObject *button) {
if (_selected) {
const int normal = _controller->getStaticsNormal(_selected->_statics->_staticsId, false);
if (normal)
- _selected->_statics = _selected->getStatic(normal);
+ _selected->setStatic(normal);
_selected = nullptr;
}
if (!_controller->canInterruptManQueue())
return false;
_selected = button;
- button->_statics = button->getStatic(pushed);
+ button->setStatic(pushed);
const int hilite = _controller->getStaticsHilite(_selected->_statics->_staticsId, false);
if (!hilite)
return false;
- _selected->_statics = _selected->getStatic(hilite);
+ _selected->setStatic(hilite);
enterLift();
return true;
}
@@ -984,7 +980,7 @@ void Lift::onGo() {
exitLift(nullptr);
if (_selected) {
- _selected->_statics = _selected->getStatic(_controller->getStaticsNormal(_selected->_statics->_staticsId, false));
+ _selected->setStatic(_controller->getStaticsNormal(_selected->_statics->_staticsId, false));
_selected = nullptr;
}
}
diff --git a/engines/ngi/fullpipe/liftcontroller.cpp b/engines/ngi/fullpipe/liftcontroller.cpp
index b5006cce359..9b45d5d3134 100644
--- a/engines/ngi/fullpipe/liftcontroller.cpp
+++ b/engines/ngi/fullpipe/liftcontroller.cpp
@@ -86,13 +86,13 @@ void LiftController::sortButtons(const Common::Array<AniObject *> &buttons) {
for (uint i = 0; i < buttons.size(); ++i) {
AniObject *big = new AniObject(original);
+ big->assignCopyId(&_scene->_aniObjects); // CScene::AddAni(big, 0): copy number
_scene->addAni(big, true);
big->_flags |= 4; // CVisibleObject +8 |= 1: visible
const float x = background->_x + 52.0f + (i & 1) * 65.0f;
const float y = background->_y + 64.0f + (i >> 1) * 85.0f;
- // ADAPTATION: the center depends on the size of the statics here, so the statics comes first (the original sets the center first)
- big->_statics = big->getStatic(buttons[i]->_statics->_staticsId - 30);
big->setCenter(Common::Point(x, y));
+ big->setStatic(buttons[i]->_statics->_staticsId - 30);
if (i + 1 == buttons.size() && buttons[i]->_x > buttons[0]->_x)
big->setCenter(Common::Point(background->_x + 52 + 65, y));
@@ -108,13 +108,10 @@ void LiftController::sortButtons(const Common::Array<AniObject *> &buttons) {
warnOnce("CLiftController::SortButtons: the additional lift tutorials are not ported");
}
-// CLiftController::OnHide: the big buttons go away. ADAPTATION: CScene::RemoveCopies removes every copy of the scene, these are the ones that
-// SortButtons made. CInventory::SetItemsState(0) and the hint of the scene 3 (CHintManager::HideHint) are not ported.
+// CLiftController::OnHide: CScene::RemoveCopies removes the big buttons, the map is cleared. CInventory::SetItemsState(0) and the hint of the scene 3
+// (CHintManager::HideHint) are not ported.
void LiftController::onHide() {
- for (const Button &button : _buttons) {
- _scene->removeAni(button.big);
- delete button.big;
- }
+ _scene->removeCopies();
_buttons.clear();
_selected = nullptr;
_time = 0;
@@ -146,7 +143,7 @@ bool LiftController::onMouseLKeyUp(uint32 id, float x, float y) {
if (hit && hit->_id == kAniLiftButtonBig && hit->_statics && isStaticsNormal(hit->_statics->_staticsId, true)) {
_selected = hit;
g_ngi->playSound(SND_CMN_032, 0); // CSoundManager::Play(0xDBD)
- _selected->_statics = _selected->getStatic(getStaticsHilite(_selected->_statics->_staticsId, true));
+ _selected->setStatic(getStaticsHilite(_selected->_statics->_staticsId, true));
} else {
g_ngi->popScene();
}
diff --git a/engines/ngi/messages.cpp b/engines/ngi/messages.cpp
index 9f111ccc6d9..332b0dfef41 100644
--- a/engines/ngi/messages.cpp
+++ b/engines/ngi/messages.cpp
@@ -150,10 +150,19 @@ bool Command::handleMessage() {
for (MessageHandler *m = g_ngi->_messageHandlers; m; m = m->nextItem)
cnt += m->callback(this);
- // CMessageQueue::ExecuteCmdMsg: a message of the Android build goes by its name to the controller of the scene (CScene::Message). ADAPTATION: the scene
- // is the current one, the original sends it to the first scene of the stack.
- if (_cmd == kCmdMessage && !_messageName.empty() && g_ngi->_gameVersion >= 201509 && g_ngi->_currentScene && g_ngi->_currentScene->_controller)
- g_ngi->_currentScene->_controller->onMessage(_messageName, Common::String(), g_ngi->_globalMessageQueueList->getMessageQueueById(_parId));
+ // CMessageQueue::ExecuteCmdMsg: goes by name to the "scene" parameter, else to the top scene
+ if (_cmd == kCmdMessage && !_messageName.empty() && g_ngi->_gameVersion >= 201509) {
+ Scene *scene = nullptr;
+ uint32 sceneId = 0;
+ if (_args.contains("scene") && g_ngi->_gameProject->_objectIds.findId(_args["scene"], sceneId))
+ scene = g_ngi->findScene(sceneId);
+ else
+ scene = g_ngi->getCurrentScene();
+ if (scene)
+ scene->message(_messageName, _args.getValOrDefault("param"), g_ngi->_globalMessageQueueList->getMessageQueueById(_parId));
+ else
+ warning("Error during CMD_MESSAGE, scene not found.");
+ }
if (_cmd == kCmdMessage || (_excFlags & 1)) {
if (_parId) {
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index fa32a67740b..4e9fb91cd99 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -627,6 +627,28 @@ void Scene::removeAni(AniObject *obj) {
}
}
+// CScene::RemoveCopies (the roaming parameters of the copies are not ported)
+void Scene::removeCopies() {
+ Common::Array<AniObject *> copies;
+ for (AniObject *ani : _aniObjects) {
+ if (ani->_copyId != 0)
+ copies.push_back(ani);
+ }
+ for (AniObject *ani : copies) {
+ removeAni(ani);
+ delete ani;
+ }
+ if (!copies.empty()) {
+ static bool warned = false;
+ if (!warned) {
+ warned = true;
+ warning("STUB/untested: CScene::RemoveRoamingObjectAnyCopes (the roaming parameters of the removed copies)");
+ }
+ }
+ if (_controller)
+ _controller->onRemoveCopies();
+}
+
void Scene::addAni(AniObject *obj, bool addList2) {
// WORKAROUND: This is used for making sure that the objects
// with same priority do not get swapped during drawing
@@ -979,6 +1001,20 @@ bool Scene::onMouseMove(uint32 id, float x, float y) {
return false;
}
+// CScene::Message (120BA4): the controller's OnMessage (slot +112), then INTERACT_ENDED clears the flag (+104) of the interaction that ends, found by
+// CInteractionController::FindInteraction(param). The interactions of this engine do not have that flag yet: STUB.
+void Scene::message(const Common::String &name, const Common::String ¶m, MessageQueue *queue) {
+ if (_controller)
+ _controller->onMessage(name, param, queue);
+ if (name == "INTERACT_ENDED") {
+ static bool warned = false;
+ if (!warned) {
+ warned = true;
+ warning("STUB/untested: CScene::Message INTERACT_ENDED (the flag of the interaction is not ported)");
+ }
+ }
+}
+
// CScene::OnKeyUp: the controller
void Scene::onKeyUp(uint32 key) {
if (_controller)
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 5e175ab629c..704dd8e69a0 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -110,6 +110,8 @@ class Scene : public Background {
bool onMouseRKeyUp(uint32 id, float x, float y);
bool onMouseMove(uint32 id, float x, float y);
void onKeyUp(uint32 key);
+ /** CScene::Message: the controller gets the message by its name */
+ void message(const Common::String &name, const Common::String ¶m, MessageQueue *queue);
bool isInventoryRendered() const;
bool isInventoryEnabled() const;
void (*_guiEventHandler)(Scene &, const Common::String &, const Common::String &) = nullptr;
@@ -153,6 +155,8 @@ class Scene : public Background {
MessageQueue *getMessageQueueByName(const Common::String &name);
void removeAni(AniObject *obj);
+ /** CScene::RemoveCopies: the copies of the objects (copy id != 0) are removed and destroyed */
+ void removeCopies();
/** takes ownership of the passed obj */
void addAni(AniObject *obj, bool addList2);
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 2cc5e834d25..b5c82759209 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -140,6 +140,9 @@ AniObject::AniObject(AniObject *src) : GameObject(src) {
_movement = nullptr;
_statics = nullptr;
+ // F2818: the copy keeps the statics of the source
+ if (g_ngi->_gameVersion >= 201509 && src->_statics)
+ _statics = getStatic(src->_statics->_staticsId);
for (uint i = 0; i < src->_movements.size(); i++) {
Movement *newmov;
@@ -1129,16 +1132,42 @@ MessageQueue *AniObject::moveToStatic(int msgNum) {
}
void AniObject::setStatic(int objId) {
- _animExFlag = 0;
+ if (g_ngi->_gameVersion < 201509) {
+ _animExFlag = 0;
- stopQueue();
+ stopQueue();
+ }
if (g_ngi->_gameVersion >= 201509) {
- // CAniObject::SetStatic: a running movement is rewound to its previous statics, then the statics is exchanged and the anchor
- // (_x, _y) stays; there is no transition offset (the handler's putObjectToStatic has no callers in the original)
+ // CAniObject::SetStatic (F22BC): a running movement is rewound to its previous statics, then, when the statics changes, the anchor moves by the
+ // difference of the offsets of the two statics (the x, y of their phases, scaled), around the center of the object (rotated by its angle).
+ // The mirror argument (+64) of the original is not modelled: ScummVM objects have no mirror flag.
stopMovementToPrev(false);
- if (Statics *statics = getStatic(objId)) {
- _statics = statics;
+ Statics *statics = getStatic(objId);
+ if (statics) {
+ if (statics != _statics) {
+ const float oldX = _x;
+ const float oldY = _y;
+ const Dims oldSize = _statics ? _statics->getDimensions() : Dims();
+ const float centerX = oldX + oldSize.x * 0.5f * _scaleX;
+ const float centerY = oldY + oldSize.y * 0.5f * _scaleY;
+ const float oldOffsetX = _statics ? _statics->_x * _scaleX : 0.0f;
+ const float oldOffsetY = _statics ? _statics->_y * _scaleY : 0.0f;
+
+ _statics = statics;
+
+ const float newX = oldX + statics->_x * _scaleX - oldOffsetX;
+ const float newY = oldY + statics->_y * _scaleY - oldOffsetY;
+ const Dims newSize = statics->getDimensions();
+ const float halfWidth = newSize.x * 0.5f * _scaleX;
+ const float halfHeight = newSize.y * 0.5f * _scaleY;
+ const float dx = newX + halfWidth - centerX;
+ const float dy = newY + halfHeight - centerY;
+ const float c = cosf(_rotation);
+ const float sn = sinf(_rotation);
+ _x = (centerX + (dx * c - dy * sn)) - halfWidth;
+ _y = (centerY + (dx * sn + dy * c)) - halfHeight;
+ }
if (_movement) // not rewound (no running flag): drop it
_movement = nullptr;
}
@@ -1149,6 +1178,11 @@ void AniObject::setStatic(int objId) {
_statics = getStatic(objId);
}
+ if (g_ngi->_gameVersion >= 201509) {
+ _animExFlag = 0; // as CAniObject::SetStatic: the queue is not touched
+ return;
+ }
+
if (_messageQueueId) {
if (g_ngi->_globalMessageQueueList->getMessageQueueById(_messageQueueId))
g_ngi->_globalMessageQueueList->deleteQueueById(_messageQueueId);
Commit: e94a782cf91cab2f61b730aad3b0a66e0829265b
https://github.com/scummvm/scummvm/commit/e94a782cf91cab2f61b730aad3b0a66e0829265b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Add SoundManager with the scene sound pause of PushScene/PopScene and the scene of MessageQueue
Changed paths:
A engines/ngi/soundmanager.h
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/lift.cpp
engines/ngi/messages.cpp
engines/ngi/messages.h
engines/ngi/ngi.h
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/sound.cpp
engines/ngi/sound.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 91dc7192d71..bda09b7544a 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -82,9 +82,7 @@ static void execSetActiveInteraction(Command *cmd) {
findId(cmd->_args.getValOrDefault("obj")), floatArg(cmd, "act", 1.0f), floatArg(cmd, "add", 0.0f));
}
-// CMessageQueue::ExecuteUserCmd (10E68C): the scene is the one of the parameter "sc"; the parameter "sceneInStack" (default -1, clamped to the last scene of the
-// stack) replaces it with that scene of the stack; without any the scene of the queue (+20) is taken, then its controller runs the command. OPEN QUESTION:
-// MessageQueue does not know its scene (+20) yet, the current scene is used for that case.
+// CMessageQueue::ExecuteUserCmd (10E68C); Windows queues without a scene use the current one
void executeUserCommand(Command *cmd, MessageQueue *queue) {
if (cmd->_messageName == "SET_ACTIVE_INTERACTION") {
execSetActiveInteraction(cmd);
@@ -100,6 +98,8 @@ void executeUserCommand(Command *cmd, MessageQueue *queue) {
sceneInStack = (int)g_ngi->_sceneStack.size() - 1;
if (sceneInStack >= 0 && (int)g_ngi->_sceneStack.size() > sceneInStack)
scene = g_ngi->getSceneInStack(sceneInStack);
+ if (!scene && queue)
+ scene = queue->_scene;
if (!scene)
scene = g_ngi->getCurrentScene();
if (scene && scene->_controller)
diff --git a/engines/ngi/fullpipe/lift.cpp b/engines/ngi/fullpipe/lift.cpp
index 75dd0c3ab2e..f93b880ef29 100644
--- a/engines/ngi/fullpipe/lift.cpp
+++ b/engines/ngi/fullpipe/lift.cpp
@@ -903,7 +903,7 @@ void Lift::onClickButton() {
// CLift::CloseDoorAndGo (MSG_LIFT_CLOSEDOOR): the door closes, then MSG_LIFT_GO
void Lift::closeDoorAndGo() {
- MessageQueue *queue = new MessageQueue(g_ngi->_globalMessageQueueList->compact());
+ MessageQueue *queue = new MessageQueue(_scene, true, true); // CMessageQueue(scene, 1, 1)
if (!_lift->_movement) {
if (_lift->_statics->_staticsId == ST_LFT_CLOSED)
queue->addCommandToEnd(staticCommand(_lift, ST_LFT_CLOSED));
@@ -928,7 +928,7 @@ void Lift::closeDoorAndGo() {
// CLift::ExitLift (MSG_LIFT_EXITLIFT): the door opens, the hero comes out
void Lift::exitLift(MessageQueue *queue) {
_lift->setStatic(ST_LFT_CLOSED);
- MessageQueue *exitQueue = new MessageQueue(g_ngi->_globalMessageQueueList->compact());
+ MessageQueue *exitQueue = new MessageQueue(_scene, false, 1); // CMessageQueue(scene, 0, 1)
if (!queue)
exitQueue->addCommandToEnd(new Command(0, kCmdPause, 3320, 0, 0, 0, 1, 0, 0, 0));
exitQueue->addCommandToEnd(movementCommand(_lift, MV_LFT_OPEN));
@@ -954,7 +954,7 @@ void Lift::onGo() {
for (const PreloadItem &passage : g_ngi->_gameLoader->_preloadItems) {
if (passage.preloadId2 != button || passage.preloadId1 != _scene->_sceneId)
continue;
- MessageQueue *queue = new MessageQueue(g_ngi->_globalMessageQueueList->compact());
+ MessageQueue *queue = new MessageQueue(_scene, true, 1); // CMessageQueue(scene, 1, 1)
Command *ride = new Command(ANI_MAN, kCmdStartMovement, passage.param != LiftDown ? MV_MAN_LIFTDOWN : MV_MAN_LIFTUP, 0, 0, 0, 1, 0, 0, 0);
ride->_param = -1;
ride->_wait = 1;
diff --git a/engines/ngi/messages.cpp b/engines/ngi/messages.cpp
index 332b0dfef41..586a584e65a 100644
--- a/engines/ngi/messages.cpp
+++ b/engines/ngi/messages.cpp
@@ -318,8 +318,27 @@ MessageQueue::MessageQueue(int dataId) {
_flag1 = 0;
}
+MessageQueue::MessageQueue(Scene *scene, bool deleteAfter, int interruptState) {
+ _field_14 = nullptr;
+ _parId = 0;
+ _queueId = 0;
+ _id = g_ngi->_globalMessageQueueList->compact();
+ _isFinished = 0;
+ _flags = 0;
+ _counter = 0;
+ _field_38 = 0;
+ _flag1 = 0;
+ _scene = scene;
+ _deleteAfter = deleteAfter;
+ _interruptState = interruptState;
+}
+
MessageQueue::MessageQueue(MessageQueue *src, int parId, int field_38) {
_counter = 0;
+ // CMessageQueue::CMessageQueue(CMessageQueue *) (110108)
+ _scene = src->_scene;
+ _deleteAfter = src->_deleteAfter;
+ _interruptState = src->_interruptState;
_field_38 = (field_38 == 0);
for (Common::List<Command *>::iterator it = src->_commands.begin(); it != src->_commands.end(); ++it) {
diff --git a/engines/ngi/messages.h b/engines/ngi/messages.h
index a295be00598..a83d224320c 100644
--- a/engines/ngi/messages.h
+++ b/engines/ngi/messages.h
@@ -195,6 +195,12 @@ class MessageQueue : public CObject {
int _isFinished;
int _parId;
int _flag1;
+ /** CMessageQueue +20: the scene of the queue (null for Windows queues made without one) */
+ Scene *_scene = nullptr;
+ /** +60: CScene::DeleteObjAfter when the queue stops */
+ bool _deleteAfter = false;
+ /** +64: the interrupt state (CMessageQueue::CanInterrupt, SetIntState) */
+ int _interruptState = 0;
private:
Common::List<Command *> _commands;
@@ -205,6 +211,8 @@ class MessageQueue : public CObject {
public:
MessageQueue();
MessageQueue(int dataId);
+ /** CMessageQueue::CMessageQueue(scene, deleteAfter, interruptState) (10C900) */
+ MessageQueue(Scene *scene, bool deleteAfter, int interruptState);
MessageQueue(MessageQueue *src, int parId, int field_38);
~MessageQueue() override;
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index a1a4eae5bec..ac0d23ab9be 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -35,6 +35,7 @@
#include "engines/engine.h"
#include "ngi/console.h"
#include "ngi/fader.h"
+#include "ngi/soundmanager.h"
namespace Audio {
class SoundHandle;
@@ -347,6 +348,8 @@ public:
BaseModalObject *_modalObject;
/** CFader (CSingleton<CFader> in the original) */
Fader _fader;
+ /** CSoundManager: the sounds of all the scenes (they register themselves) */
+ SoundManager _soundManager;
int (*_updateScreenCallback)();
int (*_updateCursorCallback)();
@@ -392,8 +395,6 @@ public:
void renderSceneStack();
/** CGame::OnMouse*, OnKeyUp for the current scene of a stack with dialogs */
bool handleSceneStackEvent(const Common::Event &event);
- /** Pauses or resumes the sounds of the scenes (CSoundManager::PauseAll / ResumeInScene) */
- void pauseSceneSounds(bool pause);
/** A dialog is shown over the scene: a modal object, or (Android) a scene pushed on the stack */
bool isDialogShown() const { return _modalObject || _sceneStack.size() > 1; }
void setSceneMusicParameters(GameVar *var);
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 4e9fb91cd99..2a8b5f8fc3a 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -94,15 +94,6 @@ bool NGIEngine::isInventoryEnabled() {
return _inventoryScene && isInventoryRendered() && !_sceneStack.empty() && getCurrentScene()->isInventoryEnabled();
}
-// CSoundManager::PauseAll / ResumeInScene: ADAPTATION, the sounds of all the lists of the shown scenes
-void NGIEngine::pauseSceneSounds(bool pause) {
- for (int i = 0; i < _currSoundListCount; ++i) {
- SoundList &sounds = *_currSoundList1[i];
- for (int j = 0; j < sounds.getCount(); ++j)
- sounds.getSoundByIndex(j).pause(pause);
- }
-}
-
// CGame::PushScene: the scene goes on the stack, the sounds below pause
void NGIEngine::pushScene(int sceneId) {
Scene *scene = findScene(sceneId);
@@ -114,7 +105,11 @@ void NGIEngine::pushScene(int sceneId) {
_sceneStack.push_back(_currentScene);
_sceneStack.push_back(scene);
// CPreloadManager::PushScene and CScene::ResetCurrLoadingObj (the loading of the scenes) do not exist here
- pauseSceneSounds(true);
+ // CGame::PushScene (FE1D0): without putPrev all sounds pause, else those not music and not looped
+ if (!getCurrentScene()->_putPrev)
+ _soundManager.pauseAll();
+ else
+ _soundManager.pauseAllSounds(false);
// the dialogs use another keymap (the back button closes the dialog)
Common::Keymapper *mapper = _system->getEventManager()->getKeymapper();
mapper->setGameKeymapState("ngi-default", false);
@@ -122,7 +117,8 @@ void NGIEngine::pushScene(int sceneId) {
scene->onShow();
}
-// CGame::PopScene: the current scene is hidden and removed, its sounds stop, those of the scene below go on
+// CGame::PopScene (FCBAC): the current scene is hidden, the sounds that were started in it stop, it is removed; the sounds of the scene below resume unless it has
+// its sound paused (CScene::IsSoundPaused). CPreloadManager::PopScene, CGame::OnMouseMove with the cursor and CRender::SetSrcRect are not ported.
void NGIEngine::popScene() {
Scene *scene = getCurrentScene();
if (!scene || _sceneStack.size() < 2) {
@@ -130,10 +126,10 @@ void NGIEngine::popScene() {
return;
}
scene->onHide();
- if (scene->_soundList)
- scene->stopAllSounds();
+ _soundManager.stopInScene(scene->_sceneId);
_sceneStack.pop_back();
- pauseSceneSounds(false);
+ if (!getCurrentScene()->isSoundPaused())
+ _soundManager.resumeInScene(getCurrentScene()->_sceneId);
if (_sceneStack.size() < 2) {
Common::Keymapper *mapper = _system->getEventManager()->getKeymapper();
mapper->setGameKeymapState("ngi-default", true);
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 704dd8e69a0..6d5c52c9cc4 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -98,6 +98,10 @@ class Scene : public Background {
void setController(ISceneController *controller);
/** CScene +392 (GetCurrentEntranceId): the entrance the scene was shown through, 0 if none */
int _currentEntranceId = 0;
+ /** CScene +308 (IsSoundPaused): PopScene does not resume the sounds of a scene with this set */
+ bool _soundPaused = false;
+ bool isSoundPaused() const { return _soundPaused; }
+ void setSoundPause(bool paused) { _soundPaused = paused; }
/** CScene +37 (SCENE putPrev): the scene is drawn over the one below it instead of replacing it */
bool _putPrev = false;
/** CScene::OnShow / OnHide: the parts that the controllers, the behaviors and the GUI need */
diff --git a/engines/ngi/sound.cpp b/engines/ngi/sound.cpp
index 87a17337630..a7294b09659 100644
--- a/engines/ngi/sound.cpp
+++ b/engines/ngi/sound.cpp
@@ -20,6 +20,7 @@
*/
#include "ngi/ngi.h"
+#include "ngi/soundmanager.h"
#include "ngi/objects.h"
#include "ngi/scene.h"
@@ -86,6 +87,7 @@ Sound::Sound(int id, const Common::Path &path, int flags) : Sound() {
_id = id;
_flags = flags;
_memfilename = path;
+ g_ngi->_soundManager.addSound(this);
}
void SoundList::addSound(int id, const Common::Path &path, int flags) {
@@ -100,10 +102,83 @@ void SoundList::stopByCreator(int objectId) {
}
Sound::~Sound() {
+ if (g_ngi)
+ g_ngi->_soundManager.removeSound(this);
unload();
delete _handle;
}
+void SoundManager::addSound(Sound *sound) {
+ _sounds.push_back(sound);
+}
+
+void SoundManager::removeSound(Sound *sound) {
+ for (uint i = 0; i < _sounds.size(); i++) {
+ if (_sounds[i] == sound) {
+ _sounds.remove_at(i);
+ return;
+ }
+ }
+}
+
+// CSoundManager::PauseAll (124F4C)
+void SoundManager::pauseAll() {
+ for (Sound *sound : _sounds)
+ sound->pause(true);
+}
+
+// CSoundManager::PauseAllSounds (124F6E)
+void SoundManager::pauseAllSounds(bool includeLooped) {
+ for (Sound *sound : _sounds) {
+ if (!(sound->getFlags() & 2) && (includeLooped || !sound->isLooped()))
+ sound->pause(true);
+ }
+}
+
+// CSoundManager::ResumeAll (124FAA)
+void SoundManager::resumeAll() {
+ for (Sound *sound : _sounds)
+ sound->pause(false);
+}
+
+// CSoundManager::PauseInScene (124FCC)
+void SoundManager::pauseInScene(int sceneId) {
+ for (Sound *sound : _sounds) {
+ if (sound->getSceneId() == sceneId)
+ sound->pause(true);
+ }
+}
+
+// CSoundManager::ResumeInScene (124FF6)
+void SoundManager::resumeInScene(int sceneId) {
+ for (Sound *sound : _sounds) {
+ if (sound->getSceneId() == sceneId)
+ sound->pause(false);
+ }
+}
+
+// CSoundManager::StopInScene (125050)
+void SoundManager::stopInScene(int sceneId) {
+ for (Sound *sound : _sounds) {
+ if (sound->getSceneId() == sceneId)
+ sound->stop();
+ }
+}
+
+// CSoundManager::StopAll (124EC8)
+void SoundManager::stopAll() {
+ for (Sound *sound : _sounds)
+ sound->stop();
+}
+
+// CSoundManager::StopAllSoundsByFlag (124EEA)
+void SoundManager::stopAllSoundsByFlag(int flags) {
+ for (Sound *sound : _sounds) {
+ if (sound->getFlags() == flags)
+ sound->stop();
+ }
+}
+
bool Sound::load(MfcArchive &file, NGIArchive *archive) {
debugC(5, kDebugLoading, "Sound::load()");
@@ -246,6 +321,9 @@ void Sound::play(int loop, int creator) {
}
const Audio::Mixer::SoundType type = streamedSound && _flags == kMusic ? Audio::Mixer::kMusicSoundType : Audio::Mixer::kSFXSoundType;
g_ngi->_mixer->playStream(type, handle, audioStream);
+ // CSound::Play (125338): +64 the loop flag, +68 the current scene
+ _looped = loop != 0;
+ _sceneId = g_ngi->getCurrentScene() ? g_ngi->getCurrentScene()->_sceneId : 0;
debugC(3, kDebugEvents, "Playing sound %d (%s), loop %d", _id, _memfilename.toString().c_str(), loop);
}
diff --git a/engines/ngi/sound.h b/engines/ngi/sound.h
index 78a6ad75c99..716c850f2eb 100644
--- a/engines/ngi/sound.h
+++ b/engines/ngi/sound.h
@@ -59,6 +59,15 @@ public:
void setPanAndVolumeByStaticAni();
void attenuate(int vol, int pan);
+
+ /** CSound::isLooped (+64): the sound was started with a loop */
+ bool isLooped() const { return _looped; }
+ /** CSound +68: the scene that was current when the sound was started (CSound::Play) */
+ int getSceneId() const { return _sceneId; }
+
+private:
+ bool _looped = false;
+ int _sceneId = 0;
};
class SoundList : public CObject {
diff --git a/engines/ngi/soundmanager.h b/engines/ngi/soundmanager.h
new file mode 100644
index 00000000000..479bdaaf395
--- /dev/null
+++ b/engines/ngi/soundmanager.h
@@ -0,0 +1,55 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_SOUNDMANAGER_H
+#define NGI_SOUNDMANAGER_H
+
+#include "common/array.h"
+
+namespace NGI {
+
+class Sound;
+
+/** CSoundManager (CSingleton, NGIEngine::_soundManager): all scene sounds, self-registering */
+class SoundManager {
+public:
+ void addSound(Sound *sound);
+ void removeSound(Sound *sound);
+
+ /** CSoundManager::PauseAll */
+ void pauseAll();
+ /** CSoundManager::PauseAllSounds (124F6E): non-music (flag 2), looped only with includeLooped */
+ void pauseAllSounds(bool includeLooped);
+ void resumeAll();
+ void pauseInScene(int sceneId);
+ void resumeInScene(int sceneId);
+ void stopInScene(int sceneId);
+ void stopAll();
+ /** CSoundManager::StopAllSoundsByFlag: the sounds whose flags equal `flags` */
+ void stopAllSoundsByFlag(int flags);
+
+private:
+ Common::Array<Sound *> _sounds;
+};
+
+} // End of namespace NGI
+
+#endif // NGI_SOUNDMANAGER_H
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 7dd0067f199..e15189b15d3 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -1267,6 +1267,7 @@ private:
bool parserCallback_QUEUE(ParserNode *node) {
Common::ScopedPtr<MessageQueue> queue(new MessageQueue());
+ queue->_scene = &_scene;
if (!readId(node->values["id"], queue->_queueId))
return parserError("Unknown queue ID " + node->values["id"]);
queue->_title = node->values.getValOrDefault("title");
Commit: a2311bc4d19c316f219ae5392b79dfa1103603dd
https://github.com/scummvm/scummvm/commit/a2311bc4d19c316f219ae5392b79dfa1103603dd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Add the Android cursor model of CCursorController (position, object, hit objects) and use it for the camera and the lift
Changed paths:
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/lift.cpp
engines/ngi/fullpipe/liftcontroller.cpp
engines/ngi/input.cpp
engines/ngi/input.h
engines/ngi/ngi.cpp
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index bda09b7544a..dfc571efc00 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -23,6 +23,7 @@
#include "common/hashmap.h"
#include "ngi/ngi.h"
+#include "ngi/input.h"
#include "ngi/messages.h"
#include "ngi/motion.h"
#include "ngi/fullpipe/objectnames.h"
@@ -173,13 +174,13 @@ AniObject *FPController::hero() const {
return g_ngi->_aniMan;
}
-// CCursorController +72, +76: the position of the cursor in scene coordinates
+// CCursorController +72, +76: the position of the cursor (the hot spot) in scene coordinates
float FPController::cursorX() const {
- return g_ngi->_mouseScreenPos.x + _scene->_x;
+ return g_ngi->_inputController->_hotSceneX;
}
float FPController::cursorY() const {
- return g_ngi->_mouseScreenPos.y + _scene->_y;
+ return g_ngi->_inputController->_hotSceneY;
}
// CRender +24 as the scroll functions read it: only a scene wider than the game area scrolls
diff --git a/engines/ngi/fullpipe/lift.cpp b/engines/ngi/fullpipe/lift.cpp
index f93b880ef29..50ee86a62ff 100644
--- a/engines/ngi/fullpipe/lift.cpp
+++ b/engines/ngi/fullpipe/lift.cpp
@@ -20,6 +20,7 @@
*/
#include "ngi/ngi.h"
+#include "ngi/input.h"
#include "ngi/objects.h"
#include "ngi/fullpipe/objectnames.h"
@@ -795,21 +796,21 @@ void Lift::onResetDest(MessageQueue *queue) {
}
}
-// CLift::GetCursorType: over the areas GD_SCn_LIFT (23116 ... 23125)
+// CLift::GetCursorType (153EA0): over the areas GD_SCn_LIFT (23116 ... 23125)
bool Lift::getCursorType(float x, float y) {
- GameObject *hit = g_ngi->_currentScene->findGameObjectAtPos(x, y);
+ GameObject *hit = g_ngi->_inputController->getInteractHitObject();
return hit && hit->_id >= 23116 && hit->_id <= 23125;
}
-// CLift::OnButtonDown: over a lift button of the scene
+// CLift::OnButtonDown (153EC4): over a lift button of the scene
bool Lift::onButtonDown(float x, float y) {
- GameObject *hit = g_ngi->_currentScene->findGameObjectAtPos(x, y);
+ GameObject *hit = g_ngi->_inputController->getInteractHitObject();
return hit && hit->_id == ANI_LIFTBUTTON;
}
-// CLift::OnButtonUp(x, y): the door of the lift (982) and the areas GD_SCn_LIFT
+// CLift::OnButtonUp(x, y) (155954): the door of the lift (982) and the areas GD_SCn_LIFT
bool Lift::onButtonUp(float x, float y) {
- GameObject *hit = g_ngi->_currentScene->findGameObjectAtPos(x, y);
+ GameObject *hit = g_ngi->_inputController->getInteractHitObject();
if (!hit || (hit->_id != ANI_LIFT && (hit->_id < 23116 || hit->_id > 23125)))
return false;
return onButtonUp(hit);
diff --git a/engines/ngi/fullpipe/liftcontroller.cpp b/engines/ngi/fullpipe/liftcontroller.cpp
index 9b45d5d3134..3d19ff1b07d 100644
--- a/engines/ngi/fullpipe/liftcontroller.cpp
+++ b/engines/ngi/fullpipe/liftcontroller.cpp
@@ -22,6 +22,7 @@
#include "common/debug.h"
#include "ngi/ngi.h"
+#include "ngi/input.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/liftcontroller.h"
@@ -139,8 +140,9 @@ void LiftController::onUpdate(uint32 elapsed) {
// CLiftController::OnMouseLKeyUp: an enabled big button is lit, a tap anywhere else closes the view
bool LiftController::onMouseLKeyUp(uint32 id, float x, float y) {
- AniObject *hit = _scene->findAniObjectAtPos(x, y);
- if (hit && hit->_id == kAniLiftButtonBig && hit->_statics && isStaticsNormal(hit->_statics->_staticsId, true)) {
+ GameObject *object = g_ngi->_inputController->getInteractHitObject();
+ AniObject *hit = object && object->_id == kAniLiftButtonBig ? static_cast<AniObject *>(object) : nullptr;
+ if (hit && hit->_statics && isStaticsNormal(hit->_statics->_staticsId, true)) {
_selected = hit;
g_ngi->playSound(SND_CMN_032, 0); // CSoundManager::Play(0xDBD)
_selected->setStatic(getStaticsHilite(_selected->_statics->_staticsId, true));
@@ -153,8 +155,9 @@ bool LiftController::onMouseLKeyUp(uint32 id, float x, float y) {
// CLiftController::GetCursorType: the hand over an enabled big button. Cursors of pushed scenes
// are not driven by controllers yet (D11); the cursor 4 list check is not ported
int LiftController::getCursorType(float x, float y) {
- AniObject *hit = _scene->findAniObjectAtPos(x, y);
- return hit && hit->_id == kAniLiftButtonBig && hit->_statics && isStaticsNormal(hit->_statics->_staticsId, true);
+ GameObject *object = g_ngi->_inputController->getInteractHitObject();
+ AniObject *hit = object && object->_id == kAniLiftButtonBig ? static_cast<AniObject *>(object) : nullptr;
+ return hit && hit->_statics && isStaticsNormal(hit->_statics->_staticsId, true);
}
} // End of namespace NGI
diff --git a/engines/ngi/input.cpp b/engines/ngi/input.cpp
index cd9cbb134db..c3868d362bb 100644
--- a/engines/ngi/input.cpp
+++ b/engines/ngi/input.cpp
@@ -345,4 +345,183 @@ int NGIEngine::drawArcadeOverlay(int adjust) {
return 1;
}
+// CCursorController::OnMouseMove (F57C0)
+void CursorController::onMouseMove(float x, float y) {
+ _screenX = x * _scaleX + _offsetX;
+ _screenY = y * _scaleY + _offsetY;
+ recalcCursorPos();
+}
+
+// hot spot of the cursor object: half its size plus the offset, halved again (F5718, F5B1C)
+static Common::Point hotSpot(const GameObject *object, float offsetX, float offsetY) {
+ const Common::Point size = object->getSize();
+ return Common::Point((size.x * 0.5f + offsetX) * 0.5f, (size.y * 0.5f + offsetY) * 0.5f);
+}
+
+// CCursorController::RecalcCursorPos (F5718)
+void CursorController::recalcCursorPos() {
+ Scene *scene = g_ngi->getCurrentScene();
+ _sceneX = _screenX + scene->_x;
+ _sceneY = _screenY + scene->_y;
+ _hotScreenX = _screenX;
+ _hotScreenY = _screenY;
+ _hotSceneX = _sceneX;
+ _hotSceneY = _sceneY;
+ if (_object) {
+ const Common::Point hot = hotSpot(_object, _objectOffsetX, _objectOffsetY);
+ _hotScreenX += hot.x;
+ _hotScreenY += hot.y;
+ _hotSceneX += hot.x;
+ _hotSceneY += hot.y;
+ }
+}
+
+// CCursorController::SetCursorPos (F5CA4)
+void CursorController::setCursorPos(float x, float y) {
+ _screenX = x;
+ _screenY = y;
+ _sceneX = x;
+ _sceneY = y;
+ if (Scene *scene = g_ngi->getCurrentScene()) {
+ _sceneX += scene->_x;
+ _sceneY += scene->_y;
+ }
+ _hotScreenX = _screenX;
+ _hotScreenY = _screenY;
+ _hotSceneX = _sceneX;
+ _hotSceneY = _sceneY;
+ if (_object) {
+ const Common::Point hot = hotSpot(_object, _objectOffsetX, _objectOffsetY);
+ _hotScreenX += hot.x;
+ _hotScreenY += hot.y;
+ _hotSceneX += hot.x;
+ _hotSceneY += hot.y;
+ }
+ // PP_SetCursorPos(...) moves the pointer of the system: not ported
+ repopulateHitObjects(nullptr);
+}
+
+// CCursorController::SetObject (F57F4)
+void CursorController::setObject(GameObject *object, float offsetX, float offsetY) {
+ _object = object;
+ _objectOffsetX = offsetX;
+ _objectOffsetY = offsetY;
+ recalcCursorPos();
+}
+
+int CursorController::getObjectId() const {
+ return _object ? _object->_id : 0;
+}
+
+Common::Point CursorController::getObjectPos(const GameObject &object) const {
+ return Common::Point(_screenX + _objectOffsetX, _screenY + _objectOffsetY);
+}
+
+void CursorController::adjustCursor(float offsetX, float offsetY, float scaleX, float scaleY) {
+ _offsetX = offsetX;
+ _offsetY = offsetY;
+ _scaleX = scaleX;
+ _scaleY = scaleY;
+}
+
+// CCursorController::RepopulateHitObjects (F5B1C): with a scene the hot spot is recomputed for it
+void CursorController::repopulateHitObjects(Scene *scene) {
+ _hitObjects.clear();
+ const float savedX = _hotSceneX;
+ const float savedY = _hotSceneY;
+ if (scene) {
+ _hotSceneX = _screenX + scene->_x;
+ _hotSceneY = _screenY + scene->_y;
+ if (_object) {
+ const Common::Point hot = hotSpot(_object, _objectOffsetX, _objectOffsetY);
+ _hotSceneX += hot.x;
+ _hotSceneY += hot.y;
+ }
+ } else {
+ scene = g_ngi->getCurrentScene();
+ }
+
+ if (scene) {
+ // shown and hit objects of the scene (CVisibleObject::Hit(x, y, 256), flag 2 of the XML objects)
+ Common::Array<GameObject *> hit;
+ for (PictureObject *picture : scene->_pictureObjects) {
+ if ((picture->_flags & 4) && (picture->_objectFlags & 2) && picture->hit(_hotSceneX, _hotSceneY))
+ hit.push_back(picture);
+ }
+ for (PictureObject *picture : scene->_roamingPictures) {
+ if ((picture->_flags & 4) && (picture->_objectFlags & 2) && picture->hit(_hotSceneX, _hotSceneY))
+ hit.push_back(picture);
+ }
+ for (AniObject *ani : scene->_renderableAnis) {
+ if ((ani->_flags & 4) && (ani->_objectFlags & 2) && ani->hit(_hotSceneX, _hotSceneY))
+ hit.push_back(ani);
+ }
+ // std::multiset with zCompare: ascending z, equal ones in insertion order
+ for (GameObject *object : hit) {
+ uint position = _hitObjects.size();
+ while (position > 0 && _hitObjects[position - 1]->_z > object->_z)
+ position--;
+ _hitObjects.insert_at(position, object);
+ }
+ }
+ _hotSceneX = savedX;
+ _hotSceneY = savedY;
+}
+
+const Common::Array<GameObject *> &CursorController::getHitObjects(Scene *scene) {
+ repopulateHitObjects(scene);
+ return _hitObjects;
+}
+
+GameObject *CursorController::getHitObject() {
+ repopulateHitObjects(nullptr);
+ return _hitObjects.empty() ? nullptr : _hitObjects.front();
+}
+
+GameObject *CursorController::getInteractHitObject() {
+ repopulateHitObjects(nullptr);
+ for (GameObject *object : _hitObjects) {
+ if (!(object->_objectFlags & 8))
+ return object;
+ }
+ return nullptr;
+}
+
+int CursorController::getHitObjectId() {
+ GameObject *object = getHitObject();
+ return object ? object->_id : 0;
+}
+
+int CursorController::getInteractHitObjectId() {
+ GameObject *object = getInteractHitObject();
+ return object ? object->_id : 0;
+}
+
+bool CursorController::isObjectHit(const GameObject *object) {
+ repopulateHitObjects(nullptr);
+ for (const GameObject *hit : _hitObjects) {
+ if (hit == object)
+ return true;
+ }
+ return false;
+}
+
+bool CursorController::isObjectHit(int objectId) {
+ repopulateHitObjects(nullptr);
+ for (const GameObject *hit : _hitObjects) {
+ if (hit->_id == objectId)
+ return true;
+ }
+ return false;
+}
+
+bool CursorController::isObjectCopyHit(int copyId) {
+ repopulateHitObjects(nullptr);
+ for (const GameObject *hit : _hitObjects) {
+ if (hit->_copyId == copyId)
+ return true;
+ }
+ return false;
+}
+
} // End of namespace NGI
diff --git a/engines/ngi/input.h b/engines/ngi/input.h
index 6ba56d24213..14d52d927fe 100644
--- a/engines/ngi/input.h
+++ b/engines/ngi/input.h
@@ -25,6 +25,8 @@
namespace NGI {
class Texture;
+class GameObject;
+class Scene;
void setInputDisabled(bool state);
@@ -56,6 +58,25 @@ class CursorController {
Common::Rect _cursorBounds;
Texture *_cursorItemPicture;
+public:
+ // Android CCursorController: the cursor in several spaces and the held object (offsets below)
+ float _sceneX = 0; // +48: the cursor in scene coordinates
+ float _sceneY = 0; // +52
+ float _screenX = 0; // +56: in screen coordinates (the 800 x 600 game area)
+ float _screenY = 0; // +60
+ float _hotScreenX = 0; // +64: the hot spot on screen (center of the held object)
+ float _hotScreenY = 0; // +68
+ float _hotSceneX = 0; // +72: the scene position of the hot spot: where the hit tests are made
+ float _hotSceneY = 0; // +76
+ GameObject *_object = nullptr; // +88: the object that the cursor holds (an inventory item)
+ float _objectOffsetX = 0; // +92
+ float _objectOffsetY = 0; // +96
+ float _scaleX = 1.0f; // +120: CRender scale and offset of the screen (AdjustCursor)
+ float _scaleY = 1.0f; // +124
+ float _offsetX = 0; // +128
+ float _offsetY = 0; // +132
+ Common::Array<GameObject *> _hitObjects; // +12: objects under the cursor, lowest z first
+
public:
CursorController();
~CursorController();
@@ -68,6 +89,36 @@ class CursorController {
void setCursor(int id);
void setObject(Texture *pic) { _cursorItemPicture = pic; }
+
+ // Android methods of CCursorController
+ /** CCursorController::OnMouseMove (F57C0) */
+ void onMouseMove(float x, float y);
+ /** CCursorController::RecalcCursorPos (F5718) */
+ void recalcCursorPos();
+ /** CCursorController::SetCursorPos (F5CA4): the OS pointer is not moved */
+ void setCursorPos(float x, float y);
+ void addCursorPos(float x, float y) { setCursorPos(_screenX + x, _screenY + y); }
+ /** CCursorController::SetObject (F57F4) */
+ void setObject(GameObject *object, float offsetX, float offsetY);
+ GameObject *getObject() const { return _object; }
+ /** CCursorController::GetObjectId (F55CA): the id of the object in the cursor, 0 without one */
+ int getObjectId() const;
+ /** CCursorController::GetObjectPos (F55AA): the position of the object relative to the cursor */
+ Common::Point getObjectPos(const GameObject &object) const;
+ /** CCursorController::AdjustCursor (F56FA) */
+ void adjustCursor(float offsetX, float offsetY, float scaleX, float scaleY);
+ /** CCursorController::RepopulateHitObjects (F5B1C): objects hit at the hot spot, lowest z first */
+ void repopulateHitObjects(Scene *scene);
+ const Common::Array<GameObject *> &getHitObjects(Scene *scene = nullptr);
+ GameObject *getHitObject();
+ /** CCursorController::GetInteractHitObject (F5DFA): the first hit object without flag 8 */
+ GameObject *getInteractHitObject();
+ int getHitObjectId();
+ int getInteractHitObjectId();
+ bool isObjectHit(const GameObject *object);
+ bool isObjectHit(int objectId);
+ /** CCursorController::IsObjectCopyHit (F5ED6): by the copy number */
+ bool isObjectCopyHit(int copyId);
};
} // End of namespace NGI
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 43934f33359..f214e1facd3 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -308,8 +308,12 @@ bool NGIEngine::handleGuiEvent(const Common::Event &event) {
if (event.type == Common::EVENT_LBUTTONDOWN)
_touchDown = true;
if (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_LBUTTONUP || event.type == Common::EVENT_RBUTTONDOWN ||
- event.type == Common::EVENT_RBUTTONUP || (event.type == Common::EVENT_MOUSEMOVE && _touchDown))
+ event.type == Common::EVENT_RBUTTONUP || (event.type == Common::EVENT_MOUSEMOVE && _touchDown)) {
_mouseScreenPos = event.mouse;
+ // CRender::EventProc: a pointer move goes to CCursorController::OnMouseMove
+ if (_inputController)
+ _inputController->onMouseMove(event.mouse.x, event.mouse.y);
+ }
if (event.type == Common::EVENT_LBUTTONUP)
_touchDown = false;
if (event.type == Common::EVENT_SCREEN_CHANGED) {
Commit: 065630710b3ac54129fe8de31ced6df2d987eaad
https://github.com/scummvm/scummvm/commit/065630710b3ac54129fe8de31ced6df2d987eaad
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Renames in class Inventory
Inventory -> Inventory2
InventoryItem -> InventoryEntry
Changed paths:
engines/ngi/fullpipe/scene01.cpp
engines/ngi/fullpipe/scene03.cpp
engines/ngi/fullpipe/scene04.cpp
engines/ngi/fullpipe/scene05.cpp
engines/ngi/fullpipe/testmode.cpp
engines/ngi/gameloader.cpp
engines/ngi/gameloader.h
engines/ngi/inventory.cpp
engines/ngi/inventory.h
engines/ngi/ngi.cpp
engines/ngi/ngi.h
diff --git a/engines/ngi/fullpipe/scene01.cpp b/engines/ngi/fullpipe/scene01.cpp
index 058d9fa61b4..750aabe198a 100644
--- a/engines/ngi/fullpipe/scene01.cpp
+++ b/engines/ngi/fullpipe/scene01.cpp
@@ -126,7 +126,7 @@ int sceneHandler01(Command *cmd) {
return 0;
}
if (cmd->_messageName == "MSG_DEACT_OBJ_SC1") {
- Inventory *inventory = getGameLoaderInventory();
+ Inventory2 *inventory = getGameLoaderInventory();
uint32 blackEgg, coinEgg;
const ObjectIdList &ids = g_ngi->_gameProject->_objectIds;
if (ids.findId("ANI_INV_EGGBLACK", blackEgg) && ids.findId("ANI_INV_EGGCOIN", coinEgg) &&
diff --git a/engines/ngi/fullpipe/scene03.cpp b/engines/ngi/fullpipe/scene03.cpp
index 0d96df15cd3..a548e9c99a2 100644
--- a/engines/ngi/fullpipe/scene03.cpp
+++ b/engines/ngi/fullpipe/scene03.cpp
@@ -105,7 +105,7 @@ void scene03_initScene(Scene *sc) {
debugC(1, kDebugSceneLogic, "scene03_initScene()");
#if 0
- Inventory *inv = getGameLoaderInventory();
+ Inventory2 *inv = getGameLoaderInventory();
inv->addItem(ANI_INV_EGGAPL, 1);
inv->addItem(ANI_INV_EGGDOM, 1);
inv->addItem(ANI_INV_EGGCOIN, 1);
diff --git a/engines/ngi/fullpipe/scene04.cpp b/engines/ngi/fullpipe/scene04.cpp
index 4e83c60fccd..73641112a30 100644
--- a/engines/ngi/fullpipe/scene04.cpp
+++ b/engines/ngi/fullpipe/scene04.cpp
@@ -133,7 +133,7 @@ void scene04_initScene(Scene *sc) {
debugC(1, kDebugSceneLogic, "scene04_initScene()");
#if 0
- Inventory *inv = getGameLoaderInventory();
+ Inventory2 *inv = getGameLoaderInventory();
inv->addItem(ANI_INV_COIN, 1);
inv->recalcItemPos();
#endif
diff --git a/engines/ngi/fullpipe/scene05.cpp b/engines/ngi/fullpipe/scene05.cpp
index 892185d2cce..51f4523587b 100644
--- a/engines/ngi/fullpipe/scene05.cpp
+++ b/engines/ngi/fullpipe/scene05.cpp
@@ -39,7 +39,7 @@ void scene05_initScene(Scene *sc) {
debugC(1, kDebugSceneLogic, "scene05_initScene()");
#if 0
- Inventory *inv = getGameLoaderInventory();
+ Inventory2 *inv = getGameLoaderInventory();
inv->addItem(ANI_INV_BOX, 1);
inv->recalcItemPos();
#endif
diff --git a/engines/ngi/fullpipe/testmode.cpp b/engines/ngi/fullpipe/testmode.cpp
index 7690cc5a737..5258d708272 100644
--- a/engines/ngi/fullpipe/testmode.cpp
+++ b/engines/ngi/fullpipe/testmode.cpp
@@ -201,7 +201,7 @@ void testmode_update(uint32 elapsed) {
if (spot->sceneId == SC_4)
g_ngi->setState(SC4_DEMO_SCROLL_STATE, g_ngi->getStateValue(SC4_DEMO_SCROLL_STATE, SC4_DEMO_SCROLL_DONE));
if (spot->item) {
- Inventory *inventory = getGameLoaderInventory();
+ Inventory2 *inventory = getGameLoaderInventory();
inventory->addItem(spot->item, 1);
inventory->recalcItemPos();
}
diff --git a/engines/ngi/gameloader.cpp b/engines/ngi/gameloader.cpp
index 889761bd848..cc196025449 100644
--- a/engines/ngi/gameloader.cpp
+++ b/engines/ngi/gameloader.cpp
@@ -33,7 +33,7 @@
namespace NGI {
-Inventory *getGameLoaderInventory() {
+Inventory2 *getGameLoaderInventory() {
return &g_ngi->_gameLoader->_inventory;
}
diff --git a/engines/ngi/gameloader.h b/engines/ngi/gameloader.h
index 43f741fc305..7a31a162547 100644
--- a/engines/ngi/gameloader.h
+++ b/engines/ngi/gameloader.h
@@ -115,7 +115,7 @@ class GameLoader : public CObject {
Common::ScopedPtr<GameProject> _gameProject;
InteractionController *_interactionController;
CursorController *_inputController;
- Inventory _inventory;
+ Inventory2 _inventory;
Sc2Array _sc2array;
void *_sceneSwitcher;
bool (*_preloadCallback)(PreloadItem &pre, int flag);
@@ -132,7 +132,7 @@ class GameLoader : public CObject {
};
-Inventory *getGameLoaderInventory();
+Inventory2 *getGameLoaderInventory();
InteractionController *getGameLoaderInteractionController();
MctlCompound *getSc2MctlCompoundBySceneId(int16 sceneId);
MovGraph *getSc2MovGraphBySceneId(int16 sceneId);
diff --git a/engines/ngi/inventory.cpp b/engines/ngi/inventory.cpp
index 78ec7dab0cd..34e170fba8e 100644
--- a/engines/ngi/inventory.cpp
+++ b/engines/ngi/inventory.cpp
@@ -60,7 +60,7 @@ int InventoryData::getInventoryPoolItemIndexById(int itemId) {
return -1;
}
-int Inventory::getCursorPictureId() {
+int Inventory2::getCursorPictureId() {
int index = getInventoryPoolItemIndexById(getSelectedItemId());
return index >= 0 ? _itemsPool[index].pictureObjectNormal : 0;
}
@@ -76,7 +76,7 @@ bool InventoryData::setItemFlags(int itemId, int flags) {
return true;
}
-Inventory::Inventory() {
+Inventory2::Inventory2() {
_selectedId = -1;
_field_48 = -1;
_scene = nullptr;
@@ -86,11 +86,11 @@ Inventory::Inventory() {
_topOffset = -65;
}
-Inventory::~Inventory() {
+Inventory2::~Inventory2() {
removeMessageHandler(125, -1);
}
-bool Inventory::loadPartial(MfcArchive &file) { // Inventory2_SerializePartially
+bool Inventory2::loadPartial(MfcArchive &file) { // Inventory2_SerializePartially
_inventoryItems.clear();
int numInvs = file.readUint32LE();
@@ -98,13 +98,13 @@ bool Inventory::loadPartial(MfcArchive &file) { // Inventory2_SerializePartially
for (int i = 0; i < numInvs; i++) {
int16 itemId = file.readUint16LE();
int16 count = file.readUint16LE();
- _inventoryItems.push_back(InventoryItem(itemId, count));
+ _inventoryItems.push_back(InventoryEntry(itemId, count));
}
return true;
}
-bool Inventory::savePartial(MfcArchive &file) {
+bool Inventory2::savePartial(MfcArchive &file) {
file.writeUint32LE(_inventoryItems.size());
for (uint i = 0; i < _inventoryItems.size(); i++) {
@@ -115,25 +115,25 @@ bool Inventory::savePartial(MfcArchive &file) {
return true;
}
-void Inventory::addItem(int itemId, int count) {
+void Inventory2::addItem(int itemId, int count) {
if (getInventoryPoolItemIndexById(itemId) >= 0)
- _inventoryItems.push_back(InventoryItem(itemId, count));
+ _inventoryItems.push_back(InventoryEntry(itemId, count));
}
-void Inventory::addItem2(AniObject *obj) {
+void Inventory2::addItem2(AniObject *obj) {
if (getInventoryPoolItemIndexById(obj->_id) >= 0 && getInventoryPoolItemFieldCById(obj->_id) != 2) {
addItem(obj->_id, 1);
obj->hide();
}
}
-void Inventory::removeItem(int itemId, int count) {
- debugC(2, kDebugInventory, "Inventory::removeItem(%d, %d)", itemId, count);
+void Inventory2::removeItem(int itemId, int count) {
+ debugC(2, kDebugInventory, "Inventory2::removeItem(%d, %d)", itemId, count);
while (count > 0) {
int i;
for (i = _inventoryItems.size() - 1; i >= 0; i--) {
- InventoryItem &item = _inventoryItems[i];
+ InventoryEntry &item = _inventoryItems[i];
if (item.itemId == itemId) {
if (_selectedId == itemId)
unselectItem(false);
@@ -157,7 +157,7 @@ void Inventory::removeItem(int itemId, int count) {
}
}
-void Inventory::removeItem2(Scene *sceneObj, int itemId, int x, int y, int priority) {
+void Inventory2::removeItem2(Scene *sceneObj, int itemId, int x, int y, int priority) {
int idx = getInventoryItemIndexById(itemId);
debugC(2, kDebugInventory, "removeItem2(*, %d, %d, %d, %d)", itemId, x, y, priority);
@@ -181,7 +181,7 @@ void Inventory::removeItem2(Scene *sceneObj, int itemId, int x, int y, int prior
}
}
-int Inventory::getCountItemsWithId(int itemId) {
+int Inventory2::getCountItemsWithId(int itemId) {
int res = 0;
for (uint i = 0; i < _inventoryItems.size(); i++) {
@@ -192,7 +192,7 @@ int Inventory::getCountItemsWithId(int itemId) {
return res;
}
-int Inventory::getInventoryItemIndexById(int itemId) {
+int Inventory2::getInventoryItemIndexById(int itemId) {
for (uint i = 0; i < _inventoryItems.size(); i++) {
if (_inventoryItems[i].itemId == itemId)
return i;
@@ -201,11 +201,11 @@ int Inventory::getInventoryItemIndexById(int itemId) {
return -1;
}
-int Inventory::getInventoryPoolItemIdAtIndex(int itemId) {
+int Inventory2::getInventoryPoolItemIdAtIndex(int itemId) {
return _itemsPool[itemId].id;
}
-int Inventory::getInventoryPoolItemFieldCById(int itemId) {
+int Inventory2::getInventoryPoolItemFieldCById(int itemId) {
for (uint i = 0; i < _itemsPool.size(); i++) {
if (_itemsPool[i].id == itemId)
return _itemsPool[i].field_C;
@@ -214,7 +214,7 @@ int Inventory::getInventoryPoolItemFieldCById(int itemId) {
return 0;
}
-int Inventory::getItemFlags(int itemId) {
+int Inventory2::getItemFlags(int itemId) {
int idx = getInventoryPoolItemIndexById(itemId);
if (idx < 0)
@@ -223,13 +223,13 @@ int Inventory::getItemFlags(int itemId) {
return _itemsPool[idx].flags;
}
-void Inventory::setItemArea(int16 sceneId, const Common::Rect &area, int interval) {
+void Inventory2::setItemArea(int16 sceneId, const Common::Rect &area, int interval) {
_sceneId = sceneId;
_itemArea = area;
_itemInterval = interval;
}
-void Inventory::recalcItemPos() {
+void Inventory2::recalcItemPos() {
debugC(2, kDebugInventory, "recalcItemPos()");
_scene = g_ngi->findScene(_sceneId);
@@ -240,7 +240,7 @@ void Inventory::recalcItemPos() {
_inventoryIcons.clear();
if (g_ngi->usesXMLProject()) {
- for (const InventoryItem &item : _inventoryItems) {
+ for (const InventoryEntry &item : _inventoryItems) {
const int idx = getInventoryPoolItemIndexById(item.itemId);
if (idx < 0)
continue;
@@ -316,7 +316,7 @@ void Inventory::recalcItemPos() {
}
}
-void Inventory::render() {
+void Inventory2::render() {
if (!_scene)
return;
@@ -398,7 +398,7 @@ reset:
}
-void Inventory::slideIn() {
+void Inventory2::slideIn() {
_isInventoryOut = false;
Command *ex = new Command(0, kCmdMessage, kMsgInventory, 0, 0, 0, 1, 0, 0, 0);
@@ -410,7 +410,7 @@ void Inventory::slideIn() {
ex->postMessage();
}
-void Inventory::slideOut() {
+void Inventory2::slideOut() {
_isInventoryOut = true;
Command *ex = new Command(0, kCmdMessage, kMsgInventory, 0, 0, 0, 1, 0, 0, 0);
@@ -423,15 +423,15 @@ void Inventory::slideOut() {
}
// CInventoryController::ScrollOut and ScrollIn: its state machine moves the bar (1.5 pixels per millisecond, up to 100) and the items
-void Inventory::scrollOut() {
+void Inventory2::scrollOut() {
warning("STUB/untested: CInventoryController::ScrollOut: the inventory bar does not leave the screen");
}
-void Inventory::scrollIn() {
+void Inventory2::scrollIn() {
warning("STUB/untested: CInventoryController::ScrollIn: the inventory bar does not come back");
}
-bool Inventory::onMouseLKeyDown(Command *cmd) {
+bool Inventory2::onMouseLKeyDown(Command *cmd) {
if (!_isInventoryOut)
return false;
@@ -466,7 +466,7 @@ bool Inventory::onMouseLKeyDown(Command *cmd) {
return res;
}
-int Inventory::putOnCursor(int itemId) {
+int Inventory2::putOnCursor(int itemId) {
if (getInventoryItemIndexById(itemId) < 0)
return -1;
@@ -484,7 +484,7 @@ int Inventory::putOnCursor(int itemId) {
return _selectedId;
}
-bool Inventory::unselectItem(bool flag) {
+bool Inventory2::unselectItem(bool flag) {
if (_selectedId < 0)
return false;
@@ -500,7 +500,7 @@ bool Inventory::unselectItem(bool flag) {
return true;
}
-int Inventory::getItemAtPos(Common::Point *point) {
+int Inventory2::getItemAtPos(Common::Point *point) {
if (g_ngi->usesXMLProject()) {
for (const InventoryIcon &icon : _inventoryIcons)
if (Common::Rect(icon.x1, icon.y1, icon.x2, icon.y2).contains(*point))
@@ -542,7 +542,7 @@ int Inventory::getItemAtPos(Common::Point *point) {
return res;
}
-void Inventory::removeAllItems() {
+void Inventory2::removeAllItems() {
unselectItem(0);
for (uint i = 0; i < _inventoryItems.size(); i++)
@@ -552,7 +552,7 @@ void Inventory::removeAllItems() {
}
void NGIEngine::getAllInventory() {
- Inventory *inv = getGameLoaderInventory();
+ Inventory2 *inv = getGameLoaderInventory();
for (uint i = 0; i < inv->getItemsPoolCount(); ++i ) {
int id = inv->getInventoryPoolItemIdAtIndex(i);
diff --git a/engines/ngi/inventory.h b/engines/ngi/inventory.h
index 5f26e996cf5..d43e9b5e037 100644
--- a/engines/ngi/inventory.h
+++ b/engines/ngi/inventory.h
@@ -56,12 +56,12 @@ class InventoryData : public CObject {
bool setItemFlags(int itemId, int flags);
};
-struct InventoryItem {
+struct InventoryEntry {
int16 itemId;
int16 count;
- InventoryItem() { itemId = count = 0; }
- InventoryItem(int id, int cnt) : itemId(id), count(cnt) {}
+ InventoryEntry() { itemId = count = 0; }
+ InventoryEntry(int id, int cnt) : itemId(id), count(cnt) {}
};
class PictureObject;
@@ -79,8 +79,8 @@ struct InventoryIcon {
bool isMouseHover;
};
-class Inventory : public InventoryData {
- Common::Array<InventoryItem> _inventoryItems;
+class Inventory2 : public InventoryData {
+ Common::Array<InventoryEntry> _inventoryItems;
Common::Array<InventoryIcon> _inventoryIcons;
int _selectedId;
int _field_48;
@@ -93,8 +93,8 @@ class Inventory : public InventoryData {
int _itemInterval = 10;
public:
- Inventory();
- ~Inventory() override;
+ Inventory2();
+ ~Inventory2() override;
void addPoolItem(const InventoryPoolItem &item) { _itemsPool.push_back(item); }
bool loadPartial(MfcArchive &file);
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index f214e1facd3..37763ee2b13 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -343,7 +343,7 @@ bool NGIEngine::handleGuiEvent(const Common::Event &event) {
GuiManager *manager = _currentScene->_guiManager.get();
if (_inventoryScene && (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_LBUTTONUP)) {
Common::Point pos = event.mouse;
- Inventory *inventory = getGameLoaderInventory();
+ Inventory2 *inventory = getGameLoaderInventory();
const int item = inventory->getItemAtPos(&pos);
if (item) {
for (const MessageQueue *queue : *_globalMessageQueueList)
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index ac0d23ab9be..9a053c3b33e 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -84,7 +84,7 @@ class BaseModalObject;
class GameLoader;
class GameVar;
class CursorController;
-class Inventory;
+class Inventory2;
struct Cursor;
struct Entrance;
class Command;
@@ -338,7 +338,7 @@ public:
int32 _mapTable[200];
Scene *_inventoryScene;
- Inventory *_inventory;
+ Inventory2 *_inventory;
int _currSelectedInventoryItemId;
int32 _updateTicks;
Commit: ac401375e51bd88010fcb25555635eb1a2bda28a
https://github.com/scummvm/scummvm/commit/ac401375e51bd88010fcb25555635eb1a2bda28a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Renames in class NGIEngine
_inventory -> _inventory2
Changed paths:
engines/ngi/fullpipe/scene11.cpp
engines/ngi/fullpipe/scene17.cpp
engines/ngi/fullpipe/scene22.cpp
engines/ngi/messagehandlers.cpp
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/stateloader.cpp
diff --git a/engines/ngi/fullpipe/scene11.cpp b/engines/ngi/fullpipe/scene11.cpp
index 32b0005c6e5..1eaa42d6fcc 100644
--- a/engines/ngi/fullpipe/scene11.cpp
+++ b/engines/ngi/fullpipe/scene11.cpp
@@ -212,7 +212,7 @@ int scene11_updateCursor() {
if (g_vars->scene11_arcadeIsOn) {
if (g_ngi->_cursorId != PIC_CSR_DEFAULT_INV && g_ngi->_cursorId != PIC_CSR_ITN_INV)
g_ngi->_cursorId = -1;
- } else if (g_vars->scene11_swingie == g_ngi->_objectAtCursor && g_ngi->_inventory->getSelectedItemId() == ANI_INV_BOOT)
+ } else if (g_vars->scene11_swingie == g_ngi->_objectAtCursor && g_ngi->_inventory2->getSelectedItemId() == ANI_INV_BOOT)
g_ngi->_cursorId = PIC_CSR_ITN_INV;
return g_ngi->_cursorId;
diff --git a/engines/ngi/fullpipe/scene17.cpp b/engines/ngi/fullpipe/scene17.cpp
index 2dcf9588381..4e66715a962 100644
--- a/engines/ngi/fullpipe/scene17.cpp
+++ b/engines/ngi/fullpipe/scene17.cpp
@@ -78,7 +78,7 @@ int scene17_updateCursor() {
if (!g_vars->scene17_handPhase)
return g_ngi->_cursorId;
- int item = g_ngi->_inventory->getSelectedItemId();
+ int item = g_ngi->_inventory2->getSelectedItemId();
if ((g_ngi->_cursorId != PIC_CSR_DEFAULT_INV || item != ANI_INV_COIN) && item != ANI_INV_BOOT && item != ANI_INV_HAMMER)
; // empty
diff --git a/engines/ngi/fullpipe/scene22.cpp b/engines/ngi/fullpipe/scene22.cpp
index 7f2a9d3ab66..3d220536a74 100644
--- a/engines/ngi/fullpipe/scene22.cpp
+++ b/engines/ngi/fullpipe/scene22.cpp
@@ -74,7 +74,7 @@ int scene22_updateCursor() {
if (g_ngi->_objectIdAtCursor != ANI_HANDLE_L)
return g_ngi->_cursorId;
- int sel = g_ngi->_inventory->getSelectedItemId();
+ int sel = g_ngi->_inventory2->getSelectedItemId();
if (!sel) {
g_ngi->_cursorId = PIC_CSR_ITN;
diff --git a/engines/ngi/messagehandlers.cpp b/engines/ngi/messagehandlers.cpp
index 36867b32524..1f57f464e72 100644
--- a/engines/ngi/messagehandlers.cpp
+++ b/engines/ngi/messagehandlers.cpp
@@ -211,7 +211,7 @@ int global_messageHandler1(Command *cmd) {
int invItem;
- if (g_ngi->_updateFlag && (invItem = g_ngi->_inventory->getItemAtPos(&g_ngi->_mouseScreenPos))) {
+ if (g_ngi->_updateFlag && (invItem = g_ngi->_inventory2->getItemAtPos(&g_ngi->_mouseScreenPos))) {
g_ngi->_cursorId = PIC_CSR_ITN;
if (!g_ngi->_currSelectedInventoryItemId && !g_ngi->_aniMan->_movement &&
!(g_ngi->_aniMan->_flags & 0x100) && g_ngi->_aniMan->isIdle()) {
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 37763ee2b13..085834e5f2e 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -167,7 +167,7 @@ NGIEngine::NGIEngine(OSystem *syst, const NGIGameDescription *gameDesc) :
_sceneHeight = 1;
_inventoryScene = nullptr;
- _inventory = nullptr;
+ _inventory2 = nullptr;
_minCursorId = 0xffff;
_maxCursorId = 0;
@@ -804,7 +804,7 @@ Common::Error NGIEngine::updateScreen(uint32 elapsed, byte &brightness, bool red
if (_inventoryScene->_guiManager)
_inventoryScene->_guiManager->render(_backgroundSurface);
} else {
- _inventory->render();
+ _inventory2->render();
}
}
if (_updateScreenCallback)
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 9a053c3b33e..1c2ff92ba0b 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -338,7 +338,7 @@ public:
int32 _mapTable[200];
Scene *_inventoryScene;
- Inventory2 *_inventory;
+ Inventory2 *_inventory2;
int _currSelectedInventoryItemId;
int32 _updateTicks;
diff --git a/engines/ngi/stateloader.cpp b/engines/ngi/stateloader.cpp
index 197c63e80b7..bb3bbb9a9bb 100644
--- a/engines/ngi/stateloader.cpp
+++ b/engines/ngi/stateloader.cpp
@@ -235,19 +235,19 @@ bool NGIEngine::loadGam(const char *fname, int scene) {
addMessageHandlerByIndex(global_messageHandler1, 0, 4);
- _inventory = getGameLoaderInventory();
+ _inventory2 = getGameLoaderInventory();
if (isDemo() && getLanguage() == Common::RU_RUS) {
- _inventory->addItem(ANI_INV_HAMMER, 1);
+ _inventory2->addItem(ANI_INV_HAMMER, 1);
} else {
- _inventory->setItemFlags(ANI_INV_MAP, 0x10003);
- _inventory->addItem(ANI_INV_MAP, 1);
+ _inventory2->setItemFlags(ANI_INV_MAP, 0x10003);
+ _inventory2->addItem(ANI_INV_MAP, 1);
}
- _inventory->recalcItemPos();
+ _inventory2->recalcItemPos();
- for (uint i = 0; i < _inventory->getScene()->_pictureObjects.size(); i++)
- _inventory->getScene()->_pictureObjects[i]->_picture->MemoryObject::load();
+ for (uint i = 0; i < _inventory2->getScene()->_pictureObjects.size(); i++)
+ _inventory2->getScene()->_pictureObjects[i]->_picture->MemoryObject::load();
// _sceneSwitcher = doSetScene; // substituted with direct call
_gameLoader->_preloadCallback = preloadCallback;
Commit: ffd239458d65343c3bccae17f16cb30d4fb374d7
https://github.com/scummvm/scummvm/commit/ffd239458d65343c3bccae17f16cb30d4fb374d7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Port CXmlNode, CInventoryItem and CInventory (Android inventory scene, not wired yet)
Changed paths:
A engines/ngi/xmlnode.cpp
A engines/ngi/xmlnode.h
engines/ngi/gfx.cpp
engines/ngi/inventory.cpp
engines/ngi/inventory.h
engines/ngi/module.mk
engines/ngi/ngi.h
engines/ngi/scene.cpp
engines/ngi/scene.h
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index 98b5e4637b0..670b712976e 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -167,6 +167,11 @@ void PictureObject::render(Common::Point scroll) {
}
void PictureObject::renderAtPos(int x, int y) {
+ if (g_ngi->_gameVersion >= 201509) {
+ // CVisibleObject::RenderAtPos: texture at the position with the object's scale, window, rotation
+ _picture->blitTo(g_ngi->_backgroundSurface, Common::Point(x, y), getRenderParams());
+ return;
+ }
if (x == -1)
x = _x;
if (y == -1)
@@ -303,7 +308,8 @@ Common::Point GameObject::getSize() const {
Dims size;
if (!textureQuad(this, topLeft, size, anchor))
return Common::Point();
- return Common::Point(static_cast<int>(size.x * (_windowRight - _windowLeft)), static_cast<int>(size.y * (_windowBottom - _windowTop)));
+ // CPictureObject::GetFullSize: the size of the texture is multiplied by the scale of the object
+ return Common::Point(static_cast<int>(size.x * _scaleX * (_windowRight - _windowLeft)), static_cast<int>(size.y * _scaleY * (_windowBottom - _windowTop)));
}
Common::Rect GameObject::getBounds() const {
@@ -321,8 +327,8 @@ Common::Point GameObject::getCenter() const {
Dims size;
if (!textureQuad(this, topLeft, size, anchor))
return Common::Point(_x, _y);
- return topLeft + Common::Point(static_cast<int>(size.x * (_windowLeft + (_windowRight - _windowLeft) * 0.5f)),
- static_cast<int>(size.y * (_windowTop + (_windowBottom - _windowTop) * 0.5f)));
+ return topLeft + Common::Point(static_cast<int>(size.x * _scaleX * (_windowLeft + (_windowRight - _windowLeft) * 0.5f)),
+ static_cast<int>(size.y * _scaleY * (_windowTop + (_windowBottom - _windowTop) * 0.5f)));
}
void GameObject::setCenter(Common::Point center) {
@@ -333,8 +339,8 @@ void GameObject::setCenter(Common::Point center) {
setPos(center.x, center.y);
return;
}
- const Common::Point offset(static_cast<int>(size.x * (_windowLeft + (_windowRight - _windowLeft) * 0.5f)),
- static_cast<int>(size.y * (_windowTop + (_windowBottom - _windowTop) * 0.5f)));
+ const Common::Point offset(static_cast<int>(size.x * _scaleX * (_windowLeft + (_windowRight - _windowLeft) * 0.5f)),
+ static_cast<int>(size.y * _scaleY * (_windowTop + (_windowBottom - _windowTop) * 0.5f)));
setPos(center.x - offset.x + anchor.x, center.y - offset.y + anchor.y);
}
diff --git a/engines/ngi/inventory.cpp b/engines/ngi/inventory.cpp
index 34e170fba8e..c73bf2f9a0f 100644
--- a/engines/ngi/inventory.cpp
+++ b/engines/ngi/inventory.cpp
@@ -19,11 +19,20 @@
*
*/
+#include "common/tokenizer.h"
+
#include "ngi/ngi.h"
#include "ngi/utils.h"
#include "ngi/inventory.h"
+#include "ngi/font.h"
#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/guimanager.h"
+#include "ngi/messages.h"
+#include "ngi/scene.h"
+#include "ngi/scenecontroller.h"
+#include "ngi/sound.h"
#include "ngi/statics.h"
#include "ngi/input.h"
@@ -564,4 +573,1297 @@ void NGIEngine::getAllInventory() {
inv->recalcItemPos();
}
+// ---- Android: CInventoryItem ----
+
+namespace {
+
+// CIDList::FindId: 0 when the symbol is not in obj.h
+int findObjectId(const char *symbol) {
+ uint32 id = 0;
+ if (g_ngi->_gameProject && g_ngi->_gameProject->_objectIds.findId(symbol, id))
+ return id;
+ return 0;
+}
+
+} // End of anonymous namespace
+
+// CInventoryItem::CInventoryItem
+InventoryItem::InventoryItem() {
+}
+
+// CInventoryItem::~CInventoryItem: the queue and the extra picture go, the others belong to SC_INV
+InventoryItem::~InventoryItem() {
+ delete _queue;
+ delete _picturePlate;
+}
+
+// CInventoryItem::Init (109DD0)
+void InventoryItem::init(const XmlNode &node, const BitmapFont *counterFont, const XmlColor &counterColor, const BitmapFont *textFont, const XmlColor &textColor,
+ float scaleSpeed, float maxScale, float minScale, bool autoCombine, const XmlVector2 &cursorOfs, PictureObject *itemPicture) {
+ _id = node.attrStr("id", "");
+ Scene *scene = g_ngi->findScene(findObjectId(node.attrStr("sc", "")));
+ if (!scene)
+ return;
+ _picture = static_cast<PictureObject *>(scene->findVisibleObject(findObjectId(node.attrStr("vis", "")), 0));
+ if (!_picture)
+ return;
+ _pictureSelected = static_cast<PictureObject *>(scene->findVisibleObject(findObjectId(node.attrStr("visSel", "")), 0));
+ _cursor = node.attrInt("cursor", 1);
+ _clickable = node.attrBool("clickable", true);
+ _queue = nullptr;
+ for (uint i = 0; i < node.childCount(); i++) {
+ const Common::String &childName = node[i].name();
+ if (childName == "CONSISTS") {
+ // std::map<std::string, int>::insert: an id that is there already keeps its number
+ const Common::String partId = node[i].attrStr("id", "");
+ const int num = node[i].attrInt("num", 1);
+ uint position = 0;
+ bool found = false;
+ while (position < _consists.size() && !found) {
+ if (_consists[position].first == partId)
+ found = true;
+ else if (_consists[position].first > partId)
+ break;
+ else
+ position++;
+ }
+ if (!found)
+ _consists.insert_at(position, Common::Pair<Common::String, int>(partId, num));
+ }
+ if (childName == "QUEUE")
+ warning("STUB/untested: the QUEUE of the inventory item %s is not read (CMessageQueue::Init of an XML node)", _id.c_str());
+ }
+ // the original attribute name starts with the Cyrillic es (0xF1), not a Latin c: never found
+ const XmlVector2 ofs = node.attrVector2("\xF1ursorOfs", cursorOfs.x, cursorOfs.y);
+ _cursorOfsX = ofs.x;
+ _cursorOfsY = ofs.y;
+ _picturePlate = itemPicture;
+ if (itemPicture) {
+ const Common::Point plateSize = _picture->getSize();
+ const Common::Point plateFull = itemPicture->getSize();
+ _offsetX = (plateFull.x - plateSize.x) * 0.5f;
+ _offsetY = (plateFull.y - plateSize.y) * 0.5f;
+ }
+ _textFont = textFont;
+ _counterFont = counterFont;
+ _counterColor = counterColor;
+ _textColor = textColor;
+ _scaleSpeed = scaleSpeed;
+ _maxScale = maxScale;
+ _minScale = minScale;
+ _autoCombine = node.attrBool("auto_combine", autoCombine);
+ _addNext = node.attrBool("add_next", true);
+ _state = 0;
+}
+
+// CInventoryItem::SetXmlData (1080F8)
+void InventoryItem::setXmlData(const XmlNode &node) {
+ _counter = node.attrInt("counter", 0);
+ _presentDelay = node.attrInt("presentDelay", 0);
+ _state = 0;
+}
+
+// CInventoryItem::OnUpdate (1085F6)
+void InventoryItem::onUpdate(uint32 elapsed) {
+ if (_queue)
+ warning("STUB/untested: CMessageQueue::Update of the queue of the inventory item %s", _id.c_str());
+ if (_counter == 0)
+ return;
+ _presentDelay += elapsed;
+ float scaleX;
+ float scaleY;
+ if (_scaleState == 1) {
+ const float step = (float)elapsed * _scaleSpeed;
+ scaleX = step + _scaleX;
+ scaleY = step + _scaleY;
+ if (scaleX >= _maxScale || scaleY >= _maxScale) {
+ _scaleState = 2;
+ _scaleX = _maxScale;
+ _scaleY = _maxScale;
+ return;
+ }
+ } else {
+ if (_scaleState != 2)
+ return;
+ const float step = (float)elapsed * _scaleSpeed;
+ scaleX = _scaleX - step;
+ scaleY = _scaleY - step;
+ if (scaleX <= _minScale || scaleY <= _minScale) {
+ _scaleState = 0;
+ _scaleX = _minScale;
+ _scaleY = _minScale;
+ return;
+ }
+ }
+ _scaleX = scaleX;
+ _scaleY = scaleY;
+}
+
+// CInventoryItem::SetPos (10889C): the extra picture moves when there is one
+void InventoryItem::setPos(int x, int y) {
+ PictureObject *target = _picturePlate ? _picturePlate : _picture;
+ target->setPos(x, y);
+}
+
+// CInventoryItem::GetPos (1088BA)
+Common::Point InventoryItem::getPos() const {
+ const PictureObject *target = _picturePlate ? _picturePlate : _picture;
+ return Common::Point(target->_x, target->_y);
+}
+
+// CInventoryItem::SetCenter (1088CE)
+void InventoryItem::setCenter(Common::Point center) {
+ if (_picturePlate)
+ _picturePlate->setCenter(center);
+ else if (_picture)
+ _picture->setCenter(center);
+}
+
+// CInventoryItem::GetCenter (1088F0)
+Common::Point InventoryItem::getCenter() const {
+ if (_picturePlate)
+ return _picturePlate->getCenter();
+ if (_picture)
+ return _picture->getCenter();
+ return Common::Point();
+}
+
+// CInventoryItem::GetSize (108A3E): the picture size includes the scale of the item
+void InventoryItem::getSize(float &width, float &height) const {
+ const PictureObject *target = _picturePlate ? _picturePlate : _picture;
+ if (!target) {
+ width = 0;
+ height = 0;
+ return;
+ }
+ const Common::Point size = target->getSize();
+ width = size.x / _scaleX;
+ height = size.y / _scaleY;
+}
+
+// CInventoryItem::Hit (108914)
+bool InventoryItem::hit(float x, float y) const {
+ if (_picturePlate)
+ return _picturePlate->hit(x, y);
+ if (_state == 1 && _pictureSelected)
+ return _pictureSelected->hit(x, y);
+ if (_picture)
+ return _picture->hit(x, y);
+ return false;
+}
+
+// CInventoryItem::GetCursorType (10893E)
+int InventoryItem::getCursorType(float x, float y) const {
+ if (_counter > 0 && _picture && hit(x, y))
+ return 1;
+ return -1;
+}
+
+// CInventoryItem::SetCounter (10895E)
+void InventoryItem::setCounter(int counter) {
+ const int old = _counter;
+ if (_addNext || old <= 0)
+ _counter = counter;
+ if (_counter > 0 && counter > old)
+ _scaleState = 1;
+}
+
+// CInventoryItem::AddCounter (10971C)
+void InventoryItem::addCounter(int delta) {
+ setCounter(delta + _counter);
+ if (delta > 0) {
+ g_ngi->_inventory->postMessageToScenes("INVENTORY_ITEM_INC_COUNTER", _id);
+ } else if (delta != 0) {
+ g_ngi->_inventory->postMessageToScenes("INVENTORY_ITEM_DEC_COUNTER", _id);
+ }
+}
+
+// CInventoryItem::OnMouseMove (108984)
+void InventoryItem::onMouseMove(uint32 id, float x, float y) {
+ _hovered = hit(x, y);
+}
+
+// CInventoryItem::Render (108AA0)
+void InventoryItem::render(float scrollX, float scrollY, bool printCounter) {
+ PictureObject *drawn = nullptr;
+ if (_state == 1 && _pictureSelected)
+ drawn = _pictureSelected;
+ else
+ drawn = _picture;
+ if (drawn) {
+ if (_picturePlate) {
+ const Common::Point center = _picturePlate->getCenter();
+ _picturePlate->_scaleX = _scaleX;
+ _picturePlate->_scaleY = _scaleY;
+ _picturePlate->setCenter(center);
+ const Common::Point pos = getPos();
+ _picturePlate->renderAtPos(pos.x - scrollX, pos.y - scrollY);
+ }
+ const Common::Point center = _picture->getCenter();
+ drawn->_scaleX = _scaleX;
+ drawn->_scaleY = _scaleY;
+ drawn->setCenter(center);
+ const Common::Point pos = getPos();
+ drawn->renderAtPos((pos.x + _offsetX) - scrollX, (pos.y + _offsetY) - scrollY);
+ }
+ if (_counterFont && printCounter) {
+ if (_counter > 1 && _state != 1) {
+ const Common::String text = Common::String::format("%d", _counter);
+ const Common::Point pos = getPos();
+ float width;
+ float height;
+ getSize(width, height);
+ const float x = (pos.x - scrollX) + (width * 3.0f) * 0.25f;
+ const float y = (pos.y - scrollY) + (height + height) / 3.0f;
+ if (!_warnedFont) {
+ warning("STUB/untested: the color of the counter is not applied (BitmapFont has no color)");
+ _warnedFont = true;
+ }
+ _counterFont->printAligned(g_ngi->_backgroundSurface, text, x, y, BitmapFont::kAlignLeft, 0);
+ }
+ }
+}
+
+// CInventoryItem::GetAccembly (108C8C)
+Common::String InventoryItem::getAssembly(int index) const {
+ if (index < 0 || index >= (int)_isPartOf.size())
+ return Common::String();
+ return _isPartOf[index];
+}
+
+// CInventoryItem::PushIsPart (10A8F6)
+void InventoryItem::pushIsPart(const Common::String &itemId) {
+ for (uint i = 0; i < _isPartOf.size(); i++) {
+ if (_isPartOf[i] == itemId)
+ return;
+ }
+ _isPartOf.push_back(itemId);
+}
+
+// CInventoryItem::CheckCombines (1097BC)
+InventoryItem *InventoryItem::checkCombines(bool addResult, bool consume) {
+ Inventory *inventory = g_ngi->_inventory;
+ InventoryItem *result = nullptr;
+ for (int i = 0; i < (int)_isPartOf.size(); ++i) {
+ InventoryItem *item = inventory->getItemByName(_isPartOf[i]);
+ if (!item)
+ continue;
+ bool complete = true;
+ for (uint j = 0; j < item->_consists.size(); j++) {
+ InventoryItem *part = inventory->getItemByName(item->_consists[j].first);
+ if (!part || part->_counter < item->_consists[j].second) {
+ complete = false;
+ break;
+ }
+ }
+ if (!complete)
+ continue;
+ if (consume) {
+ for (uint j = 0; j < item->_consists.size(); j++) {
+ InventoryItem *part = inventory->getItemByName(item->_consists[j].first);
+ inventory->removeItem(part, -item->_consists[j].second);
+ }
+ if (addResult)
+ item->addCounter(1);
+ --i;
+ }
+ result = item;
+ }
+ return result;
+}
+
+// CInventoryItem::IsCombine (1098D4): the parts of the last assembly that exists are all there
+bool InventoryItem::isCombine() const {
+ if (_isPartOf.empty())
+ return false;
+ Inventory *inventory = g_ngi->_inventory;
+ bool result = true;
+ for (uint i = 0; i < _isPartOf.size(); ++i) {
+ InventoryItem *item = inventory->getItemByName(_isPartOf[i]);
+ if (!item)
+ continue;
+ result = true;
+ for (uint j = 0; j < item->_consists.size(); j++) {
+ InventoryItem *part = inventory->getItemByName(item->_consists[j].first);
+ if (!part || part->_counter < item->_consists[j].second) {
+ result = false;
+ break;
+ }
+ }
+ }
+ return result;
+}
+
+// CInventoryItem::CheckCursorObj (1099B0): an item that is used up leaves the cursor
+void InventoryItem::checkCursorObj() {
+ if (_counter == 0) {
+ CursorController *cursor = g_ngi->_inputController;
+ if (cursor->getObject() == _picture)
+ cursor->setObject(nullptr, 0, 0);
+ }
+}
+
+// CInventoryItem::TryTakeFromCursor (109A22)
+bool InventoryItem::tryTakeFromCursor(float x, float y) {
+ CursorController *cursor = g_ngi->_inputController;
+ if (cursor->getObject() == _picture) {
+ cursor->setObject(nullptr, 0, 0);
+ return true;
+ }
+ return false;
+}
+
+// CInventoryItem::RenderName (109A48)
+void InventoryItem::renderName() {
+ if (!_textFont || !_hovered || !_picture)
+ return;
+ CursorController *cursor = g_ngi->_inputController;
+ if (cursor->getObject())
+ return;
+ const float x = cursor->_hotScreenX;
+ const float y = cursor->_hotScreenY - 40.0f;
+ const Common::String text = g_ngi->_textContainer->getText(_picture->_title);
+ if (!_warnedFont) {
+ warning("STUB/untested: the color of the name under the cursor is not applied (BitmapFont has no color)");
+ _warnedFont = true;
+ }
+ _textFont->printAligned(g_ngi->_backgroundSurface, text, x, y, BitmapFont::kAlignCenter, 100.0f);
+}
+
+// CInventoryItem::TryPutOnCursor (109B28)
+bool InventoryItem::tryPutOnCursor(float x, float y, bool needHit) {
+ if (_counter <= 0)
+ return false;
+ const bool clickable = _clickable;
+ if (!clickable)
+ return false;
+ const bool isHit = hit(x, y);
+ if (needHit && !isHit)
+ return false;
+ g_ngi->_inputController->setObject(_picture, _cursorOfsX, _cursorOfsY);
+ if (_hovered)
+ _hovered = false;
+ g_ngi->_inventory->postMessageToScenes("INVENTORY_ITEM_IN_CURSOR", _id);
+ return clickable;
+}
+
+// CInventoryItem::RunQueue (1093DA)
+bool InventoryItem::runQueue() {
+ if (!_queue)
+ return false;
+ _queue->_scene = g_ngi->getCurrentScene();
+ warning("STUB/untested: CMessageQueue::Run(4) of the queue of the inventory item %s", _id.c_str());
+ return true;
+}
+
+// ---- Android: CInventory ----
+
+namespace {
+
+// CSoundManager::Play: an unknown id does nothing
+void playInventorySound(int id) {
+ if (Sound *sound = g_ngi->findSound(id))
+ sound->play(0, 0);
+}
+
+} // End of anonymous namespace
+
+// CInventory::CInventory
+Inventory::Inventory() {
+ _sceneId = 0;
+}
+
+// CInventory::~CInventory: the items are deleted
+Inventory::~Inventory() {
+ for (uint i = 0; i < _items.size(); i++)
+ delete _items[i];
+}
+
+// CInventory::PostMessageToScenes (1093FE)
+void Inventory::postMessageToScenes(const Common::String &name, const Common::String ¶m) {
+ message(name, param, nullptr);
+ if (Scene *current = g_ngi->getCurrentScene())
+ current->message(name, param, nullptr);
+}
+
+// CInventory::GetItem(uint) (108E3A): by the id of the picture of the item
+InventoryItem *Inventory::getItem(uint pictureId) const {
+ for (uint i = 0; i < _items.size(); i++) {
+ if (pictureId == (uint16)_items[i]->_picture->_id)
+ return _items[i];
+ }
+ return nullptr;
+}
+
+// CInventory::GetItem(float, float) (108E66): the visible item at the position
+InventoryItem *Inventory::getItemAtPos(float x, float y) const {
+ for (uint i = 0; i < _visibleItems.size(); i++) {
+ if (_visibleItems[i]->hit(x, y))
+ return _visibleItems[i];
+ }
+ return nullptr;
+}
+
+// CInventory::GetItem(std::string) (109334)
+InventoryItem *Inventory::getItemByName(const Common::String &id) const {
+ for (uint i = 0; i < _items.size(); i++) {
+ if (id == _items[i]->_id)
+ return _items[i];
+ }
+ return nullptr;
+}
+
+// CInventory::Init (10B408)
+void Inventory::init() {
+ const XmlNode &root = _xmlDocument->first();
+ _areaX = root.attrFloat("x", 0.0f);
+ _areaY = root.attrFloat("y", 0.0f);
+ Common::StringTokenizer fitTo(root.attrStr("fitTo", ""), " ");
+ // CRender +8 + +24 and +12 + +28: the margins of the screen (the vertical one is 0)
+ const float marginX = g_ngi->_wideOfs;
+ const float marginY = 0;
+ while (!fitTo.empty()) {
+ const Common::String side = fitTo.nextToken();
+ if (side == "left")
+ _areaX -= marginX;
+ if (side == "right")
+ _areaX += marginX;
+ if (side == "top")
+ _areaY -= marginY;
+ if (side == "bottom")
+ _areaY += marginY;
+ }
+ _areaWidth = root.attrFloat("w", 1024.0f);
+ _areaHeight = root.attrFloat("h", 100.0f);
+ _interval = root.attrFloat("interval", 10.0f);
+ const BitmapFont *counterFont = g_ngi->getFont(root.attrStr("fontCounter", "dlg.xml"));
+ const Common::String textFontName = root.attrStr("fontText", "");
+ const BitmapFont *textFont = textFontName.empty() ? nullptr : g_ngi->getFont(textFontName);
+ const XmlColor counterColor = root.attrColor("colorCounter", 1.0f, 1.0f, 1.0f, 1.0f);
+ const XmlColor textColor = root.attrColor("colorText", 1.0f, 1.0f, 1.0f, 1.0f);
+ const XmlVector2 cursorOfs = root.attrVector2("cursorOfs", 40.0f, 40.0f);
+ _autoCombine = root.attrBool("auto_combine", false);
+ _clearOnHide = root.attrBool("clear_on_hide", false);
+
+ PictureObject *picture = nullptr;
+ const Common::String sceneName = root.attrStr("scene", "");
+ if (!sceneName.empty()) {
+ Scene *scene = g_ngi->findScene(findObjectId(sceneName.c_str()));
+ picture = scene ? scene->findPictureObjectById(findObjectId(root.attrStr("pic_item", "")), 0) : nullptr;
+ const XmlNode &assembly = root["ACCEMBLY"];
+ _assemblyShowTime = assembly.attrInt("time_show", 0);
+ _assemblyFlashes = assembly.attrInt("num_flash", 0);
+ const Common::String pics = assembly.attrStr("pics", "");
+ if (!pics.empty()) {
+ Common::StringTokenizer tokenizer(pics, " ");
+ while (!tokenizer.empty()) {
+ const Common::String name = tokenizer.nextToken();
+ _assemblyPictures.push_back(scene ? scene->findPictureObjectById(findObjectId(name.c_str()), 0) : nullptr);
+ }
+ }
+ }
+
+ const XmlNode &sounds = root["SOUNDS"];
+ _soundAssembly = findObjectId(sounds.attrStr("SND_ACCEMBLY", ""));
+ _soundAddItem = findObjectId(sounds.attrStr("SND_ADD_ITEM", ""));
+ _soundClickItem = findObjectId(sounds.attrStr("SND_CLICK_ITEM", ""));
+ _soundUnclickItem = findObjectId(sounds.attrStr("SND_UNCLICK_ITEM", ""));
+ _soundAssemblyError = findObjectId(sounds.attrStr("SND_ACCEMBLY_ERROR", ""));
+
+ const XmlNode &scale = root["SCALE"];
+ const float speed = scale.attrFloat("SPEED", 0.001f);
+ const float maxScale = scale.attrFloat("MAX_SCALE", 1.1f);
+ const float minScale = scale.attrFloat("MIN_SCALE", 1.0f);
+
+ for (uint i = 0; i < root.childCount(); i++) {
+ if (root[i].name() != "ITEM")
+ continue;
+ InventoryItem *item = new InventoryItem();
+ PictureObject *plate = picture ? new PictureObject(picture) : nullptr;
+ // the original attribute name starts with the Cyrillic es (see InventoryItem::init): default used
+ const XmlVector2 itemOfs = root[i].attrVector2("\xF1ursorOfs", cursorOfs.x, cursorOfs.y);
+ item->init(root[i], counterFont, counterColor, textFont, textColor, speed, maxScale, minScale, _autoCombine, itemOfs, plate);
+ _items.push_back(item);
+ }
+
+ for (uint i = 0; i < _items.size(); i++) {
+ const Common::Array<Common::Pair<Common::String, int> > consists = _items[i]->_consists;
+ for (uint j = 0; j < consists.size(); j++) {
+ if (InventoryItem *part = getItemByName(consists[j].first))
+ part->pushIsPart(_items[i]->_id);
+ }
+ }
+ _mode = root.attrInt("mode", 0);
+}
+
+// CInventory::SetXmlData (10AFBC)
+void Inventory::setXmlData(const XmlNode &node) {
+ for (uint i = 0; i < node.childCount(); i++) {
+ const Common::String name = node[i].name();
+ if (name == "ITEM") {
+ InventoryItem *item = getItemByName(node[i].attrStr("id", ""));
+ if (item) {
+ item->setXmlData(node[i]);
+ if (item->_counter > 0)
+ addVisibleItem(item);
+ }
+ }
+ if (name == "ASSEMBLY_ITEM") {
+ InventoryItem *item = getItemByName(node[i].attrStr("id", ""));
+ if (item) {
+ item->setXmlData(node[i]);
+ _assemblyShown = true;
+ _assemblies.push_back(item);
+ _assemblyFlashTime = 0;
+ _assemblyFlashOn = true;
+ }
+ }
+ }
+ for (uint i = 0; i < _visibleItems.size(); i++) {
+ if (_visibleItems[i]->_autoCombine)
+ _visibleItems[i]->checkCombines(true, true);
+ }
+}
+
+// CInventory::CleanXml (10BC40): CScene::CleanXml (reread the document) is not ported
+void Inventory::cleanXml() {
+ warning("STUB/untested: CScene::CleanXml of the inventory (the pictures and the GUI are not read again)");
+ for (uint i = 0; i < _items.size(); i++) {
+ // CGObject::CleanXml of an item: nothing in the original
+ }
+ _visibleItems.clear();
+}
+
+// CGObject::SaveXml(bool) (FE8D8): saves the XML state to GetSavePath (inventory.sav)
+void Inventory::saveXml(bool flag) {
+ warning("STUB/untested: CGObject::SaveXml of the inventory (inventory.sav is not written, the state is in the savegames)");
+}
+
+// CInventory::Update (10BCE8)
+bool Inventory::update(int elapsed) {
+ if (_assemblyFlashTime != -1) {
+ _assemblyFlashTime += elapsed;
+ _assemblyTimer += elapsed;
+ if (_assemblyTimer >= _assemblyShowTime) {
+ _assemblyFlashCounter++;
+ _assemblyTimer = 0;
+ _assemblyFlashOn = !_assemblyFlashOn;
+ if (_assemblyFlashCounter > _assemblyFlashes) {
+ if (!_queueRunning) {
+ _assemblyFlashTime = -1;
+ _assemblyFlashCounter = 0;
+ _assemblyShown = false;
+ InventoryItem *item = _assemblies[0];
+ _assemblies.remove_at(0);
+ addItem(item->_id, 1);
+ }
+ }
+ }
+ }
+ for (uint i = _firstVisible; i < _items.size(); i++)
+ _items[i]->onUpdate(elapsed);
+ return Scene::update(elapsed);
+}
+
+// CInventory::RenderBottom (108EA4)
+void Inventory::renderBottom() {
+ for (uint i = _firstVisible; i < _visibleItems.size(); i++) {
+ const Common::Point pos = _visibleItems[i]->getPos();
+ float width;
+ float height;
+ _visibleItems[i]->getSize(width, height);
+ if ((float)(pos.x + width) >= _areaX + _areaWidth)
+ break;
+ _visibleItems[i]->render(_x, _y, true);
+ }
+}
+
+// CInventory::RenderAccembly (10A410)
+void Inventory::renderAssembly() {
+ if (_assemblies.empty())
+ return;
+ const int parts = _assemblies[0]->_consists.size();
+ const int index = parts - 1;
+ if (index < 0 || index >= (int)_assemblyPictures.size())
+ return;
+ PictureObject *picture = _assemblyPictures[index];
+ const float x = _areaX;
+ const Common::Point pictureSize = picture->getSize();
+ const float y = (_areaY - pictureSize.y) + _interval;
+ picture->renderAtPos(x, y);
+ if (!_assemblyFlashOn)
+ return;
+ int number = 0;
+ for (uint i = 0; i < _assemblies[0]->_consists.size(); i++) {
+ InventoryItem *item = getItemByName(_assemblies[0]->_consists[i].first);
+ if (!item)
+ continue;
+ float width;
+ float height;
+ item->getSize(width, height);
+ const float spacing = (pictureSize.x - (parts * width)) / (parts + 1);
+ item->getSize(width, height);
+ const float itemY = y + _interval;
+ const float itemX = (x + spacing) + (number * (spacing + width));
+ item->setPos(itemX, itemY);
+ item->render(_x, _y, false);
+ number++;
+ }
+}
+
+// CInventory::RenderTop (10A5C0)
+void Inventory::renderTop() {
+ for (uint i = _firstVisible; i < _visibleItems.size(); i++) {
+ const Common::Point pos = _visibleItems[i]->getPos();
+ float width;
+ float height;
+ _visibleItems[i]->getSize(width, height);
+ if ((float)(pos.x + width) >= _areaX + _areaWidth)
+ break;
+ _visibleItems[i]->renderName();
+ }
+ if (_assemblyShown)
+ renderAssembly();
+}
+
+// CInventory::Render (10A648)
+void Inventory::render(bool clear) {
+ if (_controller)
+ _controller->onRenderBottom(Common::Point(_x, _y));
+ Common::Array<GameObject *> visibleObjects;
+ for (PictureObject *picture : _pictureObjects) {
+ if (picture->_flags & 4)
+ visibleObjects.push_back(picture);
+ }
+ sortRenderables(visibleObjects);
+ for (GameObject *object : visibleObjects)
+ static_cast<PictureObject *>(object)->render(Common::Point(_x, _y));
+ renderBottom();
+ if (_controller)
+ _controller->onRender(Common::Point(_x, _y));
+ if (_guiManager)
+ _guiManager->render(g_ngi->_backgroundSurface);
+ if (_controller)
+ _controller->onRenderTop(Common::Point(_x, _y));
+ renderTop();
+}
+
+// CInventory::OnHide (1086CC)
+void Inventory::onHide() {
+ if (_clearOnHide) {
+ saveXml(false);
+ cleanXml();
+ _selectedItem = nullptr;
+ _assemblies.clear();
+ _assemblyFlashTime = -1;
+ _assemblyFlashCounter = 0;
+ _assemblyShown = false;
+ _assemblyTimer = 0;
+ }
+}
+
+// CInventory::OnStartQueue (108E1C)
+void Inventory::onStartQueue() {
+ if (!_queueRunning)
+ saveXml(true);
+ _queueRunning = true;
+}
+
+// CInventory::OnMouseLKeyDown (10AB4A)
+bool Inventory::onMouseLKeyDown(uint32 id, float x, float y) {
+ const float sceneX = x + _x;
+ const float sceneY = y + _y;
+ if (_mode != 1 || !onFirstAction(sceneX, sceneY)) {
+ if (!_controller || !_controller->onMouseLKeyDownTop(id, sceneX, sceneY)) {
+ if (!_guiManager || !_guiManager->onMouseLKeyDown(Common::Point(x, y))) {
+ if (_controller)
+ _controller->onMouseLKeyDown(id, sceneX, sceneY);
+ }
+ }
+ }
+ return false;
+}
+
+// CInventory::OnMouseLKeyUp (10AF2C)
+bool Inventory::onMouseLKeyUp(uint32 id, float x, float y) {
+ const float sceneX = x + _x;
+ const float sceneY = y + _y;
+ if (_mode != 0 || !onFirstAction(sceneX, sceneY)) {
+ onSecondAction(sceneX, sceneY);
+ if (!_controller || !_controller->onMouseLKeyUpTop(id, sceneX, sceneY)) {
+ if (!_guiManager || !_guiManager->onMouseLKeyUp(Common::Point(x, y))) {
+ if (_controller)
+ _controller->onMouseLKeyUp(id, sceneX, sceneY);
+ }
+ }
+ }
+ return false;
+}
+
+// CInventory::OnMouseRKeyDown (108440)
+bool Inventory::onMouseRKeyDown(uint32 id, float x, float y) {
+ const float sceneX = x + _x;
+ const float sceneY = y + _y;
+ if (!_controller || !_controller->onMouseRKeyDownTop(id, sceneX, sceneY)) {
+ if (!_guiManager || !_guiManager->onMouseRKeyDown(Common::Point(x, y))) {
+ if (_controller)
+ _controller->onMouseRKeyDown(id, sceneX, sceneY);
+ }
+ }
+ return false;
+}
+
+// CInventory::OnMouseRKeyUp (1084AE)
+bool Inventory::onMouseRKeyUp(uint32 id, float x, float y) {
+ const float sceneX = x + _x;
+ const float sceneY = y + _y;
+ if (!_controller || !_controller->onMouseRKeyUpTop(id, sceneX, sceneY)) {
+ if (!_guiManager || !_guiManager->onMouseRKeyUp(Common::Point(x, y))) {
+ if (_controller)
+ _controller->onMouseRKeyUp(id, sceneX, sceneY);
+ }
+ }
+ return false;
+}
+
+// CInventory::OnMouseMove (1089A0): the controller gets the move in any case
+bool Inventory::onMouseMove(uint32 id, float x, float y) {
+ const float sceneX = x + _x;
+ const float sceneY = y + _y;
+ for (uint i = 0; i < _visibleItems.size(); i++)
+ _visibleItems[i]->onMouseMove(id, sceneX, sceneY);
+ if (!_controller || !_controller->onMouseMoveTop(id, sceneX, sceneY)) {
+ if (_guiManager)
+ _guiManager->onMouseMove(Common::Point(x, y));
+ }
+ if (_controller)
+ return _controller->onMouseMove(id, sceneX, sceneY);
+ return false;
+}
+
+// CInventory::GetCursorType (10851C)
+int Inventory::getCursorType(float x, float y) {
+ const float sceneX = x + _x;
+ const float sceneY = y + _y;
+ int cursorType = -1;
+ for (uint i = 0; i < _items.size(); i++) {
+ cursorType = _items[i]->getCursorType(sceneX, sceneY);
+ if (cursorType != -1)
+ break;
+ }
+ if (_controller && cursorType < _controller->getCursorType(sceneX, sceneY))
+ cursorType = _controller->getCursorType(sceneX, sceneY);
+ if (_guiManager && _guiManager->getCursorType(Common::Point(x, y)) != -1)
+ cursorType = _guiManager->getCursorType(Common::Point(x, y));
+ if (_controller && _controller->getCursorTypeTop(sceneX, sceneY) != -1)
+ return _controller->getCursorTypeTop(sceneX, sceneY);
+ return cursorType;
+}
+
+// CInventory::Hit (10927C)
+bool Inventory::hit(float x, float y) {
+ const float sceneX = x + _x;
+ const float sceneY = y + _y;
+ for (uint i = 0; i < _visibleItems.size(); i++) {
+ if (_visibleItems[i]->hit(sceneX, sceneY))
+ return true;
+ }
+ if (_guiManager && _guiManager->hit(Common::Point(x, y)))
+ return true;
+ if (_controller)
+ return _controller->hit((uint32)sceneX, (uint32)sceneY);
+ return false;
+}
+
+// CInventory::RecalcItemPos (108F20)
+void Inventory::recalcItemPos() {
+ for (uint i = _firstVisible; i < _visibleItems.size(); i++) {
+ float width;
+ float height;
+ _visibleItems[i]->getSize(width, height);
+ const float centerX = (_areaX + width * 0.5f) + (float)(i - _firstVisible) * (width + _interval);
+ _visibleItems[i]->getSize(width, height);
+ _visibleItems[i]->setCenter(Common::Point(centerX, _areaY + height * 0.5f));
+ }
+}
+
+// CInventory::IsExistVisibleItem (108FF0)
+bool Inventory::isExistVisibleItem(InventoryItem *item) const {
+ for (uint i = 0; i < _visibleItems.size(); i++) {
+ if (_visibleItems[i] == item)
+ return true;
+ }
+ return false;
+}
+
+// CInventory::GetNumInvisibleItems (10901C)
+int Inventory::getNumInvisibleItems(bool total) const {
+ uint i = _firstVisible;
+ while (i < _visibleItems.size()) {
+ const Common::Point pos = _visibleItems[i]->getPos();
+ float width;
+ float height;
+ _visibleItems[i]->getSize(width, height);
+ if ((float)(pos.x + width) >= _areaX + _areaWidth)
+ break;
+ i++;
+ }
+ if (total)
+ return _visibleItems.size() - i + _firstVisible;
+ return _visibleItems.size() - i;
+}
+
+// CInventory::SetScrollingPos (1090BE)
+void Inventory::setScrollingPos(float position) {
+ const int invisible = getNumInvisibleItems(true);
+ if (invisible != 0) {
+ _firstVisible = (int)((float)invisible * position);
+ recalcItemPos();
+ }
+}
+
+// CInventory::GetScrollingPos (1090EA)
+float Inventory::getScrollingPos() const {
+ return (float)_firstVisible / (float)getNumInvisibleItems(true);
+}
+
+// CInventory::GetNumVisibleItems (109110)
+int Inventory::getNumVisibleItems() const {
+ uint i = _firstVisible;
+ while (i < _visibleItems.size()) {
+ const Common::Point pos = _visibleItems[i]->getPos();
+ float width;
+ float height;
+ _visibleItems[i]->getSize(width, height);
+ if ((float)(pos.x + width) >= _areaX + _areaWidth)
+ break;
+ i++;
+ }
+ return i - _firstVisible;
+}
+
+// CInventory::GetNumRealItems (109184)
+int Inventory::getNumRealItems() const {
+ if (!_items.empty()) {
+ float width;
+ float height;
+ _items[0]->getSize(width, height);
+ float sum = 0.0f;
+ for (uint i = 0; i < _items.size(); i++) {
+ sum = (width + _interval) + sum;
+ if (sum >= _areaWidth)
+ return i;
+ }
+ }
+ return 0;
+}
+
+// CInventory::IsVisibleItem (1091F0)
+bool Inventory::isVisibleItem(InventoryItem *item) const {
+ for (int i = 0; i < (int)_visibleItems.size(); ++i) {
+ if (_visibleItems[i] == item) {
+ if (i < _firstVisible)
+ return false;
+ const Common::Point pos = item->getPos();
+ float width;
+ float height;
+ _visibleItems[i]->getSize(width, height);
+ if ((float)(pos.x + width) >= _areaX + _areaWidth)
+ return false;
+ if (_firstVisible - i < getNumRealItems())
+ return false;
+ }
+ }
+ return true;
+}
+
+// CInventory::SetItemsState (109302)
+void Inventory::setItemsState(int state) {
+ for (uint i = 0; i < _items.size(); i++)
+ _items[i]->setState(state);
+}
+
+// CInventory::Next (10948C)
+void Inventory::next() {
+ if (getNumInvisibleItems(false) != 0) {
+ _firstVisible++;
+ const int last = (int)_visibleItems.size() - 1;
+ if (_firstVisible >= last)
+ _firstVisible = last;
+ recalcItemPos();
+ postMessageToScenes("INV_SCROLLING", "");
+ }
+}
+
+// CInventory::Prev (109514)
+void Inventory::prev() {
+ int first = _firstVisible - 1;
+ if (first <= 0)
+ first = 0;
+ _firstVisible = first;
+ recalcItemPos();
+ postMessageToScenes("INV_SCROLLING", "");
+}
+
+// CInventory::SetItemVisible (10957C)
+bool Inventory::setItemVisible(InventoryItem *item, bool flag) {
+ if (item && (!isVisibleItem(item) || !flag)) {
+ int index = 0;
+ while (index < (int)_visibleItems.size()) {
+ InventoryItem *current = _visibleItems[index++];
+ if (current == item) {
+ _firstVisible = index - getNumVisibleItems();
+ if ((int)_visibleItems.size() - _firstVisible < getNumRealItems())
+ _firstVisible = _visibleItems.size() - getNumRealItems();
+ const int last = (int)_visibleItems.size() - 1;
+ if (_firstVisible >= last)
+ _firstVisible = last - getNumVisibleItems();
+ if (_firstVisible < 0)
+ _firstVisible = 0;
+ recalcItemPos();
+ postMessageToScenes("INV_SCROLLING", "");
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+// CInventory::SetVisibleScroll (109688)
+void Inventory::setVisibleScroll() {
+ if (getNumInvisibleItems(true) != 0)
+ postMessageToScenes("INV_SCROLL_VISIBLE", "INV_SCROLL_SHOW");
+ else
+ postMessageToScenes("INV_SCROLL_VISIBLE", "INV_SCROLL_HIDE");
+}
+
+// CInventory::AddVisibleItem (10AC60)
+bool Inventory::addVisibleItem(InventoryItem *item) {
+ if (isExistVisibleItem(item)) {
+ setItemVisible(item, true);
+ return false;
+ }
+ _visibleItems.push_back(item);
+ recalcItemPos();
+ setItemVisible(item, true);
+ setVisibleScroll();
+ postMessageToScenes("INV_SCROLLING", "");
+ return true;
+}
+
+// CInventory::RemoveVisibleItem (10A988)
+bool Inventory::removeVisibleItem(InventoryItem *item) {
+ uint index = 0;
+ while (index < _visibleItems.size() && _visibleItems[index] != item)
+ index++;
+ if (index == _visibleItems.size())
+ return false;
+ _visibleItems.remove_at(index);
+ recalcItemPos();
+ if (!_visibleItems.empty())
+ setItemVisible(_visibleItems.back(), false);
+ setVisibleScroll();
+ postMessageToScenes("INV_SCROLLING", "");
+ return true;
+}
+
+// CInventory::RenewVisibleItem (10B374): the item goes to the end, the first selected after it
+void Inventory::renewVisibleItem(InventoryItem *item) {
+ for (uint i = 0; i < _visibleItems.size(); i++) {
+ if (_visibleItems[i] == item) {
+ _visibleItems.push_back(item);
+ _visibleItems.remove_at(i);
+ break;
+ }
+ }
+ for (uint i = 0; i < _visibleItems.size(); i++) {
+ if (_visibleItems[i]->_state == 1 && _visibleItems[i] != item) {
+ InventoryItem *moved = _visibleItems[i];
+ _visibleItems.push_back(moved);
+ _visibleItems.remove_at(i);
+ recalcItemPos();
+ return;
+ }
+ }
+ recalcItemPos();
+}
+
+// CInventory::AddItem(std::string, int) (10B140)
+void Inventory::addItem(const Common::String &id, int count) {
+ InventoryItem *item = getItemByName(id);
+ if (item) {
+ addVisibleItem(item);
+ item->addCounter(count);
+ playInventorySound(_soundAddItem);
+ }
+ if (!item) {
+ warning("Inventory::addItem: unknown item %s", id.c_str());
+ return;
+ }
+ if (item->_autoCombine) {
+ InventoryItem *assembly = item->checkCombines(false, true);
+ if (assembly) {
+ _assemblyShown = true;
+ _assemblies.push_back(assembly);
+ _assemblyFlashTime = 0;
+ _assemblyFlashOn = true;
+ playInventorySound(_soundAssembly);
+ }
+ }
+ item->runQueue();
+}
+
+// CInventory::AddItem(CInventoryItem *, int) (10B1F4)
+void Inventory::addItem(InventoryItem *newItem, int count) {
+ InventoryItem *item = getItemByName(newItem->_id);
+ if (item) {
+ addVisibleItem(item);
+ item->addCounter(count);
+ playInventorySound(_soundAddItem);
+ } else {
+ _items.push_back(newItem);
+ item = newItem;
+ for (uint i = 0; i < _items.size(); i++) {
+ const Common::Array<Common::Pair<Common::String, int> > consists = _items[i]->_consists;
+ for (uint j = 0; j < consists.size(); j++) {
+ if (InventoryItem *part = getItemByName(consists[j].first))
+ part->pushIsPart(_items[i]->_id);
+ }
+ }
+ }
+ if (item->_autoCombine) {
+ InventoryItem *assembly = item->checkCombines(false, true);
+ if (assembly) {
+ _assemblyShown = true;
+ _assemblies.push_back(assembly);
+ _assemblyFlashTime = 0;
+ _assemblyFlashOn = true;
+ playInventorySound(_soundAssembly);
+ }
+ item->runQueue();
+ }
+}
+
+// CInventory::RemoveItem(std::string, int) (10AA34)
+void Inventory::removeItem(const Common::String &id, int count) {
+ InventoryItem *item = getItemByName(id);
+ if (item) {
+ item->addCounter(count);
+ item->checkCursorObj();
+ if (item->_counter <= 0)
+ removeVisibleItem(item);
+ }
+}
+
+// CInventory::RemoveItem(CInventoryItem *, int) (1081CC)
+void Inventory::removeItem(InventoryItem *item, int count) {
+ removeItem(item->_id, count);
+}
+
+// CInventory::RemoveAllItems (1099D6)
+void Inventory::removeAllItems() {
+ for (uint i = 0; i < _items.size(); i++) {
+ if (_items[i]->_counter > 0) {
+ _items[i]->setCounter(0);
+ _items[i]->checkCursorObj();
+ }
+ }
+ _visibleItems.clear();
+ setVisibleScroll();
+}
+
+// CInventory::IsItemInAccembly (10938C)
+bool Inventory::isItemInAssembly(const Common::String &id) const {
+ for (uint i = 0; i < _assemblies.size(); i++) {
+ if (id == _assemblies[i]->_id)
+ return true;
+ }
+ return false;
+}
+
+// CInventory::IsExistAccemblies (10998C)
+bool Inventory::isExistAssemblies() const {
+ for (uint i = 0; i < _visibleItems.size(); i++) {
+ if (_visibleItems[i]->isCombine())
+ return true;
+ }
+ return false;
+}
+
+// CInventory::IsExistGeneralAccemblies (10A324)
+bool Inventory::isExistGeneralAssemblies(InventoryItem *first, InventoryItem *second) const {
+ if (!first || !second)
+ return false;
+ if (first->_consists.empty())
+ return false;
+ for (uint i = 0; i < first->_consists.size(); i++) {
+ InventoryItem *item = getItemByName(first->_consists[i].first);
+ if (!item)
+ continue;
+ for (uint j = 0; j < item->getNumAssemblies(); j++) {
+ for (uint k = 0; k < second->getNumAssemblies(); k++) {
+ if (item->getAssembly(j) == second->getAssembly(k))
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+// CInventory::DisassembleItem (10A282)
+bool Inventory::disassembleItem(const Common::String &id) {
+ InventoryItem *item = getItemByName(id);
+ if (!item)
+ return false;
+ const Common::Array<Common::Pair<Common::String, int> > consists = item->_consists;
+ if (!consists.empty()) {
+ for (uint i = 0; i < consists.size(); i++)
+ addItem(consists[i].first, consists[i].second);
+ removeItem(item, -1);
+ }
+ return true;
+}
+
+// CInventory::CheckCombine (10A6C6)
+InventoryItem *Inventory::checkCombine(InventoryItem *first, InventoryItem *second, bool addResult) {
+ // the original does not test the pointers (an item that is not in the inventory crashes it)
+ if (!first || !second)
+ return nullptr;
+ if (first->getNumAssemblies() == 0 || second->getNumAssemblies() == 0 || first == second)
+ return nullptr;
+ InventoryItem *item = nullptr;
+ for (uint i = 0; i < first->getNumAssemblies(); i++) {
+ bool found = false;
+ for (uint j = 0; j < second->getNumAssemblies(); j++) {
+ if (first->getAssembly(i) == second->getAssembly(j)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ continue;
+ item = getItemByName(first->getAssembly(i));
+ if (item)
+ break;
+ }
+ if (!item)
+ return nullptr;
+ int firstNum = 0;
+ int secondNum = 0;
+ for (uint i = 0; i < item->_consists.size(); i++) {
+ if (item->_consists[i].first == first->_id)
+ firstNum = item->_consists[i].second;
+ if (item->_consists[i].first == second->_id)
+ secondNum = item->_consists[i].second;
+ }
+ if (first->_counter >= firstNum && second->_counter >= secondNum) {
+ removeItem(first->_id, -firstNum);
+ removeItem(second->_id, -secondNum);
+ if (addResult)
+ addItem(item, 1);
+ } else {
+ item = nullptr;
+ }
+ return item;
+}
+
+// CInventory::PutOnCursor(std::string) (109BC4)
+bool Inventory::putOnCursor(const Common::String &id) {
+ InventoryItem *item = getItemByName(id);
+ if (!item)
+ return false;
+ g_ngi->_inputController->setObject(item->_picture, item->_cursorOfsX, item->_cursorOfsY);
+ postMessageToScenes("INVENTORY_ITEM_IN_CURSOR", id);
+ return true;
+}
+
+// CInventory::PutOnCursor(uint) (109C54)
+bool Inventory::putOnCursor(uint pictureId) {
+ InventoryItem *item = getItem(pictureId);
+ if (!item)
+ return false;
+ g_ngi->_inputController->setObject(item->_picture, item->_cursorOfsX, item->_cursorOfsY);
+ postMessageToScenes("INVENTORY_ITEM_IN_CURSOR", item->_id);
+ return true;
+}
+
+// CInventory::PutOnCursor(float, float) (10AA80)
+bool Inventory::putOnCursor(float x, float y) {
+ if (_selectedItem) {
+ _selectedItem->tryPutOnCursor(x, y, false);
+ if (_selectedItem->_counter <= 0)
+ removeVisibleItem(_selectedItem);
+ playInventorySound(_soundClickItem);
+ _selectedItem = nullptr;
+ return true;
+ }
+ for (uint i = 0; i < _items.size(); i++) {
+ if (_items[i]->tryPutOnCursor(x, y, true)) {
+ if (_items[i]->_counter <= 0)
+ removeVisibleItem(_items[i]);
+ playInventorySound(_soundClickItem);
+ return true;
+ }
+ }
+ return false;
+}
+
+// CInventory::TakeFromCursor (10ACF4)
+bool Inventory::takeFromCursor(float x, float y) {
+ for (uint i = 0; i < _items.size(); i++) {
+ if (_items[i]->tryTakeFromCursor(x, y)) {
+ postMessageToScenes("INVENTORY_ITEM_FROM_CURSOR", _items[i]->_id);
+ addVisibleItem(_items[i]);
+ return true;
+ }
+ }
+ return false;
+}
+
+// CInventory::OnFirstAction (10AB2C)
+bool Inventory::onFirstAction(float x, float y) {
+ _selectedItem = getItemAtPos(x, y);
+ return putOnCursor(x, y);
+}
+
+// CInventory::OnSecondAction (10ADA0)
+bool Inventory::onSecondAction(float x, float y) {
+ _selectedItem = getItemAtPos(x, y);
+ CursorController *cursor = g_ngi->_inputController;
+ bool result = false;
+ bool done = false;
+ if (cursor->getObject() && _selectedItem && !_selectedItem->_autoCombine) {
+ InventoryItem *cursorItem = getItem(cursor->getObjectId());
+ if (!isExistGeneralAssemblies(_selectedItem, cursorItem)) {
+ InventoryItem *combined = checkCombine(_selectedItem, cursorItem, true);
+ if (combined) {
+ playInventorySound(_soundAssembly);
+ combined->runQueue();
+ } else {
+ playInventorySound(_soundAssemblyError);
+ }
+ } else {
+ result = disassembleItem(_selectedItem->_id);
+ if (result) {
+ InventoryItem *combined = nullptr;
+ const Common::Array<Common::Pair<Common::String, int> > consists = _selectedItem->_consists;
+ for (uint i = 0; i < consists.size() && !combined; i++)
+ combined = checkCombine(getItemByName(consists[i].first), cursorItem, true);
+ if (combined) {
+ playInventorySound(_soundAssembly);
+ combined->runQueue();
+ done = true;
+ } else {
+ playInventorySound(_soundAssemblyError);
+ }
+ }
+ }
+ }
+ if (done)
+ return result;
+ if (takeFromCursor(x, y))
+ playInventorySound(_soundUnclickItem);
+ return false;
+}
+
} // End of namespace NGI
diff --git a/engines/ngi/inventory.h b/engines/ngi/inventory.h
index d43e9b5e037..00516326928 100644
--- a/engines/ngi/inventory.h
+++ b/engines/ngi/inventory.h
@@ -22,10 +22,19 @@
#ifndef NGI_INVENTORY_H
#define NGI_INVENTORY_H
+#include "common/array.h"
+#include "common/str.h"
+
+#include "ngi/scene.h"
+#include "ngi/utils.h"
+#include "ngi/xmlnode.h"
+
namespace NGI {
class Scene;
class BigPicture;
+class BitmapFont;
+class MessageQueue;
struct InventoryPoolItem {
int16 id;
@@ -136,6 +145,190 @@ class Inventory2 : public InventoryData {
void removeAllItems();
};
+/** CInventoryItem: an item of the inventory bar (egg, coin, ...); pictures are in scene SC_INV */
+class InventoryItem : public CObject {
+public:
+ InventoryItem();
+ ~InventoryItem() override;
+
+ /** CInventoryItem::Init: colors and fonts come from the INVENTORY node (CInventory::Init) */
+ void init(const XmlNode &node, const BitmapFont *counterFont, const XmlColor &counterColor, const BitmapFont *textFont, const XmlColor &textColor,
+ float scaleSpeed, float maxScale, float minScale, bool autoCombine, const XmlVector2 &cursorOfs, PictureObject *itemPicture);
+ /** CInventoryItem::SetXmlData: "counter" and "presentDelay" */
+ void setXmlData(const XmlNode &node);
+ /** CInventoryItem::OnUpdate: the queue and the growing of the picture when an item is added */
+ void onUpdate(uint32 elapsed);
+
+ void setPos(int x, int y);
+ Common::Point getPos() const;
+ void setCenter(Common::Point center);
+ Common::Point getCenter() const;
+ /** CInventoryItem::GetSize: the size of the picture without the scale of the item */
+ void getSize(float &width, float &height) const;
+ bool hit(float x, float y) const;
+ int getCursorType(float x, float y) const;
+ void onMouseMove(uint32 id, float x, float y);
+ void setCounter(int counter);
+ void addCounter(int delta);
+ void setState(int state) { _state = state; }
+ void render(float scrollX, float scrollY, bool printCounter);
+ void renderName();
+ uint getNumAssemblies() const { return _isPartOf.size(); }
+ Common::String getAssembly(int index) const;
+ /** CInventoryItem::PushIsPart: the item is a part of the assembly `itemId` */
+ void pushIsPart(const Common::String &itemId);
+ /** CInventoryItem::CheckCombines: first assembly whose parts are all in the inventory */
+ InventoryItem *checkCombines(bool addResult, bool consume);
+ bool isCombine() const;
+ void checkCursorObj();
+ bool tryTakeFromCursor(float x, float y);
+ bool tryPutOnCursor(float x, float y, bool needHit);
+ bool runQueue();
+
+ Common::String _id; // +8: the XML id (ANI_INV_EGG)
+ float _offsetX = 0; // +12: where the picture of the item is inside the extra picture (pic_item)
+ float _offsetY = 0; // +16
+ PictureObject *_picture = nullptr; // +20: "vis"
+ PictureObject *_pictureSelected = nullptr; // +24: "visSel"
+ PictureObject *_picturePlate = nullptr; // +28: owned copy of "pic_item" of the INVENTORY node
+ /** +32: CONSISTS id -> num, the parts of an assembly (std::map: the keys are sorted) */
+ Common::Array<Common::Pair<Common::String, int> > _consists;
+ Common::Array<Common::String> _isPartOf; // +56
+ int _cursor = 1; // +68: "cursor"
+ float _cursorOfsX = 0; // +72
+ float _cursorOfsY = 0; // +76
+ int _counter = 0; // +80
+ const BitmapFont *_counterFont = nullptr; // +84
+ const BitmapFont *_textFont = nullptr; // +88: the font of the name under the cursor
+ MessageQueue *_queue = nullptr; // +92: "QUEUE" on add (STUB: XML node queues are not read)
+ bool _hovered = false; // +96
+ bool _clickable = true; // +97
+ int _scaleState = 0; // +100: 1 growing, 2 shrinking after the item was added
+ float _scaleX = 1.0f; // +104
+ float _scaleY = 1.0f; // +108
+ float _scaleSpeed = 0; // +112
+ float _maxScale = 1.0f; // +116
+ float _minScale = 1.0f; // +120
+ XmlColor _counterColor; // +124
+ XmlColor _textColor; // +140
+ bool _autoCombine = false; // +156
+ bool _addNext = true; // +157
+ int _state = 0; // +160: 1 draws the selected picture (CInventory::SetItemsState)
+ int _presentDelay = 0; // +164: grows while the item is in the inventory
+ bool _warnedFont = false;
+};
+
+/** CInventory: the inventory bar scene (id 0, inventory.xml); Windows games use Inventory2 */
+class Inventory : public Scene {
+public:
+ Inventory();
+ ~Inventory() override;
+
+ /** CInventory::Init: items, sounds and assembly pictures of the INVENTORY node */
+ void init();
+ /** CInventory::SetXmlData: the saved state of the items ("counter", "presentDelay") */
+ void setXmlData(const XmlNode &node);
+ /** CInventory::CleanXml */
+ void cleanXml();
+ /** CInventory::SaveXml (CGObject::SaveXml: the object saves itself to GetSavePath) */
+ void saveXml(bool flag);
+
+ InventoryItem *getItem(uint pictureId) const;
+ InventoryItem *getItemAtPos(float x, float y) const;
+ InventoryItem *getItemByName(const Common::String &id) const;
+
+ bool update(int elapsed) override;
+ void render(bool clear = true) override;
+ void renderBottom();
+ void renderTop();
+ void renderAssembly();
+ void onShow() override { Scene::onShow(); }
+ void onHide() override;
+ void onStartQueue();
+ void onStopQueue() { _queueRunning = false; }
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ bool onMouseRKeyDown(uint32 id, float x, float y) override;
+ bool onMouseRKeyUp(uint32 id, float x, float y) override;
+ bool onMouseMove(uint32 id, float x, float y) override;
+ /** CInventory::GetCursorType (the position is the one of the screen) */
+ int getCursorType(float x, float y);
+ /** CInventory::Hit */
+ bool hit(float x, float y);
+
+ // the list of the visible items and their positions
+ void recalcItemPos();
+ bool isExistVisibleItem(InventoryItem *item) const;
+ int getNumInvisibleItems(bool total) const;
+ void setScrollingPos(float position);
+ float getScrollingPos() const;
+ int getNumVisibleItems() const;
+ int getNumRealItems() const;
+ bool isVisibleItem(InventoryItem *item) const;
+ void setItemsState(int state);
+ void next();
+ void prev();
+ bool setItemVisible(InventoryItem *item, bool flag);
+ void setVisibleScroll();
+ bool addVisibleItem(InventoryItem *item);
+ bool removeVisibleItem(InventoryItem *item);
+ void renewVisibleItem(InventoryItem *item);
+
+ // the items
+ void addItem(const Common::String &id, int count);
+ void addItem(InventoryItem *item, int count);
+ void removeItem(const Common::String &id, int count);
+ void removeItem(InventoryItem *item, int count);
+ void removeAllItems();
+ bool isItemInAssembly(const Common::String &id) const;
+ bool isExistAssemblies() const;
+ bool isExistGeneralAssemblies(InventoryItem *first, InventoryItem *second) const;
+ bool disassembleItem(const Common::String &id);
+ InventoryItem *checkCombine(InventoryItem *first, InventoryItem *second, bool addResult);
+
+ // the items and the cursor
+ bool putOnCursor(const Common::String &id);
+ bool putOnCursor(uint pictureId);
+ bool putOnCursor(float x, float y);
+ bool takeFromCursor(float x, float y);
+ bool onFirstAction(float x, float y);
+ bool onSecondAction(float x, float y);
+
+ /** CInventory::PostMessageToScenes: the inventory and then the current scene get the message */
+ void postMessageToScenes(const Common::String &name, const Common::String ¶m);
+
+ float _areaX = 0; // +396
+ float _areaY = 0; // +400
+ float _areaWidth = 1024.0f; // +404
+ float _areaHeight = 100.0f; // +408
+ int _firstVisible = 0; // +412: the index of the first visible item that is shown
+ float _interval = 0; // +416
+ Common::Array<InventoryItem *> _items; // +420: all the items of inventory.xml, owned
+ Common::Array<InventoryItem *> _visibleItems; // +432: the items that are in the bar
+ int _assemblyShowTime = 0; // +444: "time_show"
+ int _assemblyTimer = 0; // +448
+ int _assemblyFlashTime = -1; // +452: -1 when no assembly is shown
+ int _assemblyFlashes = 0; // +456: "num_flash"
+ int _assemblyFlashCounter = 0; // +460
+ bool _assemblyFlashOn = false; // +464
+ bool _assemblyShown = false; // +465
+ Common::Array<InventoryItem *> _assemblies; // +468: assemblies found when an item was added
+ Common::Array<PictureObject *> _assemblyPictures; // +480: "pics" of ACCEMBLY per part count
+ int _soundAddItem = 0; // +492
+ int _soundAssembly = 0; // +496
+ int _soundClickItem = 0; // +500
+ int _soundUnclickItem = 0; // +504
+ int _soundAssemblyError = 0; // +508
+ InventoryItem *_selectedItem = nullptr; // +512: item under the cursor (OnFirst/SecondAction)
+ bool _autoCombine = false; // +516
+ bool _clearOnHide = true; // +517
+ int _mode = 0; // +520
+ /** CGObject +5: set while a queue of the scene runs */
+ bool _queueRunning = false;
+ /** CScene +76: the document of inventory.xml, owned; its first child is the INVENTORY node */
+ Common::ScopedPtr<XmlNode> _xmlDocument;
+};
+
} // End of namespace NGI
#endif /* NGI_INVENTORY_H */
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 0c787d48d69..3f94000cdad 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -29,6 +29,7 @@ MODULE_OBJS = \
statesaver.o \
statics.o \
utils.o \
+ xmlnode.o \
xmlproject.o \
zcontroller.o \
box2d/Collision/Shapes/b2ChainShape.o \
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 1c2ff92ba0b..b609aa5310e 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -85,6 +85,7 @@ class GameLoader;
class GameVar;
class CursorController;
class Inventory2;
+class Inventory;
struct Cursor;
struct Entrance;
class Command;
@@ -339,6 +340,8 @@ public:
Scene *_inventoryScene;
Inventory2 *_inventory2;
+ /** CGame +116: the Android inventory (scene 0 made by inventory.xml), 0 if create_inv is off */
+ Inventory *_inventory = nullptr;
int _currSelectedInventoryItemId;
int32 _updateTicks;
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 2a8b5f8fc3a..2483f0f05cf 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -687,6 +687,16 @@ PictureObject *Scene::findPictureObjectById(int objId, int flags) {
return nullptr;
}
+GameObject *Scene::findVisibleObject(int objectId, int copyId) {
+ if (PictureObject *picture = findPictureObjectById(objectId, copyId))
+ return picture;
+ for (Selection *selection : _selections) {
+ if (selection->_id == objectId && selection->_copyId == copyId)
+ return selection;
+ }
+ return findAniObjectById(objectId, copyId);
+}
+
PictureObject *Scene::getPictureObjectByName(const Common::String &objName, int flags) {
for (uint i = 0; i < _pictureObjects.size(); i++) {
if ((_pictureObjects[i]->_title == objName) && (_pictureObjects[i]->_copyId == flags || flags == -1))
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 6d5c52c9cc4..136d88c10a3 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -105,14 +105,14 @@ class Scene : public Background {
/** CScene +37 (SCENE putPrev): the scene is drawn over the one below it instead of replacing it */
bool _putPrev = false;
/** CScene::OnShow / OnHide: the parts that the controllers, the behaviors and the GUI need */
- void onShow();
- void onHide();
+ virtual void onShow();
+ virtual void onHide();
/** CScene::OnMouseLKeyDown ...: controller (Top), GUI, controller */
- bool onMouseLKeyDown(uint32 id, float x, float y);
- bool onMouseLKeyUp(uint32 id, float x, float y);
- bool onMouseRKeyDown(uint32 id, float x, float y);
- bool onMouseRKeyUp(uint32 id, float x, float y);
- bool onMouseMove(uint32 id, float x, float y);
+ virtual bool onMouseLKeyDown(uint32 id, float x, float y);
+ virtual bool onMouseLKeyUp(uint32 id, float x, float y);
+ virtual bool onMouseRKeyDown(uint32 id, float x, float y);
+ virtual bool onMouseRKeyUp(uint32 id, float x, float y);
+ virtual bool onMouseMove(uint32 id, float x, float y);
void onKeyUp(uint32 key);
/** CScene::Message: the controller gets the message by its name */
void message(const Common::String &name, const Common::String ¶m, MessageQueue *queue);
@@ -141,7 +141,7 @@ class Scene : public Background {
void initStaticANIObjects();
void init();
- void render(bool clear = true);
+ virtual void render(bool clear = true);
void renderMiddleLayer();
/** CScene::RenderDbg (nothing in the original calls it): outlines, enabled with --debugflags=bounds */
void renderDebug();
@@ -150,7 +150,7 @@ class Scene : public Background {
void updateScrolling2();
/** Returns true if the scene may need redrawing. */
- bool update(int counterdiff);
+ virtual bool update(int counterdiff);
AniObject *getAniMan();
AniObject *findAniObjectById(int obj, int a3);
@@ -166,6 +166,8 @@ class Scene : public Background {
void setPictureObjectsFlag4();
PictureObject *findPictureObjectById(int objId, int flags);
+ /** CScene::FindVisibleObject: a picture, selection or animation by id and copy id */
+ GameObject *findVisibleObject(int objectId, int copyId);
PictureObject *getPictureObjectByName(const Common::String &name, int keyCode);
void removePicture(PictureObject *obj);
void preloadMovements(GameVar *var);
@@ -180,7 +182,7 @@ class Scene : public Background {
void stopAllSounds();
- private:
+ protected:
template<typename T>
void sortRenderables(Common::Array<T*> &list, uint startIndex = 0);
};
diff --git a/engines/ngi/xmlnode.cpp b/engines/ngi/xmlnode.cpp
new file mode 100644
index 00000000000..0af3678cba7
--- /dev/null
+++ b/engines/ngi/xmlnode.cpp
@@ -0,0 +1,153 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/tokenizer.h"
+
+#include "ngi/xmlnode.h"
+
+namespace NGI {
+
+namespace {
+
+const XmlNode emptyNode;
+
+// PP_Split(string, 32): the numbers of the attribute, a missing one is 0 (CXmlNode::AttrVector2)
+Common::Array<Common::String> splitBySpace(const Common::String &text) {
+ Common::Array<Common::String> parts;
+ Common::StringTokenizer tokenizer(text, " ");
+ while (!tokenizer.empty())
+ parts.push_back(tokenizer.nextToken());
+ return parts;
+}
+
+float numberOf(const Common::Array<Common::String> &parts, uint index) {
+ return index < parts.size() ? strtof(parts[index].c_str(), nullptr) : 0.0f;
+}
+
+} // End of anonymous namespace
+
+XmlNode::~XmlNode() {
+ for (uint i = 0; i < _children.size(); i++)
+ delete _children[i];
+}
+
+const Common::String *XmlNode::findAttr(const char *name) const {
+ if (!_valid)
+ return nullptr;
+ for (uint i = 0; i < _attrNames.size(); i++) {
+ if (_attrNames[i] == name)
+ return &_attrValues[i];
+ }
+ return nullptr;
+}
+
+bool XmlNode::checkAttr(const char *name) const {
+ return findAttr(name) != nullptr;
+}
+
+bool XmlNode::checkChild(const char *name) const {
+ for (uint i = 0; i < _children.size(); i++) {
+ if (_children[i]->_name == name)
+ return true;
+ }
+ return false;
+}
+
+const XmlNode &XmlNode::child(const char *name) const {
+ for (uint i = 0; i < _children.size(); i++) {
+ if (_children[i]->_name == name)
+ return *_children[i];
+ }
+ return emptyNode;
+}
+
+const XmlNode &XmlNode::first() const {
+ return _children.empty() ? emptyNode : *_children[0];
+}
+
+const char *XmlNode::attrStr(const char *name, const char *defaultValue) const {
+ const Common::String *value = findAttr(name);
+ return value ? value->c_str() : defaultValue;
+}
+
+int XmlNode::attrInt(const char *name, int defaultValue) const {
+ const Common::String *value = findAttr(name);
+ return value ? atoi(value->c_str()) : defaultValue;
+}
+
+bool XmlNode::attrBool(const char *name, bool defaultValue) const {
+ const Common::String *value = findAttr(name);
+ if (!value)
+ return defaultValue;
+ // the first character: '1', 't' or 'T', 'y' or 'Y'
+ const char c = value->empty() ? 0 : value->firstChar();
+ return c == '1' || c == 't' || c == 'T' || c == 'y' || c == 'Y';
+}
+
+float XmlNode::attrFloat(const char *name, float defaultValue) const {
+ const Common::String *value = findAttr(name);
+ return value ? strtof(value->c_str(), nullptr) : defaultValue;
+}
+
+XmlVector2 XmlNode::attrVector2(const char *name, float defaultX, float defaultY) const {
+ XmlVector2 result;
+ const Common::String text = attrStr(name, "");
+ if (text.empty()) {
+ result.x = defaultX;
+ result.y = defaultY;
+ return result;
+ }
+ const Common::Array<Common::String> parts = splitBySpace(text);
+ result.x = numberOf(parts, 0);
+ result.y = numberOf(parts, 1);
+ return result;
+}
+
+XmlColor XmlNode::attrColor(const char *name, float defaultR, float defaultG, float defaultB, float defaultA) const {
+ XmlColor result;
+ const Common::String text = attrStr(name, "");
+ if (text.empty()) {
+ result.r = defaultR;
+ result.g = defaultG;
+ result.b = defaultB;
+ result.a = defaultA;
+ return result;
+ }
+ const Common::Array<Common::String> parts = splitBySpace(text);
+ result.r = numberOf(parts, 0);
+ result.g = numberOf(parts, 1);
+ result.b = numberOf(parts, 2);
+ result.a = numberOf(parts, 3);
+ return result;
+}
+
+XmlNode *XmlNode::append(const Common::String &name) {
+ XmlNode *node = new XmlNode(name);
+ _children.push_back(node);
+ return node;
+}
+
+void XmlNode::appendAttr(const Common::String &name, const Common::String &value) {
+ _attrNames.push_back(name);
+ _attrValues.push_back(value);
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/xmlnode.h b/engines/ngi/xmlnode.h
new file mode 100644
index 00000000000..e3f691e7893
--- /dev/null
+++ b/engines/ngi/xmlnode.h
@@ -0,0 +1,93 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_XMLNODE_H
+#define NGI_XMLNODE_H
+
+#include "common/array.h"
+#include "common/str.h"
+
+namespace NGI {
+
+struct XmlVector2 {
+ float x = 0;
+ float y = 0;
+};
+
+struct XmlColor {
+ float r = 1;
+ float g = 1;
+ float b = 1;
+ float a = 1;
+};
+
+/** CXmlNode (rapidxml node): original names and defaults (missing attribute: default) */
+class XmlNode {
+public:
+ XmlNode() {}
+ explicit XmlNode(const Common::String &name) : _name(name), _valid(true) {}
+ ~XmlNode();
+
+ /** CXmlNode::Empty: a node that was not found */
+ bool empty() const { return !_valid; }
+ /** CXmlNode::Name */
+ const Common::String &name() const { return _name; }
+ /** CXmlNode::CheckAttr */
+ bool checkAttr(const char *name) const;
+ /** CXmlNode::CheckChild */
+ bool checkChild(const char *name) const;
+ /** CXmlNode::Child and operator[] with a name: first child with the name, else an empty node */
+ const XmlNode &child(const char *name) const;
+ /** CXmlNode::operator[] with an index */
+ const XmlNode &operator[](uint index) const { return *_children[index]; }
+ const XmlNode &operator[](const char *name) const { return child(name); }
+ /** CXmlNode::ChildCount, AttrCount */
+ uint childCount() const { return _children.size(); }
+ uint attrCount() const { return _attrNames.size(); }
+ /** CXmlNode::First: the first child (an empty node when there is none) */
+ const XmlNode &first() const;
+
+ const char *attrStr(const char *name, const char *defaultValue) const;
+ int attrInt(const char *name, int defaultValue) const;
+ bool attrBool(const char *name, bool defaultValue) const;
+ float attrFloat(const char *name, float defaultValue) const;
+ /** CXmlNode::AttrVector2: "x y", the numbers are separated by one space, a missing one is 0 */
+ XmlVector2 attrVector2(const char *name, float defaultX, float defaultY) const;
+ /** CXmlNode::AttrColor: "r g b a" */
+ XmlColor attrColor(const char *name, float defaultR, float defaultG, float defaultB, float defaultA) const;
+
+ /** CXmlNode::Append / AppendAttr: for loaders that build the tree; the parent owns the node */
+ XmlNode *append(const Common::String &name);
+ void appendAttr(const Common::String &name, const Common::String &value);
+
+private:
+ Common::String _name;
+ bool _valid = false;
+ Common::Array<XmlNode *> _children;
+ Common::Array<Common::String> _attrNames;
+ Common::Array<Common::String> _attrValues;
+
+ const Common::String *findAttr(const char *name) const;
+};
+
+} // End of namespace NGI
+
+#endif // NGI_XMLNODE_H
Commit: 5a63e3db6f9a2ecd4e11b56ce80fb1b56d07cefb
https://github.com/scummvm/scummvm/commit/5a63e3db6f9a2ecd4e11b56ce80fb1b56d07cefb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Read the older XML font format of CFont (dlg.xml, dbg.xml)
Changed paths:
engines/ngi/font.cpp
diff --git a/engines/ngi/font.cpp b/engines/ngi/font.cpp
index cf4b1e26a8d..2a90aa76ae4 100644
--- a/engines/ngi/font.cpp
+++ b/engines/ngi/font.cpp
@@ -118,6 +118,19 @@ private:
CUSTOM_XML_PARSER(Loader) {
XML_KEY(font)
+ // older CFont::CFont format (dlg.xml, dbg.xml, root Font): one texture, glyphs by rectangles
+ XML_PROP(texture, false)
+ XML_PROP(width, false)
+ XML_PROP(height, false)
+ XML_KEY(Char)
+ XML_PROP(char, true)
+ XML_PROP(tu, false)
+ XML_PROP(tv, false)
+ XML_PROP(tw, false)
+ XML_PROP(th, false)
+ XML_PROP(a, false)
+ XML_PROP(c, false)
+ KEY_END()
XML_KEY(info)
XML_PROP(face, false)
XML_PROP(size, false)
@@ -178,7 +191,37 @@ private:
KEY_END()
} PARSER_END()
- bool parserCallback_font(ParserNode *) { return true; }
+ bool parserCallback_font(ParserNode *node) {
+ if (!node->values.contains("texture"))
+ return true;
+ Common::SharedPtr<Texture> page(new Texture());
+ page->loadPNG(_directory.join(node->values["texture"]), Dims());
+ if (page->getDimensions().x == 0)
+ return parserError("Missing bitmap font page");
+ _font._pages.push_back(page);
+ return true;
+ }
+
+ // CFont::CFont: glyph rect is (tu, tv, tw, th), no offset, advances by width; "a", "c" unused
+ bool parserCallback_Char(ParserNode *node) {
+ const int id = atoi(node->values["char"].c_str());
+ if (_font._glyphs.contains(id))
+ return true;
+ Glyph &g = _font._glyphs[id];
+ g.page = 0;
+ const int x = atoi(node->values.getValOrDefault("tu").c_str());
+ const int y = atoi(node->values.getValOrDefault("tv").c_str());
+ const int w = atoi(node->values.getValOrDefault("tw").c_str());
+ const int h = atoi(node->values.getValOrDefault("th").c_str());
+ const Dims size = _font._pages[0]->getDimensions();
+ if (x < 0 || y < 0 || w < 0 || h < 0 || x > size.x - w || y > size.y - h)
+ return parserError("Glyph outside bitmap font page");
+ g.source = Common::Rect(x, y, x + w, y + h);
+ g.advance = w;
+ _font._lineHeight = MAX(_font._lineHeight, h);
+ _font._maxWidth = MAX(_font._maxWidth, _font.getCharWidth(id));
+ return true;
+ }
bool parserCallback_pages(ParserNode *) { return true; }
bool parserCallback_chars(ParserNode *) { return true; }
bool parserCallback_kernings(ParserNode *) { return true; }
Commit: 264b0343f47c11ad59eaf50fa0d357e89424a8b5
https://github.com/scummvm/scummvm/commit/264b0343f47c11ad59eaf50fa0d357e89424a8b5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Use the Android CInventory scene, CursorController::Render and CInventoryController for the XML projects
Changed paths:
engines/ngi/fullpipe/arcadeinterface.cpp
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/inventorycontroller.cpp
engines/ngi/fullpipe/inventorycontroller.h
engines/ngi/fullpipe/lift.cpp
engines/ngi/fullpipe/scene01.cpp
engines/ngi/fullpipe/scene03.cpp
engines/ngi/fullpipe/scene09.cpp
engines/ngi/fullpipe/scene25.cpp
engines/ngi/fullpipe/scene26.cpp
engines/ngi/fullpipe/sceneFinal.cpp
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/testmode.cpp
engines/ngi/gameloader.cpp
engines/ngi/gfx.cpp
engines/ngi/input.cpp
engines/ngi/input.h
engines/ngi/interaction.cpp
engines/ngi/inventory.cpp
engines/ngi/messagehandlers.cpp
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/objects.h
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/arcadeinterface.cpp b/engines/ngi/fullpipe/arcadeinterface.cpp
index 2d93b408fe9..ea6d7128ea3 100644
--- a/engines/ngi/fullpipe/arcadeinterface.cpp
+++ b/engines/ngi/fullpipe/arcadeinterface.cpp
@@ -32,6 +32,7 @@
#include "ngi/sound.h"
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/inventorycontroller.h"
namespace NGI {
@@ -95,7 +96,7 @@ ArcadeInterface::ArcadeInterface() {
}
GuiElement *ArcadeInterface::getElement(const char *id) const {
- Scene *scene = getGameLoaderInventory() ? getGameLoaderInventory()->getScene() : nullptr;
+ Scene *scene = g_ngi->_inventory;
return scene && scene->_guiManager ? scene->_guiManager->getElement(id) : nullptr;
}
@@ -204,7 +205,8 @@ void ArcadeInterface::update(uint32 elapsed) {
void ArcadeInterface::scrollIn() {
if (_state != kShown) {
_state = kScrollingIn;
- getGameLoaderInventory()->scrollOut();
+ // CArcadeInterface::ScrollIn: CInventoryController::ScrollOut takes the bar out of the screen
+ static_cast<InventoryController *>(g_ngi->_inventory->_controller.get())->scrollOut();
}
_arcadeSceneId = g_ngi->_currentScene->_sceneId;
@@ -249,7 +251,7 @@ void ArcadeInterface::scrollIn() {
void ArcadeInterface::scrollOut() {
if (_state != kHidden) {
_state = kScrollingOut;
- getGameLoaderInventory()->scrollIn();
+ static_cast<InventoryController *>(g_ngi->_inventory->_controller.get())->scrollIn();
GuiElement *hidden[] = { _skipButton, _skipProgress, _skipBackground, _skipHighlight };
for (GuiElement *element : hidden) {
if (element)
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index dfc571efc00..2eccf6389b0 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -46,12 +46,12 @@ namespace NGI {
// CInventoryController, inventory.xml
void sceneController_initInventory() {
- g_ngi->_inventoryScene = g_ngi->findScene(SC_INV);
- if (g_ngi->_inventoryScene) {
- if (!g_ngi->_inventoryScene->_controller)
- createSceneController(SC_INV); // CInventoryController
- g_ngi->_inventoryScene->_controller->onShow();
- getGameLoaderInventory()->recalcItemPos();
+ g_ngi->_inventoryScene = g_ngi->_inventory;
+ if (g_ngi->_inventory) {
+ if (!g_ngi->_inventory->_controller)
+ createSceneController(0); // CInventoryController
+ g_ngi->_inventory->_controller->onShow();
+ g_ngi->_inventory->recalcItemPos();
}
}
@@ -858,7 +858,8 @@ bool FPController::onTap(float tapX, float tapY) {
uint32 upperPipe;
if (g_ngi->_gameProject->_objectIds.findId("PIC_SC1_UTRUBA", upperPipe) && upperPipe == (uint16)target->_id)
target = scene.findPictureObjectById(PIC_SC1_LADDER, 0);
- const int item = getGameLoaderInventory()->getCursorPictureId();
+ const int item = g_ngi->_inputController->getObjectId();
+ debugC(2, kDebugSceneLogic, "FPController::onTap: target %d item %d can interact %d", target ? target->_id : 0, item, target ? canInteractAny(hero, target, item) : 0);
if (target && canInteractAny(hero, target, item)) {
if (target->_objtype == kObjTypePictureObject && g_ngi->getGameLoaderGameVar()->getSubVarAsInt("Scene1ExitsDisabled"))
return false;
diff --git a/engines/ngi/fullpipe/inventorycontroller.cpp b/engines/ngi/fullpipe/inventorycontroller.cpp
index 4106e38faaa..8963006b606 100644
--- a/engines/ngi/fullpipe/inventorycontroller.cpp
+++ b/engines/ngi/fullpipe/inventorycontroller.cpp
@@ -26,7 +26,10 @@
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/inventorycontroller.h"
#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/gfx.h"
#include "ngi/guimanager.h"
+#include "ngi/input.h"
+#include "ngi/inventory.h"
#include "ngi/scene.h"
namespace NGI {
@@ -43,9 +46,150 @@ void warnOnce(const char *what) {
} // End of anonymous namespace
+// CInventoryController::CInventoryController
InventoryController::InventoryController(int sceneId) : ISceneController(sceneId) {
}
+// CInventoryController::SetXmlData (199B9C) and CleanXml (199B90)
+void InventoryController::setXmlData(const XmlNode &node) {
+ _stateHintMap = node.attrInt("stateHintMap", 0);
+ _stateHintNotebook = node.attrInt("stateHintNotebook", 0);
+}
+
+void InventoryController::cleanXml() {
+ _stateHintMap = 0;
+ _stateHintNotebook = 0;
+}
+
+// CInventoryController::UpdateTaskButtons (19A664): add (once) or remove the button; they slide in
+void InventoryController::updateTaskButtons(GuiElement *button, bool add) {
+ _showTaskButtons = true;
+ if (add) {
+ for (uint i = 0; i < _taskButtons.size(); i++) {
+ if (_taskButtons[i] == button)
+ return;
+ }
+ _taskButtons.push_back(button);
+ } else {
+ for (uint i = 0; i < _taskButtons.size(); i++) {
+ if (_taskButtons[i] == button) {
+ _taskButtons.remove_at(i);
+ return;
+ }
+ }
+ }
+}
+
+// CInventoryController::Hit (199EA4)
+bool InventoryController::hit(uint32 x, uint32 y) {
+ if ((float)y >= 60.0f)
+ return false;
+ return g_ngi->arcadeInterface().getState() == ArcadeInterface::kShown;
+}
+
+// CInventoryController::OnRenderBottom (199DA0): a transparent black band behind the bar
+void InventoryController::onRenderBottom(Common::Point scroll) {
+ // the band starts at -scroll - margin (CRender +24, +28) and is as wide as the screen
+ const int left = -scroll.x;
+ const int top = -scroll.y;
+ const int x1 = MAX(0, left);
+ const int y1 = MAX(0, top);
+ const int x2 = MIN<int>(g_ngi->_backgroundSurface.w, left + g_ngi->gameWidth() + 2 * g_ngi->_wideOfs);
+ const int y2 = MIN<int>(g_ngi->_backgroundSurface.h, top + 60);
+ if (x1 < x2 && y1 < y2)
+ g_ngi->drawAlphaRectangle(x1, y1, x2, y2, 178); // CRender::DrawQuad with the color (0, 0, 0, 0.3)
+}
+
+// CInventoryController::OnRenderTop (199E48)
+void InventoryController::onRenderTop(Common::Point scroll) {
+ if (g_ngi->getCurrentScene()->_sceneId == SC_TUTORIAL)
+ warnOnce("CTutorialController::OnRenderAfterInventory: the tutorial scene is not ported");
+ if (!_helperPicture)
+ _helperPicture = _scene->findPictureObjectById(11028, 0);
+ if (_helperVisible)
+ _helperPicture->render(Common::Point());
+}
+
+// CInventoryController::OnUpdate (199ECC). Not ported: the tutorials started from the hints
+// (CTutorialManager::ActivateTutorial); nothing adds task buttons yet, the sliding is ported
+void InventoryController::onUpdate(uint32 elapsed) {
+ Inventory *inventory = g_ngi->_inventory;
+ if (inventory->getItemByName("ANI_INV_COIN")->_counter > 0 && _stateHintNotebook == 0)
+ _stateHintNotebook = 1;
+ Scene *firstScene = g_ngi->getSceneInStack(0);
+ if (firstScene->_sceneId == 305) {
+ warnOnce("CScene::IsQueuesProcessed: the hint of the map in the scene 305 is not started");
+ }
+ if (_stateHintMap == 1)
+ warnOnce("CTutorialManager::ActivateTutorial ADDITIONAL_TUTORIAL_MAP is not ported");
+ else if (_stateHintNotebook == 1)
+ warnOnce("CTutorialManager::ActivateTutorial ADDITIONAL_TUTORIAL_NOTEBOOK is not ported");
+
+ g_ngi->arcadeInterface().update(elapsed);
+
+ // the bar leaves (1) and comes back (2): the scene scroll changes by 1.5 per update
+ if (_scrollState != 0 && _scrollState != 3) {
+ if (_scrollState == 1) {
+ _scrollY += 1.5f;
+ if (_scrollY >= 100.0f) {
+ _scrollY = 100.0f;
+ _scrollState = 3;
+ }
+ } else if (_scrollState == 2) {
+ _scrollY -= 1.5f;
+ if (_scrollY <= 0.0f) {
+ _scrollY = 0.0f;
+ _scrollState = 0;
+ }
+ }
+ _scene->_y = (int)_scrollY;
+ }
+
+ if (_showTaskButtons && !_taskButtons.empty()) {
+ // the buttons slide in from the right (0.1 pixel per millisecond) to their places under the bar
+ const float step = (float)elapsed * 0.1f;
+ for (uint i = 0; i < _taskButtons.size(); i++) {
+ const Common::Point pos = _taskButtons[i]->_pos;
+ const Common::Point size = _taskButtons[i]->_size;
+ float x = MAX(800.0f - (size.x + 10.0f), pos.x - step);
+ float y = MAX((float)i * (size.y + 5.0f) + 150.0f, pos.y - step);
+ _taskButtons[i]->setPos(Common::Point((int)x, (int)y));
+ }
+ bool arrived = true;
+ for (uint i = 0; i < _taskButtons.size(); i++) {
+ const Common::Point pos = _taskButtons[i]->_pos;
+ const Common::Point size = _taskButtons[i]->_size;
+ if (pos.x == (int)(800.0f - (size.x + 10.0f)))
+ arrived = arrived && pos.y == (int)((float)i * (size.y + 5.0f) + 150.0f);
+ else
+ arrived = false;
+ }
+ if (arrived)
+ _showTaskButtons = false;
+ }
+ if (_hideTaskButtons && !_taskButtons.empty()) {
+ // and out to the right again (0.05 pixel per millisecond)
+ const float step = (float)elapsed * 0.05f;
+ for (uint i = 0; i < _taskButtons.size(); i++) {
+ const Common::Point pos = _taskButtons[i]->_pos;
+ const Common::Point size = _taskButtons[i]->_size;
+ float x = MIN((size.x + 10.0f) + 800.0f, pos.x + step);
+ _taskButtons[i]->setPos(Common::Point((int)x, pos.y));
+ }
+ bool gone = true;
+ for (uint i = 0; i < _taskButtons.size(); i++) {
+ const Common::Point pos = _taskButtons[i]->_pos;
+ const Common::Point size = _taskButtons[i]->_size;
+ if (pos.x == (int)((size.x + 10.0f) + 800.0f))
+ gone = gone && pos.y == (int)((float)i * (size.y + 5.0f) + 150.0f);
+ else
+ gone = false;
+ }
+ if (gone)
+ _hideTaskButtons = false;
+ }
+}
+
// CInventoryController::OnShow: the buttons of the map, the menu and the notebook are 60 x 80
void InventoryController::onShow() {
static const char *const buttons[] = { "PIC_INV_MAP", "PIC_INV_ESC", "PIC_INV_TASK", "PIC_INV_TASK_PRESSED" };
diff --git a/engines/ngi/fullpipe/inventorycontroller.h b/engines/ngi/fullpipe/inventorycontroller.h
index a8ee7ca0d4e..330e0e7cc8e 100644
--- a/engines/ngi/fullpipe/inventorycontroller.h
+++ b/engines/ngi/fullpipe/inventorycontroller.h
@@ -22,14 +22,21 @@
#ifndef NGI_FULLPIPE_INVENTORYCONTROLLER_H
#define NGI_FULLPIPE_INVENTORYCONTROLLER_H
+#include "common/array.h"
+
#include "ngi/scenecontroller.h"
namespace NGI {
+class GuiElement;
+class PictureObject;
+class XmlNode;
+
/**
- * Android: CInventoryController (ISceneController), the controller of the inventory scene (SC_INV): the bar over the game scenes with the items and
- * the buttons of the map, the menu, the notebook and the skip buttons. Ported so far: OnShow and OnGuiEvent. The scroll animation of the bar
- * (OnUpdate, ScrollIn, ScrollOut, UpdateTaskButtons), OnRenderBottom/Top and the hit test are still done by the Inventory class and the engine loop.
+ * Android: CInventoryController (ISceneController), the controller of the inventory scene (the scene 0, CInventory): the bar over the game scenes with
+ * the items and the buttons of the map, the menu, the notebook and the skip buttons. It scrolls the bar out of the screen for an arcade (ScrollOut,
+ * ScrollIn, OnUpdate), darkens the bar (OnRenderBottom) and keeps the buttons of the tasks. The comments give the offsets of the fields in the original.
+ * Not ported: the tutorials that OnUpdate starts (CTutorialManager::ActivateTutorial), the tutorial scene in OnRenderTop and the hint helper.
*/
class InventoryController : public ISceneController {
public:
@@ -37,6 +44,33 @@ public:
void onShow() override;
void onGuiEvent(const Common::String &id, const Common::String &event) override;
+ void onUpdate(uint32 elapsed) override;
+ void onRenderBottom(Common::Point scroll) override;
+ void onRenderTop(Common::Point scroll) override;
+ /** CInventoryController::Hit: the bar is hit above its lower edge while the arcade shows */
+ bool hit(uint32 x, uint32 y) override;
+ /** CInventoryController::SetXmlData and CleanXml: the saved state of the hints */
+ void setXmlData(const XmlNode &node);
+ void cleanXml();
+
+ /** CInventoryController::ScrollIn / ScrollOut: the bar comes back / leaves the screen */
+ void scrollIn() { _scrollState = 2; }
+ void scrollOut() { _scrollState = 1; }
+ /** HideTaskButtons, RemoveTaskButtons, UpdateTaskButtons: slide out right, forget, add/remove */
+ void hideTaskButtons() { _hideTaskButtons = true; }
+ void removeTaskButtons() { _taskButtons.clear(); }
+ void updateTaskButtons(GuiElement *button, bool add);
+
+private:
+ bool _helperVisible = false; // +12: the hint helper picture is drawn
+ int _scrollState = 0; // +16: 0 on the screen, 1 leaving, 2 coming back, 3 out of the screen
+ bool _showTaskButtons = false; // +20: the task buttons slide in
+ bool _hideTaskButtons = false; // +21: the task buttons slide out
+ Common::Array<GuiElement *> _taskButtons; // +24
+ int _stateHintMap = 0; // +36
+ int _stateHintNotebook = 0; // +40
+ PictureObject *_helperPicture = nullptr; // +44
+ float _scrollY = 0; // scene scroll (CScene +44) as float
};
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/lift.cpp b/engines/ngi/fullpipe/lift.cpp
index 50ee86a62ff..e975b65c64d 100644
--- a/engines/ngi/fullpipe/lift.cpp
+++ b/engines/ngi/fullpipe/lift.cpp
@@ -828,7 +828,7 @@ bool Lift::onButtonUp(GameObject *) {
// CLift::SwitchToBigView: the cursor item goes back (CInventory::TakeFromCursor), SC_LIFT is pushed
void Lift::switchToBigView() {
- getGameLoaderInventory()->unselectItem(false);
+ g_ngi->_inventory->takeFromCursor(g_ngi->_inputController->_hotSceneX, g_ngi->_inputController->_hotSceneY);
g_ngi->pushScene(SC_LIFT);
Common::Array<AniObject *> buttons;
diff --git a/engines/ngi/fullpipe/scene01.cpp b/engines/ngi/fullpipe/scene01.cpp
index 750aabe198a..24763e2d13e 100644
--- a/engines/ngi/fullpipe/scene01.cpp
+++ b/engines/ngi/fullpipe/scene01.cpp
@@ -126,11 +126,9 @@ int sceneHandler01(Command *cmd) {
return 0;
}
if (cmd->_messageName == "MSG_DEACT_OBJ_SC1") {
- Inventory2 *inventory = getGameLoaderInventory();
- uint32 blackEgg, coinEgg;
- const ObjectIdList &ids = g_ngi->_gameProject->_objectIds;
- if (ids.findId("ANI_INV_EGGBLACK", blackEgg) && ids.findId("ANI_INV_EGGCOIN", coinEgg) &&
- !inventory->getCountItemsWithId(blackEgg) && !inventory->getCountItemsWithId(coinEgg))
+ const InventoryItem *blackEgg = g_ngi->_inventory->getItemByName("ANI_INV_EGGBLACK");
+ const InventoryItem *coinEgg = g_ngi->_inventory->getItemByName("ANI_INV_EGGCOIN");
+ if (blackEgg && coinEgg && !blackEgg->_counter && !coinEgg->_counter)
g_ngi->_taskManager->deactivateTask("GET_OBJECT_SC1");
return 0;
}
diff --git a/engines/ngi/fullpipe/scene03.cpp b/engines/ngi/fullpipe/scene03.cpp
index a548e9c99a2..295c40b630a 100644
--- a/engines/ngi/fullpipe/scene03.cpp
+++ b/engines/ngi/fullpipe/scene03.cpp
@@ -225,7 +225,10 @@ void sceneHandler03_giveCoin(Command *ex) {
ex0->_cmd = kCmdStartMovement;
ex1->_cmd = kCmdStartMovement;
- getGameLoaderInventory()->removeItem(ANI_INV_COIN, 1);
+ if (g_ngi->usesXMLProject())
+ g_ngi->_inventory->removeItem("ANI_INV_COIN", -1);
+ else
+ getGameLoaderInventory()->removeItem(ANI_INV_COIN, 1);
} else {
ex0->_cmd = kCmdNone;
ex0->_excFlags |= 1;
diff --git a/engines/ngi/fullpipe/scene09.cpp b/engines/ngi/fullpipe/scene09.cpp
index 7b130f414e9..48b57f56f68 100644
--- a/engines/ngi/fullpipe/scene09.cpp
+++ b/engines/ngi/fullpipe/scene09.cpp
@@ -43,7 +43,7 @@ struct Hanger {
void scene09_setupGrit(Scene *sc) {
if (g_vars->scene09_grit->_statics->_staticsId == ST_GRT9_GRIT) {
- if (!getGameLoaderInventory()->getCountItemsWithId(ANI_INV_COIN)) {
+ if (!(g_ngi->usesXMLProject() ? g_ngi->_inventory->getItemByName("ANI_INV_COIN")->_counter : getGameLoaderInventory()->getCountItemsWithId(ANI_INV_COIN))) {
if (g_ngi->getStateId(sO_CoinSlot_1) == g_ngi->getStateValue(sO_CoinSlot_1, sO_Empty)
&& (g_vars->swallowedEgg1->_value.intValue == ANI_INV_EGGBOOT || g_vars->swallowedEgg2->_value.intValue == ANI_INV_EGGBOOT || g_vars->swallowedEgg3->_value.intValue == ANI_INV_EGGBOOT)) {
Scene *oldsc = g_ngi->_currentScene;
diff --git a/engines/ngi/fullpipe/scene25.cpp b/engines/ngi/fullpipe/scene25.cpp
index 0eba3b35e82..7682b052fec 100644
--- a/engines/ngi/fullpipe/scene25.cpp
+++ b/engines/ngi/fullpipe/scene25.cpp
@@ -79,7 +79,10 @@ void scene25_initScene(Scene *sc, int entranceId) {
}
} else {
if (boardState == g_ngi->getStateValue(sO_Board_25, sO_WithDudeOnLeft)) {
- if (!getGameLoaderInventory()->getCountItemsWithId(ANI_INV_BOARD)) {
+ if (g_ngi->usesXMLProject()) {
+ if (!g_ngi->_inventory->getItemByName("ANI_INV_BOARD")->_counter)
+ g_ngi->_inventory->addItem("ANI_INV_BOARD", 1);
+ } else if (!getGameLoaderInventory()->getCountItemsWithId(ANI_INV_BOARD)) {
getGameLoaderInventory()->addItem(ANI_INV_BOARD, 1);
getGameLoaderInventory()->recalcItemPos();
}
diff --git a/engines/ngi/fullpipe/scene26.cpp b/engines/ngi/fullpipe/scene26.cpp
index 689be4b9df0..b96c864ee6e 100644
--- a/engines/ngi/fullpipe/scene26.cpp
+++ b/engines/ngi/fullpipe/scene26.cpp
@@ -48,7 +48,7 @@ void scene26_initScene(Scene *sc) {
Interact *inter = getGameLoaderInteractionController()->findInteraction(ANI_LUK26, ANI_MAN, ANI_INV_SOCK);
- if (getGameLoaderInventory()->getCountItemsWithId(ANI_INV_VENT) == 0)
+ if ((g_ngi->usesXMLProject() ? g_ngi->_inventory->getItemByName("ANI_INV_VENT")->_counter : getGameLoaderInventory()->getCountItemsWithId(ANI_INV_VENT)) == 0)
inter->_flags &= 0xFFFDFFFF;
else
inter->_flags |= 0x20000;
diff --git a/engines/ngi/fullpipe/sceneFinal.cpp b/engines/ngi/fullpipe/sceneFinal.cpp
index da6aeb08237..dfe257b624c 100644
--- a/engines/ngi/fullpipe/sceneFinal.cpp
+++ b/engines/ngi/fullpipe/sceneFinal.cpp
@@ -46,8 +46,12 @@ void sceneFinal_initScene() {
g_ngi->_gameLoader->loadScene(SC_FINAL4);
g_ngi->findScene(SC_FINAL4)->setPictureObjectsFlag4();
- getGameLoaderInventory()->setIsLocked(false);
- getGameLoaderInventory()->slideIn();
+ if (g_ngi->usesXMLProject()) {
+ warning("STUB/untested: the inventory is not slid in for the final scenes (CInventory has no slide)");
+ } else {
+ getGameLoaderInventory()->setIsLocked(false);
+ getGameLoaderInventory()->slideIn();
+ }
g_ngi->_updateFlag = false;
g_ngi->_flgCanOpenMap = false;
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index 50060f21298..d1776ef20fd 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -470,7 +470,7 @@ void createSceneController(int sceneId) {
case SC_LIFT:
new LiftController(sceneId);
break;
- case SC_INV:
+ case 0: // the inventory scene (CGame +116)
new InventoryController(sceneId);
break;
default:
diff --git a/engines/ngi/fullpipe/testmode.cpp b/engines/ngi/fullpipe/testmode.cpp
index 5258d708272..4b34a582fe4 100644
--- a/engines/ngi/fullpipe/testmode.cpp
+++ b/engines/ngi/fullpipe/testmode.cpp
@@ -201,9 +201,13 @@ void testmode_update(uint32 elapsed) {
if (spot->sceneId == SC_4)
g_ngi->setState(SC4_DEMO_SCROLL_STATE, g_ngi->getStateValue(SC4_DEMO_SCROLL_STATE, SC4_DEMO_SCROLL_DONE));
if (spot->item) {
- Inventory2 *inventory = getGameLoaderInventory();
- inventory->addItem(spot->item, 1);
- inventory->recalcItemPos();
+ if (g_ngi->usesXMLProject()) {
+ g_ngi->_inventory->addItem(g_ngi->_gameProject->_objectIds.findName(spot->item), 1);
+ } else {
+ Inventory2 *inventory = getGameLoaderInventory();
+ inventory->addItem(spot->item, 1);
+ inventory->recalcItemPos();
+ }
}
}
g_spot = 0;
diff --git a/engines/ngi/gameloader.cpp b/engines/ngi/gameloader.cpp
index cc196025449..f51386faa79 100644
--- a/engines/ngi/gameloader.cpp
+++ b/engines/ngi/gameloader.cpp
@@ -584,8 +584,12 @@ PicAniInfoList GameLoader::savePicAniInfos(Scene *sc, int flag1, int flag2) {
bool GameLoader::updateContent(int counterdiff) {
if (g_ngi->_currentScene) {
bool changed = g_ngi->_currentScene->update(counterdiff);
- if (g_ngi->_gameVersion >= 201509)
+ if (g_ngi->_gameVersion >= 201509) {
+ // CGame::UpdateContent: the inventory is updated when it is enabled
+ if (g_ngi->isInventoryEnabled())
+ changed |= g_ngi->_inventory->update(counterdiff);
return changed;
+ }
_exCommand._cmd = kCmdMessage;
_updateCounter++;
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index 670b712976e..d94ad207f08 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -617,6 +617,24 @@ void Texture::blitTo(Graphics::ManagedSurface &target, const Common::Point &posi
return;
}
+ if (params.rotation == 0.0f && part.format.bytesPerPixel > 1) {
+ // only the scale: the quad is the size of the window times the scale, from the top left corner
+ const int width = MAX(1, static_cast<int>(part.w * params.scaleX));
+ const int height = MAX(1, static_cast<int>(part.h * params.scaleY));
+ Common::ScopedPtr<Graphics::Surface> scaledPart(part.rawSurface().scale(width, height, true));
+ if (!scaledPart)
+ return;
+ Graphics::ManagedSurface result(width, height, part.format);
+ if (part.hasTransparentColor())
+ result.setTransparentColor(part.getTransparentColor());
+ result.copyFrom(*scaledPart);
+ if (params.mirror)
+ target.simpleBlitFrom(result, origin, Graphics::FLIP_H, true);
+ else
+ target.blitFrom(result, origin);
+ return;
+ }
+
Graphics::TransformStruct transform(static_cast<int32>(params.scaleX * 100.0f), static_cast<int32>(params.scaleY * 100.0f),
static_cast<uint32>(static_cast<int32>(Math::rad2deg(params.rotation))), part.w / 2, part.h / 2);
if (params.mirror)
diff --git a/engines/ngi/input.cpp b/engines/ngi/input.cpp
index c3868d362bb..b2e2ee4b5b2 100644
--- a/engines/ngi/input.cpp
+++ b/engines/ngi/input.cpp
@@ -89,6 +89,16 @@ void CursorController::setCursorMode(bool enabled) {
_inputFlags &= ~1;
}
+// CCursorController::Render (F5330)
+void CursorController::render() {
+ if (_object && _objectVisible) {
+ if (_object->_objtype == kObjTypePictureObject)
+ static_cast<PictureObject *>(_object)->renderAtPos(_screenX + _objectOffsetX, _screenY + _objectOffsetY);
+ else
+ warning("STUB/untested: CCursorController::Render of an object that is not a picture");
+ }
+}
+
void CursorController::render(int x, int y) {
if (_cursorIndex == -1)
return;
diff --git a/engines/ngi/input.h b/engines/ngi/input.h
index 14d52d927fe..fa38c93c343 100644
--- a/engines/ngi/input.h
+++ b/engines/ngi/input.h
@@ -68,6 +68,7 @@ public:
float _hotScreenY = 0; // +68
float _hotSceneX = 0; // +72: the scene position of the hot spot: where the hit tests are made
float _hotSceneY = 0; // +76
+ bool _objectVisible = true; // +84: the object is drawn
GameObject *_object = nullptr; // +88: the object that the cursor holds (an inventory item)
float _objectOffsetX = 0; // +92
float _objectOffsetY = 0; // +96
@@ -86,6 +87,8 @@ public:
void setCursorMode(bool mode);
void render(int x, int y);
+ /** CCursorController::Render: draws the held object (no pointer images, no cursor text) */
+ void render();
void setCursor(int id);
void setObject(Texture *pic) { _cursorItemPicture = pic; }
diff --git a/engines/ngi/interaction.cpp b/engines/ngi/interaction.cpp
index 9d00f17b6ff..77c905b65c7 100644
--- a/engines/ngi/interaction.cpp
+++ b/engines/ngi/interaction.cpp
@@ -20,6 +20,7 @@
*/
#include "ngi/ngi.h"
+#include "ngi/input.h"
#include "ngi/interaction.h"
#include "ngi/gameloader.h"
@@ -46,7 +47,7 @@ bool canInteractAny(GameObject *obj1, GameObject *obj2, int invId) {
break;
if (invId == -3) {
- invId = getGameLoaderInventory()->getSelectedItemId();
+ invId = g_ngi->usesXMLProject() ? g_ngi->_inputController->getObjectId() : getGameLoaderInventory()->getSelectedItemId();
}
if (intr->canRun(obj1, obj2, invId))
return true;
diff --git a/engines/ngi/inventory.cpp b/engines/ngi/inventory.cpp
index c73bf2f9a0f..84fb72fb948 100644
--- a/engines/ngi/inventory.cpp
+++ b/engines/ngi/inventory.cpp
@@ -1162,7 +1162,13 @@ bool Inventory::update(int elapsed) {
}
for (uint i = _firstVisible; i < _items.size(); i++)
_items[i]->onUpdate(elapsed);
- return Scene::update(elapsed);
+ // CScene::Update: the controller after the objects and the queues
+ if (_controller)
+ _controller->onUpdate(elapsed);
+ const bool changed = updateObjects(elapsed);
+ if (_controller)
+ _controller->onUpdateTop(elapsed);
+ return changed;
}
// CInventory::RenderBottom (108EA4)
@@ -1365,6 +1371,11 @@ bool Inventory::hit(float x, float y) {
const float sceneX = x + _x;
const float sceneY = y + _y;
for (uint i = 0; i < _visibleItems.size(); i++) {
+ const Common::Point pos = _visibleItems[i]->getPos();
+ float width;
+ float height;
+ _visibleItems[i]->getSize(width, height);
+ debugC(3, kDebugEvents, "inventory: item %s at %d,%d size %g x %g, point %g,%g", _visibleItems[i]->_id.c_str(), pos.x, pos.y, width, height, sceneX, sceneY);
if (_visibleItems[i]->hit(sceneX, sceneY))
return true;
}
diff --git a/engines/ngi/messagehandlers.cpp b/engines/ngi/messagehandlers.cpp
index 1f57f464e72..2a59be79645 100644
--- a/engines/ngi/messagehandlers.cpp
+++ b/engines/ngi/messagehandlers.cpp
@@ -765,11 +765,16 @@ int global_messageHandler4(Command *cmd) {
case kCmdRemoveInvItem:
if (!g_ngi->usesXMLProject())
return 0;
- if (cmd->_cmd == kCmdAddInvItem)
- getGameLoaderInventory()->addItem(cmd->_parentId, 1);
- else if (getGameLoaderInventory()->getCountItemsWithId(cmd->_parentId))
- getGameLoaderInventory()->removeItem(cmd->_parentId, 1);
- getGameLoaderInventory()->recalcItemPos();
+ {
+ // the command holds the item id (ANI_INV_*), the original has its name (CInventory::AddItem)
+ const Common::String itemId = g_ngi->_gameProject->_objectIds.findName(cmd->_parentId);
+ if (cmd->_cmd == kCmdAddInvItem)
+ g_ngi->_inventory->addItem(itemId, 1);
+ else if (InventoryItem *item = g_ngi->_inventory->getItemByName(itemId)) {
+ if (item->_counter)
+ g_ngi->_inventory->removeItem(itemId, -1);
+ }
+ }
break;
case kCmdUser:
if (g_ngi->_gameVersion < 201509)
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 085834e5f2e..33d17418be8 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -216,9 +216,14 @@ void NGIEngine::restartGame() {
_gameLoader->restoreDefPicAniInfos();
- getGameLoaderInventory()->removeAllItems();
- getGameLoaderInventory()->addItem(ANI_INV_MAP, 1);
- getGameLoaderInventory()->recalcItemPos();
+ if (usesXMLProject()) {
+ _inventory->removeAllItems();
+ _inventory->addItem("ANI_INV_MAP", 1);
+ } else {
+ getGameLoaderInventory()->removeAllItems();
+ getGameLoaderInventory()->addItem(ANI_INV_MAP, 1);
+ getGameLoaderInventory()->recalcItemPos();
+ }
initMap();
@@ -341,29 +346,23 @@ bool NGIEngine::handleGuiEvent(const Common::Event &event) {
if (event.type == Common::EVENT_LBUTTONUP || event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_MOUSEMOVE)
_currentScene->updateExitInput(event.mouse, event.type);
GuiManager *manager = _currentScene->_guiManager.get();
- if (_inventoryScene && (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_LBUTTONUP)) {
- Common::Point pos = event.mouse;
- Inventory2 *inventory = getGameLoaderInventory();
- const int item = inventory->getItemAtPos(&pos);
- if (item) {
- for (const MessageQueue *queue : *_globalMessageQueueList)
- if (queue->_queueId == QU_SC1_ENTER && !queue->_isFinished)
- return false;
- if (event.type == Common::EVENT_LBUTTONDOWN)
- inventory->putOnCursor(item);
- return true;
- }
- }
- if (_inventoryScene && _inventoryScene->_guiManager && _inventoryScene->_guiManager->hit(event.mouse)) {
- manager = _inventoryScene->_guiManager.get();
- for (const MessageQueue *queue : *_globalMessageQueueList) {
- if (queue->_queueId == QU_SC1_ENTER && !queue->_isFinished) {
- GuiElement *skip = manager->getElement("BTN_SKIP");
- if (!skip || !skip->hit(event.mouse))
- return false;
- }
- }
+ // CGame::OnMouse*: a hit inventory handles the event alone, else the scene and then the inventory
+ if (inventoryHitByMouseEvent(event)) {
+ sendInventoryMouseEvent(event);
+ return true;
}
+ const bool handled = handleSceneEvent(event, manager);
+ if ((event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_LBUTTONUP || event.type == Common::EVENT_RBUTTONDOWN ||
+ event.type == Common::EVENT_RBUTTONUP || event.type == Common::EVENT_MOUSEMOVE) && isInventoryEnabled())
+ sendInventoryMouseEvent(event);
+ return handled;
+ }
+ return false;
+}
+
+// The part of the event handling of the current scene: the controller touch, then the scene GUI
+bool NGIEngine::handleSceneEvent(const Common::Event &event, GuiManager *manager) {
+ {
// CFPController::OnMouseLKeyDown/Up: the touch scrolls the scene or sends the hero to its end
const bool sceneTouch = usesXMLProject() && _currentScene->_sceneId != SC_INTRO1;
const bool onGui = manager && manager->hit(event.mouse);
@@ -425,6 +424,8 @@ Common::Error NGIEngine::run() {
return Common::kUnsupportedGameidError;
_gameLoader.reset(new GameLoader());
_floaters.reset(new FlyPack);
+ // the wide screen margin is needed while the data loads (CInventory::Init, GUI elements)
+ _wideOfs = _gameVersion >= 201509 && (!ConfMan.hasKey("widescreen") || ConfMan.getBool("widescreen")) ? kWideMargin : 0;
result = _gameLoader->loadXML("data/FullPipe.xml", start, width, height);
if (result.getCode() != Common::kNoError)
return result;
@@ -799,13 +800,10 @@ Common::Error NGIEngine::updateScreen(uint32 elapsed, byte &brightness, bool red
} else if (_currentScene && (timedUpdates ? redraw : renderScene)) {
_currentScene->render();
if (_inventoryScene) {
- if (usesXMLProject()) {
- getGameLoaderInventory()->render();
- if (_inventoryScene->_guiManager)
- _inventoryScene->_guiManager->render(_backgroundSurface);
- } else {
+ if (usesXMLProject())
+ _inventory->render();
+ else
_inventory2->render();
- }
}
if (_updateScreenCallback)
_updateScreenCallback();
@@ -816,6 +814,9 @@ Common::Error NGIEngine::updateScreen(uint32 elapsed, byte &brightness, bool red
if (timedUpdates) {
if (redraw) {
drawWidescreenBars();
+ // CCursorController::Render comes after CGame::Render
+ if (usesXMLProject() && _inputController)
+ _inputController->render();
_system->copyRectToScreen(_backgroundSurface.getPixels(), _backgroundSurface.pitch, 0, 0, _backgroundSurface.w, _backgroundSurface.h);
}
} else {
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index b609aa5310e..ba621651358 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -86,6 +86,7 @@ class GameVar;
class CursorController;
class Inventory2;
class Inventory;
+class GuiManager;
struct Cursor;
struct Entrance;
class Command;
@@ -394,6 +395,12 @@ public:
/** CGame::IsInventoryRendered / IsInventoryEnabled: asked of the current scene controller */
bool isInventoryRendered();
bool isInventoryEnabled();
+ /** The event handling of the current scene: its controller, then its GUI */
+ bool handleSceneEvent(const Common::Event &event, GuiManager *manager);
+ /** CGame::OnMouse*: the mouse event goes to the inventory scene */
+ void sendInventoryMouseEvent(const Common::Event &event);
+ /** The inventory is enabled and the mouse event is over it (CInventory::Hit) */
+ bool inventoryHitByMouseEvent(const Common::Event &event);
/** CGame::Render for a stack with dialogs: the scenes visible through the ones above (putPrev) */
void renderSceneStack();
/** CGame::OnMouse*, OnKeyUp for the current scene of a stack with dialogs */
diff --git a/engines/ngi/objects.h b/engines/ngi/objects.h
index d777a0824d3..20aa4c8b34b 100644
--- a/engines/ngi/objects.h
+++ b/engines/ngi/objects.h
@@ -108,6 +108,8 @@ class GameProject : public CObject {
GameVar _walkData;
Common::HashMap<Common::Path, Common::Point, Common::Path::Hash> _textureSizes;
int _field_10;
+ /** PROJECT create_inv (CGame::CreateContent): the inventory scene is made from inventory.xml */
+ bool _createInventory = true;
public:
GameProject();
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 2483f0f05cf..b6620187587 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -48,7 +48,10 @@
namespace NGI {
+// CGame::FindScene: the scene 0 is the inventory
Scene *NGIEngine::findScene(int sceneId) {
+ if (sceneId == 0 && _inventory)
+ return _inventory;
return _gameProject->findScene(sceneId);
}
@@ -154,11 +157,8 @@ void NGIEngine::renderSceneStack() {
_sceneStack[i]->render(first);
first = false;
}
- if (inventoryAfter == (int)i && isInventoryRendered() && _inventoryScene) {
- getGameLoaderInventory()->render();
- if (_inventoryScene->_guiManager)
- _inventoryScene->_guiManager->render(_backgroundSurface);
- }
+ if (inventoryAfter == (int)i && isInventoryRendered() && _inventory)
+ _inventory->render();
}
}
@@ -168,42 +168,28 @@ bool NGIEngine::handleSceneStackEvent(const Common::Event &event) {
if (!scene)
return false;
- // CGame::OnMouse*: the inventory goes first when the controller of the scene enables it (CInventory::Hit)
- if (isInventoryEnabled() && _inventoryScene) {
- if (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_LBUTTONUP) {
- Common::Point pos = event.mouse;
- if (const int item = getGameLoaderInventory()->getItemAtPos(&pos)) {
- if (event.type == Common::EVENT_LBUTTONDOWN)
- getGameLoaderInventory()->putOnCursor(item);
- return true;
- }
- }
- GuiManager *gui = _inventoryScene->_guiManager.get();
- if (gui && gui->hit(event.mouse)) {
- gui->onMouseMove(event.mouse);
- if (event.type == Common::EVENT_LBUTTONDOWN)
- gui->onMouseLKeyDown(event.mouse);
- else if (event.type == Common::EVENT_LBUTTONUP)
- gui->onMouseLKeyUp(event.mouse);
- else if (event.type == Common::EVENT_RBUTTONDOWN)
- gui->onMouseRKeyDown(event.mouse);
- else if (event.type == Common::EVENT_RBUTTONUP)
- gui->onMouseRKeyUp(event.mouse);
- return true;
- }
+ // CGame::OnMouse*: a hit inventory gets the event alone (CInventory::Hit), else scene, inventory
+ if (inventoryHitByMouseEvent(event)) {
+ sendInventoryMouseEvent(event);
+ return true;
}
-
+ bool handled = false;
switch (event.type) {
case Common::EVENT_LBUTTONDOWN:
- return scene->onMouseLKeyDown(0, event.mouse.x, event.mouse.y);
+ handled = scene->onMouseLKeyDown(0, event.mouse.x, event.mouse.y);
+ break;
case Common::EVENT_LBUTTONUP:
- return scene->onMouseLKeyUp(0, event.mouse.x, event.mouse.y);
+ handled = scene->onMouseLKeyUp(0, event.mouse.x, event.mouse.y);
+ break;
case Common::EVENT_RBUTTONDOWN:
- return scene->onMouseRKeyDown(0, event.mouse.x, event.mouse.y);
+ handled = scene->onMouseRKeyDown(0, event.mouse.x, event.mouse.y);
+ break;
case Common::EVENT_RBUTTONUP:
- return scene->onMouseRKeyUp(0, event.mouse.x, event.mouse.y);
+ handled = scene->onMouseRKeyUp(0, event.mouse.x, event.mouse.y);
+ break;
case Common::EVENT_MOUSEMOVE:
- return scene->onMouseMove(0, event.mouse.x, event.mouse.y);
+ handled = scene->onMouseMove(0, event.mouse.x, event.mouse.y);
+ break;
case Common::EVENT_CUSTOM_ENGINE_ACTION_END:
if (event.customType == kActionCloseDialog)
scene->onKeyUp(4); // AKEYCODE_BACK
@@ -211,6 +197,43 @@ bool NGIEngine::handleSceneStackEvent(const Common::Event &event) {
default:
return false;
}
+ if (isInventoryEnabled())
+ sendInventoryMouseEvent(event);
+ return handled;
+}
+
+// CGame::OnMouse*: the event goes to the inventory scene, the mouse move too
+void NGIEngine::sendInventoryMouseEvent(const Common::Event &event) {
+ switch (event.type) {
+ case Common::EVENT_LBUTTONDOWN:
+ _inventory->onMouseLKeyDown(0, event.mouse.x, event.mouse.y);
+ break;
+ case Common::EVENT_LBUTTONUP:
+ _inventory->onMouseLKeyUp(0, event.mouse.x, event.mouse.y);
+ break;
+ case Common::EVENT_RBUTTONDOWN:
+ _inventory->onMouseRKeyDown(0, event.mouse.x, event.mouse.y);
+ break;
+ case Common::EVENT_RBUTTONUP:
+ _inventory->onMouseRKeyUp(0, event.mouse.x, event.mouse.y);
+ break;
+ case Common::EVENT_MOUSEMOVE:
+ _inventory->onMouseMove(0, event.mouse.x, event.mouse.y);
+ break;
+ default:
+ break;
+ }
+}
+
+// CGame::OnMouseLKeyDown ...: the button events that CInventory::Hit accepts
+bool NGIEngine::inventoryHitByMouseEvent(const Common::Event &event) {
+ if (event.type != Common::EVENT_LBUTTONDOWN && event.type != Common::EVENT_LBUTTONUP &&
+ event.type != Common::EVENT_RBUTTONDOWN && event.type != Common::EVENT_RBUTTONUP)
+ return false;
+ const bool enabled = isInventoryEnabled();
+ const bool hit = enabled && _inventory->hit(event.mouse.x, event.mouse.y);
+ debugC(2, kDebugEvents, "inventory: mouse %d,%d enabled %d hit %d", event.mouse.x, event.mouse.y, enabled, hit);
+ return hit;
}
Scene *GameProject::findScene(int sceneId) {
@@ -1210,6 +1233,13 @@ bool Scene::update(int counterdiff) {
if (g_ngi->_modalObject || this != g_ngi->getCurrentScene())
return true;
}
+ return changed | updateObjects(counterdiff);
+}
+
+// The part of CScene::Update that is the scene itself: the GUI and the objects, then the physics and the z controller (the updates of the global queues
+// above are those of CGame in the original)
+bool Scene::updateObjects(int counterdiff) {
+ bool changed = false;
if (_guiManager)
changed |= _guiManager->update(counterdiff);
for (uint i = 0; i < _renderableAnis.size(); i++)
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 136d88c10a3..6895aa07229 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -151,6 +151,8 @@ class Scene : public Background {
/** Returns true if the scene may need redrawing. */
virtual bool update(int counterdiff);
+ /** The objects and the GUI of CScene::Update (what a scene that is not the current one updates) */
+ bool updateObjects(int counterdiff);
AniObject *getAniMan();
AniObject *findAniObjectById(int obj, int a3);
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index e15189b15d3..41d135b1d9f 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -31,6 +31,7 @@
#include "ngi/fullpipe/fpcontroller.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/gameloader.h"
+#include "ngi/inventory.h"
#include "ngi/behavior.h"
#include "ngi/physics.h"
#include "ngi/sceneobjects.h"
@@ -43,6 +44,7 @@
#include "ngi/ngiarchive.h"
#include "ngi/objects.h"
#include "ngi/utils.h"
+#include "ngi/xmlnode.h"
#include "ngi/scene.h"
#include "ngi/statics.h"
#include "ngi/fullpipe/chaptermanager.h"
@@ -361,6 +363,10 @@ private:
bool parserCallback_PROJECT(ParserNode *node) {
_startName = node->values["start"];
+ if (node->values.contains("create_inv")) {
+ const char first = node->values["create_inv"].firstChar();
+ _project._createInventory = first == '1' || first == 't' || first == 'T' || first == 'y' || first == 'Y';
+ }
if (node->values.contains("width"))
_width = atoi(node->values["width"].c_str());
if (node->values.contains("height"))
@@ -453,8 +459,8 @@ private:
class XMLSceneParser : public Common::XMLParser {
public:
- XMLSceneParser(const GameProject &project, Scene &scene, const char *locale)
- : _project(project), _scene(scene), _locale(locale) {
+ XMLSceneParser(const GameProject &project, Scene &scene, const char *locale, Inventory *inventory = nullptr)
+ : _project(project), _scene(scene), _locale(locale), _inventory(inventory) {
setAllowText();
}
@@ -474,6 +480,9 @@ private:
const GameProject &_project;
Scene &_scene;
const char *_locale;
+ /** inventory.xml: the INVENTORY node is kept as a tree for CInventory::Init */
+ Inventory *_inventory;
+ Common::Array<XmlNode *> _inventoryNodes;
uint _objectOrder = 0;
bool _hasInitialStatics = false;
int16 _initialStaticsId = 0;
@@ -908,6 +917,14 @@ private:
XML_PROP(mode, false)
XML_PROP(fitTo, false)
XML_PROP(waitscreen, false)
+ XML_PROP(fontCounter, false)
+ XML_PROP(fontText, false)
+ XML_PROP(colorCounter, false)
+ XML_PROP(colorText, false)
+ XML_PROP(auto_combine, false)
+ XML_PROP(clear_on_hide, false)
+ XML_PROP(scene, false)
+ XML_PROP(pic_item, false)
KEY_END()
} PARSER_END()
@@ -932,6 +949,15 @@ private:
bool parserCallback_INTERACTIONS(ParserNode *) { return true; }
bool parserCallback_INVENTORY(ParserNode *node) {
+ if (_inventory) {
+ // CInventory::Init reads the node of the document (CScene +76)
+ _inventory->_xmlDocument.reset(new XmlNode());
+ XmlNode *root = _inventory->_xmlDocument->append(node->name);
+ copyAttributes(*root, *node);
+ _inventoryNodes.clear();
+ _inventoryNodes.push_back(root);
+ return true;
+ }
Common::Rect area(atoi(node->values.getValOrDefault("w", "1024").c_str()),
atoi(node->values.getValOrDefault("h", "100").c_str()));
// CInventory::Init: "fitTo" moves the item area by the widescreen margin
@@ -949,6 +975,21 @@ private:
return true;
}
+ static void copyAttributes(XmlNode &target, const ParserNode &node) {
+ for (const auto &attribute : node.values)
+ target.appendAttr(attribute._key, attribute._value);
+ }
+
+ // The children of the INVENTORY node: kept as XmlNode for CInventory::Init
+ void addInventoryNode(ParserNode *node) {
+ if (!_inventory || node->depth < 1 || node->depth > _inventoryNodes.size())
+ return;
+ XmlNode *child = _inventoryNodes[node->depth - 1]->append(node->name);
+ copyAttributes(*child, *node);
+ _inventoryNodes.resize(node->depth);
+ _inventoryNodes.push_back(child);
+ }
+
// CScene::SetXmlData ADDPIC: a picture of another scene (usually SC_COMMON) shown in this one; the attributes that are given
// replace its position, z and flags when the scene is entered (see GameLoader::doSetScene, like ADDANI)
bool parserCallback_ADDPIC(ParserNode *node) {
@@ -1591,6 +1632,7 @@ private:
const ParserNode *parent = getParentNode(node);
if (!parent)
return false;
+ addInventoryNode(node);
if (parent->name == "PICTURE" && node->name == "HITREGION" && node->values.getValOrDefault("type") == "rect") {
int16 id;
if (!readId(parent->values["id"], id))
@@ -1655,7 +1697,7 @@ private:
return parserCallback_GUIMNGR(node);
if (node->name == "PICTURE")
return parserCallback_PICTURE(node);
- if (node->name == "ITEM") {
+ if (node->name == "ITEM" && !_inventory) {
InventoryPoolItem item = {};
readId(node->values.getValOrDefault("visSel"), item.pictureObjectSelected);
if (readId(node->values.getValOrDefault("id"), item.id) && readId(node->values.getValOrDefault("vis"), item.pictureObjectNormal))
@@ -1702,22 +1744,15 @@ void SceneTag::loadSceneXML(const GameProject &project) {
// Both files list every scene, the parsers pick the entries of this one.
// exits.xml is known from the 2015 revision on
- if (g_ngi->_gameVersion >= 201509 && _sceneId != SC_INV) {
+ if (g_ngi->_gameVersion >= 201509) {
parser.close();
if (!parser.loadFile("data/exits.xml") || !parser.parse())
return;
}
- if (_sceneId != SC_INV) {
- parser.close();
- if (!parser.loadFile("data/interactions.xml") || !parser.parse())
- return;
- parser.registerInteractions();
- }
- if (_sceneId == SC_INV) {
- parser.close();
- if (!parser.loadFile("data/res/inventory.xml") || !parser.parse())
- return;
- }
+ parser.close();
+ if (!parser.loadFile("data/interactions.xml") || !parser.parse())
+ return;
+ parser.registerInteractions();
debugC(1, kDebugXML, "Loaded Full Pipe scene %s with %u pictures and %u animations",
_tag.c_str(), scene->_pictureObjects.size(), scene->_aniObjects.size());
@@ -1725,6 +1760,20 @@ void SceneTag::loadSceneXML(const GameProject &project) {
_scene = scene.release();
}
+// CGame::CreateContent: the inventory is the scene 0, read from inventory.xml for create_inv
+static bool createInventory(GameProject &project) {
+ Common::ScopedPtr<Inventory> inventory(new Inventory());
+ XMLSceneParser parser(project, *inventory, g_ngi->getResourceLocale(), inventory.get());
+ if (!parser.loadFile("data/res/inventory.xml") || !parser.parse())
+ return false;
+ if (inventory->_guiManager)
+ inventory->_guiManager->load(project);
+ g_ngi->_inventory = inventory.release();
+ g_ngi->_inventory->init();
+ createSceneController(0); // CInventoryController: CGame::FindScene(0) is the inventory
+ return true;
+}
+
Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTag *&start, int &width, int &height) {
// XML projects may ship in zip containers (the 2015 build: an APK and an OBB), later entries win, so the
// containers are added in reverse order of the detection entry. Loose files in the game directory also work.
@@ -1781,6 +1830,8 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
return Common::Error(Common::kNoGameDataFoundError, "Could not read the lift passages");
}
g_ngi->lift_resetButtons();
+ if (project._createInventory && !createInventory(project))
+ return Common::Error(Common::kNoGameDataFoundError, "Could not read the inventory");
_gameVar->addSubVarAsInt("CHAPTERS", 0);
if (g_ngi->_gameVersion >= 201509) { // tasks.xml is known from the 2015 revision on
g_ngi->_chapterManager.reset(new ChapterManager);
Commit: aa8a792872eb49eeec4e7b0277211335822ce500
https://github.com/scummvm/scummvm/commit/aa8a792872eb49eeec4e7b0277211335822ce500
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Port CSc01Controller::IsInventoryEnabled and drop the Windows inventory scroll stubs
Changed paths:
engines/ngi/fullpipe/scene01.cpp
engines/ngi/fullpipe/scenecontrollers.h
engines/ngi/inventory.cpp
engines/ngi/inventory.h
diff --git a/engines/ngi/fullpipe/scene01.cpp b/engines/ngi/fullpipe/scene01.cpp
index 24763e2d13e..e8243ec335b 100644
--- a/engines/ngi/fullpipe/scene01.cpp
+++ b/engines/ngi/fullpipe/scene01.cpp
@@ -24,6 +24,8 @@
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/scenecontrollers.h"
#include "ngi/guimanager.h"
+#include "ngi/input.h"
+#include "ngi/inventory.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/constants.h"
@@ -86,6 +88,16 @@ void Sc01Controller::onGuiEvent(const Common::String &id, const Common::String &
_scene->setExitState(0, 1);
}
+// CSc01Controller::IsInventoryEnabled: the inventory works when the entrance queue of the scene has finished, and while it runs only the skip button does
+bool Sc01Controller::isInventoryEnabled() {
+ GuiElement *skip = g_ngi->_inventory->_guiManager ? g_ngi->_inventory->_guiManager->getElement("BTN_SKIP") : nullptr;
+ CursorController *cursor = g_ngi->_inputController;
+ bool running = false;
+ for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList)
+ running = running || (queue->_queueId == QU_SC1_ENTER && !queue->_isFinished);
+ return !running || (skip && skip->hit(Common::Point(cursor->_hotSceneX, cursor->_hotSceneY)));
+}
+
void scene01_initScene(Scene *sc, int entrance) {
scene01_initObjects(sc, entrance, g_ngi->getStateId(sO_EggCracker) == g_ngi->getStateValue(sO_EggCracker, sO_DidNotCrackEgg));
if (g_ngi->isAndroidFullPipe()) {
diff --git a/engines/ngi/fullpipe/scenecontrollers.h b/engines/ngi/fullpipe/scenecontrollers.h
index b9392ca3863..740c4248e42 100644
--- a/engines/ngi/fullpipe/scenecontrollers.h
+++ b/engines/ngi/fullpipe/scenecontrollers.h
@@ -34,6 +34,7 @@ public:
explicit Sc01Controller(int sceneId) : FPController(sceneId) {}
void onShow() override;
void onGuiEvent(const Common::String &id, const Common::String &event) override;
+ bool isInventoryEnabled() override;
};
class Sc02Controller : public FPController {
diff --git a/engines/ngi/inventory.cpp b/engines/ngi/inventory.cpp
index 84fb72fb948..20deee204bb 100644
--- a/engines/ngi/inventory.cpp
+++ b/engines/ngi/inventory.cpp
@@ -431,15 +431,6 @@ void Inventory2::slideOut() {
ex->postMessage();
}
-// CInventoryController::ScrollOut and ScrollIn: its state machine moves the bar (1.5 pixels per millisecond, up to 100) and the items
-void Inventory2::scrollOut() {
- warning("STUB/untested: CInventoryController::ScrollOut: the inventory bar does not leave the screen");
-}
-
-void Inventory2::scrollIn() {
- warning("STUB/untested: CInventoryController::ScrollIn: the inventory bar does not come back");
-}
-
bool Inventory2::onMouseLKeyDown(Command *cmd) {
if (!_isInventoryOut)
return false;
diff --git a/engines/ngi/inventory.h b/engines/ngi/inventory.h
index 00516326928..b7922be4372 100644
--- a/engines/ngi/inventory.h
+++ b/engines/ngi/inventory.h
@@ -132,9 +132,6 @@ class Inventory2 : public InventoryData {
int getItemAtPos(Common::Point *point);
void slideIn();
void slideOut();
- /** CInventoryController::ScrollOut / ScrollIn (Android): the bar leaves the screen for an arcade and comes back */
- void scrollOut();
- void scrollIn();
bool onMouseLKeyDown(Command *cmd);
int putOnCursor(int itemId);
Commit: 5029d4573283c2d1a23f10555c174ab7e6764498
https://github.com/scummvm/scummvm/commit/5029d4573283c2d1a23f10555c174ab7e6764498
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: CLift::SwitchToBigView calls CInventory::TakeFromCursor with 0, 0
Changed paths:
engines/ngi/fullpipe/lift.cpp
diff --git a/engines/ngi/fullpipe/lift.cpp b/engines/ngi/fullpipe/lift.cpp
index e975b65c64d..f36a559835a 100644
--- a/engines/ngi/fullpipe/lift.cpp
+++ b/engines/ngi/fullpipe/lift.cpp
@@ -828,7 +828,7 @@ bool Lift::onButtonUp(GameObject *) {
// CLift::SwitchToBigView: the cursor item goes back (CInventory::TakeFromCursor), SC_LIFT is pushed
void Lift::switchToBigView() {
- g_ngi->_inventory->takeFromCursor(g_ngi->_inputController->_hotSceneX, g_ngi->_inputController->_hotSceneY);
+ g_ngi->_inventory->takeFromCursor(0.0f, 0.0f);
g_ngi->pushScene(SC_LIFT);
Common::Array<AniObject *> buttons;
Commit: b2a03281f130ca7778b4c63adbce5a81f8e3e889
https://github.com/scummvm/scummvm/commit/b2a03281f130ca7778b4c63adbce5a81f8e3e889
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Port CTutorial and CTutorialManager, read tutorials.xml as a tree
Changed paths:
A engines/ngi/fullpipe/tutorialmanager.cpp
A engines/ngi/fullpipe/tutorialmanager.h
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/xmlnode.cpp
engines/ngi/xmlnode.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/tutorialmanager.cpp b/engines/ngi/fullpipe/tutorialmanager.cpp
new file mode 100644
index 00000000000..72b23cf1fab
--- /dev/null
+++ b/engines/ngi/fullpipe/tutorialmanager.cpp
@@ -0,0 +1,252 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/ngi.h"
+#include "ngi/font.h"
+#include "ngi/objects.h"
+#include "ngi/scene.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+namespace {
+
+// CIDList::FindId: 0 for an unknown name
+int findId(const char *name) {
+ uint32 id = 0;
+ if (name[0])
+ g_ngi->_gameProject->_objectIds.findId(name, id);
+ return id;
+}
+
+} // End of anonymous namespace
+
+// CTutorial::CTutorial
+Tutorial::Tutorial() {
+}
+
+// CTutorial::Init (1A5800)
+bool Tutorial::init(const XmlNode &node) {
+ _id = node.attrStr("id", "");
+ _sceneId = findId(node.attrStr("scene", ""));
+ _text = g_ngi->_textContainer->getText(node.attrStr("text_id", ""));
+ _isExtra = node.attrBool("isExtra", false);
+ _isArcade = node.attrBool("isArcade", false);
+ _deferredFinish = node.attrBool("deferredFinish", false);
+ _leftOffset = 0;
+ _topOffset = 0;
+ _rightOffset = 0;
+ _bottomOffset = 0;
+ for (uint i = 0; i < node.childCount(); i++) {
+ const XmlNode &child = node[i];
+ if (child.name() == "BEARDED") {
+ _isMirror = child.attrBool("isMirror", false);
+ _beardedX = child.attrFloat("posX", 0.0f);
+ _beardedY = child.attrFloat("posY", 0.0f);
+ } else if (child.name() == "CLOUD") {
+ _isButton = child.attrBool("isButton", false);
+ _viewButton = child.attrInt("viewButton", 0);
+ _view = child.attrInt("view", 0);
+ } else if (child.name() == "TEXT") {
+ _leftOffset = child.attrFloat("left_offset", 0.0f);
+ _topOffset = child.attrFloat("top_offset", 0.0f);
+ _rightOffset = child.attrFloat("right_offset", 0.0f);
+ _bottomOffset = child.attrFloat("bottom_offset", 0.0f);
+ } else if (child.name() == "ARROW") {
+ TutorialArrow arrow;
+ arrow.shown = child.attrBool("is", false);
+ arrow.x = child.attrFloat("posX", 0.0f);
+ arrow.y = child.attrFloat("posY", 0.0f);
+ // "fitTo" moves the arrow by the margin of the wide screen (CRender +8 + +24)
+ const Common::String fitTo = child.attrStr("fitTo", "");
+ if (fitTo == "left")
+ arrow.x -= g_ngi->_wideOfs;
+ if (fitTo == "right")
+ arrow.x += g_ngi->_wideOfs;
+ if (child.checkAttr("obj"))
+ arrow.objectId = findId(child.attrStr("obj", ""));
+ if (child.checkAttr("scene"))
+ arrow.sceneId = findId(child.attrStr("scene", ""));
+ if (child.checkAttr("offset")) {
+ const XmlVector2 offset = child.attrVector2("offset", 0, 0);
+ arrow.offsetX = offset.x;
+ arrow.offsetY = offset.y;
+ }
+ arrow.view = child.attrInt("view", 0);
+ arrow.angle = child.attrInt("angle", 0);
+ _arrows.push_back(arrow);
+ }
+ }
+ _state = 1;
+ return true;
+}
+
+// CTutorial::SetXmlData (1A2C14): the state 3 is read back as 2
+void Tutorial::setXmlData(const XmlNode &node) {
+ const int state = node.attrInt("curState", 0);
+ _state = state == 3 ? 2 : state;
+}
+
+// CTutorialManager::CTutorialManager
+TutorialManager::TutorialManager() {
+}
+
+// CTutorialManager::~CTutorialManager
+TutorialManager::~TutorialManager() {
+ for (uint i = 0; i < _tutorials.size(); i++)
+ delete _tutorials[i];
+}
+
+// CTutorialManager::Init (1A6578)
+void TutorialManager::init(const char *path) {
+ Common::ScopedPtr<XmlNode> document(loadXmlDocument(path));
+ if (!document) {
+ warning("Could not read %s", path);
+ return;
+ }
+ const XmlNode &root = document->first();
+ for (uint i = 0; i < root.childCount(); i++) {
+ if (root[i].name() != "TUTORIAL")
+ continue;
+ Tutorial *tutorial = findTutorial(root[i].attrStr("id", ""));
+ if (!tutorial) {
+ tutorial = new Tutorial();
+ _tutorials.push_back(tutorial);
+ }
+ tutorial->init(root[i]);
+ }
+ debugC(1, kDebugXML, "Loaded %u tutorials from %s", _tutorials.size(), path);
+}
+
+// CTutorialManager::FindTutorial (1A2CE2)
+Tutorial *TutorialManager::findTutorial(const Common::String &id) const {
+ for (uint i = 0; i < _tutorials.size(); i++) {
+ if (_tutorials[i]->_id == id)
+ return _tutorials[i];
+ }
+ return nullptr;
+}
+
+// CTutorialManager::CleanXml (1A2D44): the tutorials wait again, TUTORIAL_LAST is for the scene 3
+void TutorialManager::cleanXml() {
+ _active = true;
+ for (uint i = 0; i < _tutorials.size(); i++)
+ _tutorials[i]->setState(1);
+ if (Tutorial *last = findTutorial("TUTORIAL_LAST"))
+ last->_sceneId = 303;
+}
+
+// CTutorialManager::FinishTutorial (1A2DA4)
+void TutorialManager::finishTutorial(const Common::String &id) {
+ if (Tutorial *tutorial = findTutorial(id))
+ tutorial->setState(4);
+}
+
+// CTutorialManager::IsTutorialCompleted (1A2DDC): all completed when the manager is inactive
+bool TutorialManager::isTutorialCompleted() const {
+ if (!_active)
+ return true;
+ return findTutorial("TUTORIAL_LAST")->_state == 4;
+}
+
+// CTutorialManager::FindActiveTutorial (1A2E20)
+Tutorial *TutorialManager::findActiveTutorial() const {
+ for (uint i = 0; i < _tutorials.size(); i++) {
+ if (_tutorials[i]->_state == 2)
+ return _tutorials[i];
+ }
+ return nullptr;
+}
+
+// CTutorialManager::FinishActiveTutorial (1A2E42): a tutorial that finishes deferred is 3, else 4
+void TutorialManager::finishActiveTutorial() {
+ if (Tutorial *tutorial = findActiveTutorial())
+ tutorial->setState(tutorial->_deferredFinish ? 3 : 4);
+}
+
+// CTutorialManager::ShowTutorial (1A2F9C)
+bool TutorialManager::showTutorial(Tutorial *tutorial) {
+ if (!tutorial || tutorial->_state != 2)
+ return false;
+ if (_active || tutorial->_isExtra) {
+ g_ngi->pushScene(SC_TUTORIAL);
+ return true;
+ }
+ tutorial->setState(4);
+ return false;
+}
+
+// CTutorialManager::Deactivate (1A2FD8)
+void TutorialManager::deactivate() {
+ _active = false;
+ for (uint i = 0; i < _tutorials.size(); i++) {
+ if (!_tutorials[i]->_isExtra && !_tutorials[i]->_isArcade)
+ _tutorials[i]->setState(4);
+ }
+ g_ngi->getSceneInStack(0)->message("MSG_GAMECENTER_TRY", "", nullptr);
+}
+
+// CTutorialManager::ActivateTutorialAnyScene (1A3064): when the scene stack has only one scene
+bool TutorialManager::activateTutorialAnyScene(const Common::String &id) {
+ Tutorial *tutorial = findTutorial(id);
+ if (!tutorial)
+ return false;
+ if (g_ngi->_sceneStack.size() != 1)
+ return false;
+ if (tutorial->_state == 1) {
+ finishActiveTutorial();
+ tutorial->setState(2);
+ showTutorial(tutorial);
+ return true;
+ }
+ if (tutorial->_state == 2) {
+ showTutorial(tutorial);
+ return true;
+ }
+ return false;
+}
+
+// CTutorialManager::ActivateTutorial (1A30D6): the tutorial of the current scene
+bool TutorialManager::activateTutorial(const Common::String &id) {
+ Tutorial *tutorial = findTutorial(id);
+ if (!tutorial)
+ return false;
+ if (tutorial->_state == 1 && g_ngi->getCurrentScene()->_sceneId == tutorial->_sceneId) {
+ finishActiveTutorial();
+ tutorial->setState(2);
+ } else if (!(tutorial->_state == 2 && g_ngi->getCurrentScene()->_sceneId == tutorial->_sceneId)) {
+ return false;
+ }
+ showTutorial(tutorial);
+ return true;
+}
+
+// CTutorialManager::SetXmlData (1A314C): "isActive" and the state of the tutorials by their index
+void TutorialManager::setXmlData(const XmlNode &node) {
+ _active = node.attrInt("isActive", 0) != 0;
+ for (uint i = 0; i < node.childCount(); i++) {
+ if (_tutorials.size() > i && node[i].name() == "TUTORIAL")
+ _tutorials[i]->setXmlData(node[i]);
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/tutorialmanager.h b/engines/ngi/fullpipe/tutorialmanager.h
new file mode 100644
index 00000000000..fae9160ef52
--- /dev/null
+++ b/engines/ngi/fullpipe/tutorialmanager.h
@@ -0,0 +1,110 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_TUTORIALMANAGER_H
+#define NGI_FULLPIPE_TUTORIALMANAGER_H
+
+#include "common/array.h"
+#include "common/str.h"
+
+#include "ngi/xmlnode.h"
+
+namespace NGI {
+
+/** CArrowData (36 bytes): the arrow of a tutorial, points at a place or an object */
+struct TutorialArrow {
+ float x = 0; // +0
+ float y = 0; // +4
+ int view = 0; // +8: "view"
+ bool shown = false; // +12: "is"
+ int angle = 0; // +16
+ int objectId = 0; // +20: "obj"
+ int sceneId = 0; // +24: "scene"
+ float offsetX = 0; // +28: "offset"
+ float offsetY = 0; // +32
+};
+
+/** CTutorial: entry of tutorials.xml; state 0 unread, 1 waiting, 2 active, 3 (as 2), 4 done */
+class Tutorial {
+public:
+ Tutorial();
+
+ /** CTutorial::Init */
+ bool init(const XmlNode &node);
+ /** CTutorial::SetXmlData: "curState" */
+ void setXmlData(const XmlNode &node);
+ void cleanXml() { _state = 0; }
+ void setState(int state) { _state = state; }
+ /** CTutorial::GetArrowData: the arrow of the index (the original copies it) */
+ const TutorialArrow &getArrowData(int index) const { return _arrows[index]; }
+
+ Common::String _id; // +0
+ int _sceneId = 0; // +4: "scene"
+ Common::String _text; // +8: the text of "text_id"
+ int _state = 0; // +12
+ bool _isExtra = false; // +16
+ bool _isArcade = false; // +17
+ bool _deferredFinish = false; // +18
+ Common::Array<TutorialArrow> _arrows; // +20
+ bool _isButton = false; // +32: CLOUD "isButton"
+ int _viewButton = 0; // +36
+ int _view = 0; // +40: the cloud
+ float _leftOffset = 0; // +44: TEXT
+ float _topOffset = 0; // +48
+ float _rightOffset = 0; // +52
+ float _bottomOffset = 0; // +56
+ bool _isMirror = false; // +60: BEARDED
+ float _beardedX = -1; // +64
+ float _beardedY = -1; // +68
+};
+
+/** CTutorialManager (CSingleton, NGIEngine::_tutorialManager): the tutorials and the active one */
+class TutorialManager {
+public:
+ TutorialManager();
+ ~TutorialManager();
+
+ /** CTutorialManager::Init: reads the file */
+ void init(const char *path);
+ void activate() { _active = true; }
+ /** CTutorialManager::Deactivate: the tutorials that are not extra and not arcade finish */
+ void deactivate();
+ Tutorial *findTutorial(const Common::String &id) const;
+ Tutorial *findActiveTutorial() const;
+ void finishTutorial(const Common::String &id);
+ void finishActiveTutorial();
+ bool isTutorialCompleted() const;
+ /** CTutorialManager::ShowTutorial: pushes SC_TUTORIAL (finishes it if the manager is off) */
+ bool showTutorial(Tutorial *tutorial);
+ bool activateTutorialAnyScene(const Common::String &id);
+ bool activateTutorial(const Common::String &id);
+ /** CTutorialManager::SetXmlData and CleanXml: the saved state */
+ void setXmlData(const XmlNode &node);
+ void cleanXml();
+
+private:
+ Common::Array<Tutorial *> _tutorials; // +8
+ bool _active = true; // +20
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_TUTORIALMANAGER_H
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 3f94000cdad..8b81eae9d2a 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -133,7 +133,8 @@ MODULE_OBJS = \
fullpipe/scenes.o \
fullpipe/taskmanager.o \
fullpipe/testmode.o \
- fullpipe/tremble.o
+ fullpipe/tremble.o \
+ fullpipe/tutorialmanager.o
ifdef USE_IMGUI
MODULE_OBJS += \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 33d17418be8..9c65dbc66a4 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -40,6 +40,7 @@
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
#include "ngi/fullpipe/testmode.h"
#include "ngi/debugger/debugtools.h"
#include "ngi/fullpipe/tremble.h"
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index ba621651358..3ee46e39a3c 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -92,6 +92,7 @@ struct Entrance;
class Command;
class FlyPack;
class TaskManager;
+class TutorialManager;
class Tremble;
class ArcadeInterface;
class BitmapFont;
@@ -300,6 +301,8 @@ public:
Common::ScopedPtr<FlyPack> _floaters;
// 2015 revision (CSingleton<CTaskManager>, CSingleton<CChapterManager>); null in older builds
Common::ScopedPtr<TaskManager> _taskManager;
+ /** CSingleton<CTutorialManager>: the tutorials of tutorials.xml (Android) */
+ Common::ScopedPtr<TutorialManager> _tutorialManager;
Common::ScopedPtr<Tremble> _tremble;
Common::ScopedPtr<ArcadeInterface> _arcadeInterface;
Common::ScopedPtr<ChapterManager> _chapterManager;
diff --git a/engines/ngi/xmlnode.cpp b/engines/ngi/xmlnode.cpp
index 0af3678cba7..8acf0b92147 100644
--- a/engines/ngi/xmlnode.cpp
+++ b/engines/ngi/xmlnode.cpp
@@ -19,6 +19,8 @@
*
*/
+#include "common/formats/xmlparser.h"
+#include "common/ptr.h"
#include "common/tokenizer.h"
#include "ngi/xmlnode.h"
@@ -150,4 +152,39 @@ void XmlNode::appendAttr(const Common::String &name, const Common::String &value
_attrValues.push_back(value);
}
+// Every node and attribute of the file goes into the tree
+class XmlDocumentParser : public Common::XMLParser {
+public:
+ explicit XmlDocumentParser(XmlNode &document) {
+ _nodes.push_back(&document);
+ }
+
+private:
+ Common::Array<XmlNode *> _nodes;
+
+ CUSTOM_XML_PARSER(XmlDocumentParser) {
+ } PARSER_END()
+
+ bool handleUnknownKey(ParserNode *node) override {
+ node->layout = _XMLkeys;
+ if (node->depth >= _nodes.size())
+ return false;
+ XmlNode *child = _nodes[node->depth]->append(node->name);
+ for (const auto &attribute : node->values)
+ child->appendAttr(attribute._key, attribute._value);
+ _nodes.resize(node->depth + 1);
+ _nodes.push_back(child);
+ node->ignore = true;
+ return true;
+ }
+};
+
+XmlNode *loadXmlDocument(const Common::Path &path) {
+ Common::ScopedPtr<XmlNode> document(new XmlNode(""));
+ XmlDocumentParser parser(*document);
+ if (!parser.loadFile(path) || !parser.parse())
+ return nullptr;
+ return document.release();
+}
+
} // End of namespace NGI
diff --git a/engines/ngi/xmlnode.h b/engines/ngi/xmlnode.h
index e3f691e7893..58805cf2bbb 100644
--- a/engines/ngi/xmlnode.h
+++ b/engines/ngi/xmlnode.h
@@ -23,6 +23,7 @@
#define NGI_XMLNODE_H
#include "common/array.h"
+#include "common/path.h"
#include "common/str.h"
namespace NGI {
@@ -88,6 +89,9 @@ private:
const Common::String *findAttr(const char *name) const;
};
+/** CXmlDocument::ParseFile: the file as a tree, the document node has the root as its only child */
+XmlNode *loadXmlDocument(const Common::Path &path);
+
} // End of namespace NGI
#endif // NGI_XMLNODE_H
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 41d135b1d9f..664f5f6f6f7 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -50,6 +50,7 @@
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
namespace NGI {
@@ -1842,6 +1843,8 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
if (!g_ngi->_taskManager->init("data/tasks.xml", project._objectIds))
return Common::Error(Common::kNoGameDataFoundError, "Could not read the tasks");
g_ngi->_taskManager->onShow();
+ g_ngi->_tutorialManager.reset(new TutorialManager);
+ g_ngi->_tutorialManager->init("data/tutorials.xml");
g_ngi->_tremble.reset(new Tremble);
if (!g_ngi->_tremble->init("data/tremble.xml", project._objectIds))
return Common::Error(Common::kNoGameDataFoundError, "Could not read the tremble objects");
Commit: f6c240b46b06cf7b7d264a5fef23addd1d9ea693
https://github.com/scummvm/scummvm/commit/f6c240b46b06cf7b7d264a5fef23addd1d9ea693
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Port CExit and CExitManager, drive them from FPController, port CSc01Controller::OnGuiEvent exits
Changed paths:
A engines/ngi/fullpipe/exitmanager.cpp
A engines/ngi/fullpipe/exitmanager.h
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/fpcontroller.h
engines/ngi/fullpipe/inventorycontroller.cpp
engines/ngi/fullpipe/inventorycontroller.h
engines/ngi/fullpipe/scene01.cpp
engines/ngi/fullpipe/sceneTutorial.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/exitmanager.cpp b/engines/ngi/fullpipe/exitmanager.cpp
new file mode 100644
index 00000000000..0a1e62485c9
--- /dev/null
+++ b/engines/ngi/fullpipe/exitmanager.cpp
@@ -0,0 +1,587 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "math/utils.h"
+
+#include "ngi/ngi.h"
+#include "ngi/utils.h"
+#include "ngi/font.h"
+#include "ngi/objects.h"
+#include "ngi/gfx.h"
+#include "ngi/scene.h"
+#include "ngi/sound.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/exitmanager.h"
+
+namespace NGI {
+
+namespace {
+
+enum {
+ kArrow = 23234, // ANI_ARROW of the scene SC_COMMON
+ kArrowPicture = 23237, // PIC_ARROW_RED
+ kArrowUp = 23236, // MOV_ARROW_UP
+ kLevelArrow = 23401, // the arrow of a new level
+ kLevelArrowPicture = 23404,
+ kLevelArrowUp = 23403,
+ kPressSound = 23238 // 0x5AC6
+};
+
+// CIDList::FindId: 0 for an unknown name
+int findId(const char *name) {
+ uint32 id = 0;
+ if (name[0])
+ g_ngi->_gameProject->_objectIds.findId(name, id);
+ return id;
+}
+
+// CGame::FindVis for the pictures of the scenes that are loaded
+Scene *findSceneOfPicture(int pictureId) {
+ for (SceneTag &tag : *g_ngi->_gameProject->_sceneTagList) {
+ if (tag._scene && tag._scene->findPictureObjectById(pictureId, 0))
+ return tag._scene;
+ }
+ return nullptr;
+}
+
+} // End of anonymous namespace
+
+// CExit::CExit
+Exit::Exit() {
+}
+
+// CExit::~CExit
+Exit::~Exit() {
+}
+
+// CExit::GetSceneId (143E36)
+int Exit::getSceneId() const {
+ return _scene->_sceneId;
+}
+
+// CExit::GetVisId (143ECE)
+int Exit::getVisId() const {
+ return _picture->_id;
+}
+
+// center of the hit region, else of the picture (CHitregionObject / CVisibleObject::GetCenter)
+Common::Point Exit::pictureCenter() const {
+ if (!_picture->_hitRegion.isEmpty())
+ return _picture->_hitRegion.center() + Common::Point(_picture->_x, _picture->_y);
+ return _picture->getCenter();
+}
+
+// CExit::CreateAndAddInScene (144258): copies of the SC_COMMON arrow and its pressed picture go in
+void Exit::createAndAddInScene() {
+ Scene *common = g_ngi->findScene(SC_COMMON);
+ int arrowId = 0;
+ int pictureId = 0;
+ if (_type == 0) {
+ arrowId = kArrow;
+ pictureId = kArrowPicture;
+ } else if (_type == 1) {
+ arrowId = kLevelArrow;
+ pictureId = kLevelArrowPicture;
+ }
+ AniObject *arrow = common->findAniObjectById(arrowId, 0);
+ PictureObject *picture = common->findPictureObjectById(pictureId, 0);
+ if (!arrow || !picture) {
+ warning("Missing Full Pipe exit artwork");
+ return;
+ }
+ _arrow = new AniObject(arrow);
+ _scene->addAni(_arrow, true);
+ _arrowCopyId = _arrow->_copyId;
+ _pressed = new PictureObject(picture);
+ _scene->addPicture(_pressed);
+}
+
+// CExit::Init (144688)
+bool Exit::init(const XmlNode &node, Scene &scene) {
+ _picture = scene.findPictureObjectById(findId(node.attrStr("vis_dst", "")), 0);
+ _angle = node.attrFloat("angle", 0.0f);
+ const int state = node.attrInt("state", 1);
+ _type = node.attrInt("type", 0);
+ _offsetX = node.attrFloat("offsetX", 0.0f);
+ _offsetY = node.attrFloat("offsetY", 0.0f);
+ _intersect = node.attrBool("intersect", false);
+ if (!_picture)
+ return false;
+ _scene = &scene;
+ createAndAddInScene();
+ if (!_arrow)
+ return false;
+ setAngle(_angle);
+ if (node.checkAttr("z")) {
+ _fixedZ = true;
+ _arrow->_z = node.attrFloat("z", 0.0f);
+ } else {
+ _arrow->_z = _picture->_z - 1;
+ }
+ const Common::Point center = pictureCenter();
+ _centerX = center.x;
+ _centerY = center.y;
+ _arrow->setCenter(Common::Point(_centerX + _offsetX, _centerY + _offsetY));
+ setState(state);
+ return true;
+}
+
+// CExit::LoadParam (1447DC)
+void Exit::loadParam(const XmlNode &node, Scene &scene) {
+ _picture = scene.findPictureObjectById(findId(node.attrStr("vis_dst", "")), 0);
+ _angle = node.attrFloat("angle", 0.0f);
+ const int state = node.attrInt("state", 1);
+ _offsetX = node.attrFloat("offsetX", 0.0f);
+ _offsetY = node.attrFloat("offsetY", 0.0f);
+ _type = node.attrInt("type", 0);
+ _intersect = node.attrBool("intersect", false);
+ const Common::Point center = pictureCenter();
+ _centerX = center.x;
+ _centerY = center.y;
+ if (!_scene->findAniObjectById(_type != 0 ? kLevelArrow : kArrow, _arrowCopyId))
+ createAndAddInScene();
+ if (node.checkAttr("z")) {
+ _fixedZ = true;
+ _arrow->_z = node.attrFloat("z", 0.0f);
+ } else {
+ _arrow->_z = _picture->_z - 1;
+ }
+ _arrow->setCenter(Common::Point(_centerX + _offsetX, _centerY + _offsetY));
+ setAngle(_angle);
+ setState(state);
+}
+
+// CExit::OnHide (143C70)
+void Exit::onHide() {
+ _arrow->stopMovement();
+ _arrow->_flags &= ~4;
+ _pressed->_flags &= ~4;
+ _releaseTime = -1;
+ _hint.clear();
+ _hintTime = -1;
+}
+
+// CExit::OnShow (143F6C)
+void Exit::onShow() {
+ if (_state == 1) {
+ _arrow->_flags |= 4;
+ if (_type == 0)
+ _arrow->startMovement(kArrowUp, 0, -1);
+ else if (_type == 1)
+ _arrow->startMovement(kLevelArrowUp, 0, -1);
+ } else if (_state == 2) {
+ setState(1);
+ _pressed->_flags &= ~4;
+ }
+}
+
+// CExit::SetState (143F40)
+void Exit::setState(int state) {
+ _state = state;
+ if (state == 1) {
+ onShow();
+ } else if (state == 2) {
+ onHide();
+ initPicPressed();
+ } else if (state == 0) {
+ onHide();
+ }
+}
+
+// CExit::SetAngle (143E40)
+void Exit::setAngle(float angle) {
+ _angle = angle;
+ _arrow->_rotation = Math::deg2rad(angle);
+}
+
+// CExit::SetNewAngle (143E8C)
+void Exit::setNewAngle(float angle) {
+ _newAngle = angle;
+ _turnAngle = _angle;
+}
+
+// CExit::InitPicPressed (143EE0): the pressed arrow is where the arrow is
+void Exit::initPicPressed() {
+ _pressed->setCenter(_arrow->getCenter());
+ _pressed->_rotation = Math::deg2rad(_angle);
+ _pressed->_z = _arrow->_z;
+ _pressed->_flags |= 4;
+}
+
+// CExit::StopRotate (14401C)
+void Exit::stopRotate() {
+ setAngle(_newAngle);
+ setState(1);
+ _newAngle = 0;
+ _turnAngle = 0;
+}
+
+// CExit::SetOffset (1442EC)
+void Exit::setOffset(float x, float y) {
+ _offsetX = x;
+ _offsetY = y;
+ if (_arrow) {
+ const Common::Point center = pictureCenter();
+ _centerX = center.x;
+ _centerY = center.y;
+ _arrow->setCenter(Common::Point(_centerX, _centerY));
+ _arrow->setCenter(Common::Point(_centerX + _offsetX, _centerY + _offsetY));
+ }
+}
+
+// CExit::RemoveFromScene (143E94)
+void Exit::removeFromScene() {
+ _scene->removeAni(_arrow);
+ _scene->removePicture(_pressed);
+}
+
+// CExit::DeleteArrow (143EAA): the objects leave the scene and are not owned any more
+void Exit::deleteArrow() {
+ delete _arrow;
+ _arrow = nullptr;
+ _pressed = nullptr; // Scene::removePicture deleted it
+}
+
+// CExit::OnUpdate (144038)
+void Exit::onUpdate(uint32 elapsed, float heroZ) {
+ if (_state == 3) {
+ bool up;
+ float angle;
+ if (_newAngle <= _turnAngle) {
+ angle = _turnAngle - elapsed * 0.4f;
+ up = false;
+ } else {
+ angle = _turnAngle + elapsed * 0.4f;
+ up = true;
+ }
+ _turnAngle = angle;
+ setAngle(_turnAngle);
+ if (up ? _turnAngle >= _newAngle : _turnAngle <= _newAngle)
+ stopRotate();
+ }
+ if (!_fixedZ) {
+ float z = heroZ + 1.0f;
+ if (_intersect) {
+ const float pictureZ = _picture->_z;
+ if (z >= pictureZ && (_picture->_flags & 4))
+ z = pictureZ - 1.0f;
+ }
+ _arrow->_z = z;
+ }
+ if (_hintTime >= 0)
+ _hintTime += elapsed;
+ if (_hintTime > 1999) {
+ _hintTime = -1;
+ _hint.clear();
+ }
+ if (_releaseTime != -1) {
+ _releaseTime += elapsed;
+ if (_releaseTime > 82) {
+ _releaseTime = -1;
+ setState(1);
+ _pressed->_flags &= ~4;
+ }
+ }
+}
+
+// CExit::OnRender (143CAC): the hint of a new level
+void Exit::onRender(float scrollX, float scrollY) {
+ if (_hint.empty())
+ return;
+ float offsetY = -30.0f;
+ float offsetX = 0;
+ if (_angle == 0.0f || _angle == 180.0f) {
+ offsetY = -45.0f;
+ offsetX = -20.0f;
+ } else if (_angle == -90.0f) {
+ offsetX = -25.0f;
+ }
+ if ((_arrow->_y - scrollY) + offsetY < 50.0f)
+ offsetY = 100.0f;
+ const BitmapFont *font = g_ngi->getFont("impact_20.fnt");
+ if (font)
+ font->print(g_ngi->_backgroundSurface, _hint, (_arrow->_x - scrollX) + offsetX, (_arrow->_y - scrollY) + offsetY, 120.0f, 0, BitmapFont::kAlignCenter, 0);
+}
+
+// CExit::OnMouseLKeyDown (144150)
+void Exit::onMouseLKeyDown(float x, float y) {
+ if (_state == 0)
+ return;
+ if (_state == 3)
+ stopRotate();
+ if (_picture->hit(x, y)) {
+ if (Sound *sound = g_ngi->findSound(kPressSound))
+ sound->play(0, 0);
+ setState(2);
+ }
+ if (_arrow->hit(x, y) && _type == 1) {
+ _hint = g_ngi->_textContainer->getText("STR_HINTS_NEWLEVEL");
+ _hintTime = 0;
+ }
+}
+
+// CExit::OnMouseLKeyUp (143E28)
+void Exit::onMouseLKeyUp(float x, float y) {
+ if (_state == 2)
+ _releaseTime = 0;
+}
+
+// CExit::OnMouseMove (143FE0)
+void Exit::onMouseMove(float x, float y) {
+ if (_state == 0)
+ return;
+ if (_picture->hit(x, y)) {
+ setState(2);
+ } else if (_state == 2) {
+ setState(1);
+ _pressed->_flags &= ~4;
+ }
+}
+
+// CExitManager::CExitManager
+ExitManager::ExitManager() {
+}
+
+// CExitManager::~CExitManager
+ExitManager::~ExitManager() {
+ clear();
+}
+
+// CExitManager::Clear (14448A)
+void ExitManager::clear() {
+ for (uint i = 0; i < _exits.size(); i++)
+ delete _exits[i];
+ _exits.clear();
+ _sceneExits.clear();
+}
+
+// CExitManager::Init (144DBC)
+void ExitManager::init(const char *path, Scene *scene) {
+ if (!_document) {
+ _document.reset(loadXmlDocument(path));
+ if (!_document) {
+ warning("Could not read %s", path);
+ return;
+ }
+ }
+ const XmlNode &root = _document->first();
+ for (uint i = 0; i < root.childCount(); i++) {
+ if (root[i].name() != "EXIT")
+ continue;
+ const int pictureId = findId(root[i].attrStr("vis_dst", ""));
+ Scene *owner = scene;
+ if (owner && !owner->findPictureObjectById(pictureId, 0))
+ continue;
+ if (!owner)
+ owner = findSceneOfPicture(pictureId);
+ Exit *exit = find(pictureId);
+ if (exit) {
+ // the exits of a scene that is loaded again are not changed
+ if (!scene && owner)
+ exit->loadParam(root[i], *owner);
+ } else if (owner) {
+ exit = new Exit();
+ if (exit->init(root[i], *owner))
+ _exits.push_back(exit);
+ else
+ delete exit;
+ }
+ }
+}
+
+// CExitManager::OnUpdate (144388)
+void ExitManager::onUpdate(uint32 elapsed, float heroZ) {
+ for (uint i = 0; i < _sceneExits.size(); i++)
+ _sceneExits[i]->onUpdate(elapsed, heroZ);
+}
+
+// CExitManager::GetState (1443B0): 2 when an exit is pressed
+int ExitManager::getState() const {
+ for (uint i = 0; i < _sceneExits.size(); i++) {
+ if (_sceneExits[i]->getState() == 2)
+ return 2;
+ }
+ return 0;
+}
+
+// CExitManager::OnRender (1443D6)
+void ExitManager::onRender(float scrollX, float scrollY) {
+ for (uint i = 0; i < _sceneExits.size(); i++)
+ _sceneExits[i]->onRender(scrollX, scrollY);
+}
+
+// CExitManager::OnMouseLKeyDown (144400)
+void ExitManager::onMouseLKeyDown(float x, float y) {
+ _pressed = true;
+ for (uint i = 0; i < _sceneExits.size(); i++)
+ _sceneExits[i]->onMouseLKeyDown(x, y);
+}
+
+// CExitManager::OnMouseLKeyUp (14442E)
+void ExitManager::onMouseLKeyUp(float x, float y) {
+ _pressed = false;
+ for (uint i = 0; i < _sceneExits.size(); i++)
+ _sceneExits[i]->onMouseLKeyUp(x, y);
+}
+
+// CExitManager::OnMouseMove (14445A)
+void ExitManager::onMouseMove(float x, float y) {
+ for (uint i = 0; i < _sceneExits.size(); i++) {
+ if (_pressed)
+ _sceneExits[i]->onMouseMove(x, y);
+ }
+}
+
+// CExitManager::Find (14450C)
+Exit *ExitManager::find(uint pictureId) const {
+ for (uint i = 0; i < _exits.size(); i++) {
+ if ((uint)_exits[i]->getVisId() == pictureId)
+ return _exits[i];
+ }
+ return nullptr;
+}
+
+// CExitManager::GetExitState (14453A)
+int ExitManager::getExitState(uint pictureId) const {
+ if (Exit *exit = find(pictureId))
+ return exit->getState();
+ return 0;
+}
+
+// CExitManager::GetExitAngle (14454C)
+float ExitManager::getExitAngle(uint pictureId) const {
+ if (Exit *exit = find(pictureId))
+ return exit->getAngle();
+ return -1.0f;
+}
+
+// CExitManager::GetExitDestAngle (144564)
+float ExitManager::getExitDestAngle(uint pictureId) const {
+ if (Exit *exit = find(pictureId))
+ return exit->getDestAngle();
+ return -1.0f;
+}
+
+// CExitManager::ResetExitIntersect (14457C)
+void ExitManager::resetExitIntersect(uint pictureId, bool intersect) {
+ if (Exit *exit = find(pictureId))
+ exit->resetIntersect(intersect);
+}
+
+// CExitManager::SetExitState (144590)
+void ExitManager::setExitState(uint pictureId, int state) {
+ if (Exit *exit = find(pictureId))
+ exit->setState(state);
+}
+
+// CExitManager::SetExitAngle (1445A4)
+void ExitManager::setExitAngle(uint pictureId, float angle) {
+ if (Exit *exit = find(pictureId))
+ exit->setAngle(angle);
+}
+
+// CExitManager::SetExitOffset (1445B8)
+void ExitManager::setExitOffset(uint pictureId, float x, float y) {
+ if (Exit *exit = find(pictureId))
+ exit->setOffset(x, y);
+}
+
+// CExitManager::SetFixedZ (1445D0)
+void ExitManager::setFixedZ(uint pictureId, bool fixedZ) {
+ if (Exit *exit = find(pictureId))
+ exit->setFixedZ(fixedZ);
+}
+
+// CExitManager::RotateArrow (1445E4): MSG_TOLADDER turns the arrow around, MSG_FROMLADDER back
+void ExitManager::rotateArrow(uint pictureId, const Common::String &where) {
+ Exit *exit = find(pictureId);
+ if (!exit)
+ return;
+ float angle = 0.0f;
+ if (where == "MSG_TOLADDER") {
+ angle = exit->getAngle() + 180.0f;
+ if (angle >= 360.0f)
+ angle -= 360.0f;
+ } else if (where == "MSG_FROMLADDER") {
+ angle = exit->getAngle() - 180.0f;
+ if (angle < 0.0f)
+ angle += 360.0f;
+ }
+ if (angle != exit->getAngle()) {
+ exit->setNewAngle(angle);
+ exit->setState(3);
+ }
+}
+
+// CExitManager::OnShow (144D5C): the exits of the scene
+void ExitManager::onShow(int sceneId) {
+ _pressed = false;
+ for (uint i = 0; i < _sceneExits.size(); i++)
+ _sceneExits[i]->onHide();
+ _sceneExits.clear();
+ for (uint i = 0; i < _exits.size(); i++) {
+ if (_exits[i] && sceneId == _exits[i]->getSceneId()) {
+ _exits[i]->onShow();
+ _sceneExits.push_back(_exits[i]);
+ }
+ }
+}
+
+// CExitManager::ReLoad (144F98)
+void ExitManager::reLoad(int sceneId) {
+ for (uint i = 0; i < _exits.size(); i++) {
+ _exits[i]->removeFromScene();
+ _exits[i]->deleteArrow();
+ }
+ clear();
+ init("data/exits.xml", nullptr);
+ onShow(sceneId);
+}
+
+// CExitManager::GetExitNum (16246A)
+Exit *ExitManager::getExitNum(int index) const {
+ if ((int)_exits.size() <= index)
+ return nullptr;
+ return _exits[index];
+}
+
+// CExitManager::SetXmlData (144AE8)
+void ExitManager::setXmlData(const XmlNode &node) {
+ for (uint i = 0; i < node.childCount(); i++) {
+ if (node[i].name() != "EXIT")
+ continue;
+ const int id = findId(node[i].attrStr("vis_dst", ""));
+ setExitState(id, node[i].attrInt("curState", 1));
+ setExitAngle(id, node[i].attrFloat("angle", 0.0f));
+ resetExitIntersect(id, node[i].attrBool("intersect", false));
+ const XmlVector2 offset = node[i].attrVector2("offset", 0, 0);
+ setExitOffset(id, offset.x, offset.y);
+ }
+}
+
+// CExitManager::CleanXml (144F64): the exits are read again
+void ExitManager::cleanXml() {
+ _sceneExits.clear();
+ init("data/exits.xml", nullptr);
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/exitmanager.h b/engines/ngi/fullpipe/exitmanager.h
new file mode 100644
index 00000000000..a2d124ae47d
--- /dev/null
+++ b/engines/ngi/fullpipe/exitmanager.h
@@ -0,0 +1,141 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_EXITMANAGER_H
+#define NGI_FULLPIPE_EXITMANAGER_H
+
+#include "common/array.h"
+#include "common/ptr.h"
+#include "common/rect.h"
+#include "common/str.h"
+
+#include "ngi/xmlnode.h"
+
+namespace NGI {
+
+class AniObject;
+class PictureObject;
+class Scene;
+
+/** CExit, the arrow over a picture that leads into another scene (exits.xml EXIT); states:
+ 0 hidden, 1 shown, 2 pressed, 3 turning to a new angle (0.4 degree per ms) */
+class Exit {
+public:
+ Exit();
+ ~Exit();
+
+ /** CExit::Init: false when the picture is not in a scene that is loaded */
+ bool init(const XmlNode &node, Scene &scene);
+ /** CExit::LoadParam: reads the parameters of an exit that exists */
+ void loadParam(const XmlNode &node, Scene &scene);
+ void onHide();
+ void onShow();
+ void onRender(float scrollX, float scrollY);
+ void onUpdate(uint32 elapsed, float heroZ);
+ void onMouseLKeyDown(float x, float y);
+ void onMouseLKeyUp(float x, float y);
+ void onMouseMove(float x, float y);
+ int getSceneId() const;
+ int getState() const { return _state; }
+ void setState(int state);
+ void setAngle(float angle);
+ float getAngle() const { return _angle; }
+ float getDestAngle() const { return _state == 3 ? _newAngle : _angle; }
+ void setNewAngle(float angle);
+ void removeFromScene();
+ void deleteArrow();
+ int getVisId() const;
+ void resetIntersect(bool intersect) { _intersect = intersect; }
+ void initPicPressed();
+ void stopRotate();
+ void setOffset(float x, float y);
+ void setFixedZ(bool fixedZ) { _fixedZ = fixedZ; }
+
+private:
+ AniObject *_arrow = nullptr; // +0
+ PictureObject *_picture = nullptr; // +4: "vis_dst"
+ PictureObject *_pressed = nullptr; // +8: the arrow when it is pressed
+ Scene *_scene = nullptr; // +12
+ float _centerX = 0; // +16: the center of the picture
+ float _centerY = 0; // +20
+ float _offsetX = 0; // +24
+ float _offsetY = 0; // +28
+ float _angle = 0; // +32
+ float _newAngle = 0; // +36
+ float _turnAngle = 0; // +40: the angle while it turns
+ int _state = 0; // +44
+ bool _intersect = false; // +48
+ bool _fixedZ = false; // +49: "z" is given
+ int _arrowCopyId = 0; // +52
+ int _type = 0; // +56: 0 the arrow, 1 the arrow of a new level
+ int _releaseTime = -1; // +60
+ Common::String _hint; // +64
+ int _hintTime = -1; // +68
+
+ void createAndAddInScene();
+ Common::Point pictureCenter() const;
+};
+
+/** CExitManager (CSingleton, NGIEngine::_exitManager): the exits of all scenes */
+class ExitManager {
+public:
+ ExitManager();
+ ~ExitManager();
+
+ /** CExitManager::Init: the original loads all exits.xml scenes; here the exits of the scene just
+ loaded are made (`scene`), existing ones stay */
+ void init(const char *path, Scene *scene);
+ void onUpdate(uint32 elapsed, float heroZ);
+ int getState() const;
+ void onRender(float scrollX, float scrollY);
+ void onMouseLKeyDown(float x, float y);
+ void onMouseLKeyUp(float x, float y);
+ void onMouseMove(float x, float y);
+ void clear();
+ Exit *find(uint pictureId) const;
+ int getExitState(uint pictureId) const;
+ float getExitAngle(uint pictureId) const;
+ float getExitDestAngle(uint pictureId) const;
+ void resetExitIntersect(uint pictureId, bool intersect);
+ void setExitState(uint pictureId, int state);
+ void setExitAngle(uint pictureId, float angle);
+ void setExitOffset(uint pictureId, float x, float y);
+ void setFixedZ(uint pictureId, bool fixedZ);
+ void rotateArrow(uint pictureId, const Common::String &where);
+ /** CExitManager::OnShow: the exits of the scene are the ones of the controller */
+ void onShow(int sceneId);
+ void reLoad(int sceneId);
+ Exit *getExitNum(int index) const;
+ uint getNumExits() const { return _exits.size(); }
+ /** CExitManager::SetXmlData and CleanXml: the saved state */
+ void setXmlData(const XmlNode &node);
+ void cleanXml();
+
+private:
+ Common::Array<Exit *> _exits; // +8
+ Common::Array<Exit *> _sceneExits; // +20
+ bool _pressed = false; // +32
+ Common::ScopedPtr<XmlNode> _document; // exits.xml
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_EXITMANAGER_H
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 2eccf6389b0..222877db769 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -37,6 +37,7 @@
#include "ngi/fullpipe/scenes.h"
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/fpcontroller.h"
+#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/guimanager.h"
#include "ngi/inventory.h"
@@ -117,11 +118,11 @@ void FPController::executeUserCmd(Command *cmd, MessageQueue *queue) {
} else if (type == "SET_EXIT_STATE") {
const int id = findId(cmd->_args.getValOrDefault("picId"));
if (id)
- scene->setExitState(id, atoi(cmd->_args.getValOrDefault("state").c_str()));
+ g_ngi->_exitManager->setExitState(id, atoi(cmd->_args.getValOrDefault("state").c_str()));
} else if (type == "EXIT_ROTATE") {
- scene->rotateExit(findId(cmd->_args.getValOrDefault("picId")), cmd->_args.getValOrDefault("where"));
+ g_ngi->_exitManager->rotateArrow(findId(cmd->_args.getValOrDefault("picId")), cmd->_args.getValOrDefault("where"));
} else if (type == "EXIT_RESET_INTERSECT") {
- scene->resetExitIntersect(findId(cmd->_args.getValOrDefault("picId")), boolArg(cmd, "intersect"));
+ g_ngi->_exitManager->resetExitIntersect(findId(cmd->_args.getValOrDefault("picId")), boolArg(cmd, "intersect"));
} else if (type == "TASK_ACTIVATE") {
const Common::String taskId = cmd->_args.getValOrDefault("taskId");
if (g_ngi->_taskManager && !(boolArg(cmd, "check_closed") && g_ngi->_taskManager->isTaskClosed(taskId)))
@@ -213,6 +214,10 @@ void FPController::onShow() {
if (PictureObject *button = _scene->findPictureObjectById(PIC_SC8_ARCADENOW, 0))
button->_flags &= ~4;
+
+ // CExitManager::OnShow: the exits of a scene that does not lie over another one
+ if (!_scene->_putPrev)
+ g_ngi->_exitManager->onShow(_scene->_sceneId);
}
// CFPController::ResetSwipeParams
@@ -523,6 +528,8 @@ void FPController::onUpdate(uint32 elapsed) {
testScroll();
}
testSwipe();
+ // CExitManager::OnUpdate; the original has no test for a missing hero
+ g_ngi->_exitManager->onUpdate(elapsed, hero() ? hero()->_z : -1000.0f);
if (_scene->_x != oldX || _scene->_y != oldY) {
debugC(2, kDebugSceneLogic, "camera %d -> %d (target %g, follow %d)", oldX, _scene->_x, _targetX, _follow != nullptr);
g_ngi->_sceneRect.moveTo(_scene->_x, _scene->_y);
@@ -716,6 +723,7 @@ void FPController::testSwipe() {
// CFPController::OnMouseLKeyDown, the part after the exit manager and the achievements: the touch starts (CanSwipeMan)
bool FPController::onMouseLKeyDown(uint32 id, float x, float y) {
+ g_ngi->_exitManager->onMouseLKeyDown(x, y);
if (!canSwipeMan(x, y))
return false;
_touching = true;
@@ -877,8 +885,20 @@ void FPController::onRenderBottom(Common::Point) {
// CFPController::OnRenderTop: the exit labels and the achievements (not implemented), black bars where the camera leaves the scene,
// then the tremble effect
+// CFPController::OnMouseMove: the pressed exits follow the finger (the achievements are not ported)
+bool FPController::onMouseMove(uint32 id, float x, float y) {
+ g_ngi->_exitManager->onMouseMove(x, y);
+ return false;
+}
+
+// CFPController::OnMouseLKeyUpTop: the part of the exits (the marker of the tap and the object helper are not ported)
+bool FPController::onMouseLKeyUpTop(uint32 id, float x, float y) {
+ g_ngi->_exitManager->onMouseLKeyUp(x, y);
+ return false;
+}
+
void FPController::onRenderTop(Common::Point scroll) {
- // CExitManager::OnRender draws the title of every exit that has one (CExit +64), none of the 2015 data sets it
+ g_ngi->_exitManager->onRender(scroll.x, scroll.y);
static bool warned = false;
if (!warned) {
warned = true;
diff --git a/engines/ngi/fullpipe/fpcontroller.h b/engines/ngi/fullpipe/fpcontroller.h
index 6838fd330e5..9aa422e4a0e 100644
--- a/engines/ngi/fullpipe/fpcontroller.h
+++ b/engines/ngi/fullpipe/fpcontroller.h
@@ -49,6 +49,9 @@ public:
bool onMouseLKeyDown(uint32 id, float x, float y) override;
/** The swipe part of CFPController::OnMouseLKeyUp, then the tap (onTap) unless the touch was a swipe or a scroll */
bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ /** CFPController::OnMouseMove and OnMouseLKeyUpTop: the exits */
+ bool onMouseMove(uint32 id, float x, float y) override;
+ bool onMouseLKeyUpTop(uint32 id, float x, float y) override;
void executeUserCmd(Command *cmd, MessageQueue *queue) override;
bool updateUserCmd(Command *cmd, uint32 elapsed) override;
bool isInventoryEnabled() override { return true; }
diff --git a/engines/ngi/fullpipe/inventorycontroller.cpp b/engines/ngi/fullpipe/inventorycontroller.cpp
index 8963006b606..c2e852ac15f 100644
--- a/engines/ngi/fullpipe/inventorycontroller.cpp
+++ b/engines/ngi/fullpipe/inventorycontroller.cpp
@@ -106,7 +106,7 @@ void InventoryController::onRenderTop(Common::Point scroll) {
warnOnce("CTutorialController::OnRenderAfterInventory: the tutorial scene is not ported");
if (!_helperPicture)
_helperPicture = _scene->findPictureObjectById(11028, 0);
- if (_helperVisible)
+ if (_helperVisible && _helperPicture)
_helperPicture->render(Common::Point());
}
diff --git a/engines/ngi/fullpipe/inventorycontroller.h b/engines/ngi/fullpipe/inventorycontroller.h
index 330e0e7cc8e..8ab19362320 100644
--- a/engines/ngi/fullpipe/inventorycontroller.h
+++ b/engines/ngi/fullpipe/inventorycontroller.h
@@ -59,6 +59,8 @@ public:
/** HideTaskButtons, RemoveTaskButtons, UpdateTaskButtons: slide out right, forget, add/remove */
void hideTaskButtons() { _hideTaskButtons = true; }
void removeTaskButtons() { _taskButtons.clear(); }
+ /** CInventoryController +12: the marker of the tutorial skip button is drawn (OnRenderTop) */
+ void setHelperVisible(bool visible) { _helperVisible = visible; }
void updateTaskButtons(GuiElement *button, bool add);
private:
diff --git a/engines/ngi/fullpipe/scene01.cpp b/engines/ngi/fullpipe/scene01.cpp
index e8243ec335b..3ee7ed58b22 100644
--- a/engines/ngi/fullpipe/scene01.cpp
+++ b/engines/ngi/fullpipe/scene01.cpp
@@ -24,6 +24,9 @@
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/scenecontrollers.h"
#include "ngi/guimanager.h"
+#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/inventorycontroller.h"
+#include "ngi/fullpipe/tutorialmanager.h"
#include "ngi/input.h"
#include "ngi/inventory.h"
@@ -71,9 +74,9 @@ void scene01_initObjects(Scene *sc, int entrance, bool eggUncracked) {
}
}
-// CSc01Controller::OnGuiEvent: the skip button of the tutorial (BTN_SKIP of the inventory) deactivates the tutorial, hides itself and opens the exits
-// of the scenes 1 and 3. ADAPTATIONS: CTutorialManager::Deactivate is the TutorialDisabled variable, the exits are the ones of Scene::_exits
-// (D10, CExitManager) and the flag that the original clears in the inventory controller (+12) is not ported.
+// CSc01Controller::OnGuiEvent: the skip button of the tutorial (BTN_SKIP of the inventory) deactivates the tutorials, hides the helper of the inventory
+// and itself and shows the exits of the scenes 1 and 3. The two variables are what the tutorial of ModalTutorial (sceneTutorial.cpp) reads, until the
+// controller of the tutorials replaces it (D05/D19).
void Sc01Controller::onGuiEvent(const Common::String &id, const Common::String &event) {
FPController::onGuiEvent(id, event);
if (event != "unpress" || id != "BTN_SKIP")
@@ -81,11 +84,15 @@ void Sc01Controller::onGuiEvent(const Common::String &id, const Common::String &
GameVar *root = g_ngi->getGameLoaderGameVar();
root->setSubVarAsInt("TutorialDisabled", 1);
root->setSubVarAsInt("Scene1ExitsDisabled", 0);
- if (g_ngi->_inventoryScene && g_ngi->_inventoryScene->_guiManager) {
- if (GuiElement *button = g_ngi->_inventoryScene->_guiManager->getElement(id))
- button->hideAndDeactivate();
+ g_ngi->_tutorialManager->deactivate();
+ static_cast<InventoryController *>(g_ngi->_inventory->_controller.get())->setHelperVisible(false);
+ if (GuiElement *button = g_ngi->_inventory->_guiManager->getElement("BTN_SKIP"))
+ button->hideAndDeactivate();
+ for (uint i = 0; i < g_ngi->_exitManager->getNumExits(); i++) {
+ Exit *exit = g_ngi->_exitManager->getExitNum(i);
+ if (exit->getSceneId() == SC_1 || exit->getSceneId() == SC_3)
+ exit->setState(1);
}
- _scene->setExitState(0, 1);
}
// CSc01Controller::IsInventoryEnabled: the inventory works when the entrance queue of the scene has finished, and while it runs only the skip button does
@@ -129,12 +136,15 @@ int sceneHandler01(Command *cmd) {
}
if (cmd->_messageName == "MSG_DISABLE_EXIT_MANAGER") {
g_ngi->getGameLoaderGameVar()->setSubVarAsInt("Scene1ExitsDisabled", 1);
- g_ngi->_currentScene->setExitState(0, 0);
- Scene *inventory = g_ngi->_inventoryScene;
- if (inventory && inventory->_guiManager) {
- if (GuiElement *skip = inventory->_guiManager->getElement("BTN_SKIP"))
- skip->showAndActivate();
+ // CSc01Controller::OnMessage: the helper of the inventory, the exits of the scene are hidden, the skip button shows
+ static_cast<InventoryController *>(g_ngi->_inventory->_controller.get())->setHelperVisible(true);
+ for (uint i = 0; i < g_ngi->_exitManager->getNumExits(); i++) {
+ Exit *exit = g_ngi->_exitManager->getExitNum(i);
+ if (exit->getSceneId() == g_ngi->_currentScene->_sceneId)
+ exit->setState(0);
}
+ if (GuiElement *skip = g_ngi->_inventory->_guiManager->getElement("BTN_SKIP"))
+ skip->showAndActivate();
return 0;
}
if (cmd->_messageName == "MSG_DEACT_OBJ_SC1") {
diff --git a/engines/ngi/fullpipe/sceneTutorial.cpp b/engines/ngi/fullpipe/sceneTutorial.cpp
index 0c14fa31195..473f8e86a80 100644
--- a/engines/ngi/fullpipe/sceneTutorial.cpp
+++ b/engines/ngi/fullpipe/sceneTutorial.cpp
@@ -29,6 +29,7 @@
#include "ngi/motion.h"
#include "ngi/fullpipe/scenes.h"
#include "ngi/fullpipe/fpcontroller.h"
+#include "ngi/fullpipe/exitmanager.h"
#include "ngi/statics.h"
#include "common/formats/xmlparser.h"
@@ -44,6 +45,15 @@ int resourceId(const Common::String &name) {
return g_ngi->_gameProject->_objectIds.findId(name, id) ? id : 0;
}
+// The exits of the current scene (the tutorial of this file does it for all of them, the controller of the original by scene number, see CTutorialController::SetExitManagerActivity)
+void setSceneExits(int state) {
+ for (uint i = 0; i < g_ngi->_exitManager->getNumExits(); i++) {
+ Exit *exit = g_ngi->_exitManager->getExitNum(i);
+ if (exit->getSceneId() == g_ngi->_currentScene->_sceneId)
+ exit->setState(state);
+ }
+}
+
class Tutorial : public Common::XMLParser {
public:
explicit Tutorial(const char *id) : _id(id) {}
@@ -129,9 +139,9 @@ public:
_man->_statics = _man->getStatic(resourceId("ST_SC_TUTORIAL_BEARDED_UP"));
_man->_flags = 4 | (_layout._mirror ? 8 : 0);
_man->startMovement(resourceId("MOV_SC_TUTORIAL_BEARDED_FALL"), 0, -1, _layout._mirror);
- g_ngi->_currentScene->setExitState(0, 0);
+ setSceneExits(0);
if (_step == kUseTransition)
- g_ngi->_currentScene->setExitState(resourceId("PIC_SC1_RTRUBA"), 1);
+ g_ngi->_exitManager->setExitState(resourceId("PIC_SC1_RTRUBA"), 1);
debugC(1, kDebugSceneLogic, "Started %s", tutorialIds[_step]);
return true;
}
@@ -248,7 +258,7 @@ public:
}
}
root->setSubVarAsInt("TutorialStep", _step + 1);
- g_ngi->_currentScene->setExitState(0, 1);
+ setSceneExits(1);
_finished = true;
debugC(1, kDebugSceneLogic, "Finished %s", tutorialIds[_step]);
return true;
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index b80ba1b3864..bb1d3333866 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -708,8 +708,6 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
scene->_motionController->attachObject(_aniMan);
scene->_motionController->activate();
}
- if (common && !scene->_exits.empty())
- scene->initExits(*common);
if (intro2) {
sceneIntro_initGui(*scene, *intro2, gameWidth());
sceneIntro_initMan(*scene);
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 8b81eae9d2a..3db59798159 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -81,6 +81,7 @@ MODULE_OBJS = \
fullpipe/arcadeinterface.o \
fullpipe/chaptercontroller.o \
fullpipe/chaptermanager.o \
+ fullpipe/exitmanager.o \
fullpipe/floaters.o \
fullpipe/fpcontroller.o \
fullpipe/inventorycontroller.o \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 9c65dbc66a4..237d8ae0b09 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -40,6 +40,7 @@
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/tutorialmanager.h"
#include "ngi/fullpipe/testmode.h"
#include "ngi/debugger/debugtools.h"
@@ -344,8 +345,6 @@ bool NGIEngine::handleGuiEvent(const Common::Event &event) {
_modalObject->handleMessage(&cmd);
}
} else {
- if (event.type == Common::EVENT_LBUTTONUP || event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_MOUSEMOVE)
- _currentScene->updateExitInput(event.mouse, event.type);
GuiManager *manager = _currentScene->_guiManager.get();
// CGame::OnMouse*: a hit inventory handles the event alone, else the scene and then the inventory
if (inventoryHitByMouseEvent(event)) {
@@ -372,6 +371,10 @@ bool NGIEngine::handleSceneEvent(const Common::Event &event, GuiManager *manager
const float sceneY = event.mouse.y + _currentScene->_y;
if (sceneTouch && event.type == Common::EVENT_LBUTTONDOWN && !onGui)
controller.onMouseLKeyDown(0, sceneX, sceneY);
+ if (sceneTouch && event.type == Common::EVENT_MOUSEMOVE)
+ controller.onMouseMove(0, sceneX, sceneY);
+ if (sceneTouch && event.type == Common::EVENT_LBUTTONUP)
+ controller.onMouseLKeyUpTop(0, sceneX, sceneY);
if (sceneTouch && event.type == Common::EVENT_LBUTTONUP) {
if (onGui)
controller.resetSwipeParams(); // the touch started on the scene and ended over a button
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 3ee46e39a3c..0106c64cf8b 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -93,6 +93,7 @@ class Command;
class FlyPack;
class TaskManager;
class TutorialManager;
+class ExitManager;
class Tremble;
class ArcadeInterface;
class BitmapFont;
@@ -303,6 +304,8 @@ public:
Common::ScopedPtr<TaskManager> _taskManager;
/** CSingleton<CTutorialManager>: the tutorials of tutorials.xml (Android) */
Common::ScopedPtr<TutorialManager> _tutorialManager;
+ /** CSingleton<CExitManager>: the exits of the scenes (Android) */
+ Common::ScopedPtr<ExitManager> _exitManager;
Common::ScopedPtr<Tremble> _tremble;
Common::ScopedPtr<ArcadeInterface> _arcadeInterface;
Common::ScopedPtr<ChapterManager> _chapterManager;
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index b6620187587..1120262a7e6 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -311,131 +311,6 @@ void SceneTag::loadScene() {
Scene::Scene() : _sceneId(0), _field_BC(0) {}
-void Exit::setState(int newState) {
- state = newState;
- releaseTime = -1;
- if (!arrow)
- return;
- if (state == 3)
- return; // rotating: the arrow keeps its current look (CExit::SetState does nothing for 3)
- if (state == 1) {
- arrow->_flags |= 4;
- pressed->_flags &= ~4;
- if (!arrow->_movement)
- arrow->startMovement(movementId, 0, -1);
- } else {
- arrow->_flags &= ~4;
- if (state == 2)
- pressed->_flags |= 4;
- else
- pressed->_flags &= ~4;
- }
-}
-
-// CExit::SetAngle
-void Exit::setAngle(float degrees) {
- angle = degrees;
- if (arrow)
- arrow->_rotation = pressed->_rotation = Math::deg2rad(degrees);
-}
-
-// CExitManager::RotateArrow: MSG_TOLADDER turns the arrow around, MSG_FROMLADDER turns it back, anything else sets 0
-void Exit::rotateTo(const Common::String &where) {
- float target = 0.0f;
- if (where == "MSG_TOLADDER") {
- target = angle + 180.0f;
- if (target >= 360.0f)
- target -= 360.0f;
- } else if (where == "MSG_FROMLADDER") {
- target = angle - 180.0f;
- if (target < 0.0f)
- target += 360.0f;
- }
- if (target != angle) {
- newAngle = target;
- setState(3);
- }
-}
-
-// CExit::OnUpdate, rotating part
-void Exit::updateRotation(uint32 elapsed) {
- if (state != 3)
- return;
- const bool up = newAngle > angle;
- setAngle(angle + (up ? 1 : -1) * elapsed * 0.4f);
- if (up ? angle >= newAngle : angle <= newAngle) {
- // CExit::StopRotate
- setAngle(newAngle);
- setState(1);
- newAngle = 0;
- }
-}
-
-void Scene::initExits(Scene &common) {
- for (Exit &exit : _exits) {
- if (!exit.arrow) {
- AniObject *animation = common.findAniObjectById(23234, 0); // ANI_ARROW
- PictureObject *picture = common.findPictureObjectById(23237, 0); // PIC_ARROW_RED
- if (!animation || !picture) {
- warning("Missing Full Pipe exit artwork");
- continue;
- }
- exit.arrow = new AniObject(animation);
- addAni(exit.arrow, true);
- exit.arrow->_statics = exit.arrow->getStatic(animation->_statics->_staticsId);
- exit.pressed = new PictureObject(picture);
- addPicture(exit.pressed);
- exit.movementId = 23236; // MOV_ARROW_UP
- const Dims size = exit.destination->getFullSize();
- Common::Rect area = exit.destination->_hitRegion;
- if (area.isEmpty())
- area = Common::Rect(size.x, size.y);
- const Common::Point center = area.center() + exit.offset + Common::Point(exit.destination->_x, exit.destination->_y);
- const Dims pressedSize = exit.pressed->getFullSize();
- const Dims arrowSize = exit.arrow->getFullSize();
- exit.arrow->setPos(center.x - arrowSize.x / 2, center.y - arrowSize.y / 2);
- exit.pressed->setPos(center.x - pressedSize.x / 2, center.y - pressedSize.y / 2);
- exit.arrow->_rotation = exit.pressed->_rotation = Math::deg2rad(exit.angle);
- exit.arrow->_objectFlags = exit.pressed->_objectFlags = 0;
- }
- exit.setState(exit.state);
- }
-}
-
-void Scene::setExitState(int pictureId, int state) {
- for (Exit &exit : _exits)
- if (!pictureId || exit.destination->_id == pictureId)
- exit.setState(state);
-}
-
-void Scene::rotateExit(int pictureId, const Common::String &where) {
- for (Exit &exit : _exits)
- if (exit.destination->_id == pictureId)
- exit.rotateTo(where);
-}
-
-void Scene::resetExitIntersect(int pictureId, bool intersect) {
- for (Exit &exit : _exits)
- if (exit.destination->_id == pictureId)
- exit.intersect = intersect;
-}
-
-void Scene::updateExitInput(Common::Point pos, Common::EventType type) {
- for (Exit &exit : _exits) {
- if (!exit.arrow || !exit.state)
- continue;
- const bool hit = exit.destination->hit(pos.x + _x, pos.y + _y);
- if (type == Common::EVENT_LBUTTONUP && exit.state == 2)
- exit.releaseTime = 0;
- else if (hit && (type == Common::EVENT_LBUTTONDOWN || type == Common::EVENT_MOUSEMOVE)) {
- exit.setState(2);
- if (type == Common::EVENT_LBUTTONDOWN)
- g_ngi->playSound(0x5ac6, 0);
- } else if (!hit && type == Common::EVENT_MOUSEMOVE && exit.state == 2)
- exit.setState(1);
- }
-}
-
void Scene::onGuiEvent(const Common::String &id, const Common::String &event) {
if (_controller)
_controller->onGuiEvent(id, event);
@@ -1210,19 +1085,6 @@ bool Scene::update(int counterdiff) {
bool changed = false;
if (g_ngi->_gameVersion >= 201509) {
- for (Exit &exit : _exits) {
- if (!exit.arrow)
- continue;
- if (exit.releaseTime >= 0 && (exit.releaseTime += counterdiff) > 82)
- exit.setState(1);
- if (exit.state == 1 && !exit.arrow->_movement)
- exit.arrow->startMovement(exit.movementId, 0, -1);
- exit.updateRotation(counterdiff);
- int z = g_ngi->_aniMan ? g_ngi->_aniMan->_z + 1 : exit.destination->_z - 1;
- if (exit.intersect && z >= exit.destination->_z && (exit.destination->_flags & 4))
- z = exit.destination->_z - 1;
- exit.arrow->_z = exit.pressed->_z = z;
- }
if (_behaviorController)
changed |= _behaviorController->update(counterdiff);
for (MessageQueue *queue : *g_ngi->_globalMessageQueueList)
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 6895aa07229..4185faff9c6 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -42,22 +42,6 @@ class Selection;
class Motion8Controller;
class ZController;
-struct Exit {
- PictureObject *destination = nullptr;
- AniObject *arrow = nullptr;
- PictureObject *pressed = nullptr;
- Common::Point offset;
- // CExit: state 0 hidden, 1 shown, 2 pressed, 3 rotating the arrow to newAngle (degrees, 0.4 per millisecond)
- float angle = 0, newAngle = 0;
- int state = 1, releaseTime = -1;
- int movementId = 0;
- bool intersect = false; // the arrow is drawn behind the destination picture when they overlap
- void setState(int newState);
- void setAngle(float degrees);
- void rotateTo(const Common::String &where);
- void updateRotation(uint32 elapsed);
-};
-
class Scene : public Background {
public:
/** list items are owned */
@@ -69,12 +53,6 @@ class Scene : public Background {
Common::Array<PictureObject *> _roamingPictures;
PicAniInfoList _roamingObjects;
Common::Array<Entrance> _entrances;
- Common::Array<Exit> _exits;
- void initExits(Scene &common);
- void setExitState(int pictureId, int state);
- void rotateExit(int pictureId, const Common::String &where);
- void resetExitIntersect(int pictureId, bool intersect);
- void updateExitInput(Common::Point pos, Common::EventType type);
int16 _heroId = 0;
/** CScene::GetSceneDims (CScene+312): the SCENE attributes width and height, the screen size when missing (Android) */
Dims _dims;
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 664f5f6f6f7..d2c9d86400b 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -48,6 +48,7 @@
#include "ngi/scene.h"
#include "ngi/statics.h"
#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/tutorialmanager.h"
@@ -904,8 +905,6 @@ private:
KEY_END()
layout.top()->children["ANI"] = layout.top()->children["OLDANI"];
KEY_END()
- XML_KEY(EXITMANAGER)
- KEY_END()
XML_KEY(INTERACTIONS)
KEY_END()
XML_KEY(INVENTORY)
@@ -945,8 +944,6 @@ private:
return true;
}
- bool parserCallback_EXITMANAGER(ParserNode *) { return true; }
-
bool parserCallback_INTERACTIONS(ParserNode *) { return true; }
bool parserCallback_INVENTORY(ParserNode *node) {
@@ -1645,21 +1642,6 @@ private:
node->layout = _XMLkeys;
return true;
}
- if (parent->name == "EXITMANAGER") {
- node->layout = _XMLkeys;
- int16 id = 0;
- if (node->name == "EXIT" && readId(node->values.getValOrDefault("vis_dst"), id)) {
- if (PictureObject *object = _scene.findPictureObjectById(id, 0)) {
- Exit exit;
- exit.destination = object;
- exit.angle = strtof(node->values.getValOrDefault("angle").c_str(), nullptr);
- exit.offset = Common::Point(intProperty(*node, "offsetX"), intProperty(*node, "offsetY"));
- exit.state = atoi(node->values.getValOrDefault("state", "1").c_str());
- _scene._exits.push_back(exit);
- }
- }
- return true;
- }
if (parent->name == "INTERACTIONS") {
node->layout = _XMLkeys;
_interaction = nullptr;
@@ -1743,13 +1725,7 @@ void SceneTag::loadSceneXML(const GameProject &project) {
return;
}
- // Both files list every scene, the parsers pick the entries of this one.
- // exits.xml is known from the 2015 revision on
- if (g_ngi->_gameVersion >= 201509) {
- parser.close();
- if (!parser.loadFile("data/exits.xml") || !parser.parse())
- return;
- }
+ // The file lists every scene, the parser picks the entries of this one.
parser.close();
if (!parser.loadFile("data/interactions.xml") || !parser.parse())
return;
@@ -1759,6 +1735,9 @@ void SceneTag::loadSceneXML(const GameProject &project) {
_tag.c_str(), scene->_pictureObjects.size(), scene->_aniObjects.size());
delete _scene;
_scene = scene.release();
+ // exits.xml exists from the 2015 revision on (the original reads all scenes at once)
+ if (g_ngi->_exitManager)
+ g_ngi->_exitManager->init("data/exits.xml", _scene);
}
// CGame::CreateContent: the inventory is the scene 0, read from inventory.xml for create_inv
@@ -1797,6 +1776,8 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
_gameProject.reset(new GameProject());
GameProject &project = *_gameProject;
g_ngi->_gameProject = _gameProject.get(); // the controllers find their scenes while the data loads
+ if (g_ngi->_gameVersion >= 201509)
+ g_ngi->_exitManager.reset(new ExitManager); // before the scenes: they ask it for their exits when they load
XMLTextureSizeParser(project).loadSizes();
if (!project._objectIds.load("data/obj.h"))
return Common::Error(Common::kNoGameDataFoundError, "Could not read the Full Pipe object IDs");
Commit: 0a0d30bd682b15ef8e2cb79f0d9de448530b6e04
https://github.com/scummvm/scummvm/commit/0a0d30bd682b15ef8e2cb79f0d9de448530b6e04
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Use named constants for the exit arrows, the tutorial marker and the scene ids
Changed paths:
engines/ngi/fullpipe/constants.h
engines/ngi/fullpipe/exitmanager.cpp
engines/ngi/fullpipe/inventorycontroller.cpp
engines/ngi/fullpipe/tutorialmanager.cpp
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index 7405a8eed8a..1dbdf5c5176 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -25,6 +25,14 @@
namespace NGI {
// Common
+#define ANI_ARROW 23234
+#define ANI_ARROW_CHAPTER 23401
+#define PIC_ARROW_RED 23237
+#define PIC_ARROW_CHAPTER_PRESS 23404
+#define MOV_ARROW_UP 23236
+#define MOV_ARROW_CHAPTER 23403
+#define SND_CMN_080 23238
+#define PIC_SC_TUTORIAL_MARKER 11028
#define ANI_FLY 4916
#define ANI_INV_MAP 5321
#define ANI_LIFTBUTTON 2751
diff --git a/engines/ngi/fullpipe/exitmanager.cpp b/engines/ngi/fullpipe/exitmanager.cpp
index 0a1e62485c9..5d2b5738a18 100644
--- a/engines/ngi/fullpipe/exitmanager.cpp
+++ b/engines/ngi/fullpipe/exitmanager.cpp
@@ -36,15 +36,6 @@ namespace NGI {
namespace {
-enum {
- kArrow = 23234, // ANI_ARROW of the scene SC_COMMON
- kArrowPicture = 23237, // PIC_ARROW_RED
- kArrowUp = 23236, // MOV_ARROW_UP
- kLevelArrow = 23401, // the arrow of a new level
- kLevelArrowPicture = 23404,
- kLevelArrowUp = 23403,
- kPressSound = 23238 // 0x5AC6
-};
// CIDList::FindId: 0 for an unknown name
int findId(const char *name) {
@@ -96,11 +87,11 @@ void Exit::createAndAddInScene() {
int arrowId = 0;
int pictureId = 0;
if (_type == 0) {
- arrowId = kArrow;
- pictureId = kArrowPicture;
+ arrowId = ANI_ARROW;
+ pictureId = PIC_ARROW_RED;
} else if (_type == 1) {
- arrowId = kLevelArrow;
- pictureId = kLevelArrowPicture;
+ arrowId = ANI_ARROW_CHAPTER;
+ pictureId = PIC_ARROW_CHAPTER_PRESS;
}
AniObject *arrow = common->findAniObjectById(arrowId, 0);
PictureObject *picture = common->findPictureObjectById(pictureId, 0);
@@ -157,7 +148,7 @@ void Exit::loadParam(const XmlNode &node, Scene &scene) {
const Common::Point center = pictureCenter();
_centerX = center.x;
_centerY = center.y;
- if (!_scene->findAniObjectById(_type != 0 ? kLevelArrow : kArrow, _arrowCopyId))
+ if (!_scene->findAniObjectById(_type != 0 ? ANI_ARROW_CHAPTER : ANI_ARROW, _arrowCopyId))
createAndAddInScene();
if (node.checkAttr("z")) {
_fixedZ = true;
@@ -185,9 +176,9 @@ void Exit::onShow() {
if (_state == 1) {
_arrow->_flags |= 4;
if (_type == 0)
- _arrow->startMovement(kArrowUp, 0, -1);
+ _arrow->startMovement(MOV_ARROW_UP, 0, -1);
else if (_type == 1)
- _arrow->startMovement(kLevelArrowUp, 0, -1);
+ _arrow->startMovement(MOV_ARROW_CHAPTER, 0, -1);
} else if (_state == 2) {
setState(1);
_pressed->_flags &= ~4;
@@ -329,7 +320,7 @@ void Exit::onMouseLKeyDown(float x, float y) {
if (_state == 3)
stopRotate();
if (_picture->hit(x, y)) {
- if (Sound *sound = g_ngi->findSound(kPressSound))
+ if (Sound *sound = g_ngi->findSound(SND_CMN_080))
sound->play(0, 0);
setState(2);
}
diff --git a/engines/ngi/fullpipe/inventorycontroller.cpp b/engines/ngi/fullpipe/inventorycontroller.cpp
index c2e852ac15f..ea11e226680 100644
--- a/engines/ngi/fullpipe/inventorycontroller.cpp
+++ b/engines/ngi/fullpipe/inventorycontroller.cpp
@@ -105,7 +105,7 @@ void InventoryController::onRenderTop(Common::Point scroll) {
if (g_ngi->getCurrentScene()->_sceneId == SC_TUTORIAL)
warnOnce("CTutorialController::OnRenderAfterInventory: the tutorial scene is not ported");
if (!_helperPicture)
- _helperPicture = _scene->findPictureObjectById(11028, 0);
+ _helperPicture = _scene->findPictureObjectById(PIC_SC_TUTORIAL_MARKER, 0);
if (_helperVisible && _helperPicture)
_helperPicture->render(Common::Point());
}
@@ -117,7 +117,7 @@ void InventoryController::onUpdate(uint32 elapsed) {
if (inventory->getItemByName("ANI_INV_COIN")->_counter > 0 && _stateHintNotebook == 0)
_stateHintNotebook = 1;
Scene *firstScene = g_ngi->getSceneInStack(0);
- if (firstScene->_sceneId == 305) {
+ if (firstScene->_sceneId == SC_5) {
warnOnce("CScene::IsQueuesProcessed: the hint of the map in the scene 305 is not started");
}
if (_stateHintMap == 1)
diff --git a/engines/ngi/fullpipe/tutorialmanager.cpp b/engines/ngi/fullpipe/tutorialmanager.cpp
index 72b23cf1fab..ae71666bee3 100644
--- a/engines/ngi/fullpipe/tutorialmanager.cpp
+++ b/engines/ngi/fullpipe/tutorialmanager.cpp
@@ -152,7 +152,7 @@ void TutorialManager::cleanXml() {
for (uint i = 0; i < _tutorials.size(); i++)
_tutorials[i]->setState(1);
if (Tutorial *last = findTutorial("TUTORIAL_LAST"))
- last->_sceneId = 303;
+ last->_sceneId = SC_3;
}
// CTutorialManager::FinishTutorial (1A2DA4)
Commit: e157cc4599d0c622df664f39485209318918caed
https://github.com/scummvm/scummvm/commit/e157cc4599d0c622df664f39485209318918caed
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Port CTutorialController (not wired yet: the CheckTutorial state machines of the scenes are next)
Changed paths:
A engines/ngi/fullpipe/tutorialcontroller.cpp
A engines/ngi/fullpipe/tutorialcontroller.h
engines/ngi/fullpipe/constants.h
engines/ngi/fullpipe/exitmanager.cpp
engines/ngi/fullpipe/exitmanager.h
engines/ngi/fullpipe/notebook.h
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/module.mk
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index 1dbdf5c5176..3f80fa2fba1 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -25,6 +25,28 @@
namespace NGI {
// Common
+#define PIC_MNU_CONTINUE 28036
+#define GD_SC38_LIFT 23125
+#define ANI_SC_TUTORIAL_BEARDED 11001
+#define PIC_SC_TUTORIAL_CLOUD_1 11002
+#define PIC_SC_TUTORIAL_CLOUD_2 11003
+#define PIC_SC_TUTORIAL_CLOUD_3 11004
+#define PIC_SC_TUTORIAL_CLOUD_4 11005
+#define PIC_SC_TUTORIAL_CLOUD_5 11006
+#define PIC_SC_TUTORIAL_BTN_CONTINUE 11009
+#define PIC_SC_TUTORIAL_BTN_OK 11010
+#define PIC_SC_TUTORIAL_BTN_YES 23535
+#define MOV_SC_TUTORIAL_BEARDED_FALL 11014
+#define QU_SC_TUTORIAL_BEARDED_FALL 11016
+#define QU_SC_TUTORIAL_BEARDED_ROTATE 11017
+#define QU_SC_TUTORIAL_BEARDED_FALL_MIRROR 11018
+#define QU_SC_TUTORIAL_BEARDED_ROTATE_MIRROR 11019
+#define QU_SC_TUTORIAL_BEARDED_RISE 11020
+#define QU_SC_TUTORIAL_BEARDED_RISE_MIRROR 11021
+#define ANI_SC_TUTORIAL_ARROW 11025
+#define MV_SC_TUTORIAL_ARROW 11027
+#define ANI_MARK_CATALOG 23285
+#define PIC_SC1_RTRUBA 698
#define ANI_ARROW 23234
#define ANI_ARROW_CHAPTER 23401
#define PIC_ARROW_RED 23237
diff --git a/engines/ngi/fullpipe/exitmanager.cpp b/engines/ngi/fullpipe/exitmanager.cpp
index 5d2b5738a18..1f76da8fb9c 100644
--- a/engines/ngi/fullpipe/exitmanager.cpp
+++ b/engines/ngi/fullpipe/exitmanager.cpp
@@ -69,6 +69,10 @@ int Exit::getSceneId() const {
return _scene->_sceneId;
}
+bool Exit::hitPicture(float x, float y) const {
+ return _picture->hit(x, y);
+}
+
// CExit::GetVisId (143ECE)
int Exit::getVisId() const {
return _picture->_id;
diff --git a/engines/ngi/fullpipe/exitmanager.h b/engines/ngi/fullpipe/exitmanager.h
index a2d124ae47d..1e47f0e35d3 100644
--- a/engines/ngi/fullpipe/exitmanager.h
+++ b/engines/ngi/fullpipe/exitmanager.h
@@ -68,6 +68,8 @@ public:
void stopRotate();
void setOffset(float x, float y);
void setFixedZ(bool fixedZ) { _fixedZ = fixedZ; }
+ /** CVisibleObject::Hit of the picture of the exit */
+ bool hitPicture(float x, float y) const;
private:
AniObject *_arrow = nullptr; // +0
diff --git a/engines/ngi/fullpipe/notebook.h b/engines/ngi/fullpipe/notebook.h
index 98bf932b297..fe61a5ae6f5 100644
--- a/engines/ngi/fullpipe/notebook.h
+++ b/engines/ngi/fullpipe/notebook.h
@@ -117,6 +117,7 @@ public:
bool checkAutoFoil() const;
bool isTimerShowing() const;
bool isFoilHit(Common::Point pos) const;
+ void clearHints();
void updateBookMarks();
void showGiveButtonHint(bool timerShowing);
@@ -142,7 +143,6 @@ private:
int _autoFoilHint = -1;
int _pulseWait = 0;
- void clearHints();
void removeFoil(uint32 elapsed);
void setElementVisible(const char *id, bool visible);
void setBonusesVisible(bool visible);
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index d1776ef20fd..c62622b459b 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -28,6 +28,7 @@
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/inventorycontroller.h"
#include "ngi/fullpipe/liftcontroller.h"
+#include "ngi/fullpipe/tutorialcontroller.h"
namespace NGI {
@@ -470,6 +471,9 @@ void createSceneController(int sceneId) {
case SC_LIFT:
new LiftController(sceneId);
break;
+ case SC_TUTORIAL:
+ new TutorialController(sceneId);
+ break;
case 0: // the inventory scene (CGame +116)
new InventoryController(sceneId);
break;
diff --git a/engines/ngi/fullpipe/tutorialcontroller.cpp b/engines/ngi/fullpipe/tutorialcontroller.cpp
new file mode 100644
index 00000000000..d28037da687
--- /dev/null
+++ b/engines/ngi/fullpipe/tutorialcontroller.cpp
@@ -0,0 +1,755 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "math/utils.h"
+
+#include "ngi/ngi.h"
+#include "ngi/utils.h"
+#include "ngi/font.h"
+#include "ngi/objects.h"
+#include "ngi/gfx.h"
+#include "ngi/guimanager.h"
+#include "ngi/input.h"
+#include "ngi/inventory.h"
+#include "ngi/messages.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/behavior.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/inventorycontroller.h"
+#include "ngi/fullpipe/notebook.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialcontroller.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+namespace {
+
+void warnOnce(const char *what) {
+ static Common::HashMap<Common::String, bool> reported;
+ if (!reported.contains(what)) {
+ reported[what] = true;
+ warning("STUB/untested: %s", what);
+ }
+}
+
+InventoryController *inventoryController() {
+ return static_cast<InventoryController *>(g_ngi->_inventory->_controller.get());
+}
+
+GuiElement *inventoryButton(const char *id) {
+ return g_ngi->_inventory->_guiManager->getElement(id);
+}
+
+// The scene below the tutorial (CGame::GetSceneInStack(size - 2))
+Scene *sceneBelow() {
+ return g_ngi->getSceneInStack(g_ngi->_sceneStack.size() - 2);
+}
+
+// The CMessageQueue::Run of a queue of the scene: a copy runs (D03)
+bool queueIsRunning(int queueId) {
+ for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList) {
+ if (queue->_queueId == queueId && !queue->_isFinished)
+ return true;
+ }
+ return false;
+}
+
+} // End of anonymous namespace
+
+// CTutorialController::CTutorialController
+TutorialController::TutorialController(int sceneId) : ISceneController(sceneId) {
+}
+
+// CTutorialController::SetXmlData (1A2950) and CleanXml (1A28E0)
+void TutorialController::setXmlData(const XmlNode &node) {
+ _step = node.attrInt("step", 0);
+}
+
+void TutorialController::cleanXml() {
+ _arrowTime = -1;
+ _step = 0;
+}
+
+// CTutorialController::IsInventoryEnabled (1A3A40): on for extra tutorials and those pointing at it
+bool TutorialController::isInventoryEnabled() {
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ if (!tutorial || tutorial->_isExtra)
+ return true;
+ if (tutorial->_id == "TUTORIAL_SEE_TASK" || tutorial->_id == "TUTORIAL_DO_EGG" || tutorial->_id == "TUTORIAL_GIVE_EGG" || tutorial->_id == "TUTORIAL_SEE_MAP")
+ return true;
+ return _skipButton && _skipButton->hit(Common::Point(g_ngi->_inputController->_hotSceneX, g_ngi->_inputController->_hotSceneY));
+}
+
+// CTutorialController::OnKeyUp (1A28F0): the key 90 is the skip button
+void TutorialController::onKeyUp(uint32 key) {
+ if (key == 90)
+ onGuiEvent("BTN_SKIP", "unpress");
+}
+
+// CTutorialController::UnloadArrays (1A2F08): copied arrows leave the scene, its own one is hidden
+void TutorialController::unloadArrays() {
+ for (uint i = 0; i < _arrows.size(); i++) {
+ if (_arrows[i]->_copyId)
+ _scene->removeAni(_arrows[i]);
+ else
+ _arrows[i]->_flags &= ~4;
+ }
+ _arrows.clear();
+}
+
+// CTutorialController::UnloadLayout (1A2F3C)
+void TutorialController::unloadLayout() {
+ unloadArrays();
+ if (_cloud) {
+ _cloud->_flags &= ~4;
+ _cloud = nullptr;
+ }
+ _text.clear();
+ if (_button) {
+ _button->hideAndDeactivate();
+ _button = nullptr;
+ }
+ if (_buttonNo) {
+ _buttonNo->hideAndDeactivate();
+ _buttonNo = nullptr;
+ }
+ _font = nullptr;
+}
+
+// CTutorialController::SetTransmitCoord (1A2F00)
+void TutorialController::setTransmitCoord(float x, float y, GameObject *object) {
+ _transmitX = x;
+ _transmitY = y;
+ _transmitObject = object;
+}
+
+// CTutorialController::TransmitCoord (1A3950): the closing touch goes on to the scene below
+void TutorialController::transmitCoord() {
+ if (_transmitX == -1.0f)
+ return;
+ CursorController *cursor = g_ngi->_inputController;
+ if (_transmitObject)
+ cursor->setObject(_transmitObject, 0, 0);
+ cursor->setCursorPos(_transmitX, _transmitY);
+ warnOnce("CCursorController::Update (the hit objects are repopulated by the next touch)");
+ g_ngi->getCurrentScene()->onMouseLKeyUp(0, _transmitX, _transmitY);
+ _transmitObject = nullptr;
+ _transmitX = -1;
+ _transmitY = -1;
+ cursor->setObject(nullptr, 0, 0);
+}
+
+// CTutorialController::MouseActionsZone (1A33BC): touch in the zone; finger up finishes
+bool TutorialController::mouseActionsZone(float x, float y, int action, const Common::Rect &zone) {
+ Scene *scene = g_ngi->getSceneInStack(0);
+ const float sceneX = x + scene->_x;
+ const float sceneY = y + scene->_y;
+ if (sceneX >= zone.left && sceneX <= zone.right && sceneY >= zone.top && sceneY <= zone.bottom) {
+ if (action == 3)
+ finish();
+ return true;
+ }
+ return false;
+}
+
+// CTutorialController::MouseActions (1A39D0): touch on the object below; finger up finishes
+bool TutorialController::mouseActions(float x, float y, int action, uint pictureId) {
+ Scene *scene = g_ngi->getSceneInStack(0);
+ GameObject *object = scene->findVisibleObject(pictureId, 0);
+ if (!object)
+ return false;
+ const bool hit = object->_objtype == kObjTypePictureObject ? static_cast<PictureObject *>(object)->hit(x + scene->_x, y + scene->_y) :
+ static_cast<AniObject *>(object)->hit(x + scene->_x, y + scene->_y);
+ if (!hit)
+ return false;
+ if (action == 3) {
+ finish();
+ setTransmitCoord(x, y, g_ngi->_inputController->getObject());
+ }
+ return true;
+}
+
+// CTutorialController::SetNotebookItemsActivity (1A3424): hides the give button hint
+void TutorialController::setNotebookItemsActivity() {
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ const uint depth = g_ngi->_sceneStack.size();
+ if (depth > 1 && tutorial && !tutorial->_isExtra) {
+ Scene *scene = g_ngi->getSceneInStack(depth - 2);
+ if (scene->_sceneId == SC_NOTEBOOK) {
+ if (AniObject *mark = scene->findAniObjectById(ANI_MARK_CATALOG, 0))
+ mark->_flags &= ~4;
+ g_ngi->_notebook->showGiveButtonHint(false);
+ g_ngi->_notebook->clearHints();
+ }
+ }
+}
+
+// CTutorialController::ResetNotebookItemsActivity (1A3488)
+void TutorialController::resetNotebookItemsActivity() {
+ if (g_ngi->_tutorialManager->isTutorialCompleted()) {
+ if (Scene *notebook = g_ngi->findScene(SC_NOTEBOOK)) {
+ if (AniObject *mark = notebook->findAniObjectById(ANI_MARK_CATALOG, 0))
+ mark->_flags |= 4;
+ }
+ }
+}
+
+// CTutorialController::SetExitManagerActivity (1A404C): hides the exits of scenes 1 to 3
+void TutorialController::setExitManagerActivity() {
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ if (!tutorial || tutorial->_isExtra)
+ return;
+ ExitManager &exits = *g_ngi->_exitManager;
+ for (uint i = 0; i < exits.getNumExits(); i++) {
+ const int sceneId = exits.getExitNum(i)->getSceneId();
+ if (sceneId == SC_1 || sceneId == SC_2 || sceneId == SC_3)
+ exits.getExitNum(i)->setState(0);
+ }
+ if (tutorial->_id == "TUTORIAL_USE_TRANSITION")
+ exits.find(PIC_SC1_RTRUBA)->setState(1);
+ else if (tutorial->_id == "TUTORIAL_USE_LADDER")
+ exits.find(PIC_SC3_LADDER)->setState(1);
+}
+
+// CTutorialController::ResetExitManagerActivity (1A4140)
+void TutorialController::resetExitManagerActivity() {
+ if (!g_ngi->_tutorialManager->isTutorialCompleted())
+ return;
+ ExitManager &exits = *g_ngi->_exitManager;
+ for (uint i = 0; i < exits.getNumExits(); i++) {
+ const int sceneId = exits.getExitNum(i)->getSceneId();
+ if (sceneId == SC_1 || sceneId == SC_2 || sceneId == SC_3)
+ exits.getExitNum(i)->setState(1);
+ }
+}
+
+// CTutorialController::SetInventoryItemsActivity (1A42C8): deactivates the unused buttons
+void TutorialController::setInventoryItemsActivity() {
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ if (tutorial) {
+ const Common::String &id = tutorial->_id;
+ if (id == "TUTORIAL_SEE_TASK") {
+ inventoryButton("PIC_INV_MAP")->deactivate();
+ inventoryButton("PIC_INV_ESC")->deactivate();
+ } else if (id == "TUTORIAL_USE_LADDER" || id == "TUTORIAL_DO_EGG" || id == "TUTORIAL_GIVE_EGG") {
+ inventoryButton("PIC_INV_MAP")->deactivate();
+ inventoryButton("PIC_INV_ESC")->deactivate();
+ inventoryButton("PIC_INV_TASK")->deactivate();
+ } else if (id == "TUTORIAL_SEE_MAP") {
+ inventoryButton("PIC_INV_ESC")->deactivate();
+ inventoryButton("PIC_INV_TASK")->deactivate();
+ }
+ }
+ g_ngi->_exitManager->find(PIC_SC1_RTRUBA)->setState(0);
+}
+
+// CTutorialController::ResetInventoryItemsActivity (1A45FC)
+void TutorialController::resetInventoryItemsActivity() {
+ inventoryButton("PIC_INV_MAP")->activate();
+ inventoryButton("PIC_INV_ESC")->activate();
+ inventoryButton("PIC_INV_TASK")->activate();
+ if (InventoryItem *boot = g_ngi->_inventory->getItemByName("ANI_INV_BOOT"))
+ boot->_clickable = true;
+}
+
+// CTutorialController::Start (1A41BC): the bearded man falls
+void TutorialController::start() {
+ _state = 1;
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ if (!tutorial) {
+ _state = 3;
+ return;
+ }
+ _man = _scene->findAniObjectById(ANI_SC_TUTORIAL_BEARDED, 0);
+ _man->setPos(tutorial->_beardedX, tutorial->_beardedY);
+ _man->_flags |= 4;
+ Movement *fall = _man->getMovement(MOV_SC_TUTORIAL_BEARDED_FALL);
+ fall->_phases[0]->_delayMs = tutorial->_isArcade ? 1000 : 0;
+ fall->_loopDelay = 83;
+ runSceneQueue(tutorial->_isMirror ? QU_SC_TUTORIAL_BEARDED_FALL_MIRROR : QU_SC_TUTORIAL_BEARDED_FALL);
+ _skipButton = inventoryButton("BTN_SKIP");
+ if (tutorial->_isExtra) {
+ inventoryController()->setHelperVisible(false);
+ } else {
+ _skipButton->showAndActivate();
+ inventoryController()->setHelperVisible(true);
+ }
+ // the man does not rotate while he falls
+ _scene->_behaviorController->getAniQueue(_man, ANI_SC_TUTORIAL_BEARDED, QU_SC_TUTORIAL_BEARDED_ROTATE)->_flags |= 1;
+ _scene->_behaviorController->getAniQueue(_man, ANI_SC_TUTORIAL_BEARDED, QU_SC_TUTORIAL_BEARDED_ROTATE_MIRROR)->_flags |= 1;
+}
+
+// CTutorialController::Finish (1A32BC): the man rises
+void TutorialController::finish() {
+ _state = 3;
+ unloadLayout();
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ const int queueId = tutorial && tutorial->_isMirror ? QU_SC_TUTORIAL_BEARDED_RISE_MIRROR : QU_SC_TUTORIAL_BEARDED_RISE;
+ if (!queueIsRunning(queueId)) {
+ Movement *fall = _man->getMovement(MOV_SC_TUTORIAL_BEARDED_FALL);
+ fall->_loopDelay = 60;
+ fall->_phases[0]->_delayMs = 0;
+ runSceneQueue(queueId);
+ }
+ if (tutorial && tutorial->_id == "TUTORIAL_LAST") {
+ inventoryController()->setHelperVisible(false);
+ _skipButton->hideAndDeactivate();
+ g_ngi->getSceneInStack(0)->message("MSG_GAMECENTER_TRY", "", nullptr);
+ }
+}
+
+// CMessageQueue::Run of a queue of this scene: a copy of the template runs
+bool TutorialController::runSceneQueue(int queueId) {
+ MessageQueue *queue = _scene->findMessageQueue(queueId);
+ if (!queue)
+ return false;
+ MessageQueue *copy = new MessageQueue(queue, 0, 0);
+ copy->_scene = _scene;
+ if (!copy->run(nullptr)) {
+ g_ngi->_globalMessageQueueList->deleteQueueById(copy->_id);
+ return false;
+ }
+ return true;
+}
+
+// CTutorialController::OnShow (1A46C8)
+void TutorialController::onShow() {
+ _step++;
+ unloadLayout();
+ resetInventoryItemsActivity();
+ setInventoryItemsActivity();
+ resetExitManagerActivity();
+ setExitManagerActivity();
+ resetNotebookItemsActivity();
+ setNotebookItemsActivity();
+ if (g_ngi->_tutorialManager->findActiveTutorial())
+ start();
+ else
+ g_ngi->popScene();
+}
+
+// CTutorialController::OnHide (1A4718)
+void TutorialController::onHide() {
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ if (tutorial) {
+ if (tutorial->_id == "TUTORIAL_LAST")
+ warning("STUB: CAchievementsManager::AddActivatingCounter ACHIEVEMENT_TUTORIAL: achievements are not ported!");
+ if (tutorial->_id == "TUTORIAL_USE_MAP")
+ g_ngi->_tutorialManager->finishTutorial("EXTRA_TUTORIAL_USE_MAP");
+ }
+ // CAniObject::UnloadMovements of the man: the textures are loaded for good here
+ g_ngi->_tutorialManager->finishActiveTutorial();
+ resetExitManagerActivity();
+ resetInventoryItemsActivity();
+ resetNotebookItemsActivity();
+ _state = 0;
+}
+
+// CTutorialController::OnMessage (1A64E0)
+void TutorialController::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (message == "MSG_SC_TUTORIAL_LOAD_LAYOUT") {
+ loadLayout();
+ } else if (message == "MSG_SC_TUTORIAL_UNLOAD_BEARDED") {
+ g_ngi->popScene();
+ transmitCoord();
+ }
+ // the controller of the scene below gets the message too
+ if (ISceneController *controller = g_ngi->getSceneInStack(0)->_controller.get())
+ controller->onMessage(message, param, queue);
+}
+
+// CTutorialController::CheckArrowPos (1A37FC): the arrows that point at an object follow it
+void TutorialController::checkArrowPos() {
+ Scene *scene = g_ngi->getSceneInStack(0);
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ if (!tutorial)
+ return;
+ for (uint i = 0; i < _arrows.size(); i++) {
+ const TutorialArrow &arrow = tutorial->getArrowData(i);
+ if (arrow.shown && arrow.sceneId == scene->_sceneId) {
+ GameObject *object = scene->findVisibleObject(arrow.objectId, 0);
+ _arrows[i]->setPos((object->_x - scene->_x) + arrow.offsetX, (object->_y - scene->_y) + arrow.offsetY);
+ }
+ }
+}
+
+// CTutorialController::OnUpdate (1A38B8): the scene below goes on
+void TutorialController::onUpdate(uint32 elapsed) {
+ if (_arrowTime != -1.0f)
+ _arrowTime += (float)elapsed / 1000.0f;
+ if (g_ngi->_sceneStack.size() > 1) {
+ Scene *below = sceneBelow();
+ below->updateObjects(elapsed);
+ if (below->_controller)
+ below->_controller->onUpdate(elapsed);
+ }
+ checkArrowPos();
+ addContinueBtnIfNeed(-1, -1, 0);
+}
+
+// CTutorialController::OnRender (1A378C)
+void TutorialController::onRender(Common::Point scroll) {
+ if (g_ngi->_sceneStack.size() > 1) {
+ Scene *below = sceneBelow();
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ if (tutorial && tutorial->_id == "TUTORIAL_USE_LADDER" && below->_controller)
+ below->_controller->onRender(scroll);
+ }
+}
+
+// CTutorialController::OnRenderTop (1A3744): over map and main menu the cloud follows the inventory
+void TutorialController::onRenderTop(Common::Point scroll) {
+ if (g_ngi->_sceneStack.size() > 1) {
+ const int below = sceneBelow()->_sceneId;
+ if (below == SC_MAINMENU || below == SC_MAP)
+ onRenderAfterInventory();
+ }
+}
+
+// CTutorialController::OnRenderAfterInventory (1A3654)
+void TutorialController::onRenderAfterInventory() {
+ if (_cloud)
+ _cloud->render(Common::Point());
+ if (_button)
+ _button->render(g_ngi->_backgroundSurface);
+ if (_buttonNo)
+ _buttonNo->render(g_ngi->_backgroundSurface);
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ for (uint i = 0; i < _arrows.size(); i++) {
+ if (tutorial && tutorial->getArrowData(i).shown)
+ _arrows[i]->render(Common::Point());
+ }
+ if (_font)
+ _font->print(g_ngi->_backgroundSurface, _text, _textLeft, _textTop, _textRight - _textLeft, _textBottom - _textTop, BitmapFont::kAlignCenter, BitmapFont::kVerticalCenter);
+}
+
+// CTutorialController::LoadLayout (1A5D50): the fallen man, cloud with text, buttons and arrows
+void TutorialController::loadLayout() {
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ if (!tutorial)
+ return;
+ // the analytics (CFlurryEventManager::StartLocalTime) is not ported
+ static const int clouds[] = { 0, PIC_SC_TUTORIAL_CLOUD_1, PIC_SC_TUTORIAL_CLOUD_2, PIC_SC_TUTORIAL_CLOUD_3, PIC_SC_TUTORIAL_CLOUD_4, PIC_SC_TUTORIAL_CLOUD_5 };
+ if (tutorial->_view >= 1 && tutorial->_view <= 5)
+ _cloud = _scene->findPictureObjectById(clouds[tutorial->_view], 0);
+ if (!_cloud) {
+ finish();
+ _state = 2;
+ return;
+ }
+ const Common::Point manPos(_man->_x, _man->_y);
+ const Common::Point manSize = _man->getSize();
+ const Common::Point cloudSize = _cloud->getSize();
+ float cloudY = manPos.y + manSize.y;
+ if (tutorial->_view <= 3)
+ cloudY -= cloudSize.y;
+ cloudY -= 50.0f;
+ const float cloudX = tutorial->_isMirror ? (manPos.x + manSize.x) - 50.0f : (manPos.x - cloudSize.x) + 50.0f;
+ _cloud->setPos(cloudX, cloudY);
+ _cloud->_z = -100;
+ _button = nullptr;
+ _buttonNo = nullptr;
+ float buttonWidth = 0;
+ float buttonHeight = 0;
+ GuiManager &gui = *_scene->_guiManager;
+ int pictureId = 0;
+ const char *buttonId = nullptr;
+ switch (tutorial->_viewButton) {
+ case 2:
+ pictureId = PIC_SC_TUTORIAL_BTN_OK;
+ buttonId = "BTN_SC_TUTORIAL_OK";
+ break;
+ case 1:
+ pictureId = PIC_SC_TUTORIAL_BTN_CONTINUE;
+ buttonId = "BTN_SC_TUTORIAL_CONTINUE";
+ break;
+ case 3:
+ pictureId = PIC_SC_TUTORIAL_BTN_YES;
+ break;
+ default:
+ break;
+ }
+ if (pictureId) {
+ const Common::Point size = _scene->findPictureObjectById(pictureId, 0)->getSize();
+ buttonWidth = size.x;
+ buttonHeight = size.y;
+ }
+ if (buttonId) {
+ _button = gui.getElement(buttonId);
+ } else if (tutorial->_viewButton == 3) {
+ _button = gui.getElement("BTN_SC_TUTORIAL_YES");
+ _buttonNo = gui.getElement("BTN_SC_TUTORIAL_NO");
+ }
+ const float buttonX = cloudX + (cloudSize.x - buttonWidth) * 0.5f;
+ float buttonY = (cloudY + (cloudSize.y - buttonHeight) * 0.5f) + 50.0f;
+ if (tutorial->_view == 4)
+ buttonY += 20.0f;
+ else if (tutorial->_view == 2)
+ buttonY -= 10.0f;
+ else if (tutorial->_id == "EXTRA_TUTORIAL_USE_DEVICES")
+ buttonY += 15.0f;
+ else if (tutorial->_id == "TUTORIAL_LAST" || tutorial->_id == "EXTRA_TUTORIAL_SEE_HELP")
+ buttonY += 7.0f;
+ if (_button) {
+ _button->setPos(Common::Point(buttonX, buttonY));
+ if (tutorial->_isButton) {
+ _button->activate();
+ _button->show();
+ }
+ }
+ if (_buttonNo) {
+ const float yesX = buttonX - buttonWidth * 0.5f;
+ _button->setPos(Common::Point(yesX, buttonY));
+ _buttonNo->setPos(Common::Point(yesX + buttonWidth, buttonY));
+ _buttonNo->activate();
+ _buttonNo->show();
+ }
+ _text = tutorial->_text;
+ _font = g_ngi->getFont("task_dlg_19.fnt");
+ _textLeft = cloudX + tutorial->_leftOffset;
+ _textTop = cloudY + tutorial->_topOffset;
+ _textRight = (cloudX + cloudSize.x) + tutorial->_rightOffset;
+ _textBottom = buttonY + tutorial->_bottomOffset;
+ for (uint i = 0; i < tutorial->_arrows.size(); i++) {
+ const TutorialArrow &arrow = tutorial->getArrowData(i);
+ AniObject *ani = nullptr;
+ if (arrow.shown) {
+ if (!_arrows.empty()) {
+ ani = new AniObject(_arrows[0]);
+ _scene->addAni(ani, true);
+ ani->_copyId = (_arrows.size() + 1) << 16 | (uint16)ani->_id;
+ } else {
+ ani = _scene->findAniObjectById(ANI_SC_TUTORIAL_ARROW, 0);
+ }
+ }
+ if (ani) {
+ ani->setPos(arrow.x, arrow.y);
+ ani->_rotation = Math::deg2rad((float)arrow.angle);
+ ani->startMovement(MV_SC_TUTORIAL_ARROW, 0, -1);
+ _arrows.push_back(ani);
+ }
+ }
+ if (tutorial->_id == "TUTORIAL_MAKE_TASK_BOOT") {
+ _arrowTime = 0;
+ tutorial->_arrows[0].shown = false;
+ }
+ // the man rotates now
+ _scene->_behaviorController->getAniQueue(_man, ANI_SC_TUTORIAL_BEARDED, QU_SC_TUTORIAL_BEARDED_ROTATE)->_flags &= ~1;
+ _scene->_behaviorController->getAniQueue(_man, ANI_SC_TUTORIAL_BEARDED, QU_SC_TUTORIAL_BEARDED_ROTATE_MIRROR)->_flags &= ~1;
+ _state = 2;
+}
+
+// CTutorialController::AddContinueBtnIfNeed (1A34C0): MAKE_TASK_BOOT shows its arrow after 5 s;
+// the MOVE_MAN part (asks the scene's controller whether the touch walks the hero) is not ported
+void TutorialController::addContinueBtnIfNeed(float x, float y, int action) {
+ if (!_button)
+ return;
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ if (!_button->_visible) {
+ if (!tutorial)
+ return;
+ if (tutorial->_id == "TUTORIAL_MOVE_MAN" && action == 3 && g_ngi->_sceneStack.size() == 2)
+ warnOnce("CTutorialController::AddContinueBtnIfNeed: the MOVE_MAN test of the controller of the scene below is not ported");
+ } else if (!tutorial) {
+ return;
+ }
+ if (tutorial->_id == "TUTORIAL_MAKE_TASK_BOOT") {
+ if (_arrowTime >= 5.0f) {
+ tutorial->_arrows[0].shown = true;
+ _arrowTime = -1;
+ }
+ if (!_button->_visible) {
+ AniObject *boot = g_ngi->getSceneInStack(0)->findAniObjectById(ANI_SC4_BOOT, 0);
+ if (action == 3 && boot && boot->hit(x, y)) {
+ _arrowTime = -1;
+ finish();
+ }
+ }
+ }
+}
+
+// CTutorialController::OnGuiEvent (1A3B4C); analytics (CFlurryEventManager) not ported
+void TutorialController::onGuiEvent(const Common::String &id, const Common::String &event) {
+ if (event != "unpress")
+ return;
+ if (id == "BTN_SC_TUTORIAL_OK" || id == "BTN_SC_TUTORIAL_CONTINUE") {
+ finish();
+ return;
+ }
+ if (id == "BTN_SC_TUTORIAL_NO") {
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ finish();
+ if (tutorial)
+ tutorial->setState(1);
+ }
+ if (id == "BTN_SC_TUTORIAL_YES") {
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ finish();
+ if (tutorial)
+ tutorial->setState(1);
+ g_ngi->pushScene(SC_NOTEBOOK);
+ warnOnce("CNotebookController::SetAutoFoil: the notebook is not opened with the foil");
+ }
+ if (id == "BTN_SKIP") {
+ finish();
+ g_ngi->_tutorialManager->deactivate();
+ inventoryController()->setHelperVisible(false);
+ _skipButton->hideAndDeactivate();
+ if (!g_ngi->_taskManager->isTaskClosed("FIND_DOMINO_SC3"))
+ g_ngi->_taskManager->activateTask("FIND_DOMINO_SC3");
+ if (!g_ngi->_taskManager->isTaskClosed("FIND_APPLE_SC4"))
+ g_ngi->_taskManager->activateTask("FIND_APPLE_SC4");
+ }
+}
+
+// CTutorialController::OnMouseLKeyDown (1A5318)
+bool TutorialController::onMouseLKeyDown(uint32 id, float x, float y) {
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ if (tutorial && tutorial->_isExtra && _state == 2 && _cloud && _cloud->hit(x, y))
+ finish();
+ if (!passMouseActions(x, y, 2) || g_ngi->_sceneStack.size() < 2)
+ return true;
+ return sceneBelow()->onMouseLKeyDown(id, x, y);
+}
+
+// CTutorialController::OnMouseLKeyUp (1A53A4); analytics (CFlurryEventManager) not ported
+bool TutorialController::onMouseLKeyUp(uint32 id, float x, float y) {
+ addContinueBtnIfNeed(x, y, 3);
+ if (passMouseActions(x, y, 3) && g_ngi->_sceneStack.size() >= 2)
+ return sceneBelow()->onMouseLKeyUp(id, x, y);
+ if (!_button)
+ return true;
+ if (!_button->_visible)
+ return true;
+ if (_cloud && _cloud->hit(x, y))
+ finish();
+ return true;
+}
+
+// CTutorialController::OnMouseMove (1A55BC)
+bool TutorialController::onMouseMove(uint32 id, float x, float y) {
+ if (passMouseActions(x, y, 1) && g_ngi->_sceneStack.size() >= 2)
+ return sceneBelow()->onMouseMove(id, x, y);
+ return false;
+}
+
+// CTutorialController::GetCursorType (1A5608): egg tutorials show the interaction cursor
+int TutorialController::getCursorType(float x, float y) {
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ if (tutorial) {
+ Scene *scene = g_ngi->getSceneInStack(0);
+ if (tutorial->_id == "TUTORIAL_DO_EGG" && g_ngi->_inputController->getObject()) {
+ GameObject *object = scene->findVisibleObject(ANI_DADAYASHIK, 0);
+ if (object && static_cast<AniObject *>(object)->hit(x, y))
+ return 102;
+ }
+ if (tutorial->_id == "TUTORIAL_GIVE_EGG" && g_ngi->_inputController->getObject()) {
+ GameObject *object = scene->findVisibleObject(ANI_EGGEATER, 0);
+ if (object && static_cast<AniObject *>(object)->hit(x, y))
+ return 102;
+ }
+ }
+ if (!passMouseActions(x, y, 0) || g_ngi->_sceneStack.size() < 2)
+ return 0;
+ if (ISceneController *controller = sceneBelow()->_controller.get())
+ return controller->getCursorType(x, y);
+ return -1;
+}
+
+// CTutorialController::PassMouseActions (1A4854): whether the touch goes on to the scene below. The action is 1 for a move, 2 for the finger down and 3 for
+// the finger up; every tutorial has its own zone, a touch in it can finish the tutorial. Read in the disassembly (the decompiler fails on the jump table):
+// the tutorials without zone are FIRST, SEE_TASK and USE_TASK (the touch does not pass), SEE_ALL_TASKS, SEE_EGGEATER and LAST (it passes). Not ported:
+// the arcade tutorials, EXTRA_TUTORIAL_SEE_EXTRA_HELP and TUTORIAL_USE_MAP (their tutorials are not started yet), they let the touch pass.
+bool TutorialController::passMouseActions(float x, float y, int action) {
+ if (_state == 1)
+ return false;
+ Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
+ if (!tutorial)
+ return false;
+ const Common::String &id = tutorial->_id;
+ if (tutorial->_isExtra && !tutorial->_isArcade && id != "EXTRA_TUTORIAL_SEE_LIFT" && id != "EXTRA_TUTORIAL_SEE_HELP" && id != "EXTRA_TUTORIAL_SEE_EXTRA_HELP")
+ return false;
+ if (id == "TUTORIAL_FIRST" || id == "TUTORIAL_SEE_TASK" || id == "TUTORIAL_USE_TASK")
+ return false;
+ if (id == "TUTORIAL_SEE_ALL_TASKS" || id == "TUTORIAL_SEE_EGGEATER" || id == "TUTORIAL_LAST")
+ return true;
+
+ Scene *scene = g_ngi->getSceneInStack(0);
+ if (id == "TUTORIAL_MOVE_MAN")
+ return g_ngi->_sceneStack.size() >= 2;
+ // object hit: finger up finishes (CTutorialController::Finish), a touch in the zone passes
+ if (id == "TUTORIAL_USE_TRANSITION" || id == "TUTORIAL_USE_LADDER") {
+ Exit *exit = g_ngi->_exitManager->find(id == "TUTORIAL_USE_TRANSITION" ? PIC_SC1_RTRUBA : PIC_SC3_LADDER);
+ if (!exit->hitPicture(x, y))
+ return false;
+ if (_state == 3)
+ return false;
+ if (action == 3)
+ finish();
+ return true;
+ }
+ if (id == "TUTORIAL_MAKE_TASK_BOOT") {
+ AniObject *boot = scene->findAniObjectById(ANI_SC4_BOOT, 0);
+ return boot && boot->hit(x, y);
+ }
+ if (id == "TUTORIAL_SEE_COMPLETE_TASK") {
+ warnOnce("CNotebookController::IsBookMarksHit: the bookmarks of the notebook are not tested");
+ return false;
+ }
+ if (id == "TUTORIAL_DO_EGG" || id == "TUTORIAL_GIVE_EGG") {
+ if (g_ngi->_inputController->getObject())
+ mouseActions(x, y, action, id == "TUTORIAL_DO_EGG" ? ANI_DADAYASHIK : ANI_EGGEATER);
+ return false;
+ }
+ if (id == "TUTORIAL_USE_CONTINUE_BUTTON") {
+ PictureObject *continueButton = scene->findPictureObjectById(PIC_MNU_CONTINUE, 0);
+ if (!continueButton || !continueButton->hit(x, y))
+ return false;
+ if (action == 3)
+ finish();
+ return true;
+ }
+ if (id == "EXTRA_TUTORIAL_SEE_LIFT") {
+ GameObject *lift = scene->findVisibleObject(GD_SC38_LIFT, 0);
+ if (!lift || !static_cast<PictureObject *>(lift)->hit(x, y))
+ return false;
+ if (action == 3) {
+ finish();
+ setTransmitCoord(x, y, nullptr);
+ }
+ return true;
+ }
+ if (id == "EXTRA_TUTORIAL_SEE_HELP") {
+ if (!g_ngi->_notebook->isFoilHit(Common::Point(x, y)))
+ return false;
+ if (action == 2)
+ finish();
+ return true;
+ }
+ if (id.hasPrefix("ARCADE_TUTORIAL_") || id == "EXTRA_TUTORIAL_SEE_EXTRA_HELP" || id == "TUTORIAL_USE_MAP")
+ warnOnce("CTutorialController::PassMouseActions: the zones of the arcade tutorials, SEE_EXTRA_HELP and USE_MAP are not ported");
+ return true;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/tutorialcontroller.h b/engines/ngi/fullpipe/tutorialcontroller.h
new file mode 100644
index 00000000000..86c48740db5
--- /dev/null
+++ b/engines/ngi/fullpipe/tutorialcontroller.h
@@ -0,0 +1,111 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_TUTORIALCONTROLLER_H
+#define NGI_FULLPIPE_TUTORIALCONTROLLER_H
+
+#include "common/array.h"
+#include "common/str.h"
+
+#include "ngi/scenecontroller.h"
+
+namespace NGI {
+
+class AniObject;
+class BitmapFont;
+class GuiElement;
+class PictureObject;
+class Tutorial;
+class XmlNode;
+
+/** CTutorialController: the scene SC_TUTORIAL; field offsets as in the original.
+ * Not ported: PassMouseActions, AddContinueBtnIfNeed MOVE_MAN, notebook hints, analytics */
+class TutorialController : public ISceneController {
+public:
+ explicit TutorialController(int sceneId);
+ ~TutorialController() override {}
+
+ void onShow() override;
+ void onHide() override;
+ void onUpdate(uint32 elapsed) override;
+ void onRender(Common::Point scroll) override;
+ void onRenderTop(Common::Point scroll) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+ void onKeyUp(uint32 key) override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ bool onMouseMove(uint32 id, float x, float y) override;
+ int getCursorType(float x, float y) override;
+ void onGuiEvent(const Common::String &id, const Common::String &event) override;
+ bool isInventoryEnabled() override;
+ bool isInventoryRendered() override { return true; }
+ /** CTutorialController::SetXmlData and CleanXml: the saved step */
+ void setXmlData(const XmlNode &node);
+ void cleanXml();
+
+ /** CTutorialController::OnRenderAfterInventory */
+ void onRenderAfterInventory();
+ void setTransmitCoord(float x, float y, GameObject *object);
+ void transmitCoord();
+ void finish();
+ void start();
+ void loadLayout();
+ void unloadLayout();
+ void unloadArrays();
+ void checkArrowPos();
+ void addContinueBtnIfNeed(float x, float y, int action);
+ bool mouseActions(float x, float y, int action, uint pictureId);
+ bool mouseActionsZone(float x, float y, int action, const Common::Rect &zone);
+ bool passMouseActions(float x, float y, int action);
+
+ void setInventoryItemsActivity();
+ void resetInventoryItemsActivity();
+ void setExitManagerActivity();
+ void resetExitManagerActivity();
+ void setNotebookItemsActivity();
+ void resetNotebookItemsActivity();
+
+private:
+ AniObject *_man = nullptr; // +12: the bearded man
+ Common::Array<AniObject *> _arrows; // +16
+ PictureObject *_cloud = nullptr; // +28
+ Common::String _text; // +32
+ GuiElement *_button = nullptr; // +36: continue, ok or yes
+ GuiElement *_buttonNo = nullptr; // +40
+ GuiElement *_skipButton = nullptr; // +44: BTN_SKIP of the inventory
+ float _textLeft = 0; // +48
+ float _textTop = 0; // +52
+ float _textRight = 0; // +56
+ float _textBottom = 0; // +60
+ const BitmapFont *_font = nullptr; // +64
+ float _arrowTime = -1; // +68: the seconds since the arrow of TUTORIAL_MAKE_TASK_BOOT was hidden
+ int _state = 0; // +72: 1 starting, 2 shown, 3 finishing
+ int _step = 0; // +76: the number of the tutorials that were shown
+ float _transmitX = -1; // +80: where the touch goes on to the scene below
+ float _transmitY = -1; // +84
+ GameObject *_transmitObject = nullptr; // +88
+
+ bool runSceneQueue(int queueId);
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_TUTORIALCONTROLLER_H
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 3db59798159..dc560b78fcc 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -135,6 +135,7 @@ MODULE_OBJS = \
fullpipe/taskmanager.o \
fullpipe/testmode.o \
fullpipe/tremble.o \
+ fullpipe/tutorialcontroller.o \
fullpipe/tutorialmanager.o
ifdef USE_IMGUI
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index d2c9d86400b..5267f36327d 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -980,7 +980,7 @@ private:
// The children of the INVENTORY node: kept as XmlNode for CInventory::Init
void addInventoryNode(ParserNode *node) {
- if (!_inventory || node->depth < 1 || node->depth > _inventoryNodes.size())
+ if (!_inventory || node->depth < 1 || (uint)node->depth > _inventoryNodes.size())
return;
XmlNode *child = _inventoryNodes[node->depth - 1]->append(node->name);
copyAttributes(*child, *node);
Commit: 410661c6116d2d47b6402b8255b3aebf9067932c
https://github.com/scummvm/scummvm/commit/410661c6116d2d47b6402b8255b3aebf9067932c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Wire the tutorials: CheckTutorial of scenes 1 to 3 and the notebook, the tutorial controller replaces ModalTutorial
Changed paths:
R engines/ngi/fullpipe/sceneTutorial.cpp
engines/ngi/behavior.cpp
engines/ngi/behavior.h
engines/ngi/fullpipe/constants.h
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/fpcontroller.h
engines/ngi/fullpipe/inventorycontroller.cpp
engines/ngi/fullpipe/inventorycontroller.h
engines/ngi/fullpipe/notebook.cpp
engines/ngi/fullpipe/notebook.h
engines/ngi/fullpipe/sc03controller.h
engines/ngi/fullpipe/scene01.cpp
engines/ngi/fullpipe/scene03.cpp
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/scenecontrollers.h
engines/ngi/fullpipe/scenes.cpp
engines/ngi/fullpipe/scenes.h
engines/ngi/fullpipe/taskmanager.cpp
engines/ngi/fullpipe/tutorialcontroller.cpp
engines/ngi/fullpipe/tutorialcontroller.h
engines/ngi/fullpipe/tutorialmanager.h
engines/ngi/guimanager.cpp
engines/ngi/messagehandlers.cpp
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/behavior.cpp b/engines/ngi/behavior.cpp
index 5974833d1ad..5bcf7c83342 100644
--- a/engines/ngi/behavior.cpp
+++ b/engines/ngi/behavior.cpp
@@ -392,6 +392,22 @@ BehaviorMove *BehaviorController::getAniQueue(AniObject *ani, int id1, int id2)
return nullptr;
}
+BehaviorMove *BehaviorController::getAniQueue(int aniId, int queueId) {
+ for (BehaviorAni &behavior : _behaviors) {
+ if (!behavior._ani || behavior._ani->_id != aniId)
+ continue;
+ for (BehaviorAnim &anim : behavior._behaviorAnims) {
+ for (BehaviorMove &move : anim._behaviorMoves) {
+ if (move._queueId == queueId)
+ return &move;
+ }
+ }
+ return nullptr;
+ }
+
+ return nullptr;
+}
+
void BehaviorAni::clear() {
_ani = nullptr;
_staticsId = 0;
diff --git a/engines/ngi/behavior.h b/engines/ngi/behavior.h
index 961933e78dd..46c7449fe76 100644
--- a/engines/ngi/behavior.h
+++ b/engines/ngi/behavior.h
@@ -122,6 +122,8 @@ class BehaviorController : public CObject {
void enableAllQueuesForAni(AniObject *ani, int flag);
BehaviorMove *getAniQueue(AniObject *ani, int id1, int id2);
+ /** CBehaviorController::GetAniQueue (F362C) */
+ BehaviorMove *getAniQueue(int aniId, int queueId);
};
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index 3f80fa2fba1..cf72f53795b 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -46,6 +46,7 @@ namespace NGI {
#define ANI_SC_TUTORIAL_ARROW 11025
#define MV_SC_TUTORIAL_ARROW 11027
#define ANI_MARK_CATALOG 23285
+#define SND_CMN_082 23540
#define PIC_SC1_RTRUBA 698
#define ANI_ARROW 23234
#define ANI_ARROW_CHAPTER 23401
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 222877db769..438f1b8443e 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -517,6 +517,7 @@ void FPController::testScroll() {
// CFPController::OnUpdate, the camera part: every 10 ms UpdateScroll, TestScroll unless touching
void FPController::onUpdate(uint32 elapsed) {
+ checkTutorial();
checkQueues();
_elapsed += elapsed;
const int oldX = _scene->_x;
@@ -862,6 +863,18 @@ bool FPController::onTap(float tapX, float tapY) {
if (target && g_ngi->isAndroidFullPipe() && (target->_id == ANI_LIFT || (target->_id >= 23116 && target->_id <= 23125)) && g_ngi->lift().onButtonUp(target))
return true;
+ // CInteractionController::FindInteractionUnderCursor looks at the objects under the finger that take hits (the flag 2), the lowest z first: the pressed
+ // arrow of an exit is not one of them, the object below it is
+ {
+ const int heldItem = g_ngi->_inputController->getObjectId();
+ for (GameObject *object : g_ngi->_inputController->getHitObjects(&scene)) {
+ if (canInteractAny(hero, object, heldItem)) {
+ target = object;
+ break;
+ }
+ }
+ }
+
if (target) {
uint32 upperPipe;
if (g_ngi->_gameProject->_objectIds.findId("PIC_SC1_UTRUBA", upperPipe) && upperPipe == (uint16)target->_id)
@@ -869,8 +882,6 @@ bool FPController::onTap(float tapX, float tapY) {
const int item = g_ngi->_inputController->getObjectId();
debugC(2, kDebugSceneLogic, "FPController::onTap: target %d item %d can interact %d", target ? target->_id : 0, item, target ? canInteractAny(hero, target, item) : 0);
if (target && canInteractAny(hero, target, item)) {
- if (target->_objtype == kObjTypePictureObject && g_ngi->getGameLoaderGameVar()->getSubVarAsInt("Scene1ExitsDisabled"))
- return false;
return handleObjectInteraction(hero, target, item);
}
}
diff --git a/engines/ngi/fullpipe/fpcontroller.h b/engines/ngi/fullpipe/fpcontroller.h
index 9aa422e4a0e..58de5fa1fa9 100644
--- a/engines/ngi/fullpipe/fpcontroller.h
+++ b/engines/ngi/fullpipe/fpcontroller.h
@@ -64,6 +64,8 @@ public:
/** CFPController::SkipArcade clears +213; the controllers of the arcade scenes override it */
virtual void skipArcade() { _skipArcade = false; }
virtual bool canSwipeMan(float x, float y) { return true; }
+ /** CFPController::CheckTutorial (slot 70): empty here, scenes with a tutorial override it */
+ virtual void checkTutorial() {}
virtual void updateScroll();
virtual void limitScroll();
virtual void defaultScroll();
diff --git a/engines/ngi/fullpipe/inventorycontroller.cpp b/engines/ngi/fullpipe/inventorycontroller.cpp
index ea11e226680..b4381e57b17 100644
--- a/engines/ngi/fullpipe/inventorycontroller.cpp
+++ b/engines/ngi/fullpipe/inventorycontroller.cpp
@@ -26,6 +26,8 @@
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/inventorycontroller.h"
#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialcontroller.h"
+#include "ngi/fullpipe/tutorialmanager.h"
#include "ngi/gfx.h"
#include "ngi/guimanager.h"
#include "ngi/input.h"
@@ -103,7 +105,7 @@ void InventoryController::onRenderBottom(Common::Point scroll) {
// CInventoryController::OnRenderTop (199E48)
void InventoryController::onRenderTop(Common::Point scroll) {
if (g_ngi->getCurrentScene()->_sceneId == SC_TUTORIAL)
- warnOnce("CTutorialController::OnRenderAfterInventory: the tutorial scene is not ported");
+ static_cast<TutorialController *>(g_ngi->getCurrentScene()->_controller.get())->onRenderAfterInventory();
if (!_helperPicture)
_helperPicture = _scene->findPictureObjectById(PIC_SC_TUTORIAL_MARKER, 0);
if (_helperVisible && _helperPicture)
@@ -117,13 +119,12 @@ void InventoryController::onUpdate(uint32 elapsed) {
if (inventory->getItemByName("ANI_INV_COIN")->_counter > 0 && _stateHintNotebook == 0)
_stateHintNotebook = 1;
Scene *firstScene = g_ngi->getSceneInStack(0);
- if (firstScene->_sceneId == SC_5) {
- warnOnce("CScene::IsQueuesProcessed: the hint of the map in the scene 305 is not started");
- }
+ if (firstScene->_sceneId == SC_5 && !firstScene->isQueuesProcessed(true) && _stateHintMap == 0)
+ _stateHintMap = 1;
if (_stateHintMap == 1)
- warnOnce("CTutorialManager::ActivateTutorial ADDITIONAL_TUTORIAL_MAP is not ported");
+ g_ngi->_tutorialManager->activateTutorial("ADDITIONAL_TUTORIAL_MAP");
else if (_stateHintNotebook == 1)
- warnOnce("CTutorialManager::ActivateTutorial ADDITIONAL_TUTORIAL_NOTEBOOK is not ported");
+ g_ngi->_tutorialManager->activateTutorial("ADDITIONAL_TUTORIAL_NOTEBOOK");
g_ngi->arcadeInterface().update(elapsed);
@@ -201,9 +202,10 @@ void InventoryController::onShow() {
}
}
-// CInventoryController::OnGuiEvent. The map (SC_MAP), the main menu (SC_MAINMENU) and the hint helper are not ported (STUB warnings), the
-// tutorial is not a scene on the stack yet (the case of SC_TUTORIAL in the original pops it first).
+// CInventoryController::OnGuiEvent. The map (SC_MAP), the main menu (SC_MAINMENU) and the hint helper are not ported (STUB warnings). The tutorial
+// scene on the stack is popped first by the buttons that leave it.
void InventoryController::onGuiEvent(const Common::String &id, const Common::String &event) {
+ debugC(2, kDebugEvents, "InventoryController::onGuiEvent(%s, %s)", id.c_str(), event.c_str());
if (event != "unpress")
return;
@@ -211,6 +213,7 @@ void InventoryController::onGuiEvent(const Common::String &id, const Common::Str
if (id == "PIC_INV_MAP") {
if (current->_sceneId == SC_TUTORIAL)
g_ngi->popScene();
+ _stateHintMap = 3;
current = g_ngi->getCurrentScene();
if (current->_sceneId == SC_NOTEBOOK)
g_ngi->popScene();
@@ -228,7 +231,15 @@ void InventoryController::onGuiEvent(const Common::String &id, const Common::Str
return;
}
if (id == "PIC_INV_TASK" || id == "PIC_INV_TASK_PRESSED") {
- // the active tutorial (CTutorialManager::FindActiveTutorial) is not a scene yet: only the notebook toggles
+ // a shown extra tutorial goes back to waiting; the notebook hint ends without one
+ Tutorial *active = g_ngi->_tutorialManager->findActiveTutorial();
+ if (current->_sceneId == SC_TUTORIAL) {
+ if (active && active->_isExtra)
+ active->setState(1);
+ g_ngi->popScene();
+ }
+ if (!active || active->_isExtra)
+ _stateHintNotebook = 3;
current = g_ngi->getCurrentScene();
if (current->_sceneId == SC_NOTEBOOK)
g_ngi->popScene();
diff --git a/engines/ngi/fullpipe/inventorycontroller.h b/engines/ngi/fullpipe/inventorycontroller.h
index 8ab19362320..246986d7d93 100644
--- a/engines/ngi/fullpipe/inventorycontroller.h
+++ b/engines/ngi/fullpipe/inventorycontroller.h
@@ -32,12 +32,8 @@ class GuiElement;
class PictureObject;
class XmlNode;
-/**
- * Android: CInventoryController (ISceneController), the controller of the inventory scene (the scene 0, CInventory): the bar over the game scenes with
- * the items and the buttons of the map, the menu, the notebook and the skip buttons. It scrolls the bar out of the screen for an arcade (ScrollOut,
- * ScrollIn, OnUpdate), darkens the bar (OnRenderBottom) and keeps the buttons of the tasks. The comments give the offsets of the fields in the original.
- * Not ported: the tutorials that OnUpdate starts (CTutorialManager::ActivateTutorial), the tutorial scene in OnRenderTop and the hint helper.
- */
+/** CInventoryController, the controller of the inventory scene 0 (CInventory): the bar with items
+ and buttons; scrolls out for an arcade, darkens the bar. Not ported: CObjHelperManager */
class InventoryController : public ISceneController {
public:
explicit InventoryController(int sceneId);
diff --git a/engines/ngi/fullpipe/notebook.cpp b/engines/ngi/fullpipe/notebook.cpp
index aac3577619c..a2b8f6054ef 100644
--- a/engines/ngi/fullpipe/notebook.cpp
+++ b/engines/ngi/fullpipe/notebook.cpp
@@ -27,6 +27,7 @@
#include "ngi/gameloader.h"
#include "ngi/objects.h"
#include "ngi/anihandler.h"
+#include "ngi/statics.h"
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/guimanager.h"
#include "ngi/fullpipe/constants.h"
@@ -35,6 +36,7 @@
#include "ngi/fullpipe/scenes.h"
#include "ngi/sound.h"
#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
namespace NGI {
@@ -320,7 +322,7 @@ void Notebook::clearHints() {
void Notebook::updateHints() {
clearHints();
- if (!sceneTutorial_isCompleted() || _current == -1)
+ if (!g_ngi->_tutorialManager->isTutorialCompleted() || _current == -1)
return;
const Task *task = currentTask();
@@ -437,7 +439,7 @@ void Notebook::updateBookMarks() {
const Task *task = currentTask();
if (!_tasks.empty() && _page == kPageTask && _current != -1) {
- const bool showBonuses = g_ngi->_taskManager->getBonuses() > 0 && task && task->_state <= Task::kStateSeen && sceneTutorial_isCompleted();
+ const bool showBonuses = g_ngi->_taskManager->getBonuses() > 0 && task && task->_state <= Task::kStateSeen && g_ngi->_tutorialManager->isTutorialCompleted();
setBonusesVisible(showBonuses);
setElementVisible("BTN_TASK_PREV", true);
setElementVisible("BTN_TASK_NEXT", true);
@@ -491,8 +493,76 @@ void Notebook::onShow() {
showGiveButtonHint(isTimerShowing());
checkAngles();
- // The flashing bookmark of the catalog and the tutorial of the notebook (CheckTutorial, 126 lines) are not ported
- warnOnce("CNotebookController::CheckTutorial and the catalog bookmark are not ported");
+ // CSettings::GetIsCompleted is not ported, the catalog bookmark follows the tutorials
+ warnOnce("CSettings::GetIsCompleted: the settings are not ported (the catalog bookmark follows the tutorials)");
+ if (AniObject *catalog = _scene->findAniObjectById(ANI_MARK_CATALOG, 0)) {
+ if (g_ngi->_tutorialManager->isTutorialCompleted())
+ catalog->_flags |= 4; // the visible flag (+8 & 1 of the original)
+ else
+ catalog->_flags &= ~4;
+ }
+ // ("1st_run_press_note" is an event of the analytics of the original)
+ if (!g_ngi->_tutorialManager->isActive() && _tutorialId != "EXTRA_TUTORIAL_SEE_HELP" && _tutorialId != "EXTRA_TUTORIAL_SEE_EXTRA_HELP" && _tutorialId != "UNDEF")
+ _tutorialId = "AFTER_TUTORIAL_SEE_ALL_TASKS";
+ checkTutorial();
+}
+
+// CNotebookController::CheckTutorial (15B604)
+void Notebook::checkTutorial() {
+ TutorialManager *manager = g_ngi->_tutorialManager.get();
+ const bool running = manager->isActive() || _tutorialId == "EXTRA_TUTORIAL_SEE_HELP" || _tutorialId == "AFTER_TUTORIAL_SEE_ALL_TASKS" ||
+ _tutorialId == "EXTRA_TUTORIAL_SEE_EXTRA_HELP";
+ if (!running || _tutorialId == "UNDEF" || g_ngi->_sceneStack.size() != 2)
+ return;
+ if (manager->activateTutorial(_tutorialId))
+ return;
+ const Common::String previous = _tutorialId;
+ if (_tutorialId == "TUTORIAL_USE_TASK") {
+ _tutorialId = "AFTER_TUTORIAL_USE_TASK";
+ g_ngi->popScene();
+ } else if (_tutorialId == "AFTER_TUTORIAL_USE_TASK") {
+ _tutorialId = "TUTORIAL_SEE_COMPLETE_TASK";
+ } else if (_tutorialId == "TUTORIAL_SEE_COMPLETE_TASK") {
+ _tutorialId = "TUTORIAL_SEE_ALL_TASKS";
+ } else if (_tutorialId == "TUTORIAL_SEE_ALL_TASKS") {
+ _tutorialId = "AFTER_TUTORIAL_SEE_ALL_TASKS";
+ g_ngi->popScene();
+ } else if (_tutorialId == "AFTER_TUTORIAL_SEE_ALL_TASKS") {
+ // a hint is not scratched yet: the player is shown where the help is
+ if (_current != -1 && _tasks[_current]->_state != Task::kStateClosed) {
+ for (Foil *foil : _foils) {
+ if (!foil->isEnd())
+ _tutorialId = "EXTRA_TUTORIAL_SEE_HELP";
+ }
+ }
+ } else if (_tutorialId == "EXTRA_TUTORIAL_SEE_HELP") {
+ if (_current == -1 || !isTimerShowing())
+ return;
+ if (_tasks[_current]->_state != Task::kStateClosed) {
+ bool stopped = true;
+ for (Foil *foil : _foils)
+ stopped = stopped && foil->isStopped();
+ if (!stopped)
+ return;
+ }
+ const Sound *sound = g_ngi->findSound(SND_CMN_082);
+ if (sound && sound->isPlaying())
+ return;
+ _tutorialId = "EXTRA_TUTORIAL_SEE_EXTRA_HELP";
+ } else {
+ _tutorialId = "UNDEF";
+ }
+ if (previous != _tutorialId)
+ checkTutorial();
+}
+
+// CNotebookController::IsBookMarksHit (158FD4): hit test on the bookmark pictures
+bool Notebook::isBookMarksHit(Common::Point pos) const {
+ for (const Common::Rect &bookmark : _bookmarks) {
+ if (bookmark.contains(pos))
+ return true;
+ }
+ return false;
}
void Notebook::onHide() {
@@ -537,6 +607,8 @@ void Notebook::onUpdate(uint32 elapsed) {
if (_autoFoil)
removeFoil(elapsed);
+ else
+ checkTutorial();
}
// CNotebookController::RemoveFoil: the hint is revealed by itself
@@ -769,7 +841,7 @@ void Notebook::renderTaskPage() const {
// Headings: the task, and the hints while the task is open
text(_headingFont, Common::Rect(177, 121, 327, 151), _texts.getText("STR_TASK_CONTROLLER_QUESTION"));
- if (task->_state != Task::kStateClosed && sceneTutorial_isCompleted())
+ if (task->_state != Task::kStateClosed && g_ngi->_tutorialManager->isTutorialCompleted())
text(_headingFont, Common::Rect(507, 121, 657, 151), _texts.getText("STR_TASK_CONTROLLER_HINT"));
text(_font, Common::Rect(130, 240, 380, 360), plainText(_texts.getText(task->_textId)));
diff --git a/engines/ngi/fullpipe/notebook.h b/engines/ngi/fullpipe/notebook.h
index fe61a5ae6f5..cb8e9062711 100644
--- a/engines/ngi/fullpipe/notebook.h
+++ b/engines/ngi/fullpipe/notebook.h
@@ -54,6 +54,8 @@ public:
float getCleanPercent() const;
bool isStart() const { return getCleanPercent() == 0.0f; }
bool isEnd() const { return getCleanPercent() >= 0.1f; }
+ // CFoil::IsStopped: nothing is scratched, or everything
+ bool isStopped() const { return getCleanPercent() == 0.0f || getCleanPercent() == 1.0f; }
// CFoil::NextPoint(uint): the zigzag; false when nothing is left
bool nextPoint(uint32 elapsed);
@@ -98,7 +100,10 @@ public:
bool isInventoryRendered() override { return true; }
bool isInventoryEnabled() override { return true; }
+ /** CNotebookController::SetTutorial */
void setTutorial(bool tutorial) { _tutorial = tutorial; }
+ /** CNotebookController::CheckTutorial */
+ void checkTutorial();
// Task lists
void sortTasks();
@@ -117,6 +122,8 @@ public:
bool checkAutoFoil() const;
bool isTimerShowing() const;
bool isFoilHit(Common::Point pos) const;
+ /** CNotebookController::IsBookMarksHit */
+ bool isBookMarksHit(Common::Point pos) const;
void clearHints();
void updateBookMarks();
@@ -137,6 +144,9 @@ public:
Common::Array<Common::Rect> _bookmarks; // hit areas of the bookmarks (60, 117 + 45 * i)
private:
+ /** +12: the next tutorial of the notebook, "UNDEF" when there is none */
+ Common::String _tutorialId = "TUTORIAL_USE_TASK";
+ /** +112 (SetTutorial) */
bool _tutorial = false;
bool _pressed = false;
bool _autoFoil = false;
diff --git a/engines/ngi/fullpipe/sc03controller.h b/engines/ngi/fullpipe/sc03controller.h
index e7e30dd7ee3..0e50b459fb9 100644
--- a/engines/ngi/fullpipe/sc03controller.h
+++ b/engines/ngi/fullpipe/sc03controller.h
@@ -26,14 +26,30 @@
namespace NGI {
-/** Android: CSc03Controller. Only the parts that are ported: OnShow (the camera margins) and OnRender (the hint over the scene) */
+class AniObject;
+
+/** Android: CSc03Controller. Only the parts that are ported: OnShow (the camera margins), OnRender (the hint over the scene) and the tutorials */
class Sc03Controller : public FPController {
public:
- explicit Sc03Controller(int sceneId) : FPController(sceneId) {}
+ explicit Sc03Controller(int sceneId) : FPController(sceneId), _tutorial("TUTORIAL_MAKE_TASK_BOOT") {}
void onShow() override;
void onRender(Common::Point scroll) override;
bool isInventoryEnabled() override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ void checkTutorial() override;
+
+private:
+ /** +216: the next tutorial of the scene, "UNDEF" when there is none */
+ Common::String _tutorial;
+ /** +220: ANI_SC3_BOOT of the scene (found by OnShow) */
+ AniObject *_boot = nullptr;
+
+ /** the part of OnMouseLKeyDown and OnMouseLKeyUp that the tutorials decide */
+ bool tutorialBlocksTouch() const;
+ /** The egg boot of the inventory is there, or an egg was swallowed */
+ bool hasEggBootOrEaten() const;
};
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/scene01.cpp b/engines/ngi/fullpipe/scene01.cpp
index 3ee7ed58b22..17c7c67e420 100644
--- a/engines/ngi/fullpipe/scene01.cpp
+++ b/engines/ngi/fullpipe/scene01.cpp
@@ -75,15 +75,11 @@ void scene01_initObjects(Scene *sc, int entrance, bool eggUncracked) {
}
// CSc01Controller::OnGuiEvent: the skip button of the tutorial (BTN_SKIP of the inventory) deactivates the tutorials, hides the helper of the inventory
-// and itself and shows the exits of the scenes 1 and 3. The two variables are what the tutorial of ModalTutorial (sceneTutorial.cpp) reads, until the
-// controller of the tutorials replaces it (D05/D19).
+// and itself and shows the exits of the scenes 1 and 3.
void Sc01Controller::onGuiEvent(const Common::String &id, const Common::String &event) {
FPController::onGuiEvent(id, event);
if (event != "unpress" || id != "BTN_SKIP")
return;
- GameVar *root = g_ngi->getGameLoaderGameVar();
- root->setSubVarAsInt("TutorialDisabled", 1);
- root->setSubVarAsInt("Scene1ExitsDisabled", 0);
g_ngi->_tutorialManager->deactivate();
static_cast<InventoryController *>(g_ngi->_inventory->_controller.get())->setHelperVisible(false);
if (GuiElement *button = g_ngi->_inventory->_guiManager->getElement("BTN_SKIP"))
@@ -99,10 +95,47 @@ void Sc01Controller::onGuiEvent(const Common::String &id, const Common::String &
bool Sc01Controller::isInventoryEnabled() {
GuiElement *skip = g_ngi->_inventory->_guiManager ? g_ngi->_inventory->_guiManager->getElement("BTN_SKIP") : nullptr;
CursorController *cursor = g_ngi->_inputController;
- bool running = false;
- for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList)
- running = running || (queue->_queueId == QU_SC1_ENTER && !queue->_isFinished);
- return !running || (skip && skip->hit(Common::Point(cursor->_hotSceneX, cursor->_hotSceneY)));
+ return !isEntranceQueueRunning() || (skip && skip->hit(Common::Point(cursor->_hotSceneX, cursor->_hotSceneY)));
+}
+
+bool Sc01Controller::isEntranceQueueRunning() const {
+ for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList) {
+ if (queue->_queueId == QU_SC1_ENTER && !queue->_isFinished)
+ return true;
+ }
+ return false;
+}
+
+// CSc01Controller::CheckTutorial (1625D8): the tutorials of the first scene follow each other, FIRST, MOVE_MAN, SEE_TASK, USE_TRANSITION; the next one
+// is activated when the one before has ended (ActivateTutorial fails then, as it is not waiting or active any more)
+void Sc01Controller::checkTutorial() {
+ TutorialManager *manager = g_ngi->_tutorialManager.get();
+ if (!manager->isActive()) {
+ if (_tutorial != "UNDEF")
+ _tutorial = "UNDEF";
+ return;
+ }
+ if (isEntranceQueueRunning())
+ return;
+ if (_tutorial == "AFTER_TUTORIAL_USE_TRANSITION" || _tutorial == "UNDEF")
+ return;
+ if (g_ngi->_sceneStack.size() != 1)
+ return;
+ if (manager->activateTutorial(_tutorial))
+ return;
+ const Common::String previous = _tutorial;
+ if (_tutorial == "TUTORIAL_FIRST")
+ _tutorial = "TUTORIAL_MOVE_MAN";
+ else if (_tutorial == "TUTORIAL_MOVE_MAN")
+ _tutorial = "TUTORIAL_SEE_TASK";
+ else if (_tutorial == "TUTORIAL_SEE_TASK")
+ _tutorial = "TUTORIAL_USE_TRANSITION";
+ else if (_tutorial == "TUTORIAL_USE_TRANSITION")
+ _tutorial = "AFTER_TUTORIAL_USE_TRANSITION";
+ else if (_tutorial != "AFTER_TUTORIAL_USE_TRANSITION")
+ _tutorial = "UNDEF";
+ if (previous != _tutorial)
+ checkTutorial();
}
void scene01_initScene(Scene *sc, int entrance) {
@@ -129,13 +162,15 @@ int sceneHandler01(Command *cmd) {
return 0;
if (g_ngi->isAndroidFullPipe() && !cmd->_messageName.empty()) {
+ // a named message goes to the scene on top of the stack (CMessageQueue::ExecuteCmdMsg)
+ if (g_ngi->getCurrentScene() != g_ngi->_currentScene)
+ return 0;
if (cmd->_messageName == "MSG_ENABLE_BHV_SOUND") {
if (g_ngi->_currentScene->_behaviorController)
g_ngi->_currentScene->_behaviorController->enableAllMusic();
return 0;
}
if (cmd->_messageName == "MSG_DISABLE_EXIT_MANAGER") {
- g_ngi->getGameLoaderGameVar()->setSubVarAsInt("Scene1ExitsDisabled", 1);
// CSc01Controller::OnMessage: the helper of the inventory, the exits of the scene are hidden, the skip button shows
static_cast<InventoryController *>(g_ngi->_inventory->_controller.get())->setHelperVisible(true);
for (uint i = 0; i < g_ngi->_exitManager->getNumExits(); i++) {
diff --git a/engines/ngi/fullpipe/scene03.cpp b/engines/ngi/fullpipe/scene03.cpp
index 295c40b630a..41dab9ba741 100644
--- a/engines/ngi/fullpipe/scene03.cpp
+++ b/engines/ngi/fullpipe/scene03.cpp
@@ -35,6 +35,9 @@
#include "ngi/font.h"
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/sc03controller.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+#include "ngi/inventory.h"
+#include "ngi/input.h"
namespace NGI {
@@ -58,11 +61,82 @@ void Sc03Controller::onShow() {
_marginY = 200;
_offsetX = 400;
_offsetY = 300;
+ _boot = _scene->findAniObjectById(ANI_SC4_BOOT, 0);
}
// CSc03Controller::IsInventoryEnabled: CTutorialManager::IsTutorialCompleted
bool Sc03Controller::isInventoryEnabled() {
- return sceneTutorial_isCompleted();
+ return g_ngi->_tutorialManager->isTutorialCompleted();
+}
+
+// CSc03Controller::OnMouseLKeyDown and OnMouseLKeyUp (1644A0, 164518): after the tutorial of the ladder or of the egg the touch goes nowhere, and
+// after the tutorial of the boot only a touch on the boot counts. Then the base class, then CLift::OnButtonDown / OnButtonUp (they stay in
+// FPController::onTap and the lift code of the scene, D02/D17).
+bool Sc03Controller::tutorialBlocksTouch() const {
+ if (_tutorial == "AFTER_TUTORIAL_USE_LADDER" || _tutorial == "AFTER_TUTORIAL_GIVE_EGG")
+ return true;
+ return _tutorial == "AFTER_TUTORIAL_MAKE_TASK_BOOT" && _boot != g_ngi->_inputController->getHitObject();
+}
+
+bool Sc03Controller::onMouseLKeyDown(uint32 id, float x, float y) {
+ if (tutorialBlocksTouch())
+ return true;
+ return FPController::onMouseLKeyDown(id, x, y);
+}
+
+bool Sc03Controller::onMouseLKeyUp(uint32 id, float x, float y) {
+ if (tutorialBlocksTouch())
+ return true;
+ return FPController::onMouseLKeyUp(id, x, y);
+}
+
+bool Sc03Controller::hasEggBootOrEaten() const {
+ return g_ngi->_inventory->getItemByName("ANI_INV_EGGBOOT")->_counter > 0 || g_vars->swallowedEgg1->_value.intValue != 0;
+}
+
+// CSc03Controller::CheckTutorial (163834): the tutorials of the third scene, MAKE_TASK_BOOT, SEE_INVENTORY, USE_LADDER, GIVE_EGG, LAST: each is
+// followed by "AFTER_...", that waits for what the player has to do (the boot, an egg) before the next one is activated
+void Sc03Controller::checkTutorial() {
+ TutorialManager *manager = g_ngi->_tutorialManager.get();
+ if (!manager->isActive()) {
+ if (_tutorial != "UNDEF")
+ _tutorial = "UNDEF";
+ return;
+ }
+ if (!canInterruptManQueue() || _tutorial == "UNDEF" || g_ngi->_sceneStack.size() != 1)
+ return;
+ if (manager->activateTutorial(_tutorial))
+ return;
+ const Common::String previous = _tutorial;
+ if (_tutorial == "TUTORIAL_MAKE_TASK_BOOT") {
+ _tutorial = "AFTER_TUTORIAL_MAKE_TASK_BOOT";
+ } else if (_tutorial == "AFTER_TUTORIAL_MAKE_TASK_BOOT") {
+ if (g_ngi->_inventory->getItemByName("ANI_INV_BOOT")->_counter > 0 || hasEggBootOrEaten()) {
+ manager->findTutorial("TUTORIAL_MAKE_TASK_BOOT")->setState(4);
+ _tutorial = "TUTORIAL_SEE_INVENTORY";
+ }
+ } else if (_tutorial == "TUTORIAL_SEE_INVENTORY") {
+ _tutorial = "AFTER_TUTORIAL_SEE_INVENTORY";
+ } else if (_tutorial == "AFTER_TUTORIAL_SEE_INVENTORY") {
+ g_ngi->_taskManager->showActiveTaskDialog(true);
+ _tutorial = "TUTORIAL_USE_LADDER";
+ } else if (_tutorial == "TUTORIAL_USE_LADDER") {
+ _tutorial = "AFTER_TUTORIAL_USE_LADDER";
+ } else if (_tutorial == "AFTER_TUTORIAL_USE_LADDER") {
+ if (hasEggBootOrEaten())
+ _tutorial = "TUTORIAL_GIVE_EGG";
+ } else if (_tutorial == "TUTORIAL_GIVE_EGG") {
+ _tutorial = "AFTER_TUTORIAL_GIVE_EGG";
+ } else if (_tutorial == "AFTER_TUTORIAL_GIVE_EGG") {
+ if (g_ngi->_inventory->getItemByName("ANI_INV_EGGBOOT")->_counter == 0) {
+ manager->findTutorial("TUTORIAL_GIVE_EGG")->setState(4);
+ _tutorial = "TUTORIAL_LAST";
+ }
+ } else {
+ _tutorial = "UNDEF";
+ }
+ if (previous != _tutorial)
+ checkTutorial();
}
// CSc03Controller::OnRender: a cloud with the text at a fixed place of the screen
@@ -431,7 +505,7 @@ int sceneHandler03(Command *ex) {
// Android: CFPController scrolls, Scene::update runs behaviors; CSc03Controller::OnUpdate: hint
if (g_ngi->isAndroidFullPipe()) {
- if (g_vars->scene03_hintTimer != -1 && sceneTutorial_isCompleted()) {
+ if (g_vars->scene03_hintTimer != -1 && g_ngi->_tutorialManager->isTutorialCompleted()) {
const int time = g_vars->scene03_hintTimer + (int)ex->_param;
g_vars->scene03_hintTimer = time < kEatenHintDuration ? time : -1;
}
diff --git a/engines/ngi/fullpipe/sceneTutorial.cpp b/engines/ngi/fullpipe/sceneTutorial.cpp
deleted file mode 100644
index 473f8e86a80..00000000000
--- a/engines/ngi/fullpipe/sceneTutorial.cpp
+++ /dev/null
@@ -1,336 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "math/utils.h"
-
-#include "ngi/ngi.h"
-#include "ngi/fullpipe/constants.h"
-#include "ngi/font.h"
-#include "ngi/gameloader.h"
-#include "ngi/modal.h"
-#include "ngi/motion.h"
-#include "ngi/fullpipe/scenes.h"
-#include "ngi/fullpipe/fpcontroller.h"
-#include "ngi/fullpipe/exitmanager.h"
-#include "ngi/statics.h"
-#include "common/formats/xmlparser.h"
-
-namespace NGI {
-
-namespace {
-
-enum TutorialStep { kFirst, kMoveMan, kSeeTask, kUseTask, kUseTransition, kLast, kDone };
-const char *const tutorialIds[] = { "TUTORIAL_FIRST", "TUTORIAL_MOVE_MAN", "TUTORIAL_SEE_TASK", "TUTORIAL_USE_TASK", "TUTORIAL_USE_TRANSITION", "TUTORIAL_LAST" };
-
-int resourceId(const Common::String &name) {
- uint32 id;
- return g_ngi->_gameProject->_objectIds.findId(name, id) ? id : 0;
-}
-
-// The exits of the current scene (the tutorial of this file does it for all of them, the controller of the original by scene number, see CTutorialController::SetExitManagerActivity)
-void setSceneExits(int state) {
- for (uint i = 0; i < g_ngi->_exitManager->getNumExits(); i++) {
- Exit *exit = g_ngi->_exitManager->getExitNum(i);
- if (exit->getSceneId() == g_ngi->_currentScene->_sceneId)
- exit->setState(state);
- }
-}
-
-class Tutorial : public Common::XMLParser {
-public:
- explicit Tutorial(const char *id) : _id(id) {}
- Common::String _text;
- Common::Point _bearded, _arrow;
- int _angle = 0, _cloud = 0, _button = 0, _viewButton = 0, _left = 0, _top = 0, _right = 0, _bottom = 0;
- bool _mirror = false, _hasArrow = false;
-
-private:
- Common::String _id;
-
- CUSTOM_XML_PARSER(Tutorial) {
- XML_KEY(TUTORIALS)
- KEY_END()
- } PARSER_END()
-
- bool parserCallback_TUTORIALS(ParserNode *) { return true; }
- bool handleUnknownKey(ParserNode *node) override {
- node->layout = _XMLkeys;
- const auto &attrs = node->values;
- if (node->name == "TUTORIAL") {
- node->ignore = attrs.getValOrDefault("id") != _id;
- if (!node->ignore)
- _text = attrs.getValOrDefault("text_id");
- } else if (!getParentNode(node) || getParentNode(node)->values.getValOrDefault("id") != _id) {
- node->ignore = true;
- } else if (node->name == "BEARDED") {
- _bearded = Common::Point(number(node, "posX"), number(node, "posY"));
- _mirror = attrs.getValOrDefault("isMirror") == "true";
- } else if (node->name == "CLOUD") {
- _cloud = number(node, "view");
- _viewButton = number(node, "viewButton");
- _button = attrs.getValOrDefault("isButton") == "true" ? _viewButton : 0;
- } else if (node->name == "TEXT") {
- _left = number(node, "left_offset");
- _right = number(node, "right_offset");
- _top = number(node, "top_offset");
- _bottom = number(node, "bottom_offset");
- } else if (node->name == "ARROW") {
- _angle = number(node, "angle");
- _hasArrow = attrs.getValOrDefault("is") == "true";
- _arrow = Common::Point(number(node, "posX"), number(node, "posY"));
- // CTutorial::Init: "fitTo" sticks the arrow to an edge of the widescreen
- const Common::String fitTo = attrs.getValOrDefault("fitTo");
- if (fitTo == "left")
- _arrow.x -= g_ngi->_wideOfs;
- else if (fitTo == "right")
- _arrow.x += g_ngi->_wideOfs;
- } else {
- node->ignore = true;
- }
- return true;
- }
-
- static int number(ParserNode *node, const char *name) {
- return atoi(node->values.getValOrDefault(name).c_str());
- }
-};
-
-class ModalTutorial : public BaseModalObject {
-public:
- const Scene *getScene() const override { return &_scene; }
-
- ModalTutorial(Scene &scene, TutorialStep step) : _scene(scene), _step(step), _layout(tutorialIds[step]) {}
-
- bool open() {
- const Common::Path directory(Common::String("data/res_") + g_ngi->getResourceLocale());
- TextContainer strings;
- if (!_layout.loadFile("data/tutorials.xml") || !_layout.parse() || !strings.load(directory) ||
- !_font.load(directory.join("Fonts/task_dlg_19.fnt")))
- return false;
- _text = strings.getText(_layout._text);
- _cloud = _scene.findPictureObjectById(resourceId(Common::String::format("PIC_SC_TUTORIAL_CLOUD_%d", _layout._cloud)), 0);
- _man = _scene.findAniObjectById(resourceId("ANI_SC_TUTORIAL_BEARDED"), 0);
- if (!_cloud || !_man || !_scene._guiManager || _text.empty())
- return false;
- for (const char *id : {"BTN_SC_TUTORIAL_CONTINUE", "BTN_SC_TUTORIAL_OK"}) {
- if (GuiElement *element = _scene._guiManager->getElement(id))
- element->hideAndDeactivate();
- }
- _button = _layout._button ? _scene._guiManager->getElement(_layout._button == 2 ? "BTN_SC_TUTORIAL_OK" : "BTN_SC_TUTORIAL_CONTINUE") : nullptr;
- _man->setPos(_layout._bearded.x, _layout._bearded.y);
- _man->_statics = _man->getStatic(resourceId("ST_SC_TUTORIAL_BEARDED_UP"));
- _man->_flags = 4 | (_layout._mirror ? 8 : 0);
- _man->startMovement(resourceId("MOV_SC_TUTORIAL_BEARDED_FALL"), 0, -1, _layout._mirror);
- setSceneExits(0);
- if (_step == kUseTransition)
- g_ngi->_exitManager->setExitState(resourceId("PIC_SC1_RTRUBA"), 1);
- debugC(1, kDebugSceneLogic, "Started %s", tutorialIds[_step]);
- return true;
- }
-
- bool init(int elapsed) override {
- if (_finished)
- return false;
- _man->update(elapsed);
- if (_arrow) {
- if (!_arrow->_movement)
- _arrow->startMovement(resourceId("MV_SC_TUTORIAL_ARROW"), 0, -1);
- _arrow->update(elapsed);
- }
- if (!_man->_movement && !_shown) {
- const Dims man = _man->getFullSize();
- const Dims cloud = _cloud->getFullSize();
- // CTutorialController::LoadLayout: clouds 4 and 5 are placed without subtracting their height
- _pos = Common::Point(_man->_x + (_layout._mirror ? man.x - 50 : 50 - cloud.x),
- _man->_y + man.y - (_layout._cloud > 3 ? 0 : cloud.y) - 50);
- // The button (and the bottom of the text) sits half a cloud down, with a different shift per cloud/tutorial
- int shift = 50;
- if (_layout._cloud == 4)
- shift = 70;
- else if (_layout._cloud == 2)
- shift = 40;
- else if (_step == kLast)
- shift = 57; // TUTORIAL_LAST (EXTRA_TUTORIAL_USE_DEVICES +15 and EXTRA_TUTORIAL_SEE_HELP +7 are not used here)
- // The size of the button picture of viewButton counts even when no button is shown (every tutorial has
- // viewButton="1"): the button and the bottom of the text sit that much higher
- Dims buttonSize;
- if (const PictureObject *picture = _scene.findPictureObjectById(resourceId(_layout._viewButton == 2 ? "PIC_SC_TUTORIAL_BTN_OK" :
- (_layout._viewButton == 3 ? "PIC_SC_TUTORIAL_BTN_YES" : "PIC_SC_TUTORIAL_BTN_CONTINUE")), 0))
- buttonSize = picture->getFullSize();
- if (_layout._viewButton < 1 || _layout._viewButton > 3)
- buttonSize = Dims();
- const int buttonY = _pos.y + (cloud.y - buttonSize.y) / 2 + shift;
- if (_button) {
- _button->setPos(Common::Point(_pos.x + (cloud.x - buttonSize.x) / 2, buttonY));
- _button->showAndActivate();
- }
- _bounds = Common::Rect(_pos.x + _layout._left, _pos.y + _layout._top,
- _pos.x + cloud.x + _layout._right, buttonY + _layout._bottom);
- if (_layout._hasArrow) {
- _arrow = _scene.findAniObjectById(resourceId("ANI_SC_TUTORIAL_ARROW"), 0);
- if (_arrow) {
- _arrow->setPos(_layout._arrow.x, _layout._arrow.y);
- _arrow->_rotation = Math::deg2rad(static_cast<float>(_layout._angle));
- _arrow->_flags |= 4;
- }
- }
- _shown = true;
- debugC(2, kDebugSceneLogic, "Showing %s cloud %d (%d x %d) at %d,%d, text %d,%d - %d,%d, man %d,%d (%d x %d)", tutorialIds[_step], _layout._cloud,
- cloud.x, cloud.y, _pos.x, _pos.y, _bounds.left, _bounds.top, _bounds.right, _bounds.bottom, _man->_x, _man->_y, man.x, man.y);
- }
- return true;
- }
-
- void update() override {
- g_ngi->_currentScene->render();
- if (g_ngi->_inventoryScene && g_ngi->_inventoryScene->_guiManager)
- g_ngi->_inventoryScene->_guiManager->render(g_ngi->_backgroundSurface);
- if (_step == kUseTask && _parentObj)
- _parentObj->update();
- _man->render();
- if (!_shown)
- return;
- _cloud->_picture->blitTo(g_ngi->_backgroundSurface, _pos);
- _font.drawCentered(g_ngi->_backgroundSurface, _bounds, _text);
- if (_arrow)
- _arrow->render();
- _scene._guiManager->render(g_ngi->_backgroundSurface);
- }
-
- bool handleMessage(Command *cmd) override {
- if (cmd->_cmd != kCmdMessage || cmd->_messageNum != kMsgLButtonUp)
- return false;
- const Common::Point pos(cmd->_x, cmd->_y);
- GameVar *root = g_ngi->getGameLoaderGameVar();
- if (g_ngi->_inventoryScene) {
- GuiManager *hud = g_ngi->_inventoryScene->_guiManager.get();
- GuiElement *skip = hud ? hud->getElement("BTN_SKIP") : nullptr;
- if (skip && skip->hit(pos)) {
- hud->onMouseMove(pos);
- hud->onMouseLKeyUp(pos);
- _finished = true;
- return true;
- }
- }
- if (!_shown)
- return false;
- if (_button) {
- if (!_button->hit(pos))
- return false;
- _scene._guiManager->onMouseMove(pos);
- _scene._guiManager->onMouseLKeyUp(pos);
- } else if (_step == kMoveMan) {
- Scene &room = *g_ngi->_currentScene;
- if (!room._motionController || !room._motionController->startMove(g_ngi->_aniMan, pos.x + room._x, pos.y + room._y, 0, 0))
- return false;
- } else if (_step == kSeeTask) {
- GuiElement *task = g_ngi->_inventoryScene->_guiManager->getElement("PIC_INV_TASK");
- if (!task || !task->hit(pos))
- return false;
- } else if (_step == kUseTransition) {
- const int pipe = resourceId("PIC_SC1_RTRUBA");
- PictureObject *picture = g_ngi->_currentScene->findPictureObjectAtPos(pos.x, pos.y);
- if (!picture || picture->_id != pipe)
- return false;
- root->setSubVarAsInt("Scene1ExitsDisabled", 0);
- Scene &scene = *g_ngi->_currentScene;
- if (!sceneController(scene).onTap(pos.x + scene._x, pos.y + scene._y)) {
- root->setSubVarAsInt("Scene1ExitsDisabled", 1);
- return false;
- }
- }
- root->setSubVarAsInt("TutorialStep", _step + 1);
- setSceneExits(1);
- _finished = true;
- debugC(1, kDebugSceneLogic, "Finished %s", tutorialIds[_step]);
- return true;
- }
- bool pollEvent() override { return true; }
- void saveload() override {}
-
-private:
- Scene &_scene;
- TutorialStep _step;
- Tutorial _layout;
- BitmapFont _font;
- Common::String _text;
- AniObject *_man = nullptr, *_arrow = nullptr;
- PictureObject *_cloud = nullptr;
- GuiElement *_button = nullptr;
- Common::Point _pos;
- Common::Rect _bounds;
- bool _finished = false, _shown = false;
-};
-
-void showTutorial(TutorialStep step) {
- Scene *scene = g_ngi->findScene(resourceId("SC_TUTORIAL"));
- if (scene) {
- Common::ScopedPtr<ModalTutorial> dialog(new ModalTutorial(*scene, step));
- if (dialog->open()) {
- dialog->_parentObj = g_ngi->_modalObject;
- g_ngi->_modalObject = dialog.release();
- return;
- }
- }
- warning("Could not open tutorial %s", tutorialIds[step]);
- g_ngi->getGameLoaderGameVar()->setSubVarAsInt("TutorialDisabled", 1);
- g_ngi->getGameLoaderGameVar()->setSubVarAsInt("Scene1ExitsDisabled", 0);
-}
-
-} // End of anonymous namespace
-
-// CTaskManager::ShowActiveTaskDialog: CGame::PushScene(SC_NOTEBOOK)
-void sceneNotebook_show() {
- if (!g_ngi->_notebook)
- return;
- g_ngi->pushScene(SC_NOTEBOOK);
- if (g_ngi->getGameLoaderGameVar()->getSubVarAsInt("TutorialStep") == kUseTask)
- showTutorial(kUseTask);
-}
-
-// CTutorialManager::IsTutorialCompleted
-bool sceneTutorial_isCompleted() {
- GameVar *root = g_ngi->getGameLoaderGameVar();
- return root->getSubVarAsInt("TutorialDisabled") || root->getSubVarAsInt("TutorialStep") >= kDone;
-}
-
-void sceneTutorial_check() {
- const int scene = g_ngi->_currentScene->_sceneId;
- if (scene != SC_1 && scene != SC_3)
- return;
- GameVar *root = g_ngi->getGameLoaderGameVar();
- if (root->getSubVarAsInt("TutorialDisabled"))
- return;
- const int step = root->getSubVarAsInt("TutorialStep");
- if (step >= kDone || ((scene == SC_3) != (step == kLast)))
- return;
- if (!g_ngi->_aniMan || g_ngi->_aniMan->_messageQueueId || g_ngi->_aniMan->_movement)
- return;
- for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList)
- if (queue->_queueId == QU_SC1_ENTER && !queue->_isFinished)
- return;
- if (step == kUseTask)
- sceneNotebook_show();
- else
- showTutorial(static_cast<TutorialStep>(step));
-}
-
-} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index c62622b459b..745b20ae075 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -29,25 +29,98 @@
#include "ngi/fullpipe/inventorycontroller.h"
#include "ngi/fullpipe/liftcontroller.h"
#include "ngi/fullpipe/tutorialcontroller.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+#include "ngi/inventory.h"
namespace NGI {
-// CSc01Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+// CSc01Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera (the rest is in scene01_initScene), and the tutorial
+// that is active when the scene is shown again through the entrance 0 (TUTORIAL_LAST is the one of the way back)
void Sc01Controller::onShow() {
FPController::onShow();
_marginX = 300;
_marginY = 200;
_offsetX = 400;
_offsetY = 300;
+
+ if (const Tutorial *active = g_ngi->_tutorialManager->findActiveTutorial()) {
+ if (_scene->_currentEntranceId == 0 && active->_id == "TUTORIAL_LAST")
+ _tutorial = "TUTORIAL_LAST";
+ }
+ if (_tutorial == "AFTER_TUTORIAL_USE_TRANSITION")
+ _tutorial = "TUTORIAL_LAST";
}
-// CSc02Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
+// CSc02Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera, the tutorial of the egg (the one of the ladder is over)
void Sc02Controller::onShow() {
FPController::onShow();
_marginX = 300;
_marginY = 200;
_offsetX = 400;
_offsetY = 300;
+ _eggInteracting = false;
+ _tutorial = "TUTORIAL_DO_EGG";
+ g_ngi->_tutorialManager->findTutorial("TUTORIAL_USE_LADDER")->setState(4);
+}
+
+// CSc02Controller::OnHide
+void Sc02Controller::onHide() {
+ FPController::onHide();
+ _eggInteracting = false;
+}
+
+// CSc02Controller::OnMessage: the end of the egg interaction (the other messages are in the scene handler, sceneHandler02)
+void Sc02Controller::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (message == "MSG_SC2_END_INTER")
+ _eggInteracting = false;
+ else
+ FPController::onMessage(message, param, queue);
+}
+
+// CSc02Controller::OnMouseLKeyUp: while the egg interaction INT_418 runs the touches are ignored, and after the tutorial of the egg the touch
+// goes nowhere. Not ported: CInteractionController::FindInteractionUnderCursor (the interaction INT_418 never starts the flag here)
+bool Sc02Controller::onMouseLKeyUp(uint32 id, float x, float y) {
+ static bool reported = false;
+ if (!reported) {
+ reported = true;
+ warning("STUB/untested: CSc02Controller::OnMouseLKeyUp: CInteractionController::FindInteractionUnderCursor (INT_418) is not ported");
+ }
+ if (_eggInteracting)
+ return true;
+ if (_tutorial == "AFTER_TUTORIAL_DO_EGG")
+ return true;
+ return FPController::onMouseLKeyUp(id, x, y);
+}
+
+// CSc02Controller::CheckTutorial (162F24): the tutorial of the egg (DO_EGG), then the one of the map once the egg boot is taken
+void Sc02Controller::checkTutorial() {
+ TutorialManager *manager = g_ngi->_tutorialManager.get();
+ if (!manager->isActive()) {
+ if (_tutorial != "UNDEF")
+ _tutorial = "UNDEF";
+ return;
+ }
+ if (!canInterruptManQueue() || _tutorial == "UNDEF" || g_ngi->_sceneStack.size() != 1)
+ return;
+ if (manager->activateTutorial(_tutorial))
+ return;
+ const Common::String previous = _tutorial;
+ if (_tutorial == "TUTORIAL_DO_EGG") {
+ _tutorial = "AFTER_TUTORIAL_DO_EGG";
+ } else if (_tutorial == "AFTER_TUTORIAL_DO_EGG") {
+ if (g_ngi->_inventory->getItemByName("ANI_INV_EGGBOOT")->_counter > 0) {
+ manager->findTutorial("TUTORIAL_DO_EGG")->setState(4);
+ manager->finishTutorial("TUTORIAL_USE_CONTINUE_BUTTON");
+ _tutorial = "TUTORIAL_SEE_MAP";
+ }
+ } else if (_tutorial == "TUTORIAL_SEE_MAP" && manager->findTutorial("TUTORIAL_SEE_MAP")->_state == 4) {
+ manager->finishTutorial("TUTORIAL_USE_MAP");
+ _tutorial = "UNDEF";
+ }
+ if (manager->isTutorialCompleted())
+ _tutorial = "UNDEF";
+ if (previous != _tutorial)
+ checkTutorial();
}
// CSc05Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
diff --git a/engines/ngi/fullpipe/scenecontrollers.h b/engines/ngi/fullpipe/scenecontrollers.h
index 740c4248e42..615c08db6b3 100644
--- a/engines/ngi/fullpipe/scenecontrollers.h
+++ b/engines/ngi/fullpipe/scenecontrollers.h
@@ -31,16 +31,34 @@ namespace NGI {
class Sc01Controller : public FPController {
public:
- explicit Sc01Controller(int sceneId) : FPController(sceneId) {}
+ explicit Sc01Controller(int sceneId) : FPController(sceneId), _tutorial("TUTORIAL_FIRST") {}
void onShow() override;
void onGuiEvent(const Common::String &id, const Common::String &event) override;
bool isInventoryEnabled() override;
+ void checkTutorial() override;
+
+private:
+ /** +216: the next tutorial of the scene, "UNDEF" when there is none */
+ Common::String _tutorial;
+
+ /** CFindQueue(QU_SC1_ENTER)->+56 != -1: the queue of the entrance runs */
+ bool isEntranceQueueRunning() const;
};
class Sc02Controller : public FPController {
public:
explicit Sc02Controller(int sceneId) : FPController(sceneId) {}
void onShow() override;
+ void onHide() override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ void checkTutorial() override;
+
+private:
+ /** +216: the next tutorial of the scene, set to TUTORIAL_DO_EGG by OnShow */
+ Common::String _tutorial;
+ /** +236: the egg interaction INT_418 was started and has not ended (MSG_SC2_END_INTER) */
+ bool _eggInteracting = false;
};
class Sc05Controller : public FPController {
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index bb1d3333866..d549e84f763 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -39,6 +39,7 @@
#include "ngi/fullpipe/fpcontroller.h"
#include "ngi/font.h"
#include "ngi/fullpipe/tremble.h"
+#include "ngi/fullpipe/tutorialmanager.h"
#include "ngi/interaction.h"
namespace NGI {
@@ -580,7 +581,7 @@ void NGIEngine::updateSceneLogic(uint32 elapsed) {
// CFPController::OnUpdate
if (_tremble && _currentScene) {
// the hint only shakes when nothing else is going on: the tutorial is completed and none is shown
- const bool idle = sceneTutorial_isCompleted() && !isDialogShown();
+ const bool idle = _tutorialManager->isTutorialCompleted() && !isDialogShown();
_tremble->onUpdate(elapsed, idle);
}
if (_taskManager)
diff --git a/engines/ngi/fullpipe/scenes.h b/engines/ngi/fullpipe/scenes.h
index c72fa07cf46..bbe694b240e 100644
--- a/engines/ngi/fullpipe/scenes.h
+++ b/engines/ngi/fullpipe/scenes.h
@@ -36,11 +36,8 @@ struct Swinger;
struct WalkingBearder;
int defaultUpdateCursor();
-void sceneTutorial_check();
class BaseModalObject;
-void sceneNotebook_show();
void sceneController_initInventory();
-bool sceneTutorial_isCompleted();
class Chapter;
int sceneIntro_updateCursor();
diff --git a/engines/ngi/fullpipe/taskmanager.cpp b/engines/ngi/fullpipe/taskmanager.cpp
index 8b911c7fe42..45f45e4894d 100644
--- a/engines/ngi/fullpipe/taskmanager.cpp
+++ b/engines/ngi/fullpipe/taskmanager.cpp
@@ -31,6 +31,7 @@
#include "ngi/objects.h"
#include "ngi/anihandler.h"
#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/scenes.h"
#include "ngi/fullpipe/taskmanager.h"
@@ -526,9 +527,8 @@ int TaskManager::getHintUsedNumItem(int chapter, const Common::String &itemFind,
// CTaskManager::ShowActiveTaskDialog: the notebook, with the tutorial flag of CNotebookController::SetTutorial
void TaskManager::showActiveTaskDialog(bool tutorial) {
- if (tutorial)
- warnOnce("CNotebookController::SetTutorial is not ported");
- sceneNotebook_show();
+ g_ngi->_notebook->setTutorial(tutorial);
+ g_ngi->pushScene(SC_NOTEBOOK);
}
// CTaskManager::GetXmlData / SetXmlData (tasks.sav of the original)
diff --git a/engines/ngi/fullpipe/tutorialcontroller.cpp b/engines/ngi/fullpipe/tutorialcontroller.cpp
index d28037da687..e596df4dead 100644
--- a/engines/ngi/fullpipe/tutorialcontroller.cpp
+++ b/engines/ngi/fullpipe/tutorialcontroller.cpp
@@ -19,6 +19,7 @@
*
*/
+#include "common/debug.h"
#include "math/utils.h"
#include "ngi/ngi.h"
@@ -39,6 +40,7 @@
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/tutorialcontroller.h"
+#include "ngi/motion.h"
#include "ngi/fullpipe/tutorialmanager.h"
namespace NGI {
@@ -227,9 +229,9 @@ void TutorialController::setExitManagerActivity() {
exits.getExitNum(i)->setState(0);
}
if (tutorial->_id == "TUTORIAL_USE_TRANSITION")
- exits.find(PIC_SC1_RTRUBA)->setState(1);
+ exits.setExitState(PIC_SC1_RTRUBA, 1);
else if (tutorial->_id == "TUTORIAL_USE_LADDER")
- exits.find(PIC_SC3_LADDER)->setState(1);
+ exits.setExitState(PIC_SC3_LADDER, 1);
}
// CTutorialController::ResetExitManagerActivity (1A4140)
@@ -261,7 +263,7 @@ void TutorialController::setInventoryItemsActivity() {
inventoryButton("PIC_INV_TASK")->deactivate();
}
}
- g_ngi->_exitManager->find(PIC_SC1_RTRUBA)->setState(0);
+ g_ngi->_exitManager->setExitState(PIC_SC1_RTRUBA, 0);
}
// CTutorialController::ResetInventoryItemsActivity (1A45FC)
@@ -296,8 +298,8 @@ void TutorialController::start() {
inventoryController()->setHelperVisible(true);
}
// the man does not rotate while he falls
- _scene->_behaviorController->getAniQueue(_man, ANI_SC_TUTORIAL_BEARDED, QU_SC_TUTORIAL_BEARDED_ROTATE)->_flags |= 1;
- _scene->_behaviorController->getAniQueue(_man, ANI_SC_TUTORIAL_BEARDED, QU_SC_TUTORIAL_BEARDED_ROTATE_MIRROR)->_flags |= 1;
+ _scene->_behaviorController->getAniQueue(ANI_SC_TUTORIAL_BEARDED, QU_SC_TUTORIAL_BEARDED_ROTATE)->_flags |= 1;
+ _scene->_behaviorController->getAniQueue(ANI_SC_TUTORIAL_BEARDED, QU_SC_TUTORIAL_BEARDED_ROTATE_MIRROR)->_flags |= 1;
}
// CTutorialController::Finish (1A32BC): the man rises
@@ -555,8 +557,8 @@ void TutorialController::loadLayout() {
tutorial->_arrows[0].shown = false;
}
// the man rotates now
- _scene->_behaviorController->getAniQueue(_man, ANI_SC_TUTORIAL_BEARDED, QU_SC_TUTORIAL_BEARDED_ROTATE)->_flags &= ~1;
- _scene->_behaviorController->getAniQueue(_man, ANI_SC_TUTORIAL_BEARDED, QU_SC_TUTORIAL_BEARDED_ROTATE_MIRROR)->_flags &= ~1;
+ _scene->_behaviorController->getAniQueue(ANI_SC_TUTORIAL_BEARDED, QU_SC_TUTORIAL_BEARDED_ROTATE)->_flags &= ~1;
+ _scene->_behaviorController->getAniQueue(ANI_SC_TUTORIAL_BEARDED, QU_SC_TUTORIAL_BEARDED_ROTATE_MIRROR)->_flags &= ~1;
_state = 2;
}
@@ -569,8 +571,11 @@ void TutorialController::addContinueBtnIfNeed(float x, float y, int action) {
if (!_button->_visible) {
if (!tutorial)
return;
- if (tutorial->_id == "TUTORIAL_MOVE_MAN" && action == 3 && g_ngi->_sceneStack.size() == 2)
- warnOnce("CTutorialController::AddContinueBtnIfNeed: the MOVE_MAN test of the controller of the scene below is not ported");
+ // finger up on the motion graph of the scene below: the man was sent there
+ if (tutorial->_id == "TUTORIAL_MOVE_MAN" && action == 3 && g_ngi->_sceneStack.size() == 2) {
+ if (sceneBelow()->_motionController->checkPoint((int)x, (int)y))
+ finish();
+ }
} else if (!tutorial) {
return;
}
@@ -682,6 +687,12 @@ int TutorialController::getCursorType(float x, float y) {
// the tutorials without zone are FIRST, SEE_TASK and USE_TASK (the touch does not pass), SEE_ALL_TASKS, SEE_EGGEATER and LAST (it passes). Not ported:
// the arcade tutorials, EXTRA_TUTORIAL_SEE_EXTRA_HELP and TUTORIAL_USE_MAP (their tutorials are not started yet), they let the touch pass.
bool TutorialController::passMouseActions(float x, float y, int action) {
+ const bool pass = passMouseActionsZone(x, y, action);
+ debugC(2, kDebugEvents, "TutorialController::passMouseActions(%g, %g, %d) = %d", x, y, action, pass);
+ return pass;
+}
+
+bool TutorialController::passMouseActionsZone(float x, float y, int action) {
if (_state == 1)
return false;
Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
@@ -696,12 +707,18 @@ bool TutorialController::passMouseActions(float x, float y, int action) {
return true;
Scene *scene = g_ngi->getSceneInStack(0);
- if (id == "TUTORIAL_MOVE_MAN")
- return g_ngi->_sceneStack.size() >= 2;
+ if (id == "TUTORIAL_MOVE_MAN") {
+ // passes when no interaction is under the finger and it is on the motion graph of the scene below
+ if (g_ngi->_sceneStack.size() < 2)
+ return false;
+ warnOnce("STUB/untested: CTutorialController::PassMouseActions: CInteractionController::FindInteractionUnderCursor is not ported");
+ return sceneBelow()->_motionController->checkPoint((int)x, (int)y);
+ }
// object hit: finger up finishes (CTutorialController::Finish), a touch in the zone passes
if (id == "TUTORIAL_USE_TRANSITION" || id == "TUTORIAL_USE_LADDER") {
Exit *exit = g_ngi->_exitManager->find(id == "TUTORIAL_USE_TRANSITION" ? PIC_SC1_RTRUBA : PIC_SC3_LADDER);
- if (!exit->hitPicture(x, y))
+ // (the exits of a scene that was not visited are not made yet, see ExitManager::init)
+ if (!exit || !exit->hitPicture(x, y))
return false;
if (_state == 3)
return false;
@@ -714,8 +731,12 @@ bool TutorialController::passMouseActions(float x, float y, int action) {
return boot && boot->hit(x, y);
}
if (id == "TUTORIAL_SEE_COMPLETE_TASK") {
- warnOnce("CNotebookController::IsBookMarksHit: the bookmarks of the notebook are not tested");
- return false;
+ // the bookmarks of the notebook, the scene over the one of the game
+ if (!g_ngi->getSceneInStack(1)->_controller || !static_cast<Notebook *>(g_ngi->getSceneInStack(1)->_controller.get())->isBookMarksHit(Common::Point((int)x, (int)y)))
+ return false;
+ if (action == 3)
+ finish();
+ return true;
}
if (id == "TUTORIAL_DO_EGG" || id == "TUTORIAL_GIVE_EGG") {
if (g_ngi->_inputController->getObject())
@@ -723,7 +744,7 @@ bool TutorialController::passMouseActions(float x, float y, int action) {
return false;
}
if (id == "TUTORIAL_USE_CONTINUE_BUTTON") {
- PictureObject *continueButton = scene->findPictureObjectById(PIC_MNU_CONTINUE, 0);
+ PictureObject *continueButton = g_ngi->getSceneInStack(1)->findPictureObjectById(PIC_MNU_CONTINUE, 0);
if (!continueButton || !continueButton->hit(x, y))
return false;
if (action == 3)
diff --git a/engines/ngi/fullpipe/tutorialcontroller.h b/engines/ngi/fullpipe/tutorialcontroller.h
index 86c48740db5..2a82bd4cc5e 100644
--- a/engines/ngi/fullpipe/tutorialcontroller.h
+++ b/engines/ngi/fullpipe/tutorialcontroller.h
@@ -75,6 +75,7 @@ public:
bool mouseActions(float x, float y, int action, uint pictureId);
bool mouseActionsZone(float x, float y, int action, const Common::Rect &zone);
bool passMouseActions(float x, float y, int action);
+ bool passMouseActionsZone(float x, float y, int action);
void setInventoryItemsActivity();
void resetInventoryItemsActivity();
diff --git a/engines/ngi/fullpipe/tutorialmanager.h b/engines/ngi/fullpipe/tutorialmanager.h
index fae9160ef52..a7941e9eebd 100644
--- a/engines/ngi/fullpipe/tutorialmanager.h
+++ b/engines/ngi/fullpipe/tutorialmanager.h
@@ -85,6 +85,7 @@ public:
/** CTutorialManager::Init: reads the file */
void init(const char *path);
void activate() { _active = true; }
+ bool isActive() const { return _active; }
/** CTutorialManager::Deactivate: the tutorials that are not extra and not arcade finish */
void deactivate();
Tutorial *findTutorial(const Common::String &id) const;
diff --git a/engines/ngi/guimanager.cpp b/engines/ngi/guimanager.cpp
index 43e2c3dce4b..927f8493da0 100644
--- a/engines/ngi/guimanager.cpp
+++ b/engines/ngi/guimanager.cpp
@@ -24,6 +24,7 @@
#include "ngi/guimanager.h"
#include "ngi/font.h"
#include "ngi/ngi.h"
+#include "ngi/inventory.h"
#include "ngi/scene.h"
namespace NGI {
@@ -38,6 +39,11 @@ static bool guiFlag(const Common::StringMap &attrs, const char *key, bool fallba
return value == "1" || value == "true" || value == "yes";
}
+// CGame::FindScene for the element pictures: scene 0 is the inventory, not in the project
+static Scene *guiSourceScene(GameProject &project, int sceneId) {
+ return sceneId == 0 && g_ngi->_inventory ? static_cast<Scene *>(g_ngi->_inventory) : project.findScene(sceneId);
+}
+
GuiElement::GuiElement(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids) :
_scene(scene) {
_id = attrs.getValOrDefault("id", "error");
@@ -67,7 +73,7 @@ GuiElement::GuiElement(Scene &scene, const Common::StringMap &attrs, const Objec
}
void GuiElement::load(GameProject &project) {
- Scene *source = project.findScene(_sourceScene);
+ Scene *source = guiSourceScene(project, _sourceScene);
_picture = source && _pictureId ? source->findPictureObjectById(_pictureId, 0) : nullptr;
if (_picture) {
if (!_hasX)
@@ -109,7 +115,7 @@ GuiProgressBar::GuiProgressBar(Scene &scene, const Common::StringMap &attrs, con
void GuiProgressBar::load(GameProject &project) {
GuiElement::load(project);
- Scene *source = project.findScene(_sourceScene);
+ Scene *source = guiSourceScene(project, _sourceScene);
_vis = source && _visId ? source->findPictureObjectById(_visId, 0) : nullptr;
if (_vis) {
if (!_hasX)
@@ -192,7 +198,7 @@ GuiButton::GuiButton(Scene &scene, const Common::StringMap &attrs, const ObjectI
void GuiButton::load(GameProject &project) {
GuiElement::load(project);
- Scene *source = project.findScene(_sourceScene);
+ Scene *source = guiSourceScene(project, _sourceScene);
PictureObject *first = _picture;
for (int i = 0; source && i < kNumStates; ++i) {
if (_pictureIds[i])
diff --git a/engines/ngi/messagehandlers.cpp b/engines/ngi/messagehandlers.cpp
index 2a59be79645..6b7f191ea3e 100644
--- a/engines/ngi/messagehandlers.cpp
+++ b/engines/ngi/messagehandlers.cpp
@@ -518,12 +518,23 @@ int global_messageHandler3(Command *cmd) {
}
}
+// Android dialogs run queues of their own scenes over the scene below; Windows queues have none
+static Scene *queueScene(const Command *cmd) {
+ if (g_ngi->_gameVersion >= 201509 && cmd->_parId) {
+ const MessageQueue *queue = g_ngi->_globalMessageQueueList->getMessageQueueById(cmd->_parId);
+ if (queue && queue->_scene)
+ return queue->_scene;
+ }
+ return g_ngi->_currentScene;
+}
+
int global_messageHandler4(Command *cmd) {
AniObject *ani = nullptr;
+ Scene *scene = queueScene(cmd);
switch (cmd->_cmd) {
case kCmdQueue: {
- MessageQueue *source = g_ngi->_currentScene ? g_ngi->_currentScene->findMessageQueue(cmd->_messageNum) : nullptr;
+ MessageQueue *source = scene ? scene->findMessageQueue(cmd->_messageNum) : nullptr;
if (!source) {
warning("Could not find message queue %d", cmd->_messageNum);
if (!(cmd->_excFlags & 1))
@@ -544,10 +555,10 @@ int global_messageHandler4(Command *cmd) {
break;
}
case kCmdSetAniQueue:
- if (!g_ngi->_currentScene)
+ if (!scene)
break;
- ani = g_ngi->_currentScene->findAniObjectById(cmd->_parentId, cmd->_param);
+ ani = scene->findAniObjectById(cmd->_parentId, cmd->_param);
if (!ani)
break;
@@ -555,10 +566,10 @@ int global_messageHandler4(Command *cmd) {
break;
case kCmdStartMovement: {
- if (!g_ngi->_currentScene)
+ if (!scene)
break;
- ani = g_ngi->_currentScene->findAniObjectById(cmd->_parentId, cmd->_param);
+ ani = scene->findAniObjectById(cmd->_parentId, cmd->_param);
if (!ani)
break;
@@ -571,10 +582,10 @@ int global_messageHandler4(Command *cmd) {
break;
}
case kCmdStartAnimEx:
- if (!g_ngi->_currentScene)
+ if (!scene)
break;
- ani = g_ngi->_currentScene->findAniObjectById(cmd->_parentId, cmd->_param);
+ ani = scene->findAniObjectById(cmd->_parentId, cmd->_param);
if (!ani)
break;
@@ -582,10 +593,10 @@ int global_messageHandler4(Command *cmd) {
break;
case kCmdStartSliding: {
- if (!g_ngi->_currentScene)
+ if (!scene)
break;
- ani = g_ngi->_currentScene->findAniObjectById(cmd->_parentId, cmd->_param);
+ ani = scene->findAniObjectById(cmd->_parentId, cmd->_param);
if (!ani)
break;
@@ -605,10 +616,10 @@ int global_messageHandler4(Command *cmd) {
break;
}
case kCmdPlayIdle:
- if (!g_ngi->_currentScene)
+ if (!scene)
break;
- ani = g_ngi->_currentScene->findAniObjectById(cmd->_parentId, cmd->_param);
+ ani = scene->findAniObjectById(cmd->_parentId, cmd->_param);
if (!ani)
break;
@@ -619,17 +630,17 @@ int global_messageHandler4(Command *cmd) {
// Nop in original
break;
case kCmdSetSceneY:
- g_ngi->_currentScene->_y = cmd->_messageNum - cmd->_messageNum % g_ngi->_scrollSpeed;
+ scene->_y = cmd->_messageNum - cmd->_messageNum % g_ngi->_scrollSpeed;
break;
case kCmdSetSceneX:
- g_ngi->_currentScene->_x = cmd->_messageNum - cmd->_messageNum % g_ngi->_scrollSpeed;
+ scene->_x = cmd->_messageNum - cmd->_messageNum % g_ngi->_scrollSpeed;
break;
case kCmdMoveToStatic: {
- if (!g_ngi->_currentScene)
+ if (!scene)
break;
- ani = g_ngi->_currentScene->findAniObjectById(cmd->_parentId, cmd->_param);
+ ani = scene->findAniObjectById(cmd->_parentId, cmd->_param);
if (!ani)
break;
@@ -650,10 +661,10 @@ int global_messageHandler4(Command *cmd) {
break;
}
case kCmdSetStatic:
- if (!g_ngi->_currentScene)
+ if (!scene)
break;
- ani = g_ngi->_currentScene->findAniObjectById(cmd->_parentId, cmd->_param);
+ ani = scene->findAniObjectById(cmd->_parentId, cmd->_param);
if (!ani)
break;
@@ -662,10 +673,10 @@ int global_messageHandler4(Command *cmd) {
break;
case kCmdHide:
- if (!g_ngi->_currentScene)
+ if (!scene)
break;
- ani = g_ngi->_currentScene->findAniObjectById(cmd->_parentId, cmd->_param);
+ ani = scene->findAniObjectById(cmd->_parentId, cmd->_param);
if (!ani)
break;
@@ -673,18 +684,18 @@ int global_messageHandler4(Command *cmd) {
break;
case kCmdShowFromScene:
- if (!g_ngi->_currentScene || g_ngi->_currentScene->findAniObjectById(cmd->_parentId, cmd->_param) == nullptr) {
+ if (!scene || scene->findAniObjectById(cmd->_parentId, cmd->_param) == nullptr) {
ani = g_ngi->findScene(cmd->_invId)->findAniObjectById(cmd->_parentId, -1);
if (ani) {
ani = new AniObject(ani);
- g_ngi->_currentScene->addAni(ani, 1);
+ scene->addAni(ani, 1);
}
}
// fall through
case kCmdShow:
- if (g_ngi->_currentScene)
- ani = g_ngi->_currentScene->findAniObjectById(cmd->_parentId, cmd->_param);
+ if (scene)
+ ani = scene->findAniObjectById(cmd->_parentId, cmd->_param);
if (!ani)
break;
@@ -702,10 +713,10 @@ int global_messageHandler4(Command *cmd) {
break;
case kCmdShow2:
- if (!g_ngi->_currentScene)
+ if (!scene)
break;
- ani = g_ngi->_currentScene->findAniObjectById(cmd->_parentId, cmd->_param);
+ ani = scene->findAniObjectById(cmd->_parentId, cmd->_param);
if (!ani)
break;
@@ -716,34 +727,34 @@ int global_messageHandler4(Command *cmd) {
break;
case kCmdScrollScene: {
- if (!g_ngi->_currentScene->_pictureObjects.size())
+ if (!scene->_pictureObjects.size())
break;
int offX = g_ngi->_scrollSpeed * (cmd->_x / g_ngi->_scrollSpeed);
int offY = g_ngi->_scrollSpeed * (cmd->_y / g_ngi->_scrollSpeed);
if (cmd->_messageNum) {
- g_ngi->_currentScene->_x = offX - g_ngi->_sceneRect.left;
- g_ngi->_currentScene->_y = offY - g_ngi->_sceneRect.top;
+ scene->_x = offX - g_ngi->_sceneRect.left;
+ scene->_y = offY - g_ngi->_sceneRect.top;
if (cmd->_wait) {
- g_ngi->_currentScene->_messageQueueId = cmd->_parId;
+ scene->_messageQueueId = cmd->_parId;
}
} else {
g_ngi->_sceneRect.translate(offX - g_ngi->_sceneRect.left, offY - g_ngi->_sceneRect.top);
- g_ngi->_currentScene->_x = 0;
- g_ngi->_currentScene->_y = 0;
+ scene->_x = 0;
+ scene->_y = 0;
- g_ngi->_currentScene->updateScrolling2();
+ scene->updateScrolling2();
}
break;
}
case kCmdSetFlags:
- if (!g_ngi->_currentScene)
+ if (!scene)
break;
- ani = g_ngi->_currentScene->findAniObjectById(cmd->_parentId, cmd->_param);
+ ani = scene->findAniObjectById(cmd->_parentId, cmd->_param);
if (!ani)
break;
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index dc560b78fcc..70b65d1d265 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -129,7 +129,6 @@ MODULE_OBJS = \
fullpipe/sceneFinal.o \
fullpipe/sceneIntro.o \
fullpipe/sceneIntroDemo.o \
- fullpipe/sceneTutorial.o \
fullpipe/scenecontrollers.o \
fullpipe/scenes.o \
fullpipe/taskmanager.o \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 237d8ae0b09..dd74b0bde30 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -762,7 +762,6 @@ Common::Error NGIEngine::updateScreen(uint32 elapsed, byte &brightness, bool red
processMessages();
if (usesXMLProject() && !isDialogShown() && !_gameLoader->_preloadSceneId) {
updateSceneLogic(elapsed);
- sceneTutorial_check();
}
}
const bool renderScene = !_modalObject;
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 1120262a7e6..41867905c11 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -1100,6 +1100,14 @@ bool Scene::update(int counterdiff) {
// The part of CScene::Update that is the scene itself: the GUI and the objects, then the physics and the z controller (the updates of the global queues
// above are those of CGame in the original)
+bool Scene::isQueuesProcessed(bool ignoreInterruptState3) const {
+ for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList) {
+ if (queue->_scene == this && !queue->_isFinished && (!ignoreInterruptState3 || queue->_interruptState != 3))
+ return true;
+ }
+ return false;
+}
+
bool Scene::updateObjects(int counterdiff) {
bool changed = false;
if (_guiManager)
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 4185faff9c6..6b8888e6589 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -136,6 +136,8 @@ class Scene : public Background {
AniObject *findAniObjectById(int obj, int a3);
AniObject *getStaticANIObject1ByName(const Common::String &name, int a3);
MessageQueue *findMessageQueue(int messageId);
+ /** CScene::IsQueuesProcessed (11FB98): copies of the template queues run in the global list */
+ bool isQueuesProcessed(bool ignoreInterruptState3) const;
MessageQueue *getMessageQueueByName(const Common::String &name);
void removeAni(AniObject *obj);
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 5267f36327d..da9a23caf92 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -1746,9 +1746,9 @@ static bool createInventory(GameProject &project) {
XMLSceneParser parser(project, *inventory, g_ngi->getResourceLocale(), inventory.get());
if (!parser.loadFile("data/res/inventory.xml") || !parser.parse())
return false;
- if (inventory->_guiManager)
- inventory->_guiManager->load(project);
- g_ngi->_inventory = inventory.release();
+ g_ngi->_inventory = inventory.release(); // the pictures of the buttons without a scene are in it
+ if (g_ngi->_inventory->_guiManager)
+ g_ngi->_inventory->_guiManager->load(project);
g_ngi->_inventory->init();
createSceneController(0); // CInventoryController: CGame::FindScene(0) is the inventory
return true;
@@ -1826,6 +1826,7 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
g_ngi->_taskManager->onShow();
g_ngi->_tutorialManager.reset(new TutorialManager);
g_ngi->_tutorialManager->init("data/tutorials.xml");
+ createSceneController(SC_TUTORIAL); // CTutorialController
g_ngi->_tremble.reset(new Tremble);
if (!g_ngi->_tremble->init("data/tremble.xml", project._objectIds))
return Common::Error(Common::kNoGameDataFoundError, "Could not read the tremble objects");
Commit: 2720e82d55cd81b30e07febd4888a1e25459140b
https://github.com/scummvm/scummvm/commit/2720e82d55cd81b30e07febd4888a1e25459140b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Tutorial man idles again, arrows show, the boot of scene 3 can be picked
Changed paths:
engines/ngi/behavior.cpp
engines/ngi/behavior.h
engines/ngi/fullpipe/tutorialcontroller.cpp
engines/ngi/interaction.cpp
engines/ngi/messages.cpp
engines/ngi/messages.h
diff --git a/engines/ngi/behavior.cpp b/engines/ngi/behavior.cpp
index 5bcf7c83342..7192026bce0 100644
--- a/engines/ngi/behavior.cpp
+++ b/engines/ngi/behavior.cpp
@@ -81,6 +81,7 @@ BehaviorMove &BehaviorAni::addMove(int16 staticsId) {
}
void BehaviorController::onShow(Scene &scene) {
+ _scene = &scene;
for (BehaviorAni &behavior : _behaviors) {
AniObject *ani = scene.findAniObjectById(behavior._objectId, 0);
if (ani && ani->_sceneId != behavior._sourceSceneId)
@@ -112,7 +113,8 @@ bool BehaviorMove::canStart(uint32 elapsed, uint32 randomMax) const {
return !(_flags & 1) && (_delay <= 0 || elapsed >= (uint32)_delay) && _percent && g_ngi->_rnd.getRandomNumber(randomMax) <= _percent;
}
-bool BehaviorAni::update(uint32 elapsed) {
+// CBehaviorAni::Update: the move queue runs in the behavior's scene (not the current one)
+bool BehaviorAni::update(uint32 elapsed, Scene *scene) {
if (!_ani)
return false;
if (_activeMove) {
@@ -143,7 +145,7 @@ bool BehaviorAni::update(uint32 elapsed) {
if (move._mirror != ((_ani->_flags & 8) != 0) || !move.canStart(_elapsed, 99))
continue;
const bool started = move._movementId ? _ani->startMovement(move._movementId, 0, -1) :
- runQueueByIdWithAni(_ani, move._queueId, kBehaviorQueue);
+ runQueueByIdWithAni(_ani, move._queueId, kBehaviorQueue, scene);
if (started) {
_elapsed = 0;
_activeMove = &move;
@@ -231,7 +233,7 @@ bool BehaviorController::update(uint32 elapsed) {
debugC(6, kDebugBehavior, "BehaviorController::update()");
for (BehaviorAni &beh : _behaviors) {
if (timedBehaviors) {
- changed |= beh.update(elapsed);
+ changed |= beh.update(elapsed, _scene);
continue;
}
diff --git a/engines/ngi/behavior.h b/engines/ngi/behavior.h
index 46c7449fe76..36b1536846c 100644
--- a/engines/ngi/behavior.h
+++ b/engines/ngi/behavior.h
@@ -72,7 +72,7 @@ struct BehaviorAni {
void clear();
BehaviorMove &addMove(int16 staticsId);
- bool update(uint32 elapsed);
+ bool update(uint32 elapsed, Scene *scene);
void initAmbientBehavior(GameVar *var, Scene *sc);
void initObjectBehavior(GameVar *var, Scene *sc, AniObject *ani);
};
diff --git a/engines/ngi/fullpipe/tutorialcontroller.cpp b/engines/ngi/fullpipe/tutorialcontroller.cpp
index e596df4dead..bbf9edc2935 100644
--- a/engines/ngi/fullpipe/tutorialcontroller.cpp
+++ b/engines/ngi/fullpipe/tutorialcontroller.cpp
@@ -439,8 +439,13 @@ void TutorialController::onRenderAfterInventory() {
_buttonNo->render(g_ngi->_backgroundSurface);
Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
for (uint i = 0; i < _arrows.size(); i++) {
- if (tutorial && tutorial->getArrowData(i).shown)
+ if (tutorial && tutorial->getArrowData(i).shown) {
+ // CVisibleObject::Render ignores the visible flag (the scene checks it); the arrow was hidden
+ const int flags = _arrows[i]->_flags;
+ _arrows[i]->_flags |= 4;
_arrows[i]->render(Common::Point());
+ _arrows[i]->_flags = flags;
+ }
}
if (_font)
_font->print(g_ngi->_backgroundSurface, _text, _textLeft, _textTop, _textRight - _textLeft, _textBottom - _textTop, BitmapFont::kAlignCenter, BitmapFont::kVerticalCenter);
@@ -548,6 +553,9 @@ void TutorialController::loadLayout() {
if (ani) {
ani->setPos(arrow.x, arrow.y);
ani->_rotation = Math::deg2rad((float)arrow.angle);
+ // CAniObject::StartMovement rewinds a running movement first (the arrow of the scene still runs the one of the tutorial before)
+ if (ani->_movement)
+ ani->stopMovementToPrev(false);
ani->startMovement(MV_SC_TUTORIAL_ARROW, 0, -1);
_arrows.push_back(ani);
}
diff --git a/engines/ngi/interaction.cpp b/engines/ngi/interaction.cpp
index 77c905b65c7..e8945702b7d 100644
--- a/engines/ngi/interaction.cpp
+++ b/engines/ngi/interaction.cpp
@@ -43,8 +43,12 @@ bool canInteractAny(GameObject *obj1, GameObject *obj2, int invId) {
for (InteractionController::InteractionList::iterator i = intC->_interactions.begin(); i != intC->_interactions.end(); ++i) {
Interact *intr = *i;
- if (intr->_sceneId > 0 && intr->_sceneId != sceneId)
+ if (intr->_sceneId > 0 && intr->_sceneId != sceneId) {
+ // the Windows list is sorted by scene, the Android interactions are looked up by scene
+ if (g_ngi->usesXMLProject())
+ continue;
break;
+ }
if (invId == -3) {
invId = g_ngi->usesXMLProject() ? g_ngi->_inputController->getObjectId() : getGameLoaderInventory()->getSelectedItemId();
diff --git a/engines/ngi/messages.cpp b/engines/ngi/messages.cpp
index 586a584e65a..56581827a6c 100644
--- a/engines/ngi/messages.cpp
+++ b/engines/ngi/messages.cpp
@@ -1036,8 +1036,8 @@ bool runQueue(int queueId, int flags) {
return true;
}
-bool runQueueByIdWithAni(AniObject *obj, int queueId, int flags) {
- MessageQueue *mq = g_ngi->_currentScene->findMessageQueue(queueId);
+bool runQueueByIdWithAni(AniObject *obj, int queueId, int flags, Scene *scene) {
+ MessageQueue *mq = (scene ? scene : g_ngi->_currentScene)->findMessageQueue(queueId);
if (!mq)
return false;
diff --git a/engines/ngi/messages.h b/engines/ngi/messages.h
index a83d224320c..0b2e9fb9099 100644
--- a/engines/ngi/messages.h
+++ b/engines/ngi/messages.h
@@ -291,7 +291,7 @@ void clearGlobalMessageQueueList();
void clearGlobalMessageQueueList1();
bool runQueue(int queueId, int flags);
-bool runQueueByIdWithAni(AniObject *obj, int queueId, int flags);
+bool runQueueByIdWithAni(AniObject *obj, int queueId, int flags, Scene *scene = nullptr);
void postExCommand(int parentId, int keyCode, int x, int y, int f20, int f16);
} // End of namespace NGI
Commit: 162061c1e12f9c764242db79b5704d3bbd4db7f7
https://github.com/scummvm/scummvm/commit/162061c1e12f9c764242db79b5704d3bbd4db7f7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Tutorial: the scene below keeps running, the man is pulled up, arrows shake, the tap shows the react shine
Changed paths:
engines/ngi/fullpipe/constants.h
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/fpcontroller.h
engines/ngi/fullpipe/tutorialcontroller.cpp
engines/ngi/messagehandlers.cpp
engines/ngi/messages.cpp
engines/ngi/messages.h
engines/ngi/statics.cpp
engines/ngi/statics.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index cf72f53795b..0803cab9e41 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -47,6 +47,9 @@ namespace NGI {
#define MV_SC_TUTORIAL_ARROW 11027
#define ANI_MARK_CATALOG 23285
#define SND_CMN_082 23540
+#define ANI_REACT 23132
+#define ST_REACT 23133
+#define MV_REACT 23134
#define PIC_SC1_RTRUBA 698
#define ANI_ARROW 23234
#define ANI_ARROW_CHAPTER 23401
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 438f1b8443e..5c4c57e1669 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -902,8 +902,41 @@ bool FPController::onMouseMove(uint32 id, float x, float y) {
return false;
}
-// CFPController::OnMouseLKeyUpTop: the part of the exits (the marker of the tap and the object helper are not ported)
+// CFPController::IsNeedReact (14B538). Not ported: CFPController::GetCursorType (D11), the second way of the original to say that the point reacts
+// (cursor type 1), and CScene::GetVisObjVHitInteract (the first of the hit objects stands for it)
+bool FPController::isNeedReact(float x, float y) {
+ if (g_ngi->_inputController->getObject() || !canInterruptManQueue())
+ return false;
+ const Common::Array<GameObject *> &hits = g_ngi->_inputController->getHitObjects(_scene);
+ const int hitId = hits.empty() ? 0 : hits.back()->_id;
+ if (_interactObjectId == hitId)
+ return false;
+ for (GameObject *object : hits) {
+ if (canInteractAny(hero(), object, 0))
+ return true;
+ }
+ return false;
+}
+
+// CFPController::OnMouseLKeyUpTop: the shine of ANI_REACT where the finger was lifted over something that reacts, then the exits (the object helper
+// and the achievements are not ported). CFPController::OnSceneInit puts ANI_REACT into every scene; here it is done at the first use. CAniObject::MoveToStatic is SetStatic.
bool FPController::onMouseLKeyUpTop(uint32 id, float x, float y) {
+ if (g_ngi->_exitManager->getState() != 2 && !_dragged && isNeedReact(x, y)) {
+ if (!_react) {
+ if (Scene *common = g_ngi->findScene(SC_COMMON))
+ _react = common->findAniObjectById(ANI_REACT, 0);
+ if (_react)
+ _scene->addAni(_react, true);
+ }
+ if (_react) {
+ if (_react->_movement)
+ _react->stopMovementToPrev(true);
+ _react->setStatic(ST_REACT);
+ _react->setCenter(Common::Point((int)x, (int)y));
+ _react->_flags |= 4;
+ _react->startMovement(MV_REACT, 0, -1);
+ }
+ }
g_ngi->_exitManager->onMouseLKeyUp(x, y);
return false;
}
diff --git a/engines/ngi/fullpipe/fpcontroller.h b/engines/ngi/fullpipe/fpcontroller.h
index 58de5fa1fa9..c29c9bad823 100644
--- a/engines/ngi/fullpipe/fpcontroller.h
+++ b/engines/ngi/fullpipe/fpcontroller.h
@@ -64,8 +64,12 @@ public:
/** CFPController::SkipArcade clears +213; the controllers of the arcade scenes override it */
virtual void skipArcade() { _skipArcade = false; }
virtual bool canSwipeMan(float x, float y) { return true; }
+ /** CFPController::IsNeedReact (slot 73): tap on something that reacts, ANI_REACT shines there */
+ virtual bool isNeedReact(float x, float y);
/** CFPController::CheckTutorial (slot 70): empty here, scenes with a tutorial override it */
virtual void checkTutorial() {}
+ /** +208: ANI_REACT of SC_COMMON (CFPController::OnSceneInit puts it into the scene) */
+ AniObject *_react = nullptr;
virtual void updateScroll();
virtual void limitScroll();
virtual void defaultScroll();
diff --git a/engines/ngi/fullpipe/tutorialcontroller.cpp b/engines/ngi/fullpipe/tutorialcontroller.cpp
index bbf9edc2935..3240bce2a01 100644
--- a/engines/ngi/fullpipe/tutorialcontroller.cpp
+++ b/engines/ngi/fullpipe/tutorialcontroller.cpp
@@ -309,6 +309,10 @@ void TutorialController::finish() {
Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
const int queueId = tutorial && tutorial->_isMirror ? QU_SC_TUTORIAL_BEARDED_RISE_MIRROR : QU_SC_TUTORIAL_BEARDED_RISE;
if (!queueIsRunning(queueId)) {
+ // CAniObject::StartMovement takes the man from whatever he does (the rotation of his behavior): it rewinds the movement and clears his queue
+ if (_man->_movement)
+ _man->stopMovementToPrev(false);
+ _man->_messageQueueId = 0;
Movement *fall = _man->getMovement(MOV_SC_TUTORIAL_BEARDED_FALL);
fall->_loopDelay = 60;
fall->_phases[0]->_delayMs = 0;
@@ -401,7 +405,10 @@ void TutorialController::onUpdate(uint32 elapsed) {
if (_arrowTime != -1.0f)
_arrowTime += (float)elapsed / 1000.0f;
if (g_ngi->_sceneStack.size() > 1) {
+ // CScene::Update of the scene below; it is not current, so the early return part is done by hand
Scene *below = sceneBelow();
+ if (below->_behaviorController)
+ below->_behaviorController->update(elapsed);
below->updateObjects(elapsed);
if (below->_controller)
below->_controller->onUpdate(elapsed);
@@ -556,7 +563,7 @@ void TutorialController::loadLayout() {
// CAniObject::StartMovement rewinds a running movement first (the arrow of the scene still runs the one of the tutorial before)
if (ani->_movement)
ani->stopMovementToPrev(false);
- ani->startMovement(MV_SC_TUTORIAL_ARROW, 0, -1);
+ ani->startMovement(MV_SC_TUTORIAL_ARROW, 0, -1, false, true);
_arrows.push_back(ani);
}
}
diff --git a/engines/ngi/messagehandlers.cpp b/engines/ngi/messagehandlers.cpp
index 6b7f191ea3e..4c2b0ac2e38 100644
--- a/engines/ngi/messagehandlers.cpp
+++ b/engines/ngi/messagehandlers.cpp
@@ -577,7 +577,13 @@ int global_messageHandler4(Command *cmd) {
if (flags <= 0)
flags = -1;
- ani->startMovement(cmd->_messageNum, (cmd->_excFlags & 1) ? 0 : cmd->_parId, flags, cmd->_mirror);
+ // the Android movements can play backwards (the flag 0x40 of the object, see AniObject::update)
+ const bool timed = g_ngi->_gameVersion >= 201509;
+ if (timed)
+ ani->setFlags40(cmd->_reverse);
+ const Common::String cycled = cmd->_args.getValOrDefault("cycled");
+ if (!ani->startMovement(cmd->_messageNum, (cmd->_excFlags & 1) ? 0 : cmd->_parId, flags, cmd->_mirror, cycled == "1" || cycled.equalsIgnoreCase("true")) && timed)
+ ani->setFlags40(false);
break;
}
diff --git a/engines/ngi/messages.cpp b/engines/ngi/messages.cpp
index 56581827a6c..df56ce6b171 100644
--- a/engines/ngi/messages.cpp
+++ b/engines/ngi/messages.cpp
@@ -42,6 +42,7 @@ Command::Command(Command *src) : Message(*src) {
_messageName = src->_messageName;
_args = src->_args;
_mirror = src->_mirror;
+ _reverse = src->_reverse;
_field_3C = 1;
_messageNum = src->_messageNum;
_excFlags = src->_excFlags;
diff --git a/engines/ngi/messages.h b/engines/ngi/messages.h
index 0b2e9fb9099..225b496d137 100644
--- a/engines/ngi/messages.h
+++ b/engines/ngi/messages.h
@@ -136,6 +136,8 @@ class Command : public Message {
// Android: every attribute of the XML command (the original keeps them as named parameters).
Common::StringMap _args;
bool _mirror = false;
+ /** START_MOVEMENT "reverse": the movement plays backwards (CAniObject::StartMovement a6) */
+ bool _reverse = false;
int _messageNum;
int _field_3C;
int _excFlags;
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index b5c82759209..487b1684975 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -814,9 +814,25 @@ bool AniObject::update(int counterdiff) {
return true;
}
+ // a movement that plays backwards (START_MOVEMENT reverse) ends at its first frame
+ if (timedMovement && (_flags & 0x40)) {
+ if (!_movement->_curFrame || !_movement->gotoPrevFrame(_flags & 8)) {
+ stopMovement();
+ } else {
+ setPos(_movement->_x, _movement->_y);
+ _counter = _initialCounter;
+ _movement->_curPhase->enter(_id);
+ }
// Android ends the movement as soon as the next statics takes over.
- if (!_movement->setNext(_callback1, _callback2, timedMovement && (_flags & 8)) || (timedMovement && _movement->_curPhase == _movement->_nextStatic)) {
- stopMovement();
+ } else if (!_movement->setNext(_callback1, _callback2, timedMovement && (_flags & 8)) || (timedMovement && _movement->_curPhase == _movement->_nextStatic)) {
+ if (timedMovement && _cycled) {
+ // the cycled movement starts again
+ _movement->gotoFirstFrame();
+ setPos(_movement->_x, _movement->_y);
+ _movement->_curPhase->enter(_id);
+ } else {
+ stopMovement();
+ }
} else {
setPos(_movement->_x, _movement->_y);
_counter = _initialCounter;
@@ -995,6 +1011,8 @@ L12:
_movement->unload();
for (int i = 0; i < g_ngi->_currSoundListCount; ++i)
g_ngi->_currSoundList1[i]->stopByCreator(_id);
+ _flags &= ~0x40; // a backward movement (START_MOVEMENT reverse) is over
+ _cycled = false;
}
_movement = nullptr;
@@ -1391,7 +1409,7 @@ bool AniObject::startAnimEx(int movid, int parId, int flag1, int flag2) {
return res;
}
-bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseIdx, bool mirror) {
+bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseIdx, bool mirror, bool cycled) {
if (_flags & 0x80)
return false;
@@ -1424,14 +1442,17 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
int newy = _y;
Common::Point point;
+ // a movement that plays backwards starts from its next statics (the flag 0x40, CAniObject::StartMovement with reverse)
+ const bool reverse = timedMovement && (_flags & 0x40);
if (timedMovement && !_movement) {
// SetStatic reflects a change of facing about the old texture's center.
- const bool prevMirror = mirror != mov->_mirrorPrev;
+ const bool startMirror = reverse ? mov->_mirrorNext : mov->_mirrorPrev;
+ const bool prevMirror = mirror != startMirror;
if (_statics && prevMirror != ((_flags & 8) != 0)) {
const int shift = _statics->getDimensions().x - 2 * _statics->_someX;
newx += prevMirror ? shift : -shift;
}
- _statics = mov->_prevStatic;
+ _statics = reverse ? mov->_nextStatic : mov->_prevStatic;
}
if (mirror)
newx = -newx;
@@ -1444,7 +1465,7 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
} else if (_statics) {
point = _statics->getSomeXY();
- if (mov->_mirrorPrev)
+ if (reverse ? mov->_mirrorNext : mov->_mirrorPrev)
point.x = _statics->getDimensions().x - point.x;
newx -= point.x;
@@ -1489,6 +1510,7 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
_flags &= 0xFFF7;
_flags |= 1;
+ _cycled = cycled;
_messageQueueId = messageQueueId;
_movement->_curPhase->_countdown = _movement->_curPhase->_delay;
@@ -2232,7 +2254,7 @@ bool Movement::setNext(void (*callback1)(int, Common::Point *point, int, int), v
return result;
}
-bool Movement::gotoPrevFrame() {
+bool Movement::gotoPrevFrame(bool mirror) {
debugC(8, kDebugAnimation, "Movement::gotoPrevFrame()");
if (!_curFrame) {
@@ -2240,6 +2262,8 @@ bool Movement::gotoPrevFrame() {
return false;
}
+ const int oldX = _x;
+
Common::Point point = getCurrDynamicPhaseXY();
_x -= point.x;
@@ -2274,6 +2298,10 @@ bool Movement::gotoPrevFrame() {
_x += point.x;
_y += point.y;
+ // mirrored: the other way (as in setNext)
+ if (mirror)
+ _x = oldX - (_x - oldX);
+
return true;
}
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index d9cd4eafdea..1d79a6550e1 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -172,7 +172,7 @@ class Movement : public GameObject {
void removeFirstPhase();
bool setNext(void (*_callback1)(int, Common::Point *point, int, int), void (*callback2)(int *), bool mirror = false);
- bool gotoPrevFrame();
+ bool gotoPrevFrame(bool mirror = false);
void gotoFirstFrame();
void setLast();
@@ -191,6 +191,7 @@ class AniObject : public GameObject {
int16 _field_32;
int _field_34;
int _initialCounter;
+ bool _cycled = false;
void (*_callback1)(int, Common::Point *point, int, int);
void (*_callback2)(int *);
/** list items are owned */
@@ -247,7 +248,8 @@ public:
void stopCutMovement(const Common::Point &pending);
void stopMovementToPrev(bool keepSounds);
- bool startMovement(int movementId, int messageQueueId, int dynPhaseIdx, bool mirror = false);
+ /** cycled: Android CAniObject::StartMovement a3, the movement starts again when it is over (START_MOVEMENT "cycled") */
+ bool startMovement(int movementId, int messageQueueId, int dynPhaseIdx, bool mirror = false, bool cycled = false);
bool startAnimEx(int movid, int parId, int flag1, int flag2);
void startSliding(int movementId, int messageQueueId, int x, int y, const PointList &points, int someDynamicPhaseIndex, bool mirror);
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index da9a23caf92..088b84c54d9 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -1423,6 +1423,7 @@ private:
} else if (kind == "START_MOVEMENT" || kind == "3") {
cmd->_cmd = kCmdStartMovement;
cmd->_mirror = boolProperty(*node, "mirror");
+ cmd->_reverse = boolProperty(*node, "reverse");
if (!readId(node->values.getValOrDefault("ani"), cmd->_parentId))
return parserError("Unknown animation in START_MOVEMENT");
idProperty = "mov";
Commit: d6a874d922783076279b64017ab5e1986043b819
https://github.com/scummvm/scummvm/commit/d6a874d922783076279b64017ab5e1986043b819
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Do not delete the animations that belong to another scene when a scene goes away
Changed paths:
engines/ngi/scene.cpp
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 41867905c11..17c6ae28286 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -329,8 +329,11 @@ Scene::~Scene() {
_messageQueues.clear();
- for (uint i = 0; i < _aniObjects.size(); i++)
- delete _aniObjects[i];
+ // an animation of another scene put in here (ANI_REACT, CFPController::OnSceneInit) is not ours
+ for (uint i = 0; i < _aniObjects.size(); i++) {
+ if (g_ngi->_gameVersion < 201509 || _aniObjects[i]->_sceneId == _sceneId || _aniObjects[i]->_copyId)
+ delete _aniObjects[i];
+ }
_aniObjects.clear();
Commit: 2fc75898e69e792f0791ded86af2ae8fbaa2f16d
https://github.com/scummvm/scummvm/commit/2fc75898e69e792f0791ded86af2ae8fbaa2f16d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Tutorial: place the cloud by the top left of the man, also when he is mirrored
Changed paths:
engines/ngi/fullpipe/tutorialcontroller.cpp
diff --git a/engines/ngi/fullpipe/tutorialcontroller.cpp b/engines/ngi/fullpipe/tutorialcontroller.cpp
index 3240bce2a01..d1dc398cf4e 100644
--- a/engines/ngi/fullpipe/tutorialcontroller.cpp
+++ b/engines/ngi/fullpipe/tutorialcontroller.cpp
@@ -472,7 +472,15 @@ void TutorialController::loadLayout() {
_state = 2;
return;
}
- const Common::Point manPos(_man->_x, _man->_y);
+ // CVisibleObject::GetPosition is the top left of the picture; the position of an animation here is its pivot (the one that AniObject::render subtracts,
+ // mirrored for an object that faces the other way)
+ Common::Point manPos(_man->_x, _man->_y);
+ if (const Phase *phase = _man->_movement ? _man->_movement->_curPhase : _man->_statics) {
+ Common::Point anchor = _man->getSomeXY();
+ if (_man->_flags & 8)
+ anchor.x = phase->getDimensions().x - anchor.x;
+ manPos -= anchor;
+ }
const Common::Point manSize = _man->getSize();
const Common::Point cloudSize = _cloud->getSize();
float cloudY = manPos.y + manSize.y;
Commit: 6c3ca0107f72020d5d9db7e66c88d4d5a1cf2b16
https://github.com/scummvm/scummvm/commit/6c3ca0107f72020d5d9db7e66c88d4d5a1cf2b16
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: GameObject::getPosition and setPosition (top left of the texture), the tutorial uses them
Changed paths:
engines/ngi/fullpipe/tutorialcontroller.cpp
engines/ngi/gfx.cpp
engines/ngi/gfx.h
diff --git a/engines/ngi/fullpipe/tutorialcontroller.cpp b/engines/ngi/fullpipe/tutorialcontroller.cpp
index d1dc398cf4e..70b1663e7f5 100644
--- a/engines/ngi/fullpipe/tutorialcontroller.cpp
+++ b/engines/ngi/fullpipe/tutorialcontroller.cpp
@@ -284,7 +284,7 @@ void TutorialController::start() {
return;
}
_man = _scene->findAniObjectById(ANI_SC_TUTORIAL_BEARDED, 0);
- _man->setPos(tutorial->_beardedX, tutorial->_beardedY);
+ _man->setPosition(Common::Point(tutorial->_beardedX, tutorial->_beardedY));
_man->_flags |= 4;
Movement *fall = _man->getMovement(MOV_SC_TUTORIAL_BEARDED_FALL);
fall->_phases[0]->_delayMs = tutorial->_isArcade ? 1000 : 0;
@@ -395,7 +395,7 @@ void TutorialController::checkArrowPos() {
const TutorialArrow &arrow = tutorial->getArrowData(i);
if (arrow.shown && arrow.sceneId == scene->_sceneId) {
GameObject *object = scene->findVisibleObject(arrow.objectId, 0);
- _arrows[i]->setPos((object->_x - scene->_x) + arrow.offsetX, (object->_y - scene->_y) + arrow.offsetY);
+ _arrows[i]->setPosition(Common::Point((object->getPosition().x - scene->_x) + arrow.offsetX, (object->getPosition().y - scene->_y) + arrow.offsetY));
}
}
}
@@ -472,15 +472,7 @@ void TutorialController::loadLayout() {
_state = 2;
return;
}
- // CVisibleObject::GetPosition is the top left of the picture; the position of an animation here is its pivot (the one that AniObject::render subtracts,
- // mirrored for an object that faces the other way)
- Common::Point manPos(_man->_x, _man->_y);
- if (const Phase *phase = _man->_movement ? _man->_movement->_curPhase : _man->_statics) {
- Common::Point anchor = _man->getSomeXY();
- if (_man->_flags & 8)
- anchor.x = phase->getDimensions().x - anchor.x;
- manPos -= anchor;
- }
+ const Common::Point manPos = _man->getPosition();
const Common::Point manSize = _man->getSize();
const Common::Point cloudSize = _cloud->getSize();
float cloudY = manPos.y + manSize.y;
@@ -566,7 +558,7 @@ void TutorialController::loadLayout() {
}
}
if (ani) {
- ani->setPos(arrow.x, arrow.y);
+ ani->setPosition(Common::Point(arrow.x, arrow.y));
ani->_rotation = Math::deg2rad((float)arrow.angle);
// CAniObject::StartMovement rewinds a running movement first (the arrow of the scene still runs the one of the tutorial before)
if (ani->_movement)
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index d94ad207f08..fcf6a542ffb 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -321,6 +321,25 @@ Common::Rect GameObject::getBounds() const {
return Common::Rect(topLeft.x, topLeft.y, topLeft.x + static_cast<int>(size.x * _scaleX), topLeft.y + static_cast<int>(size.y * _scaleY));
}
+Common::Point GameObject::getPosition() const {
+ Common::Point topLeft;
+ Common::Point anchor;
+ Dims size;
+ if (!textureQuad(this, topLeft, size, anchor))
+ return Common::Point(_x, _y);
+ return topLeft;
+}
+
+void GameObject::setPosition(Common::Point topLeft) {
+ Common::Point current;
+ Common::Point anchor;
+ Dims size;
+ if (!textureQuad(this, current, size, anchor))
+ setPos(topLeft.x, topLeft.y);
+ else
+ setPos(topLeft.x + anchor.x, topLeft.y + anchor.y);
+}
+
Common::Point GameObject::getCenter() const {
Common::Point topLeft;
Common::Point anchor;
diff --git a/engines/ngi/gfx.h b/engines/ngi/gfx.h
index 31d8c0efe4a..1a57a08e554 100644
--- a/engines/ngi/gfx.h
+++ b/engines/ngi/gfx.h
@@ -199,6 +199,9 @@ class GameObject : public CObject {
Common::String getName() { return _title; }
/** The Android drawing parameters of this object. */
RenderParams getRenderParams(bool mirror = false) const;
+ /** CVisibleObject::GetPosition / SetPos: the texture's top left (_x, _y are a pivot) */
+ Common::Point getPosition() const;
+ void setPosition(Common::Point topLeft);
/** CVisibleObject::GetSize: the size of the drawn part of the texture, scale not applied */
Common::Point getSize() const;
/** CVisibleObject::GetCenter / SetCenter: the center of the window of the texture (the whole texture by default) */
Commit: 00a3af1991b3d4dd4282695667bfdc09643b34e5
https://github.com/scummvm/scummvm/commit/00a3af1991b3d4dd4282695667bfdc09643b34e5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Android movement control flow: reverse, cycled, startFrame, no queue bail-out, the rest of a stopped movement plays
Changed paths:
engines/ngi/fullpipe/tutorialcontroller.cpp
engines/ngi/messagehandlers.cpp
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/fullpipe/tutorialcontroller.cpp b/engines/ngi/fullpipe/tutorialcontroller.cpp
index 70b1663e7f5..1bf3aa7400f 100644
--- a/engines/ngi/fullpipe/tutorialcontroller.cpp
+++ b/engines/ngi/fullpipe/tutorialcontroller.cpp
@@ -309,10 +309,6 @@ void TutorialController::finish() {
Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
const int queueId = tutorial && tutorial->_isMirror ? QU_SC_TUTORIAL_BEARDED_RISE_MIRROR : QU_SC_TUTORIAL_BEARDED_RISE;
if (!queueIsRunning(queueId)) {
- // CAniObject::StartMovement takes the man from whatever he does (the rotation of his behavior): it rewinds the movement and clears his queue
- if (_man->_movement)
- _man->stopMovementToPrev(false);
- _man->_messageQueueId = 0;
Movement *fall = _man->getMovement(MOV_SC_TUTORIAL_BEARDED_FALL);
fall->_loopDelay = 60;
fall->_phases[0]->_delayMs = 0;
@@ -560,9 +556,6 @@ void TutorialController::loadLayout() {
if (ani) {
ani->setPosition(Common::Point(arrow.x, arrow.y));
ani->_rotation = Math::deg2rad((float)arrow.angle);
- // CAniObject::StartMovement rewinds a running movement first (the arrow of the scene still runs the one of the tutorial before)
- if (ani->_movement)
- ani->stopMovementToPrev(false);
ani->startMovement(MV_SC_TUTORIAL_ARROW, 0, -1, false, true);
_arrows.push_back(ani);
}
diff --git a/engines/ngi/messagehandlers.cpp b/engines/ngi/messagehandlers.cpp
index 4c2b0ac2e38..80408d1c52e 100644
--- a/engines/ngi/messagehandlers.cpp
+++ b/engines/ngi/messagehandlers.cpp
@@ -577,13 +577,10 @@ int global_messageHandler4(Command *cmd) {
if (flags <= 0)
flags = -1;
- // the Android movements can play backwards (the flag 0x40 of the object, see AniObject::update)
- const bool timed = g_ngi->_gameVersion >= 201509;
- if (timed)
- ani->setFlags40(cmd->_reverse);
const Common::String cycled = cmd->_args.getValOrDefault("cycled");
- if (!ani->startMovement(cmd->_messageNum, (cmd->_excFlags & 1) ? 0 : cmd->_parId, flags, cmd->_mirror, cycled == "1" || cycled.equalsIgnoreCase("true")) && timed)
- ani->setFlags40(false);
+ const Common::String startFrame = cmd->_args.getValOrDefault("startFrame");
+ ani->startMovement(cmd->_messageNum, (cmd->_excFlags & 1) ? 0 : cmd->_parId, flags, cmd->_mirror, cycled == "1" || cycled.equalsIgnoreCase("true"), cmd->_reverse,
+ startFrame.empty() ? -1 : atoi(startFrame.c_str()));
break;
}
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 487b1684975..14456c71e92 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -815,24 +815,28 @@ bool AniObject::update(int counterdiff) {
}
// a movement that plays backwards (START_MOVEMENT reverse) ends at its first frame
- if (timedMovement && (_flags & 0x40)) {
- if (!_movement->_curFrame || !_movement->gotoPrevFrame(_flags & 8)) {
- stopMovement();
+ // CMovement::SetNext (EFB8E)
+ const int lastFrame = (int)_movement->_phases.size() - 2; // last phase; the next statics follows
+ if (timedMovement && _movement->_reverse) {
+ if (_movement->_curFrame > 0) {
+ _movement->gotoPrevFrame(_flags & 8);
+ } else if (_movement->_cycled) {
+ _movement->setFrame(lastFrame, _flags & 8);
} else {
- setPos(_movement->_x, _movement->_y);
- _counter = _initialCounter;
- _movement->_curPhase->enter(_id);
+ stopMovement();
+ return true;
}
+ setPos(_movement->_x, _movement->_y);
+ _counter = _initialCounter;
+ _movement->_curPhase->enter(_id);
// Android ends the movement as soon as the next statics takes over.
+ } else if (timedMovement && _movement->_cycled && _movement->_curFrame >= lastFrame) {
+ _movement->setFrame(0, _flags & 8);
+ setPos(_movement->_x, _movement->_y);
+ _counter = _initialCounter;
+ _movement->_curPhase->enter(_id);
} else if (!_movement->setNext(_callback1, _callback2, timedMovement && (_flags & 8)) || (timedMovement && _movement->_curPhase == _movement->_nextStatic)) {
- if (timedMovement && _cycled) {
- // the cycled movement starts again
- _movement->gotoFirstFrame();
- setPos(_movement->_x, _movement->_y);
- _movement->_curPhase->enter(_id);
- } else {
- stopMovement();
- }
+ stopMovement();
} else {
setPos(_movement->_x, _movement->_y);
_counter = _initialCounter;
@@ -960,21 +964,52 @@ void AniObject::stopMovement() {
Common::Point point;
if (_movement) {
- if (g_ngi->_gameVersion >= 201509 && !(_flags & 0x40)) {
- // CAniObject::StopMovement plays the rest of the movement (CMovement::SetCurFrame to the end frame, running the phase commands
- // unless the sounds are kept) before CMovement::Stop; here the object stops where it is
- const int endFrame = _targetFrame >= 0 ? _targetFrame : (int)_movement->_phases.size() - 1;
- if (_movement->_curFrame < endFrame)
- warning("STUB/untested: AniObject::stopMovement(%d) before the end of the movement %d (frame %d of %d)", _id, _movement->_id, _movement->_curFrame, endFrame);
+ const bool reversed = g_ngi->_gameVersion >= 201509 ? _movement->_reverse : (_flags & 0x40) != 0;
+ if (g_ngi->_gameVersion >= 201509) {
+ // CAniObject::StopMovement plays the rest of the movement before CMovement::Stop;
+ // a walk cut at a frame goes through stopCutMovement
+ const bool mirror = (_flags & 8) != 0;
+ if (reversed) {
+ while (_movement->_curFrame > 0) {
+ _movement->gotoPrevFrame(mirror);
+ _movement->_curPhase->enter(_id);
+ }
+ } else if (_targetFrame < 0) {
+ const int endFrame = (int)_movement->_phases.size() - 1;
+ while (_movement->_curFrame < endFrame && _movement->setNext(nullptr, nullptr, mirror))
+ _movement->_curPhase->enter(_id);
+ } else if (_movement->_curFrame < _targetFrame) {
+ warning("STUB/untested: AniObject::stopMovement(%d) before the stop frame of the movement %d (frame %d of %d)", _id, _movement->_id, _movement->_curFrame, _targetFrame);
+ }
}
setPos(_movement->_x, _movement->_y);
- if (_flags & 0x40) {
+ if (reversed) {
if (!_movement->_currMovement) {
if (_movement->_curFrame)
goto L11;
L8:
+ if (g_ngi->_gameVersion >= 201509) {
+ // CMovement::Stop with reverse: first frame position minus the previous step;
+ // mirrored: the other way about the center
+ Statics *previous = _movement->_prevStatic;
+ const Common::Point oldTopLeft = getPosition();
+ const int oldWidth = _movement->_curPhase->getDimensions().x;
+ const int newWidth = previous->getDimensions().x;
+ const bool mirrored = (_flags & 8) != 0;
+ const Common::Point newTopLeft(mirrored ? oldTopLeft.x + _movement->_prevStepX + oldWidth - newWidth : oldTopLeft.x - _movement->_prevStepX,
+ oldTopLeft.y - _movement->_prevStepY);
+ _statics = previous;
+ if (_movement->_mirrorPrev)
+ _flags ^= 8;
+ Common::Point anchor = previous->getSomeXY();
+ if (_flags & 8)
+ anchor.x = newWidth - anchor.x;
+ _x = newTopLeft.x + anchor.x;
+ _y = newTopLeft.y + anchor.y;
+ goto L12;
+ }
_statics = _movement->_prevStatic;
point = _movement->getCurrDynamicPhaseXY();
_x -= point.x;
@@ -1011,11 +1046,13 @@ L12:
_movement->unload();
for (int i = 0; i < g_ngi->_currSoundListCount; ++i)
g_ngi->_currSoundList1[i]->stopByCreator(_id);
- _flags &= ~0x40; // a backward movement (START_MOVEMENT reverse) is over
- _cycled = false;
+ _movement->_reverse = false;
+ _movement->_cycled = false;
}
_movement = nullptr;
+ debugC(1, kDebugAnimation, "movement stop: ani %d copy %d movement %d pos %d,%d topleft %d,%d flags %x statics %d", _id, _copyId, oid, _x, _y, getPosition().x,
+ getPosition().y, _flags, _statics ? _statics->_staticsId : -1);
Command *ex = new Command(_id, kCmdMessage, kMsgAniMovementEnded, 0, 0, 0, 1, 0, 0, 0);
ex->_param = _copyId;
ex->_excFlags = 2;
@@ -1409,18 +1446,19 @@ bool AniObject::startAnimEx(int movid, int parId, int flag1, int flag2) {
return res;
}
-bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseIdx, bool mirror, bool cycled) {
+bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseIdx, bool mirror, bool cycled, bool reverse, int startFrame) {
if (_flags & 0x80)
return false;
debugC(4, kDebugAnimation, "AniObject::startMovement(%d, %d, %d) (%s [%d]) [%d, %d]", movementId, messageQueueId, dynPhaseIdx, transCyrillic(_title), _id, _x, _y);
- if (_messageQueueId) {
+ const bool timedMovement = g_ngi->_gameVersion >= 201509;
+ // the Android StartMovement ignores the queue of the object
+ if (_messageQueueId && !timedMovement) {
updateGlobalMessageQueue(messageQueueId, _id);
return false;
}
- const bool timedMovement = g_ngi->_gameVersion >= 201509;
Movement *mov = getMovement(movementId);
// An XML movement without any PHASE elements contains only its end pose.
if (!mov || (timedMovement && !mov->getPhase(1))) {
@@ -1428,7 +1466,7 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
return false;
}
- if (timedMovement && _movement && _movement != mov && (_flags & 1))
+ if (timedMovement && _movement && (_flags & 1))
stopMovementToPrev(false); // CAniObject::StartMovement: a running movement is rewound to its previous statics first
if (mov == _movement) {
@@ -1442,8 +1480,9 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
int newy = _y;
Common::Point point;
- // a movement that plays backwards starts from its next statics (the flag 0x40, CAniObject::StartMovement with reverse)
- const bool reverse = timedMovement && (_flags & 0x40);
+ // a reverse movement starts from its next statics
+ if (!timedMovement)
+ reverse = (_flags & 0x40) != 0;
if (timedMovement && !_movement) {
// SetStatic reflects a change of facing about the old texture's center.
const bool startMirror = reverse ? mov->_mirrorNext : mov->_mirrorPrev;
@@ -1476,12 +1515,17 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
_stepArray.clear();
- if (_flags & 0x40)
+ if (timedMovement && reverse) {
+ // the object stands in its next statics (last frame); the first one shown is the one before
+ _movement->_curFrame = (int)_movement->_phases.size() - 1;
+ _movement->updateCurrDynamicPhase();
+ } else if (reverse) {
_movement->setLast();
- else
+ } else {
_movement->gotoFirstFrame();
+ }
- if (!(_flags & 0x40)) {
+ if (!reverse) {
if (!_movement->_curFrame) {
point = _stepArray.getCurrPoint();
newx += point.x + _movement->_prevStepX;
@@ -1510,17 +1554,33 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
_flags &= 0xFFF7;
_flags |= 1;
- _cycled = cycled;
+ if (timedMovement) {
+ _movement->_cycled = cycled;
+ _movement->_reverse = reverse;
+ if (reverse) {
+ _movement->gotoPrevFrame(mirror);
+ setPos(_movement->_x, _movement->_y);
+ }
+ }
_messageQueueId = messageQueueId;
_movement->_curPhase->_countdown = _movement->_curPhase->_delay;
_movement->_counter = 0;
_counter = _initialCounter;
- _targetFrame = dynPhaseIdx;
+ _targetFrame = reverse ? -1 : dynPhaseIdx;
+
+ if (timedMovement && startFrame != -1) {
+ // CAniObject::SetCurFrame
+ _movement->setCurFrame(startFrame);
+ setPos(_movement->_x, _movement->_y);
+ }
_stepArray.clear();
+ debugC(1, kDebugAnimation, "movement start: ani %d copy %d movement %d pos %d,%d topleft %d,%d flags %x mirror %d frame %d", _id, _copyId, movementId, _x, _y,
+ getPosition().x, getPosition().y, _flags, mirror, _movement->_curFrame);
+
Command *newex = new Command(_id, kCmdMessage, kMsgAniMovementStarted, 0, 0, movementId, 1, 0, 0, 0);
newex->_param = _copyId;
@@ -2305,6 +2365,32 @@ bool Movement::gotoPrevFrame(bool mirror) {
return true;
}
+void Movement::setFrame(int frame, bool mirror) {
+ const int oldX = _x;
+ Common::Point point = getCurrDynamicPhaseXY();
+ _x -= point.x;
+ _y -= point.y;
+
+ if (_curFrame >= frame) {
+ if (_curFrame >= 0 && (uint)_curFrame < _framePosOffsets.size()) {
+ _x -= _framePosOffsets[_curFrame].x;
+ _y -= _framePosOffsets[_curFrame].y;
+ }
+ } else if ((uint)frame < _framePosOffsets.size()) {
+ _x += _framePosOffsets[frame].x;
+ _y += _framePosOffsets[frame].y;
+ }
+ _curFrame = frame;
+
+ updateCurrDynamicPhase();
+ point = getCurrDynamicPhaseXY();
+ _x += point.x;
+ _y += point.y;
+
+ if (mirror)
+ _x = oldX - (_x - oldX);
+}
+
void Movement::gotoFirstFrame() {
while (_curFrame)
gotoPrevFrame();
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index 1d79a6550e1..7d0436b0547 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -122,6 +122,9 @@ class Movement : public GameObject {
Statics *_nextStatic;
bool _mirrorPrev = false;
bool _mirrorNext = false;
+ /** CMovement +60, +61: starts again when over, plays backwards */
+ bool _cycled = false;
+ bool _reverse = false;
int _prevStepX;
int _prevStepY;
int _nextStepX;
@@ -173,6 +176,8 @@ class Movement : public GameObject {
void removeFirstPhase();
bool setNext(void (*_callback1)(int, Common::Point *point, int, int), void (*callback2)(int *), bool mirror = false);
bool gotoPrevFrame(bool mirror = false);
+ /** CMovement::SetFrame (EF8B8) */
+ void setFrame(int frame, bool mirror);
void gotoFirstFrame();
void setLast();
@@ -191,7 +196,6 @@ class AniObject : public GameObject {
int16 _field_32;
int _field_34;
int _initialCounter;
- bool _cycled = false;
void (*_callback1)(int, Common::Point *point, int, int);
void (*_callback2)(int *);
/** list items are owned */
@@ -248,8 +252,8 @@ public:
void stopCutMovement(const Common::Point &pending);
void stopMovementToPrev(bool keepSounds);
- /** cycled: Android CAniObject::StartMovement a3, the movement starts again when it is over (START_MOVEMENT "cycled") */
- bool startMovement(int movementId, int messageQueueId, int dynPhaseIdx, bool mirror = false, bool cycled = false);
+ /** CAniObject::StartMovement (F0D46); cycled, reverse, startFrame are START_MOVEMENT attributes */
+ bool startMovement(int movementId, int messageQueueId, int dynPhaseIdx, bool mirror = false, bool cycled = false, bool reverse = false, int startFrame = -1);
bool startAnimEx(int movid, int parId, int flag1, int flag2);
void startSliding(int movementId, int messageQueueId, int x, int y, const PointList &points, int someDynamicPhaseIndex, bool mirror);
Commit: 6ca53bcab6d87e1d3c443435e1144634728ce12f
https://github.com/scummvm/scummvm/commit/6ca53bcab6d87e1d3c443435e1144634728ce12f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: CRegion
Changed paths:
A engines/ngi/region.cpp
A engines/ngi/region.h
A engines/ngi/vector2.h
engines/ngi/module.mk
engines/ngi/physics.h
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 70b65d1d265..a2d28209b54 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -21,6 +21,7 @@ MODULE_OBJS = \
ngi.o \
ngiarchive.o \
physics.o \
+ region.o \
scene.o \
scenecontroller.o \
sceneobjects.o \
diff --git a/engines/ngi/physics.h b/engines/ngi/physics.h
index cf910e9c6fd..8e4381e16db 100644
--- a/engines/ngi/physics.h
+++ b/engines/ngi/physics.h
@@ -25,6 +25,7 @@
#include "ngi/box2d/Box2D.h"
#include "ngi/objects.h"
#include "ngi/gfx.h"
+#include "ngi/vector2.h"
namespace NGI {
@@ -43,11 +44,6 @@ struct PhysObjParams {
int _unused = 0;
};
-struct Vector2 {
- float x;
- float y;
-};
-
class PhysListener;
class PhysicalObject;
class PhysGround;
diff --git a/engines/ngi/region.cpp b/engines/ngi/region.cpp
new file mode 100644
index 00000000000..fe4fb8af25c
--- /dev/null
+++ b/engines/ngi/region.cpp
@@ -0,0 +1,152 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/debug.h"
+
+#include "ngi/ngi.h"
+#include "ngi/region.h"
+
+namespace NGI {
+
+Region::Region() {
+}
+
+// CRegion::RecalcBox: the bounding box of the points
+void Region::recalcBox() {
+ _left = 10000;
+ _top = 10000;
+ _right = -10000;
+ _bottom = -10000;
+ for (uint i = 0; i < _points.size(); i++) {
+ const Vector2 &point = _points[i];
+ if (_left > point.x)
+ _left = point.x;
+ if (_right < point.x)
+ _right = point.x;
+ if (_top > point.y)
+ _top = point.y;
+ if (_bottom < point.y)
+ _bottom = point.y;
+ }
+}
+
+// CRegion::TestPoint: even-odd crossing test
+bool Region::testPoint(float x, float y) const {
+ const uint count = _points.size();
+ if (count == 0)
+ return false;
+ if (count == 1)
+ return x == _points[0].x && y == _points[0].y;
+
+ uint previous = count - 1;
+ bool previousBelow = _points[previous].y < y;
+ int crossings = 0;
+ for (uint i = 0; i < count; i++) {
+ const bool below = _points[i].y < y;
+ const float cross = (_points[previous].x - x) * ((_points[i].y - y) - (_points[previous].y - y)) -
+ (_points[previous].y - y) * ((_points[i].x - x) - (_points[previous].x - x));
+ if (below) {
+ if (!previousBelow && cross > 0.0f)
+ crossings++;
+ } else {
+ if (previousBelow && cross < 0.0f)
+ crossings++;
+ }
+ previous = i;
+ previousBelow = below;
+ }
+ return (crossings & 1) != 0;
+}
+
+// CRegion::PtInRegion
+bool Region::ptInRegion(float x, float y) const {
+ if (x < _left || x > _right || y < _top || y > _bottom)
+ return false;
+ return testPoint(x, y);
+}
+
+// CRegion::MoveRegionTo
+void Region::moveRegionTo(float x, float y) {
+ const float dx = x - (_left + _right) * 0.5f;
+ const float dy = y - (_top + _bottom) * 0.5f;
+ for (uint i = 0; i < _points.size(); i++) {
+ _points[i].x += dx;
+ _points[i].y += dy;
+ }
+ recalcBox();
+}
+
+// CRegion::OnRender: the debug drawing needs CRender::DrawLine, which is not ported
+void Region::onRender(float scrollX, float scrollY) const {
+ warning("STUB/untested: CRegion::OnRender: CRender::DrawLine is not ported");
+}
+
+// CRegion::AddPoint
+void Region::addPoint(float x, float y) {
+ Vector2 point;
+ point.x = x;
+ point.y = y;
+ _points.push_back(point);
+ recalcBox();
+}
+
+// CRegion::CreateEllipticRgn
+void Region::createEllipticRgn(float left, float top, float right, float bottom) {
+ const float radiusX = (right - left) * 0.5f;
+ const float centerX = left + radiusX;
+ const float centerY = top + (bottom - top) * 0.5f;
+ const float radiusY = (bottom - top) / (right - left) * radiusX;
+ for (int angle = 0; angle != 380; angle += 20) {
+ const double radians = (double)angle * 3.14159265358979 / 180.0;
+ Vector2 point;
+ point.x = radiusX * cosf(radians) + centerX;
+ point.y = radiusY * sinf(radians) + centerY;
+ _points.push_back(point);
+ }
+ recalcBox();
+}
+
+// CRegion::CreateRectRgn
+void Region::createRectRgn(float left, float top, float right, float bottom) {
+ Vector2 point;
+ point.x = left;
+ point.y = top;
+ _points.push_back(point);
+ point.x = right;
+ point.y = top;
+ _points.push_back(point);
+ point.x = right;
+ point.y = bottom;
+ _points.push_back(point);
+ point.x = left;
+ point.y = bottom;
+ _points.push_back(point);
+ recalcBox();
+}
+
+// CRegion::CreatePolygonRgn
+void Region::createPolygonRgn(const Vector2 *points, int count) {
+ for (int i = 0; i < count; i++)
+ _points.push_back(points[i]);
+ recalcBox();
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/region.h b/engines/ngi/region.h
new file mode 100644
index 00000000000..cdc7c86f55b
--- /dev/null
+++ b/engines/ngi/region.h
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_REGION_H
+#define NGI_REGION_H
+
+#include "common/array.h"
+
+#include "ngi/vector2.h"
+
+namespace NGI {
+
+/** Android: CRegion (28 bytes), a polygon with its bounding box */
+class Region {
+public:
+ Region(); // 161ED8
+
+ /** CRegion::RecalcBox (161F0C) */
+ void recalcBox();
+ /** CRegion::TestPoint (161F88): the even-odd test of the polygon */
+ bool testPoint(float x, float y) const;
+ /** CRegion::PtInRegion (16209C): the box first, then the polygon */
+ bool ptInRegion(float x, float y) const;
+ /** CRegion::MoveRegionTo (1620E4): the center of the box goes to (x, y) */
+ void moveRegionTo(float x, float y);
+ /** CRegion::OnRender (162160): the outline (white lines) minus the scroll */
+ void onRender(float scrollX, float scrollY) const;
+ /** CRegion::AddPoint (162274) */
+ void addPoint(float x, float y);
+ /** CRegion::CreateEllipticRgn (162290): 19 points, every 20 degrees up to 360 */
+ void createEllipticRgn(float left, float top, float right, float bottom);
+ /** CRegion::CreateRectRgn (162360) */
+ void createRectRgn(float left, float top, float right, float bottom);
+ /** CRegion::CreatePolygonRgn (1623AE) */
+ void createPolygonRgn(const Vector2 *points, int count);
+
+ Common::Array<Vector2> _points; // +0
+ float _left = 10000; // +12
+ float _top = 10000; // +16
+ float _right = -10000; // +20
+ float _bottom = -10000; // +24
+};
+
+} // End of namespace NGI
+
+#endif // NGI_REGION_H
diff --git a/engines/ngi/vector2.h b/engines/ngi/vector2.h
new file mode 100644
index 00000000000..09ca867a3d0
--- /dev/null
+++ b/engines/ngi/vector2.h
@@ -0,0 +1,35 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_VECTOR2_H
+#define NGI_VECTOR2_H
+
+namespace NGI {
+
+/** Android: vector2, two floats (the points of a CRegion, the fly points) */
+struct Vector2 {
+ float x;
+ float y;
+};
+
+} // End of namespace NGI
+
+#endif // NGI_VECTOR2_H
Commit: f27764fbf2f960a2b39bebe59a5fe8a1235502ed
https://github.com/scummvm/scummvm/commit/f27764fbf2f960a2b39bebe59a5fe8a1235502ed
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Scene::runQueue with the interrupt state, MessageQueue::canInterrupt, Command::getParamFloat, BehaviorMove::setEnabled
Changed paths:
engines/ngi/behavior.h
engines/ngi/messages.cpp
engines/ngi/messages.h
engines/ngi/scene.cpp
engines/ngi/scene.h
diff --git a/engines/ngi/behavior.h b/engines/ngi/behavior.h
index 36b1536846c..46222c61f98 100644
--- a/engines/ngi/behavior.h
+++ b/engines/ngi/behavior.h
@@ -41,6 +41,9 @@ struct BehaviorMove {
bool _mirror = false;
bool canStart(uint32 elapsed, uint32 randomMax) const;
+ /** +24 of CBehaviorQueue (EnableMove): bit 1 of _flags, set when the queue is disabled */
+ bool isEnabled() const { return !(_flags & 1); }
+ void setEnabled(bool enabled) { if (enabled) _flags &= ~1; else _flags |= 1; }
BehaviorMove() = default;
BehaviorMove(GameVar *subvar, Scene *sc, int *delay);
};
diff --git a/engines/ngi/messages.cpp b/engines/ngi/messages.cpp
index df56ce6b171..844d3ecfdef 100644
--- a/engines/ngi/messages.cpp
+++ b/engines/ngi/messages.cpp
@@ -146,6 +146,12 @@ bool Command::load(MfcArchive &file) {
return true;
}
+float Command::getParamFloat(const char *name, float defaultValue) const {
+ if (!_args.contains(name))
+ return defaultValue;
+ return (float)atof(_args.getVal(name).c_str());
+}
+
bool Command::handleMessage() {
int cnt = 0;
for (MessageHandler *m = g_ngi->_messageHandlers; m; m = m->nextItem)
@@ -409,6 +415,14 @@ bool MessageQueue::load(MfcArchive &file) {
return true;
}
+bool MessageQueue::canInterrupt() {
+ if (_interruptState == 0)
+ return true;
+ if (_interruptState == 1)
+ return getCommandNumByType(kCmdStartMovement) == -1;
+ return false;
+}
+
bool MessageQueue::run(AniObject *ani) {
if (checkGlobalExCommandList1() && checkGlobalExCommandList2()) {
if (!(getFlags() & kInGlobalQueue)) {
diff --git a/engines/ngi/messages.h b/engines/ngi/messages.h
index 225b496d137..baaebfbcd39 100644
--- a/engines/ngi/messages.h
+++ b/engines/ngi/messages.h
@@ -152,6 +152,9 @@ class Command : public Message {
virtual Command *createClone();
+ /** CCommand::GetParamFloat: the attribute of the XML command, the default when it has none */
+ float getParamFloat(const char *name, float defaultValue) const;
+
bool handleMessage();
void sendMessage();
void postMessage();
@@ -251,6 +254,8 @@ class MessageQueue : public CObject {
int calcDuration(AniObject *obj);
/** CMessageQueue::GetCommandNumByType: the index of the first command of this kind, -1 when there is none */
int getCommandNumByType(int kind);
+ /** CMessageQueue::CanInterrupt (10C7A0): state 0 allows it, 1 while no START_MOVEMENT is left */
+ bool canInterrupt();
void setObjectCopyForId(int objId, int oldCopyId, int newCopyId);
int activateExCommandsByKind(int kind);
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 17c6ae28286..f6b50309183 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -626,6 +626,27 @@ MessageQueue *Scene::findMessageQueue(int messageId) {
return _commonQueueScene ? _commonQueueScene->findMessageQueue(messageId) : nullptr;
}
+// CScene::RunQueue (1225A4)
+bool Scene::runQueue(int queueId, int interruptState) {
+ return runQueueWithAni(queueId, nullptr, interruptState);
+}
+
+// CScene::RunQueueByIdWithAni (12263E) / RunQueueWithAni (1228AE): Run(interruptState) unless 4
+bool Scene::runQueueWithAni(int queueId, AniObject *ani, int interruptState) {
+ MessageQueue *queue = findMessageQueue(queueId);
+ if (!queue)
+ return false;
+ MessageQueue *copy = new MessageQueue(queue, 0, 0);
+ copy->_scene = this;
+ if (interruptState != 4)
+ copy->_interruptState = interruptState;
+ if (!copy->run(ani)) {
+ g_ngi->_globalMessageQueueList->deleteQueueById(copy->_id);
+ return false;
+ }
+ return true;
+}
+
MessageQueue *Scene::getMessageQueueByName(const Common::String &name) {
for (uint i = 0; i < _messageQueues.size(); i++)
if (_messageQueues[i]->_title == name)
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 6b8888e6589..92aeef67891 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -136,6 +136,13 @@ class Scene : public Background {
AniObject *findAniObjectById(int obj, int a3);
AniObject *getStaticANIObject1ByName(const Common::String &name, int a3);
MessageQueue *findMessageQueue(int messageId);
+ /**
+ * CScene::RunQueue (1225A4) without the object that gets the queue (a4): the queue of the scene runs (a copy of the template here, in the scene), false when there
+ * is none or it does not start. interruptState is the argument of CMessageQueue::Run (InteruptState): 4 keeps the one of the queue.
+ */
+ bool runQueue(int queueId, int interruptState = 4);
+ /** CScene::RunQueueByIdWithAni (12263E), RunQueueWithAni (1228AE): the object gets the queue */
+ bool runQueueWithAni(int queueId, AniObject *ani, int interruptState = 4);
/** CScene::IsQueuesProcessed (11FB98): copies of the template queues run in the global list */
bool isQueuesProcessed(bool ignoreInterruptState3) const;
MessageQueue *getMessageQueueByName(const Common::String &name);
Commit: 01d74f3352c3158106d70cdb7adfd24cee78d7c2
https://github.com/scummvm/scummvm/commit/01d74f3352c3158106d70cdb7adfd24cee78d7c2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: FPController hooks for the ported controllers (controllerRunsSceneLogic, OnSceneInit, random helpers), arcade tutorial zones
Changed paths:
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/fpcontroller.h
engines/ngi/fullpipe/scenes.cpp
engines/ngi/fullpipe/tutorialcontroller.cpp
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 5c4c57e1669..e990533fc59 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -845,6 +845,26 @@ bool FPController::updateUserCmd(Command *cmd, uint32 elapsed) {
// CFPController::OnMouseLKeyUp (a tap) of every scene of an XML project: an interaction of the object under the finger, else the hero
// walks to the point. The scene 1 queue and the upper pipe of scene 1 are the only scene specific parts. ADAPTATION: the original finds
// the interaction with CInteractionController::FindInteraction and starts it with CInteract::Run (RunInteractionWithMouse).
+uint32 random31() {
+ return g_ngi->_rnd.getRandomNumber(0x7FFFFFFF);
+}
+
+int scaledRandom(int n) {
+ const int32 product = (int32)((uint32)n * random31());
+ return product / 0x7FFFFFFF;
+}
+
+// CFPController::GetCursorType (14EAC0): the object helpers (CObjHelperManager::IsHitObjHelper), the cursor of the object under the finger (map +100) and CheckBorders;
+// the cursor is chosen by the input code (D11)
+int FPController::getCursorType(float x, float y) {
+ static bool reported = false;
+ if (!reported) {
+ reported = true;
+ warning("STUB/untested: CFPController::GetCursorType (D11: the cursor of the scene is chosen by the input code)");
+ }
+ return -1;
+}
+
bool FPController::onTap(float tapX, float tapY) {
Scene &scene = *_scene;
AniObject *hero = g_ngi->_aniMan;
diff --git a/engines/ngi/fullpipe/fpcontroller.h b/engines/ngi/fullpipe/fpcontroller.h
index c29c9bad823..f599a2f22a8 100644
--- a/engines/ngi/fullpipe/fpcontroller.h
+++ b/engines/ngi/fullpipe/fpcontroller.h
@@ -68,6 +68,20 @@ public:
virtual bool isNeedReact(float x, float y);
/** CFPController::CheckTutorial (slot 70): empty here, scenes with a tutorial override it */
virtual void checkTutorial() {}
+ /** While false the ported controller methods only call the base (sceneHandlerNN runs it, D02) */
+ virtual bool controllerRunsSceneLogic() const { return false; }
+ /** CGObject::CleanXml (slot 5): resets the state; not called yet, CGame::CleanXml is not ported */
+ virtual void cleanXml() {}
+ /** CFPController::GetCursorType (14EAC0): the cursor of the scene; not ported (D11), the cursor is chosen by the input code */
+ int getCursorType(float x, float y) override;
+ /** CScene init: OnSceneInit once before the first OnShow */
+ void initScene() {
+ if (!_sceneInitDone) {
+ _sceneInitDone = true;
+ onSceneInit();
+ }
+ }
+ bool _sceneInitDone = false;
/** +208: ANI_REACT of SC_COMMON (CFPController::OnSceneInit puts it into the scene) */
AniObject *_react = nullptr;
virtual void updateScroll();
@@ -156,10 +170,17 @@ protected:
bool _smooth = false; // +188: a SET_SCROLL command with scroll=1 is moving the camera
bool _swipeWalking = false; // +189: the hero walks to the end of the scene
int _swipeDirection = 0; // +192: -1 left, 1 right, 0 none
+ bool _arcadeRunning = false; // +148: set by the arcade scenes
+ bool _field149 = true; // +149
bool _swiped = false; // +212: a swipe was made, the tap is not handled
bool _skipArcade = false; // +213
};
+/** lrand48() of the Android code: 0 .. 0x7FFFFFFF */
+uint32 random31();
+/** `n * lrand48() / 0x7FFFFFFF` as the original: the int product wraps for n > 1, as shipped */
+int scaledRandom(int n);
+
/** CSplashScreenController::CreateControllers for one scene */
void createSceneController(int sceneId);
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index d549e84f763..3cc0a72725d 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -703,8 +703,10 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
_sceneStack.push_back(scene);
scene->_currentEntranceId = entrance._id;
FPController &controller = sceneController(*scene);
- if (scene->_sceneId != SC_INTRO1)
+ if (scene->_sceneId != SC_INTRO1) {
+ controller.initScene();
controller.onShow();
+ }
if (_aniMan && scene->_motionController) {
scene->_motionController->attachObject(_aniMan);
scene->_motionController->activate();
diff --git a/engines/ngi/fullpipe/tutorialcontroller.cpp b/engines/ngi/fullpipe/tutorialcontroller.cpp
index 1bf3aa7400f..fe6f16b54e2 100644
--- a/engines/ngi/fullpipe/tutorialcontroller.cpp
+++ b/engines/ngi/fullpipe/tutorialcontroller.cpp
@@ -321,18 +321,9 @@ void TutorialController::finish() {
}
}
-// CMessageQueue::Run of a queue of this scene: a copy of the template runs
+// CScene::RunQueue of the scene of the controller
bool TutorialController::runSceneQueue(int queueId) {
- MessageQueue *queue = _scene->findMessageQueue(queueId);
- if (!queue)
- return false;
- MessageQueue *copy = new MessageQueue(queue, 0, 0);
- copy->_scene = _scene;
- if (!copy->run(nullptr)) {
- g_ngi->_globalMessageQueueList->deleteQueueById(copy->_id);
- return false;
- }
- return true;
+ return _scene->runQueue(queueId);
}
// CTutorialController::OnShow (1A46C8)
@@ -693,7 +684,7 @@ int TutorialController::getCursorType(float x, float y) {
// CTutorialController::PassMouseActions (1A4854): whether the touch goes on to the scene below. The action is 1 for a move, 2 for the finger down and 3 for
// the finger up; every tutorial has its own zone, a touch in it can finish the tutorial. Read in the disassembly (the decompiler fails on the jump table):
// the tutorials without zone are FIRST, SEE_TASK and USE_TASK (the touch does not pass), SEE_ALL_TASKS, SEE_EGGEATER and LAST (it passes). Not ported:
-// the arcade tutorials, EXTRA_TUTORIAL_SEE_EXTRA_HELP and TUTORIAL_USE_MAP (their tutorials are not started yet), they let the touch pass.
+// EXTRA_TUTORIAL_SEE_EXTRA_HELP and TUTORIAL_USE_MAP (their tutorials are not started yet), they let the touch pass.
bool TutorialController::passMouseActions(float x, float y, int action) {
const bool pass = passMouseActionsZone(x, y, action);
debugC(2, kDebugEvents, "TutorialController::passMouseActions(%g, %g, %d) = %d", x, y, action, pass);
@@ -776,8 +767,25 @@ bool TutorialController::passMouseActionsZone(float x, float y, int action) {
finish();
return true;
}
- if (id.hasPrefix("ARCADE_TUTORIAL_") || id == "EXTRA_TUTORIAL_SEE_EXTRA_HELP" || id == "TUTORIAL_USE_MAP")
- warnOnce("CTutorialController::PassMouseActions: the zones of the arcade tutorials, SEE_EXTRA_HELP and USE_MAP are not ported");
+ // arcade tutorials: a touch on the arcade object (ladder, ball ...) finishes; returns MouseActions
+ if (id == "ARCADE_TUTORIAL_04")
+ return mouseActions(x, y, action, PIC_SC4_LADDER);
+ if (id == "ARCADE_TUTORIAL_06")
+ return mouseActions(x, y, action, ANI_NEWBALL);
+ if (id == "ARCADE_TUTORIAL_08")
+ return mouseActions(x, y, action, ANI_BATUTA);
+ if (id == "ARCADE_TUTORIAL_09")
+ return mouseActions(x, y, action, ANI_PLEVATEL);
+ if (id == "ARCADE_TUTORIAL_11")
+ return mouseActions(x, y, action, ANI_KACHELI);
+ if (id == "ARCADE_TUTORIAL_14")
+ return mouseActionsZone(x, y, action, Common::Rect(1100, 480, 1260, 580));
+ if (id == "ARCADE_TUTORIAL_27")
+ return mouseActions(x, y, action, ANI_BITA);
+ if (id == "ARCADE_TUTORIAL_29")
+ return mouseActions(x, y, action, ANI_PORTER);
+ if (id == "EXTRA_TUTORIAL_SEE_EXTRA_HELP" || id == "TUTORIAL_USE_MAP")
+ warnOnce("STUB/untested: CTutorialController::PassMouseActions: the zones of EXTRA_TUTORIAL_SEE_EXTRA_HELP and TUTORIAL_USE_MAP are not ported");
return true;
}
Commit: badbdf564ea49c7ae28a8dea5975cd654dbf48a7
https://github.com/scummvm/scummvm/commit/badbdf564ea49c7ae28a8dea5975cd654dbf48a7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Object names used by the ported controllers
Changed paths:
engines/ngi/fullpipe/constants.h
engines/ngi/fullpipe/objectnames.h
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index 0803cab9e41..ab21dd90cd2 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -1781,4 +1781,96 @@ namespace NGI {
#define SC4_DEMO_SCROLL_STATE "\xc4\xe5\xec\xee\x2d\xf1\xea\xf0\xee\xeb\xeb" // Android
#define SC4_DEMO_SCROLL_DONE "\xc1\xfb\xeb" // Android
+// Android: names of obj.h that the ported controllers use
+#define ANI_SC17_TUMBA 28060
+#define ST_SC17_TUMBA_STATE1 28061
+
+// Android: names of obj.h that the ported controllers use
+#define MV_GLV_PUTDOMINO 2158
+#define MV_MAN38_PUTDOMIN 2187
+#define ANI_MUG38 2191
+
+// Android: names of obj.h that the ported controllers use
+#define MV_GLV_LOOKHMR 2168
+
+// Android: names of obj.h that the ported controllers use
+#define MV_GMA_JUMPBK 1231
+#define ST_MAN14_KICK 1238
+#define ST_BAL14_MAIN 1248
+#define ANI_GRIT_14 2724
+#define MV_GRT14_FALL 2725
+#define ST_BAL14_TOGMA 3199
+#define MV_GMA_TOTRUBA_EMPTY 23511
+
+// Android: names of obj.h that the ported controllers use
+#define QU_MID_SWITCH 2042
+#define PIC_SC27_LTRUBA 1914
+#define PIC_POWER_ARROW 23406
+
+// Android: names of obj.h that the ported controllers use
+#define SND_MUS_19 63296
+
+// Android: names of obj.h that the ported controllers use
+#define ST_CLK8_NORM 2991
+#define ANI_GRIT2 3189
+#define MV_GRIT2_FALL 3190
+#define SC_UPSELL 23478
+#define ANI_SC8_BOX 28003
+
+// Android: names of obj.h that the ported controllers use
+#define ST_VSN_RIGHT 956
+#define MV_GLT_EAT 930
+#define ST_BALL9_NORM 2973
+#define MV_GRT9_FALL 2720
+#define ST_MAN9_SHOOT 23466
+#define MV_MAN9_STARTSHOOT 23467
+#define MV_MAN9_CYCLESHOOT 23468
+#define MV_MAN9_ENDSHOOT 23469
+#define PIC_SC9_URTRUBA 2984
+#define ANI_SC9_BOOT 28029
+
+// Android: names of obj.h that the ported controllers use
+#define PIC_INV_BOOT 863
+#define PIC_SC11_LTRUBA 1119
+#define ST_MAN11_SWING_0 1109
+#define ST_MAN11_SWING_1 1111
+#define ST_MAN11_SWING_2 1112
+#define ST_MAN11_STARTJUMP 1130
+#define SND_MUS_7 63284
+#define SND_MUS_11 63288
+
+// Android: names of obj.h that the ported controllers use
+#define ST_SHG_NORM 2118
+#define ST_SHR_NORM 2132
+
+// Android: names of obj.h that the ported controllers use
+#define MV_KZW_TOPLANK 497
+#define PIC_SC4_LTRUBA 506
+#define PIC_SC4_MONETOPR 689
+#define ANI_SC4_LAMPS 23146
+#define MV_SC4_LAMPS_TORED 23149
+#define QU_SC4_GOLAMPS 23151
+#define SND_MUS_SC04_START 63310
+#define SND_MUS_SC04_LOOP 63311
+#define SND_MUS_SC04_STOP1 63312
+#define SND_MUS_SC04_STOP2 63313
+
+// Android: names of obj.h that the ported controllers use
+#define PIC_SC6_LIQUID 23152
+#define ANI_SC6_ARROW 23489
+#define ANI_GRIT_6 677
+#define ANI_GRIT1 2961
+#define MV_GRT6_BREAK 678
+#define MV_GRIT1_FALL 2962
+#define MV_NBL_OUT 1077
+#define ST_BDP_NORM 2687
+#define ST_BTN6_ON 2994
+#define QU_SC6_DROPS2 2905
+#define QU_MOM_LOOKEMPTY 2948
+#define QU_MOM_OPENEYE 2949
+#define ST_SC6_ARROW_1 23490
+#define ST_SC6_ARROW_2 23491
+#define ST_SC6_ARROW_3 23492
+#define ST_SC6_ARROW_4 23493
+
#endif /* NGI_CONSTANTS_H */
diff --git a/engines/ngi/fullpipe/objectnames.h b/engines/ngi/fullpipe/objectnames.h
index 81b916cb29b..98948532e0b 100644
--- a/engines/ngi/fullpipe/objectnames.h
+++ b/engines/ngi/fullpipe/objectnames.h
@@ -45,6 +45,7 @@ namespace NGI {
#define sO_Awaken "\xc1\xee\xe4\xf0\xf1\xf2\xe2\xf3\xe5\xf2" // "ÐодÑÑÑвÑеÑ"
#define sO_Boot_15 "\xc1\xee\xf2\xe8\xed\xee\xea_15" // "ÐоÑинок_15"
#define sO_Bottle_38 "\xc1\xf3\xf2\xfb\xeb\xea\xe0_38" // "ÐÑÑÑлка_38"
+#define sO_Fast "\xc1\xfb\xf1\xf2\xf0\xfb\xe9" // "ÐÑÑÑÑÑй"
#define sO_InSmokeRoom "\xc2 \xea\xf3\xf0\xe8\xeb\xea\xe5" // "РкÑÑилке"
#define sO_InSock "\xc2 \xed\xee\xf1\xea\xe5" // "РноÑке"
#define sO_InGlasses "\xc2 \xee\xf7\xea\xe0\xf5" // "РоÑкаÑ
"
@@ -180,6 +181,7 @@ namespace NGI {
#define sO_Broken "\xd0\xe0\xe7\xe1\xe8\xf2\xe0" // "РазбиÑа"
#define sO_Unblocked "\xd0\xe0\xe7\xe1\xeb\xee\xea\xe8\xf0\xee\xe2\xe0\xed" // "РазблокиÑован"
#define sO_Unconvoluted "\xd0\xe0\xe7\xe2\xe5\xf0\xed\xf3\xf2" // "РазвеÑнÑÑ"
+#define sO_WarmUp "\xd0\xe0\xf1\xef\xf0\xfb\xe3" // "РаÑпÑÑг"
#define sO_Jawcrucnher "\xd0\xee\xf2\xee\xf5\xf0\xf3\xf1" // "РоÑоÑ
ÑÑÑ"
#define sO_UsherHand "\xd0\xf3\xea\xe0 \xc1\xe8\xeb\xe5\xf2\xe5\xf0\xf8\xe8" // "Ð Ñка ÐилеÑеÑÑи"
#define sO_LeverHandle_23 "\xd0\xf3\xea\xee\xff\xf2\xea\xe0 \xf0\xfb\xf7\xe0\xe3\xe0_23" // "Ð ÑкоÑÑка ÑÑÑага_23"
@@ -194,6 +196,7 @@ namespace NGI {
#define sO_WithGum "\xd1 \xe6\xe2\xe0\xf7\xea\xee\xe9" // "С жваÑкой"
#define sO_WithSpade "\xd1 \xeb\xee\xef\xe0\xf2\xee\xe9" // "С лопаÑой"
#define sO_WithSmall "\xd1 \xec\xe0\xeb\xfb\xec" // "С малÑм"
+#define sO_WithoutHammer "\xc1\xe5\xe7 \xec\xee\xeb\xee\xf2\xea\xe0" // "Ðез молоÑка"
#define sO_WithHammer "\xd1 \xec\xee\xeb\xee\xf2\xea\xee\xec" // "С молоÑком"
#define sO_WithCoin "\xd1 \xec\xee\xed\xe5\xf2\xee\xe9" // "С монеÑой"
#define sO_WithSock "\xd1 \xed\xee\xf1\xea\xee\xec" // "С ноÑком"
@@ -253,6 +256,14 @@ namespace NGI {
#define sO_Egg1 "\xdf\xe9\xf6\xee\x31" // "ЯйÑо1"
#define sO_Egg2 "\xdf\xe9\xf6\xee\x32" // "ЯйÑо2"
#define sO_Egg3 "\xdf\xe9\xf6\xee\x33" // "ЯйÑо3"
+#define sO_Hint_1_05 "\xcf\xee\xe4\xf1\xea\xe0\xe7\xea\xe0_1_05" // "ÐодÑказка_1_05"
+#define sO_IsTurnedOn "\xc2\xea\xeb\xfe\xf7\xe5\xed\xe0" // "ÐклÑÑена"
+#define sO_IsRaised "\xcf\xee\xe4\xed\xff\xf2\xe0" // "ÐоднÑÑа"
+#define sO_DemoScroll "\xc4\xe5\xec\xee-\xf1\xea\xf0\xee\xeb\xeb" // "Ðемо-ÑкÑолл"
+#define sO_WasHere "\xc1\xfb\xeb" // "ÐÑл"
+#define sO_Hint_2_02 "\xcf\xee\xe4\xf1\xea\xe0\xe7\xea\xe0_2_02" // "ÐодÑказка_2_02"
+#define sO_Hint_2_03 "\xcf\xee\xe4\xf1\xea\xe0\xe7\xea\xe0_2_03" // "ÐодÑказка_2_03"
+#define sO_Enabled "\xc2\xea\xeb\xfe\xf7\xe5\xed\xe0" // "ÐклÑÑена"
} // End of namespace NGI
Commit: a29b13254bac6fffb11fbb18b042d3dc3b5dd08f
https://github.com/scummvm/scummvm/commit/a29b13254bac6fffb11fbb18b042d3dc3b5dd08f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Scene 4 controller ported
Changed paths:
A engines/ngi/fullpipe/sc04controller.cpp
engines/ngi/fullpipe/sc04controller.h
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/sc04controller.cpp b/engines/ngi/fullpipe/sc04controller.cpp
new file mode 100644
index 00000000000..bed3383d386
--- /dev/null
+++ b/engines/ngi/fullpipe/sc04controller.cpp
@@ -0,0 +1,1884 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/formats/xmlparser.h"
+#include "common/hashmap.h"
+
+#include "ngi/ngi.h"
+#include "ngi/behavior.h"
+#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/input.h"
+#include "ngi/interaction.h"
+#include "ngi/inventory.h"
+#include "ngi/messages.h"
+#include "ngi/motion.h"
+#include "ngi/scene.h"
+#include "ngi/sound.h"
+#include "ngi/statics.h"
+#include "ngi/anihandler.h"
+#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/sc04controller.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+namespace {
+
+// the table of the phases of the speaker (dword_2D5118): six phases per row, -1 ends a row
+const int kSpeakerPhases[] = {
+ 0, 1, 2, 3, -1, -1,
+ 0, 2, 3, -1, -1, -1,
+ 0, 2, -1, -1, -1, -1
+};
+
+void warnOnce(const char *what) {
+ static Common::HashMap<Common::String, bool> reported;
+ if (!reported.contains(what)) {
+ reported[what] = true;
+ warning("STUB/untested: %s", what);
+ }
+}
+
+// CBaseSettings::SetSaving (sub_164860 gets the settings of CGame): not ported
+void setSaving(bool allowed) {
+ warnOnce(allowed ? "CBaseSettings::SetSaving(true)" : "CBaseSettings::SetSaving(false)");
+}
+
+bool isState(const char *object, const char *state) {
+ return g_ngi->getStateId(object) == g_ngi->getStateValue(object, state);
+}
+
+// CSoundManager::IsPlayed
+bool isSoundPlayed(int soundId) {
+ const Sound *sound = g_ngi->findSound(soundId);
+ return sound && sound->isPlaying();
+}
+
+// CScene::RunQueueWithAni (1228AE) with a queue that was made here: CVisibleObject::SetQueue, then CScene::RunQueue(queue, state)
+void runQueueWithAni(Scene *scene, MessageQueue *queue, AniObject *ani, int state) {
+ queue->_scene = scene;
+ if (state != 4)
+ queue->_interruptState = state;
+ if (!queue->run(ani)) {
+ if (queue->getFlags() & kInGlobalQueue)
+ g_ngi->_globalMessageQueueList->deleteQueueById(queue->_id);
+ else
+ delete queue;
+ }
+}
+
+// FindQueue + CMessageQueue::CMessageQueue(CMessageQueue *): the copy of the queue of the scene
+MessageQueue *copyQueue(Scene *scene, int queueId) {
+ MessageQueue *queue = scene->findMessageQueue(queueId);
+ if (!queue)
+ return nullptr;
+ MessageQueue *copy = new MessageQueue(queue, 0, 0);
+ copy->_scene = scene;
+ return copy;
+}
+
+// CMessageQueue::SetObjectCopy: CCommand::SetObjectCopy (SetParamInt "copy") for every command of the queue
+void setObjectCopy(MessageQueue *queue, int copyId) {
+ for (uint i = 0; i < queue->getCount(); i++) {
+ Command *command = queue->getCommandByIndex(i);
+ command->_param = copyId;
+ command->_args["copy"] = Common::String::format("%d", copyId);
+ }
+}
+
+// CCommand(START_MOVEMENT, wait) with the parameters aniId, moveId, copy (and mirror)
+Command *movementCommand(int aniId, int movementId, int copyId, bool mirror = false) {
+ Command *command = new Command(aniId, kCmdStartMovement, movementId, 0, 0, 0, 1, 0, 0, 0);
+ command->_param = copyId;
+ command->_mirror = mirror;
+ command->_excFlags |= 2;
+ return command;
+}
+
+// CCommand(MESSAGE, wait): the name goes to the controllers (CScene::Message), its id to the scene handlers
+Command *messageCommand(const char *name, int wait = 0) {
+ uint32 id = 0;
+ g_ngi->_gameProject->_objectIds.findId(name, id);
+ Command *command = new Command(0, kCmdMessage, id, 0, 0, 0, wait, 0, 0, 0);
+ command->_messageName = name;
+ command->_args["msg"] = name;
+ command->_excFlags |= 2;
+ return command;
+}
+
+// CCommand(HIDE) with the parameters objId, copy
+Command *hideCommand(int objectId, int copyId) {
+ Command *command = new Command(objectId, kCmdHide, 0, 0, 0, 0, 0, 0, 0, 0);
+ command->_param = copyId;
+ command->_excFlags |= 2;
+ return command;
+}
+
+// CCommand(USER) type EXIT_ROTATE with the parameters picId and where
+Command *exitRotateCommand(const char *where) {
+ Command *command = new Command(0, kCmdUser, 0, 0, 0, 0, 0, 0, 0, 0);
+ command->_messageName = "EXIT_ROTATE";
+ command->_args["type"] = "EXIT_ROTATE";
+ command->_args["picId"] = "GD_SC4_LADDER";
+ command->_args["where"] = where;
+ command->_excFlags |= 2;
+ return command;
+}
+
+// CFPController::CreateMouseCommand (148FB4): the user command MOUSE (CFPController::ExecuteUserCmd does not handle it yet, see executeUserCmd)
+Command *createMouseCommand(Scene *scene, float x, float y, int objectId) {
+ Command *command = new Command(0, kCmdUser, 0, 0, 0, 0, 0, 0, 0, 0);
+ command->_messageName = "MOUSE";
+ command->_args["type"] = "MOUSE";
+ command->_args["key"] = "100";
+ command->_args["obj"] = Common::String::format("%d", objectId);
+ command->_args["x"] = Common::String::format("%f", x - scene->_x);
+ command->_args["y"] = Common::String::format("%f", y - scene->_y);
+ command->_args["scroll_x"] = Common::String::format("%f", (float)scene->_x);
+ command->_args["scroll_y"] = Common::String::format("%f", (float)scene->_y);
+ command->_excFlags |= 2;
+ return command;
+}
+
+// CFPController::HideAction (1490B0): the copies of the object from the given one on stop and hide
+void hideAction(Scene *scene, int objectId, int copyId) {
+ AniObject *ani;
+ do {
+ ani = scene->findAniObjectById(objectId, copyId);
+ if (ani) {
+ ani->stopMovement();
+ ani->_flags &= ~4;
+ }
+ copyId++;
+ } while (ani);
+}
+
+// CScene::GetObjectsAmount (1224D8)
+int objectsAmount(Scene *scene, int objectId) {
+ int amount = -1;
+ do {
+ amount++;
+ } while (scene->findVisibleObject(objectId, amount));
+ return amount;
+}
+
+// CVisibleObject::IsOnScreenEntirely (127682): every corner of the rect of the object is inside the visible part of the scene (the widescreen margin
+// is on both sides; CRender +8 and the vertical margins +12, +28 are taken as 0)
+bool isOnScreenEntirely(const Scene *scene, const GameObject *object) {
+ const float margin = g_ngi->_wideOfs;
+ const float left = scene->_x - margin;
+ const float right = scene->_x + margin + g_ngi->gameWidth();
+ const float top = scene->_y;
+ const float bottom = scene->_y + g_ngi->_backgroundSurface.h;
+ const Common::Rect rect = object->getBounds();
+ return rect.left > left && rect.left < right && rect.top > top && rect.top < bottom &&
+ rect.right > left && rect.right < right && rect.bottom > top && rect.bottom < bottom;
+}
+
+// CMessageQueue::Stop of the running copies of a queue of the scene (the queues of the scene are templates here)
+void stopQueueCopies(int queueId) {
+ GlobalMessageQueueList &queues = *g_ngi->_globalMessageQueueList;
+ for (uint i = 0; i < queues.size(); i++) {
+ if (queues[i]->_queueId == queueId)
+ queues.disableQueueById(queues[i]->_id);
+ }
+}
+
+// the queue of the scene has been started (CMessageQueue +56, the number of the current command, is not -1 any more)
+bool isQueueStarted(int queueId) {
+ const GlobalMessageQueueList &queues = *g_ngi->_globalMessageQueueList;
+ for (uint i = 0; i < queues.size(); i++) {
+ if (queues[i]->_queueId == queueId)
+ return true;
+ }
+ return false;
+}
+
+// CAniObject::GetMovement(id)->+96 = delay: the frame delay of the movement
+void setLoopDelay(AniObject *ani, int movementId, uint32 delay) {
+ Movement *movement = ani ? ani->getMovement(movementId) : nullptr;
+ if (movement)
+ movement->_loopDelay = delay;
+}
+
+// CAniObject::RemoveThis (EEB54): CScene::RemoveAni, then the destructor
+void removeThis(Scene *scene, AniObject *ani) {
+ scene->removeAni(ani);
+ delete ani;
+}
+
+// erase: the original goes on with the next index
+template<typename T>
+void eraseAt(Common::Array<T> &array, uint index) {
+ array.remove_at(index);
+}
+
+// the values of sc_4_settings.xml (CSc04Controller::ReadSettingsXml)
+struct Settings {
+ float kozawDelayK;
+ float kozawStartDelay;
+ float clockDelayK;
+};
+
+class Sc04SettingsParser : public Common::XMLParser {
+public:
+ Settings *_settings = nullptr;
+
+private:
+ CUSTOM_XML_PARSER(Sc04SettingsParser) {
+ XML_KEY(SETTINGS)
+ XML_KEY(KOZAWKA)
+ XML_PROP(frameDelayK, false)
+ XML_PROP(startDelay, false)
+ KEY_END()
+ XML_KEY(CLOCK)
+ XML_PROP(frameDelayK, false)
+ KEY_END()
+ KEY_END()
+ } PARSER_END()
+
+ bool parserCallback_SETTINGS(ParserNode *) {
+ return true;
+ }
+
+ bool parserCallback_KOZAWKA(ParserNode *node) {
+ _settings->kozawDelayK = atof(node->values.getValOrDefault("frameDelayK", "1.0").c_str());
+ _settings->kozawStartDelay = atof(node->values.getValOrDefault("startDelay", "0.0").c_str());
+ return true;
+ }
+
+ bool parserCallback_CLOCK(ParserNode *node) {
+ _settings->clockDelayK = atof(node->values.getValOrDefault("frameDelayK", "1.0").c_str());
+ return true;
+ }
+};
+
+} // End of anonymous namespace
+
+// CSc04Controller::CSc04Controller (167828): fields not 0/null are initialized in the class
+Sc04Controller::Sc04Controller(int sceneId) : FPController(sceneId), _tutorial("PREV_EXTRA_TUTORIAL_USE_SWIPE") {
+ for (int i = 0; i < 20; i++) {
+ _jumpPath[i].x = 0;
+ _jumpPath[i].y = 0;
+ _jumpRotatePath[i].x = 0;
+ _jumpRotatePath[i].y = 0;
+ }
+}
+
+// CSc04Controller::~CSc04Controller (1677A4): the vectors go with it
+Sc04Controller::~Sc04Controller() {
+}
+
+// CSc04Controller::CleanXml (16484C)
+void Sc04Controller::cleanXml() {
+ _tutorial = "PREV_EXTRA_TUTORIAL_USE_SWIPE";
+}
+
+// CSc04Controller::CanShowHelp (164840): not while the arcade runs
+bool Sc04Controller::canShowHelp() {
+ return !_arcade;
+}
+
+// CSc04Controller::CheckTutorial (1652F0): coin tutorial first, then the arcade one
+void Sc04Controller::checkTutorial() {
+ if (_tutorial == "UNDEF")
+ return;
+ // +150 of CFPController: the button is down
+ if (g_ngi->_sceneStack.size() != 1 || isTouching())
+ return;
+ if (g_ngi->_tutorialManager->activateTutorial(_tutorial))
+ return;
+ const Common::String previous = _tutorial;
+ bool changed = true;
+ if (_tutorial == "PREV_EXTRA_TUTORIAL_USE_SWIPE") {
+ bool visible = false;
+ const InventoryItem *coin = g_ngi->_inventory->getItemByName("ANI_INV_COIN");
+ if (coin && coin->_counter > 0) {
+ // CVisibleObject::IsOnScreenEntirely (vtable slot 132) of the picture of the slot
+ PictureObject *slot = _scene->findPictureObjectById(PIC_SC4_MONETOPR, 0);
+ visible = slot && isOnScreenEntirely(_scene, slot);
+ }
+ if (visible)
+ _tutorial = "EXTRA_TUTORIAL_USE_DEVICES";
+ else
+ changed = false;
+ } else if (_tutorial == "EXTRA_TUTORIAL_USE_DEVICES") {
+ // CFlurryEventManager::Event("show_hint_tools_use") is the analytics of the original: not ported
+ if (_arcade)
+ _tutorial = "ARCADE_TUTORIAL_04";
+ else
+ changed = false;
+ } else {
+ _tutorial = "UNDEF";
+ }
+ if (changed && previous != _tutorial)
+ checkTutorial();
+}
+
+// CSc04Controller::ReadSettingsXml (167ECC): the frame delay factors of the kozawkas and the clock
+void Sc04Controller::readSettingsXml() {
+ Settings settings;
+ settings.kozawDelayK = _kozawDelayK;
+ settings.kozawStartDelay = _kozawStartDelay;
+ settings.clockDelayK = _clockDelayK;
+
+ Sc04SettingsParser parser;
+ parser._settings = &settings;
+ if (parser.loadFile("data/sc_4_settings.xml") && parser.parse()) {
+ _kozawDelayK = settings.kozawDelayK;
+ _kozawStartDelay = settings.kozawStartDelay;
+ _clockDelayK = settings.clockDelayK;
+ }
+}
+
+// CSc04Controller::SlowDownBall (16489C): the movements of the big ball get the frame delay 73
+void Sc04Controller::slowDownBall() {
+ AniObject *ball = _scene->findAniObjectById(ANI_BIGBALL, 0);
+ if (ball) {
+ for (uint i = 0; i < ball->_movements.size(); i++)
+ ball->_movements[i]->_loopDelay = 73;
+ }
+ _ballSlow = true;
+}
+
+// CSc04Controller::SpeedUpBall (1648E0): only a ball that is shown gets its delay back
+void Sc04Controller::speedUpBall() {
+ AniObject *ball = _scene->findAniObjectById(ANI_BIGBALL, 0);
+ if (ball && (ball->_flags & 4)) {
+ for (uint i = 0; i < ball->_movements.size(); i++)
+ ball->_movements[i]->_loopDelay = 0;
+ }
+ _ballSlow = false;
+}
+
+// CSc04Controller::StartKozawka (164928): last waiting kozawka walks to the plank,
+// every start but the first waits startDelay seconds
+void Sc04Controller::startKozawka(bool first) {
+ if (_waitingKozaws.empty())
+ return;
+
+ AniObject *kozaw = _waitingKozaws.back();
+ _waitingKozaws.pop_back();
+ _walkingKozaw = kozaw;
+
+ MessageQueue *queue = copyQueue(_scene, QU_KOZAW_WALK);
+ if (queue) {
+ setObjectCopy(queue, kozaw->_copyId);
+ if (!first) {
+ Command *pause = queue->getCommandByIndex(0);
+ pause->_messageNum = (int)(_kozawStartDelay * 1000);
+ pause->_args["delay"] = Common::String::format("%d", pause->_messageNum);
+ }
+ runQueueWithAni(_scene, queue, _walkingKozaw, 3);
+ }
+
+ const uint32 delay = (uint32)(_kozawDelayK * 83.0);
+ setLoopDelay(_walkingKozaw, MV_KZW_TOPLANK, delay);
+ setLoopDelay(_walkingKozaw, MV_KZW_WALKPLANK, delay);
+ setLoopDelay(_walkingKozaw, MV_KZW_TOHOLERV, delay);
+ setLoopDelay(_plank, MV_PNK_WEIGHTRIGHT, delay);
+}
+
+// CSc04Controller::KozawTestPlank (164A20): walks on the plank if it is down on the left,
+// else falls (fifth command of QU_KOZAW_WALK; ran commands are not in the queue here)
+void Sc04Controller::kozawTestPlank(MessageQueue *queue) {
+ if (!queue)
+ return;
+ Command *command = queue->getCommandByIndex(0);
+ if (!command)
+ return;
+ if (_plank->_movement || !_plank->_statics || _plank->_statics->_staticsId != ST_PNK_WEIGHTLEFT) {
+ command->_messageNum = MV_KZW_TOHOLERV;
+ command->_args["mov"] = "MV_KZW_TOHOLERV";
+ } else {
+ command->_messageNum = MV_KZW_WALKPLANK;
+ command->_args["mov"] = "MV_KZW_WALKPLANK";
+ }
+}
+
+// CSc04Controller::KozawLowerPlank (164A9C)
+void Sc04Controller::kozawLowerPlank() {
+ _plank->startMovement(MV_PNK_WEIGHTRIGHT, 0, -1);
+}
+
+// CSc04Controller::KozawRaisePlank (164AC0)
+void Sc04Controller::kozawRaisePlank() {
+ _plank->startMovement(MV_PNK_WEIGHTLEFT, 0, -1);
+}
+
+// CSc04Controller::ManCanJump (164AE8): hero on ladder steps 3..6, no kozawka on the plank
+bool Sc04Controller::manCanJump() {
+ if (!heroOnLadder())
+ return false;
+ if ((uint)(_ladder->getCurrentStep(hero()) - 3) > 3)
+ return false;
+ AniObject *kozaw = _walkingKozaw;
+ if (kozaw && kozaw->_movement && kozaw->_movement->_id == MV_KZW_WALKPLANK && kozaw->_movement->_curFrame > 9 && kozaw->_movement->_curFrame <= 41)
+ return false;
+ return true;
+}
+
+// CSc04Controller::SetJumm_pSteps (164B44): phase offsets from the path, x * 1.25, y * scale
+void Sc04Controller::setJumpSteps(Movement *movement, int from, int to, const Vector2 *path, double scale) {
+ for (int i = from; i <= to; i++) {
+ const float y = scale * path[i].y;
+ const float x = path[i].x * 1.25;
+ Phase *phase = movement->_phases[i];
+ phase->_x = (int)x;
+ phase->_y = (int)y;
+ }
+}
+
+// CSc04Controller::MoveSpringAttachments (164B94): the objects on the spring move by delta
+void Sc04Controller::moveSpringAttachments(int delta) {
+ for (uint i = 0; i < _bottleObjects.size(); i++) {
+ GameObject *object = _bottleObjects[i];
+ const Common::Point center = object->getCenter();
+ object->setCenter(Common::Point(center.x, (int)((float)center.y + (float)delta)));
+ }
+}
+
+// CSc04Controller::RecalcSpring (164BF0): every 83 ms, damped swing towards the weight
+void Sc04Controller::recalcSpring(uint32 elapsed) {
+ const uint32 time = elapsed + _springTimer;
+ _springTimer = time;
+ if (time <= 83)
+ return;
+ _springTimer = time - 83;
+
+ const int previous = _springPos;
+ const int next = previous + _springOffset;
+ if (next < 0) {
+ _springPos = 0;
+ _springOffset = 0;
+ } else {
+ _springPos = next;
+ }
+ if (_springPos > _springMax) {
+ _springPos = _springMax;
+ _springOffset = 0;
+ }
+
+ const int weight = _bottleWeight;
+ const int pos = _springPos;
+ if (weight > pos)
+ _springOffset++;
+ else if (weight < pos)
+ _springOffset--;
+
+ // the weight was crossed: the swing is damped
+ if ((previous > weight) != (pos > weight)) {
+ _springCounter++;
+ if (_springOffset != 0 && _springCounter > 1) {
+ const int sign = _springOffset / abs(_springOffset);
+ _springOffset = _springOffset - sign * _springStep;
+ _springCounter = 0;
+ }
+ }
+
+ const Common::Point sizeBefore = _spring->getSize();
+ if (_springPos != 0) {
+ if (!_spring->_movement)
+ _spring->startMovement(MV_SPR_LOWER, 0, -1);
+ if (previous != _springPos && _spring->_movement) {
+ // CAniObject::SetCurFrame (F0C76): CMovement::SetCurFrame of the running movement
+ _spring->_movement->setCurFrame(_springPos);
+ }
+ } else {
+ _spring->setStatic(ST_SPR_UP);
+ }
+
+ if (_springPos != previous) {
+ const Common::Point sizeAfter = _spring->getSize();
+ moveSpringAttachments(sizeBefore.y - previous - (sizeAfter.y - _springPos));
+ }
+}
+
+// CSc04Controller::OnClickBottle (164D30): a click makes the jar jump on the spring
+void Sc04Controller::onClickBottle() {
+ if (!_bottleTaken)
+ _springOffset += 5;
+}
+
+// CSc04Controller::DoUpdateBottlePosition (164D4C): spring center is 108 px under the hand frame
+void Sc04Controller::doUpdateBottlePosition() {
+ const Common::Point spring = _spring->getCenter();
+ const float springY = spring.y;
+ const Common::Point hand = _hand->getCenter();
+ const Common::Point size = _hand->getSize();
+ const float y = ((float)hand.y + (float)(size.y * 0.5)) + 108.0f;
+ moveSpringAttachments((int)(float)(y - springY));
+ _spring->setCenter(Common::Point(spring.x, (int)y));
+}
+
+// CSc04Controller::OnClickButton (164DC4): not while the arcade runs or the hand is busy
+void Sc04Controller::onClickButton() {
+ AniObject *button = _scene->findAniObjectById(ANI_BUTTON, 0);
+ if (!button)
+ return;
+ if ((!_clock->_movement || (_clock->_movement->_id == MV_CLK_GO && _clock->_movement->_curFrame > 3 && _clock->_movement->_curFrame <= 104)) &&
+ !_hand->_movement && !_bottleTaken) {
+ if (!_arcade) {
+ button->startMovement(MV_BTN_CLICK, 0, -1);
+ _hand->_flags |= 4;
+ _hand->startMovement(MV_HND_POINT, 0, -1);
+ }
+ }
+}
+
+// CSc04Controller::DoShowCoin (164E8C) for MSG_SHOWCOIN
+void Sc04Controller::doShowCoin() {
+ AniObject *coin = _scene->findAniObjectById(ANI_SC4_COIN, 0);
+ if (coin) {
+ coin->_flags |= 4;
+ coin->setPosition(Common::Point(1379, 460));
+ coin->_z = 40;
+ }
+}
+
+// CSc04Controller::GramoNextFunc (164EC8): every 83 ms next speaker phase, 3 steps pause per row
+void Sc04Controller::gramoNextFunc(uint32 elapsed) {
+ const uint32 time = elapsed + _speakerTimer;
+ _speakerTimer = time;
+ if (time <= 83)
+ return;
+ _speakerTimer = time - 83;
+
+ int frame = _speaker->_movement ? _speaker->_movement->_curFrame : -1;
+ if (_arcade) {
+ const int phase = _speakerPhase;
+ int next = phase + 1;
+ bool wrapped = false;
+ if (phase >= 0) {
+ _speakerPhase = next;
+ frame = kSpeakerPhases[6 * _speakerVariant + phase];
+ if (kSpeakerPhases[6 * _speakerVariant + next] < 0) {
+ const int variant = random31() % 3;
+ _speakerVariant = variant;
+ next = -3;
+ wrapped = true;
+ }
+ }
+ if (phase < 0 || wrapped)
+ _speakerPhase = next;
+ }
+ if (frame != -1) {
+ if (!_speaker->_movement)
+ _speaker->startMovement(MV_SPK4_PLAY, 0, -1);
+ // CAniObject::SetCurFrame (F0C76)
+ if (_speaker->_movement)
+ _speaker->_movement->setCurFrame(frame);
+ }
+}
+
+// CSc04Controller::DoUpdatePath (164F7C): closable pipe link locked while the mamasha is shown
+void Sc04Controller::doUpdatePath() {
+ MovGraphLink *link = _scene->_motionController->getGraphLink(sO_CloseThing);
+ if (link) {
+ if (_mumsy->_flags & 4)
+ link->_flags |= 0x20000000;
+ else
+ link->_flags &= 0xDFFFFFFF;
+ } else {
+ warning("DoUpdatePath: cannot find link %s", sO_CloseThing);
+ }
+}
+
+// CSc04Controller::DoManFall (16505C): hero falls into the jar (QU_SC4_MANTOBOTTLE)
+void Sc04Controller::doManFall() {
+ _follow = nullptr;
+ MessageQueue *queue = copyQueue(_scene, QU_SC4_MANTOBOTTLE);
+ if (queue) {
+ Command *show = nullptr;
+ for (uint i = 0; i < queue->getCount(); i++) {
+ Command *command = queue->getCommandByIndex(i);
+ if (command->_cmd == kCmdShow) {
+ show = command;
+ break;
+ }
+ }
+ if (show) {
+ const float y = (float)_bottle->getPosition().y - 304.0f;
+ show->_y = (int)y;
+ show->_args["y"] = Common::String::format("%f", y);
+ }
+ runQueueWithAni(_scene, queue, hero(), 4);
+ }
+ _manFalls = false;
+ heroOnLadder() = false;
+ _scene->_behaviorController->enableAllQueuesForAni(hero(), 0);
+ warnOnce("CMap::SetObjState(PIC_MAP_P03, 1) (the map of the game is not ported)");
+ setSaving(true);
+}
+
+// CSc04Controller::DoTakeBottle (16513C): hand has the jar, lower pipe opens
+void Sc04Controller::doTakeBottle() {
+ _bottleTaken = true;
+ _hand->_z = 5;
+ g_ngi->setState(sO_LowerPipe, g_ngi->getStateValue(sO_LowerPipe, sO_IsOpened));
+}
+
+// CSc04Controller::DoStopArcade (1651E0): interface scrolls out, plank kozawka stops, arcade ends
+void Sc04Controller::doStopArcade() {
+ g_ngi->arcadeInterface().scrollOut();
+
+ if (_walkingKozaw && _lastKozaw != _walkingKozaw && _walkingKozaw->getMessageQueue()) {
+ // GetCurCommandNum of the kozawka queue: stop after 2 commands, turn the movement at the 3rd,
+ // change the fall to MV_KZW_TOHOLERV at the 4th (the engine queues drop the commands that ran)
+ warnOnce("CSc04Controller::DoStopArcade: the queue of the walking kozawka is not stopped (CMessageQueue::GetCurCommandNum)");
+ }
+ _arcade = false;
+ _cameraLocked = false;
+ _musicStopped = false;
+ _hintPending = false;
+ warnOnce("CHintManager::HideHint (hint glow)");
+ g_ngi->setState(sO_Hint_1_05, 0);
+ _lamps->_flags &= ~4;
+}
+
+// CSc04Controller::SkipArcade (16550C): clock closes, music stops, hand takes the jar, arcade ends
+void Sc04Controller::skipArcadeController() {
+ g_ngi->arcadeInterface().scrollOut();
+ _clock->setStatic(ST_CLK_CLOSED);
+ stopQueueCopies(QU_SC4_GOCLOCK);
+ onMessage("MSG_STOP_MUS", "", nullptr);
+ g_ngi->_taskManager->deactivateTask("FIND_EXIT_BOTLE_SC4");
+ getGameLoaderInteractionController()->setActive("INT_019", SC_4, PIC_SC4_MASK, 0.0f, 0.0f);
+ _scene->runQueue(QU_HND_TAKEBOTTLE, 3);
+ doStopArcade();
+ // CFPController::FlurryArcadeSkip (analytics): not ported
+}
+
+// CSc04Controller::TryBall (16562C): on the ladder a big ball rolls in now and then, alternating
+void Sc04Controller::tryBall() {
+ AniObject *ball = _scene->findAniObjectById(ANI_BIGBALL, 0);
+ if (heroOnLadder() && (!ball || !(ball->_flags & 4)) && _ladder->getCurrentStep(hero()) > 3 && random31() % 50 == 0) {
+ int queueId;
+ if (_ballWalksRight)
+ queueId = QU_BALL_WALKR;
+ else
+ queueId = QU_BALL_WALKL;
+ _scene->runQueue(queueId, 3);
+ _ballWalksRight = !_ballWalksRight;
+ slowDownBall();
+ _ballTimer = 0;
+ // CCatalogManager::UnlockItem(ANI_BIGBALL): the catalog is not ported
+ }
+}
+
+// CSc04Controller::DoStartArcade (1656E0): coin in and hand up: clock, lamps and music start
+void Sc04Controller::doStartArcade() {
+ // CFPController::FlurryArcadeStart (analytics): not ported
+ startKozawka(true);
+
+ const uint32 delay = (uint32)(_clockDelayK * 83.0);
+ setLoopDelay(_clock, MV_CLK_GO, delay);
+ _scene->runQueue(QU_SC4_GOCLOCK, 4);
+ setLoopDelay(_lamps, MV_SC4_LAMPS_TORED, delay);
+ _scene->runQueue(QU_SC4_GOLAMPS, 4);
+
+ _arcade = true;
+ _coinPut = false;
+ _scene->_behaviorController->disableAllMusic();
+ g_ngi->playSound(SND_MUS_SC04_START, 0);
+ g_ngi->setState(sO_Hint_1_05, g_ngi->getStateValue(sO_Hint_1_05, sO_IsTurnedOn));
+ _ballTimer = 0;
+ _kozawInBottle = false;
+ _hintPending = true;
+ _ladderActed = false;
+ // CCatalogManager::UnlockItem(ANI_KOZAWKA): the catalog is not ported
+}
+
+// CSc04Controller::AfterLadder (165840): ladder gone, walking and clicks are back
+void Sc04Controller::afterLadder() {
+ if (_ladder)
+ _ladder->detachAllObjects();
+ g_ngi->_aniHandler->attachObject(hero()->_id);
+ delete _ladder;
+ _ladder = nullptr;
+ heroOnLadder() = false;
+ _scene->_motionController->activate();
+ getGameLoaderInteractionController()->enable();
+ if (_ballSlow)
+ speedUpBall();
+ setSaving(true);
+}
+
+// CSc04Controller::DoUpdateBottlePositionDown (1658A8): jar falls (speed +5 per step)
+void Sc04Controller::doUpdateBottlePositionDown() {
+ const Common::Point spring = _spring->getCenter();
+ const float springY = spring.y;
+ const int speed = _bottleFallSpeed;
+ const float newY = springY + (float)speed;
+ _bottleFallSpeed = speed + 5;
+ moveSpringAttachments((int)(float)(newY - springY));
+ _spring->setCenter(Common::Point(spring.x, (int)newY));
+
+ if (_springState == 0) {
+ _springState = 1;
+ if (_springOffset >= 0)
+ _springOffset = -1;
+ _springTimer = 83;
+ recalcSpring(1);
+ } else if (_springState == 1) {
+ _springState = 2;
+ _springTimer = 83;
+ recalcSpring(1);
+ }
+
+ if ((float)_bottle->getCenter().y >= 226.0f) {
+ const int bottleY = _bottle->getPosition().y;
+ moveSpringAttachments(226 - bottleY);
+ _spring->stopMovementToPrev(true);
+ const Common::Point center = _spring->getCenter();
+ _spring->setPosition(Common::Point(center.x, 437));
+ _bottleDropped = false;
+ _handIsDown = false;
+ _objectIsTaken = true;
+ _bottleWeight = 2;
+ _springOffset = 10;
+ _bottleTaken = false;
+ _springState = 0;
+ g_ngi->setState(sO_LowerPipe, g_ngi->getStateValue(sO_LowerPipe, sO_IsClosed));
+ if (g_ngi->_chapterManager->getActiveChapter() == 1)
+ g_ngi->_taskManager->activateTask("FIND_EXIT_BOTLE_SC4");
+ if (_coinTaskPending) {
+ g_ngi->_taskManager->activateTask("GET_COIN_SC4");
+ _coinTaskPending = false;
+ }
+ }
+}
+
+// CSc04Controller::ActivateTasks (165A9C)
+void Sc04Controller::activateTasks() {
+ if (g_ngi->_chapterManager->getActiveChapter() == 1) {
+ g_ngi->_taskManager->activateTask("GET_COIN_SC4");
+ g_ngi->_taskManager->activateTask("FIND_EXIT_BOTLE_SC4");
+ }
+}
+
+// CSc04Controller::DoStartHand (165B04): hand takes the jar with 0..2 kozawkas (queues TAKE0..2),
+// or the whole jar (arcade won)
+void Sc04Controller::doStartHand() {
+ if (_bottleTaken)
+ return;
+
+ int queueId;
+ const uint count = _bottleKozaws.size();
+ if (count < 3) {
+ activateTasks();
+ warnOnce("CAchievementsManager::BlockActivatingCounter (ACHIEVEMENT_ARCADE_4)");
+ if (count == 0)
+ queueId = QU_HND_TAKE0;
+ else if (count == 1)
+ queueId = QU_HND_TAKE1;
+ else
+ queueId = QU_HND_TAKE2;
+ // analytics lose_count_ANI_KOZAWKA, game_ANI_KOZAWKA_lose: not ported
+ } else {
+ _clock->setStatic(ST_CLK_CLOSED);
+ stopQueueCopies(QU_SC4_GOCLOCK);
+ onMessage("MSG_STOP_MUS", "", nullptr);
+ g_ngi->_taskManager->deactivateTask("FIND_EXIT_BOTLE_SC4");
+ warnOnce("CAchievementsManager::AddActivatingCounter (ACHIEVEMENT_ARCADE_4)");
+ getGameLoaderInteractionController()->setActive("INT_019", SC_4, PIC_SC4_MASK, 0.0f, 0.0f);
+ // CFPController::FlurryArcadeEnd (analytics): not ported
+ queueId = QU_HND_TAKEBOTTLE;
+ }
+
+ _arrow->_flags &= ~4;
+ _ladderTimer = -1;
+ _blinkTimer = -1;
+ _ladderActed = true;
+ _scene->runQueue(queueId, 3);
+ _hand->_flags |= 4;
+ _objectIsTaken = false;
+ // CFPController::FlurryArcadeClean (analytics): not ported
+}
+
+// CSc04Controller::StartHandNow (165F24)
+void Sc04Controller::startHandNow() {
+ doStartHand();
+ doStopArcade();
+}
+
+// CSc04Controller::DoManJump (165F34): hero jumps from his ladder step to the plank
+MessageQueue *Sc04Controller::doManJump() {
+ AniObject *man = hero();
+ if (man->_movement && man->_movement->_id != MV_MAN_LOOKLADDER)
+ return nullptr;
+ const int statics = man->_statics ? man->_statics->_staticsId : 0;
+ if (statics != ST_MAN_STANDLADDER && statics != ST_MAN_LADDERDOWN)
+ return nullptr;
+
+ man->setStatic(ST_MAN_LADDERDOWN);
+ g_ngi->_aniHandler->attachObject(ANI_MAN);
+ MakeQueueStruct queueInfo;
+ queueInfo.ani = man;
+ queueInfo.staticsId2 = ST_MAN_ONPLANK;
+ queueInfo.movementId = MV_MAN_JUMPONPLANK;
+ queueInfo.cycleCount = 1;
+ queueInfo.x1 = 938;
+ queueInfo.y1 = 442;
+ queueInfo.destZ = 10;
+ queueInfo.flags = 78;
+ MessageQueue *queue = g_ngi->_aniHandler->makeRunQueue(&queueInfo);
+ if (queue) {
+ queue->_interruptState = 2;
+ runQueueWithAni(_scene, queue, man, 2);
+ man->_z = 10;
+ queue->addCommandToEnd(exitRotateCommand("MSG_FROMLADDER"));
+ }
+ if (_ladder)
+ _jumpStep = _ladder->getCurrentStep(man);
+ _arrow->_flags &= ~4;
+ _ladderTimer = -1;
+ _blinkTimer = -1;
+ _ladderActed = true;
+ return queue;
+}
+
+// CSc04Controller::OnClickPlank (1660DC) for MSG_CLICKPLANK
+void Sc04Controller::onClickPlank() {
+ if (manCanJump()) {
+ doManJump();
+ } else if (heroOnLadder()) {
+ g_ngi->playSound(SND_4_033, 0);
+ } else if (!_arcade) {
+ _scene->runQueue(QU_PNK_CLICK, 4);
+ }
+}
+
+// CSc04Controller::DoGotoLadder (166130): hero goes from the plank to the ladder; with the arcade
+// running (and not two kozawkas in the jar, head raised) he walks on to its end
+void Sc04Controller::doGotoLadder(MessageQueue *queue) {
+ g_ngi->_aniHandler->attachObject(ANI_MAN);
+ MakeQueueStruct queueInfo;
+ queueInfo.ani = hero();
+ queueInfo.staticsId2 = ST_MAN_UP;
+ queueInfo.movementId = MV_MAN_PLANKTOLADDER;
+ queueInfo.cycleCount = 1;
+ queueInfo.x1 = 1095;
+ queueInfo.y1 = 434;
+ queueInfo.destZ = 12;
+ queueInfo.flags = 78;
+ MessageQueue *made = g_ngi->_aniHandler->makeRunQueue(&queueInfo);
+ if (made) {
+ if (!_arcade || (_bottleKozaws.size() == 2 && _kozawHeadRaised)) {
+ made->addCommandToEnd(messageCommand("MSG_AFTERLADDER"));
+ } else {
+ made->removeCommand(made->getCount() - 1, true);
+ made->addCommandToEnd(movementCommand(ANI_MAN, MV_MAN_TOLADDER, 0));
+ made->addCommandToEnd(movementCommand(ANI_MAN, MV_MAN_STOPLADDER, 0));
+ made->addCommandToEnd(messageCommand("MSG_DOWALKLADDER_MAX"));
+ hero()->_z = 12;
+ }
+ runQueueWithAni(_scene, made, hero(), 2);
+ }
+ _kozawShot = false;
+}
+
+// CSc04Controller::MakeJumpNone (166318): the kozawka jumps (short or far) and misses the jar
+MessageQueue *Sc04Controller::makeJumpNone(AniObject *kozaw, double factor) {
+ g_ngi->_aniHandler->attachObject(kozaw->_id);
+ MakeQueueStruct queueInfo;
+ queueInfo.ani = kozaw;
+ queueInfo.staticsId2 = ST_KZW_SIT;
+ queueInfo.movementId = MV_KZW_JUMP;
+ queueInfo.cycleCount = 1;
+ queueInfo.x1 = (int)(float)(723.0 - factor * 185.0);
+ queueInfo.y1 = 486;
+ queueInfo.destZ = 10;
+ queueInfo.flags = 78;
+ MessageQueue *queue = g_ngi->_aniHandler->makeRunQueue(&queueInfo);
+ if (queue) {
+ queue->addCommandToEnd(messageCommand("SC04_MOVE_KOZAW", 1));
+ queue->addCommandToEnd(movementCommand(ANI_KOZAWKA, MV_KZW_STANDUP, kozaw->_copyId));
+ queue->addCommandToEnd(movementCommand(ANI_KOZAWKA, MV_KZW_TURN, kozaw->_copyId));
+ for (int i = 10; i != 0; i--)
+ queue->addCommandToEnd(movementCommand(ANI_KOZAWKA, MV_KZW_GOR, kozaw->_copyId, true));
+ queue->addCommandToEnd(hideCommand(ANI_KOZAWKA, kozaw->_copyId));
+ queue->addCommandToEnd(messageCommand("MSG_KOZAWRESTART"));
+ }
+ return queue;
+}
+
+// CSc04Controller::MakeJumpHit (166598): jumps against the jar (height by factor) and falls out
+MessageQueue *Sc04Controller::makeJumpHit(AniObject *kozaw, double factor) {
+ g_ngi->_aniHandler->attachObject(kozaw->_id);
+ MakeQueueStruct queueInfo;
+ queueInfo.ani = kozaw;
+ queueInfo.staticsId2 = ST_KZW_JUMPOUT;
+ queueInfo.x1 = 525;
+ const float height = 344.0 - (float)(94.0 - (float)((float)_bottle->getPosition().y - 226.0f)) * factor;
+ queueInfo.cycleCount = 1;
+ queueInfo.flags = 78;
+ queueInfo.y1 = (int)height;
+ queueInfo.destZ = 10;
+ queueInfo.movementId = MV_KZW_JUMPHIT;
+ MessageQueue *jump = g_ngi->_aniHandler->makeRunQueue(&queueInfo);
+
+ queueInfo.reset();
+ queueInfo.ani = kozaw;
+ queueInfo.staticsId1 = ST_KZW_JUMPOUT;
+ queueInfo.staticsId2 = ST_KZW_SIT;
+ queueInfo.x2 = 525;
+ const float landing = 344.0 - (float)(94.0 - (float)((float)_bottle->getPosition().y - 226.0f)) * factor;
+ queueInfo.y2 = (int)landing;
+ queueInfo.destZ = 10;
+ queueInfo.y1 = 486;
+ queueInfo.cycleCount = 1;
+ queueInfo.flags = 117;
+ queueInfo.movementId = MV_KZW_JUMPOUT;
+ MessageQueue *out = g_ngi->_aniHandler->makeRunQueue(&queueInfo);
+
+ if (jump) {
+ if (!out)
+ return out;
+ jump->addCommandToEnd(out->getCommandByIndex(0)->createClone());
+ delete out;
+ jump->addCommandToEnd(movementCommand(ANI_KOZAWKA, MV_KZW_STANDUP, kozaw->_copyId));
+ jump->addCommandToEnd(movementCommand(ANI_KOZAWKA, MV_KZW_TURN, kozaw->_copyId));
+ for (int i = 10; i != 0; i--)
+ jump->addCommandToEnd(movementCommand(ANI_KOZAWKA, MV_KZW_GOR, kozaw->_copyId, true));
+ jump->addCommandToEnd(hideCommand(ANI_KOZAWKA, kozaw->_copyId));
+ jump->addCommandToEnd(messageCommand("MSG_KOZAWRESTART"));
+ kozaw->_z = 10;
+ }
+ return jump;
+}
+
+// CSc04Controller::MakeJumpTo (166898): jumps into the jar (place a little random), raises its head
+MessageQueue *Sc04Controller::makeJumpTo(AniObject *kozaw) {
+ g_ngi->_aniHandler->attachObject(kozaw->_id);
+ MakeQueueStruct queueInfo;
+ queueInfo.ani = kozaw;
+ queueInfo.staticsId2 = ST_KZW_SIT;
+ queueInfo.cycleCount = 1;
+ // original: 4 * lrand48() / -2147483647 + 397 (the product wraps, see scaledRandom)
+ queueInfo.x1 = -scaledRandom(4) + 397;
+ const float bottleY = (float)_bottle->getPosition().y;
+ queueInfo.y1 = (int)(((bottleY - 226.0f) + 325.0f) - (float)scaledRandom(4));
+ queueInfo.destZ = kozaw->_z;
+ queueInfo.flags = 78;
+ queueInfo.movementId = MV_KZW_JUMPROTATE;
+ MessageQueue *queue = g_ngi->_aniHandler->makeRunQueue(&queueInfo);
+ if (queue) {
+ queue->removeCommand(queue->getCount() - 1, true);
+ queue->addCommandToEnd(movementCommand(ANI_KOZAWKA, MV_KZW_STANDUP, kozaw->_copyId));
+ queue->addCommandToEnd(movementCommand(ANI_KOZAWKA, MV_KZW_RAISEHEAD, kozaw->_copyId));
+ _kozawHeadRaised = true;
+ }
+ return queue;
+}
+
+// CSc04Controller::MakeJumpOver (166A68): the kozawka jumps over the jar (steps scaled by factor)
+MessageQueue *Sc04Controller::makeJumpOver(AniObject *kozaw, double factor) {
+ g_ngi->_aniHandler->attachObject(kozaw->_id);
+ MakeQueueStruct queueInfo;
+ queueInfo.ani = kozaw;
+ queueInfo.staticsId2 = ST_KZW_SIT;
+ queueInfo.x1 = (int)(float)(250.0 - factor * 100.0);
+ queueInfo.y1 = 455;
+ queueInfo.destZ = 10;
+ queueInfo.cycleCount = 1;
+ queueInfo.flags = 78;
+ queueInfo.movementId = MV_KZW_JUMPROTATE;
+ MessageQueue *queue = g_ngi->_aniHandler->makeRunQueue(&queueInfo);
+ if (queue) {
+ setJumpSteps(kozaw->getMovement(MV_KZW_JUMPROTATE), 1, 9, _jumpRotatePath, factor * 0.5 + 1.5);
+ kozaw->_z = 10;
+ queue->addCommandToEnd(hideCommand(ANI_KOZAWKA, kozaw->_copyId));
+ queue->addCommandToEnd(messageCommand("MSG_KOZAWRESTART"));
+ }
+ return queue;
+}
+
+// CSc04Controller::DoShootKozawka (166BE0): plank goes down, the kozawka on it flies; by its x it
+// misses short, hits the jar (high or low), gets in or flies over
+void Sc04Controller::doShootKozawka() {
+ warnOnce("CAniObject::MoveToStatic (the chain of movements to ST_PNK_WEIGHTRIGHT of the plank)");
+ AniObject *kozaw = _walkingKozaw;
+ if (!kozaw)
+ return;
+
+ if (kozaw->_movement && kozaw->_movement->_id == MV_KZW_WALKPLANK && kozaw->_movement->_curFrame <= 40) {
+ const int x = kozaw->getCenter().x;
+ int result = 7;
+ if ((uint)(x - 615) > 0x27) {
+ result = 6;
+ if ((uint)(x - 655) > 0x35) {
+ result = 5;
+ if ((uint)(x - 709) > 0x35)
+ result = 2 * ((uint)(x - 763) <= 0xD);
+ }
+ }
+ if (_handIsDown && result == 6)
+ result = 7;
+ kozaw->stopQueue();
+ kozaw->setStatic(ST_KZW_RIGHT);
+ MessageQueue *queue;
+ if (result > 2) {
+ if (result > 5) {
+ if (result == 6)
+ queue = makeJumpTo(kozaw);
+ else
+ queue = makeJumpOver(kozaw, 0.3333333333333333);
+ } else {
+ queue = makeJumpHit(kozaw, (double)(result - 2) / 3.0);
+ }
+ } else {
+ queue = makeJumpNone(kozaw, (double)result * 0.5);
+ }
+ // analytics total_moves, first_move, failcount of ANI_KOZAWKA: not ported
+ _lastKozaw = kozaw;
+ if (queue)
+ runQueueWithAni(_scene, queue, kozaw, 3);
+ warnOnce("CHintManager::SetHideCondition");
+ }
+ _kozawShot = true;
+}
+
+// CSc04Controller::DoStandLadder (166E00): hero goes to the ladder and stands on it; the ladder
+// controller gets him, walking and clicks are off (the callers never pass a current queue)
+void Sc04Controller::doStandLadder(MessageQueue *queue) {
+ setSaving(false);
+ MessageQueue *standQueue = new MessageQueue(_scene, true, 1);
+ if (queue)
+ warnOnce("CMessageQueue::GetCurCommand (the queue of the engine drops the commands that ran): DoStandLadder continues with MSG_SC4_CLICKLADDER");
+ standQueue->addCommandToEnd(movementCommand(ANI_MAN, MV_MAN_TOLADDER, hero()->_copyId));
+ standQueue->addCommandToEnd(movementCommand(ANI_MAN, MV_MAN_STOPLADDER, hero()->_copyId));
+ standQueue->addCommandToEnd(messageCommand("MSG_SC4_CLICKLADDER"));
+ runQueueWithAni(_scene, standQueue, hero(), 4);
+ heroOnLadder() = true;
+
+ _ladder = new MctlLadder();
+ _ladder->_x = 1089;
+ _ladder->_y = 406;
+ _ladder->_z = 12;
+ _ladder->_stepX = 0;
+ _ladder->_stepY = -40;
+ _ladder->_entryOffsetX = 0;
+ _ladder->_entryOffsetY = -60;
+ _ladder->attachObject(hero());
+ if (_ladder->_ladmovements.empty()) {
+ warnOnce("CSc04Controller::DoStandLadder: the ladder could not attach the hero (no ladder data of the hero)");
+ } else if (_arcade) {
+ _ladder->_ladmovements.front()->movementIds->upStartId = MV_MAN_STARTLADDER2;
+ _ladder->_ladmovements.front()->movementIds->upGoId = MV_MAN_GOLADDER2;
+ _ladder->_ladmovements.front()->movementIds->upStopId = MV_MAN_STOPLADDER2;
+ _ladder->_ladmovements.front()->staticIds[2] = ST_MAN_GOLADDER2;
+ } else {
+ _ladder->_ladmovements.front()->movementIds->upStartId = MV_MAN_STARTLADDER;
+ _ladder->_ladmovements.front()->movementIds->upGoId = MV_MAN_GOLADDER;
+ _ladder->_ladmovements.front()->movementIds->upStopId = MV_MAN_STOPLADDER;
+ _ladder->_ladmovements.front()->staticIds[2] = ST_MAN_GOLADDER;
+ }
+ hero()->_z = 12;
+ _scene->_motionController->deactivate();
+ getGameLoaderInteractionController()->disable();
+ g_ngi->setState(sO_Hint_1_05, 0);
+}
+
+// CSc04Controller::TryLeaveLadder (16707C): not called by the original. A tap without a hero
+// queue (or key 100) in the first motion controller area leaves the ladder
+void Sc04Controller::tryLeaveLadder(uint32 id, float x, float y) {
+ AniObject *man = hero();
+ if (man->getMessageQueue() && id != 100)
+ return;
+ MotionController *motion = _scene->_motionController.get();
+ if (!motion->_isEnabled)
+ return;
+ if (_scene->_motionController->getNumChildren() == 0 || !_scene->_motionController->getChild(0)->checkPoint((int)x, (int)y))
+ return;
+
+ if (_ladder->getCurrentStep(man) != 0) {
+ MessageQueue *queue = _ladder->makeQueue(man, 0);
+ if (queue) {
+ queue->addCommandToEnd(createMouseCommand(_scene, x, y, g_ngi->_inputController->getObjectId()));
+ runQueueWithAni(_scene, queue, man, 2);
+ if (_ballSlow)
+ speedUpBall();
+ }
+ } else {
+ MessageQueue *queue = new MessageQueue(_scene, true, 1);
+ if (man->_statics && man->_statics->_staticsId == ST_MAN_LADDERDOWN)
+ queue->addCommandToEnd(movementCommand(ANI_MAN, MV_MAN_LOOKLADDERRV, man->_copyId));
+ queue->addCommandToEnd(movementCommand(ANI_MAN, MV_MAN_STARTLADDERD, man->_copyId));
+ queue->addCommandToEnd(movementCommand(ANI_MAN, MV_MAN_FROMLADDER, man->_copyId));
+ queue->addCommandToEnd(createMouseCommand(_scene, x, y, g_ngi->_inputController->getObjectId()));
+ queue->addCommandToEnd(messageCommand("MSG_AFTERLADDER"));
+ runQueueWithAni(_scene, queue, man, 2);
+ }
+}
+
+// CSc04Controller::DoWalkLadder (1672C8): hero walks on the ladder to the point
+void Sc04Controller::doWalkLadder(float x, float y) {
+ _cameraLocked = true;
+ MessageQueue *queue = _ladder->startMove(hero(), (int)(x + _ladder->_entryOffsetX), (int)(y + _ladder->_entryOffsetY), 0, 0, false);
+ if (_kozawInBottle) {
+ _kozawInBottle = false;
+ if (queue)
+ queue->addCommandToEnd(messageCommand("MSG_KOZAWRESTART"));
+ }
+ if (queue) {
+ queue->addCommandToEnd(exitRotateCommand("MSG_TOLADDER"));
+ if (_hintPending)
+ queue->addCommandToEnd(messageCommand("MSG_SC4_SHOW_HINT"));
+ queue->addCommandToEnd(messageCommand("MSG_SC4_START_LADDER_TIMER"));
+ } else if (manCanJump()) {
+ doManJump();
+ }
+}
+
+// CSc04Controller::OnClickLadder (1674C4): on the ladder walk to the click (not above the steps),
+// else go to the foot and stand on it
+void Sc04Controller::onClickLadder() {
+ if (heroOnLadder()) {
+ _clickY = (float)((float)((float)((float)(_ladder->_stepY * 6.0) + _ladder->_y) - _ladder->_entryOffsetY) + (float)(_ladder->_stepY * 0.5)) + 1.0f;
+ doWalkLadder(_clickX, _clickY);
+ } else {
+ const Common::Point center = hero()->getCenter();
+ _clickHeroX = center.x;
+ _clickHeroY = center.y;
+ if (getGameLoaderInteractionController()->_enabled) {
+ if (fabsf(1095.0f - _clickHeroX) > 10.0f || fabsf(434.0f - _clickHeroY) > 10.0f) {
+ MessageQueue *started = mctlStartMove(1095, 434, true, ST_MAN_UP, false);
+ if (started)
+ started->addCommandToEnd(messageCommand("MSG_SC4_CLICKLADDER"));
+ } else {
+ doStandLadder(nullptr);
+ }
+ }
+ }
+}
+
+// CSc04Controller::OnUtrubaClick (167614): not called by the original. On the ladder walk up to
+// step 6, else go to the foot (current command goes on after) or stand on it
+void Sc04Controller::onUtrubaClick(MessageQueue *queue) {
+ if (heroOnLadder()) {
+ if (_ladder->getCurrentStep(hero()) <= 5) {
+ MessageQueue *up = _ladder->makeQueue(hero(), 6);
+ if (up)
+ runQueueWithAni(_scene, up, hero(), 2);
+ }
+ } else if (fabsf(1095.0f - _clickHeroX) > 10.0f || fabsf(434.0f - _clickHeroY) > 10.0f) {
+ MessageQueue *started = mctlStartMove(1095, 434, true, ST_MAN_UP, false);
+ if (started)
+ warnOnce("CMessageQueue::GetCurCommand (the queue of the engine drops the commands that ran): OnUtrubaClick does not continue the command");
+ } else {
+ doStandLadder(queue);
+ }
+}
+
+// CSc04Controller::DoJumpFromBottle (1676F4): hero jumps out of the jar (QU_SC4_MANFROMBOTTLE)
+void Sc04Controller::doJumpFromBottle(MessageQueue *queue) {
+ hero()->setStatic(ST_MAN_SIT);
+ if (queue)
+ warnOnce("CMessageQueue::GetCurCommand (the queue of the engine drops the commands that ran): DoJumpFromBottle does not continue the command");
+ MessageQueue *jump = copyQueue(_scene, QU_SC4_MANFROMBOTTLE);
+ if (jump) {
+ jump->_interruptState = 2;
+ runQueueWithAni(_scene, jump, hero(), 4);
+ }
+ _dudeInBottle = false;
+ _scene->_behaviorController->enableAllQueuesForAni(hero(), 1);
+}
+
+// CSc04Controller::DoWinArcade (167AD8): pipe closed and arcade running: hand takes the jar, end
+void Sc04Controller::doWinArcade() {
+ if (!isState(sO_LowerPipe, sO_IsClosed) || !_arcade)
+ return;
+
+ _clock->setStatic(ST_CLK_CLOSED);
+ _hand->setStatic(ST_HND_EMPTY);
+ _scene->runQueue(QU_HND_TAKEBOTTLE, 3);
+ if (_walkingKozaw) {
+ _waitingKozaws.push_back(_walkingKozaw);
+ _walkingKozaw->setStatic(ST_KZW_EMPTY);
+ _walkingKozaw->_flags &= ~4;
+ _walkingKozaw = nullptr;
+ }
+ _objectIsTaken = false;
+ _arcade = false;
+ _cameraLocked = false;
+ _scene->_motionController->activate();
+ getGameLoaderInteractionController()->enable();
+ g_ngi->_taskManager->deactivateTask("FIND_EXIT_BOTLE_SC4");
+ getGameLoaderInteractionController()->setActive("INT_019", SC_4, PIC_SC4_MASK, 0.0f, 0.0f);
+}
+
+// CSc04Controller::DoDetachMan (167C48): hero no longer moves with the spring (ladder goes)
+void Sc04Controller::doDetachMan() {
+ for (uint i = 0; i < _bottleObjects.size(); i = (uint16)(i + 1)) {
+ if (_bottleObjects[i] == hero()) {
+ eraseAt(_bottleObjects, i);
+ _bottleWeight -= 9;
+ break;
+ }
+ }
+ delete _ladder;
+ _ladder = nullptr;
+ _scene->_motionController->activate();
+ getGameLoaderInteractionController()->enable();
+}
+
+// CSc04Controller::DoDropBottle (167CAC): jar falls, its kozawkas go out, hand empty at the top
+void Sc04Controller::doDropBottle() {
+ _bottleDropped = true;
+ _bottleFallSpeed = 10;
+ _bottleWeight = 0;
+ while (!_bottleKozaws.empty()) {
+ AniObject *kozaw = _bottleKozaws.front();
+ eraseAt(_bottleKozaws, 0);
+ for (uint i = 0; i < _bottleObjects.size(); i = (uint16)(i + 1)) {
+ if (_bottleObjects[i] == kozaw)
+ eraseAt(_bottleObjects, i);
+ }
+ kozaw->stopQueue();
+ kozaw->_flags &= ~4;
+ _waitingKozaws.push_back(kozaw);
+ }
+ _hand->setStatic(ST_HND_EMPTY);
+ _hand->setPosition(Common::Point(429, 21));
+ _hand->_z = 15;
+}
+
+// CSc04Controller::DoTakeKozaw (167D6C): the hand takes the first kozawka of the jar
+void Sc04Controller::doTakeKozaw() {
+ if (_bottleKozaws.empty())
+ return;
+ if (_bottleKozaws.size() <= 1)
+ _objectIsTaken = true;
+ AniObject *kozaw = _bottleKozaws.front();
+ eraseAt(_bottleKozaws, 0);
+ if (kozaw) {
+ kozaw->stopQueue();
+ kozaw->_flags &= ~4;
+ _waitingKozaws.push_back(kozaw);
+ for (uint i = 0; i < _bottleObjects.size(); i = (uint16)(i + 1)) {
+ if (_bottleObjects[i] == kozaw)
+ eraseAt(_bottleObjects, i);
+ }
+ _bottleWeight -= _kozawWeight;
+ }
+}
+
+// CSc04Controller::DoAttachMan (167DF8): hero moves with the spring, camera follows, jar swings
+void Sc04Controller::doAttachMan() {
+ _bottleObjects.push_back(hero());
+ _bottleWeight += 9;
+ _springOffset = 5;
+ _follow = hero();
+ _dudeInBottle = true;
+}
+
+// CSc04Controller::PutKozawToBottle (167E30): kozawka sits in the jar, counter grows, 3rd: hand
+void Sc04Controller::putKozawToBottle(AniObject *kozaw, PictureObject *bottle) {
+ g_ngi->arcadeInterface().incCounter();
+ bottle->getCenter();
+ random31();
+ _bottleObjects.push_back(kozaw);
+ _bottleKozaws.push_back(kozaw);
+ _bottleWeight += _kozawWeight;
+ _walkingKozaw = nullptr;
+ _lastKozaw = nullptr;
+ const uint count = _bottleKozaws.size();
+ if (count <= 1) {
+ _kozawInBottle = true;
+ } else {
+ _objectIsTaken = false;
+ if (count == 2 || _hand->_movement)
+ _kozawInBottle = true;
+ else
+ startHandNow();
+ }
+}
+
+// CSc04Controller::OnShow (167FE4) behind the margins: objects found, jar, kozawkas and mamasha
+// set by the jar state, arcade sounds stop, ladder exit looks south
+void Sc04Controller::onShowScene() {
+ g_ngi->_taskManager->visitScene(_scene->_sceneId);
+ _kozawDelayK = 1.0f;
+ _kozawStartDelay = 0.0f;
+ _clockDelayK = 1.0f;
+ readSettingsXml();
+ heroOnLadder() = false;
+ _bottle = _scene->findPictureObjectById(PIC_SC4_BOTTLE, 0);
+ _hand = _scene->findAniObjectById(ANI_HAND, 0);
+ _plank = _scene->findAniObjectById(ANI_PLANK, 0);
+ _clock = _scene->findAniObjectById(ANI_CLOCK, 0);
+ _spring = _scene->findAniObjectById(ANI_SPRING, 0);
+ _mumsy = _scene->findAniObjectById(ANI_MAMASHA_4, 0);
+ _lamps = _scene->findAniObjectById(ANI_SC4_LAMPS, 0);
+ _arrow = _scene->findPictureObjectById(PIC_SC_4_ARROW_1, 0);
+ _domino = _scene->findAniObjectById(ANI_DOMINO_3, 0);
+ _ladder = nullptr;
+ _springState = 0;
+ warnOnce("CAniObject::MoveToStatic (the chain of movements to ST_PNK_WEIGHTLEFT of the plank)");
+
+ AniObject *kozaw = _scene->findAniObjectById(ANI_KOZAWKA, 0);
+ if (kozaw) {
+ Movement *jump = kozaw->getMovement(MV_KZW_JUMP);
+ for (uint i = 0; jump && i < jump->_phases.size() && i < 20; i++) {
+ _jumpPath[i].x = jump->_phases[i]->_x;
+ _jumpPath[i].y = jump->_phases[i]->_y;
+ }
+ Movement *rotate = kozaw->getMovement(MV_KZW_JUMPROTATE);
+ for (uint i = 0; rotate && i < rotate->_phases.size() && i < 20; i++) {
+ _jumpRotatePath[i].x = rotate->_phases[i]->_x;
+ _jumpRotatePath[i].y = rotate->_phases[i]->_y;
+ }
+ }
+ // the copies of the kozawka go
+ for (int amount = objectsAmount(_scene, ANI_KOZAWKA); amount != 1; amount = objectsAmount(_scene, ANI_KOZAWKA)) {
+ AniObject *copy = _scene->findAniObjectById(ANI_KOZAWKA, amount - 1);
+ if (!copy)
+ break;
+ removeThis(_scene, copy);
+ }
+ _waitingKozaws.clear();
+ _bottleKozaws.clear();
+ _walkingKozaw = nullptr;
+ _lastKozaw = nullptr;
+
+ if (isState(sO_Jar_4, sO_OnTheSpring)) {
+ _spring->stopMovementToPrev(true);
+ const Common::Point center = _spring->getCenter();
+ _spring->setPosition(Common::Point(center.x, 437));
+ _bottleObjects.clear();
+ PictureObject *bottle = _scene->findPictureObjectById(PIC_SC4_BOTTLE, 0);
+ bottle->setPosition(Common::Point(bottle->getPosition().x, 226));
+ _bottleObjects.push_back(bottle);
+ PictureObject *mask = _scene->findPictureObjectById(PIC_SC4_MASK, 0);
+ mask->setPosition(Common::Point(mask->getPosition().x, 235));
+ _bottleObjects.push_back(mask);
+ if (kozaw) {
+ kozaw->setStatic(ST_KZW_EMPTY);
+ kozaw->setPosition(Common::Point(0, 0));
+ kozaw->_flags &= ~4;
+ _waitingKozaws.push_back(kozaw);
+ AniObject *last = kozaw;
+ for (int i = 6; i != 0; i--) {
+ AniObject *copy = new AniObject(last);
+ last = copy;
+ _scene->addAni(copy, true);
+ copy->setStatic(ST_KZW_EMPTY);
+ copy->setPosition(Common::Point(0, 0));
+ copy->_flags &= ~4;
+ _waitingKozaws.push_back(copy);
+ }
+ }
+ _scene->findPictureObjectById(PIC_SC4_BOTTLE2, 0)->_flags &= ~4;
+ _clockCanGo = true;
+ _objectIsTaken = true;
+ g_ngi->setState(sO_LowerPipe, g_ngi->getStateValue(sO_LowerPipe, sO_IsClosed));
+ } else if (isState(sO_Jar_4, sO_UpsideDown)) {
+ _bottleObjects.clear();
+ _waitingKozaws.clear();
+ _scene->findPictureObjectById(PIC_SC4_BOTTLE, 0)->_flags &= ~4;
+ _scene->findPictureObjectById(PIC_SC4_MASK, 0)->_flags &= ~4;
+ _scene->findAniObjectById(ANI_SPRING, 0)->_flags &= ~4;
+ _scene->findPictureObjectById(PIC_SC4_BOTTLE2, 0)->_flags |= 4;
+ _clockCanGo = false;
+ _objectIsTaken = false;
+ g_ngi->setState(sO_LowerPipe, g_ngi->getStateValue(sO_LowerPipe, sO_IsClosed));
+ } else {
+ _bottleObjects.clear();
+ _waitingKozaws.clear();
+ _spring->startMovement(MV_SPR_LOWER, 0, -1);
+ if (_spring->_movement)
+ _spring->_movement->setCurFrame(8);
+ _spring->setCenter(Common::Point(433, 238));
+ }
+
+ _bottleTaken = false;
+ _arcade = false;
+ _cameraLocked = false;
+ _kozawShot = false;
+ _walkingKozaw = nullptr;
+ _bottleWeight = 2;
+ _springPos = 0;
+ _bottleKozaws.clear();
+ _manFalls = false;
+ _coinPut = false;
+ _handIsDown = false;
+ _dudeInBottle = false;
+ _kozawHeadRaised = false;
+ _bottleDropped = false;
+ _ballSlow = true;
+ _ballTimer = 0;
+ _ballWalksRight = true;
+ _musicStopped = false;
+ _coinTaskPending = false;
+ if (isState(sO_BigMumsy, sO_IsGone))
+ _mumsy->_flags |= 4;
+ else
+ _mumsy->_flags &= ~4;
+ _speaker = _scene->findAniObjectById(ANI_SPEAKER_4, 0);
+ _speakerVariant = 0;
+ _speakerPhase = 0;
+ g_ngi->stopAllSoundInstances(SND_MUS_SC04_START);
+ g_ngi->stopAllSoundInstances(SND_MUS_SC04_LOOP);
+ g_ngi->stopAllSoundInstances(SND_MUS_SC04_STOP1);
+ g_ngi->stopAllSoundInstances(SND_MUS_SC04_STOP2);
+ g_ngi->_exitManager->setExitAngle(PIC_SC4_LADDER, 0.0f);
+ _closeUpSell = false;
+ _demoScroll = false;
+}
+
+// CSc04Controller::OnHide (168678): arcade interface goes, ball and hand hidden, kozawkas gone,
+// tasks activated if the arcade ran
+void Sc04Controller::onHide() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onHide();
+ return;
+ }
+ // CFPController::FlurryArcadeClean (analytics): not ported
+ if (g_ngi->arcadeInterface().getState() != ArcadeInterface::kHidden)
+ g_ngi->arcadeInterface().scrollOut();
+ setSaving(true);
+ hideAction(_scene, ANI_BIGBALL, 0);
+ hideAction(_scene, _hand->_id, 0);
+ _hintPending = false;
+ _speaker->stopMovement();
+ for (int amount = objectsAmount(_scene, ANI_KOZAWKA); amount != 1; amount = objectsAmount(_scene, ANI_KOZAWKA)) {
+ AniObject *copy = _scene->findAniObjectById(ANI_KOZAWKA, amount - 1);
+ if (!copy)
+ break;
+ removeThis(_scene, copy);
+ }
+ _waitingKozaws.clear();
+ _bottleKozaws.clear();
+ _clock->setStatic(ST_CLK_CLOSED);
+ _lamps->_flags &= ~4;
+ FPController::onHide();
+ warnOnce("CHintManager::HideHint (hint glow)");
+ g_ngi->setState(sO_Hint_1_05, 0);
+ g_ngi->_exitManager->resetExitIntersect(PIC_SC4_LTRUBA, false);
+ // analytics lose_count_ANI_KOZAWKA, game_ANI_KOZAWKA_lose: not ported
+ if (_clockCanGo && _arcade)
+ activateTasks();
+ if (isQueueStarted(QU_HND_TAKEBOTTLE) && !isState(sO_Jar_4, sO_UpsideDown)) {
+ activateTasks();
+ g_ngi->_exitManager->setExitState(PIC_SC4_DOWNTRUBA, 0);
+ }
+}
+
+// CSc04Controller::OnKeyUp (168A10): cheats W (arcade starts and is won), Q (arcade skipped)
+void Sc04Controller::onKeyUp(uint32 key) {
+ FPController::onKeyUp(key);
+ if (!controllerRunsSceneLogic())
+ return;
+ if (key == 87) {
+ if (_clockCanGo && !_handIsDown) {
+ doStartArcade();
+ doWinArcade();
+ }
+ } else if (key == 81) {
+ skipArcade();
+ }
+}
+
+// CSc04Controller::GetCursorType (168A54): open lower pipe arrow (2), plank (105), domino (1)
+int Sc04Controller::getCursorType(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::getCursorType(x, y);
+ CursorController *cursor = g_ngi->_inputController;
+ if (cursor->isObjectHit(PIC_SC4_DOWNTRUBA) && isState(sO_LowerPipe, sO_IsOpened))
+ return 2;
+ if (cursor->isObjectHit(ANI_PLANK) || cursor->isObjectHit(PIC_SC4_PLANK)) {
+ if (manCanJump())
+ return 105;
+ return !_arcade;
+ }
+ if (cursor->isObjectHit(ANI_DOMINO_3) && _domino && (_domino->_flags & 4))
+ return 1;
+ return FPController::getCursorType(x, y);
+}
+
+// CSc04Controller::OnUpdate (168C10): arcade music, spring, speaker, falls, jump out of the jar,
+// arcade start, balls, ladder arrow
+void Sc04Controller::onUpdate(uint32 elapsed) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onUpdate(elapsed);
+ return;
+ }
+ if (_arcade) {
+ if (!isSoundPlayed(SND_MUS_SC04_START) && !isSoundPlayed(SND_MUS_SC04_LOOP) && !isSoundPlayed(SND_MUS_SC04_STOP1) && !isSoundPlayed(SND_MUS_SC04_STOP2)) {
+ if (!_musicStopped)
+ g_ngi->playSound(SND_MUS_SC04_LOOP, 1);
+ }
+ } else if (!isSoundPlayed(SND_MUS_SC04_STOP2) && !isSoundPlayed(SND_MUS_SC04_LOOP)) {
+ _scene->_behaviorController->enableAllMusic();
+ }
+ FPController::onUpdate(elapsed);
+ if (!_bottleDropped && isState(sO_Jar_4, sO_OnTheSpring))
+ recalcSpring(elapsed);
+ gramoNextFunc(elapsed);
+ if (_manFalls && !_handIsDown)
+ doManFall();
+ if (_bottleDropped)
+ doUpdateBottlePositionDown();
+ if (_dudeInBottle && _hand->_movement)
+ doJumpFromBottle(nullptr);
+ if (_coinPut && _clockCanGo && !_handIsDown && !_arcade)
+ doStartArcade();
+ if (heroOnLadder() && _arcade) {
+ _ballTimer += elapsed;
+ if (_ballTimer > 24600)
+ tryBall();
+ }
+ if (_ladderTimer != -1) {
+ _ladderTimer += elapsed;
+ if (_ladderTimer > 4999) {
+ _ladderTimer = -1;
+ _arrow->_flags |= 4;
+ _blinkTimer = 0;
+ }
+ }
+ if (_blinkTimer != -1) {
+ _blinkTimer += elapsed;
+ if (_blinkTimer > 174) {
+ _blinkTimer = 0;
+ _blinkToggle = !_blinkToggle;
+ const Common::Point position = _arrow->getPosition();
+ if (_blinkToggle)
+ _arrow->setPosition(Common::Point(position.x - 1, position.y + 2));
+ else
+ _arrow->setPosition(Common::Point(position.x + 1, position.y - 2));
+ }
+ }
+}
+
+// CSc04Controller::OnMouseLKeyUp (168EB0): base tap first, then jar jump out, ladder, plank, and
+// the jump from the ladder to the plank
+bool Sc04Controller::onMouseLKeyUpController(uint32 id, float x, float y) {
+ if (FPController::onMouseLKeyUp(id, x, y))
+ return true;
+ if (_dudeInBottle) {
+ doJumpFromBottle(nullptr);
+ return false;
+ }
+ CursorController *cursor = g_ngi->_inputController;
+ if (cursor->isObjectHit(PIC_SC4_LADDER)) {
+ if (canInterruptManQueue()) {
+ _clickX = x;
+ _clickY = y;
+ onClickLadder();
+ return true;
+ }
+ return true;
+ }
+ if (cursor->isObjectHit(ANI_PLANK) || cursor->isObjectHit(PIC_SC4_PLANK)) {
+ onClickPlank();
+ return true;
+ }
+ if (_arcade)
+ return false;
+ if (!canInterruptManQueue())
+ return false;
+ if (g_ngi->_exitManager->getExitDestAngle(PIC_SC4_LADDER) != 180.0f)
+ return false;
+ hero()->stopQueue();
+ hero()->stopMovement();
+ getGameLoaderInteractionController()->enable();
+ heroOnLadder() = false;
+ MessageQueue *jump = doManJump();
+ if (jump) {
+ // CCommand(25): the statics ST_MAN_RIGHT of ANI_MAN
+ Command *stand = new Command(ANI_MAN, kCmdSetStatic, ST_MAN_RIGHT, 0, 0, 0, 1, 0, 0, 0);
+ stand->_param = 0;
+ stand->_excFlags |= 2;
+ jump->addCommandToEnd(stand);
+ jump->addCommandToEnd(messageCommand("MSG_RAISEPLANK"));
+ jump->addCommandToEnd(createMouseCommand(_scene, x, y, cursor->getObjectId()));
+ return true;
+ }
+ return false;
+}
+
+// CSc04Controller::OnMessage (169094): the scene messages by name, the rest to CFPController
+void Sc04Controller::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onMessage(message, param, queue);
+ return;
+ }
+
+ if (message == "MSG_STOP_MUS") {
+ _musicStopped = true;
+ g_ngi->stopAllSoundInstances(SND_MUS_SC04_LOOP);
+ g_ngi->playSound(SND_MUS_SC04_STOP2, 0);
+ _lamps->_flags &= ~4;
+ return;
+ }
+ if (message == "MSG_CLOSEUPSELL") {
+ if (_closeUpSell) {
+ warnOnce("CScene::StopAllQueues (MSG_CLOSEUPSELL)");
+ hero()->stopMovementToPrev(false);
+ }
+ _closeUpSell = false;
+ return;
+ }
+ if (message == "MSG_COMPLTEUPSELL") {
+ _closeUpSell = false;
+ return;
+ }
+ if (message == "MSG_SC4_NEXT_LAMP") {
+ if (!_lamps->_movement || _lamps->_movement->_id != MV_SC4_LAMPS_TORED)
+ return;
+ const int frame = _lamps->_movement->_curFrame;
+ if (frame >= (int)_lamps->_movement->_phases.size() - 1)
+ return;
+ _lamps->_movement->setCurFrame(frame + 1);
+ return;
+ }
+ if (message == "MSG_TESTPLANK") {
+ kozawTestPlank(queue);
+ return;
+ }
+ if (message == "MSG_LOWERPLANK") {
+ kozawLowerPlank();
+ return;
+ }
+ if (message == "MSG_RAISEPLANK") {
+ kozawRaisePlank();
+ return;
+ }
+ if (message == "MSG_CLICKPLANK") {
+ onClickPlank();
+ return;
+ }
+ if (message == "MSG_CLICKBOTTLE") {
+ onClickBottle();
+ return;
+ }
+ if (message == "MSG_SHOOTKOZAW") {
+ doShootKozawka();
+ return;
+ }
+ if (message == "MSG_KOZAWRESTART") {
+ if (_walkingKozaw) {
+ _waitingKozaws.push_back(_walkingKozaw);
+ _walkingKozaw->_flags &= ~4;
+ _walkingKozaw = nullptr;
+ }
+ if (!_arcade)
+ return;
+ startKozawka(false);
+ return;
+ }
+ if (message == "MSG_SHAKEBOTTLE") {
+ if (_bottleTaken)
+ return;
+ _springOffset++;
+ return;
+ }
+ if (message == "MSG_STARTHAND") {
+ _handIsDown = true;
+ _coinPut = false;
+ if (_dudeInBottle)
+ doJumpFromBottle(nullptr);
+ doStartHand();
+ doStopArcade();
+ return;
+ }
+ if (message == "MSG_SC4_STARTCLOCK")
+ return;
+ if (message == "MSG_TAKEKOZAW") {
+ doTakeKozaw();
+ return;
+ }
+ if (message == "MSG_CLICKBUTTON") {
+ onClickButton();
+ return;
+ }
+ if (message == "MSG_TAKEBOTTLE") {
+ doTakeBottle();
+ return;
+ }
+ if (message == "MSG_UPDATEBOTTLE") {
+ doUpdateBottlePosition();
+ return;
+ }
+ if (message == "MSG_GOTOLADDER") {
+ doGotoLadder(queue);
+ return;
+ }
+ if (message == "MSG_DOWALKLADDER_MAX") {
+ doWalkLadder(1079.0f, 215.0f);
+ return;
+ }
+ if (message == "MSG_SC4_COINPUT") {
+ if (!isState(sO_Jar_4, sO_IsRaised)) {
+ _coinPut = true;
+ _coinTaskPending = false;
+ doDropBottle();
+ Task *task = g_ngi->_taskManager->findTask("FIND_EXIT_HAND_SC17");
+ if (task)
+ task->enableHint(2, true);
+ }
+ return;
+ }
+ if (message == "MSG_SHOWCOIN") {
+ doShowCoin();
+ return;
+ }
+ if (message == "MSG_SC4_CLICKLADDER") {
+ onClickLadder();
+ return;
+ }
+ if (message == "MSG_SC4_MANTOBOTTLE") {
+ doAttachMan();
+ return;
+ }
+ if (message == "MSG_SC4_MANFROMBOTTLE") {
+ doDetachMan();
+ return;
+ }
+ if (message == "MSG_SC4_KOZAWFALL") {
+ if (_kozawHeadRaised) {
+ putKozawToBottle(_lastKozaw, _bottle);
+ _kozawHeadRaised = false;
+ g_ngi->playSound(SND_4_010, 0);
+ } else {
+ g_ngi->playSound(SND_4_012, 0);
+ }
+ return;
+ }
+ if (message == "MSG_SC4_COINOUT") {
+ _clock->setStatic(ST_CLK_CLOSED);
+ _coinPut = false;
+ doStopArcade();
+ if (!_bottleKozaws.empty() && !_bottleTaken) {
+ _handIsDown = true;
+ if (_dudeInBottle)
+ doJumpFromBottle(nullptr);
+ doStartHand();
+ }
+ Task *task = g_ngi->_taskManager->findTask("FIND_EXIT_HAND_SC17");
+ if (task)
+ task->enableHint(2, false);
+ if (isSoundPlayed(SND_MUS_SC04_LOOP) || isSoundPlayed(SND_MUS_SC04_START)) {
+ g_ngi->stopAllSoundInstances(SND_MUS_SC04_LOOP);
+ g_ngi->stopAllSoundInstances(SND_MUS_SC04_START);
+ g_ngi->playSound(SND_MUS_SC04_STOP2, 0);
+ }
+ return;
+ }
+ if (message == "MSG_SC4_DROPBOTTLE") {
+ _coinTaskPending = true;
+ doDropBottle();
+ return;
+ }
+ if (message == "MSG_SC4_HANDOVER") {
+ _handIsDown = false;
+ _objectIsTaken = true;
+ return;
+ }
+ if (message == "MSG_CMN_WINARCADE") {
+ doWinArcade();
+ return;
+ }
+ if (message == "MSG_DO_START_ARCADE") {
+ if (_arcade)
+ doStopArcade();
+ doStartArcade();
+ return;
+ }
+ if (message == "MSG_AFTERLADDER") {
+ afterLadder();
+ return;
+ }
+ if (message == "SC04_MOVE_KOZAW") {
+ if (_walkingKozaw) {
+ const Common::Point position = _walkingKozaw->getPosition();
+ _walkingKozaw->setPosition(Common::Point(position.x - 40, position.y - 50));
+ }
+ return;
+ }
+ if (message == "MSG_SC4_SHOW_HINT") {
+ _hintPending = false;
+ warnOnce("CHintManager::ShowHint (MSG_SC4_SHOW_HINT)");
+ g_ngi->arcadeInterface().init(400, -100, -64, 0, 3, 0, true);
+ g_ngi->arcadeInterface().scrollIn();
+ return;
+ }
+ if (message == "MSG_SC4_START_LADDER_TIMER") {
+ if (_ladderTimer == -1 && heroOnLadder() && _arcade && !_ladderActed)
+ _ladderTimer = 0;
+ return;
+ }
+ if (message == "MSG_SC3_HIDEDOMINO") {
+ _domino->_flags &= ~4;
+ hero()->_z = 8;
+ return;
+ }
+ if (message == "MSG_SC4_SET_Z") {
+ hero()->_z = 10;
+ return;
+ }
+ if (message == "MSG_SC4_DEMO_SCROLL") {
+ // end of QU_SC4_ENTER (5th command): first time the camera pans right and back while the hero
+ // waits; the commands behind the 5th are dropped (the engine queue holds only the unrun ones)
+ if (isState(sO_DemoScroll, sO_WasHere)) {
+ _demoScroll = false;
+ _follow = hero();
+ while (queue && queue->getCount())
+ queue->removeCommand(queue->getCount() - 1, true);
+ } else {
+ _demoScroll = true;
+ _follow = nullptr;
+ g_ngi->setState(sO_DemoScroll, g_ngi->getStateValue(sO_DemoScroll, sO_WasHere));
+ if (queue) {
+ const char *positions[] = { "800", "0" };
+ for (int i = 0; i < 2; i++) {
+ Command *scroll = new Command(0, kCmdUser, 0, 0, 0, 0, 1, 0, 0, 0);
+ scroll->_messageName = "SET_SCROLL";
+ scroll->_args["type"] = "SET_SCROLL";
+ scroll->_args["x"] = positions[i];
+ scroll->_args["scroll"] = "1";
+ scroll->_excFlags |= 2;
+ queue->addCommandToEnd(scroll);
+ }
+ queue->addCommandToEnd(messageCommand("MSG_SC4_DEMO_SCROLL_END"));
+ }
+ }
+ return;
+ }
+ if (message == "MSG_SC4_DEMO_SCROLL_END") {
+ _demoScroll = false;
+ _follow = hero();
+ // the original removes all commands but the first (ran ones are not in the engine queue)
+ while (queue && queue->getCount())
+ queue->removeCommand(queue->getCount() - 1, true);
+ return;
+ }
+ FPController::onMessage(message, param, queue);
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sc04controller.h b/engines/ngi/fullpipe/sc04controller.h
index b0313fac9de..d69225dadef 100644
--- a/engines/ngi/fullpipe/sc04controller.h
+++ b/engines/ngi/fullpipe/sc04controller.h
@@ -22,22 +22,170 @@
#ifndef NGI_FULLPIPE_SC04CONTROLLER_H
#define NGI_FULLPIPE_SC04CONTROLLER_H
+#include "common/array.h"
+#include "common/str.h"
+
+#include "ngi/vector2.h"
#include "ngi/fullpipe/fpcontroller.h"
namespace NGI {
-/** Android: CSc04Controller. Only the parts that are ported: OnShow (the camera margins), OnRender (the arcade interface), CanSwipeMan,
- * UpdateScroll and OnMouseLKeyUp (the ladder, the plank); the rest of the scene logic is still in scene04.cpp */
+class GameObject;
+class MctlLadder;
+class Movement;
+class PictureObject;
+
+/** CSc04Controller (scene 4: jar, plank, ladder, hand, arcade); offsets are the original's */
class Sc04Controller : public FPController {
public:
- explicit Sc04Controller(int sceneId) : FPController(sceneId) {}
+ explicit Sc04Controller(int sceneId);
+ ~Sc04Controller() override;
+ // the methods that scene04.cpp implements (they work on g_vars->scene04_*)
void onShow() override;
void onRender(Common::Point scroll) override;
bool onMouseLKeyUp(uint32 id, float x, float y) override;
bool canSwipeMan(float x, float y) override;
void skipArcade() override;
void updateScroll() override;
+
+ // the overrides that sc04controller.cpp implements
+ void cleanXml() override;
+ bool canShowHelp() override;
+ void checkTutorial() override;
+ void onHide() override;
+ void onKeyUp(uint32 key) override;
+ int getCursorType(float x, float y) override;
+ void onUpdate(uint32 elapsed) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+
+ /** CSc04Controller::OnShow behind the margins (called when controllerRunsSceneLogic()) */
+ void onShowScene();
+ /** CSc04Controller::SkipArcade on the members (scene04.cpp skipArcade works on g_vars) */
+ void skipArcadeController();
+ /** CSc04Controller::OnMouseLKeyUp on the members (scene04.cpp onMouseLKeyUp works on g_vars) */
+ bool onMouseLKeyUpController(uint32 id, float x, float y);
+
+ void readSettingsXml();
+ void slowDownBall();
+ void speedUpBall();
+ void startKozawka(bool first);
+ void kozawTestPlank(MessageQueue *queue);
+ void kozawLowerPlank();
+ void kozawRaisePlank();
+ bool manCanJump();
+ void setJumpSteps(Movement *movement, int from, int to, const Vector2 *path, double scale);
+ void moveSpringAttachments(int delta);
+ void recalcSpring(uint32 elapsed);
+ void onClickBottle();
+ void doUpdateBottlePosition();
+ void onClickButton();
+ void doShowCoin();
+ void gramoNextFunc(uint32 elapsed);
+ void doUpdatePath();
+ void doManFall();
+ void doTakeBottle();
+ void doStopArcade();
+ void tryBall();
+ void doStartArcade();
+ void afterLadder();
+ void doUpdateBottlePositionDown();
+ void activateTasks();
+ void doStartHand();
+ void startHandNow();
+ MessageQueue *doManJump();
+ void onClickPlank();
+ void doGotoLadder(MessageQueue *queue);
+ MessageQueue *makeJumpNone(AniObject *kozaw, double factor);
+ MessageQueue *makeJumpHit(AniObject *kozaw, double factor);
+ MessageQueue *makeJumpTo(AniObject *kozaw);
+ MessageQueue *makeJumpOver(AniObject *kozaw, double factor);
+ void doShootKozawka();
+ void doStandLadder(MessageQueue *queue);
+ void tryLeaveLadder(uint32 id, float x, float y);
+ void doWalkLadder(float x, float y);
+ void onClickLadder();
+ void onUtrubaClick(MessageQueue *queue);
+ void doJumpFromBottle(MessageQueue *queue);
+ void doWinArcade();
+ void doDetachMan();
+ void doDropBottle();
+ void doTakeKozaw();
+ void doAttachMan();
+ void putKozawToBottle(AniObject *kozaw, PictureObject *bottle);
+
+private:
+ /** +148 of CFPController (arcade flag): set while the hero is on the ladder in this scene */
+ bool &heroOnLadder() { return _arcadeRunning; }
+
+ /** +214 (CFPController): upsell closeup is shown (MSG_CLOSEUPSELL stops the scene queues) */
+ bool _closeUpSell = false;
+ /** +216: the next tutorial of the scene */
+ Common::String _tutorial;
+ int _jumpStep = 0; // +220: ladder step of the hero's jump (DoManJump), never read
+ bool _kozawShot = false; // +224: set by DoShootKozawka, cleared by DoGotoLadder/OnShow, never read
+ Vector2 _jumpPath[20]; // +228: phase offsets of MV_KZW_JUMP (OnShow)
+ Vector2 _jumpRotatePath[20]; // +388: same for MV_KZW_JUMPROTATE, scaled by SetJumm_pSteps
+ Common::Array<AniObject *> _waitingKozaws; // +548: waiting for their walk to the plank
+ Common::Array<AniObject *> _bottleKozaws; // +560: sitting in the jar
+ AniObject *_walkingKozaw = nullptr; // +572: on its way (StartKozawka)
+ AniObject *_lastKozaw = nullptr; // +576: the kozawka that was shot
+ bool _arcade = false; // +580: the arcade runs (CanShowHelp, the camera, the music)
+ bool _cameraLocked = false; // +581: the camera is held (CanSwipeMan reads it)
+ bool _ballSlow = true; // +582: big ball has the slow frame delay (SlowDownBall, SpeedUpBall)
+ bool _bottleTaken = false; // +583: the hand has the jar (DoTakeBottle)
+ PictureObject *_bottle = nullptr; // +584: PIC_SC4_BOTTLE
+ AniObject *_hand = nullptr; // +588: ANI_HAND
+ AniObject *_plank = nullptr; // +592: ANI_PLANK
+ AniObject *_clock = nullptr; // +596: ANI_CLOCK
+ AniObject *_spring = nullptr; // +600: ANI_SPRING
+ AniObject *_mumsy = nullptr; // +604: ANI_MAMASHA_4
+ AniObject *_speaker = nullptr; // +608: ANI_SPEAKER_4
+ AniObject *_lamps = nullptr; // +612: ANI_SC4_LAMPS
+ int _speakerVariant = 0; // +616: the row of the table of the speaker phases
+ int _speakerPhase = 0; // +620: the column
+ int _speakerTimer = 0; // +624: the milliseconds that GramoNextFunc has not used yet (83 per step)
+ float _clickHeroX = 0; // +628: the center of the hero when the ladder was clicked
+ float _clickHeroY = 0; // +632
+ bool _clockCanGo = true; // +636: the clock can start (the jar is on the spring)
+ bool _coinPut = false; // +637: the coin is in, the arcade starts
+ float _clickX = 0; // +640: the point of the click on the ladder
+ float _clickY = 0; // +644
+ MctlLadder *_ladder = nullptr; // +648: the ladder controller while the hero is on the ladder
+ bool _manFalls = false; // +652: the hero falls into the jar (OnUpdate calls DoManFall)
+ bool _handIsDown = false; // +653: the hand came down
+ bool _dudeInBottle = false; // +654: the hero sits in the jar
+ bool _kozawHeadRaised = false; // +655: the kozawka raised its head (MakeJumpTo)
+ bool _objectIsTaken = true; // +656
+ bool _ballWalksRight = true; // +657: the next ball rolls on QU_BALL_WALKR
+ int _ballTimer = 0; // +660: the milliseconds since the last ball
+ bool _bottleDropped = false; // +664: the jar falls (DoDropBottle)
+ int _bottleFallSpeed = 0; // +668: the speed of the fall
+ int _bottleWeight = 2; // +672: the weight on the spring
+ int _kozawWeight = 2; // +676: the weight of a kozawka
+ int _springField680 = 10; // +680: set by the constructor, not read in this class
+ int _springOffset = 0; // +684: the speed of the spring (clicks add to it)
+ int _springStep = 1; // +688: the damping step
+ int _springCounter = 0; // +692: the crossings of the weight
+ int _springTimer = 0; // +696: the milliseconds that RecalcSpring has not used yet (83 per step)
+ int _springPos = 0; // +700: the phase of the spring
+ int _springMax = 13; // +704: the last phase
+ bool _musicStopped = false; // +708: MSG_STOP_MUS was handled, the loop must not start again
+ Common::Array<GameObject *> _bottleObjects; // +712: objects that move with the spring
+ float _kozawDelayK = 1.0f; // +724: sc_4_settings.xml KOZAWKA frameDelayK
+ float _kozawStartDelay = 0.0f; // +728: KOZAWKA startDelay (seconds)
+ float _clockDelayK = 1.0f; // +732: CLOCK frameDelayK
+ int _springState = 0; // +736: the stage of the fall of the jar (DoUpdateBottlePositionDown)
+ bool _kozawInBottle = false; // +740: a kozawka sits in the jar (MSG_KOZAWRESTART on leaving)
+ bool _hintPending = false; // +741: MSG_SC4_SHOW_HINT is sent when the hero climbs the ladder
+ bool _coinTaskPending = false; // +742: GET_COIN_SC4 is activated when the jar has landed
+ PictureObject *_arrow = nullptr; // +744: PIC_SC_4_ARROW_1, the arrow of the ladder
+ int _ladderTimer = -1; // +748: the milliseconds since the hero stopped on the ladder, -1 stopped
+ int _blinkTimer = -1; // +752: the arrow wiggles every 174 ms, -1 stopped
+ bool _blinkToggle = false; // +756
+ bool _ladderActed = false; // +757: the hero jumped or the hand started
+ AniObject *_domino = nullptr; // +760: ANI_DOMINO_3
+ bool _demoScroll = false; // +764: demo scroll on the first visit
};
} // End of namespace NGI
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index a2d28209b54..ba0ca4fc3de 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -89,6 +89,7 @@ MODULE_OBJS = \
fullpipe/lift.o \
fullpipe/liftcontroller.o \
fullpipe/notebook.o \
+ fullpipe/sc04controller.o \
fullpipe/scene01.o \
fullpipe/scene02.o \
fullpipe/scene03.o \
Commit: ef17e67929c2665c42f18e5773ddc3b99f8b04be
https://github.com/scummvm/scummvm/commit/ef17e67929c2665c42f18e5773ddc3b99f8b04be
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Scene 6 controller ported
Changed paths:
A engines/ngi/fullpipe/sc06controller.cpp
A engines/ngi/fullpipe/sc06controller.h
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/scenecontrollers.h
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/sc06controller.cpp b/engines/ngi/fullpipe/sc06controller.cpp
new file mode 100644
index 00000000000..a4be086ecd0
--- /dev/null
+++ b/engines/ngi/fullpipe/sc06controller.cpp
@@ -0,0 +1,1251 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/formats/xmlparser.h"
+#include "common/hash-str.h"
+#include "common/hashmap.h"
+
+#include "ngi/ngi.h"
+#include "ngi/behavior.h"
+#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/input.h"
+#include "ngi/interaction.h"
+#include "ngi/messages.h"
+#include "ngi/motion.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/lift.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/sc06controller.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+namespace {
+
+// Android obj.h ST_LBN_3N: the pushed-in normal statics of the button of the third floor (constants.h has the number of the Windows game, 2759)
+const int kLiftButton3 = 23076;
+
+void warnOnce(const char *what) {
+ static Common::HashMap<Common::String, bool> reported;
+ if (!reported.contains(what)) {
+ reported[what] = true;
+ warning("STUB/untested: %s", what);
+ }
+}
+
+// CBaseSettings::SetSaving (CGame +112): the saves are blocked while the arcade runs
+void setSaving(bool) {
+ warnOnce("CBaseSettings::SetSaving (CSc06Controller: the saves are not blocked during the arcade)");
+}
+
+// CHintManager::ShowHint / HideHint / SetHideCondition (the hint glow of the arcade)
+void hintManager(const char *what) {
+ warnOnce(what);
+}
+
+// CAniObject::GetCurFrame (F112C): the frame of the movement, -1 when there is none
+int getCurFrame(const AniObject *ani) {
+ return ani->_movement ? ani->_movement->_curFrame : -1;
+}
+
+// CAniObject::SetCurFrame (F0C76): the movement goes to the frame, when there is one. The flag (a3, CMovement +63: the timer of the phase goes on) is not modelled.
+void setCurFrame(AniObject *ani, int frame, bool keepPhaseTimer) {
+ if (!ani->_movement)
+ return;
+ if (keepPhaseTimer)
+ warnOnce("CAniObject::SetCurFrame: the flag CMovement +63 (the phase timer goes on) is not modelled");
+ ani->_movement->setCurFrame(frame);
+}
+
+// the +164 of the object: the statics that it is in
+int getStaticsId(const AniObject *ani) {
+ return ani->_statics ? ani->_statics->_staticsId : 0;
+}
+
+// CFPController::HideAction (1490B0): the copies of the object from `copy` on lose their movement and are hidden, up to the first copy that does not exist
+void hideAction(Scene *scene, int id, int copy) {
+ AniObject *ani;
+ do {
+ ani = scene->findAniObjectById(id, copy);
+ if (ani) {
+ ani->stopMovement();
+ ani->_flags &= ~4;
+ }
+ ++copy;
+ } while (ani);
+}
+
+// CCommand::CCommand(kind, wait) as the XML loader of the scenes leaves it
+Command *newCommand(int kind, bool wait) {
+ Command *command = new Command();
+ command->_cmd = kind;
+ command->_wait = wait;
+ command->_excFlags = 2;
+ return command;
+}
+
+// START_MOVEMENT with the parameters aniId and moveId
+Command *movementCommand(int aniId, int movementId) {
+ Command *command = newCommand(kCmdStartMovement, true);
+ command->_parentId = aniId;
+ command->_messageNum = movementId;
+ command->_args["aniId"] = Common::String::format("%d", aniId);
+ command->_args["moveId"] = Common::String::format("%d", movementId);
+ return command;
+}
+
+// PAUSE with the parameter delay
+Command *pauseCommand(int delay) {
+ Command *command = newCommand(kCmdPause, true);
+ command->_messageNum = delay;
+ command->_args["delay"] = Common::String::format("%d", delay);
+ return command;
+}
+
+// QUEUE with the parameter id and, when given, interupt
+Command *queueCommand(int queueId, const char *name, const char *interrupt) {
+ Command *command = newCommand(kCmdQueue, true);
+ command->_messageNum = queueId;
+ command->_args["id"] = name;
+ if (interrupt)
+ command->_args["interupt"] = interrupt;
+ return command;
+}
+
+// MESSAGE with the parameter msg (waiting for nothing)
+Command *messageCommand(const char *name) {
+ uint32 id = 0;
+ Command *command = newCommand(kCmdMessage, false);
+ command->_messageName = name;
+ command->_args["msg"] = name;
+ if (g_ngi->_gameProject->_objectIds.findId(name, id))
+ command->_messageNum = id;
+ return command;
+}
+
+// CScene::RunQueueWithAni (1228AE) for a queue that was built here: the object gets the queue and it runs with the interrupt state (CMessageQueue::Run)
+void runQueueWithAni(MessageQueue *queue, AniObject *ani, int interruptState) {
+ if (interruptState != 4)
+ queue->_interruptState = interruptState;
+ if (!queue->run(ani))
+ delete queue;
+}
+
+// CMessageQueue copy ctor + SetObjectCopy + CScene::RunQueue(queue, 4, 0), for this ball copy
+void runQueueForCopy(Scene *scene, int queueId, int copyId) {
+ MessageQueue *queue = scene->findMessageQueue(queueId);
+ if (!queue)
+ return;
+ MessageQueue *copy = new MessageQueue(queue, 0, 0);
+ copy->_scene = scene;
+ copy->setObjectCopy(-1, copyId);
+ if (!copy->run(nullptr))
+ delete copy;
+}
+
+// the original runs the scene's queue itself (-1 before its first command); we run copies
+int getCurCommandNum(const MessageQueue *queue) {
+ warnOnce("CMessageQueue::GetCurCommandNum of a queue of the scene (the engine runs copies of the queues, the template never runs)");
+ return -1;
+}
+
+// CInteractionController::FindInteraction(name) and CMessageQueue +56 of its queue (the number of the command that runs, -1 before the interaction starts):
+// the engine has no interactions by name and runs copies of their queues
+int getInteractionCurCommandNum(const char *name) {
+ warnOnce("CSc06Controller::OnMessage MSG_BREAK_GRIT: CInteractionController::FindInteraction by name (INT_277, INT_229) and the command number of its queue");
+ return -1;
+}
+
+// sc_6_settings.xml (CSc06Controller::ReadSettingsXml)
+class Scene06SettingsParser : public Common::XMLParser {
+public:
+ int _numDrops = 15;
+ int _numDropsToWin = 5;
+ int _momJumpN1 = -3;
+ int _momJumpN2 = 4;
+ float _momJumpDelay = 2.0f;
+
+private:
+ CUSTOM_XML_PARSER(Scene06SettingsParser) {
+ XML_KEY(SETTINGS)
+ XML_KEY(DROPS)
+ XML_PROP(numDrops, false)
+ XML_PROP(numDropsToWin, false)
+ KEY_END()
+ XML_KEY(MOM)
+ XML_PROP(momJumpN1, false)
+ XML_PROP(momJumpN2, false)
+ XML_PROP(momJumpDelay, false)
+ KEY_END()
+ KEY_END()
+ } PARSER_END()
+
+ bool parserCallback_SETTINGS(ParserNode *) {
+ return true;
+ }
+
+ bool parserCallback_DROPS(ParserNode *node) {
+ _numDrops = atoi(node->values.getValOrDefault("numDrops", "15").c_str());
+ _numDropsToWin = atoi(node->values.getValOrDefault("numDropsToWin", "5").c_str());
+ return true;
+ }
+
+ bool parserCallback_MOM(ParserNode *node) {
+ _momJumpN1 = atoi(node->values.getValOrDefault("momJumpN1", "-3").c_str());
+ _momJumpN2 = atoi(node->values.getValOrDefault("momJumpN2", "4").c_str());
+ _momJumpDelay = (float)atof(node->values.getValOrDefault("momJumpDelay", "2.0").c_str());
+ return true;
+ }
+};
+
+} // End of anonymous namespace
+
+// CSc06Controller::CSc06Controller (16AD28): Mumsy's catch region is 100 x 70
+Sc06Controller::Sc06Controller(int sceneId) : FPController(sceneId), _tutorial("PREV_ARCADE_TUTORIAL_06") {
+ _region.createRectRgn(0.0f, 0.0f, 100.0f, 70.0f);
+}
+
+// CSc06Controller::CleanXml (16AC7C)
+void Sc06Controller::cleanXml() {
+ _tutorial = "PREV_ARCADE_TUTORIAL_06";
+}
+
+// CSc06Controller::CanSwipeMan (16AC3C): not while the hero holds a ball in the arcade
+bool Sc06Controller::canSwipeMan(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::canSwipeMan(x, y);
+ if (_arcadeRunning)
+ return !_holdingBall;
+ return true;
+}
+
+// CSc06Controller::OnRemoveCopies (16AC58)
+void Sc06Controller::onRemoveCopies() {
+ _liquidCopy = nullptr;
+}
+
+// CSc06Controller::CanShowHelp (16AC60)
+bool Sc06Controller::canShowHelp() {
+ if (!controllerRunsSceneLogic())
+ return FPController::canShowHelp();
+ if (_arcadeRunning)
+ return !_holdingBall;
+ return true;
+}
+
+// CSc06Controller::MoveLiquid (16AE98): fills the glass, true when full
+bool Sc06Controller::moveLiquid() {
+ const float fraction = (float)(_dropsShown + 1) / (float)_numDrops;
+
+ _liquid->_windowLeft = 0.0f;
+ _liquid->_windowTop = fraction;
+ _liquid->_windowRight = 1.0f;
+ _liquid->_windowBottom = 1.0f;
+ _liquidCopy->_windowLeft = 0.0f;
+ _liquidCopy->_windowTop = 0.0f;
+ _liquidCopy->_windowRight = 1.0f;
+ _liquidCopy->_windowBottom = 0.05f;
+
+ // CVisibleObject::GetY, CPictureObject::GetFullSize, CVisibleObject::GetSize
+ const float top = (float)_liquid->getPosition().y;
+ const float height = (float)_liquid->getFullSize().y * _liquid->_scaleY;
+ const float bottom = top + fraction * height;
+ const float surfaceHeight = ((float)_liquidCopy->getFullSize().y * _liquidCopy->_scaleY) * (_liquidCopy->_windowBottom - _liquidCopy->_windowTop);
+ _liquidCopy->setPosition(Common::Point(_liquidCopy->getPosition().x, (int)(bottom - surfaceHeight)));
+
+ if (fraction >= 1.0f) {
+ _liquid->_flags &= ~4;
+ _liquidCopy->_flags &= ~4;
+ }
+ return fraction >= 1.0f;
+}
+
+// CSc06Controller::TryWalker (16AF40): one chance in ten while at least four balls are to come
+void Sc06Controller::tryWalker() {
+ if (_numDrops - _dropsShown > 3) {
+ if (random31() % 10 == 0) {
+ AniObject *eggie = _scene->findAniObjectById(ANI_EGGIE, 0);
+ if (!eggie || !(eggie->_flags & 4)) {
+ const int queueId = _eggieRight ? QU_EGG6_GOR : QU_EGG6_GOL;
+ _scene->runQueue(queueId, 3);
+ _walkTimer = 0;
+ _eggieRight = !_eggieRight;
+ }
+ }
+ }
+}
+
+// CSc06Controller::TryCreateNextBall (16AFAC): the pipe gives the next ball, or it is done
+void Sc06Controller::tryCreateNextBall() {
+ if (_dropsShown < _numDrops && _ballsCaught < _numDropsToWin) {
+ _scene->runQueue(QU_SC6_DROPS3, 2);
+ return;
+ }
+ _ballDrop->stopMovement();
+ _ballDrop->setStatic(ST_BDP_NORM);
+}
+
+// CSc06Controller::DoShootBall (16AFFC): the ball starts 60 pixels up and left of the hero
+void Sc06Controller::doShootBall() {
+ if (!_ballInHands)
+ return;
+ _flyingBall = _ballInHands;
+ _ballInHands = nullptr;
+ _flyingBall->_flags |= 4;
+ const Common::Point position = hero()->getPosition();
+ const float x = (float)position.x - 60.0f;
+ const float y = (float)position.y - 60.0f;
+ _flyingBall->setPosition(Common::Point((int)x, (int)y));
+ _flyingBall->_z = 27;
+}
+
+// CSc06Controller::StartDragMan (16B064): the hero swings his arm back
+void Sc06Controller::startDragMan() {
+ _manActive = true;
+ _manTimer = 0;
+ hero()->startMovement(MV_MAN6_THROWBALL, 0, -1);
+ setCurFrame(hero(), 0, false);
+ _aiming = true;
+}
+
+// CSc06Controller::DoInstHandle (16B0A8): the handle is put on (MSG_SC6_INSTHANDLE)
+void Sc06Controller::doInstHandle() {
+ if (!_scene->runQueue(QU_SC6_SHOWHANDLE, 4)) {
+ // CLogger::WriteLog(1, ...)
+ warning("sc6::DoShowHandle: m_scene->RunQueue() returned false!");
+ }
+ _button->setStatic(ST_BTN6_ON);
+}
+
+// CSc06Controller::OnPushButton (16B150): the button knocks the plugged handle off
+void Sc06Controller::onPushButton() {
+ _handle = _scene->findAniObjectById(ANI_INV_HANDLE, 0);
+ if (_handle && (_handle->_flags & 4) && getStaticsId(_handle) == ST_HDL_PLUGGED)
+ _scene->runQueue(QU_SC6_FALLHANDLE, 2);
+}
+
+// CSc06Controller::CheckTutorial (16B194): the arcade tutorial comes when Mumsy plays
+void Sc06Controller::checkTutorial() {
+ if (_tutorial == "UNDEF")
+ return;
+ if (g_ngi->_sceneStack.size() != 1)
+ return;
+ if (g_ngi->_tutorialManager->activateTutorial(_tutorial))
+ return;
+ const Common::String previous = _tutorial;
+ if (_tutorial == "PREV_ARCADE_TUTORIAL_06") {
+ if (g_ngi->getStateId(sO_BigMumsy) == g_ngi->getStateValue(sO_BigMumsy, sO_IsPlaying))
+ _tutorial = "ARCADE_TUTORIAL_06";
+ } else {
+ _tutorial = "UNDEF";
+ }
+ if (previous != _tutorial)
+ checkTutorial();
+}
+
+// CSc06Controller::DoUpdatePath (16B2E4): closes the exits (Mumsy away / arcade running)
+void Sc06Controller::doUpdatePath() {
+ MctlCompound *controller = _scene->_motionController.get();
+ const bool gone = g_ngi->getStateId(sO_BigMumsy) == g_ngi->getStateValue(sO_BigMumsy, sO_IsGone);
+ controller->lockLink(sO_CloseThing, !gone);
+ controller->lockLink(sO_CloseThing2, _arcadeRunning);
+}
+
+// CSc06Controller::DoStartDrops (16B3A8): the arcade starts
+void Sc06Controller::doStartDrops() {
+ setSaving(false);
+ _scene->runQueue(QU_SC6_DROPS, 4);
+ _mumsy->setStatic(ST_MOM_SITS);
+ g_ngi->setState(sO_BigMumsy, g_ngi->getStateValue(sO_BigMumsy, sO_IsPlaying));
+ g_ngi->setState(sO_Hint_2_02, g_ngi->getStateValue(sO_Hint_2_02, sO_Enabled));
+ _scene->runQueue(QU_MOM_STANDUP, 2);
+ _scene->_behaviorController->getAniQueue(_mumsy->_id, QU_MOM_JUMPFW)->_delay = (int)((double)_momJumpDelay * 1000.0);
+ _scene->_behaviorController->getAniQueue(_mumsy->_id, QU_MOM_JUMPBK)->_delay = (int)((double)_momJumpDelay * 1000.0);
+ _arcadeRunning = true;
+ _dropsShown = 0;
+ _momPos = 0;
+ _ballsCaught = 0;
+ _ballInBag = false;
+ _liquid->_flags |= 4;
+ _liquidCopy->_flags |= 4;
+ moveLiquid();
+ doUpdatePath();
+}
+
+// CSc06Controller::OnSpinHandle (16B528): the trampoline handle sets Mumsy's state and the arrow
+void Sc06Controller::onSpinHandle() {
+ if (g_ngi->getStateId(sO_TummyTrampie) == g_ngi->getStateValue(sO_TummyTrampie, sO_IsEating)) {
+ g_ngi->setState(sO_TummyTrampie, g_ngi->getStateValue(sO_TummyTrampie, sO_IsSleeping));
+ _arrow->setStatic(ST_SC6_ARROW_4);
+ } else if (g_ngi->getStateId(sO_TummyTrampie) == g_ngi->getStateValue(sO_TummyTrampie, sO_IsDrinking)) {
+ g_ngi->setState(sO_TummyTrampie, g_ngi->getStateValue(sO_TummyTrampie, sO_IsScratchingBelly));
+ _arrow->setStatic(ST_SC6_ARROW_2);
+ } else if (g_ngi->getStateId(sO_TummyTrampie) == g_ngi->getStateValue(sO_TummyTrampie, sO_IsScratchingBelly)) {
+ g_ngi->setState(sO_TummyTrampie, g_ngi->getStateValue(sO_TummyTrampie, sO_IsEating));
+ _arrow->setStatic(ST_SC6_ARROW_3);
+ } else if (g_ngi->getStateId(sO_TummyTrampie) == g_ngi->getStateValue(sO_TummyTrampie, sO_IsSleeping)) {
+ g_ngi->setState(sO_TummyTrampie, g_ngi->getStateValue(sO_TummyTrampie, sO_IsDrinking));
+ _arrow->setStatic(ST_SC6_ARROW_1);
+ }
+
+ if (g_ngi->getStateId(sO_TummyTrampie) == g_ngi->getStateValue(sO_TummyTrampie, sO_IsSleeping)) {
+ if (g_ngi->getStateId(sO_TummyTrampie) != g_ngi->getStateValue(sO_TummyTrampie, sO_IsSleeping))
+ return;
+ g_ngi->_taskManager->deactivateTask("SLEEP_BATUTA_SC8");
+ g_ngi->_taskManager->activateTask("FIND_EXIT_BATUTA_SC8");
+ } else {
+ g_ngi->_taskManager->activateTask("SLEEP_BATUTA_SC8");
+ }
+}
+
+// CSc06Controller::DoManShoot (16B8C8): the throw strength comes from the swing frame
+void Sc06Controller::doManShoot() {
+ if (_ballInHands) {
+ _ballSpeedX = ((float)(getCurFrame(hero()) + 4) * 0.02f) * 4.0f;
+ _ballSpeedY = ((float)(getCurFrame(hero()) + 4) * 0.01f) * 5.0f;
+ int frame = 11;
+ if (getCurFrame(hero()) > 3)
+ frame = 9;
+ setCurFrame(hero(), frame, false);
+ }
+ _powerArrow->_flags &= ~4;
+ _aimAngle = 205.0f;
+ _aimScale = 0.7f;
+ _powerArrow->_rotation = 3.5779249668f;
+ _powerArrow->_scaleX = _aimScale;
+ _powerArrow->_scaleY = 1.0f;
+ _aiming = false;
+ hintManager("CHintManager::SetHideCondition (CSc06Controller::DoManShoot)");
+}
+
+// CSc06Controller::GetCursorTypeTop (16B980): the cursor over Mumsy in the arcade
+int Sc06Controller::getCursorTypeTop(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::getCursorTypeTop(x, y);
+ if (_arcadeRunning && g_ngi->_inputController->isObjectHit(_mumsy))
+ return 0;
+ return -1;
+}
+
+// CSc06Controller::ManNextFunc (16B9A8): every 83 ms; aim frame = strength (distance / 10, max 8),
+// the ball flies at frame 12
+void Sc06Controller::manNextFunc(uint32 elapsed) {
+ const uint32 time = elapsed + _manTimer;
+ if (time > 83) {
+ _manTimer = time - 83;
+ int frame = getCurFrame(hero());
+ bool flag = _aiming;
+ if (_aiming) {
+ CursorController *cursor = g_ngi->_inputController;
+ const float dx = cursor->_hotSceneX - (float)_dragX;
+ const float dy = cursor->_hotSceneY - (float)_dragY;
+ frame = (int)(sqrt((double)dx * (double)dx + (double)(dy * dy)) * 0.1);
+ if (frame > 8)
+ frame = 8;
+ _aimAngle = ((float)frame * 2.2f) + 205.0f;
+ _aimScale = ((float)frame * 0.125f) + 0.7f;
+ flag = false;
+ } else {
+ frame = frame + 1;
+ if (frame == 12) {
+ doShootBall();
+ _manActive = false;
+ _manTimer = 0;
+ flag = true;
+ }
+ }
+ setCurFrame(hero(), frame, flag);
+ } else {
+ _manTimer = time;
+ }
+}
+
+// CSc06Controller::OnUTrubaClick (16BAB8): runs the ladder interaction
+void Sc06Controller::onUTrubaClick() {
+ if (!canInterruptManQueue())
+ return;
+ if (_interactObjectId == PIC_SC6_LADDER)
+ return;
+ if (getGameLoaderInteractionController()->_enabled) {
+ // CInteractionController::FindInteraction(scene, PIC_SC6_LADDER, -1) and CInteract::Run(scene)
+ warnOnce("CSc06Controller::OnUTrubaClick: CInteract::Run (the interaction with the ladder PIC_SC6_LADDER is not run)");
+ }
+}
+
+// CSc06Controller::DoTakeBall (16BAF8): the hero takes the ball, interaction and walking off
+void Sc06Controller::doTakeBall() {
+ if (_dropsShown == 1) {
+ hintManager("CHintManager::ShowHint (CSc06Controller::DoTakeBall)");
+ // CFPController::FlurryArcadeStart("ANI_MAMASHA"): analytics not ported
+ }
+ _holdingBall = true;
+ _scene->_behaviorController->enableAllQueuesForAni(hero(), false);
+ if (_currentBall) {
+ _currentBall->_flags &= ~4;
+ hero()->startMovement(MV_MAN6_TAKEBALL, 0, -1);
+ _ballInHands = _currentBall;
+ _currentBall = nullptr;
+ _scene->_motionController->deactivate();
+ getGameLoaderInteractionController()->disable();
+ }
+ g_ngi->setState(sO_Hint_2_02, 0);
+}
+
+// CSc06Controller::OnBallClick (16BBC4): take the ball at the pipe, else walk there first
+void Sc06Controller::onBallClick() {
+ if (!_currentBall || _currentBall->_movement || getStaticsId(_currentBall) != ST_NBL_NORM)
+ return;
+
+ const Common::Point center = hero()->getCenter();
+ if ((fabsf(1158.0f - (float)center.x) <= 2.0f && fabsf(452.0f - (float)center.y) <= 2.0f && !hero()->_movement && getStaticsId(hero()) == ST_MAN_RIGHT &&
+ (hero()->_flags & 8)) || _holdingBall) {
+ doTakeBall();
+ return;
+ }
+
+ MessageQueue *queue = mctlStartMove(1158, 452, true, ST_MAN_RIGHT, true);
+ if (g_ngi->arcadeInterface().getState() == ArcadeInterface::kHidden) {
+ g_ngi->arcadeInterface().init(450.0f, -100.0f, -64.0f, 0.0f, 5, 0, true);
+ g_ngi->arcadeInterface().scrollIn();
+ }
+ if (queue)
+ queue->addCommandToEnd(messageCommand("MSG_SC6_TAKEBALL"));
+}
+
+// CSc06Controller::DoStopArcade (16BD44): all balls given and none in the air, Mumsy leaves
+void Sc06Controller::doStopArcade() {
+ _scene->_behaviorController->getAniQueue(ANI_MAMASHA, QU_MOM_LOOKEMPTY)->setEnabled(true);
+ _scene->_behaviorController->getAniQueue(ANI_MAMASHA, QU_MOM_OPENEYE)->setEnabled(true);
+ g_ngi->arcadeInterface().scrollOut();
+ _holdingBall = false;
+
+ int takeMovement;
+ switch (_ballsCaught) {
+ case 1:
+ takeMovement = MV_MOM_TAKE1;
+ break;
+ case 2:
+ takeMovement = MV_MOM_TAKE2;
+ break;
+ case 3:
+ takeMovement = MV_MOM_TAKE3;
+ break;
+ case 4:
+ takeMovement = MV_MOM_TAKE4;
+ break;
+ case 5:
+ takeMovement = MV_MOM_TAKE5;
+ break;
+ default:
+ takeMovement = 0;
+ break;
+ }
+
+ MessageQueue *queue = new MessageQueue(_scene, true, 1);
+ queue->addCommandToEnd(pauseCommand(50));
+ if (_ballsCaught < _numDropsToWin) {
+ warnOnce("CAchievementsManager::BlockActivatingCounter ACHIEVEMENT_ARCADE_6 (achievements are not ported)");
+ if (takeMovement != 0)
+ queue->addCommandToEnd(movementCommand(ANI_MAMASHA, takeMovement));
+ if (_momPos <= 0) {
+ int jump = 0;
+ if (_momPos != 0) {
+ while (jump > _momPos) {
+ queue->addCommandToEnd(movementCommand(ANI_MAMASHA, MV_MOM_JUMPFW));
+ --jump;
+ }
+ }
+ } else {
+ for (int i = 0; i < _momPos; ++i)
+ queue->addCommandToEnd(movementCommand(ANI_MAMASHA, MV_MOM_JUMPBK));
+ }
+ queue->addCommandToEnd(queueCommand(QU_MOM_SITDOWN, "QU_MOM_SITDOWN", nullptr));
+ // CFlurryEventManager lose_count/game_..._lose, FlurryArcadeClean: analytics not ported
+ } else {
+ warnOnce("CAchievementsManager::AddActivatingCounter ACHIEVEMENT_ARCADE_6 (achievements are not ported)");
+ g_ngi->setState(sO_BigMumsy, g_ngi->getStateValue(sO_BigMumsy, sO_IsGone));
+ if (g_ngi->getStateId(sO_ClockAxis) == g_ngi->getStateValue(sO_ClockAxis, sO_IsNotAvailable))
+ g_ngi->setState(sO_ClockAxis, g_ngi->getStateValue(sO_ClockAxis, sO_WithoutHandle));
+ queue->addCommandToEnd(movementCommand(ANI_MAMASHA, takeMovement));
+ if (_momPos >= -3) {
+ queue->addCommandToEnd(movementCommand(ANI_MAMASHA, MV_MOM_STARTBK));
+ for (int j = 0; _momPos + 2 >= j; ++j)
+ queue->addCommandToEnd(movementCommand(ANI_MAMASHA, MV_MOM_CYCLEBK));
+ queue->addCommandToEnd(movementCommand(ANI_MAMASHA, MV_MOM_STOPBK));
+ }
+ queue->addCommandToEnd(queueCommand(QU_MOM_TOLIFT, "QU_MOM_TOLIFT", "never"));
+ g_ngi->setState(sO_Hint_2_03, g_ngi->getStateValue(sO_Hint_2_03, sO_Enabled));
+ g_ngi->_taskManager->deactivateTask("GET_DEVICE_SC6");
+ // CFPController::FlurryArcadeEnd("ANI_MAMASHA"): the analytics are not ported
+ }
+ _mumsy->stopMovementToPrev(false);
+ runQueueWithAni(queue, _mumsy, 2);
+ _scene->_behaviorController->enableAllQueuesForAni(hero(), true);
+ _ballsCaught = 0;
+ _arcadeRunning = false;
+ _follow = nullptr;
+ hintManager("CHintManager::HideHint (CSc06Controller::DoStopArcade)");
+ g_ngi->setState(sO_Hint_2_02, 0);
+ setSaving(true);
+}
+
+// CSc06Controller::DoShowNextBall (16C534)
+void Sc06Controller::doShowNextBall() {
+ if (_balls.empty())
+ return;
+ _currentBall = _balls.remove_at(0);
+ runQueueForCopy(_scene, QU_SC6_SHOWNEXTBALL, _currentBall->_copyId);
+ ++_dropsShown;
+}
+
+// CSc06Controller::SkipArcade (16C5A4): skip button or Q; waits (+213) if a ball is out
+void Sc06Controller::skipArcade() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::skipArcade();
+ return;
+ }
+ g_ngi->arcadeInterface().scrollOut();
+ if (_ballsCaught == _numDropsToWin)
+ return;
+ if (_flyingBall) {
+ _skipArcade = true;
+ return;
+ }
+ MessageQueue *drops = _scene->findMessageQueue(QU_SC6_DROPS3);
+ if (drops && getCurCommandNum(drops) != -1 && _ballInBag) {
+ if (getCurCommandNum(drops) == 0) {
+ // ANI_BALLDROP plays backwards: CMovement +61 set, +92 = frame count - 1 - itself
+ warnOnce("CSc06Controller::SkipArcade: the movement of ANI_BALLDROP is turned back (CMovement +61, +92)");
+ }
+ _skipArcade = true;
+ return;
+ }
+ if (_ballInBag) {
+ _skipArcade = true;
+ return;
+ }
+ if (_ballInHands) {
+ hero()->setStatic(ST_MAN_RIGHT);
+ hero()->_flags |= 8;
+ _ballInHands->_flags &= ~4;
+ _balls.push_back(_ballInHands);
+ _ballInHands = nullptr;
+ }
+ _skipArcade = false;
+ _scene->_behaviorController->getAniQueue(ANI_MAMASHA, QU_MOM_LOOKEMPTY)->setEnabled(true);
+ _scene->_behaviorController->getAniQueue(ANI_MAMASHA, QU_MOM_OPENEYE)->setEnabled(true);
+ _holdingBall = false;
+
+ int takeMovement;
+ switch (_ballsCaught) {
+ case 1:
+ takeMovement = MV_MOM_TAKE1;
+ break;
+ case 2:
+ takeMovement = MV_MOM_TAKE2;
+ break;
+ case 3:
+ takeMovement = MV_MOM_TAKE3;
+ break;
+ case 4:
+ takeMovement = MV_MOM_TAKE4;
+ break;
+ case 5:
+ takeMovement = MV_MOM_TAKE5;
+ break;
+ default:
+ takeMovement = 0;
+ break;
+ }
+
+ MessageQueue *queue = new MessageQueue(_scene, true, 1);
+ queue->addCommandToEnd(pauseCommand(50));
+ g_ngi->setState(sO_BigMumsy, g_ngi->getStateValue(sO_BigMumsy, sO_IsGone));
+ if (g_ngi->getStateId(sO_ClockAxis) == g_ngi->getStateValue(sO_ClockAxis, sO_IsNotAvailable))
+ g_ngi->setState(sO_ClockAxis, g_ngi->getStateValue(sO_ClockAxis, sO_WithoutHandle));
+ if (takeMovement != 0)
+ queue->addCommandToEnd(movementCommand(ANI_MAMASHA, takeMovement));
+ if (_momPos >= -3) {
+ queue->addCommandToEnd(movementCommand(ANI_MAMASHA, MV_MOM_STARTBK));
+ for (int i = 0; _momPos + 2 >= i; ++i)
+ queue->addCommandToEnd(movementCommand(ANI_MAMASHA, MV_MOM_CYCLEBK));
+ queue->addCommandToEnd(movementCommand(ANI_MAMASHA, MV_MOM_STOPBK));
+ }
+ queue->addCommandToEnd(queueCommand(QU_MOM_TOLIFT, "QU_MOM_TOLIFT", "never"));
+ g_ngi->setState(sO_Hint_2_03, g_ngi->getStateValue(sO_Hint_2_03, sO_Enabled));
+ g_ngi->_taskManager->deactivateTask("GET_DEVICE_SC6");
+ // CFPController::FlurryArcadeSkip("ANI_MAMASHA"): the analytics are not ported
+ _mumsy->stopMovementToPrev(false);
+ runQueueWithAni(queue, _mumsy, 2);
+ _scene->_behaviorController->enableAllQueuesForAni(hero(), true);
+ _ballsCaught = 0;
+ _arcadeRunning = false;
+ _follow = nullptr;
+ hintManager("CHintManager::HideHint (CSc06Controller::SkipArcade)");
+ g_ngi->setState(sO_Hint_2_02, 0);
+ setSaving(true);
+}
+
+// CSc06Controller::DoTakeLastDrop (16CAB0)
+void Sc06Controller::doTakeLastDrop() {
+ if (_currentBall) {
+ _currentBall->startMovement(MV_NBL_OUT, 0, -1);
+ _balls.push_back(_currentBall);
+ _currentBall = nullptr;
+ }
+ if (_arcadeRunning && _dropsShown < _numDrops) {
+ _scene->runQueue(QU_SC6_DROPS2, 4);
+ return;
+ }
+ _ballDrop->stopMovement();
+ _ballDrop->setStatic(ST_BDP_NORM);
+}
+
+// CSc06Controller::DoFallBall (16CB38): the missed ball falls to y 475 and returns to the pool
+void Sc06Controller::doFallBall() {
+ _ballY = 475.0f;
+ _flyingBall->setCenter(Common::Point((int)_ballX, (int)475.0f));
+ runQueueForCopy(_scene, QU_SC6_FALLBALL, _flyingBall->_copyId);
+ _balls.push_back(_flyingBall);
+ _flyingBall = nullptr;
+ if (!_skipArcade)
+ tryCreateNextBall();
+ tryWalker();
+}
+
+// CSc06Controller::PutBallToBag (16CBC0): finishes a running jump, then bags the ball
+void Sc06Controller::putBallToBag() {
+ if (!_flyingBall)
+ return;
+ _flyingBall->_flags &= ~4;
+ _balls.push_back(_flyingBall);
+ _flyingBall = nullptr;
+ ++_ballsCaught;
+ if (!_mumsy->_movement || (uint)((_mumsy->_movement->_id) - MV_MOM_JUMPFW) > 1) {
+ _mumsy->setStatic(ST_MOM_STANDS);
+ } else {
+ float moveX = 0.0f;
+ float moveY = 0.0f;
+ bool done = false;
+ if (_mumsy->_movement->_id == MV_MOM_JUMPFW) {
+ if (getCurFrame(_mumsy) > 5) {
+ const Common::Point size = _mumsy->_movement->getCenterMovementSize(1, -1);
+ moveX = (float)size.x;
+ moveY = (float)size.y;
+ ++_momPos;
+ done = true;
+ }
+ } else if (getCurFrame(_mumsy) > 4) {
+ const Common::Point size = _mumsy->_movement->getCenterMovementSize(1, -1);
+ moveX = (float)size.x;
+ moveY = (float)size.y;
+ --_momPos;
+ done = true;
+ }
+ if (!done) {
+ const Common::Point size = _mumsy->_movement->getCenterMovementSize(0, getCurFrame(_mumsy));
+ moveX = -(float)size.x;
+ moveY = -(float)size.y;
+ }
+ const Common::Point center = _mumsy->getCenter();
+ const float x = (float)center.x + moveX;
+ const float y = (float)center.y + moveY;
+ _mumsy->setStatic(ST_MOM_STANDS);
+ _mumsy->setCenter(Common::Point((int)x, (int)y));
+ }
+ _scene->runQueue(QU_MOM_PUTBALL, 2);
+ _ballInBag = true;
+ if (!_skipArcade)
+ tryCreateNextBall();
+}
+
+// CSc06Controller::TestBallFlight (16CD14): caught in the region at Mumsy, lost below the floor
+void Sc06Controller::testBallFlight() {
+ if (_ballY <= 475.0f) {
+ const Common::Point center = _mumsy->getCenter();
+ _region.moveRegionTo((float)center.x + 20.0f, (float)center.y + 0.0f);
+ if (_region.ptInRegion(_ballX, _ballY)) {
+ // CFlurryEventManager first_move/total_moves: analytics not ported
+ putBallToBag();
+ g_ngi->arcadeInterface().incCounter();
+ }
+ } else {
+ doFallBall();
+ // CFlurryEventManager failcount/first_move/total_moves: analytics not ported
+ }
+}
+
+// CSc06Controller::DoWinArcade (16CEA0): MSG_CMN_WINARCADE (and key W)
+void Sc06Controller::doWinArcade() {
+ g_ngi->setState(sO_BigMumsy, g_ngi->getStateValue(sO_BigMumsy, sO_IsGone));
+ if (g_ngi->getStateId(sO_ClockAxis) == g_ngi->getStateValue(sO_ClockAxis, sO_IsNotAvailable))
+ g_ngi->setState(sO_ClockAxis, g_ngi->getStateValue(sO_ClockAxis, sO_WithoutHandle));
+ if (_arcadeRunning) {
+ _manActive = false;
+ _manTimer = 0;
+ hero()->setStatic(ST_MAN_RIGHT);
+ hero()->_flags |= 8;
+ if (_spareBall) {
+ _spareBall->_flags &= ~4;
+ _balls.push_back(_spareBall);
+ _spareBall = nullptr;
+ }
+ if (_flyingBall) {
+ _flyingBall->_flags &= ~4;
+ _balls.push_back(_flyingBall);
+ _flyingBall = nullptr;
+ }
+ if (_ballInHands) {
+ _ballInHands->_flags &= ~4;
+ _balls.push_back(_ballInHands);
+ _ballInHands = nullptr;
+ }
+ _arcadeRunning = false;
+ _aiming = false;
+ }
+ _mumsy->_flags &= ~4;
+ doUpdatePath();
+ _scene->_motionController->activate();
+ getGameLoaderInteractionController()->enable();
+ _scene->_behaviorController->enableAllQueuesForAni(hero(), true);
+ hintManager("CHintManager::HideHint (CSc06Controller::DoWinArcade)");
+ g_ngi->setState(sO_Hint_2_02, 0);
+ g_ngi->_taskManager->deactivateTask("GET_DEVICE_SC6");
+ setSaving(true);
+}
+
+// CSc06Controller::OnSceneInit (16D0D0): objects, Mumsy's jump queues and their percents
+void Sc06Controller::onSceneInit() {
+ FPController::onSceneInit();
+ _mumsy = _scene->findAniObjectById(ANI_MAMASHA, 0);
+ _handle = _scene->findAniObjectById(ANI_INV_HANDLE, 0);
+ _button = _scene->findAniObjectById(ANI_BUTTON_6, 0);
+ _ballDrop = _scene->findAniObjectById(ANI_BALLDROP, 0);
+ _liquid = _scene->findPictureObjectById(PIC_SC6_LIQUID, 0);
+ _liquidCopy = _scene->findPictureObjectById(PIC_SC6_LIQUID, 1);
+ _powerArrow = _scene->findPictureObjectById(PIC_POWER_ARROW, 0);
+ _jumpFwQueue = _scene->_behaviorController->getAniQueue(_mumsy->_id, QU_MOM_JUMPFW);
+ _jumpBkQueue = _scene->_behaviorController->getAniQueue(_mumsy->_id, QU_MOM_JUMPBK);
+ _jumpFwPercent = _jumpFwQueue->_percent;
+ _jumpBkPercent = _jumpBkQueue->_percent;
+}
+
+// CSc06Controller::ReadSettingsXml (16D17C): data/sc_6_settings.xml, values stay when unreadable
+void Sc06Controller::readSettingsXml() {
+ Scene06SettingsParser settings;
+ if (!settings.loadFile("data/sc_6_settings.xml") || !settings.parse()) {
+ warning("Could not read sc_6_settings.xml");
+ return;
+ }
+ _numDrops = settings._numDrops;
+ _numDropsToWin = settings._numDropsToWin;
+ _momJumpN1 = settings._momJumpN1;
+ _momJumpN2 = settings._momJumpN2;
+ _momJumpDelay = settings._momJumpDelay;
+}
+
+// CSc06Controller::OnShow (16D2B4): camera margins; the rest is scene logic
+void Sc06Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+ if (!controllerRunsSceneLogic())
+ return;
+
+ warnOnce("CHelp::SetChapter (CSc06Controller::OnShow)");
+ g_ngi->_chapterManager->setActiveChapter(2);
+ if (!g_ngi->_taskManager->isSceneVisited(_scene->_sceneId)) {
+ g_ngi->_chapterManager->showChapterDialog("CHAPTER_2", true);
+ g_ngi->_taskManager->activateTask("GET_DEVICE_SC6");
+ }
+ g_ngi->_taskManager->visitScene(_scene->_sceneId);
+ _arrow = _scene->findAniObjectById(ANI_SC6_ARROW, 0);
+ _arrow->_objectFlags |= 8;
+ _numDrops = 15;
+ _numDropsToWin = 5;
+ _momJumpN1 = -3;
+ _momJumpN2 = 4;
+ _momJumpDelay = 2.0f;
+ readSettingsXml();
+ _holdingBall = false;
+ _aimAngle = 205.0f;
+ _aimScale = 0.7f;
+ _powerArrow->_rotation = 3.5779249668f;
+ _powerArrow->_scaleX = _aimScale;
+ _powerArrow->_scaleY = 1.0f;
+ _powerArrow->setPosition(Common::Point(980, 390));
+ const Common::Point arrowCenter = _powerArrow->getCenter();
+ _arrowX = (float)arrowCenter.x;
+ _arrowY = (float)arrowCenter.y;
+ if (!_liquidCopy) {
+ _liquidCopy = new PictureObject(_liquid);
+ _scene->addPicture(_liquidCopy);
+ }
+ _arcadeRunning = false;
+ _aiming = false;
+ _currentBall = nullptr;
+ _ballInHands = nullptr;
+ _flyingBall = nullptr;
+ _dropsShown = 0;
+ _balls.clear();
+ _ballsCaught = 0;
+ _walkTimer = 0;
+ _eggieRight = true;
+ AniObject *ball = _scene->findAniObjectById(ANI_NEWBALL, 0);
+ ball->_flags &= ~4;
+ ball->setStatic(ST_NBL_NORM);
+ _ballDrop->setStatic(ST_BDP_NORM);
+ _ballDrop->setPosition(Common::Point(1059, 162));
+ _ballDrop->_z = 27;
+ _ballDrop->_flags |= 4;
+ _balls.push_back(ball);
+ for (int i = 3; i != 0; --i) {
+ AniObject *copy = new AniObject(ball);
+ copy->_flags &= ~4;
+ copy->setStatic(ST_NBL_NORM);
+ _scene->addAni(copy, true);
+ _balls.push_back(copy);
+ }
+ if (g_ngi->getStateId(sO_BigMumsy) == g_ngi->getStateValue(sO_BigMumsy, sO_IsPlaying))
+ g_ngi->setState(sO_BigMumsy, g_ngi->getStateValue(sO_BigMumsy, sO_IsSleeping));
+ if (g_ngi->getStateId(sO_BigMumsy) != g_ngi->getStateValue(sO_BigMumsy, sO_IsSleeping))
+ _mumsy->_flags &= ~4;
+ g_ngi->lift().enableButton(sO_Level3, kLiftButton3);
+ g_ngi->lift().initLift(_scene, hero(), QU_SC6_ENTERLIFT, QU_SC6_EXITLIFT);
+ doUpdatePath();
+ _scene->findAniObjectById(ANI_MAMASHA, 0)->setStatic(ST_MOM_SITS);
+ _scene->findAniObjectById(ANI_MAMASHA, 0)->setPosition(Common::Point(660, 378));
+ _scene->_behaviorController->getAniQueue(ANI_MAMASHA, QU_MOM_LOOKEMPTY)->setEnabled(true);
+ _scene->_behaviorController->getAniQueue(ANI_MAMASHA, QU_MOM_OPENEYE)->setEnabled(true);
+ warnOnce("CCatalogManager::UnlockItem ANI_MAMASHA (the catalog is not ported)");
+}
+
+// CSc06Controller::OnHide (16D74C)
+void Sc06Controller::onHide() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onHide();
+ return;
+ }
+ // CFPController::FlurryArcadeClean("ANI_MAMASHA"): the analytics are not ported
+ if (g_ngi->arcadeInterface().getState() != ArcadeInterface::kHidden)
+ g_ngi->arcadeInterface().scrollOut();
+ setSaving(true);
+ hideAction(_scene, ANI_NEWBALL, 1);
+ hideAction(_scene, ANI_EGGIE, 0);
+ _scene->_behaviorController->enableAllQueuesForAni(hero(), true);
+ g_ngi->setState(sO_Hint_2_02, 0);
+ _dropsShown = -1;
+ moveLiquid();
+ hintManager("CHintManager::HideHint (CSc06Controller::OnHide)");
+ if (_arcadeRunning) {
+ // CFlurryEventManager lose_count/game_..._lose: analytics not ported
+ }
+ FPController::onHide();
+}
+
+// CSc06Controller::OnKeyUp (16D9C8): W wins the arcade, Q skips it
+void Sc06Controller::onKeyUp(uint32 key) {
+ FPController::onKeyUp(key);
+ if (!controllerRunsSceneLogic())
+ return;
+ if (key == 87)
+ doWinArcade();
+ else if (key == 81)
+ skipArcade();
+}
+
+// CSc06Controller::OnMouseLKeyDown (16D9EE): on the hero with the ball he starts to aim
+bool Sc06Controller::onMouseLKeyDown(uint32 id, float x, float y) {
+ const bool result = FPController::onMouseLKeyDown(id, x, y);
+ if (!controllerRunsSceneLogic())
+ return result;
+ if (!result && _ballInHands) {
+ CursorController *cursor = g_ngi->_inputController;
+ if (cursor->isObjectHit(hero()) && !hero()->_movement && getStaticsId(hero()) == ST_MAN6_BALL) {
+ _dragX = (int)cursor->_hotSceneX;
+ _dragY = (int)cursor->_hotSceneY;
+ startDragMan();
+ return true;
+ }
+ }
+ return result;
+}
+
+// CSc06Controller::OnMouseLKeyUp (16DA4E)
+bool Sc06Controller::onMouseLKeyUp(uint32 id, float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::onMouseLKeyUp(id, x, y);
+
+ bool result;
+ bool onBall = false;
+ _touching = false;
+ GameObject *hit = g_ngi->_inputController->getInteractHitObject();
+ if (hit) {
+ if (_currentBall == hit) {
+ onBall = true;
+ if (_dropsShown == 1)
+ onBallClick();
+ }
+ }
+ if (_aiming) {
+ doManShoot();
+ result = true;
+ } else if (onBall) {
+ result = true;
+ } else if (_holdingBall) {
+ result = FPController::onMouseLKeyUp(id, x, y);
+ } else {
+ result = g_ngi->lift().onButtonUp(x, y);
+ if (!result)
+ result = FPController::onMouseLKeyUp(id, x, y);
+ }
+ if (_arcadeRunning && _mumsy == hit)
+ return true;
+ return result;
+}
+
+// CSc06Controller::GetCursorType (16DAE4): lift, then the aim cursor over hero or ball
+int Sc06Controller::getCursorType(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::getCursorType(x, y);
+ if (g_ngi->lift().getCursorType(x, y))
+ return 116;
+ if (!_arcadeRunning)
+ return FPController::getCursorType(x, y);
+ if (_aiming)
+ return 107;
+ if (g_ngi->_inputController->isObjectHit(hero())) {
+ if (getStaticsId(hero()) != ST_MAN6_BALL)
+ return FPController::getCursorType(x, y);
+ } else if (!g_ngi->_inputController->isObjectHit(_currentBall)) {
+ return FPController::getCursorType(x, y);
+ }
+ return 1;
+}
+
+// CSc06Controller::OnUpdate (16DB5C): jump percent, egg, ball flight, swing, end of arcade
+void Sc06Controller::onUpdate(uint32 elapsed) {
+ FPController::onUpdate(elapsed);
+ if (!controllerRunsSceneLogic())
+ return;
+
+ if (_arcadeRunning) {
+ _jumpBkQueue->_percent = _momPos > _momJumpN1 ? _jumpBkPercent : 0;
+ _jumpFwQueue->_percent = _momPos < _momJumpN2 ? _jumpFwPercent : 0;
+ if (_aiming) {
+ ++_walkTimer;
+ if (_walkTimer > 599)
+ tryWalker();
+ }
+ } else {
+ _jumpFwQueue->_percent = 0;
+ _jumpBkQueue->_percent = 0;
+ }
+ if (_flyingBall) {
+ const Common::Point center = _flyingBall->getCenter();
+ _ballX = (float)center.x;
+ _ballY = (float)center.y;
+ const float time = (float)elapsed;
+ _ballX = _ballX - (time * _ballSpeedX);
+ _ballY = _ballY - (time * _ballSpeedY);
+ _flyingBall->setCenter(Common::Point((int)_ballX, (int)_ballY));
+ const float slowdown = time * 0.001f;
+ if (_ballSpeedX >= slowdown)
+ _ballSpeedX = _ballSpeedX - slowdown;
+ _ballSpeedY = _ballSpeedY - (time * 0.002f);
+ testBallFlight();
+ }
+ if (_manActive)
+ manNextFunc(elapsed);
+ if (_arcadeRunning && !_currentBall && !_ballInHands && !_flyingBall && _dropsShown >= _numDrops && !_ballDrop->_movement && !_mumsy->_movement &&
+ !_ballInBag)
+ doStopArcade();
+}
+
+// CSc06Controller::OnRender (16DCD0): arcade interface and the strength arrow
+void Sc06Controller::onRender(Common::Point scroll) {
+ FPController::onRender(scroll);
+ if (!controllerRunsSceneLogic())
+ return;
+ if (g_ngi->arcadeInterface().getState() != ArcadeInterface::kHidden)
+ g_ngi->arcadeInterface().render(Common::Point());
+ if (_powerArrow && _aiming && _manActive) {
+ _powerArrow->_rotation = (float)((double)_aimAngle * 3.14159265358979 / 180.0);
+ _powerArrow->_scaleX = _aimScale;
+ _powerArrow->_scaleY = 1.0f;
+ _powerArrow->setCenter(Common::Point((int)_arrowX, (int)_arrowY));
+ }
+}
+
+// CSc06Controller::UpdateScroll (16DD68): at the pipe (x > 1088, y < 470) the camera keeps the hero
+void Sc06Controller::updateScroll() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::updateScroll();
+ return;
+ }
+ if (!_follow)
+ return;
+ const Common::Point center = _follow->getCenter();
+ _heroCenterX = (float)center.x;
+ _heroCenterY = (float)center.y;
+ if (!_arcadeRunning || _heroCenterY > 470.0f || _heroCenterX < 1088.0f) {
+ FPController::updateScroll();
+ return;
+ }
+ const float sceneX = (float)_scene->_x;
+ const float width = (float)g_ngi->gameWidth();
+ if (_heroCenterX >= sceneX + 600.0f) {
+ if (_heroCenterX > (sceneX + width) - 50.0f)
+ _targetX = (_heroCenterX - (sceneX + width)) + 70.0f;
+ } else {
+ _targetX = (_heroCenterX - sceneX) - 700.0f;
+ }
+ limitScroll();
+ testScroll();
+}
+
+// CSc06Controller::OnMessage (16DE4C)
+void Sc06Controller::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onMessage(message, param, queue);
+ return;
+ }
+ if (message == "MSG_SC6_START_DROP")
+ moveLiquid();
+ if (message == "MSG_SC6_TAKEBALL") {
+ onBallClick();
+ return;
+ }
+ if (message == "MSG_SC6_SHOWNEXTBALL") {
+ doShowNextBall();
+ return;
+ }
+ if (message == "MSG_SC6_INSTHANDLE") {
+ doInstHandle();
+ return;
+ }
+ if (message == "MSG_SPINHANDLE") {
+ onSpinHandle();
+ return;
+ }
+ if (message == "MSG_SC6_BTNPUSH") {
+ onPushButton();
+ return;
+ }
+ if (message == "MSG_SC6_UTRUBACLICK") {
+ onUTrubaClick();
+ return;
+ }
+ if (message == "MSG_SC6_STARTDROPS") {
+ if (g_ngi->getStateId(sO_BigMumsy) != g_ngi->getStateValue(sO_BigMumsy, sO_IsSleeping))
+ return;
+ doStartDrops();
+ return;
+ }
+ if (message == "MSG_SC6_ENABLEDROPS") {
+ doStartDrops();
+ return;
+ }
+ if (message == "MSG_SC6_BEARDEDTAKEBALL") {
+ if (_dropsShown >= _numDrops) {
+ _ballDrop->stopMovement();
+ _ballDrop->setStatic(ST_BDP_NORM);
+ }
+ return;
+ }
+ if (message == "MSG_SC6_TESTNUMBALLS") {
+ _ballInBag = false;
+ if (_ballsCaught >= _numDropsToWin && _arcadeRunning) {
+ doStopArcade();
+ return;
+ }
+ if (_skipArcade)
+ skipArcade();
+ return;
+ }
+ if (message == "MSG_SC6_RESTORESCROLL") {
+ _follow = hero();
+ _scene->_motionController->activate();
+ getGameLoaderInteractionController()->enable();
+ doUpdatePath();
+ return;
+ }
+ if (message == "MSG_SC6_SLEEP_MAMASHA") {
+ g_ngi->setState(sO_BigMumsy, g_ngi->getStateValue(sO_BigMumsy, sO_IsSleeping));
+ return;
+ }
+ if (message == "MSG_SC6_JUMPFW") {
+ ++_momPos;
+ return;
+ }
+ if (message == "MSG_SC6_JUMPBK") {
+ --_momPos;
+ return;
+ }
+ if (message == "MSG_CMN_WINARCADE") {
+ doWinArcade();
+ return;
+ }
+ if (message == "MSG_SC6_DISABLE_MAMASHA_IDLE") {
+ _scene->_behaviorController->getAniQueue(ANI_MAMASHA, QU_MOM_LOOKEMPTY)->setEnabled(false);
+ _scene->_behaviorController->getAniQueue(ANI_MAMASHA, QU_MOM_OPENEYE)->setEnabled(false);
+ return;
+ }
+ if (message != "MSG_BREAK_GRIT") {
+ if (message == "MSG_SC6_END_FALL") {
+ if (_skipArcade)
+ skipArcade();
+ return;
+ }
+ FPController::onMessage(message, param, queue);
+ return;
+ }
+
+ // MSG_BREAK_GRIT: breaks (INT_229) or falls (INT_277) once its interaction has started
+ AniObject *grit;
+ if (getInteractionCurCommandNum("INT_277") == -1) {
+ if (getInteractionCurCommandNum("INT_229") == -1)
+ return;
+ grit = _scene->findAniObjectById(ANI_GRIT_6, 0);
+ if (!grit->_movement) {
+ grit->startMovement(MV_GRT6_BREAK, 0, -1);
+ return;
+ }
+ setCurFrame(grit, 9, true);
+ } else {
+ grit = _scene->findAniObjectById(ANI_GRIT1, 0);
+ if (!grit->_movement) {
+ grit->startMovement(MV_GRIT1_FALL, 0, -1);
+ return;
+ }
+ setCurFrame(grit, 7, true);
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sc06controller.h b/engines/ngi/fullpipe/sc06controller.h
new file mode 100644
index 00000000000..82f7094ffed
--- /dev/null
+++ b/engines/ngi/fullpipe/sc06controller.h
@@ -0,0 +1,135 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SC06CONTROLLER_H
+#define NGI_FULLPIPE_SC06CONTROLLER_H
+
+#include "common/array.h"
+#include "common/str.h"
+
+#include "ngi/region.h"
+#include "ngi/fullpipe/fpcontroller.h"
+
+namespace NGI {
+
+class PictureObject;
+struct BehaviorMove;
+
+/** CSc06Controller: the arcade of scene 6 (scene logic only if controllerRunsSceneLogic()) */
+class Sc06Controller : public FPController {
+public:
+ explicit Sc06Controller(int sceneId);
+
+ void cleanXml() override;
+ bool canSwipeMan(float x, float y) override;
+ bool canShowHelp() override;
+ void skipArcade() override;
+ void checkTutorial() override;
+ void onRemoveCopies() override;
+ void onSceneInit() override;
+ void onShow() override;
+ void onHide() override;
+ void onKeyUp(uint32 key) override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ int getCursorType(float x, float y) override;
+ int getCursorTypeTop(float x, float y) override;
+ void onUpdate(uint32 elapsed) override;
+ void onRender(Common::Point scroll) override;
+ void updateScroll() override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+
+ bool moveLiquid();
+ void tryWalker();
+ void tryCreateNextBall();
+ void doShootBall();
+ void startDragMan();
+ void doInstHandle();
+ void onPushButton();
+ void doUpdatePath();
+ void doStartDrops();
+ void onSpinHandle();
+ void doManShoot();
+ void manNextFunc(uint32 elapsed);
+ void onUTrubaClick();
+ void doTakeBall();
+ void onBallClick();
+ void doStopArcade();
+ void doShowNextBall();
+ void doTakeLastDrop();
+ void doFallBall();
+ void putBallToBag();
+ void testBallFlight();
+ void doWinArcade();
+ void readSettingsXml();
+
+private:
+ /** +216: the next tutorial of the scene */
+ Common::String _tutorial;
+ int _numDrops = 15; // +220: balls that fall out of the pipe in a game (sc_6_settings.xml)
+ int _numDropsToWin = 5; // +224: the balls that Mumsy has to catch (numDropsToWin)
+ int _momJumpN1 = -3; // +228: QU_MOM_JUMPBK is on while _momPos is above this (momJumpN1)
+ int _momJumpN2 = 4; // +232: QU_MOM_JUMPFW is on while her position is below this (momJumpN2)
+ float _momJumpDelay = 2.0f; // +236: the seconds between her jumps (momJumpDelay)
+ AniObject *_arrow = nullptr; // +240: ANI_SC6_ARROW
+ bool _manActive = false; // +244: the hero's throwing animation is stepped by ManNextFunc
+ uint32 _manTimer = 0; // +248: the milliseconds since the last step of ManNextFunc (83 ms each)
+ AniObject *_mumsy = nullptr; // +252: ANI_MAMASHA
+ AniObject *_spareBall = nullptr; // +256: never assigned in the original
+ AniObject *_currentBall = nullptr; // +260: the ball that the pipe gave (it waits to be taken)
+ AniObject *_ballInHands = nullptr; // +264: the ball that the hero holds
+ AniObject *_flyingBall = nullptr; // +268: the ball that flies
+ AniObject *_handle = nullptr; // +272: ANI_INV_HANDLE
+ AniObject *_button = nullptr; // +276: ANI_BUTTON_6
+ AniObject *_ballDrop = nullptr; // +280: ANI_BALLDROP (the pipe where the balls come out)
+ PictureObject *_liquid = nullptr; // +284: PIC_SC6_LIQUID
+ PictureObject *_liquidCopy = nullptr; // +288: copy 1 (the surface), made by OnShow
+ PictureObject *_powerArrow = nullptr; // +292: PIC_POWER_ARROW
+ BehaviorMove *_jumpFwQueue = nullptr; // +296: the queue QU_MOM_JUMPFW of Mumsy
+ BehaviorMove *_jumpBkQueue = nullptr; // +300: QU_MOM_JUMPBK
+ uint32 _jumpFwPercent = 0; // +304: the percent of the queue as the scene has it
+ uint32 _jumpBkPercent = 0; // +308
+ bool _aiming = false; // +312: the hero is aiming (the button is down on him)
+ // +313: a flag that the constructor sets to true and that nothing reads (not kept)
+ int _dragX = 0; // +316: where the button went down (scene coordinates)
+ int _dragY = 0; // +320
+ float _ballSpeedX = 0; // +324: the speed of the flying ball (pixels per millisecond)
+ float _ballSpeedY = 0; // +328
+ bool _holdingBall = false; // +332: the hero has taken a ball (swipe is off)
+ float _ballX = 0; // +336: the center of the flying ball
+ float _ballY = 0; // +340
+ int _dropsShown = 0; // +344: the balls that the pipe has given
+ int _momPos = 0; // +348: her position: MSG_SC6_JUMPFW counts it up, MSG_SC6_JUMPBK down
+ int _ballsCaught = 0; // +352: the balls in her bag
+ bool _ballInBag = false; // +356: a ball was just put in, MSG_SC6_TESTNUMBALLS clears it
+ int _walkTimer = 0; // +360: the updates since the egg walked, 600 start the next walk
+ bool _eggieRight = true; // +364: the next walk of ANI_EGGIE goes to the right
+ Common::Array<AniObject *> _balls; // +368: the balls that are not in use
+ Region _region; // +380: where Mumsy catches the ball (CRegion, CreateRectRgn(0, 0, 100, 70))
+ float _aimAngle = 205.0f; // +384: the rotation of the power arrow in degrees
+ float _aimScale = 0.7f; // +388: its scale
+ float _arrowX = 0; // +392: the center of the arrow when OnShow put it in place
+ float _arrowY = 0; // +396
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SC06CONTROLLER_H
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index 745b20ae075..ed0331c0d56 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -21,6 +21,7 @@
#include "ngi/ngi.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/sc06controller.h"
#include "ngi/fullpipe/scenecontrollers.h"
#include "ngi/fullpipe/sc03controller.h"
#include "ngi/fullpipe/sc04controller.h"
@@ -132,15 +133,6 @@ void Sc05Controller::onShow() {
_offsetY = 300;
}
-// CSc06Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
-void Sc06Controller::onShow() {
- FPController::onShow();
- _marginX = 300;
- _marginY = 200;
- _offsetX = 400;
- _offsetY = 300;
-}
-
// CSc07Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
void Sc07Controller::onShow() {
FPController::onShow();
diff --git a/engines/ngi/fullpipe/scenecontrollers.h b/engines/ngi/fullpipe/scenecontrollers.h
index 615c08db6b3..ce6c7551624 100644
--- a/engines/ngi/fullpipe/scenecontrollers.h
+++ b/engines/ngi/fullpipe/scenecontrollers.h
@@ -67,12 +67,6 @@ public:
void onShow() override;
};
-class Sc06Controller : public FPController {
-public:
- explicit Sc06Controller(int sceneId) : FPController(sceneId) {}
- void onShow() override;
-};
-
class Sc07Controller : public FPController {
public:
explicit Sc07Controller(int sceneId) : FPController(sceneId) {}
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index ba0ca4fc3de..d3b5ac1c791 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -90,6 +90,7 @@ MODULE_OBJS = \
fullpipe/liftcontroller.o \
fullpipe/notebook.o \
fullpipe/sc04controller.o \
+ fullpipe/sc06controller.o \
fullpipe/scene01.o \
fullpipe/scene02.o \
fullpipe/scene03.o \
Commit: 0671fc3aed0a24ad6ed8d61be1968e3166a923ca
https://github.com/scummvm/scummvm/commit/0671fc3aed0a24ad6ed8d61be1968e3166a923ca
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Scene 8 controller ported
Changed paths:
A engines/ngi/fullpipe/sc08controller.cpp
A engines/ngi/fullpipe/sc08controller.h
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/scenecontrollers.h
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/sc08controller.cpp b/engines/ngi/fullpipe/sc08controller.cpp
new file mode 100644
index 00000000000..3351ab4b190
--- /dev/null
+++ b/engines/ngi/fullpipe/sc08controller.cpp
@@ -0,0 +1,875 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/debug.h"
+#include "common/hashmap.h"
+
+#include "ngi/ngi.h"
+#include "ngi/behavior.h"
+#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/guimanager.h"
+#include "ngi/input.h"
+#include "ngi/interaction.h"
+#include "ngi/messages.h"
+#include "ngi/motion.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/xmlnode.h"
+#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/sc08controller.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+namespace {
+
+void warnOnce(const char *what) {
+ static Common::HashMap<Common::String, bool> reported;
+ if (!reported.contains(what)) {
+ reported[what] = true;
+ warning("STUB/untested: %s", what);
+ }
+}
+
+// CAniObject +164: the statics of the object (0 when it has none)
+int staticsId(const AniObject *ani) {
+ return ani->_statics ? ani->_statics->_staticsId : 0;
+}
+
+// CAniObject::GetCurFrame (F112C): the frame of the running movement, -1 when the object does not move
+int curFrame(const AniObject *ani) {
+ return ani->_movement ? ani->_movement->_curFrame : -1;
+}
+
+// CAniObject::SetCurFrame (F0C76): the movement of the object goes to the frame (the position is the one of the movement, as AniObject::startMovement does it).
+// The last argument of the original (stored in CMovement +63) is not modelled.
+void setCurFrame(AniObject *ani, int frame) {
+ if (ani->_movement) {
+ ani->_movement->setCurFrame(frame);
+ ani->setPos(ani->_movement->_x, ani->_movement->_y);
+ }
+}
+
+// CBaseSettings::SetSaving (the saves are blocked while the arcade runs)
+void setSaving(bool enable) {
+ warnOnce("CBaseSettings::SetSaving (the saves are not blocked)");
+}
+
+// CHintManager::ShowHint, HideHint and SetHideCondition (the hint of the arcade)
+void showHint() {
+ warnOnce("CHintManager::ShowHint (the hint of the arcade is not shown)");
+}
+
+void hideHint() {
+ warnOnce("CHintManager::HideHint (the hint of the arcade is not shown)");
+}
+
+void setHideHintCondition() {
+ warnOnce("CHintManager::SetHideCondition (the hint of the arcade is not shown)");
+}
+
+// CScene::StopAllQueues (120C40): the queues of the scene stop, then CInteractionController::StoppedAllInteractions
+void stopAllQueues(Scene *scene) {
+ warnOnce("CScene::StopAllQueues");
+}
+
+// CInteractionController::SetVes (106DC8): the weight of the first interaction with the name
+void setVes(int weight, const char *name) {
+ warnOnce("CInteractionController::SetVes: the weights of INT_068 and INT_069 are not changed");
+}
+
+// CInteractionController::FindInteractionUnderCursor (106D94)
+Interact *findInteractionUnderCursor() {
+ warnOnce("CInteractionController::FindInteractionUnderCursor");
+ return nullptr;
+}
+
+// CFPController::RunInteractionWithMouse (the interaction with the name runs, the hero goes to the touch)
+void runInteractionWithMouse(const char *name, float x, float y) {
+ warnOnce("CFPController::RunInteractionWithMouse");
+}
+
+} // End of anonymous namespace
+
+// CSc08Controller::CSc08Controller (16FA14)
+Sc08Controller::Sc08Controller(int sceneId) : FPController(sceneId), _tutorial("PREV_ARCADE_TUTORIAL_08"), _flyPack(new FlyPack()), _region(new Region()) {
+ _region->createRectRgn(0.0f, 500.0f, 800.0f, 690.0f);
+}
+
+// CSc08Controller::~CSc08Controller (16F98C): the fly pack, the region and the vectors go with it
+Sc08Controller::~Sc08Controller() {
+}
+
+// CSc08Controller::CanSwipeMan (16E8DC)
+bool Sc08Controller::canSwipeMan(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::canSwipeMan(x, y);
+ return !_arcadeRunning;
+}
+
+// CSc08Controller::CanShowHelp (16E8E6)
+bool Sc08Controller::canShowHelp() {
+ return !_arcadeRunning;
+}
+
+// CSc08Controller::CleanXml (16E8F0)
+void Sc08Controller::cleanXml() {
+ _tutorial = "PREV_ARCADE_TUTORIAL_08";
+}
+
+// CSc08Controller::VmyatsControlFunc (16E92C): the crumpled place follows the depth of the man
+void Sc08Controller::vmyatsControlFunc(uint32 elapsed) {
+ if (!_arcadeRunning)
+ return;
+
+ _vmyatsTimer += elapsed;
+ while (_vmyatsTimer > 25) {
+ _vmyatsTimer -= 25;
+ // CAniObject::GetCurFrame(_vmyats) and CVisibleObject::GetSize(_vmyats): the results are not used
+ const float top = hero()->getPosition().y;
+ int bottom = (int)(top + (float)hero()->getSize().y);
+ if (staticsId(hero()) == ST_MAN8_FLYDOWN)
+ bottom = (int)((float)bottom - 25.0f);
+ const int depth = (bottom - 697) / 10 + 2;
+ int frame;
+ if (depth <= 10) {
+ frame = depth & (~depth >> 31);
+ } else {
+ _manSpeed = 0;
+ frame = 10;
+ }
+ if (frame != curFrame(_vmyats)) {
+ setCurFrame(_vmyats, frame);
+ if (frame != 0) {
+ _vmyats->_flags |= 4;
+ if (!_vmyats->_movement)
+ _vmyats->startMovement(MV_VMT_DEF, 0, -1);
+ } else {
+ _vmyats->_flags &= ~4;
+ }
+ }
+ if (bottom > 697)
+ _manSpeed = stepSpeed(_step);
+ }
+}
+
+// CSc08Controller::DoStandup (16EA44)
+void Sc08Controller::doStandup() {
+ _scene->runQueue(QU_SC8_STANDUP, 2);
+ _onBelly = false;
+}
+
+// CSc08Controller::DoHideDestructedLadder (16EA60)
+void Sc08Controller::doHideDestructedLadder() {
+ _scene->findPictureObjectById(PIC_SC8_LADDER_D, 0)->_flags &= ~4;
+}
+
+// CSc08Controller::ResumeFlight (16EA7C)
+void Sc08Controller::resumeFlight() {
+ _manSpeed = 0.03f;
+ _inAir = true;
+ _stairsVisible = false;
+}
+
+// CSc08Controller::DoManDryg (16EA94): button up in the air: kick up or down, near the ground jump
+void Sc08Controller::doManDryg() {
+ const Common::Point center = hero()->getCenter();
+ float centerY = center.y;
+ const Common::Point size = hero()->getSize();
+ if (!((697.0f - (centerY + (float)size.y * 0.5f)) < 150.0f)) {
+ const int state = staticsId(hero());
+ if (state == ST_MAN8_FLYUP)
+ hero()->startMovement(MV_MAN8_DRYGUP, 0, -1);
+ else if (state == ST_MAN8_FLYDOWN)
+ hero()->startMovement(MV_MAN8_DRYGDOWN, 0, -1);
+ } else {
+ if (staticsId(hero()) == ST_MAN8_FLYDOWN) {
+ centerY = centerY - 25.0f;
+ hero()->setCenter(Common::Point(center.x, (int)centerY));
+ }
+ hero()->setStatic(ST_MAN8_STAND);
+ hero()->setCenter(Common::Point(380, (int)centerY));
+ hero()->startMovement(MV_MAN8_JUMP, 0, -1);
+ }
+}
+
+// CSc08Controller::SwitchToArcadeNow (16EB9C): the baton sleeps, the stairway is locked
+void Sc08Controller::switchToArcadeNow() {
+ MovGraphLink *link = _scene->_motionController ? _scene->_motionController->getGraphLink(sO_Stairway) : nullptr;
+ g_ngi->setState(sO_TummyTrampie, g_ngi->getStateValue(sO_TummyTrampie, sO_IsSleeping));
+ _batuta->moveToStatic(ST_BTT_SLEEPS);
+ if (link)
+ link->_flags |= 0x20000000;
+}
+
+// CSc08Controller::CheckTutorial (16EC40): the arcade tutorial once the baton sleeps
+void Sc08Controller::checkTutorial() {
+ if (_tutorial == "UNDEF")
+ return;
+ if (g_ngi->_sceneStack.size() != 1)
+ return;
+ if (g_ngi->_tutorialManager->activateTutorial(_tutorial))
+ return;
+ const Common::String previous = _tutorial;
+ if (_tutorial == "PREV_ARCADE_TUTORIAL_08") {
+ bool ready = false;
+ if (g_ngi->getStateId(sO_TummyTrampie) == g_ngi->getStateValue(sO_TummyTrampie, sO_IsSleeping) && _targetY == 0.0f)
+ ready = _scene->_y >= 200.0f;
+ if (ready)
+ _tutorial = "ARCADE_TUTORIAL_08";
+ } else {
+ _tutorial = "UNDEF";
+ }
+ if (previous != _tutorial)
+ checkTutorial();
+}
+
+// CSc08Controller::UpdateButtons (16EDC4): the up button slides in from the right while the arcade
+// runs (0.15 px per ms), out when it is over or skipped; GuiElement positions are integers here
+void Sc08Controller::updateButtons(uint32 elapsed) {
+ if (!_arrowUp)
+ return;
+
+ // CRender +36 (the width of the game) and +8 + +24 (the margin of the widescreen)
+ const float renderWidth = (float)g_ngi->gameWidth();
+ const float renderMargin = 0.0f + (float)g_ngi->_wideOfs;
+ const uint32 right = (uint32)(renderMargin + renderWidth);
+
+ bool slideOut = false;
+ if (_arcadeRunning) {
+ if (_skipped) {
+ if (!_arrowUp->_visible)
+ return;
+ slideOut = true;
+ } else {
+ if (!_arrowUp->_visible) {
+ _arrowUp->setPos(Common::Point((int)((float)right + 50.0f), 495));
+ _arrowUp->show();
+ return;
+ }
+ const Common::Point size = _arrowUp->_size;
+ const Common::Point pos = _arrowUp->_pos;
+ const float target = ((float)right - (float)size.x) - 50.0f;
+ if ((float)pos.x > target)
+ _arrowUp->setPos(Common::Point((int)((float)pos.x - (float)elapsed * 0.15f), 495));
+ else
+ _arrowUp->setPos(Common::Point((int)target, 495));
+ return;
+ }
+ } else if (_arrowUp->_visible) {
+ slideOut = true;
+ }
+
+ if (slideOut) {
+ const Common::Point pos = _arrowUp->_pos;
+ _arrowUp->setPos(Common::Point((int)((float)pos.x + (float)elapsed * 0.15f), 495));
+ if ((float)_arrowUp->_pos.x > (float)right)
+ _arrowUp->hide();
+ }
+}
+
+// CSc08Controller::DoSitdown (16EF8C): the man lands on his belly; nothing calls it
+void Sc08Controller::doSitdown() {
+ g_ngi->arcadeInterface().setCounter(0);
+ const Common::Point center = hero()->getCenter();
+ hero()->setStatic(ST_MAN8_FLYDOWN);
+ hero()->setCenter(Common::Point(380, center.y));
+ hero()->startMovement(MV_MAN8_SITDOWN, 0, -1);
+ _vmyats->setStatic(ST_VMT_MIN);
+ _vmyats->_flags &= ~4;
+ _inAir = false;
+ _onBelly = true;
+}
+
+// CSc08Controller::DoStep2 (16F018): the man reaches the top of the stairs
+void Sc08Controller::doStep2() {
+ g_ngi->arcadeInterface().setCounter(5);
+ _scene->findPictureObjectById(PIC_SC8_LADDER, 0)->_flags &= ~4;
+ hero()->setStatic(ST_MAN8_HANDSUP);
+ hero()->setPosition(Common::Point(386, 236));
+ hero()->_z = 10;
+ hero()->_flags |= 4;
+ _scene->runQueue(QU_SC8_FINISH, 2);
+ _inAir = false;
+ if (!_skipped)
+ warnOnce("CAchievementsManager::AddActivatingCounter ACHIEVEMENT_ARCADE_8: achievements are not ported");
+ g_ngi->arcadeInterface().scrollOut();
+}
+
+// CSc08Controller::DoWinArcade (16F12C)
+void Sc08Controller::doWinArcade() {
+ if (!_arcadeRunning)
+ return;
+
+ g_ngi->arcadeInterface().scrollOut();
+ _arcadeRunning = false;
+ _scene->_y = 0;
+ _targetY = 0;
+ doStep2();
+ hideHint();
+ g_ngi->_taskManager->deactivateTask("FIND_EXIT_BATUTA_SC8");
+ setSaving(true);
+}
+
+// CSc08Controller::SkipArcade (16F1A4)
+void Sc08Controller::skipArcade() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::skipArcade();
+ return;
+ }
+ g_ngi->arcadeInterface().scrollOut();
+ _skipped = true;
+ _step = (int)_stepSpeeds.size();
+ // CFPController::FlurryArcadeSkip("ANI_BATUTA") is the analytics (CFlurryEventManager), not ported
+}
+
+// CSc08Controller::EndBatut (16F1FC)
+void Sc08Controller::endBatut() {
+ _arcadeRunning = false;
+ _flyingUp = false;
+ getGameLoaderInteractionController()->enable();
+ if (_scene->_motionController)
+ _scene->_motionController->activate();
+ _scene->_behaviorController->enableAllQueuesForAni(_scene->findAniObjectById(ANI_MAN, 0), 1);
+ _scene->_behaviorController->enableAllQueuesForAni(_batuta, 1);
+ setSaving(true);
+ hideHint();
+}
+
+// CSc08Controller::DoJumpoff (16F258)
+void Sc08Controller::doJumpoff() {
+ hero()->startMovement(MV_MAN8_JUMPOFF, 0, -1);
+ endBatut();
+}
+
+// CSc08Controller::CountManRaising (16F288): the man is pulled up, 0.5 px per ms, out of the scene
+void Sc08Controller::countManRaising(uint32 elapsed) {
+ if (!_flyingUp)
+ return;
+
+ const Common::Point center = hero()->getCenter();
+ const float y = (float)((double)(float)center.y + (double)elapsed * -0.5);
+ hero()->setCenter(Common::Point(center.x, (int)y));
+ if (y < 80.0f) {
+ g_ngi->_taskManager->deactivateTask("FIND_EXIT_BATUTA_SC8");
+ endBatut();
+ g_ngi->_gameLoader->preloadScene(SC_9, TrubaDown); // CGame::SetScene
+ }
+}
+
+// CSc08Controller::StartBatut (16F348)
+void Sc08Controller::startBatut() {
+ // FlurryArcadeStart("ANI_BATUTA") (analytics) is not ported
+ ArcadeInterface &arcade = g_ngi->arcadeInterface();
+ if (arcade.getState() == ArcadeInterface::kHidden) {
+ arcade.init(-100.0f, 450.0f, 0.0f, -64.0f, 5, 0, false);
+ arcade.scrollIn();
+ }
+ setSaving(false);
+ _arcadeRunning = true;
+ _inAir = true;
+ _flyingUp = false;
+ _onBelly = false;
+ getGameLoaderInteractionController()->disable();
+ if (_scene->_motionController)
+ _scene->_motionController->deactivate();
+ _batuta->stopMovement();
+ _vmyats->setStatic(ST_VMT_MIN);
+ _vmyats->setCenter(Common::Point(382, 697));
+ _vmyats->_z = 29;
+ _manSpeed = stepSpeed(1);
+ _targetY = 0;
+ _scene->_behaviorController->enableAllQueuesForAni(_scene->findAniObjectById(ANI_MAN, 0), 0);
+ _scene->_behaviorController->enableAllQueuesForAni(_batuta, 0);
+ showHint();
+ if (g_ngi->getStateId(sO_WarmUp) == g_ngi->getStateValue(sO_WarmUp, sO_Fast))
+ _step = (int)_stepSpeeds.size();
+ else
+ _step = 1;
+ _stepGrace = 1;
+}
+
+// CSc08Controller::SwitchLadder (16F4E8): INT_068 (up) in the lower half, INT_069 in the upper
+// the original sets the activity (+80) of FindInteraction(name); setActive does it by name
+void Sc08Controller::switchLadder(bool ladderUp) {
+ getGameLoaderInteractionController()->setActive("INT_068", 0, 0, ladderUp ? 0.0f : 1.0f, 0.0f);
+ getGameLoaderInteractionController()->setActive("INT_069", 0, 0, ladderUp ? 1.0f : 0.0f, 0.0f);
+}
+
+// CSc08Controller::OnMouseDownSitting (16F564). Not called by anything in the original.
+void Sc08Controller::onMouseDownSitting(float x, float y) {
+ if (g_ngi->_inputController->isObjectHit(PIC_SC8_LADDERD))
+ doJumpoff();
+ else
+ doStandup();
+}
+
+// CSc08Controller::DoStep1 (16F58C): the man bumps into the stairs (BADLUCK): the stairs break
+void Sc08Controller::doStep1() {
+ g_ngi->arcadeInterface().setCounter(4);
+ _scene->findPictureObjectById(PIC_SC8_LADDER, 0)->_flags &= ~4;
+ hero()->setStatic(ST_MAN8_HANDSUP);
+ hero()->setPosition(Common::Point(376, 280));
+ hero()->_z = 10;
+
+ MessageQueue *queue = new MessageQueue(_scene, true, 1); // CMessageQueue(scene, 1, 1)
+ Command *command = new Command(hero()->_id, kCmdStartMovement, MV_MAN8_BADLUCK, 0, 0, 0, 1, 0, 0, 0);
+ command->_param = hero()->_copyId;
+ command->_excFlags |= 2;
+ queue->addCommandToEnd(command);
+ queue->_interruptState = 2; // CMessageQueue::SetIntState(2)
+ if (!queue->run(nullptr)) // CScene::RunQueue(queue, 4, 0)
+ delete queue;
+
+ g_ngi->setState(sO_StairsUp_8, g_ngi->getStateValue(sO_StairsUp_8, sO_Broken));
+ _inAir = false;
+}
+
+// CSc08Controller::CountManFlight (16F6E8): the physics of the flight in steps of 25 ms
+void Sc08Controller::countManFlight(uint32 elapsed) {
+ _flightTimer += elapsed;
+ Common::Point center = hero()->getCenter();
+ float centerX = center.x;
+ float centerY = center.y;
+ if ((double)fabsf(_manSpeed) <= 0.08) {
+ int counter = 0;
+ if (centerY <= 535.0f)
+ counter = (int)((((535.0f - centerY) * 3.0f) / 255.0f) + 1.0f);
+ g_ngi->arcadeInterface().setCounter(counter);
+ }
+
+ while (_flightTimer > 25) {
+ _flightTimer -= 25;
+ const float speed = _manSpeed;
+ const float newY = centerY + speed * 25.0f;
+ if (_region->_bottom - 40.0f > newY)
+ _manSpeed = speed + _gravity * 25.0f;
+ if (speed != 0.0f && (_manSpeed / speed) < 0.0f) {
+ if (_step > 1) {
+ if (_stepGrace > 0)
+ _stepGrace--;
+ else
+ _step--;
+ }
+ }
+ const float limit = stepSpeed(_step);
+ if (_manSpeed < limit)
+ _manSpeed = limit;
+ hero()->setCenter(Common::Point((int)centerX, (int)newY));
+ // CVisibleObject::GetSize(hero): the result is not used
+ center = hero()->getCenter();
+ centerX = center.x;
+ centerY = center.y;
+
+ if (centerY <= 280.0f && _stairsVisible) {
+ doStep1();
+ } else if (centerY > 236.0f || _stairsVisible) {
+ AniObject *man = hero();
+ const bool moving = man->_movement != nullptr;
+ if (moving || centerY < 660.0f || fabsf(_manSpeed) > 0.2f) {
+ if (_manSpeed >= 0.0f && !moving) {
+ if (staticsId(man) == ST_MAN8_HANDSUP)
+ man->startMovement(MV_MAN8_HANDSDOWN, 0, -1);
+ else
+ man->setStatic(ST_MAN8_FLYDOWN);
+ }
+ if (centerY < 500.0f && !hero()->_movement) {
+ if (_manSpeed < 0.0f)
+ hero()->startMovement(MV_MAN8_HANDSUP, 0, -1);
+ }
+ } else {
+ // on the ground and almost still: the original only calls GetSize here
+ }
+ } else {
+ doStep2();
+ }
+ }
+}
+
+// CSc08Controller::ReadSettingsXml (16FB48): MAN g, one VEL step per limit; keeps the vectors
+void Sc08Controller::readSettingsXml() {
+ for (int i = 0; i != 5; ++i)
+ _stepHeights.push_back(535.0f - (float)i * 63.75f);
+
+ Common::ScopedPtr<XmlNode> document(loadXmlDocument(Common::Path("data/sc_8_settings.xml")));
+ if (!document) {
+ warning("Could not read sc_8_settings.xml");
+ return;
+ }
+ const XmlNode &man = document->child("SETTINGS").child("MAN");
+ _gravity = man.attrFloat("g", _gravity);
+ for (uint i = 0; i < man.childCount(); i++)
+ _stepSpeeds.push_back(man[i].attrFloat("step", 0.0f));
+}
+
+float Sc08Controller::stepSpeed(int step) const {
+ if (step < 1 || (uint)step > _stepSpeeds.size()) {
+ warnOnce("CSc08Controller: the speed limit of the step is not in sc_8_settings.xml");
+ return 0.0f;
+ }
+ return _stepSpeeds[step - 1];
+}
+
+// CSc08Controller::OnShow (16FC80): camera margins and tutorial; the rest is in initScene
+void Sc08Controller::onShow() {
+ FPController::onShow();
+ g_ngi->_taskManager->visitScene(_scene->_sceneId);
+ _marginY = 200;
+ _marginX = 300;
+ _offsetY = 300;
+ _offsetX = 400;
+ if (!controllerRunsSceneLogic())
+ return;
+
+ _arcadeRunning = false;
+ _inAir = false;
+ _flyingUp = false;
+ _onBelly = false;
+ _skipped = false;
+ _batuta = _scene->findAniObjectById(ANI_BATUTA, 0);
+ _vmyats = _scene->findAniObjectById(ANI_VMYATS, 0);
+ _clock = _scene->findAniObjectById(ANI_CLOCK_8, 0);
+ _snoringTimer = -1;
+ readSettingsXml();
+ if (!_arrowUp)
+ _arrowUp = _scene->_guiManager ? _scene->_guiManager->getElement("BTN_ARROW_UP") : nullptr;
+ if (_arrowUp && _arrowUp->_visible)
+ _arrowUp->hide();
+
+ const int tummyState = g_ngi->getStateId(sO_TummyTrampie);
+ MovGraphLink *lock = _scene->_motionController ? _scene->_motionController->getGraphLink(sO_CloseThing) : nullptr;
+ if (lock)
+ lock->_flags &= ~0x20000000;
+ _batuta->moveToStatic(ST_BTT_SLEEPS);
+ if (tummyState == g_ngi->getStateValue(sO_TummyTrampie, sO_IsEating)) {
+ _batuta->moveToStatic(ST_BTT_SPOON);
+ _clock->stopMovement();
+ _clock->setStatic(ST_CLK8_NORM);
+ } else if (tummyState == g_ngi->getStateValue(sO_TummyTrampie, sO_IsDrinking)) {
+ _batuta->moveToStatic(ST_BTT_NOSPOON);
+ _clock->startMovement(MV_CLK8_GO, 0, -1);
+ setCurFrame(_clock, 3);
+ } else if (tummyState == g_ngi->getStateValue(sO_TummyTrampie, sO_IsScratchingBelly)) {
+ _batuta->moveToStatic(ST_BTT_CHESHET);
+ _clock->startMovement(MV_CLK8_GO, 0, -1);
+ setCurFrame(_clock, 8);
+ } else if (tummyState == g_ngi->getStateValue(sO_TummyTrampie, sO_IsSleeping)) {
+ _clock->startMovement(MV_CLK8_GO, 0, -1);
+ setCurFrame(_clock, 2);
+ if (lock)
+ lock->_flags |= 0x20000000;
+ _snoringTimer = 1;
+ if (_scene->_currentEntranceId == 0) {
+ hero()->setCenter(Common::Point(663, 436));
+ hero()->_z = 20;
+ hero()->setStatic(ST_MAN_RIGHT);
+ hero()->_flags |= 8; // CVisibleObject +64: the man looks to the left (mirrored)
+ }
+ }
+
+ if (g_ngi->getStateId(sO_StairsUp_8) == g_ngi->getStateValue(sO_StairsUp_8, sO_Broken)) {
+ _stairsVisible = false;
+ _scene->findPictureObjectById(PIC_SC8_LADDER_D, 0)->_flags |= 4;
+ } else {
+ _stairsVisible = true;
+ }
+
+ _flyPack->init(g_ngi->getGameLoaderGameVar()->getSubVarByName("SC_8"));
+ _flyPack->addFly(_scene, 100, 100, 0, 0);
+ if (g_ngi->getStateId(sO_TummyTrampie) == g_ngi->getStateValue(sO_TummyTrampie, sO_IsSleeping))
+ _scene->_behaviorController->disableAllMusic();
+ _scene->_behaviorController->enableAllQueuesForAni(_scene->findAniObjectById(ANI_MAN, 0), 1);
+ _scene->_behaviorController->enableAllQueuesForAni(_batuta, 1);
+ _scrollY = false;
+ const int entranceId = _scene->_currentEntranceId;
+ if (g_ngi->_exitManager->getExitState(PIC_SC8_LADDERD) != 3 && entranceId == TrubaRight)
+ g_ngi->_exitManager->setExitAngle(PIC_SC8_LADDERD, 180.0f);
+ _vmyats->_flags &= ~4;
+ _upsellShown = false;
+}
+
+// CSc08Controller::OnHide (1700F8)
+void Sc08Controller::onHide() {
+ if (controllerRunsSceneLogic())
+ setSaving(true);
+ _flyPack->deleteAllFlies();
+ if (controllerRunsSceneLogic()) {
+ hideHint();
+ // the analytics event game_ANI_BATUTA_lose is not ported
+ }
+ FPController::onHide();
+}
+
+// CSc08Controller::OnKeyUp (1702EC): W (87) wins the arcade, Q (81) skips it
+void Sc08Controller::onKeyUp(uint32 key) {
+ FPController::onKeyUp(key);
+ if (!controllerRunsSceneLogic())
+ return;
+ if (key == 87) {
+ switchToArcadeNow();
+ startBatut();
+ doWinArcade();
+ } else if (key == 81) {
+ skipArcade();
+ }
+}
+
+// CSc08Controller::UpdateScroll (170320): in the arcade the camera follows the man vertically
+void Sc08Controller::updateScroll() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::updateScroll();
+ return;
+ }
+ if (_follow) {
+ if (!_arcadeRunning) {
+ FPController::updateScroll();
+ return;
+ }
+ const int renderHeight = g_ngi->_backgroundSurface.h; // CRender +40
+ if ((float)_follow->getCenter().y < (float)_scene->_y + 300.0f) {
+ _scene->_y = (int)((float)_follow->getCenter().y - 300.0f);
+ if ((float)_scene->_y < 0.0f)
+ _scene->_y = 0;
+ }
+ if ((float)_follow->getCenter().y > ((float)renderHeight + (float)_scene->_y) - 350.0f)
+ _scene->_y = (int)(((float)_follow->getCenter().y + 350.0f) - (float)renderHeight);
+ }
+ limitScroll();
+ testScroll();
+}
+
+// CSc08Controller::OnUpdate (1703EC)
+void Sc08Controller::onUpdate(uint32 elapsed) {
+ FPController::onUpdate(elapsed);
+ if (!controllerRunsSceneLogic())
+ return;
+
+ vmyatsControlFunc(elapsed);
+ _flyPack->onUpdate(elapsed);
+ updateButtons(elapsed);
+ if (_arcadeRunning) {
+ if (_inAir)
+ countManFlight(elapsed);
+ if (_step == 1)
+ _arcadeTime += elapsed;
+ if (_arcadeTime > 0x752F) {
+ if (g_ngi->arcadeInterface().getState() != ArcadeInterface::kHidden)
+ g_ngi->arcadeInterface().scrollOut();
+ // the analytics events lose_count and game_ANI_BATUTA_lose (CFlurryEventManager) are not ported
+ g_ngi->_gameLoader->preloadScene(SC_7, TrubaLeft); // CGame::SetScene
+ // CFPController::FlurryArcadeClean("ANI_BATUTA") is the analytics, not ported
+ }
+ } else {
+ AniObject *man = hero();
+ if (man->_movement && man->_movement->_id == MV_MAN_TOLADDERD && curFrame(man) == 8) {
+ man->_z = 2;
+ } else {
+ man = hero();
+ if (man->_movement && man->_movement->_id == MV_MAN_FROMLADDERUP && curFrame(man) == 13)
+ man->_z = 20;
+ }
+ switchLadder(_follow->getCenter().y > 520.0f);
+ }
+ if (_flyingUp)
+ countManRaising(elapsed);
+ if (_snoringTimer > 0) {
+ _snoringTimer -= elapsed;
+ if (_snoringTimer <= 0) {
+ g_ngi->playSound(SND_8_014, 0);
+ _snoringTimer = 4000;
+ }
+ }
+}
+
+// CSc08Controller::OnRender (170EE0): the arcade interface over the scene
+void Sc08Controller::onRender(Common::Point scroll) {
+ FPController::onRender(scroll);
+ if (g_ngi->arcadeInterface().getState() != ArcadeInterface::kHidden)
+ g_ngi->arcadeInterface().render(scroll);
+}
+
+// CSc08Controller::OnMouseLKeyDown (170740)
+bool Sc08Controller::onMouseLKeyDown(uint32 id, float x, float y) {
+ const bool result = FPController::onMouseLKeyDown(id, x, y);
+ if (controllerRunsSceneLogic())
+ _arcadeTime = 0;
+ return result;
+}
+
+// CSc08Controller::OnMouseLKeyUp (170750): INT_444 and INT_279 run as INT_068 / INT_069
+bool Sc08Controller::onMouseLKeyUp(uint32 id, float x, float y) {
+ const bool result = FPController::onMouseLKeyUp(id, x, y);
+ if (!controllerRunsSceneLogic())
+ return result;
+ if (!result) {
+ Interact *interaction = findInteractionUnderCursor();
+ if (interaction && canInterruptManQueue()) {
+ bool matches = false;
+ if (interaction->_actionName == "INT_444")
+ matches = g_ngi->_exitManager->getExitDestAngle(PIC_SC8_LADDERD) == 180.0f;
+ if (matches) {
+ runInteractionWithMouse("INT_068", x, y);
+ return true;
+ }
+ matches = false;
+ if (interaction->_actionName == "INT_279")
+ matches = g_ngi->_exitManager->getExitDestAngle(PIC_SC8_LADDERD) == 0.0f;
+ if (matches) {
+ runInteractionWithMouse("INT_069", x, y);
+ return true;
+ }
+ }
+ }
+ return result;
+}
+
+// CSc08Controller::OnMessage (17085C)
+void Sc08Controller::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onMessage(message, param, queue);
+ return;
+ }
+ if (message == "MSG_STARTARCADE") {
+ startBatut();
+ } else if (message == "MSG_CLOSEUPSELL") {
+ if (_upsellShown) {
+ stopAllQueues(_scene);
+ endBatut();
+ _scene->_y = 352;
+ hero()->setStatic(ST_MAN_RIGHT);
+ hero()->_flags |= 8; // SetStatic(ST_MAN_RIGHT, mirror 1)
+ hero()->setCenter(Common::Point(663, 436));
+ PictureObject *ladder = _scene->findPictureObjectById(PIC_SC8_LADDER_D, 0);
+ ladder->setPosition(Common::Point(327, 110));
+ ladder->_flags |= 4;
+ g_ngi->setState(sO_WarmUp, g_ngi->getStateValue(sO_WarmUp, sO_Fast));
+ _upsellShown = false;
+ }
+ } else if (message == "MSG_COMPLTEUPSELL") {
+ _upsellShown = false;
+ } else if (message == "MSG_SC8_RESUMEFLIGHT") {
+ resumeFlight();
+ } else if (message == "MSG_SC8_GETHIMUP") {
+ _manSpeed = 0;
+ _flyingUp = true;
+ // CSettings::GetIsFull and IsChapterUnlocked(1) are not ported (full version, no upsell scene)
+ warnOnce("CSc08Controller::OnMessage MSG_SC8_GETHIMUP: CSettings::GetIsFull / IsChapterUnlocked (the upsell scene is not pushed)");
+ const bool isFull = true;
+ if (!isFull) {
+ g_ngi->pushScene(SC_UPSELL);
+ _upsellShown = true;
+ }
+ } else if (message == "MSG_SC8_ARCADENOW") {
+ switchToArcadeNow();
+ } else if (message == "MSG_SC8_HIDELADDER_D") {
+ doHideDestructedLadder();
+ } else if (message == "MSG_SC8_STANDUP") {
+ _manSpeed = -0.1f;
+ _vmyats->setStatic(ST_VMT_MIN);
+ _vmyats->setCenter(Common::Point(382, 697));
+ _vmyats->_z = 29;
+ _inAir = true;
+ } else if (message == "MSG_SC8_ENTERUP") {
+ doStep2();
+ } else if (message == "MSG_CMN_WINARCADE") {
+ doWinArcade();
+ } else if (message == "MSG_TOLADDER" || message == "MSG_FROMLADDER") {
+ // CUtils::SetVes("INT_068", "INT_069", message)
+ if (message == "MSG_TOLADDER") {
+ setVes(1, "INT_068");
+ setVes(5, "INT_069");
+ } else {
+ setVes(5, "INT_068");
+ setVes(1, "INT_069");
+ }
+ } else if (message == "MSG_HIDE_BOX") {
+ AniObject *box = _scene->findAniObjectById(ANI_SC8_BOX, 0);
+ if (box)
+ box->_flags &= ~4;
+ } else if (message == "MSG_BREAK_GRIT") {
+ // the grit breaks once the queue of INT_299 has started: CInteractionController::FindInteraction("INT_299")'s queue +56 (CMessageQueue::GetCurCommandNum) != -1.
+ // The interaction is not found by name here and the queue has no command number, so the condition is false.
+ warnOnce("CSc08Controller::OnMessage MSG_BREAK_GRIT: FindInteraction of INT_299 and the command number of its queue are not ported");
+ const bool queueStarted = false;
+ if (queueStarted) {
+ AniObject *grit = _scene->findAniObjectById(ANI_GRIT2, 0);
+ if (grit->_movement)
+ setCurFrame(grit, 9);
+ else
+ grit->startMovement(MV_GRIT2_FALL, 0, -1);
+ }
+ } else {
+ FPController::onMessage(message, param, queue);
+ }
+}
+
+// CSc08Controller::OnGuiEvent (170C70): button up: kick or jump; a push in the stairs region steps
+void Sc08Controller::onGuiEvent(const Common::String &id, const Common::String &event) {
+ FPController::onGuiEvent(id, event);
+ if (!controllerRunsSceneLogic())
+ return;
+ if (event == "press" && id == "BTN_ARROW_UP") {
+ if (_inAir)
+ doManDryg();
+ else if (_onBelly)
+ doStandup();
+ // the analytics counter total_moves_ANI_BATUTA (CFlurryEventManager) is not ported
+ const Common::Point center = hero()->getCenter();
+ if (_region->ptInRegion((float)center.x, (float)center.y) && (_manSpeed > 0.0f || _step == 1)) {
+ const int steps = (int)_stepSpeeds.size();
+ if (_step < steps)
+ _step++;
+ if (_step == steps) {
+ // CFPController::FlurryArcadeEnd("ANI_BATUTA") is the analytics, not ported
+ }
+ _stepGrace = 1;
+ // the analytics parameter first_move_ANI_BATUTA (CFlurryEventManager) is not ported
+ setHideHintCondition();
+ } else {
+ // the analytics parameters first_move and failcount are not ported
+ }
+ }
+}
+
+// CSc08Controller::GetCursorType (170E58): ladder cursors, hidden (6) in the arcade
+int Sc08Controller::getCursorType(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::getCursorType(x, y);
+ if (!_arcadeRunning) {
+ if (!g_ngi->_inputController->isObjectHit(PIC_SC8_LADDERD))
+ return FPController::getCursorType(x, y);
+ if ((float)_follow->getCenter().y < 520.0f)
+ return 2;
+ return (_follow->getCenter().y > 750.0f) ? 4 : 0;
+ }
+ if (!_onBelly)
+ return 6;
+ if (!g_ngi->_inputController->isObjectHit(PIC_SC8_LADDERD))
+ return FPController::getCursorType(x, y);
+ return 4;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sc08controller.h b/engines/ngi/fullpipe/sc08controller.h
new file mode 100644
index 00000000000..96d1052a498
--- /dev/null
+++ b/engines/ngi/fullpipe/sc08controller.h
@@ -0,0 +1,112 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SC08CONTROLLER_H
+#define NGI_FULLPIPE_SC08CONTROLLER_H
+
+#include "common/array.h"
+#include "common/ptr.h"
+
+#include "ngi/region.h"
+#include "ngi/fullpipe/fpcontroller.h"
+#include "ngi/fullpipe/floaters.h"
+
+namespace NGI {
+
+class GuiElement;
+
+/** CSc08Controller (the conductor's baton scene), runs only when controllerRunsSceneLogic() */
+class Sc08Controller : public FPController {
+public:
+ explicit Sc08Controller(int sceneId);
+ ~Sc08Controller() override;
+
+ bool canSwipeMan(float x, float y) override;
+ bool canShowHelp() override;
+ void cleanXml() override;
+ void skipArcade() override;
+ void checkTutorial() override;
+ void onShow() override;
+ void onHide() override;
+ void onKeyUp(uint32 key) override;
+ void updateScroll() override;
+ void onUpdate(uint32 elapsed) override;
+ void onRender(Common::Point scroll) override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+ void onGuiEvent(const Common::String &id, const Common::String &event) override;
+ int getCursorType(float x, float y) override;
+
+ void vmyatsControlFunc(uint32 elapsed);
+ void doStandup();
+ void doHideDestructedLadder();
+ void resumeFlight();
+ void doManDryg();
+ void switchToArcadeNow();
+ void updateButtons(uint32 elapsed);
+ void doSitdown();
+ void doStep2();
+ void doWinArcade();
+ void endBatut();
+ void doJumpoff();
+ void countManRaising(uint32 elapsed);
+ void startBatut();
+ void switchLadder(bool ladderUp);
+ void onMouseDownSitting(float x, float y);
+ void doStep1();
+ void countManFlight(uint32 elapsed);
+ void readSettingsXml();
+
+private:
+ /** +214: the upsell scene was pushed (MSG_SC8_GETHIMUP), MSG_CLOSEUPSELL puts the man back */
+ bool _upsellShown = false;
+ /** +216: the next tutorial of the scene */
+ Common::String _tutorial;
+ float _gravity = 0; // +220: "g" of the MAN node of sc_8_settings.xml
+ AniObject *_clock = nullptr; // +224: ANI_CLOCK_8
+ AniObject *_batuta = nullptr; // +228: ANI_BATUTA
+ AniObject *_vmyats = nullptr; // +232: ANI_VMYATS (the crumpled place where the man falls)
+ GuiElement *_arrowUp = nullptr; // +236: BTN_ARROW_UP of the scene
+ float _manSpeed = 0; // +240: vertical speed of the man (pixels per ms, negative goes up)
+ bool _stairsVisible = true; // +244: the stairs are whole (the man bumps into them at y 280)
+ bool _inAir = false; // +245: the man flies
+ bool _flyingUp = false; // +246: the man is pulled up (MSG_SC8_GETHIMUP)
+ bool _onBelly = false; // +247: the man lies on the ground
+ int _snoringTimer = -1; // +248: the milliseconds until the baton snores
+ uint32 _vmyatsTimer = 0; // +252: the time of VmyatsControlFunc, steps of 25 ms
+ uint32 _flightTimer = 0; // +256: the time of CountManFlight, steps of 25 ms
+ uint32 _arcadeTime = 0; // +260: ms of the arcade without a successful move (while _step is 1)
+ Common::ScopedPtr<FlyPack> _flyPack; // +264
+ Common::ScopedPtr<Region> _region; // +268: where the man has to push (0, 500, 800, 690)
+ int _step = 1; // +272: the number of the step (the index of _stepSpeeds + 1)
+ int _stepGrace = 0; // +276: 1 after a push: the next direction change takes no step back
+ Common::Array<float> _stepHeights; // +280: 535 - i * 63.75 (read by nothing in the class)
+ Common::Array<float> _stepSpeeds; // +292: the speed limits (VEL step of sc_8_settings.xml)
+ bool _skipped = false; // +304: the arcade was skipped
+
+ /** limit of the step speed (1 based step): the original reads the vector without a range check */
+ float stepSpeed(int step) const;
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SC08CONTROLLER_H
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index ed0331c0d56..f891f74d584 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -22,6 +22,7 @@
#include "ngi/ngi.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/sc06controller.h"
+#include "ngi/fullpipe/sc08controller.h"
#include "ngi/fullpipe/scenecontrollers.h"
#include "ngi/fullpipe/sc03controller.h"
#include "ngi/fullpipe/sc04controller.h"
@@ -142,15 +143,6 @@ void Sc07Controller::onShow() {
_offsetY = 300;
}
-// CSc08Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
-void Sc08Controller::onShow() {
- FPController::onShow();
- _marginX = 300;
- _marginY = 200;
- _offsetX = 400;
- _offsetY = 300;
-}
-
// CSc09Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
void Sc09Controller::onShow() {
FPController::onShow();
diff --git a/engines/ngi/fullpipe/scenecontrollers.h b/engines/ngi/fullpipe/scenecontrollers.h
index ce6c7551624..7b422600e02 100644
--- a/engines/ngi/fullpipe/scenecontrollers.h
+++ b/engines/ngi/fullpipe/scenecontrollers.h
@@ -73,12 +73,6 @@ public:
void onShow() override;
};
-class Sc08Controller : public FPController {
-public:
- explicit Sc08Controller(int sceneId) : FPController(sceneId) {}
- void onShow() override;
-};
-
class Sc09Controller : public FPController {
public:
explicit Sc09Controller(int sceneId) : FPController(sceneId) {}
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index d3b5ac1c791..900f3590ed5 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -91,6 +91,7 @@ MODULE_OBJS = \
fullpipe/notebook.o \
fullpipe/sc04controller.o \
fullpipe/sc06controller.o \
+ fullpipe/sc08controller.o \
fullpipe/scene01.o \
fullpipe/scene02.o \
fullpipe/scene03.o \
Commit: b675481c33b07136832332574c0b130df479ce49
https://github.com/scummvm/scummvm/commit/b675481c33b07136832332574c0b130df479ce49
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Scene 9 controller ported
Changed paths:
A engines/ngi/fullpipe/sc09controller.cpp
A engines/ngi/fullpipe/sc09controller.h
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/scenecontrollers.h
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/sc09controller.cpp b/engines/ngi/fullpipe/sc09controller.cpp
new file mode 100644
index 00000000000..9f0ed62c851
--- /dev/null
+++ b/engines/ngi/fullpipe/sc09controller.cpp
@@ -0,0 +1,1124 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/formats/xmlparser.h"
+#include "common/hashmap.h"
+
+#include "ngi/ngi.h"
+#include "ngi/behavior.h"
+#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/input.h"
+#include "ngi/interaction.h"
+#include "ngi/inventory.h"
+#include "ngi/messages.h"
+#include "ngi/motion.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/lift.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/sc09controller.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+// The statics of the first lift button of Android (ST_LBN_1N of obj.h): constants.h has the number of the Windows game (2753)
+static const int kLiftButton1Normal = 23070;
+
+namespace {
+
+void warnOnce(const char *what) {
+ static Common::HashMap<Common::String, bool> reported;
+ if (!reported.contains(what)) {
+ reported[what] = true;
+ warning("STUB/untested: %s", what);
+ }
+}
+
+// CAniObject::GetCurFrame (F112C): the frame of the running movement, -1 without one
+int getCurFrame(const AniObject *ani) {
+ if (ani->_movement)
+ return ani->_movement->_curFrame;
+ return -1;
+}
+
+// CAniObject::SetCurFrame (F0C76) of the running movement (the arguments a3, a4 of the original are not modelled by CMovement::setCurFrame)
+void setCurFrame(AniObject *ani, int frame) {
+ if (ani->_movement)
+ ani->_movement->setCurFrame(frame);
+}
+
+// CAniObject +168: the original keeps the last started movement, here it is the running one
+int movementId(const AniObject *ani) {
+ if (ani->_movement)
+ return ani->_movement->_id;
+ return 0;
+}
+
+// CAniObject::MoveToStatic (F1B0C): a running movement is rewound (StopMovementToPrev), then the movements that lead from the statics of the object to the new one
+// are started one after the other (FindMovementsBeginStatic, FastStartMovement) and the last resort is SetStatic. The chain of movements is not ported.
+void moveToStatic(AniObject *ani, int staticsId) {
+ if (ani->_movement)
+ ani->stopMovementToPrev(true);
+ if (!ani->_statics || ani->_statics->_staticsId != staticsId) {
+ warnOnce("CAniObject::MoveToStatic: the chain of movements, FastStartMovement, is not ported, SetStatic is used");
+ ani->setStatic(staticsId);
+ }
+}
+
+// CFPController::HideAction (1490B0): every copy of the animation (from the copy number given) stops and is hidden
+void hideAction(Scene *scene, int aniId, int copyId) {
+ AniObject *ani;
+ do {
+ ani = scene->findAniObjectById(aniId, copyId);
+ if (ani) {
+ ani->stopMovement();
+ ani->_flags &= ~4;
+ }
+ copyId++;
+ } while (ani);
+}
+
+// CScene::RunQueue (1225A4) with a queue that was made by the caller (a copy of the queue of the scene): the same operations as Scene::runQueueWithAni
+bool runQueueCopy(Scene *scene, MessageQueue *copy, int interruptState, AniObject *ani) {
+ copy->_scene = scene;
+ if (interruptState != 4)
+ copy->_interruptState = interruptState;
+ if (!copy->run(ani)) {
+ g_ngi->_globalMessageQueueList->deleteQueueById(copy->_id);
+ return false;
+ }
+ return true;
+}
+
+// CCommand::SetParamFloat: the engine keeps the "x" of a command in two places (the attributes of the XML and the field of the command that the handlers read)
+void setParamFloat(Command *command, const char *name, float value) {
+ command->_args[name] = Common::String::format("%f", value);
+ if (!strcmp(name, "x"))
+ command->_x = (int)value;
+}
+
+// CMessageQueue::SetObjectCopy (10F470): every command of the queue gets the copy number (CCommand::SetObjectCopy: the parameter "copy")
+void setObjectCopy(MessageQueue *queue, int copyId) {
+ for (uint i = 0; i < queue->getCount(); i++) {
+ Command *command = queue->getCommandByIndex(i);
+ command->_args["copy"] = Common::String::format("%d", copyId);
+ command->_param = copyId;
+ }
+}
+
+// a message of the queue: its name goes to the controllers (CScene::Message), its id to the scene handlers (the same as in lift.cpp)
+Command *messageCommand(const char *name) {
+ uint32 id = 0;
+ g_ngi->_gameProject->_objectIds.findId(name, id);
+ Command *command = new Command(0, kCmdMessage, id, 0, 0, 0, 1, 0, 0, 0);
+ command->_messageName = name;
+ command->_excFlags |= 3;
+ return command;
+}
+
+// CVisibleObject::IsOnScreenEntirely (127682): the four corners of the object are inside the part of the scene that the screen shows. The offsets of CRender are
+// +8, +12 (the margin of a screen narrower than the base, 0 here), +24 (the margin of a wider screen, the widescreen offset), +28 (0), the size of the base screen is
+// +36, +40. The rectangle is CVisibleObject::GetRect (the bounds of the texture)
+bool isOnScreenEntirely(const GameObject *object, const Scene *scene) {
+ const float renderLeft = 0.0f;
+ const float renderTop = 0.0f;
+ const float renderOffsetX = (float)g_ngi->_wideOfs;
+ const float renderOffsetY = 0.0f;
+ const float renderWidth = (float)g_ngi->gameWidth();
+ const float renderHeight = (float)g_ngi->_backgroundSurface.h;
+ const float sceneX = (float)scene->_x;
+ const float sceneY = (float)scene->_y;
+
+ const float left = sceneX - (renderLeft + renderOffsetX);
+ const float top = sceneY - (renderTop + renderOffsetY);
+ const float right = (renderLeft + renderOffsetX) + (renderWidth + sceneX);
+ const float bottom = (renderTop + renderOffsetY) + (renderHeight + sceneY);
+ const Common::Rect bounds = object->getBounds();
+ const float objLeft = (float)bounds.left;
+ const float objTop = (float)bounds.top;
+ const float objRight = (float)bounds.right;
+ const float objBottom = (float)bounds.bottom;
+
+ if (objLeft <= left)
+ return false;
+ if (objLeft >= right)
+ return false;
+ if (objTop <= top)
+ return false;
+ if (objTop >= bottom)
+ return false;
+ if (objRight <= left)
+ return false;
+ if (objRight >= right)
+ return false;
+ if (objBottom <= top)
+ return false;
+ return objBottom < bottom;
+}
+
+// CInteractionController::FindInteractionUnderCursor: not ported (the same STUB as CTutorialController::PassMouseActions)
+Interact *findInteractionUnderCursor() {
+ warnOnce("CInteractionController::FindInteractionUnderCursor is not ported (CSc09Controller::OnMouseLKeyUp: INT_230 ... INT_234 are never found)");
+ return nullptr;
+}
+
+// CFPController::RunInteractionWithMouse (14D5E0): not ported (the tap of FPController::onTap starts the interactions by the object, not by the name)
+void runInteractionWithMouse(const char *name, float x, float y) {
+ warnOnce("CFPController::RunInteractionWithMouse is not ported (CSc09Controller::OnMouseLKeyUp: INT_230, INT_232, INT_234)");
+}
+
+// CInteractionController::FindInteraction(name) -> CInteract +24 (the queue) -> CMessageQueue +56 (GetCurCommandNum, -1 while the queue does not run)
+int interactionCommandNum(const char *name) {
+ warnOnce("CInteractionController::FindInteraction by name is not ported (CSc09Controller::OnMessage MSG_BREAK_GRIT: INT_238)");
+ return -1;
+}
+
+// CInteractionController::SetVes(weight, name, 0, 0): the weight of the first interaction with this name. Not ported
+void setInteractionWeight(const char *name, int weight) {
+ warnOnce("CInteractionController::SetVes (the weight of an interaction) is not ported (CSc09Controller::OnMessage MSG_TOLADDER, MSG_FROMLADDER: INT_230 ... INT_234)");
+}
+
+// CUtils::SetVes (14FCC8)
+void setWeights(const char *first, const char *second, const Common::String &message) {
+ if (message == "MSG_TOLADDER") {
+ setInteractionWeight(first, 1);
+ setInteractionWeight(second, 5);
+ } else if (message == "MSG_FROMLADDER") {
+ setInteractionWeight(first, 5);
+ setInteractionWeight(second, 1);
+ }
+}
+
+// sc_9_settings.xml (CSc09Controller::ReadSettingsXml): missing values keep their defaults
+class Sc09SettingsParser : public Common::XMLParser {
+public:
+ Sc09SettingsParser(int &numToWin, float &ballSpeed, int &hangerCount, int &hangerStep, float &hangerSpeedK)
+ : _numToWin(numToWin), _ballSpeed(ballSpeed), _hangerCount(hangerCount), _hangerStep(hangerStep), _hangerSpeedK(hangerSpeedK) {}
+
+private:
+ CUSTOM_XML_PARSER(Sc09SettingsParser) {
+ XML_KEY(SETTINGS)
+ XML_KEY(BALLS)
+ XML_PROP(numToWin, false)
+ XML_PROP(speed, false)
+ KEY_END()
+ XML_KEY(VISUNCHIK)
+ XML_PROP(count, false)
+ XML_PROP(dX, false)
+ XML_PROP(speedK, false)
+ KEY_END()
+ KEY_END()
+ } PARSER_END()
+
+ bool parserCallback_SETTINGS(ParserNode *) {
+ return true;
+ }
+
+ bool parserCallback_BALLS(ParserNode *node) {
+ _numToWin = atoi(node->values.getValOrDefault("numToWin", "3").c_str());
+ _ballSpeed = (float)atof(node->values.getValOrDefault("speed", "0.12").c_str());
+ return true;
+ }
+
+ bool parserCallback_VISUNCHIK(ParserNode *node) {
+ _hangerCount = atoi(node->values.getValOrDefault("count", "4").c_str());
+ _hangerStep = atoi(node->values.getValOrDefault("dX", "75").c_str());
+ _hangerSpeedK = (float)atof(node->values.getValOrDefault("speedK", "0.05").c_str());
+ return true;
+ }
+
+ int &_numToWin;
+ float &_ballSpeed;
+ int &_hangerCount;
+ int &_hangerStep;
+ float &_hangerSpeedK;
+};
+
+} // End of anonymous namespace
+
+// CSc09Controller::CSc09Controller (1722C4)
+Sc09Controller::Sc09Controller(int sceneId) : FPController(sceneId), _tutorial("PREV_ARCADE_TUTORIAL_09") {
+ _arcadeRunning = false;
+ static const float offsets[16] = { 15, 0, 23, 0, 0, -15, 8, -15, 0, 15, 8, 15, -15, 0, -23, 0 };
+ for (int i = 0; i < 16; i++)
+ _hitOffsets[i] = offsets[i];
+ _skipArcade = false;
+}
+
+// CSc09Controller::~CSc09Controller (1724B0); the scene owns the hanger copies here
+Sc09Controller::~Sc09Controller() {
+}
+
+// CSc09Controller::CleanXml (172448)
+void Sc09Controller::cleanXml() {
+ _tutorial = "PREV_ARCADE_TUTORIAL_09";
+ for (uint i = 0; i < _hangers.size(); i++) {
+ AniObject *ani = _hangers[i].ani;
+ if (ani->_copyId != 0) {
+ // CAniObject::RemoveThis (EEB54): CScene::RemoveAni, then the destructor
+ _scene->removeAni(ani);
+ delete ani;
+ }
+ }
+ _hangers.clear();
+ _sceneBalls.clear();
+ _arcadeStarted = false;
+}
+
+// CSc09Controller::OnRemoveCopies (170F02)
+void Sc09Controller::onRemoveCopies() {
+ _hangers.clear();
+}
+
+// CSc09Controller::IsInventoryEnabled (170F0E): not while a hanger is dragged
+bool Sc09Controller::isInventoryEnabled() {
+ return _dragIndex == -1;
+}
+
+// CSc09Controller::UpdateVisuns (170F20)
+void Sc09Controller::updateVisuns(uint32 elapsed) {
+ for (uint i = 0; i < _hangers.size(); i++) {
+ Visunchik &hanger = _hangers[i];
+ AniObject *ani = hanger.ani;
+ if (hanger.timer != 0)
+ ani->setStatic(ST_VSN_NORMAL);
+ if (ani->_movement && movementId(ani) == MV_VSN_CYCLE2) {
+ int frame;
+ if (hanger.phase >= 0)
+ frame = hanger.phase / -5 + 18;
+ else
+ frame = 18 - (int)((double)hanger.phase / 4.3);
+ if (frame <= 0)
+ frame = 1;
+ else if (frame > 38)
+ frame = 38;
+ if (frame != getCurFrame(ani))
+ setCurFrame(ani, frame);
+ } else {
+ if (hanger.timer != 0) {
+ hanger.timer -= elapsed;
+ if (hanger.timer <= 0) {
+ ani->setStatic(ST_VSN_NORMAL);
+ ani->startMovement(MV_VSN_CYCLE2, 0, -1);
+ setCurFrame(ani, 0);
+ hanger.timer = 0;
+ updateVisuns(0);
+ }
+ }
+ }
+ }
+}
+
+// CSc09Controller::OnMouseMove (171040): the hanger that is dragged swings
+bool Sc09Controller::onMouseMove(uint32 id, float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::onMouseMove(id, x, y);
+ if (_dragIndex != -1) {
+ AniObject *ani = _hangers[_dragIndex].ani;
+ if (ani->_movement || movementId(ani) != MV_VSN_CYCLE2) {
+ ani->setStatic(ST_VSN_NORMAL);
+ ani->startMovement(MV_VSN_CYCLE2, 0, -1);
+ }
+ updateVisuns(0);
+ }
+ return false;
+}
+
+// CSc09Controller::CountloopVisuns (1710B8): the hangers that are not held swing back to the middle
+void Sc09Controller::countloopVisuns(uint32 elapsed) {
+ for (uint i = 0; i < _hangers.size(); i++) {
+ if ((int)i == _dragIndex)
+ continue;
+ Visunchik &hanger = _hangers[i];
+ if (hanger.timer != 0)
+ continue;
+ const float velocity = hanger.velocity;
+ const int next = (int)((float)hanger.phase + (float)(velocity * (float)elapsed));
+ if (next <= 85)
+ hanger.phase = next;
+ else
+ hanger.phase = 85;
+ if (hanger.phase < -85)
+ hanger.phase = -85;
+ if (hanger.phase < 0)
+ hanger.velocity = velocity + _hangerSpeedK;
+ else if (hanger.phase != 0)
+ hanger.velocity = velocity - _hangerSpeedK;
+ hanger.velocity = hanger.velocity * hanger.damping;
+ }
+}
+
+// CSc09Controller::MoveVisun (17115E): the hanger swings from this phase and waits for the time
+void Sc09Controller::moveVisun(uint index, int phase, int timer) {
+ if (index >= _hangers.size())
+ return;
+ Visunchik &hanger = _hangers[index];
+ hanger.phase = phase;
+ hanger.velocity = 0;
+ hanger.damping = 1.0f;
+ hanger.timer = timer;
+}
+
+// CSc09Controller::DoShoot (171178): the hero shoots
+void Sc09Controller::doShoot() {
+ if (!hero()->_movement) {
+ hero()->startMovement(MV_MAN9_CYCLESHOOT, 0, -1);
+ _shootIdle = 0;
+ }
+}
+
+// CSc09Controller::DoStartTiotia (1711AC): the aunt walks in from the right edge of the screen
+void Sc09Controller::doStartTiotia() {
+ MessageQueue *queue = _scene->findMessageQueue(QU_TTA9_GOL);
+ if (!queue)
+ return;
+ MessageQueue *copy = new MessageQueue(queue, 0, 0);
+ Command *command = copy->getCommandByIndex(0);
+ const float sceneX = (float)_scene->_x;
+ if (command)
+ setParamFloat(command, "x", (float)(sceneX + (float)g_ngi->gameWidth()) + 30.0f);
+ runQueueCopy(_scene, copy, 3, nullptr);
+ warnOnce("CCatalogManager::UnlockItem for ANI_TIOTIA is not ported");
+}
+
+// CSc09Controller::DoUpdatePath (171298)
+void Sc09Controller::doUpdatePath() {
+ MovGraphLink *link = _scene->_motionController->getGraphLink(sO_CloseThing);
+ if (_gulperPresent) {
+ if (link)
+ link->_flags |= 0x20000000;
+ const Common::Point center = hero()->getCenter();
+ if ((float)center.y <= 450.0f) {
+ hero()->setStatic(ST_MAN_UP);
+ hero()->setCenter(Common::Point(1552, 493));
+ onMessage("MSG_FROMLADDER", "", nullptr);
+ }
+ } else {
+ if (link)
+ link->_flags &= 0xDFFFFFFF;
+ _shootIdle = 10000;
+ }
+}
+
+// CSc09Controller::RenderPassage (171390): empty
+void Sc09Controller::renderPassage() {
+}
+
+// CSc09Controller::CheckTutorial (171398)
+void Sc09Controller::checkTutorial() {
+ if (_tutorial == "UNDEF")
+ return;
+ if (g_ngi->_sceneStack.size() != 1)
+ return;
+ if (g_ngi->_tutorialManager->activateTutorial(_tutorial))
+ return;
+ const Common::String previous = _tutorial;
+ if (_tutorial != "PREV_ARCADE_TUTORIAL_09") {
+ _tutorial = "UNDEF";
+ } else if (!_spitter) {
+ // OnSceneInit is not called yet, the spitter is unknown
+ warnOnce("CSc09Controller::CheckTutorial: OnSceneInit has not found the spitter yet");
+ } else if (isOnScreenEntirely(_spitter, _scene)) {
+ _tutorial = "ARCADE_TUTORIAL_09";
+ }
+ if (previous != _tutorial)
+ checkTutorial();
+}
+
+// CSc09Controller::TestGrit (1714CC)
+void Sc09Controller::testGrit() {
+ if (!_grit->_statics || _grit->_statics->_staticsId != ST_GRT9_GRIT)
+ return;
+ const InventoryItem *coin = g_ngi->_inventory->getItemByName("ANI_INV_COIN");
+ bool bootEgg = false;
+ if (coin && coin->_counter == 0) {
+ if (g_ngi->getStateId(sO_CoinSlot_1) == g_ngi->getStateValue(sO_CoinSlot_1, sO_Empty)) {
+ bootEgg = (_eggs[0] && _eggs[0]->_value.intValue == ANI_INV_EGGBOOT) || (_eggs[1] && _eggs[1]->_value.intValue == ANI_INV_EGGBOOT)
+ || (_eggs[2] && _eggs[2]->_value.intValue == ANI_INV_EGGBOOT);
+ }
+ }
+ if (bootEgg)
+ _grit->setStatic(ST_GRT9_NORM);
+}
+
+// CSc09Controller::CanSwipeMan (1715DC): not while a hanger is dragged, nor on a hanger
+bool Sc09Controller::canSwipeMan(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::canSwipeMan(x, y);
+ GameObject *hit = g_ngi->_inputController->getInteractHitObject();
+ if (_dragIndex < 0) {
+ if (hit)
+ return (uint16)hit->_id != ANI_VISUNCHIK;
+ return true;
+ }
+ return false;
+}
+
+// CSc09Controller::DoShowBall (171610): the next ball comes out at the spitter
+void Sc09Controller::doShowBall() {
+ warnOnce("CFlurryEventManager (the analytics events of the arcade) is not ported");
+ if (!_sceneBalls.empty()) {
+ AniObject *ball = _sceneBalls.front();
+ _sceneBalls.pop_front();
+ _flyingBalls.push_back(ball);
+ ball->_flags |= 4;
+ const Common::Point center = hero()->getCenter();
+ const float x = (float)center.x + 94.0f;
+ const float y = (float)hero()->getCenter().y - 162.0f;
+ ball->setCenter(Common::Point((int)x, (int)y));
+ ball->setStatic(ST_BALL9_NORM);
+ }
+}
+
+// CSc09Controller::UpdateDragVisun (1716CC): the hanger that is dragged follows the finger
+void Sc09Controller::updateDragVisun() {
+ const float cursorY = g_ngi->_inputController->_hotSceneY;
+ Visunchik &hanger = _hangers[_dragIndex];
+ hanger.velocity = 0;
+ hanger.phase = (int)((float)_dragPhase + (float)((cursorY - _dragStartY) * 0.5f));
+ if (_dragMaxPhase != -1000 && hanger.phase != _dragMaxPhase) {
+ g_ngi->playSound(SND_9_019, 0);
+ _dragMaxPhase = -1000;
+ }
+}
+
+// CSc09Controller::DoExplodeBall (1717D8): the ball bursts and goes back to the balls of the scene
+void Sc09Controller::doExplodeBall(AniObject *ball) {
+ warnOnce("CFlurryEventManager (the analytics events of the arcade) is not ported");
+ _flyingBalls.remove(ball);
+ MessageQueue *queue = _scene->findMessageQueue(QU_SC9_BALLEXPLODE);
+ if (queue) {
+ MessageQueue *copy = new MessageQueue(queue, 0, 0);
+ setObjectCopy(copy, ball->_copyId);
+ runQueueCopy(_scene, copy, 4, nullptr);
+ }
+ _sceneBalls.push_back(ball);
+}
+
+// CSc09Controller::DoEatBall (1718AC)
+void Sc09Controller::doEatBall() {
+ warnOnce("CFlurryEventManager (the analytics events of the arcade) is not ported");
+ if (_eatingBall) {
+ _eatingBall->_flags &= ~4;
+ _flyingBalls.remove(_eatingBall);
+ _sceneBalls.push_back(_eatingBall);
+ _numSwallowed++;
+ const int swallowed = _numSwallowed;
+ _eatingBall = nullptr;
+ if (swallowed >= _numToWin) {
+ _arcadeStarted = false;
+ warnOnce("CFPController::FlurryArcadeEnd (the analytics events of the arcade) is not ported");
+ _flyAway = true;
+ }
+ }
+}
+
+// CSc09Controller::StartEating (171974): the ball has reached the gulper, it opens its mouth
+void Sc09Controller::startEating(AniObject *ball) {
+ g_ngi->arcadeInterface().incCounter();
+ if (_gulperPresent) {
+ _eatingBall = ball;
+ if (_gulper) {
+ _gulper->stopMovement();
+ moveToStatic(_gulper, ST_GLT_SIT);
+ warnOnce("CBehaviorController::OnSetQueue is not ported (CSc09Controller::StartEating)");
+ MessageQueue *queue = _scene->findMessageQueue(QU_SC9_EATBALL);
+ if (queue) {
+ MessageQueue *copy = new MessageQueue(queue, 0, 0);
+ runQueueCopy(_scene, copy, 2, nullptr);
+ }
+ }
+ }
+}
+
+// CSc09Controller::CanShowHelp (1719F4): the arcade interface is hidden
+bool Sc09Controller::canShowHelp() {
+ return g_ngi->arcadeInterface().getState() == ArcadeInterface::kHidden;
+}
+
+// CSc09Controller::DoStopShoot (171A04)
+void Sc09Controller::doStopShoot() {
+ if (!_scene->_motionController->_isEnabled) {
+ warnOnce("CHintManager::HideHint is not ported");
+ hero()->setStatic(ST_MAN9_SHOOT);
+ hero()->startMovement(MV_MAN9_ENDSHOOT, 0, -1);
+ _shootIdle = 0;
+ g_ngi->arcadeInterface().scrollOut();
+ for (int i = 0; i < _hangerCount && i < (int)_hangers.size(); i++) {
+ _hangers[i].damping = 0.99f;
+ _hangers[0].timer = 0;
+ }
+ _scene->_motionController->activate();
+ getGameLoaderInteractionController()->enable();
+ }
+}
+
+// CSc09Controller::DoFlyAway (171A98): the gulper has eaten enough, it flies away
+void Sc09Controller::doFlyAway() {
+ g_ngi->arcadeInterface().scrollOut();
+ warnOnce("CAchievementsManager::AddActivatingCounter for ACHIEVEMENT_ARCADE_9 is not ported");
+ _flyAway = false;
+ _gulper->stopMovement();
+ moveToStatic(_gulper, ST_GLT_SIT);
+ _gulper->startMovement(MV_GLT_FLYAWAY, 0, -1);
+ g_ngi->setState(sO_Jug, g_ngi->getStateValue(sO_Jug, sO_Unblocked));
+ g_ngi->setState(sO_RightStairs_9, g_ngi->getStateValue(sO_RightStairs_9, sO_IsOpened));
+ warnOnce("CHintManager::HideHint is not ported");
+ _gulperPresent = false;
+ doStopShoot();
+ doUpdatePath();
+}
+
+// CSc09Controller::DoWinArcade (171C18): the gulper is there: the arcade is won at once (the key W)
+void Sc09Controller::doWinArcade() {
+ if (_gulper->_flags & 4) {
+ doStopShoot();
+ _gulper->setStatic(ST_GLT_SIT);
+ _gulper->startMovement(MV_GLT_FLYAWAY, 0, -1);
+ g_ngi->_exitManager->setExitState(PIC_SC9_URTRUBA, 1);
+ g_ngi->setState(sO_Jug, g_ngi->getStateValue(sO_Jug, sO_Unblocked));
+ g_ngi->setState(sO_RightStairs_9, g_ngi->getStateValue(sO_RightStairs_9, sO_IsOpened));
+ _gulperPresent = false;
+ doUpdatePath();
+ warnOnce("CHintManager::HideHint is not ported");
+ }
+}
+
+// CSc09Controller::SkipArcade (171D20): the balls burst, the gulper flies away
+void Sc09Controller::skipArcade() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::skipArcade();
+ return;
+ }
+ g_ngi->arcadeInterface().scrollOut();
+ if (_gulper->_flags & 4) {
+ if (!_skipArcade)
+ doStopShoot();
+ for (uint i = 0; i < _flyingBalls.size(); i++)
+ doExplodeBall(_flyingBalls.front());
+ if (_gulper->_movement && movementId(_gulper) == MV_GLT_EAT) {
+ _skipArcade = true;
+ return;
+ }
+ } else {
+ if (!_skipArcade)
+ doStopShoot();
+ for (uint i = 0; i < _flyingBalls.size(); i++)
+ doExplodeBall(_flyingBalls.front());
+ }
+ _flyAway = false;
+ if (_gulper->_flags & 4) {
+ _gulper->stopMovement();
+ moveToStatic(_gulper, ST_GLT_SIT);
+ _gulper->startMovement(MV_GLT_FLYAWAY, 0, -1);
+ }
+ g_ngi->setState(sO_Jug, g_ngi->getStateValue(sO_Jug, sO_Unblocked));
+ g_ngi->setState(sO_RightStairs_9, g_ngi->getStateValue(sO_RightStairs_9, sO_IsOpened));
+ warnOnce("CHintManager::HideHint is not ported");
+ _gulperPresent = false;
+ _skipArcade = false;
+ _arcadeStarted = false;
+ doUpdatePath();
+ warnOnce("CFPController::FlurryArcadeSkip (the analytics events of the arcade) is not ported");
+}
+
+// CSc09Controller::CountBallFlight (171F04)
+void Sc09Controller::countBallFlight(uint32 elapsed) {
+ const uint count = _hangers.size();
+ for (uint n = 0; n < _flyingBalls.size(); n++) {
+ AniObject *ball = _flyingBalls.front();
+ _flyingBalls.pop_front();
+ _flyingBalls.push_back(ball);
+ const Common::Point center = ball->getCenter();
+ const float x = (float)center.x + (float)((float)elapsed * _ballSpeed);
+ const float y = (float)center.y;
+ ball->setCenter(Common::Point((int)x, (int)y));
+ if (x <= 1398.0f || _eatingBall || !_gulperPresent) {
+ bool explode = false;
+ if (_gulperPresent || x <= 1600.0f) {
+ for (uint i = 0; i < count; i++) {
+ if (_hangers[i].ani->hit((int)x, (int)y)) {
+ const int frame = getCurFrame(_hangers[i].ani);
+ if (frame > 13 && frame <= 26) {
+ explode = true;
+ break;
+ }
+ }
+ if (i != 0)
+ warnOnce("CHintManager::SetHideCondition is not ported");
+ }
+ } else {
+ explode = true;
+ }
+ if (explode)
+ doExplodeBall(ball);
+ } else {
+ startEating(ball);
+ }
+ }
+}
+
+// CSc09Controller::DoStartShoot (172040)
+void Sc09Controller::doStartShoot() {
+ _spitter->stopMovement();
+ const float targetX = (float)_spitter->getCenter().x - 10.0f;
+ const float targetY = (float)_spitter->getCenter().y + 145.0f;
+ _shootIdle = 0;
+ if (fabsf(targetX - (float)hero()->getCenter().x) > 3.0f || fabsf(targetY - (float)hero()->getCenter().y) > 3.0f) {
+ MessageQueue *queue = mctlStartMove((int)targetX, (int)targetY, true, ST_MAN_UP, false);
+ if (queue)
+ queue->addCommandToEnd(messageCommand("MSG_SC9_PLVCLICK"));
+ } else {
+ if (!hero()->_movement) {
+ _spitter->setStatic(ST_PLV_SIT);
+ _spitter->_flags &= ~4;
+ hero()->startMovement(MV_MAN9_STARTSHOOT, 0, -1);
+ g_ngi->stopAllSoundInstances(SND_9_006);
+ moveVisun(0, 100, 1);
+ moveVisun(1, 100, 350);
+ moveVisun(2, 100, 700);
+ moveVisun(3, 100, 1050);
+ }
+ _follow = nullptr;
+ _targetX = 800.0f - (float)_scene->_x;
+ _scene->_motionController->deactivate();
+ warnOnce("CFPController::FlurryArcadeStart (the analytics events of the arcade) is not ported");
+ _arcadeStarted = true;
+ getGameLoaderInteractionController()->disable();
+ if (_gulperPresent) {
+ g_ngi->arcadeInterface().init(132.0f, -100.0f, 64.0f, 0.0f, 3, 0, true);
+ g_ngi->arcadeInterface().setCounter(_numSwallowed);
+ g_ngi->arcadeInterface().scrollIn();
+ warnOnce("CHintManager::ShowHint is not ported");
+ }
+ }
+}
+
+// CSc09Controller::ReadSettingsXml (172B1C)
+void Sc09Controller::readSettingsXml() {
+ Sc09SettingsParser settings(_numToWin, _ballSpeed, _hangerCount, _hangerStep, _hangerSpeedK);
+ if (!settings.loadFile("data/sc_9_settings.xml") || !settings.parse())
+ warning("Could not read sc_9_settings.xml");
+}
+
+// CSc09Controller::OnShow (172604): only the camera margins are active
+void Sc09Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+ if (!controllerRunsSceneLogic())
+ return;
+
+ warnOnce("CHelp::SetChapter is not ported");
+ g_ngi->_chapterManager->setActiveChapter(3);
+ if (!g_ngi->_taskManager->isSceneVisited(_scene->_sceneId)) {
+ g_ngi->_chapterManager->showChapterDialog("CHAPTER_3", true);
+ g_ngi->_taskManager->activateTask("FEED_GLOTATEL_SC9");
+ }
+ g_ngi->_taskManager->visitScene(_scene->_sceneId);
+ if (_scene->_currentEntranceId == 0 && !(_spitter->_flags & 4)) {
+ const float x = (float)_spitter->getCenter().x - 10.0f;
+ const float y = (float)_spitter->getCenter().y + 145.0f;
+ hero()->setCenter(Common::Point((int)x, (int)y));
+ hero()->setStatic(ST_MAN_UP);
+ }
+ _spitter->_flags |= 4;
+ _eatingBall = nullptr;
+ _numSwallowed = 0;
+ _gulperPresent = true;
+ doUpdatePath();
+ _gulper->_flags |= 4;
+ _gulper->setStatic(ST_GLT_SIT);
+ _gulper->setPosition(Common::Point(1537, 182));
+ _gulper->_z = 20;
+ _onLadder = false;
+ _dragIndex = -1;
+ _dragPhase = -1;
+ _dragMaxPhase = -1000;
+ _flyAway = false;
+ while (!_flyingBalls.empty()) {
+ _flyingBalls.front()->_flags &= ~4;
+ _flyingBalls.pop_front();
+ }
+ while (!_sceneBalls.empty()) {
+ _sceneBalls.front()->_flags &= ~4;
+ _sceneBalls.pop_front();
+ }
+ for (uint i = 0; i < _hangers.size(); i++) {
+ AniObject *ani = _hangers[i].ani;
+ if (ani->_copyId != 0) {
+ // CAniObject::RemoveThis (EEB54): CScene::RemoveAni, then the destructor
+ _scene->removeAni(ani);
+ delete ani;
+ }
+ }
+ _hangers.clear();
+
+ AniObject *original = _scene->findAniObjectById(ANI_VISUNCHIK, 0);
+ original->_hitAlpha = 128;
+ moveToStatic(original, ST_VSN_NORMAL);
+ Visunchik first;
+ first.ani = original;
+ first.phase = 0;
+ first.field4 = 0;
+ first.velocity = 0;
+ first.damping = 1.0f;
+ first.timer = 0;
+ _hangers.push_back(first);
+ for (int i = 1; i < _hangerCount; i++) {
+ AniObject *copy = new AniObject(original);
+ copy->_flags |= 4;
+ const float x = (float)(_hangerStep * i) + (float)original->getCenter().x;
+ const float y = (float)original->getCenter().y;
+ copy->setCenter(Common::Point((int)x, (int)y));
+ // CScene::AddAni(copy, 0): the copy number is the amount of objects with this id
+ copy->assignCopyId(&_scene->_aniObjects);
+ _scene->addAni(copy, true);
+ Visunchik hanger;
+ hanger.ani = copy;
+ hanger.phase = 0;
+ hanger.field4 = 0;
+ hanger.velocity = 0;
+ hanger.damping = 1.0f;
+ hanger.timer = 0;
+ _hangers.push_back(hanger);
+ }
+
+ while (!_sceneBalls.empty())
+ _sceneBalls.pop_front();
+ AniObject *ball = _scene->findAniObjectById(ANI_BALL9, 0);
+ _sceneBalls.push_back(ball);
+ for (int i = 4; i != 0; i--) {
+ AniObject *copy = new AniObject(ball);
+ _sceneBalls.push_back(copy);
+ copy->assignCopyId(&_scene->_aniObjects);
+ _scene->addAni(copy, true);
+ }
+
+ g_ngi->setState(sO_RightStairs_9, g_ngi->getStateValue(sO_RightStairs_9, sO_IsClosed));
+ GameVar *objectStates = g_ngi->getGameLoaderGameVar()->getSubVarByName("OBJSTATES");
+ GameVar *eggs = objectStates ? objectStates->getSubVarByName(sO_GulpedEggs) : nullptr;
+ _eggs[0] = eggs ? eggs->getSubVarByName(sO_Egg1) : nullptr;
+ _eggs[1] = eggs ? eggs->getSubVarByName(sO_Egg2) : nullptr;
+ _eggs[2] = eggs ? eggs->getSubVarByName(sO_Egg3) : nullptr;
+ g_ngi->_exitManager->setExitState(PIC_SC9_URTRUBA, 0);
+ g_ngi->lift().enableButton(sO_Level1, kLiftButton1Normal);
+ _shootIdle = 0;
+ g_ngi->_exitManager->setExitAngle(PIC_SC9_LADDER_R, 0.0f);
+}
+
+// CSc09Controller::OnSceneInit (172C48): the settings, the animations of the scene
+void Sc09Controller::onSceneInit() {
+ FPController::onSceneInit();
+ _numToWin = 3;
+ _hangerCount = 4;
+ _hangerStep = 75;
+ _ballSpeed = 0.12f;
+ _hangerSpeedK = 0.05f;
+ readSettingsXml();
+ _gulper = _scene->findAniObjectById(ANI_GLOTATEL, 0);
+ _spitter = _scene->findAniObjectById(ANI_PLEVATEL, 0);
+ _grit = _scene->findAniObjectById(ANI_GRIT_9, 0);
+}
+
+// CSc09Controller::OnKeyUp (172CB0): W wins the arcade, Q skips it
+void Sc09Controller::onKeyUp(uint32 key) {
+ FPController::onKeyUp(key);
+ if (!controllerRunsSceneLogic())
+ return;
+ if (key == 87)
+ doWinArcade();
+ else if (key == 81)
+ skipArcade();
+}
+
+// CSc09Controller::GetCursorType (172CD8): the lift, the arrow of the ladder, the shooting
+int Sc09Controller::getCursorType(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::getCursorType(x, y);
+ if (g_ngi->lift().getCursorType(x, y))
+ return 116;
+ CursorController *cursor = g_ngi->_inputController;
+ if (cursor->getInteractHitObjectId() == PIC_SC9_LADDER_R) {
+ if ((float)hero()->getCenter().y < 350.0f)
+ return 2;
+ return 4;
+ }
+ if (hero()->_statics && hero()->_statics->_staticsId == ST_MAN9_SHOOT) {
+ if (_spitter->hit((int)cursor->_hotSceneX, (int)cursor->_hotSceneY))
+ return 1;
+ }
+ return FPController::getCursorType(x, y);
+}
+
+// CSc09Controller::UpdateScroll (172D68)
+void Sc09Controller::updateScroll() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::updateScroll();
+ return;
+ }
+ const float targetX = (float)_spitter->getCenter().x - 10.0f;
+ const float targetY = (float)_spitter->getCenter().y;
+ if (fabsf(targetX - (float)hero()->getCenter().x) > 20.0f || fabsf((float)(targetY + 145.0f) - (float)hero()->getCenter().y) > 20.0f) {
+ if (_follow != nullptr) {
+ FPController::updateScroll();
+ return;
+ }
+ }
+ if (_spitter->_flags & 4) {
+ _follow = hero();
+ _targetX = 0;
+ }
+}
+
+// CSc09Controller::OnUpdate (172E0C): the hangers and the balls move in steps of 41 ms
+void Sc09Controller::onUpdate(uint32 elapsed) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onUpdate(elapsed);
+ return;
+ }
+ FPController::onUpdate(elapsed);
+ if (!hero()->_movement && hero()->_statics && hero()->_statics->_staticsId == ST_MAN9_SHOOT)
+ _shootIdle += elapsed;
+ if ((uint32)_shootIdle > 9999) {
+ doStopShoot();
+ if (_arcadeStarted) {
+ warnOnce("CFlurryEventManager (the analytics events of the arcade: lose_count) is not ported");
+ _arcadeStarted = false;
+ }
+ }
+ _updateTime += elapsed;
+ while ((uint32)_updateTime > 41) {
+ _updateTime -= 41;
+ updateVisuns(41);
+ countloopVisuns(41);
+ countBallFlight(41);
+ }
+ if (_dragIndex >= 0) {
+ _shootIdle = 0;
+ updateDragVisun();
+ }
+ if (_flyAway && !_gulper->_movement) {
+ _skipArcade = false;
+ doFlyAway();
+ }
+ if (_skipArcade && !_gulper->_movement && (_gulper->_flags & 4))
+ skipArcade();
+ if (!_gulperPresent) {
+ if (!_gulper->_movement)
+ _gulper->_flags &= ~4;
+ }
+}
+
+// CSc09Controller::OnRender (173920): the arcade interface over the scene
+void Sc09Controller::onRender(Common::Point scroll) {
+ FPController::onRender(scroll);
+ if (g_ngi->arcadeInterface().getState() != ArcadeInterface::kHidden)
+ g_ngi->arcadeInterface().render();
+ renderPassage();
+}
+
+// CSc09Controller::OnMouseLKeyDown (173110): a hanger is grabbed
+bool Sc09Controller::onMouseLKeyDown(uint32 id, float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::onMouseLKeyDown(id, x, y);
+ _dragIndex = -1;
+ if (!getGameLoaderInteractionController()->_enabled)
+ return FPController::onMouseLKeyDown(id, x, y);
+ GameObject *hit = g_ngi->_inputController->getInteractHitObject();
+ bool grabbed = false;
+ for (uint i = 0; i < _hangers.size(); i++) {
+ Visunchik &hanger = _hangers[i];
+ if (hanger.ani == hit) {
+ _dragIndex = i;
+ _dragPhase = hanger.phase;
+ _dragMaxPhase = hanger.phase;
+ _dragStartX = x;
+ _dragStartY = y;
+ hanger.damping = 0.99f;
+ hanger.timer = 0;
+ g_ngi->playSound(SND_9_018, 0);
+ grabbed = true;
+ break;
+ }
+ }
+ updateVisuns(0);
+ if (!grabbed)
+ return FPController::onMouseLKeyDown(id, x, y);
+ return true;
+}
+
+// CSc09Controller::OnMouseLKeyUp (1731DC)
+bool Sc09Controller::onMouseLKeyUp(uint32 id, float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::onMouseLKeyUp(id, x, y);
+ _touching = false;
+ _dragged = false;
+ const int oldDragIndex = _dragIndex;
+ GameObject *hit = g_ngi->_inputController->getInteractHitObject();
+ bool handled = false;
+ if (hit) {
+ if ((uint16)hit->_id == ANI_VISUNCHIK) {
+ for (uint i = 0; i < _hangers.size(); i++) {
+ if (_hangers[i].ani == hit) {
+ if (getCurFrame(_hangers[i].ani) == 18)
+ _hangers[i].ani->setStatic(ST_VSN_RIGHT);
+ }
+ }
+ handled = true;
+ }
+ }
+ _dragIndex = -1;
+
+ bool feed = false;
+ bool done = false;
+ if (hit) {
+ // the whole word of the original (+12) is compared: the copy number is 0
+ if (hit->_id == ANI_GLOTATEL && hit->_copyId == 0) {
+ feed = true;
+ done = true;
+ } else if (hit->_id == ANI_PLEVATEL && hit->_copyId == 0) {
+ _shootIdle = 0;
+ doStartShoot();
+ handled = true;
+ feed = true;
+ done = true;
+ }
+ }
+ if (!done) {
+ if (hero()->_statics && hero()->_statics->_staticsId == ST_MAN9_SHOOT) {
+ if (_spitter->hit((int)x, (int)y))
+ doShoot();
+ }
+ if (canInterruptManQueue()) {
+ Interact *under = findInteractionUnderCursor();
+ if (_onLadder) {
+ if (under) {
+ bool other = false;
+ if (under->_actionName != "INT_282")
+ other = under->_actionName != "INT_281";
+ if (other) {
+ const bool opened = g_ngi->getStateId(sO_RightStairs_9) == g_ngi->getStateValue(sO_RightStairs_9, sO_IsOpened);
+ if (!opened)
+ runInteractionWithMouse("INT_234", x, y);
+ else
+ runInteractionWithMouse("INT_232", x, y);
+ handled = true;
+ }
+ }
+ } else if (under) {
+ bool ladder = true;
+ if (under->_actionName != "INT_282")
+ ladder = under->_actionName == "INT_281";
+ if (ladder) {
+ const bool opened = g_ngi->getStateId(sO_RightStairs_9) == g_ngi->getStateValue(sO_RightStairs_9, sO_IsOpened);
+ if (opened) {
+ runInteractionWithMouse("INT_230", x, y);
+ handled = true;
+ }
+ }
+ }
+ }
+ }
+
+ bool activate = false;
+ if (g_ngi->getStateId(sO_Pipe_9) == g_ngi->getStateValue(sO_Pipe_9, sO_WithJug))
+ activate = feed && !g_ngi->_taskManager->isTaskClosed("FEED_GLOTATEL_SC9");
+ if (activate)
+ g_ngi->_taskManager->activateTask("FEED_GLOTATEL_SC9");
+ if (!handled && oldDragIndex == -1)
+ return FPController::onMouseLKeyUp(id, x, y);
+ return handled;
+}
+
+// CSc09Controller::OnMessage (1735DC)
+void Sc09Controller::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onMessage(message, param, queue);
+ return;
+ }
+ if (message == "MSG_SC9_SHOWBALL") {
+ doShowBall();
+ } else if (message == "MSG_SC9_EATBALL") {
+ doEatBall();
+ } else if (message == "MSG_SC9_PLVCLICK") {
+ doStartShoot();
+ } else if (message == "MSG_SC9_FLOWN") {
+ _gulperPresent = false;
+ doUpdatePath();
+ } else if (message == "MSG_TOLADDER" || message == "MSG_FROMLADDER") {
+ _onLadder = message == "MSG_TOLADDER";
+ setWeights("INT_230", "INT_232", message);
+ setWeights("INT_233", "INT_234", message);
+ } else if (message == "MSG_CMN_WINARCADE") {
+ doWinArcade();
+ } else if (message == "MSG_SC9_STARTTIOTIA") {
+ doStartTiotia();
+ } else if (message == "MSG_SC4_HIDEBOOT") {
+ AniObject *boot = _scene->findAniObjectById(ANI_SC9_BOOT, 0);
+ if (boot)
+ boot->_flags &= ~4;
+ } else if (message == "MSG_SC9_RESETBHVR") {
+ warnOnce("CBehaviorController::ResetTimer is not ported (CSc09Controller::OnMessage MSG_SC9_RESETBHVR)");
+ } else if (message == "MSG_BREAK_GRIT") {
+ if (interactionCommandNum("INT_238") != -1) {
+ AniObject *grit = _scene->findAniObjectById(ANI_GRIT_9, 0);
+ if (grit) {
+ if (grit->_movement)
+ setCurFrame(grit, 9);
+ else
+ grit->startMovement(MV_GRT9_FALL, 0, -1);
+ }
+ }
+ } else {
+ FPController::onMessage(message, param, queue);
+ }
+}
+
+// CSc09Controller::OnHide (173894)
+void Sc09Controller::onHide() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onHide();
+ return;
+ }
+ warnOnce("CFPController::FlurryArcadeClean (the analytics events of the arcade) is not ported");
+ _arcadeStarted = false;
+ hideAction(_scene, ANI_TIOTIA, 0);
+ if (g_ngi->arcadeInterface().getState() != ArcadeInterface::kHidden)
+ doStopShoot();
+ warnOnce("CHintManager::HideHint is not ported");
+ for (uint i = 0; i < _hangers.size(); i++) {
+ AniObject *ani = _hangers[i].ani;
+ if (ani->_copyId != 0)
+ ani->unloadMovements();
+ }
+ FPController::onHide();
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sc09controller.h b/engines/ngi/fullpipe/sc09controller.h
new file mode 100644
index 00000000000..181e7da2aa5
--- /dev/null
+++ b/engines/ngi/fullpipe/sc09controller.h
@@ -0,0 +1,124 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SC09CONTROLLER_H
+#define NGI_FULLPIPE_SC09CONTROLLER_H
+
+#include "common/array.h"
+#include "common/list.h"
+
+#include "ngi/fullpipe/fpcontroller.h"
+
+namespace NGI {
+
+class GameVar;
+
+// CSc09Controller: the arcade of scene 9 (STUBs in the .cpp)
+class Sc09Controller : public FPController {
+public:
+ explicit Sc09Controller(int sceneId);
+ ~Sc09Controller() override;
+
+ void cleanXml() override;
+ void checkTutorial() override;
+ void onShow() override;
+ void onHide() override;
+ void onSceneInit() override;
+ void onKeyUp(uint32 key) override;
+ int getCursorType(float x, float y) override;
+ void updateScroll() override;
+ void onUpdate(uint32 elapsed) override;
+ void onRender(Common::Point scroll) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ bool onMouseMove(uint32 id, float x, float y) override;
+ bool isInventoryEnabled() override;
+ void onRemoveCopies() override;
+ bool canShowHelp() override;
+ void skipArcade() override;
+ bool canSwipeMan(float x, float y) override;
+
+ void updateVisuns(uint32 elapsed);
+ void countloopVisuns(uint32 elapsed);
+ void moveVisun(uint index, int phase, int timer);
+ void doShoot();
+ void doStartTiotia();
+ void doUpdatePath();
+ void renderPassage();
+ void testGrit();
+ void doShowBall();
+ void updateDragVisun();
+ void doExplodeBall(AniObject *ball);
+ void doEatBall();
+ void startEating(AniObject *ball);
+ void doStopShoot();
+ void doFlyAway();
+ void doWinArcade();
+ void countBallFlight(uint32 elapsed);
+ void doStartShoot();
+
+private:
+ /** VISUNCHIK (24 bytes in the original): the animation and swing of a hanger */
+ struct Visunchik {
+ AniObject *ani = nullptr; // +0
+ int field4 = 0; // +4: 0, never read
+ int phase = 0; // +8: -85 .. 85, the frame of the swing follows it
+ float velocity = 0; // +12
+ float damping = 0; // +16: 1.0, 0.99 while the arcade is not over
+ int timer = 0; // +20: the milliseconds until the hanger swings again, 0 when it is not waiting
+ };
+
+ void readSettingsXml();
+
+ /** +216: the next tutorial of the scene */
+ Common::String _tutorial;
+ AniObject *_gulper = nullptr; // +220: ANI_GLOTATEL
+ AniObject *_spitter = nullptr; // +224: ANI_PLEVATEL
+ AniObject *_grit = nullptr; // +228: ANI_GRIT_9
+ Common::Array<Visunchik> _hangers; // +232: std::vector<VISUNCHIK *>
+ int _dragIndex = -1; // +244: the hanger that is dragged, -1 none
+ int _dragPhase = -1; // +248: its phase when it was grabbed
+ int _dragMaxPhase = -1000; // +252: the phase whose sound was not played yet, -1000 when played
+ int _numToWin = 3; // +256: the balls that the gulper eats (sc_9_settings.xml BALLS numToWin)
+ int _hangerCount = 4; // +260: VISUNCHIK count
+ int _hangerStep = 75; // +264: VISUNCHIK dX, the distance between two hangers
+ float _ballSpeed = 0.12f; // +268: BALLS speed, the pixels per millisecond
+ float _hangerSpeedK = 0.05f; // +272: VISUNCHIK speedK
+ float _dragStartX = 0; // +276: where the hanger was grabbed
+ float _dragStartY = 0; // +280
+ AniObject *_eatingBall = nullptr; // +284: the ball that the gulper eats
+ Common::List<AniObject *> _flyingBalls; // +288
+ Common::List<AniObject *> _sceneBalls; // +296: the balls that wait to be shot
+ float _hitOffsets[16]; // +304: eight (x, y) offsets around a ball, not read by any method
+ int _numSwallowed = 0; // +368: the balls that the gulper has eaten
+ bool _gulperPresent = true; // +372: the arcade runs, the hero's path is closed to the right
+ bool _onLadder = false; // +373: MSG_TOLADDER .. MSG_FROMLADDER
+ bool _flyAway = false; // +374: the gulper flies away when its movement is over
+ GameVar *_eggs[3] = { nullptr, nullptr, nullptr }; // +376..+384: Egg1 .. Egg3
+ int _updateTime = 0; // +388: ms since the hangers and balls moved, steps of 41
+ int _shootIdle = 0; // +392: ms the hero stands in the shooting pose, 10000 stops the shooting
+ bool _arcadeStarted = false; // +396: the arcade was started (the analytics events of the original)
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SC09CONTROLLER_H
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index f891f74d584..8bbea831178 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -23,6 +23,7 @@
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/sc06controller.h"
#include "ngi/fullpipe/sc08controller.h"
+#include "ngi/fullpipe/sc09controller.h"
#include "ngi/fullpipe/scenecontrollers.h"
#include "ngi/fullpipe/sc03controller.h"
#include "ngi/fullpipe/sc04controller.h"
@@ -143,15 +144,6 @@ void Sc07Controller::onShow() {
_offsetY = 300;
}
-// CSc09Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
-void Sc09Controller::onShow() {
- FPController::onShow();
- _marginX = 300;
- _marginY = 200;
- _offsetX = 400;
- _offsetY = 300;
-}
-
// CSc10Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
void Sc10Controller::onShow() {
FPController::onShow();
diff --git a/engines/ngi/fullpipe/scenecontrollers.h b/engines/ngi/fullpipe/scenecontrollers.h
index 7b422600e02..c406ffa5e1b 100644
--- a/engines/ngi/fullpipe/scenecontrollers.h
+++ b/engines/ngi/fullpipe/scenecontrollers.h
@@ -73,12 +73,6 @@ public:
void onShow() override;
};
-class Sc09Controller : public FPController {
-public:
- explicit Sc09Controller(int sceneId) : FPController(sceneId) {}
- void onShow() override;
-};
-
class Sc10Controller : public FPController {
public:
explicit Sc10Controller(int sceneId) : FPController(sceneId) {}
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 900f3590ed5..05d61400ba3 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -92,6 +92,7 @@ MODULE_OBJS = \
fullpipe/sc04controller.o \
fullpipe/sc06controller.o \
fullpipe/sc08controller.o \
+ fullpipe/sc09controller.o \
fullpipe/scene01.o \
fullpipe/scene02.o \
fullpipe/scene03.o \
Commit: ce07ebae6c090bd56d483e40e8807273ad3a92b7
https://github.com/scummvm/scummvm/commit/ce07ebae6c090bd56d483e40e8807273ad3a92b7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:03+01:00
Commit Message:
NGI: Scene 11 controller ported
Changed paths:
A engines/ngi/fullpipe/sc11controller.cpp
A engines/ngi/fullpipe/sc11controller.h
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/scenecontrollers.h
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/sc11controller.cpp b/engines/ngi/fullpipe/sc11controller.cpp
new file mode 100644
index 00000000000..23232c6d871
--- /dev/null
+++ b/engines/ngi/fullpipe/sc11controller.cpp
@@ -0,0 +1,1154 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/formats/xmlparser.h"
+#include "common/hash-str.h"
+#include "common/hashmap.h"
+
+#include "ngi/ngi.h"
+#include "ngi/objects.h"
+#include "ngi/anihandler.h"
+#include "ngi/behavior.h"
+#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/guimanager.h"
+#include "ngi/input.h"
+#include "ngi/interaction.h"
+#include "ngi/messages.h"
+#include "ngi/motion.h"
+#include "ngi/scene.h"
+#include "ngi/sound.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/sc11controller.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+namespace {
+
+// constants of the compiled code, digits as in the decompile (the doubles are not the exact pi)
+const double kPi = 3.14159265358979;
+const double kHalfPi = 1.570796326794895;
+const double kAngleStep = 0.017453292519943278;
+// largest angle that still hits the pipe (60 degrees), largest one of a lost swing (105)
+const double kHitAngle = 1.0471975511965967;
+const double kLoseAngle = 1.8325957145940441;
+// the rotation of an object that hangs straight down (the float 1.5707964f of the code)
+const float kRotationDown = 1.5707964f;
+
+// the glue of what is not ported: one warning for every place
+void stubOnce(const char *what) {
+ static Common::HashMap<Common::String, bool> reported;
+ if (!reported.contains(what)) {
+ reported[what] = true;
+ warning("STUB/untested: %s", what);
+ }
+}
+
+// CRender +8 + +24: the widescreen margin (+8 is 0 here)
+float renderMargin() {
+ return (float)g_ngi->_wideOfs;
+}
+
+// CCommand(MESSAGE) with the parameters "msg" and "param" as the XML loader makes it
+Command *messageCommand(const char *name, const char *param = nullptr) {
+ uint32 id = 0;
+ g_ngi->_gameProject->_objectIds.findId(name, id);
+ Command *command = new Command(0, kCmdMessage, id, 0, 0, 0, 0, 0, 0, 0);
+ command->_messageName = name;
+ command->_args["msg"] = name;
+ if (param) {
+ command->_args["param"] = param;
+ }
+ command->_excFlags = 2;
+ return command;
+}
+
+// CInteractionController::FindInteraction(name, 0, 0): looked up by objects, the name is checked
+Interact *findInteractionByName(const char *name, int objectId) {
+ Interact *interaction = getGameLoaderInteractionController()->findInteraction(objectId, ANI_MAN, 0);
+ if (interaction && interaction->_actionName == name) {
+ return interaction;
+ }
+ return nullptr;
+}
+
+// CScene::RunQueue(scene, queue, state, 0): the scene takes the queue (CScene::AddQueue) and runs it, the state 4 keeps the one of the queue
+void runQueueObject(Scene *scene, MessageQueue *queue, int state) {
+ queue->_scene = scene;
+ if (state != 4) {
+ queue->_interruptState = state;
+ }
+ if (!queue->run(nullptr)) {
+ delete queue;
+ }
+}
+
+// sc_11_settings.xml (CSc11Controller::ReadSettingsXml)
+class Scene11SettingsParser : public Common::XMLParser {
+public:
+ float _swingK = 3.0f;
+ float _minAngle = 70.0f;
+ float _maxAngle = 80.0f;
+ float _minSpeed = 16.0f;
+
+private:
+ CUSTOM_XML_PARSER(Scene11SettingsParser) {
+ XML_KEY(SETTINGS)
+ XML_KEY(SWING)
+ XML_PROP(swingK, false)
+ KEY_END()
+ XML_KEY(WIN)
+ XML_PROP(minAngle, false)
+ XML_PROP(maxAngle, false)
+ XML_PROP(minSpeed, false)
+ KEY_END()
+ KEY_END()
+ } PARSER_END()
+
+ bool parserCallback_SETTINGS(ParserNode *) {
+ return true;
+ }
+
+ bool parserCallback_SWING(ParserNode *node) {
+ _swingK = (float)atof(node->values.getValOrDefault("swingK", "3.0").c_str());
+ return true;
+ }
+
+ bool parserCallback_WIN(ParserNode *node) {
+ _minAngle = (float)atof(node->values.getValOrDefault("minAngle", "70.0").c_str());
+ _maxAngle = (float)atof(node->values.getValOrDefault("maxAngle", "80.0").c_str());
+ _minSpeed = (float)atof(node->values.getValOrDefault("minSpeed", "16.0").c_str());
+ return true;
+ }
+};
+
+} // End of anonymous namespace
+
+// CSc11Controller::CSc11Controller (174158)
+Sc11Controller::Sc11Controller(int sceneId) : FPController(sceneId), _tutorial("PREV_ARCADE_TUTORIAL_11") {
+ _arcadeRunning = false;
+ _field344 = 0;
+ _field348 = 0;
+ _field352 = 0;
+ _field356 = 1;
+ _font = g_ngi->getFont("dbg.xml");
+ _skipArcade = false;
+}
+
+// CSc11Controller::CleanXml (1740CC)
+void Sc11Controller::cleanXml() {
+ _tutorial = "PREV_ARCADE_TUTORIAL_11";
+}
+
+// CSc11Controller::CanSwipeMan (1740BC): byte +12 of the motion controller (+16)
+bool Sc11Controller::canSwipeMan(float x, float y) {
+ if (!controllerRunsSceneLogic()) {
+ return FPController::canSwipeMan(x, y);
+ }
+ return _scene->_motionController->_isEnabled;
+}
+
+// CSc11Controller::CanShowHelp (1740C2)
+bool Sc11Controller::canShowHelp() {
+ return !_arcadeRunning;
+}
+
+// CSc11Controller::SwingNextFunc (1742B8): the old version of the swing, nothing calls it
+void Sc11Controller::swingNextFunc(AniObject *ani) {
+ const float oldRotation = ani->_rotation;
+ float rotation = oldRotation + (_oldSwingSpeed * 0.5f);
+ if (rotation < 0.0f) {
+ _oldSwingSpeed = 0.0f;
+ rotation = 0.0f;
+ }
+ if ((double)rotation > kPi) {
+ rotation = 3.1415927f;
+ _oldSwingSpeed = 0.0f;
+ }
+ if (((double)oldRotation < kHalfPi || (double)rotation >= kHalfPi) && ((double)oldRotation >= kHalfPi || (double)rotation < kHalfPi)) {
+ if ((double)rotation > kHalfPi) {
+ _oldSwingSpeed = _oldSwingSpeed - 1.0f;
+ } else if ((double)rotation < kHalfPi) {
+ _oldSwingSpeed = _oldSwingSpeed + 1.0f;
+ }
+ } else {
+ if (_oldSwingSpeed > 1.0f) {
+ _oldSwingSpeed = _oldSwingSpeed - 1.0f;
+ } else if (_oldSwingSpeed < -1.0f) {
+ _oldSwingSpeed = _oldSwingSpeed + 1.0f;
+ } else {
+ _oldSwingSpeed = 0.0f;
+ }
+ }
+ ++_swingCounter;
+ ani->_rotation = rotation;
+}
+
+// CSc11Controller::DoEncline (1743E0): the man leans to the first side
+void Sc11Controller::doEncline() {
+ _swingMan->setStatic(ST_MAN11_SWING_1);
+ _swingDirection = 1;
+ _swingMaxAngle = 4;
+ _swingOldAngle = fabs(_swingAngle) * 0.12 / 1.6 + 0.12;
+}
+
+// CSc11Controller::DoDecline (174448): the man leans to the other side
+void Sc11Controller::doDecline() {
+ _swingMan->setStatic(ST_MAN11_SWING_2);
+ _swingDirection = 2;
+ _swingMaxAngle = -1;
+ _swingOldAngle = -(fabs(_swingAngle) * 0.12 / 1.6 + 0.12);
+}
+
+// CSc11Controller::DoUncline (1744B0): the man sits straight
+void Sc11Controller::doUncline() {
+ _swingMan->setStatic(ST_MAN11_SWING_0);
+ _swingDirection = 0;
+ _swingMaxAngle = 1;
+ _swingOldAngle = 0.0;
+}
+
+// CSc11Controller::OnArcadeClick (1744F0): BTN_ARROW_LEFT_RIGHT, the side the man leans to
+void Sc11Controller::onArcadeClick() {
+ int side = 1;
+ if (_swingDirection != 2 && (_swingDirection == 1 || (double)_swing->_rotation <= kHalfPi)) {
+ side = 2;
+ }
+ _swingDirectionPrevTurn = side;
+}
+
+// CSc11Controller::DoSwingerJumpdown (174534)
+void Sc11Controller::doSwingerJumpdown() {
+ _scene->runQueue(QU_SWR_JUMPDOWN, 2);
+ _swingerSwinging = false;
+ _swingerStands = true;
+ _swingerEdge = (int)(float)_scene->_x;
+}
+
+// CSc11Controller::LeaveSwing (174590): the man leaves the swing, the empty swing takes its place
+void Sc11Controller::leaveSwing() {
+ if (_swingDirection != 0) {
+ doUncline();
+ }
+ _swingMan->stopMovement();
+ _swingMan->_flags &= ~4;
+ _swing->_flags |= 4;
+ _swing->setStatic(ST_KCH_STATIC);
+ _swing->setCenter(Common::Point(691, 218));
+ _swing->_z = 20;
+ _swing->_rotation = _swingMan->_rotation;
+ _swingInertia = 0.03;
+}
+
+// CSc11Controller::TryHitMan (174618): the man is hit by the swing when he stands at x 345 .. 355
+void Sc11Controller::tryHitMan() {
+ if ((float)hero()->getCenter().x > 345.0f) {
+ if ((float)hero()->getCenter().x < 355.0f) {
+ hero()->setStatic(ST_MAN_RIGHT);
+ _scene->runQueueWithAni(QU_SC11_MANFALL, hero());
+ }
+ }
+}
+
+// CSc11Controller::DoShowSwing (174698)
+void Sc11Controller::doShowSwing() {
+ _swing->setStatic(ST_KCH_STATIC);
+ _swing->setCenter(Common::Point(691, 218));
+ _swing->_z = 20;
+ _swing->_flags |= 4;
+ _swing->_rotation = kRotationDown;
+ g_ngi->setState(sO_Swingie, g_ngi->getStateValue(sO_Swingie, sO_IsStandingInBoots));
+ g_ngi->_taskManager->deactivateTask("GET_SWING_SC11");
+ g_ngi->_taskManager->activateTask("FIND_EXIT_SWING_SC11");
+}
+
+// CSc11Controller::DoMoveSwinger (174784): the uncle in the boots sits down when scrolled away
+void Sc11Controller::doMoveSwinger() {
+ if (g_ngi->getStateId(sO_Swingie) == g_ngi->getStateValue(sO_Swingie, sO_IsStandingInBoots)) {
+ _swingerSwinging = false;
+ _swingerStands = false;
+ _swinger->setStatic(ST_SWR_SIT);
+ _swinger->setCenter(Common::Point(144, 389));
+ g_ngi->setState(sO_Swingie, g_ngi->getStateValue(sO_Swingie, sO_IsSitting));
+ }
+}
+
+// CSc11Controller::CheckTutorial (17485C): ARCADE_TUTORIAL_11 when the uncle is not swinging
+void Sc11Controller::checkTutorial() {
+ if (_tutorial == "UNDEF") {
+ return;
+ }
+ if (g_ngi->_sceneStack.size() != 1) {
+ return;
+ }
+ if (g_ngi->_tutorialManager->activateTutorial(_tutorial)) {
+ return;
+ }
+ const Common::String previous = _tutorial;
+ if (_tutorial != "PREV_ARCADE_TUTORIAL_11") {
+ _tutorial = "UNDEF";
+ }
+ if (previous != _tutorial) {
+ checkTutorial();
+ }
+}
+
+// CSc11Controller::SwingNextFunc2 (174940): one physics step of the swing for an object
+void Sc11Controller::swingNextFunc2(AniObject *ani) {
+ const double angle = _swingAngle;
+ const float oldRotation = ani->_rotation;
+ float rotation = (float)(angle * kPi / (double)_swingK + kHalfPi);
+ if (rotation < 0.0f) {
+ rotation = 0.0f;
+ }
+ if ((double)rotation > kPi) {
+ rotation = 3.1415927f;
+ }
+ const double oldAngle = _swingOldAngle;
+ _swingAngleDiff = (angle - oldAngle) * -490.00000000000006;
+ if (_skipArcade) {
+ _swingSpeed = _swingSpeed + (_swingAngleDiff + _swingAngleDiff) * 0.0042;
+ } else {
+ _swingSpeed = _swingAngleDiff * 0.0042 + _swingSpeed - (_swingAngleDiff * 0.0042 + _swingSpeed) * _swingInertia;
+ }
+ const double newAngle = angle + _swingSpeed * 0.0042;
+ if (newAngle < -1.5) {
+ _swingSpeed = 0.0;
+ _swingAngle = -1.5;
+ _swingAngleDiff = 0.0;
+ } else {
+ _swingAngle = newAngle;
+ }
+ if (_swingAngle > 1.5) {
+ _swingSpeed = 0.0;
+ _swingAngle = 1.5;
+ _swingAngleDiff = 0.0;
+ }
+ if ((double)fabsf((float)_swingMaxAngle - rotation) < kAngleStep && _swingSpeed != 0.0) {
+ if (fabs(_swingSpeed) < 2.5) {
+ _swingSpeed = 0.0;
+ _swingAngleDiff = 0.0;
+ _swingAngle = oldAngle;
+ }
+ }
+ ++_swingCounter;
+ if (_arcadeRunning) {
+ if ((uint32)_hintCounter <= 720) {
+ ++_hintCounter;
+ }
+ }
+ if (_swingSpeed != 0.0) {
+ const int oldInt = (int)oldRotation;
+ const bool newSide = (double)rotation - kHalfPi >= 0.0;
+ const bool oldSide = (double)oldInt - kHalfPi >= 0.0;
+ if (newSide != oldSide && _arcadeRunning) {
+ // the sound of the swing passing the middle: SND_11_031 going back, SND_11_020 going forth
+ if ((float)oldInt >= rotation) {
+ const Sound *playing = g_ngi->findSound(SND_11_031);
+ if (!(playing && playing->isPlaying())) {
+ g_ngi->stopAllSoundInstances(SND_11_020);
+ g_ngi->playSound(SND_11_031, 0);
+ }
+ } else {
+ const Sound *playing = g_ngi->findSound(SND_11_020);
+ if (!(playing && playing->isPlaying())) {
+ g_ngi->stopAllSoundInstances(SND_11_031);
+ g_ngi->playSound(SND_11_020, 0);
+ }
+ }
+ }
+ }
+ ani->_rotation = rotation;
+}
+
+// CSc11Controller::DoRestartMan (174C50): the man stands up after the jump
+void Sc11Controller::doRestartMan() {
+ _scene->runQueueWithAni(QU_SC11_RESTARTMAN, hero(), 2);
+ getGameLoaderInteractionController()->_enabled = true;
+ _scene->_motionController->activate();
+}
+
+// CSc11Controller::OnCloseUpsell (174C78)
+void Sc11Controller::onCloseUpsell() {
+ doRestartMan();
+ _scrollToTube = false;
+ _field267 = false;
+}
+
+// CSc11Controller::DoPutBoot (174C8C): the second boot is only put when the first one is there
+void Sc11Controller::doPutBoot() {
+ if (_boots->_flags & 4) {
+ if (_boots->_statics->_staticsId != ST_BTS11_ONE) {
+ return;
+ }
+ getGameLoaderInteractionController()->_enabled = false;
+ _scene->_motionController->deactivate();
+ _scene->_behaviorController->enableAllQueuesForAni(_scene->findAniObjectById(ANI_MAN, 0), 0);
+ _scene->runQueueWithAni(QU_SC11_PUTBOOT2, hero(), 2);
+ } else {
+ _scene->runQueueWithAni(QU_SC11_PUTBOOT1, hero(), 2);
+ }
+}
+
+// CSc11Controller::HideButtons (174CE8): the arcade buttons slide out (GUI positions are integers)
+void Sc11Controller::hideButtons(uint32 elapsed) {
+ stubOnce("CSc11Controller::HideButtons/UpdateButtons: the positions of GuiElement are integers, the original has floats (the steps of 0.15 per millisecond are truncated)");
+ if (_leftRightButton->_visible) {
+ const float width = (float)_leftRightButton->_size.x;
+ float x = (float)_leftRightButton->_pos.x;
+ _leftRightButton->setPos(Common::Point((int)(x - (float)((float)elapsed * 0.15f)), 495));
+ x = (float)_leftRightButton->_pos.x;
+ if (x < (-width - renderMargin())) {
+ _leftRightButton->hide();
+ }
+ }
+ if (_jumpButton->_visible) {
+ float x = (float)_jumpButton->_pos.x;
+ const int screenWidth = g_ngi->gameWidth();
+ _jumpButton->setPos(Common::Point((int)(x + (float)((float)elapsed * 0.15f)), 495));
+ x = (float)_jumpButton->_pos.x;
+ if (x > (renderMargin() + (float)screenWidth)) {
+ _jumpButton->hide();
+ }
+ }
+}
+
+// CSc11Controller::UpdateButtons (174E10): the buttons slide in while the arcade runs, else out
+void Sc11Controller::updateButtons(uint32 elapsed) {
+ if (!_arcadeRunning || _skipArcade) {
+ hideButtons(elapsed);
+ return;
+ }
+ stubOnce("CSc11Controller::HideButtons/UpdateButtons: the positions of GuiElement are integers, the original has floats (the steps of 0.15 per millisecond are truncated)");
+ if (_leftRightButton->_visible) {
+ const float x = (float)_leftRightButton->_pos.x;
+ const float limit = 50.0f - renderMargin();
+ if (x >= limit) {
+ _leftRightButton->setPos(Common::Point((int)limit, 495));
+ } else {
+ _leftRightButton->setPos(Common::Point((int)(x + (float)((float)elapsed * 0.15f)), 495));
+ }
+ } else {
+ const float width = (float)_leftRightButton->_size.x;
+ const float x = (-width) - 50.0f;
+ _leftRightButton->setPos(Common::Point((int)(x - renderMargin()), 495));
+ _leftRightButton->show();
+ }
+ const int screenWidth = g_ngi->gameWidth();
+ if (_jumpButton->_visible) {
+ const float width = (float)_jumpButton->_size.x;
+ const float x = (float)_jumpButton->_pos.x;
+ const float limit = ((float)screenWidth - width) - 50.0f;
+ if (x <= (renderMargin() + limit)) {
+ _jumpButton->setPos(Common::Point((int)(renderMargin() + limit), 495));
+ } else {
+ _jumpButton->setPos(Common::Point((int)(x - (float)((float)elapsed * 0.15f)), 495));
+ }
+ } else {
+ _jumpButton->setPos(Common::Point((int)(renderMargin() + ((float)screenWidth + 50.0f)), 495));
+ _jumpButton->show();
+ }
+}
+
+// CSc11Controller::DoRetire (175000): the arcade is lost at once, the man jumps from the swing
+void Sc11Controller::doRetire() {
+ _arcadeRunning = false;
+ _hint->_flags &= ~4;
+ _scrollToTube = false;
+ _field267 = false;
+ g_ngi->_aniHandler->detachAllObjects();
+ g_ngi->_aniHandler->attachObject(hero()->_id);
+ getGameLoaderInteractionController()->_enabled = true;
+ _scene->_motionController->activate();
+ _swingAngleDiff = 0.0;
+ _swingSpeed = 0.0;
+ _swingOldAngle = 0.0;
+ _swingAngle = 0.0;
+ _swingMan->_flags &= ~4;
+ _swing->setStatic(ST_KCH_STATIC);
+ _swing->setCenter(Common::Point(691, 218));
+ _swing->_z = 20;
+ _swing->_flags |= 4;
+ hero()->_flags |= 4;
+ hero()->setStatic(ST_MAN11_SWING);
+ // CVisibleObject::SetPos(685, 373, z): the z of the hero stays
+ hero()->setPosition(Common::Point(685, 373));
+ hero()->startMovement(MV_MAN11_JUMPFROMSWING, 0, -1);
+ _follow = hero();
+ stubOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
+ stubOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
+}
+
+// CSc11Controller::DoWinArcade (175128): the key W of the original; SC_5 through TrubaUp
+void Sc11Controller::doWinArcade() {
+ if (_arcadeRunning) {
+ _arcadeRunning = false;
+ leaveSwing();
+ g_ngi->_gameLoader->setScene(SC_5, TrubaUp);
+ stubOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
+ stubOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
+ }
+}
+
+// CSc11Controller::StartArcade (175170): the man is on the swing and the arcade starts
+void Sc11Controller::startArcade() {
+ // CFPController::FlurryArcadeStart("ANI_SWINGER"): the analytics events are not ported
+ ArcadeInterface &arcade = g_ngi->arcadeInterface();
+ if (arcade.getState() == ArcadeInterface::kHidden) {
+ arcade.init(380.0f, -100.0f, 64.0f, 0.0f, 1, 0, true);
+ arcade.scrollIn();
+ }
+ stubOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
+ _arcadeRunning = true;
+ _scene->_motionController->deactivate();
+ getGameLoaderInteractionController()->_enabled = false;
+ _follow->_flags &= ~4;
+ _swingCounter = 0;
+ _swingInertia = 0.01;
+ _swing->_flags &= ~4;
+ _swing->stopMovement();
+ hero()->stopMovement();
+ hero()->_flags &= ~4;
+ _swingMan->_flags |= 4;
+ _swingMan->_z = 20;
+ _swingMan->setStatic(ST_MAN11_SWING_0);
+ _swingMan->setCenter(Common::Point(691, 218));
+ _swingMan->_rotation = kRotationDown;
+ _targetX = (1150.0f - ((float)_scene->_x + (float)g_ngi->gameWidth())) + renderMargin();
+ g_ngi->_aniHandler->detachAllObjects();
+ stubOnce("CHintManager::ShowHint / SetHideCondition (CSc11Controller::StartArcade): the hints are not ported");
+}
+
+// CSc11Controller::DoJumpToTruba (175308): the man jumps over the pipe, then SC_5
+void Sc11Controller::doJumpToTruba() {
+ _targetX = 1400.0f - ((float)_scene->_x + (float)g_ngi->gameWidth());
+ _scrollToTube = true;
+ leaveSwing();
+ g_ngi->_aniHandler->detachAllObjects();
+ g_ngi->_aniHandler->attachObject(hero()->_id);
+ const double angle = _swingAngle;
+ const double sine = sin(angle);
+ const double cosine = cos(angle);
+ hero()->_flags |= 4;
+ const float x = (float)(691.0 - sine * 267.0);
+ const float y = (float)(cosine * 267.0 + 218.0);
+ hero()->setPosition(Common::Point((int)x, (int)y));
+ hero()->_z = 10;
+ hero()->setStatic(ST_MAN11_STARTJUMP);
+ _follow = hero();
+
+ MakeQueueStruct mkQueue;
+ mkQueue.ani = hero();
+ mkQueue.staticsId2 = ST_MAN_1PIX;
+ mkQueue.movementId = MV_MAN11_JUMPHIT;
+ mkQueue.cycleCount = 1;
+ mkQueue.x1 = 1400;
+ mkQueue.y1 = 0;
+ mkQueue.destZ = 10;
+ mkQueue.flags = 66;
+ MessageQueue *queue = g_ngi->_aniHandler->makeRunQueue(&mkQueue);
+ if (queue) {
+ queue->_interruptState = 2;
+ _crySound = SND_11_024;
+ Scene *tubeScene = g_ngi->findScene(SC_5);
+ AniObject *biglu = tubeScene ? tubeScene->findAniObjectById(ANI_BIGLUK, 0) : nullptr;
+ if (biglu && biglu->_statics->_staticsId == ST_BLK_OPEN) {
+ if (g_ngi->getStateId(sO_WeirdWacko) == g_ngi->getStateValue(sO_WeirdWacko, sO_WithPlunger)) {
+ queue->addCommandToEnd(messageCommand("MSG_SHOW_UPSELL", "2"));
+ }
+ }
+ Command *pause = new Command(0, kCmdPause, 36, 0, 0, 0, 1, 0, 0, 0);
+ pause->_args["delay"] = "36";
+ pause->_excFlags = 2;
+ queue->addCommandToEnd(pause);
+ Command *setScene = new Command(SC_5, kCmdSetScene, TrubaUp, 0, 0, 0, 0, 0, 0, 0);
+ setScene->_args["scene"] = "SC_5";
+ setScene->_args["entr"] = "TrubaUp";
+ setScene->_excFlags = 2;
+ queue->addCommandToEnd(setScene);
+ runQueueObject(_scene, queue, 4);
+ if (g_ngi->getStateId(sO_Swingie) == g_ngi->getStateValue(sO_Swingie, sO_IsStandingInCorner)) {
+ g_ngi->setState(sO_Swingie, g_ngi->getStateValue(sO_Swingie, sO_IsSitting));
+ }
+ g_ngi->setState(sO_DudeHasJumped, g_ngi->getStateValue(sO_DudeHasJumped, sO_Yes));
+ }
+}
+
+// CSc11Controller::SkipArcade (1756D0): the first call marks the arcade as skipped, the physics
+// then bring the swing to the winning angle (OnUpdate) and it is called again
+void Sc11Controller::skipArcade() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::skipArcade();
+ return;
+ }
+ g_ngi->arcadeInterface().scrollOut();
+ if (_skipArcade) {
+ // the analytics events (total_moves, first_move, FlurryArcadeSkip) are not ported
+ doJumpToTruba();
+ _arcadeRunning = false;
+ _hint->_flags &= ~4;
+ stubOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
+ _scene->_behaviorController->disableAllMusic();
+ stubOnce("CBehaviorController::EnableSound (CSc11Controller): SND_MUS_7 / SND_MUS_11 are not switched on");
+ stubOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
+ } else {
+ _skipArcade = true;
+ }
+}
+
+// CSc11Controller::DoBumpTruba (1757D8): too early, the man hits the pipe from below
+void Sc11Controller::doBumpTruba(double angle) {
+ leaveSwing();
+ g_ngi->_aniHandler->detachAllObjects();
+ g_ngi->_aniHandler->attachObject(hero()->_id);
+ const double sine = sin(_swingAngle);
+ const double cosine = cos(_swingAngle);
+ hero()->_flags |= 4;
+ const float x = (float)(691.0 - sine * 267.0);
+ const float y = (float)(cosine * 267.0 + 218.0);
+ hero()->setPosition(Common::Point((int)x, (int)y));
+ hero()->_z = 10;
+ hero()->setStatic(ST_MAN11_STARTJUMP);
+
+ MakeQueueStruct mkQueue;
+ mkQueue.ani = hero();
+ mkQueue.staticsId2 = ST_MAN_1PIX;
+ mkQueue.movementId = MV_MAN11_JUMPOVER;
+ mkQueue.cycleCount = 1;
+ mkQueue.x1 = 1163;
+ mkQueue.y1 = 837 - (int)(angle * 153.0);
+ mkQueue.flags = 78;
+ MessageQueue *queue = g_ngi->_aniHandler->makeRunQueue(&mkQueue);
+ if (queue) {
+ queue->_interruptState = 2;
+ _crySound = SND_11_022;
+ queue->addCommandToEnd(messageCommand("MSG_SC11_RESTARTMAN"));
+ runQueueObject(_scene, queue, 4);
+ }
+}
+
+// CSc11Controller::DoMissTruba (175980): too late or too slow, the man hits the wall
+void Sc11Controller::doMissTruba(double angle) {
+ leaveSwing();
+ g_ngi->_aniHandler->detachAllObjects();
+ g_ngi->_aniHandler->attachObject(hero()->_id);
+ if (angle < 0.0) {
+ angle = 0.0;
+ } else if (angle > 1.0) {
+ angle = 1.0;
+ }
+ const double sine = sin(_swingAngle);
+ const double cosine = cos(_swingAngle);
+ hero()->_flags |= 4;
+ const float x = (float)(691 - (int)(sine * 267.0));
+ const float y = (float)((int)(cosine * 267.0) + 218);
+ hero()->setPosition(Common::Point((int)x, (int)y));
+ hero()->_z = 0;
+ hero()->setStatic(ST_MAN11_STARTJUMP);
+
+ MakeQueueStruct mkQueue;
+ mkQueue.ani = hero();
+ mkQueue.staticsId2 = ST_MAN_1PIX;
+ mkQueue.movementId = MV_MAN11_JUMPHIT;
+ mkQueue.cycleCount = 1;
+ mkQueue.x1 = (int)(angle * 214.0) + 1017;
+ mkQueue.y1 = 700;
+ mkQueue.flags = 78;
+ MessageQueue *queue = g_ngi->_aniHandler->makeRunQueue(&mkQueue);
+ if (queue) {
+ queue->_interruptState = 2;
+ _crySound = SND_11_022;
+ queue->addCommandToEnd(messageCommand("MSG_SC11_RESTARTMAN"));
+ runQueueObject(_scene, queue, 4);
+ }
+}
+
+// CSc11Controller::OnRButtonDown (175B58): the man jumps (BTN_ARROW_JUMP): win, bump or miss
+// and speed. The analytics events (FlurryArcadeEnd ...) are not ported.
+void Sc11Controller::onRButtonDown() {
+ if (!_arcadeRunning) {
+ return;
+ }
+ const float angle = _swingMan->_rotation;
+ if (angle < 0.0f || (double)angle >= kHitAngle) {
+ if ((double)angle >= kHitAngle) {
+ if ((double)angle < kLoseAngle) {
+ if (fabs(_swingSpeed) <= (double)_minSpeed) {
+ doRetire();
+ g_ngi->arcadeInterface().scrollOut();
+ }
+ }
+ }
+ return;
+ }
+
+ if (angle < _minAngle || angle > _maxAngle || _swingSpeed > (double)_minSpeed) {
+ stubOnce("CSc11Controller::OnRButtonDown: CAchievementsManager::BlockActivatingCounter for ACHIEVEMENT_ARCADE_11, the achievements are not ported");
+ if (angle >= _minAngle || _swingSpeed < (double)_minSpeed) {
+ doMissTruba((double)(float)(angle / _minAngle) * _swingSpeed / (double)_minSpeed);
+ } else {
+ doBumpTruba((double)(float)(angle / _minAngle));
+ }
+ g_ngi->arcadeInterface().scrollOut();
+ } else {
+ stubOnce("CSc11Controller::OnRButtonDown: CAchievementsManager::AddActivatingCounter for ACHIEVEMENT_ARCADE_11, the achievements are not ported");
+ g_ngi->arcadeInterface().incCounter();
+ doJumpToTruba();
+ g_ngi->arcadeInterface().incCounter();
+ }
+ _arcadeRunning = false;
+ _hint->_flags &= ~4;
+ stubOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
+ _scene->_behaviorController->disableAllMusic();
+ stubOnce("CBehaviorController::EnableSound (CSc11Controller): SND_MUS_7 / SND_MUS_11 are not switched on");
+ stubOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
+ // the analytics events of a lost arcade are not ported
+}
+
+// CSc11Controller::TryPutBoot (1760A0): the hero walks to (348, 498) and puts the boot on
+void Sc11Controller::tryPutBoot() {
+ if (fabsf(348.0f - (float)hero()->getCenter().x) <= 3.0f) {
+ if (fabsf(498.0f - (float)hero()->getCenter().y) <= 3.0f) {
+ if (!hero()->_movement && hero()->_statics->_staticsId == ST_MAN_RIGHT) {
+ doPutBoot();
+ return;
+ }
+ }
+ }
+ MessageQueue *started = mctlStartMove(348, 498, true, ST_MAN_RIGHT, false);
+ if (started) {
+ started->addCommandToEnd(messageCommand("MSG_SC11_PUTBOOT"));
+ }
+}
+
+// CSc11Controller::DoManToPipe (176190): the hero walks to (158, 524), then INT_070
+void Sc11Controller::doManToPipe() {
+ const Common::Point center = hero()->getCenter();
+ if (getGameLoaderInteractionController()->_enabled) {
+ if (fabsf(158.0f - (float)center.x) > 3.0f || fabsf(524.0f - (float)center.y) > 3.0f) {
+ MessageQueue *started = mctlStartMove(158, 524, true, ST_MAN_RIGHT, true);
+ if (started) {
+ started->addCommandToEnd(messageCommand("MSG_SC11_MAN_TO_PIPE"));
+ started->_interruptState = 2;
+ }
+ } else {
+ Interact *interaction = findInteractionByName("INT_070", PIC_SC11_LTRUBA);
+ if (interaction && interaction->_messageQueue) {
+ // CScene::RunQueueWithAni(scene, queue, hero, 2)
+ MessageQueue *queue = new MessageQueue(interaction->_messageQueue, 0, 0);
+ queue->_scene = _scene;
+ queue->_interruptState = 2;
+ if (!queue->run(hero())) {
+ delete queue;
+ }
+ }
+ }
+ }
+}
+
+// CSc11Controller::ReadSettingsXml (1762B0): the angles of the file are in degrees
+void Sc11Controller::readSettingsXml() {
+ Scene11SettingsParser settings;
+ if (!settings.loadFile("data/sc_11_settings.xml") || !settings.parse()) {
+ warning("Could not read sc_11_settings.xml");
+ return;
+ }
+ _swingK = settings._swingK;
+ _minAngle = (float)((double)settings._minAngle * kPi / 180.0);
+ _maxAngle = (float)((double)settings._maxAngle * kPi / 180.0);
+ _minSpeed = settings._minSpeed;
+}
+
+// the tutorial part of OnShow: the arcade tutorial when the uncle is not swinging
+void Sc11Controller::setArcadeTutorial() {
+ if (_tutorial == "PREV_ARCADE_TUTORIAL_11") {
+ const int state = g_ngi->getStateId(sO_Swingie);
+ if (state != g_ngi->getStateValue(sO_Swingie, sO_IsSwinging) && state != g_ngi->getStateValue(sO_Swingie, sO_IsSwingingWithBoot)) {
+ _tutorial = "ARCADE_TUTORIAL_11";
+ }
+ }
+}
+
+// CSc11Controller::OnShow (176428): camera margins and tutorial, the rest with the scene logic
+void Sc11Controller::onShow() {
+ FPController::onShow();
+ const bool logic = controllerRunsSceneLogic();
+ if (logic) {
+ if (!g_ngi->_taskManager->isSceneVisited(_scene->_sceneId)) {
+ g_ngi->_taskManager->activateTask("GET_SWING_SC11");
+ }
+ g_ngi->_taskManager->visitScene(_scene->_sceneId);
+ readSettingsXml();
+ }
+ _marginY = 200;
+ _marginX = 300;
+ _offsetY = 300;
+ _offsetX = 400;
+ if (!logic) {
+ setArcadeTutorial();
+ return;
+ }
+
+ _swinger = _scene->findAniObjectById(ANI_SWINGER, 0);
+ _boots = _scene->findAniObjectById(ANI_BOOTS_11, 0);
+ _swingMan = _scene->findAniObjectById(ANI_MAN11, 0);
+ _swing = _scene->findAniObjectById(ANI_KACHELI, 0);
+ _hint = _scene->findPictureObjectById(PIC_SC11_HINT, 0);
+ _hint->_flags &= ~4;
+ if (!_leftRightButton) {
+ _leftRightButton = _scene->_guiManager->getElement("BTN_ARROW_LEFT_RIGHT");
+ }
+ if (_leftRightButton->_visible) {
+ _leftRightButton->hide();
+ }
+ if (!_jumpButton) {
+ _jumpButton = _scene->_guiManager->getElement("BTN_ARROW_JUMP");
+ }
+ if (_jumpButton->_visible) {
+ _jumpButton->hide();
+ }
+ _arcadeRunning = false;
+ _scrollToTube = false;
+ _field267 = false;
+ _hintCounter = 0;
+ _swingerEdge = 0;
+ _crySound = 0;
+ _swingAngle = 0.0;
+ _swingOldAngle = 0.0;
+ _swingSpeed = 0.0;
+ _swingAngleDiff = 0.0;
+ _swingInertia = 0.01;
+ _field276 = 0;
+ _oldSwingSpeed = 0.0f;
+ _swingCounter = 0;
+ _swingCounterPrevTurn = 0;
+ _swingDirection = 0;
+ _swingDirectionPrevTurn = 0;
+ _skipArcade = false;
+
+ const int swingieState = g_ngi->getStateId(sO_Swingie);
+ if (swingieState == g_ngi->getStateValue(sO_Swingie, sO_IsSwinging) || swingieState == g_ngi->getStateValue(sO_Swingie, sO_IsSwingingWithBoot)) {
+ _swingerSwinging = true;
+ _swingerStands = false;
+ } else {
+ if (swingieState == g_ngi->getStateValue(sO_Swingie, sO_IsStandingInBoots) || swingieState == g_ngi->getStateValue(sO_Swingie, sO_IsStandingInCorner)) {
+ _swingerSwinging = false;
+ _swingerStands = true;
+ _swinger->setStatic(ST_SWR_STAND3);
+ } else {
+ if (swingieState == g_ngi->getStateValue(sO_Swingie, sO_IsSitting)) {
+ g_ngi->setState(sO_Swingie, g_ngi->getStateValue(sO_Swingie, sO_IsSitting));
+ _swingerSwinging = false;
+ _swingerStands = false;
+ _swinger->stopMovement();
+ _swinger->setStatic(ST_SWR_SIT);
+ _swinger->setCenter(Common::Point(144, 389));
+ } else {
+ _swingerSwinging = false;
+ _swingerStands = false;
+ _swinger->stopMovement();
+ _swinger->setStatic(ST_SWR_SITBALD);
+ _swinger->setCenter(Common::Point(144, 415));
+ }
+ }
+ _boots->_flags &= ~4;
+ }
+
+ if (!_swingerSwinging) {
+ _swing->setStatic(ST_KCH_STATIC);
+ _swing->setCenter(Common::Point(691, 218));
+ _swing->_z = 20;
+ _swing->_rotation = kRotationDown;
+ _swingMan->_flags &= ~4;
+ _swing->_flags |= 4;
+ }
+
+ if (g_ngi->getStateId(sO_DudeHasJumped) == g_ngi->getStateValue(sO_DudeHasJumped, sO_Yes)) {
+ _scene->_behaviorController->disableAllMusic();
+ stubOnce("CBehaviorController::EnableSound (CSc11Controller): SND_MUS_7 / SND_MUS_11 are not switched on");
+ }
+
+ if (_scene->_currentEntranceId == 0) {
+ if (!(hero()->_flags & 4)) {
+ hero()->_flags |= 4;
+ if (hero()->_statics->_staticsId == ST_MAN11_SWING) {
+ hero()->setStatic(ST_MAN_RIGHT);
+ }
+ hero()->setCenter(Common::Point(493, 522));
+ hero()->_z = 10;
+ }
+ }
+
+ setArcadeTutorial();
+ _scene->_behaviorController->enableAllQueuesForAni(_scene->findAniObjectById(ANI_MAN, 0), 1);
+}
+
+// CSc11Controller::OnHide (177298): saving on, the arcade interface leaves, left pipe exit off
+// until the scene is shown again. The analytics events (FlurryArcadeClean ...) are not ported.
+void Sc11Controller::onHide() {
+ const bool logic = controllerRunsSceneLogic();
+ if (logic) {
+ stubOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
+ g_ngi->arcadeInterface().scrollOut();
+ }
+ FPController::onHide();
+ if (logic) {
+ g_ngi->_exitManager->resetExitIntersect(PIC_SC11_LTRUBA, false);
+ stubOnce("CAniObject::UnloadMovement / CPreloadManager::OnUnloadMove (CSc11Controller::OnHide): MV_KCH_MOVE2 is not unloaded");
+ stubOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
+ }
+}
+
+// CSc11Controller::OnKeyUp (176A98): keys 87 (win) and 81 (skip), for the tests of the original
+void Sc11Controller::onKeyUp(uint32 key) {
+ FPController::onKeyUp(key);
+ if (!controllerRunsSceneLogic()) {
+ return;
+ }
+ if (key == 87) {
+ if (!_swingerSwinging && !_swingerStands) {
+ doWinArcade();
+ }
+ } else if (key == 81) {
+ skipArcade();
+ }
+}
+
+// CSc11Controller::GetCursorType (176AD0): the key cursor over the swinger with the boot
+int Sc11Controller::getCursorType(float x, float y) {
+ if (!controllerRunsSceneLogic()) {
+ return FPController::getCursorType(x, y);
+ }
+ if (g_ngi->_inputController->isObjectHit(_swinger) && g_ngi->_inputController->getObjectId() == PIC_INV_BOOT) {
+ return 102;
+ }
+ return FPController::getCursorType(x, y);
+}
+
+// CSc11Controller::OnUpdate (176B10): buttons, touch commands, physics every 60 ms, the uncle
+void Sc11Controller::onUpdate(uint32 elapsed) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onUpdate(elapsed);
+ return;
+ }
+ FPController::onUpdate(elapsed);
+ updateButtons(elapsed);
+ if (_arcadeRunning) {
+ if (_swingCounterPrevTurn > 0 && _swingCounter - _swingCounterPrevTurn > 72) {
+ doUncline();
+ _swingDirectionPrevTurn = 0;
+ _swingCounterPrevTurn = 0;
+ }
+ }
+ if (!_skipArcade) {
+ if (_arcadeRunning && _swingDirection != _swingDirectionPrevTurn && _swingCounterPrevTurn > 0 && _swingCounter - _swingCounterPrevTurn > 2) {
+ if (_swingDirectionPrevTurn == 1) {
+ if (_swingDirection == 0) {
+ doEncline();
+ } else {
+ doUncline();
+ }
+ } else if (_swingDirectionPrevTurn == 2) {
+ if (_swingDirection == 0) {
+ doDecline();
+ } else {
+ doUncline();
+ }
+ }
+ _swingCounterPrevTurn = _swingCounter;
+ }
+ } else {
+ if (_swingSpeed <= 0.0 || _swingSpeed > 1.5) {
+ if (_swingSpeed >= -1.5 && _swingSpeed <= 0.0) {
+ doDecline();
+ }
+ } else {
+ doEncline();
+ }
+ if (_swingMan->_rotation >= _minAngle && _swingMan->_rotation <= _maxAngle && _swingSpeed <= (double)_minSpeed) {
+ skipArcade();
+ _skipArcade = false;
+ }
+ }
+
+ _swingTimer += elapsed;
+ if (_swingTimer > 60) {
+ _swingTimer -= 60;
+ swingNextFunc2(_swingMan);
+ swingNextFunc2(_swing);
+ if ((_swing->_flags & 4) && !_swing->_movement) {
+ _swing->setCenter(Common::Point(691, 218));
+ }
+ }
+
+ if (_swingerStands) {
+ if ((float)_scene->_x >= 534.0f && _swingerEdge <= 533) {
+ doMoveSwinger();
+ }
+ _swingerEdge = (int)(float)_scene->_x;
+ }
+
+ if (!_arcadeRunning && !_swingerSwinging) {
+ if (_swingSpeed == 0.0) {
+ if (fabs((double)_swing->_rotation - kHalfPi) < kAngleStep) {
+ _swing->setStatic(ST_KCH_STATIC);
+ }
+ }
+ }
+
+ if (!_arcadeRunning && _swingerSwinging) {
+ if (!_swinger->_movement) {
+ if ((_boots->_flags & 4) && _boots->_statics->_staticsId == ST_BTS11_2) {
+ doSwingerJumpdown();
+ } else {
+ _swinger->startMovement(MV_SWR_SWING, 0, -1);
+ }
+ }
+ }
+}
+
+// CSc11Controller::OnMouseLKeyUp (176DC0): the boot on the swinger
+bool Sc11Controller::onMouseLKeyUp(uint32 id, float x, float y) {
+ const bool result = FPController::onMouseLKeyUp(id, x, y);
+ if (!controllerRunsSceneLogic()) {
+ return result;
+ }
+ if (!result && !_arcadeRunning && _swingerSwinging) {
+ if (g_ngi->_inputController->getInteractHitObject() == _swinger) {
+ if (g_ngi->_inputController->getObjectId() == PIC_INV_BOOT) {
+ tryPutBoot();
+ }
+ }
+ }
+ return result;
+}
+
+// CSc11Controller::OnMouseRKeyUp (176E10)
+bool Sc11Controller::onMouseRKeyUp(uint32 id, float x, float y) {
+ return FPController::onMouseRKeyUp(id, x, y);
+}
+
+// CSc11Controller::OnRender (176E18): the arcade interface over the scene
+void Sc11Controller::onRender(Common::Point scroll) {
+ FPController::onRender(scroll);
+ if (g_ngi->arcadeInterface().getState() != ArcadeInterface::kHidden) {
+ g_ngi->arcadeInterface().render();
+ }
+}
+
+// CSc11Controller::OnMessage (176E3C)
+void Sc11Controller::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onMessage(message, param, queue);
+ return;
+ }
+ if (message == "MSG_SC11_SHOWSWING") {
+ doShowSwing();
+ } else if (message == "MSG_SC11_MANTOSWING") {
+ startArcade();
+ } else if (message == "MSG_SC11_RESTARTMAN") {
+ doRestartMan();
+ } else if (message == "MSG_SC11_HITMAN") {
+ tryHitMan();
+ } else if (message == "MSG_SC11_PUTBOOT") {
+ tryPutBoot();
+ } else if (message == "MSG_SC11_MANCRY") {
+ g_ngi->playSound(_crySound, 0);
+ _crySound = 0;
+ } else if (message == "MSG_SC11_SITSWINGER") {
+ if (g_ngi->getStateId(sO_Swingie) == g_ngi->getStateValue(sO_Swingie, sO_IsStandingInBoots) ||
+ g_ngi->getStateId(sO_Swingie) == g_ngi->getStateValue(sO_Swingie, sO_IsStandingInCorner)) {
+ g_ngi->setState(sO_Swingie, g_ngi->getStateValue(sO_Swingie, sO_IsSitting));
+ }
+ } else if (message == "MSG_CMN_WINARCADE") {
+ doWinArcade();
+ } else if (message == "MSG_DO_START_ARCADE") {
+ _swingerSwinging = false;
+ _swingerStands = false;
+ _swinger->stopMovement();
+ _swinger->setStatic(ST_SWR_SITBALD);
+ _swinger->setCenter(Common::Point(144, 415));
+ _swing->setStatic(ST_KCH_STATIC);
+ _swing->setCenter(Common::Point(691, 218));
+ _swing->_z = 20;
+ _swingMan->_flags &= ~4;
+ _swing->_flags |= 4;
+ } else if (message == "MSG_SC11_MAN_TO_PIPE") {
+ doManToPipe();
+ } else {
+ FPController::onMessage(message, param, queue);
+ }
+}
+
+// CSc11Controller::OnGuiEvent (177110): the buttons of the arcade
+void Sc11Controller::onGuiEvent(const Common::String &id, const Common::String &event) {
+ FPController::onGuiEvent(id, event);
+ if (!controllerRunsSceneLogic()) {
+ return;
+ }
+ if (event == "press") {
+ if (id == "BTN_ARROW_LEFT_RIGHT") {
+ onArcadeClick();
+ _swingCounterPrevTurn = _swingCounter;
+ } else if (id == "BTN_ARROW_JUMP") {
+ onRButtonDown();
+ }
+ }
+}
+
+// CSc11Controller::UpdateScroll (1771A4): the camera follows the arcade targets, or the man to
+// the pipe after the jump
+void Sc11Controller::updateScroll() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::updateScroll();
+ return;
+ }
+ bool smooth = _arcadeRunning;
+ if (!smooth) {
+ // INT_071 (the man jumps to the swing) runs while its current command (+56) is not -1
+ stubOnce("CSc11Controller::UpdateScroll: the running state of the queue of the interaction INT_071 (CMessageQueue +56) is not known, it counts as not running");
+ }
+ _smooth = smooth;
+ if (_follow) {
+ const Common::Point center = _follow->getCenter();
+ _heroCenterX = (float)center.x;
+ _heroCenterY = (float)center.y;
+ const float sceneX = (float)_scene->_x;
+ const int width = g_ngi->gameWidth();
+ if (_scrollToTube) {
+ const int right = width + (int)sceneX;
+ if (_heroCenterX > (float)(right - 300)) {
+ _scene->_x = (int)((float)((_heroCenterX - (float)right) + 300.0f) + (float)_scene->_x);
+ }
+ limitScroll();
+ } else if (!_arcadeRunning) {
+ FPController::updateScroll();
+ }
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sc11controller.h b/engines/ngi/fullpipe/sc11controller.h
new file mode 100644
index 00000000000..6ed0c23fa94
--- /dev/null
+++ b/engines/ngi/fullpipe/sc11controller.h
@@ -0,0 +1,134 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SC11CONTROLLER_H
+#define NGI_FULLPIPE_SC11CONTROLLER_H
+
+#include "ngi/fullpipe/fpcontroller.h"
+
+namespace NGI {
+
+class BitmapFont;
+class GuiElement;
+class PictureObject;
+
+/** CSc11Controller: the swing arcade; field offsets as in the original */
+class Sc11Controller : public FPController {
+public:
+ explicit Sc11Controller(int sceneId);
+
+ void cleanXml() override;
+ bool canSwipeMan(float x, float y) override;
+ bool canShowHelp() override;
+ void checkTutorial() override;
+ void skipArcade() override;
+ void onShow() override;
+ void onHide() override;
+ void onKeyUp(uint32 key) override;
+ int getCursorType(float x, float y) override;
+ void onUpdate(uint32 elapsed) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ bool onMouseRKeyUp(uint32 id, float x, float y) override;
+ void onRender(Common::Point scroll) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+ void onGuiEvent(const Common::String &id, const Common::String &event) override;
+ void updateScroll() override;
+
+ /** The right button (BTN_ARROW_JUMP or right mouse): jump off the swing, or the arcade is lost */
+ void onRButtonDown();
+ /** The upsell dialog was closed (CFPController has no virtual of this name) */
+ void onCloseUpsell();
+
+ /** The old SwingNextFunc2 (no caller in the original) */
+ void swingNextFunc(AniObject *ani);
+ void doEncline();
+ void doDecline();
+ void doUncline();
+ void onArcadeClick();
+ void doSwingerJumpdown();
+ void leaveSwing();
+ void tryHitMan();
+ void doShowSwing();
+ void doMoveSwinger();
+ /** The physics of the swing, one step (every 60 ms, for the man and for the empty swing) */
+ void swingNextFunc2(AniObject *ani);
+ void doRestartMan();
+ void doPutBoot();
+ void hideButtons(uint32 elapsed);
+ void updateButtons(uint32 elapsed);
+ void doRetire();
+ void doWinArcade();
+ void startArcade();
+ void doJumpToTruba();
+ /** angle: how far the swing was from the angle that wins, 0 .. 1 */
+ void doBumpTruba(double angle);
+ void doMissTruba(double angle);
+ void tryPutBoot();
+ void doManToPipe();
+ void readSettingsXml();
+
+private:
+ /** The part of OnShow that decides the next tutorial */
+ void setArcadeTutorial();
+
+ /** +216: the next tutorial of the scene */
+ Common::String _tutorial;
+ float _swingK = 3.0f; // +220: sc_11_settings.xml SWING swingK, the softness of the swing
+ float _minAngle = 0.0f; // +224: WIN minAngle (radians), set by ReadSettingsXml
+ float _maxAngle = 0.0f; // +228: WIN maxAngle (radians)
+ float _minSpeed = 16.0f; // +232: WIN minSpeed
+ AniObject *_swingMan = nullptr; // +236: ANI_MAN11, the hero on the swing
+ AniObject *_swing = nullptr; // +240: ANI_KACHELI, the empty swing
+ AniObject *_swinger = nullptr; // +244: ANI_SWINGER, the uncle that sits (and swings) in the corner
+ AniObject *_boots = nullptr; // +248: ANI_BOOTS_11
+ PictureObject *_hint = nullptr; // +252: PIC_SC11_HINT
+ GuiElement *_leftRightButton = nullptr; // +256: BTN_ARROW_LEFT_RIGHT
+ GuiElement *_jumpButton = nullptr; // +260: BTN_ARROW_JUMP
+ bool _swingerSwinging = true; // +264: the uncle swings
+ bool _swingerStands = false; // +265: the uncle stands in the corner
+ bool _scrollToTube = false; // +266: the camera follows the hero to the pipe (DoJumpToTruba)
+ bool _field267 = false; // +267: set to 0 by OnShow, DoRetire and OnCloseUpsell, never read
+ int _swingerEdge = 0; // +268: scene position at the last look (DoMoveSwinger runs past 534)
+ int _crySound = 0; // +272: the sound of the cry (MSG_SC11_MANCRY)
+ int _field276 = 0; // +276: never read
+ float _oldSwingSpeed = 0.0f; // +280: the speed of the old SwingNextFunc
+ int _swingCounter = 0; // +284: the steps of the swing (SwingNextFunc2)
+ int _swingCounterPrevTurn = 0; // +288: the counter at the last touch
+ int _swingDirection = 0; // +292: 0 straight, 1 leaning to one side, 2 to the other
+ int _swingDirectionPrevTurn = 0; // +296: the side of the last touch
+ int _hintCounter = 0; // +300: the steps of the arcade until the hint shows (720)
+ double _swingAngle = 0.0; // +304: the angle of the swing (-1.5 .. 1.5)
+ double _swingOldAngle = 0.0; // +312: the angle the swing is pulled to
+ double _swingSpeed = 0.0; // +320
+ double _swingAngleDiff = 0.0; // +328
+ double _swingInertia = 0.01; // +336: the damping of the speed
+ int _field344; // +344: never read
+ int _field348; // +348: never read
+ int _field352; // +352: never read
+ int _field356; // +356: never read
+ int _swingMaxAngle = 1; // +360: 1 straight, 4 leaning to the first side, -1 to the other
+ uint32 _swingTimer = 0; // +364: the milliseconds of the physics (a step every 60)
+ const BitmapFont *_font = nullptr; // +368: "dbg.xml", never used
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SC11CONTROLLER_H
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index 8bbea831178..1db1502adf7 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -24,6 +24,7 @@
#include "ngi/fullpipe/sc06controller.h"
#include "ngi/fullpipe/sc08controller.h"
#include "ngi/fullpipe/sc09controller.h"
+#include "ngi/fullpipe/sc11controller.h"
#include "ngi/fullpipe/scenecontrollers.h"
#include "ngi/fullpipe/sc03controller.h"
#include "ngi/fullpipe/sc04controller.h"
@@ -153,15 +154,6 @@ void Sc10Controller::onShow() {
_offsetY = 300;
}
-// CSc11Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
-void Sc11Controller::onShow() {
- FPController::onShow();
- _marginX = 300;
- _marginY = 200;
- _offsetX = 400;
- _offsetY = 300;
-}
-
// CSc12Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
void Sc12Controller::onShow() {
FPController::onShow();
diff --git a/engines/ngi/fullpipe/scenecontrollers.h b/engines/ngi/fullpipe/scenecontrollers.h
index c406ffa5e1b..fe8509ead89 100644
--- a/engines/ngi/fullpipe/scenecontrollers.h
+++ b/engines/ngi/fullpipe/scenecontrollers.h
@@ -79,12 +79,6 @@ public:
void onShow() override;
};
-class Sc11Controller : public FPController {
-public:
- explicit Sc11Controller(int sceneId) : FPController(sceneId) {}
- void onShow() override;
-};
-
class Sc12Controller : public FPController {
public:
explicit Sc12Controller(int sceneId) : FPController(sceneId) {}
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 05d61400ba3..4d22e2f67e9 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -93,6 +93,7 @@ MODULE_OBJS = \
fullpipe/sc06controller.o \
fullpipe/sc08controller.o \
fullpipe/sc09controller.o \
+ fullpipe/sc11controller.o \
fullpipe/scene01.o \
fullpipe/scene02.o \
fullpipe/scene03.o \
Commit: 2bc61068629258bab5a7d4655d09872e3fccf8b0
https://github.com/scummvm/scummvm/commit/2bc61068629258bab5a7d4655d09872e3fccf8b0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 14 controller ported
Changed paths:
A engines/ngi/fullpipe/sc14controller.cpp
A engines/ngi/fullpipe/sc14controller.h
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/sc14controller.cpp b/engines/ngi/fullpipe/sc14controller.cpp
new file mode 100644
index 00000000000..0ac50659c10
--- /dev/null
+++ b/engines/ngi/fullpipe/sc14controller.cpp
@@ -0,0 +1,1064 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/formats/xmlparser.h"
+#include "common/hash-str.h"
+#include "common/hashmap.h"
+
+#include "ngi/ngi.h"
+#include "ngi/behavior.h"
+#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/input.h"
+#include "ngi/interaction.h"
+#include "ngi/messages.h"
+#include "ngi/motion.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/lift.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/sc14controller.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+namespace {
+
+void warnOnce(const char *what) {
+ static Common::HashMap<Common::String, bool> reported;
+ if (!reported.contains(what)) {
+ reported[what] = true;
+ warning("STUB/untested: %s", what);
+ }
+}
+
+// CCommand(START_MOVEMENT, wait = 1) with the parameters aniId, moveId and copy
+Command *movementCommand(int aniId, int movementId, int copyId = 0) {
+ Command *command = new Command(aniId, kCmdStartMovement, movementId, 0, 0, 0, 1, 0, 0, 0);
+ command->_param = copyId;
+ command->_excFlags |= 2;
+ return command;
+}
+
+// CCommand(PAUSE, wait = 1) with the parameter delay (milliseconds)
+Command *pauseCommand(int delay) {
+ Command *command = new Command(0, kCmdPause, delay, 0, 0, 0, 1, 0, 0, 0);
+ command->_excFlags |= 2;
+ return command;
+}
+
+// CCommand(HIDE) with the parameters objId and copy
+Command *hideCommand(int objectId, int copyId) {
+ Command *command = new Command(objectId, kCmdHide, 0, 0, 0, 0, 0, 0, 0, 0);
+ command->_param = copyId;
+ command->_excFlags |= 2;
+ return command;
+}
+
+// CCommand(MESSAGE) with the parameter msg: its name goes to the controllers (CScene::Message), its id to the scene handlers
+Command *messageCommand(const char *name) {
+ uint32 id = 0;
+ g_ngi->_gameProject->_objectIds.findId(name, id);
+ Command *command = new Command(0, kCmdMessage, id, 0, 0, 0, 0, 0, 0, 0);
+ command->_messageName = name;
+ command->_excFlags |= 2;
+ return command;
+}
+
+// CScene::RunQueueWithAni(scene, queue, ani, interruptState): the object gets the queue (CVisibleObject::SetQueue), the queue runs
+void runQueueWithAni(MessageQueue *queue, AniObject *ani, int interruptState) {
+ queue->_interruptState = interruptState;
+ if (!queue->run(ani))
+ delete queue;
+}
+
+// CAniObject::SetStatic(statics, mirror): the mirror flag of the original (+64) is the bit 8 of the flags here
+void setStaticMirror(AniObject *ani, int staticsId, bool mirror) {
+ ani->setStatic(staticsId);
+ if (mirror)
+ ani->_flags |= 8;
+ else
+ ani->_flags &= ~8;
+}
+
+// CAniObject::MoveToStatic: an instant chain of the linked movements in the original, SetStatic in this engine (docs/android-support.md)
+void moveToStatic(AniObject *ani, int staticsId) {
+ ani->setStatic(staticsId);
+}
+
+// CAniObject::GetCurFrame: -1 without a movement
+int getCurFrame(const AniObject *ani) {
+ return ani->_movement ? ani->_movement->_curFrame : -1;
+}
+
+// CAniObject::SetCurFrame(frame, a3, a4): a running movement goes to the frame. a3 and a4 of the original (the flags of CMovement::SetCurFrame) are not modelled.
+void setCurFrame(AniObject *ani, int frame) {
+ if (ani->_movement)
+ ani->_movement->setCurFrame(frame);
+}
+
+// CMessageQueue::Stop(queue, 0): the engine has no counterpart (the queue is not stopped)
+void stopQueue(MessageQueue *) {
+ warnOnce("CMessageQueue::Stop: the queue is not stopped (CSc14Controller::DoWinArcade, CSc14Controller::DoManSurrender)");
+}
+
+// CFPController::HideAction: the copies of the object from the one given on are stopped and hidden, until a copy is missing
+void hideAction(Scene *scene, int objectId, int copyId) {
+ AniObject *ani;
+ do {
+ ani = scene->findAniObjectById(objectId, copyId);
+ if (ani) {
+ ani->stopMovement();
+ ani->_flags &= ~4;
+ }
+ copyId++;
+ } while (ani);
+}
+
+// CInteractionController::FindInteraction(scene, objectId, -1) and CInteract::Run(scene): the engine finds the interaction with the object, it has no
+// CInteract::Run (handleObjectInteraction also walks the hero, which Run does not do), so it is not run. True when the interaction was found.
+bool runInteraction(int objectId) {
+ Interact *interaction = getGameLoaderInteractionController()->findInteraction(objectId, 0, 0);
+ if (!interaction)
+ return false;
+ warnOnce("CInteract::Run: the interaction of the object is found but not run (CSc14Controller)");
+ return true;
+}
+
+// CInteractionController::FindInteraction(name, 0, 0): queue of interaction INT_239 has started
+bool isInteractionQueueRunning(const char *) {
+ warnOnce("CSc14Controller::OnMessage MSG_BREAK_GRIT: the state of the queue of the interaction INT_239 is not known");
+ return false;
+}
+
+// CBaseSettings::SetSaving (the saving is switched off while the arcade runs)
+void setSaving(bool) {
+ warnOnce("CBaseSettings::SetSaving (CSc14Controller)");
+}
+
+// CHintManager::ShowHint / HideHint / SetHideCondition
+void showHint() {
+ warnOnce("CHintManager::ShowHint (CSc14Controller)");
+}
+
+void hideHint() {
+ warnOnce("CHintManager::HideHint (CSc14Controller)");
+}
+
+void setHintHideCondition() {
+ warnOnce("CHintManager::SetHideCondition (CSc14Controller)");
+}
+
+// CBehaviorController::EnableSound(soundId, enable)
+void enableSound(int, bool) {
+ warnOnce("CBehaviorController::EnableSound (CSc14Controller::OnShow)");
+}
+
+// CAchievementsManager::BlockActivatingCounter / AddActivatingCounter ("ACHIEVEMENT_ARCADE_14", 100)
+void blockActivatingCounter() {
+ warnOnce("CAchievementsManager::BlockActivatingCounter (CSc14Controller::DoManSurrender)");
+}
+
+void addActivatingCounter() {
+ warnOnce("CAchievementsManager::AddActivatingCounter (CSc14Controller::DoGrandmaHit)");
+}
+
+// sc_14_settings.xml (CSc14Controller::ReadSettingsXml)
+class Scene14SettingsParser : public Common::XMLParser {
+public:
+ float _grandmaFrameDelayK = 1.0f;
+ float _manFrameDelayK = 1.0f;
+ float _kickMaxDx = 180.0f;
+ float _ballSpeedK = 1.0f;
+
+private:
+ CUSTOM_XML_PARSER(Scene14SettingsParser) {
+ XML_KEY(SETTINGS)
+ XML_KEY(GRANDMA)
+ XML_PROP(frameDelayK, false)
+ KEY_END()
+ XML_KEY(MAN)
+ XML_PROP(frameDelayK, false)
+ XML_PROP(kickMaxDx, false)
+ KEY_END()
+ XML_KEY(BALL)
+ XML_PROP(speedK, false)
+ KEY_END()
+ KEY_END()
+ } PARSER_END()
+
+ bool parserCallback_SETTINGS(ParserNode *) { return true; }
+
+ bool parserCallback_GRANDMA(ParserNode *node) {
+ _grandmaFrameDelayK = (float)atof(node->values.getValOrDefault("frameDelayK", "1.0").c_str());
+ return true;
+ }
+
+ bool parserCallback_MAN(ParserNode *node) {
+ _manFrameDelayK = (float)atof(node->values.getValOrDefault("frameDelayK", "1.0").c_str());
+ _kickMaxDx = (float)atof(node->values.getValOrDefault("kickMaxDx", "180.0").c_str());
+ return true;
+ }
+
+ bool parserCallback_BALL(ParserNode *node) {
+ _ballSpeedK = (float)atof(node->values.getValOrDefault("speedK", "1.0").c_str());
+ return true;
+ }
+};
+
+} // End of anonymous namespace
+
+// CSc14Controller::CSc14Controller (17A180)
+Sc14Controller::Sc14Controller(int sceneId) : FPController(sceneId), _tutorial("ARCADE_TUTORIAL_14") {
+}
+
+// CSc14Controller::CleanXml (1786A4)
+void Sc14Controller::cleanXml() {
+ _tutorial = "ARCADE_TUTORIAL_14";
+}
+
+// CSc14Controller::CanSwipeMan (178684): not while the arcade runs, else when the hero may walk
+bool Sc14Controller::canSwipeMan(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::canSwipeMan(x, y);
+ if (!_arcadeRunning)
+ return _scene->_motionController->_isEnabled;
+ return false;
+}
+
+// CSc14Controller::CanShowHelp (17869A)
+bool Sc14Controller::canShowHelp() {
+ return !_arcadeRunning;
+}
+
+// CSc14Controller::OnGrandmaJump (1786E0): jumps forward the way she jumped back, chances swapped
+void Sc14Controller::onGrandmaJump() {
+ BehaviorMove *jumpForward = _scene->_behaviorController->getAniQueue(_grandma->_id, QU_GMA_JUMPFW);
+ BehaviorMove *jumpBack = _scene->_behaviorController->getAniQueue(_grandma->_id, QU_GMA_JUMPBK);
+ if (jumpForward && jumpBack) {
+ const uint32 percent = jumpForward->_percent;
+ jumpForward->_percent = jumpBack->_percent;
+ jumpBack->_percent = percent;
+ }
+}
+
+// CSc14Controller::ManNextFunc (178720): dragged hero, next movement frame after 83 ms * setting
+void Sc14Controller::manNextFunc(uint32 elapsed) {
+ const uint32 counted = elapsed + _manFrameElapsed;
+ _manFrameElapsed = counted;
+ const float counter = (float)counted;
+ if (counter > (float)(_manFrameDelayK * 83.0f)) {
+ _manFrameElapsed = (uint32)(float)(counter - (float)(_manFrameDelayK * 83.0f));
+ const int frame = getCurFrame(hero());
+ setCurFrame(hero(), frame + (!_manKicking ? 1 : 0));
+ }
+}
+
+// CSc14Controller::StopDragging (178780)
+void Sc14Controller::stopDragging() {
+ _manFrameTimer = false;
+ _manKicking = false;
+}
+
+// CSc14Controller::DoShowBallKickman (17878C): the ball flies from the hero to the grandma
+void Sc14Controller::doShowBallKickman() {
+ _ballX = _manX;
+ _ballY = _manY;
+ const float x = _ballX - 85.0f;
+ _ballX = x;
+ const float y = _ballY - 76.0f;
+ _ballY = y;
+ const float targetX = _grandmaX + 65.0f;
+ const float targetY = _grandmaY - 102.0f;
+ _ballDeltaX = -1.0f;
+ const int distance = (int)(-(targetX - x));
+ float divisor = (float)distance;
+ if (distance == 0)
+ divisor = 1.0f;
+ _ballDeltaY = (float)((float)(targetY - y) - (float)((float)((float)((float)distance * 0.0f) * (float)distance) * 0.5f)) / divisor;
+ _flyingBall->_flags |= 4;
+ _flyingBall->setCenter(Common::Point((int)_ballX, (int)_ballY));
+ _flyingBall->startMovement(MV_BAL14_SPIN, 0, -1);
+ _flyingBall->_z = 5;
+ _ballFlying = true;
+}
+
+// CSc14Controller::DoShowBallFly (17888C): the grandma throws the ball, it flies to the hero
+void Sc14Controller::doShowBallFly() {
+ if (!_balls.empty()) {
+ _flyingBall = _balls.front();
+ _balls.pop_front();
+ }
+ if (_grandma->_movement) {
+ const Common::Point center = _grandma->getCenter();
+ _ballX = center.x;
+ _ballY = center.y;
+ } else {
+ _ballX = _grandmaX;
+ _ballY = _grandmaY;
+ }
+ const float x = _ballX + 38.0f;
+ const float y = _ballY - 77.0f;
+ const float targetX = _manX - 26.0f;
+ const float targetY = _manY - 40.0f;
+ _ballDeltaX = 1.0f;
+ const int distance = (int)(float)(targetX - x);
+ const float rest = targetY - y;
+ float divisor = (float)distance;
+ if (distance == 0)
+ divisor = 1.0f;
+ const float deltaY = (float)(rest - (float)((float)((float)((float)distance * 0.0f) * (float)distance) * 0.5f)) / divisor;
+ _ballDeltaY = deltaY;
+ _ballX = x + 1.0f;
+ _ballY = y + deltaY;
+ _flyingBall->_flags |= 4;
+ setStaticMirror(_flyingBall, ST_BAL14_MAIN, false);
+ _flyingBall->setCenter(Common::Point((int)_ballX, (int)_ballY));
+ _flyingBall->_z = 5;
+ _flyingBall->startMovement(MV_BAL14_SPIN, 0, -1);
+ _ballFlying = true;
+}
+
+// CSc14Controller::DoShowBallFallgrandma2 (1789F8): ball that hit the grandma stays in front of her
+void Sc14Controller::doShowBallFallgrandma2() {
+ if (_flyingBall) {
+ const float x = _grandmaX + 223.0f;
+ const float y = _grandmaY + 35.0f;
+ _flyingBall->_flags |= 4;
+ _flyingBall->setCenter(Common::Point((int)x, (int)y));
+ setStaticMirror(_flyingBall, ST_BAL14_MAIN, false);
+ _flyingBall->_z = 27;
+ _pink = _flyingBall;
+ _flyingBall = nullptr;
+ }
+}
+
+// CSc14Controller::DoShowBallLast (178A5C)
+void Sc14Controller::doShowBallLast() {
+ if (_pink) {
+ _pink->_flags |= 4;
+ setStaticMirror(_pink, ST_BAL14_MAIN, false);
+ _pink->setCenter(Common::Point(693, 491));
+ _pink->_z = 27;
+ }
+}
+
+// CSc14Controller::CheckTutorial (178AA8): the tutorial of the arcade
+void Sc14Controller::checkTutorial() {
+ if (_tutorial == "UNDEF")
+ return;
+ if (g_ngi->_sceneStack.size() != 1)
+ return;
+ if (!g_ngi->_tutorialManager->activateTutorial(_tutorial))
+ _tutorial = "UNDEF";
+}
+
+// CSc14Controller::DoShowBallDivegrandma (178B38): ball goes over the grandma, camera on the hero
+void Sc14Controller::doShowBallDivegrandma() {
+ if (_flyingBall) {
+ const float x = _grandmaX + 506.0f;
+ const float y = _grandmaY - 29.0f;
+ _flyingBall->_flags |= 4;
+ _flyingBall->setCenter(Common::Point((int)x, (int)y));
+ _balls.push_back(_flyingBall);
+ _flyingBall = nullptr;
+ }
+ _follow = hero();
+}
+
+// CSc14Controller::DoHideBallLast (178B94)
+void Sc14Controller::doHideBallLast() {
+ if (_pink) {
+ _pink->_flags &= ~4;
+ _balls.push_back(_pink);
+ _pink = nullptr;
+ }
+}
+
+// CSc14Controller::StartDragging (178BC0): the hero is dragged back, frames follow the settings
+void Sc14Controller::startDragging() {
+ CursorController *cursor = g_ngi->_inputController;
+ _dragCursorX = cursor->_hotSceneX;
+ _dragCursorY = cursor->_hotSceneY;
+ _manFrameTimer = true;
+ setStaticMirror(hero(), ST_MAN_RIGHT, true);
+ hero()->startMovement(MV_MAN14_DECLINE, 0, -1);
+ Movement *movement = hero()->getMovement(MV_MAN14_DECLINE);
+ if (movement)
+ movement->_loopDelay = (int)(float)(_manFrameDelayK * 83.0f);
+ _manKicking = true;
+}
+
+// CSc14Controller::StopArcade (178C38)
+void Sc14Controller::stopArcade() {
+ _arcadeRunning = false;
+ getGameLoaderInteractionController()->enable();
+ _scene->_motionController->activate();
+ _scene->_behaviorController->enableAllQueuesForAni(hero(), true);
+ BehaviorMove *blink = _scene->_behaviorController->getAniQueue(_grandma->_id, QU_GMA_BLINK);
+ if (blink)
+ blink->_percent = 21474836;
+ BehaviorMove *throwing = _scene->_behaviorController->getAniQueue(_grandma->_id, QU_GMA_THROW);
+ if (throwing)
+ throwing->_percent = 0;
+ _sceneMarginY = 200.0f;
+ _sceneMarginX = 300.0f;
+ _sceneOffsetY = 300.0f;
+ _sceneOffsetX = 400.0f;
+ _follow = hero();
+ hideHint();
+ setSaving(true);
+}
+
+// CSc14Controller::DoWinArcade (178CDC)
+void Sc14Controller::doWinArcade() {
+ if (!_arcadeRunning)
+ return;
+ if (_manKicking) {
+ setStaticMirror(hero(), ST_MAN_RIGHT, true);
+ _manKicking = false;
+ }
+ if (_flyingBall) {
+ _balls.push_back(_flyingBall);
+ _flyingBall->_flags &= ~4;
+ _flyingBall = nullptr;
+ }
+ _ballFlying = false;
+ stopArcade();
+ _grandmaHere = false;
+ if (g_ngi->getStateId(sO_Grandma) == g_ngi->getStateValue(sO_Grandma, sO_In_14)) {
+ g_ngi->setState(sO_Grandma, g_ngi->getStateValue(sO_Grandma, sO_In_15));
+ MessageQueue *grandmaQueue = _grandma->getMessageQueue();
+ if (grandmaQueue)
+ stopQueue(grandmaQueue);
+ stopQueue(_scene->findMessageQueue(QU_SC14_STARTARCADE));
+ setStaticMirror(_grandma, ST_GMA_SIT, false);
+ _grandma->_flags &= ~4;
+ g_ngi->_taskManager->deactivateTask("KICK_GRANDMA_SC14");
+ }
+}
+
+// CSc14Controller::StartArcade (178E48): the hero stands at the plank, the grandma starts to throw
+void Sc14Controller::startArcade() {
+ // CFPController::FlurryArcadeStart("ANI_GRANDMA"): the analytics event is not ported
+ ArcadeInterface &arcade = g_ngi->arcadeInterface();
+ if (arcade.getState() == ArcadeInterface::kHidden) {
+ arcade.init(510.0f, -100.0f, -64.0f, 0.0f, 6, 2, true);
+ arcade.scrollIn();
+ }
+ setSaving(false);
+ _arcadeRunning = true;
+ _manCanKick = true;
+ if (!hero()->_movement) {
+ setStaticMirror(hero(), ST_MAN_RIGHT, true);
+ hero()->setCenter(Common::Point(1237, 451));
+ hero()->_z = 19;
+ }
+ _scene->_motionController->deactivate();
+ getGameLoaderInteractionController()->disable();
+ _follow = nullptr;
+ _scene->_behaviorController->enableAllQueuesForAni(hero(), false);
+ _sceneMarginX = 50.0f;
+ _pink = nullptr;
+ _sceneOffsetX = 100.0f;
+ _hitsLeft = 4;
+ _scene->runQueue(QU_SC14_STARTARCADE, 2);
+ showHint();
+}
+
+// CSc14Controller::OnLButtonUp (178F7C): button let go while dragged: he kicks, hits a near ball
+bool Sc14Controller::onLButtonUp() {
+ if (!hero()->_movement)
+ return false;
+
+ setCurFrame(hero(), 11);
+ _kickFrame = getCurFrame(hero());
+ // analytics total_moves_ANI_GRANDMA: not ported
+ stopDragging();
+ if (_flyingBall && (float)(_manX - (float)_flyingBall->getPosition().x) < _kickMaxDx) {
+ // analytics first_move_ANI_GRANDMA = 1: not ported
+ hero()->stopMovement();
+ moveToStatic(hero(), ST_MAN14_KICK);
+ hero()->startMovement(MV_MAN14_KICK, 0, -1);
+ _ballFlying = false;
+ _flyingBall->stopMovement();
+ _flyingBall->_flags &= ~4;
+ if (_hitsLeft == 1)
+ g_ngi->arcadeInterface().scrollOut();
+ setHintHideCondition();
+ } else {
+ // analytics first_move_ANI_GRANDMA = 0, failcount_ANI_GRANDMA: not ported
+ hero()->stopMovement();
+ moveToStatic(hero(), ST_MAN14_KICK);
+ hero()->startMovement(MV_MAN14_KICKAIR, 0, -1);
+ }
+ return true;
+}
+
+// CSc14Controller::DoManSurrender (179158): the ball passed the hero at the end, arcade lost
+void Sc14Controller::doManSurrender() {
+ // analytics lose_count_ANI_GRANDMA, game_ANI_GRANDMA_lose, FlurryArcadeClean: not ported
+ blockActivatingCounter();
+ g_ngi->arcadeInterface().scrollOut();
+ _arcadeRunning = false;
+ if (hero()->_movement)
+ hero()->stopMovement();
+ setStaticMirror(_grandma, ST_GMA_SIT, false);
+ _scene->runQueue(QU_SC14_ENDARCADE, 2);
+ getGameLoaderInteractionController()->disable();
+ hideHint();
+ runInteraction(PIC_SC14_RTRUBA);
+ setSaving(true);
+}
+
+// CSc14Controller::DoGrandmaShoot (179374): the grandma throws a ball after 30 ms
+void Sc14Controller::doGrandmaShoot() {
+ setStaticMirror(_grandma, ST_GMA_SIT, false);
+ setStaticMirror(_grandma, ST_GMA_SIT, false);
+ MessageQueue *queue = new MessageQueue(_scene, true, 1);
+ queue->addCommandToEnd(pauseCommand(30));
+ queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_THROW));
+ runQueueWithAni(queue, _grandma, 2);
+}
+
+// CSc14Controller::DoFallBall (179444): the ball falls to the ground, the grandma throws the next
+void Sc14Controller::doFallBall() {
+ _flyingBall->stopMovement();
+ _flyingBall->_z = 27;
+ MessageQueue *queue = new MessageQueue(_scene, true, 1);
+ queue->addCommandToEnd(movementCommand(ANI_BALL14, MV_BAL14_FALL, _flyingBall->_copyId));
+ queue->addCommandToEnd(hideCommand(ANI_BALL14, _flyingBall->_copyId));
+ runQueueWithAni(queue, _flyingBall, 2);
+ _balls.push_back(_flyingBall);
+ _flyingBall = nullptr;
+ doGrandmaShoot();
+}
+
+// CSc14Controller::DoGrandmaForward (179544): grandma jumps a step forward and throws
+void Sc14Controller::doGrandmaForward() {
+ setStaticMirror(_grandma, ST_GMA_SIT, false);
+ MessageQueue *queue = new MessageQueue(_scene, true, 1);
+ queue->addCommandToEnd(pauseCommand(30));
+ queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_JUMPFW));
+ queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_THROW));
+ runQueueWithAni(queue, _grandma, 2);
+ _heroCenterX = _heroCenterX + 71.0f;
+ _targetX = _targetX + 71.0f;
+ _follow = hero();
+}
+
+// CSc14Controller::DoManHit (179664): the ball hits the hero, he falls (the grandma comes forward)
+void Sc14Controller::doManHit() {
+ if (!hero()->_movement || hero()->_movement->_id != MV_MAN14_FALL) {
+ stopDragging();
+ moveToStatic(hero(), ST_MAN_RIGHT);
+ hero()->startMovement(MV_MAN14_FALL, 0, -1);
+ _flyingBall->stopMovement();
+ _flyingBall->_flags &= ~4;
+ if (_arcadeRunning)
+ doGrandmaForward();
+ }
+ _hitsLeft++;
+}
+
+// CSc14Controller::DoManForward (1796E4): the hero steps forward, the camera follows the grandma
+void Sc14Controller::doManForward() {
+ setStaticMirror(hero(), ST_MAN_RIGHT, true);
+ MessageQueue *queue = new MessageQueue(_scene, true, 1);
+ queue->addCommandToEnd(movementCommand(hero()->_id, MV_MAN14_STEPFW));
+ runQueueWithAni(queue, hero(), 2);
+ _heroCenterX = _heroCenterX - 71.0f;
+ _targetX = _targetX - 71.0f;
+ _follow = _grandma;
+}
+
+// CSc14Controller::DoGrandmaHit (179788): ball hits the grandma, she backs off (last hit ends it)
+void Sc14Controller::doGrandmaHit() {
+ _flyingBall->stopMovement();
+ _flyingBall->_flags &= ~4;
+ if (_manKicking)
+ stopDragging();
+ if (_hitsLeft > 1) {
+ moveToStatic(_grandma, ST_GMA_SIT);
+ MessageQueue *queue = new MessageQueue(_scene, true, 1);
+ if (_hitsLeft == 3 && !_pink) {
+ queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_BACKOFF2));
+ queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_THROW));
+ } else {
+ queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_BACKOFF));
+ queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_THROW));
+ }
+ runQueueWithAni(queue, _grandma, 2);
+ doManForward();
+ } else {
+ g_ngi->lift().enableButton(sO_Level4, ST_LBN_4N);
+ g_ngi->lift().initLift(_scene, hero(), QU_SC14_ENTERLIFT, QU_SC14_EXITLIFT);
+ // CFPController::FlurryArcadeEnd("ANI_GRANDMA"): the analytics event is not ported
+ addActivatingCounter();
+ moveToStatic(hero(), ST_MAN_RIGHT);
+ hero()->setPosition(Common::Point(1020, 454));
+ stopDragging();
+ _manCanKick = false;
+ _scene->runQueue(QU_SC14_WINARCADE, 2);
+ }
+ _hitsLeft--;
+}
+
+// CSc14Controller::CountBallFlight (179A4C): ball moves by its speed (straight line, the gravity
+// term is 0) and hits hero, grandma or ground; the float operations are the original's
+void Sc14Controller::countBallFlight(uint32 elapsed) {
+ const float deltaX = _ballDeltaX;
+ const float speedK = _ballSpeedK;
+ const float step = (float)elapsed;
+ const float x = (float)((float)((float)(deltaX * speedK) * step) + _ballX);
+ _ballX = x;
+ const float deltaY = _ballDeltaY;
+ const float y = (float)((float)((float)(deltaY * speedK) * step) + _ballY);
+ _ballY = y;
+ _ballDeltaY = deltaY + (float)(step * 0.0f);
+ if (y > 517.0f) {
+ doFallBall();
+ _ballFlying = false;
+ return;
+ }
+ if (x > (float)(_manX - 26.0f)) {
+ g_ngi->arcadeInterface().decCounter();
+ doManHit();
+ _ballFlying = false;
+ return;
+ }
+ if (deltaX < 0.0f) {
+ const float targetX = _grandmaX + 65.0f;
+ if (x < targetX && x > (float)(targetX - 200.0f)) {
+ g_ngi->arcadeInterface().incCounter();
+ doGrandmaHit();
+ _ballFlying = false;
+ return;
+ }
+ }
+ if (_flyingBall)
+ _flyingBall->setCenter(Common::Point((int)_ballX, (int)_ballY));
+}
+
+// CSc14Controller::DoShowBallFallman (179B70): ball that passed the hero lands behind him
+void Sc14Controller::doShowBallFallman() {
+ if (!_flyingBall)
+ return;
+
+ const float x = _manX - 166.0f;
+ const float y = _manY + 40.0f;
+ _flyingBall->_flags |= 4;
+ setStaticMirror(_flyingBall, ST_BAL14_TOGMA, false);
+ _flyingBall->setCenter(Common::Point((int)x, (int)y));
+ _flyingBall->_z = 27;
+ MessageQueue *queue = new MessageQueue(_scene, true, 1);
+ queue->addCommandToEnd(movementCommand(ANI_BALL14, MV_BAL14_TOGMA, _flyingBall->_copyId));
+ queue->addCommandToEnd(hideCommand(ANI_BALL14, _flyingBall->_copyId));
+ runQueueWithAni(queue, _flyingBall, 2);
+ _flyingBall->startMovement(MV_BAL14_TOGMA, 0, -1);
+ _balls.push_back(_flyingBall);
+ _flyingBall = nullptr;
+ if (_manX >= 1300.0f)
+ doManSurrender();
+}
+
+// CSc14Controller::DoShowBallFallgrandma (179CF8): ball that hit the grandma falls in front of her
+void Sc14Controller::doShowBallFallgrandma() {
+ if (!_flyingBall)
+ return;
+
+ const float x = _grandmaX + 190.0f;
+ const float y = _grandmaY + 56.0f;
+ _flyingBall->_flags |= 4;
+ setStaticMirror(_flyingBall, ST_BAL14_TOGMA, false);
+ _flyingBall->setCenter(Common::Point((int)x, (int)y));
+ _flyingBall->_z = 27;
+ MessageQueue *queue = new MessageQueue(_scene, true, 1);
+ queue->addCommandToEnd(movementCommand(ANI_BALL14, MV_BAL14_TOGMA, _flyingBall->_copyId));
+ queue->addCommandToEnd(hideCommand(ANI_BALL14, _flyingBall->_copyId));
+ runQueueWithAni(queue, _flyingBall, 2);
+ _balls.push_back(_flyingBall);
+ _flyingBall = nullptr;
+}
+
+// CSc14Controller::SkipArcade (179E4C): grandma jumps back to the pipe as often as she came forward
+void Sc14Controller::skipArcade() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::skipArcade();
+ return;
+ }
+ g_ngi->lift().enableButton(sO_Level4, ST_LBN_4N);
+ g_ngi->lift().initLift(_scene, hero(), QU_SC14_ENTERLIFT, QU_SC14_EXITLIFT);
+ g_ngi->arcadeInterface().scrollOut();
+ if (_manKicking) {
+ setStaticMirror(hero(), ST_MAN_RIGHT, true);
+ _manKicking = false;
+ }
+ if (_flyingBall) {
+ _balls.push_back(_flyingBall);
+ _flyingBall->_flags &= ~4;
+ _flyingBall = nullptr;
+ }
+ _ballFlying = false;
+ stopArcade();
+ _grandmaHere = false;
+ // CVisibleObject::StopQueue
+ MessageQueue *grandmaQueue = _grandma->getMessageQueue();
+ if (grandmaQueue)
+ stopQueue(grandmaQueue);
+ if (_grandma->_movement)
+ _grandma->stopMovement();
+ setStaticMirror(_grandma, ST_GMA_SIT, false);
+ MessageQueue *queue = new MessageQueue(_scene, true, 1);
+ for (int i = 0; i < _hitsLeft; ++i)
+ queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_JUMPBK));
+ queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_TOTRUBA_EMPTY));
+ queue->addCommandToEnd(messageCommand("MSG_SC14_RESTORESCROLL"));
+ runQueueWithAni(queue, _grandma, 2);
+ if (g_ngi->getStateId(sO_Grandma) == g_ngi->getStateValue(sO_Grandma, sO_In_14))
+ g_ngi->setState(sO_Grandma, g_ngi->getStateValue(sO_Grandma, sO_In_15));
+ _targetX = -(float)_scene->_x;
+ _follow = nullptr;
+ // CFPController::FlurryArcadeSkip("ANI_GRANDMA"): the analytics event is not ported
+}
+
+// CSc14Controller::ReadSettingsXml (17A29C)
+void Sc14Controller::readSettingsXml() {
+ Scene14SettingsParser settings;
+ if (settings.loadFile("data/sc_14_settings.xml") && settings.parse()) {
+ _grandmaFrameDelayK = settings._grandmaFrameDelayK;
+ _manFrameDelayK = settings._manFrameDelayK;
+ _kickMaxDx = settings._kickMaxDx;
+ _ballSpeedK = settings._ballSpeedK;
+ } else {
+ warning("Could not read sc_14_settings.xml");
+ }
+}
+
+// CSc14Controller::OnShow (17A3D8): grandma and balls, lift or arcade; beyond the base it is scene
+// logic (Windows scene14_initScene). Base margins are not set (+316..+328 are own fields)
+void Sc14Controller::onShow() {
+ FPController::onShow();
+ if (!controllerRunsSceneLogic())
+ return;
+
+ _grandma = _scene->findAniObjectById(ANI_GRANDMA, 0);
+ _grandmaFrameDelayK = 1.0f;
+ _manFrameDelayK = 1.0f;
+ _ballSpeedK = 1.0f;
+ _kickMaxDx = 180.0f;
+ readSettingsXml();
+ if (!g_ngi->_taskManager->isSceneVisited(_scene->_sceneId))
+ g_ngi->_taskManager->activateTask("KICK_GRANDMA_SC14");
+ g_ngi->_taskManager->visitScene(_scene->_sceneId);
+ _arcadeRunning = false;
+ _manKicking = false;
+ _ballFlying = false;
+ _manCanKick = false;
+ _pink = nullptr;
+ _sceneMarginX = 300.0f;
+ _sceneMarginY = 200.0f;
+ _sceneOffsetY = 300.0f;
+ _sceneOffsetX = 400.0f;
+ _flyingBall = nullptr;
+ _balls.clear();
+ hideAction(_scene, ANI_BALL14, 1);
+
+ if (g_ngi->getStateId(sO_Grandma) != g_ngi->getStateValue(sO_Grandma, sO_In_14)) {
+ _grandmaHere = false;
+ _grandma->_flags &= ~4;
+ g_ngi->lift().initLift(_scene, hero(), QU_SC14_ENTERLIFT, QU_SC14_EXITLIFT);
+ } else {
+ _grandmaHere = true;
+ AniObject *ball = _scene->findAniObjectById(ANI_BALL14, 0);
+ if (ball) {
+ ball->_flags &= ~4;
+ _balls.push_back(ball);
+ }
+ for (int i = 3; i != 0; --i) {
+ AniObject *copy = new AniObject(ball);
+ copy->_flags &= ~4;
+ _balls.push_back(copy);
+ _scene->addAni(copy, true);
+ }
+ setStaticMirror(_grandma, ST_GMA_SIT, false);
+ _grandma->setPosition(Common::Point(713, 457));
+ Movement *throwing = _grandma->getMovement(MV_GMA_THROW);
+ if (throwing)
+ throwing->_loopDelay = (int)(float)(_grandmaFrameDelayK * 83.0f);
+ if (_scene->_currentEntranceId == 0) {
+ setStaticMirror(hero(), ST_MAN_RIGHT, false);
+ hero()->_flags |= 8;
+ hero()->setCenter(Common::Point(1448, 462));
+ hero()->_z = 10;
+ _scene->_x = 800;
+ _scene->_y = 0;
+ }
+ }
+
+ if (!_grandmaHere) {
+ _scene->_behaviorController->disableAllMusic();
+ enableSound(SND_MUS_19, true);
+ }
+ // CMovement::GetMovementSize(0, -1) of MV_MAN14_DECLINE/KICK/KICKAIR: result unused, not called
+ warnOnce("CSc14Controller::OnShow: CMovement::GetMovementSize of the movements of the hero (the result is not used) is not called");
+}
+
+// CSc14Controller::OnKeyUp (17A6C0): W wins the arcade, Q skips it
+void Sc14Controller::onKeyUp(uint32 key) {
+ FPController::onKeyUp(key);
+ if (!controllerRunsSceneLogic())
+ return;
+ if (key == 87) {
+ doWinArcade();
+ g_ngi->lift().enableButton(sO_Level4, ST_LBN_4N);
+ g_ngi->lift().initLift(_scene, hero(), QU_SC14_ENTERLIFT, QU_SC14_EXITLIFT);
+ } else if (key == 81) {
+ skipArcade();
+ }
+}
+
+// CSc14Controller::GetCursorType (17A738): the lift; the drag cursor while the arcade runs
+int Sc14Controller::getCursorType(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::getCursorType(x, y);
+ if (g_ngi->lift().getCursorType(x, y))
+ return 116;
+ if (!_arcadeRunning)
+ return FPController::getCursorType(x, y);
+ if (_manKicking)
+ return 107;
+ return g_ngi->_inputController->isObjectHit(hero());
+}
+
+// CSc14Controller::OnUpdate (17A784): hero and grandma centers, the flight of the ball
+void Sc14Controller::onUpdate(uint32 elapsed) {
+ FPController::onUpdate(elapsed);
+ if (!controllerRunsSceneLogic())
+ return;
+
+ if (_manFrameTimer)
+ manNextFunc(elapsed);
+ AniObject *man = hero();
+ if (man->_movement && man->_movement->_id == MV_MAN14_KICK) {
+ const Common::Point center = man->getCenter();
+ _manX = center.x;
+ _manY = center.y;
+ _manX = _manX + (float)(2 * getCurFrame(man));
+ } else {
+ const Common::Point center = man->getCenter();
+ _manX = center.x;
+ _manY = center.y;
+ }
+ const Common::Point grandmaCenter = _grandma->getCenter();
+ _grandmaX = grandmaCenter.x;
+ _grandmaY = grandmaCenter.y;
+ if (_ballFlying)
+ countBallFlight(elapsed);
+}
+
+// CSc14Controller::OnMouseLKeyDown (17A828): takes the hero; before the arcade: plank (x 1237)
+bool Sc14Controller::onMouseLKeyDown(uint32 id, float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::onMouseLKeyDown(id, x, y);
+
+ bool handled = false;
+ if (_arcadeRunning) {
+ if (_manCanKick && hero()->hit((int)x, (int)y) && !hero()->_movement)
+ startDragging();
+ } else {
+ handled = g_ngi->lift().onButtonDown(x, y);
+ }
+
+ if (_scene->_motionController->_isEnabled) {
+ if (_grandmaHere) {
+ if (x <= 1237.0f) {
+ y = 451.0f;
+ x = 1237.0f;
+ }
+ } else if (!g_ngi->_inputController->getObject()) {
+ if (_pink && (_pink->_flags & 4)) {
+ const Common::Point center = _pink->getCenter();
+ if (x < (float)center.x + 40.0f)
+ return true;
+ }
+ }
+ }
+ if (handled)
+ return true;
+ return FPController::onMouseLKeyDown(id, x, y);
+}
+
+// CSc14Controller::OnMouseLKeyUp (17A904): before the arcade a tap walks to the plank, starts it;
+// a tap at the grandma's ball takes it; lift buttons
+bool Sc14Controller::onMouseLKeyUp(uint32 id, float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::onMouseLKeyUp(id, x, y);
+
+ _touching = false;
+ MotionController *motion = _scene->_motionController.get();
+ if (motion->_isEnabled) {
+ const bool canInterrupt = canInterruptManQueue();
+ if (canInterrupt) {
+ if (_grandmaHere) {
+ if (motion->_objtype == kObjTypeMctlCompound) {
+ if (x <= 1237.0f) {
+ MessageQueue *queue = mctlStartMove(1237, 451, true, ST_MAN_RIGHT, true);
+ if (queue) {
+ queue->addCommandToEnd(messageCommand("MSG_SC14_STARTARCADE"));
+ motion->deactivate();
+ getGameLoaderInteractionController()->disable();
+ return true;
+ }
+ }
+ }
+ } else if (!g_ngi->_inputController->getObject()) {
+ if (_pink && (_pink->_flags & 4)) {
+ Common::Point center = _pink->getCenter();
+ if (x < (float)center.x + 40.0f) {
+ AniObject *ball = _scene->findAniObjectById(_pink->_id, 0);
+ if (ball->_statics)
+ setStaticMirror(ball, ball->_statics->_staticsId, false);
+ center = _pink->getCenter();
+ ball->setCenter(center);
+ if (runInteraction(_pink->_id))
+ return canInterrupt;
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ bool result;
+ if (_manKicking) {
+ result = onLButtonUp();
+ } else {
+ if (_arcadeRunning)
+ return FPController::onMouseLKeyUp(id, x, y);
+ result = g_ngi->lift().onButtonUp(x, y);
+ }
+ if (result)
+ return true;
+ return FPController::onMouseLKeyUp(id, x, y);
+}
+
+// CSc14Controller::OnMessage (17AAB8)
+void Sc14Controller::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onMessage(message, param, queue);
+ return;
+ }
+ if (message == "MSG_SC14_GMAJUMP") {
+ onGrandmaJump();
+ } else if (message == "MSG_SC14_SHOWBALLFLY") {
+ doShowBallFly();
+ } else if (message == "MSG_SC14_SHOWBALLMAN") {
+ doShowBallFallman();
+ } else if (message == "MSG_SC14_SHOWBALLGMAHIT") {
+ doShowBallFallgrandma();
+ } else if (message == "MSG_SC14_SHOWBALLGMAHIT2") {
+ doShowBallFallgrandma2();
+ } else if (message == "MSG_SC14_SHOWBALLGMADIVE") {
+ doShowBallDivegrandma();
+ } else if (message == "MSG_SC14_MANKICKBALL") {
+ doShowBallKickman();
+ } else if (message == "MSG_SC14_SHOWBALLLAST") {
+ doShowBallLast();
+ } else if (message == "MSG_SC14_HIDEBALLLAST") {
+ doHideBallLast();
+ } else if (message == "MSG_SC14_HIDEPINK") {
+ if (_pink)
+ _pink->_flags &= ~4;
+ } else if (message == "MSG_SC14_GMATOTRUBA") {
+ _targetX = (float)_scene->_x;
+ } else if (message == "MSG_SC14_STARTARCADE") {
+ startArcade();
+ } else if (message == "MSG_SC14_ENDARCADE") {
+ stopArcade();
+ _grandmaHere = false;
+ } else if (message == "MSG_SC14_SCROLLLEFT") {
+ _follow = nullptr;
+ _targetX = _targetX - (float)_scene->_x;
+ } else if (message == "MSG_SC14_RESTORESCROLL") {
+ _follow = hero();
+ } else if (message == "MSG_CMN_WINARCADE") {
+ doWinArcade();
+ } else if (message == "MSG_BREAK_GRIT") {
+ if (isInteractionQueueRunning("INT_239")) {
+ AniObject *grit = _scene->findAniObjectById(ANI_GRIT_14, 0);
+ if (grit->_movement)
+ setCurFrame(grit, 7);
+ else
+ grit->startMovement(MV_GRT14_FALL, 0, -1);
+ }
+ } else {
+ FPController::onMessage(message, param, queue);
+ }
+}
+
+// CSc14Controller::UpdateScroll (17AD44): arcade or interactions off: camera limited and smooth
+void Sc14Controller::updateScroll() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::updateScroll();
+ return;
+ }
+ if (_arcadeRunning || !getGameLoaderInteractionController()->_enabled) {
+ _smooth = true;
+ limitScroll();
+ } else {
+ _smooth = false;
+ }
+ FPController::updateScroll();
+}
+
+// CSc14Controller::OnHide (17AD7C)
+void Sc14Controller::onHide() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onHide();
+ return;
+ }
+ if (_arcadeRunning) {
+ // analytics lose_count_ANI_GRANDMA, game_ANI_GRANDMA_lose: not ported
+ }
+ _arcadeRunning = false;
+ setSaving(true);
+ if (_pink && (_pink->_flags & 4))
+ _pink->_flags &= ~4;
+ if (_flyingBall && (_flyingBall->_flags & 4))
+ _flyingBall->_flags &= ~4;
+ hideHint();
+ FPController::onHide();
+}
+
+// CSc14Controller::OnRender (17AF10): arcade interface over the scene (CheckInvItem not ported)
+void Sc14Controller::onRender(Common::Point scroll) {
+ FPController::onRender(scroll);
+ if (!controllerRunsSceneLogic())
+ return;
+ if (g_ngi->arcadeInterface().getState() != ArcadeInterface::kHidden)
+ g_ngi->arcadeInterface().render();
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sc14controller.h b/engines/ngi/fullpipe/sc14controller.h
new file mode 100644
index 00000000000..f6bb5ba8135
--- /dev/null
+++ b/engines/ngi/fullpipe/sc14controller.h
@@ -0,0 +1,122 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SC14CONTROLLER_H
+#define NGI_FULLPIPE_SC14CONTROLLER_H
+
+#include "common/list.h"
+#include "common/str.h"
+
+#include "ngi/fullpipe/fpcontroller.h"
+
+namespace NGI {
+
+/** CSc14Controller (arcade: the hero drags back, lets go and kicks the grandma's ball) */
+class Sc14Controller : public FPController {
+public:
+ explicit Sc14Controller(int sceneId);
+
+ void cleanXml() override;
+ bool canSwipeMan(float x, float y) override;
+ bool canShowHelp() override;
+ void skipArcade() override;
+ void checkTutorial() override;
+ void onShow() override;
+ void onHide() override;
+ void onRender(Common::Point scroll) override;
+ void onKeyUp(uint32 key) override;
+ int getCursorType(float x, float y) override;
+ void updateScroll() override;
+ void onUpdate(uint32 elapsed) override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+
+ void onGrandmaJump();
+ void manNextFunc(uint32 elapsed);
+ void stopDragging();
+ void startDragging();
+ void doShowBallKickman();
+ void doShowBallFly();
+ void doShowBallFallgrandma2();
+ void doShowBallLast();
+ void doShowBallDivegrandma();
+ void doHideBallLast();
+ void doShowBallFallman();
+ void doShowBallFallgrandma();
+ void startArcade();
+ void stopArcade();
+ void doWinArcade();
+ bool onLButtonUp();
+ void doManSurrender();
+ void doGrandmaShoot();
+ void doFallBall();
+ void doGrandmaForward();
+ void doManHit();
+ void doManForward();
+ void doGrandmaHit();
+ void countBallFlight(uint32 elapsed);
+
+private:
+ /** CSc14Controller::ReadSettingsXml: data/sc_14_settings.xml (delays, kick range, ball speed) */
+ void readSettingsXml();
+
+ /** +216: the next tutorial of the scene */
+ Common::String _tutorial;
+ float _grandmaFrameDelayK = 1.0f; // +220: GRANDMA frameDelayK
+ float _manFrameDelayK = 1.0f; // +224: MAN frameDelayK
+ float _ballSpeedK = 1.0f; // +228: BALL speedK
+ float _kickMaxDx = 180.0f; // +232: MAN kickMaxDx, how near the ball must be for the kick to hit
+ AniObject *_grandma = nullptr; // +236: ANI_GRANDMA
+ float _manX = 0; // +240: center of the hero (plus 2 pixels per frame while he kicks)
+ float _manY = 0; // +244
+ float _grandmaX = 0; // +248: the center of the grandma
+ float _grandmaY = 0; // +252
+ bool _grandmaHere = true; // +256: the grandma is in the scene (the state "ÐабÑлÑ" is "Ð_14")
+ bool _manCanKick = false; // +257: the arcade runs and the hero may be dragged
+ bool _manKicking = false; // +258: the hero is dragged back (the button is down)
+ bool _ballFlying = false; // +259: the ball flies (CountBallFlight)
+ bool _manFrameTimer = false; // +260: ManNextFunc runs
+ uint32 _manFrameElapsed = 0; // +264: the milliseconds that ManNextFunc has counted
+ AniObject *_flyingBall = nullptr; // +268: the ball that flies
+ AniObject *_pink = nullptr; // +272: the ball that the grandma holds up at the end (her last one)
+ float _ballX = 0; // +276: where the flying ball is
+ float _ballY = 0; // +280
+ Common::List<AniObject *> _balls; // +284: unused balls (ANI_BALL14 and its three copies)
+ // +292: std::vector, cleared by constructor, destructor and OnShow, never filled
+ int _kickFrame = 0; // +304: the frame of the kick when the button was let go
+ // +308: an int that only the constructor sets (0)
+ int _hitsLeft = 4; // +312: how many times the grandma has to be hit
+ // +316..+328: camera margins and offsets as in Windows (scene14_sceneDeltaX ...); set but never
+ // read, the CFPController margins (+36 ..) stay 0 here
+ float _sceneMarginX = 0; // +316
+ float _sceneMarginY = 0; // +320
+ float _sceneOffsetX = 0; // +324
+ float _sceneOffsetY = 0; // +328
+ float _ballDeltaX = 0; // +332: the speed of the ball (pixels per millisecond)
+ float _ballDeltaY = 0; // +336
+ float _dragCursorX = 0; // +340: where the cursor was when the hero was taken
+ float _dragCursorY = 0; // +344
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SC14CONTROLLER_H
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index 1db1502adf7..4a40508c8b3 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -25,6 +25,7 @@
#include "ngi/fullpipe/sc08controller.h"
#include "ngi/fullpipe/sc09controller.h"
#include "ngi/fullpipe/sc11controller.h"
+#include "ngi/fullpipe/sc14controller.h"
#include "ngi/fullpipe/scenecontrollers.h"
#include "ngi/fullpipe/sc03controller.h"
#include "ngi/fullpipe/sc04controller.h"
@@ -431,6 +432,9 @@ void createSceneController(int sceneId) {
case SC_13:
new Sc13Controller(sceneId);
break;
+ case SC_14:
+ new Sc14Controller(sceneId);
+ break;
case SC_15:
new Sc15Controller(sceneId);
break;
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 4d22e2f67e9..cec7e0551f4 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -94,6 +94,7 @@ MODULE_OBJS = \
fullpipe/sc08controller.o \
fullpipe/sc09controller.o \
fullpipe/sc11controller.o \
+ fullpipe/sc14controller.o \
fullpipe/scene01.o \
fullpipe/scene02.o \
fullpipe/scene03.o \
Commit: eaeda9ab8bc694362417fd25d79f496abd1ed4fa
https://github.com/scummvm/scummvm/commit/eaeda9ab8bc694362417fd25d79f496abd1ed4fa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 17 controller ported
Changed paths:
A engines/ngi/fullpipe/sc17controller.cpp
A engines/ngi/fullpipe/sc17controller.h
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/scenecontrollers.h
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/sc17controller.cpp b/engines/ngi/fullpipe/sc17controller.cpp
new file mode 100644
index 00000000000..86cd3e42e0c
--- /dev/null
+++ b/engines/ngi/fullpipe/sc17controller.cpp
@@ -0,0 +1,268 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/ngi.h"
+#include "ngi/behavior.h"
+#include "ngi/gfx.h"
+#include "ngi/input.h"
+#include "ngi/inventory.h"
+#include "ngi/messages.h"
+#include "ngi/motion.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/sc17controller.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+// CSc17Controller::CSc17Controller (17CBE8)
+Sc17Controller::Sc17Controller(int sceneId) : FPController(sceneId), _tutorial("PREV_EXTRA_TUTORIAL_SEE_HIGHLIGHT"), _flyPack(new FlyPack()) {
+}
+
+// CSc17Controller::~CSc17Controller (17CB80): the fly pack goes with it
+Sc17Controller::~Sc17Controller() {
+}
+
+// CSc17Controller::CleanXml (17CBD4)
+void Sc17Controller::cleanXml() {
+ _tutorial = "PREV_EXTRA_TUTORIAL_SEE_HIGHLIGHT";
+}
+
+// CSc17Controller::DoShowSugar (17CC80)
+void Sc17Controller::doShowSugar() {
+ _scene->runQueue(QU_SC17_SHOWSUGAR);
+ _sugarShown = true;
+}
+
+// CSc17Controller::DoHideSugar (17CC9C)
+void Sc17Controller::doHideSugar() {
+ AniObject *sugar = _scene->findAniObjectById(ANI_INV_SUGAR, 0);
+ if (sugar)
+ sugar->_flags &= ~4;
+}
+
+// CSc17Controller::DoShowBottle (17CCBC)
+void Sc17Controller::doShowBottle() {
+ _scene->runQueue(QU_SC17_SHOWBOTTLE);
+}
+
+// CSc17Controller::DoTakeSugar (17CCD0)
+void Sc17Controller::doTakeSugar() {
+ AniObject *moonshiner = _scene->findAniObjectById(ANI_SAMOGONSHCHIK, 0);
+ moonshiner->setStatic(ST_SMG_SIT);
+ _scene->runQueue(QU_SMG_FILLBOTTLE);
+ _sugarShown = false;
+}
+
+// CSc17Controller::DoTestTruba (17CD0C): the hand shows the fig unless it does
+void Sc17Controller::doTestTruba() {
+ if (!_hand->_movement || _hand->_movement->_id != MV_HND17_FIGA) {
+ _hand->setStatic(ST_HND17_EMPTY);
+ _hand->startMovement(MV_HND17_FIGA, 0, -1);
+ }
+}
+
+// CSc17Controller::DoDrop (17CD58)
+void Sc17Controller::doDrop() {
+ AniObject *mug = _scene->findAniObjectById(ANI_MUG_17, 0);
+ AniObject *jet = _scene->findAniObjectById(ANI_JET_17, 0);
+ if (mug && (mug->_flags & 4)) {
+ mug->setStatic(ST_MUG17_EMPTY);
+ _scene->runQueue(QU_SC17_FILLMUG_DROP);
+ } else if (jet) {
+ _scene->runQueue(QU_JET17_DROP);
+ }
+}
+
+// CSc17Controller::StartFly (17CDB8): a fly enters from the top, leaves after 6 stops
+void Sc17Controller::startFly() {
+ _flyPack->addFly(_scene, 239, -50, 20, 4);
+ GutlFly &fly = _flyPack->_flies[0];
+ fly.countdown = scaledRandom(4) + 6;
+ fly.exitX = 239;
+ fly.exitY = -50;
+}
+
+// CSc17Controller::CheckTutorial (17CE00): the highlight tutorial once the hero has the bottle
+void Sc17Controller::checkTutorial() {
+ if (_tutorial == "UNDEF")
+ return;
+ if (g_ngi->_sceneStack.size() != 1)
+ return;
+ if (g_ngi->_tutorialManager->activateTutorial(_tutorial))
+ return;
+ const Common::String previous = _tutorial;
+ if (_tutorial != "PREV_EXTRA_TUTORIAL_SEE_HIGHLIGHT") {
+ _tutorial = "UNDEF";
+ } else {
+ const InventoryItem *bottle = g_ngi->_inventory->getItemByName("ANI_INV_BOTTLE");
+ if (bottle && bottle->_counter > 0)
+ _tutorial = "EXTRA_TUTORIAL_SEE_HIGHLIGHT";
+ }
+ if (previous != _tutorial)
+ checkTutorial();
+}
+
+// CSc17Controller::DoFillBottle (17CF7C)
+void Sc17Controller::doFillBottle() {
+ AniObject *bottle = _scene->findAniObjectById(ANI_INV_BOTTLE, 0);
+ AniObject *mug = _scene->findAniObjectById(ANI_MUG_17, 0);
+ AniObject *boot = _scene->findAniObjectById(ANI_BOOT_17, 0);
+ if (bottle && (bottle->_flags & 4)) {
+ _scene->runQueue(QU_SC17_FILLBOTTLE);
+ } else if (mug && (mug->_flags & 4) && mug->_statics->_staticsId == ST_MUG17_EMPTY) {
+ _scene->runQueue(QU_SC17_FILLMUG);
+ g_ngi->_taskManager->activateTask("GET_SUGAR_SC19");
+ } else if (boot && (boot->_flags & 4)) {
+ _scene->runQueue(QU_SC17_FILLBOOT);
+ g_ngi->_taskManager->activateTask("GET_SUGAR_SC19");
+ } else {
+ _scene->runQueue(QU_JET17_FLOW);
+ g_ngi->_taskManager->activateTask("GET_SUGAR_SC19");
+ }
+}
+
+// CSc17Controller::OnShow (17D094): camera margins; the rest is scene logic
+void Sc17Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+ if (!controllerRunsSceneLogic())
+ return;
+
+ if (!g_ngi->_taskManager->isSceneVisited(_scene->_sceneId))
+ g_ngi->_taskManager->activateTask("FIND_EXIT_HAND_SC17");
+ g_ngi->_taskManager->visitScene(_scene->_sceneId);
+
+ AniObject *tumba = _scene->findAniObjectById(ANI_SC17_TUMBA, 0);
+ tumba->setStatic(ST_SC17_TUMBA_STATE1);
+ tumba->setPosition(Common::Point(470, 419));
+ tumba->_z = 40;
+
+ _sugarShown = false;
+ _heroX = 0;
+ _flyTimer = 0;
+ _flyState = 1;
+ _hand = _scene->findAniObjectById(ANI_HAND17, 0);
+ // the hand asks for the coin (the cycle is enabled) until the usher has it
+ const bool withCoin = g_ngi->getStateId(sO_UsherHand) == g_ngi->getStateValue(sO_UsherHand, sO_WithCoin);
+ _scene->_behaviorController->getAniQueue(_hand->_id, QU_HND17_ASK)->setEnabled(false);
+ _scene->_behaviorController->getAniQueue(_hand->_id, QU_HND17_TOCYCLE)->setEnabled(!withCoin);
+ _handAsks = !withCoin;
+
+ _flyPack->init(g_ngi->getGameLoaderGameVar()->getSubVarByName("SC_17"));
+ // the original reads the state "ÐÑÑ
а_17" as a number (GetState, atoi); here it is the id
+ _flyState = g_ngi->getStateId(sO_Fly_17);
+ bool flyPending = false;
+ if (_flyState <= 0) {
+ _flyTimer = scaledRandom(49800) + 49800;
+ _flyState = scaledRandom(3) + 1;
+ flyPending = true;
+ }
+ _flyPending = flyPending;
+ g_ngi->setState(sO_Fly_17, _flyState - 1);
+}
+
+// CSc17Controller::OnHide (17D2F8)
+void Sc17Controller::onHide() {
+ _flyPack->deleteAllFlies();
+ FPController::onHide();
+}
+
+// CSc17Controller::GetCursorType (17D310): key item cursor over the pipes, when asked
+int Sc17Controller::getCursorType(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::getCursorType(x, y);
+ CursorController *cursor = g_ngi->_inputController;
+ if ((cursor->isObjectHit(PIC_SC17_RTRUBA2) || (cursor->isObjectHit(PIC_SC17_RTRUBA) && _handAsks)) &&
+ (g_ngi->_inventory->getItem(ANI_INV_COIN) || g_ngi->_inventory->getItem(ANI_INV_BOOT) || g_ngi->_inventory->getItem(ANI_INV_HAMMER)))
+ return 102;
+ return FPController::getCursorType(x, y);
+}
+
+// CSc17Controller::UpdateScroll (17D394)
+void Sc17Controller::updateScroll() {
+ FPController::updateScroll();
+}
+
+// CSc17Controller::OnUpdate (17D39C)
+void Sc17Controller::onUpdate(uint32 elapsed) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onUpdate(elapsed);
+ return;
+ }
+ _heroX = hero()->getCenter().x;
+ FPController::onUpdate(elapsed);
+ if (_sugarShown)
+ doTakeSugar();
+ if (_handAsks) {
+ const bool left = hero()->getCenter().x < 410;
+ BehaviorController *behavior = _scene->_behaviorController.get();
+ behavior->getAniQueue(_hand->_id, QU_HND17_TOCYCLE)->setEnabled(left);
+ behavior->getAniQueue(_hand->_id, QU_HND17_ATTRACT)->setEnabled(left);
+ behavior->getAniQueue(_hand->_id, QU_HND17_ASK)->setEnabled(!left);
+ }
+ if (_flyPending) {
+ _flyTimer -= elapsed;
+ if (_flyTimer < 0) {
+ startFly();
+ _flyPending = false;
+ }
+ }
+ _flyPack->onUpdate(elapsed);
+}
+
+// CSc17Controller::OnMessage (17D4B0)
+void Sc17Controller::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onMessage(message, param, queue);
+ return;
+ }
+ if (message == "MSG_SC17_SHOWSUGAR") {
+ doShowSugar();
+ } else if (message == "MSG_SC17_HIDESUGAR") {
+ doHideSugar();
+ } else if (message == "MSG_SC17_SHOWBOTTLE") {
+ doShowBottle();
+ } else if (message == "MSG_SC17_FILLBOTTLE") {
+ doFillBottle();
+ } else if (message == "MSG_SC17_TESTTRUBA") {
+ doTestTruba();
+ } else if (message == "MSG_SC17_UPDATEHAND") {
+ const bool withCoin = g_ngi->getStateId(sO_UsherHand) == g_ngi->getStateValue(sO_UsherHand, sO_WithCoin);
+ _scene->_behaviorController->getAniQueue(_hand->_id, QU_HND17_ASK)->setEnabled(false);
+ _scene->_behaviorController->getAniQueue(_hand->_id, QU_HND17_TOCYCLE)->setEnabled(!withCoin);
+ _handAsks = !withCoin;
+ } else if (message == "MSG_SC17_DROP") {
+ doDrop();
+ } else if (message == "MSG_DEACT_TUTORIAL_HIGHLIGHT") {
+ _tutorial = "AFTER_EXTRA_TUTORIAL_SEE_HIGHLIGHT";
+ } else {
+ FPController::onMessage(message, param, queue);
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sc17controller.h b/engines/ngi/fullpipe/sc17controller.h
new file mode 100644
index 00000000000..ded61fbe98c
--- /dev/null
+++ b/engines/ngi/fullpipe/sc17controller.h
@@ -0,0 +1,71 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SC17CONTROLLER_H
+#define NGI_FULLPIPE_SC17CONTROLLER_H
+
+#include "common/ptr.h"
+
+#include "ngi/fullpipe/fpcontroller.h"
+#include "ngi/fullpipe/floaters.h"
+
+namespace NGI {
+
+/** CSc17Controller (usher's hand, sugar, bottle, fly); sceneHandler17 runs the scene until wired */
+class Sc17Controller : public FPController {
+public:
+ explicit Sc17Controller(int sceneId);
+ ~Sc17Controller() override;
+
+ void cleanXml() override;
+ void checkTutorial() override;
+ void onShow() override;
+ void onHide() override;
+ int getCursorType(float x, float y) override;
+ void updateScroll() override;
+ void onUpdate(uint32 elapsed) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+
+ void doShowSugar();
+ void doHideSugar();
+ void doShowBottle();
+ void doTakeSugar();
+ void doTestTruba();
+ void doDrop();
+ void startFly();
+ void doFillBottle();
+
+private:
+ /** +216: the next tutorial of the scene */
+ Common::String _tutorial;
+ bool _sugarShown = false; // +220
+ int _heroX = 0; // +224: the center of the hero
+ bool _handAsks = true; // +228: asks for the coin (hero right of x 410): ASK queue on, cycle off
+ AniObject *_hand = nullptr; // +232: ANI_HAND17
+ Common::ScopedPtr<FlyPack> _flyPack; // +236
+ int _flyTimer = 0; // +240: the milliseconds until the fly starts
+ int _flyState = 1; // +244: the state "ÐÑÑ
а_17" (1 .. 3)
+ bool _flyPending = false; // +248: the fly has to start when the timer is over
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SC17CONTROLLER_H
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index 4a40508c8b3..528dbd1ddcf 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -26,6 +26,7 @@
#include "ngi/fullpipe/sc09controller.h"
#include "ngi/fullpipe/sc11controller.h"
#include "ngi/fullpipe/sc14controller.h"
+#include "ngi/fullpipe/sc17controller.h"
#include "ngi/fullpipe/scenecontrollers.h"
#include "ngi/fullpipe/sc03controller.h"
#include "ngi/fullpipe/sc04controller.h"
@@ -191,15 +192,6 @@ void Sc16Controller::onShow() {
_offsetY = 300;
}
-// CSc17Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
-void Sc17Controller::onShow() {
- FPController::onShow();
- _marginX = 300;
- _marginY = 200;
- _offsetX = 400;
- _offsetY = 300;
-}
-
// CSc18Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
void Sc18Controller::onShow() {
FPController::onShow();
diff --git a/engines/ngi/fullpipe/scenecontrollers.h b/engines/ngi/fullpipe/scenecontrollers.h
index fe8509ead89..d98e3ee2395 100644
--- a/engines/ngi/fullpipe/scenecontrollers.h
+++ b/engines/ngi/fullpipe/scenecontrollers.h
@@ -103,12 +103,6 @@ public:
void onShow() override;
};
-class Sc17Controller : public FPController {
-public:
- explicit Sc17Controller(int sceneId) : FPController(sceneId) {}
- void onShow() override;
-};
-
class Sc18Controller : public FPController {
public:
explicit Sc18Controller(int sceneId) : FPController(sceneId) {}
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index cec7e0551f4..54cf8bc8793 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -95,6 +95,7 @@ MODULE_OBJS = \
fullpipe/sc09controller.o \
fullpipe/sc11controller.o \
fullpipe/sc14controller.o \
+ fullpipe/sc17controller.o \
fullpipe/scene01.o \
fullpipe/scene02.o \
fullpipe/scene03.o \
Commit: 23fb53fd664c229bf17d93398cc8166299421ecf
https://github.com/scummvm/scummvm/commit/23fb53fd664c229bf17d93398cc8166299421ecf
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 27 controller ported
Changed paths:
A engines/ngi/fullpipe/sc27controller.cpp
A engines/ngi/fullpipe/sc27controller.h
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/scenecontrollers.h
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/sc27controller.cpp b/engines/ngi/fullpipe/sc27controller.cpp
new file mode 100644
index 00000000000..efa27caf6de
--- /dev/null
+++ b/engines/ngi/fullpipe/sc27controller.cpp
@@ -0,0 +1,1002 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/formats/xmlparser.h"
+#include "common/hashmap.h"
+#include "common/str.h"
+
+#include "ngi/ngi.h"
+#include "ngi/behavior.h"
+#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/input.h"
+#include "ngi/interaction.h"
+#include "ngi/messages.h"
+#include "ngi/motion.h"
+#include "ngi/objects.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/sc27controller.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+namespace {
+
+// the marks of the subsystems that are not ported: once per kind
+void warnOnce(const char *what) {
+ static Common::HashMap<Common::String, bool> reported;
+ if (!reported.contains(what)) {
+ reported[what] = true;
+ warning("STUB/untested: %s", what);
+ }
+}
+
+// CAniObject::MoveToStatic (F1B0C) is not ported (the instant chain of linked movements, tracking/entities.csv "pending"); like the other ported controllers
+// the object is put into the statics (SetStatic)
+void moveToStatic(AniObject *ani, int staticsId) {
+ warnOnce("CAniObject::MoveToStatic (CSc27Controller: SetStatic is used)");
+ ani->setStatic(staticsId);
+}
+
+// CMessageQueue::Interrupt (10C882) = CMessageQueue::Stop (10C838): not ported
+void interruptQueue(MessageQueue *queue) {
+ warnOnce("CMessageQueue::Interrupt (CSc27Controller)");
+}
+
+// StopMovement(false) (slot 152), then the object's queue is interrupted (slot 64)
+void stopMovementAndQueue(AniObject *ani) {
+ ani->stopMovement();
+ MessageQueue *queue = ani->getMessageQueue();
+ if (queue)
+ interruptQueue(queue);
+}
+
+// CBehaviorController::OnSetQueue (F3774): CBehaviorAni::Stop, not ported
+void behaviorOnSetQueue(AniObject *ani) {
+ warnOnce("CBehaviorController::OnSetQueue (CBehaviorAni::Stop, CSc27Controller)");
+}
+
+// CAniObject::GetCurFrame (F112C): -1 without a movement
+int getCurFrame(const AniObject *ani) {
+ if (ani->_movement)
+ return ani->_movement->_curFrame;
+ return -1;
+}
+
+// CAniObject::SetCurFrame (F0C76): only the movement of the object steps (CMovement::SetCurFrame, EFB00). The two flags of the original (a3 = `flag` is kept in
+// CMovement +63, a4 is always 0 here and reaches CMovement::SetFrame, which then runs the command of every phase that it steps over) are not modelled by
+// Movement::setCurFrame
+void setCurFrame(AniObject *ani, int frame, bool flag) {
+ (void)flag;
+ if (ani->_movement)
+ ani->_movement->setCurFrame(frame);
+}
+
+// CCommand(5) with "msg": the message goes to the controllers by its name (CScene::Message), to the scene handlers by its id
+Command *messageCommand(const char *name) {
+ uint32 id = 0;
+ g_ngi->_gameProject->_objectIds.findId(name, id);
+ Command *command = new Command(0, kCmdMessage, id, 0, 0, 0, 0, 0, 0, 0);
+ command->_messageName = name;
+ command->_excFlags |= 3;
+ return command;
+}
+
+// CCommand(3, 1) with "aniId", "moveId" and "copy": START_MOVEMENT that the queue waits for
+Command *movementCommand(const AniObject *ani, int movementId) {
+ Command *command = new Command(ani->_id, kCmdStartMovement, movementId, 0, 0, 0, 1, 0, 0, 0);
+ command->_param = ani->_copyId;
+ command->_excFlags |= 2;
+ return command;
+}
+
+// a double from its two words (the constants of GenerateTest are read from the code)
+double doubleFromWords(uint32 high, uint32 low) {
+ const uint64 bits = ((uint64)high << 32) | low;
+ double value;
+ memcpy(&value, &bits, sizeof(value));
+ return value;
+}
+
+// word_2D534E: movement of the rack ANI_BITAHANDLER from ST_BTH_5 .. ST_BTH_1 (odd entries are 0)
+const int kRackMovements[9] = {
+ MV_BTH_5_4, 0, MV_BTH_4_3, 0, MV_BTH_3_2, 0, MV_BTH_2_1, 0, MV_BTH_1_0
+};
+
+} // End of anonymous namespace
+
+// sc_27_settings.xml (CSc27Controller::ReadSettingsXml): BETS and MAN, missing values keep OnShow's
+class Sc27SettingsParser : public Common::XMLParser {
+public:
+ explicit Sc27SettingsParser(Sc27Controller *controller) : _controller(controller) {}
+
+private:
+ Sc27Controller *_controller;
+
+ CUSTOM_XML_PARSER(Sc27SettingsParser) {
+ XML_KEY(SETTINGS)
+ XML_KEY(BETS)
+ XML_PROP(frameDelayK, false)
+ XML_PROP(shootParamMult, false)
+ XML_PROP(shootParamAdd, false)
+ XML_PROP(frict, false)
+ XML_PROP(frict2, false)
+ XML_PROP(minVel, false)
+ XML_PROP(numBets, false)
+ XML_PROP(numBetsToWin, false)
+ KEY_END()
+ XML_KEY(MAN)
+ XML_PROP(frameDelayK, false)
+ KEY_END()
+ KEY_END()
+ } PARSER_END()
+
+ bool parserCallback_SETTINGS(ParserNode *) { return true; }
+
+ bool parserCallback_BETS(ParserNode *node) {
+ _controller->_shootParamMult = (float)atof(node->values.getValOrDefault("shootParamMult", "2.5").c_str());
+ _controller->_shootParamAdd = (float)atof(node->values.getValOrDefault("shootParamAdd", "8.0").c_str());
+ _controller->_friction = (float)atof(node->values.getValOrDefault("frict", "0.035").c_str());
+ _controller->_friction2 = (float)atof(node->values.getValOrDefault("frict2", "0.4").c_str());
+ _controller->_minVelocity = (float)atof(node->values.getValOrDefault("minVel", "0.5").c_str());
+ _controller->_numBets = atoi(node->values.getValOrDefault("numBets", "5").c_str());
+ _controller->_numBetsToWin = atoi(node->values.getValOrDefault("numBetsToWin", "3").c_str());
+ return true;
+ }
+
+ bool parserCallback_MAN(ParserNode *node) {
+ _controller->_frameDelayK = (float)atof(node->values.getValOrDefault("frameDelayK", "1.0").c_str());
+ return true;
+ }
+};
+
+// CSc27Controller::CSc27Controller (189E08)
+Sc27Controller::Sc27Controller(int sceneId) : FPController(sceneId), _tutorial("ARCADE_TUTORIAL_27") {
+}
+
+// CSc27Controller::~CSc27Controller (189DA8): RemoveCopies left out, the scene destroys the objects
+Sc27Controller::~Sc27Controller() {
+}
+
+// CSc27Controller::CanSwipeMan (188148): not while the arcade runs
+bool Sc27Controller::canSwipeMan(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::canSwipeMan(x, y);
+ return !_arcadeRunning;
+}
+
+// CSc27Controller::CanShowHelp (188152): not while the arcade runs
+bool Sc27Controller::canShowHelp() {
+ if (!controllerRunsSceneLogic())
+ return FPController::canShowHelp();
+ return !_arcadeRunning;
+}
+
+// CSc27Controller::CleanXml (18815C)
+void Sc27Controller::cleanXml() {
+ _tutorial = "ARCADE_TUTORIAL_27";
+}
+
+// CSc27Controller::TestCollision (188198): the two bets touch (radii of the flattened ellipse)
+bool Sc27Controller::testCollision(int first, int second) {
+ const double angle = atan2(_bets[first]._y - _bets[second]._y, _bets[first]._x - _bets[second]._x);
+ const double cosine = cos(angle);
+ const double sine = sin(angle);
+ const double radius = sqrt(cosine * cosine + sine * sine * 0.5 * 0.5);
+ const double dx = _bets[first]._x - _bets[second]._x;
+ const double dy = _bets[first]._y - _bets[second]._y;
+ return sqrt(dx * dx + dy * dy) < radius * 27.0 + radius * 27.0;
+}
+
+// CSc27Controller::ManNextFunc (1882D0): every 83 ms the hero is drawn back one frame, up to 5
+void Sc27Controller::manNextFunc(uint32 elapsed) {
+ const int timer = elapsed + _manTimer;
+ if (timer > 83) {
+ _manTimer = timer - 83;
+ int frame = getCurFrame(hero());
+ bool flag = false;
+ if (!_maxPhase) {
+ if (frame > 4) {
+ _maxPhase = true;
+ } else {
+ _manTimer = 0;
+ frame = frame + 1;
+ flag = true;
+ }
+ }
+ _arrowScale = (float)(frame - 6) / 5.0f + 0.7f;
+ setCurFrame(hero(), frame, flag);
+ } else {
+ _manTimer = timer;
+ }
+}
+
+// CSc27Controller::StartDrag (188338)
+void Sc27Controller::startDrag(float x, float y) {
+ _dragStartX = x;
+ _dragStartY = y;
+ _aiming = true;
+ _maxPhase = false;
+ _manTimer = 0;
+}
+
+// CSc27Controller::CheckTutorial (188360): arcade tutorial, once the scene is alone on the stack
+void Sc27Controller::checkTutorial() {
+ if (_tutorial == "UNDEF")
+ return;
+ if (g_ngi->_sceneStack.size() != 1)
+ return;
+ if (!g_ngi->_tutorialManager->activateTutorial(_tutorial))
+ _tutorial = "UNDEF";
+}
+
+// CSc27Controller::SwitchMaid (1883F0): with the swab she goes to the other side of the vent
+void Sc27Controller::switchMaid() {
+ if (g_ngi->getStateId(sO_Maid) == g_ngi->getStateValue(sO_Maid, sO_WithSwab)) {
+ if (_maid->_movement || _maid->getMessageQueue()) {
+ stopMovementAndQueue(_maid);
+ behaviorOnSetQueue(_maid);
+ }
+ moveToStatic(_maid, ST_MID_SWAB2);
+ _scene->runQueue(QU_MID_SWITCH, 3);
+ }
+}
+
+// CSc27Controller::SwitchMaidBack (1884AC)
+void Sc27Controller::switchMaidBack() {
+ if (g_ngi->getStateId(sO_Maid) == g_ngi->getStateValue(sO_Maid, sO_WithSwab)) {
+ if (_maid->_movement || _maid->getMessageQueue()) {
+ stopMovementAndQueue(_maid);
+ behaviorOnSetQueue(_maid);
+ }
+ moveToStatic(_maid, ST_MID_SWAB);
+ _scene->runQueue(QU_MID_SWITCHBACK, 3);
+ }
+}
+
+// CSc27Controller::DoPushButton (188568): no bets left, the driver pushes the button
+void Sc27Controller::doPushButton() {
+ if (g_ngi->getStateId(sO_Driver) == g_ngi->getStateValue(sO_Driver, sO_WithSteering)) {
+ if (!_driver->_movement || _driver->getMessageQueue())
+ stopMovementAndQueue(_driver);
+ moveToStatic(_driver, ST_DRV_VENT);
+ _scene->runQueueWithAni(QU_DRV_PUSHBUTTON, _driver, 2);
+ } else {
+ if (!_driver->_movement || _driver->getMessageQueue())
+ stopMovementAndQueue(_driver);
+ moveToStatic(_driver, ST_DRV_SITNOVENT);
+ _scene->runQueueWithAni(QU_DRV_PUSHBUTTON_NOVENT, _driver, 2);
+ }
+ _buttonPushed = true;
+}
+
+// CSc27Controller::OnTakeVent (188658)
+void Sc27Controller::onTakeVent() {
+ if (g_ngi->getStateId(sO_Maid) == g_ngi->getStateValue(sO_Maid, sO_WithSwab)) {
+ if (!_maid->_movement || _maid->getMessageQueue()) {
+ stopMovementAndQueue(_maid);
+ _takeVent = false;
+ moveToStatic(_maid, ST_MID_SWAB2);
+ _scene->runQueueWithAni(QU_MID_CLEANVENT, _maid, 3);
+ }
+ }
+}
+
+// CSc27Controller::TestHit (188710): highlights the bets in the hit zone, updates the counter
+bool Sc27Controller::testHit(int index) {
+ const bool hit = _hitZone->hit((int)_bets[index]._x, (int)_bets[index]._y);
+ AniObject *ani = _bets[index]._ani;
+ if (hit) {
+ if (ani->_statics->_staticsId == ST_BTA_NORM && !ani->_movement) {
+ ani->setStatic(ST_BTA_HILITE);
+ g_ngi->arcadeInterface().incCounter();
+ }
+ } else if (ani->_statics->_staticsId == ST_BTA_HILITE && !ani->_movement) {
+ ani->setStatic(ST_BTA_NORM);
+ g_ngi->arcadeInterface().decCounter();
+ }
+ return hit;
+}
+
+// CSc27Controller::DoWipe (1887C8): bets still on screen are swept to the lower right
+void Sc27Controller::doWipe() {
+ if (g_ngi->arcadeInterface().getState() == ArcadeInterface::kShown)
+ g_ngi->arcadeInterface().scrollOut();
+
+ for (uint i = 0; i < _bets.size(); ++i) {
+ if (_bets[i]._x < 800.0) {
+ _bets[i]._angle = atan2(520.0 - _bets[i]._y, 800.0 - _bets[i]._x);
+ _bets[i]._power = _bets[i]._power + 1.0;
+ }
+ }
+}
+
+// CSc27Controller::GetCursorTypeTop (188888): -1 unless a bet is under the cursor, none at the hero
+int Sc27Controller::getCursorTypeTop(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::getCursorTypeTop(x, y);
+ const bool noCursor = !g_ngi->_inputController->isObjectHit(ANI_BITA) || _nextBet != nullptr;
+ return -(int)noCursor;
+}
+
+// CSc27Controller::UpdateDrag (1888B0): the frame of the hero follows the finger (6 .. 11)
+void Sc27Controller::updateDrag() {
+ int frame = (int)((_dragStartX - g_ngi->_inputController->_hotSceneX) / 20.0f + 6.0f);
+ if (frame <= 5)
+ frame = 6;
+ else if (frame > 11)
+ frame = 11;
+ if (hero()->_movement)
+ setCurFrame(hero(), frame, false);
+}
+
+// CSc27Controller::MakeCollision (188908): two bets push each other, slightly random directions
+void Sc27Controller::makeCollision(int first, int second) {
+ Bet &a = _bets[first];
+ Bet &b = _bets[second];
+ if (a._power == 0.0)
+ return;
+
+ const double direction = atan2(b._y - a._y, b._x - a._x);
+ const double angleA = (double)random31() / 2147483647.0 * 0.03 - 0.015 + direction;
+ const double powerA = a._power;
+ const double deltaA = a._angle - angleA;
+ const double pushAx = powerA * cos(deltaA) * (double)(((int)(b._x - a._x) >> 31) | 1);
+ const double pushAy = powerA * sin(deltaA) * (double)(((int)(b._y - a._y) >> 31) | 1);
+ a._powerCos = a._powerCos - pushAx * 1.1;
+ a._powerSin = a._powerSin - pushAy * 1.1;
+
+ const double directionB = atan2(a._y - b._y, a._x - b._x);
+ const double randomB = (double)random31();
+ const double powerB = b._power;
+ const double deltaB = b._angle - (randomB / 2147483647.0 * 0.03 - 0.015 + directionB);
+ const double pushBx = powerB * cos(deltaB) * (double)(((int)(a._x - b._x) >> 31) | 1);
+ const double pushBy = powerB * sin(deltaB) * (double)(((int)(a._y - b._y) >> 31) | 1);
+ b._powerCos = b._powerCos - pushBx * 1.1;
+ b._powerSin = b._powerSin - pushBy * 1.1;
+
+ const double cosine = cos(angleA);
+ const double sine = sin(angleA);
+ const double radius = sqrt(cosine * cosine + sine * sine * 0.5 * 0.5);
+ const double dx = a._x - b._x;
+ const double dy = a._y - b._y;
+ const double distance = sqrt(dx * dx + dy * dy);
+ const double angleOfA = a._angle;
+ const double cosDelta = cos(angleA - angleOfA);
+ const double cosOfA = cos(angleOfA);
+ const double shift = (radius * 27.0 + radius * 27.0 - distance) / cosDelta + 1.0;
+ a._x = a._x - cosOfA * shift;
+ a._y = a._y - sin(a._angle) * shift;
+
+ a._powerCos = a._powerCos + pushBx * 0.64;
+ if (a._x <= 500.0)
+ a._powerSin = 0.0;
+ else
+ a._powerSin = a._powerSin + pushBy * 0.64;
+ a._angle = atan2(a._powerSin, a._powerCos);
+ a._power = sqrt(a._powerCos * a._powerCos + a._powerSin * a._powerSin);
+
+ b._powerCos = b._powerCos + pushAx * 0.64;
+ if (b._x <= 500.0)
+ b._powerSin = 0.0;
+ else
+ b._powerSin = b._powerSin + pushAy * 0.64;
+ b._angle = atan2(b._powerSin, b._powerCos);
+ b._power = sqrt(b._powerCos * b._powerCos + b._powerSin * b._powerSin);
+
+ g_ngi->playSound(SND_27_026, 0);
+}
+
+// CSc27Controller::StopDrag (188EF8): the throw, strength is the frame he was drawn back to
+void Sc27Controller::stopDrag() {
+ _aiming = false;
+ _maxPhase = false;
+ _manTimer = 0;
+ _manAnimating = false;
+ const int frame = getCurFrame(hero());
+ _launchPhase = frame - 6;
+ int throwFrame = 27 - frame;
+ if (throwFrame > 19)
+ throwFrame = 20;
+ else if (throwFrame <= 13)
+ throwFrame = 14;
+ g_ngi->playSound(SND_27_044, 0);
+ _powerArrow->_flags &= ~4;
+ _arrowScale = 0.7f;
+ _powerArrow->_scaleX = 0.7f;
+ _powerArrow->_scaleY = 1.0f;
+ setCurFrame(hero(), throwFrame, true);
+ warnOnce("CHintManager::SetHideCondition (CSc27Controller::StopDrag)");
+}
+
+// CSc27Controller::ShowNextBet (188F88)
+void Sc27Controller::showNextBet() {
+ if (_nextBet) {
+ _nextBet->setStatic(ST_BTA_NORM);
+ _nextBet->setCenter(Common::Point(186, 527));
+ _nextBet->_z = 5;
+ _nextBet->_flags |= 4;
+ } else {
+ // CLogger::WriteLog
+ warning("ShowNextBet: m_pNextBet == 0");
+ }
+ _batHandler->_z = 985;
+ PictureObject *pipe = _scene->findPictureObjectById(PIC_SC27_LTRUBA, 0);
+ pipe->_z = 940;
+}
+
+// CSc27Controller::DoWin (18903C): the driver gives the vent, the controls are free again
+void Sc27Controller::doWin() {
+ // Flurry events (analytics) are not ported
+ _startEvent = true;
+ g_ngi->arcadeInterface().scrollOut();
+ if (!_driver->_movement || _driver->getMessageQueue())
+ stopMovementAndQueue(_driver);
+ moveToStatic(_driver, ST_DRV_VENT);
+ _scene->runQueueWithAni(QU_DRV_GIVEVENT, _driver, 2);
+ _arcadeRunning = false;
+ _scene->_motionController->activate();
+ getGameLoaderInteractionController()->enable();
+ _scene->_behaviorController->enableAllQueuesForAni(hero(), 1);
+ warnOnce("CHintManager::HideHint (CSc27Controller)");
+ warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc27Controller)");
+}
+
+// CSc27Controller::DoWinArcade (189174): MSG_CMN_WINARCADE and the key W
+void Sc27Controller::doWinArcade() {
+ if (g_ngi->getStateId(sO_Driver) == g_ngi->getStateValue(sO_Driver, sO_WithSteering)) {
+ _aiming = false;
+ _manTimer = 0;
+ _manAnimating = false;
+ hero()->setStatic(ST_MAN_RIGHT);
+ doWin();
+ }
+}
+
+// CSc27Controller::DoTakeBet (189200): MV_MAN27_THROWBET runs to the frame ManNextFunc stops at
+void Sc27Controller::doTakeBet(MessageQueue *queue) {
+ if (_startEvent) {
+ // CFPController::FlurryArcadeStart "ANI_BET": analytics, not ported
+ }
+ if (!_arcadeRunning)
+ warnOnce("CHintManager::ShowHint (CSc27Controller::DoTakeBet)");
+ _startEvent = false;
+ warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc27Controller)");
+ hero()->startMovement(MV_MAN27_THROWBET, 0, -1);
+ hero()->getMovement(MV_MAN27_THROWBET)->_loopDelay = 83 * (int)_frameDelayK;
+ _scene->_motionController->deactivate();
+ getGameLoaderInteractionController()->disable();
+ _scene->_behaviorController->enableAllQueuesForAni(hero(), 0);
+ _maxPhase = false;
+ _nextBet->_flags &= ~4;
+ _arcadeRunning = true;
+ _manAnimating = true;
+}
+
+// CSc27Controller::SkipArcade (1892DC): the arcade ends when no bet moves any more
+void Sc27Controller::skipArcade() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::skipArcade();
+ return;
+ }
+ g_ngi->arcadeInterface().scrollOut();
+ if (_movingBets != 0) {
+ _skipArcade = true;
+ } else {
+ _skipArcade = false;
+ _aiming = false;
+ _manTimer = 0;
+ _manAnimating = false;
+ _nextBet = nullptr;
+ hero()->setStatic(ST_MAN_RIGHT);
+ if (!_driver->_movement || _driver->getMessageQueue()) {
+ stopMovementAndQueue(_driver);
+ }
+ if (g_ngi->getStateId(sO_Driver) == g_ngi->getStateValue(sO_Driver, sO_WithSteering)) {
+ moveToStatic(_driver, ST_DRV_VENT);
+ _scene->runQueueWithAni(QU_DRV_GIVEVENT, _driver, 2);
+ }
+ _arcadeRunning = false;
+ _scene->_motionController->activate();
+ getGameLoaderInteractionController()->enable();
+ _scene->_behaviorController->enableAllQueuesForAni(hero(), 1);
+ warnOnce("CHintManager::HideHint (CSc27Controller)");
+ warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc27Controller)");
+ // CFPController::FlurryArcadeSkip "ANI_BET": analytics, not ported
+ _startEvent = true;
+ }
+}
+
+// CSc27Controller::PrepareNextBet (189434): next spare bet and rack count down, or lost
+void Sc27Controller::prepareNextBet(int highlighted) {
+ if (_spareBets.empty() || _skipArcade) {
+ _nextBet = nullptr;
+ return;
+ }
+
+ _nextBet = _spareBets.front();
+ _spareBets.pop_front();
+ PictureObject *pipe = _scene->findPictureObjectById(PIC_SC27_LTRUBA, 0);
+ pipe->_z = 987;
+
+ const uint rack = _batHandler->_statics->_staticsId - ST_BTH_5;
+ if (rack <= 8 && kRackMovements[rack] != 0) {
+ const int movementId = kRackMovements[rack];
+ MessageQueue *queue = new MessageQueue(_scene, true, 1); // CMessageQueue(scene, 1, 1)
+ queue->_interruptState = 2; // SetIntState(2)
+ _batHandler->_z = 985;
+ queue->addCommandToEnd(movementCommand(_batHandler, movementId));
+ queue->addCommandToEnd(messageCommand("MSG_SC27_CLICKBET"));
+ // CScene::RunQueue(queue, 4, 0): added to the scene and run, the object does not get it
+ if (!queue->run(nullptr)) {
+ delete queue;
+ // CLogger::WriteLog
+ warning("sc27::PrepareNextBet: m_scene->RunQueue() returned false!");
+ }
+ } else {
+ _scene->runQueue(QU_SC27_RESTARTBETS, 2);
+ _scene->_motionController->activate();
+ getGameLoaderInteractionController()->enable();
+ _scene->_behaviorController->enableAllQueuesForAni(hero(), 1);
+ _arcadeRunning = false;
+ warnOnce("CHintManager::HideHint (CSc27Controller)");
+ warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc27Controller)");
+ // Flurry events (analytics) are not ported
+ }
+}
+
+// CSc27Controller::DoRestart (1897A8): the bets that fell are put back, the next one is made ready
+void Sc27Controller::doRestart() {
+ // Flurry events (analytics) are not ported
+ _wiping = false;
+ for (uint i = 0; i < _fallenBets.size(); ++i) {
+ _fallenBets[i]._ani->_flags &= ~4;
+ _spareBets.push_back(_fallenBets[i]._ani);
+ }
+ _fallenBets.clear();
+ prepareNextBet(0);
+ _buttonPushed = false;
+}
+
+// CSc27Controller::OnStopAll (18989C): won, or the driver pushes the button, or next bet
+void Sc27Controller::onStopAll() {
+ if (!_wiping) {
+ if (!_buttonPushed) {
+ int highlighted = 0;
+ for (uint i = 0; i < _bets.size(); ++i)
+ highlighted += _bets[i]._ani->_statics->_staticsId == ST_BTA_HILITE;
+ if (highlighted >= _numBetsToWin) {
+ if (g_ngi->getStateId(sO_Driver) == g_ngi->getStateValue(sO_Driver, sO_WithSteering)) {
+ doWin();
+ warnOnce("CAchievementsManager::AddActivatingCounter ACHIEVEMENT_ARCADE_27 (CSc27Controller::OnStopAll)");
+ switchMaidBack();
+ return;
+ }
+ }
+ if (_spareBets.empty()) {
+ doPushButton();
+ warnOnce("CAchievementsManager::BlockActivatingCounter ACHIEVEMENT_ARCADE_27 (CSc27Controller::OnStopAll)");
+ // Flurry events (analytics) are not ported
+ switchMaidBack();
+ return;
+ }
+ prepareNextBet(highlighted);
+ }
+ }
+ switchMaidBack();
+}
+
+// CSc27Controller::OnBetClick (189B88): MSG_SC27_CLICKBET: the hero walks to (181, 456), takes it
+void Sc27Controller::onBetClick(MessageQueue *queue) {
+ const Common::Point betCenter = _nextBet->getCenter();
+ if (betCenter.x != 186 || betCenter.y != 527)
+ return;
+
+ if (g_ngi->arcadeInterface().getState() == ArcadeInterface::kHidden) {
+ g_ngi->arcadeInterface().init(145.0f, -100.0f, 64.0f, 0.0f, 3, 0, true);
+ g_ngi->arcadeInterface().scrollIn();
+ }
+
+ bool mirror;
+ Common::Point heroCenter = hero()->getCenter();
+ if (ABS(181.0f - heroCenter.x) > 3.0f) {
+ mirror = false;
+ } else {
+ heroCenter = hero()->getCenter();
+ if (ABS(456.0f - heroCenter.y) > 3.0f) {
+ mirror = false;
+ } else if (hero()->_movement) {
+ mirror = false;
+ } else {
+ mirror = hero()->_statics->_staticsId == ST_MAN_RIGHT;
+ if (mirror) {
+ doTakeBet(queue);
+ return;
+ }
+ }
+ }
+
+ MessageQueue *started = mctlStartMove(181, 456, true, ST_MAN_RIGHT, mirror);
+ if (started)
+ started->addCommandToEnd(messageCommand("MSG_SC27_CLICKBET"));
+}
+
+// CSc27Controller::RemoveCopies (189D00): the copies of the bets leave the scene
+void Sc27Controller::removeCopies() {
+ for (Common::List<AniObject *>::iterator it = _spareBets.begin(); it != _spareBets.end(); ++it) {
+ AniObject *ani = *it;
+ if (ani->_copyId != 0) {
+ _scene->removeAni(ani);
+ delete ani;
+ }
+ }
+ _spareBets.clear();
+
+ for (uint i = 0; i < _fallenBets.size(); ++i) {
+ AniObject *ani = _fallenBets[i]._ani;
+ if (ani->_copyId != 0) {
+ _scene->removeAni(ani);
+ delete ani;
+ }
+ }
+ _fallenBets.clear();
+
+ for (uint i = 0; i < _bets.size(); ++i) {
+ AniObject *ani = _bets[i]._ani;
+ if (ani->_copyId != 0) {
+ _scene->removeAni(ani);
+ delete ani;
+ }
+ }
+ _bets.clear();
+}
+
+// CSc27Controller::DoShootBet (18A010): MSG_SC27_STARTBET: the bet flies from the hero
+void Sc27Controller::doShootBet(AniObject *ani) {
+ Bet bet;
+ bet._ani = ani;
+ bet._power = (float)((float)_launchPhase * _shootParamMult + _shootParamAdd);
+ bet._powerCos = bet._power;
+ bet._powerSin = bet._power * 0.0;
+ Common::Point center = hero()->getCenter();
+ bet._x = center.x;
+ center = hero()->getCenter();
+ const double angle = bet._angle;
+ const double centerY = center.y;
+ const double power = bet._power;
+ const double x = power * cos(angle) + 42.0 + bet._x;
+ bet._x = x;
+ bet._y = power * sin(angle) + 63.0 + centerY;
+ ani->setCenter(Common::Point((int)x, (int)bet._y));
+ ani->_flags |= 4;
+ _bets.push_back(bet);
+ switchMaid();
+}
+
+// CSc27Controller::TestFall (18A148): a bet over the floor edge falls (MV_BTA_FALL) or is gone
+bool Sc27Controller::testFall(int index) {
+ const double x = _bets[index]._x;
+ const double edge = (_bets[index]._y - 458.0) * 64.0 / 132.0 + 734.0;
+ if (x <= edge)
+ return false;
+
+ AniObject *ani = _bets[index]._ani;
+ if (x - edge > 15.0 || ani->_statics->_staticsId == ST_BTA_FALL) {
+ ani->_z = 946;
+ _fallenBets.push_back(_bets[index]);
+ _bets.remove_at(index);
+ } else if (!ani->_movement) {
+ ani->startMovement(MV_BTA_FALL, 0, -1);
+ }
+ return true;
+}
+
+// CSc27Controller::RecalcBets (18A258): one step of the bets on the floor and of the fallen ones
+void Sc27Controller::recalcBets() {
+ const int oldMoving = _movingBets;
+ _lostBets = 0;
+ _movingBets = 0;
+
+ for (int i = 0; i < (int)_bets.size(); ++i) {
+ _bets[i]._x = _bets[i]._x + cos(_bets[i]._angle) * _bets[i]._power;
+ _bets[i]._y = _bets[i]._y + sin(_bets[i]._angle) * _bets[i]._power;
+ _bets[i]._ani->setCenter(Common::Point((int)_bets[i]._x, (int)_bets[i]._y));
+ _bets[i]._ani->_z = (int)(600.0 - _bets[i]._y);
+
+ float friction;
+ if (cos(_bets[i]._angle) >= 0.0 || _bets[i]._x >= 362.0)
+ friction = _friction;
+ else
+ friction = _friction2;
+ _bets[i]._power = _bets[i]._power - _bets[i]._power * friction;
+ _bets[i]._powerCos = _bets[i]._power * cos(_bets[i]._angle);
+ _bets[i]._powerSin = _bets[i]._power * sin(_bets[i]._angle);
+ if (_bets[i]._power >= _minVelocity) {
+ ++_movingBets;
+ } else {
+ _bets[i]._power = 0.0;
+ }
+
+ testHit(i);
+ if (!testFall(i)) {
+ if (!_wiping) {
+ for (int j = 0; j < (int)_bets.size(); ++j) {
+ if (i != j) {
+ if (testCollision(i, j))
+ makeCollision(i, j);
+ }
+ }
+ }
+ }
+ }
+
+ for (uint j = 0; j < _fallenBets.size(); ++j) {
+ if (_fallenBets[j]._y >= 700.0) {
+ ++_lostBets;
+ } else {
+ _fallenBets[j]._x = _fallenBets[j]._x + _fallenBets[j]._powerCos;
+ _fallenBets[j]._y = _fallenBets[j]._y + _fallenBets[j]._powerSin;
+ _fallenBets[j]._ani->setCenter(Common::Point((int)_fallenBets[j]._x, (int)_fallenBets[j]._y));
+ _fallenBets[j]._powerSin = _fallenBets[j]._powerSin + 1.0;
+ }
+ }
+
+ if (oldMoving != _movingBets && _movingBets == 0)
+ onStopAll();
+ if (_wiping && _lostBets == _numBets)
+ doRestart();
+}
+
+// CSc27Controller::GenerateTest (18A560): two bets for a collision test (nothing calls it)
+void Sc27Controller::generateTest() {
+ Bet first;
+ first._ani = _scene->findAniObjectById(ANI_BITA, 1);
+ first._power = doubleFromWords(0x402E0000, 0);
+ first._angle = 0.0;
+ first._x = doubleFromWords(0x40590000, 0);
+ first._y = doubleFromWords(0x40731000, 0);
+ first._powerCos = doubleFromWords(0x402E0000, 0);
+ first._powerSin = 0.0;
+ first._ani->setCenter(Common::Point(100, 305));
+ first._ani->_flags |= 4;
+ _bets.push_back(first);
+
+ Bet second;
+ second._ani = _scene->findAniObjectById(ANI_BITA, 2);
+ second._power = doubleFromWords(0x402E0000, 0);
+ second._angle = doubleFromWords(0xC00921FB, 0x544486E0);
+ second._x = doubleFromWords(0x4085E000, 0);
+ second._y = doubleFromWords(0x40727000, 0);
+ second._powerCos = doubleFromWords(0xC02E0000, 0);
+ second._powerSin = doubleFromWords(0x3DE50ACF, 0x743C301D);
+ second._ani->setCenter(Common::Point(700, 295));
+ second._ani->_flags |= 4;
+ _bets.push_back(second);
+}
+
+// CSc27Controller::ReadSettingsXml (18A6A0)
+void Sc27Controller::readSettingsXml() {
+ Sc27SettingsParser settings(this);
+ if (!settings.loadFile("data/sc_27_settings.xml") || !settings.parse())
+ warning("Could not read sc_27_settings.xml");
+}
+
+// CSc27Controller::OnShow (18A810): after CFPController::OnShow only the camera margins and offsets
+void Sc27Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+ if (!controllerRunsSceneLogic())
+ return;
+
+ g_ngi->_taskManager->deactivateTask("GET_TO_CURLING_SC25");
+ if (!g_ngi->_taskManager->isSceneVisited(_scene->_sceneId))
+ g_ngi->_taskManager->activateTask("GET_VENTIL_SC27");
+ g_ngi->_taskManager->visitScene(_scene->_sceneId);
+
+ _shootParamMult = 2.5f;
+ _shootParamAdd = 8.0f;
+ _frameDelayK = 1.0f;
+ _friction = 0.035f;
+ _friction2 = 0.4f;
+ _minVelocity = 0.5f;
+ _numBets = 5;
+ _numBetsToWin = 3;
+ _arrowScale = 0.7f;
+ readSettingsXml();
+
+ _hitZone = _scene->findPictureObjectById(PIC_SC27_HITZONE2, 0);
+ _driver = _scene->findAniObjectById(ANI_VODILLA, 0);
+ _maid = _scene->findAniObjectById(ANI_MAID, 0);
+ _powerArrow = _scene->findPictureObjectById(PIC_POWER_ARROW, 0);
+ _powerArrow->_rotation = 0;
+ _powerArrow->_scaleX = _arrowScale;
+ _powerArrow->_scaleY = 1.0f;
+ _powerArrow->setPosition(Common::Point(220, 450)); // SetPos(220, 450, z): the z stays
+ const Common::Point arrowCenter = _powerArrow->getCenter();
+ _arrowCenterX = arrowCenter.x;
+ _arrowCenterY = arrowCenter.y;
+
+ _batHandler = _scene->findAniObjectById(ANI_BITAHANDLER, 0);
+ _batHandler->setStatic(ST_BTH_4);
+ _batHandler->setCenter(Common::Point(58, 513));
+ _arcadeRunning = false;
+
+ AniObject *bet = _scene->findAniObjectById(ANI_BITA, 0);
+ _nextBet = bet;
+ for (int i = 0; i < _numBets - 1; ++i) {
+ AniObject *copy = new AniObject(bet);
+ _spareBets.push_back(copy);
+ _scene->addAni(copy, true);
+ copy->_flags &= ~4;
+ }
+ showNextBet();
+
+ _aiming = false;
+ _maxPhase = false;
+ _wiping = false;
+ _buttonPushed = false;
+ _manAnimating = false;
+ _takeVent = false;
+ _lostBets = 0;
+ _movingBets = 0;
+ _launchPhase = 0;
+ _startEvent = true;
+
+ if (g_ngi->getStateId(sO_Maid) == g_ngi->getStateValue(sO_Maid, sO_WithSwab)) {
+ moveToStatic(_maid, ST_MID_SWAB2);
+ } else if (g_ngi->getStateId(sO_Maid) == g_ngi->getStateValue(sO_Maid, sO_WithBroom)) {
+ moveToStatic(_maid, ST_MID_BROOM);
+ } else if (g_ngi->getStateId(sO_Maid) == g_ngi->getStateValue(sO_Maid, sO_WithSpade)) {
+ moveToStatic(_maid, ST_MID_SPADE);
+ }
+}
+
+// CSc27Controller::OnHide (18AB74)
+void Sc27Controller::onHide() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onHide();
+ return;
+ }
+ // CFPController::FlurryArcadeClean "ANI_BET" and the lose events: analytics, not ported
+ if (g_ngi->arcadeInterface().getState() != ArcadeInterface::kHidden)
+ g_ngi->arcadeInterface().scrollOut();
+ warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc27Controller)");
+ removeCopies();
+ warnOnce("CHintManager::HideHint (CSc27Controller)");
+ FPController::onHide();
+}
+
+// CSc27Controller::OnKeyUp (18ADB8): keys W (win) and Q (skip), test builds
+void Sc27Controller::onKeyUp(uint32 key) {
+ FPController::onKeyUp(key);
+ if (!controllerRunsSceneLogic())
+ return;
+ if (key == 87)
+ doWinArcade();
+ else if (key == 81)
+ skipArcade();
+}
+
+// CSc27Controller::GetCursorType (18ADDE): throw cursor while drawn back, else pointer on the hero
+int Sc27Controller::getCursorType(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::getCursorType(x, y);
+ if (_aiming)
+ return 114;
+ if (g_ngi->_inputController->isObjectHit(ANI_MAN) && _maxPhase)
+ return 1;
+ return FPController::getCursorType(x, y);
+}
+
+// CSc27Controller::OnUpdate (18AE1C)
+void Sc27Controller::onUpdate(uint32 elapsed) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onUpdate(elapsed);
+ return;
+ }
+ FPController::onUpdate(elapsed);
+ if (_aiming)
+ updateDrag();
+ if (_wiping) {
+ doWipe();
+ if (!hero()->_movement) {
+ if (hero()->_statics->_staticsId == ST_MAN_RIGHT)
+ hero()->startMovement(MV_MAN27_FLOW, 0, -1);
+ }
+ }
+ if (_manAnimating)
+ manNextFunc(elapsed);
+ if (_takeVent)
+ onTakeVent();
+ recalcBets();
+ if (_skipArcade)
+ skipArcade();
+}
+
+// CSc27Controller::OnMouseLKeyDown (18AEB8): touching the drawn back hero starts the aiming
+bool Sc27Controller::onMouseLKeyDown(uint32 id, float x, float y) {
+ const bool result = FPController::onMouseLKeyDown(id, x, y);
+ if (!result && controllerRunsSceneLogic() && _maxPhase) {
+ if (g_ngi->_inputController->isObjectHit(hero()))
+ startDrag(x, y);
+ }
+ return result;
+}
+
+// CSc27Controller::OnMouseLKeyUp (18AEF4): the finger is up: the throw
+bool Sc27Controller::onMouseLKeyUp(uint32 id, float x, float y) {
+ const bool result = FPController::onMouseLKeyUp(id, x, y);
+ if (!result && controllerRunsSceneLogic() && _aiming)
+ stopDrag();
+ return result;
+}
+
+// CSc27Controller::OnRender (18AF14): arcade interface and the throw arrow
+void Sc27Controller::onRender(Common::Point scroll) {
+ FPController::onRender(scroll);
+ if (!controllerRunsSceneLogic())
+ return;
+ if (g_ngi->arcadeInterface().getState() != ArcadeInterface::kHidden)
+ g_ngi->arcadeInterface().render();
+ if (_powerArrow && _aiming && _manAnimating) {
+ _powerArrow->_scaleX = _arrowScale;
+ _powerArrow->_scaleY = 1.0f;
+ _powerArrow->setCenter(Common::Point((int)_arrowCenterX, (int)_arrowCenterY));
+ }
+}
+
+// CSc27Controller::OnMessage (18AF7C)
+void Sc27Controller::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onMessage(message, param, queue);
+ return;
+ }
+ if (message == "MSG_SC27_STARTBET") {
+ if (_nextBet)
+ doShootBet(_nextBet);
+ } else if (message == "MSG_SC27_CLICKBET") {
+ if (_nextBet)
+ onBetClick(queue);
+ } else if (message == "MSG_SC27_STARTWIPE") {
+ _wiping = true;
+ g_ngi->playSound(SND_27_027, 0);
+ } else if (message == "MSG_SC27_SHOWNEXTBET") {
+ showNextBet();
+ } else if (message == "MSG_SC27_HANDLERTOFRONT") {
+ _batHandler->_z = 100;
+ } else if (message == "MSG_SC27_TAKEVENT") {
+ _takeVent = true;
+ } else if (message == "MSG_CMN_WINARCADE") {
+ doWinArcade();
+ } else {
+ FPController::onMessage(message, param, queue);
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sc27controller.h b/engines/ngi/fullpipe/sc27controller.h
new file mode 100644
index 00000000000..8be278f24c3
--- /dev/null
+++ b/engines/ngi/fullpipe/sc27controller.h
@@ -0,0 +1,137 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SC27CONTROLLER_H
+#define NGI_FULLPIPE_SC27CONTROLLER_H
+
+#include "common/array.h"
+#include "common/list.h"
+
+#include "ngi/fullpipe/fpcontroller.h"
+
+namespace NGI {
+
+class PictureObject;
+class Sc27SettingsParser;
+
+/** CSc27Controller: the bats arcade (throw ANI_BET at the pipe, three of five must stay) */
+class Sc27Controller : public FPController {
+public:
+ explicit Sc27Controller(int sceneId);
+ ~Sc27Controller() override;
+
+ void cleanXml() override;
+ bool canSwipeMan(float x, float y) override;
+ bool canShowHelp() override;
+ void skipArcade() override;
+ void checkTutorial() override;
+ void onShow() override;
+ void onHide() override;
+ int getCursorType(float x, float y) override;
+ int getCursorTypeTop(float x, float y) override;
+ void onUpdate(uint32 elapsed) override;
+ void onRender(Common::Point scroll) override;
+ void onKeyUp(uint32 key) override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+
+ bool testCollision(int first, int second);
+ void manNextFunc(uint32 elapsed);
+ void startDrag(float x, float y);
+ void switchMaid();
+ void switchMaidBack();
+ void doPushButton();
+ void onTakeVent();
+ bool testHit(int index);
+ void doWipe();
+ void updateDrag();
+ void makeCollision(int first, int second);
+ void stopDrag();
+ void showNextBet();
+ void doWin();
+ void doWinArcade();
+ void doTakeBet(MessageQueue *queue);
+ void prepareNextBet(int highlighted);
+ void doRestart();
+ void onStopAll();
+ void onBetClick(MessageQueue *queue);
+ void removeCopies();
+ void doShootBet(AniObject *bet);
+ bool testFall(int index);
+ void recalcBets();
+ void generateTest();
+ void readSettingsXml();
+
+private:
+ friend class Sc27SettingsParser;
+
+ /** _SC27_BET (56 bytes): a bat flying over the floor, the numbers are doubles */
+ struct Bet {
+ AniObject *_ani = nullptr; // +0
+ double _power = 0; // +8: the speed
+ double _angle = 0; // +16: the direction
+ double _x = 0; // +24: the center
+ double _y = 0; // +32
+ double _powerCos = 0; // +40: the speed along x
+ double _powerSin = 0; // +48: the speed along y
+ };
+
+ /** +216: the next tutorial of the scene */
+ Common::String _tutorial;
+ AniObject *_nextBet = nullptr; // +220: the waiting bet (ANI_BET), 0 when none
+ PictureObject *_hitZone = nullptr; // +224: PIC_SC27_HITZONE2, where a bet counts
+ PictureObject *_powerArrow = nullptr; // +228: PIC_POWER_ARROW, shows the strength of the throw
+ AniObject *_driver = nullptr; // +232: ANI_VODILLA
+ AniObject *_maid = nullptr; // +236: ANI_MAID
+ AniObject *_batHandler = nullptr; // +240: ANI_BITAHANDLER, the rack of bets left
+ Common::List<AniObject *> _spareBets; // +244: bets not thrown yet (std::list)
+ Common::Array<Bet> _fallenBets; // +252: the bets that fell off the floor
+ Common::Array<Bet> _bets; // +264: the bets on the floor
+ float _dragStartX = 0; // +276: where the hero was touched
+ float _dragStartY = 0; // +280
+ int _launchPhase = 0; // +284: the frame of the throw when the touch was released, minus 6
+ bool _aiming = false; // +288: the hero is touched and drawn back
+ bool _maxPhase = false; // +289: hero drawn back fully (touch starts aiming)
+ bool _wiping = false; // +290: MSG_SC27_STARTWIPE, the bets are swept to the right
+ bool _buttonPushed = false; // +291: the driver pushed the button (no bets left)
+ int _lostBets = 0; // +292: the bets that fell down the screen
+ int _movingBets = 0; // +296: the bets that still move
+ int _manTimer = 0; // +300: the milliseconds until the hero is drawn back one more frame
+ bool _manAnimating = false; // +304: ManNextFunc runs (DoTakeBet .. StopDrag)
+ bool _takeVent = false; // +305: MSG_SC27_TAKEVENT, the maid takes the vent as soon as she is free
+ float _shootParamMult = 2.5f; // +308: sc_27_settings.xml BETS shootParamMult
+ float _shootParamAdd = 8.0f; // +312: shootParamAdd
+ float _friction = 0.035f; // +316: frict
+ float _friction2 = 0.4f; // +320: frict2
+ float _minVelocity = 0.5f; // +324: minVel
+ int _numBets = 5; // +328: numBets
+ int _numBetsToWin = 3; // +332: numBetsToWin
+ float _frameDelayK = 1.0f; // +336: MAN frameDelayK
+ float _arrowScale = 0.7f; // +340: the horizontal scale of the arrow
+ float _arrowCenterX = 0; // +344: where the arrow stands
+ float _arrowCenterY = 0; // +348
+ bool _startEvent = true; // +352: the Flurry event "arcade start" is due (the next DoTakeBet)
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SC27CONTROLLER_H
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index 528dbd1ddcf..d1e4e733bde 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -27,6 +27,7 @@
#include "ngi/fullpipe/sc11controller.h"
#include "ngi/fullpipe/sc14controller.h"
#include "ngi/fullpipe/sc17controller.h"
+#include "ngi/fullpipe/sc27controller.h"
#include "ngi/fullpipe/scenecontrollers.h"
#include "ngi/fullpipe/sc03controller.h"
#include "ngi/fullpipe/sc04controller.h"
@@ -274,15 +275,6 @@ void Sc26Controller::onShow() {
_offsetY = 300;
}
-// CSc27Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
-void Sc27Controller::onShow() {
- FPController::onShow();
- _marginX = 300;
- _marginY = 200;
- _offsetX = 400;
- _offsetY = 300;
-}
-
// CSc28Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
void Sc28Controller::onShow() {
FPController::onShow();
diff --git a/engines/ngi/fullpipe/scenecontrollers.h b/engines/ngi/fullpipe/scenecontrollers.h
index d98e3ee2395..36f13800434 100644
--- a/engines/ngi/fullpipe/scenecontrollers.h
+++ b/engines/ngi/fullpipe/scenecontrollers.h
@@ -157,12 +157,6 @@ public:
void onShow() override;
};
-class Sc27Controller : public FPController {
-public:
- explicit Sc27Controller(int sceneId) : FPController(sceneId) {}
- void onShow() override;
-};
-
class Sc28Controller : public FPController {
public:
explicit Sc28Controller(int sceneId) : FPController(sceneId) {}
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 54cf8bc8793..caecd953165 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -96,6 +96,7 @@ MODULE_OBJS = \
fullpipe/sc11controller.o \
fullpipe/sc14controller.o \
fullpipe/sc17controller.o \
+ fullpipe/sc27controller.o \
fullpipe/scene01.o \
fullpipe/scene02.o \
fullpipe/scene03.o \
Commit: da453c06b00534381f8b1f9f757f33946d9530b8
https://github.com/scummvm/scummvm/commit/da453c06b00534381f8b1f9f757f33946d9530b8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 29 controller ported
Changed paths:
A engines/ngi/fullpipe/sc29controller.cpp
A engines/ngi/fullpipe/sc29controller.h
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/scenecontrollers.h
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/sc29controller.cpp b/engines/ngi/fullpipe/sc29controller.cpp
new file mode 100644
index 00000000000..5762a0d0ac5
--- /dev/null
+++ b/engines/ngi/fullpipe/sc29controller.cpp
@@ -0,0 +1,1024 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/hashmap.h"
+#include "common/str.h"
+
+#include "ngi/ngi.h"
+#include "ngi/behavior.h"
+#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/guimanager.h"
+#include "ngi/input.h"
+#include "ngi/interaction.h"
+#include "ngi/messages.h"
+#include "ngi/motion.h"
+#include "ngi/objects.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/xmlnode.h"
+#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/sc29controller.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+namespace {
+
+// the marks of the subsystems that are not ported: once per kind
+void warnOnce(const char *what) {
+ static Common::HashMap<Common::String, bool> reported;
+ if (!reported.contains(what)) {
+ reported[what] = true;
+ warning("STUB/untested: %s", what);
+ }
+}
+
+// CAniObject::SetStatic(id, mirror) (F22BC): the mirror argument is stored in +64 of the object (flags 8 here). The correction of the position that the
+// original makes for a changed mirror is the one of AniObject::setStatic (it does not model the argument)
+void setStaticMirror(AniObject *ani, int staticsId, bool mirror) {
+ ani->setStatic(staticsId);
+ if (mirror)
+ ani->_flags |= 8;
+ else
+ ani->_flags &= ~8;
+}
+
+// CAniObject::MoveToStatic (F1B0C) is not ported (the instant chain of linked movements, tracking/entities.csv "pending"); like the other ported controllers
+// the object is put into the statics (SetStatic)
+void moveToStatic(AniObject *ani, int staticsId) {
+ warnOnce("CAniObject::MoveToStatic (CSc29Controller: SetStatic is used)");
+ ani->setStatic(staticsId);
+}
+
+// a message of the queue (CCommand(5) with the parameter "msg"): its name goes to the controllers (CScene::Message), its id to the scene handlers
+Command *messageCommand(const char *name) {
+ uint32 id = 0;
+ g_ngi->_gameProject->_objectIds.findId(name, id);
+ Command *command = new Command(0, kCmdMessage, id, 0, 0, 0, 0, 0, 0, 0);
+ command->_messageName = name;
+ command->_excFlags |= 3;
+ return command;
+}
+
+// CCommand(3, 1) with the parameters aniId, moveId and copy: START_MOVEMENT that waits
+Command *movementCommand(const AniObject *ani, int movementId) {
+ Command *command = new Command(ani->_id, kCmdStartMovement, movementId, 0, 0, 0, 1, 0, 0, 0);
+ command->_param = ani->_copyId;
+ command->_excFlags |= 2;
+ return command;
+}
+
+// CCommand::SetParamFloat(command, "x", value): the attribute of the XML command and, for SHOW, the field that the handler of the command reads
+void setParamX(Command *command, float value) {
+ command->_args["x"] = Common::String::format("%f", value);
+ command->_x = (int)value;
+}
+
+// CMessageQueue::SetObjectCopy: every command of the queue gets the copy of the object ("copy" is 0 in the commands of the XML queues)
+void setObjectCopy(MessageQueue *queue, int copyId) {
+ queue->setObjectCopy(0, copyId);
+}
+
+// CScene::RunQueue(scene, queue, state, ani) (12287E, 1228AE): the queue gets the scene and the interrupt state and runs; the object (when given) owns it
+bool runQueueObject(Scene *scene, MessageQueue *queue, AniObject *ani, int interruptState) {
+ queue->_scene = scene;
+ if (interruptState != 4)
+ queue->_interruptState = interruptState;
+ if (!queue->run(ani)) {
+ g_ngi->_globalMessageQueueList->deleteQueueById(queue->_id);
+ return false;
+ }
+ return true;
+}
+
+// CMessageQueue +56 (the number of the command that runs) is not -1: the queue is running, i.e. it is still in the global list
+bool isQueueRunning(MessageQueue *queue) {
+ for (uint i = 0; i < g_ngi->_globalMessageQueueList->size(); i++) {
+ if ((*g_ngi->_globalMessageQueueList)[i] == queue)
+ return true;
+ }
+ return false;
+}
+
+} // End of anonymous namespace
+
+// CSc29Controller::CSc29Controller (18E3F4)
+Sc29Controller::Sc29Controller(int sceneId) : FPController(sceneId), _tutorial("ARCADE_TUTORIAL_29") {
+ _shootDelay = 6225;
+}
+
+// CSc29Controller::~CSc29Controller (18E378): no RemoveCopies, Scene::~Scene deletes the copies
+Sc29Controller::~Sc29Controller() {
+ if (!_greenBalls.empty() || !_flyingGreenBalls.empty() || !_redBalls.empty() || !_flyingRedBalls.empty() || !_bearders.empty())
+ warning("STUB/untested: CSc29Controller::~CSc29Controller (RemoveCopies is not run, the scene deletes the copies)");
+}
+
+// CSc29Controller::CleanXml (18C9F8)
+void Sc29Controller::cleanXml() {
+ _tutorial = "ARCADE_TUTORIAL_29";
+}
+
+// CSc29Controller::CanSwipeMan (18C9E2): not while the hero rides, nor while the arcade runs
+bool Sc29Controller::canSwipeMan(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::canSwipeMan(x, y);
+ if (_manIsRiding)
+ return false;
+ return !_arcadeIsOn;
+}
+
+// CSc29Controller::DoJump (18CA34)
+bool Sc29Controller::doJump() {
+ AniObject *man = hero();
+ bool result;
+ if (!man->_movement || man->_movement->_id == MV_MAN29_RUN || man->_movement->_id == MV_MAN29_STANDUP) {
+ result = true;
+ _rideBackEnabled = false;
+ _manIsHit = false;
+ _reachedFarRight = true;
+ moveToStatic(man, ST_MAN29_RUNR);
+ man->startMovement(MV_MAN29_JUMP, 0, -1);
+ } else {
+ result = false;
+ }
+ const Common::Point center = man->getCenter();
+ _manX = center.x;
+ _manY = center.y;
+ return result;
+}
+
+// CSc29Controller::DoBend (18CAB8)
+bool Sc29Controller::doBend() {
+ AniObject *man = hero();
+ bool result;
+ if (!man->_movement || man->_movement->_id == MV_MAN29_RUN || man->_movement->_id == MV_MAN29_STANDUP) {
+ result = true;
+ _rideBackEnabled = false;
+ _manIsHit = false;
+ _reachedFarRight = true;
+ moveToStatic(man, ST_MAN29_RUNR);
+ man->startMovement(MV_MAN29_BEND, 0, -1);
+ } else {
+ result = false;
+ }
+ const Common::Point center = man->getCenter();
+ _manX = center.x;
+ _manY = center.y;
+ return result;
+}
+
+// CSc29Controller::UpdateManRideback (18CB3C): the hero runs back to the left
+void Sc29Controller::updateManRideback(uint32 elapsed) {
+ _manX = _manX - (float)elapsed * _manSpeed;
+ hero()->setCenter(Common::Point((int)_manX, (int)_manY));
+}
+
+// CSc29Controller::TryShoot (18CB74)
+void Sc29Controller::tryShoot() {
+ if (!_arcadeIsOn)
+ return;
+ if (!(_manX < 1310.0f))
+ return;
+ if (random31() > 0x3FFFFFFF && !_shooter1->_movement && _shooter1->_statics->_staticsId == ST_STR1_RIGHT) {
+ _shooter1->startMovement(MV_STR1_SHOOT, 0, -1);
+ _shootCountdown = 0;
+ return;
+ }
+ if (!_shooter2->_movement && _shooter2->_statics->_staticsId == ST_STR2_RIGHT && (_shooter2->_flags & 4)) {
+ _shooter2->startMovement(MV_STR2_SHOOT, 0, -1);
+ _shootCountdown = 0;
+ }
+}
+
+// CSc29Controller::HitAssGreen (18CC1C)
+void Sc29Controller::hitAssGreen() {
+ if (_ass->_statics->_staticsId == ST_ASS_NORM) {
+ setStaticMirror(_ass, ST_ASS_NORM, false);
+ _ass->startMovement(MV_ASS_HITGREEN, 0, -1);
+ }
+}
+
+// CSc29Controller::HitAssRed (18CC60)
+void Sc29Controller::hitAssRed() {
+ if (_ass->_statics->_staticsId == ST_ASS_NORM) {
+ setStaticMirror(_ass, ST_ASS_NORM, false);
+ _ass->startMovement(MV_ASS_HITRED, 0, -1);
+ }
+}
+
+// CSc29Controller::HitsManRed (18CCA4)
+bool Sc29Controller::hitsManRed(AniObject *ani, int maxX) {
+ if (!_arcadeIsOn || _manIsHit)
+ return false;
+ const float x = (float)ani->getCenter().x;
+ if ((x >= _manX + 42.0f || x <= _manX + 8.0f) && (x < _manX + 8.0f || (float)maxX > (_manX + 25.0f) + _manSpeed))
+ return false;
+ AniObject *man = hero();
+ // (id & ~4) != MV_MAN29_BEND: neither the bend (2091) nor the run (2095)
+ if (man->_movement && (man->_movement->_id & ~4) != MV_MAN29_BEND &&
+ (man->_movement->_id != MV_MAN29_JUMP || (man->_movement->_curFrame > 2 && man->_movement->_curFrame <= 6)))
+ return false;
+ return _arcadeIsOn;
+}
+
+// CSc29Controller::HitsManGreen (18CD80)
+bool Sc29Controller::hitsManGreen(AniObject *ani, int maxX) {
+ if (!_arcadeIsOn || _manIsHit)
+ return false;
+ const float x = (float)ani->getCenter().x;
+ if ((x >= _manX + 40.0f || x <= _manX + 10.0f) && (x < _manX + 40.0f || (float)maxX > (_manX + 25.0f) + _manSpeed))
+ return false;
+ AniObject *man = hero();
+ if (man->_movement) {
+ const int id = man->_movement->_id;
+ if (id != MV_MAN29_JUMP && id != MV_MAN29_RUN && (id != MV_MAN29_BEND || (man->_movement->_curFrame > 0 && man->_movement->_curFrame <= 5)))
+ return false;
+ }
+ return _arcadeIsOn;
+}
+
+// CSc29Controller::CheckTutorial (18CE58)
+void Sc29Controller::checkTutorial() {
+ if (_tutorial != "UNDEF") {
+ if (g_ngi->_sceneStack.size() == 1) {
+ if (!g_ngi->_tutorialManager->activateTutorial(_tutorial))
+ _tutorial = "UNDEF";
+ }
+ }
+}
+
+// CSc29Controller::UpdateButtons (18CEE8): GUI positions are integers, the step fraction is lost
+void Sc29Controller::updateButtons(uint32 elapsed) {
+ const float margin = 0.0f + (float)g_ngi->_wideOfs;
+ if (_arcadeIsOn && g_ngi->getStateId(sO_LeftPipe_29) != g_ngi->getStateValue(sO_LeftPipe_29, sO_IsOpened)) {
+ if (_arrowDown->_visible) {
+ const float x = (float)_arrowDown->_pos.x;
+ if (x >= 50.0f - margin)
+ _arrowDown->setPos(Common::Point((int)(50.0f - margin), 495));
+ else
+ _arrowDown->setPos(Common::Point((int)(x + (float)elapsed * 0.15f), 495));
+ } else {
+ const float width = (float)_arrowDown->_size.x;
+ const float x = -width - 50.0f;
+ _arrowDown->setPos(Common::Point((int)(x - margin), 495));
+ _arrowDown->show();
+ }
+ const int screenWidth = g_ngi->gameWidth(); // CRender +36
+ if (!_arrowUp->_visible) {
+ _arrowUp->setPos(Common::Point((int)(margin + ((float)screenWidth + 50.0f)), 495));
+ _arrowUp->show();
+ return;
+ }
+ const float width = (float)_arrowUp->_size.x;
+ const float x = (float)_arrowUp->_pos.x;
+ const float target = ((float)screenWidth - width) - 50.0f;
+ if (x <= margin + target)
+ _arrowUp->setPos(Common::Point((int)(margin + target), 495));
+ else
+ _arrowUp->setPos(Common::Point((int)(x - (float)elapsed * 0.15f), 495));
+ } else {
+ if (_arrowDown->_visible) {
+ const float width = (float)_arrowDown->_size.x;
+ const float x = (float)_arrowDown->_pos.x;
+ _arrowDown->setPos(Common::Point((int)(x - (float)elapsed * 0.15f), 495));
+ if ((float)_arrowDown->_pos.x < -width - margin)
+ _arrowDown->hide();
+ }
+ if (_arrowUp->_visible) {
+ const float x = (float)_arrowUp->_pos.x;
+ const int screenWidth = g_ngi->gameWidth();
+ _arrowUp->setPos(Common::Point((int)(x + (float)elapsed * 0.15f), 495));
+ if ((float)_arrowUp->_pos.x > margin + (float)screenWidth)
+ _arrowUp->hide();
+ }
+ }
+}
+
+// CSc29Controller::DoJumpfromL (18D230): the hero steps off the porter at the left pipe
+void Sc29Controller::doJumpfromL() {
+ _scene->_motionController->activate();
+ getGameLoaderInteractionController()->enable();
+ hero()->_flags |= 8; // +64
+ setStaticMirror(hero(), ST_MAN_RIGHT, false);
+ if (!_scene->runQueue(QU_SC29_MANFROM_L, 2))
+ warning("sc29::DoJumpFromL: m_scene->RunQueue() returned false!");
+ _scrollingDisabled = true;
+}
+
+// CSc29Controller::UpdateManRide (18D2B8)
+void Sc29Controller::updateManRide() {
+ if (_manX < 497.0f && !_scrollingDisabled)
+ doJumpfromL();
+}
+
+// CSc29Controller::DoJumpfromR (18D2E4): the hero steps off the porter at the right pipe
+void Sc29Controller::doJumpfromR() {
+ _scene->_motionController->activate();
+ getGameLoaderInteractionController()->enable();
+ if (!_scene->runQueue(QU_SC29_MANFROM_R, 2))
+ warning("sc29::DoJumpFromR: m_scene->RunQueue() returned false!");
+ _arcadeIsOn = false;
+ _rideBackEnabled = false;
+ warnOnce("CHintManager::HideHint (CSc29Controller)");
+ warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc29Controller)");
+}
+
+// CSc29Controller::UpdateManRideRight (18D374)
+void Sc29Controller::updateManRideRight() {
+ AniObject *man = hero();
+ if (man->_statics->_staticsId == ST_MAN29_RUNR) {
+ if (_manX <= 1436.0f) {
+ _shootDelay = (int)(_shootDelayMin + ((_shootDelayMax - _shootDelayMin) * (1310.0f - _manX)) / 959.0f);
+ if (!_manIsHit && !man->getMessageQueue()) {
+ const Common::Point center = man->getCenter();
+ man->setCenter(Common::Point(center.x, 427));
+ man->startMovement(MV_MAN29_RUN, 0, -1);
+ }
+ } else {
+ doJumpfromR();
+ }
+ }
+ const Common::Point center = man->getCenter();
+ _manX = center.x;
+ _manY = center.y;
+}
+
+// CSc29Controller::DoJumptoR (18D458): the hero steps on the porter at the right pipe
+void Sc29Controller::doJumptoR() {
+ warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc29Controller)");
+ _scene->_motionController->deactivate();
+ getGameLoaderInteractionController()->disable();
+ if (!_scene->runQueue(QU_SC29_MANTO_R, 2))
+ warning("sc29::DoJumptoR: m_scene->RunQueue() returned false!");
+ _manIsRiding = true;
+ _scrollingDisabled = false;
+}
+
+// CSc29Controller::CountLoopBeardeds (18D4DC)
+void Sc29Controller::countLoopBeardeds(uint32 elapsed) {
+ for (uint i = 0; i < _bearders.size(); i++) {
+ if (!_bearders[i]._walking) {
+ if (_arcadeIsOn && (uint)_bearders[i]._counter > 0x9BA) {
+ if (random31() > 0x3FFFFFFF && _manX > 700.0f && _manX < 1100.0f) {
+ MessageQueue *queue = new MessageQueue(_scene->findMessageQueue(QU_SC29_BRD1), 0, 0);
+ setParamX(queue->getCommandByIndex(0), _manX + 350.0f);
+ setObjectCopy(queue, _bearders[i]._ani->_copyId);
+ if (!runQueueObject(_scene, queue, nullptr, 4))
+ warning("sc29::CountLoopBeardeds: m_scene->RunQueue() returned false!");
+ _bearders[i]._walking = true;
+ _bearders[i]._counter = 0;
+ } else if (_manX > 700.0f && _manX < 1350.0f) {
+ MessageQueue *queue = new MessageQueue(_scene->findMessageQueue(QU_SC29_BRD2), 0, 0);
+ setParamX(queue->getCommandByIndex(0), _manX - 200.0f);
+ setObjectCopy(queue, _bearders[i]._ani->_copyId);
+ if (!runQueueObject(_scene, queue, nullptr, 4))
+ warning("sc29::CountLoopBeardeds: m_scene->RunQueue() returned false!");
+ _bearders[i]._walking = true;
+ _bearders[i]._counter = 0;
+ }
+ }
+ _bearders[i]._counter += elapsed;
+ continue;
+ }
+
+ AniObject *ani = _bearders[i]._ani;
+ const Common::Point center = ani->getCenter();
+ float x = center.x;
+ const float y = center.y;
+ if (!ani->_movement && ani->_statics->_staticsId == ST_BRDCMN_RIGHT) {
+ x = x - (float)elapsed * 0.092f;
+ if ((x - _manX) < 100.0f || !_arcadeIsOn) {
+ MessageQueue *queue = new MessageQueue(_scene->findMessageQueue(QU_SC29_BRDOUT1), 0, 0);
+ setObjectCopy(queue, _bearders[i]._ani->_copyId);
+ if (!runQueueObject(_scene, queue, nullptr, 4))
+ warning("sc29::CountLoopBeardeds: m_scene->RunQueue() returned false!");
+ _bearders[i]._walking = false;
+ _bearders[i]._counter = 0;
+ }
+ }
+ if (!_bearders[i]._ani->_movement && _bearders[i]._ani->_statics->_staticsId == ST_BRDCMN_GOR)
+ _bearders[i]._ani->startMovement(MV_BRDCMN_GOR, 0, -1);
+ ani = _bearders[i]._ani;
+ if (ani->_movement && ani->_movement->_id == MV_BRDCMN_GOR) {
+ const float manX = _manX;
+ x = x - (float)elapsed * 0.048f;
+ if ((manX - x) < 60.0f || (x - manX) < -260.0f || !_arcadeIsOn) {
+ setStaticMirror(ani, ST_BRDCMN_RIGHT, false);
+ MessageQueue *queue = new MessageQueue(_scene->findMessageQueue(QU_SC29_BRDOUT2), 0, 0);
+ setObjectCopy(queue, _bearders[i]._ani->_copyId);
+ if (!runQueueObject(_scene, queue, nullptr, 4))
+ warning("sc29::CountLoopBeardeds: m_scene->RunQueue() returned false!");
+ _bearders[i]._walking = false;
+ _bearders[i]._counter = 0;
+ }
+ }
+ _bearders[i]._ani->setCenter(Common::Point((int)x, (int)y));
+ }
+}
+
+// CSc29Controller::CalcScore (18D90C)
+void Sc29Controller::calcScore() {
+ g_ngi->arcadeInterface().setCounter((int)(((_manX - 497.0f) * 7.0f) / 813.0f));
+}
+
+// CSc29Controller::CanShowHelp (18D948): not while the arcade interface is shown
+bool Sc29Controller::canShowHelp() {
+ if (!controllerRunsSceneLogic())
+ return FPController::canShowHelp();
+ return g_ngi->arcadeInterface().getState() == ArcadeInterface::kHidden;
+}
+
+// CSc29Controller::DoJumptoL (18D958)
+void Sc29Controller::doJumptoL() {
+ warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc29Controller)");
+ _scene->_motionController->deactivate();
+ getGameLoaderInteractionController()->disable();
+ if (!_scene->runQueue(QU_SC29_MANTO_L, 2))
+ warning("sc29::DoJumptoL: m_scene->RunQueue() returned false!");
+ _arcadeIsOn = true;
+ if (g_ngi->getStateId(sO_LeftPipe_29) != g_ngi->getStateValue(sO_LeftPipe_29, sO_IsOpened)) {
+ warnOnce("CHintManager::ShowHint, SetHideCondition (CSc29Controller::DoJumptoL)");
+ // CFPController::FlurryArcadeStart (the analytics event of the start of the arcade) is not ported
+ if (g_ngi->arcadeInterface().getState() == ArcadeInterface::kHidden) {
+ g_ngi->arcadeInterface().init(155.0f, -100.0f, 64.0f, 0.0f, 7, 0, true);
+ g_ngi->arcadeInterface().scrollIn();
+ }
+ }
+}
+
+// CSc29Controller::TryEscapeShooters (18DAC0)
+void Sc29Controller::tryEscapeShooters() {
+ if (!_shooter1->_movement && !_shooter2->_movement && _shooter1->_statics->_staticsId == ST_STR1_RIGHT) {
+ _shootCountdown = 0;
+ setStaticMirror(_shooter1, ST_STR1_STAND, false);
+ setStaticMirror(_shooter2, ST_STR2_STAND, false);
+ _scene->runQueue(QU_SC29_ESCAPE, 2);
+ _ass->_flags &= ~4;
+ g_ngi->arcadeInterface().scrollOut();
+ warnOnce("CAchievementsManager::AddActivatingCounter ACHIEVEMENT_ARCADE_29 (CSc29Controller::TryEscapeShooters)");
+ // CFPController::FlurryArcadeEnd is not ported
+ }
+ g_ngi->_taskManager->deactivateTask("FIND_EXIT_PORTER_SC29");
+}
+
+// CSc29Controller::UpdateManPosition (18DBE4)
+void Sc29Controller::updateManPosition(uint32 elapsed) {
+ if (_arcadeIsOn) {
+ _manX = _manX + (float)elapsed * _manSpeed;
+ hero()->setCenter(Common::Point((int)_manX, (int)_manY));
+ if (_manX > 1310.0f)
+ tryEscapeShooters();
+ calcScore();
+ } else if (_manIsRiding) {
+ _manX = _manX - (float)elapsed * 0.092f;
+ hero()->setCenter(Common::Point((int)_manX, (int)_manY));
+ }
+}
+
+// CSc29Controller::OnClickPorter (18DC78): MSG_SC29_PORTER_CLICK comes back here
+void Sc29Controller::onClickPorter() {
+ const float heroX = _manX;
+ const Common::Point porterCenter = _porter->getCenter();
+ AniObject *man = hero();
+ if (heroX <= (float)porterCenter.x) {
+ Common::Point center = man->getCenter();
+ _manX = center.x;
+ _manY = center.y;
+ if (fabsf(351.0f - _manX) <= 3.0f && fabsf(443.0f - _manY) <= 3.0f) {
+ if (!man->_movement && man->_statics->_staticsId == ST_MAN_RIGHT && !(man->_flags & 8)) {
+ doJumptoL();
+ return;
+ }
+ }
+ if (_manX != 351.0f || _manY != 443.0f) {
+ MessageQueue *queue = mctlStartMove(351, 443, true, ST_MAN_RIGHT, false);
+ if (queue)
+ queue->addCommandToEnd(messageCommand("MSG_SC29_PORTER_CLICK"));
+ }
+ } else {
+ Common::Point center = man->getCenter();
+ _manX = center.x;
+ _manY = center.y;
+ if (fabsf(1582.0f - _manX) <= 3.0f && fabsf(445.0f - _manY) <= 3.0f) {
+ if (!man->_movement && man->_statics->_staticsId == ST_MAN_RIGHT && (man->_flags & 8)) {
+ doJumptoR();
+ return;
+ }
+ }
+ if (_manX != 1582.0f || _manY != 445.0f) {
+ MessageQueue *queue = mctlStartMove(1582, 445, true, ST_MAN_RIGHT, true);
+ if (queue)
+ queue->addCommandToEnd(messageCommand("MSG_SC29_PORTER_CLICK"));
+ }
+ }
+}
+
+// CSc29Controller::DoHitMan (18DEA8)
+void Sc29Controller::doHitMan() {
+ AniObject *man = hero();
+ _manIsHit = true;
+ moveToStatic(man, ST_MAN29_RUNR);
+ man->setCenter(Common::Point((int)_manX, (int)_manY));
+
+ MakeQueueStruct make;
+ make.ani = man;
+ make.staticsId2 = ST_MAN29_SITR;
+ make.movementId = MV_MAN29_HIT;
+ make.cycleCount = 1; // 1.0f in the original structure
+ make.x1 = _manX <= 638.0f ? 351 : 0;
+ make.y1 = 443;
+ make.destZ = 10;
+ make.flags = _manX <= 638.0f ? 70 : 68;
+ calcScore();
+ MessageQueue *queue = g_ngi->_aniHandler->makeRunQueue(&make);
+ if (queue) {
+ if (_manX <= 638.0f) {
+ // the analytics events (lose_count_ANI_PORTER ...) and FlurryArcadeClean are not ported
+ g_ngi->arcadeInterface().scrollOut();
+ warnOnce("CAchievementsManager::BlockActivatingCounter ACHIEVEMENT_ARCADE_29 (CSc29Controller::DoHitMan)");
+ queue->addCommandToEnd(movementCommand(man, MV_MAN29_STANDUP_NORM));
+ queue->addCommandToEnd(messageCommand("MSG_SC29_STOPRIDE"));
+ _manIsRiding = false;
+ _arcadeIsOn = false;
+ _reachedFarRight = false;
+ _rideBackEnabled = false;
+ warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc29Controller)");
+ } else {
+ queue->addCommandToEnd(movementCommand(man, MV_MAN29_STANDUP));
+ }
+ queue->addCommandToEnd(messageCommand("MSG_SC29_STOP_HITQUEUE"));
+ runQueueObject(_scene, queue, man, 2);
+ _hitQueue = queue;
+ }
+}
+
+// CSc29Controller::RemoveCopies (18E290)
+void Sc29Controller::removeCopies() {
+ for (Common::List<AniObject *>::iterator it = _greenBalls.begin(); it != _greenBalls.end(); ++it) {
+ _scene->removeAni(*it);
+ delete *it;
+ }
+ _greenBalls.clear();
+ for (uint i = 0; i < _flyingGreenBalls.size(); i++) {
+ _scene->removeAni(_flyingGreenBalls[i]);
+ delete _flyingGreenBalls[i];
+ }
+ _flyingGreenBalls.clear();
+ for (Common::List<AniObject *>::iterator it = _redBalls.begin(); it != _redBalls.end(); ++it) {
+ _scene->removeAni(*it);
+ delete *it;
+ }
+ _redBalls.clear();
+ for (uint i = 0; i < _flyingRedBalls.size(); i++) {
+ _scene->removeAni(_flyingRedBalls[i]);
+ delete _flyingRedBalls[i];
+ }
+ _flyingRedBalls.clear();
+ for (uint i = 0; i < _bearders.size(); i++) {
+ _scene->removeAni(_bearders[i]._ani);
+ delete _bearders[i]._ani;
+ }
+ _bearders.clear();
+}
+
+// CSc29Controller::DoWinArcadeNow (18E5C8)
+void Sc29Controller::doWinArcadeNow() {
+ if (_shooter2->_flags & 4) {
+ _shootCountdown = 0;
+ setStaticMirror(_shooter1, ST_STR1_STAND, false);
+ setStaticMirror(_shooter2, ST_STR2_STAND, false);
+ _shooter2->_flags &= ~4;
+ while (!_flyingGreenBalls.empty()) {
+ AniObject *ball = _flyingGreenBalls[0];
+ _flyingGreenBalls.remove_at(0);
+ ball->_flags &= ~4;
+ _greenBalls.push_back(ball);
+ }
+ while (!_flyingRedBalls.empty()) {
+ AniObject *ball = _flyingRedBalls[0];
+ _flyingRedBalls.remove_at(0);
+ ball->_flags &= ~4;
+ _redBalls.push_back(ball);
+ }
+ _ass->_flags &= ~4;
+ _scene->runQueue(QU_SC29_ESCAPE, 2);
+ }
+ _manSpeed = _manSpeed * 4.0f;
+ g_ngi->setState(sO_LeftPipe_29, g_ngi->getStateValue(sO_LeftPipe_29, sO_IsOpened));
+ g_ngi->_exitManager->setExitState(PIC_SC29_LTRUBA, 1);
+}
+
+// CSc29Controller::SkipArcade (18E700): the skip button of the arcade interface
+void Sc29Controller::skipArcade() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::skipArcade();
+ return;
+ }
+ g_ngi->arcadeInterface().scrollOut();
+ doWinArcadeNow();
+ // CFPController::FlurryArcadeSkip (the analytics event) is not ported
+}
+
+// CSc29Controller::UpdateShellFlight (18E740)
+void Sc29Controller::updateShellFlight(uint32 elapsed) {
+ for (int i = 0; i < (int)_flyingGreenBalls.size(); i++) {
+ AniObject *ball = _flyingGreenBalls[i];
+ const Common::Point center = ball->getCenter();
+ float x = (float)center.x - (float)elapsed * _greenSpeed;
+ const float y = center.y;
+ if (x < 186.0f) {
+ _greenBalls.push_back(ball);
+ ball->_flags &= ~4;
+ hitAssGreen();
+ _flyingGreenBalls.remove_at(i);
+ --i;
+ // CFlurryEventManager (total_moves_ANI_PORTER, first_move_ANI_PORTER) is not ported
+ continue;
+ }
+ if (hitsManGreen(ball, (int)x)) {
+ _greenBalls.push_back(ball);
+ doHitMan();
+ g_ngi->playSound(SND_29_014, 0);
+ ball->startMovement(MV_SHG_HITMAN, 0, -1);
+ _hitBall = ball->_id;
+ _flyingGreenBalls.remove_at(i);
+ --i;
+ // CFlurryEventManager (total_moves, first_move, failcount_ANI_PORTER) is not ported
+ continue;
+ }
+ ball->setCenter(Common::Point((int)x, (int)y));
+ }
+ for (int j = 0; j < (int)_flyingRedBalls.size(); j++) {
+ AniObject *ball = _flyingRedBalls[j];
+ const Common::Point center = ball->getCenter();
+ float x = (float)center.x - (float)elapsed * _redSpeed;
+ const float y = center.y;
+ if (x < 147.0f) {
+ // CFlurryEventManager (total_moves_ANI_PORTER, first_move_ANI_PORTER) is not ported
+ _redBalls.push_back(ball);
+ ball->_flags &= ~4;
+ hitAssRed();
+ _flyingRedBalls.remove_at(j);
+ --j;
+ continue;
+ }
+ if (hitsManRed(ball, (int)x)) {
+ // CFlurryEventManager (total_moves, first_move, failcount_ANI_PORTER) is not ported
+ _redBalls.push_back(ball);
+ doHitMan();
+ g_ngi->playSound(SND_29_027, 0);
+ ball->startMovement(MV_SHR_HITMAN, 0, -1);
+ _hitBall = ball->_id;
+ _flyingRedBalls.remove_at(j);
+ --j;
+ continue;
+ }
+ ball->setCenter(Common::Point((int)x, (int)y));
+ }
+}
+
+// CSc29Controller::DoShootGreen (18EB64): the first free green shell flies from the first shooter
+void Sc29Controller::doShootGreen() {
+ if (!_greenBalls.empty()) {
+ const Common::Point center = _shooter1->getCenter();
+ const float x = center.x - 113.0f;
+ const float y = center.y - 48.0f;
+ AniObject *ball = _greenBalls.front();
+ _greenBalls.pop_front();
+ setStaticMirror(ball, ST_SHG_NORM, false);
+ ball->_flags |= 4;
+ ball->setCenter(Common::Point((int)x, (int)y));
+ _flyingGreenBalls.push_back(ball);
+ }
+}
+
+// CSc29Controller::DoShootRed (18EBF0): the first free red shell flies from the second shooter
+void Sc29Controller::doShootRed() {
+ if (!_redBalls.empty()) {
+ const Common::Point center = _shooter2->getCenter();
+ const float x = center.x - 101.0f;
+ const float y = center.y - 14.0f;
+ AniObject *ball = _redBalls.front();
+ _redBalls.pop_front();
+ setStaticMirror(ball, ST_SHR_NORM, false);
+ ball->_flags |= 4;
+ ball->setCenter(Common::Point((int)x, (int)y));
+ _flyingRedBalls.push_back(ball);
+ }
+}
+
+// CSc29Controller::ReadSettingsXml (18EC7C): "redSpeed" in the file, "redspeed" in code (default)
+void Sc29Controller::readSettingsXml() {
+ Common::ScopedPtr<XmlNode> document(loadXmlDocument("data/sc_29_settings.xml"));
+ if (document) {
+ const XmlNode &settings = document->child("SETTINGS");
+ const XmlNode &man = settings.child("MAN");
+ const XmlNode &shoot = settings.child("SHOOT");
+ _manSpeed = man.attrFloat("speed", 0.024f);
+ _shootDelayMin = shoot.attrFloat("delayMin", 2.075f) * 1000.0f;
+ _shootDelayMax = shoot.attrFloat("delayMax", 6.225f) * 1000.0f;
+ _greenSpeed = shoot.attrFloat("greenSpeed", 0.36f);
+ _redSpeed = shoot.attrFloat("redspeed", 0.36f);
+ }
+}
+
+// CSc29Controller::OnShow (18EDDC)
+void Sc29Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+ if (!controllerRunsSceneLogic())
+ return;
+
+ if (!g_ngi->_taskManager->isSceneVisited(_scene->_sceneId))
+ g_ngi->_taskManager->activateTask("FIND_EXIT_PORTER_SC29");
+ g_ngi->_taskManager->visitScene(_scene->_sceneId);
+ _manSpeed = 0.024f;
+ _shootDelayMin = 2075.0f;
+ _shootDelayMax = 6225.0f;
+ _greenSpeed = 0.36f;
+ _redSpeed = 0.36f;
+ readSettingsXml();
+ _porter = _scene->findAniObjectById(ANI_PORTER, 0);
+ _shooter1 = _scene->findAniObjectById(ANI_SHOOTER1, 0);
+ _shooter2 = _scene->findAniObjectById(ANI_SHOOTER2, 0);
+ _ass = _scene->findAniObjectById(ANI_ASS, 0);
+ if (!_arrowUp)
+ _arrowUp = _scene->_guiManager->getElement("BTN_ARROW_UP");
+ if (_arrowUp->_visible)
+ _arrowUp->hide();
+ if (!_arrowDown)
+ _arrowDown = _scene->_guiManager->getElement("BTN_ARROW_DOWN");
+ if (_arrowDown->_visible)
+ _arrowDown->hide();
+
+ _greenBalls.clear();
+ _flyingGreenBalls.clear();
+ AniObject *green = _scene->findAniObjectById(ANI_SHELL_GREEN, 0);
+ for (int i = 3; i != 0; --i) {
+ AniObject *copy = new AniObject(green);
+ _scene->addAni(copy, true);
+ _greenBalls.push_back(copy);
+ }
+ _redBalls.clear();
+ _flyingRedBalls.clear();
+ AniObject *red = _scene->findAniObjectById(ANI_SHELL_RED, 0);
+ for (int i = 3; i != 0; --i) {
+ AniObject *copy = new AniObject(red);
+ _scene->addAni(copy, true);
+ _redBalls.push_back(copy);
+ }
+ _bearders.clear();
+ AniObject *bearded = g_ngi->findScene(SC_COMMON)->findAniObjectById(ANI_BEARDED_CMN, 0);
+ AniObject *copy = new AniObject(bearded);
+ setStaticMirror(copy, ST_BRDCMN_EMPTY, false);
+ _scene->addAni(copy, true);
+ Bearded entry;
+ entry._ani = copy;
+ _bearders.push_back(entry);
+
+ _manIsRiding = false;
+ _arcadeIsOn = false;
+ _reachedFarRight = false;
+ _rideBackEnabled = false;
+ _shootCountdown = 0;
+ _shootDelay = (int)_shootDelayMax;
+ _manIsHit = false;
+ _scrollingDisabled = false;
+ _scrollSpeed = 0;
+ _hitBall = 0;
+ _hitQueue = nullptr;
+}
+
+// CSc29Controller::OnHide (18F0C8)
+void Sc29Controller::onHide() {
+ if (controllerRunsSceneLogic()) {
+ warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc29Controller)");
+ // the analytics event of a lost arcade is not ported
+ removeCopies();
+ warnOnce("CHintManager::HideHint (CSc29Controller)");
+ }
+ FPController::onHide();
+}
+
+// CSc29Controller::OnKeyUp (18F234): cheat keys, W wins the arcade, Q skips it
+void Sc29Controller::onKeyUp(uint32 key) {
+ FPController::onKeyUp(key);
+ if (!controllerRunsSceneLogic())
+ return;
+ if (key == 87) {
+ if (_reachedFarRight)
+ doWinArcadeNow();
+ } else if (key == 81) {
+ skipArcade();
+ }
+}
+
+// CSc29Controller::GetCursorType (18F264)
+int Sc29Controller::getCursorType(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::getCursorType(x, y);
+ if (g_ngi->_inputController->isObjectHit(ANI_PORTER))
+ return 1;
+ if (g_ngi->_inputController->isObjectHit(PIC_SC29_LTRUBA))
+ return 3;
+ return FPController::getCursorType(x, y);
+}
+
+// CSc29Controller::OnUpdate (18F2A4)
+void Sc29Controller::onUpdate(uint32 elapsed) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onUpdate(elapsed);
+ return;
+ }
+ FPController::onUpdate(elapsed);
+ // with a dialog over the scene and the hit queue running, the hero gives the position
+ if (g_ngi->_sceneStack.size() > 1) {
+ if (_hitQueue && isQueueRunning(_hitQueue)) {
+ const Common::Point center = hero()->getCenter();
+ _manX = center.x;
+ _manY = center.y;
+ }
+ }
+ updateShellFlight(elapsed);
+ updateButtons(elapsed);
+ if (!_porter->_movement)
+ _porter->startMovement(MV_PTR_MOVEFAST, 0, -1);
+ if (_manIsRiding)
+ updateManRide();
+ else if (_arcadeIsOn && !hero()->_movement)
+ updateManRideRight();
+ if (_reachedFarRight)
+ updateManPosition(elapsed);
+ else if (_rideBackEnabled)
+ updateManRideback(elapsed);
+ _shootCountdown = elapsed + _shootCountdown;
+ if (_shootCountdown > _shootDelay)
+ tryShoot();
+ countLoopBeardeds(elapsed);
+}
+
+// CSc29Controller::OnMouseLKeyDown (18F38C)
+bool Sc29Controller::onMouseLKeyDown(uint32 id, float x, float y) {
+ return FPController::onMouseLKeyDown(id, x, y);
+}
+
+// CSc29Controller::OnMouseLKeyUp (18F394)
+bool Sc29Controller::onMouseLKeyUp(uint32 id, float x, float y) {
+ const bool result = FPController::onMouseLKeyUp(id, x, y);
+ if (!controllerRunsSceneLogic())
+ return result;
+ if (!result && !_manIsRiding && !_arcadeIsOn && _porter->hit((int)x, (int)y))
+ onClickPorter();
+ return result;
+}
+
+// CSc29Controller::OnMouseRKeyUp (18F3DE)
+bool Sc29Controller::onMouseRKeyUp(uint32 id, float x, float y) {
+ return FPController::onMouseRKeyUp(id, x, y);
+}
+
+// CSc29Controller::OnMessage (18F3E8): the first message is tested alone, also goes to the base
+void Sc29Controller::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onMessage(message, param, queue);
+ return;
+ }
+ if (message == "MSG_SC29_ENABLEPORTER") {
+ _reachedFarRight = true;
+ _rideBackEnabled = false;
+ _manIsHit = false;
+ }
+ if (message == "MSG_SC29_DISABLEPORTER") {
+ _reachedFarRight = false;
+ } else if (message == "MSG_SC29_ENABLERIDEBACK") {
+ _rideBackEnabled = true;
+ _reachedFarRight = false;
+ } else if (message == "MSG_SC29_DISABLERIDEBACK") {
+ _rideBackEnabled = false;
+ } else if (message == "MSG_SC29_STOPRIDE") {
+ _manIsRiding = false;
+ _arcadeIsOn = false;
+ _reachedFarRight = false;
+ _rideBackEnabled = false;
+ _scene->_motionController->activate();
+ getGameLoaderInteractionController()->enable();
+ warnOnce("CHintManager::HideHint (CSc29Controller)");
+ warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc29Controller)");
+ } else if (message == "MSG_SC29_SHOOTGREEN") {
+ doShootGreen();
+ } else if (message == "MSG_SC29_SHOOTRED") {
+ doShootRed();
+ } else if (message == "MSG_SC29_SHOWLASTGREEN") {
+ if (!_greenBalls.empty()) {
+ AniObject *ball = _greenBalls.back();
+ ball->_flags |= 4;
+ ball->startMovement(MV_SHG_HITASS, 0, -1);
+ }
+ } else if (message == "MSG_SC29_SHOWLASTRED") {
+ // the original tests the green list but takes the last red one (reads garbage if it is empty)
+ if (!_greenBalls.empty()) {
+ if (_redBalls.empty()) {
+ warning("STUB/untested: CSc29Controller::OnMessage MSG_SC29_SHOWLASTRED with no red shell (the original reads the sentinel of the list)");
+ } else {
+ AniObject *ball = _redBalls.back();
+ ball->_flags |= 4;
+ ball->startMovement(MV_SHR_HITASS, 0, -1);
+ }
+ }
+ } else if (message == "MSG_SC29_LAUGH") {
+ if (_hitBall == ANI_SHELL_GREEN)
+ g_ngi->playSound(SND_29_028, 0);
+ else
+ g_ngi->playSound(SND_29_029, 0);
+ } else if (message == "MSG_CMN_WINARCADE") {
+ doWinArcadeNow();
+ } else if (message == "MSG_SC29_PORTER_CLICK") {
+ onClickPorter();
+ } else if (message == "MSG_SC29_STOP_HITQUEUE") {
+ _hitQueue = nullptr;
+ } else if (message == "MSG_SC29_ENDARCADE") {
+ g_ngi->setState(sO_LeftPipe_29, g_ngi->getStateValue(sO_LeftPipe_29, sO_IsOpened));
+ g_ngi->_exitManager->setExitState(PIC_SC29_LTRUBA, 1);
+ } else {
+ FPController::onMessage(message, param, queue);
+ }
+}
+
+// CSc29Controller::OnGuiEvent (18F6CC): the arrow buttons jump and bend while the arcade runs
+void Sc29Controller::onGuiEvent(const Common::String &id, const Common::String &event) {
+ FPController::onGuiEvent(id, event);
+ if (!controllerRunsSceneLogic())
+ return;
+ if (event == "press") {
+ if (id == "BTN_ARROW_UP") {
+ if (_arcadeIsOn)
+ doJump();
+ } else if (id == "BTN_ARROW_DOWN") {
+ if (_arcadeIsOn)
+ doBend();
+ }
+ }
+}
+
+// CSc29Controller::UpdateScroll (18F770)
+void Sc29Controller::updateScroll() {
+ if (!controllerRunsSceneLogic()) {
+ FPController::updateScroll();
+ return;
+ }
+ if (_arcadeIsOn) {
+ const float cameraX = (float)_scene->_x;
+ const float right = cameraX + (float)g_ngi->gameWidth(); // CRender +36
+ if (_manX > right - 500.0f)
+ _targetX = (right - 350.0f) - _manX;
+ if (_manX < cameraX + 100.0f)
+ _targetX = (_manX - cameraX) - 100.0f;
+ FPController::limitScroll();
+ testScroll();
+ } else if (_follow) {
+ if (_manIsRiding) {
+ defaultScroll();
+ testScroll();
+ } else {
+ FPController::updateScroll();
+ }
+ }
+ const Common::Point center = hero()->getCenter();
+ _manX = center.x;
+ _manY = center.y;
+}
+
+// CSc29Controller::OnRender (18F834): the arcade interface over the scene while it is not hidden
+void Sc29Controller::onRender(Common::Point scroll) {
+ FPController::onRender(scroll);
+ if (g_ngi->arcadeInterface().getState() != ArcadeInterface::kHidden)
+ g_ngi->arcadeInterface().render();
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sc29controller.h b/engines/ngi/fullpipe/sc29controller.h
new file mode 100644
index 00000000000..407652b7b80
--- /dev/null
+++ b/engines/ngi/fullpipe/sc29controller.h
@@ -0,0 +1,129 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SC29CONTROLLER_H
+#define NGI_FULLPIPE_SC29CONTROLLER_H
+
+#include "common/array.h"
+#include "common/list.h"
+
+#include "ngi/fullpipe/fpcontroller.h"
+
+namespace NGI {
+
+class GuiElement;
+
+/** CSc29Controller: the porter arcade (jump or bend under the shells, bearded men walk in) */
+class Sc29Controller : public FPController {
+public:
+ explicit Sc29Controller(int sceneId);
+ ~Sc29Controller() override;
+
+ void cleanXml() override;
+ bool canSwipeMan(float x, float y) override;
+ bool canShowHelp() override;
+ void checkTutorial() override;
+ void skipArcade() override;
+ void onShow() override;
+ void onHide() override;
+ void onKeyUp(uint32 key) override;
+ int getCursorType(float x, float y) override;
+ void updateScroll() override;
+ void onUpdate(uint32 elapsed) override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ bool onMouseRKeyUp(uint32 id, float x, float y) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+ void onGuiEvent(const Common::String &id, const Common::String &event) override;
+ void onRender(Common::Point scroll) override;
+
+ bool doJump();
+ bool doBend();
+ void updateManRideback(uint32 elapsed);
+ void tryShoot();
+ void hitAssGreen();
+ void hitAssRed();
+ bool hitsManRed(AniObject *ani, int maxX);
+ bool hitsManGreen(AniObject *ani, int maxX);
+ void updateButtons(uint32 elapsed);
+ void doJumpfromL();
+ void updateManRide();
+ void doJumpfromR();
+ void updateManRideRight();
+ void doJumptoR();
+ void countLoopBeardeds(uint32 elapsed);
+ void calcScore();
+ void doJumptoL();
+ void tryEscapeShooters();
+ void updateManPosition(uint32 elapsed);
+ void onClickPorter();
+ void doHitMan();
+ void removeCopies();
+ void doWinArcadeNow();
+ void updateShellFlight(uint32 elapsed);
+ void doShootGreen();
+ void doShootRed();
+ void readSettingsXml();
+
+private:
+ /** _SC29_BEARDED: a bearded man (copy of ANI_BEARDED_CMN) walking in while the arcade runs */
+ struct Bearded {
+ AniObject *_ani = nullptr; // +0
+ bool _walking = false; // +4: the queue BRD1 or BRD2 has started him, he walks until he is out
+ int _counter = 0; // +8: the milliseconds since he left
+ };
+
+ /** +216: the next tutorial of the scene */
+ Common::String _tutorial;
+ float _manSpeed = 0.024f; // +220: sc_29_settings.xml MAN speed
+ float _shootDelayMin = 2075.0f; // +224: SHOOT delayMin * 1000
+ float _shootDelayMax = 6225.0f; // +228: SHOOT delayMax * 1000
+ float _greenSpeed = 0.36f; // +232: SHOOT greenSpeed
+ float _redSpeed = 0.36f; // +236: SHOOT redspeed
+ AniObject *_porter = nullptr; // +240: ANI_PORTER
+ AniObject *_shooter1 = nullptr; // +244: ANI_SHOOTER1
+ AniObject *_shooter2 = nullptr; // +248: ANI_SHOOTER2
+ AniObject *_ass = nullptr; // +252: ANI_ASS
+ GuiElement *_arrowUp = nullptr; // +256: BTN_ARROW_UP (slides in from the right)
+ GuiElement *_arrowDown = nullptr; // +260: BTN_ARROW_DOWN (slides in from the left)
+ float _manX = 0; // +264: the center of the hero
+ float _manY = 0; // +268
+ bool _manIsRiding = false; // +272: the hero rides the porter to the right
+ bool _arcadeIsOn = false; // +273
+ bool _reachedFarRight = false; // +274
+ bool _rideBackEnabled = false; // +275
+ bool _manIsHit = false; // +276
+ bool _scrollingDisabled = false; // +277
+ int _hitBall = 0; // +280: the id of the shell that hit the hero (the laugh depends on it)
+ int _scrollSpeed = 0; // +284: not used by the original after it is cleared
+ int _shootCountdown = 0; // +288: the milliseconds since the last shot
+ int _shootDelay = 0; // +292: the milliseconds until the next shot
+ Common::List<AniObject *> _greenBalls; // +296: the shells that are ready (std::list)
+ Common::Array<AniObject *> _flyingGreenBalls; // +304 (std::vector)
+ Common::List<AniObject *> _redBalls; // +316
+ Common::Array<AniObject *> _flyingRedBalls; // +324
+ Common::Array<Bearded> _bearders; // +336
+ MessageQueue *_hitQueue = nullptr; // +348: the queue of the hit hero, until MSG_SC29_STOP_HITQUEUE
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SC29CONTROLLER_H
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index d1e4e733bde..0490131c384 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -28,6 +28,7 @@
#include "ngi/fullpipe/sc14controller.h"
#include "ngi/fullpipe/sc17controller.h"
#include "ngi/fullpipe/sc27controller.h"
+#include "ngi/fullpipe/sc29controller.h"
#include "ngi/fullpipe/scenecontrollers.h"
#include "ngi/fullpipe/sc03controller.h"
#include "ngi/fullpipe/sc04controller.h"
@@ -284,15 +285,6 @@ void Sc28Controller::onShow() {
_offsetY = 300;
}
-// CSc29Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
-void Sc29Controller::onShow() {
- FPController::onShow();
- _marginX = 300;
- _marginY = 200;
- _offsetX = 400;
- _offsetY = 300;
-}
-
// CSc30Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
void Sc30Controller::onShow() {
FPController::onShow();
diff --git a/engines/ngi/fullpipe/scenecontrollers.h b/engines/ngi/fullpipe/scenecontrollers.h
index 36f13800434..571102db636 100644
--- a/engines/ngi/fullpipe/scenecontrollers.h
+++ b/engines/ngi/fullpipe/scenecontrollers.h
@@ -163,12 +163,6 @@ public:
void onShow() override;
};
-class Sc29Controller : public FPController {
-public:
- explicit Sc29Controller(int sceneId) : FPController(sceneId) {}
- void onShow() override;
-};
-
class Sc30Controller : public FPController {
public:
explicit Sc30Controller(int sceneId) : FPController(sceneId) {}
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index caecd953165..ef4e129043d 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -97,6 +97,7 @@ MODULE_OBJS = \
fullpipe/sc14controller.o \
fullpipe/sc17controller.o \
fullpipe/sc27controller.o \
+ fullpipe/sc29controller.o \
fullpipe/scene01.o \
fullpipe/scene02.o \
fullpipe/scene03.o \
Commit: 0572df31115b2b63e61fb1879dd9e9c6074d9c86
https://github.com/scummvm/scummvm/commit/0572df31115b2b63e61fb1879dd9e9c6074d9c86
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 38 controller ported
Changed paths:
A engines/ngi/fullpipe/sc38controller.cpp
A engines/ngi/fullpipe/sc38controller.h
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/scenecontrollers.h
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/sc38controller.cpp b/engines/ngi/fullpipe/sc38controller.cpp
new file mode 100644
index 00000000000..4c5ba46974b
--- /dev/null
+++ b/engines/ngi/fullpipe/sc38controller.cpp
@@ -0,0 +1,407 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/ngi.h"
+#include "ngi/behavior.h"
+#include "ngi/gfx.h"
+#include "ngi/messages.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/lift.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/sc38controller.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+// lrand48() <= 85899344: the chance of 4 % of a draw (and 0x51EB850 in the code)
+static const uint32 kChance = 85899344;
+// The idle animations start after 4150 ms of idling
+static const int kIdleTime = 4149;
+
+// CSc38Controller::CSc38Controller (1959BC)
+Sc38Controller::Sc38Controller(int sceneId) : FPController(sceneId), _tutorial("EXTRA_TUTORIAL_SEE_LIFT") {
+ _tallyChatter._counter = 15;
+ _shortyChatter._counter = 30;
+}
+
+// CSc38Controller::CleanXml (195968)
+void Sc38Controller::cleanXml() {
+ _tutorial = "EXTRA_TUTORIAL_SEE_LIFT";
+}
+
+// CSc38Controller::CanSwipeMan (195924): not while the boss puts the domino down or the hero does
+bool Sc38Controller::canSwipeMan(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::canSwipeMan(x, y);
+ return (!_boss->_movement || _boss->_movement->_id != MV_GLV_PUTDOMINO) && (!hero()->_movement || hero()->_movement->_id != MV_MAN38_PUTDOMIN);
+}
+
+bool Sc38Controller::repeatsAllowed(Chatter &chatter, int queueId) {
+ if (chatter._lastQueue == queueId) {
+ chatter._repeats++;
+ } else {
+ chatter._lastQueue = queueId;
+ chatter._repeats = 1;
+ }
+ return chatter._repeats <= 2 && queueId != 0;
+}
+
+// CSc38Controller::CountBehavior (195A4C): idle for 4150 ms, then a queue, the same at most twice
+void Sc38Controller::countBehavior(uint32 elapsed) {
+ if (_boss->_movement || !(_boss->_flags & 4)) {
+ _bossChatter._counter = 0;
+ } else {
+ if (_bossWaits) {
+ _bossWaits = false;
+ _bossChatter._counter = 4150;
+ }
+ _bossChatter._counter += elapsed;
+ if (_bossChatter._counter > kIdleTime) {
+ const int state = _boss->_statics->_staticsId;
+ if (state == ST_GLV_SLEEP2) {
+ _bossChatter._counter = 0;
+ } else if ((_domino0->_flags & 4) && _domino0->_statics->_staticsId == ST_DMN38_6) {
+ if (state == ST_GLV_HAMMER) {
+ _scene->runQueueWithAni(QU_GLV_TAKEDOMINO, _boss, 2);
+ _bossChatter._counter = 0;
+ } else if (state == ST_GLV_NOHAMMER) {
+ _scene->runQueueWithAni(QU_GLV_TAKEDOMINO_NOHMR, _boss, 2);
+ _bossChatter._counter = 0;
+ }
+ } else if ((_bottle->_flags & 4) && _bottle->_statics->_staticsId == ST_BTL38_FULL && state == ST_GLV_NOHAMMER) {
+ _scene->runQueueWithAni(QU_GLV_DRINKBOTTLE, _boss, 2);
+ _bossChatter._counter = 0;
+ } else {
+ int queueId = 0;
+ if (random31() <= kChance && _boss->_statics->_staticsId == ST_GLV_HAMMER) {
+ queueId = QU_GLV_HMRKICK;
+ } else if (random31() > kChance) {
+ if (random31() <= kChance) {
+ const int current = _boss->_statics->_staticsId;
+ if (current == ST_GLV_HAMMER)
+ queueId = QU_GLV_DRINK;
+ else if (current == ST_GLV_NOHAMMER)
+ queueId = QU_GLV_DRINK_NOHMR;
+ }
+ } else {
+ const int current = _boss->_statics->_staticsId;
+ if (current == ST_GLV_HAMMER)
+ queueId = QU_GLV_PROPOSE;
+ else if (current == ST_GLV_NOHAMMER)
+ queueId = QU_GLV_PROPOSE_NOHMR;
+ }
+ if (repeatsAllowed(_bossChatter, queueId)) {
+ _scene->runQueue(queueId);
+ _bossChatter._counter = 0;
+ }
+ }
+ }
+ }
+
+ if (_tally->_movement || !(_tally->_flags & 4)) {
+ _tallyChatter._counter = 0;
+ } else {
+ _tallyChatter._counter += elapsed;
+ if (_tallyChatter._counter > kIdleTime) {
+ int queueId = 0;
+ if (random31() <= kChance) {
+ const int current = _domino1->_statics->_staticsId;
+ if (current == ST_DMN38_NORM3)
+ queueId = QU_DLD_TAKE1;
+ else if (current == ST_DMN38_NORM4)
+ queueId = QU_DLD_TAKE2;
+ } else if (random31() <= kChance) {
+ queueId = QU_DLD_BLINK;
+ } else if (random31() <= kChance) {
+ queueId = QU_DLD_GLOT;
+ } else if (random31() <= kChance) {
+ queueId = QU_DLD_ICK;
+ }
+ if (repeatsAllowed(_tallyChatter, queueId)) {
+ _scene->runQueue(queueId);
+ _tallyChatter._counter = 0;
+ }
+ }
+ }
+
+ if (_shorty->_movement || !(_shorty->_flags & 4)) {
+ _shortyChatter._counter = 0;
+ } else {
+ _shortyChatter._counter += elapsed;
+ if (_shortyChatter._counter > kIdleTime) {
+ int queueId = 0;
+ if (random31() > kChance) {
+ if (random31() <= kChance && _shorty->_statics->_staticsId == ST_MLS_LEFT2) {
+ queueId = QU_MLS_BLINK;
+ } else if (_boss->_statics->_staticsId != ST_GLV_SLEEP2 && _bossChatter._counter > 2490 && random31() <= 0x3FFFFFFE &&
+ _shorty->_statics->_staticsId == ST_MLS_LEFT2) {
+ queueId = QU_MLS_HAND;
+ }
+ } else {
+ const int current = _shorty->_statics->_staticsId;
+ if (current == ST_MLS_RIGHT2)
+ queueId = QU_MLS_TURNL;
+ else if (current == ST_MLS_LEFT2)
+ queueId = QU_MLS_TURNR;
+ }
+ if (repeatsAllowed(_shortyChatter, queueId)) {
+ _scene->runQueue(queueId);
+ _shortyChatter._counter = 0;
+ }
+ }
+ }
+}
+
+// CSc38Controller::OnHmrKick (195DE0)
+void Sc38Controller::onHmrKick() {
+ if (!_shorty->_movement && (_shorty->_flags & 4)) {
+ if (_shortyChatter._counter > 1 && _shorty->_statics->_staticsId == ST_MLS_LEFT2 && random31() <= 214748363) {
+ _scene->runQueue(QU_MLS_TURNR);
+ _shortyChatter._counter = 0;
+ }
+ }
+ const Common::Point center = _domino1->getCenter();
+ _domino1->setCenter(Common::Point(center.x, center.y - 2));
+ const int state = _dominos->_statics->_staticsId;
+ if (state == ST_DMS_3)
+ _dominos->startMovement(MV_DMS_THREE, 0, -1);
+ else if (state == ST_DMS_4)
+ _dominos->startMovement(MV_DMS_FOUR, 0, -1);
+}
+
+// CSc38Controller::OnPostHmrKick (195EC4)
+void Sc38Controller::onPostHmrKick() {
+ const Common::Point center = _domino1->getCenter();
+ _domino1->setCenter(Common::Point(center.x, center.y + 2));
+}
+
+// CSc38Controller::OnDrink (195F00)
+void Sc38Controller::onDrink() {
+ if (!_shorty->_movement && (_shorty->_flags & 4)) {
+ if (_shortyChatter._counter > 0 && _shorty->_statics->_staticsId == ST_MLS_LEFT2 && random31() <= 214748363) {
+ _scene->runQueue(QU_MLS_TURNR);
+ _shortyChatter._counter = 0;
+ }
+ }
+}
+
+// CSc38Controller::OnPropose (195F54)
+void Sc38Controller::onPropose() {
+ if (!_tally->_movement && (_tally->_flags & 4)) {
+ if (_tallyChatter._counter > 0 && random31() != 0x7FFFFFFF) {
+ _scene->runQueue(QU_DLD_DENY);
+ _tallyChatter._counter = 0;
+ }
+ }
+}
+
+// CSc38Controller::OnHand (195F9C)
+void Sc38Controller::onHand() {
+ if (!_boss->_movement && (_boss->_flags & 4)) {
+ if (_bossChatter._counter > 0 && random31() != 0x7FFFFFFF) {
+ const int state = _boss->_statics->_staticsId;
+ if (state == ST_GLV_HAMMER)
+ _scene->runQueue(QU_GLV_TOSMALL);
+ else if (state == ST_GLV_NOHAMMER)
+ _scene->runQueue(QU_GLV_TOSMALL_NOHMR);
+ else
+ return;
+ _bossChatter._counter = 0;
+ }
+ }
+}
+
+// CSc38Controller::OnTryTakeBottle (196008)
+void Sc38Controller::onTryTakeBottle() {
+ MessageQueue *queue = _boss->getMessageQueue();
+ if (!queue || queue->canInterrupt()) {
+ if (_boss->_statics->_staticsId == ST_GLV_NOHAMMER) {
+ _boss->setStatic(ST_GLV_NOHAMMER);
+ _boss->startMovement(MV_GLV_LOOKMAN, 0, -1);
+ } else {
+ _boss->setStatic(ST_GLV_HAMMER);
+ _boss->startMovement(MV_GLV_LOOKHMR, 0, -1);
+ }
+ _bossChatter._counter = 0;
+ }
+}
+
+// CSc38Controller::CheckTutorial (19608C): 60 seconds after the scene
+void Sc38Controller::checkTutorial() {
+ if (_tutorial == "UNDEF")
+ return;
+ if (g_ngi->_sceneStack.size() != 1)
+ return;
+ if (_tutorialTime >= 60.0f) {
+ if (!g_ngi->_tutorialManager->activateTutorial(_tutorial)) {
+ _tutorial = "UNDEF";
+ _tutorialTime = -1.0f;
+ }
+ }
+}
+
+// CSc38Controller::TestBottle (19613C)
+void Sc38Controller::testBottle() {
+ if (g_ngi->lift().isButtonEnabled(sO_Level5)) {
+ MessageQueue *queue = _scene->findMessageQueue(QU_SC38_SHOWBOTTLE);
+ Command *command = queue->getCommandByIndex(0);
+ float x = command->getParamFloat("x", 0.0f);
+ float y = command->getParamFloat("y", 0.0f);
+ float z = command->getParamFloat("z", 0.0f);
+ if (z < -1000.0f)
+ z = _bottle->_z;
+ _bottle->setPosition(Common::Point((int)x, (int)y));
+ _bottle->_z = (int)z;
+ g_ngi->setState(sO_Bottle_38, g_ngi->getStateValue(sO_Bottle_38, sO_BlockedShe));
+ }
+}
+
+// CSc38Controller::OnHide (196278)
+void Sc38Controller::onHide() {
+ _bossWaits = false;
+ if (_dominos && (_dominos->_flags & 4) && _dominos->_statics->_staticsId == ST_DMS_4)
+ _dominos->setStatic(ST_DMS_3);
+ if (_tutorial != "UNDEF") {
+ g_ngi->_tutorialManager->finishTutorial(_tutorial);
+ _tutorial = "UNDEF";
+ }
+ FPController::onHide();
+}
+
+// CSc38Controller::OnShow (19630C)
+void Sc38Controller::onShow() {
+ FPController::onShow();
+ g_ngi->_taskManager->visitScene(_scene->_sceneId);
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+ if (!controllerRunsSceneLogic()) {
+ if (_tutorial != "UNDEF")
+ _tutorialTime = 0;
+ return;
+ }
+
+ _boss = _scene->findAniObjectById(ANI_GLAVAR, 0);
+ _tally = _scene->findAniObjectById(ANI_DYLDA, 0);
+ _shorty = _scene->findAniObjectById(ANI_MALYSH, 0);
+ _domino0 = _scene->findAniObjectById(ANI_DOMINO38, 0);
+ _dominos = _scene->findAniObjectById(ANI_DOMINOS, 0);
+ _domino1 = _scene->findAniObjectById(ANI_DOMINO38, 1);
+ _bottle = _scene->findAniObjectById(ANI_BOTTLE38, 0);
+ _bossChatter = Chatter();
+ _tallyChatter = Chatter();
+ _shortyChatter = Chatter();
+ _tallyChatter._counter = 1245;
+ _shortyChatter._counter = 2490;
+
+ if (g_ngi->getStateId(sO_Boss) == g_ngi->getStateValue(sO_Boss, sO_IsSleeping)) {
+ _shorty->_flags &= ~4;
+ _tally->stopMovement();
+ _tally->_flags &= ~4;
+ _domino0->_flags &= ~4;
+ _dominos->_flags &= ~4;
+ _domino1->_flags &= ~4;
+ } else if (g_ngi->getStateId(sO_Boss) == g_ngi->getStateValue(sO_Boss, sO_WithoutHammer)) {
+ _dominos->setPosition(Common::Point(598, 464));
+ _dominos->_z = 21;
+ }
+
+ g_ngi->lift().initLift(_scene, hero(), QU_SC38_ENTERLIFT, QU_SC38_EXITLIFT);
+ // the id of the statics of the button is the one of the Android project (not the Windows ST_LBN_0N of constants.h)
+ uint32 buttonId;
+ if (g_ngi->_gameProject->_objectIds.findId("ST_LBN_0N", buttonId))
+ g_ngi->lift().enableButton(_scene, buttonId);
+ if (_tutorial != "UNDEF")
+ _tutorialTime = 0;
+ testBottle();
+}
+
+// CSc38Controller::GetCursorType (196578): the lift
+int Sc38Controller::getCursorType(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::getCursorType(x, y);
+ if (g_ngi->lift().getCursorType(x, y))
+ return 116;
+ return FPController::getCursorType(x, y);
+}
+
+// CSc38Controller::OnUpdate (1965A8)
+void Sc38Controller::onUpdate(uint32 elapsed) {
+ if (_tutorialTime != -1.0f)
+ _tutorialTime += (float)elapsed / 1000.0f;
+ FPController::onUpdate(elapsed);
+ if (controllerRunsSceneLogic())
+ countBehavior(elapsed);
+}
+
+// CSc38Controller::OnMouseLKeyDown (196618) / OnMouseLKeyUp (196634)
+bool Sc38Controller::onMouseLKeyDown(uint32 id, float x, float y) {
+ const bool result = FPController::onMouseLKeyDown(id, x, y);
+ if (!result && controllerRunsSceneLogic())
+ return g_ngi->lift().onButtonDown(x, y);
+ return result;
+}
+
+bool Sc38Controller::onMouseLKeyUp(uint32 id, float x, float y) {
+ const bool result = FPController::onMouseLKeyUp(id, x, y);
+ if (!result && controllerRunsSceneLogic())
+ return g_ngi->lift().onButtonUp(x, y);
+ return result;
+}
+
+// CSc38Controller::OnMessage (196650)
+void Sc38Controller::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onMessage(message, param, queue);
+ return;
+ }
+ if (message == "MSG_SC38_HMRKICK") {
+ onHmrKick();
+ } else if (message == "MSG_SC38_POSTHMRKICK") {
+ onPostHmrKick();
+ } else if (message == "MSG_SC38_DRINK") {
+ onDrink();
+ } else if (message == "MSG_SC38_POINT") {
+ onHand();
+ } else if (message == "MSG_SC38_PROPOSE") {
+ onPropose();
+ } else if (message == "MSG_SC38_TRYTAKEBOTTLE") {
+ onTryTakeBottle();
+ } else if (message == "MSG_SC38_TAKEDOMINO") {
+ _bossWaits = true;
+ } else if (message == "MSG_HIDE_MUG") {
+ _scene->findAniObjectById(ANI_MUG38, 0)->_flags &= ~4;
+ } else if (message == "MSG_SC38_MOVEDOMINO1") {
+ _domino0->setPosition(Common::Point(539, 482));
+ _domino0->_z = 25;
+ } else if (message == "MSG_SC38_MOVEDOMINO2") {
+ _domino0->setPosition(Common::Point(549, 482));
+ _domino0->_z = 25;
+ } else {
+ FPController::onMessage(message, param, queue);
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sc38controller.h b/engines/ngi/fullpipe/sc38controller.h
new file mode 100644
index 00000000000..5f3addeb0aa
--- /dev/null
+++ b/engines/ngi/fullpipe/sc38controller.h
@@ -0,0 +1,84 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SC38CONTROLLER_H
+#define NGI_FULLPIPE_SC38CONTROLLER_H
+
+#include "ngi/fullpipe/fpcontroller.h"
+
+namespace NGI {
+
+/** CSc38Controller: the lift floor with the domino gang */
+class Sc38Controller : public FPController {
+public:
+ explicit Sc38Controller(int sceneId);
+
+ void cleanXml() override;
+ bool canSwipeMan(float x, float y) override;
+ void checkTutorial() override;
+ void onShow() override;
+ void onHide() override;
+ int getCursorType(float x, float y) override;
+ void onUpdate(uint32 elapsed) override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+
+ void countBehavior(uint32 elapsed);
+ void onHmrKick();
+ void onPostHmrKick();
+ void onDrink();
+ void onPropose();
+ void onHand();
+ void onTryTakeBottle();
+ void testBottle();
+
+private:
+ /** same as the counters: last queue of a character, how often it came, the next one */
+ struct Chatter {
+ int _counter = 0; // the milliseconds the character is idle
+ int _lastQueue = 0;
+ int _repeats = 0;
+ };
+
+ /** +216: the seconds since the scene was shown while a tutorial waits, -1 when none */
+ float _tutorialTime = -1;
+ /** +220: the next tutorial of the scene */
+ Common::String _tutorial;
+ AniObject *_boss = nullptr; // +224: ANI_GLAVAR
+ AniObject *_tally = nullptr; // +228: ANI_DYLDA
+ AniObject *_shorty = nullptr; // +232: ANI_MALYSH
+ AniObject *_domino0 = nullptr; // +236: ANI_DOMINO38
+ AniObject *_domino1 = nullptr; // +240: ANI_DOMINO38, the copy 1
+ AniObject *_dominos = nullptr; // +244: ANI_DOMINOS
+ AniObject *_bottle = nullptr; // +248: ANI_BOTTLE38
+ Chatter _bossChatter; // +252, +256, +260
+ Chatter _tallyChatter; // +264, +268, +272
+ Chatter _shortyChatter; // +276, +280, +284
+ bool _bossWaits = false; // +288: MSG_SC38_TAKEDOMINO
+
+ /** the start of the same idle queue is limited to two times in a row (CountBehavior) */
+ bool repeatsAllowed(Chatter &chatter, int queueId);
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SC38CONTROLLER_H
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index 0490131c384..e8f33a57da1 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -26,9 +26,10 @@
#include "ngi/fullpipe/sc09controller.h"
#include "ngi/fullpipe/sc11controller.h"
#include "ngi/fullpipe/sc14controller.h"
-#include "ngi/fullpipe/sc17controller.h"
#include "ngi/fullpipe/sc27controller.h"
#include "ngi/fullpipe/sc29controller.h"
+#include "ngi/fullpipe/sc17controller.h"
+#include "ngi/fullpipe/sc38controller.h"
#include "ngi/fullpipe/scenecontrollers.h"
#include "ngi/fullpipe/sc03controller.h"
#include "ngi/fullpipe/sc04controller.h"
@@ -357,15 +358,6 @@ void Sc37Controller::onShow() {
_offsetY = 300;
}
-// CSc38Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
-void Sc38Controller::onShow() {
- FPController::onShow();
- _marginX = 300;
- _marginY = 200;
- _offsetX = 400;
- _offsetY = 300;
-}
-
// CSplashScreenController::CreateControllers: the class of the scene number, else CFPController
void createSceneController(int sceneId) {
switch (sceneId) {
diff --git a/engines/ngi/fullpipe/scenecontrollers.h b/engines/ngi/fullpipe/scenecontrollers.h
index 571102db636..17eef70afeb 100644
--- a/engines/ngi/fullpipe/scenecontrollers.h
+++ b/engines/ngi/fullpipe/scenecontrollers.h
@@ -211,12 +211,6 @@ public:
void onShow() override;
};
-class Sc38Controller : public FPController {
-public:
- explicit Sc38Controller(int sceneId) : FPController(sceneId) {}
- void onShow() override;
-};
-
} // End of namespace NGI
#endif // NGI_FULLPIPE_SCENECONTROLLERS_H
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index ef4e129043d..bd310b7fe4d 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -98,6 +98,7 @@ MODULE_OBJS = \
fullpipe/sc17controller.o \
fullpipe/sc27controller.o \
fullpipe/sc29controller.o \
+ fullpipe/sc38controller.o \
fullpipe/scene01.o \
fullpipe/scene02.o \
fullpipe/scene03.o \
Commit: e65ec3dc6806ca6e17e5f16a6f4d25959d688854
https://github.com/scummvm/scummvm/commit/e65ec3dc6806ca6e17e5f16a6f4d25959d688854
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: AniObject::setStatic with the mirror, MoveToStatic (linked movement chain), GetCurFrame/SetCurFrame, GameObject::isOnScreen
Changed paths:
engines/ngi/gfx.cpp
engines/ngi/gfx.h
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index fcf6a542ffb..19c669ef2b1 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -350,6 +350,46 @@ Common::Point GameObject::getCenter() const {
static_cast<int>(size.y * _scaleY * (_windowTop + (_windowBottom - _windowTop) * 0.5f)));
}
+// visible part of the scene in scene coordinates (CRender +8, +12 = 0, +24 = wide offset, +28 = 0)
+static void visibleScreenPart(const Scene *scene, float &left, float &top, float &right, float &bottom) {
+ const float renderOffsetX = (float)g_ngi->_wideOfs;
+ left = (float)scene->_x - renderOffsetX;
+ top = (float)scene->_y;
+ right = renderOffsetX + ((float)g_ngi->gameWidth() + (float)scene->_x);
+ bottom = (float)g_ngi->_backgroundSurface.h + (float)scene->_y;
+}
+
+// CVisibleObject::IsOnScreenEntirely (127682)
+bool GameObject::isOnScreenEntirely(const Scene *scene) const {
+ float left;
+ float top;
+ float right;
+ float bottom;
+ visibleScreenPart(scene, left, top, right, bottom);
+ const Common::Rect rect = getBounds();
+ if ((float)rect.left <= left || (float)rect.left >= right)
+ return false;
+ if ((float)rect.top <= top || (float)rect.top >= bottom)
+ return false;
+ if ((float)rect.right <= left || (float)rect.right >= right)
+ return false;
+ return (float)rect.bottom > top && (float)rect.bottom < bottom;
+}
+
+// CVisibleObject::IsOnScreen (12755E): the rects overlap (the vertical test first)
+bool GameObject::isOnScreen(const Scene *scene) const {
+ float left;
+ float top;
+ float right;
+ float bottom;
+ visibleScreenPart(scene, left, top, right, bottom);
+ const Common::Rect rect = getBounds();
+ const bool vertical = (top <= (float)rect.top && bottom >= (float)rect.top) || (top >= (float)rect.top && top <= (float)rect.bottom);
+ if (!vertical)
+ return false;
+ return (left <= (float)rect.left && right >= (float)rect.left) || (left >= (float)rect.left && left <= (float)rect.right);
+}
+
void GameObject::setCenter(Common::Point center) {
Common::Point topLeft;
Common::Point anchor;
diff --git a/engines/ngi/gfx.h b/engines/ngi/gfx.h
index 1a57a08e554..34bcb2059d1 100644
--- a/engines/ngi/gfx.h
+++ b/engines/ngi/gfx.h
@@ -207,6 +207,9 @@ class GameObject : public CObject {
/** CVisibleObject::GetCenter / SetCenter: the center of the window of the texture (the whole texture by default) */
Common::Point getCenter() const;
void setCenter(Common::Point center);
+ /** CVisibleObject::IsOnScreenEntirely (127682) / IsOnScreen (12755E) */
+ bool isOnScreenEntirely(const Scene *scene) const;
+ bool isOnScreen(const Scene *scene) const;
/** the quad of the texture as drawn (CVisibleObject::GetRect without the rotation) */
Common::Rect getBounds() const;
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 14456c71e92..b2515bc6d56 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -19,6 +19,8 @@
*
*/
+#include "common/algorithm.h"
+
#include "ngi/ngi.h"
#include "ngi/objects.h"
@@ -1187,6 +1189,14 @@ MessageQueue *AniObject::moveToStatic(int msgNum) {
}
void AniObject::setStatic(int objId) {
+ setStatic(objId, false, false);
+}
+
+void AniObject::setStatic(int objId, bool mirror) {
+ setStatic(objId, mirror, true);
+}
+
+void AniObject::setStatic(int objId, bool mirror, bool useMirror) {
if (g_ngi->_gameVersion < 201509) {
_animExFlag = 0;
@@ -1194,13 +1204,12 @@ void AniObject::setStatic(int objId) {
}
if (g_ngi->_gameVersion >= 201509) {
- // CAniObject::SetStatic (F22BC): a running movement is rewound to its previous statics, then, when the statics changes, the anchor moves by the
- // difference of the offsets of the two statics (the x, y of their phases, scaled), around the center of the object (rotated by its angle).
- // The mirror argument (+64) of the original is not modelled: ScummVM objects have no mirror flag.
+ // CAniObject::SetStatic (F22BC): rewinds a running movement, then moves the anchor by the offset
+ // difference of the two statics, about the center; the mirror argument is bit 8 of the flags
stopMovementToPrev(false);
Statics *statics = getStatic(objId);
if (statics) {
- if (statics != _statics) {
+ if (statics != _statics || (useMirror && mirror != ((_flags & 8) != 0))) {
const float oldX = _x;
const float oldY = _y;
const Dims oldSize = _statics ? _statics->getDimensions() : Dims();
@@ -1216,13 +1225,21 @@ void AniObject::setStatic(int objId) {
const Dims newSize = statics->getDimensions();
const float halfWidth = newSize.x * 0.5f * _scaleX;
const float halfHeight = newSize.y * 0.5f * _scaleY;
- const float dx = newX + halfWidth - centerX;
+ float dx = newX + halfWidth - centerX;
const float dy = newY + halfHeight - centerY;
+ if (useMirror && mirror)
+ dx = -dx;
const float c = cosf(_rotation);
const float sn = sinf(_rotation);
_x = (centerX + (dx * c - dy * sn)) - halfWidth;
_y = (centerY + (dx * sn + dy * c)) - halfHeight;
}
+ if (useMirror) {
+ if (mirror)
+ _flags |= 8;
+ else
+ _flags &= ~8;
+ }
if (_movement) // not rewound (no running flag): drop it
_movement = nullptr;
}
@@ -1246,6 +1263,175 @@ void AniObject::setStatic(int objId) {
}
}
+// CAniObject::GetCurFrame (F112C)
+int AniObject::getCurFrame() const {
+ return _movement ? _movement->_curFrame : -1;
+}
+
+// CAniObject::SetCurFrame (F0C76)
+void AniObject::setCurFrame(int frame, bool keepPhaseTimer, bool silent) {
+ if (!_movement)
+ return;
+ static bool reported = false;
+ if (!silent && !reported) {
+ reported = true;
+ warning("STUB/untested: CAniObject::SetCurFrame: the commands and sounds of the phases that are stepped over are not run, the flag +63 is not kept");
+ }
+ _movement->setCurFrame(frame);
+ setPos(_movement->_x, _movement->_y);
+}
+
+// CAniObject::FastStartMovement (F0CC4): StartMovement, last frame (first if reversed),
+// StopMovement(0); the silent flag (CMovement::SetNext a12) is not modelled
+bool AniObject::fastStartMovement(int movementId, bool reverse) {
+ static bool reported = false;
+ if (!reported) {
+ reported = true;
+ warning("STUB/untested: CAniObject::FastStartMovement: the silent flag of CMovement::Start is not modelled");
+ }
+ if (!startMovement(movementId, 0, -1, (_flags & 8) != 0, false, reverse, -1))
+ return false;
+ int frame = 0;
+ if (!reverse) {
+ Movement *movement = _movement;
+ frame = (int)(movement->_currMovement ? movement->_currMovement->_phases.size() : movement->_phases.size()) - 1;
+ }
+ setCurFrame(frame, true, true);
+ stopMovement();
+ return true;
+}
+
+static bool movementIdLess(const Movement *a, const Movement *b) {
+ return a->_id < b->_id;
+}
+
+// CAniObject::FindMovementsBeginStatic (F15EC): depth first search from the statics to the
+// target, by id; forwards only linked movements, reversed those that end at the statics
+Common::Array<Movement *> AniObject::findMovementsBeginStatic(int excludedMovementId, int fromStaticsId, int toStaticsId, Common::Array<Movement *> visited, bool ignoreLink) {
+ Common::Array<Movement *> result;
+ Common::Array<Movement *> candidates;
+ Common::Array<Movement *> sorted = _movements;
+ Common::sort(sorted.begin(), sorted.end(), movementIdLess);
+
+ for (Movement *movement : sorted) {
+ if (movement->_id == excludedMovementId || (!ignoreLink && !movement->_link))
+ continue;
+ bool seen = false;
+ for (Movement *other : visited) {
+ if (other == movement)
+ seen = true;
+ }
+ if (seen)
+ continue;
+ const int start = movement->_prevStatic->_staticsId;
+ const int end = movement->_nextStatic->_staticsId;
+ if (ignoreLink) {
+ if (start == toStaticsId) {
+ if (end == fromStaticsId) {
+ result.push_back(movement);
+ return result;
+ }
+ } else if (end == fromStaticsId && start != fromStaticsId) {
+ candidates.push_back(movement);
+ visited.push_back(movement);
+ }
+ } else if (start == fromStaticsId) {
+ if (end == toStaticsId) {
+ result.push_back(movement);
+ return result;
+ }
+ if (fromStaticsId != end) {
+ candidates.push_back(movement);
+ visited.push_back(movement);
+ }
+ }
+ }
+
+ for (Movement *candidate : candidates) {
+ Common::Array<Movement *> path = findMovementsBeginStatic(candidate->_id, candidate->_nextStatic->_staticsId, toStaticsId, visited, ignoreLink);
+ if (path.empty())
+ break;
+ result.push_back(candidate);
+ for (Movement *step : path)
+ result.push_back(step);
+ }
+ return result;
+}
+
+// CAniObject::MoveToStatic (F1B0C)
+void AniObject::moveToStaticChain(int staticsId) {
+ if (_movement)
+ stopMovementToPrev(true);
+ if (!_statics || _statics->_staticsId == staticsId)
+ return;
+
+ const int current = _statics->_staticsId;
+ Common::Array<Movement *> sorted = _movements;
+ Common::sort(sorted.begin(), sorted.end(), movementIdLess);
+
+ // forwards: a linked movement that leads to the statics, or the linked ones that begin at the current one and the path from their end
+ Common::Array<Movement *> candidates;
+ for (Movement *movement : sorted) {
+ if (!movement->_link)
+ continue;
+ const int start = movement->_prevStatic->_staticsId;
+ const int end = movement->_nextStatic->_staticsId;
+ if (end == staticsId) {
+ if (start == current) {
+ fastStartMovement(movement->_id, false);
+ return;
+ }
+ } else if (start == current && end != start) {
+ candidates.push_back(movement);
+ }
+ }
+ Common::Array<Movement *> chain;
+ for (Movement *candidate : candidates) {
+ Common::Array<Movement *> path = findMovementsBeginStatic(candidate->_id, candidate->_nextStatic->_staticsId, staticsId, candidates, false);
+ if (!path.empty()) {
+ chain.push_back(candidate);
+ for (Movement *step : path)
+ chain.push_back(step);
+ break;
+ }
+ }
+ if (!chain.empty()) {
+ for (Movement *step : chain)
+ fastStartMovement(step->_id, false);
+ return;
+ }
+
+ // backwards: the movements that end at the current statics, played in reverse
+ candidates.clear();
+ for (Movement *movement : sorted) {
+ const int start = movement->_prevStatic->_staticsId;
+ const int end = movement->_nextStatic->_staticsId;
+ if (end != current)
+ continue;
+ if (start == staticsId) {
+ fastStartMovement(movement->_id, true);
+ return;
+ }
+ if (end != start)
+ candidates.push_back(movement);
+ }
+ for (Movement *candidate : candidates) {
+ Common::Array<Movement *> path = findMovementsBeginStatic(candidate->_id, candidate->_nextStatic->_staticsId, staticsId, candidates, true);
+ if (!path.empty()) {
+ chain.push_back(candidate);
+ for (Movement *step : path)
+ chain.push_back(step);
+ break;
+ }
+ }
+ if (chain.empty()) {
+ setStatic(staticsId);
+ return;
+ }
+ for (Movement *step : chain)
+ fastStartMovement(step->_id, true);
+}
+
void AniObject::hide() {
if (!_messageQueueId) {
if (_flags & 4)
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index 7d0436b0547..a13fc199b6e 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -278,6 +278,21 @@ public:
MessageQueue *moveToStatic(int msgNum);
void setStatic(int objId);
+ /** CAniObject::SetStatic(statics, mirror) (F22BC); the overload without mirror keeps it */
+ void setStatic(int objId, bool mirror);
+ void setStatic(int objId, bool mirror, bool useMirror);
+ /** CAniObject +164: the id of the statics (0 without one) */
+ int getStaticsId() const { return _statics ? _statics->_staticsId : 0; }
+ /** CAniObject::GetCurFrame (F112C): the frame of the running movement, -1 without one */
+ int getCurFrame() const;
+ /** CAniObject::SetCurFrame (F0C76); not modelled: keepPhaseTimer, commands of skipped phases */
+ void setCurFrame(int frame, bool keepPhaseTimer = false, bool silent = false);
+ /** CAniObject::FastStartMovement (F0CC4) */
+ bool fastStartMovement(int movementId, bool reverse);
+ /** CAniObject::MoveToStatic (F1B0C), Android; moveToStatic(int) is the Windows version */
+ void moveToStaticChain(int staticsId);
+ /** CAniObject::FindMovementsBeginStatic (F15EC) */
+ Common::Array<Movement *> findMovementsBeginStatic(int excludedMovementId, int fromStaticsId, int toStaticsId, Common::Array<Movement *> visited, bool ignoreLink);
bool getPixelAtPos(int x, int y, uint32 *pixel, bool hitOnly = false);
bool hit(int x, int y);
Commit: bce67c7c7a98e73067b00aa25c4d0fc27137f531
https://github.com/scummvm/scummvm/commit/bce67c7c7a98e73067b00aa25c4d0fc27137f531
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: MessageQueue::stop and setObjectCopyAll, Command::setParamFloat, Scene::runQueueObject and stopAllQueues
Changed paths:
engines/ngi/messages.cpp
engines/ngi/messages.h
engines/ngi/scene.cpp
engines/ngi/scene.h
diff --git a/engines/ngi/messages.cpp b/engines/ngi/messages.cpp
index 844d3ecfdef..8c0257b7b2e 100644
--- a/engines/ngi/messages.cpp
+++ b/engines/ngi/messages.cpp
@@ -152,6 +152,21 @@ float Command::getParamFloat(const char *name, float defaultValue) const {
return (float)atof(_args.getVal(name).c_str());
}
+void Command::setParamFloat(const char *name, float value) {
+ _args[name] = Common::String::format("%f", value);
+ if (!strcmp(name, "x"))
+ _x = (int)value;
+ else if (!strcmp(name, "y"))
+ _y = (int)value;
+ else if (!strcmp(name, "z"))
+ _z = (int)value;
+}
+
+void Command::setObjectCopy(int copyId) {
+ _args["copy"] = Common::String::format("%d", copyId);
+ _param = copyId;
+}
+
bool Command::handleMessage() {
int cnt = 0;
for (MessageHandler *m = g_ngi->_messageHandlers; m; m = m->nextItem)
@@ -415,6 +430,24 @@ bool MessageQueue::load(MfcArchive &file) {
return true;
}
+void MessageQueue::stop(bool) {
+ static bool reported = false;
+ if (!reported) {
+ reported = true;
+ warning("STUB/untested: CMessageQueue::Stop: the queue is emptied and finished (no current command number, no OnStopQueue, no DeleteObjAfter)");
+ }
+ _flag1 = 0;
+ while (getCount())
+ removeCommand(0, true);
+ _counter = 0;
+ _isFinished = 1;
+}
+
+void MessageQueue::setObjectCopyAll(int copyId) {
+ for (uint i = 0; i < getCount(); i++)
+ getCommandByIndex(i)->setObjectCopy(copyId);
+}
+
bool MessageQueue::canInterrupt() {
if (_interruptState == 0)
return true;
diff --git a/engines/ngi/messages.h b/engines/ngi/messages.h
index baaebfbcd39..6c22eac75ec 100644
--- a/engines/ngi/messages.h
+++ b/engines/ngi/messages.h
@@ -154,6 +154,10 @@ class Command : public Message {
/** CCommand::GetParamFloat: the attribute of the XML command, the default when it has none */
float getParamFloat(const char *name, float defaultValue) const;
+ /** CCommand::SetParamFloat (10F494): sets the attribute and keeps the x, y, z fields in step */
+ void setParamFloat(const char *name, float value);
+ /** CCommand::SetObjectCopy (10F45C): the parameter "copy", and the field of the copy */
+ void setObjectCopy(int copyId);
bool handleMessage();
void sendMessage();
@@ -256,6 +260,12 @@ class MessageQueue : public CObject {
int getCommandNumByType(int kind);
/** CMessageQueue::CanInterrupt (10C7A0): state 0 allows it, 1 while no START_MOVEMENT is left */
bool canInterrupt();
+ /** CMessageQueue::Stop (10C838) / Interrupt (10C882): the remaining commands are dropped and
+ the queue ends; CGame::OnStopQueue and CScene::DeleteObjAfter are not called */
+ void stop(bool silent);
+ void interrupt(bool silent) { stop(silent); }
+ /** CMessageQueue::SetObjectCopy (10F470): the copy of every command, or of those with the key */
+ void setObjectCopyAll(int copyId);
void setObjectCopyForId(int objId, int oldCopyId, int newCopyId);
int activateExCommandsByKind(int kind);
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index f6b50309183..182e75e46eb 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -631,6 +631,28 @@ bool Scene::runQueue(int queueId, int interruptState) {
return runQueueWithAni(queueId, nullptr, interruptState);
}
+bool Scene::runQueueObject(MessageQueue *queue, AniObject *ani, int interruptState) {
+ queue->_scene = this;
+ if (interruptState != 4)
+ queue->_interruptState = interruptState;
+ if (!queue->run(ani)) {
+ g_ngi->_globalMessageQueueList->deleteQueueById(queue->_id);
+ return false;
+ }
+ return true;
+}
+
+void Scene::stopAllQueues() {
+ Common::Array<MessageQueue *> running;
+ for (MessageQueue *queue : *g_ngi->_globalMessageQueueList) {
+ if (queue->_scene == this && !queue->_isFinished)
+ running.push_back(queue);
+ }
+ for (MessageQueue *queue : running)
+ queue->stop(false);
+ warning("STUB/untested: CInteractionController::StoppedAllInteractions (CScene::StopAllQueues)");
+}
+
// CScene::RunQueueByIdWithAni (12263E) / RunQueueWithAni (1228AE): Run(interruptState) unless 4
bool Scene::runQueueWithAni(int queueId, AniObject *ani, int interruptState) {
MessageQueue *queue = findMessageQueue(queueId);
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 92aeef67891..9f8bc0236c2 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -143,6 +143,10 @@ class Scene : public Background {
bool runQueue(int queueId, int interruptState = 4);
/** CScene::RunQueueByIdWithAni (12263E), RunQueueWithAni (1228AE): the object gets the queue */
bool runQueueWithAni(int queueId, AniObject *ani, int interruptState = 4);
+ /** CScene::RunQueue / RunQueueWithAni with a queue of the caller; deleted if it does not start */
+ bool runQueueObject(MessageQueue *queue, AniObject *ani, int interruptState = 4);
+ /** CScene::StopAllQueues (120C40); StoppedAllInteractions is not ported */
+ void stopAllQueues();
/** CScene::IsQueuesProcessed (11FB98): copies of the template queues run in the global list */
bool isQueuesProcessed(bool ignoreInterruptState3) const;
MessageQueue *getMessageQueueByName(const Common::String &name);
Commit: faced66d8a79be7f3b20ad858f3bfb76ec481327
https://github.com/scummvm/scummvm/commit/faced66d8a79be7f3b20ad858f3bfb76ec481327
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Shared helpers of the scene controllers (command builders, HideAction, stubs)
Changed paths:
A engines/ngi/fullpipe/controllerhelpers.cpp
A engines/ngi/fullpipe/controllerhelpers.h
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/controllerhelpers.cpp b/engines/ngi/fullpipe/controllerhelpers.cpp
new file mode 100644
index 00000000000..cc045f9996a
--- /dev/null
+++ b/engines/ngi/fullpipe/controllerhelpers.cpp
@@ -0,0 +1,165 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/hashmap.h"
+
+#include "ngi/ngi.h"
+#include "ngi/messages.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/controllerhelpers.h"
+
+namespace NGI {
+
+Command *messageCommand(const char *name, int wait, int excFlags, const char *param) {
+ uint32 id = 0;
+ g_ngi->_gameProject->_objectIds.findId(name, id);
+ Command *command = new Command(0, kCmdMessage, id, 0, 0, 0, wait, 0, 0, 0);
+ command->_messageName = name;
+ command->_args["msg"] = name;
+ if (param)
+ command->_args["param"] = param;
+ command->_excFlags |= excFlags;
+ return command;
+}
+
+Command *movementCommand(int aniId, int movementId, int copyId, bool mirror) {
+ Command *command = new Command(aniId, kCmdStartMovement, movementId, 0, 0, 0, 1, 0, 0, 0);
+ command->_param = copyId;
+ command->_mirror = mirror;
+ command->_excFlags |= 2;
+ return command;
+}
+
+Command *movementCommand(const AniObject *ani, int movementId) {
+ return movementCommand(ani->_id, movementId, ani->_copyId);
+}
+
+Command *pauseCommand(int delay) {
+ Command *command = new Command(0, kCmdPause, delay, 0, 0, 0, 1, 0, 0, 0);
+ command->_excFlags |= 2;
+ return command;
+}
+
+Command *hideCommand(int objectId, int copyId) {
+ Command *command = new Command(objectId, kCmdHide, 0, 0, 0, 0, 0, 0, 0, 0);
+ command->_param = copyId;
+ command->_excFlags |= 2;
+ return command;
+}
+
+Command *queueCommand(int queueId, const char *name, const char *interrupt) {
+ Command *command = new Command(0, kCmdQueue, queueId, 0, 0, 0, 1, 0, 0, 0);
+ command->_args["id"] = name;
+ if (interrupt)
+ command->_args["interupt"] = interrupt;
+ command->_excFlags |= 2;
+ return command;
+}
+
+void hideAction(Scene *scene, int objectId, int copyId) {
+ AniObject *ani;
+ do {
+ ani = scene->findAniObjectById(objectId, copyId);
+ if (ani) {
+ ani->stopMovement();
+ ani->_flags &= ~4;
+ }
+ copyId++;
+ } while (ani);
+}
+
+Command *createMouseCommand(Scene *scene, float x, float y, int objectId) {
+ Command *command = new Command(0, kCmdUser, 0, 0, 0, 0, 0, 0, 0, 0);
+ command->_messageName = "MOUSE";
+ command->_args["type"] = "MOUSE";
+ command->_args["key"] = "100";
+ command->_args["obj"] = Common::String::format("%d", objectId);
+ command->_args["x"] = Common::String::format("%f", x - scene->_x);
+ command->_args["y"] = Common::String::format("%f", y - scene->_y);
+ command->_args["scroll_x"] = Common::String::format("%f", (float)scene->_x);
+ command->_args["scroll_y"] = Common::String::format("%f", (float)scene->_y);
+ command->_excFlags |= 2;
+ return command;
+}
+
+int projectId(const char *name) {
+ uint32 id = 0;
+ if (!g_ngi->_gameProject->_objectIds.findId(name, id))
+ warning("projectId: unknown object '%s'", name);
+ return (int)id;
+}
+
+void warnOnce(const char *what) {
+ static Common::HashMap<Common::String, bool> reported;
+ if (!reported.contains(what)) {
+ reported[what] = true;
+ warning("STUB/untested: %s", what);
+ }
+}
+
+void setSaving(bool) {
+ warnOnce("CBaseSettings::SetSaving (the saves are not blocked while the arcade runs)");
+}
+
+void showHint() {
+ warnOnce("CHintManager::ShowHint (the hint of the arcade is not shown)");
+}
+
+void hideHint() {
+ warnOnce("CHintManager::HideHint (the hint of the arcade is not shown)");
+}
+
+void setHideHintCondition() {
+ warnOnce("CHintManager::SetHideCondition (the hint of the arcade is not shown)");
+}
+
+void enableSound(int, bool) {
+ warnOnce("CBehaviorController::EnableSound is not ported");
+}
+
+void blockActivatingCounter() {
+ warnOnce("CAchievementsManager::BlockActivatingCounter is not ported");
+}
+
+void addActivatingCounter() {
+ warnOnce("CAchievementsManager::AddActivatingCounter is not ported");
+}
+
+Interact *findInteractionUnderCursor() {
+ warnOnce("CInteractionController::FindInteractionUnderCursor is not ported (D17)");
+ return nullptr;
+}
+
+void runInteractionWithMouse(const char *, float, float) {
+ warnOnce("CFPController::RunInteractionWithMouse is not ported (the tap of FPController::onTap starts the interactions by the object, not by the name)");
+}
+
+void setInteractionWeight(const char *, int) {
+ warnOnce("CInteractionController::SetVes is not ported: the weights of the interactions are not changed");
+}
+
+int interactionCommandNum(const char *) {
+ warnOnce("CInteractionController::FindInteraction by name is not ported (the number of the current command of the queue of an interaction)");
+ return -1;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/controllerhelpers.h b/engines/ngi/fullpipe/controllerhelpers.h
new file mode 100644
index 00000000000..eab62b30177
--- /dev/null
+++ b/engines/ngi/fullpipe/controllerhelpers.h
@@ -0,0 +1,65 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_CONTROLLERHELPERS_H
+#define NGI_FULLPIPE_CONTROLLERHELPERS_H
+
+namespace NGI {
+
+class AniObject;
+class Command;
+class Interact;
+class Scene;
+
+/** Helpers shared by the CScNNController ports: queue and mouse commands, STUB placeholders */
+
+// queue commands (excFlags 2 = run by the queue)
+Command *messageCommand(const char *name, int wait = 0, int excFlags = 2, const char *param = nullptr);
+Command *movementCommand(int aniId, int movementId, int copyId = 0, bool mirror = false);
+Command *movementCommand(const AniObject *ani, int movementId);
+Command *pauseCommand(int delay);
+Command *hideCommand(int objectId, int copyId);
+Command *queueCommand(int queueId, const char *name, const char *interrupt);
+
+/** CFPController::HideAction (1490B0): stops and hides the copies from copyId on */
+void hideAction(Scene *scene, int objectId, int copyId);
+/** CFPController::CreateMouseCommand (148FB4): the user command MOUSE (not handled yet) */
+Command *createMouseCommand(Scene *scene, float x, float y, int objectId);
+/** the object id in the game project (Android obj.h differs from constants.h, e.g. ST_LBN_*) */
+int projectId(const char *name);
+
+// placeholders of subsystems that are not ported
+void warnOnce(const char *what);
+void setSaving(bool allowed); // CBaseSettings::SetSaving
+void showHint(); // CHintManager::ShowHint
+void hideHint(); // CHintManager::HideHint
+void setHideHintCondition(); // CHintManager::SetHideCondition
+void enableSound(int soundId, bool enable); // CBehaviorController::EnableSound
+void blockActivatingCounter(); // CAchievementsManager::BlockActivatingCounter
+void addActivatingCounter(); // CAchievementsManager::AddActivatingCounter
+Interact *findInteractionUnderCursor(); // CInteractionController (106D94)
+void runInteractionWithMouse(const char *name, float x, float y); // CFPController (14D5E0)
+void setInteractionWeight(const char *name, int weight); // CInteractionController::SetVes (106DC8)
+int interactionCommandNum(const char *name); // CInteractionController::FindInteraction(name)
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_CONTROLLERHELPERS_H
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index bd310b7fe4d..1fbc2ffa928 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -82,6 +82,7 @@ MODULE_OBJS = \
fullpipe/arcadeinterface.o \
fullpipe/chaptercontroller.o \
fullpipe/chaptermanager.o \
+ fullpipe/controllerhelpers.o \
fullpipe/exitmanager.o \
fullpipe/floaters.o \
fullpipe/fpcontroller.o \
Commit: 87605fe3a8ffa605212bd409de31a4372d56b91a
https://github.com/scummvm/scummvm/commit/87605fe3a8ffa605212bd409de31a4372d56b91a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 4 controller uses the shared helpers
Changed paths:
engines/ngi/fullpipe/sc04controller.cpp
diff --git a/engines/ngi/fullpipe/sc04controller.cpp b/engines/ngi/fullpipe/sc04controller.cpp
index bed3383d386..cd4995be3a1 100644
--- a/engines/ngi/fullpipe/sc04controller.cpp
+++ b/engines/ngi/fullpipe/sc04controller.cpp
@@ -38,6 +38,7 @@
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc04controller.h"
@@ -55,19 +56,6 @@ const int kSpeakerPhases[] = {
0, 2, -1, -1, -1, -1
};
-void warnOnce(const char *what) {
- static Common::HashMap<Common::String, bool> reported;
- if (!reported.contains(what)) {
- reported[what] = true;
- warning("STUB/untested: %s", what);
- }
-}
-
-// CBaseSettings::SetSaving (sub_164860 gets the settings of CGame): not ported
-void setSaving(bool allowed) {
- warnOnce(allowed ? "CBaseSettings::SetSaving(true)" : "CBaseSettings::SetSaving(false)");
-}
-
bool isState(const char *object, const char *state) {
return g_ngi->getStateId(object) == g_ngi->getStateValue(object, state);
}
@@ -78,19 +66,6 @@ bool isSoundPlayed(int soundId) {
return sound && sound->isPlaying();
}
-// CScene::RunQueueWithAni (1228AE) with a queue that was made here: CVisibleObject::SetQueue, then CScene::RunQueue(queue, state)
-void runQueueWithAni(Scene *scene, MessageQueue *queue, AniObject *ani, int state) {
- queue->_scene = scene;
- if (state != 4)
- queue->_interruptState = state;
- if (!queue->run(ani)) {
- if (queue->getFlags() & kInGlobalQueue)
- g_ngi->_globalMessageQueueList->deleteQueueById(queue->_id);
- else
- delete queue;
- }
-}
-
// FindQueue + CMessageQueue::CMessageQueue(CMessageQueue *): the copy of the queue of the scene
MessageQueue *copyQueue(Scene *scene, int queueId) {
MessageQueue *queue = scene->findMessageQueue(queueId);
@@ -101,43 +76,6 @@ MessageQueue *copyQueue(Scene *scene, int queueId) {
return copy;
}
-// CMessageQueue::SetObjectCopy: CCommand::SetObjectCopy (SetParamInt "copy") for every command of the queue
-void setObjectCopy(MessageQueue *queue, int copyId) {
- for (uint i = 0; i < queue->getCount(); i++) {
- Command *command = queue->getCommandByIndex(i);
- command->_param = copyId;
- command->_args["copy"] = Common::String::format("%d", copyId);
- }
-}
-
-// CCommand(START_MOVEMENT, wait) with the parameters aniId, moveId, copy (and mirror)
-Command *movementCommand(int aniId, int movementId, int copyId, bool mirror = false) {
- Command *command = new Command(aniId, kCmdStartMovement, movementId, 0, 0, 0, 1, 0, 0, 0);
- command->_param = copyId;
- command->_mirror = mirror;
- command->_excFlags |= 2;
- return command;
-}
-
-// CCommand(MESSAGE, wait): the name goes to the controllers (CScene::Message), its id to the scene handlers
-Command *messageCommand(const char *name, int wait = 0) {
- uint32 id = 0;
- g_ngi->_gameProject->_objectIds.findId(name, id);
- Command *command = new Command(0, kCmdMessage, id, 0, 0, 0, wait, 0, 0, 0);
- command->_messageName = name;
- command->_args["msg"] = name;
- command->_excFlags |= 2;
- return command;
-}
-
-// CCommand(HIDE) with the parameters objId, copy
-Command *hideCommand(int objectId, int copyId) {
- Command *command = new Command(objectId, kCmdHide, 0, 0, 0, 0, 0, 0, 0, 0);
- command->_param = copyId;
- command->_excFlags |= 2;
- return command;
-}
-
// CCommand(USER) type EXIT_ROTATE with the parameters picId and where
Command *exitRotateCommand(const char *where) {
Command *command = new Command(0, kCmdUser, 0, 0, 0, 0, 0, 0, 0, 0);
@@ -149,34 +87,6 @@ Command *exitRotateCommand(const char *where) {
return command;
}
-// CFPController::CreateMouseCommand (148FB4): the user command MOUSE (CFPController::ExecuteUserCmd does not handle it yet, see executeUserCmd)
-Command *createMouseCommand(Scene *scene, float x, float y, int objectId) {
- Command *command = new Command(0, kCmdUser, 0, 0, 0, 0, 0, 0, 0, 0);
- command->_messageName = "MOUSE";
- command->_args["type"] = "MOUSE";
- command->_args["key"] = "100";
- command->_args["obj"] = Common::String::format("%d", objectId);
- command->_args["x"] = Common::String::format("%f", x - scene->_x);
- command->_args["y"] = Common::String::format("%f", y - scene->_y);
- command->_args["scroll_x"] = Common::String::format("%f", (float)scene->_x);
- command->_args["scroll_y"] = Common::String::format("%f", (float)scene->_y);
- command->_excFlags |= 2;
- return command;
-}
-
-// CFPController::HideAction (1490B0): the copies of the object from the given one on stop and hide
-void hideAction(Scene *scene, int objectId, int copyId) {
- AniObject *ani;
- do {
- ani = scene->findAniObjectById(objectId, copyId);
- if (ani) {
- ani->stopMovement();
- ani->_flags &= ~4;
- }
- copyId++;
- } while (ani);
-}
-
// CScene::GetObjectsAmount (1224D8)
int objectsAmount(Scene *scene, int objectId) {
int amount = -1;
@@ -186,19 +96,6 @@ int objectsAmount(Scene *scene, int objectId) {
return amount;
}
-// CVisibleObject::IsOnScreenEntirely (127682): every corner of the rect of the object is inside the visible part of the scene (the widescreen margin
-// is on both sides; CRender +8 and the vertical margins +12, +28 are taken as 0)
-bool isOnScreenEntirely(const Scene *scene, const GameObject *object) {
- const float margin = g_ngi->_wideOfs;
- const float left = scene->_x - margin;
- const float right = scene->_x + margin + g_ngi->gameWidth();
- const float top = scene->_y;
- const float bottom = scene->_y + g_ngi->_backgroundSurface.h;
- const Common::Rect rect = object->getBounds();
- return rect.left > left && rect.left < right && rect.top > top && rect.top < bottom &&
- rect.right > left && rect.right < right && rect.bottom > top && rect.bottom < bottom;
-}
-
// CMessageQueue::Stop of the running copies of a queue of the scene (the queues of the scene are templates here)
void stopQueueCopies(int queueId) {
GlobalMessageQueueList &queues = *g_ngi->_globalMessageQueueList;
@@ -320,7 +217,7 @@ void Sc04Controller::checkTutorial() {
if (coin && coin->_counter > 0) {
// CVisibleObject::IsOnScreenEntirely (vtable slot 132) of the picture of the slot
PictureObject *slot = _scene->findPictureObjectById(PIC_SC4_MONETOPR, 0);
- visible = slot && isOnScreenEntirely(_scene, slot);
+ visible = slot && slot->isOnScreenEntirely(_scene);
}
if (visible)
_tutorial = "EXTRA_TUTORIAL_USE_DEVICES";
@@ -387,13 +284,13 @@ void Sc04Controller::startKozawka(bool first) {
MessageQueue *queue = copyQueue(_scene, QU_KOZAW_WALK);
if (queue) {
- setObjectCopy(queue, kozaw->_copyId);
+ queue->setObjectCopyAll(kozaw->_copyId);
if (!first) {
Command *pause = queue->getCommandByIndex(0);
pause->_messageNum = (int)(_kozawStartDelay * 1000);
pause->_args["delay"] = Common::String::format("%d", pause->_messageNum);
}
- runQueueWithAni(_scene, queue, _walkingKozaw, 3);
+ _scene->runQueueObject(queue, _walkingKozaw, 3);
}
const uint32 delay = (uint32)(_kozawDelayK * 83.0);
@@ -506,7 +403,7 @@ void Sc04Controller::recalcSpring(uint32 elapsed) {
_spring->startMovement(MV_SPR_LOWER, 0, -1);
if (previous != _springPos && _spring->_movement) {
// CAniObject::SetCurFrame (F0C76): CMovement::SetCurFrame of the running movement
- _spring->_movement->setCurFrame(_springPos);
+ _spring->setCurFrame(_springPos);
}
} else {
_spring->setStatic(ST_SPR_UP);
@@ -591,7 +488,7 @@ void Sc04Controller::gramoNextFunc(uint32 elapsed) {
_speaker->startMovement(MV_SPK4_PLAY, 0, -1);
// CAniObject::SetCurFrame (F0C76)
if (_speaker->_movement)
- _speaker->_movement->setCurFrame(frame);
+ _speaker->setCurFrame(frame);
}
}
@@ -626,7 +523,7 @@ void Sc04Controller::doManFall() {
show->_y = (int)y;
show->_args["y"] = Common::String::format("%f", y);
}
- runQueueWithAni(_scene, queue, hero(), 4);
+ _scene->runQueueObject(queue, hero(), 4);
}
_manFalls = false;
heroOnLadder() = false;
@@ -849,7 +746,7 @@ MessageQueue *Sc04Controller::doManJump() {
MessageQueue *queue = g_ngi->_aniHandler->makeRunQueue(&queueInfo);
if (queue) {
queue->_interruptState = 2;
- runQueueWithAni(_scene, queue, man, 2);
+ _scene->runQueueObject(queue, man, 2);
man->_z = 10;
queue->addCommandToEnd(exitRotateCommand("MSG_FROMLADDER"));
}
@@ -897,7 +794,7 @@ void Sc04Controller::doGotoLadder(MessageQueue *queue) {
made->addCommandToEnd(messageCommand("MSG_DOWALKLADDER_MAX"));
hero()->_z = 12;
}
- runQueueWithAni(_scene, made, hero(), 2);
+ _scene->runQueueObject(made, hero(), 2);
}
_kozawShot = false;
}
@@ -1057,7 +954,7 @@ void Sc04Controller::doShootKozawka() {
// analytics total_moves, first_move, failcount of ANI_KOZAWKA: not ported
_lastKozaw = kozaw;
if (queue)
- runQueueWithAni(_scene, queue, kozaw, 3);
+ _scene->runQueueObject(queue, kozaw, 3);
warnOnce("CHintManager::SetHideCondition");
}
_kozawShot = true;
@@ -1073,7 +970,7 @@ void Sc04Controller::doStandLadder(MessageQueue *queue) {
standQueue->addCommandToEnd(movementCommand(ANI_MAN, MV_MAN_TOLADDER, hero()->_copyId));
standQueue->addCommandToEnd(movementCommand(ANI_MAN, MV_MAN_STOPLADDER, hero()->_copyId));
standQueue->addCommandToEnd(messageCommand("MSG_SC4_CLICKLADDER"));
- runQueueWithAni(_scene, standQueue, hero(), 4);
+ _scene->runQueueObject(standQueue, hero(), 4);
heroOnLadder() = true;
_ladder = new MctlLadder();
@@ -1120,7 +1017,7 @@ void Sc04Controller::tryLeaveLadder(uint32 id, float x, float y) {
MessageQueue *queue = _ladder->makeQueue(man, 0);
if (queue) {
queue->addCommandToEnd(createMouseCommand(_scene, x, y, g_ngi->_inputController->getObjectId()));
- runQueueWithAni(_scene, queue, man, 2);
+ _scene->runQueueObject(queue, man, 2);
if (_ballSlow)
speedUpBall();
}
@@ -1132,7 +1029,7 @@ void Sc04Controller::tryLeaveLadder(uint32 id, float x, float y) {
queue->addCommandToEnd(movementCommand(ANI_MAN, MV_MAN_FROMLADDER, man->_copyId));
queue->addCommandToEnd(createMouseCommand(_scene, x, y, g_ngi->_inputController->getObjectId()));
queue->addCommandToEnd(messageCommand("MSG_AFTERLADDER"));
- runQueueWithAni(_scene, queue, man, 2);
+ _scene->runQueueObject(queue, man, 2);
}
}
@@ -1184,7 +1081,7 @@ void Sc04Controller::onUtrubaClick(MessageQueue *queue) {
if (_ladder->getCurrentStep(hero()) <= 5) {
MessageQueue *up = _ladder->makeQueue(hero(), 6);
if (up)
- runQueueWithAni(_scene, up, hero(), 2);
+ _scene->runQueueObject(up, hero(), 2);
}
} else if (fabsf(1095.0f - _clickHeroX) > 10.0f || fabsf(434.0f - _clickHeroY) > 10.0f) {
MessageQueue *started = mctlStartMove(1095, 434, true, ST_MAN_UP, false);
@@ -1203,7 +1100,7 @@ void Sc04Controller::doJumpFromBottle(MessageQueue *queue) {
MessageQueue *jump = copyQueue(_scene, QU_SC4_MANFROMBOTTLE);
if (jump) {
jump->_interruptState = 2;
- runQueueWithAni(_scene, jump, hero(), 4);
+ _scene->runQueueObject(jump, hero(), 4);
}
_dudeInBottle = false;
_scene->_behaviorController->enableAllQueuesForAni(hero(), 1);
@@ -1412,7 +1309,7 @@ void Sc04Controller::onShowScene() {
_waitingKozaws.clear();
_spring->startMovement(MV_SPR_LOWER, 0, -1);
if (_spring->_movement)
- _spring->_movement->setCurFrame(8);
+ _spring->setCurFrame(8);
_spring->setCenter(Common::Point(433, 238));
}
@@ -1654,7 +1551,7 @@ void Sc04Controller::onMessage(const Common::String &message, const Common::Stri
const int frame = _lamps->_movement->_curFrame;
if (frame >= (int)_lamps->_movement->_phases.size() - 1)
return;
- _lamps->_movement->setCurFrame(frame + 1);
+ _lamps->setCurFrame(frame + 1);
return;
}
if (message == "MSG_TESTPLANK") {
Commit: 84d8ecb805a946e495484870e20d1ece3551f620
https://github.com/scummvm/scummvm/commit/84d8ecb805a946e495484870e20d1ece3551f620
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 6 controller uses the shared helpers
Changed paths:
engines/ngi/fullpipe/sc06controller.cpp
diff --git a/engines/ngi/fullpipe/sc06controller.cpp b/engines/ngi/fullpipe/sc06controller.cpp
index a4be086ecd0..56bdc6416d0 100644
--- a/engines/ngi/fullpipe/sc06controller.cpp
+++ b/engines/ngi/fullpipe/sc06controller.cpp
@@ -36,6 +36,7 @@
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc06controller.h"
@@ -46,115 +47,6 @@ namespace NGI {
namespace {
-// Android obj.h ST_LBN_3N: the pushed-in normal statics of the button of the third floor (constants.h has the number of the Windows game, 2759)
-const int kLiftButton3 = 23076;
-
-void warnOnce(const char *what) {
- static Common::HashMap<Common::String, bool> reported;
- if (!reported.contains(what)) {
- reported[what] = true;
- warning("STUB/untested: %s", what);
- }
-}
-
-// CBaseSettings::SetSaving (CGame +112): the saves are blocked while the arcade runs
-void setSaving(bool) {
- warnOnce("CBaseSettings::SetSaving (CSc06Controller: the saves are not blocked during the arcade)");
-}
-
-// CHintManager::ShowHint / HideHint / SetHideCondition (the hint glow of the arcade)
-void hintManager(const char *what) {
- warnOnce(what);
-}
-
-// CAniObject::GetCurFrame (F112C): the frame of the movement, -1 when there is none
-int getCurFrame(const AniObject *ani) {
- return ani->_movement ? ani->_movement->_curFrame : -1;
-}
-
-// CAniObject::SetCurFrame (F0C76): the movement goes to the frame, when there is one. The flag (a3, CMovement +63: the timer of the phase goes on) is not modelled.
-void setCurFrame(AniObject *ani, int frame, bool keepPhaseTimer) {
- if (!ani->_movement)
- return;
- if (keepPhaseTimer)
- warnOnce("CAniObject::SetCurFrame: the flag CMovement +63 (the phase timer goes on) is not modelled");
- ani->_movement->setCurFrame(frame);
-}
-
-// the +164 of the object: the statics that it is in
-int getStaticsId(const AniObject *ani) {
- return ani->_statics ? ani->_statics->_staticsId : 0;
-}
-
-// CFPController::HideAction (1490B0): the copies of the object from `copy` on lose their movement and are hidden, up to the first copy that does not exist
-void hideAction(Scene *scene, int id, int copy) {
- AniObject *ani;
- do {
- ani = scene->findAniObjectById(id, copy);
- if (ani) {
- ani->stopMovement();
- ani->_flags &= ~4;
- }
- ++copy;
- } while (ani);
-}
-
-// CCommand::CCommand(kind, wait) as the XML loader of the scenes leaves it
-Command *newCommand(int kind, bool wait) {
- Command *command = new Command();
- command->_cmd = kind;
- command->_wait = wait;
- command->_excFlags = 2;
- return command;
-}
-
-// START_MOVEMENT with the parameters aniId and moveId
-Command *movementCommand(int aniId, int movementId) {
- Command *command = newCommand(kCmdStartMovement, true);
- command->_parentId = aniId;
- command->_messageNum = movementId;
- command->_args["aniId"] = Common::String::format("%d", aniId);
- command->_args["moveId"] = Common::String::format("%d", movementId);
- return command;
-}
-
-// PAUSE with the parameter delay
-Command *pauseCommand(int delay) {
- Command *command = newCommand(kCmdPause, true);
- command->_messageNum = delay;
- command->_args["delay"] = Common::String::format("%d", delay);
- return command;
-}
-
-// QUEUE with the parameter id and, when given, interupt
-Command *queueCommand(int queueId, const char *name, const char *interrupt) {
- Command *command = newCommand(kCmdQueue, true);
- command->_messageNum = queueId;
- command->_args["id"] = name;
- if (interrupt)
- command->_args["interupt"] = interrupt;
- return command;
-}
-
-// MESSAGE with the parameter msg (waiting for nothing)
-Command *messageCommand(const char *name) {
- uint32 id = 0;
- Command *command = newCommand(kCmdMessage, false);
- command->_messageName = name;
- command->_args["msg"] = name;
- if (g_ngi->_gameProject->_objectIds.findId(name, id))
- command->_messageNum = id;
- return command;
-}
-
-// CScene::RunQueueWithAni (1228AE) for a queue that was built here: the object gets the queue and it runs with the interrupt state (CMessageQueue::Run)
-void runQueueWithAni(MessageQueue *queue, AniObject *ani, int interruptState) {
- if (interruptState != 4)
- queue->_interruptState = interruptState;
- if (!queue->run(ani))
- delete queue;
-}
-
// CMessageQueue copy ctor + SetObjectCopy + CScene::RunQueue(queue, 4, 0), for this ball copy
void runQueueForCopy(Scene *scene, int queueId, int copyId) {
MessageQueue *queue = scene->findMessageQueue(queueId);
@@ -328,7 +220,7 @@ void Sc06Controller::startDragMan() {
_manActive = true;
_manTimer = 0;
hero()->startMovement(MV_MAN6_THROWBALL, 0, -1);
- setCurFrame(hero(), 0, false);
+ hero()->setCurFrame(0, false);
_aiming = true;
}
@@ -344,7 +236,7 @@ void Sc06Controller::doInstHandle() {
// CSc06Controller::OnPushButton (16B150): the button knocks the plugged handle off
void Sc06Controller::onPushButton() {
_handle = _scene->findAniObjectById(ANI_INV_HANDLE, 0);
- if (_handle && (_handle->_flags & 4) && getStaticsId(_handle) == ST_HDL_PLUGGED)
+ if (_handle && (_handle->_flags & 4) && _handle->getStaticsId() == ST_HDL_PLUGGED)
_scene->runQueue(QU_SC6_FALLHANDLE, 2);
}
@@ -425,12 +317,12 @@ void Sc06Controller::onSpinHandle() {
// CSc06Controller::DoManShoot (16B8C8): the throw strength comes from the swing frame
void Sc06Controller::doManShoot() {
if (_ballInHands) {
- _ballSpeedX = ((float)(getCurFrame(hero()) + 4) * 0.02f) * 4.0f;
- _ballSpeedY = ((float)(getCurFrame(hero()) + 4) * 0.01f) * 5.0f;
+ _ballSpeedX = ((float)(hero()->getCurFrame() + 4) * 0.02f) * 4.0f;
+ _ballSpeedY = ((float)(hero()->getCurFrame() + 4) * 0.01f) * 5.0f;
int frame = 11;
- if (getCurFrame(hero()) > 3)
+ if (hero()->getCurFrame() > 3)
frame = 9;
- setCurFrame(hero(), frame, false);
+ hero()->setCurFrame(frame, false);
}
_powerArrow->_flags &= ~4;
_aimAngle = 205.0f;
@@ -439,7 +331,7 @@ void Sc06Controller::doManShoot() {
_powerArrow->_scaleX = _aimScale;
_powerArrow->_scaleY = 1.0f;
_aiming = false;
- hintManager("CHintManager::SetHideCondition (CSc06Controller::DoManShoot)");
+ setHideHintCondition();
}
// CSc06Controller::GetCursorTypeTop (16B980): the cursor over Mumsy in the arcade
@@ -457,7 +349,7 @@ void Sc06Controller::manNextFunc(uint32 elapsed) {
const uint32 time = elapsed + _manTimer;
if (time > 83) {
_manTimer = time - 83;
- int frame = getCurFrame(hero());
+ int frame = hero()->getCurFrame();
bool flag = _aiming;
if (_aiming) {
CursorController *cursor = g_ngi->_inputController;
@@ -478,7 +370,7 @@ void Sc06Controller::manNextFunc(uint32 elapsed) {
flag = true;
}
}
- setCurFrame(hero(), frame, flag);
+ hero()->setCurFrame(frame, flag);
} else {
_manTimer = time;
}
@@ -499,7 +391,7 @@ void Sc06Controller::onUTrubaClick() {
// CSc06Controller::DoTakeBall (16BAF8): the hero takes the ball, interaction and walking off
void Sc06Controller::doTakeBall() {
if (_dropsShown == 1) {
- hintManager("CHintManager::ShowHint (CSc06Controller::DoTakeBall)");
+ showHint();
// CFPController::FlurryArcadeStart("ANI_MAMASHA"): analytics not ported
}
_holdingBall = true;
@@ -517,11 +409,11 @@ void Sc06Controller::doTakeBall() {
// CSc06Controller::OnBallClick (16BBC4): take the ball at the pipe, else walk there first
void Sc06Controller::onBallClick() {
- if (!_currentBall || _currentBall->_movement || getStaticsId(_currentBall) != ST_NBL_NORM)
+ if (!_currentBall || _currentBall->_movement || _currentBall->getStaticsId() != ST_NBL_NORM)
return;
const Common::Point center = hero()->getCenter();
- if ((fabsf(1158.0f - (float)center.x) <= 2.0f && fabsf(452.0f - (float)center.y) <= 2.0f && !hero()->_movement && getStaticsId(hero()) == ST_MAN_RIGHT &&
+ if ((fabsf(1158.0f - (float)center.x) <= 2.0f && fabsf(452.0f - (float)center.y) <= 2.0f && !hero()->_movement && hero()->getStaticsId() == ST_MAN_RIGHT &&
(hero()->_flags & 8)) || _holdingBall) {
doTakeBall();
return;
@@ -603,12 +495,12 @@ void Sc06Controller::doStopArcade() {
// CFPController::FlurryArcadeEnd("ANI_MAMASHA"): the analytics are not ported
}
_mumsy->stopMovementToPrev(false);
- runQueueWithAni(queue, _mumsy, 2);
+ _scene->runQueueObject(queue, _mumsy, 2);
_scene->_behaviorController->enableAllQueuesForAni(hero(), true);
_ballsCaught = 0;
_arcadeRunning = false;
_follow = nullptr;
- hintManager("CHintManager::HideHint (CSc06Controller::DoStopArcade)");
+ hideHint();
g_ngi->setState(sO_Hint_2_02, 0);
setSaving(true);
}
@@ -700,12 +592,12 @@ void Sc06Controller::skipArcade() {
g_ngi->_taskManager->deactivateTask("GET_DEVICE_SC6");
// CFPController::FlurryArcadeSkip("ANI_MAMASHA"): the analytics are not ported
_mumsy->stopMovementToPrev(false);
- runQueueWithAni(queue, _mumsy, 2);
+ _scene->runQueueObject(queue, _mumsy, 2);
_scene->_behaviorController->enableAllQueuesForAni(hero(), true);
_ballsCaught = 0;
_arcadeRunning = false;
_follow = nullptr;
- hintManager("CHintManager::HideHint (CSc06Controller::SkipArcade)");
+ hideHint();
g_ngi->setState(sO_Hint_2_02, 0);
setSaving(true);
}
@@ -752,14 +644,14 @@ void Sc06Controller::putBallToBag() {
float moveY = 0.0f;
bool done = false;
if (_mumsy->_movement->_id == MV_MOM_JUMPFW) {
- if (getCurFrame(_mumsy) > 5) {
+ if (_mumsy->getCurFrame() > 5) {
const Common::Point size = _mumsy->_movement->getCenterMovementSize(1, -1);
moveX = (float)size.x;
moveY = (float)size.y;
++_momPos;
done = true;
}
- } else if (getCurFrame(_mumsy) > 4) {
+ } else if (_mumsy->getCurFrame() > 4) {
const Common::Point size = _mumsy->_movement->getCenterMovementSize(1, -1);
moveX = (float)size.x;
moveY = (float)size.y;
@@ -767,7 +659,7 @@ void Sc06Controller::putBallToBag() {
done = true;
}
if (!done) {
- const Common::Point size = _mumsy->_movement->getCenterMovementSize(0, getCurFrame(_mumsy));
+ const Common::Point size = _mumsy->_movement->getCenterMovementSize(0, _mumsy->getCurFrame());
moveX = -(float)size.x;
moveY = -(float)size.y;
}
@@ -832,7 +724,7 @@ void Sc06Controller::doWinArcade() {
_scene->_motionController->activate();
getGameLoaderInteractionController()->enable();
_scene->_behaviorController->enableAllQueuesForAni(hero(), true);
- hintManager("CHintManager::HideHint (CSc06Controller::DoWinArcade)");
+ hideHint();
g_ngi->setState(sO_Hint_2_02, 0);
g_ngi->_taskManager->deactivateTask("GET_DEVICE_SC6");
setSaving(true);
@@ -936,7 +828,7 @@ void Sc06Controller::onShow() {
g_ngi->setState(sO_BigMumsy, g_ngi->getStateValue(sO_BigMumsy, sO_IsSleeping));
if (g_ngi->getStateId(sO_BigMumsy) != g_ngi->getStateValue(sO_BigMumsy, sO_IsSleeping))
_mumsy->_flags &= ~4;
- g_ngi->lift().enableButton(sO_Level3, kLiftButton3);
+ g_ngi->lift().enableButton(sO_Level3, projectId("ST_LBN_3N"));
g_ngi->lift().initLift(_scene, hero(), QU_SC6_ENTERLIFT, QU_SC6_EXITLIFT);
doUpdatePath();
_scene->findAniObjectById(ANI_MAMASHA, 0)->setStatic(ST_MOM_SITS);
@@ -962,7 +854,7 @@ void Sc06Controller::onHide() {
g_ngi->setState(sO_Hint_2_02, 0);
_dropsShown = -1;
moveLiquid();
- hintManager("CHintManager::HideHint (CSc06Controller::OnHide)");
+ hideHint();
if (_arcadeRunning) {
// CFlurryEventManager lose_count/game_..._lose: analytics not ported
}
@@ -987,7 +879,7 @@ bool Sc06Controller::onMouseLKeyDown(uint32 id, float x, float y) {
return result;
if (!result && _ballInHands) {
CursorController *cursor = g_ngi->_inputController;
- if (cursor->isObjectHit(hero()) && !hero()->_movement && getStaticsId(hero()) == ST_MAN6_BALL) {
+ if (cursor->isObjectHit(hero()) && !hero()->_movement && hero()->getStaticsId() == ST_MAN6_BALL) {
_dragX = (int)cursor->_hotSceneX;
_dragY = (int)cursor->_hotSceneY;
startDragMan();
@@ -1041,7 +933,7 @@ int Sc06Controller::getCursorType(float x, float y) {
if (_aiming)
return 107;
if (g_ngi->_inputController->isObjectHit(hero())) {
- if (getStaticsId(hero()) != ST_MAN6_BALL)
+ if (hero()->getStaticsId() != ST_MAN6_BALL)
return FPController::getCursorType(x, y);
} else if (!g_ngi->_inputController->isObjectHit(_currentBall)) {
return FPController::getCursorType(x, y);
@@ -1237,14 +1129,14 @@ void Sc06Controller::onMessage(const Common::String &message, const Common::Stri
grit->startMovement(MV_GRT6_BREAK, 0, -1);
return;
}
- setCurFrame(grit, 9, true);
+ grit->setCurFrame(9, true);
} else {
grit = _scene->findAniObjectById(ANI_GRIT1, 0);
if (!grit->_movement) {
grit->startMovement(MV_GRIT1_FALL, 0, -1);
return;
}
- setCurFrame(grit, 7, true);
+ grit->setCurFrame(7, true);
}
}
Commit: 70d40598f89cb64c01f683605748c0ab512c0e97
https://github.com/scummvm/scummvm/commit/70d40598f89cb64c01f683605748c0ab512c0e97
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 8 controller uses the shared helpers
Changed paths:
engines/ngi/fullpipe/sc08controller.cpp
diff --git a/engines/ngi/fullpipe/sc08controller.cpp b/engines/ngi/fullpipe/sc08controller.cpp
index 3351ab4b190..7f61a1ef884 100644
--- a/engines/ngi/fullpipe/sc08controller.cpp
+++ b/engines/ngi/fullpipe/sc08controller.cpp
@@ -36,6 +36,7 @@
#include "ngi/xmlnode.h"
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc08controller.h"
@@ -46,72 +47,6 @@ namespace NGI {
namespace {
-void warnOnce(const char *what) {
- static Common::HashMap<Common::String, bool> reported;
- if (!reported.contains(what)) {
- reported[what] = true;
- warning("STUB/untested: %s", what);
- }
-}
-
-// CAniObject +164: the statics of the object (0 when it has none)
-int staticsId(const AniObject *ani) {
- return ani->_statics ? ani->_statics->_staticsId : 0;
-}
-
-// CAniObject::GetCurFrame (F112C): the frame of the running movement, -1 when the object does not move
-int curFrame(const AniObject *ani) {
- return ani->_movement ? ani->_movement->_curFrame : -1;
-}
-
-// CAniObject::SetCurFrame (F0C76): the movement of the object goes to the frame (the position is the one of the movement, as AniObject::startMovement does it).
-// The last argument of the original (stored in CMovement +63) is not modelled.
-void setCurFrame(AniObject *ani, int frame) {
- if (ani->_movement) {
- ani->_movement->setCurFrame(frame);
- ani->setPos(ani->_movement->_x, ani->_movement->_y);
- }
-}
-
-// CBaseSettings::SetSaving (the saves are blocked while the arcade runs)
-void setSaving(bool enable) {
- warnOnce("CBaseSettings::SetSaving (the saves are not blocked)");
-}
-
-// CHintManager::ShowHint, HideHint and SetHideCondition (the hint of the arcade)
-void showHint() {
- warnOnce("CHintManager::ShowHint (the hint of the arcade is not shown)");
-}
-
-void hideHint() {
- warnOnce("CHintManager::HideHint (the hint of the arcade is not shown)");
-}
-
-void setHideHintCondition() {
- warnOnce("CHintManager::SetHideCondition (the hint of the arcade is not shown)");
-}
-
-// CScene::StopAllQueues (120C40): the queues of the scene stop, then CInteractionController::StoppedAllInteractions
-void stopAllQueues(Scene *scene) {
- warnOnce("CScene::StopAllQueues");
-}
-
-// CInteractionController::SetVes (106DC8): the weight of the first interaction with the name
-void setVes(int weight, const char *name) {
- warnOnce("CInteractionController::SetVes: the weights of INT_068 and INT_069 are not changed");
-}
-
-// CInteractionController::FindInteractionUnderCursor (106D94)
-Interact *findInteractionUnderCursor() {
- warnOnce("CInteractionController::FindInteractionUnderCursor");
- return nullptr;
-}
-
-// CFPController::RunInteractionWithMouse (the interaction with the name runs, the hero goes to the touch)
-void runInteractionWithMouse(const char *name, float x, float y) {
- warnOnce("CFPController::RunInteractionWithMouse");
-}
-
} // End of anonymous namespace
// CSc08Controller::CSc08Controller (16FA14)
@@ -151,7 +86,7 @@ void Sc08Controller::vmyatsControlFunc(uint32 elapsed) {
// CAniObject::GetCurFrame(_vmyats) and CVisibleObject::GetSize(_vmyats): the results are not used
const float top = hero()->getPosition().y;
int bottom = (int)(top + (float)hero()->getSize().y);
- if (staticsId(hero()) == ST_MAN8_FLYDOWN)
+ if (hero()->getStaticsId() == ST_MAN8_FLYDOWN)
bottom = (int)((float)bottom - 25.0f);
const int depth = (bottom - 697) / 10 + 2;
int frame;
@@ -161,8 +96,8 @@ void Sc08Controller::vmyatsControlFunc(uint32 elapsed) {
_manSpeed = 0;
frame = 10;
}
- if (frame != curFrame(_vmyats)) {
- setCurFrame(_vmyats, frame);
+ if (frame != _vmyats->getCurFrame()) {
+ _vmyats->setCurFrame(frame);
if (frame != 0) {
_vmyats->_flags |= 4;
if (!_vmyats->_movement)
@@ -200,13 +135,13 @@ void Sc08Controller::doManDryg() {
float centerY = center.y;
const Common::Point size = hero()->getSize();
if (!((697.0f - (centerY + (float)size.y * 0.5f)) < 150.0f)) {
- const int state = staticsId(hero());
+ const int state = hero()->getStaticsId();
if (state == ST_MAN8_FLYUP)
hero()->startMovement(MV_MAN8_DRYGUP, 0, -1);
else if (state == ST_MAN8_FLYDOWN)
hero()->startMovement(MV_MAN8_DRYGDOWN, 0, -1);
} else {
- if (staticsId(hero()) == ST_MAN8_FLYDOWN) {
+ if (hero()->getStaticsId() == ST_MAN8_FLYDOWN) {
centerY = centerY - 25.0f;
hero()->setCenter(Common::Point(center.x, (int)centerY));
}
@@ -491,7 +426,7 @@ void Sc08Controller::countManFlight(uint32 elapsed) {
const bool moving = man->_movement != nullptr;
if (moving || centerY < 660.0f || fabsf(_manSpeed) > 0.2f) {
if (_manSpeed >= 0.0f && !moving) {
- if (staticsId(man) == ST_MAN8_HANDSUP)
+ if (man->getStaticsId() == ST_MAN8_HANDSUP)
man->startMovement(MV_MAN8_HANDSDOWN, 0, -1);
else
man->setStatic(ST_MAN8_FLYDOWN);
@@ -571,14 +506,14 @@ void Sc08Controller::onShow() {
} else if (tummyState == g_ngi->getStateValue(sO_TummyTrampie, sO_IsDrinking)) {
_batuta->moveToStatic(ST_BTT_NOSPOON);
_clock->startMovement(MV_CLK8_GO, 0, -1);
- setCurFrame(_clock, 3);
+ _clock->setCurFrame(3);
} else if (tummyState == g_ngi->getStateValue(sO_TummyTrampie, sO_IsScratchingBelly)) {
_batuta->moveToStatic(ST_BTT_CHESHET);
_clock->startMovement(MV_CLK8_GO, 0, -1);
- setCurFrame(_clock, 8);
+ _clock->setCurFrame(8);
} else if (tummyState == g_ngi->getStateValue(sO_TummyTrampie, sO_IsSleeping)) {
_clock->startMovement(MV_CLK8_GO, 0, -1);
- setCurFrame(_clock, 2);
+ _clock->setCurFrame(2);
if (lock)
lock->_flags |= 0x20000000;
_snoringTimer = 1;
@@ -684,11 +619,11 @@ void Sc08Controller::onUpdate(uint32 elapsed) {
}
} else {
AniObject *man = hero();
- if (man->_movement && man->_movement->_id == MV_MAN_TOLADDERD && curFrame(man) == 8) {
+ if (man->_movement && man->_movement->_id == MV_MAN_TOLADDERD && man->getCurFrame() == 8) {
man->_z = 2;
} else {
man = hero();
- if (man->_movement && man->_movement->_id == MV_MAN_FROMLADDERUP && curFrame(man) == 13)
+ if (man->_movement && man->_movement->_id == MV_MAN_FROMLADDERUP && man->getCurFrame() == 13)
man->_z = 20;
}
switchLadder(_follow->getCenter().y > 520.0f);
@@ -756,7 +691,7 @@ void Sc08Controller::onMessage(const Common::String &message, const Common::Stri
startBatut();
} else if (message == "MSG_CLOSEUPSELL") {
if (_upsellShown) {
- stopAllQueues(_scene);
+ _scene->stopAllQueues();
endBatut();
_scene->_y = 352;
hero()->setStatic(ST_MAN_RIGHT);
@@ -799,11 +734,11 @@ void Sc08Controller::onMessage(const Common::String &message, const Common::Stri
} else if (message == "MSG_TOLADDER" || message == "MSG_FROMLADDER") {
// CUtils::SetVes("INT_068", "INT_069", message)
if (message == "MSG_TOLADDER") {
- setVes(1, "INT_068");
- setVes(5, "INT_069");
+ setInteractionWeight("INT_068", 1);
+ setInteractionWeight("INT_069", 5);
} else {
- setVes(5, "INT_068");
- setVes(1, "INT_069");
+ setInteractionWeight("INT_068", 5);
+ setInteractionWeight("INT_069", 1);
}
} else if (message == "MSG_HIDE_BOX") {
AniObject *box = _scene->findAniObjectById(ANI_SC8_BOX, 0);
@@ -817,7 +752,7 @@ void Sc08Controller::onMessage(const Common::String &message, const Common::Stri
if (queueStarted) {
AniObject *grit = _scene->findAniObjectById(ANI_GRIT2, 0);
if (grit->_movement)
- setCurFrame(grit, 9);
+ grit->setCurFrame(9);
else
grit->startMovement(MV_GRIT2_FALL, 0, -1);
}
Commit: 8463a0473c905e1dd456f998634089842314c802
https://github.com/scummvm/scummvm/commit/8463a0473c905e1dd456f998634089842314c802
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 9 controller uses the shared helpers
Changed paths:
engines/ngi/fullpipe/sc09controller.cpp
diff --git a/engines/ngi/fullpipe/sc09controller.cpp b/engines/ngi/fullpipe/sc09controller.cpp
index 9f0ed62c851..685b1ff78e5 100644
--- a/engines/ngi/fullpipe/sc09controller.cpp
+++ b/engines/ngi/fullpipe/sc09controller.cpp
@@ -36,6 +36,7 @@
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/objectnames.h"
@@ -45,32 +46,8 @@
namespace NGI {
-// The statics of the first lift button of Android (ST_LBN_1N of obj.h): constants.h has the number of the Windows game (2753)
-static const int kLiftButton1Normal = 23070;
-
namespace {
-void warnOnce(const char *what) {
- static Common::HashMap<Common::String, bool> reported;
- if (!reported.contains(what)) {
- reported[what] = true;
- warning("STUB/untested: %s", what);
- }
-}
-
-// CAniObject::GetCurFrame (F112C): the frame of the running movement, -1 without one
-int getCurFrame(const AniObject *ani) {
- if (ani->_movement)
- return ani->_movement->_curFrame;
- return -1;
-}
-
-// CAniObject::SetCurFrame (F0C76) of the running movement (the arguments a3, a4 of the original are not modelled by CMovement::setCurFrame)
-void setCurFrame(AniObject *ani, int frame) {
- if (ani->_movement)
- ani->_movement->setCurFrame(frame);
-}
-
// CAniObject +168: the original keeps the last started movement, here it is the running one
int movementId(const AniObject *ani) {
if (ani->_movement)
@@ -78,130 +55,6 @@ int movementId(const AniObject *ani) {
return 0;
}
-// CAniObject::MoveToStatic (F1B0C): a running movement is rewound (StopMovementToPrev), then the movements that lead from the statics of the object to the new one
-// are started one after the other (FindMovementsBeginStatic, FastStartMovement) and the last resort is SetStatic. The chain of movements is not ported.
-void moveToStatic(AniObject *ani, int staticsId) {
- if (ani->_movement)
- ani->stopMovementToPrev(true);
- if (!ani->_statics || ani->_statics->_staticsId != staticsId) {
- warnOnce("CAniObject::MoveToStatic: the chain of movements, FastStartMovement, is not ported, SetStatic is used");
- ani->setStatic(staticsId);
- }
-}
-
-// CFPController::HideAction (1490B0): every copy of the animation (from the copy number given) stops and is hidden
-void hideAction(Scene *scene, int aniId, int copyId) {
- AniObject *ani;
- do {
- ani = scene->findAniObjectById(aniId, copyId);
- if (ani) {
- ani->stopMovement();
- ani->_flags &= ~4;
- }
- copyId++;
- } while (ani);
-}
-
-// CScene::RunQueue (1225A4) with a queue that was made by the caller (a copy of the queue of the scene): the same operations as Scene::runQueueWithAni
-bool runQueueCopy(Scene *scene, MessageQueue *copy, int interruptState, AniObject *ani) {
- copy->_scene = scene;
- if (interruptState != 4)
- copy->_interruptState = interruptState;
- if (!copy->run(ani)) {
- g_ngi->_globalMessageQueueList->deleteQueueById(copy->_id);
- return false;
- }
- return true;
-}
-
-// CCommand::SetParamFloat: the engine keeps the "x" of a command in two places (the attributes of the XML and the field of the command that the handlers read)
-void setParamFloat(Command *command, const char *name, float value) {
- command->_args[name] = Common::String::format("%f", value);
- if (!strcmp(name, "x"))
- command->_x = (int)value;
-}
-
-// CMessageQueue::SetObjectCopy (10F470): every command of the queue gets the copy number (CCommand::SetObjectCopy: the parameter "copy")
-void setObjectCopy(MessageQueue *queue, int copyId) {
- for (uint i = 0; i < queue->getCount(); i++) {
- Command *command = queue->getCommandByIndex(i);
- command->_args["copy"] = Common::String::format("%d", copyId);
- command->_param = copyId;
- }
-}
-
-// a message of the queue: its name goes to the controllers (CScene::Message), its id to the scene handlers (the same as in lift.cpp)
-Command *messageCommand(const char *name) {
- uint32 id = 0;
- g_ngi->_gameProject->_objectIds.findId(name, id);
- Command *command = new Command(0, kCmdMessage, id, 0, 0, 0, 1, 0, 0, 0);
- command->_messageName = name;
- command->_excFlags |= 3;
- return command;
-}
-
-// CVisibleObject::IsOnScreenEntirely (127682): the four corners of the object are inside the part of the scene that the screen shows. The offsets of CRender are
-// +8, +12 (the margin of a screen narrower than the base, 0 here), +24 (the margin of a wider screen, the widescreen offset), +28 (0), the size of the base screen is
-// +36, +40. The rectangle is CVisibleObject::GetRect (the bounds of the texture)
-bool isOnScreenEntirely(const GameObject *object, const Scene *scene) {
- const float renderLeft = 0.0f;
- const float renderTop = 0.0f;
- const float renderOffsetX = (float)g_ngi->_wideOfs;
- const float renderOffsetY = 0.0f;
- const float renderWidth = (float)g_ngi->gameWidth();
- const float renderHeight = (float)g_ngi->_backgroundSurface.h;
- const float sceneX = (float)scene->_x;
- const float sceneY = (float)scene->_y;
-
- const float left = sceneX - (renderLeft + renderOffsetX);
- const float top = sceneY - (renderTop + renderOffsetY);
- const float right = (renderLeft + renderOffsetX) + (renderWidth + sceneX);
- const float bottom = (renderTop + renderOffsetY) + (renderHeight + sceneY);
- const Common::Rect bounds = object->getBounds();
- const float objLeft = (float)bounds.left;
- const float objTop = (float)bounds.top;
- const float objRight = (float)bounds.right;
- const float objBottom = (float)bounds.bottom;
-
- if (objLeft <= left)
- return false;
- if (objLeft >= right)
- return false;
- if (objTop <= top)
- return false;
- if (objTop >= bottom)
- return false;
- if (objRight <= left)
- return false;
- if (objRight >= right)
- return false;
- if (objBottom <= top)
- return false;
- return objBottom < bottom;
-}
-
-// CInteractionController::FindInteractionUnderCursor: not ported (the same STUB as CTutorialController::PassMouseActions)
-Interact *findInteractionUnderCursor() {
- warnOnce("CInteractionController::FindInteractionUnderCursor is not ported (CSc09Controller::OnMouseLKeyUp: INT_230 ... INT_234 are never found)");
- return nullptr;
-}
-
-// CFPController::RunInteractionWithMouse (14D5E0): not ported (the tap of FPController::onTap starts the interactions by the object, not by the name)
-void runInteractionWithMouse(const char *name, float x, float y) {
- warnOnce("CFPController::RunInteractionWithMouse is not ported (CSc09Controller::OnMouseLKeyUp: INT_230, INT_232, INT_234)");
-}
-
-// CInteractionController::FindInteraction(name) -> CInteract +24 (the queue) -> CMessageQueue +56 (GetCurCommandNum, -1 while the queue does not run)
-int interactionCommandNum(const char *name) {
- warnOnce("CInteractionController::FindInteraction by name is not ported (CSc09Controller::OnMessage MSG_BREAK_GRIT: INT_238)");
- return -1;
-}
-
-// CInteractionController::SetVes(weight, name, 0, 0): the weight of the first interaction with this name. Not ported
-void setInteractionWeight(const char *name, int weight) {
- warnOnce("CInteractionController::SetVes (the weight of an interaction) is not ported (CSc09Controller::OnMessage MSG_TOLADDER, MSG_FROMLADDER: INT_230 ... INT_234)");
-}
-
// CUtils::SetVes (14FCC8)
void setWeights(const char *first, const char *second, const Common::String &message) {
if (message == "MSG_TOLADDER") {
@@ -316,15 +169,15 @@ void Sc09Controller::updateVisuns(uint32 elapsed) {
frame = 1;
else if (frame > 38)
frame = 38;
- if (frame != getCurFrame(ani))
- setCurFrame(ani, frame);
+ if (frame != ani->getCurFrame())
+ ani->setCurFrame(frame);
} else {
if (hanger.timer != 0) {
hanger.timer -= elapsed;
if (hanger.timer <= 0) {
ani->setStatic(ST_VSN_NORMAL);
ani->startMovement(MV_VSN_CYCLE2, 0, -1);
- setCurFrame(ani, 0);
+ ani->setCurFrame(0);
hanger.timer = 0;
updateVisuns(0);
}
@@ -400,8 +253,8 @@ void Sc09Controller::doStartTiotia() {
Command *command = copy->getCommandByIndex(0);
const float sceneX = (float)_scene->_x;
if (command)
- setParamFloat(command, "x", (float)(sceneX + (float)g_ngi->gameWidth()) + 30.0f);
- runQueueCopy(_scene, copy, 3, nullptr);
+ command->setParamFloat("x", (float)(sceneX + (float)g_ngi->gameWidth()) + 30.0f);
+ _scene->runQueueObject(copy, nullptr, 3);
warnOnce("CCatalogManager::UnlockItem for ANI_TIOTIA is not ported");
}
@@ -442,7 +295,7 @@ void Sc09Controller::checkTutorial() {
} else if (!_spitter) {
// OnSceneInit is not called yet, the spitter is unknown
warnOnce("CSc09Controller::CheckTutorial: OnSceneInit has not found the spitter yet");
- } else if (isOnScreenEntirely(_spitter, _scene)) {
+ } else if (_spitter->isOnScreenEntirely(_scene)) {
_tutorial = "ARCADE_TUTORIAL_09";
}
if (previous != _tutorial)
@@ -513,8 +366,8 @@ void Sc09Controller::doExplodeBall(AniObject *ball) {
MessageQueue *queue = _scene->findMessageQueue(QU_SC9_BALLEXPLODE);
if (queue) {
MessageQueue *copy = new MessageQueue(queue, 0, 0);
- setObjectCopy(copy, ball->_copyId);
- runQueueCopy(_scene, copy, 4, nullptr);
+ copy->setObjectCopyAll(ball->_copyId);
+ _scene->runQueueObject(copy, nullptr, 4);
}
_sceneBalls.push_back(ball);
}
@@ -544,12 +397,12 @@ void Sc09Controller::startEating(AniObject *ball) {
_eatingBall = ball;
if (_gulper) {
_gulper->stopMovement();
- moveToStatic(_gulper, ST_GLT_SIT);
+ _gulper->moveToStaticChain(ST_GLT_SIT);
warnOnce("CBehaviorController::OnSetQueue is not ported (CSc09Controller::StartEating)");
MessageQueue *queue = _scene->findMessageQueue(QU_SC9_EATBALL);
if (queue) {
MessageQueue *copy = new MessageQueue(queue, 0, 0);
- runQueueCopy(_scene, copy, 2, nullptr);
+ _scene->runQueueObject(copy, nullptr, 2);
}
}
}
@@ -583,7 +436,7 @@ void Sc09Controller::doFlyAway() {
warnOnce("CAchievementsManager::AddActivatingCounter for ACHIEVEMENT_ARCADE_9 is not ported");
_flyAway = false;
_gulper->stopMovement();
- moveToStatic(_gulper, ST_GLT_SIT);
+ _gulper->moveToStaticChain(ST_GLT_SIT);
_gulper->startMovement(MV_GLT_FLYAWAY, 0, -1);
g_ngi->setState(sO_Jug, g_ngi->getStateValue(sO_Jug, sO_Unblocked));
g_ngi->setState(sO_RightStairs_9, g_ngi->getStateValue(sO_RightStairs_9, sO_IsOpened));
@@ -633,7 +486,7 @@ void Sc09Controller::skipArcade() {
_flyAway = false;
if (_gulper->_flags & 4) {
_gulper->stopMovement();
- moveToStatic(_gulper, ST_GLT_SIT);
+ _gulper->moveToStaticChain(ST_GLT_SIT);
_gulper->startMovement(MV_GLT_FLYAWAY, 0, -1);
}
g_ngi->setState(sO_Jug, g_ngi->getStateValue(sO_Jug, sO_Unblocked));
@@ -662,7 +515,7 @@ void Sc09Controller::countBallFlight(uint32 elapsed) {
if (_gulperPresent || x <= 1600.0f) {
for (uint i = 0; i < count; i++) {
if (_hangers[i].ani->hit((int)x, (int)y)) {
- const int frame = getCurFrame(_hangers[i].ani);
+ const int frame = _hangers[i].ani->getCurFrame();
if (frame > 13 && frame <= 26) {
explode = true;
break;
@@ -691,7 +544,7 @@ void Sc09Controller::doStartShoot() {
if (fabsf(targetX - (float)hero()->getCenter().x) > 3.0f || fabsf(targetY - (float)hero()->getCenter().y) > 3.0f) {
MessageQueue *queue = mctlStartMove((int)targetX, (int)targetY, true, ST_MAN_UP, false);
if (queue)
- queue->addCommandToEnd(messageCommand("MSG_SC9_PLVCLICK"));
+ queue->addCommandToEnd(messageCommand("MSG_SC9_PLVCLICK", 1, 3));
} else {
if (!hero()->_movement) {
_spitter->setStatic(ST_PLV_SIT);
@@ -782,7 +635,7 @@ void Sc09Controller::onShow() {
AniObject *original = _scene->findAniObjectById(ANI_VISUNCHIK, 0);
original->_hitAlpha = 128;
- moveToStatic(original, ST_VSN_NORMAL);
+ original->moveToStaticChain(ST_VSN_NORMAL);
Visunchik first;
first.ani = original;
first.phase = 0;
@@ -828,7 +681,7 @@ void Sc09Controller::onShow() {
_eggs[1] = eggs ? eggs->getSubVarByName(sO_Egg2) : nullptr;
_eggs[2] = eggs ? eggs->getSubVarByName(sO_Egg3) : nullptr;
g_ngi->_exitManager->setExitState(PIC_SC9_URTRUBA, 0);
- g_ngi->lift().enableButton(sO_Level1, kLiftButton1Normal);
+ g_ngi->lift().enableButton(sO_Level1, projectId("ST_LBN_1N"));
_shootIdle = 0;
g_ngi->_exitManager->setExitAngle(PIC_SC9_LADDER_R, 0.0f);
}
@@ -987,7 +840,7 @@ bool Sc09Controller::onMouseLKeyUp(uint32 id, float x, float y) {
if ((uint16)hit->_id == ANI_VISUNCHIK) {
for (uint i = 0; i < _hangers.size(); i++) {
if (_hangers[i].ani == hit) {
- if (getCurFrame(_hangers[i].ani) == 18)
+ if (_hangers[i].ani->getCurFrame() == 18)
_hangers[i].ani->setStatic(ST_VSN_RIGHT);
}
}
@@ -1091,7 +944,7 @@ void Sc09Controller::onMessage(const Common::String &message, const Common::Stri
AniObject *grit = _scene->findAniObjectById(ANI_GRIT_9, 0);
if (grit) {
if (grit->_movement)
- setCurFrame(grit, 9);
+ grit->setCurFrame(9);
else
grit->startMovement(MV_GRT9_FALL, 0, -1);
}
Commit: f36d4b907ee3c6e4c745828f1bf48827ff59b51e
https://github.com/scummvm/scummvm/commit/f36d4b907ee3c6e4c745828f1bf48827ff59b51e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 11 controller uses the shared helpers
Changed paths:
engines/ngi/fullpipe/sc11controller.cpp
diff --git a/engines/ngi/fullpipe/sc11controller.cpp b/engines/ngi/fullpipe/sc11controller.cpp
index 23232c6d871..36c5277042a 100644
--- a/engines/ngi/fullpipe/sc11controller.cpp
+++ b/engines/ngi/fullpipe/sc11controller.cpp
@@ -39,6 +39,7 @@
#include "ngi/statics.h"
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc11controller.h"
@@ -59,34 +60,11 @@ const double kLoseAngle = 1.8325957145940441;
// the rotation of an object that hangs straight down (the float 1.5707964f of the code)
const float kRotationDown = 1.5707964f;
-// the glue of what is not ported: one warning for every place
-void stubOnce(const char *what) {
- static Common::HashMap<Common::String, bool> reported;
- if (!reported.contains(what)) {
- reported[what] = true;
- warning("STUB/untested: %s", what);
- }
-}
-
// CRender +8 + +24: the widescreen margin (+8 is 0 here)
float renderMargin() {
return (float)g_ngi->_wideOfs;
}
-// CCommand(MESSAGE) with the parameters "msg" and "param" as the XML loader makes it
-Command *messageCommand(const char *name, const char *param = nullptr) {
- uint32 id = 0;
- g_ngi->_gameProject->_objectIds.findId(name, id);
- Command *command = new Command(0, kCmdMessage, id, 0, 0, 0, 0, 0, 0, 0);
- command->_messageName = name;
- command->_args["msg"] = name;
- if (param) {
- command->_args["param"] = param;
- }
- command->_excFlags = 2;
- return command;
-}
-
// CInteractionController::FindInteraction(name, 0, 0): looked up by objects, the name is checked
Interact *findInteractionByName(const char *name, int objectId) {
Interact *interaction = getGameLoaderInteractionController()->findInteraction(objectId, ANI_MAN, 0);
@@ -96,17 +74,6 @@ Interact *findInteractionByName(const char *name, int objectId) {
return nullptr;
}
-// CScene::RunQueue(scene, queue, state, 0): the scene takes the queue (CScene::AddQueue) and runs it, the state 4 keeps the one of the queue
-void runQueueObject(Scene *scene, MessageQueue *queue, int state) {
- queue->_scene = scene;
- if (state != 4) {
- queue->_interruptState = state;
- }
- if (!queue->run(nullptr)) {
- delete queue;
- }
-}
-
// sc_11_settings.xml (CSc11Controller::ReadSettingsXml)
class Scene11SettingsParser : public Common::XMLParser {
public:
@@ -416,7 +383,7 @@ void Sc11Controller::doPutBoot() {
// CSc11Controller::HideButtons (174CE8): the arcade buttons slide out (GUI positions are integers)
void Sc11Controller::hideButtons(uint32 elapsed) {
- stubOnce("CSc11Controller::HideButtons/UpdateButtons: the positions of GuiElement are integers, the original has floats (the steps of 0.15 per millisecond are truncated)");
+ warnOnce("CSc11Controller::HideButtons/UpdateButtons: the positions of GuiElement are integers, the original has floats (the steps of 0.15 per millisecond are truncated)");
if (_leftRightButton->_visible) {
const float width = (float)_leftRightButton->_size.x;
float x = (float)_leftRightButton->_pos.x;
@@ -443,7 +410,7 @@ void Sc11Controller::updateButtons(uint32 elapsed) {
hideButtons(elapsed);
return;
}
- stubOnce("CSc11Controller::HideButtons/UpdateButtons: the positions of GuiElement are integers, the original has floats (the steps of 0.15 per millisecond are truncated)");
+ warnOnce("CSc11Controller::HideButtons/UpdateButtons: the positions of GuiElement are integers, the original has floats (the steps of 0.15 per millisecond are truncated)");
if (_leftRightButton->_visible) {
const float x = (float)_leftRightButton->_pos.x;
const float limit = 50.0f - renderMargin();
@@ -499,8 +466,8 @@ void Sc11Controller::doRetire() {
hero()->setPosition(Common::Point(685, 373));
hero()->startMovement(MV_MAN11_JUMPFROMSWING, 0, -1);
_follow = hero();
- stubOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
- stubOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
+ warnOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
+ warnOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
}
// CSc11Controller::DoWinArcade (175128): the key W of the original; SC_5 through TrubaUp
@@ -509,8 +476,8 @@ void Sc11Controller::doWinArcade() {
_arcadeRunning = false;
leaveSwing();
g_ngi->_gameLoader->setScene(SC_5, TrubaUp);
- stubOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
- stubOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
+ warnOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
+ warnOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
}
}
@@ -522,7 +489,7 @@ void Sc11Controller::startArcade() {
arcade.init(380.0f, -100.0f, 64.0f, 0.0f, 1, 0, true);
arcade.scrollIn();
}
- stubOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
+ warnOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
_arcadeRunning = true;
_scene->_motionController->deactivate();
getGameLoaderInteractionController()->_enabled = false;
@@ -540,7 +507,7 @@ void Sc11Controller::startArcade() {
_swingMan->_rotation = kRotationDown;
_targetX = (1150.0f - ((float)_scene->_x + (float)g_ngi->gameWidth())) + renderMargin();
g_ngi->_aniHandler->detachAllObjects();
- stubOnce("CHintManager::ShowHint / SetHideCondition (CSc11Controller::StartArcade): the hints are not ported");
+ warnOnce("CHintManager::ShowHint / SetHideCondition (CSc11Controller::StartArcade): the hints are not ported");
}
// CSc11Controller::DoJumpToTruba (175308): the man jumps over the pipe, then SC_5
@@ -578,7 +545,7 @@ void Sc11Controller::doJumpToTruba() {
AniObject *biglu = tubeScene ? tubeScene->findAniObjectById(ANI_BIGLUK, 0) : nullptr;
if (biglu && biglu->_statics->_staticsId == ST_BLK_OPEN) {
if (g_ngi->getStateId(sO_WeirdWacko) == g_ngi->getStateValue(sO_WeirdWacko, sO_WithPlunger)) {
- queue->addCommandToEnd(messageCommand("MSG_SHOW_UPSELL", "2"));
+ queue->addCommandToEnd(messageCommand("MSG_SHOW_UPSELL", 0, 2, "2"));
}
}
Command *pause = new Command(0, kCmdPause, 36, 0, 0, 0, 1, 0, 0, 0);
@@ -590,7 +557,7 @@ void Sc11Controller::doJumpToTruba() {
setScene->_args["entr"] = "TrubaUp";
setScene->_excFlags = 2;
queue->addCommandToEnd(setScene);
- runQueueObject(_scene, queue, 4);
+ _scene->runQueueObject(queue, nullptr, 4);
if (g_ngi->getStateId(sO_Swingie) == g_ngi->getStateValue(sO_Swingie, sO_IsStandingInCorner)) {
g_ngi->setState(sO_Swingie, g_ngi->getStateValue(sO_Swingie, sO_IsSitting));
}
@@ -611,10 +578,10 @@ void Sc11Controller::skipArcade() {
doJumpToTruba();
_arcadeRunning = false;
_hint->_flags &= ~4;
- stubOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
+ warnOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
_scene->_behaviorController->disableAllMusic();
- stubOnce("CBehaviorController::EnableSound (CSc11Controller): SND_MUS_7 / SND_MUS_11 are not switched on");
- stubOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
+ warnOnce("CBehaviorController::EnableSound (CSc11Controller): SND_MUS_7 / SND_MUS_11 are not switched on");
+ warnOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
} else {
_skipArcade = true;
}
@@ -647,7 +614,7 @@ void Sc11Controller::doBumpTruba(double angle) {
queue->_interruptState = 2;
_crySound = SND_11_022;
queue->addCommandToEnd(messageCommand("MSG_SC11_RESTARTMAN"));
- runQueueObject(_scene, queue, 4);
+ _scene->runQueueObject(queue, nullptr, 4);
}
}
@@ -683,7 +650,7 @@ void Sc11Controller::doMissTruba(double angle) {
queue->_interruptState = 2;
_crySound = SND_11_022;
queue->addCommandToEnd(messageCommand("MSG_SC11_RESTARTMAN"));
- runQueueObject(_scene, queue, 4);
+ _scene->runQueueObject(queue, nullptr, 4);
}
}
@@ -707,7 +674,7 @@ void Sc11Controller::onRButtonDown() {
}
if (angle < _minAngle || angle > _maxAngle || _swingSpeed > (double)_minSpeed) {
- stubOnce("CSc11Controller::OnRButtonDown: CAchievementsManager::BlockActivatingCounter for ACHIEVEMENT_ARCADE_11, the achievements are not ported");
+ warnOnce("CSc11Controller::OnRButtonDown: CAchievementsManager::BlockActivatingCounter for ACHIEVEMENT_ARCADE_11, the achievements are not ported");
if (angle >= _minAngle || _swingSpeed < (double)_minSpeed) {
doMissTruba((double)(float)(angle / _minAngle) * _swingSpeed / (double)_minSpeed);
} else {
@@ -715,17 +682,17 @@ void Sc11Controller::onRButtonDown() {
}
g_ngi->arcadeInterface().scrollOut();
} else {
- stubOnce("CSc11Controller::OnRButtonDown: CAchievementsManager::AddActivatingCounter for ACHIEVEMENT_ARCADE_11, the achievements are not ported");
+ warnOnce("CSc11Controller::OnRButtonDown: CAchievementsManager::AddActivatingCounter for ACHIEVEMENT_ARCADE_11, the achievements are not ported");
g_ngi->arcadeInterface().incCounter();
doJumpToTruba();
g_ngi->arcadeInterface().incCounter();
}
_arcadeRunning = false;
_hint->_flags &= ~4;
- stubOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
+ warnOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
_scene->_behaviorController->disableAllMusic();
- stubOnce("CBehaviorController::EnableSound (CSc11Controller): SND_MUS_7 / SND_MUS_11 are not switched on");
- stubOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
+ warnOnce("CBehaviorController::EnableSound (CSc11Controller): SND_MUS_7 / SND_MUS_11 are not switched on");
+ warnOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
// the analytics events of a lost arcade are not ported
}
@@ -889,7 +856,7 @@ void Sc11Controller::onShow() {
if (g_ngi->getStateId(sO_DudeHasJumped) == g_ngi->getStateValue(sO_DudeHasJumped, sO_Yes)) {
_scene->_behaviorController->disableAllMusic();
- stubOnce("CBehaviorController::EnableSound (CSc11Controller): SND_MUS_7 / SND_MUS_11 are not switched on");
+ warnOnce("CBehaviorController::EnableSound (CSc11Controller): SND_MUS_7 / SND_MUS_11 are not switched on");
}
if (_scene->_currentEntranceId == 0) {
@@ -912,14 +879,14 @@ void Sc11Controller::onShow() {
void Sc11Controller::onHide() {
const bool logic = controllerRunsSceneLogic();
if (logic) {
- stubOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
+ warnOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
g_ngi->arcadeInterface().scrollOut();
}
FPController::onHide();
if (logic) {
g_ngi->_exitManager->resetExitIntersect(PIC_SC11_LTRUBA, false);
- stubOnce("CAniObject::UnloadMovement / CPreloadManager::OnUnloadMove (CSc11Controller::OnHide): MV_KCH_MOVE2 is not unloaded");
- stubOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
+ warnOnce("CAniObject::UnloadMovement / CPreloadManager::OnUnloadMove (CSc11Controller::OnHide): MV_KCH_MOVE2 is not unloaded");
+ warnOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
}
}
@@ -1130,7 +1097,7 @@ void Sc11Controller::updateScroll() {
bool smooth = _arcadeRunning;
if (!smooth) {
// INT_071 (the man jumps to the swing) runs while its current command (+56) is not -1
- stubOnce("CSc11Controller::UpdateScroll: the running state of the queue of the interaction INT_071 (CMessageQueue +56) is not known, it counts as not running");
+ warnOnce("CSc11Controller::UpdateScroll: the running state of the queue of the interaction INT_071 (CMessageQueue +56) is not known, it counts as not running");
}
_smooth = smooth;
if (_follow) {
Commit: d026f6031f430467458892da1c7510c187e72ee9
https://github.com/scummvm/scummvm/commit/d026f6031f430467458892da1c7510c187e72ee9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 14 controller uses the shared helpers
Changed paths:
engines/ngi/fullpipe/sc14controller.cpp
diff --git a/engines/ngi/fullpipe/sc14controller.cpp b/engines/ngi/fullpipe/sc14controller.cpp
index 0ac50659c10..47d69fab014 100644
--- a/engines/ngi/fullpipe/sc14controller.cpp
+++ b/engines/ngi/fullpipe/sc14controller.cpp
@@ -35,6 +35,7 @@
#include "ngi/statics.h"
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc14controller.h"
@@ -45,97 +46,11 @@ namespace NGI {
namespace {
-void warnOnce(const char *what) {
- static Common::HashMap<Common::String, bool> reported;
- if (!reported.contains(what)) {
- reported[what] = true;
- warning("STUB/untested: %s", what);
- }
-}
-
-// CCommand(START_MOVEMENT, wait = 1) with the parameters aniId, moveId and copy
-Command *movementCommand(int aniId, int movementId, int copyId = 0) {
- Command *command = new Command(aniId, kCmdStartMovement, movementId, 0, 0, 0, 1, 0, 0, 0);
- command->_param = copyId;
- command->_excFlags |= 2;
- return command;
-}
-
-// CCommand(PAUSE, wait = 1) with the parameter delay (milliseconds)
-Command *pauseCommand(int delay) {
- Command *command = new Command(0, kCmdPause, delay, 0, 0, 0, 1, 0, 0, 0);
- command->_excFlags |= 2;
- return command;
-}
-
-// CCommand(HIDE) with the parameters objId and copy
-Command *hideCommand(int objectId, int copyId) {
- Command *command = new Command(objectId, kCmdHide, 0, 0, 0, 0, 0, 0, 0, 0);
- command->_param = copyId;
- command->_excFlags |= 2;
- return command;
-}
-
-// CCommand(MESSAGE) with the parameter msg: its name goes to the controllers (CScene::Message), its id to the scene handlers
-Command *messageCommand(const char *name) {
- uint32 id = 0;
- g_ngi->_gameProject->_objectIds.findId(name, id);
- Command *command = new Command(0, kCmdMessage, id, 0, 0, 0, 0, 0, 0, 0);
- command->_messageName = name;
- command->_excFlags |= 2;
- return command;
-}
-
-// CScene::RunQueueWithAni(scene, queue, ani, interruptState): the object gets the queue (CVisibleObject::SetQueue), the queue runs
-void runQueueWithAni(MessageQueue *queue, AniObject *ani, int interruptState) {
- queue->_interruptState = interruptState;
- if (!queue->run(ani))
- delete queue;
-}
-
-// CAniObject::SetStatic(statics, mirror): the mirror flag of the original (+64) is the bit 8 of the flags here
-void setStaticMirror(AniObject *ani, int staticsId, bool mirror) {
- ani->setStatic(staticsId);
- if (mirror)
- ani->_flags |= 8;
- else
- ani->_flags &= ~8;
-}
-
-// CAniObject::MoveToStatic: an instant chain of the linked movements in the original, SetStatic in this engine (docs/android-support.md)
-void moveToStatic(AniObject *ani, int staticsId) {
- ani->setStatic(staticsId);
-}
-
-// CAniObject::GetCurFrame: -1 without a movement
-int getCurFrame(const AniObject *ani) {
- return ani->_movement ? ani->_movement->_curFrame : -1;
-}
-
-// CAniObject::SetCurFrame(frame, a3, a4): a running movement goes to the frame. a3 and a4 of the original (the flags of CMovement::SetCurFrame) are not modelled.
-void setCurFrame(AniObject *ani, int frame) {
- if (ani->_movement)
- ani->_movement->setCurFrame(frame);
-}
-
// CMessageQueue::Stop(queue, 0): the engine has no counterpart (the queue is not stopped)
void stopQueue(MessageQueue *) {
warnOnce("CMessageQueue::Stop: the queue is not stopped (CSc14Controller::DoWinArcade, CSc14Controller::DoManSurrender)");
}
-// CFPController::HideAction: the copies of the object from the one given on are stopped and hidden, until a copy is missing
-void hideAction(Scene *scene, int objectId, int copyId) {
- AniObject *ani;
- do {
- ani = scene->findAniObjectById(objectId, copyId);
- if (ani) {
- ani->stopMovement();
- ani->_flags &= ~4;
- }
- copyId++;
- } while (ani);
-}
-
// CInteractionController::FindInteraction(scene, objectId, -1) and CInteract::Run(scene): the engine finds the interaction with the object, it has no
// CInteract::Run (handleObjectInteraction also walks the hero, which Run does not do), so it is not run. True when the interaction was found.
bool runInteraction(int objectId) {
@@ -152,38 +67,6 @@ bool isInteractionQueueRunning(const char *) {
return false;
}
-// CBaseSettings::SetSaving (the saving is switched off while the arcade runs)
-void setSaving(bool) {
- warnOnce("CBaseSettings::SetSaving (CSc14Controller)");
-}
-
-// CHintManager::ShowHint / HideHint / SetHideCondition
-void showHint() {
- warnOnce("CHintManager::ShowHint (CSc14Controller)");
-}
-
-void hideHint() {
- warnOnce("CHintManager::HideHint (CSc14Controller)");
-}
-
-void setHintHideCondition() {
- warnOnce("CHintManager::SetHideCondition (CSc14Controller)");
-}
-
-// CBehaviorController::EnableSound(soundId, enable)
-void enableSound(int, bool) {
- warnOnce("CBehaviorController::EnableSound (CSc14Controller::OnShow)");
-}
-
-// CAchievementsManager::BlockActivatingCounter / AddActivatingCounter ("ACHIEVEMENT_ARCADE_14", 100)
-void blockActivatingCounter() {
- warnOnce("CAchievementsManager::BlockActivatingCounter (CSc14Controller::DoManSurrender)");
-}
-
-void addActivatingCounter() {
- warnOnce("CAchievementsManager::AddActivatingCounter (CSc14Controller::DoGrandmaHit)");
-}
-
// sc_14_settings.xml (CSc14Controller::ReadSettingsXml)
class Scene14SettingsParser : public Common::XMLParser {
public:
@@ -270,8 +153,8 @@ void Sc14Controller::manNextFunc(uint32 elapsed) {
const float counter = (float)counted;
if (counter > (float)(_manFrameDelayK * 83.0f)) {
_manFrameElapsed = (uint32)(float)(counter - (float)(_manFrameDelayK * 83.0f));
- const int frame = getCurFrame(hero());
- setCurFrame(hero(), frame + (!_manKicking ? 1 : 0));
+ const int frame = hero()->getCurFrame();
+ hero()->setCurFrame(frame + (!_manKicking ? 1 : 0));
}
}
@@ -333,7 +216,7 @@ void Sc14Controller::doShowBallFly() {
_ballX = x + 1.0f;
_ballY = y + deltaY;
_flyingBall->_flags |= 4;
- setStaticMirror(_flyingBall, ST_BAL14_MAIN, false);
+ _flyingBall->setStatic(ST_BAL14_MAIN, false);
_flyingBall->setCenter(Common::Point((int)_ballX, (int)_ballY));
_flyingBall->_z = 5;
_flyingBall->startMovement(MV_BAL14_SPIN, 0, -1);
@@ -347,7 +230,7 @@ void Sc14Controller::doShowBallFallgrandma2() {
const float y = _grandmaY + 35.0f;
_flyingBall->_flags |= 4;
_flyingBall->setCenter(Common::Point((int)x, (int)y));
- setStaticMirror(_flyingBall, ST_BAL14_MAIN, false);
+ _flyingBall->setStatic(ST_BAL14_MAIN, false);
_flyingBall->_z = 27;
_pink = _flyingBall;
_flyingBall = nullptr;
@@ -358,7 +241,7 @@ void Sc14Controller::doShowBallFallgrandma2() {
void Sc14Controller::doShowBallLast() {
if (_pink) {
_pink->_flags |= 4;
- setStaticMirror(_pink, ST_BAL14_MAIN, false);
+ _pink->setStatic(ST_BAL14_MAIN, false);
_pink->setCenter(Common::Point(693, 491));
_pink->_z = 27;
}
@@ -402,7 +285,7 @@ void Sc14Controller::startDragging() {
_dragCursorX = cursor->_hotSceneX;
_dragCursorY = cursor->_hotSceneY;
_manFrameTimer = true;
- setStaticMirror(hero(), ST_MAN_RIGHT, true);
+ hero()->setStatic(ST_MAN_RIGHT, true);
hero()->startMovement(MV_MAN14_DECLINE, 0, -1);
Movement *movement = hero()->getMovement(MV_MAN14_DECLINE);
if (movement)
@@ -436,7 +319,7 @@ void Sc14Controller::doWinArcade() {
if (!_arcadeRunning)
return;
if (_manKicking) {
- setStaticMirror(hero(), ST_MAN_RIGHT, true);
+ hero()->setStatic(ST_MAN_RIGHT, true);
_manKicking = false;
}
if (_flyingBall) {
@@ -453,7 +336,7 @@ void Sc14Controller::doWinArcade() {
if (grandmaQueue)
stopQueue(grandmaQueue);
stopQueue(_scene->findMessageQueue(QU_SC14_STARTARCADE));
- setStaticMirror(_grandma, ST_GMA_SIT, false);
+ _grandma->setStatic(ST_GMA_SIT, false);
_grandma->_flags &= ~4;
g_ngi->_taskManager->deactivateTask("KICK_GRANDMA_SC14");
}
@@ -471,7 +354,7 @@ void Sc14Controller::startArcade() {
_arcadeRunning = true;
_manCanKick = true;
if (!hero()->_movement) {
- setStaticMirror(hero(), ST_MAN_RIGHT, true);
+ hero()->setStatic(ST_MAN_RIGHT, true);
hero()->setCenter(Common::Point(1237, 451));
hero()->_z = 19;
}
@@ -492,25 +375,25 @@ bool Sc14Controller::onLButtonUp() {
if (!hero()->_movement)
return false;
- setCurFrame(hero(), 11);
- _kickFrame = getCurFrame(hero());
+ hero()->setCurFrame(11);
+ _kickFrame = hero()->getCurFrame();
// analytics total_moves_ANI_GRANDMA: not ported
stopDragging();
if (_flyingBall && (float)(_manX - (float)_flyingBall->getPosition().x) < _kickMaxDx) {
// analytics first_move_ANI_GRANDMA = 1: not ported
hero()->stopMovement();
- moveToStatic(hero(), ST_MAN14_KICK);
+ hero()->moveToStaticChain(ST_MAN14_KICK);
hero()->startMovement(MV_MAN14_KICK, 0, -1);
_ballFlying = false;
_flyingBall->stopMovement();
_flyingBall->_flags &= ~4;
if (_hitsLeft == 1)
g_ngi->arcadeInterface().scrollOut();
- setHintHideCondition();
+ setHideHintCondition();
} else {
// analytics first_move_ANI_GRANDMA = 0, failcount_ANI_GRANDMA: not ported
hero()->stopMovement();
- moveToStatic(hero(), ST_MAN14_KICK);
+ hero()->moveToStaticChain(ST_MAN14_KICK);
hero()->startMovement(MV_MAN14_KICKAIR, 0, -1);
}
return true;
@@ -524,7 +407,7 @@ void Sc14Controller::doManSurrender() {
_arcadeRunning = false;
if (hero()->_movement)
hero()->stopMovement();
- setStaticMirror(_grandma, ST_GMA_SIT, false);
+ _grandma->setStatic(ST_GMA_SIT, false);
_scene->runQueue(QU_SC14_ENDARCADE, 2);
getGameLoaderInteractionController()->disable();
hideHint();
@@ -534,12 +417,12 @@ void Sc14Controller::doManSurrender() {
// CSc14Controller::DoGrandmaShoot (179374): the grandma throws a ball after 30 ms
void Sc14Controller::doGrandmaShoot() {
- setStaticMirror(_grandma, ST_GMA_SIT, false);
- setStaticMirror(_grandma, ST_GMA_SIT, false);
+ _grandma->setStatic(ST_GMA_SIT, false);
+ _grandma->setStatic(ST_GMA_SIT, false);
MessageQueue *queue = new MessageQueue(_scene, true, 1);
queue->addCommandToEnd(pauseCommand(30));
queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_THROW));
- runQueueWithAni(queue, _grandma, 2);
+ _scene->runQueueObject(queue, _grandma, 2);
}
// CSc14Controller::DoFallBall (179444): the ball falls to the ground, the grandma throws the next
@@ -549,7 +432,7 @@ void Sc14Controller::doFallBall() {
MessageQueue *queue = new MessageQueue(_scene, true, 1);
queue->addCommandToEnd(movementCommand(ANI_BALL14, MV_BAL14_FALL, _flyingBall->_copyId));
queue->addCommandToEnd(hideCommand(ANI_BALL14, _flyingBall->_copyId));
- runQueueWithAni(queue, _flyingBall, 2);
+ _scene->runQueueObject(queue, _flyingBall, 2);
_balls.push_back(_flyingBall);
_flyingBall = nullptr;
doGrandmaShoot();
@@ -557,12 +440,12 @@ void Sc14Controller::doFallBall() {
// CSc14Controller::DoGrandmaForward (179544): grandma jumps a step forward and throws
void Sc14Controller::doGrandmaForward() {
- setStaticMirror(_grandma, ST_GMA_SIT, false);
+ _grandma->setStatic(ST_GMA_SIT, false);
MessageQueue *queue = new MessageQueue(_scene, true, 1);
queue->addCommandToEnd(pauseCommand(30));
queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_JUMPFW));
queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_THROW));
- runQueueWithAni(queue, _grandma, 2);
+ _scene->runQueueObject(queue, _grandma, 2);
_heroCenterX = _heroCenterX + 71.0f;
_targetX = _targetX + 71.0f;
_follow = hero();
@@ -572,7 +455,7 @@ void Sc14Controller::doGrandmaForward() {
void Sc14Controller::doManHit() {
if (!hero()->_movement || hero()->_movement->_id != MV_MAN14_FALL) {
stopDragging();
- moveToStatic(hero(), ST_MAN_RIGHT);
+ hero()->moveToStaticChain(ST_MAN_RIGHT);
hero()->startMovement(MV_MAN14_FALL, 0, -1);
_flyingBall->stopMovement();
_flyingBall->_flags &= ~4;
@@ -584,10 +467,10 @@ void Sc14Controller::doManHit() {
// CSc14Controller::DoManForward (1796E4): the hero steps forward, the camera follows the grandma
void Sc14Controller::doManForward() {
- setStaticMirror(hero(), ST_MAN_RIGHT, true);
+ hero()->setStatic(ST_MAN_RIGHT, true);
MessageQueue *queue = new MessageQueue(_scene, true, 1);
queue->addCommandToEnd(movementCommand(hero()->_id, MV_MAN14_STEPFW));
- runQueueWithAni(queue, hero(), 2);
+ _scene->runQueueObject(queue, hero(), 2);
_heroCenterX = _heroCenterX - 71.0f;
_targetX = _targetX - 71.0f;
_follow = _grandma;
@@ -600,7 +483,7 @@ void Sc14Controller::doGrandmaHit() {
if (_manKicking)
stopDragging();
if (_hitsLeft > 1) {
- moveToStatic(_grandma, ST_GMA_SIT);
+ _grandma->moveToStaticChain(ST_GMA_SIT);
MessageQueue *queue = new MessageQueue(_scene, true, 1);
if (_hitsLeft == 3 && !_pink) {
queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_BACKOFF2));
@@ -609,14 +492,14 @@ void Sc14Controller::doGrandmaHit() {
queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_BACKOFF));
queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_THROW));
}
- runQueueWithAni(queue, _grandma, 2);
+ _scene->runQueueObject(queue, _grandma, 2);
doManForward();
} else {
g_ngi->lift().enableButton(sO_Level4, ST_LBN_4N);
g_ngi->lift().initLift(_scene, hero(), QU_SC14_ENTERLIFT, QU_SC14_EXITLIFT);
// CFPController::FlurryArcadeEnd("ANI_GRANDMA"): the analytics event is not ported
addActivatingCounter();
- moveToStatic(hero(), ST_MAN_RIGHT);
+ hero()->moveToStaticChain(ST_MAN_RIGHT);
hero()->setPosition(Common::Point(1020, 454));
stopDragging();
_manCanKick = false;
@@ -669,13 +552,13 @@ void Sc14Controller::doShowBallFallman() {
const float x = _manX - 166.0f;
const float y = _manY + 40.0f;
_flyingBall->_flags |= 4;
- setStaticMirror(_flyingBall, ST_BAL14_TOGMA, false);
+ _flyingBall->setStatic(ST_BAL14_TOGMA, false);
_flyingBall->setCenter(Common::Point((int)x, (int)y));
_flyingBall->_z = 27;
MessageQueue *queue = new MessageQueue(_scene, true, 1);
queue->addCommandToEnd(movementCommand(ANI_BALL14, MV_BAL14_TOGMA, _flyingBall->_copyId));
queue->addCommandToEnd(hideCommand(ANI_BALL14, _flyingBall->_copyId));
- runQueueWithAni(queue, _flyingBall, 2);
+ _scene->runQueueObject(queue, _flyingBall, 2);
_flyingBall->startMovement(MV_BAL14_TOGMA, 0, -1);
_balls.push_back(_flyingBall);
_flyingBall = nullptr;
@@ -691,13 +574,13 @@ void Sc14Controller::doShowBallFallgrandma() {
const float x = _grandmaX + 190.0f;
const float y = _grandmaY + 56.0f;
_flyingBall->_flags |= 4;
- setStaticMirror(_flyingBall, ST_BAL14_TOGMA, false);
+ _flyingBall->setStatic(ST_BAL14_TOGMA, false);
_flyingBall->setCenter(Common::Point((int)x, (int)y));
_flyingBall->_z = 27;
MessageQueue *queue = new MessageQueue(_scene, true, 1);
queue->addCommandToEnd(movementCommand(ANI_BALL14, MV_BAL14_TOGMA, _flyingBall->_copyId));
queue->addCommandToEnd(hideCommand(ANI_BALL14, _flyingBall->_copyId));
- runQueueWithAni(queue, _flyingBall, 2);
+ _scene->runQueueObject(queue, _flyingBall, 2);
_balls.push_back(_flyingBall);
_flyingBall = nullptr;
}
@@ -712,7 +595,7 @@ void Sc14Controller::skipArcade() {
g_ngi->lift().initLift(_scene, hero(), QU_SC14_ENTERLIFT, QU_SC14_EXITLIFT);
g_ngi->arcadeInterface().scrollOut();
if (_manKicking) {
- setStaticMirror(hero(), ST_MAN_RIGHT, true);
+ hero()->setStatic(ST_MAN_RIGHT, true);
_manKicking = false;
}
if (_flyingBall) {
@@ -729,13 +612,13 @@ void Sc14Controller::skipArcade() {
stopQueue(grandmaQueue);
if (_grandma->_movement)
_grandma->stopMovement();
- setStaticMirror(_grandma, ST_GMA_SIT, false);
+ _grandma->setStatic(ST_GMA_SIT, false);
MessageQueue *queue = new MessageQueue(_scene, true, 1);
for (int i = 0; i < _hitsLeft; ++i)
queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_JUMPBK));
queue->addCommandToEnd(movementCommand(ANI_GRANDMA, MV_GMA_TOTRUBA_EMPTY));
queue->addCommandToEnd(messageCommand("MSG_SC14_RESTORESCROLL"));
- runQueueWithAni(queue, _grandma, 2);
+ _scene->runQueueObject(queue, _grandma, 2);
if (g_ngi->getStateId(sO_Grandma) == g_ngi->getStateValue(sO_Grandma, sO_In_14))
g_ngi->setState(sO_Grandma, g_ngi->getStateValue(sO_Grandma, sO_In_15));
_targetX = -(float)_scene->_x;
@@ -802,13 +685,13 @@ void Sc14Controller::onShow() {
_balls.push_back(copy);
_scene->addAni(copy, true);
}
- setStaticMirror(_grandma, ST_GMA_SIT, false);
+ _grandma->setStatic(ST_GMA_SIT, false);
_grandma->setPosition(Common::Point(713, 457));
Movement *throwing = _grandma->getMovement(MV_GMA_THROW);
if (throwing)
throwing->_loopDelay = (int)(float)(_grandmaFrameDelayK * 83.0f);
if (_scene->_currentEntranceId == 0) {
- setStaticMirror(hero(), ST_MAN_RIGHT, false);
+ hero()->setStatic(ST_MAN_RIGHT, false);
hero()->_flags |= 8;
hero()->setCenter(Common::Point(1448, 462));
hero()->_z = 10;
@@ -865,7 +748,7 @@ void Sc14Controller::onUpdate(uint32 elapsed) {
const Common::Point center = man->getCenter();
_manX = center.x;
_manY = center.y;
- _manX = _manX + (float)(2 * getCurFrame(man));
+ _manX = _manX + (float)(2 * man->getCurFrame());
} else {
const Common::Point center = man->getCenter();
_manX = center.x;
@@ -939,7 +822,7 @@ bool Sc14Controller::onMouseLKeyUp(uint32 id, float x, float y) {
if (x < (float)center.x + 40.0f) {
AniObject *ball = _scene->findAniObjectById(_pink->_id, 0);
if (ball->_statics)
- setStaticMirror(ball, ball->_statics->_staticsId, false);
+ ball->setStatic(ball->_statics->_staticsId, false);
center = _pink->getCenter();
ball->setCenter(center);
if (runInteraction(_pink->_id))
@@ -1009,7 +892,7 @@ void Sc14Controller::onMessage(const Common::String &message, const Common::Stri
if (isInteractionQueueRunning("INT_239")) {
AniObject *grit = _scene->findAniObjectById(ANI_GRIT_14, 0);
if (grit->_movement)
- setCurFrame(grit, 7);
+ grit->setCurFrame(7);
else
grit->startMovement(MV_GRT14_FALL, 0, -1);
}
Commit: 7103c6730e951631a5594059f2a40e803c8953b3
https://github.com/scummvm/scummvm/commit/7103c6730e951631a5594059f2a40e803c8953b3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 27 controller uses the shared helpers
Changed paths:
engines/ngi/fullpipe/sc27controller.cpp
diff --git a/engines/ngi/fullpipe/sc27controller.cpp b/engines/ngi/fullpipe/sc27controller.cpp
index efa27caf6de..a3f009ab2c5 100644
--- a/engines/ngi/fullpipe/sc27controller.cpp
+++ b/engines/ngi/fullpipe/sc27controller.cpp
@@ -36,6 +36,7 @@
#include "ngi/statics.h"
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc27controller.h"
#include "ngi/fullpipe/taskmanager.h"
@@ -45,33 +46,12 @@ namespace NGI {
namespace {
-// the marks of the subsystems that are not ported: once per kind
-void warnOnce(const char *what) {
- static Common::HashMap<Common::String, bool> reported;
- if (!reported.contains(what)) {
- reported[what] = true;
- warning("STUB/untested: %s", what);
- }
-}
-
-// CAniObject::MoveToStatic (F1B0C) is not ported (the instant chain of linked movements, tracking/entities.csv "pending"); like the other ported controllers
-// the object is put into the statics (SetStatic)
-void moveToStatic(AniObject *ani, int staticsId) {
- warnOnce("CAniObject::MoveToStatic (CSc27Controller: SetStatic is used)");
- ani->setStatic(staticsId);
-}
-
-// CMessageQueue::Interrupt (10C882) = CMessageQueue::Stop (10C838): not ported
-void interruptQueue(MessageQueue *queue) {
- warnOnce("CMessageQueue::Interrupt (CSc27Controller)");
-}
-
// StopMovement(false) (slot 152), then the object's queue is interrupted (slot 64)
void stopMovementAndQueue(AniObject *ani) {
ani->stopMovement();
MessageQueue *queue = ani->getMessageQueue();
if (queue)
- interruptQueue(queue);
+ queue->interrupt(false);
}
// CBehaviorController::OnSetQueue (F3774): CBehaviorAni::Stop, not ported
@@ -79,40 +59,6 @@ void behaviorOnSetQueue(AniObject *ani) {
warnOnce("CBehaviorController::OnSetQueue (CBehaviorAni::Stop, CSc27Controller)");
}
-// CAniObject::GetCurFrame (F112C): -1 without a movement
-int getCurFrame(const AniObject *ani) {
- if (ani->_movement)
- return ani->_movement->_curFrame;
- return -1;
-}
-
-// CAniObject::SetCurFrame (F0C76): only the movement of the object steps (CMovement::SetCurFrame, EFB00). The two flags of the original (a3 = `flag` is kept in
-// CMovement +63, a4 is always 0 here and reaches CMovement::SetFrame, which then runs the command of every phase that it steps over) are not modelled by
-// Movement::setCurFrame
-void setCurFrame(AniObject *ani, int frame, bool flag) {
- (void)flag;
- if (ani->_movement)
- ani->_movement->setCurFrame(frame);
-}
-
-// CCommand(5) with "msg": the message goes to the controllers by its name (CScene::Message), to the scene handlers by its id
-Command *messageCommand(const char *name) {
- uint32 id = 0;
- g_ngi->_gameProject->_objectIds.findId(name, id);
- Command *command = new Command(0, kCmdMessage, id, 0, 0, 0, 0, 0, 0, 0);
- command->_messageName = name;
- command->_excFlags |= 3;
- return command;
-}
-
-// CCommand(3, 1) with "aniId", "moveId" and "copy": START_MOVEMENT that the queue waits for
-Command *movementCommand(const AniObject *ani, int movementId) {
- Command *command = new Command(ani->_id, kCmdStartMovement, movementId, 0, 0, 0, 1, 0, 0, 0);
- command->_param = ani->_copyId;
- command->_excFlags |= 2;
- return command;
-}
-
// a double from its two words (the constants of GenerateTest are read from the code)
double doubleFromWords(uint32 high, uint32 low) {
const uint64 bits = ((uint64)high << 32) | low;
@@ -216,7 +162,7 @@ void Sc27Controller::manNextFunc(uint32 elapsed) {
const int timer = elapsed + _manTimer;
if (timer > 83) {
_manTimer = timer - 83;
- int frame = getCurFrame(hero());
+ int frame = hero()->getCurFrame();
bool flag = false;
if (!_maxPhase) {
if (frame > 4) {
@@ -228,7 +174,7 @@ void Sc27Controller::manNextFunc(uint32 elapsed) {
}
}
_arrowScale = (float)(frame - 6) / 5.0f + 0.7f;
- setCurFrame(hero(), frame, flag);
+ hero()->setCurFrame(frame, flag);
} else {
_manTimer = timer;
}
@@ -260,7 +206,7 @@ void Sc27Controller::switchMaid() {
stopMovementAndQueue(_maid);
behaviorOnSetQueue(_maid);
}
- moveToStatic(_maid, ST_MID_SWAB2);
+ _maid->moveToStaticChain(ST_MID_SWAB2);
_scene->runQueue(QU_MID_SWITCH, 3);
}
}
@@ -272,7 +218,7 @@ void Sc27Controller::switchMaidBack() {
stopMovementAndQueue(_maid);
behaviorOnSetQueue(_maid);
}
- moveToStatic(_maid, ST_MID_SWAB);
+ _maid->moveToStaticChain(ST_MID_SWAB);
_scene->runQueue(QU_MID_SWITCHBACK, 3);
}
}
@@ -282,12 +228,12 @@ void Sc27Controller::doPushButton() {
if (g_ngi->getStateId(sO_Driver) == g_ngi->getStateValue(sO_Driver, sO_WithSteering)) {
if (!_driver->_movement || _driver->getMessageQueue())
stopMovementAndQueue(_driver);
- moveToStatic(_driver, ST_DRV_VENT);
+ _driver->moveToStaticChain(ST_DRV_VENT);
_scene->runQueueWithAni(QU_DRV_PUSHBUTTON, _driver, 2);
} else {
if (!_driver->_movement || _driver->getMessageQueue())
stopMovementAndQueue(_driver);
- moveToStatic(_driver, ST_DRV_SITNOVENT);
+ _driver->moveToStaticChain(ST_DRV_SITNOVENT);
_scene->runQueueWithAni(QU_DRV_PUSHBUTTON_NOVENT, _driver, 2);
}
_buttonPushed = true;
@@ -299,7 +245,7 @@ void Sc27Controller::onTakeVent() {
if (!_maid->_movement || _maid->getMessageQueue()) {
stopMovementAndQueue(_maid);
_takeVent = false;
- moveToStatic(_maid, ST_MID_SWAB2);
+ _maid->moveToStaticChain(ST_MID_SWAB2);
_scene->runQueueWithAni(QU_MID_CLEANVENT, _maid, 3);
}
}
@@ -350,7 +296,7 @@ void Sc27Controller::updateDrag() {
else if (frame > 11)
frame = 11;
if (hero()->_movement)
- setCurFrame(hero(), frame, false);
+ hero()->setCurFrame(frame, false);
}
// CSc27Controller::MakeCollision (188908): two bets push each other, slightly random directions
@@ -416,7 +362,7 @@ void Sc27Controller::stopDrag() {
_maxPhase = false;
_manTimer = 0;
_manAnimating = false;
- const int frame = getCurFrame(hero());
+ const int frame = hero()->getCurFrame();
_launchPhase = frame - 6;
int throwFrame = 27 - frame;
if (throwFrame > 19)
@@ -428,7 +374,7 @@ void Sc27Controller::stopDrag() {
_arrowScale = 0.7f;
_powerArrow->_scaleX = 0.7f;
_powerArrow->_scaleY = 1.0f;
- setCurFrame(hero(), throwFrame, true);
+ hero()->setCurFrame(throwFrame, true);
warnOnce("CHintManager::SetHideCondition (CSc27Controller::StopDrag)");
}
@@ -455,7 +401,7 @@ void Sc27Controller::doWin() {
g_ngi->arcadeInterface().scrollOut();
if (!_driver->_movement || _driver->getMessageQueue())
stopMovementAndQueue(_driver);
- moveToStatic(_driver, ST_DRV_VENT);
+ _driver->moveToStaticChain(ST_DRV_VENT);
_scene->runQueueWithAni(QU_DRV_GIVEVENT, _driver, 2);
_arcadeRunning = false;
_scene->_motionController->activate();
@@ -516,7 +462,7 @@ void Sc27Controller::skipArcade() {
stopMovementAndQueue(_driver);
}
if (g_ngi->getStateId(sO_Driver) == g_ngi->getStateValue(sO_Driver, sO_WithSteering)) {
- moveToStatic(_driver, ST_DRV_VENT);
+ _driver->moveToStaticChain(ST_DRV_VENT);
_scene->runQueueWithAni(QU_DRV_GIVEVENT, _driver, 2);
}
_arcadeRunning = false;
@@ -549,7 +495,7 @@ void Sc27Controller::prepareNextBet(int highlighted) {
queue->_interruptState = 2; // SetIntState(2)
_batHandler->_z = 985;
queue->addCommandToEnd(movementCommand(_batHandler, movementId));
- queue->addCommandToEnd(messageCommand("MSG_SC27_CLICKBET"));
+ queue->addCommandToEnd(messageCommand("MSG_SC27_CLICKBET", 0, 3));
// CScene::RunQueue(queue, 4, 0): added to the scene and run, the object does not get it
if (!queue->run(nullptr)) {
delete queue;
@@ -641,7 +587,7 @@ void Sc27Controller::onBetClick(MessageQueue *queue) {
MessageQueue *started = mctlStartMove(181, 456, true, ST_MAN_RIGHT, mirror);
if (started)
- started->addCommandToEnd(messageCommand("MSG_SC27_CLICKBET"));
+ started->addCommandToEnd(messageCommand("MSG_SC27_CLICKBET", 0, 3));
}
// CSc27Controller::RemoveCopies (189D00): the copies of the bets leave the scene
@@ -869,11 +815,11 @@ void Sc27Controller::onShow() {
_startEvent = true;
if (g_ngi->getStateId(sO_Maid) == g_ngi->getStateValue(sO_Maid, sO_WithSwab)) {
- moveToStatic(_maid, ST_MID_SWAB2);
+ _maid->moveToStaticChain(ST_MID_SWAB2);
} else if (g_ngi->getStateId(sO_Maid) == g_ngi->getStateValue(sO_Maid, sO_WithBroom)) {
- moveToStatic(_maid, ST_MID_BROOM);
+ _maid->moveToStaticChain(ST_MID_BROOM);
} else if (g_ngi->getStateId(sO_Maid) == g_ngi->getStateValue(sO_Maid, sO_WithSpade)) {
- moveToStatic(_maid, ST_MID_SPADE);
+ _maid->moveToStaticChain(ST_MID_SPADE);
}
}
Commit: ae55c429caf8e86d2ca39fca9caa3942ef319b52
https://github.com/scummvm/scummvm/commit/ae55c429caf8e86d2ca39fca9caa3942ef319b52
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 29 controller uses the shared helpers
Changed paths:
engines/ngi/fullpipe/sc29controller.cpp
diff --git a/engines/ngi/fullpipe/sc29controller.cpp b/engines/ngi/fullpipe/sc29controller.cpp
index 5762a0d0ac5..073ca945b8c 100644
--- a/engines/ngi/fullpipe/sc29controller.cpp
+++ b/engines/ngi/fullpipe/sc29controller.cpp
@@ -37,6 +37,7 @@
#include "ngi/xmlnode.h"
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc29controller.h"
@@ -47,73 +48,6 @@ namespace NGI {
namespace {
-// the marks of the subsystems that are not ported: once per kind
-void warnOnce(const char *what) {
- static Common::HashMap<Common::String, bool> reported;
- if (!reported.contains(what)) {
- reported[what] = true;
- warning("STUB/untested: %s", what);
- }
-}
-
-// CAniObject::SetStatic(id, mirror) (F22BC): the mirror argument is stored in +64 of the object (flags 8 here). The correction of the position that the
-// original makes for a changed mirror is the one of AniObject::setStatic (it does not model the argument)
-void setStaticMirror(AniObject *ani, int staticsId, bool mirror) {
- ani->setStatic(staticsId);
- if (mirror)
- ani->_flags |= 8;
- else
- ani->_flags &= ~8;
-}
-
-// CAniObject::MoveToStatic (F1B0C) is not ported (the instant chain of linked movements, tracking/entities.csv "pending"); like the other ported controllers
-// the object is put into the statics (SetStatic)
-void moveToStatic(AniObject *ani, int staticsId) {
- warnOnce("CAniObject::MoveToStatic (CSc29Controller: SetStatic is used)");
- ani->setStatic(staticsId);
-}
-
-// a message of the queue (CCommand(5) with the parameter "msg"): its name goes to the controllers (CScene::Message), its id to the scene handlers
-Command *messageCommand(const char *name) {
- uint32 id = 0;
- g_ngi->_gameProject->_objectIds.findId(name, id);
- Command *command = new Command(0, kCmdMessage, id, 0, 0, 0, 0, 0, 0, 0);
- command->_messageName = name;
- command->_excFlags |= 3;
- return command;
-}
-
-// CCommand(3, 1) with the parameters aniId, moveId and copy: START_MOVEMENT that waits
-Command *movementCommand(const AniObject *ani, int movementId) {
- Command *command = new Command(ani->_id, kCmdStartMovement, movementId, 0, 0, 0, 1, 0, 0, 0);
- command->_param = ani->_copyId;
- command->_excFlags |= 2;
- return command;
-}
-
-// CCommand::SetParamFloat(command, "x", value): the attribute of the XML command and, for SHOW, the field that the handler of the command reads
-void setParamX(Command *command, float value) {
- command->_args["x"] = Common::String::format("%f", value);
- command->_x = (int)value;
-}
-
-// CMessageQueue::SetObjectCopy: every command of the queue gets the copy of the object ("copy" is 0 in the commands of the XML queues)
-void setObjectCopy(MessageQueue *queue, int copyId) {
- queue->setObjectCopy(0, copyId);
-}
-
-// CScene::RunQueue(scene, queue, state, ani) (12287E, 1228AE): the queue gets the scene and the interrupt state and runs; the object (when given) owns it
-bool runQueueObject(Scene *scene, MessageQueue *queue, AniObject *ani, int interruptState) {
- queue->_scene = scene;
- if (interruptState != 4)
- queue->_interruptState = interruptState;
- if (!queue->run(ani)) {
- g_ngi->_globalMessageQueueList->deleteQueueById(queue->_id);
- return false;
- }
- return true;
-}
-
// CMessageQueue +56 (the number of the command that runs) is not -1: the queue is running, i.e. it is still in the global list
bool isQueueRunning(MessageQueue *queue) {
for (uint i = 0; i < g_ngi->_globalMessageQueueList->size(); i++) {
@@ -159,7 +93,7 @@ bool Sc29Controller::doJump() {
_rideBackEnabled = false;
_manIsHit = false;
_reachedFarRight = true;
- moveToStatic(man, ST_MAN29_RUNR);
+ man->moveToStaticChain(ST_MAN29_RUNR);
man->startMovement(MV_MAN29_JUMP, 0, -1);
} else {
result = false;
@@ -179,7 +113,7 @@ bool Sc29Controller::doBend() {
_rideBackEnabled = false;
_manIsHit = false;
_reachedFarRight = true;
- moveToStatic(man, ST_MAN29_RUNR);
+ man->moveToStaticChain(ST_MAN29_RUNR);
man->startMovement(MV_MAN29_BEND, 0, -1);
} else {
result = false;
@@ -216,7 +150,7 @@ void Sc29Controller::tryShoot() {
// CSc29Controller::HitAssGreen (18CC1C)
void Sc29Controller::hitAssGreen() {
if (_ass->_statics->_staticsId == ST_ASS_NORM) {
- setStaticMirror(_ass, ST_ASS_NORM, false);
+ _ass->setStatic(ST_ASS_NORM, false);
_ass->startMovement(MV_ASS_HITGREEN, 0, -1);
}
}
@@ -224,7 +158,7 @@ void Sc29Controller::hitAssGreen() {
// CSc29Controller::HitAssRed (18CC60)
void Sc29Controller::hitAssRed() {
if (_ass->_statics->_staticsId == ST_ASS_NORM) {
- setStaticMirror(_ass, ST_ASS_NORM, false);
+ _ass->setStatic(ST_ASS_NORM, false);
_ass->startMovement(MV_ASS_HITRED, 0, -1);
}
}
@@ -322,7 +256,7 @@ void Sc29Controller::doJumpfromL() {
_scene->_motionController->activate();
getGameLoaderInteractionController()->enable();
hero()->_flags |= 8; // +64
- setStaticMirror(hero(), ST_MAN_RIGHT, false);
+ hero()->setStatic(ST_MAN_RIGHT, false);
if (!_scene->runQueue(QU_SC29_MANFROM_L, 2))
warning("sc29::DoJumpFromL: m_scene->RunQueue() returned false!");
_scrollingDisabled = true;
@@ -384,17 +318,17 @@ void Sc29Controller::countLoopBeardeds(uint32 elapsed) {
if (_arcadeIsOn && (uint)_bearders[i]._counter > 0x9BA) {
if (random31() > 0x3FFFFFFF && _manX > 700.0f && _manX < 1100.0f) {
MessageQueue *queue = new MessageQueue(_scene->findMessageQueue(QU_SC29_BRD1), 0, 0);
- setParamX(queue->getCommandByIndex(0), _manX + 350.0f);
- setObjectCopy(queue, _bearders[i]._ani->_copyId);
- if (!runQueueObject(_scene, queue, nullptr, 4))
+ queue->getCommandByIndex(0)->setParamFloat("x", _manX + 350.0f);
+ queue->setObjectCopyAll(_bearders[i]._ani->_copyId);
+ if (!_scene->runQueueObject(queue, nullptr, 4))
warning("sc29::CountLoopBeardeds: m_scene->RunQueue() returned false!");
_bearders[i]._walking = true;
_bearders[i]._counter = 0;
} else if (_manX > 700.0f && _manX < 1350.0f) {
MessageQueue *queue = new MessageQueue(_scene->findMessageQueue(QU_SC29_BRD2), 0, 0);
- setParamX(queue->getCommandByIndex(0), _manX - 200.0f);
- setObjectCopy(queue, _bearders[i]._ani->_copyId);
- if (!runQueueObject(_scene, queue, nullptr, 4))
+ queue->getCommandByIndex(0)->setParamFloat("x", _manX - 200.0f);
+ queue->setObjectCopyAll(_bearders[i]._ani->_copyId);
+ if (!_scene->runQueueObject(queue, nullptr, 4))
warning("sc29::CountLoopBeardeds: m_scene->RunQueue() returned false!");
_bearders[i]._walking = true;
_bearders[i]._counter = 0;
@@ -412,8 +346,8 @@ void Sc29Controller::countLoopBeardeds(uint32 elapsed) {
x = x - (float)elapsed * 0.092f;
if ((x - _manX) < 100.0f || !_arcadeIsOn) {
MessageQueue *queue = new MessageQueue(_scene->findMessageQueue(QU_SC29_BRDOUT1), 0, 0);
- setObjectCopy(queue, _bearders[i]._ani->_copyId);
- if (!runQueueObject(_scene, queue, nullptr, 4))
+ queue->setObjectCopyAll(_bearders[i]._ani->_copyId);
+ if (!_scene->runQueueObject(queue, nullptr, 4))
warning("sc29::CountLoopBeardeds: m_scene->RunQueue() returned false!");
_bearders[i]._walking = false;
_bearders[i]._counter = 0;
@@ -426,10 +360,10 @@ void Sc29Controller::countLoopBeardeds(uint32 elapsed) {
const float manX = _manX;
x = x - (float)elapsed * 0.048f;
if ((manX - x) < 60.0f || (x - manX) < -260.0f || !_arcadeIsOn) {
- setStaticMirror(ani, ST_BRDCMN_RIGHT, false);
+ ani->setStatic(ST_BRDCMN_RIGHT, false);
MessageQueue *queue = new MessageQueue(_scene->findMessageQueue(QU_SC29_BRDOUT2), 0, 0);
- setObjectCopy(queue, _bearders[i]._ani->_copyId);
- if (!runQueueObject(_scene, queue, nullptr, 4))
+ queue->setObjectCopyAll(_bearders[i]._ani->_copyId);
+ if (!_scene->runQueueObject(queue, nullptr, 4))
warning("sc29::CountLoopBeardeds: m_scene->RunQueue() returned false!");
_bearders[i]._walking = false;
_bearders[i]._counter = 0;
@@ -473,8 +407,8 @@ void Sc29Controller::doJumptoL() {
void Sc29Controller::tryEscapeShooters() {
if (!_shooter1->_movement && !_shooter2->_movement && _shooter1->_statics->_staticsId == ST_STR1_RIGHT) {
_shootCountdown = 0;
- setStaticMirror(_shooter1, ST_STR1_STAND, false);
- setStaticMirror(_shooter2, ST_STR2_STAND, false);
+ _shooter1->setStatic(ST_STR1_STAND, false);
+ _shooter2->setStatic(ST_STR2_STAND, false);
_scene->runQueue(QU_SC29_ESCAPE, 2);
_ass->_flags &= ~4;
g_ngi->arcadeInterface().scrollOut();
@@ -516,7 +450,7 @@ void Sc29Controller::onClickPorter() {
if (_manX != 351.0f || _manY != 443.0f) {
MessageQueue *queue = mctlStartMove(351, 443, true, ST_MAN_RIGHT, false);
if (queue)
- queue->addCommandToEnd(messageCommand("MSG_SC29_PORTER_CLICK"));
+ queue->addCommandToEnd(messageCommand("MSG_SC29_PORTER_CLICK", 0, 3));
}
} else {
Common::Point center = man->getCenter();
@@ -531,7 +465,7 @@ void Sc29Controller::onClickPorter() {
if (_manX != 1582.0f || _manY != 445.0f) {
MessageQueue *queue = mctlStartMove(1582, 445, true, ST_MAN_RIGHT, true);
if (queue)
- queue->addCommandToEnd(messageCommand("MSG_SC29_PORTER_CLICK"));
+ queue->addCommandToEnd(messageCommand("MSG_SC29_PORTER_CLICK", 0, 3));
}
}
}
@@ -540,7 +474,7 @@ void Sc29Controller::onClickPorter() {
void Sc29Controller::doHitMan() {
AniObject *man = hero();
_manIsHit = true;
- moveToStatic(man, ST_MAN29_RUNR);
+ man->moveToStaticChain(ST_MAN29_RUNR);
man->setCenter(Common::Point((int)_manX, (int)_manY));
MakeQueueStruct make;
@@ -560,7 +494,7 @@ void Sc29Controller::doHitMan() {
g_ngi->arcadeInterface().scrollOut();
warnOnce("CAchievementsManager::BlockActivatingCounter ACHIEVEMENT_ARCADE_29 (CSc29Controller::DoHitMan)");
queue->addCommandToEnd(movementCommand(man, MV_MAN29_STANDUP_NORM));
- queue->addCommandToEnd(messageCommand("MSG_SC29_STOPRIDE"));
+ queue->addCommandToEnd(messageCommand("MSG_SC29_STOPRIDE", 0, 3));
_manIsRiding = false;
_arcadeIsOn = false;
_reachedFarRight = false;
@@ -569,8 +503,8 @@ void Sc29Controller::doHitMan() {
} else {
queue->addCommandToEnd(movementCommand(man, MV_MAN29_STANDUP));
}
- queue->addCommandToEnd(messageCommand("MSG_SC29_STOP_HITQUEUE"));
- runQueueObject(_scene, queue, man, 2);
+ queue->addCommandToEnd(messageCommand("MSG_SC29_STOP_HITQUEUE", 0, 3));
+ _scene->runQueueObject(queue, man, 2);
_hitQueue = queue;
}
}
@@ -608,8 +542,8 @@ void Sc29Controller::removeCopies() {
void Sc29Controller::doWinArcadeNow() {
if (_shooter2->_flags & 4) {
_shootCountdown = 0;
- setStaticMirror(_shooter1, ST_STR1_STAND, false);
- setStaticMirror(_shooter2, ST_STR2_STAND, false);
+ _shooter1->setStatic(ST_STR1_STAND, false);
+ _shooter2->setStatic(ST_STR2_STAND, false);
_shooter2->_flags &= ~4;
while (!_flyingGreenBalls.empty()) {
AniObject *ball = _flyingGreenBalls[0];
@@ -708,7 +642,7 @@ void Sc29Controller::doShootGreen() {
const float y = center.y - 48.0f;
AniObject *ball = _greenBalls.front();
_greenBalls.pop_front();
- setStaticMirror(ball, ST_SHG_NORM, false);
+ ball->setStatic(ST_SHG_NORM, false);
ball->_flags |= 4;
ball->setCenter(Common::Point((int)x, (int)y));
_flyingGreenBalls.push_back(ball);
@@ -723,7 +657,7 @@ void Sc29Controller::doShootRed() {
const float y = center.y - 14.0f;
AniObject *ball = _redBalls.front();
_redBalls.pop_front();
- setStaticMirror(ball, ST_SHR_NORM, false);
+ ball->setStatic(ST_SHR_NORM, false);
ball->_flags |= 4;
ball->setCenter(Common::Point((int)x, (int)y));
_flyingRedBalls.push_back(ball);
@@ -796,7 +730,7 @@ void Sc29Controller::onShow() {
_bearders.clear();
AniObject *bearded = g_ngi->findScene(SC_COMMON)->findAniObjectById(ANI_BEARDED_CMN, 0);
AniObject *copy = new AniObject(bearded);
- setStaticMirror(copy, ST_BRDCMN_EMPTY, false);
+ copy->setStatic(ST_BRDCMN_EMPTY, false);
_scene->addAni(copy, true);
Bearded entry;
entry._ani = copy;
Commit: dd1bfade89e2eee2a7bc13ffc1f48172b4877693
https://github.com/scummvm/scummvm/commit/dd1bfade89e2eee2a7bc13ffc1f48172b4877693
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 38 controller uses the shared helpers
Changed paths:
engines/ngi/fullpipe/sc38controller.cpp
diff --git a/engines/ngi/fullpipe/sc38controller.cpp b/engines/ngi/fullpipe/sc38controller.cpp
index 4c5ba46974b..e25d0c83707 100644
--- a/engines/ngi/fullpipe/sc38controller.cpp
+++ b/engines/ngi/fullpipe/sc38controller.cpp
@@ -26,6 +26,7 @@
#include "ngi/scene.h"
#include "ngi/statics.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc38controller.h"
@@ -329,10 +330,7 @@ void Sc38Controller::onShow() {
}
g_ngi->lift().initLift(_scene, hero(), QU_SC38_ENTERLIFT, QU_SC38_EXITLIFT);
- // the id of the statics of the button is the one of the Android project (not the Windows ST_LBN_0N of constants.h)
- uint32 buttonId;
- if (g_ngi->_gameProject->_objectIds.findId("ST_LBN_0N", buttonId))
- g_ngi->lift().enableButton(_scene, buttonId);
+ g_ngi->lift().enableButton(_scene, projectId("ST_LBN_0N"));
if (_tutorial != "UNDEF")
_tutorialTime = 0;
testBottle();
Commit: 2998f8b8f839cd67e94f2c00627d6cf57f3bb9b8
https://github.com/scummvm/scummvm/commit/2998f8b8f839cd67e94f2c00627d6cf57f3bb9b8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 1 controller in its own file
Changed paths:
A engines/ngi/fullpipe/sc01controller.cpp
A engines/ngi/fullpipe/sc01controller.h
engines/ngi/fullpipe/scene01.cpp
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/scenecontrollers.h
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/sc01controller.cpp b/engines/ngi/fullpipe/sc01controller.cpp
new file mode 100644
index 00000000000..7e3238bf827
--- /dev/null
+++ b/engines/ngi/fullpipe/sc01controller.cpp
@@ -0,0 +1,124 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/ngi.h"
+#include "ngi/behavior.h"
+#include "ngi/gfx.h"
+#include "ngi/guimanager.h"
+#include "ngi/input.h"
+#include "ngi/interaction.h"
+#include "ngi/inventory.h"
+#include "ngi/messages.h"
+#include "ngi/motion.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/inventorycontroller.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/sc01controller.h"
+#include "ngi/fullpipe/scenes.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+// CSc01Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera (the rest is in scene01_initScene), and the tutorial
+// that is active when the scene is shown again through the entrance 0 (TUTORIAL_LAST is the one of the way back)
+void Sc01Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+
+ if (const Tutorial *active = g_ngi->_tutorialManager->findActiveTutorial()) {
+ if (_scene->_currentEntranceId == 0 && active->_id == "TUTORIAL_LAST")
+ _tutorial = "TUTORIAL_LAST";
+ }
+ if (_tutorial == "AFTER_TUTORIAL_USE_TRANSITION")
+ _tutorial = "TUTORIAL_LAST";
+}
+
+// CSc01Controller::OnGuiEvent: BTN_SKIP ends the tutorials and shows the exits of scenes 1 and 3
+void Sc01Controller::onGuiEvent(const Common::String &id, const Common::String &event) {
+ FPController::onGuiEvent(id, event);
+ if (event != "unpress" || id != "BTN_SKIP")
+ return;
+ g_ngi->_tutorialManager->deactivate();
+ static_cast<InventoryController *>(g_ngi->_inventory->_controller.get())->setHelperVisible(false);
+ if (GuiElement *button = g_ngi->_inventory->_guiManager->getElement("BTN_SKIP"))
+ button->hideAndDeactivate();
+ for (uint i = 0; i < g_ngi->_exitManager->getNumExits(); i++) {
+ Exit *exit = g_ngi->_exitManager->getExitNum(i);
+ if (exit->getSceneId() == SC_1 || exit->getSceneId() == SC_3)
+ exit->setState(1);
+ }
+}
+
+// CSc01Controller::IsInventoryEnabled: after the entrance queue; while it runs only the skip button
+bool Sc01Controller::isInventoryEnabled() {
+ GuiElement *skip = g_ngi->_inventory->_guiManager ? g_ngi->_inventory->_guiManager->getElement("BTN_SKIP") : nullptr;
+ CursorController *cursor = g_ngi->_inputController;
+ return !isEntranceQueueRunning() || (skip && skip->hit(Common::Point(cursor->_hotSceneX, cursor->_hotSceneY)));
+}
+
+bool Sc01Controller::isEntranceQueueRunning() const {
+ for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList) {
+ if (queue->_queueId == QU_SC1_ENTER && !queue->_isFinished)
+ return true;
+ }
+ return false;
+}
+
+// CSc01Controller::CheckTutorial (1625D8): FIRST, MOVE_MAN, SEE_TASK, USE_TRANSITION in turn
+void Sc01Controller::checkTutorial() {
+ TutorialManager *manager = g_ngi->_tutorialManager.get();
+ if (!manager->isActive()) {
+ if (_tutorial != "UNDEF")
+ _tutorial = "UNDEF";
+ return;
+ }
+ if (isEntranceQueueRunning())
+ return;
+ if (_tutorial == "AFTER_TUTORIAL_USE_TRANSITION" || _tutorial == "UNDEF")
+ return;
+ if (g_ngi->_sceneStack.size() != 1)
+ return;
+ if (manager->activateTutorial(_tutorial))
+ return;
+ const Common::String previous = _tutorial;
+ if (_tutorial == "TUTORIAL_FIRST")
+ _tutorial = "TUTORIAL_MOVE_MAN";
+ else if (_tutorial == "TUTORIAL_MOVE_MAN")
+ _tutorial = "TUTORIAL_SEE_TASK";
+ else if (_tutorial == "TUTORIAL_SEE_TASK")
+ _tutorial = "TUTORIAL_USE_TRANSITION";
+ else if (_tutorial == "TUTORIAL_USE_TRANSITION")
+ _tutorial = "AFTER_TUTORIAL_USE_TRANSITION";
+ else if (_tutorial != "AFTER_TUTORIAL_USE_TRANSITION")
+ _tutorial = "UNDEF";
+ if (previous != _tutorial)
+ checkTutorial();
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sc01controller.h b/engines/ngi/fullpipe/sc01controller.h
new file mode 100644
index 00000000000..936e7b93c33
--- /dev/null
+++ b/engines/ngi/fullpipe/sc01controller.h
@@ -0,0 +1,49 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SC01CONTROLLER_H
+#define NGI_FULLPIPE_SC01CONTROLLER_H
+
+#include "ngi/fullpipe/fpcontroller.h"
+
+namespace NGI {
+
+/** Android: CSc01Controller. Only the parts that are ported: the camera margins and the tutorials; the rest of the scene logic is in scene01.cpp */
+class Sc01Controller : public FPController {
+public:
+ explicit Sc01Controller(int sceneId) : FPController(sceneId), _tutorial("TUTORIAL_FIRST") {}
+ void onShow() override;
+ void onGuiEvent(const Common::String &id, const Common::String &event) override;
+ bool isInventoryEnabled() override;
+ void checkTutorial() override;
+
+private:
+ /** +216: the next tutorial of the scene, "UNDEF" when there is none */
+ Common::String _tutorial;
+
+ /** CFindQueue(QU_SC1_ENTER)->+56 != -1: the queue of the entrance runs */
+ bool isEntranceQueueRunning() const;
+};
+
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SC01CONTROLLER_H
diff --git a/engines/ngi/fullpipe/scene01.cpp b/engines/ngi/fullpipe/scene01.cpp
index 17c7c67e420..0390efdd1ee 100644
--- a/engines/ngi/fullpipe/scene01.cpp
+++ b/engines/ngi/fullpipe/scene01.cpp
@@ -74,70 +74,6 @@ void scene01_initObjects(Scene *sc, int entrance, bool eggUncracked) {
}
}
-// CSc01Controller::OnGuiEvent: the skip button of the tutorial (BTN_SKIP of the inventory) deactivates the tutorials, hides the helper of the inventory
-// and itself and shows the exits of the scenes 1 and 3.
-void Sc01Controller::onGuiEvent(const Common::String &id, const Common::String &event) {
- FPController::onGuiEvent(id, event);
- if (event != "unpress" || id != "BTN_SKIP")
- return;
- g_ngi->_tutorialManager->deactivate();
- static_cast<InventoryController *>(g_ngi->_inventory->_controller.get())->setHelperVisible(false);
- if (GuiElement *button = g_ngi->_inventory->_guiManager->getElement("BTN_SKIP"))
- button->hideAndDeactivate();
- for (uint i = 0; i < g_ngi->_exitManager->getNumExits(); i++) {
- Exit *exit = g_ngi->_exitManager->getExitNum(i);
- if (exit->getSceneId() == SC_1 || exit->getSceneId() == SC_3)
- exit->setState(1);
- }
-}
-
-// CSc01Controller::IsInventoryEnabled: the inventory works when the entrance queue of the scene has finished, and while it runs only the skip button does
-bool Sc01Controller::isInventoryEnabled() {
- GuiElement *skip = g_ngi->_inventory->_guiManager ? g_ngi->_inventory->_guiManager->getElement("BTN_SKIP") : nullptr;
- CursorController *cursor = g_ngi->_inputController;
- return !isEntranceQueueRunning() || (skip && skip->hit(Common::Point(cursor->_hotSceneX, cursor->_hotSceneY)));
-}
-
-bool Sc01Controller::isEntranceQueueRunning() const {
- for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList) {
- if (queue->_queueId == QU_SC1_ENTER && !queue->_isFinished)
- return true;
- }
- return false;
-}
-
-// CSc01Controller::CheckTutorial (1625D8): the tutorials of the first scene follow each other, FIRST, MOVE_MAN, SEE_TASK, USE_TRANSITION; the next one
-// is activated when the one before has ended (ActivateTutorial fails then, as it is not waiting or active any more)
-void Sc01Controller::checkTutorial() {
- TutorialManager *manager = g_ngi->_tutorialManager.get();
- if (!manager->isActive()) {
- if (_tutorial != "UNDEF")
- _tutorial = "UNDEF";
- return;
- }
- if (isEntranceQueueRunning())
- return;
- if (_tutorial == "AFTER_TUTORIAL_USE_TRANSITION" || _tutorial == "UNDEF")
- return;
- if (g_ngi->_sceneStack.size() != 1)
- return;
- if (manager->activateTutorial(_tutorial))
- return;
- const Common::String previous = _tutorial;
- if (_tutorial == "TUTORIAL_FIRST")
- _tutorial = "TUTORIAL_MOVE_MAN";
- else if (_tutorial == "TUTORIAL_MOVE_MAN")
- _tutorial = "TUTORIAL_SEE_TASK";
- else if (_tutorial == "TUTORIAL_SEE_TASK")
- _tutorial = "TUTORIAL_USE_TRANSITION";
- else if (_tutorial == "TUTORIAL_USE_TRANSITION")
- _tutorial = "AFTER_TUTORIAL_USE_TRANSITION";
- else if (_tutorial != "AFTER_TUTORIAL_USE_TRANSITION")
- _tutorial = "UNDEF";
- if (previous != _tutorial)
- checkTutorial();
-}
-
void scene01_initScene(Scene *sc, int entrance) {
scene01_initObjects(sc, entrance, g_ngi->getStateId(sO_EggCracker) == g_ngi->getStateValue(sO_EggCracker, sO_DidNotCrackEgg));
if (g_ngi->isAndroidFullPipe()) {
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index e8f33a57da1..e2023849688 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -21,6 +21,7 @@
#include "ngi/ngi.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/sc01controller.h"
#include "ngi/fullpipe/sc06controller.h"
#include "ngi/fullpipe/sc08controller.h"
#include "ngi/fullpipe/sc09controller.h"
@@ -43,23 +44,6 @@
namespace NGI {
-// CSc01Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera (the rest is in scene01_initScene), and the tutorial
-// that is active when the scene is shown again through the entrance 0 (TUTORIAL_LAST is the one of the way back)
-void Sc01Controller::onShow() {
- FPController::onShow();
- _marginX = 300;
- _marginY = 200;
- _offsetX = 400;
- _offsetY = 300;
-
- if (const Tutorial *active = g_ngi->_tutorialManager->findActiveTutorial()) {
- if (_scene->_currentEntranceId == 0 && active->_id == "TUTORIAL_LAST")
- _tutorial = "TUTORIAL_LAST";
- }
- if (_tutorial == "AFTER_TUTORIAL_USE_TRANSITION")
- _tutorial = "TUTORIAL_LAST";
-}
-
// CSc02Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera, the tutorial of the egg (the one of the ladder is over)
void Sc02Controller::onShow() {
FPController::onShow();
diff --git a/engines/ngi/fullpipe/scenecontrollers.h b/engines/ngi/fullpipe/scenecontrollers.h
index 17eef70afeb..e7b2c967803 100644
--- a/engines/ngi/fullpipe/scenecontrollers.h
+++ b/engines/ngi/fullpipe/scenecontrollers.h
@@ -26,24 +26,7 @@
namespace NGI {
-// The controllers of the scenes (CScNNController). Generated by scripts/ngi_gen_scene_controllers.py, then maintained by hand as the logic
-// of the scenes moves into them. Scenes 3 and 4 are in sc03controller.h and sc04controller.h.
-
-class Sc01Controller : public FPController {
-public:
- explicit Sc01Controller(int sceneId) : FPController(sceneId), _tutorial("TUTORIAL_FIRST") {}
- void onShow() override;
- void onGuiEvent(const Common::String &id, const Common::String &event) override;
- bool isInventoryEnabled() override;
- void checkTutorial() override;
-
-private:
- /** +216: the next tutorial of the scene, "UNDEF" when there is none */
- Common::String _tutorial;
-
- /** CFindQueue(QU_SC1_ENTER)->+56 != -1: the queue of the entrance runs */
- bool isEntranceQueueRunning() const;
-};
+// The scene controllers (CScNNController), generated by scripts/ngi_gen_scene_controllers.py
class Sc02Controller : public FPController {
public:
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 1fbc2ffa928..446f7dafcc4 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -90,6 +90,7 @@ MODULE_OBJS = \
fullpipe/lift.o \
fullpipe/liftcontroller.o \
fullpipe/notebook.o \
+ fullpipe/sc01controller.o \
fullpipe/sc04controller.o \
fullpipe/sc06controller.o \
fullpipe/sc08controller.o \
Commit: 0c2666a19bc60290f40b27f494a666888adcee82
https://github.com/scummvm/scummvm/commit/0c2666a19bc60290f40b27f494a666888adcee82
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 2 controller in its own file
Changed paths:
A engines/ngi/fullpipe/sc02controller.cpp
A engines/ngi/fullpipe/sc02controller.h
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/scenecontrollers.h
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/sc02controller.cpp b/engines/ngi/fullpipe/sc02controller.cpp
new file mode 100644
index 00000000000..27310d51430
--- /dev/null
+++ b/engines/ngi/fullpipe/sc02controller.cpp
@@ -0,0 +1,117 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/ngi.h"
+#include "ngi/behavior.h"
+#include "ngi/gfx.h"
+#include "ngi/guimanager.h"
+#include "ngi/input.h"
+#include "ngi/interaction.h"
+#include "ngi/inventory.h"
+#include "ngi/messages.h"
+#include "ngi/motion.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/inventorycontroller.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/sc02controller.h"
+#include "ngi/fullpipe/scenes.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+// CSc02Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera, the tutorial of the egg (the one of the ladder is over)
+void Sc02Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+ _eggInteracting = false;
+ _tutorial = "TUTORIAL_DO_EGG";
+ g_ngi->_tutorialManager->findTutorial("TUTORIAL_USE_LADDER")->setState(4);
+}
+
+// CSc02Controller::OnHide
+void Sc02Controller::onHide() {
+ FPController::onHide();
+ _eggInteracting = false;
+}
+
+// CSc02Controller::OnMessage: the end of the egg interaction (the other messages are in the scene handler, sceneHandler02)
+void Sc02Controller::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (message == "MSG_SC2_END_INTER")
+ _eggInteracting = false;
+ else
+ FPController::onMessage(message, param, queue);
+}
+
+// CSc02Controller::OnMouseLKeyUp: while the egg interaction INT_418 runs the touches are ignored, and after the tutorial of the egg the touch
+// goes nowhere. Not ported: CInteractionController::FindInteractionUnderCursor (the interaction INT_418 never starts the flag here)
+bool Sc02Controller::onMouseLKeyUp(uint32 id, float x, float y) {
+ static bool reported = false;
+ if (!reported) {
+ reported = true;
+ warning("STUB/untested: CSc02Controller::OnMouseLKeyUp: CInteractionController::FindInteractionUnderCursor (INT_418) is not ported");
+ }
+ if (_eggInteracting)
+ return true;
+ if (_tutorial == "AFTER_TUTORIAL_DO_EGG")
+ return true;
+ return FPController::onMouseLKeyUp(id, x, y);
+}
+
+// CSc02Controller::CheckTutorial (162F24): the egg tutorial (DO_EGG), then the map one
+void Sc02Controller::checkTutorial() {
+ TutorialManager *manager = g_ngi->_tutorialManager.get();
+ if (!manager->isActive()) {
+ if (_tutorial != "UNDEF")
+ _tutorial = "UNDEF";
+ return;
+ }
+ if (!canInterruptManQueue() || _tutorial == "UNDEF" || g_ngi->_sceneStack.size() != 1)
+ return;
+ if (manager->activateTutorial(_tutorial))
+ return;
+ const Common::String previous = _tutorial;
+ if (_tutorial == "TUTORIAL_DO_EGG") {
+ _tutorial = "AFTER_TUTORIAL_DO_EGG";
+ } else if (_tutorial == "AFTER_TUTORIAL_DO_EGG") {
+ if (g_ngi->_inventory->getItemByName("ANI_INV_EGGBOOT")->_counter > 0) {
+ manager->findTutorial("TUTORIAL_DO_EGG")->setState(4);
+ manager->finishTutorial("TUTORIAL_USE_CONTINUE_BUTTON");
+ _tutorial = "TUTORIAL_SEE_MAP";
+ }
+ } else if (_tutorial == "TUTORIAL_SEE_MAP" && manager->findTutorial("TUTORIAL_SEE_MAP")->_state == 4) {
+ manager->finishTutorial("TUTORIAL_USE_MAP");
+ _tutorial = "UNDEF";
+ }
+ if (manager->isTutorialCompleted())
+ _tutorial = "UNDEF";
+ if (previous != _tutorial)
+ checkTutorial();
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sc02controller.h b/engines/ngi/fullpipe/sc02controller.h
new file mode 100644
index 00000000000..bde7bdba5bb
--- /dev/null
+++ b/engines/ngi/fullpipe/sc02controller.h
@@ -0,0 +1,49 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SC02CONTROLLER_H
+#define NGI_FULLPIPE_SC02CONTROLLER_H
+
+#include "ngi/fullpipe/fpcontroller.h"
+
+namespace NGI {
+
+/** Android: CSc02Controller. Only the parts that are ported: the camera margins and the tutorials, OnMessage and OnMouseLKeyUp (the egg); the rest of the scene logic is in scene02.cpp */
+class Sc02Controller : public FPController {
+public:
+ explicit Sc02Controller(int sceneId) : FPController(sceneId) {}
+ void onShow() override;
+ void onHide() override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ void checkTutorial() override;
+
+private:
+ /** +216: the next tutorial of the scene, set to TUTORIAL_DO_EGG by OnShow */
+ Common::String _tutorial;
+ /** +236: the egg interaction INT_418 was started and has not ended (MSG_SC2_END_INTER) */
+ bool _eggInteracting = false;
+};
+
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SC02CONTROLLER_H
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index e2023849688..8d5edc881b6 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -22,6 +22,7 @@
#include "ngi/ngi.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/sc01controller.h"
+#include "ngi/fullpipe/sc02controller.h"
#include "ngi/fullpipe/sc06controller.h"
#include "ngi/fullpipe/sc08controller.h"
#include "ngi/fullpipe/sc09controller.h"
@@ -44,78 +45,6 @@
namespace NGI {
-// CSc02Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera, the tutorial of the egg (the one of the ladder is over)
-void Sc02Controller::onShow() {
- FPController::onShow();
- _marginX = 300;
- _marginY = 200;
- _offsetX = 400;
- _offsetY = 300;
- _eggInteracting = false;
- _tutorial = "TUTORIAL_DO_EGG";
- g_ngi->_tutorialManager->findTutorial("TUTORIAL_USE_LADDER")->setState(4);
-}
-
-// CSc02Controller::OnHide
-void Sc02Controller::onHide() {
- FPController::onHide();
- _eggInteracting = false;
-}
-
-// CSc02Controller::OnMessage: the end of the egg interaction (the other messages are in the scene handler, sceneHandler02)
-void Sc02Controller::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
- if (message == "MSG_SC2_END_INTER")
- _eggInteracting = false;
- else
- FPController::onMessage(message, param, queue);
-}
-
-// CSc02Controller::OnMouseLKeyUp: while the egg interaction INT_418 runs the touches are ignored, and after the tutorial of the egg the touch
-// goes nowhere. Not ported: CInteractionController::FindInteractionUnderCursor (the interaction INT_418 never starts the flag here)
-bool Sc02Controller::onMouseLKeyUp(uint32 id, float x, float y) {
- static bool reported = false;
- if (!reported) {
- reported = true;
- warning("STUB/untested: CSc02Controller::OnMouseLKeyUp: CInteractionController::FindInteractionUnderCursor (INT_418) is not ported");
- }
- if (_eggInteracting)
- return true;
- if (_tutorial == "AFTER_TUTORIAL_DO_EGG")
- return true;
- return FPController::onMouseLKeyUp(id, x, y);
-}
-
-// CSc02Controller::CheckTutorial (162F24): the tutorial of the egg (DO_EGG), then the one of the map once the egg boot is taken
-void Sc02Controller::checkTutorial() {
- TutorialManager *manager = g_ngi->_tutorialManager.get();
- if (!manager->isActive()) {
- if (_tutorial != "UNDEF")
- _tutorial = "UNDEF";
- return;
- }
- if (!canInterruptManQueue() || _tutorial == "UNDEF" || g_ngi->_sceneStack.size() != 1)
- return;
- if (manager->activateTutorial(_tutorial))
- return;
- const Common::String previous = _tutorial;
- if (_tutorial == "TUTORIAL_DO_EGG") {
- _tutorial = "AFTER_TUTORIAL_DO_EGG";
- } else if (_tutorial == "AFTER_TUTORIAL_DO_EGG") {
- if (g_ngi->_inventory->getItemByName("ANI_INV_EGGBOOT")->_counter > 0) {
- manager->findTutorial("TUTORIAL_DO_EGG")->setState(4);
- manager->finishTutorial("TUTORIAL_USE_CONTINUE_BUTTON");
- _tutorial = "TUTORIAL_SEE_MAP";
- }
- } else if (_tutorial == "TUTORIAL_SEE_MAP" && manager->findTutorial("TUTORIAL_SEE_MAP")->_state == 4) {
- manager->finishTutorial("TUTORIAL_USE_MAP");
- _tutorial = "UNDEF";
- }
- if (manager->isTutorialCompleted())
- _tutorial = "UNDEF";
- if (previous != _tutorial)
- checkTutorial();
-}
-
// CSc05Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera
void Sc05Controller::onShow() {
FPController::onShow();
diff --git a/engines/ngi/fullpipe/scenecontrollers.h b/engines/ngi/fullpipe/scenecontrollers.h
index e7b2c967803..96640136dc1 100644
--- a/engines/ngi/fullpipe/scenecontrollers.h
+++ b/engines/ngi/fullpipe/scenecontrollers.h
@@ -28,22 +28,6 @@ namespace NGI {
// The scene controllers (CScNNController), generated by scripts/ngi_gen_scene_controllers.py
-class Sc02Controller : public FPController {
-public:
- explicit Sc02Controller(int sceneId) : FPController(sceneId) {}
- void onShow() override;
- void onHide() override;
- void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
- bool onMouseLKeyUp(uint32 id, float x, float y) override;
- void checkTutorial() override;
-
-private:
- /** +216: the next tutorial of the scene, set to TUTORIAL_DO_EGG by OnShow */
- Common::String _tutorial;
- /** +236: the egg interaction INT_418 was started and has not ended (MSG_SC2_END_INTER) */
- bool _eggInteracting = false;
-};
-
class Sc05Controller : public FPController {
public:
explicit Sc05Controller(int sceneId) : FPController(sceneId) {}
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 446f7dafcc4..d552b9fd537 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -91,6 +91,7 @@ MODULE_OBJS = \
fullpipe/liftcontroller.o \
fullpipe/notebook.o \
fullpipe/sc01controller.o \
+ fullpipe/sc02controller.o \
fullpipe/sc04controller.o \
fullpipe/sc06controller.o \
fullpipe/sc08controller.o \
Commit: 7117d621242da88a7ad9933fa1b27cc35b7327f3
https://github.com/scummvm/scummvm/commit/7117d621242da88a7ad9933fa1b27cc35b7327f3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 3 controller in its own file
Changed paths:
A engines/ngi/fullpipe/sc03controller.cpp
engines/ngi/fullpipe/scene03.cpp
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/sc03controller.cpp b/engines/ngi/fullpipe/sc03controller.cpp
new file mode 100644
index 00000000000..071dd238870
--- /dev/null
+++ b/engines/ngi/fullpipe/sc03controller.cpp
@@ -0,0 +1,141 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/ngi.h"
+#include "ngi/behavior.h"
+#include "ngi/font.h"
+#include "ngi/gfx.h"
+#include "ngi/guimanager.h"
+#include "ngi/input.h"
+#include "ngi/interaction.h"
+#include "ngi/inventory.h"
+#include "ngi/messages.h"
+#include "ngi/motion.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/inventorycontroller.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/sc03controller.h"
+#include "ngi/fullpipe/scenes.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+// CSc03Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera (the rest is in scene03_initScene)
+void Sc03Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+ _boot = _scene->findAniObjectById(ANI_SC4_BOOT, 0);
+}
+
+// CSc03Controller::IsInventoryEnabled: CTutorialManager::IsTutorialCompleted
+bool Sc03Controller::isInventoryEnabled() {
+ return g_ngi->_tutorialManager->isTutorialCompleted();
+}
+
+// CSc03Controller::OnMouseLKeyDown and OnMouseLKeyUp (1644A0, 164518): after the tutorial of the ladder or of the egg the touch goes nowhere, and
+// after the tutorial of the boot only a touch on the boot counts. Then the base class, then CLift::OnButtonDown / OnButtonUp (they stay in
+// FPController::onTap and the lift code of the scene, D02/D17).
+bool Sc03Controller::tutorialBlocksTouch() const {
+ if (_tutorial == "AFTER_TUTORIAL_USE_LADDER" || _tutorial == "AFTER_TUTORIAL_GIVE_EGG")
+ return true;
+ return _tutorial == "AFTER_TUTORIAL_MAKE_TASK_BOOT" && _boot != g_ngi->_inputController->getHitObject();
+}
+
+bool Sc03Controller::onMouseLKeyDown(uint32 id, float x, float y) {
+ if (tutorialBlocksTouch())
+ return true;
+ return FPController::onMouseLKeyDown(id, x, y);
+}
+
+bool Sc03Controller::onMouseLKeyUp(uint32 id, float x, float y) {
+ if (tutorialBlocksTouch())
+ return true;
+ return FPController::onMouseLKeyUp(id, x, y);
+}
+
+bool Sc03Controller::hasEggBootOrEaten() const {
+ return g_ngi->_inventory->getItemByName("ANI_INV_EGGBOOT")->_counter > 0 || g_vars->swallowedEgg1->_value.intValue != 0;
+}
+
+// CSc03Controller::CheckTutorial (163834): MAKE_TASK_BOOT, SEE_INVENTORY, USE_LADDER,
+// GIVE_EGG, LAST, each followed by an "AFTER_..." that waits for the player
+void Sc03Controller::checkTutorial() {
+ TutorialManager *manager = g_ngi->_tutorialManager.get();
+ if (!manager->isActive()) {
+ if (_tutorial != "UNDEF")
+ _tutorial = "UNDEF";
+ return;
+ }
+ if (!canInterruptManQueue() || _tutorial == "UNDEF" || g_ngi->_sceneStack.size() != 1)
+ return;
+ if (manager->activateTutorial(_tutorial))
+ return;
+ const Common::String previous = _tutorial;
+ if (_tutorial == "TUTORIAL_MAKE_TASK_BOOT") {
+ _tutorial = "AFTER_TUTORIAL_MAKE_TASK_BOOT";
+ } else if (_tutorial == "AFTER_TUTORIAL_MAKE_TASK_BOOT") {
+ if (g_ngi->_inventory->getItemByName("ANI_INV_BOOT")->_counter > 0 || hasEggBootOrEaten()) {
+ manager->findTutorial("TUTORIAL_MAKE_TASK_BOOT")->setState(4);
+ _tutorial = "TUTORIAL_SEE_INVENTORY";
+ }
+ } else if (_tutorial == "TUTORIAL_SEE_INVENTORY") {
+ _tutorial = "AFTER_TUTORIAL_SEE_INVENTORY";
+ } else if (_tutorial == "AFTER_TUTORIAL_SEE_INVENTORY") {
+ g_ngi->_taskManager->showActiveTaskDialog(true);
+ _tutorial = "TUTORIAL_USE_LADDER";
+ } else if (_tutorial == "TUTORIAL_USE_LADDER") {
+ _tutorial = "AFTER_TUTORIAL_USE_LADDER";
+ } else if (_tutorial == "AFTER_TUTORIAL_USE_LADDER") {
+ if (hasEggBootOrEaten())
+ _tutorial = "TUTORIAL_GIVE_EGG";
+ } else if (_tutorial == "TUTORIAL_GIVE_EGG") {
+ _tutorial = "AFTER_TUTORIAL_GIVE_EGG";
+ } else if (_tutorial == "AFTER_TUTORIAL_GIVE_EGG") {
+ if (g_ngi->_inventory->getItemByName("ANI_INV_EGGBOOT")->_counter == 0) {
+ manager->findTutorial("TUTORIAL_GIVE_EGG")->setState(4);
+ _tutorial = "TUTORIAL_LAST";
+ }
+ } else {
+ _tutorial = "UNDEF";
+ }
+ if (previous != _tutorial)
+ checkTutorial();
+}
+
+// CSc03Controller::OnRender: a cloud with the text at a fixed place of the screen
+void Sc03Controller::onRender(Common::Point) {
+ if (g_vars->scene03_hintTimer <= 0 || !g_vars->scene03_hintFont)
+ return;
+
+ if (PictureObject *cloud = _scene->findPictureObjectById(23509, 0)) // 0x5BD5
+ cloud->_picture->blitTo(g_ngi->_backgroundSurface, Common::Point(500, 200));
+ g_vars->scene03_hintFont->drawCentered(g_ngi->_backgroundSurface, Common::Rect(520, 215, 520 + 113, 215 + 71), g_vars->scene03_hintText);
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/scene03.cpp b/engines/ngi/fullpipe/scene03.cpp
index 41dab9ba741..ff671ad6321 100644
--- a/engines/ngi/fullpipe/scene03.cpp
+++ b/engines/ngi/fullpipe/scene03.cpp
@@ -54,101 +54,6 @@ static GameVar *scene03_eggVariable(const char *name) {
// Android: hint over the scene with the eggs still needed (CSc03Controller +244 time, +248 text)
static const int kEatenHintDuration = 4000;
-// CSc03Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera (the rest is in scene03_initScene)
-void Sc03Controller::onShow() {
- FPController::onShow();
- _marginX = 300;
- _marginY = 200;
- _offsetX = 400;
- _offsetY = 300;
- _boot = _scene->findAniObjectById(ANI_SC4_BOOT, 0);
-}
-
-// CSc03Controller::IsInventoryEnabled: CTutorialManager::IsTutorialCompleted
-bool Sc03Controller::isInventoryEnabled() {
- return g_ngi->_tutorialManager->isTutorialCompleted();
-}
-
-// CSc03Controller::OnMouseLKeyDown and OnMouseLKeyUp (1644A0, 164518): after the tutorial of the ladder or of the egg the touch goes nowhere, and
-// after the tutorial of the boot only a touch on the boot counts. Then the base class, then CLift::OnButtonDown / OnButtonUp (they stay in
-// FPController::onTap and the lift code of the scene, D02/D17).
-bool Sc03Controller::tutorialBlocksTouch() const {
- if (_tutorial == "AFTER_TUTORIAL_USE_LADDER" || _tutorial == "AFTER_TUTORIAL_GIVE_EGG")
- return true;
- return _tutorial == "AFTER_TUTORIAL_MAKE_TASK_BOOT" && _boot != g_ngi->_inputController->getHitObject();
-}
-
-bool Sc03Controller::onMouseLKeyDown(uint32 id, float x, float y) {
- if (tutorialBlocksTouch())
- return true;
- return FPController::onMouseLKeyDown(id, x, y);
-}
-
-bool Sc03Controller::onMouseLKeyUp(uint32 id, float x, float y) {
- if (tutorialBlocksTouch())
- return true;
- return FPController::onMouseLKeyUp(id, x, y);
-}
-
-bool Sc03Controller::hasEggBootOrEaten() const {
- return g_ngi->_inventory->getItemByName("ANI_INV_EGGBOOT")->_counter > 0 || g_vars->swallowedEgg1->_value.intValue != 0;
-}
-
-// CSc03Controller::CheckTutorial (163834): the tutorials of the third scene, MAKE_TASK_BOOT, SEE_INVENTORY, USE_LADDER, GIVE_EGG, LAST: each is
-// followed by "AFTER_...", that waits for what the player has to do (the boot, an egg) before the next one is activated
-void Sc03Controller::checkTutorial() {
- TutorialManager *manager = g_ngi->_tutorialManager.get();
- if (!manager->isActive()) {
- if (_tutorial != "UNDEF")
- _tutorial = "UNDEF";
- return;
- }
- if (!canInterruptManQueue() || _tutorial == "UNDEF" || g_ngi->_sceneStack.size() != 1)
- return;
- if (manager->activateTutorial(_tutorial))
- return;
- const Common::String previous = _tutorial;
- if (_tutorial == "TUTORIAL_MAKE_TASK_BOOT") {
- _tutorial = "AFTER_TUTORIAL_MAKE_TASK_BOOT";
- } else if (_tutorial == "AFTER_TUTORIAL_MAKE_TASK_BOOT") {
- if (g_ngi->_inventory->getItemByName("ANI_INV_BOOT")->_counter > 0 || hasEggBootOrEaten()) {
- manager->findTutorial("TUTORIAL_MAKE_TASK_BOOT")->setState(4);
- _tutorial = "TUTORIAL_SEE_INVENTORY";
- }
- } else if (_tutorial == "TUTORIAL_SEE_INVENTORY") {
- _tutorial = "AFTER_TUTORIAL_SEE_INVENTORY";
- } else if (_tutorial == "AFTER_TUTORIAL_SEE_INVENTORY") {
- g_ngi->_taskManager->showActiveTaskDialog(true);
- _tutorial = "TUTORIAL_USE_LADDER";
- } else if (_tutorial == "TUTORIAL_USE_LADDER") {
- _tutorial = "AFTER_TUTORIAL_USE_LADDER";
- } else if (_tutorial == "AFTER_TUTORIAL_USE_LADDER") {
- if (hasEggBootOrEaten())
- _tutorial = "TUTORIAL_GIVE_EGG";
- } else if (_tutorial == "TUTORIAL_GIVE_EGG") {
- _tutorial = "AFTER_TUTORIAL_GIVE_EGG";
- } else if (_tutorial == "AFTER_TUTORIAL_GIVE_EGG") {
- if (g_ngi->_inventory->getItemByName("ANI_INV_EGGBOOT")->_counter == 0) {
- manager->findTutorial("TUTORIAL_GIVE_EGG")->setState(4);
- _tutorial = "TUTORIAL_LAST";
- }
- } else {
- _tutorial = "UNDEF";
- }
- if (previous != _tutorial)
- checkTutorial();
-}
-
-// CSc03Controller::OnRender: a cloud with the text at a fixed place of the screen
-void Sc03Controller::onRender(Common::Point) {
- if (g_vars->scene03_hintTimer <= 0 || !g_vars->scene03_hintFont)
- return;
-
- if (PictureObject *cloud = _scene->findPictureObjectById(23509, 0)) // 0x5BD5
- cloud->_picture->blitTo(g_ngi->_backgroundSurface, Common::Point(500, 200));
- g_vars->scene03_hintFont->drawCentered(g_ngi->_backgroundSurface, Common::Rect(520, 215, 520 + 113, 215 + 71), g_vars->scene03_hintText);
-}
-
static void scene03_showEatenHint(const char *stringId) {
const Common::Path directory(Common::String("data/res_") + g_ngi->getResourceLocale());
if (!g_vars->scene03_hintFont) {
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index d552b9fd537..0bb7b419d77 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -92,6 +92,7 @@ MODULE_OBJS = \
fullpipe/notebook.o \
fullpipe/sc01controller.o \
fullpipe/sc02controller.o \
+ fullpipe/sc03controller.o \
fullpipe/sc04controller.o \
fullpipe/sc06controller.o \
fullpipe/sc08controller.o \
Commit: 61bc979dc7e74fc89adfe5d9848161b6de8e4a05
https://github.com/scummvm/scummvm/commit/61bc979dc7e74fc89adfe5d9848161b6de8e4a05
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 4 controller methods of scene04.cpp in sc04controller.cpp
Changed paths:
engines/ngi/fullpipe/sc04controller.cpp
engines/ngi/fullpipe/scene04.cpp
engines/ngi/fullpipe/scenes.h
diff --git a/engines/ngi/fullpipe/sc04controller.cpp b/engines/ngi/fullpipe/sc04controller.cpp
index cd4995be3a1..4b9f287156c 100644
--- a/engines/ngi/fullpipe/sc04controller.cpp
+++ b/engines/ngi/fullpipe/sc04controller.cpp
@@ -42,6 +42,7 @@
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc04controller.h"
+#include "ngi/fullpipe/scenes.h"
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/tutorialmanager.h"
@@ -1778,4 +1779,60 @@ void Sc04Controller::onMessage(const Common::String &message, const Common::Stri
FPController::onMessage(message, param, queue);
}
+// CSc04Controller::OnShow: after CFPController::OnShow the camera margins and offsets
+void Sc04Controller::onShow() {
+ FPController::onShow();
+ _marginX = 300;
+ _marginY = 200;
+ _offsetX = 400;
+ _offsetY = 300;
+}
+
+// CSc04Controller::OnRender: the arcade interface over the scene
+void Sc04Controller::onRender(Common::Point) {
+ g_ngi->arcadeInterface().render();
+}
+
+// CSc04Controller::CanSwipeMan: not while the camera is held
+bool Sc04Controller::canSwipeMan(float, float) {
+ return !g_vars->scene04_cameraLocked;
+}
+
+// CSc04Controller::UpdateScroll: camera held at x 380 while the arcade runs or the hand moves;
+// follows the hero again when no ladder, arcade or demo scroll is active
+void Sc04Controller::updateScroll() {
+ if (!g_vars->scene04_dudeOnLadder && !g_vars->scene04_soundPlaying)
+ g_vars->scene04_cameraLocked = false;
+
+ const bool handMoves = g_vars->scene04_hand && (g_vars->scene04_hand->_flags & 4) && g_vars->scene04_hand->_movement;
+ if (handMoves)
+ g_vars->scene04_cameraLocked = true;
+
+ if (g_vars->scene04_cameraLocked) {
+ if (handMoves || (g_vars->scene04_soundPlaying && g_ngi->_aniMan)) {
+ setFollowHero(false);
+ if (fabsf(_scene->_x - 380.0f) > 3.0f)
+ setScrollTarget(380.0f - _scene->_x);
+ }
+ } else if (!g_vars->scene04_demoScroll) {
+ setFollowHero(true);
+ }
+ FPController::updateScroll();
+}
+
+// CSc04Controller::OnMouseLKeyUp: the ladder, the plank and the hero on the ladder, between the swipe and the tap of the base class
+// (ADAPTATION: in the original the base call comes first and includes the tap, see FPController::onMouseLKeyUp)
+bool Sc04Controller::onMouseLKeyUp(uint32 id, float x, float y) {
+ if (onMouseLKeyUpSwipe(x, y))
+ return true;
+ if (scene04_click(Common::Point(x - _scene->_x, y - _scene->_y)))
+ return true;
+ return onTap(x, y);
+}
+
+// CSc04Controller::SkipArcade (skip button): the Windows handler logic (scene04_skipArcade)
+void Sc04Controller::skipArcade() {
+ scene04_skipArcade();
+}
+
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/scene04.cpp b/engines/ngi/fullpipe/scene04.cpp
index 73641112a30..0346b7dd9b2 100644
--- a/engines/ngi/fullpipe/scene04.cpp
+++ b/engines/ngi/fullpipe/scene04.cpp
@@ -51,7 +51,6 @@ static const int scene04_speakerPhases[] = {
};
void sceneHandler04_putKozyawkaBack(AniObject *ani);
-static bool scene04_click(Common::Point pos);
// the camera follows the hero (CFPController +60) or not
static void scene04_followHero(bool follow) {
@@ -303,57 +302,6 @@ void scene04_initScene(Scene *sc) {
}
}
-// CSc04Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera (the rest is in scene04_initScene)
-void Sc04Controller::onShow() {
- FPController::onShow();
- _marginX = 300;
- _marginY = 200;
- _offsetX = 400;
- _offsetY = 300;
-}
-
-// CSc04Controller::OnRender: the arcade interface over the scene
-void Sc04Controller::onRender(Common::Point) {
- g_ngi->arcadeInterface().render();
-}
-
-// CSc04Controller::CanSwipeMan: not while the camera is held
-bool Sc04Controller::canSwipeMan(float, float) {
- return !g_vars->scene04_cameraLocked;
-}
-
-// CSc04Controller::OnMouseLKeyUp: the ladder, the plank and the hero on the ladder, between the swipe and the tap of the base class
-// (ADAPTATION: in the original the base call comes first and includes the tap, see FPController::onMouseLKeyUp)
-bool Sc04Controller::onMouseLKeyUp(uint32 id, float x, float y) {
- if (onMouseLKeyUpSwipe(x, y))
- return true;
- if (scene04_click(Common::Point(x - _scene->_x, y - _scene->_y)))
- return true;
- return onTap(x, y);
-}
-
-// CSc04Controller::UpdateScroll: while the arcade runs or the hand moves, the camera is held at x 380 (the jar, the plank and the ladder
-// are in view); the camera follows the hero again when neither the ladder nor the arcade are used and no demo scroll is running
-void Sc04Controller::updateScroll() {
- if (!g_vars->scene04_dudeOnLadder && !g_vars->scene04_soundPlaying)
- g_vars->scene04_cameraLocked = false;
-
- const bool handMoves = g_vars->scene04_hand && (g_vars->scene04_hand->_flags & 4) && g_vars->scene04_hand->_movement;
- if (handMoves)
- g_vars->scene04_cameraLocked = true;
-
- if (g_vars->scene04_cameraLocked) {
- if (handMoves || (g_vars->scene04_soundPlaying && g_ngi->_aniMan)) {
- setFollowHero(false);
- if (fabsf(_scene->_x - 380.0f) > 3.0f)
- setScrollTarget(380.0f - _scene->_x);
- }
- } else if (!g_vars->scene04_demoScroll) {
- setFollowHero(true);
- }
- FPController::updateScroll();
-}
-
bool sceneHandler04_friesAreWalking() {
if (g_vars->scene04_dudeOnLadder && g_ngi->_aniMan->isIdle() && !(g_ngi->_aniMan->_flags & 0x100)) {
int col = g_vars->scene04_ladder->getCurrentStep(g_ngi->_aniMan);
@@ -1555,7 +1503,7 @@ void sceneHandler04_doWinArcade() {
}
// CSc04Controller::OnMouseLKeyUp: the ladder, the plank, the hero on the ladder
-static bool scene04_click(Common::Point pos) {
+bool scene04_click(Common::Point pos) {
Scene &scene = *g_ngi->_currentScene;
const int x = pos.x + scene._x;
const int y = pos.y + scene._y;
@@ -1713,8 +1661,8 @@ static void scene04_winArcade() {
scene04_finishArcadeTask();
}
-// CSc04Controller::SkipArcade (the skip button): the clock closes, the hand takes the bottle and the arcade stops
-void Sc04Controller::skipArcade() {
+// CSc04Controller::SkipArcade (skip button): the clock closes, the hand takes the bottle
+void scene04_skipArcade() {
g_ngi->arcadeInterface().scrollOut();
g_vars->scene04_clock->setStatic(ST_CLK_CLOSED);
scene04_stopQueue(QU_SC4_GOCLOCK);
diff --git a/engines/ngi/fullpipe/scenes.h b/engines/ngi/fullpipe/scenes.h
index bbe694b240e..609a1fc8e63 100644
--- a/engines/ngi/fullpipe/scenes.h
+++ b/engines/ngi/fullpipe/scenes.h
@@ -66,6 +66,10 @@ void scene03_initScene(Scene *sc);
int sceneHandler03(Command *cmd);
int scene04_updateCursor();
+/** CSc04Controller::OnMouseLKeyUp: click on the ladder, the plank or the hero on the ladder */
+bool scene04_click(Common::Point pos);
+/** CSc04Controller::SkipArcade */
+void scene04_skipArcade();
void scene04_initScene(Scene *sc);
int sceneHandler04(Command *cmd);
Commit: 814c8c5e21430b9f289fd8174d74e229dc400bf7
https://github.com/scummvm/scummvm/commit/814c8c5e21430b9f289fd8174d74e229dc400bf7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: testmode moved to debugger/
Changed paths:
A engines/ngi/debugger/testmode.cpp
A engines/ngi/debugger/testmode.h
R engines/ngi/fullpipe/testmode.cpp
R engines/ngi/fullpipe/testmode.h
engines/ngi/debugger/debugtools.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/module.mk
engines/ngi/ngi.cpp
diff --git a/engines/ngi/debugger/debugtools.cpp b/engines/ngi/debugger/debugtools.cpp
index b3db07b8c8c..b9a53bf0a24 100644
--- a/engines/ngi/debugger/debugtools.cpp
+++ b/engines/ngi/debugger/debugtools.cpp
@@ -26,7 +26,7 @@
#include "common/system.h"
#include "ngi/ngi.h"
-#include "ngi/fullpipe/testmode.h"
+#include "ngi/debugger/testmode.h"
#include "ngi/debugger/debugtools.h"
#include "ngi/debugger/dt-internal.h"
diff --git a/engines/ngi/fullpipe/testmode.cpp b/engines/ngi/debugger/testmode.cpp
similarity index 98%
rename from engines/ngi/fullpipe/testmode.cpp
rename to engines/ngi/debugger/testmode.cpp
index 4b34a582fe4..7cfe004beef 100644
--- a/engines/ngi/fullpipe/testmode.cpp
+++ b/engines/ngi/debugger/testmode.cpp
@@ -33,13 +33,13 @@
#include "ngi/scene.h"
#include "ngi/statics.h"
#include "ngi/fullpipe/constants.h"
-#include "ngi/fullpipe/testmode.h"
+#include "ngi/debugger/testmode.h"
namespace NGI {
namespace {
-// Places for Dude (scene id, spot, x, y): the spot 1 and the following are near the exits of the scene
+// Places for Dude (scene id, spot, x, y); spot 1 and up are near the exits
struct Spot {
int sceneId;
int spot;
diff --git a/engines/ngi/fullpipe/testmode.h b/engines/ngi/debugger/testmode.h
similarity index 71%
rename from engines/ngi/fullpipe/testmode.h
rename to engines/ngi/debugger/testmode.h
index 0e4aa4016e6..f860374b2f2 100644
--- a/engines/ngi/fullpipe/testmode.h
+++ b/engines/ngi/debugger/testmode.h
@@ -29,15 +29,8 @@
namespace NGI {
-/**
- * Troubleshooting aids of the Android game, all switched on from the command line (docs/test-mode.md):
- * --debugflags=imgui the ImGui debugger (debugger/debugtools.cpp), with the Info window: the state of the game
- * --debugflags=info the state of Dude is logged as INFO lines (with -d1) whenever his movement or phase changes, no ImGui needed
- * --debugflags=fast the game runs six times faster (six updates of 42 ms per frame, no waiting), for test runs
- * --boot-param=N N = scene + 100 * spot: the scene N % 100, and Dude is moved to the spot (see testmode.cpp) as soon as he stands
- * after the entrance queue, with the camera on the spot: the walk to a place that is tested is skipped
- * In the test mode (the fast flag or a spot) the Info window of the ImGui debugger is open from the start.
- */
+/** Troubleshooting aids switched on from the command line: --debugflags=imgui, info, fast and
+ * --boot-param=N (N = scene + 100 * spot), see docs/test-mode.md */
struct TestInfo {
int frame = 0;
uint32 step = 0;
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index 3cc0a72725d..c6bd2d0d32c 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -31,7 +31,7 @@
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/floaters.h"
#include "ngi/fullpipe/taskmanager.h"
-#include "ngi/fullpipe/testmode.h"
+#include "ngi/debugger/testmode.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/objectnames.h"
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 0bb7b419d77..b4a85f9c464 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -78,6 +78,7 @@ MODULE_OBJS = \
box2d/Dynamics/b2World.o \
box2d/Dynamics/b2WorldCallbacks.o \
box2d/Rope/b2Rope.o \
+ debugger/testmode.o \
fullpipe/achievements.o \
fullpipe/arcadeinterface.o \
fullpipe/chaptercontroller.o \
@@ -147,7 +148,6 @@ MODULE_OBJS = \
fullpipe/scenecontrollers.o \
fullpipe/scenes.o \
fullpipe/taskmanager.o \
- fullpipe/testmode.o \
fullpipe/tremble.o \
fullpipe/tutorialcontroller.o \
fullpipe/tutorialmanager.o
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index dd74b0bde30..47631e5bb9a 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -42,7 +42,7 @@
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/tutorialmanager.h"
-#include "ngi/fullpipe/testmode.h"
+#include "ngi/debugger/testmode.h"
#include "ngi/debugger/debugtools.h"
#include "ngi/fullpipe/tremble.h"
#include "ngi/detection.h"
Commit: 84dd2afc6cc88640526abaf23f63bb783730ccc1
https://github.com/scummvm/scummvm/commit/84dd2afc6cc88640526abaf23f63bb783730ccc1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: NGI_TEST_SETUP: states, items and the camera for a test run
Changed paths:
engines/ngi/debugger/testmode.cpp
diff --git a/engines/ngi/debugger/testmode.cpp b/engines/ngi/debugger/testmode.cpp
index 7cfe004beef..574469f5a1f 100644
--- a/engines/ngi/debugger/testmode.cpp
+++ b/engines/ngi/debugger/testmode.cpp
@@ -20,9 +20,14 @@
*/
+#define FORBIDDEN_SYMBOL_EXCEPTION_getenv
+
#include "common/debug-channels.h"
#include "common/hash-str.h"
+#include "common/str-enc.h"
+#include "common/tokenizer.h"
+
#include "ngi/ngi.h"
#include "ngi/gameloader.h"
#include "ngi/gfx.h"
@@ -57,6 +62,52 @@ const Spot kSpots[] = {
{ SC_4, 3, 1150, 476, 800, "scene 4: with the coin for the horn", ANI_INV_COIN },
};
+// NGI_TEST_SETUP (environment): actions that are done once, when Dude stands after the entrance queue, separated by ";":
+// state=Object:Value the state of an object of the game (UTF-8 names, e.g. state=ÐамаÑа:ÐгÑаеÑ)
+// item=ANI_INV_COIN an inventory item
+// scroll=x,y the camera
+bool g_setupDone = false;
+
+Common::String toGameEncoding(const Common::String &utf8) {
+ return Common::U32String(utf8, Common::kUtf8).encode(Common::kWindows1251);
+}
+
+void runSetup() {
+ const char *setup = getenv("NGI_TEST_SETUP");
+ if (!setup || !g_ngi->_currentScene)
+ return;
+ Common::StringTokenizer actions(setup, ";");
+ while (!actions.empty()) {
+ const Common::String action = actions.nextToken();
+ const int equals = action.findFirstOf('=');
+ if (equals == (int)Common::String::npos)
+ continue;
+ const Common::String key = action.substr(0, equals);
+ const Common::String value = action.substr(equals + 1);
+ if (key == "state") {
+ const int colon = value.findFirstOf(':');
+ if (colon == (int)Common::String::npos)
+ continue;
+ const Common::String object = toGameEncoding(value.substr(0, colon));
+ const Common::String state = toGameEncoding(value.substr(colon + 1));
+ warning("TESTMODE: state %s = %s", value.substr(0, colon).c_str(), value.substr(colon + 1).c_str());
+ g_ngi->setState(object, g_ngi->getStateValue(object, state.c_str()));
+ } else if (key == "item") {
+ warning("TESTMODE: item %s", value.c_str());
+ g_ngi->_inventory->addItem(value, 1);
+ } else if (key == "scroll") {
+ int x = 0;
+ int y = 0;
+ if (sscanf(value.c_str(), "%d,%d", &x, &y) == 2) {
+ warning("TESTMODE: camera %d, %d", x, y);
+ g_ngi->_currentScene->_x = x;
+ g_ngi->_currentScene->_y = y;
+ g_ngi->_sceneRect.moveTo(x, y);
+ }
+ }
+ }
+}
+
int g_frame = 0;
int g_spot = 0;
int g_idleFrames = 0;
@@ -176,7 +227,7 @@ void testmode_update(uint32 elapsed) {
}
}
- if (!g_spot || !hero || !g_ngi->_currentScene)
+ if ((g_setupDone && !g_spot) || !hero || !g_ngi->_currentScene)
return;
// Dude has to stand after the entrance queue
@@ -184,6 +235,13 @@ void testmode_update(uint32 elapsed) {
if (g_idleFrames < 10)
return;
+ if (!g_setupDone) {
+ g_setupDone = true;
+ runSetup();
+ }
+ if (!g_spot)
+ return;
+
const Spot *spot = findSpot(g_ngi->_currentScene->_sceneId, g_spot);
if (!spot) {
warning("TESTMODE: no spot %d in scene %d", g_spot, g_ngi->_currentScene->_sceneId);
Commit: 48c58c233c7b39ba0d90aadeb96b130ad4c46a50
https://github.com/scummvm/scummvm/commit/48c58c233c7b39ba0d90aadeb96b130ad4c46a50
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 4 tutorial follows the arcade that the scene handler runs
Changed paths:
engines/ngi/fullpipe/sc04controller.cpp
diff --git a/engines/ngi/fullpipe/sc04controller.cpp b/engines/ngi/fullpipe/sc04controller.cpp
index 4b9f287156c..36180a77093 100644
--- a/engines/ngi/fullpipe/sc04controller.cpp
+++ b/engines/ngi/fullpipe/sc04controller.cpp
@@ -226,7 +226,8 @@ void Sc04Controller::checkTutorial() {
changed = false;
} else if (_tutorial == "EXTRA_TUTORIAL_USE_DEVICES") {
// CFlurryEventManager::Event("show_hint_tools_use") is the analytics of the original: not ported
- if (_arcade)
+ // +580: arcade runs; not started here yet, the Windows handler keeps it (scene04_soundPlaying)
+ if (controllerRunsSceneLogic() ? _arcade : g_vars->scene04_soundPlaying)
_tutorial = "ARCADE_TUTORIAL_04";
else
changed = false;
Commit: 98ccddc8b91b1ecd498f2801d450d17a3e5a5552
https://github.com/scummvm/scummvm/commit/98ccddc8b91b1ecd498f2801d450d17a3e5a5552
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: The test setup comes from --start-movie, no getenv
Changed paths:
engines/ngi/debugger/testmode.cpp
diff --git a/engines/ngi/debugger/testmode.cpp b/engines/ngi/debugger/testmode.cpp
index 574469f5a1f..cea729f0516 100644
--- a/engines/ngi/debugger/testmode.cpp
+++ b/engines/ngi/debugger/testmode.cpp
@@ -20,11 +20,10 @@
*/
-#define FORBIDDEN_SYMBOL_EXCEPTION_getenv
-
#include "common/debug-channels.h"
#include "common/hash-str.h"
+#include "common/config-manager.h"
#include "common/str-enc.h"
#include "common/tokenizer.h"
@@ -62,7 +61,7 @@ const Spot kSpots[] = {
{ SC_4, 3, 1150, 476, 800, "scene 4: with the coin for the horn", ANI_INV_COIN },
};
-// NGI_TEST_SETUP (environment): actions that are done once, when Dude stands after the entrance queue, separated by ";":
+// --start-movie=<actions> (the string is free for the engine; the scripts take it from NGI_TEST_SETUP): actions that are done once, when Dude stands after the entrance queue, separated by ";":
// state=Object:Value the state of an object of the game (UTF-8 names, e.g. state=ÐамаÑа:ÐгÑаеÑ)
// item=ANI_INV_COIN an inventory item
// scroll=x,y the camera
@@ -73,9 +72,9 @@ Common::String toGameEncoding(const Common::String &utf8) {
}
void runSetup() {
- const char *setup = getenv("NGI_TEST_SETUP");
- if (!setup || !g_ngi->_currentScene)
+ if (!ConfMan.hasKey("start_movie") || !g_ngi->_currentScene)
return;
+ const Common::String setup = ConfMan.get("start_movie");
Common::StringTokenizer actions(setup, ";");
while (!actions.empty()) {
const Common::String action = actions.nextToken();
Commit: 2d25e46e7d60ba8d1b0a2b25a2f42d16493ab4de
https://github.com/scummvm/scummvm/commit/2d25e46e7d60ba8d1b0a2b25a2f42d16493ab4de
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
BASE: --start-movie also for the NGI engine (the test setup)
Changed paths:
base/commandLine.cpp
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 87b0fafe9f2..4fc59d7ede5 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -231,8 +231,8 @@ static const char HELP_STRING4[] =
#if defined(ENABLE_SCUMM) || defined(ENABLE_GROOVIE)
" --demo-mode Start demo mode of Maniac Mansion or The 7th Guest\n"
#endif
-#if defined(ENABLE_DIRECTOR) || defined(ENABLE_TESTBED)
- " --start-movie=NAME at NUM Start movie at frame for Director\n"
+#if defined(ENABLE_DIRECTOR) || defined(ENABLE_TESTBED) || defined(ENABLE_NGI)
+ " --start-movie=NAME at NUM Start movie at frame for Director, a test setup for NGI\n"
" Either can be specified without the other.\n"
#endif
#ifdef ENABLE_SCUMM
@@ -1066,7 +1066,7 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
END_OPTION
#endif
-#if defined(ENABLE_DIRECTOR) || defined(ENABLE_TESTBED)
+#if defined(ENABLE_DIRECTOR) || defined(ENABLE_TESTBED) || defined(ENABLE_NGI)
DO_LONG_OPTION("start-movie")
END_OPTION
#endif
Commit: e265166c7ab6c1fe1cebc6ff0eba00832ef52614
https://github.com/scummvm/scummvm/commit/e265166c7ab6c1fe1cebc6ff0eba00832ef52614
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: FPGuiController (CFPGuiController)
Changed paths:
A engines/ngi/fullpipe/fpguicontroller.cpp
A engines/ngi/fullpipe/fpguicontroller.h
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/fpguicontroller.cpp b/engines/ngi/fullpipe/fpguicontroller.cpp
new file mode 100644
index 00000000000..43c4a9b76df
--- /dev/null
+++ b/engines/ngi/fullpipe/fpguicontroller.cpp
@@ -0,0 +1,67 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/ngi.h"
+#include "ngi/scene.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
+#include "ngi/fullpipe/fpguicontroller.h"
+
+namespace NGI {
+
+// CFPGuiController::CFPGuiController (151578): ISceneController, +12 is 0
+FPGuiController::FPGuiController(int sceneId) : ISceneController(sceneId) {
+}
+
+// CFPGuiController::OnUpdate (151564): CBehaviorController::UpdateMusic of the scene below
+void FPGuiController::onUpdate(uint32 elapsed) {
+ if (_sceneBelow && _sceneBelow->_behaviorController)
+ warnOnce("CBehaviorController::UpdateMusic: not ported as a method (BehaviorController::update does the sounds and the music together), the music of the scene below is not updated while the dialog is shown");
+}
+
+// CFPGuiController::OnShow (1515A0)
+void FPGuiController::onShow() {
+ if (g_ngi->_sceneStack.size() < 2)
+ _sceneBelow = nullptr;
+ else
+ _sceneBelow = g_ngi->getSceneInStack(0);
+}
+
+// CFPGuiController::OnGuiEvent (1515C8)
+void FPGuiController::onGuiEvent(const Common::String &id, const Common::String &event) {
+ if (event == "unpress" && id == "BTN_CLOSE")
+ g_ngi->popScene();
+}
+
+// CFPGuiController::OnKeyUp (1515FC)
+void FPGuiController::onKeyUp(uint32 key) {
+ if (key != 4) // AKEYCODE_BACK
+ return;
+ if (g_ngi->_sceneStack.size() < 2) {
+ Scene *current = g_ngi->getCurrentScene();
+ if (current && current->_sceneId == SC_MAINMENU)
+ current->message("MSG_RESTART_GAME", "", nullptr);
+ } else {
+ g_ngi->popScene();
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/fpguicontroller.h b/engines/ngi/fullpipe/fpguicontroller.h
new file mode 100644
index 00000000000..62c812a876c
--- /dev/null
+++ b/engines/ngi/fullpipe/fpguicontroller.h
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_FPGUICONTROLLER_H
+#define NGI_FULLPIPE_FPGUICONTROLLER_H
+
+#include "ngi/scenecontroller.h"
+
+namespace NGI {
+
+/** CFPGuiController: base of the dialog controllers (menu, map, help); BTN_CLOSE/back closes */
+class FPGuiController : public ISceneController {
+public:
+ explicit FPGuiController(int sceneId);
+
+ /** CGObject::CleanXml (vtable slot 5): reset the state; not called yet (no CGame::CleanXml) */
+ virtual void cleanXml() {}
+
+ /** CFPGuiController::OnUpdate (151564): the scene below keeps its music going */
+ void onUpdate(uint32 elapsed) override;
+ /** CFPGuiController::OnShow (1515A0): the scene below is the first of the stack (none if alone) */
+ void onShow() override;
+ /** CFPGuiController::OnGuiEvent (1515C8): BTN_CLOSE closes the dialog */
+ void onGuiEvent(const Common::String &id, const Common::String &event) override;
+ /** CFPGuiController::OnKeyUp (1515FC): back key (4) closes; no scene below: restart the game */
+ void onKeyUp(uint32 key) override;
+
+protected:
+ Scene *_sceneBelow = nullptr; // +12
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_FPGUICONTROLLER_H
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index b4a85f9c464..ccfad5bb7da 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -87,6 +87,7 @@ MODULE_OBJS = \
fullpipe/exitmanager.o \
fullpipe/floaters.o \
fullpipe/fpcontroller.o \
+ fullpipe/fpguicontroller.o \
fullpipe/inventorycontroller.o \
fullpipe/lift.o \
fullpipe/liftcontroller.o \
Commit: df16fd8b88ee461754431b6eece08ee983fb96db
https://github.com/scummvm/scummvm/commit/df16fd8b88ee461754431b6eece08ee983fb96db
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Map (CMap), the state of the map of the game
Changed paths:
A engines/ngi/fullpipe/map.cpp
A engines/ngi/fullpipe/map.h
engines/ngi/fullpipe/constants.h
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index ab21dd90cd2..a1f4cfa33f7 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -1873,4 +1873,14 @@ namespace NGI {
#define ST_SC6_ARROW_3 23492
#define ST_SC6_ARROW_4 23493
+// Android: names of obj.h that the ported controllers use
+#define TrubaUp1 10004
+#define TrubaUp10 10005
+#define TrubaUp15 10006
+#define TrubaUp19 10007
+#define ENT_SC19_RTRUBA3 20005
+#define ENT_SC18_RTRUBA 20007
+#define PIC_MAP_SEL 10003
+#define PIC_MAP_STOP 23001
+#define TrubaLeft_fin 23274
#endif /* NGI_CONSTANTS_H */
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index e990533fc59..d25bd8e0a9f 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -39,6 +39,7 @@
#include "ngi/fullpipe/fpcontroller.h"
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/lift.h"
+#include "ngi/fullpipe/map.h"
#include "ngi/guimanager.h"
#include "ngi/inventory.h"
#include "ngi/fullpipe/tremble.h"
@@ -199,6 +200,9 @@ bool FPController::isScrollYScene() const {
// CFPController::OnShow, camera part; not ported: ResetSwipeParams, flurry, hints, GUI helpers
void FPController::onShow() {
+ // CMap::Update: the scene and the entrance it was entered through appear on the map
+ if (g_ngi->_map)
+ g_ngi->_map->update(_scene->_sceneId, _scene->_currentEntranceId);
_follow = hero();
if (_scene->_currentEntranceId) { // CScene::GetCurrentEntranceId
_scene->_x = marginX();
diff --git a/engines/ngi/fullpipe/map.cpp b/engines/ngi/fullpipe/map.cpp
new file mode 100644
index 00000000000..2a2d4956a98
--- /dev/null
+++ b/engines/ngi/fullpipe/map.cpp
@@ -0,0 +1,364 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/ngi.h"
+#include "ngi/scene.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
+#include "ngi/fullpipe/map.h"
+#include "ngi/fullpipe/mapwindowcontroller.h"
+#include "ngi/fullpipe/objectnames.h"
+
+namespace NGI {
+
+// CMap::CMap (156298): the vector of the items is empty, +20 is 0
+Map::Map() {
+}
+
+// CMap::GetSavePath (155F54): the path of the saves of CPathManager and "map.sav"
+Common::String Map::getSavePath() const {
+ warnOnce("CMap::GetSavePath: CPathManager is not ported (map.sav)");
+ return "map.sav";
+}
+
+// CMap::CleanXml (155FF4)
+void Map::cleanXml() {
+ for (uint i = 0; i < _items.size(); i++) {
+ Scene *scene = g_ngi->findScene(SC_MAP);
+ GameObject *picture = scene ? scene->findVisibleObject(_items[i].id, 0) : nullptr;
+ if (picture)
+ picture->_flags &= ~4;
+ }
+ _items.clear();
+ _firstEnterToSc13 = 0;
+}
+
+// CMap::GetXmlData (156040)
+void Map::getXmlData() {
+ warnOnce("CMap::GetXmlData: the XML writer is not ported, the map is not saved");
+}
+
+// CMap::SetXmlData (157B60)
+void Map::setXmlData(const XmlNode &node) {
+ _firstEnterToSc13 = node.attrInt("first_enter_sc13", 0);
+ for (uint i = 0; i < node.childCount(); i++) {
+ const Common::String name = node[i].name();
+ if (name == "MAPOBJECT") {
+ Item item;
+ item.id = node[i].attrInt("id", 0);
+ item.state = node[i].attrInt("curState", 0);
+ item.dontEnter = node[i].attrBool("dont_enter", false);
+ _items.push_back(item);
+ } else if (name == "MAPTUTORIAL") {
+ Scene *scene = g_ngi->findScene(SC_MAP);
+ if (scene && scene->_controller)
+ static_cast<MapWindowController *>(scene->_controller.get())->setTutorial(node[i].attrStr("state", ""));
+ }
+ }
+}
+
+// CMap::Reset (157CB4)
+void Map::reset() {
+ _items.clear();
+ setObjState(PIC_MAP_S01, 1);
+ setObjState(PIC_MAP_A13, 1);
+}
+
+// CMap::GetObjId (156308)
+int Map::getObjId(int index) const {
+ if (index >= 0 && index < (int)_items.size())
+ return _items[index].id;
+ return -1;
+}
+
+// CMap::GetObjState (156330)
+int Map::getObjState(int index) const {
+ if (index >= 0 && index < (int)_items.size())
+ return _items[index].state;
+ return -1;
+}
+
+// CMap::GetMapItem (156370)
+int Map::getMapItem(uint id) const {
+ for (uint i = 0; i < _items.size(); i++) {
+ if ((uint)_items[i].id == id)
+ return i;
+ }
+ return -1;
+}
+
+// CMap::SetObjState (157C80)
+void Map::setObjState(uint id, uint state) {
+ const int index = getMapItem(id);
+ if (index == -1) {
+ Item item;
+ item.id = id;
+ item.state = state;
+ item.dontEnter = false;
+ _items.push_back(item);
+ } else {
+ _items[index].state = state;
+ }
+}
+
+// CMap::SetDontEnter (1563A0)
+void Map::setDontEnter(uint id, bool dontEnter) {
+ const int index = getMapItem(id);
+ if (index != -1)
+ _items[index].dontEnter = dontEnter;
+}
+
+// CMap::IsDontEnter (1563BA)
+bool Map::isDontEnter(uint id) const {
+ const int index = getMapItem(id);
+ if (index == -1)
+ return false;
+ return _items[index].dontEnter;
+}
+
+// CMap::Update (157CD8): the order of the SetObjState calls is the order of the items
+void Map::update(uint sceneId, uint entranceId) {
+ switch (sceneId) {
+ case SC_1:
+ setObjState(PIC_MAP_S01, 1);
+ if (entranceId == TrubaLeft)
+ setObjState(PIC_MAP_A13, 1);
+ else if (entranceId == TrubaUp)
+ setObjState(PIC_MAP_P01, 1);
+ break;
+ case SC_2:
+ setObjState(PIC_MAP_S02, 1);
+ if (entranceId == TrubaLeft)
+ setObjState(PIC_MAP_P01, 1);
+ break;
+ case SC_3:
+ setObjState(PIC_MAP_S03, 1);
+ break;
+ case SC_4:
+ setObjState(PIC_MAP_S04, 1);
+ if (entranceId == TrubaRight)
+ setObjState(PIC_MAP_P04, 1);
+ break;
+ case SC_5:
+ setObjState(PIC_MAP_S05, 1);
+ if (entranceId == TrubaLeft) {
+ setObjState(PIC_MAP_P04, 1);
+ } else if (entranceId == TrubaUp) {
+ setObjState(PIC_MAP_P05, 1);
+ setObjState(PIC_MAP_A11, 1);
+ }
+ break;
+ case SC_6:
+ setObjState(PIC_MAP_S06, 1);
+ if (entranceId == TrubaUp)
+ setObjState(PIC_MAP_A12, 1);
+ break;
+ case SC_7:
+ setObjState(PIC_MAP_S07, 1);
+ if (entranceId == TrubaLeft)
+ setObjState(PIC_MAP_P18, 1);
+ break;
+ case SC_8:
+ setObjState(PIC_MAP_S08, 1);
+ if (entranceId == TrubaUp)
+ setObjState(PIC_MAP_P11, 1);
+ else if (entranceId == TrubaRight)
+ setObjState(PIC_MAP_P18, 1);
+ break;
+ case SC_9:
+ setObjState(PIC_MAP_S09, 1);
+ if (entranceId == TrubaDown)
+ setObjState(PIC_MAP_P11, 1);
+ break;
+ case SC_10:
+ setObjState(PIC_MAP_S10, 1);
+ if (entranceId == TrubaRight)
+ setObjState(PIC_MAP_P02, 1);
+ break;
+ case SC_11:
+ setObjState(PIC_MAP_S11, 1);
+ if (entranceId == TrubaLeft)
+ setObjState(PIC_MAP_P02, 1);
+ break;
+ case SC_12:
+ setObjState(PIC_MAP_S12, 1);
+ break;
+ case SC_13:
+ setObjState(PIC_MAP_S13, 1);
+ if (entranceId == TrubaUp) {
+ setObjState(PIC_MAP_P06, 1);
+ setObjState(PIC_MAP_A10, 1);
+ }
+ break;
+ case SC_14:
+ setObjState(PIC_MAP_S14, 1);
+ break;
+ case SC_15:
+ setObjState(PIC_MAP_S15, 1);
+ if (entranceId == TrubaUp) {
+ setObjState(PIC_MAP_P08, 1);
+ setObjState(PIC_MAP_A14, 1);
+ }
+ break;
+ case SC_16:
+ setObjState(PIC_MAP_S16, 1);
+ break;
+ case SC_17:
+ setObjState(PIC_MAP_S17, 1);
+ break;
+ case SC_18:
+ setObjState(PIC_MAP_S1819, 1);
+ if (entranceId == ENT_SC18_RTRUBA)
+ setObjState(PIC_MAP_P14, 1);
+ break;
+ case SC_19:
+ setObjState(PIC_MAP_S1819, 1);
+ if (entranceId == ENT_SC19_RTRUBA3) {
+ setObjState(PIC_MAP_P15, 1);
+ setObjState(PIC_MAP_A09, 1);
+ }
+ break;
+ case SC_20:
+ setObjState(PIC_MAP_S20, 1);
+ break;
+ case SC_21:
+ setObjState(PIC_MAP_S21, 1);
+ if (entranceId == TrubaLeft) {
+ setObjState(PIC_MAP_P15, 1);
+ setObjState(PIC_MAP_A09, 1);
+ } else if (entranceId == TrubaDown) {
+ setObjState(PIC_MAP_A08, 1);
+ }
+ break;
+ case SC_22:
+ setObjState(PIC_MAP_S22, 1);
+ break;
+ case SC_23:
+ if (g_ngi->getStateId(sO_UpperHatch_23) == g_ngi->getStateValue(sO_UpperHatch_23, sO_Opened)) {
+ setObjState(PIC_MAP_S23_1, 0);
+ setObjState(PIC_MAP_S23_2, 1);
+ setObjState(PIC_MAP_P07, 1);
+ } else {
+ setObjState(PIC_MAP_S23_1, 1);
+ setObjState(PIC_MAP_S23_2, 0);
+ }
+ break;
+ case SC_24:
+ setObjState(PIC_MAP_S24, 1);
+ if (entranceId == TrubaUp) {
+ setObjState(PIC_MAP_A08, 1);
+ } else if (entranceId == TrubaDown) {
+ setObjState(PIC_MAP_P13, 1);
+ setObjState(PIC_MAP_A07, 1);
+ }
+ break;
+ case SC_25:
+ setObjState(PIC_MAP_S25, 1);
+ break;
+ case SC_26:
+ setObjState(PIC_MAP_S26, 1);
+ if (entranceId == TrubaLeft) {
+ setObjState(PIC_MAP_A06, 1);
+ } else if (entranceId == TrubaUp) {
+ setObjState(PIC_MAP_P13, 1);
+ setObjState(PIC_MAP_A07, 1);
+ }
+ break;
+ case SC_27:
+ setObjState(PIC_MAP_S27, 1);
+ break;
+ case SC_28:
+ setObjState(PIC_MAP_S28, 1);
+ if (entranceId == TrubaRight)
+ setObjState(PIC_MAP_A06, 1);
+ break;
+ case SC_29:
+ setObjState(PIC_MAP_S29, 1);
+ if (entranceId == TrubaUp)
+ setObjState(PIC_MAP_A05, 1);
+ break;
+ case SC_30:
+ setObjState(PIC_MAP_S30, 1);
+ if (entranceId == TrubaLeft)
+ setObjState(PIC_MAP_P09, 1);
+ else if (entranceId == TrubaRight)
+ setObjState(PIC_MAP_A04, 1);
+ break;
+ case SC_31:
+ setObjState(PIC_MAP_S31_2, 1);
+ if (g_ngi->getStateId(sO_Cactus) == g_ngi->getStateValue(sO_Cactus, sO_HasGrown))
+ setObjState(PIC_MAP_S31_1, 1);
+ if (entranceId == TrubaRight)
+ setObjState(PIC_MAP_P09, 1);
+ break;
+ case SC_32:
+ setObjState(PIC_MAP_S32_2, 1);
+ if (g_ngi->getStateId(sO_Cactus) == g_ngi->getStateValue(sO_Cactus, sO_HasGrown))
+ setObjState(PIC_MAP_S32_1, 1);
+ break;
+ case SC_33:
+ setObjState(PIC_MAP_S33, 1);
+ break;
+ case SC_34:
+ setObjState(PIC_MAP_S34, 1);
+ if (entranceId == TrubaUp)
+ setObjState(PIC_MAP_A03, 1);
+ break;
+ case SC_35:
+ setObjState(PIC_MAP_S35, 1);
+ if (entranceId == TrubaLeft)
+ setObjState(PIC_MAP_A02, 1);
+ else if (entranceId == TrubaDown)
+ setObjState(PIC_MAP_A03, 1);
+ break;
+ case SC_36:
+ setObjState(PIC_MAP_S36, 1);
+ break;
+ case SC_37:
+ setObjState(PIC_MAP_S37, 1);
+ setObjState(PIC_MAP_A01, 1);
+ break;
+ case SC_38:
+ setObjState(PIC_MAP_S38, 1);
+ setObjState(PIC_MAP_P10, 1);
+ switch (entranceId) {
+ case TrubaUp1:
+ setObjState(PIC_MAP_P10, 1);
+ break;
+ case TrubaUp10:
+ setObjState(PIC_MAP_P17, 1);
+ break;
+ case TrubaUp15:
+ setObjState(PIC_MAP_P16, 1);
+ break;
+ case TrubaUp19:
+ setObjState(PIC_MAP_P12, 1);
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/map.h b/engines/ngi/fullpipe/map.h
new file mode 100644
index 00000000000..8b4c54adb80
--- /dev/null
+++ b/engines/ngi/fullpipe/map.h
@@ -0,0 +1,77 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_MAP_H
+#define NGI_FULLPIPE_MAP_H
+
+#include "common/array.h"
+#include "common/str.h"
+
+#include "ngi/xmlnode.h"
+
+namespace NGI {
+
+/** CMap: the state of the map pictures (visited scenes, pipes, forbidden scenes) */
+class Map {
+public:
+ /** MapItem (12 bytes) */
+ struct Item {
+ int id = 0; // +0: the picture of the scene SC_MAP
+ int state = 0; // +4: 1 = shown
+ bool dontEnter = false; // +8
+ };
+
+ Map();
+
+ /** CMap::GetSavePath (155F54): the file map.sav; CPathManager is not ported */
+ Common::String getSavePath() const;
+ /** CMap::CleanXml (155FF4): the pictures are hidden, the items are forgotten */
+ void cleanXml();
+ /** CMap::GetXmlData (156040); the XML writer is not ported */
+ void getXmlData();
+ /** CMap::SetXmlData (157B60) */
+ void setXmlData(const XmlNode &node);
+ /** CMap::Reset (157CB4): the map of a new game, the first scene and its pipe are shown */
+ void reset();
+ /** CMap::Update (157CD8): the shown scene and its entrance */
+ void update(uint sceneId, uint entranceId);
+
+ /** CMap::GetObjId, GetObjState: -1 for an index that is out of range */
+ int getObjId(int index) const;
+ int getObjState(int index) const;
+ int getNumItems() const { return _items.size(); }
+ /** CMap::GetMapItem: the index of the item with this picture id, -1 when there is none */
+ int getMapItem(uint id) const;
+ /** CMap::SetObjState (157C80): adds the item when there is none */
+ void setObjState(uint id, uint state);
+ void setDontEnter(uint id, bool dontEnter);
+ bool isDontEnter(uint id) const;
+ int getFirstEnterToSc13() const { return _firstEnterToSc13; }
+ void setFirstEnterToSc13(int value) { _firstEnterToSc13 = value; }
+
+private:
+ Common::Array<Item> _items; // +8, +12
+ int _firstEnterToSc13 = 0; // +20
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_MAP_H
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index ccfad5bb7da..8e85dc01ce4 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -91,6 +91,7 @@ MODULE_OBJS = \
fullpipe/inventorycontroller.o \
fullpipe/lift.o \
fullpipe/liftcontroller.o \
+ fullpipe/map.o \
fullpipe/notebook.o \
fullpipe/sc01controller.o \
fullpipe/sc02controller.o \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 47631e5bb9a..92aeccb6068 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -37,6 +37,7 @@
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/fpcontroller.h"
+#include "ngi/fullpipe/map.h"
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/taskmanager.h"
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 0106c64cf8b..6de77386a1a 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -95,6 +95,7 @@ class TaskManager;
class TutorialManager;
class ExitManager;
class Tremble;
+class Map;
class ArcadeInterface;
class BitmapFont;
class TextContainer;
@@ -307,6 +308,8 @@ public:
/** CSingleton<CExitManager>: the exits of the scenes (Android) */
Common::ScopedPtr<ExitManager> _exitManager;
Common::ScopedPtr<Tremble> _tremble;
+ /** CSingleton<CMap>: the state of the map of the game (Android) */
+ Common::ScopedPtr<Map> _map;
Common::ScopedPtr<ArcadeInterface> _arcadeInterface;
Common::ScopedPtr<ChapterManager> _chapterManager;
/** CNotebookController, owned by its scene (SC_NOTEBOOK) */
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 088b84c54d9..f82920adc9d 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -29,6 +29,7 @@
#include "ngi/ngi.h"
#include "ngi/fullpipe/fpcontroller.h"
+#include "ngi/fullpipe/map.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/gameloader.h"
#include "ngi/inventory.h"
@@ -1828,6 +1829,9 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
g_ngi->_tutorialManager.reset(new TutorialManager);
g_ngi->_tutorialManager->init("data/tutorials.xml");
createSceneController(SC_TUTORIAL); // CTutorialController
+ createSceneController(SC_MAP); // CMapWindow
+ g_ngi->_map.reset(new Map); // CMap, CMap::Reset
+ g_ngi->_map->reset();
g_ngi->_tremble.reset(new Tremble);
if (!g_ngi->_tremble->init("data/tremble.xml", project._objectIds))
return Common::Error(Common::kNoGameDataFoundError, "Could not read the tremble objects");
Commit: 55942394550eb5c0aa258d50c4930c25cddbbec2
https://github.com/scummvm/scummvm/commit/55942394550eb5c0aa258d50c4930c25cddbbec2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: MainMenuController (CMainMenu)
Changed paths:
A engines/ngi/fullpipe/mainmenucontroller.cpp
A engines/ngi/fullpipe/mainmenucontroller.h
engines/ngi/fullpipe/constants.h
engines/ngi/fullpipe/inventorycontroller.cpp
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/module.mk
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index a1f4cfa33f7..10c41f19dd9 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -1882,5 +1882,11 @@ namespace NGI {
#define ENT_SC18_RTRUBA 20007
#define PIC_MAP_SEL 10003
#define PIC_MAP_STOP 23001
+#define GD_MNU_DEBUG1 28123
+#define GD_MNU_DEBUG2 28124
+#define GD_MNU_DEBUG3 28125
#define TrubaLeft_fin 23274
+#define SC_CONFIRMATION 23496
+#define SC_OPTIONS 10009
+
#endif /* NGI_CONSTANTS_H */
diff --git a/engines/ngi/fullpipe/inventorycontroller.cpp b/engines/ngi/fullpipe/inventorycontroller.cpp
index b4381e57b17..06df646fe65 100644
--- a/engines/ngi/fullpipe/inventorycontroller.cpp
+++ b/engines/ngi/fullpipe/inventorycontroller.cpp
@@ -36,18 +36,6 @@
namespace NGI {
-namespace {
-
-void warnOnce(const char *what) {
- static Common::HashMap<Common::String, bool> reported;
- if (!reported.contains(what)) {
- reported[what] = true;
- warning("STUB/untested: %s", what);
- }
-}
-
-} // End of anonymous namespace
-
// CInventoryController::CInventoryController
InventoryController::InventoryController(int sceneId) : ISceneController(sceneId) {
}
@@ -202,8 +190,7 @@ void InventoryController::onShow() {
}
}
-// CInventoryController::OnGuiEvent. The map (SC_MAP), the main menu (SC_MAINMENU) and the hint helper are not ported (STUB warnings). The tutorial
-// scene on the stack is popped first by the buttons that leave it.
+// CInventoryController::OnGuiEvent: the buttons that leave pop the tutorial scene first
void InventoryController::onGuiEvent(const Common::String &id, const Common::String &event) {
debugC(2, kDebugEvents, "InventoryController::onGuiEvent(%s, %s)", id.c_str(), event.c_str());
if (event != "unpress")
@@ -223,7 +210,7 @@ void InventoryController::onGuiEvent(const Common::String &id, const Common::Str
if (id == "PIC_INV_ESC") {
if (current->_sceneId == SC_TUTORIAL)
g_ngi->popScene();
- warnOnce("CGame::PushScene(SC_MAINMENU): the main menu of the Android build is not ported");
+ g_ngi->pushScene(SC_MAINMENU);
return;
}
if (id == "PIC_INV_HELPER_ACTIONS" || id == "PIC_INV_HELPER_BUBBLE") {
diff --git a/engines/ngi/fullpipe/mainmenucontroller.cpp b/engines/ngi/fullpipe/mainmenucontroller.cpp
new file mode 100644
index 00000000000..f5112d5ac19
--- /dev/null
+++ b/engines/ngi/fullpipe/mainmenucontroller.cpp
@@ -0,0 +1,375 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/ngi.h"
+#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/guimanager.h"
+#include "ngi/interaction.h"
+#include "ngi/inventory.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
+#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/mainmenucontroller.h"
+#include "ngi/fullpipe/map.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+namespace {
+
+// CSettings::GetIsFull: the settings are not ported, the game counts as the full version
+bool settingsIsFull() {
+ warnOnce("CSettings::GetIsFull: the settings are not ported (the game counts as the full version)");
+ return true;
+}
+
+// CSettings::IsChapterUnlocked
+bool settingsIsChapterUnlocked(int chapter) {
+ warnOnce("CSettings::IsChapterUnlocked: the settings are not ported (no chapter is locked)");
+ return true;
+}
+
+// CDebugger::IsCheater: the debug class is not ported
+bool debuggerIsCheater() {
+ warnOnce("CDebugger::IsCheater: the debug class is not ported (the player is not a cheater)");
+ return false;
+}
+
+// the platform services (PP_FB_isConnected, PP_GC_IsAuthorized ...): none, nothing is connected
+bool platformService(const char *name) {
+ warnOnce(Common::String::format("%s: the platform services of the Android application are not ported", name).c_str());
+ return false;
+}
+
+// CGame::SetScene(sceneId, entranceId)
+void setScene(int sceneId, int entranceId) {
+ g_ngi->_gameLoader->preloadScene(sceneId, entranceId);
+}
+
+// the element of the GUI of the scene (CGuiManager::GetElement of the GUI of the menu)
+GuiElement *guiElement(Scene *scene, const char *id) {
+ return scene && scene->_guiManager ? scene->_guiManager->getElement(id) : nullptr;
+}
+
+// CScene::FindVisibleObject (11FE44), CScene::GetVisObjVHit (11FDE0)
+GameObject *findVisibleObjectAt(Scene *scene, float x, float y) {
+ GameObject *found = nullptr;
+ for (PictureObject *picture : scene->_pictureObjects) {
+ if ((picture->_flags & 4) && picture->hit((int)x, (int)y) && (!found || picture->_z < found->_z))
+ found = picture;
+ }
+ for (PictureObject *picture : scene->_roamingPictures) {
+ if ((picture->_flags & 4) && picture->hit((int)x, (int)y) && (!found || picture->_z < found->_z))
+ found = picture;
+ }
+ for (AniObject *ani : scene->_renderableAnis) {
+ if ((ani->_flags & 4) && ani->hit((int)x, (int)y) && (!found || ani->_z < found->_z))
+ found = ani;
+ }
+ return found;
+}
+
+// SC_CONFIRMATION (CConfirmationDlg, +40: 1 exits, 2 restarts), options and upsell scenes
+void pushDialog(int sceneId, int mode) {
+ warnOnce(Common::String::format("CGame::PushScene(%d) (mode %d): the controller of the scene (CConfirmationDlg, CScOptionsController, CUpsellController) is not ported, the scene is not pushed", sceneId, mode).c_str());
+}
+
+} // End of anonymous namespace
+
+// CMainMenu::CMainMenu (19AA98)
+MainMenuController::MainMenuController(int sceneId) : FPGuiController(sceneId) {
+}
+
+// CMainMenu::CleanXml (19A760)
+void MainMenuController::cleanXml() {
+ _tutorial = "";
+}
+
+// CMainMenu::CheckTutorial (19B484)
+void MainMenuController::checkTutorial() {
+ TutorialManager *manager = g_ngi->_tutorialManager.get();
+ if (!manager->isActive() || _tutorial == "UNDEF" || g_ngi->_sceneStack.size() != 2)
+ return;
+ if (!manager->activateTutorial(_tutorial))
+ _tutorial = "UNDEF";
+}
+
+// CMainMenu::RestartGame (19B4F8); the settings and the load list are not ported
+void MainMenuController::restartGame() {
+ ArcadeInterface &arcade = g_ngi->arcadeInterface();
+ if (arcade.getState() != ArcadeInterface::kHidden)
+ arcade.scrollOut();
+
+ Scene *intro = g_ngi->findScene(SC_INTRO1);
+ if (intro)
+ intro->message("MSG_RESTART_GAME", "", nullptr);
+
+ while (g_ngi->_sceneStack.size() >= 2) {
+ Scene *scene = g_ngi->getSceneInStack(0);
+ if (scene) {
+ if (scene->_sceneId == SC_NOTEBOOK) {
+ if (scene->_controller)
+ scene->_controller->onHide();
+ } else {
+ scene->removeCopies();
+ scene->stopAllQueues();
+ }
+ }
+ g_ngi->removeSceneInStack(0);
+ }
+
+ setSaving(true); // CBaseSettings::SetSaving(1) when the saving flag (CSettings +28) is 0
+ warnOnce("CGame::CleanXml(0): not ported (the load list of the scenes, CInventory::CleanXml, CInteractionController::CleanXml and the CleanXml of the scenes)");
+ warnOnce("CStateManager::CleanXml (CStateManager::SetStartStates): not ported");
+ if (g_ngi->_exitManager)
+ g_ngi->_exitManager->cleanXml();
+ if (g_ngi->_taskManager)
+ g_ngi->_taskManager->cleanXml();
+ if (g_ngi->_tutorialManager)
+ g_ngi->_tutorialManager->cleanXml();
+ warnOnce("CAchievementsManager::CleanXml: the achievements manager is not a singleton here");
+ if (g_ngi->_chapterManager)
+ g_ngi->_chapterManager->cleanXml();
+ warnOnce("CCatalogManager::CleanXml: the catalog is not ported");
+ if (g_ngi->_map)
+ g_ngi->_map->cleanXml();
+ warnOnce("CHelp::CleanXml and CHintManager::CleanXml: not hooked here (ported separately)");
+ warnOnce("CTremble::CleanXml: not ported");
+ // CFlurryEventManager::CleanXml: the analytics are not ported
+ g_ngi->arcadeInterface().cleanProgress();
+
+ warnOnce("CGame::AddScenesInLoadList, CSettings::Save, CGame::ClearLoadList: the load list of the scenes and the settings are not ported");
+ setScene(SC_INTRO1, 0);
+ warnOnce("CObjHelperManager::SetObjHelperCount(0): not hooked here (ported separately)");
+ if (g_ngi->_inventory && g_ngi->_inventory->_guiManager)
+ g_ngi->_inventory->_guiManager->deselectAll();
+ warnOnce("CSettings::SetIsCompleted(0): the settings are not ported");
+}
+
+// CMainMenu::EnableDebugMenu (19BCC4)
+void MainMenuController::enableDebugMenu() {
+ GuiElement *button = guiElement(_scene, "BTN_MNU_DEBUG");
+ if (!button)
+ return;
+ if (g_ngi->_gameLoader->_interactionController->_enabled)
+ button->showAndActivate();
+ else
+ button->hideAndDeactivate();
+}
+
+// CMainMenu::InitButtons (19BD58)
+void MainMenuController::initButtons() {
+ GuiElement *button = nullptr;
+ if (settingsIsFull() || settingsIsChapterUnlocked(9)) {
+ if ((button = guiElement(_scene, "BTN_MNU_CONTINUE")))
+ button->setPos(Common::Point(197, 147));
+ if ((button = guiElement(_scene, "BTN_MNU_RESTART")))
+ button->setPos(Common::Point(264, 222));
+ if ((button = guiElement(_scene, "BTN_MNU_GC")))
+ button->setPos(Common::Point(372, 492));
+ if ((button = guiElement(_scene, "BTN_MNU_GC")))
+ button->showAndActivate();
+ if ((button = guiElement(_scene, "BTN_MNU_MAIL")))
+ button->hide();
+ if ((button = guiElement(_scene, "BTN_MNU_ACHIEVE")))
+ button->setPos(Common::Point(242, 297));
+ if ((button = guiElement(_scene, "BTN_MNU_GET_FULL")))
+ button->hideAndDeactivate();
+ } else {
+ if ((button = guiElement(_scene, "BTN_MNU_CONTINUE")))
+ button->setPos(Common::Point(197, 107));
+ if ((button = guiElement(_scene, "BTN_MNU_RESTART")))
+ button->setPos(Common::Point(264, 182));
+ if ((button = guiElement(_scene, "BTN_MNU_GC")))
+ button->setPos(Common::Point(372, 492));
+ if ((button = guiElement(_scene, "BTN_MNU_GC")))
+ button->showAndActivate();
+ if ((button = guiElement(_scene, "BTN_MNU_MAIL")))
+ button->hide();
+ if ((button = guiElement(_scene, "BTN_MNU_ACHIEVE")))
+ button->setPos(Common::Point(242, 257));
+ if ((button = guiElement(_scene, "BTN_MNU_GET_FULL")))
+ button->showAndActivate();
+ }
+
+ const bool connected = platformService("PP_FB_isConnected");
+ if ((button = guiElement(_scene, "BTN_MNU_FACEBOOK"))) {
+ if (connected)
+ button->deactivate();
+ else
+ button->activate();
+ }
+}
+
+// CMainMenu::OnShow (19C07C); analytics and Upsight are not ported
+void MainMenuController::onShow() {
+ FPGuiController::onShow();
+ _field16 = false;
+ if (debuggerIsCheater())
+ enableDebugMenu();
+ initButtons();
+ _facebookTimer = 0;
+ _debugSequence.clear();
+}
+
+// CMainMenu::OnUpdate (19C850)
+void MainMenuController::onUpdate(uint32 elapsed) {
+ FPGuiController::onUpdate(elapsed);
+ checkTutorial();
+ if (_facebookTimer != -1) {
+ _facebookTimer += elapsed;
+ if (_facebookTimer > 499) {
+ _facebookTimer = 0;
+ const bool connected = platformService("PP_FB_isConnected");
+ if (GuiElement *button = guiElement(_scene, "BTN_MNU_FACEBOOK")) {
+ if (connected)
+ button->deactivate();
+ else
+ button->activate();
+ }
+ }
+ }
+}
+
+// CMainMenu::OnRender (19ABCC)
+void MainMenuController::onRender(Common::Point scroll) {
+ if (_debugSequence.size() == 3)
+ warnOnce("CMainMenu::OnRender: CFontController::GetFont(dbg.xml) and CFont::Print are not ported (the text of the debug purchases is not drawn)");
+}
+
+// CMainMenu::OnMessage (19C16C)
+void MainMenuController::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (message == "MSG_RESTART_GAME") {
+ restartGame();
+ } else if (message == "MSG_EXIT") {
+ g_ngi->quitGame(); // CGame::ExitGame
+ } else if (message == "MSG_SKIP_PURCHASE" || message == "MSG_INIT_BUTTONS") {
+ initButtons();
+ } else if (message == "PURCHASE_COMPLETED") {
+ warnOnce("CSettings::GetUnlockId and SetIsFull: the settings are not ported (no purchase unlocks the full version)");
+ const Common::String unlockId; // CSettings::GetUnlockId
+ if (param == unlockId) {
+ initButtons();
+ } else {
+ warnOnce("CNotebookController::OnPurchaseCompleted: not ported");
+ }
+ }
+}
+
+// CMainMenu::OnGuiEvent (19B9E4); the platform services are not ported
+void MainMenuController::onGuiEvent(const Common::String &id, const Common::String &event) {
+ if (event == "unpress") {
+ if (id == "BTN_MNU_DEBUG") {
+ setScene(SC_DBGMENU, 0);
+ } else if (id == "BTN_MNU_CONTINUE") {
+ if (g_ngi->_sceneStack.size() < 2) {
+ setScene(SC_1, TrubaLeft_fin);
+ } else {
+ if (g_ngi->getCurrentScene()->_sceneId == SC_TUTORIAL)
+ g_ngi->popScene();
+ if (g_ngi->getCurrentScene() == _scene)
+ g_ngi->popScene();
+ }
+ } else if (id == "BTN_MNU_RESTART") {
+ pushDialog(SC_CONFIRMATION, 2);
+ } else if (id == "BTN_MNU_ACHIEVE" || id == "BTN_MNU_GC") {
+ // PP_CheckInternetConnection, PP_GC_IsAuthorized, PP_GC_ShowAchievements / PP_GC_Authenticate
+ if (platformService("PP_CheckInternetConnection")) {
+ if (platformService("PP_GC_IsAuthorized"))
+ platformService("PP_GC_ShowAchievements");
+ else
+ platformService("PP_GC_Authenticate");
+ }
+ } else if (id == "BTN_MNU_OPTIONS") {
+ pushDialog(SC_OPTIONS, 0);
+ } else if (id == "BTN_MNU_REVIEW") {
+ platformService("PP_OpenLink (CSettings::GetReviewLink)");
+ } else if (id == "BTN_MNU_MAIL") {
+ platformService("PP_OpenLink (CSettings::GetMailLink)");
+ } else if (id == "BTN_MNU_FACEBOOK") {
+ if (!platformService("PP_FB_isConnected")) {
+ platformService("PP_FB_Login");
+ } else if (GuiElement *button = guiElement(_scene, "BTN_MNU_FACEBOOK")) {
+ button->deactivate();
+ }
+ } else if (id == "BTN_MNU_MORE_GAMES") {
+ if (platformService("PP_CheckInternetConnection"))
+ platformService("PP_UpsightContent");
+ } else if (id == "BTN_MNU_GET_FULL") {
+ pushDialog(SC_UPSELL, 0);
+ }
+ }
+
+ if (event == "unpress_unactive") {
+ if (id == "BTN_MNU_FACEBOOK") {
+ if (platformService("PP_FB_isConnected")) {
+ platformService("PP_FB_Logout");
+ } else if (GuiElement *button = guiElement(_scene, "BTN_MNU_FACEBOOK")) {
+ button->activate();
+ }
+ } else if (id == "BTN_MNU_GC") {
+ if (platformService("PP_GC_IsAuthorized")) {
+ platformService("PP_GC_SignOut");
+ } else if (GuiElement *button = guiElement(_scene, "BTN_MNU_GC")) {
+ button->activate();
+ }
+ }
+ }
+}
+
+// CMainMenu::OnKeyUp (19ACF8)
+void MainMenuController::onKeyUp(uint32 key) {
+ if (key == 4) // AKEYCODE_BACK
+ pushDialog(SC_CONFIRMATION, 1);
+}
+
+// CMainMenu::OnMouseLKeyDown (19A6F4)
+bool MainMenuController::onMouseLKeyDown(uint32 id, float x, float y) {
+ return true;
+}
+
+// CMainMenu::OnMouseLKeyUp (19C7C0)
+bool MainMenuController::onMouseLKeyUp(uint32 id, float x, float y) {
+ GameObject *object = findVisibleObjectAt(_scene, x, y);
+ if (!object || (uint)(object->_id - GD_MNU_DEBUG1) > 2) {
+ _debugSequence.clear();
+ return true;
+ }
+
+ if (!_debugSequence.empty()) {
+ if (_debugSequence.back() + 1 == object->_id)
+ _debugSequence.push_back(_debugSequence.back() + 1);
+ } else if (object->_id == GD_MNU_DEBUG1) {
+ _debugSequence.push_back(GD_MNU_DEBUG1);
+ }
+
+ if (_debugSequence.size() == 3)
+ warnOnce("CSettings::SetDebugPurchase and PreSave: the settings are not ported");
+ return true;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/mainmenucontroller.h b/engines/ngi/fullpipe/mainmenucontroller.h
new file mode 100644
index 00000000000..f97250bb184
--- /dev/null
+++ b/engines/ngi/fullpipe/mainmenucontroller.h
@@ -0,0 +1,68 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_MAINMENUCONTROLLER_H
+#define NGI_FULLPIPE_MAINMENUCONTROLLER_H
+
+#include "common/array.h"
+#include "common/str.h"
+
+#include "ngi/fullpipe/fpguicontroller.h"
+
+namespace NGI {
+
+class GameObject;
+
+/** CMainMenu: the scene SC_MAINMENU; field offsets as in the original */
+class MainMenuController : public FPGuiController {
+public:
+ explicit MainMenuController(int sceneId);
+
+ /** CMainMenu::CleanXml (19A760): the tutorial is empty again */
+ void cleanXml() override;
+ /** CMainMenu::CheckTutorial (19B484), called by OnUpdate */
+ void checkTutorial();
+ /** CMainMenu::RestartGame (19B4F8): MSG_RESTART_GAME, a new game */
+ void restartGame();
+ /** CMainMenu::EnableDebugMenu (19BCC4): the button BTN_MNU_DEBUG (the debug scene) */
+ void enableDebugMenu();
+ /** CMainMenu::InitButtons (19BD58) */
+ void initButtons();
+
+ void onShow() override;
+ void onUpdate(uint32 elapsed) override;
+ void onRender(Common::Point scroll) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+ void onGuiEvent(const Common::String &id, const Common::String &event) override;
+ void onKeyUp(uint32 key) override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+
+private:
+ bool _field16 = false; // +16: set to 0 by the constructor and OnShow, never read
+ Common::String _tutorial; // +20: nothing sets it, CheckTutorial turns it into "UNDEF"
+ int _facebookTimer = -1; // +24: ms since the buttons were set up, -1 before OnShow
+ Common::Array<int> _debugSequence; // +28: the debug grid objects pressed, in order
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_MAINMENUCONTROLLER_H
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index 8d5edc881b6..b36b9e89323 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -39,6 +39,7 @@
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/inventorycontroller.h"
#include "ngi/fullpipe/liftcontroller.h"
+#include "ngi/fullpipe/mainmenucontroller.h"
#include "ngi/fullpipe/tutorialcontroller.h"
#include "ngi/fullpipe/tutorialmanager.h"
#include "ngi/inventory.h"
@@ -400,6 +401,9 @@ void createSceneController(int sceneId) {
case SC_TUTORIAL:
new TutorialController(sceneId);
break;
+ case SC_MAINMENU:
+ new MainMenuController(sceneId);
+ break;
case 0: // the inventory scene (CGame +116)
new InventoryController(sceneId);
break;
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 8e85dc01ce4..78885d21b66 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -91,6 +91,7 @@ MODULE_OBJS = \
fullpipe/inventorycontroller.o \
fullpipe/lift.o \
fullpipe/liftcontroller.o \
+ fullpipe/mainmenucontroller.o \
fullpipe/map.o \
fullpipe/notebook.o \
fullpipe/sc01controller.o \
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index f82920adc9d..8d8719f1b8e 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -1829,6 +1829,7 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
g_ngi->_tutorialManager.reset(new TutorialManager);
g_ngi->_tutorialManager->init("data/tutorials.xml");
createSceneController(SC_TUTORIAL); // CTutorialController
+ createSceneController(SC_MAINMENU); // CMainMenu
createSceneController(SC_MAP); // CMapWindow
g_ngi->_map.reset(new Map); // CMap, CMap::Reset
g_ngi->_map->reset();
Commit: 774217209ad296b02d87a33bc22b1d3e424be15c
https://github.com/scummvm/scummvm/commit/774217209ad296b02d87a33bc22b1d3e424be15c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: MapWindowController (CMapWindow), the TUTORIAL_USE_MAP zone
Changed paths:
A engines/ngi/fullpipe/mapwindowcontroller.cpp
A engines/ngi/fullpipe/mapwindowcontroller.h
engines/ngi/fullpipe/inventorycontroller.cpp
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/fullpipe/tutorialcontroller.cpp
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/inventorycontroller.cpp b/engines/ngi/fullpipe/inventorycontroller.cpp
index 06df646fe65..43ad6eb9a6b 100644
--- a/engines/ngi/fullpipe/inventorycontroller.cpp
+++ b/engines/ngi/fullpipe/inventorycontroller.cpp
@@ -204,7 +204,7 @@ void InventoryController::onGuiEvent(const Common::String &id, const Common::Str
current = g_ngi->getCurrentScene();
if (current->_sceneId == SC_NOTEBOOK)
g_ngi->popScene();
- warnOnce("CGame::PushScene(SC_MAP): the map is not ported");
+ g_ngi->pushScene(SC_MAP);
return;
}
if (id == "PIC_INV_ESC") {
diff --git a/engines/ngi/fullpipe/mapwindowcontroller.cpp b/engines/ngi/fullpipe/mapwindowcontroller.cpp
new file mode 100644
index 00000000000..81b3eb08151
--- /dev/null
+++ b/engines/ngi/fullpipe/mapwindowcontroller.cpp
@@ -0,0 +1,650 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/util.h"
+
+#include "ngi/ngi.h"
+#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/input.h"
+#include "ngi/scene.h"
+#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
+#include "ngi/fullpipe/map.h"
+#include "ngi/fullpipe/mapwindowcontroller.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+namespace {
+
+// CGame::SetScene(sceneId, entranceId)
+void setScene(int sceneId, int entranceId) {
+ g_ngi->_gameLoader->preloadScene(sceneId, entranceId);
+}
+
+// CStateManager::GetState(object) == the state
+bool hasState(const char *object, const char *state) {
+ return g_ngi->getStateId(object) == g_ngi->getStateValue(object, state);
+}
+
+} // End of anonymous namespace
+
+// CMapWindow::CMapWindow (1563E0)
+MapWindowController::MapWindowController(int sceneId) : FPGuiController(sceneId) {
+}
+
+// CMapWindow::CleanXml (155F40)
+void MapWindowController::cleanXml() {
+ _tutorial = "TUTORIAL_USE_MAP";
+}
+
+// CMapWindow::GetSceneId (156470): word_2D4F54, pictures from PIC_MAP_S01 (5223) on
+int MapWindowController::getSceneId(int pictureId) const {
+ static const int16 scenes[40] = {
+ SC_1, SC_2, SC_3, SC_4, SC_5, SC_6, SC_7, SC_9, SC_8, SC_10,
+ SC_11, SC_12, SC_13, SC_14, SC_15, SC_16, SC_17, SC_18, SC_20, SC_21,
+ SC_22, SC_23, SC_23, SC_24, SC_25, SC_26, SC_27, SC_28, SC_29, SC_30,
+ SC_31, SC_31, SC_32, SC_32, SC_33, SC_34, SC_35, SC_36, SC_37, SC_38
+ };
+ const uint index = pictureId - PIC_MAP_S01;
+ if (index < ARRAYSIZE(scenes))
+ return scenes[index];
+ return 0;
+}
+
+// CMapWindow::GetCurrentScene (156680): SC_18 and SC_19 share a picture, the last scene uses 38's
+PictureObject *MapWindowController::getCurrentScene() const {
+ int pictureId;
+ switch (g_ngi->getSceneInStack(0)->_sceneId) {
+ case SC_1:
+ pictureId = PIC_MAP_S01;
+ break;
+ case SC_2:
+ pictureId = PIC_MAP_S02;
+ break;
+ case SC_3:
+ pictureId = PIC_MAP_S03;
+ break;
+ case SC_4:
+ pictureId = PIC_MAP_S04;
+ break;
+ case SC_5:
+ pictureId = PIC_MAP_S05;
+ break;
+ case SC_6:
+ pictureId = PIC_MAP_S06;
+ break;
+ case SC_7:
+ pictureId = PIC_MAP_S07;
+ break;
+ case SC_8:
+ pictureId = PIC_MAP_S08;
+ break;
+ case SC_9:
+ pictureId = PIC_MAP_S09;
+ break;
+ case SC_10:
+ pictureId = PIC_MAP_S10;
+ break;
+ case SC_11:
+ pictureId = PIC_MAP_S11;
+ break;
+ case SC_12:
+ pictureId = PIC_MAP_S12;
+ break;
+ case SC_13:
+ pictureId = PIC_MAP_S13;
+ break;
+ case SC_14:
+ pictureId = PIC_MAP_S14;
+ break;
+ case SC_15:
+ pictureId = PIC_MAP_S15;
+ break;
+ case SC_16:
+ pictureId = PIC_MAP_S16;
+ break;
+ case SC_17:
+ pictureId = PIC_MAP_S17;
+ break;
+ case SC_18:
+ case SC_19:
+ pictureId = PIC_MAP_S1819;
+ break;
+ case SC_20:
+ pictureId = PIC_MAP_S20;
+ break;
+ case SC_21:
+ pictureId = PIC_MAP_S21;
+ break;
+ case SC_22:
+ pictureId = PIC_MAP_S22;
+ break;
+ case SC_23:
+ pictureId = PIC_MAP_S23_1;
+ break;
+ case SC_24:
+ pictureId = PIC_MAP_S24;
+ break;
+ case SC_25:
+ pictureId = PIC_MAP_S25;
+ break;
+ case SC_26:
+ pictureId = PIC_MAP_S26;
+ break;
+ case SC_27:
+ pictureId = PIC_MAP_S27;
+ break;
+ case SC_28:
+ pictureId = PIC_MAP_S28;
+ break;
+ case SC_29:
+ pictureId = PIC_MAP_S29;
+ break;
+ case SC_30:
+ pictureId = PIC_MAP_S30;
+ break;
+ case SC_31:
+ pictureId = PIC_MAP_S31_1;
+ break;
+ case SC_32:
+ pictureId = PIC_MAP_S32_1;
+ break;
+ case SC_33:
+ pictureId = PIC_MAP_S33;
+ break;
+ case SC_34:
+ pictureId = PIC_MAP_S34;
+ break;
+ case SC_35:
+ pictureId = PIC_MAP_S35;
+ break;
+ case SC_36:
+ pictureId = PIC_MAP_S36;
+ break;
+ case SC_37:
+ pictureId = PIC_MAP_S37;
+ break;
+ case SC_38:
+ case SC_FINAL1:
+ pictureId = PIC_MAP_S38;
+ break;
+ default:
+ return nullptr;
+ }
+ return _scene->findPictureObjectById(pictureId, 0);
+}
+
+// CMapWindow::GetEntrId (156990): scenes 13 and 25 depend on the scene below, 29 on its left pipe
+int MapWindowController::getEntrId(int pictureId) const {
+ const int below = g_ngi->getSceneInStack(0)->_sceneId;
+ switch (pictureId) {
+ case PIC_MAP_S01:
+ case PIC_MAP_S08:
+ case PIC_MAP_S12:
+ case PIC_MAP_S14:
+ case PIC_MAP_S20:
+ case PIC_MAP_S28:
+ case PIC_MAP_S30:
+ case PIC_MAP_S31_1:
+ case PIC_MAP_S31_2:
+ case PIC_MAP_S32_1:
+ case PIC_MAP_S32_2:
+ case PIC_MAP_S36:
+ case PIC_MAP_S37:
+ return TrubaRight;
+ case PIC_MAP_S02:
+ case PIC_MAP_S03:
+ case PIC_MAP_S04:
+ case PIC_MAP_S05:
+ case PIC_MAP_S07:
+ case PIC_MAP_S09:
+ case PIC_MAP_S10:
+ case PIC_MAP_S11:
+ case PIC_MAP_S16:
+ case PIC_MAP_S1819:
+ case PIC_MAP_S21:
+ case PIC_MAP_S27:
+ case PIC_MAP_S33:
+ case PIC_MAP_S35:
+ return TrubaLeft;
+ case PIC_MAP_S06:
+ case PIC_MAP_S15:
+ case PIC_MAP_S17:
+ case PIC_MAP_S26:
+ case PIC_MAP_S34:
+ return TrubaUp;
+ case PIC_MAP_S13:
+ if (below == SC_11)
+ return TrubaUp;
+ return TrubaLeft;
+ case PIC_MAP_S22:
+ case PIC_MAP_S23_1:
+ case PIC_MAP_S23_2:
+ case PIC_MAP_S24:
+ return TrubaDown;
+ case PIC_MAP_S25:
+ if (below != SC_27)
+ return TrubaUp;
+ return TrubaRight;
+ case PIC_MAP_S29:
+ if (hasState(sO_LeftPipe_29, sO_IsOpened))
+ return TrubaLeft;
+ return TrubaUp;
+ case PIC_MAP_S38:
+ return TrubaUp1;
+ default:
+ return 0;
+ }
+}
+
+// CMapWindow::GetVisibleCount (156AA0)
+int MapWindowController::getVisibleCount() const {
+ Map *map = g_ngi->_map.get();
+ int count = 0;
+ for (int i = 0; i < map->getNumItems(); i++)
+ count += map->getObjState(i) == 1;
+ return count;
+}
+
+// CMapWindow::BlockScenes (156AD0): needs the hero in the scene
+void MapWindowController::blockScenes() {
+ Scene *below = g_ngi->getSceneInStack(0);
+ if (!below)
+ return;
+ if (!below->findAniObjectById(ANI_MAN, 0))
+ return;
+
+ Map *map = g_ngi->_map.get();
+ const int sceneId = below->_sceneId;
+ const int count = map->getNumItems();
+
+ if (sceneId == SC_27) {
+ for (int i = 0; i < count; i++) {
+ const int objectId = map->getObjId(i);
+ const int scene = getSceneId(objectId);
+ map->setDontEnter(objectId, !(scene == SC_25 || scene == SC_27));
+ }
+ return;
+ }
+
+ if (sceneId == SC_25) {
+ bool block = false;
+ if (hasState(sO_Pool, sO_HalfFull) || hasState(sO_Pool, sO_Empty))
+ block = _blockAll;
+ if (block) {
+ for (int i = 0; i < count; i++) {
+ const int objectId = map->getObjId(i);
+ map->setDontEnter(objectId, getSceneId(objectId) != SC_25);
+ }
+ return;
+ }
+ }
+
+ if (sceneId == SC_25) {
+ bool halfFull = false;
+ if (hasState(sO_Pool, sO_HalfFull))
+ halfFull = !_blockAll;
+ if (halfFull) {
+ for (int i = 0; i < count; i++) {
+ const int objectId = map->getObjId(i);
+ map->setDontEnter(objectId, getSceneId(objectId) == SC_27);
+ }
+ return;
+ }
+ }
+
+ if (sceneId == SC_13 && map->getFirstEnterToSc13() == 1) {
+ for (int i = 0; i < count; i++) {
+ const int objectId = map->getObjId(i);
+ map->setDontEnter(objectId, getSceneId(objectId) != SC_13);
+ }
+ } else if (hasState(sO_Pool, sO_Full) || hasState(sO_Pool, sO_Overfull)) {
+ for (int i = 0; i < count; i++) {
+ const int objectId = map->getObjId(i);
+ const int scene = getSceneId(objectId);
+ map->setDontEnter(objectId, scene == SC_25 || scene == SC_27);
+ }
+ } else {
+ for (int i = 0; i < count; i++) {
+ const int objectId = map->getObjId(i);
+ map->setDontEnter(objectId, getSceneId(objectId) == SC_27);
+ }
+ }
+}
+
+// CMapWindow::UnblockAllScenes (156EDC)
+void MapWindowController::unblockAllScenes() {
+ Map *map = g_ngi->_map.get();
+ for (int i = 0; i < map->getNumItems(); i++)
+ map->setDontEnter(map->getObjId(i), false);
+}
+
+// CMapWindow::SetScroll (156FB4): stays inside the scene unless the wide bars are shown
+void MapWindowController::setScroll(float x, float y) {
+ _scrollY = y;
+ _scrollX = x;
+ _scene->_x = x;
+ _scene->_y = y;
+ if (_scene->hasWidescreenBars())
+ return;
+
+ const float margin = g_ngi->_wideOfs;
+ if (_scene->_x < margin)
+ _scene->_x = margin;
+ if (_scene->_y < 0.0f)
+ _scene->_y = 0.0f;
+ if (_scene->_x > (float)(_scene->_dims.x - g_ngi->gameWidth()) - margin)
+ _scene->_x = (float)(_scene->_dims.x - g_ngi->gameWidth()) - margin;
+ if (_scene->_y > (float)(_scene->_dims.y - g_ngi->_backgroundSurface.h))
+ _scene->_y = (float)(_scene->_dims.y - g_ngi->_backgroundSurface.h);
+}
+
+// CMapWindow::CheckTutorial (1570D4)
+void MapWindowController::checkTutorial() {
+ if ((!g_ngi->_tutorialManager->isActive() && _tutorial != "EXTRA_TUTORIAL_USE_MAP") || _tutorial == "UNDEF")
+ return;
+ if (g_ngi->_sceneStack.size() != 2 || getVisibleCount() <= 2)
+ return;
+ if (_tutorial == "TUTORIAL_USE_MAP") {
+ if (!g_ngi->_tutorialManager->activateTutorial(_tutorial))
+ _tutorial = "UNDEF";
+ } else if (_tutorialTime >= 5.0f) {
+ if (!g_ngi->_tutorialManager->activateTutorial(_tutorial))
+ _tutorial = "UNDEF";
+ }
+}
+
+// CMapWindow::OnShow (1571B8); the analytics events (CFlurryEventManager) are not ported
+void MapWindowController::onShow() {
+ _touching = false;
+ _stopShown = false;
+ _touchCount = 0;
+ _multiTouch = false;
+
+ Map *map = g_ngi->_map.get();
+ const int count = map->getNumItems();
+ for (int i = 0; i < count; i++) {
+ const int objectId = map->getObjId(i);
+ if (objectId == -1)
+ continue;
+ PictureObject *picture = _scene->findPictureObjectById(objectId, 0);
+ if (picture) {
+ if (map->getObjState(i) == 1)
+ picture->_flags |= 4;
+ else
+ picture->_flags &= ~4;
+ }
+ }
+
+ _stopSign = _scene->findPictureObjectById(PIC_MAP_STOP, 0);
+ PictureObject *current = getCurrentScene();
+ if (current) {
+ // the scroll puts the picture of the scene below into the middle of the screen
+ const Common::Point position = current->getPosition();
+ const Common::Point size = current->getSize();
+ const float scrollX = (position.x + size.x * 0.5f) - (float)(g_ngi->gameWidth() >> 1);
+ const float scrollY = (position.y + size.y * 0.5f) - (float)(g_ngi->_backgroundSurface.h >> 1);
+ setScroll(scrollX, scrollY);
+
+ // PIC_MAP_I02 and PIC_MAP_I01 (1 pixel higher) mark the scene below
+ _marker = _scene->findPictureObjectById(PIC_MAP_I02, 0);
+ const float markerX = (position.x + size.x * 0.5f) - _marker->getSize().x * 0.5f;
+ const float markerY = ((position.y + size.y) - _marker->getSize().y * 0.5f) - 24.0f;
+ _marker->setPosition(Common::Point(markerX, markerY));
+ _marker->_z = -1001;
+ _marker->_flags |= 4;
+
+ _marker = _scene->findPictureObjectById(PIC_MAP_I01, 0);
+ const float secondX = (position.x + size.x * 0.5f) - _marker->getSize().x * 0.5f;
+ const float secondY = (((position.y + size.y) - _marker->getSize().y * 0.5f) - 24.0f) - 1.0f;
+ _marker->setPosition(Common::Point(secondX, secondY));
+ _marker->_z = -1001;
+ _marker->_flags |= 4;
+ }
+ _hitObject = nullptr;
+ blockScenes();
+
+ if (_tutorial != "UNDEF" && _tutorial != "AFTER_TUTORIAL_USE_MAP") {
+ if (g_ngi->_tutorialManager->isTutorialCompleted()) {
+ _tutorial = "EXTRA_TUTORIAL_USE_MAP";
+ _tutorialTime = 0;
+ }
+ }
+ _selection = _scene->findPictureObjectById(PIC_MAP_SEL, 0);
+}
+
+// CMapWindow::OnHide (156F0C)
+void MapWindowController::onHide() {
+ _touchCount = 0;
+ _multiTouch = false;
+ unblockAllScenes();
+}
+
+// CMapWindow::OnUpdate (1576B0)
+void MapWindowController::onUpdate(uint32 elapsed) {
+ if (_tutorialTime != -1.0f)
+ _tutorialTime = _tutorialTime + (float)elapsed / 1000.0f;
+
+ g_ngi->arcadeInterface().update(elapsed);
+
+ const float hotX = g_ngi->_inputController->_hotScreenX; // CCursorController +64
+ const float hotY = g_ngi->_inputController->_hotScreenY; // +68
+ if (_touching && !_pointerMoved) {
+ const float previousTouchY = _touchY;
+ const float x = _scrollStartX - (hotX - _touchX);
+ const float y = _scrollStartY - (hotY - previousTouchY);
+ if (x < 0.0f)
+ _touchX = _touchX - x;
+ if (y < 0.0f)
+ _touchY = previousTouchY - y;
+ if (x > (float)(_scene->_dims.x - g_ngi->gameWidth()))
+ _touchX = ((_touchX + (float)_scene->_dims.x) - (float)g_ngi->gameWidth()) - x;
+ if (y > (float)(_scene->_dims.y - g_ngi->_backgroundSurface.h))
+ _touchY = ((_touchY + (float)_scene->_dims.y) - (float)g_ngi->_backgroundSurface.h) - y;
+ setScroll(x, y);
+ }
+
+ _blinkTime -= elapsed;
+ if (_blinkTime <= 0) {
+ _blinkTime = 996;
+ if (_marker) {
+ if (_marker->_flags & 4)
+ _marker->_flags &= ~4;
+ else
+ _marker->_flags |= 4;
+ }
+ }
+ checkTutorial();
+}
+
+// CMapWindow::OnRender (156490): 5 pixel frame around the picture under the finger, the stop sign
+void MapWindowController::onRender(Common::Point scroll) {
+ if (_hitObject && getSceneId(_hitObject->_id) != 0) {
+ const Common::Point position = _hitObject->getPosition();
+ const float left = position.x;
+ const float top = position.y;
+ const float right = (left + _hitObject->getSize().x) - 5.0f;
+ const float bottom = (top + _hitObject->getSize().y) - 5.0f;
+
+ // the top
+ _selection->setPosition(Common::Point(left, top));
+ _selection->_z = -1001;
+ _selection->_scaleX = (right - left) / _selection->getSize().x;
+ _selection->_scaleY = 5.0f / _selection->getSize().y;
+ _selection->render(scroll);
+ _selection->_scaleX = 1.0f;
+ _selection->_scaleY = 1.0f;
+
+ // the right side
+ _selection->setPosition(Common::Point(right, top));
+ _selection->_z = -1001;
+ const float rightScaleX = 5.0f / _selection->getSize().x;
+ const float height = _hitObject->getSize().y;
+ _selection->_scaleY = height / _selection->getSize().y;
+ _selection->_scaleX = rightScaleX;
+ _selection->render(scroll);
+ _selection->_scaleX = 1.0f;
+ _selection->_scaleY = 1.0f;
+
+ // the bottom
+ _selection->setPosition(Common::Point(left, bottom));
+ _selection->_z = -1001;
+ _selection->_scaleX = (right - left) / _selection->getSize().x;
+ _selection->_scaleY = 5.0f / _selection->getSize().y;
+ _selection->render(scroll);
+ _selection->_scaleX = 1.0f;
+ _selection->_scaleY = 1.0f;
+
+ // the left side
+ _selection->setPosition(Common::Point(left, top));
+ _selection->_z = -1001;
+ const float leftScaleX = 5.0f / _selection->getSize().x;
+ const float leftHeight = _hitObject->getSize().y;
+ _selection->_scaleY = leftHeight / _selection->getSize().y;
+ _selection->_scaleX = leftScaleX;
+ _selection->render(scroll);
+ _selection->_scaleX = 1.0f;
+ _selection->_scaleY = 1.0f;
+ }
+ if (_stopShown)
+ _stopSign->render(scroll);
+}
+
+// CMapWindow::OnMessage (156F20)
+void MapWindowController::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ Map *map = g_ngi->_map.get();
+ if (message == "MSG_SC_MAP_BLOCK_ALL_SCENES") {
+ _blockAll = true;
+ } else if (message == "MSG_SC_MAP_UNBLOCK_ALL_SCENES") {
+ _blockAll = false;
+ } else if (message == "MSG_SCMAP_FIRST_ENTER_SC13") {
+ if (map->getFirstEnterToSc13() == 0)
+ map->setFirstEnterToSc13(1);
+ } else if (message == "MSG_SCMAP_SECOND_ENTER_SC13") {
+ if (map->getFirstEnterToSc13() == 1) {
+ map->setFirstEnterToSc13(2);
+ unblockAllScenes();
+ }
+ }
+}
+
+// CMapWindow::GetCursorType (1578A8): the hand over the picture of a scene that can be entered
+int MapWindowController::getCursorType(float x, float y) {
+ GameObject *hit = g_ngi->_inputController->getHitObject();
+ if (hit && getSceneId(hit->_id) != 0 && !g_ngi->_map->isDontEnter(hit->_id))
+ return 1;
+ return -1;
+}
+
+// CMapWindow::OnTouchesDown (1579E0)
+bool MapWindowController::onTouchesDown(uint32 id, float x, float y) {
+ _touchCount = id + 1;
+ if (_touchCount > 1) {
+ _multiTouch = true;
+ _touching = false;
+ }
+ if (_multiTouch)
+ return false;
+
+ _hitObject = g_ngi->_inputController->getHitObject();
+ bool stop = false;
+ if (_hitObject && getSceneId(_hitObject->_id) != 0) {
+ if (g_ngi->_map->isDontEnter(_hitObject->_id)) {
+ _stopSign->setCenter(_hitObject->getCenter());
+ stop = true;
+ }
+ }
+ _stopShown = stop;
+
+ _touching = true;
+ _touchY = g_ngi->_inputController->_hotScreenY;
+ _touchX = g_ngi->_inputController->_hotScreenX;
+ _scrollStartX = _scene->_x;
+ _scrollStartY = _scene->_y;
+ _scrollX = _scene->_x;
+ _scrollY = _scene->_y;
+ return true;
+}
+
+// CMapWindow::OnTouchesUp (1578DC): a tap (under 6 pixels) on an enterable picture goes there
+bool MapWindowController::onTouchesUp(uint32 id, float x, float y) {
+ if (_touchCount <= 0) {
+ if (_touchCount == 0) {
+ _touching = false;
+ return false;
+ }
+ } else {
+ _touchCount = _touchCount - id - 1;
+ if (_multiTouch && _touchCount <= 0)
+ _multiTouch = false;
+ }
+ if (_multiTouch) {
+ _touching = false;
+ return false;
+ }
+
+ CursorController *cursor = g_ngi->_inputController;
+ if (ABS(_touchX - cursor->_hotScreenX) < 6.0f && ABS(_touchY - cursor->_hotScreenY) < 6.0f) {
+ GameObject *hit = cursor->getHitObject();
+ if (hit && !g_ngi->_map->isDontEnter(hit->_id)) {
+ const int sceneId = getSceneId(hit->_id);
+ const int entranceId = getEntrId(hit->_id);
+ if (sceneId == 0 || sceneId == g_ngi->getSceneInStack(0)->_sceneId) {
+ g_ngi->popScene();
+ } else {
+ setScene(sceneId, entranceId);
+ _tutorial = "AFTER_TUTORIAL_USE_MAP";
+ }
+ }
+ }
+ _touching = false;
+ return true;
+}
+
+// CMapWindow::OnMouseLKeyDown (157A82), OnMouseRKeyDown (157A8A)
+bool MapWindowController::onMouseLKeyDown(uint32 id, float x, float y) {
+ return onTouchesDown(id, x, y);
+}
+
+bool MapWindowController::onMouseRKeyDown(uint32 id, float x, float y) {
+ return onTouchesDown(id, x, y);
+}
+
+// CMapWindow::OnMouseLKeyUp (1579D8), OnMouseRKeyUp (1579D0)
+bool MapWindowController::onMouseLKeyUp(uint32 id, float x, float y) {
+ return onTouchesUp(id, x, y);
+}
+
+bool MapWindowController::onMouseRKeyUp(uint32 id, float x, float y) {
+ return onTouchesUp(id, x, y);
+}
+
+// CMapWindow::OnMouseMove (155F34)
+bool MapWindowController::onMouseMove(uint32 id, float x, float y) {
+ _pointerMoved = id != 0;
+ return true; // the original returns the address of the flag
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/mapwindowcontroller.h b/engines/ngi/fullpipe/mapwindowcontroller.h
new file mode 100644
index 00000000000..af09ddd5c40
--- /dev/null
+++ b/engines/ngi/fullpipe/mapwindowcontroller.h
@@ -0,0 +1,105 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_MAPWINDOWCONTROLLER_H
+#define NGI_FULLPIPE_MAPWINDOWCONTROLLER_H
+
+#include "common/str.h"
+
+#include "ngi/fullpipe/fpguicontroller.h"
+
+namespace NGI {
+
+class GameObject;
+class PictureObject;
+
+// CMapWindow (CFPGuiController): the SC_MAP controller, the world map
+// Named MapWindowController because the Windows map (modal.h) is a class of its own
+class MapWindowController : public FPGuiController {
+public:
+ explicit MapWindowController(int sceneId);
+
+ /** CMapWindow::CleanXml (155F40) */
+ void cleanXml() override;
+ /** The tutorial that CMap saves (MAPTUTORIAL state) and CMap::SetXmlData restores */
+ const Common::String &tutorial() const { return _tutorial; }
+ void setTutorial(const Common::String &tutorial) { _tutorial = tutorial; }
+ /** The picture under the finger (+56), set by CTutorialController::PassMouseActions */
+ void setHitObject(GameObject *object) { _hitObject = object; }
+
+ /** CMapWindow::GetSceneId (156470): the scene of a map picture (PIC_MAP_S01 ... S38) */
+ int getSceneId(int pictureId) const;
+ /** CMapWindow::GetCurrentScene (156680): the map picture of the scene shown below the map */
+ PictureObject *getCurrentScene() const;
+ /** CMapWindow::GetEntrId (156990): the entrance (TrubaLeft ...) of the picture's scene */
+ int getEntrId(int pictureId) const;
+ /** CMapWindow::GetVisibleCount (156AA0): the pictures of the map that are shown */
+ int getVisibleCount() const;
+ /** CMapWindow::BlockScenes (156AD0): the scenes the player may not enter now */
+ void blockScenes();
+ /** CMapWindow::UnblockAllScenes (156EDC) */
+ void unblockAllScenes();
+ /** CMapWindow::SetScroll (156FB4): the map is scrolled, the scroll stays inside the scene */
+ void setScroll(float x, float y);
+ /** CMapWindow::CheckTutorial (1570D4): TUTORIAL_USE_MAP, then EXTRA_TUTORIAL_USE_MAP */
+ void checkTutorial();
+
+ void onShow() override;
+ void onHide() override;
+ void onUpdate(uint32 elapsed) override;
+ void onRender(Common::Point scroll) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+ int getCursorType(float x, float y) override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ bool onMouseRKeyDown(uint32 id, float x, float y) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ bool onMouseRKeyUp(uint32 id, float x, float y) override;
+ bool onMouseMove(uint32 id, float x, float y) override;
+
+private:
+ /** CMapWindow::OnTouchesDown (1579E0) and OnTouchesUp (1578DC), called by the mouse handlers */
+ bool onTouchesDown(uint32 id, float x, float y);
+ bool onTouchesUp(uint32 id, float x, float y);
+
+ Common::String _tutorial = "TUTORIAL_USE_MAP"; // +16: the next tutorial of the map
+ float _tutorialTime = -1.0f; // +20: seconds since the map was shown while an extra tutorial waits
+ PictureObject *_marker = nullptr; // +24: PIC_MAP_I01, blinks over the scene that was left
+ PictureObject *_selection = nullptr; // +28: PIC_MAP_SEL, the frame around the touched picture
+ bool _touching = false; // +32: the finger is down and drags the map
+ float _touchX = 0; // +36: where it went down (the screen)
+ float _touchY = 0; // +40
+ float _scrollStartX = 0; // +44: the scroll of the map when it did
+ float _scrollStartY = 0; // +48
+ int _blinkTime = 996; // +52: the time in ms until the marker blinks again
+ GameObject *_hitObject = nullptr; // +56: the picture that was under the finger when it went down
+ PictureObject *_stopSign = nullptr; // +60: PIC_MAP_STOP
+ bool _stopShown = false; // +64: the stop sign is drawn over the picture under the finger
+ bool _blockAll = false; // +65: MSG_SC_MAP_BLOCK_ALL_SCENES
+ float _scrollX = 0; // +68: the last scroll (SetScroll)
+ float _scrollY = 0; // +72
+ int _touchCount = 0; // +76: the fingers that are down
+ bool _multiTouch = false; // +80: more than one finger went down, the touch is not a tap
+ bool _pointerMoved = false; // +81: OnMouseMove with an id other than 0, no dragging
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_MAPWINDOWCONTROLLER_H
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index b36b9e89323..d4d1e3a44d4 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -40,6 +40,7 @@
#include "ngi/fullpipe/inventorycontroller.h"
#include "ngi/fullpipe/liftcontroller.h"
#include "ngi/fullpipe/mainmenucontroller.h"
+#include "ngi/fullpipe/mapwindowcontroller.h"
#include "ngi/fullpipe/tutorialcontroller.h"
#include "ngi/fullpipe/tutorialmanager.h"
#include "ngi/inventory.h"
@@ -404,6 +405,9 @@ void createSceneController(int sceneId) {
case SC_MAINMENU:
new MainMenuController(sceneId);
break;
+ case SC_MAP:
+ new MapWindowController(sceneId);
+ break;
case 0: // the inventory scene (CGame +116)
new InventoryController(sceneId);
break;
diff --git a/engines/ngi/fullpipe/tutorialcontroller.cpp b/engines/ngi/fullpipe/tutorialcontroller.cpp
index fe6f16b54e2..3af9118740d 100644
--- a/engines/ngi/fullpipe/tutorialcontroller.cpp
+++ b/engines/ngi/fullpipe/tutorialcontroller.cpp
@@ -24,6 +24,7 @@
#include "ngi/ngi.h"
#include "ngi/utils.h"
+#include "ngi/gameloader.h"
#include "ngi/font.h"
#include "ngi/objects.h"
#include "ngi/gfx.h"
@@ -37,6 +38,7 @@
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/inventorycontroller.h"
+#include "ngi/fullpipe/mapwindowcontroller.h"
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/tutorialcontroller.h"
@@ -681,10 +683,9 @@ int TutorialController::getCursorType(float x, float y) {
return -1;
}
-// CTutorialController::PassMouseActions (1A4854): whether the touch goes on to the scene below. The action is 1 for a move, 2 for the finger down and 3 for
-// the finger up; every tutorial has its own zone, a touch in it can finish the tutorial. Read in the disassembly (the decompiler fails on the jump table):
-// the tutorials without zone are FIRST, SEE_TASK and USE_TASK (the touch does not pass), SEE_ALL_TASKS, SEE_EGGEATER and LAST (it passes). Not ported:
-// EXTRA_TUTORIAL_SEE_EXTRA_HELP and TUTORIAL_USE_MAP (their tutorials are not started yet), they let the touch pass.
+// CTutorialController::PassMouseActions (1A4854): action 1 move, 2 finger down, 3 finger up;
+// every tutorial has a zone, a touch in it can finish it. From the disassembly (jump table):
+// no zone: FIRST, SEE_TASK, USE_TASK (no pass), SEE_ALL_TASKS, SEE_EGGEATER, LAST (pass)
bool TutorialController::passMouseActions(float x, float y, int action) {
const bool pass = passMouseActionsZone(x, y, action);
debugC(2, kDebugEvents, "TutorialController::passMouseActions(%g, %g, %d) = %d", x, y, action, pass);
@@ -784,8 +785,29 @@ bool TutorialController::passMouseActionsZone(float x, float y, int action) {
return mouseActions(x, y, action, ANI_BITA);
if (id == "ARCADE_TUTORIAL_29")
return mouseActions(x, y, action, ANI_PORTER);
- if (id == "EXTRA_TUTORIAL_SEE_EXTRA_HELP" || id == "TUTORIAL_USE_MAP")
- warnOnce("STUB/untested: CTutorialController::PassMouseActions: the zones of EXTRA_TUTORIAL_SEE_EXTRA_HELP and TUTORIAL_USE_MAP are not ported");
+ if (id == "TUTORIAL_USE_MAP") {
+ // scene 3 picture on the map (scene below): finger up leaves the map for scene 3 and finishes
+ // TUTORIAL_SEE_MAP, the touch never reaches the map; analytics event not ported
+ Scene *map = g_ngi->getSceneInStack(1);
+ PictureObject *picture = map->findPictureObjectById(PIC_MAP_S03, 0);
+ const float mapX = x + map->_x;
+ const float mapY = y + map->_y;
+ MapWindowController *controller = static_cast<MapWindowController *>(map->_controller.get());
+ if (!picture || !picture->hit((int)mapX, (int)mapY)) {
+ controller->setHitObject(nullptr);
+ return false;
+ }
+ if (action == 2) {
+ controller->setHitObject(picture);
+ return false;
+ }
+ if (action != 3)
+ return false;
+ g_ngi->popScene();
+ g_ngi->_gameLoader->preloadScene(SC_3, TrubaUp); // CGame::SetScene
+ g_ngi->_tutorialManager->findTutorial("TUTORIAL_SEE_MAP")->setState(4);
+ return false;
+ }
return true;
}
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 78885d21b66..ba01d6fa04e 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -93,6 +93,7 @@ MODULE_OBJS = \
fullpipe/liftcontroller.o \
fullpipe/mainmenucontroller.o \
fullpipe/map.o \
+ fullpipe/mapwindowcontroller.o \
fullpipe/notebook.o \
fullpipe/sc01controller.o \
fullpipe/sc02controller.o \
Commit: 079fdb490c3a2cd292cf6b726eb9d5615c1496fd
https://github.com/scummvm/scummvm/commit/079fdb490c3a2cd292cf6b726eb9d5615c1496fd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: ObjHelperManager, ObjHelperHint and ObjHelper (the object helper)
Changed paths:
A engines/ngi/fullpipe/objhelper.cpp
A engines/ngi/fullpipe/objhelper.h
engines/ngi/fullpipe/constants.h
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/inventorycontroller.cpp
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index 10c41f19dd9..d9867ca39dd 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -1873,6 +1873,14 @@ namespace NGI {
#define ST_SC6_ARROW_3 23492
#define ST_SC6_ARROW_4 23493
+// Android: names of obj.h that the ported controllers use
+#define ANI_OBJHELPER 23027
+#define ST_OBJHELPER_EMPTY 23029
+#define QU_OBJHELPER_STARTBEARDED 23142
+#define QU_OBJHELPER_STARTBEARDED_MIRROR 23143
+#define QU_OBJHELPER_STARTBEARDED_UPDOWN 23144
+#define QU_OBJHELPER_STARTBEARDED_UPDOWN_MIRROR 23145
+
// Android: names of obj.h that the ported controllers use
#define TrubaUp1 10004
#define TrubaUp10 10005
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index d25bd8e0a9f..08121841a2a 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -38,6 +38,7 @@
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/fpcontroller.h"
#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/objhelper.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/map.h"
#include "ngi/guimanager.h"
@@ -533,6 +534,9 @@ void FPController::onUpdate(uint32 elapsed) {
testScroll();
}
testSwipe();
+ // CObjHelperHint::CheckObjHelperHint
+ if (g_ngi->_objHelperHint)
+ g_ngi->_objHelperHint->checkObjHelperHint(_scene);
// CExitManager::OnUpdate; the original has no test for a missing hero
g_ngi->_exitManager->onUpdate(elapsed, hero() ? hero()->_z : -1000.0f);
if (_scene->_x != oldX || _scene->_y != oldY) {
@@ -942,8 +946,8 @@ bool FPController::isNeedReact(float x, float y) {
return false;
}
-// CFPController::OnMouseLKeyUpTop: the shine of ANI_REACT where the finger was lifted over something that reacts, then the exits (the object helper
-// and the achievements are not ported). CFPController::OnSceneInit puts ANI_REACT into every scene; here it is done at the first use. CAniObject::MoveToStatic is SetStatic.
+// CFPController::OnMouseLKeyUpTop: the shine of ANI_REACT where the finger was lifted over something that reacts, then the exits and the object helper (the
+// achievements are not ported). CFPController::OnSceneInit puts ANI_REACT into every scene; here it is done at the first use. CAniObject::MoveToStatic is SetStatic.
bool FPController::onMouseLKeyUpTop(uint32 id, float x, float y) {
if (g_ngi->_exitManager->getState() != 2 && !_dragged && isNeedReact(x, y)) {
if (!_react) {
@@ -962,7 +966,13 @@ bool FPController::onMouseLKeyUpTop(uint32 id, float x, float y) {
}
}
g_ngi->_exitManager->onMouseLKeyUp(x, y);
- return false;
+ // CObjHelperManager::CatchObjHelper: a tap on the glow that falls into the scene; CAchievementsManager::OnMouseLKeyUp is not ported
+ bool caught = false;
+ if (g_ngi->_objHelperManager)
+ caught = g_ngi->_objHelperManager->catchObjHelper(_scene, x, y);
+ if (caught)
+ resetSwipeParams();
+ return caught;
}
void FPController::onRenderTop(Common::Point scroll) {
diff --git a/engines/ngi/fullpipe/inventorycontroller.cpp b/engines/ngi/fullpipe/inventorycontroller.cpp
index 43ad6eb9a6b..18319eda41d 100644
--- a/engines/ngi/fullpipe/inventorycontroller.cpp
+++ b/engines/ngi/fullpipe/inventorycontroller.cpp
@@ -25,6 +25,7 @@
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/inventorycontroller.h"
+#include "ngi/fullpipe/objhelper.h"
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/tutorialcontroller.h"
#include "ngi/fullpipe/tutorialmanager.h"
@@ -214,7 +215,8 @@ void InventoryController::onGuiEvent(const Common::String &id, const Common::Str
return;
}
if (id == "PIC_INV_HELPER_ACTIONS" || id == "PIC_INV_HELPER_BUBBLE") {
- warnOnce("CObjHelperManager::ShowObjHelperActionMessage: the object helper is not ported");
+ if (g_ngi->_objHelperManager)
+ g_ngi->_objHelperManager->showObjHelperActionMessage();
return;
}
if (id == "PIC_INV_TASK" || id == "PIC_INV_TASK_PRESSED") {
diff --git a/engines/ngi/fullpipe/objhelper.cpp b/engines/ngi/fullpipe/objhelper.cpp
new file mode 100644
index 00000000000..fa82f7796ac
--- /dev/null
+++ b/engines/ngi/fullpipe/objhelper.cpp
@@ -0,0 +1,594 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/debug.h"
+#include "common/ptr.h"
+
+#include "ngi/ngi.h"
+#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/interaction.h"
+#include "ngi/messages.h"
+#include "ngi/motion.h"
+#include "ngi/objects.h"
+#include "ngi/scene.h"
+#include "ngi/sceneobjects.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
+#include "ngi/fullpipe/fpcontroller.h"
+#include "ngi/fullpipe/objhelper.h"
+
+namespace NGI {
+
+namespace {
+
+// CIDList::FindId: 0 for an unknown name
+int findId(const char *name) {
+ uint32 id = 0;
+ if (name[0])
+ g_ngi->_gameProject->_objectIds.findId(name, id);
+ return id;
+}
+
+// the conversion of a float to unsigned int of the ARM code: a negative value gives 0
+uint32 floatToUint(float value) {
+ if (!(value > 0.0f))
+ return 0;
+ return static_cast<uint32>(value);
+}
+
+// CScene::GetObjectsAmount (1224D8): objects with that id in the scene (copies count from 0)
+int objectsAmount(Scene *scene, int objectId) {
+ int amount = -1;
+ do {
+ amount++;
+ } while (scene->findVisibleObject(objectId, amount));
+ return amount;
+}
+
+// CScene::AddAni(scene, ani, 0) (122E60): the copy id is the number of objects with that id
+void addAniCopy(Scene *scene, AniObject *ani) {
+ ani->_copyId = objectsAmount(scene, ani->_id);
+ scene->addAni(ani, true);
+}
+
+// CScene::FindVisibleObjectAllCopy (1235B0): pictures, selections, animations with the id
+void findVisibleObjectAllCopy(Scene *scene, int objectId, Common::Array<GameObject *> &result) {
+ for (PictureObject *picture : scene->_pictureObjects) {
+ if (picture->_id == objectId)
+ result.push_back(picture);
+ }
+ for (PictureObject *picture : scene->_roamingPictures) {
+ if (picture->_id == objectId)
+ result.push_back(picture);
+ }
+ for (Selection *selection : scene->_selections) {
+ if (selection->_id == objectId)
+ result.push_back(selection);
+ }
+ const Common::Array<AniObject *> &anis = scene->_roamingObjects.empty() ? scene->_aniObjects : scene->_renderableAnis;
+ for (AniObject *ani : anis) {
+ if (ani->_id == objectId)
+ result.push_back(ani);
+ }
+}
+
+// CAniObject::FindMovement(0): the first movement (the original keeps a map ordered by id)
+Movement *firstMovement(AniObject *ani) {
+ Movement *first = nullptr;
+ for (Movement *movement : ani->_movements) {
+ if (!first || movement->_id < first->_id)
+ first = movement;
+ }
+ return first;
+}
+
+// Command type of the Android build (the "cmd" of objhints.xml, CCommand +32), as in the queues
+// (renames/command_kinds.csv, docs/command-kinds.md); -1 when the engine has no kind for it
+int commandKind(int androidType) {
+ switch (androidType) {
+ case 1:
+ return kCmdShow;
+ case 2:
+ return kCmdHide;
+ case 3:
+ return kCmdStartMovement;
+ case 5:
+ return kCmdMessage;
+ case 6:
+ return kCmdSetScene;
+ case 7:
+ return kCmdSound;
+ case 9:
+ return kCmdStartSliding;
+ case 12:
+ return kCmdUser;
+ case 14:
+ return kCmdAddInvItem;
+ case 15:
+ return kCmdRemoveInvItem;
+ case 20:
+ return kCmdSetFlags;
+ case 22:
+ return kCmdPause;
+ case 24:
+ return kCmdQueue;
+ case 25:
+ return kCmdSetStatic;
+ default:
+ warnOnce("CObjHelperHint: the command type of objhints.xml has no kind in the engine");
+ return -1;
+ }
+}
+
+} // End of anonymous namespace
+
+// CObjHelper::CObjHelper (160A6C)
+ObjHelper::ObjHelper() {
+}
+
+void ObjHelper::reset() {
+ _x = 0;
+ _y = 0;
+ _delay = 0;
+ _time = 0;
+ _percent = 0;
+ _innerLeft = 0;
+ _innerRight = 0;
+}
+
+// CObjHelper::Init (160AD0)
+void ObjHelper::init(const XmlNode &node) {
+ const Common::String name = node.name();
+ _delay = node.attrInt("delay", 0);
+ _percent = node.attrInt("percent", 0);
+ if (name == "SCENE_INFO") {
+ _fallUpType = node.attrBool("fallUpType", false);
+ if (_fallUpType) {
+ _offsetX = node.attrFloat("fallUpOffsetX", 0.0f);
+ _offsetY = node.attrFloat("fallUpOffsetY", 0.0f);
+ }
+ if (node.checkAttr("fallUpLeftBorder"))
+ _fallUpLeftBorder = node.attrFloat("fallUpLeftBorder", 0.0f);
+ else
+ _fallUpLeftBorder = 0.0f;
+ if (node.checkAttr("fallUpRightBorder"))
+ _fallUpRightBorder = node.attrFloat("fallUpRightBorder", 0.0f);
+ else
+ _fallUpRightBorder = 0.0f;
+ if (node.checkAttr("innerLeft")) {
+ _innerLeft = node.attrInt("innerLeft", 0);
+ _innerRight = node.attrInt("innerRight", 0);
+ }
+ }
+}
+
+// CObjHelper::ChanceToShowObjHelper (160A80)
+bool ObjHelper::chanceToShowObjHelper() {
+ const uint32 chance = random31() % 100;
+ if (_percent < chance) {
+ _time = 0;
+ return false;
+ }
+ return true;
+}
+
+// CObjHelper::TimeCounting (160A9C)
+bool ObjHelper::timeCounting(uint32 elapsed) {
+ if (_time < _delay) {
+ _time = elapsed + _time;
+ return true;
+ }
+ return false;
+}
+
+// CObjHelper::RefreshPos (1610F4)
+bool ObjHelper::refreshPos(Scene *scene, uint32 a3, uint32 a4, uint32 a5, bool a6) {
+ _x = static_cast<float>(random31() % a5 + a3);
+ const int random = random31();
+ _y = static_cast<float>(a4) - static_cast<float>(random % g_ngi->_objHelperManager->getOffsetY());
+ if (a6) {
+ if (_fallUpLeftBorder > _x)
+ _x = _fallUpLeftBorder;
+ const float sceneX = static_cast<float>(scene->_x);
+ const float right = (sceneX + static_cast<float>(g_ngi->gameWidth())) - _fallUpRightBorder;
+ if (right < _x)
+ _x = right;
+ }
+ if (static_cast<float>(_innerLeft) <= _x)
+ return static_cast<float>(_innerRight) < _x;
+ return true;
+}
+
+// CObjHelperManager::CObjHelperManager (16104C): the CGObject base is not ported
+ObjHelperManager::ObjHelperManager() {
+ Scene *common = g_ngi->findScene(SC_COMMON);
+ if (common)
+ _helperAni = common->findAniObjectById(ANI_OBJHELPER, 0);
+ _helperType = 0;
+ _sceneId = 0;
+ // +44: new CGuiText (CGuiText::CGuiText, 0x5C bytes)
+ warnOnce("CObjHelperManager::CObjHelperManager: the CGuiText of the count (+44) is not created (the GUI of the engine has no text that is made at run time)");
+}
+
+// CObjHelperManager::~CObjHelperManager (160FE4): the map is erased and the text is deleted
+ObjHelperManager::~ObjHelperManager() {
+}
+
+// CObjHelperManager::Init (161594)
+void ObjHelperManager::init(const char *path) {
+ Common::ScopedPtr<XmlNode> document(loadXmlDocument(path));
+ if (!document) {
+ warning("Could not read %s", path);
+ return;
+ }
+ const XmlNode &root = document->first();
+ _action = root.attrInt("action", 0);
+ _zone = root.attrInt("zone", 0);
+ _leftBorder = root.attrInt("leftBorder", 0);
+ _rightBorder = root.attrInt("rightBorder", 0);
+ _offsetY = root.attrInt("offsetY", 0);
+ const XmlNode &defInfo = root.child("DEF_INFO");
+ // the original CObjHelper is one local: fields after +21 keep the last iteration's values
+ ObjHelper helper;
+ for (uint i = 0; i < root.childCount(); i++) {
+ // the original's CXmlNode::AppendAttr attributes are appended to the child
+ XmlNode &node = const_cast<XmlNode &>(root[i]);
+ const Common::String name = node.name();
+ helper.reset();
+ if (name == "SCENE_INFO") {
+ if (!node.checkAttr("innerLeft")) {
+ node.appendAttr("delay", defInfo.attrStr("delay", ""));
+ node.appendAttr("percent", defInfo.attrStr("percent", ""));
+ }
+ node.appendAttr("fallUpOffsetX", defInfo.attrStr("fallUpOffsetX", ""));
+ node.appendAttr("fallUpOffsetY", defInfo.attrStr("fallUpOffsetY", ""));
+ if (!node.checkAttr("fallUpType"))
+ node.appendAttr("fallUpType", defInfo.attrStr("fallUpType", ""));
+ }
+ helper.init(node);
+ uint32 key = 0;
+ if (name == "SCENE_INFO")
+ key = findId(node.attrStr("scene", ""));
+ // std::map::insert: an entry that exists stays
+ if (!_helpers.contains(key))
+ _helpers[key] = helper;
+ }
+ debugC(1, kDebugXML, "Loaded %u object helper settings from %s", _helpers.size(), path);
+}
+
+// CObjHelperManager::GetSavePath (160F48): the path of the saves (CPathManager) and "objhelper.sav"
+Common::String ObjHelperManager::getSavePath() const {
+ warnOnce("CObjHelperManager::GetSavePath: CPathManager is not ported, only the file name is given");
+ return "objhelper.sav";
+}
+
+// CObjHelperManager::GetXmlData (1609F0): OBJHELPER with objHelperCount (CXmlSerializer)
+void ObjHelperManager::getXmlData() {
+ warnOnce("CObjHelperManager::GetXmlData: the XML serializer of CGObject::SaveXml is not ported, objhelper.sav is not written");
+}
+
+// CObjHelperManager::SetXmlData (160E20)
+void ObjHelperManager::setXmlData(const XmlNode &node) {
+ _count = node.attrInt("objHelperCount", 0);
+ hidePipeAction();
+ hidePipeZone();
+ showPipeAction();
+ showPipeZone();
+}
+
+// CObjHelperManager::IsHitObjHelper (160C0A): circle of the glow width sitting on its bottom edge
+bool ObjHelperManager::isHitObjHelper(Scene *scene, float x, float y) const {
+ if (!_helperAni)
+ return false;
+ if (!(_helperAni->_flags & 4))
+ return false;
+ // CVisibleObject::GetX / GetY (vtable 96, 100): top left of the texture
+ const Common::Point position = _helperAni->getPosition();
+ const Common::Point size = _helperAni->getSize();
+ const float centerX = static_cast<float>(position.x) + static_cast<float>(size.x) * 0.5f;
+ const float bottom = static_cast<float>(position.y) + static_cast<float>(size.y);
+ const float centerY = bottom - static_cast<float>(size.x) * 0.5f;
+ const float distance = sqrtf((x - centerX) * (x - centerX) + (y - centerY) * (y - centerY));
+ return distance < static_cast<float>(size.x) * 0.5f;
+}
+
+// CObjHelperManager::ShowObjHelperCount (160CD8): no caller in the Android build
+void ObjHelperManager::showObjHelperCount() {
+ warnOnce("CObjHelperManager::ShowObjHelperCount: the CGuiText of the count is not ported");
+}
+
+// CObjHelperManager::UpdateObjHelperCount (160E04): CGuiText::SetText(count)
+void ObjHelperManager::updateObjHelperCount() {
+ warnOnce("CObjHelperManager::UpdateObjHelperCount: the CGuiText of the count is not ported");
+}
+
+// CObjHelperManager::ShowObjHelperActionMessage (160E50): caller CInventoryController::OnGuiEvent
+void ObjHelperManager::showObjHelperActionMessage() {
+ hidePipeAction();
+ hidePipeZone();
+ warnOnce("CHelp::Show (CObjHelperManager::ShowObjHelperActionMessage): CHelp is not ported");
+}
+
+// CObjHelperManager::ShowObjHelperZoneMessage (160E94): no caller in the Android build
+void ObjHelperManager::showObjHelperZoneMessage(Scene *scene) {
+ const uint16 zone = _zone;
+ const uint16 count = _count;
+ if (zone <= count) {
+ _count = count - zone;
+ hidePipeZone();
+ hidePipeAction();
+ if (g_ngi->_objHelperHint)
+ g_ngi->_objHelperHint->showObjHelperHint(scene);
+ }
+}
+
+// CObjHelperManager::GetHelperType (160EF0)
+void ObjHelperManager::getHelperType() {
+ const uint32 random = random31();
+ _helperType = random % 2 != 0;
+}
+
+// CObjHelperManager::SetWinParam (160F18): CRender +36 is the width of the base screen
+void ObjHelperManager::setWinParam(Scene *scene) {
+ const uint32 width = g_ngi->gameWidth();
+ _areaWidth = width - _rightBorder;
+ _areaLeft = floatToUint(static_cast<float>(_leftBorder) + static_cast<float>(scene->_x));
+ _areaTop = floatToUint(static_cast<float>(scene->_y));
+}
+
+// CObjHelperManager::SetScId (161212)
+void ObjHelperManager::setScId(Scene *scene) {
+ const uint32 sceneId = scene->_sceneId;
+ if (!_helpers.contains(sceneId))
+ _sceneId = 0;
+ else
+ _sceneId = sceneId;
+}
+
+ObjHelper *ObjHelperManager::findHelper(uint32 sceneId) {
+ Common::HashMap<uint32, ObjHelper>::iterator it = _helpers.find(sceneId);
+ if (it == _helpers.end())
+ return nullptr;
+ return &it->_value;
+}
+
+// CObjHelperManager::ShowObjHelper (161238)
+void ObjHelperManager::showObjHelper(Scene *scene) {
+ const uint32 random = random31();
+ ObjHelper *found = findHelper(_sceneId);
+ if (!found) {
+ warning("STUB/untested: CObjHelperManager::ShowObjHelper: no settings for the scene %u (not even the defaults)", _sceneId);
+ return;
+ }
+ // the original copies the settings (10 words) into a local CObjHelper
+ ObjHelper helper = *found;
+ if (helper.needFallUp())
+ getHelperType();
+ else
+ _helperType = 0;
+ if (helper.refreshPos(scene, _areaLeft, _areaTop, _areaWidth, _helperType == 1)) {
+ int side = random & 1;
+ addAniCopy(scene, _helperAni);
+ const int type = _helperType;
+ if (type == 0) {
+ _helperAni->setPosition(Common::Point(static_cast<int>(helper.getX()), static_cast<int>(helper.getY())));
+ scene->runQueueWithAni(side == 0 ? QU_OBJHELPER_STARTBEARDED_UPDOWN : QU_OBJHELPER_STARTBEARDED_UPDOWN_MIRROR, _helperAni, 3);
+ _helperAni->_flags |= 4;
+ return;
+ }
+ if (type != 1)
+ return;
+ const float x = helper.getX();
+ const float sceneX = static_cast<float>(scene->_x);
+ float offsetX;
+ float offsetY;
+ helper.getOffset(offsetX, offsetY);
+ const float left = sceneX + offsetX;
+ const bool leftOfRange = x < left + helper.getFallUpLeftBorder();
+ int newSide = 0;
+ bool inRange = false;
+ if (!leftOfRange) {
+ const float x2 = helper.getX();
+ const float sceneX2 = static_cast<float>(scene->_x);
+ const float right = sceneX2 + static_cast<float>(g_ngi->gameWidth());
+ helper.getOffset(offsetX, offsetY);
+ const float limit = right - offsetX;
+ if (x2 <= limit - helper.getFallUpRightBorder())
+ inRange = true;
+ else
+ newSide = type;
+ }
+ if (!inRange)
+ side = newSide;
+ const float x3 = helper.getX();
+ helper.getOffset(offsetX, offsetY);
+ _helperAni->setPosition(Common::Point(static_cast<int>(x3), static_cast<int>(offsetY)));
+ scene->runQueueWithAni(QU_OBJHELPER_STARTBEARDED + side, _helperAni, 3);
+ _helperAni->_flags |= 4;
+ }
+}
+
+// CObjHelperManager::HideObjHelper (1613E8)
+void ObjHelperManager::hideObjHelper(Scene *scene) {
+ // CVisibleObject::StopQueue
+ if (MessageQueue *queue = _helperAni->getMessageQueue())
+ queue->stop(false);
+ _helperAni->_flags &= ~4;
+ _helperAni->setStatic(ST_OBJHELPER_EMPTY, false);
+ scene->removeAni(_helperAni);
+ if (ObjHelper *helper = findHelper(_sceneId))
+ helper->setTime(0);
+}
+
+// CObjHelperManager::CatchObjHelper (161434): called by CFPController::OnMouseLKeyUpTop
+bool ObjHelperManager::catchObjHelper(Scene *scene, float x, float y) {
+ const bool hit = isHitObjHelper(scene, x, y);
+ if (hit) {
+ ++_count;
+ hideObjHelper(scene);
+ showPipeAction();
+ showPipeZone();
+ }
+ return hit;
+}
+
+// CObjHelperManager::UpdateObjHelper (161460): no caller in the Android build, flags unknown
+void ObjHelperManager::updateObjHelper(Scene *scene, uint32 elapsed, bool a3, bool a4) {
+ setScId(scene);
+ if (_helperAni->_flags & 4) {
+ if (!_helperAni->getMessageQueue())
+ hideObjHelper(scene);
+ } else if (!a3 && a4) {
+ ObjHelper *helper = findHelper(_sceneId);
+ if (helper && !helper->timeCounting(elapsed)) {
+ helper = findHelper(_sceneId);
+ if (helper->chanceToShowObjHelper())
+ showObjHelper(scene);
+ }
+ }
+ setWinParam(scene);
+ updateObjHelperCount();
+}
+
+// CObjHelperHint::CObjHelperHint (160714)
+ObjHelperHint::ObjHelperHint() {
+ Scene *common = g_ngi->findScene(SC_COMMON);
+ if (common)
+ _template = common->findAniObjectById(ANI_REACT, 0);
+}
+
+// CObjHelperHint::~CObjHelperHint (1606AC): the copies are not deleted
+ObjHelperHint::~ObjHelperHint() {
+}
+
+// CObjHelperHint::Init (160824)
+void ObjHelperHint::init(const char *path) {
+ Common::ScopedPtr<XmlNode> document(loadXmlDocument(path));
+ if (!document) {
+ warning("Could not read %s", path);
+ return;
+ }
+ const XmlNode &root = document->first();
+ for (uint i = 0; i < root.childCount(); i++) {
+ const Common::String name = root[i].name();
+ if (name == "OBJ") {
+ Item item;
+ item.objectId = findId(root[i].attrStr("id", ""));
+ item.command = root[i].attrInt("cmd", 14);
+ _items.push_back(item);
+ }
+ }
+ debugC(1, kDebugXML, "Loaded %u object hints from %s", _items.size(), path);
+}
+
+// CObjHelperHint::CheckHintable (1603D4)
+bool ObjHelperHint::checkHintable(Interact *interaction) {
+ for (const Item &item : _items) {
+ if (interaction->_objectId == item.objectId) {
+ const int kind = commandKind(item.command);
+ if (interaction->_messageQueue && kind != -1 && interaction->_messageQueue->getCommandNumByType(kind) != -1)
+ return true;
+ }
+ }
+ return false;
+}
+
+// CObjHelperHint::InitAniObjs (160404)
+void ObjHelperHint::initAniObjs(Scene *scene) {
+ Common::Array<Interact *> interactions;
+ getGameLoaderInteractionController()->getAllRunnableInteractions(scene, interactions);
+ for (Interact *interaction : interactions) {
+ if (!checkHintable(interaction))
+ continue;
+ GameObject *object = interaction->getObject();
+ if (!object)
+ continue;
+ Common::Array<GameObject *> targets;
+ findVisibleObjectAllCopy(scene, object->_id, targets);
+ for (GameObject *target : targets) {
+ // ordered by object address; one already in the map keeps its glow (the original loses it)
+ uint pos = 0;
+ while (pos < _aniObjs.size() && reinterpret_cast<uintptr>(_aniObjs[pos].object) < reinterpret_cast<uintptr>(target))
+ pos++;
+ if (pos < _aniObjs.size() && _aniObjs[pos].object == target)
+ continue;
+ if (!_template) {
+ warning("STUB/untested: CObjHelperHint::InitAniObjs: ANI_REACT of SC_COMMON is not there");
+ return;
+ }
+ AniObject *ani = new AniObject(_template);
+ ani->setCenter(target->getCenter());
+ HintAni entry;
+ entry.object = target;
+ entry.ani = ani;
+ _aniObjs.insert_at(pos, entry);
+ }
+ }
+}
+
+// CObjHelperHint::ShowObjHelperHint (160578)
+void ObjHelperHint::showObjHelperHint(Scene *scene) {
+ initAniObjs(scene);
+ for (const HintAni &entry : _aniObjs) {
+ AniObject *ani = entry.ani;
+ if (Movement *movement = firstMovement(ani))
+ ani->startMovement(movement->_id, 0, -1);
+ addAniCopy(scene, ani);
+ ani->_flags |= 4;
+ }
+}
+
+// CObjHelperHint::HideObjHelperHint (1605DA)
+void ObjHelperHint::hideObjHelperHint(Scene *scene) {
+ for (const HintAni &entry : _aniObjs) {
+ entry.ani->_flags &= ~4;
+ scene->removeAni(entry.ani);
+ }
+}
+
+// CObjHelperHint::ClearAniObjs (160628): the copies are not deleted
+void ObjHelperHint::clearAniObjs() {
+ if (!_aniObjs.empty())
+ _aniObjs.clear();
+}
+
+// CObjHelperHint::CheckObjHelperHint (16064A): glows of invisible objects stop, all stop when idle
+void ObjHelperHint::checkObjHelperHint(Scene *scene) {
+ if (!_aniObjs.empty()) {
+ bool allStopped = true;
+ for (const HintAni &entry : _aniObjs) {
+ if (!(entry.object->_flags & 4))
+ entry.ani->stopMovement();
+ if (entry.ani->_movement)
+ allStopped = false;
+ else
+ entry.ani->_flags &= ~4;
+ }
+ if (allStopped) {
+ hideObjHelperHint(scene);
+ clearAniObjs();
+ }
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/objhelper.h b/engines/ngi/fullpipe/objhelper.h
new file mode 100644
index 00000000000..c6b5f91a2c8
--- /dev/null
+++ b/engines/ngi/fullpipe/objhelper.h
@@ -0,0 +1,194 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_OBJHELPER_H
+#define NGI_FULLPIPE_OBJHELPER_H
+
+#include "common/array.h"
+#include "common/hashmap.h"
+#include "common/str.h"
+
+#include "ngi/xmlnode.h"
+
+namespace NGI {
+
+class AniObject;
+class GameObject;
+class Interact;
+class Scene;
+
+/** CObjHelper: settings of one scene of objhelpers.xml (SCENE_INFO) or the defaults (DEF_INFO) */
+class ObjHelper {
+public:
+ ObjHelper();
+
+ /** CObjHelper::CObjHelper (160A6C): clears the fields up to +21 */
+ void reset();
+ /** CObjHelper::Init (160AD0) */
+ void init(const XmlNode &node);
+ /** CObjHelper::ChanceToShowObjHelper (160A80) */
+ bool chanceToShowObjHelper();
+ /** CObjHelper::TimeCounting (160A9C): true while the delay has not run out */
+ bool timeCounting(uint32 elapsed);
+ /** CObjHelper::RefreshPos (1610F4): false when the new x is inside the inner zone */
+ bool refreshPos(Scene *scene, uint32 a3, uint32 a4, uint32 a5, bool a6);
+ float getX() const { return _x; }
+ float getY() const { return _y; }
+ void setDelay(uint32 delay) { _delay = delay; }
+ void setTime(uint32 time) { _time = time; }
+ void setPercent(uint16 percent) { _percent = percent; }
+ void setInnerLeft(uint16 innerLeft) { _innerLeft = innerLeft; }
+ void setInnerRight(uint16 innerRight) { _innerRight = innerRight; }
+ bool needFallUp() const { return _fallUpType; }
+ /** CObjHelper::GetOffset: the offset of the glow that falls up (fallUpOffsetX, fallUpOffsetY) */
+ void getOffset(float &x, float &y) const {
+ x = _offsetX;
+ y = _offsetY;
+ }
+ float getFallUpLeftBorder() const { return _fallUpLeftBorder; }
+ float getFallUpRightBorder() const { return _fallUpRightBorder; }
+
+private:
+ float _x = 0; // +0
+ float _y = 0; // +4
+ uint32 _delay = 0; // +8: "delay", ms between two glows
+ uint32 _time = 0; // +12: ms since the last one
+ uint16 _percent = 0; // +16: "percent", the chance to show it
+ uint16 _innerLeft = 0; // +18: "innerLeft"
+ uint16 _innerRight = 0; // +20: "innerRight"
+ bool _fallUpType = false; // +22: "fallUpType"
+ float _offsetX = 0; // +24: "fallUpOffsetX"
+ float _offsetY = 0; // +28: "fallUpOffsetY"
+ float _fallUpLeftBorder = 0; // +32
+ float _fallUpRightBorder = 0; // +36
+};
+
+/** CObjHelperManager (CSingleton), objhelpers.xml; field offsets as in the original */
+class ObjHelperManager {
+public:
+ ObjHelperManager();
+ ~ObjHelperManager();
+
+ /** CObjHelperManager::Init (161594): reads objhelpers.xml */
+ void init(const char *path);
+
+ /** CObjHelperManager::GetSavePath (160F48, vtable slot 6): the file of the saved state */
+ Common::String getSavePath() const;
+ /** CObjHelperManager::GetXmlData (1609F0, slot 7) */
+ void getXmlData();
+ /** CObjHelperManager::SetXmlData (160E20, slot 8): "objHelperCount" */
+ void setXmlData(const XmlNode &node);
+
+ /** CObjHelperManager::SetObjHelperCount */
+ void setObjHelperCount(uint16 count) { _count = count; }
+ /** CObjHelperManager::IsHitObjHelper (160C0A) */
+ bool isHitObjHelper(Scene *scene, float x, float y) const;
+ /** CObjHelperManager::ShowObjHelperCount (160CD8) */
+ void showObjHelperCount();
+ /** CObjHelperManager::UpdateObjHelperCount (160E04) */
+ void updateObjHelperCount();
+ /** CObjHelperManager::ShowPipeAction, HidePipeAction, ShowPipeZone, HidePipeZone: empty */
+ void showPipeAction() {}
+ void hidePipeAction() {}
+ void showPipeZone() {}
+ void hidePipeZone() {}
+ /** CObjHelperManager::ShowObjHelperActionMessage (160E50) */
+ void showObjHelperActionMessage();
+ /** CObjHelperManager::ShowObjHelperZoneMessage (160E94) */
+ void showObjHelperZoneMessage(Scene *scene);
+ /** CObjHelperManager::GetOffsetY */
+ int getOffsetY() const { return _offsetY; }
+ /** CObjHelperManager::GetHelperType (160EF0): the type is chosen at random */
+ void getHelperType();
+ /** CObjHelperManager::SetWinParam (160F18) */
+ void setWinParam(Scene *scene);
+ /** CObjHelperManager::SetScId (161212): the defaults (key 0) when the scene has no settings */
+ void setScId(Scene *scene);
+ /** CObjHelperManager::ShowObjHelper (161238) */
+ void showObjHelper(Scene *scene);
+ /** CObjHelperManager::HideObjHelper (1613E8) */
+ void hideObjHelper(Scene *scene);
+ /** CObjHelperManager::CatchObjHelper (161434): a tap on the glow */
+ bool catchObjHelper(Scene *scene, float x, float y);
+ /** CObjHelperManager::UpdateObjHelper (161460): no caller in the Android build */
+ void updateObjHelper(Scene *scene, uint32 elapsed, bool a3, bool a4);
+
+private:
+ ObjHelper *findHelper(uint32 sceneId);
+
+ int _helperType = 0; // +8: 0 falls down, 1 falls up
+ uint32 _sceneId = 0; // +12: the key of the settings of the scene
+ AniObject *_helperAni = nullptr; // +16: ANI_OBJHELPER of SC_COMMON
+ Common::HashMap<uint32, ObjHelper> _helpers; // +20: std::map, DEF_INFO is the key 0
+ // +44: the CGuiText of the count (not ported)
+ uint16 _count = 0; // +48: "objHelperCount"
+ uint16 _action = 0; // +50: "action", the count that the action message costs
+ uint16 _zone = 0; // +52: "zone", the count that the hint costs
+ uint16 _leftBorder = 0; // +54: "leftBorder"
+ uint16 _rightBorder = 0; // +56: "rightBorder"
+ uint32 _areaWidth = 0; // +60: the width where the glow falls (SetWinParam)
+ uint32 _areaLeft = 0; // +64: its left edge
+ uint32 _areaTop = 0; // +68: the top of the visible part of the scene
+ int _offsetY = 0; // +72: "offsetY"
+};
+
+/** CObjHelperHint (CSingleton), objhints.xml: glow (ANI_REACT) on objects that give items */
+class ObjHelperHint {
+public:
+ ObjHelperHint();
+ ~ObjHelperHint();
+
+ /** CObjHelperHint::Init (160824): reads objhints.xml */
+ void init(const char *path);
+ /** CObjHelperHint::CheckHintable (1603D4) */
+ bool checkHintable(Interact *interaction);
+ /** CObjHelperHint::InitAniObjs (160404) */
+ void initAniObjs(Scene *scene);
+ /** CObjHelperHint::ShowObjHelperHint (160578) */
+ void showObjHelperHint(Scene *scene);
+ /** CObjHelperHint::HideObjHelperHint (1605DA) */
+ void hideObjHelperHint(Scene *scene);
+ /** CObjHelperHint::ClearAniObjs (160628) */
+ void clearAniObjs();
+ /** CObjHelperHint::CheckObjHelperHint (16064A): called by CFPController::OnUpdate */
+ void checkObjHelperHint(Scene *scene);
+
+private:
+ /** ObjHelperHintItem: one OBJ of objhints.xml */
+ struct Item {
+ int objectId; // +0: "id"
+ int command; // +4: "cmd", the command type of the Android build
+ };
+
+ /** one glow copy and the object it is shown on */
+ struct HintAni {
+ GameObject *object;
+ AniObject *ani;
+ };
+
+ AniObject *_template = nullptr; // +8: ANI_REACT of SC_COMMON
+ Common::Array<HintAni> _aniObjs; // +12: std::map<CVisibleObject *, CAniObject *>, the size is +32
+ Common::Array<Item> _items; // +36: std::vector<ObjHelperHintItem>
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_OBJHELPER_H
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index ba01d6fa04e..b929f6c0eb9 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -95,6 +95,7 @@ MODULE_OBJS = \
fullpipe/map.o \
fullpipe/mapwindowcontroller.o \
fullpipe/notebook.o \
+ fullpipe/objhelper.o \
fullpipe/sc01controller.o \
fullpipe/sc02controller.o \
fullpipe/sc03controller.o \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 92aeccb6068..7db765a2474 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -42,6 +42,7 @@
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/objhelper.h"
#include "ngi/fullpipe/tutorialmanager.h"
#include "ngi/debugger/testmode.h"
#include "ngi/debugger/debugtools.h"
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 6de77386a1a..b649eb73cf3 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -93,6 +93,8 @@ class Command;
class FlyPack;
class TaskManager;
class TutorialManager;
+class ObjHelperManager;
+class ObjHelperHint;
class ExitManager;
class Tremble;
class Map;
@@ -305,6 +307,9 @@ public:
Common::ScopedPtr<TaskManager> _taskManager;
/** CSingleton<CTutorialManager>: the tutorials of tutorials.xml (Android) */
Common::ScopedPtr<TutorialManager> _tutorialManager;
+ /** CSingleton<CObjHelperManager> (objhelpers.xml), CSingleton<CObjHelperHint> (objhints.xml) */
+ Common::ScopedPtr<ObjHelperManager> _objHelperManager;
+ Common::ScopedPtr<ObjHelperHint> _objHelperHint;
/** CSingleton<CExitManager>: the exits of the scenes (Android) */
Common::ScopedPtr<ExitManager> _exitManager;
Common::ScopedPtr<Tremble> _tremble;
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 8d8719f1b8e..85cd3879de0 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -52,6 +52,7 @@
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/objhelper.h"
#include "ngi/fullpipe/tutorialmanager.h"
namespace NGI {
@@ -1821,6 +1822,11 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
g_ngi->_chapterManager.reset(new ChapterManager);
if (!g_ngi->_chapterManager->init("data/chapter.xml"))
return Common::Error(Common::kNoGameDataFoundError, "Could not read the chapters");
+ // CSplashScreenController::CreateControllers (1A6B8C): objhelpers.xml, objhints.xml
+ g_ngi->_objHelperManager.reset(new ObjHelperManager);
+ g_ngi->_objHelperManager->init("data/objhelpers.xml");
+ g_ngi->_objHelperHint.reset(new ObjHelperHint);
+ g_ngi->_objHelperHint->init("data/objhints.xml");
g_ngi->_taskManager.reset(new TaskManager);
createSceneController(SC_NOTEBOOK); // CNotebookController
if (!g_ngi->_taskManager->init("data/tasks.xml", project._objectIds))
Commit: f9adfd72cb8af0eb1515b729b535f0676a803d1b
https://github.com/scummvm/scummvm/commit/f9adfd72cb8af0eb1515b729b535f0676a803d1b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: HintManager (CHintManager) and the hints of the controllers
Changed paths:
A engines/ngi/fullpipe/hintmanager.cpp
A engines/ngi/fullpipe/hintmanager.h
engines/ngi/fullpipe/controllerhelpers.cpp
engines/ngi/fullpipe/controllerhelpers.h
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/liftcontroller.cpp
engines/ngi/fullpipe/sc04controller.cpp
engines/ngi/fullpipe/sc06controller.cpp
engines/ngi/fullpipe/sc08controller.cpp
engines/ngi/fullpipe/sc09controller.cpp
engines/ngi/fullpipe/sc11controller.cpp
engines/ngi/fullpipe/sc14controller.cpp
engines/ngi/fullpipe/sc27controller.cpp
engines/ngi/fullpipe/sc29controller.cpp
engines/ngi/guimanager.cpp
engines/ngi/guimanager.h
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/controllerhelpers.cpp b/engines/ngi/fullpipe/controllerhelpers.cpp
index cc045f9996a..69e76be7a6e 100644
--- a/engines/ngi/fullpipe/controllerhelpers.cpp
+++ b/engines/ngi/fullpipe/controllerhelpers.cpp
@@ -120,18 +120,6 @@ void setSaving(bool) {
warnOnce("CBaseSettings::SetSaving (the saves are not blocked while the arcade runs)");
}
-void showHint() {
- warnOnce("CHintManager::ShowHint (the hint of the arcade is not shown)");
-}
-
-void hideHint() {
- warnOnce("CHintManager::HideHint (the hint of the arcade is not shown)");
-}
-
-void setHideHintCondition() {
- warnOnce("CHintManager::SetHideCondition (the hint of the arcade is not shown)");
-}
-
void enableSound(int, bool) {
warnOnce("CBehaviorController::EnableSound is not ported");
}
diff --git a/engines/ngi/fullpipe/controllerhelpers.h b/engines/ngi/fullpipe/controllerhelpers.h
index eab62b30177..c32f1c08ef9 100644
--- a/engines/ngi/fullpipe/controllerhelpers.h
+++ b/engines/ngi/fullpipe/controllerhelpers.h
@@ -49,9 +49,6 @@ int projectId(const char *name);
// placeholders of subsystems that are not ported
void warnOnce(const char *what);
void setSaving(bool allowed); // CBaseSettings::SetSaving
-void showHint(); // CHintManager::ShowHint
-void hideHint(); // CHintManager::HideHint
-void setHideHintCondition(); // CHintManager::SetHideCondition
void enableSound(int soundId, bool enable); // CBehaviorController::EnableSound
void blockActivatingCounter(); // CAchievementsManager::BlockActivatingCounter
void addActivatingCounter(); // CAchievementsManager::AddActivatingCounter
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 08121841a2a..2ebf96902c2 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -38,6 +38,7 @@
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/fpcontroller.h"
#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/objhelper.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/map.h"
@@ -522,6 +523,8 @@ void FPController::testScroll() {
// CFPController::OnUpdate, the camera part: every 10 ms UpdateScroll, TestScroll unless touching
void FPController::onUpdate(uint32 elapsed) {
+ // the time restarts while the hero cannot be swiped (CanSwipeMan(0, 0) is false)
+ g_ngi->_hintManager->onUpdate(elapsed);
checkTutorial();
checkQueues();
_elapsed += elapsed;
diff --git a/engines/ngi/fullpipe/hintmanager.cpp b/engines/ngi/fullpipe/hintmanager.cpp
new file mode 100644
index 00000000000..ab106345d4c
--- /dev/null
+++ b/engines/ngi/fullpipe/hintmanager.cpp
@@ -0,0 +1,194 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/serializer.h"
+
+#include "ngi/ngi.h"
+#include "ngi/font.h"
+#include "ngi/guimanager.h"
+#include "ngi/scene.h"
+#include "ngi/xmlnode.h"
+#include "ngi/fullpipe/hintmanager.h"
+
+namespace NGI {
+
+namespace {
+
+// CIDList::FindId: 0 for an unknown name
+int findId(const char *name) {
+ uint32 id = 0;
+ if (name[0])
+ g_ngi->_gameProject->_objectIds.findId(name, id);
+ return id;
+}
+
+// CTextContainer::GetText: the text of the id, the id itself when it is not a text of the game
+Common::String getText(const Common::String &id) {
+ const Common::String text = g_ngi->getText(id);
+ return text.empty() ? id : text;
+}
+
+} // End of anonymous namespace
+
+// CHintManager::CHintManager
+HintManager::HintManager() {
+}
+
+// CHintManager::~CHintManager
+HintManager::~HintManager() {
+}
+
+// CHintManager::Init (153098): the hint time (+24) is not set there, CleanXml makes it -1
+void HintManager::init(const char *path) {
+ g_ngi->getFont("impact_20.fnt");
+ Common::ScopedPtr<XmlNode> document(loadXmlDocument(path));
+ if (!document) {
+ warning("Could not read %s", path);
+ return;
+ }
+ const XmlNode &root = document->first();
+ for (uint i = 0; i < root.childCount(); i++) {
+ if (root[i].name() != "HINT")
+ continue;
+ HintInfo info;
+ info._text = getText(root[i].attrStr("text_id", ""));
+ const XmlVector2 pos = root[i].attrVector2("pos", 150, 550);
+ info._x = pos.x;
+ info._y = pos.y;
+ const XmlVector2 size = root[i].attrVector2("size", 520, 50);
+ info._width = size.x;
+ info._height = size.y;
+ info._font = g_ngi->getFont(root[i].attrStr("font", "impact_20.fnt"));
+ info._shown = false;
+ info._hideCondition = false;
+ const uint32 sceneId = findId(root[i].attrStr("scene", ""));
+ _hints[sceneId].push_back(info);
+ }
+ debugC(1, kDebugXML, "Loaded the hints of %u scenes from %s", _hints.size(), path);
+}
+
+// CHintManager::CleanXml (1525BA)
+void HintManager::cleanXml() {
+ for (auto &entry : _hints) {
+ Common::Array<HintInfo> &hints = entry.second;
+ for (uint i = 0; i < hints.size(); i++) {
+ hints[i]._shown = false;
+ hints[i]._time = -1;
+ hints[i]._hideCondition = false;
+ }
+ }
+}
+
+// CHintManager::SetXmlData (152DEC). The index num is checked here (the original does not)
+void HintManager::setXmlData(const XmlNode &node) {
+ for (uint i = 0; i < node.childCount(); i++) {
+ if (node[i].name() != "HINT")
+ continue;
+ const uint32 sceneId = findId(node[i].attrStr("scene", ""));
+ auto it = _hints.find(sceneId);
+ if (it == _hints.end())
+ continue;
+ const uint num = node[i].attrInt("num", 0);
+ if (num < it->second.size())
+ it->second[num]._shown = node[i].attrInt("show", 0) != 0;
+ }
+}
+
+// CHintManager::GetXmlData (152660) / SetXmlData: the scene, the number and "show" of every hint
+void HintManager::syncGame(Common::Serializer &s) {
+ for (auto &entry : _hints) {
+ Common::Array<HintInfo> &hints = entry.second;
+ for (uint i = 0; i < hints.size(); i++)
+ s.syncAsByte(hints[i]._shown);
+ }
+}
+
+// CHintManager::OnUpdate (15286C): after 10 s (9999 ms) with the hide condition (+29) it hides
+void HintManager::onUpdate(uint32 elapsed) {
+ for (auto &entry : _hints) {
+ Common::Array<HintInfo> &hints = entry.second;
+ for (uint i = 0; i < hints.size(); i++) {
+ HintInfo &hint = hints[i];
+ if (hint._time < 0)
+ continue;
+ hint._time += elapsed;
+ if (hint._time > 9999 && hint._hideCondition) {
+ hideHint(g_ngi->findScene(entry.first));
+ hint._time = -1;
+ hint._hideCondition = false;
+ }
+ }
+ }
+}
+
+// CHintManager::ShowHint (152B70): a hint that was shown (SetShown) does not show again
+void HintManager::showHint(Scene *scene, int num, int time) {
+ if (!scene)
+ return;
+ if (_hints.find(scene->_sceneId) == _hints.end())
+ return;
+ if (_hints[scene->_sceneId][num]._shown)
+ return;
+
+ GuiText *element = static_cast<GuiText *>(scene->_guiManager->getElement("HINT_TEXT"));
+ _hints[scene->_sceneId][num]._time = time;
+ const HintInfo info = _hints[scene->_sceneId][num];
+ if (!element) {
+ element = new GuiText(*scene);
+ element->_id = "HINT_TEXT";
+ element->setAlign(BitmapFont::kAlignCenter);
+ element->setVerticalAlign(BitmapFont::kVerticalBottom);
+ scene->_guiManager->addGuiElement(element);
+ }
+ element->setFont(info._font);
+ element->setText(info._text);
+ element->setSize(info._width, info._height);
+ element->setPos(Common::Point((int)info._x, (int)info._y));
+ element->show();
+}
+
+// CHintManager::HideHint (152834)
+void HintManager::hideHint(Scene *scene) {
+ if (!scene)
+ return;
+ if (GuiElement *element = scene->_guiManager->getElement("HINT_TEXT"))
+ element->hide();
+}
+
+// CHintManager::SetShown (152CCC)
+void HintManager::setShown(Scene *scene, int num) {
+ if (!scene)
+ return;
+ if (_hints.find(scene->_sceneId) != _hints.end())
+ _hints[scene->_sceneId][num]._shown = true;
+}
+
+// CHintManager::SetHideCondition (152D0C): only a hint that is shown (+24 >= 0) gets it
+void HintManager::setHideCondition(Scene *scene, int num) {
+ if (!scene)
+ return;
+ if (_hints.find(scene->_sceneId) == _hints.end())
+ return;
+ if (_hints[scene->_sceneId][num]._time >= 0)
+ _hints[scene->_sceneId][num]._hideCondition = true;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/hintmanager.h b/engines/ngi/fullpipe/hintmanager.h
new file mode 100644
index 00000000000..821c7722df6
--- /dev/null
+++ b/engines/ngi/fullpipe/hintmanager.h
@@ -0,0 +1,90 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_HINTMANAGER_H
+#define NGI_FULLPIPE_HINTMANAGER_H
+
+#include "common/array.h"
+#include "common/stablemap.h"
+#include "common/str.h"
+
+namespace Common {
+class Serializer;
+}
+
+namespace NGI {
+
+class BitmapFont;
+class Scene;
+class XmlNode;
+
+/** CHintInfo (32 bytes), one hint of hints.xml: the text over an arcade scene and its show state */
+struct HintInfo {
+ Common::String _text; // +0: "text_id"
+ float _x = 150; // +4: "pos"
+ float _y = 550; // +8
+ float _width = 520; // +12: "size"
+ float _height = 50; // +16
+ const BitmapFont *_font = nullptr; // +20: "font"
+ int _time = -1; // +24: the milliseconds that the hint is shown, -1 while it is not
+ bool _shown = false; // +28: CHintManager::SetShown; the only field that is saved
+ bool _hideCondition = false; // +29: CHintManager::SetHideCondition: hides after 10 seconds
+};
+
+/** CHintManager (CSingleton, here NGIEngine::_hintManager): the hints of hints.xml by scene */
+class HintManager {
+public:
+ /** CHintManager::CHintManager */
+ HintManager();
+ /** CHintManager::~CHintManager */
+ ~HintManager();
+
+ /** CHintManager::Init: reads the file */
+ void init(const char *path);
+ /** CHintManager::CleanXml: no hint was shown (a new game, a load) */
+ void cleanXml();
+ /** CHintManager::SetXmlData: the saved "show" of every HINT (scene, num) */
+ void setXmlData(const XmlNode &node);
+ /** CHintManager::GetXmlData / SetXmlData: hints.sav in the original; here the show fields
+ are synced in the order of the scenes */
+ void syncGame(Common::Serializer &s);
+ /** CHintManager::GetSavePath: the file of the original; the engine saves in the savegames */
+ Common::String getSavePath() const { return "hints.sav"; }
+
+ /** CHintManager::OnUpdate: the time of the shown hints; a hide condition hides after 10 s */
+ void onUpdate(uint32 elapsed);
+ /** CHintManager::ShowHint: shows hint num of the scene (HINT_TEXT), its time starts at time */
+ void showHint(Scene *scene, int num, int time);
+ /** CHintManager::HideHint: HINT_TEXT of the scene is hidden */
+ void hideHint(Scene *scene);
+ /** CHintManager::SetShown */
+ void setShown(Scene *scene, int num);
+ /** CHintManager::SetHideCondition: a hint that is shown hides when its time is over */
+ void setHideCondition(Scene *scene, int num);
+
+private:
+ // +8: std::map<unsigned int, std::vector<CHintInfo>> by the id of the scene
+ Common::StableMap<uint32, Common::Array<HintInfo> > _hints;
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_HINTMANAGER_H
diff --git a/engines/ngi/fullpipe/liftcontroller.cpp b/engines/ngi/fullpipe/liftcontroller.cpp
index 3d19ff1b07d..1bf18b3876c 100644
--- a/engines/ngi/fullpipe/liftcontroller.cpp
+++ b/engines/ngi/fullpipe/liftcontroller.cpp
@@ -24,6 +24,7 @@
#include "ngi/ngi.h"
#include "ngi/input.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/liftcontroller.h"
#include "ngi/scene.h"
@@ -109,15 +110,15 @@ void LiftController::sortButtons(const Common::Array<AniObject *> &buttons) {
warnOnce("CLiftController::SortButtons: the additional lift tutorials are not ported");
}
-// CLiftController::OnHide: CScene::RemoveCopies removes the big buttons, the map is cleared. CInventory::SetItemsState(0) and the hint of the scene 3
-// (CHintManager::HideHint) are not ported.
+// CLiftController::OnHide: RemoveCopies, clears the map, hides the scene 3 hint
+// (CHintManager::HideHint); CInventory::SetItemsState(0) is not ported
void LiftController::onHide() {
_scene->removeCopies();
_buttons.clear();
_selected = nullptr;
_time = 0;
if (g_ngi->getSceneInStack(0)->_sceneId == SC_3)
- warnOnce("CHintManager::HideHint (the scene 3 hint) is not ported");
+ g_ngi->_hintManager->hideHint(g_ngi->getSceneInStack(0));
}
// CLiftController::OnUpdate: the scene below goes on (CScene::Update); 100 ms after a button
diff --git a/engines/ngi/fullpipe/sc04controller.cpp b/engines/ngi/fullpipe/sc04controller.cpp
index 36180a77093..963ea94659f 100644
--- a/engines/ngi/fullpipe/sc04controller.cpp
+++ b/engines/ngi/fullpipe/sc04controller.cpp
@@ -40,6 +40,7 @@
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc04controller.h"
#include "ngi/fullpipe/scenes.h"
@@ -554,7 +555,7 @@ void Sc04Controller::doStopArcade() {
_cameraLocked = false;
_musicStopped = false;
_hintPending = false;
- warnOnce("CHintManager::HideHint (hint glow)");
+ g_ngi->_hintManager->hideHint(_scene);
g_ngi->setState(sO_Hint_1_05, 0);
_lamps->_flags &= ~4;
}
@@ -957,7 +958,7 @@ void Sc04Controller::doShootKozawka() {
_lastKozaw = kozaw;
if (queue)
_scene->runQueueObject(queue, kozaw, 3);
- warnOnce("CHintManager::SetHideCondition");
+ g_ngi->_hintManager->setHideCondition(_scene, 0);
}
_kozawShot = true;
}
@@ -1376,7 +1377,7 @@ void Sc04Controller::onHide() {
_clock->setStatic(ST_CLK_CLOSED);
_lamps->_flags &= ~4;
FPController::onHide();
- warnOnce("CHintManager::HideHint (hint glow)");
+ g_ngi->_hintManager->hideHint(_scene);
g_ngi->setState(sO_Hint_1_05, 0);
g_ngi->_exitManager->resetExitIntersect(PIC_SC4_LTRUBA, false);
// analytics lose_count_ANI_KOZAWKA, game_ANI_KOZAWKA_lose: not ported
@@ -1722,7 +1723,7 @@ void Sc04Controller::onMessage(const Common::String &message, const Common::Stri
}
if (message == "MSG_SC4_SHOW_HINT") {
_hintPending = false;
- warnOnce("CHintManager::ShowHint (MSG_SC4_SHOW_HINT)");
+ g_ngi->_hintManager->showHint(_scene, 0, 0);
g_ngi->arcadeInterface().init(400, -100, -64, 0, 3, 0, true);
g_ngi->arcadeInterface().scrollIn();
return;
diff --git a/engines/ngi/fullpipe/sc06controller.cpp b/engines/ngi/fullpipe/sc06controller.cpp
index 56bdc6416d0..5e7e4437b79 100644
--- a/engines/ngi/fullpipe/sc06controller.cpp
+++ b/engines/ngi/fullpipe/sc06controller.cpp
@@ -37,6 +37,7 @@
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
+#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc06controller.h"
@@ -331,7 +332,7 @@ void Sc06Controller::doManShoot() {
_powerArrow->_scaleX = _aimScale;
_powerArrow->_scaleY = 1.0f;
_aiming = false;
- setHideHintCondition();
+ g_ngi->_hintManager->setHideCondition(_scene, 0);
}
// CSc06Controller::GetCursorTypeTop (16B980): the cursor over Mumsy in the arcade
@@ -391,7 +392,7 @@ void Sc06Controller::onUTrubaClick() {
// CSc06Controller::DoTakeBall (16BAF8): the hero takes the ball, interaction and walking off
void Sc06Controller::doTakeBall() {
if (_dropsShown == 1) {
- showHint();
+ g_ngi->_hintManager->showHint(_scene, 0, 0);
// CFPController::FlurryArcadeStart("ANI_MAMASHA"): analytics not ported
}
_holdingBall = true;
@@ -500,7 +501,7 @@ void Sc06Controller::doStopArcade() {
_ballsCaught = 0;
_arcadeRunning = false;
_follow = nullptr;
- hideHint();
+ g_ngi->_hintManager->hideHint(_scene);
g_ngi->setState(sO_Hint_2_02, 0);
setSaving(true);
}
@@ -597,7 +598,7 @@ void Sc06Controller::skipArcade() {
_ballsCaught = 0;
_arcadeRunning = false;
_follow = nullptr;
- hideHint();
+ g_ngi->_hintManager->hideHint(_scene);
g_ngi->setState(sO_Hint_2_02, 0);
setSaving(true);
}
@@ -724,7 +725,7 @@ void Sc06Controller::doWinArcade() {
_scene->_motionController->activate();
getGameLoaderInteractionController()->enable();
_scene->_behaviorController->enableAllQueuesForAni(hero(), true);
- hideHint();
+ g_ngi->_hintManager->hideHint(_scene);
g_ngi->setState(sO_Hint_2_02, 0);
g_ngi->_taskManager->deactivateTask("GET_DEVICE_SC6");
setSaving(true);
@@ -854,7 +855,7 @@ void Sc06Controller::onHide() {
g_ngi->setState(sO_Hint_2_02, 0);
_dropsShown = -1;
moveLiquid();
- hideHint();
+ g_ngi->_hintManager->hideHint(_scene);
if (_arcadeRunning) {
// CFlurryEventManager lose_count/game_..._lose: analytics not ported
}
diff --git a/engines/ngi/fullpipe/sc08controller.cpp b/engines/ngi/fullpipe/sc08controller.cpp
index 7f61a1ef884..cc8d0daa77e 100644
--- a/engines/ngi/fullpipe/sc08controller.cpp
+++ b/engines/ngi/fullpipe/sc08controller.cpp
@@ -37,6 +37,7 @@
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
+#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc08controller.h"
@@ -264,7 +265,7 @@ void Sc08Controller::doWinArcade() {
_scene->_y = 0;
_targetY = 0;
doStep2();
- hideHint();
+ g_ngi->_hintManager->hideHint(_scene);
g_ngi->_taskManager->deactivateTask("FIND_EXIT_BATUTA_SC8");
setSaving(true);
}
@@ -291,7 +292,7 @@ void Sc08Controller::endBatut() {
_scene->_behaviorController->enableAllQueuesForAni(_scene->findAniObjectById(ANI_MAN, 0), 1);
_scene->_behaviorController->enableAllQueuesForAni(_batuta, 1);
setSaving(true);
- hideHint();
+ g_ngi->_hintManager->hideHint(_scene);
}
// CSc08Controller::DoJumpoff (16F258)
@@ -339,7 +340,7 @@ void Sc08Controller::startBatut() {
_targetY = 0;
_scene->_behaviorController->enableAllQueuesForAni(_scene->findAniObjectById(ANI_MAN, 0), 0);
_scene->_behaviorController->enableAllQueuesForAni(_batuta, 0);
- showHint();
+ g_ngi->_hintManager->showHint(_scene, 0, 0);
if (g_ngi->getStateId(sO_WarmUp) == g_ngi->getStateValue(sO_WarmUp, sO_Fast))
_step = (int)_stepSpeeds.size();
else
@@ -552,7 +553,7 @@ void Sc08Controller::onHide() {
setSaving(true);
_flyPack->deleteAllFlies();
if (controllerRunsSceneLogic()) {
- hideHint();
+ g_ngi->_hintManager->hideHint(_scene);
// the analytics event game_ANI_BATUTA_lose is not ported
}
FPController::onHide();
@@ -782,7 +783,7 @@ void Sc08Controller::onGuiEvent(const Common::String &id, const Common::String &
}
_stepGrace = 1;
// the analytics parameter first_move_ANI_BATUTA (CFlurryEventManager) is not ported
- setHideHintCondition();
+ g_ngi->_hintManager->setHideCondition(_scene, 0);
} else {
// the analytics parameters first_move and failcount are not ported
}
diff --git a/engines/ngi/fullpipe/sc09controller.cpp b/engines/ngi/fullpipe/sc09controller.cpp
index 685b1ff78e5..c35140320a1 100644
--- a/engines/ngi/fullpipe/sc09controller.cpp
+++ b/engines/ngi/fullpipe/sc09controller.cpp
@@ -38,6 +38,7 @@
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc09controller.h"
@@ -416,7 +417,7 @@ bool Sc09Controller::canShowHelp() {
// CSc09Controller::DoStopShoot (171A04)
void Sc09Controller::doStopShoot() {
if (!_scene->_motionController->_isEnabled) {
- warnOnce("CHintManager::HideHint is not ported");
+ g_ngi->_hintManager->hideHint(_scene);
hero()->setStatic(ST_MAN9_SHOOT);
hero()->startMovement(MV_MAN9_ENDSHOOT, 0, -1);
_shootIdle = 0;
@@ -440,7 +441,7 @@ void Sc09Controller::doFlyAway() {
_gulper->startMovement(MV_GLT_FLYAWAY, 0, -1);
g_ngi->setState(sO_Jug, g_ngi->getStateValue(sO_Jug, sO_Unblocked));
g_ngi->setState(sO_RightStairs_9, g_ngi->getStateValue(sO_RightStairs_9, sO_IsOpened));
- warnOnce("CHintManager::HideHint is not ported");
+ g_ngi->_hintManager->hideHint(_scene);
_gulperPresent = false;
doStopShoot();
doUpdatePath();
@@ -457,7 +458,7 @@ void Sc09Controller::doWinArcade() {
g_ngi->setState(sO_RightStairs_9, g_ngi->getStateValue(sO_RightStairs_9, sO_IsOpened));
_gulperPresent = false;
doUpdatePath();
- warnOnce("CHintManager::HideHint is not ported");
+ g_ngi->_hintManager->hideHint(_scene);
}
}
@@ -491,7 +492,7 @@ void Sc09Controller::skipArcade() {
}
g_ngi->setState(sO_Jug, g_ngi->getStateValue(sO_Jug, sO_Unblocked));
g_ngi->setState(sO_RightStairs_9, g_ngi->getStateValue(sO_RightStairs_9, sO_IsOpened));
- warnOnce("CHintManager::HideHint is not ported");
+ g_ngi->_hintManager->hideHint(_scene);
_gulperPresent = false;
_skipArcade = false;
_arcadeStarted = false;
@@ -522,7 +523,7 @@ void Sc09Controller::countBallFlight(uint32 elapsed) {
}
}
if (i != 0)
- warnOnce("CHintManager::SetHideCondition is not ported");
+ g_ngi->_hintManager->setHideCondition(_scene, 0);
}
} else {
explode = true;
@@ -566,7 +567,7 @@ void Sc09Controller::doStartShoot() {
g_ngi->arcadeInterface().init(132.0f, -100.0f, 64.0f, 0.0f, 3, 0, true);
g_ngi->arcadeInterface().setCounter(_numSwallowed);
g_ngi->arcadeInterface().scrollIn();
- warnOnce("CHintManager::ShowHint is not ported");
+ g_ngi->_hintManager->showHint(_scene, 0, 0);
}
}
}
@@ -965,7 +966,7 @@ void Sc09Controller::onHide() {
hideAction(_scene, ANI_TIOTIA, 0);
if (g_ngi->arcadeInterface().getState() != ArcadeInterface::kHidden)
doStopShoot();
- warnOnce("CHintManager::HideHint is not ported");
+ g_ngi->_hintManager->hideHint(_scene);
for (uint i = 0; i < _hangers.size(); i++) {
AniObject *ani = _hangers[i].ani;
if (ani->_copyId != 0)
diff --git a/engines/ngi/fullpipe/sc11controller.cpp b/engines/ngi/fullpipe/sc11controller.cpp
index 36c5277042a..d7091cf650a 100644
--- a/engines/ngi/fullpipe/sc11controller.cpp
+++ b/engines/ngi/fullpipe/sc11controller.cpp
@@ -40,6 +40,7 @@
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
+#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc11controller.h"
@@ -466,7 +467,7 @@ void Sc11Controller::doRetire() {
hero()->setPosition(Common::Point(685, 373));
hero()->startMovement(MV_MAN11_JUMPFROMSWING, 0, -1);
_follow = hero();
- warnOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
+ g_ngi->_hintManager->hideHint(_scene);
warnOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
}
@@ -476,7 +477,7 @@ void Sc11Controller::doWinArcade() {
_arcadeRunning = false;
leaveSwing();
g_ngi->_gameLoader->setScene(SC_5, TrubaUp);
- warnOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
+ g_ngi->_hintManager->hideHint(_scene);
warnOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
}
}
@@ -507,7 +508,8 @@ void Sc11Controller::startArcade() {
_swingMan->_rotation = kRotationDown;
_targetX = (1150.0f - ((float)_scene->_x + (float)g_ngi->gameWidth())) + renderMargin();
g_ngi->_aniHandler->detachAllObjects();
- warnOnce("CHintManager::ShowHint / SetHideCondition (CSc11Controller::StartArcade): the hints are not ported");
+ g_ngi->_hintManager->showHint(_scene, 0, 0);
+ g_ngi->_hintManager->setHideCondition(_scene, 0);
}
// CSc11Controller::DoJumpToTruba (175308): the man jumps over the pipe, then SC_5
@@ -578,7 +580,7 @@ void Sc11Controller::skipArcade() {
doJumpToTruba();
_arcadeRunning = false;
_hint->_flags &= ~4;
- warnOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
+ g_ngi->_hintManager->hideHint(_scene);
_scene->_behaviorController->disableAllMusic();
warnOnce("CBehaviorController::EnableSound (CSc11Controller): SND_MUS_7 / SND_MUS_11 are not switched on");
warnOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
@@ -689,7 +691,7 @@ void Sc11Controller::onRButtonDown() {
}
_arcadeRunning = false;
_hint->_flags &= ~4;
- warnOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
+ g_ngi->_hintManager->hideHint(_scene);
_scene->_behaviorController->disableAllMusic();
warnOnce("CBehaviorController::EnableSound (CSc11Controller): SND_MUS_7 / SND_MUS_11 are not switched on");
warnOnce("CBaseSettings::SetSaving (CSc11Controller): saving is not switched off and on during the arcade");
@@ -886,7 +888,7 @@ void Sc11Controller::onHide() {
if (logic) {
g_ngi->_exitManager->resetExitIntersect(PIC_SC11_LTRUBA, false);
warnOnce("CAniObject::UnloadMovement / CPreloadManager::OnUnloadMove (CSc11Controller::OnHide): MV_KCH_MOVE2 is not unloaded");
- warnOnce("CHintManager::HideHint (CSc11Controller::DoRetire, DoWinArcade, OnRButtonDown, SkipArcade, OnHide): the hints are not ported");
+ g_ngi->_hintManager->hideHint(_scene);
}
}
diff --git a/engines/ngi/fullpipe/sc14controller.cpp b/engines/ngi/fullpipe/sc14controller.cpp
index 47d69fab014..54eb1277967 100644
--- a/engines/ngi/fullpipe/sc14controller.cpp
+++ b/engines/ngi/fullpipe/sc14controller.cpp
@@ -36,6 +36,7 @@
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
+#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc14controller.h"
@@ -310,7 +311,7 @@ void Sc14Controller::stopArcade() {
_sceneOffsetY = 300.0f;
_sceneOffsetX = 400.0f;
_follow = hero();
- hideHint();
+ g_ngi->_hintManager->hideHint(_scene);
setSaving(true);
}
@@ -367,7 +368,7 @@ void Sc14Controller::startArcade() {
_sceneOffsetX = 100.0f;
_hitsLeft = 4;
_scene->runQueue(QU_SC14_STARTARCADE, 2);
- showHint();
+ g_ngi->_hintManager->showHint(_scene, 0, 0);
}
// CSc14Controller::OnLButtonUp (178F7C): button let go while dragged: he kicks, hits a near ball
@@ -389,7 +390,7 @@ bool Sc14Controller::onLButtonUp() {
_flyingBall->_flags &= ~4;
if (_hitsLeft == 1)
g_ngi->arcadeInterface().scrollOut();
- setHideHintCondition();
+ g_ngi->_hintManager->setHideCondition(_scene, 0);
} else {
// analytics first_move_ANI_GRANDMA = 0, failcount_ANI_GRANDMA: not ported
hero()->stopMovement();
@@ -410,7 +411,7 @@ void Sc14Controller::doManSurrender() {
_grandma->setStatic(ST_GMA_SIT, false);
_scene->runQueue(QU_SC14_ENDARCADE, 2);
getGameLoaderInteractionController()->disable();
- hideHint();
+ g_ngi->_hintManager->hideHint(_scene);
runInteraction(PIC_SC14_RTRUBA);
setSaving(true);
}
@@ -931,7 +932,7 @@ void Sc14Controller::onHide() {
_pink->_flags &= ~4;
if (_flyingBall && (_flyingBall->_flags & 4))
_flyingBall->_flags &= ~4;
- hideHint();
+ g_ngi->_hintManager->hideHint(_scene);
FPController::onHide();
}
diff --git a/engines/ngi/fullpipe/sc27controller.cpp b/engines/ngi/fullpipe/sc27controller.cpp
index a3f009ab2c5..6e93321e57a 100644
--- a/engines/ngi/fullpipe/sc27controller.cpp
+++ b/engines/ngi/fullpipe/sc27controller.cpp
@@ -37,6 +37,7 @@
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
+#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc27controller.h"
#include "ngi/fullpipe/taskmanager.h"
@@ -375,7 +376,7 @@ void Sc27Controller::stopDrag() {
_powerArrow->_scaleX = 0.7f;
_powerArrow->_scaleY = 1.0f;
hero()->setCurFrame(throwFrame, true);
- warnOnce("CHintManager::SetHideCondition (CSc27Controller::StopDrag)");
+ g_ngi->_hintManager->setHideCondition(_scene, 0);
}
// CSc27Controller::ShowNextBet (188F88)
@@ -407,7 +408,7 @@ void Sc27Controller::doWin() {
_scene->_motionController->activate();
getGameLoaderInteractionController()->enable();
_scene->_behaviorController->enableAllQueuesForAni(hero(), 1);
- warnOnce("CHintManager::HideHint (CSc27Controller)");
+ g_ngi->_hintManager->hideHint(_scene);
warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc27Controller)");
}
@@ -428,7 +429,7 @@ void Sc27Controller::doTakeBet(MessageQueue *queue) {
// CFPController::FlurryArcadeStart "ANI_BET": analytics, not ported
}
if (!_arcadeRunning)
- warnOnce("CHintManager::ShowHint (CSc27Controller::DoTakeBet)");
+ g_ngi->_hintManager->showHint(_scene, 0, 0);
_startEvent = false;
warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc27Controller)");
hero()->startMovement(MV_MAN27_THROWBET, 0, -1);
@@ -469,7 +470,7 @@ void Sc27Controller::skipArcade() {
_scene->_motionController->activate();
getGameLoaderInteractionController()->enable();
_scene->_behaviorController->enableAllQueuesForAni(hero(), 1);
- warnOnce("CHintManager::HideHint (CSc27Controller)");
+ g_ngi->_hintManager->hideHint(_scene);
warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc27Controller)");
// CFPController::FlurryArcadeSkip "ANI_BET": analytics, not ported
_startEvent = true;
@@ -508,7 +509,7 @@ void Sc27Controller::prepareNextBet(int highlighted) {
getGameLoaderInteractionController()->enable();
_scene->_behaviorController->enableAllQueuesForAni(hero(), 1);
_arcadeRunning = false;
- warnOnce("CHintManager::HideHint (CSc27Controller)");
+ g_ngi->_hintManager->hideHint(_scene);
warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc27Controller)");
// Flurry events (analytics) are not ported
}
@@ -834,7 +835,7 @@ void Sc27Controller::onHide() {
g_ngi->arcadeInterface().scrollOut();
warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc27Controller)");
removeCopies();
- warnOnce("CHintManager::HideHint (CSc27Controller)");
+ g_ngi->_hintManager->hideHint(_scene);
FPController::onHide();
}
diff --git a/engines/ngi/fullpipe/sc29controller.cpp b/engines/ngi/fullpipe/sc29controller.cpp
index 073ca945b8c..8b6d518c067 100644
--- a/engines/ngi/fullpipe/sc29controller.cpp
+++ b/engines/ngi/fullpipe/sc29controller.cpp
@@ -38,6 +38,7 @@
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
+#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc29controller.h"
@@ -276,7 +277,7 @@ void Sc29Controller::doJumpfromR() {
warning("sc29::DoJumpFromR: m_scene->RunQueue() returned false!");
_arcadeIsOn = false;
_rideBackEnabled = false;
- warnOnce("CHintManager::HideHint (CSc29Controller)");
+ g_ngi->_hintManager->hideHint(_scene);
warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc29Controller)");
}
@@ -394,7 +395,8 @@ void Sc29Controller::doJumptoL() {
warning("sc29::DoJumptoL: m_scene->RunQueue() returned false!");
_arcadeIsOn = true;
if (g_ngi->getStateId(sO_LeftPipe_29) != g_ngi->getStateValue(sO_LeftPipe_29, sO_IsOpened)) {
- warnOnce("CHintManager::ShowHint, SetHideCondition (CSc29Controller::DoJumptoL)");
+ g_ngi->_hintManager->showHint(_scene, 0, 0);
+ g_ngi->_hintManager->setHideCondition(_scene, 0);
// CFPController::FlurryArcadeStart (the analytics event of the start of the arcade) is not ported
if (g_ngi->arcadeInterface().getState() == ArcadeInterface::kHidden) {
g_ngi->arcadeInterface().init(155.0f, -100.0f, 64.0f, 0.0f, 7, 0, true);
@@ -755,7 +757,7 @@ void Sc29Controller::onHide() {
warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc29Controller)");
// the analytics event of a lost arcade is not ported
removeCopies();
- warnOnce("CHintManager::HideHint (CSc29Controller)");
+ g_ngi->_hintManager->hideHint(_scene);
}
FPController::onHide();
}
@@ -862,7 +864,7 @@ void Sc29Controller::onMessage(const Common::String &message, const Common::Stri
_rideBackEnabled = false;
_scene->_motionController->activate();
getGameLoaderInteractionController()->enable();
- warnOnce("CHintManager::HideHint (CSc29Controller)");
+ g_ngi->_hintManager->hideHint(_scene);
warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc29Controller)");
} else if (message == "MSG_SC29_SHOOTGREEN") {
doShootGreen();
diff --git a/engines/ngi/guimanager.cpp b/engines/ngi/guimanager.cpp
index 927f8493da0..bf2bd1318b6 100644
--- a/engines/ngi/guimanager.cpp
+++ b/engines/ngi/guimanager.cpp
@@ -72,6 +72,20 @@ GuiElement::GuiElement(Scene &scene, const Common::StringMap &attrs, const Objec
_pictureId = resourceId(attrs, "texture", ids);
}
+GuiElement::GuiElement(Scene &scene) :
+ _scene(scene) {
+ _id = "error";
+ _cursor = 1;
+ _z = 0;
+ _active = false;
+ _visible = false;
+ _scrolling = false;
+ _hasX = true;
+ _hasY = true;
+ _sourceScene = scene._sceneId;
+ _pictureId = 0;
+}
+
void GuiElement::load(GameProject &project) {
Scene *source = guiSourceScene(project, _sourceScene);
_picture = source && _pictureId ? source->findPictureObjectById(_pictureId, 0) : nullptr;
@@ -270,6 +284,16 @@ GuiText::GuiText(Scene &scene, const Common::StringMap &attrs, const ObjectIdLis
guiWarnColor(attrs, _id);
}
+GuiText::GuiText(Scene &scene) :
+ GuiElement(scene) {
+ _font = nullptr;
+ _width = 0;
+ _height = 0;
+ _align = BitmapFont::kAlignLeft;
+ _verticalAlign = BitmapFont::kVerticalTop;
+ _separate = true;
+}
+
void GuiText::setText(const Common::String &id) {
// CTextContainer::GetText returns the id itself when it is not a game text
_text = g_ngi->getText(id);
diff --git a/engines/ngi/guimanager.h b/engines/ngi/guimanager.h
index 8e25cdfb4a0..5bab9c4523a 100644
--- a/engines/ngi/guimanager.h
+++ b/engines/ngi/guimanager.h
@@ -40,6 +40,8 @@ class PictureObject;
class GuiElement {
public:
GuiElement(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids);
+ /** CGuiElement::CGuiElement(): an element made by code (CHintManager::ShowHint) */
+ explicit GuiElement(Scene &scene);
virtual ~GuiElement() {}
virtual void load(GameProject &project);
virtual void unload() { _picture = nullptr; }
@@ -103,9 +105,19 @@ class BitmapFont;
class GuiText : public GuiElement {
public:
GuiText(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids);
+ /** CGuiText::CGuiText(): left, top, no font, the text wrapped into the box (+88) */
+ explicit GuiText(Scene &scene);
void render(Graphics::ManagedSurface &target) const override;
/** CGuiText::SetText: the id of a text of the game, or a string that is shown as it is */
void setText(const Common::String &id);
+ /** CGuiText::SetFont, SetAlign (vtable 47), SetVerticalAlign (48) */
+ void setFont(const BitmapFont *font) { _font = font; }
+ void setAlign(int align) { _align = align; }
+ void setVerticalAlign(int align) { _verticalAlign = align; }
+ void setSize(float width, float height) {
+ _width = width;
+ _height = height;
+ }
private:
Common::String _text;
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index b929f6c0eb9..1d29e221e56 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -88,6 +88,7 @@ MODULE_OBJS = \
fullpipe/floaters.o \
fullpipe/fpcontroller.o \
fullpipe/fpguicontroller.o \
+ fullpipe/hintmanager.o \
fullpipe/inventorycontroller.o \
fullpipe/lift.o \
fullpipe/liftcontroller.o \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 7db765a2474..1f3854b6b51 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -44,6 +44,7 @@
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/objhelper.h"
#include "ngi/fullpipe/tutorialmanager.h"
+#include "ngi/fullpipe/hintmanager.h"
#include "ngi/debugger/testmode.h"
#include "ngi/debugger/debugtools.h"
#include "ngi/fullpipe/tremble.h"
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index b649eb73cf3..c430406d620 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -93,6 +93,7 @@ class Command;
class FlyPack;
class TaskManager;
class TutorialManager;
+class HintManager;
class ObjHelperManager;
class ObjHelperHint;
class ExitManager;
@@ -307,6 +308,8 @@ public:
Common::ScopedPtr<TaskManager> _taskManager;
/** CSingleton<CTutorialManager>: the tutorials of tutorials.xml (Android) */
Common::ScopedPtr<TutorialManager> _tutorialManager;
+ /** CSingleton<CHintManager> (hints.xml), <CHelp> (help.xml), <CNoActionLogger> */
+ Common::ScopedPtr<HintManager> _hintManager;
/** CSingleton<CObjHelperManager> (objhelpers.xml), CSingleton<CObjHelperHint> (objhints.xml) */
Common::ScopedPtr<ObjHelperManager> _objHelperManager;
Common::ScopedPtr<ObjHelperHint> _objHelperHint;
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 85cd3879de0..99a26451877 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -54,6 +54,7 @@
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/objhelper.h"
#include "ngi/fullpipe/tutorialmanager.h"
+#include "ngi/fullpipe/hintmanager.h"
namespace NGI {
@@ -1842,6 +1843,8 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
g_ngi->_tremble.reset(new Tremble);
if (!g_ngi->_tremble->init("data/tremble.xml", project._objectIds))
return Common::Error(Common::kNoGameDataFoundError, "Could not read the tremble objects");
+ g_ngi->_hintManager.reset(new HintManager);
+ g_ngi->_hintManager->init("data/hints.xml");
warning("STUB: the task state is not saved yet (TaskManager::syncGame is not hooked into the savegames)");
}
width = parser.width();
Commit: 0df9c0ac98c39c309e88aa9bfa337485a81038e9
https://github.com/scummvm/scummvm/commit/0df9c0ac98c39c309e88aa9bfa337485a81038e9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Help (CHelp, CHelpItem, CHelpController)
Changed paths:
A engines/ngi/fullpipe/help.cpp
A engines/ngi/fullpipe/help.h
engines/ngi/fullpipe/constants.h
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/sc06controller.cpp
engines/ngi/fullpipe/sc09controller.cpp
engines/ngi/fullpipe/scene01.cpp
engines/ngi/fullpipe/scenecontrollers.cpp
engines/ngi/interaction.cpp
engines/ngi/interaction.h
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index d9867ca39dd..ff6e10218c8 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -1881,6 +1881,13 @@ namespace NGI {
#define QU_OBJHELPER_STARTBEARDED_UPDOWN 23144
#define QU_OBJHELPER_STARTBEARDED_UPDOWN_MIRROR 23145
+// Android: names of obj.h that the ported controllers use
+#define PIC_HELP_6_02 23221
+#define PIC_HELP_7_02 23224
+#define PIC_HELP_8_02 23227
+#define PIC_HELP_9_02 23232
+#define PIC_HELP_9_03 23233
+
// Android: names of obj.h that the ported controllers use
#define TrubaUp1 10004
#define TrubaUp10 10005
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 2ebf96902c2..d0ae9200048 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -38,6 +38,7 @@
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/fpcontroller.h"
#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/help.h"
#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/objhelper.h"
#include "ngi/fullpipe/lift.h"
@@ -221,6 +222,9 @@ void FPController::onShow() {
if (PictureObject *button = _scene->findPictureObjectById(PIC_SC8_ARCADENOW, 0))
button->_flags &= ~4;
+ // CHelp::OnShowScene
+ g_ngi->_help->onShowScene(_scene->_sceneId);
+
// CExitManager::OnShow: the exits of a scene that does not lie over another one
if (!_scene->_putPrev)
g_ngi->_exitManager->onShow(_scene->_sceneId);
diff --git a/engines/ngi/fullpipe/help.cpp b/engines/ngi/fullpipe/help.cpp
new file mode 100644
index 00000000000..143cc53c0e6
--- /dev/null
+++ b/engines/ngi/fullpipe/help.cpp
@@ -0,0 +1,339 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/serializer.h"
+
+#include "ngi/ngi.h"
+#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/interaction.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/xmlnode.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
+#include "ngi/fullpipe/fpcontroller.h"
+#include "ngi/fullpipe/help.h"
+
+namespace NGI {
+
+namespace {
+
+// CIDList::FindId: 0 for an unknown name
+int findId(const char *name) {
+ uint32 id = 0;
+ if (name[0])
+ g_ngi->_gameProject->_objectIds.findId(name, id);
+ return id;
+}
+
+// CScene::GetFirstPictureObject (11F79C): first of the picture map, ordered by id | copy << 16
+PictureObject *firstPictureObject(Scene *scene) {
+ PictureObject *first = nullptr;
+ uint32 firstKey = 0;
+ for (PictureObject *picture : scene->_pictureObjects) {
+ const uint32 key = (uint16)picture->_id | ((uint32)(uint16)picture->_copyId << 16);
+ if (!first || key < firstKey) {
+ first = picture;
+ firstKey = key;
+ }
+ }
+ return first;
+}
+
+} // End of anonymous namespace
+
+// CHelpItem::CHelpItem (1516EC)
+HelpItem::HelpItem(uint id) {
+ Scene *scene = g_ngi->findScene(SC_HELP);
+ _object = scene->findVisibleObject(id, 0);
+ _enabled = true;
+ _chapter = 0;
+}
+
+// CHelpItem::~CHelpItem (15173C): the logic states and the lists are freed with the arrays
+HelpItem::~HelpItem() {
+}
+
+// CHelpItem::AddInteraction (1521EC): scenes load on first use here, so an interaction that is not
+// found is looked up again when the item is tried
+void HelpItem::addInteraction(const Common::String &name) {
+ HelpInteraction interaction;
+ interaction._name = name;
+ interaction._interaction = getGameLoaderInteractionController()->findInteractionByName(name);
+ if (!interaction._interaction)
+ warnOnce("CHelpItem::AddInteraction: an interaction of a scene that is not loaded yet is looked up when the help is shown");
+ _interactions.push_back(interaction);
+}
+
+// CHelpItem::AddLogicState (15204C)
+void HelpItem::addLogicState(const Common::String &title, const Common::String &state) {
+ LogicState logicState;
+ logicState._name = title;
+ logicState._value = g_ngi->getStateValue(title, state.c_str());
+ _logicStates.push_back(logicState);
+}
+
+// CHelpItem::SetXmlData (151920)
+void HelpItem::setXmlData(const XmlNode &node) {
+ _enabled = node.attrBool("enable", false);
+}
+
+// CHelpItem::GetXmlData (151808)
+void HelpItem::syncGame(Common::Serializer &s) {
+ s.syncAsByte(_enabled);
+}
+
+// CHelpItem::Hide (151A44): the visible flag of the picture (Android bit 1, flag 4 here) is cleared
+void HelpItem::hide() {
+ _object->_flags &= ~4;
+}
+
+// CHelpItem::TryShow (151C50): an enabled item shows when an interaction can run now
+// (CInteract::CanBeRunnedNow(1)) or a logic state is the state of its object
+bool HelpItem::tryShow() {
+ if (!_enabled)
+ return false;
+
+ bool canRun = false;
+ for (uint i = 0; i < _interactions.size(); i++) {
+ if (!_interactions[i]._interaction)
+ _interactions[i]._interaction = getGameLoaderInteractionController()->findInteractionByName(_interactions[i]._name);
+ if (_interactions[i]._interaction && _interactions[i]._interaction->canBeRunNow(true)) {
+ canRun = true;
+ break;
+ }
+ }
+ for (uint i = 0; i < _logicStates.size(); i++) {
+ if (_logicStates[i]._value == g_ngi->getStateId(_logicStates[i]._name)) {
+ _object->_flags |= 4;
+ return true;
+ }
+ }
+ if (canRun) {
+ _object->_flags |= 4;
+ return true;
+ }
+ return false;
+}
+
+// CHelpController::CHelpController (151A50)
+HelpController::HelpController(int sceneId) : ISceneController(sceneId) {
+}
+
+// CHelpController::OnSceneInit (1516C0): the hero (FindAni(SC_COMMON, ANI_MAN)) and the size of
+// the first picture of the scene
+void HelpController::onSceneInit() {
+ _hero = g_ngi->_aniMan;
+ const Common::Point size = firstPictureObject(_scene)->getSize();
+ _width = size.x;
+ _height = size.y;
+}
+
+// CHelpController::CalculationPostHelp (151CF4): help centered over the hero, kept 5 px inside
+// the game screen (CRender +36, +40); the result is the negative scroll of the help
+void HelpController::calculationPostHelp(float &x, float &y, float centerX, float centerY, float sizeX, float sizeY, float scrollX, float scrollY) const {
+ const int screenHeight = g_ngi->_backgroundSurface.h; // CRender +40
+ const int screenWidth = g_ngi->gameWidth(); // CRender +36
+
+ x = centerX - scrollX;
+ const float halfHeight = _height * 0.5f;
+ y = (centerY - scrollY) - (sizeY * 0.5f) - halfHeight;
+ const float resultY = y;
+ const float halfWidth = _width * 0.5f;
+ if (x >= halfWidth + 5.0f) {
+ const float limit = ((float)screenWidth - halfWidth) - 5.0f;
+ if (x > limit)
+ x = limit;
+ } else {
+ x = halfWidth + 5.0f;
+ }
+ float limitY = halfHeight + 5.0f;
+ if (resultY < limitY) {
+ y = limitY;
+ } else {
+ limitY = ((float)screenHeight - halfHeight) - 5.0f;
+ if (resultY > limitY)
+ y = limitY;
+ }
+ x = -x;
+ y = -y;
+}
+
+// CHelpController::OnShow (151DEC)
+void HelpController::onShow() {
+ if (!_sceneInitDone) {
+ _sceneInitDone = true;
+ onSceneInit();
+ }
+ const Common::Point center = _hero->getCenter();
+ const Common::Point size = _hero->getSize();
+ Scene *below = g_ngi->getSceneInStack(0);
+ float x;
+ float y;
+ calculationPostHelp(x, y, center.x, center.y, size.x, size.y, below->_x, below->_y);
+ _scene->_x = (int)x;
+ _scene->_y = (int)y;
+}
+
+// CHelpController::OnUpdate (151B78): the scene below goes on
+void HelpController::onUpdate(uint32 elapsed) {
+ g_ngi->getSceneInStack(0)->update(elapsed);
+}
+
+// CHelpController::OnMessage (151BF8): the scene below gets the messages
+void HelpController::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ g_ngi->getSceneInStack(0)->message(message, param, queue);
+}
+
+// CHelpController::OnMouseLKeyUp (151BBC)
+bool HelpController::onMouseLKeyUp(uint32 id, float x, float y) {
+ g_ngi->_help->hide();
+ return true;
+}
+
+// CHelp::CHelp (151A7C): the controller of the scene SC_HELP is looked up, the chapter is 0
+Help::Help() {
+ if (Scene *scene = g_ngi->findScene(SC_HELP))
+ _controller = scene->_controller.get();
+}
+
+// CHelp::~CHelp (151788)
+Help::~Help() {
+ for (uint i = 0; i < _items.size(); i++)
+ delete _items[i];
+}
+
+// CHelp::Init (15226C): every HELP of the file is an item with its interactions and logic states
+void Help::init(const char *path) {
+ Common::ScopedPtr<XmlNode> document(loadXmlDocument(path));
+ if (!document) {
+ warning("Could not read %s", path);
+ return;
+ }
+ const XmlNode &root = document->first();
+ for (uint i = 0; i < root.childCount(); i++) {
+ if (root[i].name() != "HELP")
+ continue;
+ HelpItem *item = new HelpItem(findId(root[i].attrStr("id", "")));
+ _items.push_back(item);
+ for (uint j = 0; j < root[i].childCount(); j++) {
+ const XmlNode &child = root[i][j];
+ if (child.name() == "INTERACTION")
+ item->addInteraction(child.attrStr("id", ""));
+ else if (child.name() == "LOGICSTATE")
+ item->addLogicState(child.attrStr("title", ""), child.attrStr("state", ""));
+ }
+ item->_chapter = root[i].attrInt("enableChapter", 0);
+ }
+ debugC(1, kDebugXML, "Loaded %u help items from %s", _items.size(), path);
+}
+
+// CHelp::CleanXml (151A1E)
+void Help::cleanXml() {
+ _chapter = 0;
+ for (uint i = 0; i < _items.size(); i++)
+ _items[i]->cleanXml();
+}
+
+// CHelp::SetXmlData (151938): child i is item i (the index is checked here, not in the original)
+void Help::setXmlData(const XmlNode &node) {
+ _chapter = node.attrInt("chapter", 0);
+ for (uint i = 0; i < node.childCount(); i++) {
+ if (node[i].name() == "HELP" && i < _items.size())
+ _items[i]->setXmlData(node[i]);
+ }
+}
+
+// CHelp::GetXmlData (15187C)
+void Help::syncGame(Common::Serializer &s) {
+ s.syncAsSint32LE(_chapter);
+ for (uint i = 0; i < _items.size(); i++)
+ _items[i]->syncGame(s);
+}
+
+// CHelp::SetChapter (151AE8)
+void Help::setChapter(int chapter) {
+ if (_chapter < chapter)
+ _chapter = chapter;
+}
+
+// CHelp::DisableHelpWithId (151AF4)
+void Help::disableHelpWithId(uint id) {
+ for (uint i = 0; i < _items.size(); i++) {
+ if ((uint)_items[i]->_object->_id == id)
+ _items[i]->_enabled = false;
+ }
+}
+
+// CHelp::OnShowScene (151B1C): the scenes of the arcades of the chapters 6 to 9 have their own help
+void Help::onShowScene(int sceneId) {
+ switch (sceneId) {
+ case SC_27:
+ disableHelpWithId(PIC_HELP_6_02);
+ break;
+ case SC_30:
+ disableHelpWithId(PIC_HELP_7_02);
+ break;
+ case SC_34:
+ disableHelpWithId(PIC_HELP_8_02);
+ break;
+ case SC_37:
+ disableHelpWithId(PIC_HELP_9_02);
+ break;
+ case SC_FINAL1:
+ disableHelpWithId(PIC_HELP_9_03);
+ break;
+ default:
+ break;
+ }
+}
+
+// CHelp::Hide (151B90)
+void Help::hide() {
+ for (uint i = 0; i < _items.size(); i++)
+ _items[i]->hide();
+ g_ngi->popScene();
+}
+
+// CHelp::Show (151E3C): if the first scene's controller allows help (CanShowHelp) the first item
+// that shows pushes SC_HELP, widescreen margins follow the scene below, sounds resume
+void Help::show() {
+ if (g_ngi->_sceneStack.empty())
+ return;
+ Scene *scene = g_ngi->getSceneInStack(0);
+ if (!sceneController(*scene).canShowHelp())
+ return;
+ for (uint i = 0; i < _items.size(); i++) {
+ if (_items[i]->_chapter != _chapter)
+ continue;
+ if (_items[i]->tryShow()) {
+ g_ngi->pushScene(SC_HELP);
+ // CRender::SetSrcRect(width, height, "", drawOffset of the scene below): the black bars flag
+ // comes from the scene on top (Scene::hasWidescreenBars)
+ warnOnce("CHelp::Show: CRender::SetSrcRect with the size of the scene below is not ported (the widescreen bars follow the help scene)");
+ g_ngi->_soundManager.resumeAll();
+ return;
+ }
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/help.h b/engines/ngi/fullpipe/help.h
new file mode 100644
index 00000000000..8a867ad4e08
--- /dev/null
+++ b/engines/ngi/fullpipe/help.h
@@ -0,0 +1,148 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_HELP_H
+#define NGI_FULLPIPE_HELP_H
+
+#include "common/array.h"
+#include "common/str.h"
+
+#include "ngi/scenecontroller.h"
+
+namespace Common {
+class Serializer;
+}
+
+namespace NGI {
+
+class AniObject;
+class GameObject;
+class Interact;
+class XmlNode;
+
+/** Android: CLogicState (8 bytes), a state of an object that makes a help item show: the name of the object and the value of the state */
+struct LogicState {
+ Common::String _name; // +0: "title"
+ int _value = 0; // +4: CStateManager::GetStateValue(title, state)
+};
+
+/** CHelpItem (40 bytes), one HELP of help.xml: a bubble picture of SC_HELP */
+class HelpItem {
+public:
+ /** CHelpItem::CHelpItem: the picture of the id in the scene SC_HELP */
+ explicit HelpItem(uint id);
+ /** CHelpItem::~CHelpItem */
+ ~HelpItem();
+
+ /** CHelpItem::AddInteraction: the interaction by name (FindInteraction(name, 0, 0)) */
+ void addInteraction(const Common::String &name);
+ /** CHelpItem::AddLogicState: the object with the title and the value of its state */
+ void addLogicState(const Common::String &title, const Common::String &state);
+ /** CHelpItem::SetXmlData: "enable" */
+ void setXmlData(const XmlNode &node);
+ /** CHelpItem::GetXmlData for the savegame (see Help::syncGame): "enable" */
+ void syncGame(Common::Serializer &s);
+ /** CHelpItem::CleanXml: enabled again */
+ void cleanXml() { _enabled = true; }
+ /** CHelpItem::Hide: the picture is hidden */
+ void hide();
+ /** CHelpItem::TryShow: shows the picture when enabled and an interaction or state holds */
+ bool tryShow();
+
+ bool _enabled = true; // +4
+ int _chapter = 0; // +8: "enableChapter"
+ GameObject *_object = nullptr; // +12: the picture
+
+private:
+ struct HelpInteraction {
+ Common::String _name;
+ Interact *_interaction = nullptr;
+ };
+
+ Common::Array<HelpInteraction> _interactions; // +16
+ Common::Array<LogicState> _logicStates; // +28
+};
+
+/** CHelpController, the controller of SC_HELP (pushed over the game scene) */
+class HelpController : public ISceneController {
+public:
+ explicit HelpController(int sceneId);
+ ~HelpController() override {}
+
+ void onSceneInit() override;
+ void onShow() override;
+ void onUpdate(uint32 elapsed) override;
+ void onRender(Common::Point scroll) override {}
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ bool isInventoryRendered() override { return true; }
+
+ /** CHelpController::CalculationPostHelp: the place of the help scene (hero, scroll) */
+ void calculationPostHelp(float &x, float &y, float centerX, float centerY, float sizeX, float sizeY, float scrollX, float scrollY) const;
+
+ /** the first OnShow does the OnSceneInit of CScene::OnInit (scenes load on first use here) */
+ bool _sceneInitDone = false;
+
+private:
+ float _width = 0; // +12: the size of the first picture of the scene
+ float _height = 0; // +16
+ AniObject *_hero = nullptr; // +20: ANI_MAN of SC_COMMON
+};
+
+/** CHelp (CSingleton, here NGIEngine::_help): the help items of help.xml and the current chapter */
+class Help {
+public:
+ /** CHelp::CHelp */
+ Help();
+ /** CHelp::~CHelp */
+ ~Help();
+
+ /** CHelp::Init: reads the file */
+ void init(const char *path);
+ /** CHelp::CleanXml: chapter 0, every item enabled */
+ void cleanXml();
+ /** CHelp::SetXmlData: "chapter" and the "enable" of every HELP */
+ void setXmlData(const XmlNode &node);
+ /** CHelp::GetXmlData: the original writes help.sav as XML, here the savegame holds it */
+ void syncGame(Common::Serializer &s);
+ /** CHelp::GetSavePath: the file of the original; the engine saves in the savegames (syncGame) */
+ Common::String getSavePath() const { return "help.sav"; }
+
+ /** CHelp::SetChapter: the chapter only grows */
+ void setChapter(int chapter);
+ /** CHelp::DisableHelpWithId: the item with the picture of the id is disabled */
+ void disableHelpWithId(uint id);
+ /** CHelp::OnShowScene: the help of the arcades is disabled in the scene that shows it itself */
+ void onShowScene(int sceneId);
+ /** CHelp::Hide: the pictures hide and the scene SC_HELP is popped */
+ void hide();
+ /** CHelp::Show: the first item of the chapter that shows goes over the scene (pushes SC_HELP) */
+ void show();
+
+private:
+ ISceneController *_controller = nullptr; // +8: the controller of SC_HELP (CHelpController)
+ Common::Array<HelpItem *> _items; // +12
+ int _chapter = 0; // +24
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_HELP_H
diff --git a/engines/ngi/fullpipe/sc06controller.cpp b/engines/ngi/fullpipe/sc06controller.cpp
index 5e7e4437b79..d06664df4ff 100644
--- a/engines/ngi/fullpipe/sc06controller.cpp
+++ b/engines/ngi/fullpipe/sc06controller.cpp
@@ -37,6 +37,7 @@
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
+#include "ngi/fullpipe/help.h"
#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/objectnames.h"
@@ -771,7 +772,7 @@ void Sc06Controller::onShow() {
if (!controllerRunsSceneLogic())
return;
- warnOnce("CHelp::SetChapter (CSc06Controller::OnShow)");
+ g_ngi->_help->setChapter(2);
g_ngi->_chapterManager->setActiveChapter(2);
if (!g_ngi->_taskManager->isSceneVisited(_scene->_sceneId)) {
g_ngi->_chapterManager->showChapterDialog("CHAPTER_2", true);
diff --git a/engines/ngi/fullpipe/sc09controller.cpp b/engines/ngi/fullpipe/sc09controller.cpp
index c35140320a1..7d20cba3142 100644
--- a/engines/ngi/fullpipe/sc09controller.cpp
+++ b/engines/ngi/fullpipe/sc09controller.cpp
@@ -38,6 +38,7 @@
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/help.h"
#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/objectnames.h"
@@ -589,7 +590,7 @@ void Sc09Controller::onShow() {
if (!controllerRunsSceneLogic())
return;
- warnOnce("CHelp::SetChapter is not ported");
+ g_ngi->_help->setChapter(3);
g_ngi->_chapterManager->setActiveChapter(3);
if (!g_ngi->_taskManager->isSceneVisited(_scene->_sceneId)) {
g_ngi->_chapterManager->showChapterDialog("CHAPTER_3", true);
diff --git a/engines/ngi/fullpipe/scene01.cpp b/engines/ngi/fullpipe/scene01.cpp
index 0390efdd1ee..195b4884d63 100644
--- a/engines/ngi/fullpipe/scene01.cpp
+++ b/engines/ngi/fullpipe/scene01.cpp
@@ -25,6 +25,7 @@
#include "ngi/fullpipe/scenecontrollers.h"
#include "ngi/guimanager.h"
#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/help.h"
#include "ngi/fullpipe/inventorycontroller.h"
#include "ngi/fullpipe/tutorialmanager.h"
#include "ngi/input.h"
@@ -81,6 +82,7 @@ void scene01_initScene(Scene *sc, int entrance) {
if (g_ngi->_gameProject->_objectIds.findId("ST_LBN_2N", buttonId))
g_ngi->lift_setButton(sO_Level2, buttonId);
// CSc01Controller::OnShow (the scene is marked as visited by the common scene setup afterwards)
+ g_ngi->_help->setChapter(1);
g_ngi->_chapterManager->setActiveChapter(1);
if (!g_ngi->_taskManager->isSceneVisited(sc->_sceneId)) {
g_ngi->_chapterManager->showChapterDialog("CHAPTER_1", true);
diff --git a/engines/ngi/fullpipe/scenecontrollers.cpp b/engines/ngi/fullpipe/scenecontrollers.cpp
index d4d1e3a44d4..57e23453475 100644
--- a/engines/ngi/fullpipe/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/scenecontrollers.cpp
@@ -36,6 +36,7 @@
#include "ngi/fullpipe/sc03controller.h"
#include "ngi/fullpipe/sc04controller.h"
#include "ngi/fullpipe/chaptercontroller.h"
+#include "ngi/fullpipe/help.h"
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/inventorycontroller.h"
#include "ngi/fullpipe/liftcontroller.h"
@@ -408,6 +409,9 @@ void createSceneController(int sceneId) {
case SC_MAP:
new MapWindowController(sceneId);
break;
+ case SC_HELP:
+ new HelpController(sceneId);
+ break;
case 0: // the inventory scene (CGame +116)
new InventoryController(sceneId);
break;
diff --git a/engines/ngi/interaction.cpp b/engines/ngi/interaction.cpp
index e8945702b7d..b876eb84fd2 100644
--- a/engines/ngi/interaction.cpp
+++ b/engines/ngi/interaction.cpp
@@ -23,6 +23,7 @@
#include "ngi/input.h"
#include "ngi/interaction.h"
+#include "ngi/inventory.h"
#include "ngi/gameloader.h"
#include "ngi/statics.h"
#include "ngi/motion.h"
@@ -612,7 +613,7 @@ GameObject *Interact::getObject() const {
return scene->findAniObjectById(_objectId, 0);
}
-bool Interact::canBeRunNow() const {
+bool Interact::canBeRunNow(bool checkItem) const {
if (_activity < 0.9999f)
return false;
@@ -620,6 +621,13 @@ bool Interact::canBeRunNow() const {
if (!object || !(object->_flags & 4))
return false;
+ // ANY_OBJECT is 0xFFFF in the original, -2 here
+ if (checkItem && _cursorObjectId != 0 && _cursorObjectId != -2) {
+ const InventoryItem *item = g_ngi->_inventory ? g_ngi->_inventory->getItem(_cursorObjectId) : nullptr;
+ if (!item || item->_counter == 0)
+ return false;
+ }
+
if (_objectStaticId && (_flags & 1) && object->_objtype == kObjTypeStaticANIObject) {
const AniObject *ani = static_cast<AniObject *>(object);
if (!ani->_statics || ani->_statics->_staticsId != _objectStaticId)
@@ -649,6 +657,14 @@ void InteractionController::getAllRunnableInteractions(Scene *scene, Common::Arr
}
}
+Interact *InteractionController::findInteractionByName(const Common::String &name) {
+ for (Interact *interaction : _interactions) {
+ if (interaction->_actionName == name)
+ return interaction;
+ }
+ return nullptr;
+}
+
bool InteractionController::setActive(const Common::String &name, int sceneId, int objectId, float act, float add) {
for (Interact *interaction : _interactions) {
if ((sceneId && interaction->_sceneId != sceneId) || (objectId && interaction->_objectId != objectId))
diff --git a/engines/ngi/interaction.h b/engines/ngi/interaction.h
index 411508ef838..ad95d0f1cc0 100644
--- a/engines/ngi/interaction.h
+++ b/engines/ngi/interaction.h
@@ -62,8 +62,11 @@ class Interact : public CObject {
bool isOverlapping(AniObject *subj, GameObject *obj);
/** CInteract::GetObject: the object of the interaction, looked up in its scene */
GameObject *getObject() const;
- /** CInteract::CanBeRunnedNow(false): active, the object is visible and in the static the interaction needs */
- bool canBeRunNow() const;
+ /**
+ * CInteract::CanBeRunnedNow: active, the object is visible and in the static the interaction needs; with checkItem (CHelpItem::TryShow passes 1) the
+ * item of the cursor that the interaction needs must be in the inventory
+ */
+ bool canBeRunNow(bool checkItem = false) const;
};
class InteractionController : public CObject {
@@ -92,6 +95,8 @@ public:
bool handleInteraction(AniObject *subj, GameObject *obj, int invId);
Interact *findInteraction(int obId, int obId2, int obId3);
+ /** CInteractionController::FindInteraction(name, 0, 0): the first interaction with that name */
+ Interact *findInteractionByName(const Common::String &name);
// CInteractionController::SetActive: the first interaction with this name (in the scene and for the object,
// when given) gets its activity set to act, or increased by add when add is not 0
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 1d29e221e56..54a93088795 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -88,6 +88,7 @@ MODULE_OBJS = \
fullpipe/floaters.o \
fullpipe/fpcontroller.o \
fullpipe/fpguicontroller.o \
+ fullpipe/help.o \
fullpipe/hintmanager.o \
fullpipe/inventorycontroller.o \
fullpipe/lift.o \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 1f3854b6b51..e33f6220a09 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -45,6 +45,7 @@
#include "ngi/fullpipe/objhelper.h"
#include "ngi/fullpipe/tutorialmanager.h"
#include "ngi/fullpipe/hintmanager.h"
+#include "ngi/fullpipe/help.h"
#include "ngi/debugger/testmode.h"
#include "ngi/debugger/debugtools.h"
#include "ngi/fullpipe/tremble.h"
@@ -708,6 +709,8 @@ ArcadeInterface &NGIEngine::arcadeInterface() {
void NGIEngine::freeGameLoader() {
// the effects of the tremble items belong to the scenes that are destroyed with the loader
_tremble.reset();
+ // the help items point into the scene SC_HELP and the interactions of the loader
+ _help.reset();
_arcadeInterface.reset();
setCursor(0);
_floaters->deleteAllFlies();
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index c430406d620..1f91c6510a6 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -94,6 +94,7 @@ class FlyPack;
class TaskManager;
class TutorialManager;
class HintManager;
+class Help;
class ObjHelperManager;
class ObjHelperHint;
class ExitManager;
@@ -310,6 +311,7 @@ public:
Common::ScopedPtr<TutorialManager> _tutorialManager;
/** CSingleton<CHintManager> (hints.xml), <CHelp> (help.xml), <CNoActionLogger> */
Common::ScopedPtr<HintManager> _hintManager;
+ Common::ScopedPtr<Help> _help;
/** CSingleton<CObjHelperManager> (objhelpers.xml), CSingleton<CObjHelperHint> (objhints.xml) */
Common::ScopedPtr<ObjHelperManager> _objHelperManager;
Common::ScopedPtr<ObjHelperHint> _objHelperHint;
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 99a26451877..fbee940865a 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -55,6 +55,7 @@
#include "ngi/fullpipe/objhelper.h"
#include "ngi/fullpipe/tutorialmanager.h"
#include "ngi/fullpipe/hintmanager.h"
+#include "ngi/fullpipe/help.h"
namespace NGI {
@@ -1845,6 +1846,9 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
return Common::Error(Common::kNoGameDataFoundError, "Could not read the tremble objects");
g_ngi->_hintManager.reset(new HintManager);
g_ngi->_hintManager->init("data/hints.xml");
+ createSceneController(SC_HELP); // CHelpController
+ g_ngi->_help.reset(new Help);
+ g_ngi->_help->init("data/help.xml");
warning("STUB: the task state is not saved yet (TaskManager::syncGame is not hooked into the savegames)");
}
width = parser.width();
Commit: 28c9ed81099e7dc2d862d1e192e10f8495bb06d7
https://github.com/scummvm/scummvm/commit/28c9ed81099e7dc2d862d1e192e10f8495bb06d7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: NoActionLogger (CNoActionLogger)
Changed paths:
A engines/ngi/fullpipe/noactionlogger.cpp
A engines/ngi/fullpipe/noactionlogger.h
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index d0ae9200048..1ceace93cbf 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -40,6 +40,7 @@
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/help.h"
#include "ngi/fullpipe/hintmanager.h"
+#include "ngi/fullpipe/noactionlogger.h"
#include "ngi/fullpipe/objhelper.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/map.h"
@@ -529,6 +530,9 @@ void FPController::testScroll() {
void FPController::onUpdate(uint32 elapsed) {
// the time restarts while the hero cannot be swiped (CanSwipeMan(0, 0) is false)
g_ngi->_hintManager->onUpdate(elapsed);
+ g_ngi->_noActionLogger->onUpdate(elapsed);
+ if (!canSwipeMan(0.0f, 0.0f))
+ g_ngi->_noActionLogger->_time = 0;
checkTutorial();
checkQueues();
_elapsed += elapsed;
diff --git a/engines/ngi/fullpipe/noactionlogger.cpp b/engines/ngi/fullpipe/noactionlogger.cpp
new file mode 100644
index 00000000000..0c6aed3661f
--- /dev/null
+++ b/engines/ngi/fullpipe/noactionlogger.cpp
@@ -0,0 +1,65 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/ngi.h"
+#include "ngi/fullpipe/controllerhelpers.h"
+#include "ngi/fullpipe/notebook.h"
+#include "ngi/fullpipe/noactionlogger.h"
+#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/tutorialmanager.h"
+
+namespace NGI {
+
+// CNoActionLogger::CNoActionLogger (158410)
+NoActionLogger::NoActionLogger() {
+}
+
+// CNoActionLogger::~CNoActionLogger (1583D4)
+NoActionLogger::~NoActionLogger() {
+}
+
+// CNoActionLogger::ShowHintOffer (158438)
+void NoActionLogger::showHintOffer() {
+ g_ngi->_tutorialManager->activateTutorialAnyScene("ADDITIONAL_TUTORIAL_WANT_HINT");
+ warnOnce("CNoActionLogger::ShowHintOffer: the analytics event hint_offer (CFlurryEventManager::Event) is not ported");
+}
+
+// CNoActionLogger::OnUpdate (1585B0): the "no_action" analytics event is not ported
+void NoActionLogger::onUpdate(uint32 elapsed) {
+ _time += elapsed;
+ if (_time > 59999) {
+ if (g_ngi->_taskManager->getBonuses() > 0) {
+ if (g_ngi->_tutorialManager->isTutorialCompleted()) {
+ // CSettings::GetIsFull (CGame +112) is not ported: the game counts as the full version
+ warnOnce("CNoActionLogger::OnUpdate: CSettings::GetIsFull is not ported (the game is the full version)");
+ const bool isFull = true;
+ if (!isFull) {
+ if (g_ngi->_notebook->checkAutoFoil())
+ showHintOffer();
+ }
+ }
+ }
+ _time = 0;
+ warnOnce("CNoActionLogger::OnUpdate: the analytics event no_action (CFlurryEventManager) is not ported");
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/noactionlogger.h b/engines/ngi/fullpipe/noactionlogger.h
new file mode 100644
index 00000000000..a7540ea4893
--- /dev/null
+++ b/engines/ngi/fullpipe/noactionlogger.h
@@ -0,0 +1,47 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_NOACTIONLOGGER_H
+#define NGI_FULLPIPE_NOACTIONLOGGER_H
+
+#include "common/scummsys.h"
+
+namespace NGI {
+
+/** CNoActionLogger: after a minute without player action it offers a hint */
+class NoActionLogger {
+public:
+ /** CNoActionLogger::CNoActionLogger */
+ NoActionLogger();
+ /** CNoActionLogger::~CNoActionLogger */
+ ~NoActionLogger();
+
+ /** CNoActionLogger::OnUpdate: offers the hint after 60 seconds without action */
+ void onUpdate(uint32 elapsed);
+ /** CNoActionLogger::ShowHintOffer */
+ void showHintOffer();
+
+ uint32 _time = 0; // +8: the milliseconds without action
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_NOACTIONLOGGER_H
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 54a93088795..a5fd159b3f1 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -96,6 +96,7 @@ MODULE_OBJS = \
fullpipe/mainmenucontroller.o \
fullpipe/map.o \
fullpipe/mapwindowcontroller.o \
+ fullpipe/noactionlogger.o \
fullpipe/notebook.o \
fullpipe/objhelper.o \
fullpipe/sc01controller.o \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index e33f6220a09..84833b05fe1 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -46,6 +46,7 @@
#include "ngi/fullpipe/tutorialmanager.h"
#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/help.h"
+#include "ngi/fullpipe/noactionlogger.h"
#include "ngi/debugger/testmode.h"
#include "ngi/debugger/debugtools.h"
#include "ngi/fullpipe/tremble.h"
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 1f91c6510a6..397ae398712 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -95,6 +95,7 @@ class TaskManager;
class TutorialManager;
class HintManager;
class Help;
+class NoActionLogger;
class ObjHelperManager;
class ObjHelperHint;
class ExitManager;
@@ -312,6 +313,7 @@ public:
/** CSingleton<CHintManager> (hints.xml), <CHelp> (help.xml), <CNoActionLogger> */
Common::ScopedPtr<HintManager> _hintManager;
Common::ScopedPtr<Help> _help;
+ Common::ScopedPtr<NoActionLogger> _noActionLogger;
/** CSingleton<CObjHelperManager> (objhelpers.xml), CSingleton<CObjHelperHint> (objhints.xml) */
Common::ScopedPtr<ObjHelperManager> _objHelperManager;
Common::ScopedPtr<ObjHelperHint> _objHelperHint;
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index fbee940865a..ad501bc7695 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -56,6 +56,7 @@
#include "ngi/fullpipe/tutorialmanager.h"
#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/help.h"
+#include "ngi/fullpipe/noactionlogger.h"
namespace NGI {
@@ -1849,6 +1850,7 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
createSceneController(SC_HELP); // CHelpController
g_ngi->_help.reset(new Help);
g_ngi->_help->init("data/help.xml");
+ g_ngi->_noActionLogger.reset(new NoActionLogger);
warning("STUB: the task state is not saved yet (TaskManager::syncGame is not hooked into the savegames)");
}
width = parser.width();
Commit: 1ebf41ad5fbbaf6c269693762c3e4619f33e9107
https://github.com/scummvm/scummvm/commit/1ebf41ad5fbbaf6c269693762c3e4619f33e9107
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: The lift tutorials and the EXTRA_TUTORIAL_SEE_EXTRA_HELP zone
Changed paths:
engines/ngi/fullpipe/liftcontroller.cpp
engines/ngi/fullpipe/tutorialcontroller.cpp
diff --git a/engines/ngi/fullpipe/liftcontroller.cpp b/engines/ngi/fullpipe/liftcontroller.cpp
index 1bf18b3876c..70933a9d706 100644
--- a/engines/ngi/fullpipe/liftcontroller.cpp
+++ b/engines/ngi/fullpipe/liftcontroller.cpp
@@ -27,6 +27,7 @@
#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/liftcontroller.h"
+#include "ngi/fullpipe/tutorialmanager.h"
#include "ngi/scene.h"
#include "ngi/statics.h"
@@ -41,14 +42,6 @@ enum {
kSceneStatics = 23070
};
-void warnOnce(const char *what) {
- static Common::HashMap<Common::String, bool> reported;
- if (!reported.contains(what)) {
- reported[what] = true;
- warning("STUB/untested: %s", what);
- }
-}
-
} // End of anonymous namespace
// CLiftController::CLiftController
@@ -104,10 +97,20 @@ void LiftController::sortButtons(const Common::Array<AniObject *> &buttons) {
_buttons.push_back(button);
}
- // the tutorials of the lift (CTutorialManager::ActivateTutorial ADDITIONAL_TUTORIAL_LIFT in the scenes 3 and 38) are not ported
+ // lift tutorials: scene 3 with one pressable button, scene 38 with two or fewer; the scene's
+ // tutorial (ADDITIONAL_TUTORIAL_LIFT, _1) is activated and EXTRA_TUTORIAL_SEE_LIFT finished
const int sceneId = g_ngi->getSceneInStack(0)->_sceneId;
- if ((sceneId == SC_3 && countStaticNormal() == 1) || (sceneId == SC_38 && countStaticNormal() <= 2))
- warnOnce("CLiftController::SortButtons: the additional lift tutorials are not ported");
+ if (sceneId == SC_3) {
+ if (countStaticNormal() != 1)
+ return;
+ g_ngi->_tutorialManager->activateTutorial("ADDITIONAL_TUTORIAL_LIFT");
+ g_ngi->_tutorialManager->findTutorial("EXTRA_TUTORIAL_SEE_LIFT")->setState(4);
+ } else if (g_ngi->getSceneInStack(0)->_sceneId == SC_38) {
+ if (countStaticNormal() <= 2) {
+ g_ngi->_tutorialManager->activateTutorial("ADDITIONAL_TUTORIAL_LIFT_1");
+ g_ngi->_tutorialManager->findTutorial("EXTRA_TUTORIAL_SEE_LIFT")->setState(4);
+ }
+ }
}
// CLiftController::OnHide: RemoveCopies, clears the map, hides the scene 3 hint
diff --git a/engines/ngi/fullpipe/tutorialcontroller.cpp b/engines/ngi/fullpipe/tutorialcontroller.cpp
index 3af9118740d..56b07a18f45 100644
--- a/engines/ngi/fullpipe/tutorialcontroller.cpp
+++ b/engines/ngi/fullpipe/tutorialcontroller.cpp
@@ -768,6 +768,15 @@ bool TutorialController::passMouseActionsZone(float x, float y, int action) {
finish();
return true;
}
+ if (id == "EXTRA_TUTORIAL_SEE_EXTRA_HELP") {
+ // GIVE_HINT of the notebook GUI (scene over the game): finger down finishes the tutorial
+ GuiElement *button = g_ngi->getSceneInStack(1)->_guiManager->getElement("GIVE_HINT");
+ if (!button->hit(Common::Point(x, y)))
+ return false;
+ if (action == 2)
+ finish();
+ return true;
+ }
// arcade tutorials: a touch on the arcade object (ladder, ball ...) finishes; returns MouseActions
if (id == "ARCADE_TUTORIAL_04")
return mouseActions(x, y, action, PIC_SC4_LADDER);
Commit: ed8f599c10aa0d38c210b9a16fac5b52ef3a7d0c
https://github.com/scummvm/scummvm/commit/ed8f599c10aa0d38c210b9a16fac5b52ef3a7d0c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:04+01:00
Commit Message:
NGI: Scene 4 controller sets the map object of the third scene
Changed paths:
engines/ngi/fullpipe/sc04controller.cpp
diff --git a/engines/ngi/fullpipe/sc04controller.cpp b/engines/ngi/fullpipe/sc04controller.cpp
index 963ea94659f..d7c48b29cea 100644
--- a/engines/ngi/fullpipe/sc04controller.cpp
+++ b/engines/ngi/fullpipe/sc04controller.cpp
@@ -42,6 +42,7 @@
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/map.h"
#include "ngi/fullpipe/sc04controller.h"
#include "ngi/fullpipe/scenes.h"
#include "ngi/fullpipe/taskmanager.h"
@@ -531,7 +532,7 @@ void Sc04Controller::doManFall() {
_manFalls = false;
heroOnLadder() = false;
_scene->_behaviorController->enableAllQueuesForAni(hero(), 0);
- warnOnce("CMap::SetObjState(PIC_MAP_P03, 1) (the map of the game is not ported)");
+ g_ngi->_map->setObjState(PIC_MAP_P03, 1);
setSaving(true);
}
Commit: 349168857c3eb58368298c90c42d84e93e51c199
https://github.com/scummvm/scummvm/commit/349168857c3eb58368298c90c42d84e93e51c199
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: Draw 8 bit textures with their palette, scaled ones without rotation, and skip those that have none
Changed paths:
engines/ngi/gfx.cpp
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index 19c669ef2b1..d9817015748 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -666,8 +666,20 @@ void Texture::blitTo(Graphics::ManagedSurface &target, const Common::Point &posi
origin.x += static_cast<int>(window.left * params.scaleX);
origin.y += static_cast<int>(window.top * params.scaleY);
+ if (full.format.isCLUT8() && !full.hasPalette()) {
+ // a texture that could not be loaded is an empty 8 bit surface
+ warning("Texture::blitTo: the 8 bit texture %s has no palette and is not drawn", _memfilename.toString().c_str());
+ return;
+ }
+
Graphics::ManagedSurface part(const_cast<Graphics::ManagedSurface &>(full), window);
const bool scaled = params.scaleX != 1.0f || params.scaleY != 1.0f;
+ // a window of an 8 bit texture does not have the palette of the texture
+ const Graphics::Palette *palette = full.format.isCLUT8() && full.hasPalette() ? full.grabPalette() : nullptr;
+ if (palette && !scaled && params.rotation == 0.0f && !params.mirror) {
+ target.blitFrom(part.rawSurface(), origin, palette);
+ return;
+ }
if (!scaled && params.rotation == 0.0f) {
if (params.mirror)
target.simpleBlitFrom(part, origin, Graphics::FLIP_H, true);
@@ -676,17 +688,29 @@ void Texture::blitTo(Graphics::ManagedSurface &target, const Common::Point &posi
return;
}
- if (params.rotation == 0.0f && part.format.bytesPerPixel > 1) {
+ // a rotation of less than a degree is none (rotoscale() asserts on the angle 0)
+ const int angle = static_cast<int>(Math::rad2deg(params.rotation));
+ if (angle == 0) {
// only the scale: the quad is the size of the window times the scale, from the top left corner
const int width = MAX(1, static_cast<int>(part.w * params.scaleX));
const int height = MAX(1, static_cast<int>(part.h * params.scaleY));
- Common::ScopedPtr<Graphics::Surface> scaledPart(part.rawSurface().scale(width, height, true));
+ Common::ScopedPtr<Graphics::Surface> scaledPart(part.rawSurface().scale(width, height, part.format.bytesPerPixel > 1));
if (!scaledPart)
return;
Graphics::ManagedSurface result(width, height, part.format);
if (part.hasTransparentColor())
result.setTransparentColor(part.getTransparentColor());
result.copyFrom(*scaledPart);
+ if (part.format.isCLUT8()) {
+ // (copyFrom drops the palette: it is set after it)
+ if (!palette) {
+ warning("Texture::blitTo: an 8 bit texture without a palette is not drawn scaled");
+ return;
+ }
+ byte colors[256 * 3];
+ full.grabPalette(colors, 0, 256);
+ result.setPalette(colors, 0, 256);
+ }
if (params.mirror)
target.simpleBlitFrom(result, origin, Graphics::FLIP_H, true);
else
Commit: d567c4e38e3d2face0d79f82e66cc5fc533f515e
https://github.com/scummvm/scummvm/commit/d567c4e38e3d2face0d79f82e66cc5fc533f515e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: A pending scene replaces the whole stack of scenes, every one of them is hidden (CGame::DoSetScene)
Changed paths:
engines/ngi/fullpipe/scenes.cpp
engines/ngi/ngi.cpp
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index c6bd2d0d32c..b6d35ed6374 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -695,8 +695,13 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
if (scene->_commonQueueScene && common->_soundList)
_currSoundList1[_currSoundListCount++] = common->_soundList.get();
- if (_currentScene && _currentScene->_guiManager)
+ if (usesXMLProject()) {
+ // CGame::DoSetScene: every scene of the stack is hidden (CScene::OnHide), bottom first
+ for (uint i = 0; i < _sceneStack.size(); i++)
+ _sceneStack[i]->onHide();
+ } else if (_currentScene && _currentScene->_guiManager) {
_currentScene->_guiManager->onHide();
+ }
_currentScene = scene;
// CGame::DoSetScene: the stack holds the scene only
_sceneStack.clear();
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 84833b05fe1..d1805eaae58 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -791,7 +791,8 @@ Common::Error NGIEngine::updateScreen(uint32 elapsed, byte &brightness, bool red
debugC(2, kDebugDrawing, "Switched scene from %d to %d", scene->_sceneId, _currentScene->_sceneId);
redraw = true;
}
- if (timedUpdates && !isDialogShown() && _gameLoader->_preloadSceneId) {
+ // CGame::DoSetScene replaces the whole scene stack, dialog scenes hold no pending scene back
+ if (timedUpdates && !(usesXMLProject() ? _modalObject != nullptr : isDialogShown()) && _gameLoader->_preloadSceneId) {
if (!_gameLoader->setScene(_gameLoader->_preloadSceneId, _gameLoader->_preloadEntranceId))
return Common::Error(Common::kNoGameDataFoundError, "Could not enter the requested scene");
_gameLoader->_preloadSceneId = _gameLoader->_preloadEntranceId = 0;
Commit: f3e9d9373aa244b27cfedb15459963a29771d63c
https://github.com/scummvm/scummvm/commit/f3e9d9373aa244b27cfedb15459963a29771d63c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: SHOW of the Android build does not look at the queue of the object
Changed paths:
engines/ngi/statics.cpp
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index b2515bc6d56..fdbc9774854 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -1442,7 +1442,8 @@ void AniObject::hide() {
void AniObject::show1(int x, int y, int movId, int mqId) {
debugC(6, kDebugAnimation, "AniObject::show1(%d, %d, %d, %d)", x, y, movId, mqId);
- if (_messageQueueId)
+ // CMessageQueue::ExecuteCmdShow (10CE00): the object is shown whatever its queue does
+ if (_messageQueueId && g_ngi->_gameVersion < 201509)
return;
if (movId == -1) {
Commit: 23274f18e5c97c36c93ebb0a71de25f9ba52528f
https://github.com/scummvm/scummvm/commit/23274f18e5c97c36c93ebb0a71de25f9ba52528f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: Log TUTORIAL ready when the bubble of a tutorial is shown
Changed paths:
engines/ngi/fullpipe/tutorialcontroller.cpp
diff --git a/engines/ngi/fullpipe/tutorialcontroller.cpp b/engines/ngi/fullpipe/tutorialcontroller.cpp
index 56b07a18f45..ab2a304498b 100644
--- a/engines/ngi/fullpipe/tutorialcontroller.cpp
+++ b/engines/ngi/fullpipe/tutorialcontroller.cpp
@@ -561,6 +561,8 @@ void TutorialController::loadLayout() {
_scene->_behaviorController->getAniQueue(ANI_SC_TUTORIAL_BEARDED, QU_SC_TUTORIAL_BEARDED_ROTATE)->_flags &= ~1;
_scene->_behaviorController->getAniQueue(ANI_SC_TUTORIAL_BEARDED, QU_SC_TUTORIAL_BEARDED_ROTATE_MIRROR)->_flags &= ~1;
_state = 2;
+ // the scripted playthroughs (scripts/ngi_play_actions.sh, `waittut`) tap a second after this line
+ debugC(1, kDebugEvents, "TUTORIAL ready: %s", tutorial->_id.c_str());
}
// CTutorialController::AddContinueBtnIfNeed (1A34C0): MAKE_TASK_BOOT shows its arrow after 5 s;
Commit: cc361c8cbc98b58a8c8879b14aa62b416ddf7885
https://github.com/scummvm/scummvm/commit/cc361c8cbc98b58a8c8879b14aa62b416ddf7885
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: Hero queue id in the info line of the test mode
Changed paths:
engines/ngi/debugger/testmode.cpp
engines/ngi/debugger/testmode.h
diff --git a/engines/ngi/debugger/testmode.cpp b/engines/ngi/debugger/testmode.cpp
index cea729f0516..4361694d0ae 100644
--- a/engines/ngi/debugger/testmode.cpp
+++ b/engines/ngi/debugger/testmode.cpp
@@ -131,8 +131,8 @@ Common::String name(int id) {
Common::String heroState(const TestInfo &info) {
if (!info.hero)
return "no hero";
- Common::String state = Common::String::format("hero %d,%d z %d flags %02x%s | %s %s", info.heroPos.x, info.heroPos.y, info.heroZ, info.heroFlags,
- info.heroMirror ? " MIRROR" : "", info.heroMoving ? "movement" : "statics", info.heroAction.c_str());
+ Common::String state = Common::String::format("hero %d,%d z %d flags %02x%s mq %d | %s %s", info.heroPos.x, info.heroPos.y, info.heroZ, info.heroFlags,
+ info.heroMirror ? " MIRROR" : "", info.heroQueue, info.heroMoving ? "movement" : "statics", info.heroAction.c_str());
if (info.heroMoving)
state += Common::String::format(" phase %d/%d mov xy %d,%d", info.phase, info.phases, info.movementPos.x, info.movementPos.y);
state += Common::String::format(" size %dx%d anchor %d,%d | quad %d,%d - %d,%d", info.size.x, info.size.y, info.anchor.x, info.anchor.y,
@@ -185,6 +185,7 @@ void testmode_getInfo(TestInfo &info) {
info.heroPos = Common::Point(hero->_x, hero->_y);
info.heroZ = hero->_z;
info.heroFlags = hero->_flags;
+ info.heroQueue = hero->_messageQueueId;
info.heroMirror = (hero->_flags & 8) != 0;
if (hero->_movement) {
const Movement *movement = hero->_movement;
diff --git a/engines/ngi/debugger/testmode.h b/engines/ngi/debugger/testmode.h
index f860374b2f2..8d650ecb3c1 100644
--- a/engines/ngi/debugger/testmode.h
+++ b/engines/ngi/debugger/testmode.h
@@ -47,6 +47,7 @@ struct TestInfo {
Common::Point heroPos;
int heroZ = 0;
uint heroFlags = 0;
+ int heroQueue = 0;
bool heroMirror = false;
bool heroMoving = false; // a movement, else statics
Common::String heroAction; // the name of the statics or the movement
Commit: b70c4a80cb2a58677dd70db0a2083d4849fa408a
https://github.com/scummvm/scummvm/commit/b70c4a80cb2a58677dd70db0a2083d4849fa408a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: Notebook: the label Task, the tab numbers and the check mark as in RenderBookMarks, BitmapFont::printRotate
Changed paths:
engines/ngi/font.cpp
engines/ngi/font.h
engines/ngi/fullpipe/notebook.cpp
engines/ngi/fullpipe/notebook.h
diff --git a/engines/ngi/font.cpp b/engines/ngi/font.cpp
index 2a90aa76ae4..aa281ee58ce 100644
--- a/engines/ngi/font.cpp
+++ b/engines/ngi/font.cpp
@@ -385,6 +385,98 @@ void BitmapFont::printLine(Graphics::ManagedSurface &target, const Common::Strin
}
}
+// CFont::GetTextSize (F9CCC): width = advances + kerning to the next letter, height = tallest
+void BitmapFont::getTextSize(const Common::String &text, float &width, float &height) const {
+ width = 0;
+ height = 0;
+ for (uint i = 0; i < text.size(); i++) {
+ width += getCharAdvance((byte)text[i]) + (i + 1 < text.size() ? getKerningOffset((byte)text[i], (byte)text[i + 1]) : 0);
+ height = MAX<float>(height, getBoundingBox((byte)text[i]).bottom + 2 * _outline + _spacing.y);
+ }
+}
+
+static int roundAwayFromZero(float value) {
+ return (int)(value + (value < 0.0f ? -0.5f : 0.5f));
+}
+
+// CFont::PrintRotate (FA358), PrintCharRotate (F9880), CRender::DrawFontQuadRotate (11E16C):
+// glyph quad corners turned about the text start (CalcRotatePoints), plain 2D rotation + pivot
+void BitmapFont::printRotate(Graphics::ManagedSurface &target, const Common::String &text, float x, float y, float angle) const {
+ const float cosine = cosf(angle);
+ const float sine = sinf(angle);
+ const Common::Point wide = &target == &g_ngi->_backgroundSurface ? Common::Point(g_ngi->_wideOfs, 0) : Common::Point();
+ float advance = 0;
+ for (uint i = 0; i < text.size(); i++) {
+ const int kerning = i ? getKerningOffset((byte)text[i - 1], (byte)text[i]) : 0;
+ const Glyph &g = glyph((byte)text[i]);
+ const Bitmap *bitmap = g.source.isEmpty() ? nullptr : _pages[g.page]->getPixelData();
+ if (bitmap && bitmap->_surface) {
+ const Graphics::ManagedSurface &page = *bitmap->_surface;
+ const int left = roundAwayFromZero(x + advance + g.offset.x + kerning);
+ const int top = roundAwayFromZero(y + g.offset.y);
+ const int width = g.source.width();
+ const int height = g.source.height();
+
+ // the bounding box of the turned quad
+ float minX = 1e9f;
+ float minY = 1e9f;
+ float maxX = -1e9f;
+ float maxY = -1e9f;
+ for (int corner = 0; corner < 4; corner++) {
+ const float dx = left + (corner & 1 ? width : 0) - x;
+ const float dy = top + (corner & 2 ? height : 0) - y;
+ const float rx = dx * cosine - dy * sine + x;
+ const float ry = dx * sine + dy * cosine + y;
+ minX = MIN(minX, rx);
+ maxX = MAX(maxX, rx);
+ minY = MIN(minY, ry);
+ maxY = MAX(maxY, ry);
+ }
+ const int boxLeft = (int)floorf(minX);
+ const int boxTop = (int)floorf(minY);
+ const int boxWidth = (int)ceilf(maxX) - boxLeft;
+ const int boxHeight = (int)ceilf(maxY) - boxTop;
+ if (boxWidth > 0 && boxHeight > 0) {
+ Graphics::ManagedSurface turned(boxWidth, boxHeight, Graphics::PixelFormat::createFormatARGB32());
+ turned.fillRect(Common::Rect(boxWidth, boxHeight), 0);
+ byte palette[256 * 3];
+ if (page.format.isCLUT8())
+ page.grabPalette(palette, 0, 256);
+ for (int v = 0; v < boxHeight; v++) {
+ for (int u = 0; u < boxWidth; u++) {
+ // the pixel of the glyph that lands on the center of this one
+ const float dx = boxLeft + u + 0.5f - x;
+ const float dy = boxTop + v + 0.5f - y;
+ const int sx = (int)floorf(dx * cosine + dy * sine + x - left);
+ const int sy = (int)floorf(-dx * sine + dy * cosine + y - top);
+ if (sx < 0 || sy < 0 || sx >= width || sy >= height)
+ continue;
+ const int px = g.source.left + sx;
+ const int py = g.source.top + sy;
+ byte a = 255, r, gr, b;
+ if (page.format.isCLUT8()) {
+ const byte index = *(const byte *)page.getBasePtr(px, py);
+ if (page.hasTransparentColor() && index == page.getTransparentColor())
+ continue;
+ r = palette[index * 3];
+ gr = palette[index * 3 + 1];
+ b = palette[index * 3 + 2];
+ } else {
+ uint32 pixel = page.format.bytesPerPixel == 4 ? *(const uint32 *)page.getBasePtr(px, py) : *(const uint16 *)page.getBasePtr(px, py);
+ page.format.colorToARGB(pixel, a, r, gr, b);
+ }
+ if (!a)
+ continue;
+ *(uint32 *)turned.getBasePtr(u, v) = turned.format.ARGBToColor(a, r, gr, b);
+ }
+ }
+ target.blitFrom(turned, Common::Point(boxLeft, boxTop) + wide);
+ }
+ }
+ advance += getCharAdvance((byte)text[i]) + kerning;
+ }
+}
+
void BitmapFont::printAligned(Graphics::ManagedSurface &target, const Common::String &line, float x, float y, int align, float width) const {
const float lineSize = lineWidth(line);
float spaceExtra = 0;
diff --git a/engines/ngi/font.h b/engines/ngi/font.h
index 4d11459d40f..57b3d216b99 100644
--- a/engines/ngi/font.h
+++ b/engines/ngi/font.h
@@ -54,6 +54,10 @@ public:
void drawCentered(Graphics::ManagedSurface &target, const Common::Rect &bounds, const Common::String &text) const;
/** CFont::Print with the vertical alignment */
void print(Graphics::ManagedSurface &target, const Common::String &text, float x, float y, float width, float height, int align, int verticalAlign) const;
+ /** CFont::GetTextSize (one line, extra spacing 0) */
+ void getTextSize(const Common::String &text, float &width, float &height) const;
+ /** CFont::PrintRotate: one line, turned by the angle (radians) about (x, y) */
+ void printRotate(Graphics::ManagedSurface &target, const Common::String &text, float x, float y, float angle) const;
/** CFont::PrintAligned: one line, x is its left, right or center */
void printAligned(Graphics::ManagedSurface &target, const Common::String &line, float x, float y, int align, float width) const;
diff --git a/engines/ngi/fullpipe/notebook.cpp b/engines/ngi/fullpipe/notebook.cpp
index a2b8f6054ef..a9843d00d04 100644
--- a/engines/ngi/fullpipe/notebook.cpp
+++ b/engines/ngi/fullpipe/notebook.cpp
@@ -27,6 +27,7 @@
#include "ngi/gameloader.h"
#include "ngi/objects.h"
#include "ngi/anihandler.h"
+#include "ngi/fullpipe/achievements.h"
#include "ngi/statics.h"
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/guimanager.h"
@@ -389,7 +390,10 @@ void Notebook::showHint(int index) {
// The hints cost the achievements ACHIEVEMENT_HELPLESS_CHAPTER_n and ACHIEVEMENT_HELPLESS_FINISH points
// (CAchievementsManager::BlockActivatingCounter, 50 in chapter 1 and 100 later)
- warnOnce("CAchievementsManager::BlockActivatingCounter: achievements are not ported");
+ const int chapter = g_ngi->_chapterManager->getActiveChapter();
+ const int blocked = chapter == 1 ? 50 : 100;
+ g_ngi->_achievementsManager->blockActivatingCounter(Common::String::format("ACHIEVEMENT_HELPLESS_CHAPTER_%d", chapter), blocked);
+ g_ngi->_achievementsManager->blockActivatingCounter("ACHIEVEMENT_HELPLESS_FINISH", blocked);
// (and reports the hint to its analytics)
task->showHint(index);
@@ -470,6 +474,8 @@ void Notebook::onShow() {
if (!_texts.load(directory) || !_headingFont.load(fonts.join("task_dlg_29.fnt")) || !_font.load(fonts.join("task_dlg_25.fnt")) ||
!_hintFont.load(fonts.join(_russian ? "task_dlg_19.fnt" : "task_dlg_17_smile.fnt")))
warning("Could not load the texts or fonts of the notebook");
+ if (!_bookmarkFont.load(fonts.join("task_dlg_17.fnt")) || !_bookmarkLabelFont.load(fonts.join("task_dlg_16.fnt")))
+ warning("Could not load the fonts of the bookmarks of the notebook");
// (the original scrolls the inventory out of the way here, CInventoryController::ScrollOut)
_current = -1;
@@ -798,34 +804,69 @@ void Notebook::text(const BitmapFont &font, const Common::Rect &bounds, const Co
}
-// CNotebookController::RenderBookMarks. The labels of the tabs are printed rotated by a quarter turn in the original;
-// they are not drawn here, only the numbers (horizontally).
+// CNotebookController::RenderBookMarks (159DC4): task numbers, "Task" label, check marks
void Notebook::renderBookmarks() const {
- const Notebook ¬ebook = *this;
- bool green = false;
- for (int pass = 0; pass < 2; pass++) { // the tab that is open on top
- for (uint i = 0; i < notebook._tasks.size(); i++) {
- const bool selected = (int)i == notebook._current && notebook._page == Notebook::kPageTask;
- if (selected != (pass == 1))
- continue;
- int picture = kPicBookmark;
- if (selected) {
- picture = kPicBookmarkActive;
- } else if (notebook._page == Notebook::kPageTask && green) {
- picture = kPicBookmarkGreen;
- }
- if (!selected && notebook._page == Notebook::kPageTask)
- green = !green;
- const int x = 60;
- const int y = 117 + 45 * i;
- blit(picture, x, y);
- if (notebook._tasks[i]->_state == Task::kStateClosed) {
- const int offset = selected ? 8 : ((notebook._current == -1 || (int)i <= notebook._current) ? 6 : 75);
- blit(kPicCheck, x + 8, y + offset);
- }
- const Dims bookmark = size(picture);
- text(_font, Common::Rect(x, y, x + bookmark.x, y + bookmark.y), Common::String::format("%d", i + 1));
+ const int count = (int)_tasks.size();
+ const bool plain = _page == kPageBuy || _page == kPageCatalog; // pages without an open tab
+
+ // the pictures of the bookmarks: the tabs that are not open alternate between the two pictures
+ int pictures[64];
+ int depth[64];
+ if (count > 64)
+ return;
+ bool alternate = false;
+ for (int i = 0; i < count; i++) {
+ if (i == _current) {
+ pictures[i] = plain ? kPicBookmark : kPicBookmarkActive;
+ } else {
+ pictures[i] = (alternate && !plain) ? kPicBookmarkGreen : kPicBookmark;
+ alternate = !alternate;
+ }
+ depth[i] = _current == -1 ? 0 : (i >= _current ? i - _current : _current - i);
+ }
+ for (int z = count; z >= 0; z--) { // the scene draws the greater z first
+ for (int i = 0; i < count; i++) {
+ if (depth[i] == z)
+ blit(pictures[i], kBookmarkX, kBookmarkY + kBookmarkStep * i);
+ }
+ }
+
+ const Dims check = size(kPicCheck);
+ const bool german = g_ngi->getResourceLocale() == Common::String("de");
+ const bool russian = _russian;
+ const BitmapFont &labelFont = german ? _bookmarkLabelFont : _bookmarkFont;
+ for (int i = 0; i < count; i++) {
+ const float x = kBookmarkX;
+ const float y = kBookmarkY + kBookmarkStep * i;
+ Common::String label;
+ float offset;
+ if ((_current == -1 && i == count - 1) || _current == i) {
+ label = _texts.getText("STR_TASK_CONTROLLER");
+ offset = 8.0f;
+ } else if (i <= _current || _current == -1) {
+ offset = 6.0f;
+ } else {
+ offset = 75.0f;
}
+ const float checkX = x + 8.0f;
+ const float checkY = y + offset;
+ const int labelGap = i == 0 ? 5 : (russian ? 5 : 0);
+
+ float numberWidth;
+ float numberHeight;
+ const Common::String number = Common::String::format("%d", i + 1);
+ _bookmarkFont.getTextSize(number, numberWidth, numberHeight);
+ const float numberX = (checkX + check.x * 0.5f) - numberHeight * 0.5f - (russian ? 4 : 0);
+ const float numberY = (checkY + check.y * 0.5f) + numberWidth * 0.5f;
+ float labelWidth;
+ float labelHeight;
+ labelFont.getTextSize(label, labelWidth, labelHeight);
+ const float labelY = (numberY + labelGap) + labelWidth;
+ const float quarterTurn = -1.5707964f;
+ _bookmarkFont.printRotate(g_ngi->_backgroundSurface, number, numberX, numberY, quarterTurn);
+ labelFont.printRotate(g_ngi->_backgroundSurface, label, x + 12.0f, labelY, quarterTurn);
+ if (_tasks[i]->_state == Task::kStateClosed)
+ blit(kPicCheck, (int)checkX, (int)checkY);
}
}
diff --git a/engines/ngi/fullpipe/notebook.h b/engines/ngi/fullpipe/notebook.h
index cb8e9062711..58522d212f1 100644
--- a/engines/ngi/fullpipe/notebook.h
+++ b/engines/ngi/fullpipe/notebook.h
@@ -172,6 +172,8 @@ private:
BitmapFont _headingFont; // task_dlg_29.fnt
BitmapFont _font; // task_dlg_25.fnt
BitmapFont _hintFont; // task_dlg_19.fnt (ru) or task_dlg_17_smile.fnt
+ BitmapFont _bookmarkFont; // task_dlg_17.fnt (+56): the bookmark numbers
+ BitmapFont _bookmarkLabelFont; // task_dlg_16.fnt (+60): the bookmark label in the German build
bool _russian = false;
};
Commit: 6436acd45c346242345089aa47243a822b856d6f
https://github.com/scummvm/scummvm/commit/6436acd45c346242345089aa47243a822b856d6f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: AchievementsManager and Achievement (CAchievementsManager), the banner and the ScummVM achievements
Changed paths:
A engines/ngi/achievements_tables.h
engines/ngi/fullpipe/achievements.cpp
engines/ngi/fullpipe/achievements.h
engines/ngi/fullpipe/chaptermanager.cpp
engines/ngi/fullpipe/constants.h
engines/ngi/fullpipe/controllerhelpers.cpp
engines/ngi/fullpipe/controllerhelpers.h
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/mainmenucontroller.cpp
engines/ngi/fullpipe/sc04controller.cpp
engines/ngi/fullpipe/sc06controller.cpp
engines/ngi/fullpipe/sc08controller.cpp
engines/ngi/fullpipe/sc09controller.cpp
engines/ngi/fullpipe/sc11controller.cpp
engines/ngi/fullpipe/sc14controller.cpp
engines/ngi/fullpipe/sc27controller.cpp
engines/ngi/fullpipe/sc29controller.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/fullpipe/tutorialcontroller.cpp
engines/ngi/metaengine.cpp
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/achievements_tables.h b/engines/ngi/achievements_tables.h
new file mode 100644
index 00000000000..ec6eceb4a4c
--- /dev/null
+++ b/engines/ngi/achievements_tables.h
@@ -0,0 +1,39 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_ACHIEVEMENTS_TABLES_H
+#define NGI_ACHIEVEMENTS_TABLES_H
+
+#include "engines/achievements.h"
+
+namespace NGI {
+
+// Android Full Pipe: the Google Play key stands for the game (the tables know Steam and GOG only).
+// No titles in achievements.dat yet, an unlocked achievement shows its id.
+static const Common::AchievementDescriptionList achievementDescriptionList[] = {
+ {"fullpipe", Common::UNK_ACHIEVEMENTS, "CgkI-MbEjr0C"},
+
+ ACHIEVEMENT_DESC_TABLE_END_MARKER
+};
+
+} // End of namespace NGI
+
+#endif
diff --git a/engines/ngi/fullpipe/achievements.cpp b/engines/ngi/fullpipe/achievements.cpp
index ae2a3b20012..858aeb27e09 100644
--- a/engines/ngi/fullpipe/achievements.cpp
+++ b/engines/ngi/fullpipe/achievements.cpp
@@ -20,188 +20,414 @@
*/
#include "common/debug.h"
-#include "common/hashmap.h"
+
+#include "engines/achievements.h"
#include "ngi/ngi.h"
+#include "ngi/font.h"
+#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/scene.h"
#include "ngi/fullpipe/achievements.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
namespace NGI {
-static void stub(const char *name) {
- static Common::HashMap<Common::String, bool> reported;
- if (reported.contains(name))
- return;
- reported[name] = true;
- warning("STUB/untested: %s", name);
-}
+namespace {
-AchievementsManager::AchievementsManager() {
- stub("AchievementsManager::AchievementsManager");
+// CIDList::FindId: 0 for an unknown name
+int findId(const Common::String &name) {
+ uint32 id = 0;
+ if (!name.empty())
+ g_ngi->_gameProject->_objectIds.findId(name, id);
+ return id;
}
-void AchievementsManager::getXmlData(int *arg2) {
- stub("AchievementsManager::getXmlData");
+// FindPicture(0x141, id, 0): the pictures of the achievements are in SC_COMMON
+PictureObject *findCommonPicture(int id) {
+ Scene *common = g_ngi->findScene(SC_COMMON);
+ return common ? common->findPictureObjectById(id, 0) : nullptr;
}
-uint32 AchievementsManager::setXmlData(void *arg2) {
- stub("AchievementsManager::setXmlData");
- return 0;
-}
+// the banner slides in and out in 0.6 seconds and stays 3 seconds
+const float kSlideTime = 0.6f;
+const float kShowTime = 3.0f;
-float AchievementsManager::onUpdate(uint32 arg2) {
- stub("AchievementsManager::onUpdate");
- return 0.0f;
-}
+} // End of anonymous namespace
-void AchievementsManager::onRender(uint32 arg2, uint32 arg3) {
- stub("AchievementsManager::onRender");
+// CAchievement::CAchievement (1462F0)
+Achievement::Achievement() : _curActivatingCounter(-100), _curBlockingCounter(-100), _parentId("UNDEF"), _id("UNDEF"), _banner(nullptr), _icon(nullptr),
+ _state(0), _bannerState(0), _timer(0), _textLeft(0), _textTop(0), _textRight(0), _textBottom(0), _isFB(false) {
+ _font = g_ngi->getFont("impact_17.fnt");
}
-int AchievementsManager::onMouseLKeyDown(float arg2, float arg3) {
- stub("AchievementsManager::onMouseLKeyDown");
- return 0;
+Achievement::~Achievement() {
+ delete _banner;
}
-int AchievementsManager::onMouseMove(float arg2, float arg3) {
- stub("AchievementsManager::onMouseMove");
- return 0;
+// name_id, description_id, fb_description_id and description_id_no_reach (CTextContainer::GetText)
+void Achievement::loadTexts(const XmlNode &node) {
+ _name = g_ngi->getText(node.attrStr("name_id", ""));
+ _description = g_ngi->getText(node.attrStr("description_id", ""));
+ _descriptionNoReach = g_ngi->getText(node.attrStr("description_id_no_reach", ""));
+ _fbDescription = g_ngi->getText(node.attrStr("fb_description_id", ""));
}
-int AchievementsManager::getNumVisibleAchievements() {
- stub("AchievementsManager::getNumVisibleAchievements");
- return 0;
+// CAchievement::Init (1456BC)
+bool Achievement::init(const XmlNode &node) {
+ _id = node.attrStr("id", "");
+ if (node.checkChild("google_play"))
+ _googlePlayId = node.child("google_play").attrStr("id", "");
+ _fbLink = "http://apps.absolutist.com/full-pipe/achievements/";
+ _fbLink += node.attrStr("fb_pic_name", "");
+ _icon = findCommonPicture(findId(node.attrStr("pic_id", "")));
+ loadTexts(node);
+ _parentId = node.attrStr("parent_id", "UNDEF");
+ if (_id == "UNDEF")
+ return false;
+ _curActivatingCounter = 0;
+ _curBlockingCounter = 0;
+ _state = kNotReached;
+ _bannerState = kBannerHidden;
+ _isFB = false;
+ return true;
}
-float AchievementsManager::onMouseLKeyUp(float arg2, float arg3) {
- stub("AchievementsManager::onMouseLKeyUp");
- return 0.0f;
+// CAchievement::LoadParam (145958)
+bool Achievement::loadParam(const XmlNode &node) {
+ _id = node.attrStr("id", "UNDEF");
+ _icon = findCommonPicture(findId(node.attrStr("pic_id", "")));
+ loadTexts(node);
+ _parentId = node.attrStr("parent_id", "UNDEF");
+ return _id != "UNDEF";
}
-int AchievementsManager::findAchievement(void **arg2) {
- stub("AchievementsManager::findAchievement");
- return 0;
+// CAchievement::GetXmlData (145054)
+void Achievement::getXmlData() {
+ warnOnce("CAchievement::GetXmlData: the XML serializer of CGObject::SaveXml is not ported, achievements.sav is not written");
}
-void AchievementsManager::blockActivatingCounter(int *arg2, int arg3) {
- stub("AchievementsManager::blockActivatingCounter");
+// CAchievement::SetXmlData (1451B0)
+bool Achievement::setXmlData(const XmlNode &node) {
+ _state = node.attrInt("curState", 0);
+ _curActivatingCounter = node.attrInt("curActivatingCounter", 0);
+ _curBlockingCounter = node.attrInt("curBlokingCounter", 0);
+ _isFB = node.attrBool("isFB", false);
+ return _isFB;
}
-int AchievementsManager::isActivatingItem(void *arg2, int *arg3) {
- stub("AchievementsManager::isActivatingItem");
- return 0;
+// CAchievement::CleanXml (1461E8)
+void Achievement::cleanXml() {
+ _state = kNotReached;
+ _bannerState = kBannerHidden;
+ _curActivatingCounter = 0;
+ _curBlockingCounter = 0;
+ _isFB = false;
+ _activatingItems.clear();
}
-AchievementsManager *AchievementsManager::getSavePath(int arg2, int arg3) {
- stub("AchievementsManager::getSavePath");
- return nullptr;
+// CAchievement::IsVisible (1452E0): the mask ~4 leaves the banner states 1, 2 and 3
+bool Achievement::isVisible() const {
+ return _state == kReached && (_bannerState & ~4) != 0;
}
-int AchievementsManager::addActivatingCounter(int *arg2, int arg3, int *arg4) {
- stub("AchievementsManager::addActivatingCounter");
- return 0;
+// CAchievement::OnHide (1452F8): the icon is unloaded; the textures load when drawn here
+void Achievement::onHide() {
+ _bannerState = kBannerHidden;
+ delete _banner;
+ _banner = nullptr;
}
-int AchievementsManager::cheatAchievements(uint32 arg2) {
- stub("AchievementsManager::cheatAchievements");
- return 0;
+// CAchievement::OnUpdate (145320)
+void Achievement::onUpdate(uint32 elapsed) {
+ if (!isVisible())
+ return;
+ _timer += (float)elapsed / 1000.0f;
+ switch (_bannerState) {
+ case kBannerAppearing:
+ if (_timer >= kSlideTime) {
+ _bannerState = kBannerShown;
+ _timer = 0;
+ }
+ break;
+ case kBannerShown:
+ if (_timer >= kShowTime) {
+ _bannerState = kBannerDisappearing;
+ _timer = 0;
+ }
+ break;
+ case kBannerDisappearing:
+ if (_timer >= kSlideTime)
+ onHide();
+ break;
+ default:
+ break;
+ }
+}
+
+// CAchievement::OnRender (1453C8): the caller's shift is not used (Render subtracts it)
+void Achievement::onRender(float x, float y) {
+ if (!isVisible())
+ return;
+ if (_bannerState == kBannerShown) {
+ x = 0;
+ y = 0;
+ } else if (_bannerState == kBannerAppearing || _bannerState == kBannerDisappearing) {
+ const float part = (_bannerState == kBannerAppearing ? kSlideTime - _timer : _timer) / kSlideTime;
+ x = part * (float)_banner->getSize().x;
+ y = 0;
+ }
+ _banner->render(Common::Point((int)x, (int)y));
+ _icon->render(Common::Point((int)x, (int)y));
+ if (_font)
+ _font->print(g_ngi->_backgroundSurface, _name, _textLeft - x, _textTop - y, _textRight - _textLeft, _textBottom - _textTop, BitmapFont::kAlignCenter,
+ BitmapFont::kVerticalCenter);
+}
+
+// CAchievement::OnMouseLKeyUp (1455C8): a tap on a banner that is not sliding out starts to hide it
+void Achievement::onMouseLKeyUp(float x, float y) {
+ if (!isVisible())
+ return;
+ const Scene *scene = g_ngi->getCurrentScene();
+ const float sceneX = scene->_x;
+ const float sceneY = scene->_y;
+ if (_bannerState == kBannerDisappearing)
+ return;
+ if (_banner->hit((int)(x - sceneX), (int)(y - sceneY))) {
+ if (_bannerState == kBannerAppearing)
+ _timer = kSlideTime - _timer;
+ else
+ _timer = 0;
+ _bannerState = kBannerDisappearing;
+ }
}
-void AchievementsManager::cleanXml() {
- stub("AchievementsManager::cleanXml");
+// CAchievement::FBPublish (145678): PP_FB_achievementsPublish with the description and the link
+void Achievement::fbPublish(int, int, const char *) {
+ warnOnce("CAchievement::FBPublish: PP_FB_achievementsPublish (Facebook) is not ported");
}
-void AchievementsManager::init(char **arg2) {
- stub("AchievementsManager::init");
+// CAchievement::OnShow (145B7C)
+void Achievement::onShow() {
+ if (_state != kReached)
+ return;
+ PictureObject *picture = findCommonPicture(PIC_ACHIEVEMENTS_BGR);
+ if (!picture || !_icon) {
+ warning("Achievement::onShow: the pictures of the achievement %s are missing", _id.c_str());
+ return;
+ }
+ _bannerState = kBannerAppearing;
+ _timer = 0;
+ delete _banner;
+ _banner = new PictureObject(picture);
+ const float wide = (float)g_ngi->_wideOfs; // CRender +24, the widescreen offset
+ const int visible = g_ngi->_achievementsManager->getNumVisibleAchievements();
+ const float bannerY = (float)(visible - 1) * (float)_banner->getSize().y + 60.0f;
+ _banner->setPos(-g_ngi->_wideOfs, (int)bannerY);
+ _icon->_scaleX = 0.5f;
+ _icon->_scaleY = 0.5f;
+ const float bannerHeight = (float)_banner->getSize().y;
+ _icon->setPos((int)(15.0f - wide), (int)(bannerY + (bannerHeight - (float)_icon->getSize().y) * 0.5f));
+ _textLeft = (15.0f - wide) + (float)_icon->getSize().x - 6.0f;
+ _textRight = ((float)_banner->getSize().x - wide) - 5.0f;
+ _textTop = bannerY + 20.0f;
+ _textBottom = bannerY + (float)_banner->getSize().y;
+}
+
+// CAchievement::IsActivatingItem (145CF4)
+bool Achievement::isActivatingItem(const Common::String &item) const {
+ for (const Common::String &counted : _activatingItems) {
+ if (counted == item)
+ return true;
+ }
+ return false;
}
-Achievement::Achievement() {
- stub("Achievement::Achievement");
+// CAchievement::GetParentAchievement (145DEC)
+Achievement *Achievement::getParentAchievement() const {
+ if (_parentId == "UNDEF")
+ return nullptr;
+ return g_ngi->_achievementsManager->findAchievement(_parentId);
}
-void Achievement::getXmlData(int *arg2, int arg3) {
- stub("Achievement::getXmlData");
+// CAchievement::GetChildAchievement (145E38): the first achievement that has this one as its parent
+Achievement *Achievement::getChildAchievement() const {
+ for (Achievement *achievement : g_ngi->_achievementsManager->_achievements) {
+ if (achievement && achievement->_parentId == _id)
+ return achievement;
+ }
+ return nullptr;
}
-bool Achievement::setXmlData(void *arg2) {
- stub("Achievement::setXmlData");
+// CAchievement::IsAnyChildReached (145E96): follows the children down, one after the other
+bool Achievement::isAnyChildReached() const {
+ const Achievement *achievement = this;
+ while ((achievement = achievement->getChildAchievement()) != nullptr) {
+ if (achievement->_state == kReached)
+ return true;
+ }
return false;
}
-bool Achievement::isVisible() {
- stub("Achievement::isVisible");
+// CAchievement::AddActivatingCounter (145FA8): the platform report goes to ScummVM's achievements
+bool Achievement::addActivatingCounter(int count, const Common::String &item) {
+ if (_state != kNotReached || _curBlockingCounter > 99)
+ return false;
+ if (item != "UNDEF") {
+ if (isActivatingItem(item))
+ return false;
+ _activatingItems.push_back(item);
+ }
+ _curActivatingCounter += count;
+ if (_curActivatingCounter <= 99)
+ return false;
+ if (_parentId == "UNDEF" || !getParentAchievement() || getParentAchievement()->_state == kReached) {
+ _state = kReached;
+ warnOnce("PP_GC_ReportAchievement (Google Play, Game Center): only the achievements of ScummVM (AchMan) get the achievement, its titles are not in achievements.dat");
+ AchMan.setAchievement(_id);
+ onShow();
+ return true;
+ }
return false;
}
-int Achievement::onHide() {
- stub("Achievement::onHide");
- return 0;
-}
-
-float Achievement::onUpdate(uint32 arg2) {
- stub("Achievement::onUpdate");
- return 0.0f;
+// CAchievementsManager::CAchievementsManager (1454D4)
+AchievementsManager::AchievementsManager() {
}
-void Achievement::onRender(float arg2, float arg3) {
- stub("Achievement::onRender");
+AchievementsManager::~AchievementsManager() {
+ for (Achievement *achievement : _achievements)
+ delete achievement;
}
-int Achievement::blockActivatingCounter(int arg2) {
- stub("Achievement::blockActivatingCounter");
- return 0;
+// CAchievementsManager::Init (146488): an achievement that exists reloads its parameters
+void AchievementsManager::init(const char *path) {
+ Common::ScopedPtr<XmlNode> document(loadXmlDocument(path));
+ if (!document)
+ return;
+ const XmlNode &root = document->first();
+ for (uint i = 0; i < root.childCount(); i++) {
+ const XmlNode &node = root[i];
+ if (node.name() != "ACHIEVEMENT")
+ continue;
+ const Common::String id = node.attrStr("id", "");
+ if (Achievement *existing = findAchievement(id)) {
+ existing->loadParam(node);
+ continue;
+ }
+ Achievement *achievement = new Achievement();
+ if (achievement->init(node))
+ _achievements.push_back(achievement);
+ else
+ delete achievement;
+ }
+}
+
+// CAchievementsManager::GetSavePath (145EAC)
+Common::String AchievementsManager::getSavePath() const {
+ warnOnce("CAchievementsManager::GetSavePath: CPathManager is not ported, only the file name is given");
+ return "achievements.sav";
+}
+
+// CAchievementsManager::GetXmlData (145130)
+void AchievementsManager::getXmlData() {
+ for (Achievement *achievement : _achievements)
+ achievement->getXmlData();
+}
+
+// CAchievementsManager::SetXmlData (145204): the children are in the order of the file
+void AchievementsManager::setXmlData(const XmlNode &node) {
+ for (uint i = 0; i < node.childCount(); i++) {
+ if (_achievements.size() > i && node[i].name() == "ACHIEVEMENT")
+ _achievements[i]->setXmlData(node[i]);
+ }
+}
+
+// CAchievementsManager::CleanXml (14620E)
+void AchievementsManager::cleanXml() {
+ for (Achievement *achievement : _achievements)
+ achievement->cleanXml();
}
-float Achievement::onMouseLKeyUp(float arg2, float arg3) {
- stub("Achievement::onMouseLKeyUp");
- return 0.0f;
+// CAchievementsManager::OnUpdate (145500)
+void AchievementsManager::onUpdate(uint32 elapsed) {
+ for (Achievement *achievement : _achievements)
+ achievement->onUpdate(elapsed);
}
-void Achievement::fBPublish(int arg2, int arg3, char *arg4) {
- stub("Achievement::fBPublish");
+// CAchievementsManager::OnRender (145524)
+void AchievementsManager::onRender(float x, float y) {
+ for (Achievement *achievement : _achievements)
+ achievement->onRender(x, y);
}
-int Achievement::init(void *arg2) {
- stub("Achievement::init");
- return 0;
+// CAchievementsManager::OnMouseLKeyDown (14554E)
+void AchievementsManager::onMouseLKeyDown(float x, float y) {
+ for (Achievement *achievement : _achievements)
+ achievement->onMouseLKeyDown(x, y);
}
-bool Achievement::loadParam(void *arg2) {
- stub("Achievement::loadParam");
- return false;
+// CAchievementsManager::OnMouseMove (145576)
+void AchievementsManager::onMouseMove(float x, float y) {
+ for (Achievement *achievement : _achievements)
+ achievement->onMouseMove(x, y);
}
-float Achievement::onShow() {
- stub("Achievement::onShow");
- return 0.0f;
+// CAchievementsManager::OnMouseLKeyUp (145650)
+void AchievementsManager::onMouseLKeyUp(float x, float y) {
+ for (Achievement *achievement : _achievements)
+ achievement->onMouseLKeyUp(x, y);
}
-bool Achievement::isActivatingItem(void **arg2) {
- stub("Achievement::isActivatingItem");
- return false;
+// CAchievementsManager::GetNumVisibleAchievements (14559E)
+int AchievementsManager::getNumVisibleAchievements() const {
+ int count = 0;
+ for (const Achievement *achievement : _achievements)
+ count += achievement->isVisible() ? 1 : 0;
+ return count;
}
-int Achievement::getParentAchievement(void *arg2) {
- stub("Achievement::getParentAchievement");
- return 0;
+// CAchievementsManager::FindAchievement (145D1C)
+Achievement *AchievementsManager::findAchievement(const Common::String &id) const {
+ for (Achievement *achievement : _achievements) {
+ if (achievement->_id == id)
+ return achievement;
+ }
+ return nullptr;
}
-int Achievement::getChildAchievement() {
- stub("Achievement::getChildAchievement");
- return 0;
+// CAchievementsManager::BlockActivatingCounter (145D66)
+void AchievementsManager::blockActivatingCounter(const Common::String &id, int count) {
+ if (Achievement *achievement = findAchievement(id))
+ achievement->blockActivatingCounter(count);
}
-Achievement *Achievement::isAnyChildReached() {
- stub("Achievement::isAnyChildReached");
- return nullptr;
+// CAchievementsManager::IsActivatingItem (145D9E)
+bool AchievementsManager::isActivatingItem(const Common::String &id, const Common::String &item) const {
+ const Achievement *achievement = findAchievement(id);
+ return achievement && achievement->isActivatingItem(item);
}
-int Achievement::addActivatingCounter(int arg2, int *arg3) {
- stub("Achievement::addActivatingCounter");
- return 0;
+// CAchievementsManager::AddActivatingCounter (146110)
+bool AchievementsManager::addActivatingCounter(const Common::String &id, int count, const Common::String &item) {
+ Achievement *achievement = findAchievement(id);
+ return achievement && achievement->addActivatingCounter(count, item);
}
-void Achievement::cleanXml() {
- stub("Achievement::cleanXml");
+// CAchievementsManager::CheatAchievements (146160): 1.99999f of the decompile is 0x3FFFFFFE
+void AchievementsManager::cheatAchievements(uint32 key) {
+ warnOnce("CAchievementsManager::CheatAchievements has no caller in the Android build, untested");
+ if (getNumVisibleAchievements() > 1)
+ return;
+ int limit = (int)key - 48;
+ for (uint n = 0; n < _achievements.size() / 10 && limit < (int)_achievements.size(); n++, limit += 10) {
+ const int index = 10 * (int)n + (int)key - 2;
+ if (index < 0 || index >= (int)_achievements.size())
+ break;
+ if (_achievements[index]->addActivatingCounter(100, "UNDEF"))
+ break;
+ }
}
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/achievements.h b/engines/ngi/fullpipe/achievements.h
index 84ae6981904..65babd7e76e 100644
--- a/engines/ngi/fullpipe/achievements.h
+++ b/engines/ngi/fullpipe/achievements.h
@@ -22,65 +22,140 @@
#ifndef NGI_ACHIEVEMENTS_H
#define NGI_ACHIEVEMENTS_H
-#include "ngi/objects.h"
-#include "ngi/gfx.h"
+#include "common/array.h"
+#include "common/str.h"
+#include "common/str-array.h"
-namespace NGI {
+#include "ngi/xmlnode.h"
-// The achievements of the Android engine (achievements.xml, Google Play / Game Center / Microsoft Store), drawn by CFPController::OnRenderTop.
-// Generated by scripts/ngi_gen_stubs.py achievements from the Android class inventory: every method of the Android classes is
-// declared here and warns "STUB/untested: Class::method" once when called. The parameter types are what the decompiler
-// shows (approximations), the field layouts are not known yet. Replace a stub by the real code and drop its warning.
+namespace NGI {
class AchievementsManager;
-class Achievement;
+class BitmapFont;
+class PictureObject;
-/** Android CAchievementsManager */
-class AchievementsManager {
+/** CAchievement (96 bytes), one entry of achievements.xml; field offsets as in the original */
+class Achievement {
public:
- AchievementsManager();
- virtual ~AchievementsManager() {}
- void getXmlData(int *arg2); // 145130
- uint32 setXmlData(void *arg2); // 145204
- float onUpdate(uint32 arg2); // 145500
- void onRender(uint32 arg2, uint32 arg3); // 145524
- int onMouseLKeyDown(float arg2, float arg3); // 14554E
- int onMouseMove(float arg2, float arg3); // 145576
- int getNumVisibleAchievements(); // 14559E
- float onMouseLKeyUp(float arg2, float arg3); // 145650
- int findAchievement(void **arg2); // 145D1C
- void blockActivatingCounter(int *arg2, int arg3); // 145D66
- int isActivatingItem(void *arg2, int *arg3); // 145D9E
- AchievementsManager *getSavePath(int arg2, int arg3); // 145EAC
- int addActivatingCounter(int *arg2, int arg3, int *arg4); // 146110
- int cheatAchievements(uint32 arg2); // 146160
- void cleanXml(); // 14620E
- void init(char **arg2); // 146488
+ /** +60: the state of the achievement */
+ enum State {
+ kNotReached = 1,
+ kReached = 2
+ };
+ /** +64: the state of the banner; 4 is hidden (not visible) */
+ enum BannerState {
+ kBannerAppearing = 1,
+ kBannerShown = 2,
+ kBannerDisappearing = 3,
+ kBannerHidden = 4
+ };
+
+ Achievement();
+ ~Achievement();
+
+ /** CAchievement::Init (1456BC): false when the achievement has no id */
+ bool init(const XmlNode &node);
+ /** CAchievement::LoadParam (145958) */
+ bool loadParam(const XmlNode &node);
+ /** CAchievement::GetXmlData (145054): not written (no XML serializer) */
+ void getXmlData();
+ /** CAchievement::SetXmlData (1451B0) */
+ bool setXmlData(const XmlNode &node);
+ /** CAchievement::CleanXml (1461E8): the state of a new game */
+ void cleanXml();
+
+ /** CAchievement::IsVisible (1452E0): reached and the banner is not hidden */
+ bool isVisible() const;
+ /** CAchievement::OnShow (145B7C): the banner starts to slide in */
+ void onShow();
+ /** CAchievement::OnHide (1452F8) */
+ void onHide();
+ /** CAchievement::OnUpdate (145320), the time in milliseconds */
+ void onUpdate(uint32 elapsed);
+ /** CAchievement::OnRender (1453C8) */
+ void onRender(float x, float y);
+ /** CAchievement::OnMouseLKeyDown (1454C8) and OnMouseMove (1454C4) are empty */
+ void onMouseLKeyDown(float, float) {}
+ void onMouseMove(float, float) {}
+ /** CAchievement::OnMouseLKeyUp (1455C8): a tap on the banner hides it */
+ void onMouseLKeyUp(float x, float y);
+
+ /** CAchievement::AddActivatingCounter (145FA8): true when the achievement is reached by it */
+ bool addActivatingCounter(int count, const Common::String &item);
+ /** CAchievement::BlockActivatingCounter (1454CC) */
+ void blockActivatingCounter(int count) { _curBlockingCounter += count; }
+ /** CAchievement::IsActivatingItem (145CF4): the item was counted already */
+ bool isActivatingItem(const Common::String &item) const;
+ /** CAchievement::GetParentAchievement (145DEC), GetChildAchievement, IsAnyChildReached */
+ Achievement *getParentAchievement() const;
+ Achievement *getChildAchievement() const;
+ bool isAnyChildReached() const;
+ /** CAchievement::FBPublish (145678): not ported */
+ void fbPublish(int arg2, int arg3, const char *arg4);
+
+ int _curActivatingCounter; // +0, "curActivatingCounter"
+ int _curBlockingCounter; // +4, "curBlokingCounter"
+ Common::String _parentId; // +8, "parent_id", UNDEF without
+ Common::StringArray _activatingItems; // +12: the items that counted
+ Common::String _id; // +24
+ Common::String _googlePlayId; // +28
+ Common::String _fbLink; // +32
+ PictureObject *_banner; // +36: the copy of PIC_ACHIEVEMENTS_BGR that is shown
+ PictureObject *_icon; // +40: PIC_ACHIEVEMENT_* of SC_COMMON
+ Common::String _name; // +44
+ Common::String _description; // +48
+ Common::String _fbDescription; // +52
+ Common::String _descriptionNoReach; // +56
+ int _state; // +60, "curState"
+ int _bannerState; // +64
+ const BitmapFont *_font; // +68: impact_17.fnt
+ float _timer; // +72: the seconds in the state of the banner
+ float _textLeft; // +76
+ float _textTop; // +80
+ float _textRight; // +84
+ float _textBottom; // +88
+ bool _isFB; // +92, "isFB"
+
+private:
+ void loadTexts(const XmlNode &node);
};
-/** Android CAchievement */
-class Achievement {
+/** CAchievementsManager (CSingleton), achievements.xml */
+class AchievementsManager {
public:
- Achievement();
- virtual ~Achievement() {}
- void getXmlData(int *arg2, int arg3); // 145054
- bool setXmlData(void *arg2); // 1451B0
- bool isVisible(); // 1452E0
- int onHide(); // 1452F8
- float onUpdate(uint32 arg2); // 145320
- void onRender(float arg2, float arg3); // 1453C8
- int blockActivatingCounter(int arg2); // 1454CC
- float onMouseLKeyUp(float arg2, float arg3); // 1455C8
- void fBPublish(int arg2, int arg3, char *arg4); // 145678
- int init(void *arg2); // 1456BC
- bool loadParam(void *arg2); // 145958
- float onShow(); // 145B7C
- bool isActivatingItem(void **arg2); // 145CF4
- int getParentAchievement(void *arg2); // 145DEC
- int getChildAchievement(); // 145E38
- Achievement *isAnyChildReached(); // 145E96
- int addActivatingCounter(int arg2, int *arg3); // 145FA8
- void cleanXml(); // 1461E8
+ AchievementsManager();
+ ~AchievementsManager();
+
+ /** CAchievementsManager::Init (146488): reads achievements.xml */
+ void init(const char *path);
+ /** CAchievementsManager::GetSavePath (145EAC, slot 6): "achievements.sav" */
+ Common::String getSavePath() const;
+ /** CAchievementsManager::GetXmlData (145130, slot 7) */
+ void getXmlData();
+ /** CAchievementsManager::SetXmlData (145204, slot 8): the ACHIEVEMENT children, by their order */
+ void setXmlData(const XmlNode &node);
+ /** CAchievementsManager::CleanXml (14620E, slot 5) */
+ void cleanXml();
+
+ void onUpdate(uint32 elapsed); // 145500
+ void onRender(float x, float y); // 145524
+ void onMouseLKeyDown(float x, float y); // 14554E
+ void onMouseMove(float x, float y); // 145576
+ void onMouseLKeyUp(float x, float y); // 145650
+ /** CAchievementsManager::GetNumVisibleAchievements (14559E) */
+ int getNumVisibleAchievements() const;
+ /** CAchievementsManager::FindAchievement (145D1C): null for an unknown id */
+ Achievement *findAchievement(const Common::String &id) const;
+ /** CAchievementsManager::BlockActivatingCounter (145D66) */
+ void blockActivatingCounter(const Common::String &id, int count);
+ /** CAchievementsManager::IsActivatingItem (145D9E) */
+ bool isActivatingItem(const Common::String &id, const Common::String &item) const;
+ /** CAchievementsManager::AddActivatingCounter (146110): true when reached */
+ bool addActivatingCounter(const Common::String &id, int count, const Common::String &item = "UNDEF");
+ /** CAchievementsManager::CheatAchievements (146160): has no caller in the Android build */
+ void cheatAchievements(uint32 key);
+
+ Common::Array<Achievement *> _achievements; // +8
};
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/chaptermanager.cpp b/engines/ngi/fullpipe/chaptermanager.cpp
index c713cdc1b77..c706a9bc7a7 100644
--- a/engines/ngi/fullpipe/chaptermanager.cpp
+++ b/engines/ngi/fullpipe/chaptermanager.cpp
@@ -30,6 +30,7 @@
#include "ngi/gameloader.h"
#include "ngi/objects.h"
#include "ngi/anihandler.h"
+#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/chaptercontroller.h"
#include "ngi/fullpipe/constants.h"
@@ -191,8 +192,11 @@ void ChapterManager::setActiveChapter(int chapter) {
if (_activeChapter >= chapter)
return;
- // The chapter that ends gets its achievement counters (ACHIEVEMENT_CHAPTER_n, ACHIEVEMENT_HELPLESS_CHAPTER_n)
- warning("STUB: CAchievementsManager::AddActivatingCounter for chapter %d: achievements are not ported", _activeChapter);
+ // the ending chapter gets its counters (ACHIEVEMENT_CHAPTER_n, ACHIEVEMENT_HELPLESS_CHAPTER_n)
+ if (g_ngi->_achievementsManager) { // the chapter is set while loading, before the manager exists
+ g_ngi->_achievementsManager->addActivatingCounter(Common::String::format("ACHIEVEMENT_CHAPTER_%d", _activeChapter), 100, "UNDEF");
+ g_ngi->_achievementsManager->addActivatingCounter(Common::String::format("ACHIEVEMENT_HELPLESS_CHAPTER_%d", _activeChapter), 100, "UNDEF");
+ }
if (_activeChapter != 0) {
// (the original reports the time spent and the hints used to its analytics here)
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index ff6e10218c8..ec9de74900b 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -55,6 +55,7 @@ namespace NGI {
#define ANI_ARROW_CHAPTER 23401
#define PIC_ARROW_RED 23237
#define PIC_ARROW_CHAPTER_PRESS 23404
+#define PIC_ACHIEVEMENTS_BGR 23408 // Android: the banner of an achievement
#define MOV_ARROW_UP 23236
#define MOV_ARROW_CHAPTER 23403
#define SND_CMN_080 23238
diff --git a/engines/ngi/fullpipe/controllerhelpers.cpp b/engines/ngi/fullpipe/controllerhelpers.cpp
index 69e76be7a6e..dfdf73a1b45 100644
--- a/engines/ngi/fullpipe/controllerhelpers.cpp
+++ b/engines/ngi/fullpipe/controllerhelpers.cpp
@@ -124,14 +124,6 @@ void enableSound(int, bool) {
warnOnce("CBehaviorController::EnableSound is not ported");
}
-void blockActivatingCounter() {
- warnOnce("CAchievementsManager::BlockActivatingCounter is not ported");
-}
-
-void addActivatingCounter() {
- warnOnce("CAchievementsManager::AddActivatingCounter is not ported");
-}
-
Interact *findInteractionUnderCursor() {
warnOnce("CInteractionController::FindInteractionUnderCursor is not ported (D17)");
return nullptr;
diff --git a/engines/ngi/fullpipe/controllerhelpers.h b/engines/ngi/fullpipe/controllerhelpers.h
index c32f1c08ef9..14f1163325a 100644
--- a/engines/ngi/fullpipe/controllerhelpers.h
+++ b/engines/ngi/fullpipe/controllerhelpers.h
@@ -50,8 +50,6 @@ int projectId(const char *name);
void warnOnce(const char *what);
void setSaving(bool allowed); // CBaseSettings::SetSaving
void enableSound(int soundId, bool enable); // CBehaviorController::EnableSound
-void blockActivatingCounter(); // CAchievementsManager::BlockActivatingCounter
-void addActivatingCounter(); // CAchievementsManager::AddActivatingCounter
Interact *findInteractionUnderCursor(); // CInteractionController (106D94)
void runInteractionWithMouse(const char *name, float x, float y); // CFPController (14D5E0)
void setInteractionWeight(const char *name, int weight); // CInteractionController::SetVes (106DC8)
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 1ceace93cbf..0f044f06777 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -32,8 +32,10 @@
#include "ngi/interaction.h"
#include "ngi/objects.h"
#include "ngi/gfx.h"
+#include "ngi/sound.h"
#include "ngi/statics.h"
#include "ngi/scene.h"
+#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/scenes.h"
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/fpcontroller.h"
@@ -135,8 +137,12 @@ void FPController::executeUserCmd(Command *cmd, MessageQueue *queue) {
} else if (type == "TASK_DEACTIVATE") {
if (g_ngi->_taskManager)
g_ngi->_taskManager->deactivateTask(cmd->_args.getValOrDefault("taskId"));
+ } else if (type == "ADD_ACHIEVEMENT_ACTIVITY") {
+ // CAchievementsManager::AddActivatingCounter
+ g_ngi->_achievementsManager->addActivatingCounter(cmd->_args.getValOrDefault("achievementId"), atoi(cmd->_args.getValOrDefault("procent").c_str()),
+ cmd->_args.getValOrDefault("item", "UNDEF"));
} else if (type == "GO_MCTL" || type == "MOUSE" || type == "SET_CENTER" || type == "TUTORIAL_ACTIVATE" || type == "SHOW_CHAPTER_DIALOG" || type == "CATALOG" ||
- type == "ENABLE_CHARACTER" || type == "HINT_ENABLE" || type == "ADD_ACHIEVEMENT_ACTIVITY" || type == "SHOW_REVIEW") {
+ type == "ENABLE_CHARACTER" || type == "HINT_ENABLE" || type == "SHOW_REVIEW") {
// Handled by CFPController::ExecuteUserCmd, waiting for the subsystems they belong to (TASK_* are in taskmanager.cpp)
static Common::HashMap<Common::String, bool> reported;
if (!reported.contains(type)) {
@@ -741,9 +747,10 @@ void FPController::testSwipe() {
}
}
-// CFPController::OnMouseLKeyDown, the part after the exit manager and the achievements: the touch starts (CanSwipeMan)
+// CFPController::OnMouseLKeyDown
bool FPController::onMouseLKeyDown(uint32 id, float x, float y) {
g_ngi->_exitManager->onMouseLKeyDown(x, y);
+ g_ngi->_achievementsManager->onMouseLKeyDown(x, y);
if (!canSwipeMan(x, y))
return false;
_touching = true;
@@ -933,11 +940,10 @@ void FPController::onRenderBottom(Common::Point) {
g_ngi->_tremble->preRender();
}
-// CFPController::OnRenderTop: the exit labels and the achievements (not implemented), black bars where the camera leaves the scene,
-// then the tremble effect
-// CFPController::OnMouseMove: the pressed exits follow the finger (the achievements are not ported)
+// CFPController::OnMouseMove: the pressed exits follow the finger, then the achievements
bool FPController::onMouseMove(uint32 id, float x, float y) {
g_ngi->_exitManager->onMouseMove(x, y);
+ g_ngi->_achievementsManager->onMouseMove(x, y);
return false;
}
@@ -957,8 +963,7 @@ bool FPController::isNeedReact(float x, float y) {
return false;
}
-// CFPController::OnMouseLKeyUpTop: the shine of ANI_REACT where the finger was lifted over something that reacts, then the exits and the object helper (the
-// achievements are not ported). CFPController::OnSceneInit puts ANI_REACT into every scene; here it is done at the first use. CAniObject::MoveToStatic is SetStatic.
+// CFPController::OnMouseLKeyUpTop; ANI_REACT is added at first use (original: OnSceneInit)
bool FPController::onMouseLKeyUpTop(uint32 id, float x, float y) {
if (g_ngi->_exitManager->getState() != 2 && !_dragged && isNeedReact(x, y)) {
if (!_react) {
@@ -977,7 +982,8 @@ bool FPController::onMouseLKeyUpTop(uint32 id, float x, float y) {
}
}
g_ngi->_exitManager->onMouseLKeyUp(x, y);
- // CObjHelperManager::CatchObjHelper: a tap on the glow that falls into the scene; CAchievementsManager::OnMouseLKeyUp is not ported
+ g_ngi->_achievementsManager->onMouseLKeyUp(x, y);
+ // CObjHelperManager::CatchObjHelper: a tap on the glow that falls into the scene
bool caught = false;
if (g_ngi->_objHelperManager)
caught = g_ngi->_objHelperManager->catchObjHelper(_scene, x, y);
@@ -986,13 +992,10 @@ bool FPController::onMouseLKeyUpTop(uint32 id, float x, float y) {
return caught;
}
+// CFPController::OnRenderTop
void FPController::onRenderTop(Common::Point scroll) {
g_ngi->_exitManager->onRender(scroll.x, scroll.y);
- static bool warned = false;
- if (!warned) {
- warned = true;
- warning("STUB/untested: CAchievementsManager::OnRender (the achievement banner) is not drawn");
- }
+ g_ngi->_achievementsManager->onRender(scroll.x, scroll.y);
// two DrawQuad calls: [0, -scroll] and [sceneWidth - scroll, scroll], shifted by the margin
Graphics::ManagedSurface &target = g_ngi->_backgroundSurface;
diff --git a/engines/ngi/fullpipe/mainmenucontroller.cpp b/engines/ngi/fullpipe/mainmenucontroller.cpp
index f5112d5ac19..83392479da1 100644
--- a/engines/ngi/fullpipe/mainmenucontroller.cpp
+++ b/engines/ngi/fullpipe/mainmenucontroller.cpp
@@ -29,6 +29,7 @@
#include "ngi/statics.h"
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/exitmanager.h"
@@ -151,7 +152,8 @@ void MainMenuController::restartGame() {
g_ngi->_taskManager->cleanXml();
if (g_ngi->_tutorialManager)
g_ngi->_tutorialManager->cleanXml();
- warnOnce("CAchievementsManager::CleanXml: the achievements manager is not a singleton here");
+ if (g_ngi->_achievementsManager)
+ g_ngi->_achievementsManager->cleanXml();
if (g_ngi->_chapterManager)
g_ngi->_chapterManager->cleanXml();
warnOnce("CCatalogManager::CleanXml: the catalog is not ported");
diff --git a/engines/ngi/fullpipe/sc04controller.cpp b/engines/ngi/fullpipe/sc04controller.cpp
index d7c48b29cea..061dc6f6507 100644
--- a/engines/ngi/fullpipe/sc04controller.cpp
+++ b/engines/ngi/fullpipe/sc04controller.cpp
@@ -37,6 +37,7 @@
#include "ngi/anihandler.h"
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/exitmanager.h"
@@ -692,7 +693,7 @@ void Sc04Controller::doStartHand() {
const uint count = _bottleKozaws.size();
if (count < 3) {
activateTasks();
- warnOnce("CAchievementsManager::BlockActivatingCounter (ACHIEVEMENT_ARCADE_4)");
+ g_ngi->_achievementsManager->blockActivatingCounter("ACHIEVEMENT_ARCADE_4", 100);
if (count == 0)
queueId = QU_HND_TAKE0;
else if (count == 1)
@@ -705,7 +706,7 @@ void Sc04Controller::doStartHand() {
stopQueueCopies(QU_SC4_GOCLOCK);
onMessage("MSG_STOP_MUS", "", nullptr);
g_ngi->_taskManager->deactivateTask("FIND_EXIT_BOTLE_SC4");
- warnOnce("CAchievementsManager::AddActivatingCounter (ACHIEVEMENT_ARCADE_4)");
+ g_ngi->_achievementsManager->addActivatingCounter("ACHIEVEMENT_ARCADE_4", 100, "UNDEF");
getGameLoaderInteractionController()->setActive("INT_019", SC_4, PIC_SC4_MASK, 0.0f, 0.0f);
// CFPController::FlurryArcadeEnd (analytics): not ported
queueId = QU_HND_TAKEBOTTLE;
diff --git a/engines/ngi/fullpipe/sc06controller.cpp b/engines/ngi/fullpipe/sc06controller.cpp
index d06664df4ff..008f6da8e23 100644
--- a/engines/ngi/fullpipe/sc06controller.cpp
+++ b/engines/ngi/fullpipe/sc06controller.cpp
@@ -35,6 +35,7 @@
#include "ngi/statics.h"
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/help.h"
@@ -462,7 +463,7 @@ void Sc06Controller::doStopArcade() {
MessageQueue *queue = new MessageQueue(_scene, true, 1);
queue->addCommandToEnd(pauseCommand(50));
if (_ballsCaught < _numDropsToWin) {
- warnOnce("CAchievementsManager::BlockActivatingCounter ACHIEVEMENT_ARCADE_6 (achievements are not ported)");
+ g_ngi->_achievementsManager->blockActivatingCounter("ACHIEVEMENT_ARCADE_6", 100);
if (takeMovement != 0)
queue->addCommandToEnd(movementCommand(ANI_MAMASHA, takeMovement));
if (_momPos <= 0) {
@@ -480,7 +481,7 @@ void Sc06Controller::doStopArcade() {
queue->addCommandToEnd(queueCommand(QU_MOM_SITDOWN, "QU_MOM_SITDOWN", nullptr));
// CFlurryEventManager lose_count/game_..._lose, FlurryArcadeClean: analytics not ported
} else {
- warnOnce("CAchievementsManager::AddActivatingCounter ACHIEVEMENT_ARCADE_6 (achievements are not ported)");
+ g_ngi->_achievementsManager->addActivatingCounter("ACHIEVEMENT_ARCADE_6", 100, "UNDEF");
g_ngi->setState(sO_BigMumsy, g_ngi->getStateValue(sO_BigMumsy, sO_IsGone));
if (g_ngi->getStateId(sO_ClockAxis) == g_ngi->getStateValue(sO_ClockAxis, sO_IsNotAvailable))
g_ngi->setState(sO_ClockAxis, g_ngi->getStateValue(sO_ClockAxis, sO_WithoutHandle));
diff --git a/engines/ngi/fullpipe/sc08controller.cpp b/engines/ngi/fullpipe/sc08controller.cpp
index cc8d0daa77e..a7d7ab2df9e 100644
--- a/engines/ngi/fullpipe/sc08controller.cpp
+++ b/engines/ngi/fullpipe/sc08controller.cpp
@@ -35,6 +35,7 @@
#include "ngi/statics.h"
#include "ngi/xmlnode.h"
#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/hintmanager.h"
@@ -251,7 +252,7 @@ void Sc08Controller::doStep2() {
_scene->runQueue(QU_SC8_FINISH, 2);
_inAir = false;
if (!_skipped)
- warnOnce("CAchievementsManager::AddActivatingCounter ACHIEVEMENT_ARCADE_8: achievements are not ported");
+ g_ngi->_achievementsManager->addActivatingCounter("ACHIEVEMENT_ARCADE_8", 100, "UNDEF");
g_ngi->arcadeInterface().scrollOut();
}
diff --git a/engines/ngi/fullpipe/sc09controller.cpp b/engines/ngi/fullpipe/sc09controller.cpp
index 7d20cba3142..1eb23e67dca 100644
--- a/engines/ngi/fullpipe/sc09controller.cpp
+++ b/engines/ngi/fullpipe/sc09controller.cpp
@@ -35,6 +35,7 @@
#include "ngi/statics.h"
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/exitmanager.h"
@@ -435,7 +436,7 @@ void Sc09Controller::doStopShoot() {
// CSc09Controller::DoFlyAway (171A98): the gulper has eaten enough, it flies away
void Sc09Controller::doFlyAway() {
g_ngi->arcadeInterface().scrollOut();
- warnOnce("CAchievementsManager::AddActivatingCounter for ACHIEVEMENT_ARCADE_9 is not ported");
+ g_ngi->_achievementsManager->addActivatingCounter("ACHIEVEMENT_ARCADE_9", 100, "UNDEF");
_flyAway = false;
_gulper->stopMovement();
_gulper->moveToStaticChain(ST_GLT_SIT);
diff --git a/engines/ngi/fullpipe/sc11controller.cpp b/engines/ngi/fullpipe/sc11controller.cpp
index d7091cf650a..828a7a2902c 100644
--- a/engines/ngi/fullpipe/sc11controller.cpp
+++ b/engines/ngi/fullpipe/sc11controller.cpp
@@ -38,6 +38,7 @@
#include "ngi/sound.h"
#include "ngi/statics.h"
#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/hintmanager.h"
@@ -676,7 +677,7 @@ void Sc11Controller::onRButtonDown() {
}
if (angle < _minAngle || angle > _maxAngle || _swingSpeed > (double)_minSpeed) {
- warnOnce("CSc11Controller::OnRButtonDown: CAchievementsManager::BlockActivatingCounter for ACHIEVEMENT_ARCADE_11, the achievements are not ported");
+ g_ngi->_achievementsManager->blockActivatingCounter("ACHIEVEMENT_ARCADE_11", 100);
if (angle >= _minAngle || _swingSpeed < (double)_minSpeed) {
doMissTruba((double)(float)(angle / _minAngle) * _swingSpeed / (double)_minSpeed);
} else {
@@ -684,7 +685,7 @@ void Sc11Controller::onRButtonDown() {
}
g_ngi->arcadeInterface().scrollOut();
} else {
- warnOnce("CSc11Controller::OnRButtonDown: CAchievementsManager::AddActivatingCounter for ACHIEVEMENT_ARCADE_11, the achievements are not ported");
+ g_ngi->_achievementsManager->addActivatingCounter("ACHIEVEMENT_ARCADE_11", 100, "UNDEF");
g_ngi->arcadeInterface().incCounter();
doJumpToTruba();
g_ngi->arcadeInterface().incCounter();
diff --git a/engines/ngi/fullpipe/sc14controller.cpp b/engines/ngi/fullpipe/sc14controller.cpp
index 54eb1277967..43549b69c9a 100644
--- a/engines/ngi/fullpipe/sc14controller.cpp
+++ b/engines/ngi/fullpipe/sc14controller.cpp
@@ -34,6 +34,7 @@
#include "ngi/scene.h"
#include "ngi/statics.h"
#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/hintmanager.h"
@@ -403,7 +404,7 @@ bool Sc14Controller::onLButtonUp() {
// CSc14Controller::DoManSurrender (179158): the ball passed the hero at the end, arcade lost
void Sc14Controller::doManSurrender() {
// analytics lose_count_ANI_GRANDMA, game_ANI_GRANDMA_lose, FlurryArcadeClean: not ported
- blockActivatingCounter();
+ g_ngi->_achievementsManager->blockActivatingCounter("ACHIEVEMENT_ARCADE_14", 100);
g_ngi->arcadeInterface().scrollOut();
_arcadeRunning = false;
if (hero()->_movement)
@@ -499,7 +500,7 @@ void Sc14Controller::doGrandmaHit() {
g_ngi->lift().enableButton(sO_Level4, ST_LBN_4N);
g_ngi->lift().initLift(_scene, hero(), QU_SC14_ENTERLIFT, QU_SC14_EXITLIFT);
// CFPController::FlurryArcadeEnd("ANI_GRANDMA"): the analytics event is not ported
- addActivatingCounter();
+ g_ngi->_achievementsManager->addActivatingCounter("ACHIEVEMENT_ARCADE_14", 100, "UNDEF");
hero()->moveToStaticChain(ST_MAN_RIGHT);
hero()->setPosition(Common::Point(1020, 454));
stopDragging();
diff --git a/engines/ngi/fullpipe/sc27controller.cpp b/engines/ngi/fullpipe/sc27controller.cpp
index 6e93321e57a..90588813905 100644
--- a/engines/ngi/fullpipe/sc27controller.cpp
+++ b/engines/ngi/fullpipe/sc27controller.cpp
@@ -35,6 +35,7 @@
#include "ngi/scene.h"
#include "ngi/statics.h"
#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/hintmanager.h"
@@ -538,14 +539,14 @@ void Sc27Controller::onStopAll() {
if (highlighted >= _numBetsToWin) {
if (g_ngi->getStateId(sO_Driver) == g_ngi->getStateValue(sO_Driver, sO_WithSteering)) {
doWin();
- warnOnce("CAchievementsManager::AddActivatingCounter ACHIEVEMENT_ARCADE_27 (CSc27Controller::OnStopAll)");
+ g_ngi->_achievementsManager->addActivatingCounter("ACHIEVEMENT_ARCADE_27", 100, "UNDEF");
switchMaidBack();
return;
}
}
if (_spareBets.empty()) {
doPushButton();
- warnOnce("CAchievementsManager::BlockActivatingCounter ACHIEVEMENT_ARCADE_27 (CSc27Controller::OnStopAll)");
+ g_ngi->_achievementsManager->blockActivatingCounter("ACHIEVEMENT_ARCADE_27", 100);
// Flurry events (analytics) are not ported
switchMaidBack();
return;
diff --git a/engines/ngi/fullpipe/sc29controller.cpp b/engines/ngi/fullpipe/sc29controller.cpp
index 8b6d518c067..c8f51128195 100644
--- a/engines/ngi/fullpipe/sc29controller.cpp
+++ b/engines/ngi/fullpipe/sc29controller.cpp
@@ -36,6 +36,7 @@
#include "ngi/statics.h"
#include "ngi/xmlnode.h"
#include "ngi/fullpipe/arcadeinterface.h"
+#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/hintmanager.h"
@@ -414,7 +415,7 @@ void Sc29Controller::tryEscapeShooters() {
_scene->runQueue(QU_SC29_ESCAPE, 2);
_ass->_flags &= ~4;
g_ngi->arcadeInterface().scrollOut();
- warnOnce("CAchievementsManager::AddActivatingCounter ACHIEVEMENT_ARCADE_29 (CSc29Controller::TryEscapeShooters)");
+ g_ngi->_achievementsManager->addActivatingCounter("ACHIEVEMENT_ARCADE_29", 100, "UNDEF");
// CFPController::FlurryArcadeEnd is not ported
}
g_ngi->_taskManager->deactivateTask("FIND_EXIT_PORTER_SC29");
@@ -494,7 +495,7 @@ void Sc29Controller::doHitMan() {
if (_manX <= 638.0f) {
// the analytics events (lose_count_ANI_PORTER ...) and FlurryArcadeClean are not ported
g_ngi->arcadeInterface().scrollOut();
- warnOnce("CAchievementsManager::BlockActivatingCounter ACHIEVEMENT_ARCADE_29 (CSc29Controller::DoHitMan)");
+ g_ngi->_achievementsManager->blockActivatingCounter("ACHIEVEMENT_ARCADE_29", 100);
queue->addCommandToEnd(movementCommand(man, MV_MAN29_STANDUP_NORM));
queue->addCommandToEnd(messageCommand("MSG_SC29_STOPRIDE", 0, 3));
_manIsRiding = false;
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index b6d35ed6374..15661218454 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -28,6 +28,7 @@
#include "ngi/motion.h"
#include "ngi/input.h"
#include "ngi/behavior.h"
+#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/arcadeinterface.h"
#include "ngi/fullpipe/floaters.h"
#include "ngi/fullpipe/taskmanager.h"
@@ -586,6 +587,8 @@ void NGIEngine::updateSceneLogic(uint32 elapsed) {
}
if (_taskManager)
_taskManager->onUpdate(elapsed);
+ if (_achievementsManager)
+ _achievementsManager->onUpdate(elapsed);
testmode_update(elapsed);
// CInventoryController::OnUpdate runs the arcade interface
if (_arcadeInterface)
diff --git a/engines/ngi/fullpipe/tutorialcontroller.cpp b/engines/ngi/fullpipe/tutorialcontroller.cpp
index ab2a304498b..4c43bafbd72 100644
--- a/engines/ngi/fullpipe/tutorialcontroller.cpp
+++ b/engines/ngi/fullpipe/tutorialcontroller.cpp
@@ -35,6 +35,7 @@
#include "ngi/scene.h"
#include "ngi/statics.h"
#include "ngi/behavior.h"
+#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/inventorycontroller.h"
@@ -349,7 +350,7 @@ void TutorialController::onHide() {
Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
if (tutorial) {
if (tutorial->_id == "TUTORIAL_LAST")
- warning("STUB: CAchievementsManager::AddActivatingCounter ACHIEVEMENT_TUTORIAL: achievements are not ported!");
+ g_ngi->_achievementsManager->addActivatingCounter("ACHIEVEMENT_TUTORIAL", 100, "UNDEF");
if (tutorial->_id == "TUTORIAL_USE_MAP")
g_ngi->_tutorialManager->finishTutorial("EXTRA_TUTORIAL_USE_MAP");
}
diff --git a/engines/ngi/metaengine.cpp b/engines/ngi/metaengine.cpp
index de7a787963b..30b717937d2 100644
--- a/engines/ngi/metaengine.cpp
+++ b/engines/ngi/metaengine.cpp
@@ -27,6 +27,7 @@
#include "graphics/surface.h"
+#include "ngi/achievements_tables.h"
#include "ngi/ngi.h"
#include "ngi/detection.h"
#include "ngi/gameloader.h"
@@ -103,6 +104,10 @@ public:
int getMaximumSaveSlot() const override { return 99; }
+ const Common::AchievementDescriptionList *getAchievementDescriptionList() const override {
+ return NGI::achievementDescriptionList;
+ }
+
Common::Error createInstance(OSystem *syst, Engine **engine, const NGI::NGIGameDescription *desc) const override;
Common::KeymapArray initKeymaps(const char *target) const override;
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index d1805eaae58..3a724d50775 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -28,6 +28,7 @@
#include "common/debug-channels.h"
#include "audio/mixer.h"
+#include "engines/achievements.h"
#include "engines/metaengine.h"
#include "engines/util.h"
#include "graphics/surface.h"
@@ -42,6 +43,7 @@
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/objhelper.h"
#include "ngi/fullpipe/tutorialmanager.h"
#include "ngi/fullpipe/hintmanager.h"
@@ -439,6 +441,9 @@ Common::Error NGIEngine::run() {
if (result.getCode() != Common::kNoError)
return result;
_gameProject = _gameLoader->_gameProject.get();
+ // the achievements of ScummVM stand in for Google Play (CAchievement::AddActivatingCounter)
+ if (_gameVersion >= 201509)
+ AchMan.setActiveDomain(getMetaEngine()->getAchievementsInfo(ConfMan.getActiveDomainName()));
}
// The Android revision shows a wide screen: the 800x600 area stays in the middle, the margins
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 397ae398712..fe353e65748 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -96,6 +96,7 @@ class TutorialManager;
class HintManager;
class Help;
class NoActionLogger;
+class AchievementsManager;
class ObjHelperManager;
class ObjHelperHint;
class ExitManager;
@@ -324,6 +325,8 @@ public:
Common::ScopedPtr<Map> _map;
Common::ScopedPtr<ArcadeInterface> _arcadeInterface;
Common::ScopedPtr<ChapterManager> _chapterManager;
+ /** CSingleton<CAchievementsManager>: the achievements and their banners (achievements.xml) */
+ Common::ScopedPtr<AchievementsManager> _achievementsManager;
/** CNotebookController, owned by its scene (SC_NOTEBOOK) */
Notebook *_notebook = nullptr;
Common::ScopedPtr<AniHandler> _aniHandler;
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index ad501bc7695..7bfecbd66d8 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -52,8 +52,10 @@
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/taskmanager.h"
+#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/objhelper.h"
#include "ngi/fullpipe/tutorialmanager.h"
+#include "ngi/fullpipe/waitscreen.h"
#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/help.h"
#include "ngi/fullpipe/noactionlogger.h"
@@ -1837,6 +1839,9 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
g_ngi->_taskManager->onShow();
g_ngi->_tutorialManager.reset(new TutorialManager);
g_ngi->_tutorialManager->init("data/tutorials.xml");
+ // CAchievementsManager::Init (after CCatalogManager::Init): achievements.xml
+ g_ngi->_achievementsManager.reset(new AchievementsManager);
+ g_ngi->_achievementsManager->init("data/achievements.xml");
createSceneController(SC_TUTORIAL); // CTutorialController
createSceneController(SC_MAINMENU); // CMainMenu
createSceneController(SC_MAP); // CMapWindow
Commit: a5bafce508cd4979f5444bf294c1ca84ec42eac8
https://github.com/scummvm/scummvm/commit/a5bafce508cd4979f5444bf294c1ca84ec42eac8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: The item on the cursor is hidden in the inventory and has a green outline over what it can be used on (CFPController::OnItemInCursor, CheckInvItem)
Changed paths:
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/fpcontroller.h
engines/ngi/fullpipe/sc04controller.cpp
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 0f044f06777..179527016fb 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -824,7 +824,8 @@ bool FPController::onMouseLKeyUp(uint32 id, float x, float y) {
}
// CFPController::OnMessage. Ported: the messages of the lift (CLift), MSG_SET_SAVING (CBaseSettings::SetSaving is a STUB) and the lift part of MSG_RESETDEST.
-// Not ported: the rest of MSG_RESETDEST (the hero's queue), INVENTORY_ITEM_*, INTERACT_*, CHEATER_*, the tutorial and the other messages.
+// Ported: INVENTORY_ITEM_IN_CURSOR / FROM_CURSOR, INTERACT_PRESTART / ENDED. Not ported: the rest of MSG_RESETDEST (the hero's queue), INVENTORY_ITEM_INC / DEC_COUNTER,
+// INTERACT_STARTED, CHEATER_*, the tutorial and the other messages.
void FPController::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
if (message == "MSG_LIFT_CLICKBUTTON") {
g_ngi->lift().onClickButton();
@@ -844,9 +845,112 @@ void FPController::onMessage(const Common::String &message, const Common::String
}
} else if (message == "MSG_RESETDEST") {
g_ngi->lift().onResetDest(queue);
+ } else if (message == "INVENTORY_ITEM_IN_CURSOR") {
+ onItemInCursor(param);
+ } else if (message == "INVENTORY_ITEM_FROM_CURSOR") {
+ onItemFromCursor(param);
+ } else if (message == "INTERACT_PRESTART") {
+ onInteractPrestart();
+ } else if (message == "INTERACT_ENDED") {
+ onInteractEnded(param, queue);
}
}
+// CFPController::OnItemInCursor (149478)
+void FPController::onItemInCursor(const Common::String &itemId) {
+ InventoryItem *item = g_ngi->_inventory->getItemByName(itemId);
+ if (!item)
+ return;
+ item->setState(1);
+ g_ngi->_inventory->renewVisibleItem(item);
+ _itemInCursorId = (uint16)item->_picture->_id;
+}
+
+// CFPController::OnItemFromCursor (149BD8): the item shows again, unless an interaction that started with it is still running (INTERACT_PRESTART).
+// The analytics counter "failcount" (CFlurryEventManager::IncAdditonalParam) is not ported.
+void FPController::onItemFromCursor(const Common::String &itemId) {
+ InventoryItem *item = g_ngi->_inventory->getItemByName(itemId);
+ if (_itemInCursorId != _interactItemId) {
+ if (item)
+ item->setState(0);
+ _itemInCursorId = _interactItemId;
+ }
+ static bool warned = false;
+ if (!warned) {
+ warned = true;
+ warning("STUB/untested: INTERACT_PRESTART and INTERACT_ENDED are not posted by the interactions (CInteract::Run, the end of its queue): the item shows in the bar again as soon as it leaves the cursor");
+ }
+}
+
+// CFPController::OnInteractPrestart (14B500)
+void FPController::onInteractPrestart() {
+ const int id = g_ngi->_inputController->getObjectId();
+ if (!id)
+ return;
+ InventoryItem *item = g_ngi->_inventory->getItem(id);
+ if (!item)
+ return;
+ item->setState(1);
+ g_ngi->_inventory->renewVisibleItem(item);
+ _interactItemId = id;
+}
+
+// CFPController::OnInteractEnded (14BAFC); the analytics event "item found" is not ported
+void FPController::onInteractEnded(const Common::String &interactionId, MessageQueue *queue) {
+ if (_interactItemId) {
+ if (InventoryItem *item = g_ngi->_inventory->getItem(_interactItemId))
+ item->setState(0);
+ _interactItemId = 0;
+ }
+}
+
+// CInteractionController::FindInteractionUnderCursor (106D94): FindInteraction over the objects under the cursor (the lowest z first) with the item that it holds
+bool FPController::hasInteractionUnderCursor() const {
+ CursorController *cursor = g_ngi->_inputController;
+ Scene *scene = g_ngi->getSceneInStack(0);
+ const int heldItem = cursor->getObjectId();
+ for (GameObject *object : cursor->getHitObjects(scene)) {
+ if (canInteractAny(g_ngi->_aniMan, object, heldItem))
+ return true;
+ }
+ return false;
+}
+
+// CFPController::OnRender (14B704)
+void FPController::onRender(Common::Point) {
+ checkInvItem();
+}
+
+// CFPController::CheckInvItem (14B5B8): type 102 means the item of the cursor can be used here
+void FPController::checkInvItem() {
+ CursorController *cursor = g_ngi->_inputController;
+ Scene *current = g_ngi->getCurrentScene();
+ int type = -1;
+ if (current && current->_controller)
+ type = current->_controller->getCursorType(cursor->_hotSceneX, cursor->_hotSceneY);
+ if (type != 102) {
+ _hintedItemId = 0;
+ return;
+ }
+ const uint itemId = cursor->getObjectId();
+ if (!itemId)
+ return;
+ if (itemId != _hintedItemId) {
+ if (Sound *sound = g_ngi->findSound(23131)) // 0x5A5B
+ sound->play(0, 0);
+ _hintedItemId = itemId;
+ }
+ uint32 pictureId;
+ if (!g_ngi->_gameProject->_objectIds.findId(g_ngi->_gameProject->_objectIds.findName(_hintedItemId) + "_H", pictureId))
+ return;
+ Scene *inventoryScene = g_ngi->findScene(SC_INV);
+ PictureObject *outline = inventoryScene ? inventoryScene->findPictureObjectById(pictureId, 0) : nullptr;
+ if (!outline || !cursor->getObject())
+ return;
+ const Common::Point pos = cursor->getObjectPos(*cursor->getObject());
+ outline->renderAtPos(pos.x - 4, pos.y - 4);
+}
+
// CFPController::OnGuiEvent
void FPController::onGuiEvent(const Common::String &id, const Common::String &event) {
if (event == "unpress" && id == "BTN_SKIP_ARCADE") {
@@ -880,9 +984,11 @@ int scaledRandom(int n) {
return product / 0x7FFFFFFF;
}
-// CFPController::GetCursorType (14EAC0): the object helpers (CObjHelperManager::IsHitObjHelper), the cursor of the object under the finger (map +100) and CheckBorders;
-// the cursor is chosen by the input code (D11)
+// CFPController::GetCursorType (14EAC0); only the end: 101 with an item, 102 when usable
int FPController::getCursorType(float x, float y) {
+ // the original's end replaces what the borders and object helpers said before
+ if (g_ngi->_inputController->getObject())
+ return hasInteractionUnderCursor() ? 102 : 101;
static bool reported = false;
if (!reported) {
reported = true;
diff --git a/engines/ngi/fullpipe/fpcontroller.h b/engines/ngi/fullpipe/fpcontroller.h
index f599a2f22a8..f65b6d82570 100644
--- a/engines/ngi/fullpipe/fpcontroller.h
+++ b/engines/ngi/fullpipe/fpcontroller.h
@@ -44,6 +44,8 @@ public:
void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
/** CFPController::OnGuiEvent: BTN_SKIP_ARCADE skips the arcade and hides the button */
void onGuiEvent(const Common::String &id, const Common::String &event) override;
+ /** CFPController::OnRender (14B704): CheckInvItem */
+ void onRender(Common::Point scroll) override;
void onRenderBottom(Common::Point scroll) override;
void onRenderTop(Common::Point scroll) override;
bool onMouseLKeyDown(uint32 id, float x, float y) override;
@@ -72,7 +74,7 @@ public:
virtual bool controllerRunsSceneLogic() const { return false; }
/** CGObject::CleanXml (slot 5): resets the state; not called yet, CGame::CleanXml is not ported */
virtual void cleanXml() {}
- /** CFPController::GetCursorType (14EAC0): the cursor of the scene; not ported (D11), the cursor is chosen by the input code */
+ /** CFPController::GetCursorType (14EAC0): only the item-in-cursor part (D11) */
int getCursorType(float x, float y) override;
/** CScene init: OnSceneInit once before the first OnShow */
void initScene() {
@@ -84,6 +86,20 @@ public:
bool _sceneInitDone = false;
/** +208: ANI_REACT of SC_COMMON (CFPController::OnSceneInit puts it into the scene) */
AniObject *_react = nullptr;
+ /** CFPController::CheckInvItem (14B5B8): the "<item>_H" outline where the cursor item fits */
+ void checkInvItem();
+ /** CInteractionController::FindInteractionUnderCursor (106D94): an interaction of the hero, the item of the cursor and one of the objects under it */
+ bool hasInteractionUnderCursor() const;
+ /** CFPController::OnItemInCursor (149478): the bar item goes to state 1 */
+ void onItemInCursor(const Common::String &itemId);
+ /** INVENTORY_ITEM_FROM_CURSOR (CFPController::OnItemFromCursor, 149BD8) */
+ void onItemFromCursor(const Common::String &itemId);
+ /** CFPController::OnInteractPrestart (14B500), OnInteractEnded (14BAFC) */
+ void onInteractPrestart();
+ void onInteractEnded(const Common::String &interactionId, MessageQueue *queue);
+ uint _hintedItemId = 0; // +196: item whose outline was shown last
+ uint _itemInCursorId = 0; // +200: picture id of the cursor item
+ uint _interactItemId = 0; // +204: item of the running interaction
virtual void updateScroll();
virtual void limitScroll();
virtual void defaultScroll();
diff --git a/engines/ngi/fullpipe/sc04controller.cpp b/engines/ngi/fullpipe/sc04controller.cpp
index 061dc6f6507..57a4f05d67a 100644
--- a/engines/ngi/fullpipe/sc04controller.cpp
+++ b/engines/ngi/fullpipe/sc04controller.cpp
@@ -1792,8 +1792,9 @@ void Sc04Controller::onShow() {
_offsetY = 300;
}
-// CSc04Controller::OnRender: the arcade interface over the scene
-void Sc04Controller::onRender(Common::Point) {
+// CSc04Controller::OnRender: CFPController::OnRender, then the arcade interface over the scene
+void Sc04Controller::onRender(Common::Point scroll) {
+ FPController::onRender(scroll);
g_ngi->arcadeInterface().render();
}
Commit: 8edb096c704112bb05387aacbaf119a747acf549
https://github.com/scummvm/scummvm/commit/8edb096c704112bb05387aacbaf119a747acf549
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: Sc01Controller (CSc01Controller): all methods, MSG_DISABLE_EXIT_MANAGER reaches it through the chapter controller
Changed paths:
engines/ngi/fullpipe/sc01controller.cpp
engines/ngi/fullpipe/sc01controller.h
engines/ngi/fullpipe/scene01.cpp
diff --git a/engines/ngi/fullpipe/sc01controller.cpp b/engines/ngi/fullpipe/sc01controller.cpp
index 7e3238bf827..e7c661a1f8d 100644
--- a/engines/ngi/fullpipe/sc01controller.cpp
+++ b/engines/ngi/fullpipe/sc01controller.cpp
@@ -33,7 +33,9 @@
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/fullpipe/help.h"
#include "ngi/fullpipe/inventorycontroller.h"
+#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc01controller.h"
#include "ngi/fullpipe/scenes.h"
@@ -42,14 +44,76 @@
namespace NGI {
-// CSc01Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera (the rest is in scene01_initScene), and the tutorial
-// that is active when the scene is shown again through the entrance 0 (TUTORIAL_LAST is the one of the way back)
+// CSc01Controller::CSc01Controller (162484)
+Sc01Controller::Sc01Controller(int sceneId) : FPController(sceneId), _tutorial("TUTORIAL_FIRST") {
+}
+
+// CSc01Controller::CleanXml (1623F0)
+void Sc01Controller::cleanXml() {
+ _tutorial = "TUTORIAL_FIRST";
+}
+
+// CSc01Controller::CreateLadder (162510): no caller; the original does not delete the ladder either
+void Sc01Controller::createLadder() {
+ _ladder = new MctlLadder();
+ _ladder->_x = 543;
+ _ladder->_y = 442;
+ _ladder->_z = 10;
+ _ladder->_stepX = 0;
+ _ladder->_stepY = -40;
+ _ladder->_entryOffsetX = 0;
+ _ladder->_entryOffsetY = -60;
+ _ladder->attachObject(hero());
+}
+
+// CSc01Controller::OnUTrubaClick (162574): runs the ladder interaction (PIC_SC1_LADDER)
+void Sc01Controller::onUTrubaClick() {
+ if (!controllerRunsSceneLogic())
+ return;
+ if (!canInterruptManQueue())
+ return;
+ if (_interactObjectId == 0 || _interactObjectId != PIC_SC1_LADDER) {
+ warning("STUB/untested: CSc01Controller::OnUTrubaClick: CInteractionController::FindInteraction(scene, object, -1) and CInteract::Run are not ported (D17)");
+ }
+}
+
+// CSc01Controller::OnShow (1627F8): also done by scene01_initScene until D02
void Sc01Controller::onShow() {
FPController::onShow();
+ if (controllerRunsSceneLogic()) {
+ g_ngi->_help->setChapter(1);
+ g_ngi->_chapterManager->setActiveChapter(1);
+ // the byte +13 of the CBaseSettings of CGame (+112) is cleared when it is set
+ warning("STUB/untested: CSc01Controller::OnShow: the byte +13 of CBaseSettings is not ported (the settings are not ported)");
+ if (!g_ngi->_taskManager->isSceneVisited(_scene->_sceneId)) {
+ g_ngi->_chapterManager->showChapterDialog("CHAPTER_1", true);
+ g_ngi->_taskManager->activateTask("FIND_BOOT_SC4");
+ }
+ g_ngi->_taskManager->visitScene(_scene->_sceneId);
+ }
_marginX = 300;
_marginY = 200;
_offsetX = 400;
_offsetY = 300;
+ if (controllerRunsSceneLogic()) {
+ _field232 = false;
+ _osk = _scene->findPictureObjectById(PIC_SC1_OSK, 0);
+ _osk->_flags &= ~4;
+ _osk2 = _scene->findPictureObjectById(PIC_SC1_OSK2, 0);
+ _osk2->_flags &= ~4;
+ if (PictureObject *heap = _scene->findPictureObjectById(PIC_SC1_KUCHKA, 0)) {
+ if (g_ngi->getStateId(sO_EggCracker) == g_ngi->getStateValue(sO_EggCracker, sO_DidNotCrackEgg))
+ heap->_flags &= ~4;
+ else
+ heap->_flags |= 4;
+ }
+ if (_scene->_currentEntranceId != TrubaLeft) {
+ if (AniObject *boot = _scene->findAniObjectById(ANI_BOOT_1, 0))
+ boot->_flags &= ~4;
+ }
+ // Android button statics, numbered from 23070
+ g_ngi->lift().enableButton(sO_Level2, 23073);
+ }
if (const Tutorial *active = g_ngi->_tutorialManager->findActiveTutorial()) {
if (_scene->_currentEntranceId == 0 && active->_id == "TUTORIAL_LAST")
@@ -121,4 +185,67 @@ void Sc01Controller::checkTutorial() {
checkTutorial();
}
+// CSc01Controller::GetCursorType (162BB8)
+int Sc01Controller::getCursorType(float x, float y) {
+ return FPController::getCursorType(x, y);
+}
+
+// CSc01Controller::OnMessage (162BC0): the rest is CFPController's
+void Sc01Controller::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (message == "MSG_SC1_SHOWOSK") {
+ if (!controllerRunsSceneLogic())
+ return FPController::onMessage(message, param, queue);
+ _osk->_flags |= 4;
+ _osk->_z = 20;
+ _osk2->_z = 21;
+ return;
+ }
+ if (message == "MSG_SC1_SHOWOSK2") {
+ if (!controllerRunsSceneLogic())
+ return FPController::onMessage(message, param, queue);
+ _osk2->_flags |= 4;
+ _osk2->_z = 20;
+ _osk->_z = 21;
+ return;
+ }
+ if (message == "MSG_SC1_UTRUBACLICK") {
+ onUTrubaClick();
+ return;
+ }
+ if (message == "MSG_ENABLE_BHV_SOUND") {
+ _scene->_behaviorController->enableAllMusic();
+ return;
+ }
+ if (message == "MSG_DISABLE_EXIT_MANAGER") {
+ static_cast<InventoryController *>(g_ngi->_inventory->_controller.get())->setHelperVisible(true);
+ for (uint i = 0; i < g_ngi->_exitManager->getNumExits(); i++) {
+ Exit *exit = g_ngi->_exitManager->getExitNum(i);
+ if (exit->getSceneId() == _scene->_sceneId)
+ exit->setState(0);
+ }
+ g_ngi->_inventory->_guiManager->getElement("BTN_SKIP")->showAndActivate();
+ return;
+ }
+ if (message == "MSG_DEACT_OBJ_SC1") {
+ const InventoryItem *blackEgg = g_ngi->_inventory->getItemByName("ANI_INV_EGGBLACK");
+ const InventoryItem *coinEgg = g_ngi->_inventory->getItemByName("ANI_INV_EGGCOIN");
+ if (blackEgg->_counter != 0 || coinEgg->_counter != 0)
+ return;
+ g_ngi->_taskManager->deactivateTask("GET_OBJECT_SC1");
+ return;
+ }
+ FPController::onMessage(message, param, queue);
+}
+
+// CSc01Controller::OnKeyUp (162DC0)
+void Sc01Controller::onKeyUp(uint32 key) {
+ FPController::onKeyUp(key);
+}
+
+// CSc01Controller::OnRender (162DC8)
+void Sc01Controller::onRender(Common::Point scroll) {
+ FPController::onRender(scroll);
+}
+
+
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sc01controller.h b/engines/ngi/fullpipe/sc01controller.h
index 936e7b93c33..f5f3eb14bc5 100644
--- a/engines/ngi/fullpipe/sc01controller.h
+++ b/engines/ngi/fullpipe/sc01controller.h
@@ -26,19 +26,47 @@
namespace NGI {
-/** Android: CSc01Controller. Only the parts that are ported: the camera margins and the tutorials; the rest of the scene logic is in scene01.cpp */
+class MctlLadder;
+class PictureObject;
+
+/** CSc01Controller: the first scene (tutorial, exits, skip button) */
class Sc01Controller : public FPController {
public:
- explicit Sc01Controller(int sceneId) : FPController(sceneId), _tutorial("TUTORIAL_FIRST") {}
+ explicit Sc01Controller(int sceneId);
+
+ void cleanXml() override;
void onShow() override;
void onGuiEvent(const Common::String &id, const Common::String &event) override;
bool isInventoryEnabled() override;
void checkTutorial() override;
+ int getCursorType(float x, float y) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+ void onKeyUp(uint32 key) override;
+ void onRender(Common::Point scroll) override;
+
+ /** CSc01Controller::CreateLadder (162510): no method of the class or of the game calls it */
+ void createLadder();
+ /** CSc01Controller::OnUTrubaClick (162574): runs the ladder interaction */
+ void onUTrubaClick();
private:
/** +216: the next tutorial of the scene, "UNDEF" when there is none */
Common::String _tutorial;
+ PictureObject *_osk = nullptr; // +220: PIC_SC1_OSK, shown by MSG_SC1_SHOWOSK
+ PictureObject *_osk2 = nullptr; // +224: PIC_SC1_OSK2
+ MctlLadder *_ladder = nullptr; // +228: made by CreateLadder, not deleted by the original
+ bool _field232 = false; // +232: cleared by the constructor and OnShow, never read
+protected:
+ // +236 .. +248: the constructor sets them (491, 214, 591, 441), no method of the class reads them
+ float _zoneLeft = 491;
+ float _zoneTop = 214;
+ float _zoneRight = 591;
+ float _zoneBottom = 441;
+ int _field252 = 0; // +252
+ int _field256 = 0; // +256
+
+private:
/** CFindQueue(QU_SC1_ENTER)->+56 != -1: the queue of the entrance runs */
bool isEntranceQueueRunning() const;
};
diff --git a/engines/ngi/fullpipe/scene01.cpp b/engines/ngi/fullpipe/scene01.cpp
index 195b4884d63..91a78f26bd1 100644
--- a/engines/ngi/fullpipe/scene01.cpp
+++ b/engines/ngi/fullpipe/scene01.cpp
@@ -103,30 +103,9 @@ int sceneHandler01(Command *cmd) {
// a named message goes to the scene on top of the stack (CMessageQueue::ExecuteCmdMsg)
if (g_ngi->getCurrentScene() != g_ngi->_currentScene)
return 0;
- if (cmd->_messageName == "MSG_ENABLE_BHV_SOUND") {
- if (g_ngi->_currentScene->_behaviorController)
- g_ngi->_currentScene->_behaviorController->enableAllMusic();
+ // CSc01Controller::OnMessage handles these (the chapter dialog passes it to the scene below)
+ if (cmd->_messageName == "MSG_ENABLE_BHV_SOUND" || cmd->_messageName == "MSG_DISABLE_EXIT_MANAGER" || cmd->_messageName == "MSG_DEACT_OBJ_SC1")
return 0;
- }
- if (cmd->_messageName == "MSG_DISABLE_EXIT_MANAGER") {
- // CSc01Controller::OnMessage: the helper of the inventory, the exits of the scene are hidden, the skip button shows
- static_cast<InventoryController *>(g_ngi->_inventory->_controller.get())->setHelperVisible(true);
- for (uint i = 0; i < g_ngi->_exitManager->getNumExits(); i++) {
- Exit *exit = g_ngi->_exitManager->getExitNum(i);
- if (exit->getSceneId() == g_ngi->_currentScene->_sceneId)
- exit->setState(0);
- }
- if (GuiElement *skip = g_ngi->_inventory->_guiManager->getElement("BTN_SKIP"))
- skip->showAndActivate();
- return 0;
- }
- if (cmd->_messageName == "MSG_DEACT_OBJ_SC1") {
- const InventoryItem *blackEgg = g_ngi->_inventory->getItemByName("ANI_INV_EGGBLACK");
- const InventoryItem *coinEgg = g_ngi->_inventory->getItemByName("ANI_INV_EGGCOIN");
- if (blackEgg && coinEgg && !blackEgg->_counter && !coinEgg->_counter)
- g_ngi->_taskManager->deactivateTask("GET_OBJECT_SC1");
- return 0;
- }
if (!cmd->_messageNum) {
warning("STUB: %s", cmd->_messageName.c_str());
return 0;
Commit: 6ffb3813703965846671396b4b5f07baee1772f7
https://github.com/scummvm/scummvm/commit/6ffb3813703965846671396b4b5f07baee1772f7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: Sc02Controller (CSc02Controller): all methods
Changed paths:
engines/ngi/fullpipe/sc02controller.cpp
engines/ngi/fullpipe/sc02controller.h
diff --git a/engines/ngi/fullpipe/sc02controller.cpp b/engines/ngi/fullpipe/sc02controller.cpp
index 27310d51430..971d55a97d4 100644
--- a/engines/ngi/fullpipe/sc02controller.cpp
+++ b/engines/ngi/fullpipe/sc02controller.cpp
@@ -32,6 +32,7 @@
#include "ngi/statics.h"
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/inventorycontroller.h"
#include "ngi/fullpipe/objectnames.h"
@@ -42,47 +43,168 @@
namespace NGI {
-// CSc02Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera, the tutorial of the egg (the one of the ladder is over)
+// CSc02Controller::CSc02Controller (162E38): the tutorial stays empty until OnShow or CleanXml
+Sc02Controller::Sc02Controller(int sceneId) : FPController(sceneId), _flyPack(new FlyPack()) {
+}
+
+// CSc02Controller::CleanXml (162DD0)
+void Sc02Controller::cleanXml() {
+ _tutorial = "TUTORIAL_DO_EGG";
+}
+
+// CSc02Controller::OnHideLadder (162EA8)
+void Sc02Controller::onHideLadder() {
+ _scene->findPictureObjectById(PIC_SC2_LADDER, 0)->_flags &= ~4;
+ hero()->_z = 25;
+}
+
+// CSc02Controller::OnShowLadder (162ECC)
+void Sc02Controller::onShowLadder() {
+ _scene->findPictureObjectById(PIC_SC2_LADDER, 0)->_flags |= 4;
+}
+
+// CSc02Controller::IsInventoryEnabled (162EE4): CTutorialManager::IsTutorialCompleted
+bool Sc02Controller::isInventoryEnabled() {
+ return g_ngi->_tutorialManager->isTutorialCompleted();
+}
+
+// CSc02Controller::OnClickLadder (163168): when the hero can take a new queue and the interaction under the cursor is not the one of the lower pipe, the
+// interaction of the lower pipe (CInteractionController::FindInteraction(scene, PIC_SC2_DTRUBA, -1)) runs (CInteract::Run). Not ported: running an interaction by
+// its object (the engine starts them through handleObjectInteraction by the tap)
+void Sc02Controller::onClickLadder() {
+ if (!canInterruptManQueue())
+ return;
+ if (_interactObjectId == 0 || _interactObjectId != PIC_SC2_DTRUBA)
+ warnOnce("CSc02Controller::OnClickLadder: CInteractionController::FindInteraction(scene, PIC_SC2_DTRUBA, -1) and CInteract::Run are not ported");
+}
+
+// CSc02Controller::OnShow (1631A0): after CFPController::OnShow the scene is visited, the margins and offsets of the camera, the sleeping Guv the Drawer lies, the
+// ladder shows, the box opens after a time when it is closed, the flies of the scene (SC_2) are made; the tutorial of the egg is next (the one of the ladder is over).
+// Scene logic that sceneHandler02 does too (scene02_initScene) waits for controllerRunsSceneLogic().
void Sc02Controller::onShow() {
FPController::onShow();
+ const bool sceneLogic = controllerRunsSceneLogic();
+ if (sceneLogic)
+ g_ngi->_taskManager->visitScene(_scene->_sceneId);
_marginX = 300;
_marginY = 200;
_offsetX = 400;
_offsetY = 300;
+ _guvTheDrawer = _scene->findAniObjectById(ANI_DADAYASHIK, 0);
+ if (sceneLogic) {
+ if (g_ngi->getStateId(sO_GuvTheDrawer) == g_ngi->getStateValue(sO_GuvTheDrawer, sO_IsSleeping))
+ _guvTheDrawer->setStatic(ST_DYAS_LIES);
+ _scene->findPictureObjectById(PIC_SC2_LADDER, 0)->_flags |= 4;
+ _boxDelay = 0;
+ AniObject *box = _scene->findAniObjectById(ANI_SC2_BOX, 0);
+ if (box && (box->_flags & 4)) {
+ _boxOpen = false;
+ } else {
+ _boxOpen = true;
+ _boxDelay = scaledRandom(8300) + 12450;
+ }
+ _flyPack->init(g_ngi->getGameLoaderGameVar()->getSubVarByName("SC_2"));
+ }
_eggInteracting = false;
_tutorial = "TUTORIAL_DO_EGG";
g_ngi->_tutorialManager->findTutorial("TUTORIAL_USE_LADDER")->setState(4);
}
-// CSc02Controller::OnHide
+// CSc02Controller::OnHide (16335C)
void Sc02Controller::onHide() {
+ _flyPack->deleteAllFlies();
+ _boxOpen = false;
FPController::onHide();
_eggInteracting = false;
}
-// CSc02Controller::OnMessage: the end of the egg interaction (the other messages are in the scene handler, sceneHandler02)
+// CSc02Controller::GetCursorType (16337E): the one of CFPController
+int Sc02Controller::getCursorType(float x, float y) {
+ return FPController::getCursorType(x, y);
+}
+
+// CSc02Controller::OnUpdate (163388): the box lets a fly out, takes it back later; the flies move
+void Sc02Controller::onUpdate(uint32 elapsed) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onUpdate(elapsed);
+ return;
+ }
+ FPController::onUpdate(elapsed);
+ if (_boxOpen) {
+ if (_boxDelay > 0) {
+ _boxDelay -= elapsed;
+ _flyPack->onUpdate(elapsed);
+ return;
+ }
+ if (_flyPack->_flies.size() > 0) {
+ GutlFly &fly = _flyPack->_flies[0];
+ if (fly.y != -50) {
+ fly.targetY = -50;
+ _flyPack->onUpdate(elapsed);
+ return;
+ }
+ _flyPack->deleteAllFlies();
+ _boxOpen = false;
+ _boxDelay = scaledRandom(8300) + 12450;
+ } else {
+ _flyPack->addFly(_scene, scaledRandom(700) + 100, -50, 0, 0);
+ _boxDelay = scaledRandom(41500) + 83000;
+ }
+ }
+ _flyPack->onUpdate(elapsed);
+}
+
+// CSc02Controller::OnMessage (163450): ladder, man put up (MSG_SC2_PUTMANUP: z 0), grit
+// (INT_277_1), egg end; ladder and man are also in sceneHandler02 (guarded the same way)
void Sc02Controller::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
- if (message == "MSG_SC2_END_INTER")
+ if (message == "MSG_SC2_END_INTER") {
_eggInteracting = false;
- else
+ return;
+ }
+ if (!controllerRunsSceneLogic()) {
FPController::onMessage(message, param, queue);
+ return;
+ }
+ if (message == "MSG_SC2_HIDELADDER") {
+ onHideLadder();
+ } else if (message == "MSG_SC2_SHOWLADDER") {
+ onShowLadder();
+ } else if (message == "MSG_SC2_PUTMANUP") {
+ hero()->_z = 0;
+ } else if (message == "MSG_SC2_LADDERCLICK") {
+ onClickLadder();
+ } else if (message == "MSG_BREAK_GRIT") {
+ if (interactionCommandNum("INT_277_1") != -1) {
+ AniObject *grit = _scene->findAniObjectById(ANI_GRIT1, 0);
+ if (grit->_movement)
+ grit->setCurFrame(7, true);
+ else
+ grit->startMovement(MV_GRIT1_FALL, 0, -1);
+ }
+ } else {
+ FPController::onMessage(message, param, queue);
+ }
}
-// CSc02Controller::OnMouseLKeyUp: while the egg interaction INT_418 runs the touches are ignored, and after the tutorial of the egg the touch
-// goes nowhere. Not ported: CInteractionController::FindInteractionUnderCursor (the interaction INT_418 never starts the flag here)
+// CSc02Controller::OnMouseLKeyUp (1635A8): while the egg interaction INT_418 runs the touches are ignored (it starts when the interaction under the cursor is
+// INT_418), and after the tutorial of the egg the touch goes nowhere. Not ported: CInteractionController::FindInteractionUnderCursor (the interaction INT_418
+// never starts the flag here)
bool Sc02Controller::onMouseLKeyUp(uint32 id, float x, float y) {
- static bool reported = false;
- if (!reported) {
- reported = true;
- warning("STUB/untested: CSc02Controller::OnMouseLKeyUp: CInteractionController::FindInteractionUnderCursor (INT_418) is not ported");
- }
+ Interact *underCursor = NGI::findInteractionUnderCursor();
if (_eggInteracting)
return true;
+ if (underCursor && underCursor->_actionName == "INT_418")
+ _eggInteracting = true;
if (_tutorial == "AFTER_TUTORIAL_DO_EGG")
return true;
return FPController::onMouseLKeyUp(id, x, y);
}
+// CSc02Controller::OnKeyUp (163628): the one of CFPController
+void Sc02Controller::onKeyUp(uint32 key) {
+ FPController::onKeyUp(key);
+}
+
// CSc02Controller::CheckTutorial (162F24): the egg tutorial (DO_EGG), then the map one
void Sc02Controller::checkTutorial() {
TutorialManager *manager = g_ngi->_tutorialManager.get();
diff --git a/engines/ngi/fullpipe/sc02controller.h b/engines/ngi/fullpipe/sc02controller.h
index bde7bdba5bb..c7e8bd22c1c 100644
--- a/engines/ngi/fullpipe/sc02controller.h
+++ b/engines/ngi/fullpipe/sc02controller.h
@@ -22,23 +22,51 @@
#ifndef NGI_FULLPIPE_SC02CONTROLLER_H
#define NGI_FULLPIPE_SC02CONTROLLER_H
+#include "common/ptr.h"
+#include "common/str.h"
+
+#include "ngi/fullpipe/floaters.h"
#include "ngi/fullpipe/fpcontroller.h"
namespace NGI {
-/** Android: CSc02Controller. Only the parts that are ported: the camera margins and the tutorials, OnMessage and OnMouseLKeyUp (the egg); the rest of the scene logic is in scene02.cpp */
+/**
+ * Android: CSc02Controller. The tutorials, the camera margins, the constructor, CleanXml, IsInventoryEnabled and the helpers are active; OnShow beyond the
+ * margins and the tutorial, OnUpdate, OnMessage and the touch are ported but wait for controllerRunsSceneLogic() (the scene runs with sceneHandler02 of
+ * scene02.cpp until D02).
+ */
class Sc02Controller : public FPController {
public:
- explicit Sc02Controller(int sceneId) : FPController(sceneId) {}
+ explicit Sc02Controller(int sceneId);
+ void cleanXml() override;
void onShow() override;
void onHide() override;
+ int getCursorType(float x, float y) override;
+ void onUpdate(uint32 elapsed) override;
void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ void onKeyUp(uint32 key) override;
+ bool isInventoryEnabled() override;
void checkTutorial() override;
+ /** CSc02Controller::OnHideLadder (162EA8) for MSG_SC2_HIDELADDER: ladder hidden, hero z 25 */
+ void onHideLadder();
+ /** CSc02Controller::OnShowLadder (162ECC) for MSG_SC2_SHOWLADDER */
+ void onShowLadder();
+ /** CSc02Controller::OnClickLadder (163168) for MSG_SC2_LADDERCLICK: lower pipe interaction */
+ void onClickLadder();
+
private:
- /** +216: the next tutorial of the scene, set to TUTORIAL_DO_EGG by OnShow */
+ /** +216: the next tutorial of the scene, TUTORIAL_DO_EGG after OnShow and CleanXml */
Common::String _tutorial;
+ /** +220: ANI_DADAYASHIK of the scene */
+ AniObject *_guvTheDrawer = nullptr;
+ /** +224: the flies that come out of the box */
+ Common::ScopedPtr<FlyPack> _flyPack;
+ /** +228: the box is open (a fly may come out) */
+ bool _boxOpen = false;
+ /** +232: the time in ms until the next fly comes or goes */
+ int _boxDelay = 0;
/** +236: the egg interaction INT_418 was started and has not ended (MSG_SC2_END_INTER) */
bool _eggInteracting = false;
};
Commit: 7b0191d1131000618b357430b57f51052a379e7f
https://github.com/scummvm/scummvm/commit/7b0191d1131000618b357430b57f51052a379e7f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: Sc03Controller (CSc03Controller): all methods
Changed paths:
engines/ngi/fullpipe/constants.h
engines/ngi/fullpipe/sc03controller.cpp
engines/ngi/fullpipe/sc03controller.h
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index ec9de74900b..af6137ff49e 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -1905,4 +1905,8 @@ namespace NGI {
#define SC_CONFIRMATION 23496
#define SC_OPTIONS 10009
+// Android: names of obj.h that the ported controllers use
+#define QU_EGTR_FATASK 5334
+#define PIC_SC3_CLOUD_1 23509
+
#endif /* NGI_CONSTANTS_H */
diff --git a/engines/ngi/fullpipe/sc03controller.cpp b/engines/ngi/fullpipe/sc03controller.cpp
index 071dd238870..7f7fd8a1533 100644
--- a/engines/ngi/fullpipe/sc03controller.cpp
+++ b/engines/ngi/fullpipe/sc03controller.cpp
@@ -22,6 +22,7 @@
#include "ngi/ngi.h"
#include "ngi/behavior.h"
#include "ngi/font.h"
+#include "ngi/gameloader.h"
#include "ngi/gfx.h"
#include "ngi/guimanager.h"
#include "ngi/input.h"
@@ -33,8 +34,10 @@
#include "ngi/statics.h"
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/inventorycontroller.h"
+#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/objectnames.h"
#include "ngi/fullpipe/sc03controller.h"
#include "ngi/fullpipe/scenes.h"
@@ -43,14 +46,58 @@
namespace NGI {
-// CSc03Controller::OnShow: after CFPController::OnShow the margins and offsets of the camera (the rest is in scene03_initScene)
+// CSc03Controller::CSc03Controller (163678): the first tutorial of the scene, no hint
+Sc03Controller::Sc03Controller(int sceneId) : FPController(sceneId), _tutorial("TUTORIAL_MAKE_TASK_BOOT") {
+}
+
+// CSc03Controller::CleanXml (163D18)
+void Sc03Controller::cleanXml() {
+ _tutorial = "TUTORIAL_MAKE_TASK_BOOT";
+ resetEggs();
+}
+
+// CStateManager::GetObjStatePtr("ÐÑоглоÑеннÑе ÑйÑа") and the three eggs' logic states (ENUMSTATES)
+void Sc03Controller::findEggStates() {
+ GameVar *object = g_ngi->getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->getSubVarByName(sO_GulpedEggs);
+ GameVar *states = object->getSubVarByName("ENUMSTATES");
+ _egg1 = states->getSubVarByName(sO_Egg1);
+ _egg2 = states->getSubVarByName(sO_Egg2);
+ _egg3 = states->getSubVarByName(sO_Egg3);
+}
+
+// CSc03Controller::ResetEggs (163C40)
+void Sc03Controller::resetEggs() {
+ findEggStates();
+ _egg1->_value.intValue = 0;
+ _egg2->_value.intValue = 0;
+ _egg3->_value.intValue = 0;
+}
+
+// CSc03Controller::OnSceneInit (16427C): the font of the hint
+void Sc03Controller::onSceneInit() {
+ FPController::onSceneInit();
+ _font = g_ngi->getFont("task_dlg_19.fnt");
+}
+
+// CSc03Controller::OnShow (164300): after the base: tasks visited, margins and offsets, objects and
+// swallowed-egg states found, lift set up (the Windows-derived code does it in scene03_initScene)
void Sc03Controller::onShow() {
FPController::onShow();
+ if (controllerRunsSceneLogic())
+ g_ngi->_taskManager->visitScene(_scene->_sceneId);
_marginX = 300;
_marginY = 200;
_offsetX = 400;
_offsetY = 300;
_boot = _scene->findAniObjectById(ANI_SC4_BOOT, 0);
+ _eggeater = _scene->findAniObjectById(ANI_EGGEATER, 0);
+ _hintTime = -1;
+ _hintText.clear();
+ findEggStates();
+ if (!controllerRunsSceneLogic())
+ return;
+ g_ngi->lift().enableButton(sO_Level2, 23073);
+ g_ngi->lift().initLift(_scene, hero(), QU_SC3_ENTERLIFT, QU_SC3_EXITLIFT);
}
// CSc03Controller::IsInventoryEnabled: CTutorialManager::IsTutorialCompleted
@@ -58,6 +105,45 @@ bool Sc03Controller::isInventoryEnabled() {
return g_ngi->_tutorialManager->isTutorialCompleted();
}
+// CSc03Controller::OnUpdate (164764): hint timer runs while the tutorials are over, up to 4 s
+void Sc03Controller::onUpdate(uint32 elapsed) {
+ FPController::onUpdate(elapsed);
+ if (!controllerRunsSceneLogic())
+ return;
+ if (_hintTime != -1 && g_ngi->_tutorialManager->isTutorialCompleted()) {
+ const uint32 time = elapsed + _hintTime;
+ if (time <= 3999)
+ _hintTime = time;
+ else
+ _hintTime = -1;
+ }
+}
+
+// CSc03Controller::OnRender (16479C): a text cloud at a fixed place (the hint is kept in
+// scene03_showEatenHint while the Windows-derived code runs the scene)
+void Sc03Controller::onRender(Common::Point scroll) {
+ FPController::onRender(scroll);
+ const bool own = controllerRunsSceneLogic();
+ const int time = own ? _hintTime : g_vars->scene03_hintTimer;
+ const BitmapFont *font = own ? _font : g_vars->scene03_hintFont;
+ const Common::String &text = own ? _hintText : g_vars->scene03_hintText;
+ if (time <= 0 || !font)
+ return;
+
+ if (PictureObject *cloud = _scene->findPictureObjectById(PIC_SC3_CLOUD_1, 0))
+ cloud->_picture->blitTo(g_ngi->_backgroundSurface, Common::Point(500, 200));
+ font->drawCentered(g_ngi->_backgroundSurface, Common::Rect(520, 215, 520 + 113, 215 + 71), text);
+}
+
+// CSc03Controller::GetCursorType (164474): the lift buttons have their own cursor
+int Sc03Controller::getCursorType(float x, float y) {
+ if (!controllerRunsSceneLogic())
+ return FPController::getCursorType(x, y);
+ if (g_ngi->lift().getCursorType(x, y))
+ return 116;
+ return FPController::getCursorType(x, y);
+}
+
// CSc03Controller::OnMouseLKeyDown and OnMouseLKeyUp (1644A0, 164518): after the tutorial of the ladder or of the egg the touch goes nowhere, and
// after the tutorial of the boot only a touch on the boot counts. Then the base class, then CLift::OnButtonDown / OnButtonUp (they stay in
// FPController::onTap and the lift code of the scene, D02/D17).
@@ -80,7 +166,166 @@ bool Sc03Controller::onMouseLKeyUp(uint32 id, float x, float y) {
}
bool Sc03Controller::hasEggBootOrEaten() const {
- return g_ngi->_inventory->getItemByName("ANI_INV_EGGBOOT")->_counter > 0 || g_vars->swallowedEgg1->_value.intValue != 0;
+ return g_ngi->_inventory->getItemByName("ANI_INV_EGGBOOT")->_counter > 0 || (_egg1 && _egg1->_value.intValue != 0);
+}
+
+// CSc03Controller::OnUTrubaClick (163704): hero goes to the ladder unless already on his way
+void Sc03Controller::onUTrubaClick() {
+ if (!canInterruptManQueue())
+ return;
+ if (_interactObjectId == PIC_SC3_LADDER)
+ return;
+ // CInteractionController::FindInteraction(scene, PIC_SC3_LADDER, -1) and CInteract::Run are done by handleObjectInteraction of the Windows-derived engine
+ warnOnce("CSc03Controller::OnUTrubaClick: the interaction with the ladder is run by handleObjectInteraction (CInteractionController::FindInteraction, CInteract::Run) (D17)");
+ handleObjectInteraction(hero(), _scene->findPictureObjectById(PIC_SC3_LADDER, 0), 0);
+}
+
+// CSc03Controller::GetFirstEaten (163768)
+int Sc03Controller::getFirstEaten() const {
+ return _egg1->_value.intValue;
+}
+
+// CSc03Controller::RemoveFirstEaten (163770): eggs move up; the apple egg stays behind the boot egg
+int Sc03Controller::removeFirstEaten() {
+ _egg1->_value.intValue = _egg2->_value.intValue;
+ _egg2->_value.intValue = _egg3->_value.intValue;
+ _egg3->_value.intValue = 0;
+ const int second = _egg2->_value.intValue;
+ if (second == ANI_INV_EGGBOOT && _egg1->_value.intValue == ANI_INV_EGGAPL) {
+ _egg1->_value.intValue = ANI_INV_EGGBOOT;
+ _egg2->_value.intValue = ANI_INV_EGGAPL;
+ }
+ return second;
+}
+
+// CSc03Controller::PrepareReleaseEgg (1637B8): the egg eater shows
+void Sc03Controller::prepareReleaseEgg() {
+ _eggeater->_flags |= 4;
+}
+
+// CSc03Controller::DoTestFat (1637C8): with an egg in him the first two commands are movements
+void Sc03Controller::doTestFat(MessageQueue *queue) {
+ if (!queue || !queue->getCount())
+ return;
+ Command *first = queue->getCommandByIndex(0);
+ Command *second = queue->getCommandByIndex(1);
+ if (getFirstEaten()) {
+ first->_cmd = kCmdStartMovement;
+ second->_cmd = kCmdStartMovement;
+ // the original passes 1 to CInventory::RemoveItem (the Windows-derived code passes -1)
+ g_ngi->_inventory->removeItem("ANI_INV_COIN", 1);
+ } else {
+ // the engine queue goes on through a none command only with flag 1 (Command::handleMessage)
+ first->_cmd = kCmdNone;
+ first->_excFlags |= 1;
+ second->_cmd = kCmdNone;
+ second->_excFlags |= 1;
+ }
+}
+
+// CSc03Controller::UpdateBehavior (163B9C): after the coin the thin and fat egg queues are disabled
+void Sc03Controller::updateBehavior() {
+ if (g_ngi->getStateId(sO_EggGulperGaveCoin) != g_ngi->getStateValue(sO_EggGulperGaveCoin, sO_Yes))
+ return;
+ BehaviorController *behavior = _scene->_behaviorController.get();
+ behavior->enableMoves(_eggeater, QU_EGTR_SLIMSHOW, false);
+ behavior->enableMoves(_eggeater, QU_EGTR_MD1_SHOW, false);
+ behavior->enableMoves(_eggeater, QU_EGTR_MD2_SHOW, false);
+}
+
+// CSc03Controller::DoTakeEgg (163D34): the command behind the message gets the first swallowed egg,
+// the next one the egg eater state (GetCurCommandNum + 1, + 2 are the first two commands left)
+void Sc03Controller::doTakeEgg(MessageQueue *queue) {
+ if (!queue || !queue->getCount())
+ return;
+ warnOnce("CMessageQueue::GetCurCommandNum (the queue of the engine drops the commands that ran): DoTakeEgg takes the first two commands of the queue");
+ Command *take = queue->getCommandByIndex(0);
+ const int firstEaten = getFirstEaten();
+ Command *state = queue->getCommandByIndex(1);
+ if (firstEaten && take) {
+ take->_parentId = firstEaten; // CCommand::SetParamString("id", item name)
+ removeFirstEaten();
+ if (firstEaten == ANI_INV_EGGGLS)
+ g_ngi->setState(sO_Hint_2_03, 0);
+ }
+ if (_egg1->_value.intValue == ANI_INV_EGGAPL && !_egg2->_value.intValue && !_egg3->_value.intValue && state) {
+ const int value = g_ngi->getStateValue(sO_EggGulper, sO_WantsNothing);
+ if (state->_objtype == kObjTypeObjstateCommand)
+ static_cast<ObjstateCommand *>(state)->_value = value;
+ else if (state->_cmd == kCmdSetLogic)
+ state->_messageNum = value; // the XML SET_LOGIC command keeps the state in the message number
+ }
+}
+
+// CSc03Controller::OnTakeCoin (163E6C): egg eater wants nothing more, coin queue stops, tasks go on
+void Sc03Controller::onTakeCoin() {
+ g_ngi->setState(sO_EggGulper, g_ngi->getStateValue(sO_EggGulper, sO_WantsNothing));
+ _scene->_behaviorController->enableMoves(_eggeater, QU_EGTR_FATASK, false);
+ g_ngi->_taskManager->deactivateTask("FIND_COIN_SC3");
+ g_ngi->_taskManager->activateTask("FIND_EXIT_BOTLE_SC4");
+}
+
+// CSc03Controller::AddLastEaten (163F2C): next swallowed egg; the 1st and 2nd show the hint, the
+// 3rd makes the egg eater give the coin (analytics not ported)
+void Sc03Controller::addLastEaten(const Common::String &item) {
+ uint32 id = 0;
+ g_ngi->_gameProject->_objectIds.findId(item, id);
+ if (!_egg1->_value.intValue) {
+ _egg1->_value.intValue = id;
+ _hintTime = 0;
+ _hintText = g_ngi->_textContainer->getText("STR_SC3_GIVE_ONE_EGG");
+ warnOnce("CFlurryEventManager::Event 1st_egg_complete (the analytics events are not ported)");
+ } else if (!_egg2->_value.intValue) {
+ _egg2->_value.intValue = id;
+ _hintTime = 0;
+ _hintText = g_ngi->_textContainer->getText("STR_SC3_GIVE_TWO_EGG");
+ warnOnce("CFlurryEventManager::Event 2nd_egg_complete (the analytics events are not ported)");
+ } else if (!_egg3->_value.intValue) {
+ _egg3->_value.intValue = id;
+ warnOnce("CFlurryEventManager::Event 3rd_egg_complete (the analytics events are not ported)");
+ g_ngi->setState(sO_EggGulperGaveCoin, g_ngi->getStateValue(sO_EggGulperGaveCoin, sO_Yes));
+ updateBehavior();
+ }
+}
+
+// CSc03Controller::OnInvDrop (1641F8): an egg that left the inventory (the egg eater swallowed it)
+void Sc03Controller::onInvDrop(const Common::String &item) {
+ if (item == "ANI_INV_EGGAPL" || item == "ANI_INV_EGGDOM" || item == "ANI_INV_EGGCOIN" || item == "ANI_INV_EGGBOOT" || item == "ANI_INV_EGGGLS")
+ addLastEaten(item);
+}
+
+// CSc03Controller::OnMessage (164590): all but the last two messages are sceneHandler03 logic
+void Sc03Controller::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (!controllerRunsSceneLogic()) {
+ FPController::onMessage(message, param, queue);
+ return;
+ }
+ if (message == "MSG_SC3_UTRUBACLICK") {
+ onUTrubaClick();
+ } else if (message == "MSG_SC3_TESTFAT") {
+ doTestFat(queue);
+ } else if (message == "MSG_SC3_TAKEEGG") {
+ doTakeEgg(queue);
+ } else if (message == "MSG_SC3_RELEASEEGG") {
+ prepareReleaseEgg();
+ } else if (message == "MSG_SC3_ONTAKECOIN") {
+ onTakeCoin();
+ } else if (message == "INVENTORY_ITEM_DEC_COUNTER") {
+ const InventoryItem *item = g_ngi->_inventory->getItemByName(param);
+ if (item && item->_counter == 0)
+ onInvDrop(param);
+ FPController::onMessage(message, param, queue);
+ } else if (message == "MSG_SC3_MOVEEGGEATER") {
+ _eggeater->setPos(609, 424);
+ _eggeater->_z = 60;
+ } else if (message == "MSG_SC4_HIDEBOOT") {
+ _boot->_flags &= ~4;
+ } else if (message == "MSG_HIDE_BOX") {
+ if (AniObject *box = _scene->findAniObjectById(ANI_SC2_BOX, 0))
+ box->_flags &= ~4;
+ } else {
+ FPController::onMessage(message, param, queue);
+ }
}
// CSc03Controller::CheckTutorial (163834): MAKE_TASK_BOOT, SEE_INVENTORY, USE_LADDER,
@@ -128,14 +373,4 @@ void Sc03Controller::checkTutorial() {
checkTutorial();
}
-// CSc03Controller::OnRender: a cloud with the text at a fixed place of the screen
-void Sc03Controller::onRender(Common::Point) {
- if (g_vars->scene03_hintTimer <= 0 || !g_vars->scene03_hintFont)
- return;
-
- if (PictureObject *cloud = _scene->findPictureObjectById(23509, 0)) // 0x5BD5
- cloud->_picture->blitTo(g_ngi->_backgroundSurface, Common::Point(500, 200));
- g_vars->scene03_hintFont->drawCentered(g_ngi->_backgroundSurface, Common::Rect(520, 215, 520 + 113, 215 + 71), g_vars->scene03_hintText);
-}
-
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/sc03controller.h b/engines/ngi/fullpipe/sc03controller.h
index 0e50b459fb9..f06545a5905 100644
--- a/engines/ngi/fullpipe/sc03controller.h
+++ b/engines/ngi/fullpipe/sc03controller.h
@@ -27,29 +27,70 @@
namespace NGI {
class AniObject;
+class BitmapFont;
+class Command;
+class GameVar;
+class MessageQueue;
-/** Android: CSc03Controller. Only the parts that are ported: OnShow (the camera margins), OnRender (the hint over the scene) and the tutorials */
+/**
+ * Android: CSc03Controller (the egg eater: the eggs that it swallowed, the coin, the hint over the scene). Every method is ported; the constructor, CleanXml,
+ * CheckTutorial, the touch blocks of the tutorials, the camera margins and the objects that OnShow finds are active, the rest only runs when
+ * controllerRunsSceneLogic() is true (the sceneHandler03 code of the Windows engine does it until then).
+ */
class Sc03Controller : public FPController {
public:
- explicit Sc03Controller(int sceneId) : FPController(sceneId), _tutorial("TUTORIAL_MAKE_TASK_BOOT") {}
+ explicit Sc03Controller(int sceneId);
+ void cleanXml() override;
+ void checkTutorial() override;
+ void onSceneInit() override;
void onShow() override;
+ void onUpdate(uint32 elapsed) override;
void onRender(Common::Point scroll) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+ int getCursorType(float x, float y) override;
bool isInventoryEnabled() override;
bool onMouseLKeyDown(uint32 id, float x, float y) override;
bool onMouseLKeyUp(uint32 id, float x, float y) override;
- void checkTutorial() override;
+
+ void onUTrubaClick();
+ /** The first of the swallowed eggs (the id of its item), 0 when there is none */
+ int getFirstEaten() const;
+ /** The second egg becomes the first */
+ int removeFirstEaten();
+ void prepareReleaseEgg();
+ void doTestFat(MessageQueue *queue);
+ void updateBehavior();
+ void resetEggs();
+ void doTakeEgg(MessageQueue *queue);
+ void onTakeCoin();
+ void addLastEaten(const Common::String &item);
+ void onInvDrop(const Common::String &item);
private:
/** +216: the next tutorial of the scene, "UNDEF" when there is none */
Common::String _tutorial;
- /** +220: ANI_SC3_BOOT of the scene (found by OnShow) */
+ /** +220: ANI_SC4_BOOT of the scene (found by OnShow) */
AniObject *_boot = nullptr;
+ /** +224: ANI_EGGEATER of the scene (found by OnShow) */
+ AniObject *_eggeater = nullptr;
+ /** +228, +232, +236: states "ЯйÑо1" .. "ЯйÑо3": item id of the swallowed egg, 0 for none */
+ GameVar *_egg1 = nullptr;
+ GameVar *_egg2 = nullptr;
+ GameVar *_egg3 = nullptr;
+ /** +240: task_dlg_19.fnt (OnSceneInit) */
+ const BitmapFont *_font = nullptr;
+ /** +244: the time the hint over the scene is shown, -1 for none */
+ int _hintTime = -1;
+ /** +248: the text of the hint */
+ Common::String _hintText;
/** the part of OnMouseLKeyDown and OnMouseLKeyUp that the tutorials decide */
bool tutorialBlocksTouch() const;
/** The egg boot of the inventory is there, or an egg was swallowed */
bool hasEggBootOrEaten() const;
+ /** CStateManager::GetObjStatePtr("ÐÑоглоÑеннÑе ÑйÑа") and GetLogicStatePtr of the three eggs */
+ void findEggStates();
};
} // End of namespace NGI
Commit: 2b118d07391ba483fc01e3f901f4cff2ae84851b
https://github.com/scummvm/scummvm/commit/2b118d07391ba483fc01e3f901f4cff2ae84851b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: WaitScreen (CWaitScreen, CWaitScreenController): the crawling screen while the textures of a scene load
Changed paths:
A engines/ngi/fullpipe/waitscreen.cpp
A engines/ngi/fullpipe/waitscreen.h
engines/ngi/module.mk
engines/ngi/ngi.h
engines/ngi/objects.h
engines/ngi/scene.h
engines/ngi/statics.cpp
engines/ngi/statics.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/waitscreen.cpp b/engines/ngi/fullpipe/waitscreen.cpp
new file mode 100644
index 00000000000..972aad69096
--- /dev/null
+++ b/engines/ngi/fullpipe/waitscreen.cpp
@@ -0,0 +1,70 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/ngi.h"
+#include "ngi/utils.h"
+#include "ngi/gfx.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/waitscreen.h"
+
+namespace NGI {
+
+WaitScreenController::WaitScreenController(int sceneId) : ISceneController(sceneId) {
+}
+
+// CWaitScreenController::OnShow (1A6934)
+void WaitScreenController::onShow() {
+ _bar = _scene->findAniObjectById(ANI_PBAR, 0);
+ _bar->startMovement(MV_PBAR_RUN, 0, -1);
+ _bar->setPos(337, 456);
+ _bar->_flags |= 4;
+ const Movement *movement = _bar->getMovement(MV_PBAR_RUN);
+ _lastFrame = (int)movement->_phases.size() - 1;
+}
+
+// CWaitScreenController::OnUpdate (1A67A4): SetCurFrame(lastFrame * percent / 1000, 0, 0)
+void WaitScreenController::onUpdate(uint32 percent) {
+ if (_bar)
+ _bar->setCurFrame(_lastFrame * (int)percent / 1000, false, false);
+}
+
+// CGame::CallWaitScreen (FC1F0), CWaitScreen::Update (128448), CWaitScreen::Render (128568)
+void callWaitScreen(uint percent) {
+ static bool rendering = false;
+ Scene *scene = g_ngi->_waitScreen;
+ if (!scene)
+ return;
+ if (scene->_controller)
+ scene->_controller->onUpdate(percent);
+ if (rendering)
+ return;
+ rendering = true;
+ g_ngi->_backgroundSurface.fillRect(Common::Rect(g_ngi->_backgroundSurface.w, g_ngi->_backgroundSurface.h), 0);
+ scene->render();
+ g_ngi->drawWidescreenBars();
+ g_ngi->_system->copyRectToScreen(g_ngi->_backgroundSurface.getPixels(), g_ngi->_backgroundSurface.pitch, 0, 0, g_ngi->_backgroundSurface.w, g_ngi->_backgroundSurface.h);
+ g_ngi->_system->updateScreen();
+ rendering = false;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/waitscreen.h b/engines/ngi/fullpipe/waitscreen.h
new file mode 100644
index 00000000000..b5b47934519
--- /dev/null
+++ b/engines/ngi/fullpipe/waitscreen.h
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_WAITSCREEN_H
+#define NGI_FULLPIPE_WAITSCREEN_H
+
+#include "ngi/scenecontroller.h"
+
+namespace NGI {
+
+class AniObject;
+class Scene;
+
+/** CWaitScreenController: the loading screen (scene SC_LDR); field offsets as in the original */
+class WaitScreenController : public ISceneController {
+public:
+ explicit WaitScreenController(int sceneId);
+
+ /** CWaitScreenController::OnShow */
+ void onShow() override;
+ /** CWaitScreenController::OnUpdate: the argument is the loading percent in thousandths */
+ void onUpdate(uint32 percent) override;
+
+private:
+ AniObject *_bar = nullptr; // +12
+ int _lastFrame = 0; // +16
+};
+
+/** CGame::CallWaitScreen: percent in thousandths */
+void callWaitScreen(uint percent);
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_WAITSCREEN_H
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index a5fd159b3f1..c6907ddf31c 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -158,7 +158,8 @@ MODULE_OBJS = \
fullpipe/taskmanager.o \
fullpipe/tremble.o \
fullpipe/tutorialcontroller.o \
- fullpipe/tutorialmanager.o
+ fullpipe/tutorialmanager.o \
+ fullpipe/waitscreen.o
ifdef USE_IMGUI
MODULE_OBJS += \
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index fe353e65748..cd949bed8b0 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -367,6 +367,8 @@ public:
Inventory2 *_inventory2;
/** CGame +116: the Android inventory (scene 0 made by inventory.xml), 0 if create_inv is off */
Inventory *_inventory = nullptr;
+ /** CGame +120: the scene of the wait screen (SC_LDR), owned by the scene list under the id 1 */
+ Scene *_waitScreen = nullptr;
int _currSelectedInventoryItemId;
int32 _updateTicks;
diff --git a/engines/ngi/objects.h b/engines/ngi/objects.h
index 20aa4c8b34b..61d5875d5fb 100644
--- a/engines/ngi/objects.h
+++ b/engines/ngi/objects.h
@@ -110,6 +110,8 @@ class GameProject : public CObject {
int _field_10;
/** PROJECT create_inv (CGame::CreateContent): the inventory scene is made from inventory.xml */
bool _createInventory = true;
+ /** create_waitscreen of the project: the scene SC_LDR of sc_waitscreen.xml (the Android build) */
+ bool _createWaitScreen = true;
public:
GameProject();
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 9f8bc0236c2..a6ced9f2766 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -82,6 +82,8 @@ class Scene : public Background {
void setSoundPause(bool paused) { _soundPaused = paused; }
/** CScene +37 (SCENE putPrev): the scene is drawn over the one below it instead of replacing it */
bool _putPrev = false;
+ /** CScene +352 ("waitscreen", default true): show the wait screen while the textures load */
+ bool _waitscreen = true;
/** CScene::OnShow / OnHide: the parts that the controllers, the behaviors and the GUI need */
virtual void onShow();
virtual void onHide();
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index fdbc9774854..6010762ddcb 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -2699,9 +2699,13 @@ void Phase::setPNG(const Common::Path &path, const Dims &size) {
_height = size.y;
}
-void Phase::enter(int objectId) {
+void Phase::loadTexture() {
if (!_bitmap && !_memfilename.empty())
loadPNG(_memfilename, getDimensions());
+}
+
+void Phase::enter(int objectId) {
+ loadTexture();
if (_soundId && g_ngi->_soundEnabled)
g_ngi->playSound(_soundId, _loopSound, objectId);
if (_command) {
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index a13fc199b6e..8cb4fcb276d 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -83,6 +83,8 @@ class Phase : public StaticPhase {
Phase();
Phase(Phase *src, bool reverse);
void setPNG(const Common::Path &path, const Dims &size);
+ /** the texture of the phase is loaded now, not when the phase is entered the first time */
+ void loadTexture();
void enter(int objectId);
bool load(MfcArchive &file) override;
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 7bfecbd66d8..f2035bd1ed5 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -376,6 +376,10 @@ private:
const char first = node->values["create_inv"].firstChar();
_project._createInventory = first == '1' || first == 't' || first == 'T' || first == 'y' || first == 'Y';
}
+ if (node->values.contains("create_waitscreen")) {
+ const char first = node->values["create_waitscreen"].firstChar();
+ _project._createWaitScreen = first == '1' || first == 't' || first == 'T' || first == 'y' || first == 'Y';
+ }
if (node->values.contains("width"))
_width = atoi(node->values["width"].c_str());
if (node->values.contains("height"))
@@ -944,6 +948,8 @@ private:
_scene._sceneName = node->values.getValOrDefault("title");
_scene._drawOffset = node->values.contains("drawOffset") ? atoi(node->values["drawOffset"].c_str()) : -1;
_scene._putPrev = node->values.getValOrDefault("putPrev") == "true" || node->values.getValOrDefault("putPrev") == "1";
+ if (node->values.contains("waitscreen"))
+ _scene._waitscreen = node->values["waitscreen"] == "true" || node->values["waitscreen"] == "1";
_scene._dims = Dims(atoi(node->values.getValOrDefault("width", Common::String::format("%d", g_ngi->gameWidth())).c_str()),
atoi(node->values.getValOrDefault("height", Common::String::format("%d", g_ngi->_backgroundSurface.h)).c_str()));
_scene._x = strtod(node->values.getValOrDefault("scrollX").c_str(), nullptr);
@@ -1723,6 +1729,8 @@ const char *NGIEngine::getResourceLocale() const {
}
}
+static void loadSceneTextures(Scene &scene);
+
void SceneTag::loadSceneXML(const GameProject &project) {
Common::ScopedPtr<Scene> scene(new Scene());
scene->_sceneId = _sceneId;
@@ -1741,6 +1749,9 @@ void SceneTag::loadSceneXML(const GameProject &project) {
debugC(1, kDebugXML, "Loaded Full Pipe scene %s with %u pictures and %u animations",
_tag.c_str(), scene->_pictureObjects.size(), scene->_aniObjects.size());
+ // the wait screen shows how far the textures of the scene are loaded (CScene::LoadPictures)
+ if (g_ngi->_waitScreen && scene->_waitscreen && g_ngi->_gameVersion >= 201509)
+ loadSceneTextures(*scene);
delete _scene;
_scene = scene.release();
// exits.xml exists from the 2015 revision on (the original reads all scenes at once)
@@ -1748,6 +1759,43 @@ void SceneTag::loadSceneXML(const GameProject &project) {
g_ngi->_exitManager->init("data/exits.xml", _scene);
}
+// CGame::CreateContent "create_waitscreen": scene id 1, its controller is kept in +120
+static bool createWaitScreen(GameProject &project) {
+ Common::ScopedPtr<Scene> scene(new Scene());
+ scene->_sceneId = SC_LDR;
+ XMLSceneParser parser(project, *scene, g_ngi->getResourceLocale());
+ if (!parser.loadFile("data/res/sc_waitscreen.xml") || !parser.parse())
+ return false;
+ project._sceneTagList->emplace_back();
+ SceneTag &tag = project._sceneTagList->back();
+ tag._sceneId = 1;
+ tag._scene = scene.release();
+ g_ngi->_waitScreen = tag._scene;
+ new WaitScreenController(1);
+ return true;
+}
+
+// CScene::LoadPictures and LoadAnis: the textures of the scene are loaded one after the other, and while that is done the wait screen shows the part that is
+// loaded (CScene::GetLoadingPercent, in thousandths). The pictures and the poses are loaded by the parser already, so the percent counts the phases of the
+// movements (the original has a preload manager that loads and frees the textures of the scenes, it is not ported).
+static void loadSceneTextures(Scene &scene) {
+ uint total = 0;
+ for (const AniObject *ani : scene._aniObjects) {
+ for (const Movement *movement : ani->_movements)
+ total += movement->_phases.size();
+ }
+ uint loaded = 0;
+ for (AniObject *ani : scene._aniObjects) {
+ for (Movement *movement : ani->_movements) {
+ for (Phase *phase : movement->_phases) {
+ loaded++;
+ phase->loadTexture();
+ callWaitScreen(MIN<uint>(1000, loaded * 1000 / MAX<uint>(1, total)));
+ }
+ }
+ }
+}
+
// CGame::CreateContent: the inventory is the scene 0, read from inventory.xml for create_inv
static bool createInventory(GameProject &project) {
Common::ScopedPtr<Inventory> inventory(new Inventory());
@@ -1820,8 +1868,12 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
return Common::Error(Common::kNoGameDataFoundError, "Could not read the lift passages");
}
g_ngi->lift_resetButtons();
+ if (g_ngi->_gameVersion >= 201509)
+ setManSpeed(_gameVar, 4.0f); // CSplashScreenController::CreateControllers
if (project._createInventory && !createInventory(project))
return Common::Error(Common::kNoGameDataFoundError, "Could not read the inventory");
+ if (g_ngi->_gameVersion >= 201509 && project._createWaitScreen && !createWaitScreen(project))
+ return Common::Error(Common::kNoGameDataFoundError, "Could not read the wait screen");
_gameVar->addSubVarAsInt("CHAPTERS", 0);
if (g_ngi->_gameVersion >= 201509) { // tasks.xml is known from the 2015 revision on
g_ngi->_chapterManager.reset(new ChapterManager);
Commit: a377c6893c171c8c44b84e801326927ea666b46f
https://github.com/scummvm/scummvm/commit/a377c6893c171c8c44b84e801326927ea666b46f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: CUtils::SetManSpeed: the walk, the ladders and the pipes of the hero are faster
Changed paths:
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index f2035bd1ed5..5494e8bc9b3 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -222,6 +222,8 @@ private:
GameVar *_scene = nullptr;
GameVar *_group = nullptr;
Common::String _section;
+ /** the node ANI_MAN: the movement lists that CUtils::SetManSpeed speeds up */
+ bool _isMan = false;
CUSTOM_XML_PARSER(XMLSceneDataParser) {
XML_KEY(DATA)
@@ -254,7 +256,8 @@ private:
return true;
if (node->depth == 1) {
- if (!node->name.hasPrefix("SC_")) {
+ _isMan = node->name == "ANI_MAN";
+ if (!_isMan && !node->name.hasPrefix("SC_")) {
node->ignore = true;
return true;
}
@@ -263,10 +266,17 @@ private:
}
if (node->depth == 2) {
_section = node->name;
- node->ignore = _section != "FLIES" && _section != "CURSORS" && _section != "BORDER";
+ if (_isMan)
+ node->ignore = _section != "SpeedUp" && _section != "SpeedUpDouble" && _section != "SpeedUpHalf";
+ else
+ node->ignore = _section != "FLIES" && _section != "CURSORS" && _section != "BORDER";
return true;
}
if (node->depth == 3) {
+ if (_isMan) {
+ addVar(*findOrAddVar(*_scene, _section), node->name, atoi(node->values.getValOrDefault("id").c_str()));
+ return true;
+ }
if (_section == "FLIES") {
const bool region = node->name == "FlyIdleRegion";
if (!region && node->name != "FlyPoints") {
@@ -1810,6 +1820,27 @@ static bool createInventory(GameProject &project) {
return true;
}
+// CUtils::SetManSpeed (14FD94): the hero is the ANI_MAN of SC_COMMON
+static void setManSpeed(GameVar *gameVar, float speed) {
+ Scene *common = g_ngi->findScene(SC_COMMON);
+ AniObject *hero = common ? common->findAniObjectById(ANI_MAN, 0) : nullptr;
+ GameVar *data = gameVar->getSubVarByName("ANI_MAN");
+ if (!hero || !data)
+ return;
+ static const char *const lists[] = { "SpeedUp", "SpeedUpDouble", "SpeedUpHalf" };
+ for (int i = 0; i < 3; i++) {
+ const GameVar *list = data->getSubVarByName(lists[i]);
+ if (!list)
+ continue;
+ for (const GameVar *item = list->_subVars; item; item = item->_nextVarObj) {
+ Movement *movement = hero->getMovement(item->_value.intValue);
+ if (!movement)
+ continue;
+ movement->_loopDelay = i == 0 ? (int)(83.0f / speed) : (i == 1 ? 20 : 41);
+ }
+ }
+}
+
Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTag *&start, int &width, int &height) {
// XML projects may ship in zip containers (the 2015 build: an APK and an OBB), later entries win, so the
// containers are added in reverse order of the detection entry. Loose files in the game directory also work.
Commit: c4adf618b9d28c443bda0542b7685673868c2a29
https://github.com/scummvm/scummvm/commit/c4adf618b9d28c443bda0542b7685673868c2a29
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: Time of the movements and of the hero in the debug output
Changed paths:
engines/ngi/debugger/testmode.cpp
engines/ngi/statics.cpp
diff --git a/engines/ngi/debugger/testmode.cpp b/engines/ngi/debugger/testmode.cpp
index 4361694d0ae..be22313c8ee 100644
--- a/engines/ngi/debugger/testmode.cpp
+++ b/engines/ngi/debugger/testmode.cpp
@@ -223,7 +223,7 @@ void testmode_update(uint32 elapsed) {
const uint stateHash = Common::hashit(state.c_str());
if (stateHash != g_lastHeroState) {
g_lastHeroState = stateHash;
- debugC(1, kDebugInfo, "INFO f %d scene %d %s", g_frame, info.sceneId, state.c_str());
+ debugC(1, kDebugInfo, "INFO f %d t %u scene %d %s", g_frame, g_system->getMillis(), info.sceneId, state.c_str());
}
}
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 6010762ddcb..f48a94979ca 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -1053,7 +1053,7 @@ L12:
}
_movement = nullptr;
- debugC(1, kDebugAnimation, "movement stop: ani %d copy %d movement %d pos %d,%d topleft %d,%d flags %x statics %d", _id, _copyId, oid, _x, _y, getPosition().x,
+ debugC(1, kDebugAnimation, "movement stop: t %u ani %d copy %d movement %d pos %d,%d topleft %d,%d flags %x statics %d", g_system->getMillis(), _id, _copyId, oid, _x, _y, getPosition().x,
getPosition().y, _flags, _statics ? _statics->_staticsId : -1);
Command *ex = new Command(_id, kCmdMessage, kMsgAniMovementEnded, 0, 0, 0, 1, 0, 0, 0);
ex->_param = _copyId;
@@ -1765,7 +1765,7 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
_stepArray.clear();
- debugC(1, kDebugAnimation, "movement start: ani %d copy %d movement %d pos %d,%d topleft %d,%d flags %x mirror %d frame %d", _id, _copyId, movementId, _x, _y,
+ debugC(1, kDebugAnimation, "movement start: t %u ani %d copy %d movement %d pos %d,%d topleft %d,%d flags %x mirror %d frame %d", g_system->getMillis(), _id, _copyId, movementId, _x, _y,
getPosition().x, getPosition().y, _flags, mirror, _movement->_curFrame);
Command *newex = new Command(_id, kCmdMessage, kMsgAniMovementStarted, 0, 0, movementId, 1, 0, 0, 0);
Commit: 3ccaa54425bd3b973528a9749628cabda459e328
https://github.com/scummvm/scummvm/commit/3ccaa54425bd3b973528a9749628cabda459e328
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: WaitScreen shows the bar before a load and services events while it draws
Changed paths:
engines/ngi/fullpipe/waitscreen.cpp
engines/ngi/fullpipe/waitscreen.h
diff --git a/engines/ngi/fullpipe/waitscreen.cpp b/engines/ngi/fullpipe/waitscreen.cpp
index 972aad69096..f927bea9c81 100644
--- a/engines/ngi/fullpipe/waitscreen.cpp
+++ b/engines/ngi/fullpipe/waitscreen.cpp
@@ -48,6 +48,21 @@ void WaitScreenController::onUpdate(uint32 percent) {
_bar->setCurFrame(_lastFrame * (int)percent / 1000, false, false);
}
+// CGame::DoSetScene: CPreloadManager::LoadScene(1) (the PRELOAD item is ANI_PBAR with MV_PBAR_RUN) and the OnShow of the wait screen. The phases are loaded after
+// the OnShow here: the StartMovement of a bar that is shown the second time rewinds it, which frees its phases (the original has the preload manager do it).
+void showWaitScreen() {
+ Scene *scene = g_ngi->_waitScreen;
+ if (!scene)
+ return;
+ scene->onShow();
+ for (const AniObject *ani : scene->_aniObjects) {
+ for (const Movement *movement : ani->_movements) {
+ for (Phase *phase : movement->_phases)
+ phase->loadTexture();
+ }
+ }
+}
+
// CGame::CallWaitScreen (FC1F0), CWaitScreen::Update (128448), CWaitScreen::Render (128568)
void callWaitScreen(uint percent) {
static bool rendering = false;
@@ -64,6 +79,10 @@ void callWaitScreen(uint percent) {
g_ngi->drawWidescreenBars();
g_ngi->_system->copyRectToScreen(g_ngi->_backgroundSurface.getPixels(), g_ngi->_backgroundSurface.pitch, 0, 0, g_ngi->_backgroundSurface.w, g_ngi->_backgroundSurface.h);
g_ngi->_system->updateScreen();
+ // services the event queue, or macOS shows the wait cursor and does not paint
+ Common::Event event;
+ while (g_ngi->getEventManager()->pollEvent(event)) {
+ }
rendering = false;
}
diff --git a/engines/ngi/fullpipe/waitscreen.h b/engines/ngi/fullpipe/waitscreen.h
index b5b47934519..7b5d8f40260 100644
--- a/engines/ngi/fullpipe/waitscreen.h
+++ b/engines/ngi/fullpipe/waitscreen.h
@@ -47,6 +47,12 @@ private:
/** CGame::CallWaitScreen: percent in thousandths */
void callWaitScreen(uint percent);
+/**
+ * The start of CGame::DoSetScene before a scene is loaded: CPreloadManager::LoadScene(1) loads the PRELOAD item of the wait screen (the phases of MV_PBAR_RUN),
+ * then the OnShow of the scene.
+ */
+void showWaitScreen();
+
} // End of namespace NGI
#endif // NGI_FULLPIPE_WAITSCREEN_H
Commit: 3a8d2b0b2f496457a5cde046eb611bdd8c0fc9b8
https://github.com/scummvm/scummvm/commit/3a8d2b0b2f496457a5cde046eb611bdd8c0fc9b8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: GameProject shows the wait screen before it loads a scene
Changed paths:
engines/ngi/scene.cpp
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 182e75e46eb..8c81b9ac321 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -22,6 +22,7 @@
#include "math/utils.h"
#include "ngi/ngi.h"
+#include "ngi/fullpipe/waitscreen.h"
#include "ngi/scenecontroller.h"
#include "ngi/fullpipe/fpcontroller.h"
@@ -242,6 +243,10 @@ Scene *GameProject::findScene(int sceneId) {
continue;
if (!tag._scene) {
if (g_ngi->usesXMLProject()) {
+ // CGame::DoSetScene: CPreloadManager::LoadScene(1) and the OnShow of the wait screen (the bar starts at the first dot) come before the scene is
+ // loaded, which the lookup does here
+ if (g_ngi->_gameVersion >= 201509)
+ showWaitScreen();
tag.loadSceneXML(*this);
if (tag._scene && tag._scene->_guiManager)
tag._scene->_guiManager->load(*this);
Commit: c49287c4a8206c06cf0c0647e1b9a8e1e8eca7db
https://github.com/scummvm/scummvm/commit/c49287c4a8206c06cf0c0647e1b9a8e1e8eca7db
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: Wait screen steps per picture and animation like CScene::LoadPictures and LoadAnis
Changed paths:
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 5494e8bc9b3..d8ce4251517 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -1785,24 +1785,20 @@ static bool createWaitScreen(GameProject &project) {
return true;
}
-// CScene::LoadPictures and LoadAnis: the textures of the scene are loaded one after the other, and while that is done the wait screen shows the part that is
-// loaded (CScene::GetLoadingPercent, in thousandths). The pictures and the poses are loaded by the parser already, so the percent counts the phases of the
-// movements (the original has a preload manager that loads and frees the textures of the scenes, it is not ported).
+// CScene::LoadPictures and LoadAnis: the pictures and then the animations of the scene are loaded one after the other (CAniObject::LoadMovements loads the phases of all
+// its movements), and after each object the wait screen shows the part that is loaded (CScene::GetLoadingPercent, in thousandths). The pictures and the poses are loaded
+// by the parser already, so their step only reports the percent (the original has a preload manager that loads and frees the textures of the scenes, it is not ported).
static void loadSceneTextures(Scene &scene) {
- uint total = 0;
- for (const AniObject *ani : scene._aniObjects) {
- for (const Movement *movement : ani->_movements)
- total += movement->_phases.size();
- }
+ const uint total = scene._pictureObjects.size() + scene._aniObjects.size();
uint loaded = 0;
+ for (uint i = 0; i < scene._pictureObjects.size(); i++)
+ callWaitScreen(MIN<uint>(1000, ++loaded * 1000 / MAX<uint>(1, total)));
for (AniObject *ani : scene._aniObjects) {
for (Movement *movement : ani->_movements) {
- for (Phase *phase : movement->_phases) {
- loaded++;
+ for (Phase *phase : movement->_phases)
phase->loadTexture();
- callWaitScreen(MIN<uint>(1000, loaded * 1000 / MAX<uint>(1, total)));
- }
}
+ callWaitScreen(MIN<uint>(1000, ++loaded * 1000 / MAX<uint>(1, total)));
}
}
Commit: fb183a06f7214e1718f9e313cf4bc44698823c8c
https://github.com/scummvm/scummvm/commit/fb183a06f7214e1718f9e313cf4bc44698823c8c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: PreloadManager (CPreloadManager): the textures of the scenes are loaded and freed with the scene stack
Changed paths:
A engines/ngi/preloadmanager.cpp
A engines/ngi/preloadmanager.h
engines/ngi/module.mk
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index c6907ddf31c..f48930ecdda 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -21,6 +21,7 @@ MODULE_OBJS = \
ngi.o \
ngiarchive.o \
physics.o \
+ preloadmanager.o \
region.o \
scene.o \
scenecontroller.o \
diff --git a/engines/ngi/preloadmanager.cpp b/engines/ngi/preloadmanager.cpp
new file mode 100644
index 00000000000..a5a2e9aba69
--- /dev/null
+++ b/engines/ngi/preloadmanager.cpp
@@ -0,0 +1,292 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/debug.h"
+
+#include "ngi/ngi.h"
+#include "ngi/preloadmanager.h"
+#include "ngi/scene.h"
+#include "ngi/scenecontroller.h"
+#include "ngi/font.h"
+#include "ngi/statics.h"
+
+namespace NGI {
+
+PreloadManager::PreloadManager() {
+}
+
+PreloadManager::~PreloadManager() {
+}
+
+// CPreloadManager::AddItem (11AA40)
+bool PreloadManager::addItem(uint sceneId, uint aniId, uint movementId) {
+ for (const PreloadEntry &item : _items) {
+ if (item.sceneId == sceneId && item.movementId == movementId)
+ return false;
+ }
+ PreloadEntry item;
+ item.sceneId = sceneId;
+ item.aniId = aniId;
+ item.movementId = movementId;
+ _items.push_back(item);
+ return true;
+}
+
+// CPreloadManager::PushToPreload (11AC60)
+void PreloadManager::pushToPreload(Scene *scene, uint aniId, uint movementId) {
+ if (addItem(scene->_sceneId, aniId, movementId)) {
+ _preloaded += scene->loadMovement(aniId, movementId);
+ _loaded.push_back(_items.back());
+ }
+}
+
+// CPreloadManager::IsPreloaded (11A530)
+bool PreloadManager::isPreloaded(uint movementId) const {
+ for (const PreloadEntry &item : _loaded) {
+ if (item.movementId == movementId)
+ return true;
+ }
+ return false;
+}
+
+// CPreloadManager::NeedInScene (11A4F0)
+bool PreloadManager::needInScene(uint movementId, uint sceneId) const {
+ for (const PreloadEntry &item : _items) {
+ if (item.sceneId == sceneId && item.movementId == movementId)
+ return true;
+ }
+ return false;
+}
+
+// CPreloadManager::LoadScene (11ACB0)
+void PreloadManager::loadScene(uint sceneId) {
+ debugC(4, kDebugLoading, "CPreloadManager::LoadScene(), id = %s", g_ngi->gameIdToStr(sceneId).c_str());
+ Scene *scene = g_ngi->findScene(sceneId);
+ if (!scene)
+ return;
+ _pictures += scene->loadPictures();
+ _anis += scene->loadAnis();
+ _roamings += scene->loadRoamings(true);
+ _additional += scene->loadAdditional();
+ for (uint i = 0; i < _items.size(); i++) {
+ if (sceneId == _items[i].sceneId) {
+ _preloaded += scene->loadMovement(_items[i].aniId, _items[i].movementId);
+ _loaded.push_back(_items[i]);
+ }
+ }
+}
+
+// CPreloadManager::UnloadScene (11A62C): the original skips the item after an erased one
+void PreloadManager::unloadScene(uint sceneId) {
+ debugC(4, kDebugLoading, "CPreloadManager::UnloadScene(), id = %s", g_ngi->gameIdToStr(sceneId).c_str());
+ Scene *scene = g_ngi->findScene(sceneId);
+ if (!scene)
+ return;
+ _pictures -= scene->unloadPictures();
+ _anis -= scene->unloadAnis();
+ _roamings -= scene->unloadRoamings(true);
+ _additional -= scene->unloadAdditional();
+ for (uint i = 0; i < _loaded.size(); i++) {
+ if (sceneId == _loaded[i].sceneId) {
+ _preloaded -= scene->unloadMovement(_loaded[i].aniId, _loaded[i].movementId);
+ _loaded.remove_at(i);
+ i++;
+ }
+ }
+}
+
+// CPreloadManager::SetScene (11AF5C)
+void PreloadManager::setScene(uint sceneId) {
+ debugC(4, kDebugLoading, "CPreloadManager::SetScene(), id = %s", g_ngi->gameIdToStr(sceneId).c_str());
+ for (uint i = 0; i < g_ngi->_sceneStack.size(); i++) {
+ Scene *stacked = g_ngi->getSceneInStack(i);
+ _pictures -= stacked->unloadPictures();
+ _anis -= g_ngi->getSceneInStack(i)->unloadAnis();
+ _roamings -= g_ngi->getSceneInStack(i)->unloadRoamings(false);
+ _additional -= g_ngi->getSceneInStack(i)->unloadAdditional();
+ }
+ Scene *scene = g_ngi->findScene(sceneId);
+ if (!scene)
+ return;
+ for (uint j = 0; j < _loaded.size(); j++) {
+ if (!needInScene(_loaded[j].movementId, sceneId)) {
+ Scene *owner = g_ngi->findScene(_loaded[j].sceneId);
+ if (owner)
+ _preloaded -= owner->unloadMovement(_loaded[j].aniId, _loaded[j].movementId);
+ _loaded.remove_at(j);
+ j--;
+ }
+ }
+ for (uint k = 0; k < _items.size(); k++) {
+ if (sceneId == _items[k].sceneId) {
+ _preloaded += scene->loadMovement(_items[k].aniId, _items[k].movementId);
+ _loaded.push_back(_items[k]);
+ }
+ }
+ _pictures += scene->loadPictures();
+ _anis += scene->loadAnis();
+ _roamings += scene->loadRoamings(false);
+ _additional += scene->loadAdditional();
+}
+
+// CPreloadManager::PushScene (11B15C)
+void PreloadManager::pushScene(uint sceneId) {
+ debugC(4, kDebugLoading, "CPreloadManager::PushScene(), id = %s", g_ngi->gameIdToStr(sceneId).c_str());
+ Scene *scene = g_ngi->findScene(sceneId);
+ if (!scene)
+ return;
+ for (uint i = 0; i < _items.size(); i++) {
+ if (sceneId == _items[i].sceneId) {
+ _preloaded += scene->loadMovement(_items[i].aniId, _items[i].movementId);
+ _loaded.push_back(_items[i]);
+ }
+ }
+ _pictures += scene->loadPictures();
+ _anis += scene->loadAnis();
+ _roamings += scene->loadRoamings(false);
+ _additional += scene->loadAdditional();
+}
+
+// CPreloadManager::PopScene (11A758): unloads the current scene, reloads the roamings below it;
+// skips the item after an erased one like the original
+void PreloadManager::popScene() {
+ Scene *current = g_ngi->getCurrentScene();
+ debugC(4, kDebugLoading, "CPreloadManager::PopScene(), id = %s", g_ngi->gameIdToStr(current->_sceneId).c_str());
+ _pictures -= current->unloadPictures();
+ _anis -= current->unloadAnis();
+ _roamings -= current->unloadRoamings(false);
+ _additional -= current->unloadAdditional();
+ for (uint i = 0; i < _loaded.size(); i++) {
+ if (current->_sceneId == _loaded[i].sceneId) {
+ _preloaded -= current->unloadMovement(_loaded[i].aniId, _loaded[i].movementId);
+ _loaded.remove_at(i);
+ i++;
+ }
+ }
+ for (uint i = 0; i + 1 < g_ngi->_sceneStack.size(); i++) {
+ Scene *stacked = g_ngi->getSceneInStack(i);
+ if (stacked)
+ _roamings += stacked->loadRoamings(false);
+ }
+}
+
+// CPreloadManager::StartGame (11ADDC)
+void PreloadManager::startGame() {
+ warning("STUB/untested: CCursorController::Load: the cursors are pictures of the inventory scene, they are loaded with it");
+ loadInventory();
+}
+
+// CPreloadManager::LoadAll (11ADF0)
+void PreloadManager::loadAll() {
+ debugC(4, kDebugLoading, "CPreloadManager::LoadAll()");
+ for (uint i = 0; i < g_ngi->_sceneStack.size(); i++) {
+ Scene *scene = g_ngi->getSceneInStack(i);
+ for (uint j = 0; j < _items.size(); j++) {
+ if (scene->_sceneId == _items[j].sceneId) {
+ const uint size = scene->loadMovement(_items[j].aniId, _items[j].movementId);
+ if (size) {
+ debugC(4, kDebugLoading, "CPreloadManager::LoadAll(), move = %s", g_ngi->gameIdToStr(_items[j].movementId).c_str());
+ _loaded.push_back(_items[j]);
+ }
+ _preloaded += size;
+ }
+ }
+ _pictures += scene->loadPictures();
+ _anis += scene->loadAnis();
+ _roamings += scene->loadRoamings(true);
+ _additional += scene->loadAdditional();
+ if (scene->_controller)
+ scene->_controller->onResetRender();
+ }
+ warning("STUB/untested: CCursorController::Load: the cursors are pictures of the inventory scene, they are loaded with it");
+ loadInventory();
+}
+
+// CPreloadManager::UnloadAll (11A8D0)
+void PreloadManager::unloadAll() {
+ debugC(4, kDebugLoading, "CPreloadManager::UnloadAll()");
+ while (!_loaded.empty()) {
+ Scene *scene = g_ngi->findScene(_loaded[0].sceneId);
+ if (scene)
+ _preloaded -= scene->unloadMovement(_loaded[0].aniId, _loaded[0].movementId);
+ _loaded.remove_at(0);
+ }
+ for (uint i = 0; i < g_ngi->_sceneStack.size(); i++) {
+ Scene *scene = g_ngi->getSceneInStack(i);
+ _pictures -= scene->unloadPictures();
+ _anis -= scene->unloadAnis();
+ _roamings -= scene->unloadRoamings(true);
+ _additional -= scene->unloadAdditional();
+ if (scene->_controller)
+ scene->_controller->onLostDevice();
+ }
+ warning("STUB/untested: CCursorController::Unload: the cursors are pictures of the inventory scene, they are unloaded with it");
+ unloadInventory();
+ unloadFonts();
+}
+
+// CPreloadManager::LoadInventory (11ADC4), UnloadInventory (11A740): the inventory is scene 0
+void PreloadManager::loadInventory() {
+ if (g_ngi->_inventory)
+ loadScene(0);
+}
+
+void PreloadManager::unloadInventory() {
+ if (g_ngi->_inventory)
+ unloadScene(0);
+}
+
+// CPreloadManager::LoadFonts (11A590) and UnloadFonts (11A5AC)
+void PreloadManager::loadFonts() {
+ warning("STUB/untested: CFontController::Load: the fonts are loaded when they are first used and kept");
+}
+
+void PreloadManager::unloadFonts() {
+ warning("STUB/untested: CFontController::Unload: the fonts are loaded when they are first used and kept");
+}
+
+// CPreloadManager::LoadRoamings (11A5C8)
+void PreloadManager::loadRoamings() {
+ _roamings += g_ngi->getCurrentScene()->loadRoamings(false);
+}
+
+// CPreloadManager::Render (11A238)
+void PreloadManager::render(Graphics::ManagedSurface &target, const BitmapFont &font) const {
+ const float million = 1000000.0f;
+ const float all = (float)(_fonts + _pictures + _anis + _roamings + _moves + _preloaded);
+ const Common::String lines[] = {
+ Common::String::format("Fonts: %f", _fonts / million),
+ Common::String::format("Pictures: %f", _pictures / million),
+ Common::String::format("Anis: %f", _anis / million),
+ Common::String::format("Roamings: %f", _roamings / million),
+ Common::String::format("Moves: %f", _moves / million),
+ Common::String::format("Preloaded: %f", _preloaded / million),
+ Common::String::format("Additional: %f", _additional / million),
+ Common::String::format("ALL: %f", all / million)
+ };
+ float y = 130.0f;
+ for (const Common::String &line : lines) {
+ font.print(target, line, 200.0f, y, 400.0f, 20.0f, BitmapFont::kAlignLeft, BitmapFont::kVerticalTop);
+ y += y < 270.0f ? 20.0f : 0.0f;
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/preloadmanager.h b/engines/ngi/preloadmanager.h
new file mode 100644
index 00000000000..d68387acac4
--- /dev/null
+++ b/engines/ngi/preloadmanager.h
@@ -0,0 +1,94 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_PRELOADMANAGER_H
+#define NGI_PRELOADMANAGER_H
+
+#include "common/array.h"
+
+namespace Graphics { class ManagedSurface; }
+
+namespace NGI {
+
+class BitmapFont;
+class Scene;
+
+/** A movement kept in memory for a scene (PreloadItem: scene, animation, movement) */
+struct PreloadEntry {
+ uint sceneId;
+ uint aniId;
+ uint movementId;
+};
+
+/** CPreloadManager: loads and frees the scene textures (CGame::DoSetScene calls SetScene) */
+class PreloadManager {
+public:
+ PreloadManager();
+ ~PreloadManager();
+
+ /** CPreloadManager::AddItem (11AA40): false when the scene has the item already */
+ bool addItem(uint sceneId, uint aniId, uint movementId);
+ /** CPreloadManager::PushToPreload (11AC60): the movement is added and loaded now */
+ void pushToPreload(Scene *scene, uint aniId, uint movementId);
+ /** CPreloadManager::IsPreloaded (11A530): a movement with this id is loaded for a scene */
+ bool isPreloaded(uint movementId) const;
+ /** CPreloadManager::NeedInScene (11A4F0): the PRELOAD list has the movement for that scene */
+ bool needInScene(uint movementId, uint sceneId) const;
+
+ /** CPreloadManager::LoadScene (11ACB0) and UnloadScene (11A62C) */
+ void loadScene(uint sceneId);
+ void unloadScene(uint sceneId);
+ /** CPreloadManager::SetScene (11AF5C) */
+ void setScene(uint sceneId);
+ /** CPreloadManager::PushScene (11B15C) and PopScene (11A758) */
+ void pushScene(uint sceneId);
+ void popScene();
+ /** CPreloadManager::StartGame (11ADDC), LoadAll (11ADF0), UnloadAll (11A8D0) */
+ void startGame();
+ void loadAll();
+ void unloadAll();
+ void loadInventory();
+ void unloadInventory();
+ void loadFonts();
+ void unloadFonts();
+ /** CPreloadManager::LoadRoamings (11A5C8): the roamings of the current scene */
+ void loadRoamings();
+ /** CPreloadManager::OnLoadMove (11A564) and OnUnloadMove (11A57A) */
+ void onLoadMove(uint size) { _moves += size; }
+ void onUnloadMove(uint size) { _moves -= size; }
+ /** CPreloadManager::Render (11A238): the counters in millions of bytes */
+ void render(Graphics::ManagedSurface &target, const BitmapFont &font) const;
+
+private:
+ Common::Array<PreloadEntry> _items; // +8, the PRELOAD lists of all the scenes
+ Common::Array<PreloadEntry> _loaded; // +20, the items that are in memory
+ int _fonts = 0; // +32
+ int _pictures = 0; // +36
+ int _anis = 0; // +40
+ int _roamings = 0; // +44
+ int _preloaded = 0; // +48
+ int _moves = 0; // +52
+ int _additional = 0; // +56
+};
+
+} // End of namespace NGI
+
+#endif // NGI_PRELOADMANAGER_H
Commit: 554373bcfccbc884fa6a100a03f935c2c3fbcad1
https://github.com/scummvm/scummvm/commit/554373bcfccbc884fa6a100a03f935c2c3fbcad1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: Texture loads and unloads with a load count (CRenderResources), PictureObject::load and unload
Changed paths:
engines/ngi/gfx.cpp
engines/ngi/gfx.h
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index d9817015748..c660b83a87e 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -154,8 +154,18 @@ bool PictureObject::load(MfcArchive &file, bool bigPicture) {
return true;
}
+// CPictureObject::Load (119CAC) and Unload (119CBC)
+uint PictureObject::load() {
+ return _picture->loadTexture();
+}
+
+uint PictureObject::unload() {
+ return _picture->unloadTexture();
+}
+
void PictureObject::render(Common::Point scroll) {
if (g_ngi->_gameVersion >= 201509) {
+ _picture->loadIfNeeded();
_picture->blitTo(g_ngi->_backgroundSurface, Common::Point(_x, _y) - scroll, getRenderParams());
return;
}
@@ -169,6 +179,7 @@ void PictureObject::render(Common::Point scroll) {
void PictureObject::renderAtPos(int x, int y) {
if (g_ngi->_gameVersion >= 201509) {
// CVisibleObject::RenderAtPos: texture at the position with the object's scale, window, rotation
+ _picture->loadIfNeeded();
_picture->blitTo(g_ngi->_backgroundSurface, Common::Point(x, y), getRenderParams());
return;
}
@@ -602,6 +613,7 @@ void Texture::loadPNG(const Common::Path &path, const Dims &sizeHint) {
Image::PNGDecoder png;
if (!file.open(path) || !png.loadStream(file)) {
warning("Could not load scene texture %s (%d x %d)", path.toString().c_str(), _width, _height);
+ _fileMissing = true;
return;
}
@@ -621,6 +633,39 @@ void Texture::loadPNG(const Common::Path &path, const Dims &sizeHint) {
debugC(2, kDebugLoading, "Loaded scene texture %s (%d x %d)", path.toString().c_str(), _width, _height);
}
+void Texture::setPNG(const Common::Path &path, const Dims &size) {
+ _memfilename = path;
+ _width = size.x;
+ _height = size.y;
+ _fileMissing = false;
+}
+
+// CRenderResources::LoadTexture
+uint Texture::loadTexture() {
+ if (!_bitmap && !_fileMissing && !_memfilename.empty())
+ loadPNG(_memfilename, getDimensions());
+ if (++_loadCount == 1)
+ return getSizeInMemory();
+ return 0;
+}
+
+// CRenderResources::UnloadTexture
+uint Texture::unloadTexture() {
+ if (!_bitmap)
+ return 0;
+ if (--_loadCount != 0)
+ return 0;
+ const uint size = getSizeInMemory();
+ freePicture();
+ return size;
+}
+
+// CVisibleObject::Render, RenderAtPos: LoadTexture when the texture is not there
+void Texture::loadIfNeeded() {
+ if (!_bitmap && !_fileMissing)
+ loadTexture();
+}
+
// the game is drawn shifted by the widescreen margin (CRender::DrawTexQuad adds the CRender offset)
static Common::Point screenPosition(const Graphics::ManagedSurface &target, const Common::Point &position) {
return &target == &g_ngi->_backgroundSurface ? position + Common::Point(g_ngi->_wideOfs, 0) : position;
diff --git a/engines/ngi/gfx.h b/engines/ngi/gfx.h
index 34bcb2059d1..7bf084a16d5 100644
--- a/engines/ngi/gfx.h
+++ b/engines/ngi/gfx.h
@@ -107,6 +107,18 @@ public:
bool load(MfcArchive &file) override;
void loadPNG(const Common::Path &path, const Dims &sizeHint);
+ /** file and size of the texture of an XML project, the pixels are read by loadTexture */
+ void setPNG(const Common::Path &path, const Dims &size);
+ /** CRender::LoadTexture: reads the pixels if needed, returns the memory size at count 1 */
+ uint loadTexture();
+ /** CRender::UnloadTexture: frees the pixels when the load count reaches 0 */
+ uint unloadTexture();
+ /** CTexture::GetSizeInMemory: 4 bytes of every pixel */
+ uint getSizeInMemory() const { return 4 * _width * _height; }
+ /** The pixels are there (CPhase::IsTextureLoaded / CPictureObject::IsTextureLoaded) */
+ bool isTextureLoaded() const { return _bitmap != nullptr; }
+ /** CVisibleObject::Render: a texture that is not loaded is loaded before it is drawn */
+ void loadIfNeeded();
void blitTo(Graphics::ManagedSurface &target, const Common::Point &position, bool mirror = false, int angle = 0) const;
/** CTexture::Render / RenderRotate: scale, rotation about the center, mirror and the visible part of the texture. */
void blitTo(Graphics::ManagedSurface &target, const Common::Point &position, const struct RenderParams ¶ms) const;
@@ -145,6 +157,8 @@ protected:
int _width;
int _height;
Common::ScopedPtr<Bitmap> _bitmap;
+ int _loadCount = 0; // CTexture +28
+ bool _fileMissing = false; // the file of an XML texture is not there: it is not asked for again
int _hasMirroredBitmap;
Common::ScopedPtr<MemoryObject2> _memoryObject2;
int _alpha;
@@ -226,6 +240,10 @@ public:
virtual bool load(MfcArchive &file, bool bigPicture);
bool load(MfcArchive &file) override { assert(0); return false; } // Disable base class
+ /** CPictureObject::Load / Unload (Android): the result is the size loaded / freed */
+ uint load();
+ uint unload();
+ bool isTextureLoaded() const { return _picture && _picture->isTextureLoaded(); }
Dims getFullSize() const { return _picture->getDimensions(); }
void render(Common::Point scroll = Common::Point());
Commit: 6b0326244a9f6397d90772f8b2cb84cbaec845a4
https://github.com/scummvm/scummvm/commit/6b0326244a9f6397d90772f8b2cb84cbaec845a4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: GuiManager loads and unloads the textures of its elements (CGuiManager::Load, Unload)
Changed paths:
engines/ngi/guimanager.cpp
engines/ngi/guimanager.h
diff --git a/engines/ngi/guimanager.cpp b/engines/ngi/guimanager.cpp
index bf2bd1318b6..35e44a08c47 100644
--- a/engines/ngi/guimanager.cpp
+++ b/engines/ngi/guimanager.cpp
@@ -112,6 +112,9 @@ public:
class GuiPicture : public GuiElement {
public:
GuiPicture(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids) : GuiElement(scene, attrs, ids) {}
+ // CGuiPicture::Load and Unload
+ uint loadTexture() override { return _picture ? _picture->load() : 0; }
+ uint unloadTexture() override { return _picture ? _picture->unload() : 0; }
void render(Graphics::ManagedSurface &target) const override {
if (_visible && _picture)
_picture->_picture->blitTo(target, screenPos());
@@ -140,6 +143,15 @@ void GuiProgressBar::load(GameProject &project) {
}
}
+// CGuiProgressBar::Load and Unload: the picture of the bar
+uint GuiProgressBar::loadTexture() {
+ return _vis ? _vis->load() : 0;
+}
+
+uint GuiProgressBar::unloadTexture() {
+ return _vis ? _vis->unload() : 0;
+}
+
void GuiProgressBar::unload() {
GuiElement::unload();
_vis = nullptr;
@@ -183,6 +195,8 @@ public:
GuiButton(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids);
void load(GameProject &project) override;
void unload() override;
+ uint loadTexture() override;
+ uint unloadTexture() override;
void activate() override;
void render(Graphics::ManagedSurface &target) const override;
bool hit(Common::Point pos) const override;
@@ -239,6 +253,25 @@ void GuiButton::unload() {
picture = nullptr;
}
+// CGuiButton::Load and Unload (1010F0): the picture and the pictures of the states
+uint GuiButton::loadTexture() {
+ uint size = _picture ? _picture->load() : 0;
+ for (PictureObject *picture : _pictures) {
+ if (picture)
+ size += picture->load();
+ }
+ return size;
+}
+
+uint GuiButton::unloadTexture() {
+ uint size = _picture ? _picture->unload() : 0;
+ for (PictureObject *picture : _pictures) {
+ if (picture)
+ size += picture->unload();
+ }
+ return size;
+}
+
void GuiButton::activate() {
GuiElement::activate();
onMouseMove(g_system->getEventManager()->getMousePos() - Common::Point(g_ngi->_wideOfs, 0));
@@ -514,6 +547,22 @@ void GuiManager::unload() {
entry.second->unload();
}
+// CGuiManager::Load (100558)
+uint GuiManager::loadTextures() {
+ uint size = 0;
+ for (const auto &entry : _elements)
+ size += entry.second->loadTexture();
+ return size;
+}
+
+// CGuiManager::Unload (100580)
+uint GuiManager::unloadTextures() {
+ uint size = 0;
+ for (const auto &entry : _elements)
+ size += entry.second->unloadTexture();
+ return size;
+}
+
bool GuiManager::update(uint32 elapsed) {
bool changed = false;
for (const auto &entry : _elements)
diff --git a/engines/ngi/guimanager.h b/engines/ngi/guimanager.h
index 5bab9c4523a..1122639f861 100644
--- a/engines/ngi/guimanager.h
+++ b/engines/ngi/guimanager.h
@@ -45,6 +45,9 @@ public:
virtual ~GuiElement() {}
virtual void load(GameProject &project);
virtual void unload() { _picture = nullptr; }
+ /** CGuiElement::Load and Unload (Android): returns the size, the base has none */
+ virtual uint loadTexture() { return 0; }
+ virtual uint unloadTexture() { return 0; }
virtual bool update(uint32 elapsed) { return false; }
virtual void onKeyDown(Common::KeyCode key) {}
virtual void onKeyUp(Common::KeyCode key) {}
@@ -86,6 +89,8 @@ public:
GuiProgressBar(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids);
void load(GameProject &project) override;
void unload() override;
+ uint loadTexture() override;
+ uint unloadTexture() override;
void render(Graphics::ManagedSurface &target) const override;
/** CArcadeInterface::Update sets the fraction to this (0..1) */
void setFraction(float perc) { _fraction = perc; }
@@ -150,6 +155,9 @@ public:
void onChar(uint16 ch);
bool update(uint32 elapsed);
void unload();
+ /** CGuiManager::Load and Unload: the sum of the elements */
+ uint loadTextures();
+ uint unloadTextures();
bool hit(Common::Point pos) const;
int getCursorType(Common::Point pos) const;
bool isCursorObjectRender(Common::Point pos) const;
Commit: 0c0fcbe7f534fe8e9a6b67707812059c4266d46b
https://github.com/scummvm/scummvm/commit/0c0fcbe7f534fe8e9a6b67707812059c4266d46b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: Movement and AniObject load and unload their textures (CMovement::Load, CAniObject::Load, LoadMovement, PushToPreload)
Changed paths:
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index f48a94979ca..3dc1ec41524 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -26,6 +26,7 @@
#include "ngi/objects.h"
#include "ngi/ngiarchive.h"
#include "ngi/statics.h"
+#include "ngi/preloadmanager.h"
#include "ngi/messages.h"
#include "ngi/interaction.h"
#include "ngi/motion.h"
@@ -541,14 +542,70 @@ void Movement::draw(bool flipFlag, int angle) {
}
}
-void AniObject::loadMovements() {
+uint AniObject::loadMovements() {
+ uint size = 0;
for (uint i = 0; i < _movements.size(); i++)
- _movements[i]->load();
+ size += _movements[i]->load();
+ return size;
}
-void AniObject::unloadMovements() {
+uint AniObject::unloadMovements() {
+ uint size = 0;
for (uint i = 0; i < _movements.size(); i++)
- _movements[i]->unload();
+ size += _movements[i]->unload();
+ return size;
+}
+
+// CAniObject::LoadMovement (F0BD2)
+uint AniObject::loadMovement(int movementId) {
+ Movement *movement = getMovement(movementId);
+ return movement ? movement->load() : 0;
+}
+
+// CAniObject::UnloadMovement (F0C00)
+uint AniObject::unloadMovement(int movementId) {
+ Movement *movement = getMovement(movementId);
+ return movement ? movement->unload() : 0;
+}
+
+// CAniObject::Load (F0A1A)
+uint AniObject::load() {
+ uint size = 0;
+ for (Statics *statics : _staticsList)
+ size += statics->loadTexture();
+ if (_movement && !g_ngi->_preloadManager->isPreloaded(_movement->_id))
+ g_ngi->_preloadManager->onLoadMove(_movement->load());
+ return size;
+}
+
+// CAniObject::Unload (F0A82)
+uint AniObject::unload() {
+ uint size = 0;
+ for (Statics *statics : _staticsList)
+ size += statics->unloadTexture();
+ if (_movement && !g_ngi->_preloadManager->isPreloaded(_movement->_id))
+ g_ngi->_preloadManager->onUnloadMove(_movement->unload());
+ return size;
+}
+
+// CAniObject::IsTextureLoaded (F14D2)
+bool AniObject::isTextureLoaded() {
+ if (_movement)
+ return _movement->isTextureLoaded();
+ return _statics && _statics->isTextureLoaded();
+}
+
+// CAniObject::PushToPreload (F2980)
+void AniObject::pushToPreload(Scene *scene) {
+ // the original never makes the copy: it looks the movement up in this very animation
+ for (uint i = 0; i < _movements.size(); i++) {
+ Movement *source = _movements[i];
+ if (!source || getMovement(source->_id))
+ continue;
+ Movement *copy = new Movement(source, this);
+ _movements.push_back(copy);
+ g_ngi->_preloadManager->pushToPreload(scene, _id, copy->_id);
+ }
}
Statics *AniObject::addReverseStatics(Statics *st) {
@@ -1045,7 +1102,9 @@ L12:
_statics->_y = _y - point.y;
oid = _movement->_id;
if (g_ngi->_gameVersion >= 201509) {
- _movement->unload();
+ // CAniObject::StopMovement: the movement is unloaded unless the preload manager keeps it
+ if (!g_ngi->_preloadManager->isPreloaded(_movement->_id))
+ g_ngi->_preloadManager->onUnloadMove(_movement->unload());
for (int i = 0; i < g_ngi->_currSoundListCount; ++i)
g_ngi->_currSoundList1[i]->stopByCreator(_id);
_movement->_reverse = false;
@@ -1069,8 +1128,10 @@ L12:
} else {
if (_messageQueueId == oldmqid) {
_messageQueueId = 0;
- if (_field_34 == 1)
+ if (_field_34 == 1) {
+ debugC(1, kDebugInfo, "INFO t %u the movement of %d (%s) ends and goes on with the queue %d", g_system->getMillis(), _id, transCyrillic(_title), mqid);
updateGlobalMessageQueue(mqid, _id);
+ }
}
}
}
@@ -1130,7 +1191,8 @@ void AniObject::stopMovementToPrev(bool keepSounds) {
setPos(nowMirrored ? centerX + previous.x / 2 - some.x : centerX - previous.x / 2 + some.x, originY + some.y);
if (!keepSounds && g_ngi->_gameVersion >= 201509) {
- mov->unload();
+ if (!g_ngi->_preloadManager->isPreloaded(mov->_id))
+ g_ngi->_preloadManager->onUnloadMove(mov->unload());
for (int i = 0; i < g_ngi->_currSoundListCount; ++i)
g_ngi->_currSoundList1[i]->stopByCreator(_id);
}
@@ -1653,8 +1715,11 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
return false;
}
- if (timedMovement && _movement && (_flags & 1))
+ if (timedMovement && _movement && (_flags & 1)) {
+ debugC(1, kDebugInfo, "INFO t %u movement %d of %d is started while %d runs (frame %d of %d, queue %d, new queue %d)", g_system->getMillis(), movementId, _id,
+ _movement->_id, _movement->_curFrame, (int)_movement->_phases.size(), _messageQueueId, messageQueueId);
stopMovementToPrev(false); // CAniObject::StartMovement: a running movement is rewound to its previous statics first
+ }
if (mov == _movement) {
_flags |= 1;
@@ -2330,7 +2395,15 @@ Phase *Movement::getPhase(int idx) {
}
}
-void Movement::load() {
+uint Movement::load() {
+ if (g_ngi->_gameVersion >= 201509) {
+ // CMovement::Load (EF448): the last phase of an XML movement is the statics of the animation
+ uint size = 0;
+ for (uint i = 0; i + 1 < _phases.size(); ++i)
+ size += _phases[i]->loadTexture();
+ return _dxt ? size >> 2 : size;
+ }
+
Movement *mov = this;
while (mov->_currMovement)
mov = mov->_currMovement;
@@ -2342,14 +2415,16 @@ void Movement::load() {
if (!(mov->_prevStatic->_staticsId & 0x4000))
mov->_prevStatic->getPixelData();
+ return 0;
}
-void Movement::unload() {
+uint Movement::unload() {
if (g_ngi->_gameVersion >= 201509) {
- // XML movements borrow their last phase from the actor's statics.
+ // CMovement::Unload (EF4B0)
+ uint size = 0;
for (uint i = 0; i + 1 < _phases.size(); ++i)
- _phases[i]->unload();
- return;
+ size += _phases[i]->unloadTexture();
+ return _dxt ? size >> 2 : size;
}
if (!_currMovement)
for (uint i = 0; i < _phases.size(); i++)
@@ -2357,6 +2432,12 @@ void Movement::unload() {
if (_prevStatic)
_prevStatic->unload();
+ return 0;
+}
+
+// CMovement::IsTextureLoaded (EEAEE): the current phase
+bool Movement::isTextureLoaded() const {
+ return _curPhase && _curPhase->isTextureLoaded();
}
void Movement::removeFirstPhase() {
@@ -2693,19 +2774,8 @@ Common::String Phase::toXML() {
StaticPhase::toXML().c_str());
}
-void Phase::setPNG(const Common::Path &path, const Dims &size) {
- _memfilename = path;
- _width = size.x;
- _height = size.y;
-}
-
-void Phase::loadTexture() {
- if (!_bitmap && !_memfilename.empty())
- loadPNG(_memfilename, getDimensions());
-}
-
void Phase::enter(int objectId) {
- loadTexture();
+ loadIfNeeded();
if (_soundId && g_ngi->_soundEnabled)
g_ngi->playSound(_soundId, _loopSound, objectId);
if (_command) {
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index 8cb4fcb276d..9ad644c936c 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -82,9 +82,6 @@ class Phase : public StaticPhase {
public:
Phase();
Phase(Phase *src, bool reverse);
- void setPNG(const Common::Path &path, const Dims &size);
- /** the texture of the phase is loaded now, not when the phase is entered the first time */
- void loadTexture();
void enter(int objectId);
bool load(MfcArchive &file) override;
@@ -124,6 +121,8 @@ class Movement : public GameObject {
Statics *_nextStatic;
bool _mirrorPrev = false;
bool _mirrorNext = false;
+ /** CMovement +62, XML "dxt": compressed textures, sizes count a quarter */
+ bool _dxt = false;
/** CMovement +60, +61: starts again when over, plays backwards */
bool _cycled = false;
bool _reverse = false;
@@ -183,8 +182,11 @@ class Movement : public GameObject {
void gotoFirstFrame();
void setLast();
- void load();
- void unload();
+ /** CMovement::Load and Unload (Android): returns the size loaded / freed (a quarter for "dxt") */
+ uint load();
+ uint unload();
+ /** CMovement::IsTextureLoaded: the texture of the current phase is there */
+ bool isTextureLoaded() const;
void draw(bool flipFlag, int angle);
};
@@ -245,8 +247,19 @@ public:
void startMQIfIdle(int qId, int flag);
void initMovements();
- void loadMovements();
- void unloadMovements();
+ /** CAniObject::LoadMovements and UnloadMovements (Android), Windows: 0 */
+ uint loadMovements();
+ uint unloadMovements();
+ /** CAniObject::LoadMovement and UnloadMovement: one movement by id */
+ uint loadMovement(int movementId);
+ uint unloadMovement(int movementId);
+ /** CAniObject::Load and Unload (Android): all statics, the current movement if not preloaded */
+ uint load();
+ uint unload();
+ /** CAniObject::IsTextureLoaded */
+ bool isTextureLoaded();
+ /** CAniObject::PushToPreload: copies the movements the scene lacks into it, preloads them */
+ void pushToPreload(Scene *scene);
void preloadMovements(MovTable *mt);
void setTargetFrame(int val) { _targetFrame = val; }
Commit: b8a5d9c5f477111f715780255ae0f326780d60db
https://github.com/scummvm/scummvm/commit/b8a5d9c5f477111f715780255ae0f326780d60db
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: Scene loads and unloads its pictures, animations and roamings (CScene::LoadPictures to UnloadRoamings, GetLoadingPercent)
Changed paths:
engines/ngi/scene.h
engines/ngi/scenecontroller.h
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index a6ced9f2766..c5f621d9c74 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -52,6 +52,28 @@ class Scene : public Background {
// Non-owning references to pictures of other scenes (XML ADDPIC, CScene roaming pictures).
Common::Array<PictureObject *> _roamingPictures;
PicAniInfoList _roamingObjects;
+ /** Non-owning: animations of other scenes that this scene shows (ADDANI), CScene +156 */
+ Common::Array<AniObject *> _roamingAnis;
+ /** CScene +309, the attribute "picNotLoad": the pictures are not loaded with the scene */
+ bool _picNotLoad = false;
+ /** CScene +356, +360: the objects a load goes through and how many are done */
+ uint _loadingTotal = 0;
+ uint _loadingCurrent = 0;
+ void updateLoadingTotal();
+ void resetCurrLoadingObj() { _loadingCurrent = 0; }
+ uint getLoadingPercent();
+ // CScene::LoadPictures ... UnloadAdditonal (CPreloadManager calls them), each returns the size;
+ // the wait screen runs after each object ("waitscreen"); "all" adds the roamings of scenes below
+ uint loadPictures();
+ uint unloadPictures();
+ uint loadAnis();
+ uint unloadAnis();
+ uint loadRoamings(bool all);
+ uint unloadRoamings(bool all);
+ uint loadMovement(int aniId, int movementId);
+ uint unloadMovement(int aniId, int movementId);
+ uint loadAdditional();
+ uint unloadAdditional();
Common::Array<Entrance> _entrances;
int16 _heroId = 0;
/** CScene::GetSceneDims (CScene+312): the SCENE attributes width and height, the screen size when missing (Android) */
diff --git a/engines/ngi/scenecontroller.h b/engines/ngi/scenecontroller.h
index 73828763931..a7b693bb8e4 100644
--- a/engines/ngi/scenecontroller.h
+++ b/engines/ngi/scenecontroller.h
@@ -74,8 +74,9 @@ public:
virtual void executeUserCmd(Command *cmd, MessageQueue *queue) {}
/** True while the command still waits (CMessageQueue::UpdateUserCmd goes on when it returns 0) */
virtual bool updateUserCmd(Command *cmd, uint32 elapsed) { return false; }
- virtual bool loadAdditional() { return false; }
- virtual bool unloadAdditional() { return false; }
+ /** True while the command still waits (CMessageQueue::UpdateUserCmd goes on at 0) */
+ virtual uint loadAdditional() { return 0; }
+ virtual uint unloadAdditional() { return 0; }
virtual bool isInventoryEnabled() { return false; }
virtual bool isInventoryRendered() { return false; }
virtual Common::String getInventorySavePath() { return Common::String(); }
Commit: 4d6c458a7f009d534fe239a1efd99d429e413be1
https://github.com/scummvm/scummvm/commit/4d6c458a7f009d534fe239a1efd99d429e413be1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: XML scenes: the PRELOAD items go to the PreloadManager and the textures are read when the scene is loaded
Changed paths:
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index d8ce4251517..14950ee9931 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -56,6 +56,7 @@
#include "ngi/fullpipe/objhelper.h"
#include "ngi/fullpipe/tutorialmanager.h"
#include "ngi/fullpipe/waitscreen.h"
+#include "ngi/preloadmanager.h"
#include "ngi/fullpipe/hintmanager.h"
#include "ngi/fullpipe/help.h"
#include "ngi/fullpipe/noactionlogger.h"
@@ -522,7 +523,10 @@ private:
void loadTexture(Texture &texture, const Common::String &resource, bool localized) {
const Common::Path path = texturePath(resource, localized);
- texture.loadPNG(path, _project._textureSizes.getValOrDefault(path));
+ if (g_ngi->_gameVersion >= 201509)
+ texture.setPNG(path, _project._textureSizes.getValOrDefault(path)); // CPreloadManager loads it
+ else
+ texture.loadPNG(path, _project._textureSizes.getValOrDefault(path));
}
CUSTOM_XML_PARSER(XMLSceneParser) {
@@ -1098,10 +1102,8 @@ private:
return true;
}
- // CPreloadManager::AddItems: the list of the animations and movements that the scene loads into GPU memory before it is
- // shown. The software renderer decodes the textures when they are first drawn, so the list is not needed.
+ // CPreloadManager::AddItems: its ITEMs are read in parserCallback_ITEM
bool parserCallback_PRELOAD(ParserNode *node) {
- node->ignore = true;
return true;
}
@@ -1130,6 +1132,16 @@ private:
// ITEM of ZCONTROLLER (CZController::CZController): IdScene names the scene of an object that is not in this one.
// The ITEM of PRELOAD is skipped with its parent.
bool parserCallback_ITEM(ParserNode *node) {
+ if (getParentNode(node)->name == "PRELOAD") {
+ // CPreloadManager::AddItems (11AB0C): the scene, the animation and the movement
+ int16 aniId = 0;
+ int16 movementId = 0;
+ if (!readId(node->values["ani"], aniId) || !readId(node->values["move"], movementId))
+ return parserError("Unknown preloaded movement " + node->values["ani"] + " " + node->values["move"]);
+ if (g_ngi->_preloadManager)
+ g_ngi->_preloadManager->addItem(static_cast<uint16>(_scene._sceneId), static_cast<uint16>(aniId), static_cast<uint16>(movementId));
+ return true;
+ }
if (getParentNode(node)->name != "ZCONTROLLER") {
warning("STUB: XML <ITEM>");
node->ignore = true;
@@ -1739,8 +1751,6 @@ const char *NGIEngine::getResourceLocale() const {
}
}
-static void loadSceneTextures(Scene &scene);
-
void SceneTag::loadSceneXML(const GameProject &project) {
Common::ScopedPtr<Scene> scene(new Scene());
scene->_sceneId = _sceneId;
@@ -1759,9 +1769,7 @@ void SceneTag::loadSceneXML(const GameProject &project) {
debugC(1, kDebugXML, "Loaded Full Pipe scene %s with %u pictures and %u animations",
_tag.c_str(), scene->_pictureObjects.size(), scene->_aniObjects.size());
- // the wait screen shows how far the textures of the scene are loaded (CScene::LoadPictures)
- if (g_ngi->_waitScreen && scene->_waitscreen && g_ngi->_gameVersion >= 201509)
- loadSceneTextures(*scene);
+ scene->updateLoadingTotal();
delete _scene;
_scene = scene.release();
// exits.xml exists from the 2015 revision on (the original reads all scenes at once)
@@ -1785,23 +1793,6 @@ static bool createWaitScreen(GameProject &project) {
return true;
}
-// CScene::LoadPictures and LoadAnis: the pictures and then the animations of the scene are loaded one after the other (CAniObject::LoadMovements loads the phases of all
-// its movements), and after each object the wait screen shows the part that is loaded (CScene::GetLoadingPercent, in thousandths). The pictures and the poses are loaded
-// by the parser already, so their step only reports the percent (the original has a preload manager that loads and frees the textures of the scenes, it is not ported).
-static void loadSceneTextures(Scene &scene) {
- const uint total = scene._pictureObjects.size() + scene._aniObjects.size();
- uint loaded = 0;
- for (uint i = 0; i < scene._pictureObjects.size(); i++)
- callWaitScreen(MIN<uint>(1000, ++loaded * 1000 / MAX<uint>(1, total)));
- for (AniObject *ani : scene._aniObjects) {
- for (Movement *movement : ani->_movements) {
- for (Phase *phase : movement->_phases)
- phase->loadTexture();
- }
- callWaitScreen(MIN<uint>(1000, ++loaded * 1000 / MAX<uint>(1, total)));
- }
-}
-
// CGame::CreateContent: the inventory is the scene 0, read from inventory.xml for create_inv
static bool createInventory(GameProject &project) {
Common::ScopedPtr<Inventory> inventory(new Inventory());
@@ -1859,8 +1850,10 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
_gameProject.reset(new GameProject());
GameProject &project = *_gameProject;
g_ngi->_gameProject = _gameProject.get(); // the controllers find their scenes while the data loads
- if (g_ngi->_gameVersion >= 201509)
- g_ngi->_exitManager.reset(new ExitManager); // before the scenes: they ask it for their exits when they load
+ if (g_ngi->_gameVersion >= 201509) {
+ g_ngi->_preloadManager.reset(new PreloadManager); // before the scenes
+ g_ngi->_exitManager.reset(new ExitManager); // before the scenes
+ }
XMLTextureSizeParser(project).loadSizes();
if (!project._objectIds.load("data/obj.h"))
return Common::Error(Common::kNoGameDataFoundError, "Could not read the Full Pipe object IDs");
Commit: c551143e2ba7e618ede83119967efde163d130c4
https://github.com/scummvm/scummvm/commit/c551143e2ba7e618ede83119967efde163d130c4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: WaitScreen: the load of the bar and the percent come from the PreloadManager
Changed paths:
engines/ngi/fullpipe/waitscreen.cpp
engines/ngi/fullpipe/waitscreen.h
diff --git a/engines/ngi/fullpipe/waitscreen.cpp b/engines/ngi/fullpipe/waitscreen.cpp
index f927bea9c81..2ff790daae6 100644
--- a/engines/ngi/fullpipe/waitscreen.cpp
+++ b/engines/ngi/fullpipe/waitscreen.cpp
@@ -48,21 +48,6 @@ void WaitScreenController::onUpdate(uint32 percent) {
_bar->setCurFrame(_lastFrame * (int)percent / 1000, false, false);
}
-// CGame::DoSetScene: CPreloadManager::LoadScene(1) (the PRELOAD item is ANI_PBAR with MV_PBAR_RUN) and the OnShow of the wait screen. The phases are loaded after
-// the OnShow here: the StartMovement of a bar that is shown the second time rewinds it, which frees its phases (the original has the preload manager do it).
-void showWaitScreen() {
- Scene *scene = g_ngi->_waitScreen;
- if (!scene)
- return;
- scene->onShow();
- for (const AniObject *ani : scene->_aniObjects) {
- for (const Movement *movement : ani->_movements) {
- for (Phase *phase : movement->_phases)
- phase->loadTexture();
- }
- }
-}
-
// CGame::CallWaitScreen (FC1F0), CWaitScreen::Update (128448), CWaitScreen::Render (128568)
void callWaitScreen(uint percent) {
static bool rendering = false;
diff --git a/engines/ngi/fullpipe/waitscreen.h b/engines/ngi/fullpipe/waitscreen.h
index 7b5d8f40260..b5b47934519 100644
--- a/engines/ngi/fullpipe/waitscreen.h
+++ b/engines/ngi/fullpipe/waitscreen.h
@@ -47,12 +47,6 @@ private:
/** CGame::CallWaitScreen: percent in thousandths */
void callWaitScreen(uint percent);
-/**
- * The start of CGame::DoSetScene before a scene is loaded: CPreloadManager::LoadScene(1) loads the PRELOAD item of the wait screen (the phases of MV_PBAR_RUN),
- * then the OnShow of the scene.
- */
-void showWaitScreen();
-
} // End of namespace NGI
#endif // NGI_FULLPIPE_WAITSCREEN_H
Commit: 62c8f6896e856c86804e5d5cc5ad10b9bb87e22c
https://github.com/scummvm/scummvm/commit/62c8f6896e856c86804e5d5cc5ad10b9bb87e22c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: DoSetScene, PushScene, PopScene and the start of the game use the PreloadManager; debug flag skipIntro
Changed paths:
engines/ngi/detection.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/fullpipe/tutorialmanager.cpp
engines/ngi/fullpipe/tutorialmanager.h
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/scene.cpp
diff --git a/engines/ngi/detection.cpp b/engines/ngi/detection.cpp
index 5b30252ff34..01a18190bc1 100644
--- a/engines/ngi/detection.cpp
+++ b/engines/ngi/detection.cpp
@@ -42,6 +42,7 @@ static const DebugChannelDef debugFlagList[] = {
{NGI::kDebugBounds, "bounds", "Outlines of the objects, hit regions and z controller"},
{NGI::kDebugInfo, "info", "Log the state of Dude (movement, phase, position) whenever it changes"},
{NGI::kDebugFast, "fast", "Six times faster game, for test runs"},
+ {NGI::kDebugSkipIntro, "skipIntro", "Starts without the initial tutorial (the Skip button of it is pressed at the start)"},
DEBUG_CHANNEL_END
};
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index 15661218454..c19f437b950 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -20,6 +20,7 @@
*/
#include "ngi/ngi.h"
+#include "ngi/preloadmanager.h"
#include "ngi/utils.h"
#include "ngi/objects.h"
@@ -623,6 +624,7 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
return false;
scene->_commonQueueScene = common == scene ? nullptr : common;
scene->_roamingPictures.clear();
+ scene->_roamingAnis.clear();
for (const PicAniInfo &ref : scene->_roamingObjects) {
Scene *source = findScene(ref.sceneId);
if (!source)
@@ -665,8 +667,10 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
}
if (!actor)
return false;
- if (!scene->findAniObjectById(ref.objectId, ref.copyId))
+ if (!scene->findAniObjectById(ref.objectId, ref.copyId)) {
scene->_renderableAnis.push_back(actor);
+ scene->_roamingAnis.push_back(actor);
+ }
if (ref.staticsId)
actor->_statics = actor->getStatic(ref.staticsId);
actor->setPos(ref.ox == -1 ? actor->_x : ref.ox, ref.oy == -1 ? actor->_y : ref.oy);
@@ -684,6 +688,8 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
if (scene->_heroId && !_aniMan)
return false;
+ scene->updateLoadingTotal(); // CScene::Init sums the objects after AddRoamingObjects
+
clearGlobalMessageQueueList1();
removeMessageHandler(2, -1);
stopAllSounds(Sound::kSpeech);
@@ -700,8 +706,19 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
if (usesXMLProject()) {
// CGame::DoSetScene: every scene of the stack is hidden (CScene::OnHide), bottom first
+ scene->resetCurrLoadingObj();
for (uint i = 0; i < _sceneStack.size(); i++)
_sceneStack[i]->onHide();
+ if (_preloadManager) {
+ // the wait screen shows while textures of the left scenes are freed and the new scene's loaded
+ if (_waitScreen) {
+ _preloadManager->loadScene(1);
+ _waitScreen->onShow();
+ }
+ _preloadManager->setScene(scene->_sceneId);
+ if (_waitScreen)
+ _preloadManager->unloadScene(1);
+ }
} else if (_currentScene && _currentScene->_guiManager) {
_currentScene->_guiManager->onHide();
}
diff --git a/engines/ngi/fullpipe/tutorialmanager.cpp b/engines/ngi/fullpipe/tutorialmanager.cpp
index ae71666bee3..65c8a84d4f0 100644
--- a/engines/ngi/fullpipe/tutorialmanager.cpp
+++ b/engines/ngi/fullpipe/tutorialmanager.cpp
@@ -196,13 +196,14 @@ bool TutorialManager::showTutorial(Tutorial *tutorial) {
}
// CTutorialManager::Deactivate (1A2FD8)
-void TutorialManager::deactivate() {
+void TutorialManager::deactivate(bool sendMessage) {
_active = false;
for (uint i = 0; i < _tutorials.size(); i++) {
if (!_tutorials[i]->_isExtra && !_tutorials[i]->_isArcade)
_tutorials[i]->setState(4);
}
- g_ngi->getSceneInStack(0)->message("MSG_GAMECENTER_TRY", "", nullptr);
+ if (sendMessage)
+ g_ngi->getSceneInStack(0)->message("MSG_GAMECENTER_TRY", "", nullptr);
}
// CTutorialManager::ActivateTutorialAnyScene (1A3064): when the scene stack has only one scene
diff --git a/engines/ngi/fullpipe/tutorialmanager.h b/engines/ngi/fullpipe/tutorialmanager.h
index a7941e9eebd..2b8637a9bdc 100644
--- a/engines/ngi/fullpipe/tutorialmanager.h
+++ b/engines/ngi/fullpipe/tutorialmanager.h
@@ -86,8 +86,8 @@ public:
void init(const char *path);
void activate() { _active = true; }
bool isActive() const { return _active; }
- /** CTutorialManager::Deactivate: the tutorials that are not extra and not arcade finish */
- void deactivate();
+ /** CTutorialManager::Deactivate: non-extra, non-arcade tutorials finish; no message if no scene */
+ void deactivate(bool sendMessage = true);
Tutorial *findTutorial(const Common::String &id) const;
Tutorial *findActiveTutorial() const;
void finishTutorial(const Common::String &id);
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 3a724d50775..d43d12e4330 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -43,6 +43,7 @@
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/exitmanager.h"
+#include "ngi/preloadmanager.h"
#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/objhelper.h"
#include "ngi/fullpipe/tutorialmanager.h"
@@ -474,6 +475,17 @@ Common::Error NGIEngine::run() {
if (bootScene && !bootScene->_entrances.empty())
startEntranceId = bootScene->_entrances.front()._id;
}
+ if (DebugMan.isDebugChannelEnabled(kDebugSkipIntro) && _tutorialManager && _taskManager) {
+ // --debugflags=skipIntro: what BTN_SKIP does (CTutorialController::OnGuiEvent), no tutorial
+ _tutorialManager->deactivate(false);
+ if (!_taskManager->isTaskClosed("FIND_DOMINO_SC3"))
+ _taskManager->activateTask("FIND_DOMINO_SC3");
+ if (!_taskManager->isTaskClosed("FIND_APPLE_SC4"))
+ _taskManager->activateTask("FIND_APPLE_SC4");
+ }
+ if (_preloadManager)
+ // CGame::OnShow: the inventory (cursors, buttons) is loaded before the first scene
+ _preloadManager->startGame();
if (!_gameLoader->setScene(startSceneId, startEntranceId))
return Common::Error(Common::kNoGameDataFoundError, "Could not load the Full Pipe start scene");
} else {
@@ -713,6 +725,7 @@ ArcadeInterface &NGIEngine::arcadeInterface() {
}
void NGIEngine::freeGameLoader() {
+ _preloadManager.reset();
// the effects of the tremble items belong to the scenes that are destroyed with the loader
_tremble.reset();
// the help items point into the scene SC_HELP and the interactions of the loader
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index cd949bed8b0..4dc2d1cda90 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -58,6 +58,7 @@ enum {
kDebugBounds,
kDebugInfo,
kDebugFast,
+ kDebugSkipIntro,
};
enum NGIActions {
@@ -97,6 +98,7 @@ class HintManager;
class Help;
class NoActionLogger;
class AchievementsManager;
+class PreloadManager;
class ObjHelperManager;
class ObjHelperHint;
class ExitManager;
@@ -318,6 +320,8 @@ public:
/** CSingleton<CObjHelperManager> (objhelpers.xml), CSingleton<CObjHelperHint> (objhints.xml) */
Common::ScopedPtr<ObjHelperManager> _objHelperManager;
Common::ScopedPtr<ObjHelperHint> _objHelperHint;
+ /** CSingleton<CPreloadManager>: the loading and freeing of the textures of the scenes (Android) */
+ Common::ScopedPtr<PreloadManager> _preloadManager;
/** CSingleton<CExitManager>: the exits of the scenes (Android) */
Common::ScopedPtr<ExitManager> _exitManager;
Common::ScopedPtr<Tremble> _tremble;
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 8c81b9ac321..2a5f7275703 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -23,6 +23,7 @@
#include "ngi/ngi.h"
#include "ngi/fullpipe/waitscreen.h"
+#include "ngi/preloadmanager.h"
#include "ngi/scenecontroller.h"
#include "ngi/fullpipe/fpcontroller.h"
@@ -105,10 +106,15 @@ void NGIEngine::pushScene(int sceneId) {
warning("Can't find scene");
return;
}
+ debugC(1, kDebugInfo, "INFO t %u scene %d is pushed", g_system->getMillis(), sceneId);
if (_sceneStack.empty() && _currentScene)
_sceneStack.push_back(_currentScene);
+ if (_preloadManager) {
+ // CScene::ResetCurrLoadingObj, CPreloadManager::PushScene: the textures load before the push
+ scene->resetCurrLoadingObj();
+ _preloadManager->pushScene(sceneId);
+ }
_sceneStack.push_back(scene);
- // CPreloadManager::PushScene and CScene::ResetCurrLoadingObj (the loading of the scenes) do not exist here
// CGame::PushScene (FE1D0): without putPrev all sounds pause, else those not music and not looped
if (!getCurrentScene()->_putPrev)
_soundManager.pauseAll();
@@ -121,17 +127,20 @@ void NGIEngine::pushScene(int sceneId) {
scene->onShow();
}
-// CGame::PopScene (FCBAC): the current scene is hidden, the sounds that were started in it stop, it is removed; the sounds of the scene below resume unless it has
-// its sound paused (CScene::IsSoundPaused). CPreloadManager::PopScene, CGame::OnMouseMove with the cursor and CRender::SetSrcRect are not ported.
+// CGame::PopScene (FCBAC): CGame::OnMouseMove with the cursor, CRender::SetSrcRect are not ported
void NGIEngine::popScene() {
Scene *scene = getCurrentScene();
if (!scene || _sceneStack.size() < 2) {
warning("No scene to pop");
return;
}
+ debugC(1, kDebugInfo, "INFO t %u scene %d is popped", g_system->getMillis(), scene->_sceneId);
+ if (_preloadManager)
+ _preloadManager->popScene(); // the textures of the scene that goes
scene->onHide();
_soundManager.stopInScene(scene->_sceneId);
_sceneStack.pop_back();
+ getCurrentScene()->resetCurrLoadingObj();
if (!getCurrentScene()->isSoundPaused())
_soundManager.resumeInScene(getCurrentScene()->_sceneId);
if (_sceneStack.size() < 2) {
@@ -243,10 +252,6 @@ Scene *GameProject::findScene(int sceneId) {
continue;
if (!tag._scene) {
if (g_ngi->usesXMLProject()) {
- // CGame::DoSetScene: CPreloadManager::LoadScene(1) and the OnShow of the wait screen (the bar starts at the first dot) come before the scene is
- // loaded, which the lookup does here
- if (g_ngi->_gameVersion >= 201509)
- showWaitScreen();
tag.loadSceneXML(*this);
if (tag._scene && tag._scene->_guiManager)
tag._scene->_guiManager->load(*this);
@@ -876,6 +881,137 @@ void Scene::renderDebug() {
// CMotion8Controller::RenderDbg (the grid) has no counterpart yet
}
+// CScene::Init (sum at +356): the objects that LoadPictures, LoadAnis and LoadRoamings go through
+void Scene::updateLoadingTotal() {
+ _loadingTotal = _aniObjects.size() + _pictureObjects.size() + _roamingPictures.size() + _roamingAnis.size();
+}
+
+// CScene::GetLoadingPercent (11FF90): one more object done, the share of all in thousandths
+uint Scene::getLoadingPercent() {
+ _loadingCurrent++;
+ if (!_loadingTotal)
+ return 1000;
+ return MIN<uint>(1000, (uint)((float)_loadingCurrent / (float)_loadingTotal * 1000.0f));
+}
+
+// CScene::LoadPictures (120ED4)
+uint Scene::loadPictures() {
+ uint size = 0;
+ if (!_picNotLoad) {
+ for (PictureObject *picture : _pictureObjects) {
+ size += picture->load();
+ if (_waitscreen)
+ callWaitScreen(getLoadingPercent());
+ }
+ for (PictureObject *picture : _roamingPictures) {
+ size += picture->load();
+ if (_waitscreen)
+ callWaitScreen(getLoadingPercent());
+ }
+ }
+ if (_guiManager)
+ size += _guiManager->loadTextures();
+ return size;
+}
+
+// CScene::UnloadPictures (120F74): the wait screen bar is at its start while textures are freed
+uint Scene::unloadPictures() {
+ uint size = 0;
+ if (_guiManager)
+ size += _guiManager->unloadTextures();
+ for (PictureObject *picture : _pictureObjects) {
+ size += picture->unload();
+ if (_waitscreen)
+ callWaitScreen(0);
+ }
+ for (PictureObject *picture : _roamingPictures) {
+ size += picture->unload();
+ if (_waitscreen)
+ callWaitScreen(0);
+ }
+ return size;
+}
+
+// CScene::LoadAnis (120FF4)
+uint Scene::loadAnis() {
+ uint size = 0;
+ for (AniObject *ani : _aniObjects) {
+ size += ani->load();
+ if (_waitscreen)
+ callWaitScreen(getLoadingPercent());
+ }
+ return size;
+}
+
+// CScene::UnloadAnis (12103C)
+uint Scene::unloadAnis() {
+ uint size = 0;
+ for (AniObject *ani : _aniObjects) {
+ size += ani->unload();
+ if (_waitscreen)
+ callWaitScreen(0);
+ }
+ return size;
+}
+
+// roaming animations that no scene below in the stack owns (CScene::LoadRoamings, "all" 0)
+static bool roamingIsFree(const AniObject *ani) {
+ for (uint i = 0; i + 1 < g_ngi->_sceneStack.size(); i++) {
+ if (g_ngi->_sceneStack[i]->_sceneId == ani->_sceneId)
+ return false;
+ }
+ return true;
+}
+
+// CScene::LoadRoamings (12107C)
+uint Scene::loadRoamings(bool all) {
+ uint size = 0;
+ for (AniObject *ani : _roamingAnis) {
+ debugC(4, kDebugLoading, "TryLoadRoamings, id = %s", g_ngi->gameIdToStr(ani->_id).c_str());
+ if (all || roamingIsFree(ani)) {
+ size += ani->load();
+ debugC(4, kDebugLoading, "LoadRoamings, id = %s", g_ngi->gameIdToStr(ani->_id).c_str());
+ if (_waitscreen && all)
+ callWaitScreen(getLoadingPercent());
+ }
+ }
+ return size;
+}
+
+// CScene::UnloadRoamings (1211B4)
+uint Scene::unloadRoamings(bool all) {
+ uint size = 0;
+ for (AniObject *ani : _roamingAnis) {
+ if (all || roamingIsFree(ani)) {
+ size += ani->unload();
+ debugC(4, kDebugLoading, "UnloadRoamings, id = %s", g_ngi->gameIdToStr(ani->_id).c_str());
+ if (_waitscreen)
+ callWaitScreen(0);
+ }
+ }
+ return size;
+}
+
+// CScene::LoadMovement (121FA0) and UnloadMovement (121FB6)
+uint Scene::loadMovement(int aniId, int movementId) {
+ AniObject *ani = findAniObjectById(aniId, 0);
+ return ani ? ani->loadMovement(movementId) : 0;
+}
+
+uint Scene::unloadMovement(int aniId, int movementId) {
+ AniObject *ani = findAniObjectById(aniId, 0);
+ return ani ? ani->unloadMovement(movementId) : 0;
+}
+
+// CScene::LoadAdditonal (11F484) and UnloadAdditonal (11F496): the controller
+uint Scene::loadAdditional() {
+ return _controller ? _controller->loadAdditional() : 0;
+}
+
+uint Scene::unloadAdditional() {
+ return _controller ? _controller->unloadAdditional() : 0;
+}
+
// CScene::OnShow (the parts that are ported): the controller, the behaviors
void Scene::onShow() {
if (_behaviorController)
Commit: 499c069bd9aca9ba781d70bc67664712d938356a
https://github.com/scummvm/scummvm/commit/499c069bd9aca9ba781d70bc67664712d938356a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: Test mode: the visit action, the walks and the interrupted movements in the INFO log
Changed paths:
engines/ngi/debugger/testmode.cpp
engines/ngi/motion.cpp
diff --git a/engines/ngi/debugger/testmode.cpp b/engines/ngi/debugger/testmode.cpp
index be22313c8ee..8be3efb858c 100644
--- a/engines/ngi/debugger/testmode.cpp
+++ b/engines/ngi/debugger/testmode.cpp
@@ -61,11 +61,12 @@ const Spot kSpots[] = {
{ SC_4, 3, 1150, 476, 800, "scene 4: with the coin for the horn", ANI_INV_COIN },
};
-// --start-movie=<actions> (the string is free for the engine; the scripts take it from NGI_TEST_SETUP): actions that are done once, when Dude stands after the entrance queue, separated by ";":
-// state=Object:Value the state of an object of the game (UTF-8 names, e.g. state=ÐамаÑа:ÐгÑаеÑ)
-// item=ANI_INV_COIN an inventory item
-// scroll=x,y the camera
+// --start-movie=<actions> (NGI_TEST_SETUP): ';' separated, done once after the entrance queue:
+// state=Object:Value, item=ANI_INV_COIN, scroll=x,y, visit=1,2,1,3 (scenes in turn, 7 s each)
bool g_setupDone = false;
+Common::Array<int> g_visits;
+uint g_nextVisit = 0;
+uint32 g_visitTimer = 0;
Common::String toGameEncoding(const Common::String &utf8) {
return Common::U32String(utf8, Common::kUtf8).encode(Common::kWindows1251);
@@ -103,6 +104,11 @@ void runSetup() {
g_ngi->_currentScene->_y = y;
g_ngi->_sceneRect.moveTo(x, y);
}
+ } else if (key == "visit") {
+ Common::StringTokenizer scenes(value, ",");
+ while (!scenes.empty())
+ g_visits.push_back(atoi(scenes.nextToken().c_str()));
+ g_visitTimer = 7000;
}
}
}
@@ -227,6 +233,17 @@ void testmode_update(uint32 elapsed) {
}
}
+ if (g_setupDone && g_nextVisit < g_visits.size()) {
+ g_visitTimer += elapsed;
+ if (g_visitTimer >= 7000) {
+ g_visitTimer = 0;
+ const int sceneId = g_ngi->convertScene(g_visits[g_nextVisit++]);
+ warning("TESTMODE: visit scene %d", sceneId);
+ g_ngi->_gameLoader->setScene(sceneId, 0);
+ return;
+ }
+ }
+
if ((g_setupDone && !g_spot) || !hero || !g_ngi->_currentScene)
return;
diff --git a/engines/ngi/motion.cpp b/engines/ngi/motion.cpp
index 20504b73226..182b64fbae4 100644
--- a/engines/ngi/motion.cpp
+++ b/engines/ngi/motion.cpp
@@ -309,6 +309,9 @@ MessageQueue *MctlCompound::makeQueue(AniObject *subj, int xpos, int ypos, int f
if (!subj)
return nullptr;
+ // --debugflags=info: logged walks (scripts/ngi_play_actions.sh keeps them)
+ debugC(1, kDebugInfo, "INFO t %u WALK of %d from %d,%d to %d,%d fuzzy %d statics %d", g_system->getMillis(), subj->_id, subj->_x, subj->_y, xpos, ypos, fuzzyMatch, staticsId);
+
for (uint i = 0; i < _motionControllers.size(); i++) {
if (_motionControllers[i]->_movGraphReactObj) {
if (_motionControllers[i]->_movGraphReactObj->hitTest(subj->_x, subj->_y)) {
@@ -318,8 +321,10 @@ MessageQueue *MctlCompound::makeQueue(AniObject *subj, int xpos, int ypos, int f
}
}
- if (match1 == -1)
+ if (match1 == -1) {
+ debugC(1, kDebugInfo, "INFO t %u WALK refused: the start %d,%d is on no motion controller", g_system->getMillis(), subj->_x, subj->_y);
return nullptr;
+ }
for (uint i = 0; i < _motionControllers.size(); i++) {
if (_motionControllers[i]->_movGraphReactObj) {
@@ -330,11 +335,16 @@ MessageQueue *MctlCompound::makeQueue(AniObject *subj, int xpos, int ypos, int f
}
}
- if (match2 == -1)
+ if (match2 == -1) {
+ debugC(1, kDebugInfo, "INFO t %u WALK refused: the target %d,%d is on no motion controller", g_system->getMillis(), xpos, ypos);
return nullptr;
+ }
- if (match1 == match2)
- return _motionControllers[match1]->_motionControllerObj->makeQueue(subj, xpos, ypos, fuzzyMatch, staticsId, mirror);
+ if (match1 == match2) {
+ MessageQueue *queue = _motionControllers[match1]->_motionControllerObj->makeQueue(subj, xpos, ypos, fuzzyMatch, staticsId, mirror);
+ debugC(1, kDebugInfo, "INFO t %u WALK %s", g_system->getMillis(), queue ? "queue made" : "refused: no path on the graph");
+ return queue;
+ }
double dist;
MctlConnectionPoint *closestP = getNextPoint(subj->_x, subj->_y, match1, xpos, ypos, match2, &dist);
@@ -2261,11 +2271,16 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
Common::Point point;
debugC(1, kDebugPathfinding, "MctlGraph::makeQueue(%d, %d, %d, %d, %d)", obj->_id, xpos, ypos, fuzzyMatch, staticsId);
+ // --debugflags=info: walks asked for and refusals
+ debugC(1, kDebugInfo, "INFO t %u WALK of %d from %d,%d to %d,%d fuzzy %d statics %d%s", g_system->getMillis(), obj->_id, obj->_x, obj->_y, xpos, ypos, fuzzyMatch, staticsId,
+ obj->_movement ? " (while a movement runs)" : "");
int idx = getObjIndex(obj->_id);
- if (idx < 0)
+ if (idx < 0) {
+ debugC(1, kDebugInfo, "INFO t %u WALK refused: the object %d is not in this graph", g_system->getMillis(), obj->_id);
return nullptr;
+ }
linkInfoSource.link = nullptr;
linkInfoSource.node = nullptr;
@@ -2305,8 +2320,10 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
idxsub = getDirByPoint(idx, obj);
subMgm = true;
- if (idxsub == -1)
+ if (idxsub == -1) {
+ debugC(1, kDebugInfo, "INFO t %u WALK refused: no direction for the statics of the object", g_system->getMillis());
return nullptr;
+ }
}
if (obj->_movement && revised) {
@@ -2392,6 +2409,7 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
linkInfoSource.link = getNearestLink(obj->_x, obj->_y);
if (!linkInfoSource.link) {
+ debugC(1, kDebugInfo, "INFO t %u WALK refused: no link near the start %d,%d", g_system->getMillis(), obj->_x, obj->_y);
obj->setPicAniInfo(picAniInfo);
return nullptr;
@@ -2405,6 +2423,7 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
linkInfoDest.link = getHitLink(xpos, ypos, idxsub, fuzzyMatch);
if (!linkInfoDest.link) {
+ debugC(1, kDebugInfo, "INFO t %u WALK refused: the target %d,%d is on no node or link", g_system->getMillis(), xpos, ypos);
obj->setPicAniInfo(picAniInfo);
return nullptr;
@@ -2417,6 +2436,7 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
debugC(0, kDebugPathfinding, "MctlGraph::makeQueue(): path: %g parts: %d", minPath, tempLinkList.size());
if (minPath < 0.0 || ((linkInfoSource.node != linkInfoDest.node || !linkInfoSource.node) && !tempLinkList.size())) {
+ debugC(1, kDebugInfo, "INFO t %u WALK refused: no path (%g)", g_system->getMillis(), minPath);
if (revised)
obj->setPicAniInfo(picAniInfo);
return nullptr;
Commit: 2cc212258ed6df22207286510289a5844c485e19
https://github.com/scummvm/scummvm/commit/2cc212258ed6df22207286510289a5844c485e19
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: GUI pictures and buttons take their size from the texture when it is loaded (CGuiPicture::Load, CGuiButton::Load)
Changed paths:
engines/ngi/guimanager.cpp
diff --git a/engines/ngi/guimanager.cpp b/engines/ngi/guimanager.cpp
index 35e44a08c47..9b86fad0700 100644
--- a/engines/ngi/guimanager.cpp
+++ b/engines/ngi/guimanager.cpp
@@ -112,8 +112,13 @@ public:
class GuiPicture : public GuiElement {
public:
GuiPicture(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids) : GuiElement(scene, attrs, ids) {}
- // CGuiPicture::Load and Unload
- uint loadTexture() override { return _picture ? _picture->load() : 0; }
+ // CGuiPicture::Load and Unload: the size of the element is the one of the texture that was loaded
+ uint loadTexture() override {
+ const uint size = _picture ? _picture->load() : 0;
+ if (_picture)
+ _size = _picture->getFullSize();
+ return size;
+ }
uint unloadTexture() override { return _picture ? _picture->unload() : 0; }
void render(Graphics::ManagedSurface &target) const override {
if (_visible && _picture)
@@ -260,6 +265,9 @@ uint GuiButton::loadTexture() {
if (picture)
size += picture->load();
}
+ // the size of the first texture present: picture, disabled, pressed, selected
+ PictureObject *sized = _picture ? _picture : _pictures[kDisabled] ? _pictures[kDisabled] : _pictures[kPressed] ? _pictures[kPressed] : _pictures[kSelected];
+ _size = sized ? sized->getFullSize() : Common::Point();
return size;
}
Commit: a23294c8956fca0d3cdf8bc54fd51e4252dfcf12
https://github.com/scummvm/scummvm/commit/a23294c8956fca0d3cdf8bc54fd51e4252dfcf12
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: The textures of the second intro scene are loaded with the first, its skip button works again
Changed paths:
engines/ngi/fullpipe/scenes.cpp
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index c19f437b950..77d674b5ba4 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -716,6 +716,9 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
_waitScreen->onShow();
}
_preloadManager->setScene(scene->_sceneId);
+ // the second intro scene is shown by the first one's handler (sceneHandlerIntro_part2)
+ if (intro2)
+ _preloadManager->loadScene(SC_INTRO2);
if (_waitScreen)
_preloadManager->unloadScene(1);
}
Commit: 6d6f37a32ca73bf0751a74775389eaff3545ad90
https://github.com/scummvm/scummvm/commit/6d6f37a32ca73bf0751a74775389eaff3545ad90
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: AniObject::setCurFrame loads the texture of the phase it goes to, so the bar of the wait screen grows
Changed paths:
engines/ngi/statics.cpp
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 3dc1ec41524..569932f198b 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -1340,6 +1340,9 @@ void AniObject::setCurFrame(int frame, bool keepPhaseTimer, bool silent) {
warning("STUB/untested: CAniObject::SetCurFrame: the commands and sounds of the phases that are stepped over are not run, the flag +63 is not kept");
}
_movement->setCurFrame(frame);
+ // CMovement::SetFrame: the texture is loaded unless the preload manager keeps the movement (D27)
+ if (g_ngi->_gameVersion >= 201509 && g_ngi->_preloadManager && !g_ngi->_preloadManager->isPreloaded(_movement->_id))
+ _movement->_curPhase->loadIfNeeded();
setPos(_movement->_x, _movement->_y);
}
Commit: fc40ba45ac880e7c9a01bcc831850938229f0516
https://github.com/scummvm/scummvm/commit/fc40ba45ac880e7c9a01bcc831850938229f0516
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: The queue ids of the animations are cleared when the global queues are cleared (D30 mitigation)
Changed paths:
engines/ngi/messages.cpp
diff --git a/engines/ngi/messages.cpp b/engines/ngi/messages.cpp
index 8c0257b7b2e..4975e8ee243 100644
--- a/engines/ngi/messages.cpp
+++ b/engines/ngi/messages.cpp
@@ -863,6 +863,17 @@ void clearGlobalMessageQueueList1() {
clearMessages();
g_ngi->_globalMessageQueueList->clear();
+
+ // D30: no queue is left, so no animation can wait for one. The scenes stay loaded here (the original has no queue ids in its animations at all): an animation that goes on
+ // with a movement in a scene that is left would advance a new queue that gets its id (the ids are reused) when its movement ends
+ if (g_ngi->_gameVersion >= 201509 && g_ngi->_gameProject && g_ngi->_gameProject->_sceneTagList) {
+ for (SceneTag &tag : *g_ngi->_gameProject->_sceneTagList) {
+ if (!tag._scene)
+ continue;
+ for (AniObject *ani : tag._scene->_aniObjects)
+ ani->_messageQueueId = 0;
+ }
+ }
}
void clearMessages() {
Commit: 535b2aaec4302a8698ef0c0cea759f754fb08541
https://github.com/scummvm/scummvm/commit/535b2aaec4302a8698ef0c0cea759f754fb08541
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: INFO log of the interactions that are refused
Changed paths:
engines/ngi/interaction.cpp
diff --git a/engines/ngi/interaction.cpp b/engines/ngi/interaction.cpp
index b876eb84fd2..a74d514c075 100644
--- a/engines/ngi/interaction.cpp
+++ b/engines/ngi/interaction.cpp
@@ -104,15 +104,27 @@ void InteractionController::sortInteractions(int sceneId) {
bool InteractionController::handleInteraction(AniObject *subj, GameObject *obj, int invId) {
if (g_ngi->usesXMLProject()) {
- if (!_enabled || !subj || !obj || subj->_messageQueueId)
+ if (!_enabled || !subj || !obj || subj->_messageQueueId) {
+ debugC(1, kDebugInfo, "INFO t %u INTERACTION refused: enabled %d subject %p object %p subject queue %d", g_system->getMillis(), _enabled, (void *)subj, (void *)obj,
+ subj ? subj->_messageQueueId : -1);
return false;
+ }
Interact *action = nullptr;
for (Interact *candidate : _interactions) {
if (candidate->canRun(subj, obj, invId) && (!action || candidate->_weight > action->_weight))
action = candidate;
}
- if (!action)
+ if (!action) {
+ // --debugflags=info: why nothing can run (the statics of an animation has to be the one that the interaction wants)
+ const AniObject *ani = obj->_objtype == kObjTypeStaticANIObject ? static_cast<const AniObject *>(obj) : nullptr;
+ debugC(1, kDebugInfo, "INFO t %u INTERACTION refused: object %d item %d, its statics %d%s", g_system->getMillis(), obj->_id, invId, ani && ani->_statics ? ani->_statics->_staticsId : -1,
+ ani && ani->_movement ? " (a movement runs)" : "");
+ for (const Interact *candidate : _interactions) {
+ if (candidate->_objectId == obj->_id)
+ debugC(1, kDebugInfo, "INFO candidate: item %d statics %d flags %x activity %f scene %d", candidate->_cursorObjectId, candidate->_objectStaticId, candidate->_flags, candidate->_activity, candidate->_sceneId);
+ }
return false;
+ }
Common::ScopedPtr<MessageQueue> queue;
if (action->_heroId) {
int x = obj->_x + action->_heroOffsetX;
Commit: a2ded47673c84805187397b6ce6b617c54f7686e
https://github.com/scummvm/scummvm/commit/a2ded47673c84805187397b6ce6b617c54f7686e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: A tap walks Dude only without an object in the cursor (CFPController::OnMouseLKeyUp), INFO log of the drop of an item
Changed paths:
engines/ngi/fullpipe/fpcontroller.cpp
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 179527016fb..10aacbe8795 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -771,7 +771,9 @@ bool FPController::onMouseLKeyDown(uint32 id, float x, float y) {
// from the last target (CFPController::MctlStartMove with fuzzy 0, the motion controller decides what is reachable).
bool FPController::onTapWalk(float x, float y) {
MotionController *controller = _scene->_motionController.get();
- if (_swiped || !controller || !controller->_isEnabled || g_ngi->_currSelectedInventoryItemId || _interactObjectId)
+ // CFPController::OnMouseLKeyUp: the walk to the touch point is only done when no object is in the cursor (CCursorController +88); the item of a drop that is
+ // refused goes back to the bar and Dude stays
+ if (_swiped || !controller || !controller->_isEnabled || g_ngi->_inputController->getObjectId() || _interactObjectId)
return false;
if (checkBorders(x, y) != 0)
return moveBorders(x, y);
@@ -1015,16 +1017,25 @@ bool FPController::onTap(float tapX, float tapY) {
if (target && g_ngi->isAndroidFullPipe() && (target->_id == ANI_LIFT || (target->_id >= 23116 && target->_id <= 23125)) && g_ngi->lift().onButtonUp(target))
return true;
+ const int exactId = target ? target->_id : 0;
// CInteractionController::FindInteractionUnderCursor looks at the objects under the finger that take hits (the flag 2), the lowest z first: the pressed
// arrow of an exit is not one of them, the object below it is
{
const int heldItem = g_ngi->_inputController->getObjectId();
+ Common::String hits;
for (GameObject *object : g_ngi->_inputController->getHitObjects(&scene)) {
- if (canInteractAny(hero, object, heldItem)) {
+ const bool can = canInteractAny(hero, object, heldItem);
+ if (heldItem)
+ hits += Common::String::format(" %d(z %d%s)", object->_id, object->_z, can ? " can" : "");
+ if (can) {
target = object;
break;
}
}
+ // --debugflags=info: what a drop of an item meets (the objects at the hot spot of the cursor, the object at the exact point)
+ if (heldItem)
+ debugC(1, kDebugInfo, "INFO t %u TAP %d,%d with item %d: the object at the point %d, the hit objects:%s, the target %d", g_system->getMillis(), pos.x, pos.y, heldItem, exactId,
+ hits.c_str(), target ? target->_id : 0);
}
if (target) {
Commit: 343756bf27bccfe862fac2f709435aac90005e11
https://github.com/scummvm/scummvm/commit/343756bf27bccfe862fac2f709435aac90005e11
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: Sc01Controller runs the scene logic of scene 1 (CSc01Controller diffed against the assembly)
Changed paths:
engines/ngi/fullpipe/sc01controller.cpp
engines/ngi/fullpipe/sc01controller.h
diff --git a/engines/ngi/fullpipe/sc01controller.cpp b/engines/ngi/fullpipe/sc01controller.cpp
index e7c661a1f8d..0f4ee76657a 100644
--- a/engines/ngi/fullpipe/sc01controller.cpp
+++ b/engines/ngi/fullpipe/sc01controller.cpp
@@ -95,8 +95,8 @@ void Sc01Controller::onShow() {
_marginY = 200;
_offsetX = 400;
_offsetY = 300;
+ _field232 = false;
if (controllerRunsSceneLogic()) {
- _field232 = false;
_osk = _scene->findPictureObjectById(PIC_SC1_OSK, 0);
_osk->_flags &= ~4;
_osk2 = _scene->findPictureObjectById(PIC_SC1_OSK2, 0);
diff --git a/engines/ngi/fullpipe/sc01controller.h b/engines/ngi/fullpipe/sc01controller.h
index f5f3eb14bc5..dd87658f696 100644
--- a/engines/ngi/fullpipe/sc01controller.h
+++ b/engines/ngi/fullpipe/sc01controller.h
@@ -35,6 +35,8 @@ public:
explicit Sc01Controller(int sceneId);
void cleanXml() override;
+ /** the scene logic is this controller's (D02), scenes.cpp does not hook sceneHandler0N */
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onGuiEvent(const Common::String &id, const Common::String &event) override;
bool isInventoryEnabled() override;
Commit: fd47d49c8eee92f38a4f75950641a407ca0f9a6b
https://github.com/scummvm/scummvm/commit/fd47d49c8eee92f38a4f75950641a407ca0f9a6b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:05+01:00
Commit Message:
NGI: Sc02Controller runs the scene logic of scene 2 (VisitScene and SetStatic as in the assembly)
Changed paths:
engines/ngi/fullpipe/sc02controller.cpp
engines/ngi/fullpipe/sc02controller.h
diff --git a/engines/ngi/fullpipe/sc02controller.cpp b/engines/ngi/fullpipe/sc02controller.cpp
index 971d55a97d4..5b516574e90 100644
--- a/engines/ngi/fullpipe/sc02controller.cpp
+++ b/engines/ngi/fullpipe/sc02controller.cpp
@@ -78,14 +78,13 @@ void Sc02Controller::onClickLadder() {
warnOnce("CSc02Controller::OnClickLadder: CInteractionController::FindInteraction(scene, PIC_SC2_DTRUBA, -1) and CInteract::Run are not ported");
}
-// CSc02Controller::OnShow (1631A0): after CFPController::OnShow the scene is visited, the margins and offsets of the camera, the sleeping Guv the Drawer lies, the
-// ladder shows, the box opens after a time when it is closed, the flies of the scene (SC_2) are made; the tutorial of the egg is next (the one of the ladder is over).
-// Scene logic that sceneHandler02 does too (scene02_initScene) waits for controllerRunsSceneLogic().
+// CSc02Controller::OnShow (1631A0): visit the scene, camera, Guv, ladder, box, flies, then the
+// egg tutorial. The logic of scene02_initScene waits for controllerRunsSceneLogic();
+// VisitScene is unguarded (it adds the scene once)
void Sc02Controller::onShow() {
FPController::onShow();
const bool sceneLogic = controllerRunsSceneLogic();
- if (sceneLogic)
- g_ngi->_taskManager->visitScene(_scene->_sceneId);
+ g_ngi->_taskManager->visitScene(_scene->_sceneId);
_marginX = 300;
_marginY = 200;
_offsetX = 400;
@@ -93,7 +92,7 @@ void Sc02Controller::onShow() {
_guvTheDrawer = _scene->findAniObjectById(ANI_DADAYASHIK, 0);
if (sceneLogic) {
if (g_ngi->getStateId(sO_GuvTheDrawer) == g_ngi->getStateValue(sO_GuvTheDrawer, sO_IsSleeping))
- _guvTheDrawer->setStatic(ST_DYAS_LIES);
+ _guvTheDrawer->setStatic(ST_DYAS_LIES, false); // the original passes mirror 0 (163238: R2 = 0)
_scene->findPictureObjectById(PIC_SC2_LADDER, 0)->_flags |= 4;
_boxDelay = 0;
AniObject *box = _scene->findAniObjectById(ANI_SC2_BOX, 0);
diff --git a/engines/ngi/fullpipe/sc02controller.h b/engines/ngi/fullpipe/sc02controller.h
index c7e8bd22c1c..ebcee93262a 100644
--- a/engines/ngi/fullpipe/sc02controller.h
+++ b/engines/ngi/fullpipe/sc02controller.h
@@ -30,15 +30,14 @@
namespace NGI {
-/**
- * Android: CSc02Controller. The tutorials, the camera margins, the constructor, CleanXml, IsInventoryEnabled and the helpers are active; OnShow beyond the
- * margins and the tutorial, OnUpdate, OnMessage and the touch are ported but wait for controllerRunsSceneLogic() (the scene runs with sceneHandler02 of
- * scene02.cpp until D02).
- */
+/** CSc02Controller: tutorials, VisitScene, margins and helpers are active; the rest waits for
+ controllerRunsSceneLogic() (docs/android-sc02-switch-notes.md) */
class Sc02Controller : public FPController {
public:
explicit Sc02Controller(int sceneId);
void cleanXml() override;
+ /** The scene logic is this controller's (D02): scenes.cpp does not hook sceneHandler0N */
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onHide() override;
int getCursorType(float x, float y) override;
Commit: c25ab7a4734a211db9c740e2919606918c10abe1
https://github.com/scummvm/scummvm/commit/c25ab7a4734a211db9c740e2919606918c10abe1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Sc03Controller runs the scene logic of scene 3 (lift buttons, MSG_SC3_MOVEEGGEATER as in the assembly)
Changed paths:
engines/ngi/fullpipe/sc03controller.cpp
engines/ngi/fullpipe/sc03controller.h
diff --git a/engines/ngi/fullpipe/sc03controller.cpp b/engines/ngi/fullpipe/sc03controller.cpp
index 7f7fd8a1533..0395ed733f3 100644
--- a/engines/ngi/fullpipe/sc03controller.cpp
+++ b/engines/ngi/fullpipe/sc03controller.cpp
@@ -144,9 +144,8 @@ int Sc03Controller::getCursorType(float x, float y) {
return FPController::getCursorType(x, y);
}
-// CSc03Controller::OnMouseLKeyDown and OnMouseLKeyUp (1644A0, 164518): after the tutorial of the ladder or of the egg the touch goes nowhere, and
-// after the tutorial of the boot only a touch on the boot counts. Then the base class, then CLift::OnButtonDown / OnButtonUp (they stay in
-// FPController::onTap and the lift code of the scene, D02/D17).
+// CSc03Controller::OnMouseLKeyDown/Up (1644A0, 164518): after the ladder or egg tutorial the touch
+// goes nowhere, after the boot tutorial only the boot counts; then the base, CLift::OnButtonDown/Up
bool Sc03Controller::tutorialBlocksTouch() const {
if (_tutorial == "AFTER_TUTORIAL_USE_LADDER" || _tutorial == "AFTER_TUTORIAL_GIVE_EGG")
return true;
@@ -156,13 +155,17 @@ bool Sc03Controller::tutorialBlocksTouch() const {
bool Sc03Controller::onMouseLKeyDown(uint32 id, float x, float y) {
if (tutorialBlocksTouch())
return true;
- return FPController::onMouseLKeyDown(id, x, y);
+ if (FPController::onMouseLKeyDown(id, x, y))
+ return true;
+ return g_ngi->lift().onButtonDown(x, y);
}
bool Sc03Controller::onMouseLKeyUp(uint32 id, float x, float y) {
if (tutorialBlocksTouch())
return true;
- return FPController::onMouseLKeyUp(id, x, y);
+ if (FPController::onMouseLKeyUp(id, x, y))
+ return true;
+ return g_ngi->lift().onButtonUp(x, y);
}
bool Sc03Controller::hasEggBootOrEaten() const {
@@ -209,6 +212,8 @@ void Sc03Controller::doTestFat(MessageQueue *queue) {
return;
Command *first = queue->getCommandByIndex(0);
Command *second = queue->getCommandByIndex(1);
+ if (!first || !second)
+ return;
if (getFirstEaten()) {
first->_cmd = kCmdStartMovement;
second->_cmd = kCmdStartMovement;
@@ -316,7 +321,8 @@ void Sc03Controller::onMessage(const Common::String &message, const Common::Stri
onInvDrop(param);
FPController::onMessage(message, param, queue);
} else if (message == "MSG_SC3_MOVEEGGEATER") {
- _eggeater->setPos(609, 424);
+ // CVisibleObject::SetPos(vector3) (vtable slot 20): the position is the top left of the picture, as in the XML
+ _eggeater->setPosition(Common::Point(609, 424));
_eggeater->_z = 60;
} else if (message == "MSG_SC4_HIDEBOOT") {
_boot->_flags &= ~4;
diff --git a/engines/ngi/fullpipe/sc03controller.h b/engines/ngi/fullpipe/sc03controller.h
index f06545a5905..9763d7810d1 100644
--- a/engines/ngi/fullpipe/sc03controller.h
+++ b/engines/ngi/fullpipe/sc03controller.h
@@ -32,15 +32,13 @@ class Command;
class GameVar;
class MessageQueue;
-/**
- * Android: CSc03Controller (the egg eater: the eggs that it swallowed, the coin, the hint over the scene). Every method is ported; the constructor, CleanXml,
- * CheckTutorial, the touch blocks of the tutorials, the camera margins and the objects that OnShow finds are active, the rest only runs when
- * controllerRunsSceneLogic() is true (the sceneHandler03 code of the Windows engine does it until then).
- */
+/** CSc03Controller: the egg eater; runs the scene logic, see docs/android-sc03-switch-notes.md */
class Sc03Controller : public FPController {
public:
explicit Sc03Controller(int sceneId);
+ bool controllerRunsSceneLogic() const override { return true; }
+
void cleanXml() override;
void checkTutorial() override;
void onSceneInit() override;
Commit: 3bde420e99b1fbdc843fcc268f9fe4027c2af36c
https://github.com/scummvm/scummvm/commit/3bde420e99b1fbdc843fcc268f9fe4027c2af36c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: The scenes 1 to 3 run from their controllers, no sceneHandler hook
Changed paths:
engines/ngi/fullpipe/scenes.cpp
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index 77d674b5ba4..d95b3de79b3 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -556,18 +556,7 @@ void NGIEngine::sceneAutoScrolling() {
bool NGIEngine::initSceneLogic(Scene *scene, int entranceId) {
_floaters->deleteAllFlies();
switch (scene->_sceneId) {
- case SC_1:
- scene01_initScene(scene, entranceId);
- addMessageHandler(sceneHandler01, 2);
- return true;
- case SC_2:
- scene02_initScene(scene);
- addMessageHandler(sceneHandler02, 2);
- return true;
- case SC_3:
- scene03_initScene(scene);
- addMessageHandler(sceneHandler03, 2);
- return true;
+ // scenes 1, 2 and 3 run from their controllers (controllerRunsSceneLogic())
case SC_4:
scene04_initScene(scene);
addMessageHandler(sceneHandler04, 2);
Commit: ab2f0ffd6efabff786e81f3fc083b747cc61c1ac
https://github.com/scummvm/scummvm/commit/ab2f0ffd6efabff786e81f3fc083b747cc61c1ac
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: StateManager (CStateManager): the states of the objects and the activity of the interactions
Changed paths:
A engines/ngi/fullpipe/statemanager.cpp
A engines/ngi/fullpipe/statemanager.h
engines/ngi/fullpipe/help.h
engines/ngi/fullpipe/scene16.cpp
engines/ngi/fullpipe/scene18and19.cpp
engines/ngi/init.cpp
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/stateloader.cpp
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/help.h b/engines/ngi/fullpipe/help.h
index 8a867ad4e08..91473a56c76 100644
--- a/engines/ngi/fullpipe/help.h
+++ b/engines/ngi/fullpipe/help.h
@@ -26,6 +26,7 @@
#include "common/str.h"
#include "ngi/scenecontroller.h"
+#include "ngi/fullpipe/statemanager.h" // LogicState
namespace Common {
class Serializer;
@@ -38,12 +39,6 @@ class GameObject;
class Interact;
class XmlNode;
-/** Android: CLogicState (8 bytes), a state of an object that makes a help item show: the name of the object and the value of the state */
-struct LogicState {
- Common::String _name; // +0: "title"
- int _value = 0; // +4: CStateManager::GetStateValue(title, state)
-};
-
/** CHelpItem (40 bytes), one HELP of help.xml: a bubble picture of SC_HELP */
class HelpItem {
public:
diff --git a/engines/ngi/fullpipe/scene16.cpp b/engines/ngi/fullpipe/scene16.cpp
index d0c0b25fa62..f98581834b9 100644
--- a/engines/ngi/fullpipe/scene16.cpp
+++ b/engines/ngi/fullpipe/scene16.cpp
@@ -236,7 +236,7 @@ void sceneHandler16_startLaugh() {
mq->setFlags(mq->getFlags() | 1);
mq->run(nullptr);
- g_ngi->getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->setSubVarAsInt(sO_DudeSwinged, 0);
+ g_ngi->setState(sO_DudeSwinged, 0);
g_vars->scene16_girlIsLaughing = true;
}
diff --git a/engines/ngi/fullpipe/scene18and19.cpp b/engines/ngi/fullpipe/scene18and19.cpp
index 1f9ff8e3e93..271e0a9479b 100644
--- a/engines/ngi/fullpipe/scene18and19.cpp
+++ b/engines/ngi/fullpipe/scene18and19.cpp
@@ -807,7 +807,7 @@ int sceneHandler18(Command *cmd) {
}
void sceneHandler19_updateNumRides() {
- int numRides = g_ngi->getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->getSubVarAsInt(sO_DudeSwinged) + 1;
+ int numRides = g_ngi->getStateId(sO_DudeSwinged) + 1;
if (numRides > 1) {
g_ngi->setState(sO_Girl, g_ngi->getStateValue(sO_Girl, sO_IsSwinging));
@@ -818,7 +818,7 @@ void sceneHandler19_updateNumRides() {
numRides = 0;
}
- g_ngi->getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->setSubVarAsInt(sO_DudeSwinged, numRides);
+ g_ngi->setState(sO_DudeSwinged, numRides);
}
int sceneHandler19(Command *cmd) {
diff --git a/engines/ngi/fullpipe/statemanager.cpp b/engines/ngi/fullpipe/statemanager.cpp
new file mode 100644
index 00000000000..54e9c3989dc
--- /dev/null
+++ b/engines/ngi/fullpipe/statemanager.cpp
@@ -0,0 +1,524 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/debug.h"
+
+#include "ngi/ngi.h"
+#include "ngi/gameloader.h"
+#include "ngi/interaction.h"
+#include "ngi/objects.h"
+#include "ngi/utils.h"
+#include "ngi/fullpipe/controllerhelpers.h"
+#include "ngi/fullpipe/lift.h"
+#include "ngi/fullpipe/objectnames.h"
+#include "ngi/fullpipe/statemanager.h"
+
+namespace NGI {
+
+namespace {
+
+// CIDList::FindId: 0 for an unknown name
+uint32 findId(const char *name) {
+ uint32 id = 0;
+ if (name[0] && g_ngi->_gameProject)
+ g_ngi->_gameProject->_objectIds.findId(name, id);
+ return id;
+}
+
+// CInteractionController::FindInteraction(id, 0, 0) (106F58): the first interaction with the name
+Interact *findInteraction(const Common::String &id) {
+ if (!g_ngi->_gameLoader || !g_ngi->_gameLoader->_interactionController)
+ return nullptr;
+ return g_ngi->_gameLoader->_interactionController->findInteractionByName(id);
+}
+
+// CXmlWriter (XmlOpenNodeWithAttr FF438, XmlStartChildren FE988, XmlSerializeString FF118,
+// XmlSerializeU32 FEA4C, XmlCloseNodeWithAttr FE95C, XmlCloseNode FF4E8): the text is one string,
+// every part starts with the separator its kind needs when the string is not empty
+void xmlOpenNodeWithAttr(Common::String &out, const char *name) {
+ if (!out.empty())
+ out += "\n";
+ out += "<";
+ out += name;
+}
+
+void xmlStartChildren(Common::String &out) {
+ if (!out.empty())
+ out += " ";
+ out += ">";
+}
+
+void xmlSerializeString(Common::String &out, const char *name, const Common::String &value) {
+ if (!out.empty())
+ out += " ";
+ out += Common::String::format("%s=\"%s\"", name, value.c_str());
+}
+
+void xmlSerializeU32(Common::String &out, const char *name, int value) {
+ if (!out.empty())
+ out += " ";
+ out += Common::String::format("%s=\"%d\"", name, value);
+}
+
+void xmlCloseNodeWithAttr(Common::String &out) {
+ if (!out.empty())
+ out += " ";
+ out += "/>";
+}
+
+void xmlCloseNode(Common::String &out, const char *name) {
+ if (!out.empty())
+ out += "\n";
+ out += "</";
+ out += name;
+ out += ">";
+}
+
+// CStateManager::SetStartStates (1A01B8): object and state title, in the original order
+struct StartState {
+ const char *object;
+ const char *state;
+};
+
+const StartState startStates[] = {
+ { sO_Dude, sO_NotCarryingEgg }, // ÐÑдÑ: ЯйÑо не неÑеÑ
+ { sO_EggCracker, sO_DidNotCrackEgg }, // ЯйÑекол: Ðе колол ÑйÑо
+ { sO_GuvTheDrawer, sO_Awaken }, // ÐÑдÑ-ÑÑик: ÐодÑÑÑвÑеÑ
+ { sO_EggGulper, sO_First }, // ЯйÑеглоÑ: ÐеÑвÑй
+ { sO_EggGulperGaveCoin, sO_No }, // ЯйÑÐµÐ³Ð»Ð¾Ñ Ð¾Ñдал монеÑÑ: ÐеÑ
+ { sO_Jar_4, sO_OnTheSpring }, // Ðанка_4: Ðа пÑÑжине
+ { sO_GulpedEgg, sO_NotPresent }, // ÐÑоглоÑенное ÑйÑо: ÐÑÑÑÑÑÑвÑеÑ
+ { sO_WeirdWacko, sO_InGlasses }, // ÐÑмоÑоженнÑй: РоÑкаÑ
+ { sO_TummyTrampie, sO_IsDrinking }, // ÐаÑÑÑа: ÐÑеÑ
+ { sO_StairsUp_8, sO_NotBroken }, // ÐеÑÑниÑа ÑвеÑÑ
Ñ_8: Цела
+ { sO_HareTheNooksiter, sO_WithHandle }, // ÐÑглÑÑед: С ÑÑÑкой
+ { sO_Elephantine, sO_WithBoot }, // ÐевоÑка-Ñлоник: С баÑмаком
+ { sO_Fly_12, "0" }, // ÐÑÑ
а_12: 0
+ { sO_ClockAxis, sO_IsNotAvailable }, // ÐÑÑ ÑаÑов: ÐедоÑÑÑпна
+ { sO_ClockHandle, sO_In_7 }, // Ð ÑÑка Ð¾Ñ ÑаÑов: Ð_7
+ { sO_BigMumsy, sO_IsSleeping }, // ÐамаÑа: СпиÑ
+ { sO_CoinSlot_1, sO_Empty }, // ÐонеÑопÑиемник 1: ÐÑÑÑ
+ { sO_FriesPit, sO_WithApple }, // ÐоÑка козÑвки: С Ñблоком
+ { sO_Jug, sO_Blocked }, // ÐоÑÑок: ÐлокиÑован
+ { sO_RightStairs_9, sO_IsClosed }, // ÐÑÐ°Ð²Ð°Ñ Ð»ÐµÑÑниÑа_9: ÐакÑÑÑа
+ { sO_Pipe_9, sO_WithJug }, // ТÑÑба_9: С гоÑÑком
+ { sO_Inflater, sO_WithGum }, // ÐадÑваÑелÑ: С жваÑкой
+ { sO_Swingie, sO_IsSwinging }, // ÐаÑеленÑ: ÐаÑаеÑÑÑ
+ { sO_DudeHasJumped, sO_No }, // ÐÑÐ´Ñ Ð¿ÑÑгал: ÐеÑ
+ { sO_Bridge, sO_Convoluted }, // ÐоÑÑ: СвеÑнÑÑ
+ { sO_Guardian, sO_OnRight }, // СÑоÑож: СпÑава
+ { sO_Grandma, sO_In_14 }, // ÐабÑлÑ: Ð_14
+ { sO_Boot_15, sO_NotPresent }, // ÐоÑинок_15: ÐÑÑÑÑÑÑвÑеÑ
+ { sO_LeftPipe_15, sO_IsOpened }, // ÐÐµÐ²Ð°Ñ ÑÑÑба_15: ÐÑкÑÑÑа
+ { sO_Pedestal_16, sO_IsFree }, // ТÑмба_16: Свободна
+ { sO_Cup, sO_InSmokeRoom }, // ÐÑÑжка: РкÑÑилке
+ { sO_Pedestal_17, sO_IsFree }, // ТÑмба_17: Свободна
+ { sO_UsherHand, sO_WithoutCoin }, // Ð Ñка ÐилеÑеÑÑи: Ðез монеÑÑ
+ { sO_RightPipe_17, sO_IsClosed }, // ÐÑÐ°Ð²Ð°Ñ ÑÑÑба_17: ÐакÑÑÑа
+ { sO_Fly_17, "1" }, // ÐÑÑ
а_17: 1
+ { sO_Girl, sO_IsSwinging }, // ÐевоÑка: ÐаÑаеÑÑÑ
+ { sO_Sugar, sO_Present }, // СаÑ
аÑок: ÐÑÑÑ
+ { sO_Janitors, sO_Together }, // УбоÑÑики: Ðдвоем
+ { sO_Bag_22, sO_NotFallen }, // ÐеÑок_22: Ðе падал
+ { sO_Grandpa, sO_InSock }, // ÐедÑÑка: РноÑке
+ { sO_CoinSlot_22, sO_Empty }, // ÐонеÑопÑиемник_22: ÐÑÑÑ
+ { sO_UpperHatch_23, sO_Closed }, // ÐеÑÑ
ний лÑк_23: ÐакÑÑÑ
+ { sO_LowerHatch_23, sO_Closed }, // Ðижний лÑк_23: ÐакÑÑÑ
+ { sO_Lever_23, sO_NotTaken }, // Ð ÑÑаг_23: Ðе взÑÑ
+ { sO_LeverHandle_23, sO_WithoutStool }, // Ð ÑкоÑÑка ÑÑÑага_23: Ðез ÑабÑÑеÑки
+ { sO_LowerPipe_21, sO_IsClosed }, // ÐижнÑÑ ÑÑÑба_21: ÐакÑÑÑа
+ { sO_StairsDown_24, sO_IsOpened }, // ÐеÑÑниÑа вниз_24: ÐÑкÑÑÑа
+ { sO_Hatch_26, sO_Closed }, // ÐÑк_26: ÐакÑÑÑ
+ { sO_Sock_26, sO_NotHanging }, // ÐоÑок_26: Ðе виÑиÑ
+ { sO_LeftPipe_26, sO_IsClosed }, // ÐÐµÐ²Ð°Ñ ÑÑÑба_26: ÐакÑÑÑа
+ { sO_Valve1_26, sO_Opened }, // ÐенÑилÑ1_26: ÐÑкÑÑÑ
+ { sO_Valve2_26, sO_Closed }, // ÐенÑилÑ2_26: ÐакÑÑÑ
+ { sO_Valve3_26, sO_Closed }, // ÐенÑилÑ3_26: ÐакÑÑÑ
+ { sO_Valve4_26, sO_Closed }, // ÐенÑилÑ4_26: ÐакÑÑÑ
+ { sO_Valve5_26, sO_Opened }, // ÐенÑилÑ5_26: ÐÑкÑÑÑ
+ { sO_Pool, sO_Overfull }, // ÐаÑÑейн: ÐеÑеполнен
+ { sO_Board_25, sO_NearDudesStairs }, // ÐоÑка_25: У ÐÑди на леÑÑниÑе
+ { sO_Driver, sO_WithSteering }, // Ðодила: С ÑÑлем
+ { sO_Maid, sO_WithSwab }, // УбоÑÑиÑа: Со ÑвабÑой
+ { sO_LeftPipe_29, sO_IsClosed }, // ÐÐµÐ²Ð°Ñ ÑÑÑба_29: ÐакÑÑÑа
+ { sO_LeftPipe_30, sO_IsClosed }, // ÐÐµÐ²Ð°Ñ ÑÑÑба_30: ÐакÑÑÑа
+ { sO_Leg, sO_ShowingHeel }, // Ðога: ÐоказÑÐ²Ð°ÐµÑ Ð¿ÑÑкÑ
+ { sO_Tub, sO_EmptyShe }, // Ðадка: ÐÑÑÑаÑ
+ { sO_Cactus, sO_NotGrown }, // ÐакÑÑÑ: Ðе вÑÑоÑ
+ { sO_Fireman, sO_WithHose }, // ÐожаÑник: Со Ñлангом
+ { sO_Cube, sO_In_33 }, // ÐÑбик: Ð_33
+ { sO_MommyOfHandle_32, sO_WithoutHandle }, // Ðама ÑÑÑки_32: Ðез ÑÑÑки
+ { sO_Pedestal_33, sO_IsFree }, // ТÑмба_33: Свободна
+ { sO_Valve_34, "\xd1\x20\xf2\xe0\xe1\xf3\xf0\xe5\xf2\xea\xee\xe9" }, // ÐенÑилÑ_34: С ÑабÑÑеÑкой
+ { sO_Stool_34, sO_WithoutDrawer }, // ТабÑÑеÑ_34: Ðез ÑÑика
+ { sO_Plank_34, sO_Passive }, // ÐоÑка_34: ÐаÑÑивна
+ { sO_Hatch_34, sO_Closed }, // ÐÑк_34: ÐакÑÑÑ
+ { sO_Valve_35, sO_TurnedOff }, // ÐÑан_35: ÐÑклÑÑен
+ { sO_Carpet_35, sO_CannotTake }, // ÐовÑик_35: ÐелÑÐ·Ñ Ð²Ð·ÑÑÑ
+ { sO_CoinSlot_35, sO_WithCoin }, // ÐонеÑопÑиемник_35: С монеÑой
+ { sO_BellyInflater, sO_WithCork }, // ÐÑзодÑв: С пÑобкой
+ { sO_Jawcrucnher, sO_WithoutCarpet }, // РоÑоÑ
ÑÑÑ: Ðез ковÑика
+ { sO_Guard_1, sO_On }, // СÑÑаж 1: Ðкл
+ { sO_Guard_2, sO_On }, // СÑÑаж 2: Ðкл
+ { sO_Guard_3, sO_On }, // СÑÑаж 3: Ðкл
+ { sO_Bottle_38, sO_OnTheTable }, // ÐÑÑÑлка_38: Ðа ÑÑоле
+ { sO_Boss, sO_WithHammer }, // ÐлаваÑÑ: С молоÑком
+ // ТабÑÑеÑ_23: Ðе забиÑаем
+ { "\xd2\xe0\xe1\xf3\xf0\xe5\xf2\x5f\x32\x33", "\xcd\xe5\x20\xe7\xe0\xe1\xe8\xf0\xe0\xe5\xec" },
+};
+
+} // End of anonymous namespace
+
+// CObjState::CObjState() (19F738)
+ObjState::ObjState() {
+}
+
+// CObjState::CObjState(CXmlNode &) (19FAD0)
+ObjState::ObjState(const XmlNode &node) {
+ _title = node.attrStr("title", "");
+ _curState = node.attrInt("curState", 0);
+ for (uint i = 0; i < node.childCount(); i++) {
+ const Common::String name = node[i].name();
+ if (name == "ITEM") {
+ LogicItem *item = new LogicItem;
+ item->_id = findId(node[i].attrStr("id", ""));
+ item->_scene = findId(node[i].attrStr("scene", ""));
+ _items.push_back(item);
+ } else if (name == "STATE") {
+ LogicState *state = new LogicState;
+ state->_name = node[i].attrStr("title", "");
+ state->_value = node[i].attrInt("num", 0);
+ _states.push_back(state);
+ }
+ }
+}
+
+// CObjState::~CObjState (19F794)
+ObjState::~ObjState() {
+ for (uint i = 0; i < _items.size(); i++)
+ delete _items[i];
+ for (uint i = 0; i < _states.size(); i++)
+ delete _states[i];
+}
+
+// CStateManager::CStateManager (19FDB8)
+StateManager::StateManager() {
+}
+
+// CStateManager::~CStateManager (1A1564)
+StateManager::~StateManager() {
+ for (uint i = 0; i < _objStates.size(); i++)
+ delete _objStates[i];
+ for (IntDataMap::iterator it = _intData.begin(); it != _intData.end(); ++it) {
+ Common::Array<IntData *> &list = it->_value;
+ for (uint i = 0; i < list.size(); i++) {
+ delete list[i]->_objState;
+ delete list[i]->_heroState;
+ delete list[i];
+ }
+ }
+}
+
+// CStateManager::Init (1A1660)
+bool StateManager::init(const Common::Path &path) {
+ Common::ScopedPtr<XmlNode> document(loadXmlDocument(path));
+ if (!document) {
+ warning("Could not read %s", path.toString().c_str());
+ return false;
+ }
+
+ const XmlNode &root = document->first();
+ for (uint i = 0; i < root.childCount(); i++) {
+ const Common::String name = root[i].name();
+ if (name == "OBJECT") {
+ _objStates.push_back(new ObjState(root[i]));
+ } else if (name == "INTERACTION") {
+ IntData *data = new IntData;
+ data->_objState = new LogicState;
+ data->_heroState = new LogicState;
+ data->_objState->_name = root[i].attrStr("objTitle", "");
+ data->_objState->_value = root[i].attrInt("objState", 0);
+ data->_heroState->_name = root[i].attrStr("heroTitle", "");
+ data->_heroState->_value = root[i].attrInt("heroState", 0);
+ data->_id = root[i].attrStr("id", "");
+ data->_interact = findInteraction(data->_id);
+ if (!data->_interact)
+ data->_interact = findInteraction(data->_id);
+ // std::map::find / insert: the list of the interactions of the object title
+ _intData[data->_objState->_name].push_back(data);
+ }
+ }
+
+ debugC(1, kDebugXML, "StateManager: %u objects, %u object titles with interactions in %s", _objStates.size(), _intData.size(), path.toString().c_str());
+ return true;
+}
+
+// CStateManager::InitData (19F814)
+bool StateManager::initData(const Common::Path &path) {
+ _document.reset(loadXmlDocument(path));
+ return _document.get() != nullptr;
+}
+
+// CStateManager::GetRootData (19F7F8)
+const XmlNode &StateManager::getRootData(const char *name) const {
+ static const XmlNode emptyNode;
+ if (!_document)
+ return emptyNode;
+ return _document->child("DATA").child(name);
+}
+
+// CStateManager::GetStateId (19F8E0)
+int StateManager::getStateId(const Common::String &objTitle) const {
+ for (uint i = 0; i < _objStates.size(); i++) {
+ if (_objStates[i]->_title == objTitle)
+ return _objStates[i]->_curState;
+ }
+ return 0;
+}
+
+// CStateManager::GetObjStatePtr (19F916)
+ObjState *StateManager::getObjStatePtr(const Common::String &objTitle) const {
+ for (uint i = 0; i < _objStates.size(); i++) {
+ if (_objStates[i]->_title == objTitle)
+ return _objStates[i];
+ }
+ return nullptr;
+}
+
+// CStateManager::GetLogicStatePtr (19F94A)
+LogicState *StateManager::getLogicStatePtr(const ObjState *objState, const Common::String &stateTitle) const {
+ for (uint i = 0; i < objState->_states.size(); i++) {
+ if (objState->_states[i]->_name == stateTitle)
+ return objState->_states[i];
+ }
+ return nullptr;
+}
+
+// CStateManager::GetStateValue (19F97E)
+int StateManager::getStateValue(const Common::String &objTitle, const Common::String &stateTitle) const {
+ const ObjState *objState = getObjStatePtr(objTitle);
+ const LogicState *state = objState ? getLogicStatePtr(objState, stateTitle) : nullptr;
+ if (!state) {
+ // the original reads through the null pointer here
+ warning("StateManager::getStateValue: no state \"%s\" of the object \"%s\"", transCyrillic(stateTitle), transCyrillic(objTitle));
+ return 0;
+ }
+ return state->_value;
+}
+
+// CStateManager::GetState (19F9D4)
+Common::String StateManager::getState(const Common::String &objTitle) const {
+ for (uint i = 0; i < _objStates.size(); i++) {
+ const ObjState *objState = _objStates[i];
+ if (objState->_title != objTitle)
+ continue;
+ for (uint j = 0; j < objState->_states.size(); j++) {
+ if (objState->_curState == objState->_states[j]->_value)
+ return objState->_states[j]->_name;
+ }
+ }
+ return Common::String();
+}
+
+// CStateManager::SetState(std::string, int) (1A00FA)
+void StateManager::setState(const Common::String &objTitle, int state) {
+ for (uint i = 0; i < _objStates.size(); i++) {
+ if (_objStates[i]->_title == objTitle) {
+ _objStates[i]->_curState = state;
+ debugC(1, kDebugSceneLogic, "StateManager::setState: \"%s\" = %d", transCyrillic(objTitle), state);
+ mirrorToGameVar(_objStates[i]);
+ setActivity();
+ return;
+ }
+ }
+}
+
+// CStateManager::SetState(std::string, std::string) (1A013E)
+void StateManager::setState(const Common::String &objTitle, const Common::String &stateTitle) {
+ for (uint i = 0; i < _objStates.size(); i++) {
+ ObjState *objState = _objStates[i];
+ if (objState->_title != objTitle)
+ continue;
+ for (uint j = 0; j < objState->_states.size(); j++) {
+ if (objState->_states[j]->_name == stateTitle) {
+ objState->_curState = objState->_states[j]->_value;
+ debugC(1, kDebugSceneLogic, "StateManager::setState: \"%s\" = \"%s\" (%d)", transCyrillic(objTitle), transCyrillic(stateTitle), objState->_curState);
+ mirrorToGameVar(objState);
+ setActivity();
+ return;
+ }
+ }
+ }
+}
+
+// CStateManager::SetActivity (1A0042)
+void StateManager::setActivity() {
+ int active = 0;
+ int inactive = 0;
+ for (uint i = 0; i < _objStates.size(); i++) {
+ IntDataMap::iterator it = _intData.find(_objStates[i]->_title);
+ if (it == _intData.end())
+ continue;
+ // the original copies the vector of the object title
+ const Common::Array<IntData *> list = it->_value;
+ for (uint j = 0; j < list.size(); j++) {
+ IntData *data = list[j];
+ if (!data->_interact)
+ continue;
+ const int needed = data->_objState->_value;
+ if (needed == 0 || needed == _objStates[i]->_curState) {
+ data->_interact->_activity = 1.0f;
+ active++;
+ } else {
+ data->_interact->_activity = 0.0f;
+ inactive++;
+ }
+ }
+ }
+ debugC(2, kDebugInteractions, "StateManager::setActivity: %d interactions active, %d inactive", active, inactive);
+}
+
+// CStateManager::SetStartStates (1A01B8)
+void StateManager::setStartStates() {
+ // CSingleton<CLift>::GetInst()->ResetButtons()
+ g_ngi->lift().resetButtons();
+ for (uint i = 0; i < ARRAYSIZE(startStates); i++)
+ setState(startStates[i].object, Common::String(startStates[i].state));
+ setState(sO_DemoScroll, 0);
+}
+
+// CStateManager::CleanXml (1A155C)
+void StateManager::cleanXml() {
+ setStartStates();
+}
+
+// CStateManager::GetSavePath (19F864)
+Common::String StateManager::getSavePath(bool flag) const {
+ warnOnce("CStateManager::GetSavePath: CPathManager is not ported, only the file name is given");
+ return "states.sav";
+}
+
+// CStateManager::GetXmlData (19F3C8)
+void StateManager::getXmlData(Common::String &out) const {
+ xmlOpenNodeWithAttr(out, "OBJSTATES");
+ xmlStartChildren(out);
+ for (uint i = 0; i < _objStates.size(); i++) {
+ const ObjState *objState = _objStates[i];
+ xmlOpenNodeWithAttr(out, "OBJECT");
+ xmlSerializeString(out, "title", objState->_title);
+ xmlSerializeU32(out, "curState", objState->_curState);
+ xmlStartChildren(out);
+ for (uint j = 0; j < objState->_states.size(); j++) {
+ xmlOpenNodeWithAttr(out, "STATE");
+ xmlSerializeString(out, "title", objState->_states[j]->_name);
+ xmlSerializeU32(out, "num", objState->_states[j]->_value);
+ xmlCloseNodeWithAttr(out);
+ }
+ xmlCloseNode(out, "OBJECT");
+ }
+ xmlCloseNode(out, "OBJSTATES");
+}
+
+// CStateManager::SetXmlData (19F5E8)
+void StateManager::setXmlData(const XmlNode &node) {
+ for (uint i = 0; i < node.childCount(); i++) {
+ const XmlNode &objectNode = node[i];
+ if (objectNode.name() != "OBJECT")
+ continue;
+ if (i >= _objStates.size()) {
+ warning("StateManager::setXmlData: the object %u is not in objstates.xml", i);
+ continue;
+ }
+ ObjState *objState = _objStates[i];
+ objState->_curState = objectNode.attrInt("curState", 0);
+ for (uint j = 0; j < objectNode.childCount(); j++) {
+ if (objectNode[j].name() != "STATE")
+ continue;
+ if (j >= objState->_states.size()) {
+ warning("StateManager::setXmlData: the state %u of the object %u is not in objstates.xml", j, i);
+ continue;
+ }
+ LogicState *state = objState->_states[j];
+ state->_value = objectNode[j].attrInt("num", state->_value);
+ }
+ }
+}
+
+// DEVIATION D-statemanager-1: see the header
+void StateManager::resolveInteractions() {
+ for (IntDataMap::iterator it = _intData.begin(); it != _intData.end(); ++it) {
+ Common::Array<IntData *> &list = it->_value;
+ for (uint i = 0; i < list.size(); i++) {
+ IntData *data = list[i];
+ if (data->_interact)
+ continue;
+ data->_interact = findInteraction(data->_id);
+ if (!data->_interact)
+ continue;
+ // SetActivity (1A0042) at the start of the original, with all scenes' interactions loaded
+ bool objectExists = false;
+ for (uint j = 0; j < _objStates.size(); j++) {
+ if (_objStates[j]->_title != it->_key)
+ continue;
+ objectExists = true;
+ const int needed = data->_objState->_value;
+ data->_interact->_activity = (needed == 0 || needed == _objStates[j]->_curState) ? 1.0f : 0.0f;
+ }
+ debugC(2, kDebugInteractions, "StateManager::resolveInteractions: %s found, object %s, activity %f", data->_id.c_str(),
+ objectExists ? "known" : "unknown", data->_interact->_activity);
+ }
+ }
+}
+
+// DEVIATION D-statemanager-2: see the header
+void StateManager::mirrorToGameVar(const ObjState *objState) {
+ // one GameVar per title: it belongs to the first object with it (found by GetStateId)
+ if (!g_ngi->_gameLoader || !g_ngi->_gameLoader->_gameVar || getObjStatePtr(objState->_title) != objState)
+ return;
+ if (GameVar *states = g_ngi->_gameLoader->_gameVar->getSubVarByName("OBJSTATES"))
+ states->setSubVarAsInt(objState->_title, objState->_curState);
+}
+
+// DEVIATION D-statemanager-2: see the header
+void StateManager::syncFromGameVar(GameVar *states) {
+ if (!states)
+ return;
+ for (uint i = 0; i < _objStates.size(); i++) {
+ ObjState *objState = _objStates[i];
+ // one GameVar per title: it belongs to the first object with it (found by GetStateId)
+ if (getObjStatePtr(objState->_title) != objState)
+ continue;
+ GameVar *var = states->getSubVarByName(objState->_title);
+ if (!var)
+ continue;
+ objState->_curState = var->_value.intValue;
+ GameVar *values = var->getSubVarByName("ENUMSTATES");
+ if (!values)
+ continue;
+ for (uint j = 0; j < objState->_states.size(); j++) {
+ if (GameVar *value = values->getSubVarByName(objState->_states[j]->_name))
+ objState->_states[j]->_value = value->_value.intValue;
+ }
+ }
+ setActivity();
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/statemanager.h b/engines/ngi/fullpipe/statemanager.h
new file mode 100644
index 00000000000..e25319aca97
--- /dev/null
+++ b/engines/ngi/fullpipe/statemanager.h
@@ -0,0 +1,141 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_STATEMANAGER_H
+#define NGI_FULLPIPE_STATEMANAGER_H
+
+#include "common/array.h"
+#include "common/hashmap.h"
+#include "common/hash-str.h"
+#include "common/path.h"
+#include "common/ptr.h"
+#include "common/str.h"
+
+#include "ngi/xmlnode.h"
+
+namespace NGI {
+
+class GameVar;
+class Interact;
+
+/** CLogicState (8 bytes): a state name and its number (objstates.xml STATE title, num; help.xml) */
+struct LogicState {
+ Common::String _name; // +0: "title"
+ int _value = 0; // +4: "num"
+};
+
+/** CLogicItem (8 bytes): an ITEM of objstates.xml, the scene object that shows the state */
+struct LogicItem {
+ uint32 _id = 0; // +0
+ uint32 _scene = 0; // +4
+};
+
+/** CObjState (0x20 bytes): an OBJECT of objstates.xml, its possible states and the current one */
+class ObjState {
+public:
+ ObjState();
+ /** CObjState::CObjState(CXmlNode &) (19FAD0): title, curState, the ITEM and STATE children */
+ explicit ObjState(const XmlNode &node);
+ ~ObjState();
+
+ Common::String _title; // +0
+ int _curState = 0; // +4
+ Common::Array<LogicItem *> _items; // +8
+ Common::Array<LogicState *> _states; // +20
+};
+
+/** CIntData (0x10 bytes): an INTERACTION of objstates.xml, active while objTitle is in objState */
+struct IntData {
+ Common::String _id; // +0
+ // +4: the interaction, null until found (CInteractionController::FindInteraction)
+ Interact *_interact = nullptr;
+ LogicState *_objState = nullptr; // +8: objTitle / objState
+ LogicState *_heroState = nullptr; // +12: heroTitle / heroState
+};
+
+/** CStateManager (CSingleton, CGObject): object states (objstates.xml) and the activity of
+ * the interactions that depend on them, see docs/android-statemanager-notes.md */
+class StateManager {
+public:
+ StateManager();
+ ~StateManager();
+
+ /** CStateManager::Init (1A1660): objstates.xml, OBJECT and INTERACTION nodes */
+ bool init(const Common::Path &path);
+ /** CStateManager::InitData (19F814): data.xml (unused here, scene data is in the GameVar) */
+ bool initData(const Common::Path &path);
+ /** CStateManager::GetRootData (19F7F8) */
+ const XmlNode &getRootData(const char *name) const;
+
+ /** CStateManager::GetStateId (19F8E0): state of the first object with the title, 0 if unknown */
+ int getStateId(const Common::String &objTitle) const;
+ /** CStateManager::GetObjStatePtr (19F916): the first object with the title */
+ ObjState *getObjStatePtr(const Common::String &objTitle) const;
+ /** CStateManager::GetLogicStatePtr (19F94A): the first state of the object with the title */
+ LogicState *getLogicStatePtr(const ObjState *objState, const Common::String &stateTitle) const;
+ /** CStateManager::GetStateValue (19F97E): 0 and a warning where the original would crash */
+ int getStateValue(const Common::String &objTitle, const Common::String &stateTitle) const;
+ /** CStateManager::GetState (19F9D4): title of the object's state, empty when none */
+ Common::String getState(const Common::String &objTitle) const;
+
+ /** CStateManager::SetState(name, int) (1A00FA), then SetActivity */
+ void setState(const Common::String &objTitle, int state);
+ /** CStateManager::SetState(name, name) (1A013E), then SetActivity */
+ void setState(const Common::String &objTitle, const Common::String &stateTitle);
+ /** CStateManager::SetActivity (1A0042) */
+ void setActivity();
+ /** CStateManager::SetStartStates (1A01B8): CLift::ResetButtons, start state of 83 objects */
+ void setStartStates();
+ /** CStateManager::CleanXml (1A155C, vtable slot CGObject::CleanXml): SetStartStates */
+ void cleanXml();
+
+ /** CStateManager::GetSavePath (19F864): CPathManager is not ported */
+ Common::String getSavePath(bool flag) const;
+ /** CStateManager::GetXmlData (19F3C8): OBJSTATES with OBJECT / STATE nodes as text */
+ void getXmlData(Common::String &out) const;
+ /** CStateManager::SetXmlData (19F5E8): the node OBJSTATES that GetXmlData wrote */
+ void setXmlData(const XmlNode &node);
+
+ // DEVIATION D-statemanager-1: objstates.xml is read before the scenes (the original loads
+ // interactions in CGame::LoadInteractions first); unresolved ones are looked up per scene
+ void resolveInteractions();
+
+ // DEVIATION D-statemanager-2: saves keep the object states in the GameVar OBJSTATES (Windows
+ // format), not states.sav; after a load the numbers are taken from it
+ void syncFromGameVar(GameVar *states);
+
+private:
+ /** the GameVar OBJSTATES variable of the object follows its state number (D-statemanager-2) */
+ void mirrorToGameVar(const ObjState *objState);
+
+ typedef Common::HashMap<Common::String, Common::Array<IntData *> > IntDataMap;
+
+ Common::Array<ObjState *> _objStates; // +8
+ IntDataMap _intData; // +20: by object title (a std::map of vectors)
+ Common::ScopedPtr<XmlNode> _document; // +44
+
+ StateManager(const StateManager &);
+ StateManager &operator=(const StateManager &);
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_STATEMANAGER_H
diff --git a/engines/ngi/init.cpp b/engines/ngi/init.cpp
index abdd532b270..672584678f2 100644
--- a/engines/ngi/init.cpp
+++ b/engines/ngi/init.cpp
@@ -27,10 +27,18 @@
#include "ngi/input.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/statemanager.h"
namespace NGI {
void NGIEngine::initObjectStates() {
+ if (_stateManager) {
+ // CStateManager::CleanXml (SetStartStates): the 2015 start states, CLift::ResetButtons included
+ _stateManager->cleanXml();
+ setSwallowedEggsState(); // the Windows scene code of scene 3 takes the variables of the eggs here
+ return;
+ }
+
setLevelStates();
setState(sO_Dude, getStateValue(sO_Dude, sO_NotCarryingEgg));
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index f48930ecdda..42d9669d904 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -156,6 +156,7 @@ MODULE_OBJS = \
fullpipe/sceneIntroDemo.o \
fullpipe/scenecontrollers.o \
fullpipe/scenes.o \
+ fullpipe/statemanager.o \
fullpipe/taskmanager.o \
fullpipe/tremble.o \
fullpipe/tutorialcontroller.o \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index d43d12e4330..78c9d987be6 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -40,6 +40,7 @@
#include "ngi/fullpipe/fpcontroller.h"
#include "ngi/fullpipe/map.h"
#include "ngi/fullpipe/chaptermanager.h"
+#include "ngi/fullpipe/statemanager.h"
#include "ngi/fullpipe/notebook.h"
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/exitmanager.h"
@@ -856,6 +857,9 @@ Common::Error NGIEngine::updateScreen(uint32 elapsed, byte &brightness, bool red
}
int NGIEngine::getStateValue(const Common::String &name, const char *state) {
+ if (_stateManager)
+ return _stateManager->getStateValue(name, state);
+
GameVar *var = _gameLoader->_gameVar->getSubVarByName("OBJSTATES");
if (!var) {
@@ -873,6 +877,9 @@ int NGIEngine::getStateValue(const Common::String &name, const char *state) {
}
int NGIEngine::getStateId(const Common::String &objname) {
+ if (_stateManager)
+ return _stateManager->getStateId(objname);
+
GameVar *var = _gameLoader->_gameVar->getSubVarByName("OBJSTATES");
if (var)
@@ -882,6 +889,12 @@ int NGIEngine::getStateId(const Common::String &objname) {
}
void NGIEngine::setState(const Common::String &name, int state) {
+ if (_stateManager) {
+ // CStateManager::SetState (it keeps the GameVar in step, see StateManager::mirrorToGameVar)
+ _stateManager->setState(name, state);
+ return;
+ }
+
GameVar *var = _gameLoader->_gameVar->getSubVarByName("OBJSTATES");
if (!var) {
@@ -891,6 +904,23 @@ void NGIEngine::setState(const Common::String &name, int state) {
var->setSubVarAsInt(name, state);
}
+Common::String NGIEngine::getState(const Common::String &name) {
+ if (_stateManager)
+ return _stateManager->getState(name);
+
+ // object states are the variables of its ENUMSTATES, the one with the object's number
+ GameVar *states = _gameLoader->_gameVar->getSubVarByName("OBJSTATES");
+ GameVar *object = states ? states->getSubVarByName(name) : nullptr;
+ GameVar *values = object ? object->getSubVarByName("ENUMSTATES") : nullptr;
+ if (!values)
+ return Common::String();
+ for (GameVar *value = values->_subVars; value; value = value->_nextVarObj) {
+ if (value->_value.intValue == object->_value.intValue)
+ return value->_varName;
+ }
+ return Common::String();
+}
+
void NGIEngine::disableSaves(Command *ex) {
if (_isSaveAllowed) {
_isSaveAllowed = false;
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 4dc2d1cda90..08822196fa8 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -108,6 +108,7 @@ class ArcadeInterface;
class BitmapFont;
class TextContainer;
class ChapterManager;
+class StateManager;
class Notebook;
class GameProject;
class GameObject;
@@ -329,6 +330,8 @@ public:
Common::ScopedPtr<Map> _map;
Common::ScopedPtr<ArcadeInterface> _arcadeInterface;
Common::ScopedPtr<ChapterManager> _chapterManager;
+ /** CSingleton<CStateManager>: objstates.xml (201509 and later), null in older builds */
+ Common::ScopedPtr<StateManager> _stateManager;
/** CSingleton<CAchievementsManager>: the achievements and their banners (achievements.xml) */
Common::ScopedPtr<AchievementsManager> _achievementsManager;
/** CNotebookController, owned by its scene (SC_NOTEBOOK) */
@@ -406,6 +409,8 @@ public:
int getStateId(const Common::String &objname);
void setState(const Common::String &name, int state);
int getStateValue(const Common::String &name, const char *state);
+ /** CStateManager::GetState: the title of the state of the object (empty when it is in none) */
+ Common::String getState(const Common::String &name);
void sceneAutoScrolling();
// XML projects: runs the shared per-scene logic (initScene, message handler) for scenes that have it.
diff --git a/engines/ngi/stateloader.cpp b/engines/ngi/stateloader.cpp
index bb3bbb9a9bb..059aa6de515 100644
--- a/engines/ngi/stateloader.cpp
+++ b/engines/ngi/stateloader.cpp
@@ -22,6 +22,7 @@
#include "ngi/ngi.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/statemanager.h"
#include "ngi/detection.h"
#include "ngi/gameloader.h"
#include "ngi/interaction.h"
@@ -125,6 +126,10 @@ bool GameLoader::readSavegame(const char *fname) {
if (var)
deleteLoadedVars(var);
+ // the 2015 build keeps the object states in CStateManager, the savegame has them in the GameVar
+ if (g_ngi->_stateManager)
+ g_ngi->_stateManager->syncFromGameVar(v);
+
getGameLoaderInventory()->loadPartial(archive);
uint32 arrSize = archive.readUint32LE();
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 14950ee9931..fdbad810b30 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -51,6 +51,7 @@
#include "ngi/fullpipe/chaptermanager.h"
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/notebook.h"
+#include "ngi/fullpipe/statemanager.h"
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/achievements.h"
#include "ngi/fullpipe/objhelper.h"
@@ -1766,6 +1767,9 @@ void SceneTag::loadSceneXML(const GameProject &project) {
if (!parser.loadFile("data/interactions.xml") || !parser.parse())
return;
parser.registerInteractions();
+ // CStateManager::Init has resolved the loaded scenes already, this one is new
+ if (g_ngi->_stateManager)
+ g_ngi->_stateManager->resolveInteractions();
debugC(1, kDebugXML, "Loaded Full Pipe scene %s with %u pictures and %u animations",
_tag.c_str(), scene->_pictureObjects.size(), scene->_aniObjects.size());
@@ -1878,7 +1882,16 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
XMLObjectStateParser stateParser(*states);
if (!stateParser.loadFile("data/objstates.xml") || !stateParser.parse())
return Common::Error(Common::kNoGameDataFoundError, "Could not read the object states");
- g_ngi->setState(sO_EggCracker, g_ngi->getStateValue(sO_EggCracker, sO_DidNotCrackEgg));
+ if (g_ngi->_gameVersion >= 201509) {
+ // CStateManager::Init (objstates.xml), SetStartStates, SetActivity; GameVar stays the save store
+ g_ngi->_stateManager.reset(new StateManager);
+ if (!g_ngi->_stateManager->init("data/objstates.xml"))
+ return Common::Error(Common::kNoGameDataFoundError, "Could not read the object states");
+ g_ngi->_stateManager->setStartStates();
+ g_ngi->_stateManager->setActivity();
+ } else {
+ g_ngi->setState(sO_EggCracker, g_ngi->getStateValue(sO_EggCracker, sO_DidNotCrackEgg));
+ }
XMLSceneDataParser sceneDataParser(*_gameVar);
if (!sceneDataParser.loadFile("data/data.xml") || !sceneDataParser.parse())
return Common::Error(Common::kNoGameDataFoundError, "Could not read the scene data");
@@ -1887,7 +1900,8 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
if (!passageParser.loadFile("data/data.xml") || !passageParser.parse())
return Common::Error(Common::kNoGameDataFoundError, "Could not read the lift passages");
}
- g_ngi->lift_resetButtons();
+ if (g_ngi->_gameVersion < 201509)
+ g_ngi->lift_resetButtons(); // CStateManager::SetStartStates does it from 201509 on
if (g_ngi->_gameVersion >= 201509)
setManSpeed(_gameVar, 4.0f); // CSplashScreenController::CreateControllers
if (project._createInventory && !createInventory(project))
Commit: 46bae777c354302401f68d7b79f938828ac70ca7
https://github.com/scummvm/scummvm/commit/46bae777c354302401f68d7b79f938828ac70ca7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: A tap walks Dude and interrupts his interruptible queue (CFPController::CanInterruptManQueue, MctlStartMove), INFO log of the green outline
Changed paths:
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/motion.cpp
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 10aacbe8795..40ff1099b63 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -564,7 +564,7 @@ void FPController::onUpdate(uint32 elapsed) {
// CFPController::CanInterruptManQueue; not ported: CMessageQueue::CanInterrupt (interrupt state)
bool FPController::canInterruptManQueue() const {
- return hero() && !hero()->_messageQueueId;
+ return hero() && (g_ngi->_gameVersion >= 201509 ? hero()->canInterruptQueue() : !hero()->_messageQueueId);
}
// CFPController::CheckQueues (hero's queue part: +72, +76, +88, +192) and the swipe flag (+212)
@@ -930,11 +930,18 @@ void FPController::checkInvItem() {
int type = -1;
if (current && current->_controller)
type = current->_controller->getCursorType(cursor->_hotSceneX, cursor->_hotSceneY);
+ const uint itemId = cursor->getObjectId();
+ // --debugflags=info: the item outline on the cursor comes and goes
+ static bool outlineShown = false;
+ const bool outlineOn = type == 102 && itemId;
+ if (outlineOn != outlineShown) {
+ outlineShown = outlineOn;
+ debugC(1, kDebugInfo, "INFO t %u HIGHLIGHT %s item %d at the scene point %d,%d", g_system->getMillis(), outlineOn ? "on" : "off", itemId, (int)cursor->_hotSceneX, (int)cursor->_hotSceneY);
+ }
if (type != 102) {
_hintedItemId = 0;
return;
}
- const uint itemId = cursor->getObjectId();
if (!itemId)
return;
if (itemId != _hintedItemId) {
@@ -1002,11 +1009,11 @@ int FPController::getCursorType(float x, float y) {
bool FPController::onTap(float tapX, float tapY) {
Scene &scene = *_scene;
AniObject *hero = g_ngi->_aniMan;
- if (!hero || hero->_messageQueueId || !scene._motionController)
+ // CFPController::OnMouseLKeyUp does not look at the queue of the hero: the walk interrupts it when it can be interrupted (MctlStartMove, CanInterruptManQueue)
+ if (!hero || !scene._motionController) {
+ debugC(1, kDebugInfo, "INFO t %u TAP %d,%d ignored: hero %p motion controller %p", g_system->getMillis(), (int)tapX, (int)tapY, (void *)hero, (void *)scene._motionController.get());
return false;
- for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList)
- if (queue->_queueId == QU_SC1_ENTER && !queue->_isFinished)
- return false;
+ }
const Common::Point pos(tapX, tapY);
PictureObject *picture = scene.findPictureObjectAtPos(pos.x, pos.y);
AniObject *actor = scene.findAniObjectAtPos(pos.x, pos.y);
diff --git a/engines/ngi/motion.cpp b/engines/ngi/motion.cpp
index 182b64fbae4..157890db5ef 100644
--- a/engines/ngi/motion.cpp
+++ b/engines/ngi/motion.cpp
@@ -2221,7 +2221,9 @@ void MctlGraph::detachAllObjects() {
MessageQueue *MctlGraph::startMove(AniObject *ani, int xpos, int ypos, int fuzzyMatch, int staticsId, bool mirror) {
debugC(4, kDebugPathfinding, "MctlGraph::startMove(*%d, %d, %d, %d, %d)", ani->_id, xpos, ypos, fuzzyMatch, staticsId);
- if (!ani->isIdle())
+ // CFPController::MctlStartMove: CanInterruptManQueue, InterruptManQueue, RunQueueWithAni
+ const bool interrupting = g_ngi->_gameVersion >= 201509;
+ if (interrupting ? !ani->canInterruptQueue() : !ani->isIdle())
return nullptr;
if (ani->_flags & 0x100)
@@ -2232,6 +2234,8 @@ MessageQueue *MctlGraph::startMove(AniObject *ani, int xpos, int ypos, int fuzzy
if (!mq)
return nullptr;
+ if (interrupting)
+ ani->interruptQueue();
// CMctlGraph::StartMove is MakeQueue + RunQueueWithAni: MakeQueue stops a running movement itself (stopMovementToPrev)
if (ani->_movement && g_ngi->_gameVersion < 201509) {
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 569932f198b..c2a5139fc77 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -310,6 +310,21 @@ MessageQueue *AniObject::getMessageQueue() {
return g_ngi->_globalMessageQueueList->getMessageQueueById(_messageQueueId);
}
+// CFPController::CanInterruptManQueue (14A0F8)
+bool AniObject::canInterruptQueue() {
+ MessageQueue *queue = getMessageQueue();
+ return !queue || queue->canInterrupt() || queue->_interruptState == 3;
+}
+
+// CFPController::InterruptManQueue: CMessageQueue::Stop, then SetQueue(nullptr)
+void AniObject::interruptQueue() {
+ MessageQueue *queue = getMessageQueue();
+ if (queue) {
+ queue->stop(false);
+ _messageQueueId = 0;
+ }
+}
+
bool AniObject::trySetMessageQueue(int msgNum, int qId) {
if (_messageQueueId || !msgNum) {
updateGlobalMessageQueue(qId, _id);
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index 9ad644c936c..a87cdb378ea 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -243,6 +243,10 @@ public:
bool setQueue(MessageQueue *msg);
void restartMessageQueue(MessageQueue *msg);
MessageQueue *getMessageQueue();
+ /** CFPController::CanInterruptManQueue */
+ bool canInterruptQueue();
+ /** CFPController::InterruptManQueue (the part of the hero's queue) */
+ void interruptQueue();
bool trySetMessageQueue(int msgNum, int qId);
void startMQIfIdle(int qId, int flag);
Commit: d8d92f7a58e1e5019bdc129b8722d3c3627d6bfb
https://github.com/scummvm/scummvm/commit/d8d92f7a58e1e5019bdc129b8722d3c3627d6bfb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: MessageQueue has the Android state machine (CMessageQueue: Next, Update and the UpdateCmd polls, Stop, Interrupt, SetIntState)
Changed paths:
engines/ngi/messagehandlers.cpp
engines/ngi/messages.cpp
engines/ngi/messages.h
diff --git a/engines/ngi/messagehandlers.cpp b/engines/ngi/messagehandlers.cpp
index 80408d1c52e..b33548e2ac9 100644
--- a/engines/ngi/messagehandlers.cpp
+++ b/engines/ngi/messagehandlers.cpp
@@ -534,6 +534,11 @@ int global_messageHandler4(Command *cmd) {
switch (cmd->_cmd) {
case kCmdQueue: {
+ if (g_ngi->_gameVersion >= 201509) {
+ // CScene::RunQueue; the queue of this command polls it (UpdateCmdQueue) while the command waits
+ MessageQueue::executeCmdQueue(cmd, scene);
+ break;
+ }
MessageQueue *source = scene ? scene->findMessageQueue(cmd->_messageNum) : nullptr;
if (!source) {
warning("Could not find message queue %d", cmd->_messageNum);
@@ -647,6 +652,14 @@ int global_messageHandler4(Command *cmd) {
if (!ani)
break;
+ if (g_ngi->_gameVersion >= 201509) {
+ // CFPController::ExecCmdToStatic (14917C)
+ if (cmd->_messageNum)
+ ani->moveToStaticChain(cmd->_messageNum);
+ if (cmd->_auxParam)
+ ani->_flags |= 4;
+ break;
+ }
if (g_ngi->usesXMLProject()) {
if (cmd->_auxParam)
ani->_flags |= 4;
diff --git a/engines/ngi/messages.cpp b/engines/ngi/messages.cpp
index 4975e8ee243..04181e666e7 100644
--- a/engines/ngi/messages.cpp
+++ b/engines/ngi/messages.cpp
@@ -19,6 +19,8 @@
*
*/
+#include "common/algorithm.h"
+
#include "ngi/ngi.h"
#include "ngi/objects.h"
@@ -31,6 +33,9 @@
namespace NGI {
+// The queue whose command runs: the scene handlers look it up by id (getMessageQueueById)
+static MessageQueue *s_executingQueue = nullptr;
+
Command::Command() {
_field_3C = 1;
_messageNum = 0;
@@ -167,7 +172,7 @@ void Command::setObjectCopy(int copyId) {
_param = copyId;
}
-bool Command::handleMessage() {
+int Command::dispatch() {
int cnt = 0;
for (MessageHandler *m = g_ngi->_messageHandlers; m; m = m->nextItem)
cnt += m->callback(this);
@@ -186,7 +191,14 @@ bool Command::handleMessage() {
warning("Error during CMD_MESSAGE, scene not found.");
}
- if (_cmd == kCmdMessage || (_excFlags & 1)) {
+ return cnt;
+}
+
+bool Command::handleMessage() {
+ const int cnt = dispatch();
+
+ // the queues of the Android build poll their commands, they are not told that one is done
+ if (g_ngi->_gameVersion < 201509 && (_cmd == kCmdMessage || (_excFlags & 1))) {
if (_parId) {
MessageQueue *mq = g_ngi->_globalMessageQueueList->getMessageQueueById(_parId);
if (mq)
@@ -316,11 +328,17 @@ ObjstateCommand *ObjstateCommand::createClone() {
return new ObjstateCommand(this);
}
+static int s_lastQueueId = 0;
+
+int newQueueId() {
+ return ++s_lastQueueId;
+}
+
MessageQueue::MessageQueue() {
_field_14 = nullptr;
_parId = 0;
_queueId = 0;
- _id = 0;
+ _id = g_ngi->_gameVersion >= 201509 ? newQueueId() : 0;
_isFinished = 0;
_flags = 0;
_counter = 0;
@@ -333,6 +351,8 @@ MessageQueue::MessageQueue(int dataId) {
_parId = 0;
_queueId = dataId;
_id = g_ngi->_globalMessageQueueList->compact();
+ // a one-run queue made by the code: the scene deletes it after it stops
+ _deleteAfter = g_ngi->_gameVersion >= 201509;
_isFinished = 0;
_flags = 0;
_counter = 0;
@@ -371,6 +391,18 @@ MessageQueue::MessageQueue(MessageQueue *src, int parId, int field_38) {
}
_field_14 = src->_field_14;
+ if (g_ngi->_gameVersion >= 201509) {
+ // state 0, index -1; the copy belongs to no scene yet (CScene::RunQueue / AddQueue)
+ _parId = 0;
+ _id = newQueueId();
+ _queueId = src->_queueId;
+ _flags = src->_flags & ~kInGlobalQueue;
+ _title = src->_title;
+ _isFinished = 0;
+ _flag1 = 0;
+ return;
+ }
+
if (parId)
_parId = parId;
else
@@ -402,6 +434,10 @@ MessageQueue::~MessageQueue() {
g_ngi->_globalMessageQueueList->removeQueueById(_id);
}
+ // CScene::RemoveQueue
+ if (_scene && g_ngi->_gameVersion >= 201509)
+ _scene->forgetQueue(this);
+
finish();
}
@@ -430,7 +466,23 @@ bool MessageQueue::load(MfcArchive &file) {
return true;
}
-void MessageQueue::stop(bool) {
+// CMessageQueue::Stop (10C838): a2 is "silent", CGame::OnStopQueue is not called
+void MessageQueue::stop(bool silent) {
+ if (g_ngi->_gameVersion >= 201509) {
+ const int index = _curIndex;
+ _state = 0;
+ if (index != -1) {
+ // CMessageQueue::IsCommand(this, 9, 0) of the original has no effect
+ if (isNeedSave() && !silent)
+ g_ngi->onStopQueue();
+ _curIndex = -1;
+ debugC(2, kDebugInfo, "INFO t %u queue %d (%s) stops after the command %d", g_system->getMillis(), _id, _title.c_str(), index);
+ if (_deleteAfter && _scene)
+ _scene->deleteObjAfter(this);
+ }
+ return;
+ }
+
static bool reported = false;
if (!reported) {
reported = true;
@@ -443,12 +495,27 @@ void MessageQueue::stop(bool) {
_isFinished = 1;
}
+// CMctrlMessageQueue::Interrupt (1AD848)
+void MctrlMessageQueue::interrupt(bool silent) {
+ if (_scene)
+ _scene->message("MSG_RESETDEST", "", this);
+ MessageQueue::interrupt(silent);
+}
+
void MessageQueue::setObjectCopyAll(int copyId) {
for (uint i = 0; i < getCount(); i++)
getCommandByIndex(i)->setObjectCopy(copyId);
}
bool MessageQueue::canInterrupt() {
+ if (g_ngi->_gameVersion >= 201509) {
+ // CMessageQueue::CanInterrupt (10C7A0)
+ if (_interruptState == 0)
+ return true;
+ if (_interruptState == 1)
+ return !isCommand(kCmdStartMovement, true);
+ return false;
+ }
if (_interruptState == 0)
return true;
if (_interruptState == 1)
@@ -457,6 +524,21 @@ bool MessageQueue::canInterrupt() {
}
bool MessageQueue::run(AniObject *ani) {
+ if (g_ngi->_gameVersion >= 201509) {
+ // CScene::RunQueueWithAni / RunQueue: a queue without a scene takes the scene of the animation
+ Scene *scene = _scene;
+ if (!scene && ani) {
+ for (int i = (int)g_ngi->_sceneStack.size() - 1; i >= 0 && !scene; i--) {
+ const Scene *candidate = g_ngi->_sceneStack[i];
+ if (Common::find(candidate->_renderableAnis.begin(), candidate->_renderableAnis.end(), ani) != candidate->_renderableAnis.end() ||
+ Common::find(candidate->_aniObjects.begin(), candidate->_aniObjects.end(), ani) != candidate->_aniObjects.end())
+ scene = g_ngi->_sceneStack[i];
+ }
+ }
+ if (!scene)
+ scene = g_ngi->getCurrentScene();
+ return scene && scene->runQueueObject(this, ani, 4);
+ }
if (checkGlobalExCommandList1() && checkGlobalExCommandList2()) {
if (!(getFlags() & kInGlobalQueue)) {
g_ngi->_globalMessageQueueList->addMessageQueue(this);
@@ -472,6 +554,15 @@ bool MessageQueue::run(AniObject *ani) {
}
void MessageQueue::update() {
+ if (g_ngi->_gameVersion >= 201509) {
+ // the Android queues poll their commands (update(elapsed))
+ static bool reported = false;
+ if (!reported) {
+ reported = true;
+ warning("STUB/untested: MessageQueue::update() is the event of the Windows queues and does nothing for _gameVersion >= 201509");
+ }
+ return;
+ }
if (_counter > 0)
_counter--;
@@ -564,6 +655,10 @@ void MessageQueue::mergeQueue(MessageQueue *mq) { // Original belongs to AniHand
}
void MessageQueue::next() {
+ if (g_ngi->_gameVersion >= 201509) {
+ nextCommand();
+ return;
+ }
if (getCount()) {
if (!(_flags & 4) && (_flags & 1)) {
messageQueueCallback1(16);
@@ -577,39 +672,278 @@ void MessageQueue::next() {
ex->_excFlags |= (ex->_wait == 0 ? 1 : 0) | (ex->_field_3C != 0 ? 2 : 0);
_flags |= 4;
- if (ex->_cmd == kCmdPause && ex->_wait && g_ngi->_gameVersion >= 201509)
- _pauseCommand.reset(ex);
- else if (ex->_cmd == kCmdUser && ex->_wait && ex->_messageName == "SET_SCROLL" && g_ngi->_gameVersion >= 201509) {
- executeUserCommand(ex, this);
- _userCommand.reset(ex);
- } else
- ex->sendMessage();
+ ex->sendMessage();
} else if (_counter <= 0) {
_isFinished = 1;
finish();
}
}
-bool MessageQueue::updateCmdPause(uint32 elapsed) {
- if (!_pauseCommand)
- return false;
+// CMessageQueue::Next (10F690)
+void MessageQueue::nextCommand() {
+ _curIndex++;
+ int index = _curIndex;
+ // the waiting commands, mask 0x282673 of the original
+ for (;; index++) {
+ if (index >= (int)getCount())
+ break;
+ if (_curIndex == -1)
+ return;
+ Command *cmd = getCommandByIndex(index);
+ execute(cmd);
+ if (_curIndex == -1)
+ return;
+ if (cmd->_wait) {
+ switch (cmd->_cmd) {
+ case kCmdStartMovement:
+ case kCmdStartSliding:
+ case kCmdUser:
+ case kCmdPause:
+ case kCmdQueue:
+ case kCmdSound:
+ _state = 2;
+ _curIndex = index;
+ return;
+ default:
+ break;
+ }
+ }
+ }
+ stop(false);
+}
+
+// CMessageQueue::Run (10F6F4)
+void MessageQueue::run(int interruptState) {
+ _state = 1;
+ if (interruptState != 4)
+ _interruptState = interruptState;
+ else if (_interruptState < 0)
+ _interruptState = checkInterruptable(); // CMessageQueue::Init
+ if (isNeedSave())
+ g_ngi->onStartQueue(_queueId, _scene ? _scene->_sceneId : 0);
+ _curIndex = -1;
+ debugC(2, kDebugInfo, "INFO t %u queue %d (%s) runs in scene %d, interrupt state %d, %d commands", g_system->getMillis(), _id, _title.c_str(), _scene ? _scene->_sceneId : 0, _interruptState,
+ (int)getCount());
+ nextCommand();
+}
+
+// CMessageQueue::Execute (10F59C): the queue polls (Update), the handlers do not report back
+void MessageQueue::execute(Command *cmd) {
+ // the Windows scene code finds the queue of a command by this number (getMessageQueueById)
+ cmd->_parId = _id;
+ if (cmd->_cmd == kCmdPause) {
+ executeCmdPause(cmd);
+ return;
+ }
+ MessageQueue *outer = s_executingQueue;
+ s_executingQueue = this;
+ cmd->dispatch();
+ s_executingQueue = outer;
+}
+
+// CMessageQueue::ExecuteCmdPause (10F574)
+void MessageQueue::executeCmdPause(Command *cmd) {
+ cmd->setParamFloat("timer", cmd->getParamFloat("delay", 0.0f));
+}
+
+// The scene of the command: the parameter "scene", else the scene of the queue
+static Scene *commandScene(Scene *queueScene, const Command *cmd) {
+ Scene *scene = queueScene ? queueScene : g_ngi->getCurrentScene();
+ uint32 sceneId = 0;
+ if (cmd->_args.contains("scene") && g_ngi->_gameProject->_objectIds.findId(cmd->_args["scene"], sceneId))
+ scene = g_ngi->findScene(sceneId);
+ return scene;
+}
+
+// CMessageQueue::ExecuteCmdQueue (10E390): "interupt" 0 ... 3, else the queue state (4)
+void MessageQueue::executeCmdQueue(Command *cmd, Scene *queueScene) {
+ Scene *scene = commandScene(queueScene, cmd);
+ const Common::String interrupt = cmd->_args.getValOrDefault("interupt");
+ int state = 4;
+ if (interrupt == "always")
+ state = 0;
+ else if (interrupt == "nomove")
+ state = 1;
+ else if (interrupt == "never")
+ state = 2;
+ else if (interrupt == "background")
+ state = 3;
+ const Common::String setHero = cmd->_args.getValOrDefault("setHero");
+ if (scene)
+ scene->runQueue(cmd->getMovementId(), state, setHero == "1" || setHero.equalsIgnoreCase("true"));
+}
+
+// CMessageQueue::Update (10FD44): only a queue that waits (state 2) polls its current command
+void MessageQueue::update(uint32 elapsed) {
+ if (_state != 2)
+ return;
+ Command *cmd = getCommandByIndex(_curIndex);
+ if (!cmd)
+ return;
+ switch (cmd->_cmd) {
+ case kCmdStartMovement:
+ updateCmdStartMove(cmd);
+ break;
+ case kCmdSound:
+ updateCmdSnd(cmd);
+ break;
+ case kCmdStartSliding:
+ updateCmdStartSliding(cmd);
+ break;
+ case kCmdUser:
+ updateUserCmd(cmd, elapsed);
+ break;
+ case kCmdPause:
+ updateCmdPause(cmd, elapsed);
+ break;
+ case kCmdQueue:
+ updateCmdQueue(cmd);
+ break;
+ default:
+ // TALK, MOVIE, MOVE_TO and FADE have no command kind here: the loader does not make them
+ break;
+ }
+}
- if (elapsed < (uint32)_pauseCommand->_messageNum) {
- _pauseCommand->_messageNum -= elapsed;
- return false;
+// CMessageQueue::UpdateCmdStartMove (10F740): the original crashes on a missing object
+void MessageQueue::updateCmdStartMove(Command *cmd) {
+ Scene *scene = _scene ? _scene : g_ngi->getCurrentScene();
+ if (!scene) {
+ nextCommand();
+ return;
}
- _pauseCommand->_excFlags |= 1;
- _pauseCommand.release()->postMessage();
- return true;
+ if (cmd->getCopy() == -1) {
+ for (int copy = 0;; copy++) {
+ AniObject *ani = scene->findAniObjectById(cmd->getAniId(), copy);
+ if (!ani)
+ break;
+ if (!ani->_movement) {
+ nextCommand();
+ return;
+ }
+ }
+ return;
+ }
+ AniObject *ani = scene->findAniObjectById(cmd->getAniId(), cmd->getCopy());
+ if (!ani || !ani->_movement)
+ nextCommand();
+}
+
+// CMessageQueue::UpdateCmdStartSliding (10F81C)
+void MessageQueue::updateCmdStartSliding(Command *cmd) {
+ Scene *scene = _scene ? _scene : g_ngi->getCurrentScene();
+ AniObject *ani = scene ? scene->findAniObjectById(cmd->getAniId(), cmd->getCopy()) : nullptr;
+ if (!ani || ani->isSlidingEnd(cmd->getParamFloat("endX", 0.0f), cmd->getParamFloat("endY", 0.0f))) {
+ if (ani)
+ ani->stopMovement();
+ nextCommand();
+ }
+}
+
+// CMessageQueue::UpdateCmdQueue (10FBD8): the queue that the command started is stopped
+void MessageQueue::updateCmdQueue(Command *cmd) {
+ Scene *scene = commandScene(_scene, cmd);
+ MessageQueue *other = scene ? scene->findMessageQueue(cmd->getMovementId()) : nullptr;
+ if (!other || other->_state == 0)
+ nextCommand();
+}
+
+// CMessageQueue::UpdateCmdPause (10FCF8)
+void MessageQueue::updateCmdPause(Command *cmd, uint32 elapsed) {
+ const float timer = cmd->getParamFloat("timer", 0.0f) - (float)elapsed;
+ if (timer <= 0.0f)
+ nextCommand();
+ else
+ cmd->setParamFloat("timer", timer);
+}
+
+// CMessageQueue::UpdateCmdSnd (10F984): CSoundManager::IsPlayed
+void MessageQueue::updateCmdSnd(Command *cmd) {
+ Sound *sound = g_ngi->findSound(cmd->_messageNum);
+ if (!sound || !sound->isPlaying())
+ nextCommand();
+}
+
+// CMessageQueue::UpdateUserCmd (10FA14)
+void MessageQueue::updateUserCmd(Command *cmd, uint32 elapsed) {
+ Scene *scene = getUserCommandScene(cmd, this);
+ if (!scene || !scene->_controller || !scene->_controller->updateUserCmd(cmd, elapsed))
+ nextCommand();
+}
+
+void MessageQueue::pause() {
+ _state = 3;
}
-// CFPController::UpdateUserCmd: the queue goes on when the camera has reached the point
-bool MessageQueue::updateCmdUser() {
- if (!_userCommand || !g_ngi->_currentScene || !g_ngi->_currentScene->_controller ||
- g_ngi->_currentScene->_controller->updateUserCmd(_userCommand.get(), 0))
+// CMessageQueue::Resume (10F728): the current command is executed again
+void MessageQueue::resume() {
+ _state = 0;
+ if (_curIndex != -1) {
+ _curIndex--;
+ nextCommand();
+ }
+}
+
+// CMessageQueue::FinishNow (10FCBC): the commands that do not wait run, then the queue stops
+void MessageQueue::finishNow() {
+ if (_state == 0)
+ return;
+ for (int index = _curIndex + 1; index < (int)getCount(); index++) {
+ Command *cmd = getCommandByIndex(index);
+ if (!cmd->_wait)
+ execute(cmd);
+ }
+ stop(false);
+}
+
+// CMessageQueue::TryInterrupt (10FDCA): stopping a TALK (StopCurrent) is not ported
+void MessageQueue::tryInterrupt() {
+ if (_state != 0 && canInterrupt())
+ interrupt(false);
+}
+
+// CMessageQueue::IsNeedSave (10C7C4)
+bool MessageQueue::isNeedSave() {
+ if (_interruptState == 1)
+ return isCommand(kCmdStartMovement, true);
+ if (_interruptState == 3)
return false;
- _userCommand.reset();
- update();
+ return _interruptState != 0;
+}
+
+// CMessageQueue::SetIntState (10C88A)
+void MessageQueue::setIntState(int state) {
+ const bool needed = isNeedSave();
+ _interruptState = state;
+ if (_curIndex != -1 && needed != isNeedSave()) {
+ if (needed)
+ g_ngi->onStopQueue();
+ else
+ g_ngi->onStartQueue(_queueId, _scene ? _scene->_sceneId : 0);
+ }
+}
+
+// CMessageQueue::GetCurCommand (164888)
+Command *MessageQueue::getCurCommand() {
+ return _curIndex == -1 ? nullptr : getCommandByIndex(_curIndex);
+}
+
+// CMessageQueue::IsCommand (10C76E)
+bool MessageQueue::isCommand(int kind, bool fromCurrent) {
+ for (int index = fromCurrent ? MAX(_curIndex, 0) : 0; index < (int)getCount(); index++) {
+ if (getCommandByIndex(index)->_cmd == kind)
+ return true;
+ }
+ return false;
+}
+
+// CMessageQueue::CheckInterruptable (10C73A)
+bool MessageQueue::checkInterruptable() {
+ for (uint i = 0; i < getCount(); i++) {
+ const Command *cmd = getCommandByIndex(i);
+ if (cmd->_wait && cmd->_cmd != kCmdSound)
+ return false;
+ }
return true;
}
@@ -775,6 +1109,20 @@ int MessageQueue::activateExCommandsByKind(int kind) {
}
MessageQueue *GlobalMessageQueueList::getMessageQueueById(int id) {
+ if (g_ngi->_gameVersion >= 201509) {
+ // the queues belong to their scenes (CScene +212 / +236), ids are never reused
+ if (s_executingQueue && s_executingQueue->_id == id)
+ return s_executingQueue;
+ if (id <= 0 || !g_ngi->_gameProject || !g_ngi->_gameProject->_sceneTagList)
+ return nullptr;
+ for (SceneTag &tag : *g_ngi->_gameProject->_sceneTagList) {
+ if (tag._scene) {
+ if (MessageQueue *queue = tag._scene->findQueueById(id))
+ return queue;
+ }
+ }
+ return nullptr;
+ }
for (Common::Array<MessageQueue *>::iterator s = begin(); s != end(); ++s) {
if ((*s)->_id == id)
return *s;
@@ -811,6 +1159,9 @@ void GlobalMessageQueueList::disableQueueById(int id) {
}
int GlobalMessageQueueList::compact() {
+ if (g_ngi->_gameVersion >= 201509)
+ return newQueueId();
+
Common::Array<bool> useList(size() + 2);
for (uint i = 0; i < size();) {
@@ -862,18 +1213,11 @@ void clearGlobalMessageQueueList() {
void clearGlobalMessageQueueList1() {
clearMessages();
- g_ngi->_globalMessageQueueList->clear();
+ // 201509: queues stay with their scenes (CGame::DoSetScene); stopAllQueues stops them
+ if (g_ngi->_gameVersion >= 201509)
+ return;
- // D30: no queue is left, so no animation can wait for one. The scenes stay loaded here (the original has no queue ids in its animations at all): an animation that goes on
- // with a movement in a scene that is left would advance a new queue that gets its id (the ids are reused) when its movement ends
- if (g_ngi->_gameVersion >= 201509 && g_ngi->_gameProject && g_ngi->_gameProject->_sceneTagList) {
- for (SceneTag &tag : *g_ngi->_gameProject->_sceneTagList) {
- if (!tag._scene)
- continue;
- for (AniObject *ani : tag._scene->_aniObjects)
- ani->_messageQueueId = 0;
- }
- }
+ g_ngi->_globalMessageQueueList->clear();
}
void clearMessages() {
@@ -1078,6 +1422,11 @@ void updateGlobalMessageQueue(int id, int objid) {
}
bool runQueue(int queueId, int flags) {
+ if (g_ngi->_gameVersion >= 201509) {
+ // CScene::RunQueue(scene, id, 4, 0): own interrupt state, not the Windows flags
+ return g_ngi->_currentScene && g_ngi->_currentScene->runQueue(queueId, 4);
+ }
+
MessageQueue *mq = g_ngi->_currentScene->findMessageQueue(queueId);
if (!mq)
@@ -1096,6 +1445,12 @@ bool runQueue(int queueId, int flags) {
}
bool runQueueByIdWithAni(AniObject *obj, int queueId, int flags, Scene *scene) {
+ if (g_ngi->_gameVersion >= 201509) {
+ // CScene::RunQueueByIdWithAni (12263E): kBehaviorQueue (8) is interrupt state 3
+ Scene *where = scene ? scene : g_ngi->_currentScene;
+ return where && where->runQueueWithAni(queueId, obj, flags == kBehaviorQueue ? 3 : 4);
+ }
+
MessageQueue *mq = (scene ? scene : g_ngi->_currentScene)->findMessageQueue(queueId);
if (!mq)
diff --git a/engines/ngi/messages.h b/engines/ngi/messages.h
index 6c22eac75ec..0c537256326 100644
--- a/engines/ngi/messages.h
+++ b/engines/ngi/messages.h
@@ -158,8 +158,15 @@ class Command : public Message {
void setParamFloat(const char *name, float value);
/** CCommand::SetObjectCopy (10F45C): the parameter "copy", and the field of the copy */
void setObjectCopy(int copyId);
+ /** Command parameters as CMessageQueue::UpdateCmd* read them: ani, copy (-1 = all), mov */
+ int getAniId() const { return _parentId; }
+ int getCopy() const { return _param; }
+ int getMovementId() const { return _messageNum; }
bool handleMessage();
+ /** CMessageQueue::Execute: the handlers get the command, a scene message goes to its controller
+ by name (ExecuteCmdMsg); the queue polls it, the command is not deleted (>= 201509) */
+ int dispatch();
void sendMessage();
void postMessage();
void handle();
@@ -208,14 +215,15 @@ class MessageQueue : public CObject {
Scene *_scene = nullptr;
/** +60: CScene::DeleteObjAfter when the queue stops */
bool _deleteAfter = false;
- /** +64: the interrupt state (CMessageQueue::CanInterrupt, SetIntState) */
+ /** +64: the interrupt state (CanInterrupt, SetIntState); -1 until the first Run of an XML queue */
int _interruptState = 0;
+ /** +52: 0 stopped, 1 running (in Next), 2 waiting for the command, 3 paused (>= 201509) */
+ int _state = 0;
+ /** +56: the current command, -1 when not running; the commands stay in the queue */
+ int _curIndex = -1;
private:
Common::List<Command *> _commands;
- Common::ScopedPtr<Command> _pauseCommand;
- /** CMessageQueue::UpdateUserCmd: a user command that the queue waits for (SET_SCROLL with wait) */
- Common::ScopedPtr<Command> _userCommand;
public:
MessageQueue();
@@ -226,6 +234,8 @@ class MessageQueue : public CObject {
~MessageQueue() override;
bool load(MfcArchive &file) override;
+ /** Android model: the state +52 is not 0 */
+ bool isRunning() const { return _state != 0; }
int getFlags() { return _flags; }
void setFlags(int flags) { _flags = flags; }
@@ -242,12 +252,50 @@ class MessageQueue : public CObject {
void setObjectCopy(int key1, int key2);
- /** `ani` will own `this` if `run` returns true */
+ /** `ani` will own `this` if `run` returns true; from _gameVersion >= 201509 the scene owns the
+ queue (Scene::runQueueObject) and polls it in CScene::Update */
bool run(AniObject *ani);
void update();
void next();
- bool updateCmdPause(uint32 elapsed);
- bool updateCmdUser();
+
+ /** The Android queue (>= 201509): Run (10F6F4) starts at the first command, Next (10F690) runs
+ them (Execute 10F59C) up to one that waits, Update (10FD44) polls it (UpdateCmd*) */
+ void run(int interruptState);
+ /** CMessageQueue::Next (10F690) */
+ void nextCommand();
+ /** CMessageQueue::Execute (10F59C) */
+ void execute(Command *cmd);
+ /** CMessageQueue::Update (10FD44) */
+ void update(uint32 elapsed);
+ /** CMessageQueue::UpdateCmdStartMove (10F740): the animation (all copies: one of them) stands */
+ void updateCmdStartMove(Command *cmd);
+ /** CMessageQueue::UpdateCmdStartSliding (10F81C) */
+ void updateCmdStartSliding(Command *cmd);
+ /** CMessageQueue::UpdateCmdQueue (10FBD8): the other queue is stopped */
+ void updateCmdQueue(Command *cmd);
+ /** CMessageQueue::UpdateCmdPause (10FCF8): the timer counts down by the elapsed ms */
+ void updateCmdPause(Command *cmd, uint32 elapsed);
+ /** CMessageQueue::UpdateCmdSnd (10F984): the sound is not played any more */
+ void updateCmdSnd(Command *cmd);
+ /** CMessageQueue::UpdateUserCmd (10FA14): the controller says that the command is done */
+ void updateUserCmd(Command *cmd, uint32 elapsed);
+ /** CMessageQueue::ExecuteCmdPause (10F574): the timer starts at the delay */
+ void executeCmdPause(Command *cmd);
+ /** CMessageQueue::ExecuteCmdQueue (10E390): CScene::RunQueue(scene, id, state, setHero) */
+ static void executeCmdQueue(Command *cmd, Scene *queueScene);
+ void pause();
+ void resume();
+ void finishNow();
+ void tryInterrupt();
+ bool isNeedSave();
+ void setIntState(int state);
+ int getCurCommandNum() const { return _curIndex; }
+ Command *getCurCommand();
+ /** CMessageQueue::IsCommand (10C76E): a command of this kind from the start (or current) on */
+ bool isCommand(int kind, bool fromCurrent);
+ /** CMessageQueue::CheckInterruptable (10C73A): every command that waits is a sound */
+ bool checkInterruptable();
+
void finish();
void messageQueueCallback1(int par);
@@ -263,7 +311,7 @@ class MessageQueue : public CObject {
/** CMessageQueue::Stop (10C838) / Interrupt (10C882): the remaining commands are dropped and
the queue ends; CGame::OnStopQueue and CScene::DeleteObjAfter are not called */
void stop(bool silent);
- void interrupt(bool silent) { stop(silent); }
+ virtual void interrupt(bool silent) { stop(silent); }
/** CMessageQueue::SetObjectCopy (10F470): the copy of every command, or of those with the key */
void setObjectCopyAll(int copyId);
void setObjectCopyForId(int objId, int oldCopyId, int newCopyId);
@@ -271,6 +319,14 @@ class MessageQueue : public CObject {
int activateExCommandsByKind(int kind);
};
+/** CMctrlMessageQueue (1AD824): queue of a motion controller walk, interrupt sends MSG_RESETDEST */
+class MctrlMessageQueue : public MessageQueue {
+public:
+ MctrlMessageQueue(Scene *scene, bool deleteAfter, int interruptState) : MessageQueue(scene, deleteAfter, interruptState) {}
+
+ void interrupt(bool silent) override;
+};
+
class GlobalMessageQueueList : public Common::Array<MessageQueue *> {
public:
MessageQueue *getMessageQueueById(int id);
@@ -306,6 +362,8 @@ void updateGlobalMessageQueue(int id, int objid);
void clearMessages();
void clearGlobalMessageQueueList();
void clearGlobalMessageQueueList1();
+/** Id of a queue of the Android build (_gameVersion >= 201509); never given twice */
+int newQueueId();
bool runQueue(int queueId, int flags);
bool runQueueByIdWithAni(AniObject *obj, int queueId, int flags, Scene *scene = nullptr);
Commit: f0a50ab114d64d321907b5b12477562db422c7a0
https://github.com/scummvm/scummvm/commit/f0a50ab114d64d321907b5b12477562db422c7a0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Scene owns and polls its queues (CScene::RunQueue, RunQueueWithAni, Update order, StopAllQueues, TryInterruptQueues)
Changed paths:
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/scenecontroller.h
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 2a5f7275703..3655a3f24ee 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -334,10 +334,15 @@ Scene::~Scene() {
// _faObjlist is not used
+ _destroying = true;
for (uint i = 0; i < _messageQueues.size(); i++)
delete _messageQueues[i];
_messageQueues.clear();
+ for (uint i = 0; i < _madeQueues.size(); i++)
+ delete _madeQueues[i];
+ _madeQueues.clear();
+ _deleteAfterQueues.clear();
// an animation of another scene put in here (ANI_REACT, CFPController::OnSceneInit) is not ours
for (uint i = 0; i < _aniObjects.size(); i++) {
@@ -633,15 +638,49 @@ MessageQueue *Scene::findMessageQueue(int messageId) {
if (_messageQueues[i]->_queueId == messageId)
return _messageQueues[i];
- return _commonQueueScene ? _commonQueueScene->findMessageQueue(messageId) : nullptr;
+ MessageQueue *shared = _commonQueueScene ? _commonQueueScene->findMessageQueue(messageId) : nullptr;
+ if (shared && g_ngi->_gameVersion >= 201509) {
+ // as in the original (CScene::FindMessageQueue): the common queue becomes one of this scene
+ MessageQueue *own = new MessageQueue(shared, 0, 0);
+ own->_scene = this;
+ _messageQueues.push_back(own);
+ return own;
+ }
+ return shared;
}
// CScene::RunQueue (1225A4)
-bool Scene::runQueue(int queueId, int interruptState) {
+bool Scene::runQueue(int queueId, int interruptState, bool setHero) {
+ if (g_ngi->_gameVersion >= 201509) {
+ MessageQueue *queue = findMessageQueue(queueId);
+ if (!queue)
+ return false;
+ queue->run(interruptState);
+ if (setHero && g_ngi->_aniMan) // CScene +388, the hero
+ g_ngi->_aniMan->setQueue(queue);
+ return true;
+ }
return runQueueWithAni(queueId, nullptr, interruptState);
}
+// CScene::AddQueue (12285A)
+void Scene::addQueue(MessageQueue *queue) {
+ queue->_scene = this;
+ if (Common::find(_messageQueues.begin(), _messageQueues.end(), queue) != _messageQueues.end() ||
+ Common::find(_madeQueues.begin(), _madeQueues.end(), queue) != _madeQueues.end())
+ return;
+ _madeQueues.push_back(queue);
+}
+
+// CScene::RunQueue(queue, state, 0) (12287E) / RunQueueWithAni (1228AE): SetQueue, AddQueue, Run
bool Scene::runQueueObject(MessageQueue *queue, AniObject *ani, int interruptState) {
+ if (g_ngi->_gameVersion >= 201509) {
+ if (ani)
+ ani->setQueue(queue);
+ addQueue(queue);
+ queue->run(interruptState);
+ return true;
+ }
queue->_scene = this;
if (interruptState != 4)
queue->_interruptState = interruptState;
@@ -652,7 +691,16 @@ bool Scene::runQueueObject(MessageQueue *queue, AniObject *ani, int interruptSta
return true;
}
+// CScene::StopAllQueues (120C40)
void Scene::stopAllQueues() {
+ if (g_ngi->_gameVersion >= 201509) {
+ for (uint i = 0; i < _messageQueues.size(); i++)
+ _messageQueues[i]->stop(false);
+ for (uint i = 0; i < _madeQueues.size(); i++)
+ _madeQueues[i]->stop(false);
+ warning("STUB/untested: CInteractionController::StoppedAllInteractions (CScene::StopAllQueues)");
+ return;
+ }
Common::Array<MessageQueue *> running;
for (MessageQueue *queue : *g_ngi->_globalMessageQueueList) {
if (queue->_scene == this && !queue->_isFinished)
@@ -668,6 +716,12 @@ bool Scene::runQueueWithAni(int queueId, AniObject *ani, int interruptState) {
MessageQueue *queue = findMessageQueue(queueId);
if (!queue)
return false;
+ if (g_ngi->_gameVersion >= 201509) {
+ if (ani)
+ ani->setQueue(queue);
+ queue->run(interruptState);
+ return true;
+ }
MessageQueue *copy = new MessageQueue(queue, 0, 0);
copy->_scene = this;
if (interruptState != 4)
@@ -679,6 +733,71 @@ bool Scene::runQueueWithAni(int queueId, AniObject *ani, int interruptState) {
return true;
}
+// CScene::DeleteObjAfter (122B78): the object is listed once
+void Scene::deleteObjAfter(MessageQueue *queue) {
+ if (Common::find(_deleteAfterQueues.begin(), _deleteAfterQueues.end(), queue) == _deleteAfterQueues.end())
+ _deleteAfterQueues.push_back(queue);
+}
+
+// CScene::RemoveObjectSafe (11FF24): RemoveThis of the objects, then the list is empty
+void Scene::removeObjectSafe() {
+ if (_deleteAfterQueues.empty())
+ return;
+ Common::Array<MessageQueue *> doomed = _deleteAfterQueues;
+ _deleteAfterQueues.clear();
+ for (MessageQueue *queue : doomed)
+ delete queue; // CMessageQueue::RemoveThis: CScene::RemoveQueue, then the destructor
+}
+
+// CScene::RemoveQueue (11FDA2): the animations' pointers to the queue are cleared too
+// (the original clears them in CAniObject::Update when the queue stops)
+void Scene::forgetQueue(MessageQueue *queue) {
+ if (_destroying)
+ return;
+ for (uint i = 0; i < _messageQueues.size(); i++) {
+ if (_messageQueues[i] == queue) {
+ _messageQueues.remove_at(i);
+ break;
+ }
+ }
+ for (uint i = 0; i < _madeQueues.size(); i++) {
+ if (_madeQueues[i] == queue) {
+ _madeQueues.remove_at(i);
+ break;
+ }
+ }
+ for (uint i = 0; i < _deleteAfterQueues.size(); i++) {
+ if (_deleteAfterQueues[i] == queue) {
+ _deleteAfterQueues.remove_at(i);
+ break;
+ }
+ }
+ if (g_ngi->_gameProject && g_ngi->_gameProject->_sceneTagList) {
+ for (SceneTag &tag : *g_ngi->_gameProject->_sceneTagList) {
+ if (!tag._scene || tag._scene->_destroying)
+ continue;
+ for (AniObject *ani : tag._scene->_aniObjects) {
+ if (ani->_queue == queue)
+ ani->_queue = nullptr;
+ }
+ if (tag._scene->_controller)
+ tag._scene->_controller->forgetQueue(queue);
+ }
+ }
+}
+
+MessageQueue *Scene::findQueueById(int id) {
+ for (uint i = 0; i < _messageQueues.size(); i++) {
+ if (_messageQueues[i]->_id == id)
+ return _messageQueues[i];
+ }
+ for (uint i = 0; i < _madeQueues.size(); i++) {
+ if (_madeQueues[i]->_id == id)
+ return _madeQueues[i];
+ }
+ return nullptr;
+}
+
MessageQueue *Scene::getMessageQueueByName(const Common::String &name) {
for (uint i = 0; i < _messageQueues.size(); i++)
if (_messageQueues[i]->_title == name)
@@ -1092,6 +1211,37 @@ bool Scene::onMouseMove(uint32 id, float x, float y) {
return false;
}
+// CScene::OnStartQueue (121DB8): not ported: RestoreQueue of a savegame, SaveXml(true) when the
+// flag goes up, the update of the roaming objects
+void Scene::onStartQueue(uint32 queueId, uint32 sceneId) {
+ if (_controller)
+ _controller->onStartQueue(queueId, sceneId);
+ if (_sceneId == (int)sceneId) {
+ if (_behaviorController)
+ _behaviorController->onStartQueue();
+ _runningQueueId = queueId;
+ }
+ _queueStarted = true;
+}
+
+// CScene::OnStopQueue (11FFF8): an entrance queue that started last ends the "just entered" state
+void Scene::onStopQueue() {
+ if (_controller)
+ _controller->onStopQueue();
+ if (_runningQueueId != -1 && isEntranceQueue(_runningQueueId))
+ _currentEntranceId = 0;
+ _runningQueueId = -1;
+ _queueStarted = false;
+}
+
+bool Scene::isEntranceQueue(uint32 queueId) const {
+ for (const Entrance &entrance : _entrances) {
+ if ((uint32)entrance._queueId == queueId)
+ return true;
+ }
+ return false;
+}
+
// CScene::Message (120BA4): the controller's OnMessage (slot +112), then INTERACT_ENDED clears the flag (+104) of the interaction that ends, found by
// CInteractionController::FindInteraction(param). The interactions of this engine do not have that flag yet: STUB.
void Scene::message(const Common::String &name, const Common::String ¶m, MessageQueue *queue) {
@@ -1272,22 +1422,40 @@ bool Scene::update(int counterdiff) {
bool changed = false;
if (g_ngi->_gameVersion >= 201509) {
+ // CScene::Update (120A3E): behaviors, queues check their current command, then objects move
if (_behaviorController)
changed |= _behaviorController->update(counterdiff);
- for (MessageQueue *queue : *g_ngi->_globalMessageQueueList)
- changed |= queue->updateCmdPause(counterdiff);
- for (MessageQueue *queue : *g_ngi->_globalMessageQueueList)
- changed |= queue->updateCmdUser();
+ for (uint i = 0; i < _messageQueues.size(); i++)
+ _messageQueues[i]->update(counterdiff);
+ for (uint i = 0; i < _madeQueues.size(); i++)
+ _madeQueues[i]->update(counterdiff);
processMessages();
- if (g_ngi->_modalObject || this != g_ngi->getCurrentScene())
+ if (g_ngi->_modalObject || this != g_ngi->getCurrentScene()) {
+ removeObjectSafe();
return true;
+ }
+ changed |= updateObjects(counterdiff);
+ removeObjectSafe();
+ return changed;
}
return changed | updateObjects(counterdiff);
}
-// The part of CScene::Update that is the scene itself: the GUI and the objects, then the physics and the z controller (the updates of the global queues
-// above are those of CGame in the original)
+// CScene::IsQueuesProcessed (11FB98): a queue that is not stopped (interaction queues first)
bool Scene::isQueuesProcessed(bool ignoreInterruptState3) const {
+ if (g_ngi->_gameVersion >= 201509) {
+ for (uint i = 0; i < _madeQueues.size(); i++) {
+ const MessageQueue *queue = _madeQueues[i];
+ if (queue->_state != 0 && (!ignoreInterruptState3 || queue->_interruptState != 3))
+ return true;
+ }
+ for (uint i = 0; i < _messageQueues.size(); i++) {
+ const MessageQueue *queue = _messageQueues[i];
+ if (queue->_state != 0 && (!ignoreInterruptState3 || queue->_interruptState != 3))
+ return true;
+ }
+ return false;
+ }
for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList) {
if (queue->_scene == this && !queue->_isFinished && (!ignoreInterruptState3 || queue->_interruptState != 3))
return true;
@@ -1295,6 +1463,64 @@ bool Scene::isQueuesProcessed(bool ignoreInterruptState3) const {
return false;
}
+bool Scene::isQueueRunning(int queueId) {
+ const MessageQueue *queue = findMessageQueue(queueId);
+ return queue && queue->_state != 0;
+}
+
+bool Scene::isQueueStarted(int queueId) {
+ const MessageQueue *queue = findMessageQueue(queueId);
+ return queue && queue->_curIndex != -1;
+}
+
+void Scene::stopQueue(int queueId) {
+ if (MessageQueue *queue = findMessageQueue(queueId))
+ queue->stop(false);
+}
+
+bool Scene::ownsQueue(const MessageQueue *queue) const {
+ return Common::find(_messageQueues.begin(), _messageQueues.end(), queue) != _messageQueues.end() ||
+ Common::find(_madeQueues.begin(), _madeQueues.end(), queue) != _madeQueues.end();
+}
+
+// CScene::HowManyQueuesProcessed (11FBFE)
+int Scene::howManyQueuesProcessed() const {
+ int count = 0;
+ for (uint i = 0; i < _madeQueues.size(); i++)
+ count += _madeQueues[i]->_state != 0;
+ for (uint i = 0; i < _messageQueues.size(); i++)
+ count += _messageQueues[i]->_state != 0;
+ return count;
+}
+
+// CScene::TryInterruptQueues (11FC50): true when no queue is left (interrupt state 3 aside)
+bool Scene::tryInterruptQueues() {
+ for (uint i = 0; i < _madeQueues.size(); i++) {
+ if (_madeQueues[i]->_state != 0)
+ _madeQueues[i]->tryInterrupt();
+ }
+ for (uint i = 0; i < _messageQueues.size(); i++) {
+ if (_messageQueues[i]->_state != 0)
+ _messageQueues[i]->tryInterrupt();
+ }
+ return !isQueuesProcessed(true);
+}
+
+// CScene::CanInterruptQueues (11FCB2)
+bool Scene::canInterruptQueues() const {
+ for (uint i = 0; i < _madeQueues.size(); i++) {
+ MessageQueue *queue = _madeQueues[i];
+ if (queue->_state != 0 && !queue->canInterrupt() && queue->_interruptState != 3)
+ return false;
+ }
+ for (uint i = 0; i < _messageQueues.size(); i++) {
+ MessageQueue *queue = _messageQueues[i];
+ if (queue->_state != 0 && !queue->canInterrupt() && queue->_interruptState != 3)
+ return false;
+ }
+ return true;
+}
+
bool Scene::updateObjects(int counterdiff) {
bool changed = false;
if (_guiManager)
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index c5f621d9c74..23d148fd5a9 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -106,6 +106,14 @@ class Scene : public Background {
bool _putPrev = false;
/** CScene +352 ("waitscreen", default true): show the wait screen while the textures load */
bool _waitscreen = true;
+ /** CScene::OnStartQueue (121DB8) / OnStopQueue (11FFF8) */
+ void onStartQueue(uint32 queueId, uint32 sceneId);
+ void onStopQueue();
+ /** CScene::IsEntranceQueue (11FFCC): the queue is the one of an entrance of the scene */
+ bool isEntranceQueue(uint32 queueId) const;
+ /** CScene +5: a queue started and none stopped since; +340: id of the last started queue */
+ bool _queueStarted = false;
+ int _runningQueueId = -1;
/** CScene::OnShow / OnHide: the parts that the controllers, the behaviors and the GUI need */
virtual void onShow();
virtual void onHide();
@@ -122,9 +130,16 @@ class Scene : public Background {
bool isInventoryEnabled() const;
void (*_guiEventHandler)(Scene &, const Common::String &, const Common::String &) = nullptr;
void onGuiEvent(const Common::String &id, const Common::String &event);
+ // CScene +212: the XML queues, owned. From >= 201509 they run in place and Update polls them;
+ // the queues of the common scene (_commonQueueScene) are copied in at first use (findMessageQueue)
Common::Array<MessageQueue *> _messageQueues;
- // XML queue templates are cloned when run and can be shared between scenes.
Scene *_commonQueueScene = nullptr;
+ /** Queues made by the code (CScene::AddQueue), owned, polled like _messageQueues (>= 201509) */
+ Common::Array<MessageQueue *> _madeQueues;
+ /** CScene +292: DeleteObjAfter queues, deleted by RemoveObjectSafe at the end of the update */
+ Common::Array<MessageQueue *> _deleteAfterQueues;
+ /** The scene is being deleted: its queues do not look for animations pointing to them */
+ bool _destroying = false;
// PtrList _faObjectList; // not used
Common::ScopedPtr<Shadows> _shadows;
Common::ScopedPtr<SoundList> _soundList;
@@ -160,11 +175,28 @@ class Scene : public Background {
AniObject *findAniObjectById(int obj, int a3);
AniObject *getStaticANIObject1ByName(const Common::String &name, int a3);
MessageQueue *findMessageQueue(int messageId);
- /**
- * CScene::RunQueue (1225A4) without the object that gets the queue (a4): the queue of the scene runs (a copy of the template here, in the scene), false when there
- * is none or it does not start. interruptState is the argument of CMessageQueue::Run (InteruptState): 4 keeps the one of the queue.
- */
- bool runQueue(int queueId, int interruptState = 4);
+ // CScene::RunQueue (1225A4): false without such a queue; interruptState 4 keeps the queue's own;
+ // from >= 201509 the queue itself runs (again if running), before that a copy of the template
+ bool runQueue(int queueId, int interruptState = 4, bool setHero = false);
+ /** CScene::AddQueue (12285A): the scene owns the queue from now on and Update polls it */
+ void addQueue(MessageQueue *queue);
+ /** CScene::DeleteObjAfter (122B78), RemoveObjectSafe (11FF24): delete at the end of the update */
+ void deleteObjAfter(MessageQueue *queue);
+ void removeObjectSafe();
+ /** CScene::RemoveQueue (11FDA2), and no animation keeps a pointer to the queue any more */
+ void forgetQueue(MessageQueue *queue);
+ /** The queue of the scene with this id (a template or one the code made) */
+ MessageQueue *findQueueById(int id);
+ /** CScene::HowManyQueuesProcessed (11FBFE), TryInterruptQueues (11FC50), CanInterruptQueues */
+ int howManyQueuesProcessed() const;
+ bool tryInterruptQueues();
+ bool canInterruptQueues() const;
+ /** not stopped (CMessageQueue +52 != 0) / started and not stopped since (+56 != -1) / stop */
+ bool isQueueRunning(int queueId);
+ bool isQueueStarted(int queueId);
+ void stopQueue(int queueId);
+ /** The scene keeps this queue (CScene +212) */
+ bool ownsQueue(const MessageQueue *queue) const;
/** CScene::RunQueueByIdWithAni (12263E), RunQueueWithAni (1228AE): the object gets the queue */
bool runQueueWithAni(int queueId, AniObject *ani, int interruptState = 4);
/** CScene::RunQueue / RunQueueWithAni with a queue of the caller; deleted if it does not start */
diff --git a/engines/ngi/scenecontroller.h b/engines/ngi/scenecontroller.h
index a7b693bb8e4..9196957220b 100644
--- a/engines/ngi/scenecontroller.h
+++ b/engines/ngi/scenecontroller.h
@@ -83,6 +83,8 @@ public:
virtual bool hit(uint32 x, uint32 y) { return false; }
virtual void onStartQueue(uint32 queueId, uint32 sceneId) {}
virtual void onStopQueue() {}
+ /** A queue of the scene is deleted: forget the pointers kept to it (CheckQueues) */
+ virtual void forgetQueue(MessageQueue *queue) {}
virtual bool createCustomGui() { return false; }
virtual void onRemoveCopies() {}
Commit: d80422231937c83c068f69fde462102e22e481a8
https://github.com/scummvm/scummvm/commit/d80422231937c83c068f69fde462102e22e481a8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: AniObject keeps its queue as a pointer and tells nobody when a movement stops (CVisibleObject::SetQueue)
Changed paths:
engines/ngi/behavior.cpp
engines/ngi/behavior.h
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/behavior.cpp b/engines/ngi/behavior.cpp
index 7192026bce0..8c40a613940 100644
--- a/engines/ngi/behavior.cpp
+++ b/engines/ngi/behavior.cpp
@@ -113,6 +113,24 @@ bool BehaviorMove::canStart(uint32 elapsed, uint32 randomMax) const {
return !(_flags & 1) && (_delay <= 0 || elapsed >= (uint32)_delay) && _percent && g_ngi->_rnd.getRandomNumber(randomMax) <= _percent;
}
+// CBehaviorAni::Stop(scene, flag) (F2F08): stops the movement and, if the flag allows, the queue
+void BehaviorAni::stop(Scene *scene, bool stopQueues) {
+ if (!_activeMove)
+ return;
+ if (_activeMove->_movementId) {
+ if (_ani && _ani->_movement && _ani->_movement->_id == _activeMove->_movementId)
+ _ani->stopMovement();
+ } else if (_activeMove->_queueId != 0 && stopQueues) {
+ MessageQueue *queue = scene ? scene->findMessageQueue(_activeMove->_queueId) : nullptr;
+ if (queue)
+ queue->stop(false);
+ } else {
+ return;
+ }
+ _activeMove = nullptr;
+ _elapsed = 0; // CBehaviorAni::ResetTimerForItem
+}
+
// CBehaviorAni::Update: the move queue runs in the behavior's scene (not the current one)
bool BehaviorAni::update(uint32 elapsed, Scene *scene) {
if (!_ani)
@@ -122,20 +140,19 @@ bool BehaviorAni::update(uint32 elapsed, Scene *scene) {
if (_ani->_movement && _ani->_movement->_id == _activeMove->_movementId)
return false;
} else {
- for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList)
- if (queue->_queueId == _activeMove->_queueId && !queue->_isFinished)
- return false;
+ // the queue of the move is a queue of the scene: the move is over when it is stopped
+ const MessageQueue *queue = scene->findMessageQueue(_activeMove->_queueId);
+ if (queue && queue->_state != 0)
+ return false;
}
_activeMove = nullptr;
return false;
}
- if (_ani->_movement || !_ani->_statics || !(_ani->_flags & 4) || _ani->_messageQueueId)
+ // CBehaviorAni::CanMove (F2FC4): standing, visible, no queue; the behavior flags add conditions
+ if (_ani->_movement || !_ani->_statics || !(_ani->_flags & 4) || _ani->_queue)
+ return false;
+ if ((_flags & 1) && scene->isQueuesProcessed(true))
return false;
- if (_flags & 1) {
- for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList)
- if (!queue->_isFinished && !(queue->_flags & kBehaviorQueue))
- return false;
- }
_elapsed += elapsed;
for (const BehaviorAnim &anim : _behaviorAnims) {
@@ -224,6 +241,22 @@ void BehaviorController::initBehavior(Scene *sc, GameVar *var) {
}
}
+// CBehaviorController::OnSetQueue (F3774): a new queue stops what its behavior started
+void BehaviorController::onSetQueue(int aniId) {
+ for (BehaviorAni &beh : _behaviors) {
+ if (beh._ani && beh._ani->_id == aniId)
+ beh.stop(_scene, true);
+ }
+}
+
+// CBehaviorController::OnStartQueue (F3564), CBehaviorAni::OnStartQueue (F305C): flag 1 stops
+void BehaviorController::onStartQueue() {
+ for (BehaviorAni &beh : _behaviors) {
+ if (beh._flags & 1)
+ beh.stop(_scene, true);
+ }
+}
+
bool BehaviorController::update(uint32 elapsed) {
if (!_isActive)
return false;
diff --git a/engines/ngi/behavior.h b/engines/ngi/behavior.h
index 46222c61f98..f1a02610f2f 100644
--- a/engines/ngi/behavior.h
+++ b/engines/ngi/behavior.h
@@ -76,6 +76,8 @@ struct BehaviorAni {
void clear();
BehaviorMove &addMove(int16 staticsId);
bool update(uint32 elapsed, Scene *scene);
+ /** CBehaviorAni::Stop(scene, flag) (F2F08) */
+ void stop(Scene *scene, bool stopQueues);
void initAmbientBehavior(GameVar *var, Scene *sc);
void initObjectBehavior(GameVar *var, Scene *sc, AniObject *ani);
};
@@ -115,6 +117,9 @@ class BehaviorController : public CObject {
BehaviorAni &addAni(int16 objectId, int16 sceneId, int flags);
void onShow(Scene &scene);
bool update(uint32 elapsed = 1);
+ /** CBehaviorController::OnSetQueue (F3774) and OnStartQueue (F3564) */
+ void onSetQueue(int aniId);
+ void onStartQueue();
void updateBehavior(BehaviorAni &behaviorInfo, BehaviorAnim &entry);
void updateStaticAniBehavior(AniObject &ani, int delay, const BehaviorAnim &beh);
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index c2a5139fc77..468dc2194a4 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -26,6 +26,7 @@
#include "ngi/objects.h"
#include "ngi/ngiarchive.h"
#include "ngi/statics.h"
+#include "ngi/behavior.h"
#include "ngi/preloadmanager.h"
#include "ngi/messages.h"
#include "ngi/interaction.h"
@@ -223,6 +224,7 @@ void AniObject::clearFlags() {
_flags = 0;
stopQueue();
+ _queue = nullptr;
_messageQueueId = 0;
_movement = nullptr;
_statics = nullptr;
@@ -241,7 +243,13 @@ void AniObject::setFlags40(bool state) {
}
}
+// CVisibleObject::StopQueue (EF19A)
void AniObject::stopQueue() {
+ if (g_ngi->_gameVersion >= 201509) {
+ if (_queue)
+ _queue->stop(false);
+ return;
+ }
while (_messageQueueId) {
if (g_ngi->_globalMessageQueueList->getMessageQueueById(_messageQueueId)) {
if (!isIdle())
@@ -254,7 +262,16 @@ void AniObject::stopQueue() {
}
}
+// CVisibleObject::SetQueue (126E70): the behavior controller stops what it started
bool AniObject::setQueue(MessageQueue *mq) {
+ if (g_ngi->_gameVersion >= 201509) {
+ _queue = mq;
+ Scene *scene = g_ngi->getCurrentScene();
+ if (scene && scene->_behaviorController)
+ scene->_behaviorController->onSetQueue(_id);
+ return true;
+ }
+
if (_flags & 0x80)
return false;
@@ -281,6 +298,10 @@ bool AniObject::setQueue(MessageQueue *mq) {
}
void AniObject::restartMessageQueue(MessageQueue *mq) {
+ if (g_ngi->_gameVersion >= 201509) {
+ warning("STUB/untested: AniObject::restartMessageQueue is a function of the Windows scene code (scene 25)");
+ return;
+ }
Command *ex = mq->getCommandByIndex(0);
if (ex) {
while (ex->_cmd != kCmdStartMovement || ex->_parentId != _id) {
@@ -304,6 +325,9 @@ void AniObject::restartMessageQueue(MessageQueue *mq) {
}
MessageQueue *AniObject::getMessageQueue() {
+ if (g_ngi->_gameVersion >= 201509)
+ return _queue; // CVisibleObject +104
+
if (this->_messageQueueId <= 0)
return nullptr;
@@ -320,12 +344,17 @@ bool AniObject::canInterruptQueue() {
void AniObject::interruptQueue() {
MessageQueue *queue = getMessageQueue();
if (queue) {
- queue->stop(false);
+ queue->interrupt(false);
+ _queue = nullptr;
_messageQueueId = 0;
}
}
bool AniObject::trySetMessageQueue(int msgNum, int qId) {
+ if (g_ngi->_gameVersion >= 201509) {
+ warning("STUB/untested: SET_ANI_QUEUE (AniObject::trySetMessageQueue) is a command of the Windows scene code: the queue would wait for a tick counter that the Android build does not have");
+ return false;
+ }
if (_messageQueueId || !msgNum) {
updateGlobalMessageQueue(qId, _id);
return false;
@@ -340,6 +369,12 @@ bool AniObject::trySetMessageQueue(int msgNum, int qId) {
}
void AniObject::startMQIfIdle(int qId, int flag) {
+ if (g_ngi->_gameVersion >= 201509) {
+ // the queue of the scene runs for the object when it is not busy (CScene::RunQueueByIdWithAni)
+ if (isIdle() && !(_flags & 0x100))
+ g_ngi->_currentScene->runQueueWithAni(qId, this, 4);
+ return;
+ }
MessageQueue *msg = g_ngi->_currentScene->findMessageQueue(qId);
if (msg && isIdle() && !(_flags & 0x100)) {
@@ -374,6 +409,9 @@ void AniObject::startMQIfIdle(int qId, int flag) {
bool AniObject::isIdle() {
assert(_objtype == kObjTypeStaticANIObject);
+ if (g_ngi->_gameVersion >= 201509)
+ return !_queue || _queue->_state == 0;
+
if (_messageQueueId) {
MessageQueue *m = g_ngi->_globalMessageQueueList->getMessageQueueById(_messageQueueId);
@@ -818,12 +856,20 @@ Common::Point AniObject::getSomeXY() const {
error("No someXY found");
}
+// CAniObject::Update (F2D7C): afterwards the object lets go of a stopped queue
bool AniObject::update(int counterdiff) {
+ const bool changed = updateAnimation(counterdiff);
+ if (g_ngi->_gameVersion >= 201509 && _queue && _queue->_state == 0)
+ setQueue(nullptr);
+ return changed;
+}
+
+bool AniObject::updateAnimation(int counterdiff) {
int mqid;
debugC(6, kDebugAnimation, "AniObject::update() (%s) [%d] [%d, %d] fl: %x", transCyrillic(_title), _id, _x, _y, _flags);
- if (_flags & 2) {
+ if ((_flags & 2) && g_ngi->_gameVersion < 201509) {
_messageNum--;
if (_messageNum)
return false;
@@ -1135,6 +1181,10 @@ L12:
ex->postMessage();
}
+ // nobody is told: the queue sees that the object stands (CMessageQueue::UpdateCmdStartMove)
+ if (g_ngi->_gameVersion >= 201509)
+ return;
+
int mqid = _messageQueueId;
if (_animExFlag) {
@@ -1168,6 +1218,14 @@ void AniObject::stopCutMovement(const Common::Point &pending) {
setPos(mirrored ? originX - some.x : originX + some.x, originY + some.y);
}
+bool AniObject::isSlidingEnd(float endX, float endY) const {
+ if (!_movement)
+ return true;
+ if (_movement->_cycled && (endX != 0.0f || endY != 0.0f))
+ warning("STUB/untested: CMovement::IsSlidingEnd of a cycled slide with an end point (%f, %f)", endX, endY);
+ return _movement->_cycled;
+}
+
// CAniObject::StopMovementToPrev (movement stopped by a new walk or a script): the object goes back to the previous statics of the
// running movement, keeping the horizontal center of the sprite; the vertical position is that of the statics at the start of the
// movement (the movement origin minus the steps taken since: the phase offsets and the sliding steps).
@@ -1513,7 +1571,8 @@ void AniObject::moveToStaticChain(int staticsId) {
}
void AniObject::hide() {
- if (!_messageQueueId) {
+ // CMessageQueue::ExecuteCmdHide hides the object whatever it does
+ if (g_ngi->_gameVersion >= 201509 || !_messageQueueId) {
if (_flags & 4)
_flags ^= 4;
}
@@ -1564,7 +1623,9 @@ void AniObject::show1(int x, int y, int movId, int mqId) {
if (_flags & 1)
_flags ^= 1;
- _messageQueueId = mqId;
+ // ExecuteCmdShow does not tie the object to a queue
+ if (g_ngi->_gameVersion < 201509)
+ _messageQueueId = mqId;
}
void AniObject::show2(int x, int y, int movementId, int mqId) {
@@ -1729,19 +1790,21 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
Movement *mov = getMovement(movementId);
// An XML movement without any PHASE elements contains only its end pose.
if (!mov || (timedMovement && !mov->getPhase(1))) {
- updateGlobalMessageQueue(messageQueueId, _id);
+ if (!timedMovement) // the queue sees that the object stands
+ updateGlobalMessageQueue(messageQueueId, _id);
return false;
}
if (timedMovement && _movement && (_flags & 1)) {
debugC(1, kDebugInfo, "INFO t %u movement %d of %d is started while %d runs (frame %d of %d, queue %d, new queue %d)", g_system->getMillis(), movementId, _id,
- _movement->_id, _movement->_curFrame, (int)_movement->_phases.size(), _messageQueueId, messageQueueId);
+ _movement->_id, _movement->_curFrame, (int)_movement->_phases.size(), _queue ? _queue->_id : 0, messageQueueId);
stopMovementToPrev(false); // CAniObject::StartMovement: a running movement is rewound to its previous statics first
}
if (mov == _movement) {
_flags |= 1;
- _messageQueueId = messageQueueId;
+ if (!timedMovement)
+ _messageQueueId = messageQueueId;
return true;
}
@@ -1833,7 +1896,8 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
}
}
- _messageQueueId = messageQueueId;
+ if (!timedMovement) // no queue started the movement (CAniObject::StartMovement has none)
+ _messageQueueId = messageQueueId;
_movement->_curPhase->_countdown = _movement->_curPhase->_delay;
_movement->_counter = 0;
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index a87cdb378ea..ec86f7318a3 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -208,7 +208,10 @@ class AniObject : public GameObject {
Common::Array<Statics *> _staticsList;
StepArray _stepArray;
int16 _field_96;
+ /** the Windows queue id; 0 for _gameVersion >= 201509 (see _queue) */
int _messageQueueId;
+ /** CVisibleObject +104 (>= 201509): the queue that moves the object, owned by its scene */
+ MessageQueue *_queue = nullptr;
int _messageNum;
int _animExFlag;
int _counter;
@@ -240,6 +243,9 @@ public:
void setAlpha(int alpha);
void stopQueue();
+ /** the Windows scene code writes _messageQueueId = 0 to free the object */
+ void resetQueue() { _messageQueueId = 0; _queue = nullptr; }
+ /** CVisibleObject::SetQueue (126E70) */
bool setQueue(MessageQueue *msg);
void restartMessageQueue(MessageQueue *msg);
MessageQueue *getMessageQueue();
@@ -280,7 +286,10 @@ public:
void show1(int x, int y, int movementId, int mqId);
void show2(int x, int y, int movementId, int mqId);
void playIdle();
+ /** CAniObject::Update (F2D7C) */
bool update(int counterdiff);
+ /** The movement of the object (update without the queue pointer) */
+ bool updateAnimation(int counterdiff);
Statics *addReverseStatics(Statics *ani);
void render(Common::Point scroll = Common::Point());
@@ -293,6 +302,8 @@ public:
void updateStepPos();
void stopMovement();
+ /** CAniObject::IsSlidingEnd (F0EEE); the end point test for cycled movements is not ported */
+ bool isSlidingEnd(float endX, float endY) const;
Common::Point *calcNextStep(Common::Point *point);
MessageQueue *moveToStatic(int msgNum);
Commit: 4581baead77b5abd91cff0e76e12836b815d01c2
https://github.com/scummvm/scummvm/commit/4581baead77b5abd91cff0e76e12836b815d01c2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: The walk queues are made as CMctrlMessageQueue and run through RunQueueWithAni
Changed paths:
engines/ngi/motion.cpp
diff --git a/engines/ngi/motion.cpp b/engines/ngi/motion.cpp
index 157890db5ef..4eb20bf42c3 100644
--- a/engines/ngi/motion.cpp
+++ b/engines/ngi/motion.cpp
@@ -2064,6 +2064,8 @@ void MctlGraph::generateList(GmctlMqStruct &movinfo, MovGraphLinkList *linkList,
}
}
+static MessageQueue *newWalkQueue();
+
MessageQueue *MctlGraph::makeWholeQueue(GmctlMqStruct &mctlMQ) {
debugC(4, kDebugPathfinding, "MctlGraph::makeWholeQueue(...)");
@@ -2073,7 +2075,7 @@ MessageQueue *MctlGraph::makeWholeQueue(GmctlMqStruct &mctlMQ) {
int curY = mctlMQ.sourcePos.y;
int curDistance = mctlMQ.sourceZ;
- MessageQueue *mq = new MessageQueue(g_ngi->_globalMessageQueueList->compact());
+ MessageQueue *mq = newWalkQueue();
int numItems = mctlMQ.items.size();
@@ -2267,6 +2269,13 @@ MessageQueue *MctlGraph::startMove(AniObject *ani, int xpos, int ypos, int fuzzy
return mq;
}
+// CMctlGraph::MakeQueue: CMctrlMessageQueue(scene, 1, 1), interrupt state 1
+static MessageQueue *newWalkQueue() {
+ if (g_ngi->_gameVersion >= 201509)
+ return new MctrlMessageQueue(nullptr, true, 1); // Scene::addQueue gives it its scene
+ return new MessageQueue(g_ngi->_globalMessageQueueList->compact());
+}
+
MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzyMatch, int staticsId, bool mirror) {
LinkOrNode linkInfoDest;
LinkOrNode linkInfoSource;
@@ -2361,7 +2370,7 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
// CMctlGraph::MakeQueue: already there within one pixel (of the sprite center)
const bool near = revised ? (abs(obj->_x - xpos) <= 1 && abs(obj->_y - ypos) <= 1) : (obj->_x == xpos && obj->_y == ypos);
if (near) {
- MessageQueue *mq = new MessageQueue(g_ngi->_globalMessageQueueList->compact());
+ MessageQueue *mq = newWalkQueue();
if (staticsId && obj->_statics->_staticsId != staticsId) {
int idxwalk = getDirByStatics(idx, staticsId, mirror);
Commit: 988d90505645e6b08d781de37550fa53370d7901
https://github.com/scummvm/scummvm/commit/988d90505645e6b08d781de37550fa53370d7901
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Interactions and the inventory run their queues in the scene of the animation
Changed paths:
engines/ngi/interaction.cpp
engines/ngi/interaction.h
engines/ngi/inventory.cpp
diff --git a/engines/ngi/interaction.cpp b/engines/ngi/interaction.cpp
index a74d514c075..243831ab838 100644
--- a/engines/ngi/interaction.cpp
+++ b/engines/ngi/interaction.cpp
@@ -96,6 +96,17 @@ bool InteractionController::compareInteractions(const Interact *i1, const Intera
return true;
}
+void InteractionController::onStartQueue() {
+ if (!_queueRunning) {
+ static bool reported = false;
+ if (!reported) {
+ reported = true;
+ warning("STUB/untested: CGObject::SaveXml of the interaction controller (CInteractionController::OnStartQueue)");
+ }
+ }
+ _queueRunning = true;
+}
+
void InteractionController::sortInteractions(int sceneId) {
static_compSceneId = sceneId;
@@ -104,9 +115,11 @@ void InteractionController::sortInteractions(int sceneId) {
bool InteractionController::handleInteraction(AniObject *subj, GameObject *obj, int invId) {
if (g_ngi->usesXMLProject()) {
- if (!_enabled || !subj || !obj || subj->_messageQueueId) {
+ // the subject is busy while its queue runs (the Android build has its pointer, the Windows engine an id)
+ const bool busy = subj && (g_ngi->_gameVersion >= 201509 ? !subj->isIdle() : subj->_messageQueueId != 0);
+ if (!_enabled || !subj || !obj || busy) {
debugC(1, kDebugInfo, "INFO t %u INTERACTION refused: enabled %d subject %p object %p subject queue %d", g_system->getMillis(), _enabled, (void *)subj, (void *)obj,
- subj ? subj->_messageQueueId : -1);
+ !subj ? -1 : (subj->_queue ? subj->_queue->_id : subj->_messageQueueId));
return false;
}
Interact *action = nullptr;
diff --git a/engines/ngi/interaction.h b/engines/ngi/interaction.h
index ad95d0f1cc0..8586a6da158 100644
--- a/engines/ngi/interaction.h
+++ b/engines/ngi/interaction.h
@@ -92,6 +92,11 @@ public:
void sortInteractions(int sceneId);
+ /** CInteractionController::OnStartQueue (105C18) / OnStopQueue (105C30): flag +5 */
+ void onStartQueue();
+ void onStopQueue() { _queueRunning = false; }
+ bool _queueRunning = false;
+
bool handleInteraction(AniObject *subj, GameObject *obj, int invId);
Interact *findInteraction(int obId, int obId2, int obId3);
diff --git a/engines/ngi/inventory.cpp b/engines/ngi/inventory.cpp
index 20deee204bb..a40714e2ede 100644
--- a/engines/ngi/inventory.cpp
+++ b/engines/ngi/inventory.cpp
@@ -943,7 +943,7 @@ bool InventoryItem::runQueue() {
if (!_queue)
return false;
_queue->_scene = g_ngi->getCurrentScene();
- warning("STUB/untested: CMessageQueue::Run(4) of the queue of the inventory item %s", _id.c_str());
+ _queue->run(4);
return true;
}
@@ -1127,7 +1127,11 @@ void Inventory::cleanXml() {
// CGObject::SaveXml(bool) (FE8D8): saves the XML state to GetSavePath (inventory.sav)
void Inventory::saveXml(bool flag) {
- warning("STUB/untested: CGObject::SaveXml of the inventory (inventory.sav is not written, the state is in the savegames)");
+ static bool reported = false;
+ if (!reported) {
+ reported = true;
+ warning("STUB/untested: CGObject::SaveXml of the inventory (inventory.sav is not written, the state is in the savegames)");
+ }
}
// CInventory::Update (10BCE8)
Commit: d70f794b9adb0ad3ee5aaa111bd4990da93620aa
https://github.com/scummvm/scummvm/commit/d70f794b9adb0ad3ee5aaa111bd4990da93620aa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Loader, engine and XML project: queues stay with their scene, queue ids only for the Windows handlers
Changed paths:
engines/ngi/gameloader.cpp
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/stateloader.cpp
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/gameloader.cpp b/engines/ngi/gameloader.cpp
index f51386faa79..51450e03a9c 100644
--- a/engines/ngi/gameloader.cpp
+++ b/engines/ngi/gameloader.cpp
@@ -231,7 +231,8 @@ bool GameLoader::setScene(int sceneId, int entranceId) {
g_ngi->_currentScene = scene;
if (xmlEntrances) {
- if (entrance->_queueId && !runQueue(entrance->_queueId, 0))
+ // CScene::Entrance (1225FA)
+ if (entrance->_queueId && !scene->runQueue(entrance->_queueId, 2, true))
return false;
debugC(1, kDebugSceneLogic, "Entered scene %d through entrance %d, queue %d", sceneId, entranceId, entrance->_queueId);
return true;
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 78c9d987be6..302931bf097 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -764,6 +764,36 @@ void NGIEngine::deleteModalObject() {
_modalObject = tmp;
}
+// CGame::OnStartQueue (FCD3C). CGame +4 (game is saved) is taken as set, +5 is the state the next
+// queue finds. The XML save (CGame::SaveXml(true)) when it goes up is not ported
+void NGIEngine::onStartQueue(uint32 queueId, uint32 sceneId) {
+ if (!_queueStarted) {
+ static bool reported = false;
+ if (!reported) {
+ reported = true;
+ warning("STUB/untested: CGame::SaveXml(true) (CGame::OnStartQueue) is not ported");
+ }
+ }
+ _queueStarted = true;
+ if (_gameLoader && _gameLoader->_interactionController)
+ _gameLoader->_interactionController->onStartQueue();
+ if (_inventory)
+ _inventory->onStartQueue();
+ for (uint i = 0; i < _sceneStack.size(); i++)
+ _sceneStack[i]->onStartQueue(queueId, sceneId);
+}
+
+// CGame::OnStopQueue (FCD96)
+void NGIEngine::onStopQueue() {
+ _queueStarted = false;
+ if (_gameLoader && _gameLoader->_interactionController)
+ _gameLoader->_interactionController->onStopQueue();
+ if (_inventory)
+ _inventory->onStopQueue();
+ for (uint i = 0; i < _sceneStack.size(); i++)
+ _sceneStack[i]->onStopQueue();
+}
+
Common::Error NGIEngine::updateScreen(uint32 elapsed, byte &brightness, bool redraw) {
const bool timedUpdates = _gameVersion >= 201509;
_mouseVirtX = _mouseScreenPos.x + _sceneRect.left;
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 08822196fa8..a2223c3b4f5 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -150,6 +150,8 @@ int global_messageHandler3(Command *cmd);
int global_messageHandler4(Command *cmd);
void global_messageHandler_handleSound(Command *cmd);
void executeUserCommand(Command *cmd, MessageQueue *queue = nullptr);
+/** CMessageQueue::ExecuteUserCmd / UpdateUserCmd: the scene whose controller runs a USER command */
+Scene *getUserCommandScene(const Command *cmd, const MessageQueue *queue);
/** Pixels beyond each side of the 800x600 area on a 16:9 screen (CRender::AdjustSize) */
@@ -430,6 +432,11 @@ public:
/** CGame::IsInventoryRendered / IsInventoryEnabled: asked of the current scene controller */
bool isInventoryRendered();
bool isInventoryEnabled();
+ /** CGame::OnStartQueue (FCD3C) / OnStopQueue (FCD96) */
+ void onStartQueue(uint32 queueId, uint32 sceneId);
+ void onStopQueue();
+ /** CGame +5 */
+ bool _queueStarted = false;
/** The event handling of the current scene: its controller, then its GUI */
bool handleSceneEvent(const Common::Event &event, GuiManager *manager);
/** CGame::OnMouse*: the mouse event goes to the inventory scene */
diff --git a/engines/ngi/stateloader.cpp b/engines/ngi/stateloader.cpp
index 059aa6de515..1338d8a80f6 100644
--- a/engines/ngi/stateloader.cpp
+++ b/engines/ngi/stateloader.cpp
@@ -174,6 +174,9 @@ bool GameLoader::readSavegame(const char *fname) {
}
clearGlobalMessageQueueList1();
+ // CSettings::Load: StopAllQueues of the scene of the stack
+ if (g_ngi->_gameVersion >= 201509 && g_ngi->_currentScene)
+ g_ngi->_currentScene->stopAllQueues();
if (g_ngi->_currentScene)
unloadScene(g_ngi->_currentScene->_sceneId);
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index fdbad810b30..3b6f3eb09f4 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -1343,6 +1343,7 @@ private:
bool parserCallback_QUEUE(ParserNode *node) {
Common::ScopedPtr<MessageQueue> queue(new MessageQueue());
queue->_scene = &_scene;
+ queue->_interruptState = -1; // CMessageQueue::Init: CheckInterruptable() at the first Run
if (!readId(node->values["id"], queue->_queueId))
return parserError("Unknown queue ID " + node->values["id"]);
queue->_title = node->values.getValOrDefault("title");
Commit: 969257d9c3d4de65992198ad54e202befdfcaf87
https://github.com/scummvm/scummvm/commit/969257d9c3d4de65992198ad54e202befdfcaf87
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: FPController mctlStartMove, interruptManQueue and MSG_RESETDEST as in the original; the scene controllers use the new queues
Changed paths:
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/fpcontroller.h
engines/ngi/fullpipe/sc01controller.cpp
engines/ngi/fullpipe/sc04controller.cpp
engines/ngi/fullpipe/sc29controller.cpp
engines/ngi/fullpipe/scene09.cpp
engines/ngi/fullpipe/scene25.cpp
engines/ngi/fullpipe/sceneIntro.cpp
engines/ngi/fullpipe/tutorialcontroller.cpp
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 40ff1099b63..6000d8e52c3 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -92,12 +92,7 @@ static void execSetActiveInteraction(Command *cmd) {
}
// CMessageQueue::ExecuteUserCmd (10E68C); Windows queues without a scene use the current one
-void executeUserCommand(Command *cmd, MessageQueue *queue) {
- if (cmd->_messageName == "SET_ACTIVE_INTERACTION") {
- execSetActiveInteraction(cmd);
- return;
- }
-
+Scene *getUserCommandScene(const Command *cmd, const MessageQueue *queue) {
Scene *scene = nullptr;
const Common::String sceneName = cmd->_args.getValOrDefault("sc");
if (!sceneName.empty())
@@ -111,6 +106,16 @@ void executeUserCommand(Command *cmd, MessageQueue *queue) {
scene = queue->_scene;
if (!scene)
scene = g_ngi->getCurrentScene();
+ return scene;
+}
+
+void executeUserCommand(Command *cmd, MessageQueue *queue) {
+ if (cmd->_messageName == "SET_ACTIVE_INTERACTION") {
+ execSetActiveInteraction(cmd);
+ return;
+ }
+
+ Scene *scene = getUserCommandScene(cmd, queue);
if (scene && scene->_controller)
scene->_controller->executeUserCmd(cmd, queue);
}
@@ -569,7 +574,9 @@ bool FPController::canInterruptManQueue() const {
// CFPController::CheckQueues (hero's queue part: +72, +76, +88, +192) and the swipe flag (+212)
void FPController::checkQueues() {
- if (hero() && !hero()->_messageQueueId) {
+ if (hero() && !hero()->getMessageQueue() && !hero()->_messageQueueId) {
+ _walkQueue = nullptr;
+ _interactionQueue = nullptr;
_lastTargetX = 0;
_lastTargetY = 0;
_interactObjectId = 0;
@@ -578,6 +585,33 @@ void FPController::checkQueues() {
}
}
+// CFPController::InterruptManQueue (148DFE)
+void FPController::interruptManQueue() {
+ MessageQueue *queue = hero()->getMessageQueue();
+ if (!queue)
+ return;
+ if (_interactionQueue != queue) {
+ queue->interrupt(false);
+ hero()->setQueue(nullptr);
+ }
+ if (_walkQueue) {
+ _walkQueue->interrupt(false);
+ if (_interactionQueue && _interactionQueue != hero()->getMessageQueue()) {
+ _interactionQueue->interrupt(false);
+ _interactionQueue = nullptr;
+ _interactObjectId = 0;
+ }
+ }
+}
+
+// A queue that goes away: the controller does not keep it
+void FPController::forgetQueue(MessageQueue *queue) {
+ if (_walkQueue == queue)
+ _walkQueue = nullptr;
+ if (_interactionQueue == queue)
+ _interactionQueue = nullptr;
+}
+
// CFPController::CheckTry
bool FPController::checkTry() const {
return !g_ngi->_currSelectedInventoryItemId && hero() && g_ngi->_aniHandler->isObjectAttached(hero()->_id) && canInterruptManQueue();
@@ -588,6 +622,24 @@ MessageQueue *FPController::mctlStartMove(int x, int y, bool fuzzy, int staticsI
checkQueues();
MotionController *controller = _scene->_motionController.get();
if (controller && (fuzzy || controller->_isEnabled) && canInterruptManQueue()) {
+ if (g_ngi->_gameVersion >= 201509) {
+ // MakeQueue (slot 72), the hero's queue stops, the walk runs with the hero as owner (state 0)
+ MessageQueue *queue = controller->makeQueue(hero(), x, y, fuzzy, staticsId, mirror);
+ if (queue) {
+ if (queue->getCount()) {
+ interruptManQueue();
+ _scene->runQueueObject(queue, hero(), 0);
+ _walkQueue = queue;
+ _lastTargetX = x;
+ _lastTargetY = y;
+ return queue;
+ }
+ delete queue;
+ }
+ _failedTargetX = x;
+ _failedTargetY = y;
+ return nullptr;
+ }
MessageQueue *queue = controller->startMove(hero(), x, y, fuzzy, staticsId, mirror);
if (queue) {
_lastTargetX = x;
@@ -846,6 +898,20 @@ void FPController::onMessage(const Common::String &message, const Common::String
warning("STUB/untested: CBaseSettings::SetSaving (the saves are not blocked while the lift moves)");
}
} else if (message == "MSG_RESETDEST") {
+ // the hero's walk queue was interrupted: forget it, the following interaction queue stops
+ if (g_ngi->_gameVersion >= 201509 && queue && queue == _walkQueue) {
+ if (queue == hero()->getMessageQueue())
+ hero()->setQueue(nullptr);
+ MessageQueue *interactionQueue = _interactionQueue;
+ _walkQueue = nullptr;
+ _lastTargetX = 0;
+ _lastTargetY = 0;
+ if (interactionQueue && interactionQueue->_curIndex != -1) {
+ interactionQueue->interrupt(false);
+ _interactionQueue = nullptr;
+ _interactObjectId = 0;
+ }
+ }
g_ngi->lift().onResetDest(queue);
} else if (message == "INVENTORY_ITEM_IN_CURSOR") {
onItemInCursor(param);
diff --git a/engines/ngi/fullpipe/fpcontroller.h b/engines/ngi/fullpipe/fpcontroller.h
index f65b6d82570..8c488117871 100644
--- a/engines/ngi/fullpipe/fpcontroller.h
+++ b/engines/ngi/fullpipe/fpcontroller.h
@@ -128,6 +128,9 @@ public:
void initBorders();
/** CFPController::MctlStartMove */
MessageQueue *mctlStartMove(int x, int y, bool fuzzy, int staticsId, bool mirror);
+ /** CFPController::InterruptManQueue (148DFE) */
+ void interruptManQueue();
+ void forgetQueue(MessageQueue *queue) override;
/** The camera fields that a scene controller changes (CSc04Controller::UpdateScroll ...) */
@@ -165,6 +168,9 @@ protected:
float _lastTargetY = 0; // +76
float _failedTargetX = 0; // +80: where the hero could not be sent
float _failedTargetY = 0; // +84
+ /** +20: walk queue, +24: interaction queue; the hero holds one (_gameVersion >= 201509) */
+ MessageQueue *_walkQueue = nullptr;
+ MessageQueue *_interactionQueue = nullptr;
int _interactObjectId = 0; // +88: the object of the interaction under the cursor
bool _hasLeftBorder = false; // +120: swipe target points of the borders (key -1 left, 1 right)
bool _hasRightBorder = false;
diff --git a/engines/ngi/fullpipe/sc01controller.cpp b/engines/ngi/fullpipe/sc01controller.cpp
index 0f4ee76657a..3f1686f6d9a 100644
--- a/engines/ngi/fullpipe/sc01controller.cpp
+++ b/engines/ngi/fullpipe/sc01controller.cpp
@@ -147,11 +147,7 @@ bool Sc01Controller::isInventoryEnabled() {
}
bool Sc01Controller::isEntranceQueueRunning() const {
- for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList) {
- if (queue->_queueId == QU_SC1_ENTER && !queue->_isFinished)
- return true;
- }
- return false;
+ return _scene->isQueueRunning(QU_SC1_ENTER);
}
// CSc01Controller::CheckTutorial (1625D8): FIRST, MOVE_MAN, SEE_TASK, USE_TRANSITION in turn
diff --git a/engines/ngi/fullpipe/sc04controller.cpp b/engines/ngi/fullpipe/sc04controller.cpp
index 57a4f05d67a..87147a2d759 100644
--- a/engines/ngi/fullpipe/sc04controller.cpp
+++ b/engines/ngi/fullpipe/sc04controller.cpp
@@ -100,25 +100,6 @@ int objectsAmount(Scene *scene, int objectId) {
return amount;
}
-// CMessageQueue::Stop of the running copies of a queue of the scene (the queues of the scene are templates here)
-void stopQueueCopies(int queueId) {
- GlobalMessageQueueList &queues = *g_ngi->_globalMessageQueueList;
- for (uint i = 0; i < queues.size(); i++) {
- if (queues[i]->_queueId == queueId)
- queues.disableQueueById(queues[i]->_id);
- }
-}
-
-// the queue of the scene has been started (CMessageQueue +56, the number of the current command, is not -1 any more)
-bool isQueueStarted(int queueId) {
- const GlobalMessageQueueList &queues = *g_ngi->_globalMessageQueueList;
- for (uint i = 0; i < queues.size(); i++) {
- if (queues[i]->_queueId == queueId)
- return true;
- }
- return false;
-}
-
// CAniObject::GetMovement(id)->+96 = delay: the frame delay of the movement
void setLoopDelay(AniObject *ani, int movementId, uint32 delay) {
Movement *movement = ani ? ani->getMovement(movementId) : nullptr;
@@ -566,7 +547,7 @@ void Sc04Controller::doStopArcade() {
void Sc04Controller::skipArcadeController() {
g_ngi->arcadeInterface().scrollOut();
_clock->setStatic(ST_CLK_CLOSED);
- stopQueueCopies(QU_SC4_GOCLOCK);
+ _scene->stopQueue(QU_SC4_GOCLOCK);
onMessage("MSG_STOP_MUS", "", nullptr);
g_ngi->_taskManager->deactivateTask("FIND_EXIT_BOTLE_SC4");
getGameLoaderInteractionController()->setActive("INT_019", SC_4, PIC_SC4_MASK, 0.0f, 0.0f);
@@ -703,7 +684,7 @@ void Sc04Controller::doStartHand() {
// analytics lose_count_ANI_KOZAWKA, game_ANI_KOZAWKA_lose: not ported
} else {
_clock->setStatic(ST_CLK_CLOSED);
- stopQueueCopies(QU_SC4_GOCLOCK);
+ _scene->stopQueue(QU_SC4_GOCLOCK);
onMessage("MSG_STOP_MUS", "", nullptr);
g_ngi->_taskManager->deactivateTask("FIND_EXIT_BOTLE_SC4");
g_ngi->_achievementsManager->addActivatingCounter("ACHIEVEMENT_ARCADE_4", 100, "UNDEF");
@@ -1385,7 +1366,7 @@ void Sc04Controller::onHide() {
// analytics lose_count_ANI_KOZAWKA, game_ANI_KOZAWKA_lose: not ported
if (_clockCanGo && _arcade)
activateTasks();
- if (isQueueStarted(QU_HND_TAKEBOTTLE) && !isState(sO_Jar_4, sO_UpsideDown)) {
+ if (_scene->isQueueStarted(QU_HND_TAKEBOTTLE) && !isState(sO_Jar_4, sO_UpsideDown)) {
activateTasks();
g_ngi->_exitManager->setExitState(PIC_SC4_DOWNTRUBA, 0);
}
diff --git a/engines/ngi/fullpipe/sc29controller.cpp b/engines/ngi/fullpipe/sc29controller.cpp
index c8f51128195..bfc2c374e3b 100644
--- a/engines/ngi/fullpipe/sc29controller.cpp
+++ b/engines/ngi/fullpipe/sc29controller.cpp
@@ -50,13 +50,9 @@ namespace NGI {
namespace {
-// CMessageQueue +56 (the number of the command that runs) is not -1: the queue is running, i.e. it is still in the global list
-bool isQueueRunning(MessageQueue *queue) {
- for (uint i = 0; i < g_ngi->_globalMessageQueueList->size(); i++) {
- if ((*g_ngi->_globalMessageQueueList)[i] == queue)
- return true;
- }
- return false;
+// CMessageQueue +56 (running command index) is not -1: the queue is running
+bool isQueueRunning(Scene *scene, MessageQueue *queue) {
+ return scene->ownsQueue(queue) && queue->_curIndex != -1;
}
} // End of anonymous namespace
@@ -796,7 +792,7 @@ void Sc29Controller::onUpdate(uint32 elapsed) {
FPController::onUpdate(elapsed);
// with a dialog over the scene and the hit queue running, the hero gives the position
if (g_ngi->_sceneStack.size() > 1) {
- if (_hitQueue && isQueueRunning(_hitQueue)) {
+ if (_hitQueue && isQueueRunning(_scene, _hitQueue)) {
const Common::Point center = hero()->getCenter();
_manX = center.x;
_manY = center.y;
diff --git a/engines/ngi/fullpipe/scene09.cpp b/engines/ngi/fullpipe/scene09.cpp
index 48b57f56f68..176d9841409 100644
--- a/engines/ngi/fullpipe/scene09.cpp
+++ b/engines/ngi/fullpipe/scene09.cpp
@@ -188,7 +188,7 @@ void sceneHandler09_spitterClick() {
PicAniInfo info;
g_vars->scene09_spitter->getPicAniInfo(info);
- g_vars->scene09_spitter->_messageQueueId = 0;
+ g_vars->scene09_spitter->resetQueue();
g_vars->scene09_spitter->setStatic(ST_PLV_SIT);
int x = g_vars->scene09_spitter->_x - 10;
diff --git a/engines/ngi/fullpipe/scene25.cpp b/engines/ngi/fullpipe/scene25.cpp
index 7682b052fec..73107886fab 100644
--- a/engines/ngi/fullpipe/scene25.cpp
+++ b/engines/ngi/fullpipe/scene25.cpp
@@ -164,7 +164,7 @@ void sceneHandler25_enterTruba() {
PicAniInfo info;
g_ngi->_aniMan->getPicAniInfo(info);
- g_ngi->_aniMan->_messageQueueId = 0;
+ g_ngi->_aniMan->resetQueue();
g_ngi->_aniMan->setStatic(g_ngi->_aniMan->_statics->_staticsId);
int x = g_ngi->_aniMan->_x;
@@ -199,7 +199,7 @@ void sceneHandler25_toLadder() {
PicAniInfo info;
g_ngi->_aniMan->getPicAniInfo(info);
- g_ngi->_aniMan->_messageQueueId = 0;
+ g_ngi->_aniMan->resetQueue();
g_ngi->_aniMan->setStatic(g_ngi->_aniMan->_statics->_staticsId);
int x = g_ngi->_aniMan->_x;
@@ -278,7 +278,7 @@ void sceneHandler25_rowShovel() {
PicAniInfo info;
g_ngi->_aniMan->getPicAniInfo(info);
- g_ngi->_aniMan->_messageQueueId = 0;
+ g_ngi->_aniMan->resetQueue();
g_ngi->_aniMan->setStatic(g_ngi->_aniMan->_statics->_staticsId);
int x = g_ngi->_aniMan->_x;
@@ -312,7 +312,7 @@ void sceneHandler25_rowHand() {
PicAniInfo info;
g_ngi->_aniMan->getPicAniInfo(info);
- g_ngi->_aniMan->_messageQueueId = 0;
+ g_ngi->_aniMan->resetQueue();
g_ngi->_aniMan->setStatic(g_ngi->_aniMan->_statics->_staticsId);
int x = g_ngi->_aniMan->_x;
@@ -366,7 +366,7 @@ void sceneHandler25_tryRow(int obj) {
PicAniInfo info;
g_ngi->_aniMan->getPicAniInfo(info);
- g_ngi->_aniMan->_messageQueueId = 0;
+ g_ngi->_aniMan->resetQueue();
g_ngi->_aniMan->setStatic(ST_MAN_RIGHT | 0x4000);
int x = g_ngi->_aniMan->_x;
diff --git a/engines/ngi/fullpipe/sceneIntro.cpp b/engines/ngi/fullpipe/sceneIntro.cpp
index b0116fb535c..a4f995a9f1a 100644
--- a/engines/ngi/fullpipe/sceneIntro.cpp
+++ b/engines/ngi/fullpipe/sceneIntro.cpp
@@ -45,6 +45,8 @@ static void sceneIntro_onGuiEvent(Scene &scene, const Common::String &id, const
button->hideAndDeactivate();
}
clearGlobalMessageQueueList1();
+ for (int sceneId : {SC_INTRO1, SC_INTRO2})
+ g_ngi->findScene(sceneId)->stopAllQueues();
if (scene._soundList)
scene.stopAllSounds();
g_ngi->stopAllSounds(Sound::kSpeech);
diff --git a/engines/ngi/fullpipe/tutorialcontroller.cpp b/engines/ngi/fullpipe/tutorialcontroller.cpp
index 4c43bafbd72..14b74384ee3 100644
--- a/engines/ngi/fullpipe/tutorialcontroller.cpp
+++ b/engines/ngi/fullpipe/tutorialcontroller.cpp
@@ -71,15 +71,6 @@ Scene *sceneBelow() {
return g_ngi->getSceneInStack(g_ngi->_sceneStack.size() - 2);
}
-// The CMessageQueue::Run of a queue of the scene: a copy runs (D03)
-bool queueIsRunning(int queueId) {
- for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList) {
- if (queue->_queueId == queueId && !queue->_isFinished)
- return true;
- }
- return false;
-}
-
} // End of anonymous namespace
// CTutorialController::CTutorialController
@@ -311,7 +302,7 @@ void TutorialController::finish() {
unloadLayout();
Tutorial *tutorial = g_ngi->_tutorialManager->findActiveTutorial();
const int queueId = tutorial && tutorial->_isMirror ? QU_SC_TUTORIAL_BEARDED_RISE_MIRROR : QU_SC_TUTORIAL_BEARDED_RISE;
- if (!queueIsRunning(queueId)) {
+ if (!_scene->isQueueRunning(queueId)) {
Movement *fall = _man->getMovement(MOV_SC_TUTORIAL_BEARDED_FALL);
fall->_loopDelay = 60;
fall->_phases[0]->_delayMs = 0;
Commit: 18434a20dfa80d26fd4a065510a8c2e2387d7226
https://github.com/scummvm/scummvm/commit/18434a20dfa80d26fd4a065510a8c2e2387d7226
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Test mode: the INFO log follows the new queues
Changed paths:
engines/ngi/debugger/testmode.cpp
diff --git a/engines/ngi/debugger/testmode.cpp b/engines/ngi/debugger/testmode.cpp
index 8be3efb858c..1b7bced6997 100644
--- a/engines/ngi/debugger/testmode.cpp
+++ b/engines/ngi/debugger/testmode.cpp
@@ -179,9 +179,21 @@ void testmode_getInfo(TestInfo &info) {
info.mouse = g_ngi->_mouseScreenPos;
info.mouseInScene = info.mouse + info.camera;
- for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList) {
- if (!queue->_isFinished)
- info.queues.push_back(name(queue->_queueId));
+ if (g_ngi->_gameVersion >= 201509) {
+ // the queues belong to the scene: the ones that run (the made ones have no name)
+ for (const MessageQueue *queue : scene->_messageQueues) {
+ if (queue->_state != 0)
+ info.queues.push_back(name(queue->_queueId));
+ }
+ for (const MessageQueue *queue : scene->_madeQueues) {
+ if (queue->_state != 0)
+ info.queues.push_back(name(queue->_queueId));
+ }
+ } else {
+ for (const MessageQueue *queue : *g_ngi->_globalMessageQueueList) {
+ if (!queue->_isFinished)
+ info.queues.push_back(name(queue->_queueId));
+ }
}
AniObject *hero = g_ngi->_aniMan;
@@ -191,7 +203,7 @@ void testmode_getInfo(TestInfo &info) {
info.heroPos = Common::Point(hero->_x, hero->_y);
info.heroZ = hero->_z;
info.heroFlags = hero->_flags;
- info.heroQueue = hero->_messageQueueId;
+ info.heroQueue = hero->_queue ? hero->_queue->_id : hero->_messageQueueId;
info.heroMirror = (hero->_flags & 8) != 0;
if (hero->_movement) {
const Movement *movement = hero->_movement;
@@ -248,7 +260,7 @@ void testmode_update(uint32 elapsed) {
return;
// Dude has to stand after the entrance queue
- g_idleFrames = hero->_movement || hero->_messageQueueId ? 0 : g_idleFrames + 1;
+ g_idleFrames = hero->_movement || hero->_messageQueueId || hero->_queue ? 0 : g_idleFrames + 1;
if (g_idleFrames < 10)
return;
Commit: 73282a6a8f36dba96f2a77e940a7368eee90acab
https://github.com/scummvm/scummvm/commit/73282a6a8f36dba96f2a77e940a7368eee90acab
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: MSG_SC3_MOVEEGGEATER puts the egg eater at the position of the XML, not behind the box
Changed paths:
engines/ngi/fullpipe/sc03controller.cpp
diff --git a/engines/ngi/fullpipe/sc03controller.cpp b/engines/ngi/fullpipe/sc03controller.cpp
index 0395ed733f3..580f5f64a8a 100644
--- a/engines/ngi/fullpipe/sc03controller.cpp
+++ b/engines/ngi/fullpipe/sc03controller.cpp
@@ -321,8 +321,9 @@ void Sc03Controller::onMessage(const Common::String &message, const Common::Stri
onInvDrop(param);
FPController::onMessage(message, param, queue);
} else if (message == "MSG_SC3_MOVEEGGEATER") {
- // CVisibleObject::SetPos(vector3) (vtable slot 20): the position is the top left of the picture, as in the XML
- _eggeater->setPosition(Common::Point(609, 424));
+ // CVisibleObject::SetPos (vtable slot 20): the position sc_3.xml gives the egg eater (609, 425),
+ // not the picture corner (setPosition put him 70 px right and 86 down)
+ _eggeater->setPos(609, 424);
_eggeater->_z = 60;
} else if (message == "MSG_SC4_HIDEBOOT") {
_boot->_flags &= ~4;
Commit: 33b622ab42d03383332438931932b27bb081200c
https://github.com/scummvm/scummvm/commit/33b622ab42d03383332438931932b27bb081200c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Port CInteract and CInteractionController of Android
Changed paths:
engines/ngi/interaction.cpp
engines/ngi/interaction.h
engines/ngi/objects.h
diff --git a/engines/ngi/interaction.cpp b/engines/ngi/interaction.cpp
index 243831ab838..ef8b67dce9d 100644
--- a/engines/ngi/interaction.cpp
+++ b/engines/ngi/interaction.cpp
@@ -23,6 +23,8 @@
#include "ngi/input.h"
#include "ngi/interaction.h"
+#include "ngi/messages.h"
+#include "ngi/scene.h"
#include "ngi/inventory.h"
#include "ngi/gameloader.h"
#include "ngi/statics.h"
@@ -65,6 +67,52 @@ InteractionController::~InteractionController() {
removeMessageHandler(124, -1);
}
+// CInteractionController::AddInteract(CInteract *) (107988)
+void InteractionController::addInteract(Interact *interaction) {
+ _interactions.push_back(interaction);
+ if (g_ngi->_gameVersion < 201509)
+ return;
+
+ uint sceneIndex = 0;
+ while (sceneIndex < _scenes.size() && (uint)_scenes[sceneIndex]._sceneId < (uint)interaction->getSceneId())
+ sceneIndex++;
+ if (sceneIndex == _scenes.size() || _scenes[sceneIndex]._sceneId != interaction->getSceneId()) {
+ SceneInteractions entry;
+ entry._sceneId = interaction->getSceneId();
+ _scenes.insert_at(sceneIndex, entry);
+ }
+ Common::Array<ObjectInteractions> &objects = _scenes[sceneIndex]._objects;
+ const int key = interaction->getObjectId();
+ uint objectIndex = 0;
+ while (objectIndex < objects.size() && (uint)objects[objectIndex]._key < (uint)key)
+ objectIndex++;
+ if (objectIndex == objects.size() || objects[objectIndex]._key != key) {
+ ObjectInteractions entry;
+ entry._key = key;
+ objects.insert_at(objectIndex, entry);
+ }
+ objects[objectIndex]._interacts.push_back(interaction);
+}
+
+SceneInteractions *InteractionController::findSceneInteractions(int sceneId) {
+ for (uint i = 0; i < _scenes.size(); i++) {
+ if (_scenes[i]._sceneId == sceneId)
+ return &_scenes[i];
+ }
+ return nullptr;
+}
+
+ObjectInteractions *InteractionController::findObjectInteractions(int sceneId, int objectKey) {
+ SceneInteractions *scene = findSceneInteractions(sceneId);
+ if (!scene)
+ return nullptr;
+ for (uint i = 0; i < scene->_objects.size(); i++) {
+ if (scene->_objects[i]._key == objectKey)
+ return &scene->_objects[i];
+ }
+ return nullptr;
+}
+
bool InteractionController::load(MfcArchive &file) {
debugC(5, kDebugLoading, "InteractionController::load()");
@@ -114,66 +162,14 @@ void InteractionController::sortInteractions(int sceneId) {
}
bool InteractionController::handleInteraction(AniObject *subj, GameObject *obj, int invId) {
- if (g_ngi->usesXMLProject()) {
- // the subject is busy while its queue runs (the Android build has its pointer, the Windows engine an id)
- const bool busy = subj && (g_ngi->_gameVersion >= 201509 ? !subj->isIdle() : subj->_messageQueueId != 0);
- if (!_enabled || !subj || !obj || busy) {
- debugC(1, kDebugInfo, "INFO t %u INTERACTION refused: enabled %d subject %p object %p subject queue %d", g_system->getMillis(), _enabled, (void *)subj, (void *)obj,
- !subj ? -1 : (subj->_queue ? subj->_queue->_id : subj->_messageQueueId));
- return false;
- }
- Interact *action = nullptr;
- for (Interact *candidate : _interactions) {
- if (candidate->canRun(subj, obj, invId) && (!action || candidate->_weight > action->_weight))
- action = candidate;
- }
- if (!action) {
- // --debugflags=info: why nothing can run (the statics of an animation has to be the one that the interaction wants)
- const AniObject *ani = obj->_objtype == kObjTypeStaticANIObject ? static_cast<const AniObject *>(obj) : nullptr;
- debugC(1, kDebugInfo, "INFO t %u INTERACTION refused: object %d item %d, its statics %d%s", g_system->getMillis(), obj->_id, invId, ani && ani->_statics ? ani->_statics->_staticsId : -1,
- ani && ani->_movement ? " (a movement runs)" : "");
- for (const Interact *candidate : _interactions) {
- if (candidate->_objectId == obj->_id)
- debugC(1, kDebugInfo, "INFO candidate: item %d statics %d flags %x activity %f scene %d", candidate->_cursorObjectId, candidate->_objectStaticId, candidate->_flags, candidate->_activity, candidate->_sceneId);
- }
+ if (g_ngi->_gameVersion >= 201509) {
+ // original: FindInteraction(objects) in the stacked scene, then TryStartInteract (GO_MCTL walk)
+ if (!obj)
return false;
- }
- Common::ScopedPtr<MessageQueue> queue;
- if (action->_heroId) {
- int x = obj->_x + action->_heroOffsetX;
- int y = obj->_y + action->_heroOffsetY;
- if (obj->_objtype == kObjTypeStaticANIObject) {
- const AniObject *actor = static_cast<AniObject *>(obj);
- const Dims size = actor->getFullSize();
- const Common::Point anchor = actor->getSomeXY();
- x += (actor->_flags & 8 ? -1 : 1) * (size.x / 2 - anchor.x);
- y += size.y / 2 - anchor.y;
- }
- if (x != subj->_x || y != subj->_y) {
- // CFPController::ExecCmdMctl (the GO_MCTL command of the interaction) walks with the fuzzy flag set: the point has to be on the
- // graph (within 3 pixels of a link) and Dude arrives exactly there, the last walk is stretched to it
- MotionController *controller = getCurrSceneSc2MotionController();
- queue.reset(controller->makeQueue(subj, x, y, 1, action->_heroStaticId, action->_heroMirror));
- if (!queue)
- queue.reset(controller->makeQueue(subj, x, y, 0, action->_heroStaticId, action->_heroMirror));
- if (!queue)
- return false;
- }
- }
- if (!queue)
- queue.reset(new MessageQueue(0));
- if (action->_heroId) {
- Command *mirror = new Command(subj->_id, kCmdSetFlags, action->_heroMirror ? 8 : 0, 0, 0, 0, 1, 0, 0, 0);
- mirror->_z = 8;
- mirror->_excFlags = 3;
- queue->addCommandToEnd(mirror);
- }
- for (uint i = 0; i < action->_messageQueue->getCount(); ++i)
- queue->addCommandToEnd(action->_messageQueue->getCommandByIndex(i)->createClone());
- if (!queue->run(action->_heroId ? subj : nullptr))
- return false;
- queue.release();
- return true;
+ Common::Array<GameObject *> objects;
+ objects.push_back(obj);
+ Interact *interact = findInteraction(objects);
+ return interact && tryStartInteract(g_ngi->getSceneInStack(0), interact);
}
if (subj) {
if (!subj->isIdle() || (subj->_flags & 0x100))
@@ -511,6 +507,10 @@ Interact::Interact() {
}
Interact::~Interact() {
+ // the queue of an Android interaction belongs to its scene (CScene::AddInteractionQueue)
+ if (g_ngi->_gameVersion >= 201509)
+ return;
+
if (_messageQueue) {
while (_messageQueue->getCommandByIndex(0))
_messageQueue->removeCommand(0, 1);
@@ -630,12 +630,18 @@ bool Entrance::load(MfcArchive &file) {
}
GameObject *Interact::getObject() const {
- Scene *scene = g_ngi->findScene(_sceneId);
+ // findScene would load a scene that is not loaded
+ Scene *scene = g_ngi->findLoadedScene(_sceneId);
if (!scene)
return nullptr;
- if (GameObject *picture = scene->findPictureObjectById(_objectId, 0))
- return picture;
- return scene->findAniObjectById(_objectId, 0);
+ return scene->findVisibleObject(_objectId, _copy);
+}
+
+AniObject *Interact::getHero() const {
+ if (!_heroId)
+ return nullptr;
+ Scene *scene = g_ngi->findLoadedScene(_heroSceneId ? _heroSceneId : _sceneId);
+ return scene ? scene->findAniObjectById(_heroId, 0) : nullptr;
}
bool Interact::canBeRunNow(bool checkItem) const {
@@ -707,4 +713,450 @@ bool InteractionController::setActive(const Common::String &name, int sceneId, i
return false;
}
+// CInteract::CanRun (105E48)
+bool Interact::canRun() {
+ if (_activity < 0.9999f)
+ return false;
+
+ GameObject *object = getObject();
+ if (!object)
+ return false;
+ if (!(object->_flags & 4)) // CVisibleObject +8, bit 1: the object is shown
+ return false;
+
+ // an object busy with a queue that is not in interrupt state 3 takes no interaction
+ AniObject *ani = object->_objtype == kObjTypeStaticANIObject ? static_cast<AniObject *>(object) : nullptr;
+ if (ani && ani->_queue && ani->_queue->_interruptState != 3)
+ return false;
+
+ const bool incorrectItem = _actionName == "INT_INCORRECT_ITEM";
+ CursorController *cursor = g_ngi->_inputController;
+ if (!incorrectItem || !cursor->getObject()) {
+ if (_cursorObjectId != -2) { // ANY_OBJECT (0xFFFF)
+ if (_cursorObjectId != cursor->getObjectId() || incorrectItem)
+ return false;
+ }
+ }
+
+ if (!_objectStaticId)
+ return true;
+ if (!ani)
+ return false; // the original reads garbage there
+ if (_flags & 1)
+ return _objectStaticId == ani->getStaticsId();
+
+ int currentStatics = ani->getStaticsId();
+ if (_objectStaticId == currentStatics)
+ return true;
+ // a movement that runs ends in its next statics
+ if (ani->_movement)
+ currentStatics = ani->_movement->_nextStatic->_staticsId;
+ return ani->isExistLinkedMovements(currentStatics, _objectStaticId);
+}
+
+// CInteract::GetHeroPos (105A9E)
+Common::Point Interact::getHeroPos() {
+ AniObject *hero = getHero();
+ if (!_heroId || !hero)
+ return Common::Point(0, 0);
+
+ hero->stopMovement();
+ const Common::Point heroCenter = hero->getCenter();
+ const int heroStatics = hero->getStaticsId();
+ const bool heroMirror = (hero->_flags & 8) != 0;
+
+ GameObject *object = getObject();
+ Common::Point base;
+ if (object && object->_objtype == kObjTypeStaticANIObject) {
+ // the object goes into the statics of the interaction to take its center, then back
+ AniObject *ani = static_cast<AniObject *>(object);
+ ani->stopMovement();
+ const int oldStatics = ani->getStaticsId();
+ const bool oldMirror = (ani->_flags & 8) != 0;
+ const Common::Point oldCenter = ani->getCenter();
+ if (_objectStaticId && oldStatics != _objectStaticId)
+ ani->moveToStaticChain(_objectStaticId);
+ base = ani->getCenter();
+ ani->setStatic(oldStatics, oldMirror);
+ ani->setCenter(oldCenter);
+ } else if (object) {
+ base = object->getPosition();
+ }
+
+ hero->setStatic(_heroStaticId ? _heroStaticId : hero->getStaticsId(), _heroMirror);
+ // DEVIATION D39: the decompile uses SetPos and GetCenter (half a hero too far); the data say the
+ // point is the hero's center (scripts/ngi_interact_target_check.py), so SetCenter
+ hero->setCenter(Common::Point(base.x + _heroOffsetX, base.y + _heroOffsetY));
+ const Common::Point result = hero->getCenter();
+ debugC(2, kDebugInfo, "INFO t %u GetHeroPos %s: the object %d at %d,%d (statics %d), the hero at %d,%d size %d,%d, offset %d,%d, hero center %d,%d", g_system->getMillis(),
+ _actionName.c_str(), _objectId, base.x, base.y, _objectStaticId, hero->getPosition().x, hero->getPosition().y, hero->getSize().x, hero->getSize().y, _heroOffsetX, _heroOffsetY,
+ result.x, result.y);
+ hero->setStatic(heroStatics, heroMirror);
+ hero->setCenter(heroCenter);
+ return result;
+}
+
+static Command *interactMessage(const char *message, const Common::String ¶m) {
+ Command *command = new Command(0, kCmdMessage, 0, 0, 0, 0, 0, 0, 0, 0);
+ command->_messageName = message;
+ command->_args["msg"] = message;
+ command->_args["param"] = param;
+ command->_excFlags = 2;
+ return command;
+}
+
+// CInteract::Run (106468)
+void Interact::run(Scene *scene) {
+ if (_running)
+ return;
+
+ scene->message("INTERACT_PRESTART", _actionName, _messageQueue);
+
+ GameObject *object = getObject();
+ AniObject *ani = object && object->_objtype == kObjTypeStaticANIObject ? static_cast<AniObject *>(object) : nullptr;
+ // the object must be in the interaction's statics (flag 1: already), else movements lead there
+ if (_objectStaticId != 0 && !(_flags & 1) && ani) {
+ Command *restart = nullptr;
+ int fromStatics;
+ if (ani->_movement) {
+ // a running movement is stopped and restarted at its frame as the first command
+ const int curFrame = ani->getCurFrame();
+ Movement *movement = ani->_movement;
+ debugC(1, kDebugInfo, "INFO t %u INTERACTION %s: the movement %d of %d runs (frame %d of %d) at %d,%d, center %d,%d", g_system->getMillis(), _actionName.c_str(), movement->_id, ani->_id,
+ curFrame, (int)movement->_phases.size(), ani->_x, ani->_y, ani->getCenter().x, ani->getCenter().y);
+ fromStatics = movement->_nextStatic->_staticsId;
+ const bool mirror = (ani->_flags & 8) != 0;
+ if (movement->_reverse)
+ warning("STUB/untested: CInteract::Run: a movement that plays backwards is stopped by the engine's StopMovementToPrev (the reverse flag of the original is not toggled)");
+ ani->stopMovementToPrev(false, true);
+ restart = new Command(ani->_id, kCmdStartMovement, movement->_id, 0, 0, 0, 1, 0, 0, 0);
+ restart->_param = ani->_copyId;
+ restart->_mirror = mirror;
+ restart->_args["startFrame"] = Common::String::format("%d", curFrame);
+ restart->_excFlags = 2;
+ } else {
+ fromStatics = ani->getStaticsId();
+ }
+
+ MessageQueue *linked = ani->getLinkedMovements(fromStatics, _objectStaticId);
+ debugC(1, kDebugInfo, "INFO t %u INTERACTION %s runs: the object %d stands at %d,%d (center %d,%d) in the statics %d, wants %d, restart %d, %d linked movements", g_system->getMillis(),
+ _actionName.c_str(), ani->_id, ani->_x, ani->_y, ani->getCenter().x, ani->getCenter().y, ani->getStaticsId(), _objectStaticId, restart != nullptr, (int)linked->getCount());
+ if (linked->getCount() != 0 || restart) {
+ MessageQueue *queue = scene->addInteractionQueue(linked, this);
+ if (restart)
+ queue->addCommand(0, restart);
+ queue->addCommandToEnd(interactMessage("INTERACT_STARTED", _actionName));
+ for (uint i = 0; i < _messageQueue->getCount(); i++)
+ queue->addCommandToEnd(_messageQueue->getCommandByIndex(i)->createClone());
+ ani->setQueue(queue);
+ if (_heroId) {
+ if (AniObject *hero = getHero())
+ hero->setQueue(queue);
+ queue->run(2);
+ } else {
+ queue->run(3);
+ _running = true;
+ }
+ delete linked;
+ return;
+ }
+ delete linked;
+ }
+
+ scene->message("INTERACT_STARTED", _actionName, _messageQueue);
+ object = getObject();
+ if (object && object->_objtype == kObjTypeStaticANIObject) {
+ ani = static_cast<AniObject *>(object);
+ if (ani->_movement)
+ ani->stopMovement();
+ ani->setQueue(_messageQueue);
+ }
+ if (_heroId) {
+ if (AniObject *hero = getHero())
+ hero->setQueue(_messageQueue);
+ } else {
+ _running = true;
+ }
+ _messageQueue->run(4);
+}
+
+// CInteract::Stop (105A5A)
+void Interact::stop() {
+ _messageQueue->stop(false);
+ _running = false;
+}
+
+// CInteract::Init (105A4C)
+void Interact::init() {
+ _weight = _weightOriginal;
+ _activity = _activityOriginal;
+ _importance = _importanceOriginal;
+}
+
+// CInteract::OnUpdate (105D00)
+bool Interact::onUpdate(uint elapsed) {
+ const bool runnable = canBeRunNow(true);
+ if (runnable)
+ _runnableTime += elapsed;
+ else if (_messageQueue->_state == 0)
+ _runnableTime = 0;
+ return runnable;
+}
+
+// CInteractionController::FindInteraction(scene, object key, a4) (106AE8)
+Interact *InteractionController::findInteraction(Scene *scene, int objectKey, int a4) {
+ ObjectInteractions *entry = findObjectInteractions(scene->_sceneId, objectKey);
+ if (!entry)
+ return nullptr;
+ if (entry->_interacts.size() == 1)
+ return entry->_interacts[0]->_activity >= 0.9999f ? entry->_interacts[0] : nullptr;
+
+ CursorController *cursor = g_ngi->_inputController;
+ Interact *best = nullptr;
+ for (Interact *candidate : entry->_interacts) {
+ if (candidate->_weight == 0 || candidate->_activity < 0.9999f || (best && best->_weight >= candidate->_weight))
+ continue;
+ const bool incorrectItem = candidate->_actionName == "INT_INCORRECT_ITEM";
+ // the wrong-item interaction takes any item; the others need the item (unless a4 = -1)
+ if ((incorrectItem && cursor->getObject()) || ((candidate->_cursorObjectId == cursor->getObjectId() || a4 != -1) && !incorrectItem)) {
+ GameObject *object = candidate->getObject();
+ const int staticsId = object && object->_objtype == kObjTypeStaticANIObject ? static_cast<AniObject *>(object)->getStaticsId() : 0;
+ if (candidate->_objectStaticId == 0 || candidate->_objectStaticId == staticsId)
+ best = candidate;
+ }
+ }
+ return best;
+}
+
+// CInteractionController::FindInteractionQueue (106C30)
+MessageQueue *InteractionController::findInteractionQueue(Scene *scene, int objectKey) {
+ Interact *interact = findInteraction(scene, objectKey, -1);
+ return interact ? interact->_messageQueue : nullptr;
+}
+
+// CInteractionController::IsAnyInteraction (106C48)
+bool InteractionController::isAnyInteraction(Scene *scene, int objectKey) {
+ ObjectInteractions *entry = findObjectInteractions(scene->_sceneId, objectKey);
+ if (!entry)
+ return false;
+ if (entry->_interacts.size() == 1)
+ return entry->_interacts[0]->_activity >= 0.9999f;
+ for (Interact *interact : entry->_interacts) {
+ if (interact->_weight != 0 && interact->_activity >= 0.9999f)
+ return true;
+ }
+ return false;
+}
+
+// CInteractionController::FindInteraction(objects) (106CD0)
+Interact *InteractionController::findInteraction(const Common::Array<GameObject *> &objects) {
+ Scene *scene = g_ngi->getSceneInStack(0);
+ if (!scene || !findSceneInteractions(scene->_sceneId))
+ return nullptr;
+
+ for (GameObject *object : objects) {
+ if (!(object->_flags & 4))
+ continue;
+ ObjectInteractions *entry = findObjectInteractions(scene->_sceneId, (uint16)object->_id | (object->_copyId << 16));
+ if (!entry) {
+ // an object without interaction that takes the touch ends the search, flag 8 does not
+ if (!(object->_objectFlags & 8))
+ return nullptr;
+ continue;
+ }
+ Interact *best = nullptr;
+ if (entry->_interacts.size() == 1 && entry->_interacts[0]->canRun())
+ best = entry->_interacts[0];
+ for (Interact *candidate : entry->_interacts) {
+ if (candidate->_weight != 0 && candidate->canRun() && (!best || best->_weight < candidate->_weight))
+ best = candidate;
+ }
+ if (best)
+ return best;
+ }
+ return nullptr;
+}
+
+// CInteractionController::FindInteraction(x, y) (1072AC)
+Interact *InteractionController::findInteraction(float x, float y) {
+ Scene *scene = g_ngi->getSceneInStack(0);
+ if (!scene)
+ return nullptr;
+ Common::Array<GameObject *> objects;
+ scene->getVisObjsVHitInteract(objects, x, y);
+ return findInteraction(objects);
+}
+
+// CInteractionController::FindInteractionUnderCursor (106D94)
+Interact *InteractionController::findInteractionUnderCursor() {
+ return findInteraction(g_ngi->_inputController->getHitObjects(g_ngi->getSceneInStack(0)));
+}
+
+// CInteractionController::GetCursorType (106DBA)
+int InteractionController::getCursorType() {
+ Interact *interact = findInteractionUnderCursor();
+ return interact ? interact->_cursor : 0;
+}
+
+// CInteractionController::TryStartInteract (106780)
+bool InteractionController::tryStartInteract(Scene *scene, Interact *interact) {
+ if (!_enabled)
+ return false;
+ debugC(1, kDebugInfo, "INFO t %u TryStartInteract %s in the scene %d", g_system->getMillis(), interact->_actionName.c_str(), scene->_sceneId);
+ if (interact->_heroId) {
+ // the hero is part of the interaction: the queues of the scene must let him go
+ if (!scene->canInterruptQueues())
+ return false;
+ scene->tryInterruptQueues();
+ }
+ interact->run(scene);
+ return true;
+}
+
+// CInteractionController::FindImportantInteraction (107330): highest importance in the scene
+Interact *InteractionController::findImportantInteraction(Scene *scene) {
+ if (!findSceneInteractions(scene->_sceneId))
+ return nullptr;
+ Interact *result = nullptr;
+ float importance = 0.0f;
+ Common::Array<GameObject *> objects;
+ for (PictureObject *picture : scene->_pictureObjects)
+ objects.push_back(picture);
+ for (PictureObject *picture : scene->_roamingPictures)
+ objects.push_back(picture);
+ for (AniObject *ani : scene->_renderableAnis)
+ objects.push_back(ani);
+ for (GameObject *object : objects) {
+ // shown and hit when on the screen (IsOnScreen, vtable slot 32) and not blocked (flag 4 of +8)
+ if (!(object->_flags & 4) || !object->isOnScreen(scene) || (object->_objectFlags & 4))
+ continue;
+ ObjectInteractions *entry = findObjectInteractions(scene->_sceneId, (uint16)object->_id | (object->_copyId << 16));
+ if (!entry)
+ continue;
+ for (Interact *interact : entry->_interacts) {
+ if (importance < interact->_importance && interact->_activity >= 0.9999f) {
+ if (interact->_cursorObjectId == 0) {
+ result = interact;
+ importance = interact->_importance;
+ } else {
+ const InventoryItem *item = g_ngi->_inventory->getItem(interact->_cursorObjectId);
+ if (item && item->_counter != 0) {
+ result = interact;
+ importance = interact->_importance;
+ }
+ }
+ }
+ }
+ }
+ return result;
+}
+
+// CInteractionController::GetAllImportantInteractions (107508): sorted by weight, the highest first
+void InteractionController::getAllImportantInteractions(Scene *scene, Common::Array<Interact *> &result) {
+ result.clear();
+ if (!findSceneInteractions(scene->_sceneId))
+ return;
+ Common::Array<GameObject *> objects;
+ for (PictureObject *picture : scene->_pictureObjects)
+ objects.push_back(picture);
+ for (PictureObject *picture : scene->_roamingPictures)
+ objects.push_back(picture);
+ for (AniObject *ani : scene->_renderableAnis)
+ objects.push_back(ani);
+ for (GameObject *object : objects) {
+ if (!(object->_flags & 4) || !object->isOnScreen(scene) || (object->_objectFlags & 4))
+ continue;
+ ObjectInteractions *entry = findObjectInteractions(scene->_sceneId, (uint16)object->_id | (object->_copyId << 16));
+ if (!entry)
+ continue;
+ for (Interact *interact : entry->_interacts) {
+ if (interact->_importance > 0.0f && interact->_activity >= 0.9999f) {
+ if (interact->_cursorObjectId == 0) {
+ result.push_back(interact);
+ } else {
+ const InventoryItem *item = g_ngi->_inventory->getItem(interact->_cursorObjectId);
+ if (item && item->_counter != 0)
+ result.push_back(interact);
+ }
+ }
+ }
+ }
+ // the exchange sort of the original: the weights descend
+ for (uint i = 0; i < result.size(); i++) {
+ for (uint j = i + 1; j < result.size(); j++) {
+ if (result[i]->_weight < result[j]->_weight)
+ SWAP(result[i], result[j]);
+ }
+ }
+}
+
+// CInteractionController::GetCurrentInteract (106898) and GetCurrentInteractVisObjId (106842)
+Interact *InteractionController::getCurrentInteract(Scene *scene) {
+ SceneInteractions *sceneEntry = findSceneInteractions(scene->_sceneId);
+ if (!sceneEntry)
+ return nullptr;
+ for (const ObjectInteractions &entry : sceneEntry->_objects) {
+ for (Interact *interact : entry._interacts) {
+ if (interact->_messageQueue && interact->_messageQueue->_curIndex != -1)
+ return interact;
+ }
+ }
+ return nullptr;
+}
+
+int InteractionController::getCurrentInteractObjectKey(Scene *scene) {
+ SceneInteractions *sceneEntry = findSceneInteractions(scene->_sceneId);
+ if (!sceneEntry)
+ return 0;
+ for (const ObjectInteractions &entry : sceneEntry->_objects) {
+ for (Interact *interact : entry._interacts) {
+ if (interact->_messageQueue && interact->_messageQueue->_curIndex != -1)
+ return entry._key;
+ }
+ }
+ return 0;
+}
+
+// CInteractionController::OnUpdate (105D24)
+void InteractionController::onUpdate(uint elapsed) {
+ for (Interact *interact : _interactions)
+ interact->onUpdate(elapsed);
+}
+
+// CInteractionController::StopAllInteractions (105C36)
+void InteractionController::stopAllInteractions() {
+ for (Interact *interact : _interactions)
+ interact->stop();
+}
+
+// CInteractionController::StoppedAllInteractions (1068EA)
+void InteractionController::stoppedAllInteractions(Scene *scene) {
+ SceneInteractions *sceneEntry = findSceneInteractions(scene->_sceneId);
+ if (!sceneEntry)
+ return;
+ for (const ObjectInteractions &entry : sceneEntry->_objects) {
+ for (Interact *interact : entry._interacts)
+ interact->_running = false;
+ }
+}
+
+// CInteractionController::Init (108054): the quest files (InitFromFile) are not in the game data
+void InteractionController::init() {
+ for (Interact *interact : _interactions)
+ interact->init();
+}
+
+// CInteractionController::SetVes (106DC8): the first interaction with the name
+bool InteractionController::setVes(const Common::String &name, int sceneId, int objectId, int weight) {
+ for (Interact *interaction : _interactions) {
+ if ((sceneId && interaction->_sceneId != sceneId) || (objectId && interaction->_objectId != objectId))
+ continue;
+ if (interaction->_actionName != name)
+ continue;
+ interaction->_weight = weight;
+ return true;
+ }
+ return false;
+}
+
} // End of namespace NGI
diff --git a/engines/ngi/interaction.h b/engines/ngi/interaction.h
index 8586a6da158..39642f641ab 100644
--- a/engines/ngi/interaction.h
+++ b/engines/ngi/interaction.h
@@ -22,6 +22,9 @@
#ifndef NGI_INTERACTION_H
#define NGI_INTERACTION_H
+#include "common/array.h"
+#include "common/str.h"
+
#include "ngi/utils.h"
namespace NGI {
@@ -29,6 +32,7 @@ namespace NGI {
class GameObject;
class MessageQueue;
class AniObject;
+class Scene;
int handleObjectInteraction(AniObject *subject, GameObject *object, int invId);
bool canInteractAny(GameObject *obj1, GameObject *obj2, int invId);
@@ -53,22 +57,69 @@ class Interact : public CObject {
Common::String _actionName;
float _activity = 1.0f; // Android CInteract act: below 0.9999 the interaction cannot run (SET_ACTIVE_INTERACTION)
+ // CInteract fields at _gameVersion >= 201509; _messageQueue (+24) belongs to the scene
+ /** +12: child DESCRIPTION of the XML node */
+ Common::String _description;
+ /** +20: cursor type (attribute "cursor", else the controller's) */
+ int _cursor = 0;
+ /** +56: copy of the object (attribute "copy") */
+ int _copy = 0;
+ /** attribute "heroScene": where the hero is looked for, 0 = the interaction's scene */
+ int16 _heroSceneId = 0;
+ /** +76, +84, +88, +92: originals restored by Init (ves, act), importance and its original */
+ int _weightOriginal = 0;
+ float _activityOriginal = 1.0f;
+ float _importance = 0.0f;
+ float _importanceOriginal = 0.0f;
+ /** +100: milliseconds the interaction could run (OnUpdate) */
+ uint _runnableTime = 0;
+ /** +104: Run started it and its queue has not ended */
+ bool _running = false;
+
public:
Interact();
~Interact() override;
bool load(MfcArchive &file) override;
bool canRun(GameObject *obj1, GameObject *obj2, int invId);
+ /** CInteract::CanRun (105E48), _gameVersion >= 201509: the item is the cursor controller's */
+ bool canRun();
bool isOverlapping(AniObject *subj, GameObject *obj);
- /** CInteract::GetObject: the object of the interaction, looked up in its scene */
+ /** CInteract::GetObject: the object, looked up in its scene (FindVis) */
GameObject *getObject() const;
- /**
- * CInteract::CanBeRunnedNow: active, the object is visible and in the static the interaction needs; with checkItem (CHelpItem::TryShow passes 1) the
- * item of the cursor that the interaction needs must be in the inventory
- */
+ /** CInteract::GetObjectId (105A6E): the copy and the id of the object */
+ int getObjectId() const { return (_copy << 16) | (uint16)_objectId; }
+ /** CInteract::GetObjectOriginal (105A7A) and GetSceneId (105A7E) */
+ int getObjectOriginal() const { return _objectId; }
+ int getSceneId() const { return _sceneId; }
+ /** +28: the hero (CAniObject of scene "heroScene"), looked up on demand */
+ AniObject *getHero() const;
+ /** CInteract::GetHeroPos (105A9E): the hero's center in the interaction statics; (0, 0) if none */
+ Common::Point getHeroPos();
+ /** CInteract::Run (106468): INTERACT_PRESTART, movements to the statics, INTERACT_STARTED */
+ void run(Scene *scene);
+ /** CInteract::Stop (105A5A) and Init (105A4C) */
+ void stop();
+ void init();
+ /** CInteract::OnUpdate (105D00): counts the time the interaction could run */
+ bool onUpdate(uint elapsed);
+ /** CInteract::GetXmlData / SetXmlData / CleanXml (savegames): STUBs, see InteractionController */
+ /** CInteract::CanBeRunnedNow: active, object visible, needed static; checkItem: inventory item */
bool canBeRunNow(bool checkItem = false) const;
};
+/** The interactions of one object (key = object id and copy), in XML order */
+struct ObjectInteractions {
+ int _key;
+ Common::Array<Interact *> _interacts;
+};
+
+/** The interactions of a scene, objects ordered by key (std::map) */
+struct SceneInteractions {
+ int _sceneId;
+ Common::Array<ObjectInteractions> _objects;
+};
+
class InteractionController : public CObject {
friend bool canInteractAny(GameObject *obj1, GameObject *obj2, int invId);
@@ -79,6 +130,10 @@ public:
private:
InteractionList _interactions;
static bool compareInteractions(const Interact *i1, const Interact *i2);
+ /** CInteractionController +8 (_gameVersion >= 201509): map<scene, map<object key, vector>> */
+ Common::Array<SceneInteractions> _scenes;
+ SceneInteractions *findSceneInteractions(int sceneId);
+ ObjectInteractions *findObjectInteractions(int sceneId, int objectKey);
public:
InteractionController() : _enabled(true) {}
@@ -86,9 +141,12 @@ public:
bool load(MfcArchive &file) override;
- void addInteract(Interact *interaction) { _interactions.push_back(interaction); }
+ /** CInteractionController::AddInteract (107988): into the map of its scene and object */
+ void addInteract(Interact *interaction);
void enable() { _enabled = true; }
void disable() { _enabled = false; }
+ /** +40: cursor type of an interaction whose XML node has none (root attribute "cursor", 1) */
+ int _cursor = 1;
void sortInteractions(int sceneId);
@@ -97,15 +155,45 @@ public:
void onStopQueue() { _queueRunning = false; }
bool _queueRunning = false;
+ /** _gameVersion >= 201509: FindInteraction(objects) plus TryStartInteract; not in the original */
bool handleInteraction(AniObject *subj, GameObject *obj, int invId);
Interact *findInteraction(int obId, int obId2, int obId3);
/** CInteractionController::FindInteraction(name, 0, 0): the first interaction with that name */
Interact *findInteractionByName(const Common::String &name);
+ /** CInteractionController::FindInteraction(scene, object key, a4) (106AE8): best of the object */
+ Interact *findInteraction(Scene *scene, int objectKey, int a4);
+ /** CInteractionController::FindInteractionQueue (106C30) */
+ MessageQueue *findInteractionQueue(Scene *scene, int objectKey);
+ /** CInteractionController::IsAnyInteraction (106C48): the object has an active interaction */
+ bool isAnyInteraction(Scene *scene, int objectKey);
+ /** CInteractionController::FindInteraction(objects) (106CD0): lowest z first, first that runs */
+ Interact *findInteraction(const Common::Array<GameObject *> &objects);
+ /** CInteractionController::FindInteraction(x, y) (1072AC): the objects at the point */
+ Interact *findInteraction(float x, float y);
+ /** CInteractionController::FindInteractionUnderCursor (106D94) and GetCursorType (106DBA) */
+ Interact *findInteractionUnderCursor();
+ int getCursorType();
+ /** CInteractionController::TryStartInteract (106780) */
+ bool tryStartInteract(Scene *scene, Interact *interact);
+ /** CInteractionController::FindImportantInteraction (107330), GetAllImportant... (107508) */
+ Interact *findImportantInteraction(Scene *scene);
+ void getAllImportantInteractions(Scene *scene, Common::Array<Interact *> &result);
+ /** CInteractionController::GetCurrentInteract (106898) / GetCurrentInteractVisObjId (106842) */
+ Interact *getCurrentInteract(Scene *scene);
+ int getCurrentInteractObjectKey(Scene *scene);
+ /** CInteractionController::OnUpdate (105D24), StopAll... (105C36), StoppedAll... (1068EA) */
+ void onUpdate(uint elapsed);
+ void stopAllInteractions();
+ void stoppedAllInteractions(Scene *scene);
+ /** CInteractionController::Init (108054): restores ves, act and importance */
+ void init();
// CInteractionController::SetActive: the first interaction with this name (in the scene and for the object,
// when given) gets its activity set to act, or increased by add when add is not 0
bool setActive(const Common::String &name, int sceneId, int objectId, float act, float add);
+ /** CInteractionController::SetVes (106DC8) */
+ bool setVes(const Common::String &name, int sceneId, int objectId, int weight);
/** CInteractionController::GetAllRunableInteractions: the interactions of the visible objects of the scene that can run now */
void getAllRunnableInteractions(Scene *scene, Common::Array<Interact *> &result);
diff --git a/engines/ngi/objects.h b/engines/ngi/objects.h
index 61d5875d5fb..ef1609d6f98 100644
--- a/engines/ngi/objects.h
+++ b/engines/ngi/objects.h
@@ -117,6 +117,7 @@ class GameProject : public CObject {
GameProject();
bool load(MfcArchive &file) override;
Scene *findScene(int sceneId);
+ Scene *findLoadedScene(int sceneId);
};
} // End of namespace NGI
Commit: dbe8146f6b7703fb03ae6efdc0e89229862837e6
https://github.com/scummvm/scummvm/commit/dbe8146f6b7703fb03ae6efdc0e89229862837e6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Port the interaction queues and INTERACT messages of CMessageQueue
Changed paths:
engines/ngi/messages.cpp
engines/ngi/messages.h
diff --git a/engines/ngi/messages.cpp b/engines/ngi/messages.cpp
index 04181e666e7..0b5e782e99b 100644
--- a/engines/ngi/messages.cpp
+++ b/engines/ngi/messages.cpp
@@ -398,6 +398,7 @@ MessageQueue::MessageQueue(MessageQueue *src, int parId, int field_38) {
_queueId = src->_queueId;
_flags = src->_flags & ~kInGlobalQueue;
_title = src->_title;
+ _interact = src->_interact; // +68 (110108)
_isFinished = 0;
_flag1 = 0;
return;
@@ -898,8 +899,10 @@ void MessageQueue::finishNow() {
// CMessageQueue::TryInterrupt (10FDCA): stopping a TALK (StopCurrent) is not ported
void MessageQueue::tryInterrupt() {
- if (_state != 0 && canInterrupt())
+ if (_state != 0 && canInterrupt()) {
+ debugC(1, kDebugInfo, "INFO t %u queue %d (scene %d) is interrupted (TryInterrupt, state %d)", g_system->getMillis(), _id, _scene ? _scene->_sceneId : 0, _interruptState);
interrupt(false);
+ }
}
// CMessageQueue::IsNeedSave (10C7C4)
diff --git a/engines/ngi/messages.h b/engines/ngi/messages.h
index 0c537256326..a8d5d6987eb 100644
--- a/engines/ngi/messages.h
+++ b/engines/ngi/messages.h
@@ -30,6 +30,8 @@
namespace NGI {
+class Interact;
+
enum QueueFlags {
kInGlobalQueue = 2,
kBehaviorQueue = 8
@@ -213,6 +215,8 @@ class MessageQueue : public CObject {
int _flag1;
/** CMessageQueue +20: the scene of the queue (null for Windows queues made without one) */
Scene *_scene = nullptr;
+ /** +68: the interaction of the queue (CScene::AddInteractionQueue), else null */
+ Interact *_interact = nullptr;
/** +60: CScene::DeleteObjAfter when the queue stops */
bool _deleteAfter = false;
/** +64: the interrupt state (CanInterrupt, SetIntState); -1 until the first Run of an XML queue */
Commit: c7e3921b6a6cbbac8f6e63b13a313c2aae460447
https://github.com/scummvm/scummvm/commit/c7e3921b6a6cbbac8f6e63b13a313c2aae460447
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Port CScene interaction queues and OnMouseLKeyUp tail
Changed paths:
engines/ngi/scene.cpp
engines/ngi/scene.h
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 3655a3f24ee..48472caa0e7 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -57,6 +57,12 @@ Scene *NGIEngine::findScene(int sceneId) {
return _gameProject->findScene(sceneId);
}
+Scene *NGIEngine::findLoadedScene(int sceneId) {
+ if (sceneId == 0 && _inventory)
+ return _inventory;
+ return _gameProject->findLoadedScene(sceneId);
+}
+
// CGame::GetCurrentScene: the last scene of the stack
Scene *NGIEngine::getCurrentScene() {
return _sceneStack.empty() ? _currentScene : _sceneStack.back();
@@ -264,6 +270,14 @@ Scene *GameProject::findScene(int sceneId) {
return nullptr;
}
+Scene *GameProject::findLoadedScene(int sceneId) {
+ for (SceneTag &tag : *_sceneTagList) {
+ if (tag._sceneId == sceneId)
+ return tag._scene;
+ }
+ return nullptr;
+}
+
bool SceneTagList::load(MfcArchive &file) {
debugC(5, kDebugLoading, "SceneTagList::load()");
@@ -342,6 +356,9 @@ Scene::~Scene() {
for (uint i = 0; i < _madeQueues.size(); i++)
delete _madeQueues[i];
_madeQueues.clear();
+ for (uint i = 0; i < _interactionQueues.size(); i++)
+ delete _interactionQueues[i];
+ _interactionQueues.clear();
_deleteAfterQueues.clear();
// an animation of another scene put in here (ANI_REACT, CFPController::OnSceneInit) is not ours
@@ -698,7 +715,9 @@ void Scene::stopAllQueues() {
_messageQueues[i]->stop(false);
for (uint i = 0; i < _madeQueues.size(); i++)
_madeQueues[i]->stop(false);
- warning("STUB/untested: CInteractionController::StoppedAllInteractions (CScene::StopAllQueues)");
+ for (uint i = 0; i < _interactionQueues.size(); i++)
+ _interactionQueues[i]->stop(false);
+ getGameLoaderInteractionController()->stoppedAllInteractions(this);
return;
}
Common::Array<MessageQueue *> running;
@@ -766,6 +785,12 @@ void Scene::forgetQueue(MessageQueue *queue) {
break;
}
}
+ for (uint i = 0; i < _interactionQueues.size(); i++) {
+ if (_interactionQueues[i] == queue) {
+ _interactionQueues.remove_at(i);
+ break;
+ }
+ }
for (uint i = 0; i < _deleteAfterQueues.size(); i++) {
if (_deleteAfterQueues[i] == queue) {
_deleteAfterQueues.remove_at(i);
@@ -795,9 +820,31 @@ MessageQueue *Scene::findQueueById(int id) {
if (_madeQueues[i]->_id == id)
return _madeQueues[i];
}
+ for (uint i = 0; i < _interactionQueues.size(); i++) {
+ if (_interactionQueues[i]->_id == id)
+ return _interactionQueues[i];
+ }
return nullptr;
}
+// CScene::AddInteractionQueue(CXmlNode &, CInteract *) (1227AE): CMessageQueue(scene, false, 1),
+// id = scene counter (CheckId); the interrupt state is set when the node is complete
+MessageQueue *Scene::addInteractionQueue(Interact *interact) {
+ MessageQueue *queue = new MessageQueue(this, false, -1);
+ queue->_interact = interact;
+ _interactionQueues.push_back(queue);
+ return queue;
+}
+
+// CScene::AddInteractionQueue(CMessageQueue *, CInteract *) (12280A)
+MessageQueue *Scene::addInteractionQueue(MessageQueue *source, Interact *interact) {
+ MessageQueue *queue = new MessageQueue(source, 0, 0);
+ queue->_scene = this;
+ queue->_interact = interact;
+ _interactionQueues.push_back(queue);
+ return queue;
+}
+
MessageQueue *Scene::getMessageQueueByName(const Common::String &name) {
for (uint i = 0; i < _messageQueues.size(); i++)
if (_messageQueues[i]->_title == name)
@@ -1161,15 +1208,24 @@ bool Scene::onMouseLKeyDown(uint32 id, float x, float y) {
return false;
}
-// CScene::OnMouseLKeyUp: the same order; when none of them handles it the interaction under the cursor starts (CInteractionController::FindInteraction
-// and TryStartInteract: not ported here, the controllers of the scenes do it, see FPController::onTap)
+// CScene::OnMouseLKeyUp (120980): controller (Top), GUI, controller; if none handles it the
+// interaction at the point starts (FindInteraction(x, y), TryStartInteract).
+// CDialogController::OnMouseLKeyUp and CPhysListener::OnMouseLUp are not ported
bool Scene::onMouseLKeyUp(uint32 id, float x, float y) {
const float sceneX = x + _x;
const float sceneY = y + _y;
if (!_controller || !_controller->onMouseLKeyUpTop(id, sceneX, sceneY)) {
if (!_guiManager || !_guiManager->onMouseLKeyUp(Common::Point(x, y))) {
- if (_controller)
- _controller->onMouseLKeyUp(id, sceneX, sceneY);
+ if (!_controller || !_controller->onMouseLKeyUp(id, sceneX, sceneY)) {
+ if (g_ngi->_gameVersion >= 201509) {
+ InteractionController *interactions = getGameLoaderInteractionController();
+ if (Interact *interact = interactions->findInteraction(sceneX, sceneY)) {
+ debugC(1, kDebugInfo, "INFO t %u INTERACTION %s at %d,%d starts (object %d)", g_system->getMillis(), interact->_actionName.c_str(), (int)sceneX, (int)sceneY,
+ interact->_objectId);
+ interactions->tryStartInteract(this, interact);
+ }
+ }
+ }
}
}
return false;
@@ -1242,17 +1298,14 @@ bool Scene::isEntranceQueue(uint32 queueId) const {
return false;
}
-// CScene::Message (120BA4): the controller's OnMessage (slot +112), then INTERACT_ENDED clears the flag (+104) of the interaction that ends, found by
-// CInteractionController::FindInteraction(param). The interactions of this engine do not have that flag yet: STUB.
+// CScene::Message (120BA4): the controller's OnMessage (slot +112), then INTERACT_ENDED clears
+// the flag (+104) of the interaction found by FindInteraction(param, 0, 0)
void Scene::message(const Common::String &name, const Common::String ¶m, MessageQueue *queue) {
if (_controller)
_controller->onMessage(name, param, queue);
- if (name == "INTERACT_ENDED") {
- static bool warned = false;
- if (!warned) {
- warned = true;
- warning("STUB/untested: CScene::Message INTERACT_ENDED (the flag of the interaction is not ported)");
- }
+ if (name == "INTERACT_ENDED" && g_ngi->_gameVersion >= 201509) {
+ if (Interact *interact = getGameLoaderInteractionController()->findInteractionByName(param))
+ interact->_running = false;
}
}
@@ -1417,6 +1470,41 @@ int Scene::getPictureObjectIdAtPos(int x, int y) {
return res;
}
+// CScene::GetVisObjsVHitInteract (122A9C): the shown objects hit with 0x100 (XML flag 2, as in
+// RepopulateHitObjects) without flag 8 go into a set ordered by z (equal ones by insertion)
+void Scene::getVisObjsVHitInteract(Common::Array<GameObject *> &result, float x, float y) {
+ result.clear();
+ Common::Array<GameObject *> hit;
+ for (int i = (int)_renderableAnis.size() - 1; i >= 0; i--) {
+ AniObject *ani = _renderableAnis[i];
+ if ((ani->_flags & 4) && (ani->_objectFlags & 2) && ani->hit(x, y) && !(ani->_objectFlags & 8))
+ hit.push_back(ani);
+ }
+ for (int i = (int)_roamingPictures.size() - 1; i >= 0; i--) {
+ PictureObject *picture = _roamingPictures[i];
+ if ((picture->_flags & 4) && (picture->_objectFlags & 2) && picture->hit(x, y) && !(picture->_objectFlags & 8))
+ hit.push_back(picture);
+ }
+ for (int i = (int)_pictureObjects.size() - 1; i >= 0; i--) {
+ PictureObject *picture = _pictureObjects[i];
+ if ((picture->_flags & 4) && (picture->_objectFlags & 2) && picture->hit(x, y) && !(picture->_objectFlags & 8))
+ hit.push_back(picture);
+ }
+ for (GameObject *object : hit) {
+ uint position = result.size();
+ while (position > 0 && result[position - 1]->_z > object->_z)
+ position--;
+ result.insert_at(position, object);
+ }
+}
+
+// CScene::GetVisObjVHitInteract (11FE6C)
+GameObject *Scene::getVisObjVHitInteract(float x, float y) {
+ Common::Array<GameObject *> objects;
+ getVisObjsVHitInteract(objects, x, y);
+ return objects.empty() ? nullptr : objects.front();
+}
+
bool Scene::update(int counterdiff) {
debugC(6, kDebugDrawing, "Scene::update(%d)", counterdiff);
@@ -1429,12 +1517,16 @@ bool Scene::update(int counterdiff) {
_messageQueues[i]->update(counterdiff);
for (uint i = 0; i < _madeQueues.size(); i++)
_madeQueues[i]->update(counterdiff);
+ for (uint i = 0; i < _interactionQueues.size(); i++)
+ _interactionQueues[i]->update(counterdiff);
processMessages();
if (g_ngi->_modalObject || this != g_ngi->getCurrentScene()) {
+ getGameLoaderInteractionController()->onUpdate(counterdiff);
removeObjectSafe();
return true;
}
changed |= updateObjects(counterdiff);
+ getGameLoaderInteractionController()->onUpdate(counterdiff);
removeObjectSafe();
return changed;
}
@@ -1444,6 +1536,11 @@ bool Scene::update(int counterdiff) {
// CScene::IsQueuesProcessed (11FB98): a queue that is not stopped (interaction queues first)
bool Scene::isQueuesProcessed(bool ignoreInterruptState3) const {
if (g_ngi->_gameVersion >= 201509) {
+ for (uint i = 0; i < _interactionQueues.size(); i++) {
+ const MessageQueue *queue = _interactionQueues[i];
+ if (queue->_state != 0 && (!ignoreInterruptState3 || queue->_interruptState != 3))
+ return true;
+ }
for (uint i = 0; i < _madeQueues.size(); i++) {
const MessageQueue *queue = _madeQueues[i];
if (queue->_state != 0 && (!ignoreInterruptState3 || queue->_interruptState != 3))
@@ -1480,12 +1577,15 @@ void Scene::stopQueue(int queueId) {
bool Scene::ownsQueue(const MessageQueue *queue) const {
return Common::find(_messageQueues.begin(), _messageQueues.end(), queue) != _messageQueues.end() ||
- Common::find(_madeQueues.begin(), _madeQueues.end(), queue) != _madeQueues.end();
+ Common::find(_madeQueues.begin(), _madeQueues.end(), queue) != _madeQueues.end() ||
+ Common::find(_interactionQueues.begin(), _interactionQueues.end(), queue) != _interactionQueues.end();
}
// CScene::HowManyQueuesProcessed (11FBFE)
int Scene::howManyQueuesProcessed() const {
int count = 0;
+ for (uint i = 0; i < _interactionQueues.size(); i++)
+ count += _interactionQueues[i]->_state != 0;
for (uint i = 0; i < _madeQueues.size(); i++)
count += _madeQueues[i]->_state != 0;
for (uint i = 0; i < _messageQueues.size(); i++)
@@ -1495,6 +1595,10 @@ int Scene::howManyQueuesProcessed() const {
// CScene::TryInterruptQueues (11FC50): true when no queue is left (interrupt state 3 aside)
bool Scene::tryInterruptQueues() {
+ for (uint i = 0; i < _interactionQueues.size(); i++) {
+ if (_interactionQueues[i]->_state != 0)
+ _interactionQueues[i]->tryInterrupt();
+ }
for (uint i = 0; i < _madeQueues.size(); i++) {
if (_madeQueues[i]->_state != 0)
_madeQueues[i]->tryInterrupt();
@@ -1508,6 +1612,11 @@ bool Scene::tryInterruptQueues() {
// CScene::CanInterruptQueues (11FCB2)
bool Scene::canInterruptQueues() const {
+ for (uint i = 0; i < _interactionQueues.size(); i++) {
+ MessageQueue *queue = _interactionQueues[i];
+ if (queue->_state != 0 && !queue->canInterrupt() && queue->_interruptState != 3)
+ return false;
+ }
for (uint i = 0; i < _madeQueues.size(); i++) {
MessageQueue *queue = _madeQueues[i];
if (queue->_state != 0 && !queue->canInterrupt() && queue->_interruptState != 3)
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 23d148fd5a9..62a6b1a2f48 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -33,6 +33,7 @@
namespace NGI {
class MessageQueue;
+class Interact;
class GameProject;
class BehaviorController;
class MctlCompound;
@@ -136,6 +137,12 @@ class Scene : public Background {
Scene *_commonQueueScene = nullptr;
/** Queues made by the code (CScene::AddQueue), owned, polled like _messageQueues (>= 201509) */
Common::Array<MessageQueue *> _madeQueues;
+ /** CScene +236 (>= 201509): the interaction queues (AddInteractionQueue), owned, polled too */
+ Common::Array<MessageQueue *> _interactionQueues;
+ /** CScene::AddInteractionQueue(CXmlNode &, CInteract *) (1227AE) */
+ MessageQueue *addInteractionQueue(Interact *interact);
+ /** CScene::AddInteractionQueue(CMessageQueue *, CInteract *) (12280A): the scene keeps a copy */
+ MessageQueue *addInteractionQueue(MessageQueue *source, Interact *interact);
/** CScene +292: DeleteObjAfter queues, deleted by RemoveObjectSafe at the end of the update */
Common::Array<MessageQueue *> _deleteAfterQueues;
/** The scene is being deleted: its queues do not look for animations pointing to them */
@@ -221,6 +228,10 @@ class Scene : public Background {
void removePicture(PictureObject *obj);
void preloadMovements(GameVar *var);
+ /** CScene::GetVisObjsVHitInteract (122A9C): hit objects without flag 8, lowest z first */
+ void getVisObjsVHitInteract(Common::Array<GameObject *> &result, float x, float y);
+ /** CScene::GetVisObjVHitInteract (11FE6C): the first of them */
+ GameObject *getVisObjVHitInteract(float x, float y);
AniObject *findAniObjectAtPos(int x, int y);
PictureObject *findPictureObjectAtPos(int x, int y);
int getPictureObjectIdAtPos(int x, int y);
Commit: 3b597d5241ea1a245ee68009e5f775a93323f3f2
https://github.com/scummvm/scummvm/commit/3b597d5241ea1a245ee68009e5f775a93323f3f2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Port CAniObject linked movements and exact stop for interactions
Changed paths:
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 468dc2194a4..d8455c917b8 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -1071,7 +1071,7 @@ Common::Point *AniObject::calcNextStep(Common::Point *pRes) {
return pRes;
}
-void AniObject::stopMovement() {
+void AniObject::stopMovement(bool keepSounds) {
debugC(2, kDebugAnimation, "AniObject::stopMovement()");
if (!(_flags & 1))
@@ -1092,12 +1092,15 @@ void AniObject::stopMovement() {
if (reversed) {
while (_movement->_curFrame > 0) {
_movement->gotoPrevFrame(mirror);
- _movement->_curPhase->enter(_id);
+ if (!keepSounds)
+ _movement->_curPhase->enter(_id);
}
} else if (_targetFrame < 0) {
const int endFrame = (int)_movement->_phases.size() - 1;
- while (_movement->_curFrame < endFrame && _movement->setNext(nullptr, nullptr, mirror))
- _movement->_curPhase->enter(_id);
+ while (_movement->_curFrame < endFrame && _movement->setNext(nullptr, nullptr, mirror)) {
+ if (!keepSounds)
+ _movement->_curPhase->enter(_id);
+ }
} else if (_movement->_curFrame < _targetFrame) {
warning("STUB/untested: AniObject::stopMovement(%d) before the stop frame of the movement %d (frame %d of %d)", _id, _movement->_id, _movement->_curFrame, _targetFrame);
}
@@ -1163,11 +1166,13 @@ L12:
_statics->_y = _y - point.y;
oid = _movement->_id;
if (g_ngi->_gameVersion >= 201509) {
- // CAniObject::StopMovement: the movement is unloaded unless the preload manager keeps it
- if (!g_ngi->_preloadManager->isPreloaded(_movement->_id))
- g_ngi->_preloadManager->onUnloadMove(_movement->unload());
- for (int i = 0; i < g_ngi->_currSoundListCount; ++i)
- g_ngi->_currSoundList1[i]->stopByCreator(_id);
+ // unload the movement unless the preload manager keeps it; the sounds stop (not with keepSounds)
+ if (!keepSounds) {
+ if (!g_ngi->_preloadManager->isPreloaded(_movement->_id))
+ g_ngi->_preloadManager->onUnloadMove(_movement->unload());
+ for (int i = 0; i < g_ngi->_currSoundListCount; ++i)
+ g_ngi->_currSoundList1[i]->stopByCreator(_id);
+ }
_movement->_reverse = false;
_movement->_cycled = false;
}
@@ -1229,10 +1234,18 @@ bool AniObject::isSlidingEnd(float endX, float endY) const {
// CAniObject::StopMovementToPrev (movement stopped by a new walk or a script): the object goes back to the previous statics of the
// running movement, keeping the horizontal center of the sprite; the vertical position is that of the statics at the start of the
// movement (the movement origin minus the steps taken since: the phase offsets and the sliding steps).
-void AniObject::stopMovementToPrev(bool keepSounds) {
+void AniObject::stopMovementToPrev(bool keepSounds, bool exact) {
if (!_movement || !(_flags & 1))
return;
+ if (exact && g_ngi->_gameVersion >= 201509 && !_stepArray.getPointsCount() && !_movement->_currMovement) {
+ // CAniObject::StopMovementToPrev (F10F4): turn the movement round, StopMovement rewinds it;
+ // slides and mirrored movements keep the reconstruction below
+ _movement->_reverse = !_movement->_reverse;
+ stopMovement(keepSounds);
+ return;
+ }
+
Movement *mov = _movement;
Statics *prev = mov->_prevStatic;
const bool mirrored = (_flags & 8) != 0;
@@ -1496,6 +1509,68 @@ Common::Array<Movement *> AniObject::findMovementsBeginStatic(int excludedMoveme
return result;
}
+// the search of GetLinkedMovements (F1770), IsExistLinkedMovements (F1ED8), MoveToStatic (F1B0C):
+// linked movements first, then all of them as the first step
+bool AniObject::findLinkedChain(int fromStaticsId, int toStaticsId, Common::Array<Movement *> &chain) {
+ chain.clear();
+ Common::Array<Movement *> sorted = _movements;
+ Common::sort(sorted.begin(), sorted.end(), movementIdLess);
+
+ for (int pass = 0; pass < 2; pass++) {
+ Common::Array<Movement *> candidates;
+ for (Movement *movement : sorted) {
+ if (pass == 0 && !movement->_link)
+ continue;
+ const int start = movement->_prevStatic->_staticsId;
+ const int end = movement->_nextStatic->_staticsId;
+ if (end == toStaticsId) {
+ if (start == fromStaticsId) {
+ chain.push_back(movement);
+ return true;
+ }
+ } else if (start == fromStaticsId && end != fromStaticsId) {
+ candidates.push_back(movement);
+ }
+ }
+ for (Movement *candidate : candidates) {
+ Common::Array<Movement *> path = findMovementsBeginStatic(candidate->_id, candidate->_nextStatic->_staticsId, toStaticsId, candidates, false);
+ if (!path.empty()) {
+ chain.push_back(candidate);
+ for (Movement *step : path)
+ chain.push_back(step);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+// CAniObject::GetLinkedMovements (F1770)
+MessageQueue *AniObject::getLinkedMovements(int fromStaticsId, int toStaticsId) {
+ if (_movement)
+ return nullptr;
+ MessageQueue *queue = new MessageQueue(nullptr, false, 1);
+ if (toStaticsId == fromStaticsId)
+ return queue;
+ Common::Array<Movement *> chain;
+ if (findLinkedChain(fromStaticsId, toStaticsId, chain)) {
+ for (Movement *movement : chain) {
+ Command *command = new Command(_id, kCmdStartMovement, movement->_id, 0, 0, 0, 1, 0, 0, 0);
+ command->_excFlags = 2;
+ queue->addCommandToEnd(command);
+ }
+ }
+ return queue;
+}
+
+// CAniObject::IsExistLinkedMovements (F1ED8)
+bool AniObject::isExistLinkedMovements(int fromStaticsId, int toStaticsId) {
+ if (fromStaticsId == toStaticsId)
+ return true;
+ Common::Array<Movement *> chain;
+ return findLinkedChain(fromStaticsId, toStaticsId, chain);
+}
+
// CAniObject::MoveToStatic (F1B0C)
void AniObject::moveToStaticChain(int staticsId) {
if (_movement)
@@ -1507,33 +1582,10 @@ void AniObject::moveToStaticChain(int staticsId) {
Common::Array<Movement *> sorted = _movements;
Common::sort(sorted.begin(), sorted.end(), movementIdLess);
- // forwards: a linked movement that leads to the statics, or the linked ones that begin at the current one and the path from their end
+ // forwards: linked movements that lead to the statics, else from any movement
Common::Array<Movement *> candidates;
- for (Movement *movement : sorted) {
- if (!movement->_link)
- continue;
- const int start = movement->_prevStatic->_staticsId;
- const int end = movement->_nextStatic->_staticsId;
- if (end == staticsId) {
- if (start == current) {
- fastStartMovement(movement->_id, false);
- return;
- }
- } else if (start == current && end != start) {
- candidates.push_back(movement);
- }
- }
Common::Array<Movement *> chain;
- for (Movement *candidate : candidates) {
- Common::Array<Movement *> path = findMovementsBeginStatic(candidate->_id, candidate->_nextStatic->_staticsId, staticsId, candidates, false);
- if (!path.empty()) {
- chain.push_back(candidate);
- for (Movement *step : path)
- chain.push_back(step);
- break;
- }
- }
- if (!chain.empty()) {
+ if (findLinkedChain(current, staticsId, chain)) {
for (Movement *step : chain)
fastStartMovement(step->_id, false);
return;
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index ec86f7318a3..c2e9ebd4bbc 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -275,7 +275,9 @@ public:
void setTargetFrame(int val) { _targetFrame = val; }
void adjustSomeXY();
void stopCutMovement(const Common::Point &pending);
- void stopMovementToPrev(bool keepSounds);
+ /** CAniObject::StopMovementToPrev (F10F4); `exact` is the original way, not the default:
+ * it moved the tutorial man by 440 pixels (movement 11015) */
+ void stopMovementToPrev(bool keepSounds, bool exact = false);
/** CAniObject::StartMovement (F0D46); cycled, reverse, startFrame are START_MOVEMENT attributes */
bool startMovement(int movementId, int messageQueueId, int dynPhaseIdx, bool mirror = false, bool cycled = false, bool reverse = false, int startFrame = -1);
@@ -301,7 +303,8 @@ public:
void setSpeed(int speed);
void updateStepPos();
- void stopMovement();
+ /** CAniObject::StopMovement(bool) (F0F28); keepSounds skips sounds and phase commands */
+ void stopMovement(bool keepSounds = false);
/** CAniObject::IsSlidingEnd (F0EEE); the end point test for cycled movements is not ported */
bool isSlidingEnd(float endX, float endY) const;
Common::Point *calcNextStep(Common::Point *point);
@@ -321,6 +324,12 @@ public:
bool fastStartMovement(int movementId, bool reverse);
/** CAniObject::MoveToStatic (F1B0C), Android; moveToStatic(int) is the Windows version */
void moveToStaticChain(int staticsId);
+ /** CAniObject::GetLinkedMovements (F1770): a new queue (caller owns it), null while moving */
+ MessageQueue *getLinkedMovements(int fromStaticsId, int toStaticsId);
+ /** CAniObject::IsExistLinkedMovements (F1ED8) */
+ bool isExistLinkedMovements(int fromStaticsId, int toStaticsId);
+ /** the search of GetLinkedMovements, IsExistLinkedMovements and MoveToStatic */
+ bool findLinkedChain(int fromStaticsId, int toStaticsId, Common::Array<Movement *> &chain);
/** CAniObject::FindMovementsBeginStatic (F15EC) */
Common::Array<Movement *> findMovementsBeginStatic(int excludedMovementId, int fromStaticsId, int toStaticsId, Common::Array<Movement *> visited, bool ignoreLink);
Commit: 45ba6d70ea107c8cb12d92540894dacbbe14f6fc
https://github.com/scummvm/scummvm/commit/45ba6d70ea107c8cb12d92540894dacbbe14f6fc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Parse INTERACTION nodes like Android and route taps to the scene
Changed paths:
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 302931bf097..a294b0f4f27 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -382,13 +382,15 @@ bool NGIEngine::handleSceneEvent(const Common::Event &event, GuiManager *manager
controller.onMouseLKeyDown(0, sceneX, sceneY);
if (sceneTouch && event.type == Common::EVENT_MOUSEMOVE)
controller.onMouseMove(0, sceneX, sceneY);
- if (sceneTouch && event.type == Common::EVENT_LBUTTONUP)
- controller.onMouseLKeyUpTop(0, sceneX, sceneY);
if (sceneTouch && event.type == Common::EVENT_LBUTTONUP) {
- if (onGui)
+ if (onGui) {
+ controller.onMouseLKeyUpTop(0, sceneX, sceneY);
controller.resetSwipeParams(); // the touch started on the scene and ended over a button
- else
- return controller.onMouseLKeyUp(0, sceneX, sceneY);
+ } else {
+ // CScene::OnMouseLKeyUp: controller (Top), GUI, controller, then the interaction at the point
+ _currentScene->onMouseLKeyUp(0, event.mouse.x, event.mouse.y);
+ return true;
+ }
}
if (!manager)
return false;
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index a2223c3b4f5..db0ae32e852 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -420,6 +420,8 @@ public:
void updateSceneLogic(uint32 elapsed);
bool doSetScene(const Entrance &entrance);
Scene *findScene(int sceneId);
+ /** The scene if it is loaded already (findScene loads it otherwise); the inventory is scene 0 */
+ Scene *findLoadedScene(int sceneId);
// CGame +72: the stack of scenes; PushScene puts dialogs over it. _currentScene is its first scene
Common::Array<Scene *> _sceneStack;
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 3b6f3eb09f4..ca6e04076ce 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -494,14 +494,28 @@ public:
delete action;
}
+ // CInteract::CInteract ends with the queue init and INTERACT_ENDED
void registerInteractions() {
- for (Interact *action : _actions)
+ for (uint i = 0; i < _actions.size(); i++) {
+ Interact *action = _actions[i];
+ MessageQueue *queue = action->_messageQueue;
+ queue->_interruptState = _actionInterruptStates[i] >= 0 ? _actionInterruptStates[i] : queue->checkInterruptable();
+ Command *ended = new Command(0, kCmdMessage, 0, 0, 0, 0, 0, 0, 0, 0);
+ ended->_messageName = "INTERACT_ENDED";
+ ended->_args["msg"] = "INTERACT_ENDED";
+ ended->_args["param"] = action->_actionName;
+ ended->_excFlags = 2;
+ queue->addCommandToEnd(ended);
getGameLoaderInteractionController()->addInteract(action);
+ }
_actions.clear();
+ _actionInterruptStates.clear();
}
private:
Common::Array<Interact *> _actions;
+ /** interrupt state of the action queue from its node (-1: decided by the commands) */
+ Common::Array<int> _actionInterruptStates;
const GameProject &_project;
Scene &_scene;
const char *_locale;
@@ -1691,25 +1705,36 @@ private:
return parserError("Unknown interaction object");
action->_sceneId = sceneId;
action->_actionName = node->values.getValOrDefault("id");
+ // CInteract::CInteract: the hero is found in "heroScene", else in the scene of the interaction
readId(node->values.getValOrDefault("hero"), action->_heroId);
+ readId(node->values.getValOrDefault("heroScene"), action->_heroSceneId);
readId(node->values.getValOrDefault("heroStatic"), action->_heroStaticId);
action->_heroOffsetX = intProperty(*node, "x");
action->_heroOffsetY = intProperty(*node, "y");
action->_heroMirror = boolProperty(*node, "heroMirror");
- action->_weight = intProperty(*node, "ves");
- action->_activity = strtof(node->values.getValOrDefault("act", "1.0").c_str(), nullptr);
+ action->_copy = intProperty(*node, "copy");
+ readId(node->values.getValOrDefault("static"), action->_objectStaticId);
+ action->_cursor = node->values.contains("cursor") ? intProperty(*node, "cursor") : getGameLoaderInteractionController()->_cursor;
+ action->_weight = action->_weightOriginal = intProperty(*node, "ves");
+ action->_activity = action->_activityOriginal = strtof(node->values.getValOrDefault("act", "1.0").c_str(), nullptr);
+ action->_importance = action->_importanceOriginal = strtof(node->values.getValOrDefault("importance", "0.0").c_str(), nullptr);
+ action->_flags = intProperty(*node, "flags");
const Common::String item = node->values.getValOrDefault("curor_obj_id");
if (item == "ANY_OBJECT")
action->_cursorObjectId = -2;
else if (!item.empty() && item != "0")
readId(item, action->_cursorObjectId);
- action->_messageQueue = new MessageQueue();
+ // CScene::AddInteractionQueue(node, interaction): the queue belongs to the scene
+ action->_messageQueue = _scene.addInteractionQueue(action.get());
+ _actionInterruptStates.push_back(node->values.contains("uninterruptable") ? intProperty(*node, "interupt_state") : -1);
_interaction = action.release();
_actions.push_back(_interaction);
return true;
}
if (parent->name == "INTERACTION") {
node->layout = _XMLkeys;
+ if (_interaction && node->name == "DESCRIPTION")
+ _interaction->_description = node->values.getValOrDefault("str");
return !_interaction || node->name != "COMMAND" || parserCallback_COMMAND(node);
}
if (parent->name == "INVENTORY") {
Commit: c17a038dfe0c874fb2e3896446abf10f05a8709f
https://github.com/scummvm/scummvm/commit/c17a038dfe0c874fb2e3896446abf10f05a8709f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Port CFPController interaction walk (GO_MCTL, OnMouseLKeyUp) and drop the interaction stand-ins
Changed paths:
engines/ngi/fullpipe/controllerhelpers.cpp
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/fpcontroller.h
engines/ngi/fullpipe/sc01controller.cpp
engines/ngi/fullpipe/sc02controller.cpp
engines/ngi/fullpipe/sc03controller.cpp
engines/ngi/fullpipe/sc04controller.cpp
engines/ngi/fullpipe/sc06controller.cpp
engines/ngi/fullpipe/sc08controller.cpp
engines/ngi/fullpipe/sc14controller.cpp
diff --git a/engines/ngi/fullpipe/controllerhelpers.cpp b/engines/ngi/fullpipe/controllerhelpers.cpp
index dfdf73a1b45..d244751e484 100644
--- a/engines/ngi/fullpipe/controllerhelpers.cpp
+++ b/engines/ngi/fullpipe/controllerhelpers.cpp
@@ -22,10 +22,13 @@
#include "common/hashmap.h"
#include "ngi/ngi.h"
+#include "ngi/gameloader.h"
+#include "ngi/interaction.h"
#include "ngi/messages.h"
#include "ngi/scene.h"
#include "ngi/statics.h"
#include "ngi/fullpipe/controllerhelpers.h"
+#include "ngi/fullpipe/fpcontroller.h"
namespace NGI {
@@ -125,21 +128,24 @@ void enableSound(int, bool) {
}
Interact *findInteractionUnderCursor() {
- warnOnce("CInteractionController::FindInteractionUnderCursor is not ported (D17)");
- return nullptr;
+ return getGameLoaderInteractionController()->findInteractionUnderCursor();
}
-void runInteractionWithMouse(const char *, float, float) {
- warnOnce("CFPController::RunInteractionWithMouse is not ported (the tap of FPController::onTap starts the interactions by the object, not by the name)");
+// CFPController::RunInteractionWithMouse of the controller of the scene of the interaction
+void runInteractionWithMouse(const char *name, float x, float y) {
+ Interact *interact = getGameLoaderInteractionController()->findInteractionByName(name);
+ Scene *scene = interact ? g_ngi->findScene(interact->_sceneId) : nullptr;
+ if (scene)
+ sceneController(*scene).runInteractionWithMouse(name, x, y);
}
-void setInteractionWeight(const char *, int) {
- warnOnce("CInteractionController::SetVes is not ported: the weights of the interactions are not changed");
+void setInteractionWeight(const char *name, int weight) {
+ getGameLoaderInteractionController()->setVes(name, 0, 0, weight);
}
-int interactionCommandNum(const char *) {
- warnOnce("CInteractionController::FindInteraction by name is not ported (the number of the current command of the queue of an interaction)");
- return -1;
+int interactionCommandNum(const char *name) {
+ Interact *interact = getGameLoaderInteractionController()->findInteractionByName(name);
+ return interact && interact->_messageQueue ? interact->_messageQueue->getCurCommandNum() : -1;
}
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 6000d8e52c3..3a3ecada63e 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -39,6 +39,7 @@
#include "ngi/fullpipe/scenes.h"
#include "ngi/fullpipe/taskmanager.h"
#include "ngi/fullpipe/fpcontroller.h"
+#include "ngi/fullpipe/controllerhelpers.h"
#include "ngi/fullpipe/exitmanager.h"
#include "ngi/fullpipe/help.h"
#include "ngi/fullpipe/hintmanager.h"
@@ -146,7 +147,11 @@ void FPController::executeUserCmd(Command *cmd, MessageQueue *queue) {
// CAchievementsManager::AddActivatingCounter
g_ngi->_achievementsManager->addActivatingCounter(cmd->_args.getValOrDefault("achievementId"), atoi(cmd->_args.getValOrDefault("procent").c_str()),
cmd->_args.getValOrDefault("item", "UNDEF"));
- } else if (type == "GO_MCTL" || type == "MOUSE" || type == "SET_CENTER" || type == "TUTORIAL_ACTIVATE" || type == "SHOW_CHAPTER_DIALOG" || type == "CATALOG" ||
+ } else if (type == "GO_MCTL") {
+ execCmdMctl(cmd, queue);
+ } else if (type == "MOUSE") {
+ execCmdMouse(cmd, queue);
+ } else if (type == "SET_CENTER" || type == "TUTORIAL_ACTIVATE" || type == "SHOW_CHAPTER_DIALOG" || type == "CATALOG" ||
type == "ENABLE_CHARACTER" || type == "HINT_ENABLE" || type == "SHOW_REVIEW") {
// Handled by CFPController::ExecuteUserCmd, waiting for the subsystems they belong to (TASK_* are in taskmanager.cpp)
static Common::HashMap<Common::String, bool> reported;
@@ -373,7 +378,8 @@ void FPController::defaultScroll() {
_heroCenterY = center.y;
const float cx = cursorX();
const float cy = cursorY();
- const bool free = _scene->_motionController && !g_ngi->_currSelectedInventoryItemId;
+ // CCursorController +88
+ const bool free = _scene->_motionController && !g_ngi->_inputController->getObject();
bool edge = false;
const int viewWidth = g_ngi->gameWidth();
const int viewHeight = g_ngi->_backgroundSurface.h;
@@ -582,6 +588,12 @@ void FPController::checkQueues() {
_interactObjectId = 0;
_swipeDirection = 0;
_swiped = false;
+ // the item that INTERACT_PRESTART kept in the state 1 shows again (+204)
+ if (_interactItemId) {
+ if (InventoryItem *item = g_ngi->_inventory->getItem(_interactItemId))
+ item->setState(0);
+ _interactItemId = 0;
+ }
}
}
@@ -614,7 +626,7 @@ void FPController::forgetQueue(MessageQueue *queue) {
// CFPController::CheckTry
bool FPController::checkTry() const {
- return !g_ngi->_currSelectedInventoryItemId && hero() && g_ngi->_aniHandler->isObjectAttached(hero()->_id) && canInterruptManQueue();
+ return !g_ngi->_inputController->getObjectId() && hero() && g_ngi->_aniHandler->isObjectAttached(hero()->_id) && canInterruptManQueue();
}
// CFPController::MctlStartMove
@@ -726,7 +738,7 @@ bool FPController::moveBorders(float x, float y) {
_heroCenterX = center.x;
_heroCenterY = center.y;
MotionController *controller = _scene->_motionController.get();
- const bool active = controller && controller->_isEnabled && !g_ngi->_currSelectedInventoryItemId;
+ const bool active = controller && controller->_isEnabled && !g_ngi->_inputController->getObject();
if (x <= _heroCenterX) {
if (_leftBorderX < x || _leftBorderX < _heroCenterX) {
if (y > 60.0f && active)
@@ -757,16 +769,15 @@ bool FPController::tryStartInteractMan() {
}
const Common::Point center = hero()->getCenter();
const float x = _swipeDirection == -1 ? 2.0f : _scene->_dims.x - 2.0f;
- // CInteractionController::FindInteraction(x, y), CInteract::Run: the object at the edge is handled like a tap on it
- GameObject *target = _scene->findPictureObjectAtPos((int)x, center.y);
- AniObject *actor = _scene->findAniObjectAtPos((int)x, center.y);
- if (actor && (!target || actor->_z < target->_z))
- target = actor;
- if (!target || !canInteractAny(hero(), target, 0))
+ // runs unless its object is the one of the interaction that runs
+ Interact *interact = getGameLoaderInteractionController()->findInteraction(x, (float)center.y);
+ if (!interact)
return false;
- if (target->_id != _interactObjectId)
- handleObjectInteraction(hero(), target, 0);
- _interactObjectId = target->_id;
+ GameObject *object = interact->getObject();
+ if ((object ? object->_id : 0) != _interactObjectId)
+ interact->run(_scene);
+ object = interact->getObject();
+ _interactObjectId = object ? object->_id : 0;
_swipeDirection = _swipeDirection == -1 ? -2 : 2;
_swipeWalking = true;
return true;
@@ -818,28 +829,17 @@ bool FPController::onMouseLKeyDown(uint32 id, float x, float y) {
return true;
}
-// CFPController::OnMouseLKeyUp, the last part: a tap on the scene when no interaction is under the cursor and no item is on the cursor. At the
-// edge of the screen the hero goes to the border of the scene (CheckBorders, MoveBorders), else to the point, when it is more than 30 pixels
-// from the last target (CFPController::MctlStartMove with fuzzy 0, the motion controller decides what is reachable).
-bool FPController::onTapWalk(float x, float y) {
- MotionController *controller = _scene->_motionController.get();
- // CFPController::OnMouseLKeyUp: the walk to the touch point is only done when no object is in the cursor (CCursorController +88); the item of a drop that is
- // refused goes back to the bar and Dude stays
- if (_swiped || !controller || !controller->_isEnabled || g_ngi->_inputController->getObjectId() || _interactObjectId)
- return false;
- if (checkBorders(x, y) != 0)
- return moveBorders(x, y);
- if (fabsf(x - _lastTargetX) > 30.0f || fabsf(y - _lastTargetY) > 30.0f)
- return mctlStartMove((int)x, (int)y, false, 0, false) != nullptr;
- return false;
+void FPController::setFollowHero(bool follow) {
+ _follow = follow ? hero() : nullptr;
}
-// CFPController::OnMouseLKeyUp, the first part: after a drag of the scene beyond 5 pixels the hero is sent to the point at the end of the scene
-// (CalcFinPoint, TrySwipeMan); the touch is over. The result is true when the touch was a scroll or a swipe, so no tap follows.
-bool FPController::onMouseLKeyUpSwipe(float x, float y) {
+// CFPController::OnMouseLKeyUp (14F08C); the item_*_fail_used analytics events are not ported
+bool FPController::onMouseLKeyUp(uint32 id, float x, float y) {
+ CursorController *cursor = g_ngi->_inputController;
+ InteractionController *interactions = getGameLoaderInteractionController();
bool handled = false;
if (canSwipeMan(x, y)) {
- if (_follow != hero() || _smooth || g_ngi->_currSelectedInventoryItemId) {
+ if (id == 100 || _follow != hero() || _smooth || cursor->getObject()) {
handled = false;
} else {
if (fabsf(_touchStartCameraX - _scene->_x) > 5.0f && !_interactObjectId) {
@@ -862,24 +862,47 @@ bool FPController::onMouseLKeyUpSwipe(float x, float y) {
}
_touching = false;
_dragged = false;
- return handled;
-}
-void FPController::setFollowHero(bool follow) {
- _follow = follow ? hero() : nullptr;
+ // the lift panel (the original: in the controllers of the scenes with a lift, after this)
+ if (!_swiped && !handled && tapOnLift(x, y))
+ return true;
+
+ MotionController *controller = _scene->_motionController.get();
+ if (!_swiped && !handled && controller && controller->_isEnabled) {
+ if (!cursor->getObject()) {
+ Interact *underCursor = interactions->findInteractionUnderCursor();
+ if (!underCursor && !_interactObjectId) {
+ if (checkBorders(x, y) != 0) {
+ handled = moveBorders(x, y);
+ } else if (fabsf(x - _lastTargetX) > 30.0f || fabsf(y - _lastTargetY) > 30.0f) {
+ handled = mctlStartMove((int)x, (int)y, false, 0, false) != nullptr;
+ }
+ }
+ debugC(1, kDebugInfo, "INFO t %u TAP %d,%d: interaction under the cursor %s, the interaction that runs %d, handled %d", g_system->getMillis(), (int)x, (int)y,
+ underCursor ? underCursor->_actionName.c_str() : "none", _interactObjectId, handled);
+ }
+ }
+
+ GameObject *interactHit = cursor->getInteractHitObject();
+ if ((interactHit ? interactHit->_id : 0) == _interactObjectId)
+ handled = true;
+
+ if (GameObject *hit = cursor->getHitObject()) {
+ if (interactions->isAnyInteraction(_scene, (uint16)hit->_id) && !interactions->findInteractionUnderCursor()) {
+ debugC(1, kDebugInfo, "INFO t %u INTERACTION refused: item %d at %d,%d, the object %d has interactions but none runs with it (statistics of the original not ported)",
+ g_system->getMillis(), cursor->getObjectId(), (int)x, (int)y, hit->_id);
+ }
+ }
+ return handled;
}
-// CFPController::OnMouseLKeyUp: the swipe part, then the tap (the scene controllers that react to the tap before the hero walks do so between
-// the two: ADAPTATION, in the original the tap is a part of this function and the scene controller runs after the base call)
-bool FPController::onMouseLKeyUp(uint32 id, float x, float y) {
- if (onMouseLKeyUpSwipe(x, y))
- return true;
- return onTap(x, y);
+// CLift::OnButtonUp for all scenes (the original: the controllers of the scenes with a lift)
+bool FPController::tapOnLift(float x, float y) {
+ GameObject *target = _scene->findGameObjectAtPos((int)x, (int)y);
+ return target && g_ngi->isAndroidFullPipe() && (target->_id == ANI_LIFT || (target->_id >= 23116 && target->_id <= 23125)) && g_ngi->lift().onButtonUp(target);
}
-// CFPController::OnMessage. Ported: the messages of the lift (CLift), MSG_SET_SAVING (CBaseSettings::SetSaving is a STUB) and the lift part of MSG_RESETDEST.
-// Ported: INVENTORY_ITEM_IN_CURSOR / FROM_CURSOR, INTERACT_PRESTART / ENDED. Not ported: the rest of MSG_RESETDEST (the hero's queue), INVENTORY_ITEM_INC / DEC_COUNTER,
-// INTERACT_STARTED, CHEATER_*, the tutorial and the other messages.
+// CFPController::OnMessage; not ported: INVENTORY_ITEM_INC / DEC_COUNTER, CHEATER_*, the tutorial
void FPController::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
if (message == "MSG_LIFT_CLICKBUTTON") {
g_ngi->lift().onClickButton();
@@ -917,6 +940,8 @@ void FPController::onMessage(const Common::String &message, const Common::String
onItemInCursor(param);
} else if (message == "INVENTORY_ITEM_FROM_CURSOR") {
onItemFromCursor(param);
+ } else if (message == "INTERACT_STARTED") {
+ onInteractStarted(param, queue);
} else if (message == "INTERACT_PRESTART") {
onInteractPrestart();
} else if (message == "INTERACT_ENDED") {
@@ -934,8 +959,7 @@ void FPController::onItemInCursor(const Common::String &itemId) {
_itemInCursorId = (uint16)item->_picture->_id;
}
-// CFPController::OnItemFromCursor (149BD8): the item shows again, unless an interaction that started with it is still running (INTERACT_PRESTART).
-// The analytics counter "failcount" (CFlurryEventManager::IncAdditonalParam) is not ported.
+// CFPController::OnItemFromCursor (149BD8); the analytics counter "failcount" is not ported
void FPController::onItemFromCursor(const Common::String &itemId) {
InventoryItem *item = g_ngi->_inventory->getItemByName(itemId);
if (_itemInCursorId != _interactItemId) {
@@ -943,11 +967,6 @@ void FPController::onItemFromCursor(const Common::String &itemId) {
item->setState(0);
_itemInCursorId = _interactItemId;
}
- static bool warned = false;
- if (!warned) {
- warned = true;
- warning("STUB/untested: INTERACT_PRESTART and INTERACT_ENDED are not posted by the interactions (CInteract::Run, the end of its queue): the item shows in the bar again as soon as it leaves the cursor");
- }
}
// CFPController::OnInteractPrestart (14B500)
@@ -972,16 +991,137 @@ void FPController::onInteractEnded(const Common::String &interactionId, MessageQ
}
}
-// CInteractionController::FindInteractionUnderCursor (106D94): FindInteraction over the objects under the cursor (the lowest z first) with the item that it holds
-bool FPController::hasInteractionUnderCursor() const {
- CursorController *cursor = g_ngi->_inputController;
- Scene *scene = g_ngi->getSceneInStack(0);
- const int heldItem = cursor->getObjectId();
- for (GameObject *object : cursor->getHitObjects(scene)) {
- if (canInteractAny(g_ngi->_aniMan, object, heldItem))
- return true;
+// CFPController::OnInteractStarted (14CA94); the analytics parameter "action_time" is not ported
+void FPController::onInteractStarted(const Common::String &interactionId, MessageQueue *queue) {
+ Interact *interact = getGameLoaderInteractionController()->findInteractionByName(interactionId);
+ if (!interact || !queue || !interact->_heroId)
+ return;
+
+ int nextIndex = queue->getCurCommandNum() + 1;
+ if (nextIndex > 0) {
+ const Command *current = queue->getCurCommand();
+ if (current && current->_args.getValOrDefault("type") == "GO_MCTL")
+ nextIndex = queue->getCurCommandNum();
}
- return false;
+ Command *goMctl = nextIndex < (int)queue->getCount() ? queue->getCommandByIndex(nextIndex) : nullptr;
+ const Common::Point heroPos = interact->getHeroPos();
+ if (!goMctl || goMctl->_args.getValOrDefault("type") != "GO_MCTL") {
+ goMctl = new Command(0, kCmdUser, 0, 0, 0, 0, 1, 0, 0, 0);
+ goMctl->_messageName = "GO_MCTL";
+ goMctl->_args["type"] = "GO_MCTL";
+ goMctl->_excFlags = 2;
+ queue->addCommand(nextIndex, goMctl);
+ }
+ goMctl->setParamFloat("x", heroPos.x);
+ goMctl->setParamFloat("y", heroPos.y);
+ goMctl->_args["stat"] = Common::String::format("%d", interact->_heroStaticId);
+ goMctl->_args["mirror"] = interact->_heroMirror ? "true" : "false";
+
+ if (_interactionQueue)
+ _interactionQueue->interrupt(false);
+ _interactionQueue = queue;
+ GameObject *object = interact->getObject();
+ _interactObjectId = object ? object->_id : 0;
+ g_ngi->_noActionLogger->_time = 0;
+ debugC(1, kDebugInfo, "INFO t %u INTERACTION %s started: the hero goes to %d,%d (statics %d), queue %d", g_system->getMillis(), interactionId.c_str(), heroPos.x, heroPos.y,
+ interact->_heroStaticId, queue->_id);
+}
+
+// CFPController::ExecCmdMctl (14936C)
+void FPController::execCmdMctl(Command *cmd, MessageQueue *queue) {
+ const float x = cmd->getParamFloat("x", 0.0f);
+ const float y = cmd->getParamFloat("y", 0.0f);
+ AniObject *man = hero();
+ if (!(x == _lastTargetX && y == _lastTargetY)) {
+ if (man->_queue)
+ man->_queue->setIntState(0);
+ const int staticsId = atoi(cmd->_args.getValOrDefault("stat", "0").c_str());
+ const bool mirror = boolParam(cmd, "mirror");
+ MessageQueue *started = mctlStartMove((int)x, (int)y, true, staticsId, mirror);
+ if (started) {
+ if (started->getCurCommandNum() + 1 != 0)
+ return;
+ } else {
+ if (fabsf(x - man->getCenter().x) > 1.0f) {
+ queue->stop(false);
+ return;
+ }
+ if (fabsf(y - man->getCenter().y) > 1.0f) {
+ queue->stop(false);
+ return;
+ }
+ }
+ }
+ man->setQueue(_interactionQueue);
+ if (man->_queue)
+ man->_queue->setIntState(2);
+ _walkQueue = nullptr;
+}
+
+// CFPController::UpdateCmdMctl (148EC8)
+bool FPController::updateCmdMctl() {
+ if (!_walkQueue)
+ return false;
+ if (_walkQueue->getCurCommandNum() == -1) {
+ hero()->setQueue(_interactionQueue);
+ if (_interactionQueue && hero()->_queue)
+ hero()->_queue->setIntState(2);
+ return false;
+ }
+ return true;
+}
+
+// CFPController::ExecCmdMouse (14B3C0)
+void FPController::execCmdMouse(Command *cmd, MessageQueue *queue) {
+ CursorController *cursor = g_ngi->_inputController;
+ GameObject *oldObject = cursor->getObject();
+ const float oldX = cursor->_hotSceneX;
+ const float oldY = cursor->_hotSceneY;
+ const int oldScrollX = _scene->_x;
+ const int oldScrollY = _scene->_y;
+
+ Scene *inventoryScene = g_ngi->findScene(SC_INV);
+ PictureObject *picture = inventoryScene ? inventoryScene->findPictureObjectById(atoi(cmd->_args.getValOrDefault("obj", "0").c_str()), 0) : nullptr;
+ cursor->setObject(picture, 0, 0);
+ if (hero()->_queue)
+ hero()->_queue->setIntState(1);
+ _walkQueue = nullptr;
+ _scene->_x = (int)cmd->getParamFloat("scroll_x", 0.0f);
+ _scene->_y = (int)cmd->getParamFloat("scroll_y", 0.0f);
+ const float x = cmd->getParamFloat("x", 0.0f);
+ const float y = cmd->getParamFloat("y", 0.0f);
+ cursor->setCursorPos(x, y);
+ _scene->onMouseLKeyUp(atoi(cmd->_args.getValOrDefault("key", "0").c_str()), x, y);
+ cursor->setObject(oldObject, 0, 0);
+ cursor->setCursorPos(oldX, oldY);
+ _scene->_x = oldScrollX;
+ _scene->_y = oldScrollY;
+}
+
+// CFPController::RunInteractionWithMouse (14D5E0)
+void FPController::runInteractionWithMouse(const Common::String &interactionId, float x, float y) {
+ Interact *interact = getGameLoaderInteractionController()->findInteractionByName(interactionId);
+ if (!interact)
+ return;
+ GameObject *object = interact->getObject();
+ const int objectId = object ? object->_id : 0;
+ if (objectId == _interactObjectId)
+ return;
+ _interactObjectId = objectId;
+ if (hero()->_queue)
+ hero()->_queue->stop(false);
+ hero()->stopMovement();
+ MessageQueue *queue = _scene->addInteractionQueue(interact->_messageQueue, interact);
+ Command *started = new Command(0, kCmdMessage, 0, 0, 0, 0, 0, 0, 0, 0);
+ started->_messageName = "INTERACT_STARTED";
+ started->_args["msg"] = "INTERACT_STARTED";
+ started->_args["param"] = interactionId;
+ started->_excFlags = 2;
+ queue->addCommand(0, started);
+ // CFPController::CreateMouseCommand
+ queue->addCommandToEnd(createMouseCommand(_scene, x, y, g_ngi->_inputController->getObjectId()));
+ hero()->setQueue(queue);
+ queue->run(2);
}
// CFPController::OnRender (14B704)
@@ -1037,19 +1177,16 @@ void FPController::onGuiEvent(const Common::String &id, const Common::String &ev
}
}
-// CFPController::UpdateUserCmd: SET_SCROLL waits until the camera is there; GO_MCTL (UpdateCmdMctl) is not ported yet
+// CFPController::UpdateUserCmd
bool FPController::updateUserCmd(Command *cmd, uint32 elapsed) {
const Common::String type = cmd->_args.getValOrDefault("type");
if (type == "GO_MCTL")
- warning("STUB/untested: CFPController::UpdateCmdMctl");
+ return updateCmdMctl();
if (type == "SET_SCROLL")
return updateCmdScroll(cmd);
return false;
}
-// CFPController::OnMouseLKeyUp (a tap) of every scene of an XML project: an interaction of the object under the finger, else the hero
-// walks to the point. The scene 1 queue and the upper pipe of scene 1 are the only scene specific parts. ADAPTATION: the original finds
-// the interaction with CInteractionController::FindInteraction and starts it with CInteract::Run (RunInteractionWithMouse).
uint32 random31() {
return g_ngi->_rnd.getRandomNumber(0x7FFFFFFF);
}
@@ -1063,7 +1200,7 @@ int scaledRandom(int n) {
int FPController::getCursorType(float x, float y) {
// the original's end replaces what the borders and object helpers said before
if (g_ngi->_inputController->getObject())
- return hasInteractionUnderCursor() ? 102 : 101;
+ return getGameLoaderInteractionController()->findInteractionUnderCursor() ? 102 : 101;
static bool reported = false;
if (!reported) {
reported = true;
@@ -1072,58 +1209,6 @@ int FPController::getCursorType(float x, float y) {
return -1;
}
-bool FPController::onTap(float tapX, float tapY) {
- Scene &scene = *_scene;
- AniObject *hero = g_ngi->_aniMan;
- // CFPController::OnMouseLKeyUp does not look at the queue of the hero: the walk interrupts it when it can be interrupted (MctlStartMove, CanInterruptManQueue)
- if (!hero || !scene._motionController) {
- debugC(1, kDebugInfo, "INFO t %u TAP %d,%d ignored: hero %p motion controller %p", g_system->getMillis(), (int)tapX, (int)tapY, (void *)hero, (void *)scene._motionController.get());
- return false;
- }
- const Common::Point pos(tapX, tapY);
- PictureObject *picture = scene.findPictureObjectAtPos(pos.x, pos.y);
- AniObject *actor = scene.findAniObjectAtPos(pos.x, pos.y);
- GameObject *target = scene.findGameObjectAtPos(pos.x, pos.y);
- debugC(2, kDebugSceneLogic, "FPController::onTap: %d,%d picture %d (z %d) actor %d (z %d)", pos.x, pos.y, picture ? picture->_id : 0, picture ? picture->_z : 0,
- actor ? actor->_id : 0, actor ? actor->_z : 0);
- // CLift::OnButtonUp: the lift door and the areas GD_SC3_LIFT ... GD_SC38_LIFT open the panel of the lift buttons
- if (target && g_ngi->isAndroidFullPipe() && (target->_id == ANI_LIFT || (target->_id >= 23116 && target->_id <= 23125)) && g_ngi->lift().onButtonUp(target))
- return true;
-
- const int exactId = target ? target->_id : 0;
- // CInteractionController::FindInteractionUnderCursor looks at the objects under the finger that take hits (the flag 2), the lowest z first: the pressed
- // arrow of an exit is not one of them, the object below it is
- {
- const int heldItem = g_ngi->_inputController->getObjectId();
- Common::String hits;
- for (GameObject *object : g_ngi->_inputController->getHitObjects(&scene)) {
- const bool can = canInteractAny(hero, object, heldItem);
- if (heldItem)
- hits += Common::String::format(" %d(z %d%s)", object->_id, object->_z, can ? " can" : "");
- if (can) {
- target = object;
- break;
- }
- }
- // --debugflags=info: what a drop of an item meets (the objects at the hot spot of the cursor, the object at the exact point)
- if (heldItem)
- debugC(1, kDebugInfo, "INFO t %u TAP %d,%d with item %d: the object at the point %d, the hit objects:%s, the target %d", g_system->getMillis(), pos.x, pos.y, heldItem, exactId,
- hits.c_str(), target ? target->_id : 0);
- }
-
- if (target) {
- uint32 upperPipe;
- if (g_ngi->_gameProject->_objectIds.findId("PIC_SC1_UTRUBA", upperPipe) && upperPipe == (uint16)target->_id)
- target = scene.findPictureObjectById(PIC_SC1_LADDER, 0);
- const int item = g_ngi->_inputController->getObjectId();
- debugC(2, kDebugSceneLogic, "FPController::onTap: target %d item %d can interact %d", target ? target->_id : 0, item, target ? canInteractAny(hero, target, item) : 0);
- if (target && canInteractAny(hero, target, item)) {
- return handleObjectInteraction(hero, target, item);
- }
- }
- return onTapWalk(pos.x, pos.y);
-}
-
// CFPController::OnRenderBottom
void FPController::onRenderBottom(Common::Point) {
if (g_ngi->_tremble)
@@ -1137,20 +1222,16 @@ bool FPController::onMouseMove(uint32 id, float x, float y) {
return false;
}
-// CFPController::IsNeedReact (14B538). Not ported: CFPController::GetCursorType (D11), the second way of the original to say that the point reacts
-// (cursor type 1), and CScene::GetVisObjVHitInteract (the first of the hit objects stands for it)
+// CFPController::IsNeedReact (14B538); the cursor type map of the objects is not ported (D11)
bool FPController::isNeedReact(float x, float y) {
if (g_ngi->_inputController->getObject() || !canInterruptManQueue())
return false;
- const Common::Array<GameObject *> &hits = g_ngi->_inputController->getHitObjects(_scene);
- const int hitId = hits.empty() ? 0 : hits.back()->_id;
- if (_interactObjectId == hitId)
+ GameObject *hit = _scene->getVisObjVHitInteract(x, y);
+ if (_interactObjectId == (hit ? hit->_id : 0))
return false;
- for (GameObject *object : hits) {
- if (canInteractAny(hero(), object, 0))
- return true;
- }
- return false;
+ if (!getGameLoaderInteractionController()->findInteraction(x, y) && getCursorType(x, y) != 1)
+ return false;
+ return getCursorTypeTop(x, y) != 0;
}
// CFPController::OnMouseLKeyUpTop; ANI_REACT is added at first use (original: OnSceneInit)
diff --git a/engines/ngi/fullpipe/fpcontroller.h b/engines/ngi/fullpipe/fpcontroller.h
index 8c488117871..f4dbee74f96 100644
--- a/engines/ngi/fullpipe/fpcontroller.h
+++ b/engines/ngi/fullpipe/fpcontroller.h
@@ -49,7 +49,7 @@ public:
void onRenderBottom(Common::Point scroll) override;
void onRenderTop(Common::Point scroll) override;
bool onMouseLKeyDown(uint32 id, float x, float y) override;
- /** The swipe part of CFPController::OnMouseLKeyUp, then the tap (onTap) unless the touch was a swipe or a scroll */
+ /** CFPController::OnMouseLKeyUp (14F08C): swipe, then the tap; true when handled */
bool onMouseLKeyUp(uint32 id, float x, float y) override;
/** CFPController::OnMouseMove and OnMouseLKeyUpTop: the exits */
bool onMouseMove(uint32 id, float x, float y) override;
@@ -58,8 +58,6 @@ public:
bool updateUserCmd(Command *cmd, uint32 elapsed) override;
bool isInventoryEnabled() override { return true; }
bool isInventoryRendered() override { return true; }
- /** The tap of CFPController::OnMouseLKeyUp (position in scene coordinates): an interaction of the object under the finger, else the hero walks to the point */
- bool onTap(float x, float y);
// virtual methods that CFPController adds (vtable slots from 0x2DE258)
virtual bool canShowHelp() { return true; }
@@ -88,8 +86,14 @@ public:
AniObject *_react = nullptr;
/** CFPController::CheckInvItem (14B5B8): the "<item>_H" outline where the cursor item fits */
void checkInvItem();
- /** CInteractionController::FindInteractionUnderCursor (106D94): an interaction of the hero, the item of the cursor and one of the objects under it */
- bool hasInteractionUnderCursor() const;
+ /** CFPController::OnInteractStarted (14CA94): puts GO_MCTL into the queue */
+ void onInteractStarted(const Common::String &interactionId, MessageQueue *queue);
+ /** CFPController::ExecCmdMctl (14936C), UpdateCmdMctl (148EC8): GO_MCTL walks the hero */
+ void execCmdMctl(Command *cmd, MessageQueue *queue);
+ bool updateCmdMctl();
+ /** CFPController::ExecCmdMouse (14B3C0), RunInteractionWithMouse (14D5E0) */
+ void execCmdMouse(Command *cmd, MessageQueue *queue);
+ void runInteractionWithMouse(const Common::String &interactionId, float x, float y);
/** CFPController::OnItemInCursor (149478): the bar item goes to state 1 */
void onItemInCursor(const Common::String &itemId);
/** INVENTORY_ITEM_FROM_CURSOR (CFPController::OnItemFromCursor, 149BD8) */
@@ -124,6 +128,8 @@ public:
void checkQueues();
bool canInterruptManQueue() const;
bool moveBorders(float x, float y);
+ /** Tap on the lift door or its areas opens the button panel (CLift::OnButtonUp in the original) */
+ bool tapOnLift(float x, float y);
void calcFinPoint(float &x, float &y);
void initBorders();
/** CFPController::MctlStartMove */
@@ -141,11 +147,6 @@ public:
bool wasDragged() const { return _dragged; }
protected:
- /** The swipe part of CFPController::OnMouseLKeyUp: true when the touch was a swipe or a scroll and must not be handled as a tap */
- bool onMouseLKeyUpSwipe(float x, float y);
- /** The last part of the tap: the hero walks */
- bool onTapWalk(float x, float y);
-
AniObject *hero() const;
float cursorX() const;
float cursorY() const;
diff --git a/engines/ngi/fullpipe/sc01controller.cpp b/engines/ngi/fullpipe/sc01controller.cpp
index 3f1686f6d9a..884277d149f 100644
--- a/engines/ngi/fullpipe/sc01controller.cpp
+++ b/engines/ngi/fullpipe/sc01controller.cpp
@@ -23,6 +23,7 @@
#include "ngi/behavior.h"
#include "ngi/gfx.h"
#include "ngi/guimanager.h"
+#include "ngi/gameloader.h"
#include "ngi/input.h"
#include "ngi/interaction.h"
#include "ngi/inventory.h"
@@ -73,7 +74,8 @@ void Sc01Controller::onUTrubaClick() {
if (!canInterruptManQueue())
return;
if (_interactObjectId == 0 || _interactObjectId != PIC_SC1_LADDER) {
- warning("STUB/untested: CSc01Controller::OnUTrubaClick: CInteractionController::FindInteraction(scene, object, -1) and CInteract::Run are not ported (D17)");
+ if (Interact *interact = getGameLoaderInteractionController()->findInteraction(_scene, PIC_SC1_LADDER, -1))
+ interact->run(_scene);
}
}
diff --git a/engines/ngi/fullpipe/sc02controller.cpp b/engines/ngi/fullpipe/sc02controller.cpp
index 5b516574e90..f6f5148043c 100644
--- a/engines/ngi/fullpipe/sc02controller.cpp
+++ b/engines/ngi/fullpipe/sc02controller.cpp
@@ -23,6 +23,7 @@
#include "ngi/behavior.h"
#include "ngi/gfx.h"
#include "ngi/guimanager.h"
+#include "ngi/gameloader.h"
#include "ngi/input.h"
#include "ngi/interaction.h"
#include "ngi/inventory.h"
@@ -68,14 +69,15 @@ bool Sc02Controller::isInventoryEnabled() {
return g_ngi->_tutorialManager->isTutorialCompleted();
}
-// CSc02Controller::OnClickLadder (163168): when the hero can take a new queue and the interaction under the cursor is not the one of the lower pipe, the
-// interaction of the lower pipe (CInteractionController::FindInteraction(scene, PIC_SC2_DTRUBA, -1)) runs (CInteract::Run). Not ported: running an interaction by
-// its object (the engine starts them through handleObjectInteraction by the tap)
+// CSc02Controller::OnClickLadder (163168): runs the lower pipe interaction (PIC_SC2_DTRUBA)
+// when the hero can take a queue and the interaction under the cursor is not it
void Sc02Controller::onClickLadder() {
if (!canInterruptManQueue())
return;
- if (_interactObjectId == 0 || _interactObjectId != PIC_SC2_DTRUBA)
- warnOnce("CSc02Controller::OnClickLadder: CInteractionController::FindInteraction(scene, PIC_SC2_DTRUBA, -1) and CInteract::Run are not ported");
+ if (_interactObjectId == 0 || _interactObjectId != PIC_SC2_DTRUBA) {
+ if (Interact *interact = getGameLoaderInteractionController()->findInteraction(_scene, PIC_SC2_DTRUBA, -1))
+ interact->run(_scene);
+ }
}
// CSc02Controller::OnShow (1631A0): visit the scene, camera, Guv, ladder, box, flies, then the
@@ -185,11 +187,10 @@ void Sc02Controller::onMessage(const Common::String &message, const Common::Stri
}
}
-// CSc02Controller::OnMouseLKeyUp (1635A8): while the egg interaction INT_418 runs the touches are ignored (it starts when the interaction under the cursor is
-// INT_418), and after the tutorial of the egg the touch goes nowhere. Not ported: CInteractionController::FindInteractionUnderCursor (the interaction INT_418
-// never starts the flag here)
+// CSc02Controller::OnMouseLKeyUp (1635A8): touches are ignored while the egg interaction
+// INT_418 runs, and after the egg tutorial the touch goes nowhere
bool Sc02Controller::onMouseLKeyUp(uint32 id, float x, float y) {
- Interact *underCursor = NGI::findInteractionUnderCursor();
+ Interact *underCursor = getGameLoaderInteractionController()->findInteractionUnderCursor();
if (_eggInteracting)
return true;
if (underCursor && underCursor->_actionName == "INT_418")
diff --git a/engines/ngi/fullpipe/sc03controller.cpp b/engines/ngi/fullpipe/sc03controller.cpp
index 580f5f64a8a..e5e6e7b6a2d 100644
--- a/engines/ngi/fullpipe/sc03controller.cpp
+++ b/engines/ngi/fullpipe/sc03controller.cpp
@@ -178,9 +178,8 @@ void Sc03Controller::onUTrubaClick() {
return;
if (_interactObjectId == PIC_SC3_LADDER)
return;
- // CInteractionController::FindInteraction(scene, PIC_SC3_LADDER, -1) and CInteract::Run are done by handleObjectInteraction of the Windows-derived engine
- warnOnce("CSc03Controller::OnUTrubaClick: the interaction with the ladder is run by handleObjectInteraction (CInteractionController::FindInteraction, CInteract::Run) (D17)");
- handleObjectInteraction(hero(), _scene->findPictureObjectById(PIC_SC3_LADDER, 0), 0);
+ if (Interact *interact = getGameLoaderInteractionController()->findInteraction(_scene, PIC_SC3_LADDER, -1))
+ interact->run(_scene);
}
// CSc03Controller::GetFirstEaten (163768)
diff --git a/engines/ngi/fullpipe/sc04controller.cpp b/engines/ngi/fullpipe/sc04controller.cpp
index 87147a2d759..fc0ed515558 100644
--- a/engines/ngi/fullpipe/sc04controller.cpp
+++ b/engines/ngi/fullpipe/sc04controller.cpp
@@ -1806,14 +1806,12 @@ void Sc04Controller::updateScroll() {
FPController::updateScroll();
}
-// CSc04Controller::OnMouseLKeyUp: the ladder, the plank and the hero on the ladder, between the swipe and the tap of the base class
-// (ADAPTATION: in the original the base call comes first and includes the tap, see FPController::onMouseLKeyUp)
+// CSc04Controller::OnMouseLKeyUp: base first, then ladder, plank, hero on the ladder. Not ported:
+// jump from the bottle (+654), exit 0x59E at 180 degrees (Windows scene04_click does them)
bool Sc04Controller::onMouseLKeyUp(uint32 id, float x, float y) {
- if (onMouseLKeyUpSwipe(x, y))
- return true;
- if (scene04_click(Common::Point(x - _scene->_x, y - _scene->_y)))
+ if (FPController::onMouseLKeyUp(id, x, y))
return true;
- return onTap(x, y);
+ return scene04_click(Common::Point(x - _scene->_x, y - _scene->_y));
}
// CSc04Controller::SkipArcade (skip button): the Windows handler logic (scene04_skipArcade)
diff --git a/engines/ngi/fullpipe/sc06controller.cpp b/engines/ngi/fullpipe/sc06controller.cpp
index 008f6da8e23..0bc381b54f1 100644
--- a/engines/ngi/fullpipe/sc06controller.cpp
+++ b/engines/ngi/fullpipe/sc06controller.cpp
@@ -68,11 +68,9 @@ int getCurCommandNum(const MessageQueue *queue) {
return -1;
}
-// CInteractionController::FindInteraction(name) and CMessageQueue +56 of its queue (the number of the command that runs, -1 before the interaction starts):
-// the engine has no interactions by name and runs copies of their queues
+// CInteractionController::FindInteraction(name), CMessageQueue +56 (current command)
int getInteractionCurCommandNum(const char *name) {
- warnOnce("CSc06Controller::OnMessage MSG_BREAK_GRIT: CInteractionController::FindInteraction by name (INT_277, INT_229) and the command number of its queue");
- return -1;
+ return interactionCommandNum(name);
}
// sc_6_settings.xml (CSc06Controller::ReadSettingsXml)
@@ -386,8 +384,8 @@ void Sc06Controller::onUTrubaClick() {
if (_interactObjectId == PIC_SC6_LADDER)
return;
if (getGameLoaderInteractionController()->_enabled) {
- // CInteractionController::FindInteraction(scene, PIC_SC6_LADDER, -1) and CInteract::Run(scene)
- warnOnce("CSc06Controller::OnUTrubaClick: CInteract::Run (the interaction with the ladder PIC_SC6_LADDER is not run)");
+ if (Interact *interact = getGameLoaderInteractionController()->findInteraction(_scene, PIC_SC6_LADDER, -1))
+ interact->run(_scene);
}
}
diff --git a/engines/ngi/fullpipe/sc08controller.cpp b/engines/ngi/fullpipe/sc08controller.cpp
index a7d7ab2df9e..468763bf4ea 100644
--- a/engines/ngi/fullpipe/sc08controller.cpp
+++ b/engines/ngi/fullpipe/sc08controller.cpp
@@ -747,10 +747,8 @@ void Sc08Controller::onMessage(const Common::String &message, const Common::Stri
if (box)
box->_flags &= ~4;
} else if (message == "MSG_BREAK_GRIT") {
- // the grit breaks once the queue of INT_299 has started: CInteractionController::FindInteraction("INT_299")'s queue +56 (CMessageQueue::GetCurCommandNum) != -1.
- // The interaction is not found by name here and the queue has no command number, so the condition is false.
- warnOnce("CSc08Controller::OnMessage MSG_BREAK_GRIT: FindInteraction of INT_299 and the command number of its queue are not ported");
- const bool queueStarted = false;
+ // the grit breaks once the queue of INT_299 has started (its CMessageQueue +56 is not -1)
+ const bool queueStarted = interactionCommandNum("INT_299") != -1;
if (queueStarted) {
AniObject *grit = _scene->findAniObjectById(ANI_GRIT2, 0);
if (grit->_movement)
diff --git a/engines/ngi/fullpipe/sc14controller.cpp b/engines/ngi/fullpipe/sc14controller.cpp
index 43549b69c9a..050bfbb7873 100644
--- a/engines/ngi/fullpipe/sc14controller.cpp
+++ b/engines/ngi/fullpipe/sc14controller.cpp
@@ -53,20 +53,18 @@ void stopQueue(MessageQueue *) {
warnOnce("CMessageQueue::Stop: the queue is not stopped (CSc14Controller::DoWinArcade, CSc14Controller::DoManSurrender)");
}
-// CInteractionController::FindInteraction(scene, objectId, -1) and CInteract::Run(scene): the engine finds the interaction with the object, it has no
-// CInteract::Run (handleObjectInteraction also walks the hero, which Run does not do), so it is not run. True when the interaction was found.
-bool runInteraction(int objectId) {
- Interact *interaction = getGameLoaderInteractionController()->findInteraction(objectId, 0, 0);
+// CInteractionController::FindInteraction(scene, objectId, -1) + CInteract::Run: true if found
+bool runInteraction(Scene *scene, int objectId) {
+ Interact *interaction = getGameLoaderInteractionController()->findInteraction(scene, objectId, -1);
if (!interaction)
return false;
- warnOnce("CInteract::Run: the interaction of the object is found but not run (CSc14Controller)");
+ interaction->run(scene);
return true;
}
// CInteractionController::FindInteraction(name, 0, 0): queue of interaction INT_239 has started
-bool isInteractionQueueRunning(const char *) {
- warnOnce("CSc14Controller::OnMessage MSG_BREAK_GRIT: the state of the queue of the interaction INT_239 is not known");
- return false;
+bool isInteractionQueueRunning(const char *name) {
+ return interactionCommandNum(name) != -1;
}
// sc_14_settings.xml (CSc14Controller::ReadSettingsXml)
@@ -413,7 +411,7 @@ void Sc14Controller::doManSurrender() {
_scene->runQueue(QU_SC14_ENDARCADE, 2);
getGameLoaderInteractionController()->disable();
g_ngi->_hintManager->hideHint(_scene);
- runInteraction(PIC_SC14_RTRUBA);
+ runInteraction(_scene, PIC_SC14_RTRUBA);
setSaving(true);
}
@@ -827,7 +825,7 @@ bool Sc14Controller::onMouseLKeyUp(uint32 id, float x, float y) {
ball->setStatic(ball->_statics->_staticsId, false);
center = _pink->getCenter();
ball->setCenter(center);
- if (runInteraction(_pink->_id))
+ if (runInteraction(_scene, _pink->_id))
return canInterrupt;
return true;
}
Commit: 6d0a69f640f6702e88bd7ca9a5e4fe55f59c3c97
https://github.com/scummvm/scummvm/commit/6d0a69f640f6702e88bd7ca9a5e4fe55f59c3c97
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Tutorial finish runs the rise queue with interrupt state 3
Changed paths:
engines/ngi/fullpipe/tutorialcontroller.cpp
engines/ngi/fullpipe/tutorialcontroller.h
diff --git a/engines/ngi/fullpipe/tutorialcontroller.cpp b/engines/ngi/fullpipe/tutorialcontroller.cpp
index 14b74384ee3..59c91642576 100644
--- a/engines/ngi/fullpipe/tutorialcontroller.cpp
+++ b/engines/ngi/fullpipe/tutorialcontroller.cpp
@@ -306,7 +306,8 @@ void TutorialController::finish() {
Movement *fall = _man->getMovement(MOV_SC_TUTORIAL_BEARDED_FALL);
fall->_loopDelay = 60;
fall->_phases[0]->_delayMs = 0;
- runSceneQueue(queueId);
+ // CMessageQueue::Run(queue, 3): background queue, interactions starting meanwhile do not stop it
+ runSceneQueue(queueId, 3);
}
if (tutorial && tutorial->_id == "TUTORIAL_LAST") {
inventoryController()->setHelperVisible(false);
@@ -316,8 +317,8 @@ void TutorialController::finish() {
}
// CScene::RunQueue of the scene of the controller
-bool TutorialController::runSceneQueue(int queueId) {
- return _scene->runQueue(queueId);
+bool TutorialController::runSceneQueue(int queueId, int interruptState) {
+ return _scene->runQueue(queueId, interruptState);
}
// CTutorialController::OnShow (1A46C8)
@@ -705,7 +706,8 @@ bool TutorialController::passMouseActionsZone(float x, float y, int action) {
// passes when no interaction is under the finger and it is on the motion graph of the scene below
if (g_ngi->_sceneStack.size() < 2)
return false;
- warnOnce("STUB/untested: CTutorialController::PassMouseActions: CInteractionController::FindInteractionUnderCursor is not ported");
+ if (getGameLoaderInteractionController()->findInteractionUnderCursor())
+ return false;
return sceneBelow()->_motionController->checkPoint((int)x, (int)y);
}
// object hit: finger up finishes (CTutorialController::Finish), a touch in the zone passes
diff --git a/engines/ngi/fullpipe/tutorialcontroller.h b/engines/ngi/fullpipe/tutorialcontroller.h
index 2a82bd4cc5e..0b6963a9b98 100644
--- a/engines/ngi/fullpipe/tutorialcontroller.h
+++ b/engines/ngi/fullpipe/tutorialcontroller.h
@@ -104,7 +104,7 @@ private:
float _transmitY = -1; // +84
GameObject *_transmitObject = nullptr; // +88
- bool runSceneQueue(int queueId);
+ bool runSceneQueue(int queueId, int interruptState = 4);
};
} // End of namespace NGI
Commit: 652c4f902cb84f57d53a5a58567bfe99ceeee70e
https://github.com/scummvm/scummvm/commit/652c4f902cb84f57d53a5a58567bfe99ceeee70e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Log the state of Egggulper in the test mode info
Changed paths:
engines/ngi/debugger/testmode.cpp
diff --git a/engines/ngi/debugger/testmode.cpp b/engines/ngi/debugger/testmode.cpp
index 1b7bced6997..2a457177c19 100644
--- a/engines/ngi/debugger/testmode.cpp
+++ b/engines/ngi/debugger/testmode.cpp
@@ -118,6 +118,7 @@ int g_spot = 0;
int g_idleFrames = 0;
uint32 g_elapsed = 0;
uint g_lastHeroState = 0;
+uint g_lastEaterState = 0;
const Spot *findSpot(int sceneId, int spot) {
for (const Spot &candidate : kSpots) {
@@ -243,6 +244,22 @@ void testmode_update(uint32 elapsed) {
g_lastHeroState = stateHash;
debugC(1, kDebugInfo, "INFO f %d t %u scene %d %s", g_frame, g_system->getMillis(), info.sceneId, state.c_str());
}
+
+ // follow the statics of Egggulper: after each egg it must be MID1, MID2, FAT
+ uint32 eaterId = 0;
+ if (g_ngi->_gameProject && g_ngi->_gameProject->_objectIds.findId("ANI_EGGEATER", eaterId)) {
+ const AniObject *eater = g_ngi->_currentScene->findAniObjectById(eaterId, 0);
+ if (eater) {
+ const Common::String eaterState = eater->_movement ? Common::String::format("movement %d %s", eater->_movement->_id, name(eater->_movement->_id).c_str()) :
+ eater->_statics ? Common::String::format("statics %d %s", eater->_statics->_staticsId, name(eater->_statics->_staticsId).c_str()) : Common::String("none");
+ const Common::String line = Common::String::format("%s flags %02x z %d center %d,%d", eaterState.c_str(), eater->_flags, eater->_z, eater->getCenter().x, eater->getCenter().y);
+ const uint eaterHash = Common::hashit(Common::String::format("%s %02x %d", eaterState.c_str(), eater->_flags, eater->_z).c_str());
+ if (eaterHash != g_lastEaterState) {
+ g_lastEaterState = eaterHash;
+ debugC(1, kDebugInfo, "INFO f %d t %u EGGEATER %s", g_frame, g_system->getMillis(), line.c_str());
+ }
+ }
+ }
}
if (g_setupDone && g_nextVisit < g_visits.size()) {
Commit: 966a19203aa606a9061915e5b3c4b7560c581c31
https://github.com/scummvm/scummvm/commit/966a19203aa606a9061915e5b3c4b7560c581c31
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Run XML movements without phases like CAniObject::StartMovement
Changed paths:
engines/ngi/messagehandlers.cpp
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/messagehandlers.cpp b/engines/ngi/messagehandlers.cpp
index b33548e2ac9..e34e631f7a9 100644
--- a/engines/ngi/messagehandlers.cpp
+++ b/engines/ngi/messagehandlers.cpp
@@ -654,8 +654,10 @@ int global_messageHandler4(Command *cmd) {
if (g_ngi->_gameVersion >= 201509) {
// CFPController::ExecCmdToStatic (14917C)
+ debugC(1, kDebugInfo, "INFO t %u MOVE_TO_STATIC %d: the object %d is in the statics %d, goes to %d", g_system->getMillis(), cmd->_messageNum, ani->_id, ani->_statics ? ani->_statics->_staticsId : 0, cmd->_messageNum);
if (cmd->_messageNum)
ani->moveToStaticChain(cmd->_messageNum);
+ debugC(1, kDebugInfo, "INFO t %u MOVE_TO_STATIC: the object %d is now in the statics %d (movement %d)", g_system->getMillis(), ani->_id, ani->_statics ? ani->_statics->_staticsId : 0, ani->_movement ? ani->_movement->_id : 0);
if (cmd->_auxParam)
ani->_flags |= 4;
break;
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index d8455c917b8..16ec8d90953 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -1826,6 +1826,40 @@ bool AniObject::startAnimEx(int movid, int parId, int flag1, int flag2) {
return res;
}
+// CAniObject::StartMovement (F0D46) of a movement without phases (MV_EGTR_0_1): it stops at
+// once, only the end statics and the facing are set (CAniObject::StopMovement F0F28)
+void AniObject::startMovementWithoutPhases(Movement *movement, bool mirror, bool reverse, int startFrame) {
+ if (_movement && (_flags & 1))
+ stopMovementToPrev(false);
+
+ Statics *start = reverse ? movement->_nextStatic : movement->_prevStatic;
+ Statics *end = reverse ? movement->_prevStatic : movement->_nextStatic;
+ const bool startMirror = (reverse ? movement->_mirrorNext : movement->_mirrorPrev) != mirror;
+ if (startFrame == -1 && (_statics != start || ((_flags & 8) != 0) != startMirror))
+ setStatic(start->_staticsId, startMirror);
+ _flags = (_flags & ~8) | (mirror ? 8 : 0);
+
+ // CMovement::Start: the top left moves by the previous step (reverse: the next, negated),
+ // mirrored: x negated, then rotated about the object
+ float dx = reverse ? -movement->_nextStepX * _scaleX : movement->_prevStepX * _scaleX;
+ const float dy = reverse ? -movement->_nextStepY * _scaleY : movement->_prevStepY * _scaleY;
+ if (mirror)
+ dx = -dx;
+ const float c = cosf(_rotation);
+ const float sn = sinf(_rotation);
+ const Common::Point topLeft = getPosition();
+
+ // CAniObject::StopMovement: the end statics and the facing
+ _movement = nullptr;
+ _flags &= ~1;
+ _statics = end;
+ bool endMirror = reverse ? movement->_mirrorPrev : movement->_mirrorNext;
+ if (_flags & 8)
+ endMirror = !endMirror;
+ _flags = (_flags & ~8) | (endMirror ? 8 : 0);
+ setPosition(Common::Point(topLeft.x + (int)(dx * c - dy * sn), topLeft.y + (int)(dx * sn + dy * c)));
+}
+
bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseIdx, bool mirror, bool cycled, bool reverse, int startFrame) {
if (_flags & 0x80)
return false;
@@ -1840,8 +1874,12 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
}
Movement *mov = getMovement(movementId);
- // An XML movement without any PHASE elements contains only its end pose.
- if (!mov || (timedMovement && !mov->getPhase(1))) {
+ if (mov && timedMovement && !mov->getPhase(1)) {
+ // a movement without PHASE elements holds only its end pose, StartMovement still runs it
+ startMovementWithoutPhases(mov, mirror, reverse, startFrame);
+ return false;
+ }
+ if (!mov) {
if (!timedMovement) // the queue sees that the object stands
updateGlobalMessageQueue(messageQueueId, _id);
return false;
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index c2e9ebd4bbc..84f29ce2fcd 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -281,6 +281,7 @@ public:
/** CAniObject::StartMovement (F0D46); cycled, reverse, startFrame are START_MOVEMENT attributes */
bool startMovement(int movementId, int messageQueueId, int dynPhaseIdx, bool mirror = false, bool cycled = false, bool reverse = false, int startFrame = -1);
+ void startMovementWithoutPhases(Movement *movement, bool mirror, bool reverse, int startFrame);
bool startAnimEx(int movid, int parId, int flag1, int flag2);
void startSliding(int movementId, int messageQueueId, int x, int y, const PointList &points, int someDynamicPhaseIndex, bool mirror);
Commit: 84494f486ad1829f9cf09ef3c90fed606d3d4d36
https://github.com/scummvm/scummvm/commit/84494f486ad1829f9cf09ef3c90fed606d3d4d36
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Port CAniHandler::GetNumCycles frame counting
Changed paths:
engines/ngi/anihandler.cpp
diff --git a/engines/ngi/anihandler.cpp b/engines/ngi/anihandler.cpp
index 20cb82d860c..19428b770b2 100644
--- a/engines/ngi/anihandler.cpp
+++ b/engines/ngi/anihandler.cpp
@@ -682,7 +682,21 @@ Common::Point AniHandler::getNumCycles(Movement *mov, int x, int y, int *mult, i
int phase = 1;
int sz;
- if (flag) {
+ if (flag && centered) {
+ // CAniHandler::GetNumCycles (1A816E): stops at the first frame where the center displacement plus
+ // that of the whole cycles (absolute values) reaches the distance; stop = frame before
+ // without the end statics that this engine's movement holds
+ const int phases = (int)(mov->_currMovement ? mov->_currMovement->_phases.size() : mov->_phases.size()) - 1;
+ const bool vertical = abs(p1y) > abs(p1x);
+ int frame = 0;
+ for (;; frame++) {
+ const Common::Point step = size(0, frame);
+ const int part = vertical ? abs(step.y) + abs(p1y * newmult) : abs(step.x) + abs(p1x * newmult);
+ if (part >= (vertical ? abs(y) : abs(x)) || frame >= phases)
+ break;
+ }
+ *len = frame - 1;
+ } else if (flag) {
if (abs(p1y) > abs(p1x)) {
while (abs(p1y * newmult + size(0, phase).y) < abs(y)) {
sz = mov->_currMovement ? mov->_currMovement->_phases.size() : mov->_phases.size();
Commit: 4e1ea92f1faca8fe75317f479c71dc753f0a0b96
https://github.com/scummvm/scummvm/commit/4e1ea92f1faca8fe75317f479c71dc753f0a0b96
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Keep the last started movement id of an animation (CAniObject +168)
Changed paths:
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 16ec8d90953..5e7a4a134d1 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -144,6 +144,7 @@ AniObject::AniObject(AniObject *src) : GameObject(src) {
_movement = nullptr;
_statics = nullptr;
+ _lastMovementId = src->_lastMovementId; // F2818 copies +168
// F2818: the copy keeps the statics of the source
if (g_ngi->_gameVersion >= 201509 && src->_statics)
_statics = getStatic(src->_statics->_staticsId);
@@ -1411,6 +1412,18 @@ void AniObject::setStatic(int objId, bool mirror, bool useMirror) {
}
}
+// CAniObject +168: the last started movement, also when over (first: the lowest id)
+int AniObject::getLastMovementId() const {
+ if (_lastMovementId)
+ return _lastMovementId;
+ int first = 0;
+ for (const Movement *movement : _movements) {
+ if (!first || movement->_id < first)
+ first = movement->_id;
+ }
+ return first;
+}
+
// CAniObject::GetCurFrame (F112C)
int AniObject::getCurFrame() const {
return _movement ? _movement->_curFrame : -1;
@@ -1874,6 +1887,8 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
}
Movement *mov = getMovement(movementId);
+ if (mov && timedMovement)
+ _lastMovementId = movementId; // CAniObject::StartMovement: +168 = the movement
if (mov && timedMovement && !mov->getPhase(1)) {
// a movement without PHASE elements holds only its end pose, StartMovement still runs it
startMovementWithoutPhases(mov, mirror, reverse, startFrame);
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index 84f29ce2fcd..66eec1ba89e 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -214,6 +214,8 @@ class AniObject : public GameObject {
MessageQueue *_queue = nullptr;
int _messageNum;
int _animExFlag;
+ /** CAniObject +168 (_gameVersion >= 201509): the movement started last, kept when it stops */
+ int _lastMovementId = 0;
int _counter;
int _targetFrame;
@@ -317,6 +319,7 @@ public:
void setStatic(int objId, bool mirror, bool useMirror);
/** CAniObject +164: the id of the statics (0 without one) */
int getStaticsId() const { return _statics ? _statics->_staticsId : 0; }
+ int getLastMovementId() const;
/** CAniObject::GetCurFrame (F112C): the frame of the running movement, -1 without one */
int getCurFrame() const;
/** CAniObject::SetCurFrame (F0C76); not modelled: keepPhaseTimer, commands of skipped phases */
Commit: 1f6a3d82bb8a8ee9ee34f30c6427ce69adfc8f51
https://github.com/scummvm/scummvm/commit/1f6a3d82bb8a8ee9ee34f30c6427ce69adfc8f51
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Port CMctlLadder heights, stop and RunQueue, last movement id for the walk direction
Changed paths:
engines/ngi/motion.cpp
diff --git a/engines/ngi/motion.cpp b/engines/ngi/motion.cpp
index 4eb20bf42c3..e36d42c2650 100644
--- a/engines/ngi/motion.cpp
+++ b/engines/ngi/motion.cpp
@@ -396,12 +396,15 @@ int MctlLadder::getCurrentStep(AniObject *man) {
double delta;
- if ((double)(man->_y - _y) / (double)_stepY < 0.0)
+ // CMctlLadder::GetCurrentStep (1AD008): the height is the y of the center
+ const int manY = g_ngi->_gameVersion >= 201509 ? man->getCenter().y : man->_y;
+
+ if ((double)(manY - _y) / (double)_stepY < 0.0)
delta = -0.5;
else
delta = 0.5;
- int res = (int)((double)(man->_y - _y) / (double)_stepY + delta);
+ int res = (int)((double)(manY - _y) / (double)_stepY + delta);
if (res < 0)
return 0;
@@ -502,7 +505,14 @@ void MctlLadder::detachAllObjects() {
MessageQueue *MctlLadder::startMove(AniObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId, bool mirror) {
debugC(4, kDebugPathfinding, "MctlLadder::startMove(*%d, %d, %d, %d, %d)", (subj ? subj->_id : -1), xpos, ypos, fuzzyMatch, staticsId);
- MessageQueue *mq = makeQueue(subj, xpos, ypos, fuzzyMatch, staticsId);
+ MessageQueue *mq = makeQueue(subj, xpos, ypos, fuzzyMatch, staticsId, mirror);
+
+ if (g_ngi->_gameVersion >= 201509) {
+ // CMctlLadder::StartMove (1ACC56): CScene::RunQueue(scene, queue, 2, 1), never interrupted
+ if (mq)
+ g_ngi->getCurrentScene()->runQueueObject(mq, subj, 2);
+ return mq;
+ }
if (mq) {
if (mq->run(subj))
@@ -520,8 +530,16 @@ MessageQueue *MctlLadder::makeQueue(AniObject *ani, int xpos, int ypos, int fuzz
if (pos < 0)
return nullptr;
+ const bool revised = g_ngi->_gameVersion >= 201509;
+ static bool reported = false;
+ if (revised && !reported) {
+ reported = true;
+ warning("STUB/untested: CMctlLadder::MakeQueue / StartMove (the ladder of scene 4) are ported from the decompile (heights from the center, top left for the stop movements, RunQueue(q, 2, 1)) and not played");
+ }
+ // CMctlLadder::MakeQueue (1AD110): every height is the y of the center of the object
+ const int aniY = revised ? ani->getCenter().y : ani->_y;
double dh = _stepY;
- double corr = (double)(ani->_y - _y) / dh;
+ double corr = (double)(aniY - _y) / dh;
int dl = (int)(corr + (corr < 0.0 ? -0.5 : 0.5));
corr = (double)(ypos - _y) / dh;
@@ -533,7 +551,7 @@ MessageQueue *MctlLadder::makeQueue(AniObject *ani, int xpos, int ypos, int fuzz
if (dl == dl2 || dl2 < 0)
return nullptr;
- int direction = (normy - ani->_y) < 0 ? 0 : 1;
+ int direction = (normy - aniY) < 0 ? 0 : 1;
MakeQueueStruct mkQueue;
PicAniInfo picinfo;
@@ -544,9 +562,10 @@ MessageQueue *MctlLadder::makeQueue(AniObject *ani, int xpos, int ypos, int fuzz
if (ani->_movement) {
ani->getPicAniInfo(picinfo);
- if (g_ngi->_gameVersion >= 201509) {
- // CMctlLadder::MakeQueue: CAniObject::StopMovement(false), the movement is cut at its current phase
- ani->updateStepPos();
+ if (revised) {
+ // CMctlLadder::MakeQueue: StopMovement(false) again for the ladder step, no restore
+ ani->stopMovement(false);
+ return makeQueue(ani, normx, normy, fuzzyMatch, staticsId, mirror);
} else {
int ox = ani->_x;
int oy = ani->_y;
@@ -599,8 +618,10 @@ MessageQueue *MctlLadder::makeQueue(AniObject *ani, int xpos, int ypos, int fuzz
return _aniHandler.makeRunQueue(&mkQueue);
}
- int ox = ani->_x;
- int oy = ani->_y;
+ // CMctlLadder::MakeQueue reads +40, +44 (top left), not the center
+ const Common::Point topLeft = revised ? ani->getPosition() : Common::Point(ani->_x, ani->_y);
+ int ox = topLeft.x;
+ int oy = topLeft.y;
Movement *upStop = ani->getMovement(_ladmovements[pos]->movementIds->upStopId);
point = g_ngi->_gameVersion >= 201509 ? upStop->getCenterMovementSize(0, -1) : upStop->getMovementSize(0, -1); // CMovement::GetMovementSize
@@ -638,6 +659,22 @@ MessageQueue *MctlLadder::makeQueue(AniObject *ani, int xpos, int ypos, int fuzz
if (!mq)
return nullptr;
+ if (revised) {
+ // ladder statics: StopMovement(false), SetStatic(statics, 0), step queue, MergeQueue, restore
+ ani->stopMovement(false);
+ const Common::Point center = ani->getCenter();
+ const int oldStatics = ani->getStaticsId();
+ ani->setStatic(_ladmovements[pos]->staticIds[0], false);
+ MessageQueue *next = makeQueue(ani, normx, normy, fuzzyMatch, staticsId, mirror);
+ if (next) {
+ mq->mergeQueue(next);
+ delete next;
+ }
+ ani->setStatic(oldStatics, false);
+ ani->setCenter(center);
+ return mq;
+ }
+
int nx = ani->_x;
int ny = ani->_y;
@@ -664,8 +701,10 @@ MessageQueue *MctlLadder::makeQueue(AniObject *ani, int xpos, int ypos, int fuzz
}
if (!direction) {
- int nx = ani->_x;
- int ny = ani->_y;
+ // +40, +44
+ const Common::Point topLeft = revised ? ani->getPosition() : Common::Point(ani->_x, ani->_y);
+ int nx = topLeft.x;
+ int ny = topLeft.y;
Movement *downStop = ani->getMovement(_ladmovements[pos]->movementIds->downStopId);
point = g_ngi->_gameVersion >= 201509 ? downStop->getCenterMovementSize(0, -1) : downStop->getMovementSize(0, -1);
@@ -2324,8 +2363,9 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
bool subMgm = false;
if (idxsub == -1 && revised) {
- // CMctlGraph::MakeQueue: GetDirByTurn, then the facing of the object (GetDirByPoint never finds anything there)
- idxsub = obj->_movement ? getDirByTurn(idx, obj->_movement->_id, objMirror) : -1;
+ // CMctlGraph::MakeQueue: GetDirByTurn, then the facing of the object
+ // +168, also when the object stands
+ idxsub = getDirByTurn(idx, obj->_movement ? obj->_movement->_id : obj->getLastMovementId(), objMirror);
if (idxsub == -1)
idxsub = objMirror ? 1 : 0;
} else if (idxsub == -1) {
Commit: be6cf427adc607f25f0836bfe2dd7f1d63b22b39
https://github.com/scummvm/scummvm/commit/be6cf427adc607f25f0836bfe2dd7f1d63b22b39
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Make GameObject::setPos virtual so SetCenter keeps the movement of an animation in step
Changed paths:
engines/ngi/gfx.h
engines/ngi/physics.h
engines/ngi/statics.h
diff --git a/engines/ngi/gfx.h b/engines/ngi/gfx.h
index 7bf084a16d5..62b783c818c 100644
--- a/engines/ngi/gfx.h
+++ b/engines/ngi/gfx.h
@@ -205,7 +205,7 @@ class GameObject : public CObject {
virtual Common::String toXML();
bool load(MfcArchive &file) override;
- void setPos(int x, int y);
+ virtual void setPos(int x, int y); // CVisibleObject::SetPos (vtable slot 80)
void assignCopyId(Common::Array<AniObject *> *lst);
void assignCopyId(Common::Array<PictureObject *> *lst);
void setFlags(int16 flags) { _flags = flags; }
diff --git a/engines/ngi/physics.h b/engines/ngi/physics.h
index 8e4381e16db..bcea3cdeadb 100644
--- a/engines/ngi/physics.h
+++ b/engines/ngi/physics.h
@@ -111,6 +111,7 @@ public:
PhysicalObject(char **arg2);
~PhysicalObject() override {}
int processMessage(Command *arg2); // 116DC4
+ using GameObject::setPos;
void setPos(uint32 arg2); // 116DD2
void clearPhysics(); // 116DE8
int removeThis(); // 116E06
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index 66eec1ba89e..feeaf87c2ab 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -229,7 +229,7 @@ public:
bool load(MfcArchive &file) override;
- void setPos(int x, int y);
+ void setPos(int x, int y) override;
Statics *getStatic(int id);
Statics *getStaticsByName(const Common::String &name);
Movement *getMovement(int id);
Commit: c5b68a5639d7abf24060bf38d098dc43be3a3669
https://github.com/scummvm/scummvm/commit/c5b68a5639d7abf24060bf38d098dc43be3a3669
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Port CMctlGraph::ResetObjMove for the failed walks of the 2015 build
Changed paths:
engines/ngi/motion.cpp
engines/ngi/motion.h
diff --git a/engines/ngi/motion.cpp b/engines/ngi/motion.cpp
index e36d42c2650..86cc2cf2786 100644
--- a/engines/ngi/motion.cpp
+++ b/engines/ngi/motion.cpp
@@ -2315,6 +2315,19 @@ static MessageQueue *newWalkQueue() {
return new MessageQueue(g_ngi->_globalMessageQueueList->compact());
}
+// CMctlGraph::ResetObjMove (1AA3C2): after a failed MakeQueue the stopped movement restarts
+// at its frame and center; nothing when no movement ran (id 0)
+void MctlGraph::resetObjMove(AniObject *ani, int movementId, Common::Point center, int frame) {
+ if (movementId == 0)
+ return;
+
+ debugC(1, kDebugInfo, "INFO t %u WALK reset: the movement %d of %d goes back to frame %d at the center %d,%d", g_system->getMillis(), movementId, ani->_id, frame, center.x, center.y);
+
+ ani->startMovement(movementId, 0, -1, false, false, false, -1);
+ ani->setCurFrame(frame, true, false);
+ ani->setCenter(center);
+}
+
MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzyMatch, int staticsId, bool mirror) {
LinkOrNode linkInfoDest;
LinkOrNode linkInfoSource;
@@ -2379,9 +2392,19 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
}
}
+ // CMctlGraph::MakeQueue keeps id (+168), center and frame for ResetObjMove
+ int resetMovementId = 0;
+ int resetFrame = 0;
+ Common::Point resetCenter(-1, -1);
+
if (obj->_movement && revised) {
- // CAniObject::StopMovementToPrev: back to the previous statics, the x of the center stays
+ resetMovementId = obj->_movement->_id; // +168 is the running movement while one runs
+ resetCenter = obj->getCenter();
+ resetFrame = obj->getCurFrame();
+
+ // CAniObject::StopMovementToPrev, then SetCenter(x before, y now)
obj->stopMovementToPrev(true);
+ obj->setCenter(Common::Point(resetCenter.x, obj->getCenter().y));
} else if (obj->_movement) {
int newx, newy;
@@ -2415,7 +2438,10 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
if (staticsId && obj->_statics->_staticsId != staticsId) {
int idxwalk = getDirByStatics(idx, staticsId, mirror);
if (idxwalk == -1 || (revised && !_aniData[idx]._directions[idxsub]._turnS[idxwalk]._movementId)) {
- obj->setPicAniInfo(picAniInfo);
+ if (revised)
+ resetObjMove(obj, resetMovementId, resetCenter, resetFrame);
+ else
+ obj->setPicAniInfo(picAniInfo);
delete mq;
@@ -2463,7 +2489,10 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
if (!linkInfoSource.link) {
debugC(1, kDebugInfo, "INFO t %u WALK refused: no link near the start %d,%d", g_system->getMillis(), obj->_x, obj->_y);
- obj->setPicAniInfo(picAniInfo);
+ if (revised)
+ resetObjMove(obj, resetMovementId, resetCenter, resetFrame);
+ else
+ obj->setPicAniInfo(picAniInfo);
return nullptr;
}
@@ -2477,7 +2506,10 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
if (!linkInfoDest.link) {
debugC(1, kDebugInfo, "INFO t %u WALK refused: the target %d,%d is on no node or link", g_system->getMillis(), xpos, ypos);
- obj->setPicAniInfo(picAniInfo);
+ if (revised)
+ resetObjMove(obj, resetMovementId, resetCenter, resetFrame);
+ else
+ obj->setPicAniInfo(picAniInfo);
return nullptr;
}
@@ -2491,7 +2523,7 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
if (minPath < 0.0 || ((linkInfoSource.node != linkInfoDest.node || !linkInfoSource.node) && !tempLinkList.size())) {
debugC(1, kDebugInfo, "INFO t %u WALK refused: no path (%g)", g_system->getMillis(), minPath);
if (revised)
- obj->setPicAniInfo(picAniInfo);
+ resetObjMove(obj, resetMovementId, resetCenter, resetFrame);
return nullptr;
}
@@ -2589,8 +2621,10 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
}
// 2015: on success the object stays stopped (the queue starts from there); on failure ResetObjMove restores it
- if (!revised || !mq)
+ if (!revised)
obj->setPicAniInfo(picAniInfo);
+ else if (!mq)
+ resetObjMove(obj, resetMovementId, resetCenter, resetFrame);
return mq;
}
diff --git a/engines/ngi/motion.h b/engines/ngi/motion.h
index dd5868818c2..35f34be9839 100644
--- a/engines/ngi/motion.h
+++ b/engines/ngi/motion.h
@@ -396,6 +396,7 @@ public:
using MovGraph::startMove;
MessageQueue *startMove(AniObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId, bool mirror = false) override;
MessageQueue *makeQueue(AniObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId, bool mirror = false) override;
+ void resetObjMove(AniObject *ani, int movementId, Common::Point center, int frame);
int getObjIndex(int objectId);
int getDirByStatics(int index, int staticsId, bool mirror = false);
Commit: 68cc061cd70a907f5a3e85bf86bba0fcecb68f47
https://github.com/scummvm/scummvm/commit/68cc061cd70a907f5a3e85bf86bba0fcecb68f47
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: The ladder turn commands of the 2015 build wait like CCommand(START_MOVEMENT, 1)
Changed paths:
engines/ngi/motion.cpp
diff --git a/engines/ngi/motion.cpp b/engines/ngi/motion.cpp
index 86cc2cf2786..6492b83de51 100644
--- a/engines/ngi/motion.cpp
+++ b/engines/ngi/motion.cpp
@@ -647,6 +647,8 @@ MessageQueue *MctlLadder::makeQueue(AniObject *ani, int xpos, int ypos, int fuzz
ex = new Command(ani->_id, kCmdStartMovement, _ladmovements[pos]->movementIds->upStopId, 0, 0, 0, 1, 0, 0, 0);
ex->_param = ani->_copyId;
ex->_excFlags |= 2;
+ if (revised)
+ ex->_wait = 1; // CCommand(START_MOVEMENT, wait 1)
mq->addCommand(0, ex);
@@ -732,6 +734,8 @@ MessageQueue *MctlLadder::makeQueue(AniObject *ani, int xpos, int ypos, int fuzz
ex = new Command(ani->_id, kCmdStartMovement, _ladmovements[pos]->movementIds->downStopId, 0, 0, 0, 1, 0, 0, 0);
ex->_param = ani->_copyId;
ex->_excFlags |= 2;
+ if (revised)
+ ex->_wait = 1; // CCommand(START_MOVEMENT, wait 1)
mq->addCommand(0, ex);
Commit: 7ebbb788580510bfcfebbd6f1ee4352bff1817c4
https://github.com/scummvm/scummvm/commit/7ebbb788580510bfcfebbd6f1ee4352bff1817c4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Port CMctlLadder::MakeQueue(ani, index, from, to)
Changed paths:
engines/ngi/motion.cpp
engines/ngi/motion.h
diff --git a/engines/ngi/motion.cpp b/engines/ngi/motion.cpp
index 6492b83de51..068c526c6e0 100644
--- a/engines/ngi/motion.cpp
+++ b/engines/ngi/motion.cpp
@@ -763,6 +763,37 @@ MessageQueue *MctlLadder::makeQueue(AniObject *ani, int off) {
return makeQueue(ani, _x + off * _stepX, _y + off * _stepY, 1, 0);
}
+// CMctlLadder::MakeQueue(CAniObject *, int, uint, uint) (1AD5E8): queue from step `from` to `to`
+MessageQueue *MctlLadder::makeQueue(AniObject *ani, int index, int from, int to) {
+ static bool reported = false;
+ if (!reported) {
+ reported = true;
+ warning("STUB/untested: CMctlLadder::MakeQueue(ani, index, from, to): ported from the decompile, the original has no caller");
+ }
+
+ if (from == to)
+ return nullptr;
+
+ // direction index: (to >> 31 logical) + (from >= to unsigned) + (from >> 31 arithmetic)
+ const uint uFrom = (uint)from;
+ const uint uTo = (uint)to;
+ const int dir = (int)(uTo >> 31) + (uFrom >= uTo ? 1 : 0) + (from >> 31);
+
+ MakeQueueStruct mkQueue;
+ mkQueue.ani = ani;
+ mkQueue.staticsId1 = _ladmovements[index]->staticIds[dir];
+ mkQueue.staticsId2 = _ladmovements[index]->staticIds[dir];
+ mkQueue.x2 = (int)(_x + _entryOffsetX * (float)from);
+ mkQueue.y2 = (int)(_y + _entryOffsetY * (float)from);
+ mkQueue.x1 = (int)(_x + _entryOffsetX * (float)to);
+ mkQueue.y1 = (int)(_y + _entryOffsetY * (float)to);
+ mkQueue.destZ = _z;
+ mkQueue.flags = 63;
+ mkQueue.movementId = dir ? _ladmovements[index]->movementIds->downGoId : _ladmovements[index]->movementIds->upGoId;
+
+ return _aniHandler.makeRunQueue(&mkQueue);
+}
+
MctlConnectionPoint *MctlCompound::getNextPoint(int ox, int oy, int destIndex, int connectionX, int connectionY, int sourceIdx, double *minDistancePtr) {
if (destIndex == sourceIdx) {
*minDistancePtr = sqrt((double)((oy - connectionY) * (oy - connectionY) + (ox - connectionX) * (ox - connectionX)));
diff --git a/engines/ngi/motion.h b/engines/ngi/motion.h
index 35f34be9839..dfa858f4910 100644
--- a/engines/ngi/motion.h
+++ b/engines/ngi/motion.h
@@ -161,6 +161,7 @@ public:
MessageQueue *makeQueue(AniObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId, bool mirror = false) override;
MessageQueue *makeQueue(AniObject *ani, int off);
+ MessageQueue *makeQueue(AniObject *ani, int index, int from, int to);
private:
int findIndex(AniObject *obj);
Commit: 1610fe2775a0581b15a020aefd54cadcb7cff67d
https://github.com/scummvm/scummvm/commit/1610fe2775a0581b15a020aefd54cadcb7cff67d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Test mode action ladder=STEP at MS for the ladder of scene 4
Changed paths:
engines/ngi/debugger/testmode.cpp
engines/ngi/fullpipe/sc04controller.cpp
engines/ngi/fullpipe/sc04controller.h
diff --git a/engines/ngi/debugger/testmode.cpp b/engines/ngi/debugger/testmode.cpp
index 2a457177c19..7fca18d5678 100644
--- a/engines/ngi/debugger/testmode.cpp
+++ b/engines/ngi/debugger/testmode.cpp
@@ -37,6 +37,8 @@
#include "ngi/scene.h"
#include "ngi/statics.h"
#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/fpcontroller.h"
+#include "ngi/fullpipe/sc04controller.h"
#include "ngi/debugger/testmode.h"
namespace NGI {
@@ -67,6 +69,13 @@ bool g_setupDone = false;
Common::Array<int> g_visits;
uint g_nextVisit = 0;
uint32 g_visitTimer = 0;
+struct LadderStep {
+ int step;
+ uint32 delay;
+};
+Common::Array<LadderStep> g_ladderSteps; // ladder=STEP at MS: the ladder of scene 4 goes to the step MS ms after the previous action
+uint g_nextLadderStep = 0;
+uint32 g_ladderTimer = 0;
Common::String toGameEncoding(const Common::String &utf8) {
return Common::U32String(utf8, Common::kUtf8).encode(Common::kWindows1251);
@@ -104,6 +113,12 @@ void runSetup() {
g_ngi->_currentScene->_y = y;
g_ngi->_sceneRect.moveTo(x, y);
}
+ } else if (key == "ladder") {
+ LadderStep ladder;
+ ladder.step = atoi(value.c_str());
+ const int at = value.findFirstOf('@');
+ ladder.delay = at == (int)Common::String::npos ? 0 : atoi(value.substr(at + 1).c_str());
+ g_ladderSteps.push_back(ladder);
} else if (key == "visit") {
Common::StringTokenizer scenes(value, ",");
while (!scenes.empty())
@@ -273,6 +288,20 @@ void testmode_update(uint32 elapsed) {
}
}
+ if (g_setupDone && g_nextLadderStep < g_ladderSteps.size() && g_ngi->_currentScene && g_ngi->_currentScene->_sceneId == SC_4) {
+ Sc04Controller &controller = static_cast<Sc04Controller &>(sceneController(*g_ngi->_currentScene));
+ // the delay runs while the hero stands on the ladder without a queue
+ if (controller.testLadderReady()) {
+ g_ladderTimer += elapsed;
+ if (g_ladderTimer >= g_ladderSteps[g_nextLadderStep].delay) {
+ g_ladderTimer = 0;
+ const int step = g_ladderSteps[g_nextLadderStep++].step;
+ warning("TESTMODE: ladder step %d", step);
+ controller.testLadderStep(step);
+ }
+ }
+ }
+
if ((g_setupDone && !g_spot) || !hero || !g_ngi->_currentScene)
return;
diff --git a/engines/ngi/fullpipe/sc04controller.cpp b/engines/ngi/fullpipe/sc04controller.cpp
index fc0ed515558..a740764eda4 100644
--- a/engines/ngi/fullpipe/sc04controller.cpp
+++ b/engines/ngi/fullpipe/sc04controller.cpp
@@ -1019,6 +1019,22 @@ void Sc04Controller::tryLeaveLadder(uint32 id, float x, float y) {
}
}
+// Test mode: the queue TryLeaveLadder makes (CMctlLadder::MakeQueue, RunQueue(queue, 2)),
+// reaches the ladder movements that no original click starts (down)
+bool Sc04Controller::testLadderStep(int step) {
+ if (!_ladder)
+ return false;
+ MessageQueue *queue = _ladder->makeQueue(hero(), step);
+ debugC(1, kDebugInfo, "INFO t %u LADDER test: the hero at the step %d goes to the step %d, queue %s", g_system->getMillis(), _ladder->getCurrentStep(hero()), step, queue ? "made" : "none");
+ if (queue)
+ _scene->runQueueObject(queue, hero(), 2);
+ return true;
+}
+
+bool Sc04Controller::testLadderReady() {
+ return _ladder && hero() && !hero()->_movement && !hero()->_queue;
+}
+
// CSc04Controller::DoWalkLadder (1672C8): hero walks on the ladder to the point
void Sc04Controller::doWalkLadder(float x, float y) {
_cameraLocked = true;
diff --git a/engines/ngi/fullpipe/sc04controller.h b/engines/ngi/fullpipe/sc04controller.h
index d69225dadef..f0d6657daf9 100644
--- a/engines/ngi/fullpipe/sc04controller.h
+++ b/engines/ngi/fullpipe/sc04controller.h
@@ -113,6 +113,10 @@ public:
void doTakeKozaw();
void doAttachMan();
void putKozawToBottle(AniObject *kozaw, PictureObject *bottle);
+ /** Test mode (--start-movie="ladder=STEP at MS"): ladder queue to the step, like TryLeaveLadder */
+ bool testLadderStep(int step);
+ /** Test mode: the ladder exists and the hero stands on it without a queue */
+ bool testLadderReady();
private:
/** +148 of CFPController (arcade flag): set while the hero is on the ladder in this scene */
Commit: 7c7ba57eea2cf2b04d157d750c0e5492b3a499db
https://github.com/scummvm/scummvm/commit/7c7ba57eea2cf2b04d157d750c0e5492b3a499db
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Say what of the scene 4 ladder was played in the STUB warning
Changed paths:
engines/ngi/motion.cpp
diff --git a/engines/ngi/motion.cpp b/engines/ngi/motion.cpp
index 068c526c6e0..d23b59b4f3f 100644
--- a/engines/ngi/motion.cpp
+++ b/engines/ngi/motion.cpp
@@ -534,7 +534,7 @@ MessageQueue *MctlLadder::makeQueue(AniObject *ani, int xpos, int ypos, int fuzz
static bool reported = false;
if (revised && !reported) {
reported = true;
- warning("STUB/untested: CMctlLadder::MakeQueue / StartMove (the ladder of scene 4) are ported from the decompile (heights from the center, top left for the stop movements, RunQueue(q, 2, 1)) and not played");
+ warning("STUB/untested: CMctlLadder::MakeQueue / StartMove (the ladder of scene 4): played up and down from the foot, from ST_MAN_STANDLADDER and from the idle ST_MAN_LADDERDOWN with the scene 4 controller running the scene (not the shipped state, D02); not played: the cases of the idle statics ST_MAN_GOLADDER / ST_MAN_GOLADDERD and a call while a movement runs");
}
// CMctlLadder::MakeQueue (1AD110): every height is the y of the center of the object
const int aniY = revised ? ani->getCenter().y : ani->_y;
Commit: 870fad9c23d2235548219fe8e48f3e7174852c44
https://github.com/scummvm/scummvm/commit/870fad9c23d2235548219fe8e48f3e7174852c44
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Debug flag noRandom for repeatable test runs
Changed paths:
A engines/ngi/determinism.cpp
A engines/ngi/determinism.h
engines/ngi/detection.cpp
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
diff --git a/engines/ngi/detection.cpp b/engines/ngi/detection.cpp
index 01a18190bc1..1828b932ae2 100644
--- a/engines/ngi/detection.cpp
+++ b/engines/ngi/detection.cpp
@@ -43,6 +43,7 @@ static const DebugChannelDef debugFlagList[] = {
{NGI::kDebugInfo, "info", "Log the state of Dude (movement, phase, position) whenever it changes"},
{NGI::kDebugFast, "fast", "Six times faster game, for test runs"},
{NGI::kDebugSkipIntro, "skipIntro", "Starts without the initial tutorial (the Skip button of it is pressed at the start)"},
+ {NGI::kDebugNoRandom, "noRandom", "Repeatable runs for tests: fixed random seed, fixed update steps, no cursor, --start-movie=freeze=N stops the updates"},
DEBUG_CHANNEL_END
};
diff --git a/engines/ngi/determinism.cpp b/engines/ngi/determinism.cpp
new file mode 100644
index 00000000000..0276b977522
--- /dev/null
+++ b/engines/ngi/determinism.cpp
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/config-manager.h"
+#include "common/debug.h"
+#include "common/debug-channels.h"
+#include "common/str.h"
+#include "common/tokenizer.h"
+
+#include "ngi/ngi.h"
+#include "ngi/determinism.h"
+
+namespace NGI {
+
+static uint32 g_updates = 0;
+static uint32 g_freezeAfter = 0;
+
+bool determinismActive() {
+ return DebugMan.isDebugChannelEnabled(kDebugNoRandom);
+}
+
+void determinismStart() {
+ g_ngi->_rnd.setSeed(0x4E4749);
+ g_ngi->_mouseScreenPos = Common::Point(400, 300);
+ g_updates = 0;
+ g_freezeAfter = 0;
+ if (!ConfMan.hasKey("start_movie"))
+ return;
+ Common::StringTokenizer actions(ConfMan.get("start_movie"), ";");
+ while (!actions.empty()) {
+ const Common::String action = actions.nextToken();
+ if (action.hasPrefix("freeze="))
+ g_freezeAfter = atoi(action.c_str() + 7);
+ }
+ if (g_freezeAfter)
+ debug("NGI: noRandom, the updates stop after %u", g_freezeAfter);
+}
+
+bool determinismAllowUpdate() {
+ if (g_freezeAfter && g_updates >= g_freezeAfter)
+ return false;
+ ++g_updates;
+ return true;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/determinism.h b/engines/ngi/determinism.h
new file mode 100644
index 00000000000..af9f3c70927
--- /dev/null
+++ b/engines/ngi/determinism.h
@@ -0,0 +1,40 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_DETERMINISM_H
+#define NGI_DETERMINISM_H
+
+#include "common/scummsys.h"
+
+namespace NGI {
+
+/** --debugflags=noRandom: repeatable runs, see docs/windows-regression-baseline.md */
+bool determinismActive();
+
+/** Seeds the random generator (once, before the main loop). */
+void determinismStart();
+
+/** True when the game may be updated now; counts the updates for freeze=N. */
+bool determinismAllowUpdate();
+
+} // End of namespace NGI
+
+#endif
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 42d9669d904..726aa96c698 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -4,6 +4,7 @@ MODULE_OBJS = \
anihandler.o \
behavior.o \
console.o \
+ determinism.o \
fader.o \
font.o \
gameloader.o \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index a294b0f4f27..ab446e5192b 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -34,6 +34,7 @@
#include "graphics/surface.h"
#include "ngi/ngi.h"
+#include "ngi/determinism.h"
#include "ngi/scenecontroller.h"
#include "ngi/fullpipe/lift.h"
#include "ngi/fullpipe/arcadeinterface.h"
@@ -519,6 +520,9 @@ Common::Error NGIEngine::run() {
#endif
uint32 lastUpdate = _system->getMillis();
+ const bool deterministic = determinismActive();
+ if (deterministic)
+ determinismStart();
while (!shouldQuit()) {
#ifdef USE_IMGUI
// For performance reasons, disable the renderer callback if the ImGui debug flag isn't set
@@ -533,17 +537,25 @@ Common::Error NGIEngine::run() {
break;
const uint32 now = _system->getMillis();
const uint32 elapsed = now - lastUpdate;
- if (timedUpdates || elapsed >= 33 || !_normalSpeed) {
+ if (deterministic || timedUpdates || elapsed >= 33 || !_normalSpeed) {
lastUpdate = now;
// CGame::Update discounts long stalls on Android.
uint32 step = 42;
- if (timedUpdates)
+ if (timedUpdates && !deterministic)
step = elapsed > 350 ? 15 : elapsed;
+ // --debugflags=noRandom: a fixed step, and freeze=N stops the updates
+ if (deterministic && !determinismAllowUpdate()) {
+ _system->updateScreen();
+ _system->delayMillis(5);
+ continue;
+ }
result = updateScreen(step, brightness, redraw);
if (result.getCode() != Common::kNoError)
break;
// --debugflags=fast: more updates per frame (movements advance one phase per update)
for (int i = 1; usesXMLProject() && i < testmode_updatesPerFrame(); i++) {
+ if (deterministic && !determinismAllowUpdate())
+ break;
result = updateScreen(42, brightness, false);
if (result.getCode() != Common::kNoError)
break;
@@ -668,6 +680,9 @@ bool NGIEngine::updateEvents() {
_keyState = Common::KEYCODE_INVALID;
break;
case Common::EVENT_MOUSEMOVE:
+ // --debugflags=noRandom: the pointer over the window does not count (top hover shows the map)
+ if (determinismActive())
+ break;
if (_recordEvents) {
ex = new Command(0, kCmdMessage, kMsgMouseMove, event.mouse.x, event.mouse.y, 0, 1, 0, 0, 0);
ex->_excFlags |= 3;
@@ -877,12 +892,13 @@ Common::Error NGIEngine::updateScreen(uint32 elapsed, byte &brightness, bool red
if (redraw) {
drawWidescreenBars();
// CCursorController::Render comes after CGame::Render
- if (usesXMLProject() && _inputController)
+ if (usesXMLProject() && _inputController && !determinismActive())
_inputController->render();
_system->copyRectToScreen(_backgroundSurface.getPixels(), _backgroundSurface.pitch, 0, 0, _backgroundSurface.w, _backgroundSurface.h);
}
} else {
- _inputController->render(_mouseScreenPos.x, _mouseScreenPos.y);
+ if (!determinismActive())
+ _inputController->render(_mouseScreenPos.x, _mouseScreenPos.y);
}
++_updateTicks;
return Common::kNoError;
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index db0ae32e852..df59855b386 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -59,6 +59,7 @@ enum {
kDebugInfo,
kDebugFast,
kDebugSkipIntro,
+ kDebugNoRandom,
};
enum NGIActions {
Commit: 33280eb1e559704c27ff7919d54ac4723b7a2569
https://github.com/scummvm/scummvm/commit/33280eb1e559704c27ff7919d54ac4723b7a2569
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
BASE: SURFACESDL: Initialize _numDirtyRects
Changed paths:
backends/graphics/surfacesdl/surfacesdl-graphics.cpp
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 9be951fce44..92144300a2d 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -190,7 +190,7 @@ SurfaceSdlGraphicsManager::SurfaceSdlGraphicsManager(SdlEventSource *sdlEventSou
#endif
_transactionMode(kTransactionNone),
_scalerPlugins(ScalerMan.getPlugins()), _scalerPlugin(nullptr), _scaler(nullptr),
- _prevOverlayVisible(false), _isInOverlayPalette(false), _isDoubleBuf(false), _prevForceRedraw(false), _numPrevDirtyRects(0),
+ _prevOverlayVisible(false), _isInOverlayPalette(false), _isDoubleBuf(false), _prevForceRedraw(false), _numDirtyRects(0), _numPrevDirtyRects(0),
_prevCursorNeedsRedraw(false),
_mouseKeyColor(0), _disableMouseKeyColor(false) {
Commit: 4a483365a47e41e2f11fc72ccb176cffb4ff1fc8
https://github.com/scummvm/scummvm/commit/4a483365a47e41e2f11fc72ccb176cffb4ff1fc8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:06+01:00
Commit Message:
NGI: Fix compiler warnings
Changed paths:
engines/ngi/debugger/testmode.cpp
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/hintmanager.cpp
engines/ngi/fullpipe/sc04controller.h
engines/ngi/preloadmanager.cpp
engines/ngi/xmlnode.cpp
diff --git a/engines/ngi/debugger/testmode.cpp b/engines/ngi/debugger/testmode.cpp
index 7fca18d5678..8db026bb66f 100644
--- a/engines/ngi/debugger/testmode.cpp
+++ b/engines/ngi/debugger/testmode.cpp
@@ -66,14 +66,21 @@ const Spot kSpots[] = {
// --start-movie=<actions> (NGI_TEST_SETUP): ';' separated, done once after the entrance queue:
// state=Object:Value, item=ANI_INV_COIN, scroll=x,y, visit=1,2,1,3 (scenes in turn, 7 s each)
bool g_setupDone = false;
-Common::Array<int> g_visits;
+Common::Array<int> &visits() { // function-local statics: no global destructors
+ static Common::Array<int> list;
+ return list;
+}
uint g_nextVisit = 0;
uint32 g_visitTimer = 0;
struct LadderStep {
int step;
uint32 delay;
};
-Common::Array<LadderStep> g_ladderSteps; // ladder=STEP at MS: the ladder of scene 4 goes to the step MS ms after the previous action
+// ladder=STEP at MS: the ladder of scene 4 goes to the step MS ms after the previous action
+Common::Array<LadderStep> &ladderSteps() {
+ static Common::Array<LadderStep> list;
+ return list;
+}
uint g_nextLadderStep = 0;
uint32 g_ladderTimer = 0;
@@ -118,11 +125,11 @@ void runSetup() {
ladder.step = atoi(value.c_str());
const int at = value.findFirstOf('@');
ladder.delay = at == (int)Common::String::npos ? 0 : atoi(value.substr(at + 1).c_str());
- g_ladderSteps.push_back(ladder);
+ ladderSteps().push_back(ladder);
} else if (key == "visit") {
Common::StringTokenizer scenes(value, ",");
while (!scenes.empty())
- g_visits.push_back(atoi(scenes.nextToken().c_str()));
+ visits().push_back(atoi(scenes.nextToken().c_str()));
g_visitTimer = 7000;
}
}
@@ -277,25 +284,25 @@ void testmode_update(uint32 elapsed) {
}
}
- if (g_setupDone && g_nextVisit < g_visits.size()) {
+ if (g_setupDone && g_nextVisit < visits().size()) {
g_visitTimer += elapsed;
if (g_visitTimer >= 7000) {
g_visitTimer = 0;
- const int sceneId = g_ngi->convertScene(g_visits[g_nextVisit++]);
+ const int sceneId = g_ngi->convertScene(visits()[g_nextVisit++]);
warning("TESTMODE: visit scene %d", sceneId);
g_ngi->_gameLoader->setScene(sceneId, 0);
return;
}
}
- if (g_setupDone && g_nextLadderStep < g_ladderSteps.size() && g_ngi->_currentScene && g_ngi->_currentScene->_sceneId == SC_4) {
+ if (g_setupDone && g_nextLadderStep < ladderSteps().size() && g_ngi->_currentScene && g_ngi->_currentScene->_sceneId == SC_4) {
Sc04Controller &controller = static_cast<Sc04Controller &>(sceneController(*g_ngi->_currentScene));
// the delay runs while the hero stands on the ladder without a queue
if (controller.testLadderReady()) {
g_ladderTimer += elapsed;
- if (g_ladderTimer >= g_ladderSteps[g_nextLadderStep].delay) {
+ if (g_ladderTimer >= ladderSteps()[g_nextLadderStep].delay) {
g_ladderTimer = 0;
- const int step = g_ladderSteps[g_nextLadderStep++].step;
+ const int step = ladderSteps()[g_nextLadderStep++].step;
warning("TESTMODE: ladder step %d", step);
controller.testLadderStep(step);
}
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 3a3ecada63e..4182af6e0f2 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -124,7 +124,6 @@ void executeUserCommand(Command *cmd, MessageQueue *queue) {
// CFPController::ExecuteUserCmd
void FPController::executeUserCmd(Command *cmd, MessageQueue *queue) {
const Common::String &type = cmd->_messageName;
- Scene *scene = _scene;
if (type == "SET_SCROLL") {
execCmdScroll(cmd);
diff --git a/engines/ngi/fullpipe/hintmanager.cpp b/engines/ngi/fullpipe/hintmanager.cpp
index ab106345d4c..0ebdf395b14 100644
--- a/engines/ngi/fullpipe/hintmanager.cpp
+++ b/engines/ngi/fullpipe/hintmanager.cpp
@@ -82,7 +82,7 @@ void HintManager::init(const char *path) {
const uint32 sceneId = findId(root[i].attrStr("scene", ""));
_hints[sceneId].push_back(info);
}
- debugC(1, kDebugXML, "Loaded the hints of %u scenes from %s", _hints.size(), path);
+ debugC(1, kDebugXML, "Loaded the hints of %u scenes from %s", (uint)_hints.size(), path);
}
// CHintManager::CleanXml (1525BA)
diff --git a/engines/ngi/fullpipe/sc04controller.h b/engines/ngi/fullpipe/sc04controller.h
index f0d6657daf9..0fada883ff0 100644
--- a/engines/ngi/fullpipe/sc04controller.h
+++ b/engines/ngi/fullpipe/sc04controller.h
@@ -167,7 +167,7 @@ private:
int _bottleFallSpeed = 0; // +668: the speed of the fall
int _bottleWeight = 2; // +672: the weight on the spring
int _kozawWeight = 2; // +676: the weight of a kozawka
- int _springField680 = 10; // +680: set by the constructor, not read in this class
+ // +680: an int the constructor sets to 10, nothing reads it
int _springOffset = 0; // +684: the speed of the spring (clicks add to it)
int _springStep = 1; // +688: the damping step
int _springCounter = 0; // +692: the crossings of the weight
diff --git a/engines/ngi/preloadmanager.cpp b/engines/ngi/preloadmanager.cpp
index a5a2e9aba69..bc63adc71a4 100644
--- a/engines/ngi/preloadmanager.cpp
+++ b/engines/ngi/preloadmanager.cpp
@@ -175,7 +175,7 @@ void PreloadManager::popScene() {
_roamings -= current->unloadRoamings(false);
_additional -= current->unloadAdditional();
for (uint i = 0; i < _loaded.size(); i++) {
- if (current->_sceneId == _loaded[i].sceneId) {
+ if (static_cast<uint>(current->_sceneId) == _loaded[i].sceneId) {
_preloaded -= current->unloadMovement(_loaded[i].aniId, _loaded[i].movementId);
_loaded.remove_at(i);
i++;
@@ -200,7 +200,7 @@ void PreloadManager::loadAll() {
for (uint i = 0; i < g_ngi->_sceneStack.size(); i++) {
Scene *scene = g_ngi->getSceneInStack(i);
for (uint j = 0; j < _items.size(); j++) {
- if (scene->_sceneId == _items[j].sceneId) {
+ if (static_cast<uint>(scene->_sceneId) == _items[j].sceneId) {
const uint size = scene->loadMovement(_items[j].aniId, _items[j].movementId);
if (size) {
debugC(4, kDebugLoading, "CPreloadManager::LoadAll(), move = %s", g_ngi->gameIdToStr(_items[j].movementId).c_str());
diff --git a/engines/ngi/xmlnode.cpp b/engines/ngi/xmlnode.cpp
index 8acf0b92147..a59985fa8d4 100644
--- a/engines/ngi/xmlnode.cpp
+++ b/engines/ngi/xmlnode.cpp
@@ -29,7 +29,11 @@ namespace NGI {
namespace {
-const XmlNode emptyNode;
+// a function-local static: no global destructor
+const XmlNode &emptyNode() {
+ static const XmlNode node;
+ return node;
+}
// PP_Split(string, 32): the numbers of the attribute, a missing one is 0 (CXmlNode::AttrVector2)
Common::Array<Common::String> splitBySpace(const Common::String &text) {
@@ -78,11 +82,11 @@ const XmlNode &XmlNode::child(const char *name) const {
if (_children[i]->_name == name)
return *_children[i];
}
- return emptyNode;
+ return emptyNode();
}
const XmlNode &XmlNode::first() const {
- return _children.empty() ? emptyNode : *_children[0];
+ return _children.empty() ? emptyNode() : *_children[0];
}
const char *XmlNode::attrStr(const char *name, const char *defaultValue) const {
@@ -163,11 +167,12 @@ private:
Common::Array<XmlNode *> _nodes;
CUSTOM_XML_PARSER(XmlDocumentParser) {
+ (void)lay; // no known keys: every key goes to handleUnknownKey
} PARSER_END()
bool handleUnknownKey(ParserNode *node) override {
node->layout = _XMLkeys;
- if (node->depth >= _nodes.size())
+ if (static_cast<uint>(node->depth) >= _nodes.size())
return false;
XmlNode *child = _nodes[node->depth]->append(node->name);
for (const auto &attribute : node->values)
Commit: 4563a2b938c3704cdf226c2bd95f5a17adf1b531
https://github.com/scummvm/scummvm/commit/4563a2b938c3704cdf226c2bd95f5a17adf1b531
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-01T01:02:07+01:00
Commit Message:
NGI: Shorten comments
Changed paths:
engines/ngi/anihandler.cpp
engines/ngi/font.h
engines/ngi/fullpipe/chaptermanager.cpp
engines/ngi/fullpipe/chaptermanager.h
engines/ngi/fullpipe/floaters.cpp
engines/ngi/fullpipe/fpcontroller.cpp
engines/ngi/fullpipe/notebook.cpp
engines/ngi/fullpipe/notebook.h
engines/ngi/fullpipe/scene02.cpp
engines/ngi/fullpipe/sceneFinal.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/fullpipe/taskmanager.cpp
engines/ngi/fullpipe/taskmanager.h
engines/ngi/fullpipe/tremble.cpp
engines/ngi/fullpipe/tremble.h
engines/ngi/gfx.cpp
engines/ngi/gfx.h
engines/ngi/interaction.h
engines/ngi/messages.h
engines/ngi/metaengine.cpp
engines/ngi/motion.cpp
engines/ngi/motion.h
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/physics.h
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/sceneobjects.h
engines/ngi/stateloader.cpp
engines/ngi/statics.cpp
engines/ngi/statics.h
engines/ngi/xmlproject.cpp
engines/ngi/zcontroller.cpp
engines/ngi/zcontroller.h
diff --git a/engines/ngi/anihandler.cpp b/engines/ngi/anihandler.cpp
index 19428b770b2..52352fe2938 100644
--- a/engines/ngi/anihandler.cpp
+++ b/engines/ngi/anihandler.cpp
@@ -30,8 +30,8 @@
namespace NGI {
-// CMovement::GetMovementSize of the 2015 revision measures from sprite center to sprite center (Movement::getCenterMovementSize).
-// The plan of a walk must use one unit: the cycles, the transitions of seekWay and the offsets of makeRunQueue.
+// CMovement::GetMovementSize of 2015 measures center to center (Movement::getCenterMovementSize);
+// a walk plan (cycles, seekWay transitions, makeRunQueue offsets) must use one unit
static Common::Point moveSize(Movement *mov, int idx, int dynidx) {
return g_ngi->_gameVersion >= 201509 ? mov->getCenterMovementSize(idx, dynidx) : mov->getMovementSize(idx, dynidx);
}
@@ -187,8 +187,8 @@ void AniHandler::resetData(int objId) {
Common::Array<Statics *> staticsList(obj->_staticsList);
Common::Array<Movement *> movements(obj->_movements);
if (g_ngi->_gameVersion >= 201509) {
- // CAniObject keeps both in a std::map<id, ...> and CAniHandler::ResetData walks them with FindStatic/FindMovement: ascending
- // id order. seekWay keeps the first of two equal chains, so the order decides which movements are used.
+ // CAniObject keeps both in a std::map<id, ...> and CAniHandler::ResetData walks them in id order;
+ // seekWay keeps the first of two equal chains, so the order decides which movements are used
Common::sort(staticsList.begin(), staticsList.end(), [](Statics *a, Statics *b) { return (uint16)a->_staticsId < (uint16)b->_staticsId; });
Common::sort(movements.begin(), movements.end(), [](Movement *a, Movement *b) { return (uint16)a->_id < (uint16)b->_id; });
}
@@ -653,7 +653,7 @@ int AniHandler::getNumMovements(int objectId, int idx1, int idx2) {
}
Common::Point AniHandler::getNumCycles(Movement *mov, int x, int y, int *mult, int *len, int flag) {
- // CAniHandler::GetNumCycles measures with CMovement::GetMovementSize, the center displacement of the 2015 revision
+ // CAniHandler::GetNumCycles measures with CMovement::GetMovementSize (center displacement, 2015)
const bool centered = g_ngi->_gameVersion >= 201509;
auto size = [&](int idx, int dynidx) {
return moveSize(mov, idx, dynidx);
diff --git a/engines/ngi/font.h b/engines/ngi/font.h
index 57b3d216b99..bc2bcbf8d0e 100644
--- a/engines/ngi/font.h
+++ b/engines/ngi/font.h
@@ -64,7 +64,7 @@ public:
int getFontHeight() const override { return _lineHeight; }
int getMaxCharWidth() const override { return _maxWidth; }
int getCharWidth(uint32 chr) const override;
- // CFont::GetSize: the outline ("0.5" in many fonts) makes the width fractional, the text is laid out with it
+ // CFont::GetSize: the outline makes the width fractional
float getCharAdvance(uint32 chr) const;
int getKerningOffset(uint32 left, uint32 right) const override;
Common::Rect getBoundingBox(uint32 chr) const override;
diff --git a/engines/ngi/fullpipe/chaptermanager.cpp b/engines/ngi/fullpipe/chaptermanager.cpp
index c706a9bc7a7..0baeb241372 100644
--- a/engines/ngi/fullpipe/chaptermanager.cpp
+++ b/engines/ngi/fullpipe/chaptermanager.cpp
@@ -44,7 +44,7 @@ namespace NGI {
namespace {
-// chapter.xml: CHAPTERS / CHAPTER (START, FINISH, CHARACTERS / CHARACTER); CHAPTER_CONTROLLER is read by the dialog
+// chapter.xml: CHAPTERS / CHAPTER (START, FINISH, CHARACTERS); CHAPTER_CONTROLLER is for the dialog
class ChapterXmlParser : public Common::XMLParser {
public:
Common::Array<Chapter> _chapters;
@@ -68,7 +68,7 @@ private:
KEY_END()
KEY_END()
KEY_END()
- // a second top-level element after CHAPTERS, read by the dialog (CChapterController::ReadSettingsXml)
+ // read by the dialog (CChapterController::ReadSettingsXml)
XML_KEY(CHAPTER_CONTROLLER)
XML_PROP(text_appearance, false)
XML_PROP(char_delay, false)
@@ -84,8 +84,7 @@ private:
bool parserCallback_CHAPTER(ParserNode *node) {
Chapter chapter;
chapter._id = node->values["id"];
- // countShow of the XML is kept here: CChapterManager::Init reads "m_countShow", which no data has (0), and only
- // CChapter::LoadParam reads "countShow"
+ // CChapterManager::Init reads "m_countShow" (no data has it), CChapter::LoadParam "countShow"
chapter._countShow = atoi(node->values.getValOrDefault("countShow").c_str());
_chapters.push_back(chapter);
return true;
diff --git a/engines/ngi/fullpipe/chaptermanager.h b/engines/ngi/fullpipe/chaptermanager.h
index 4c53de5b9c6..e2ff3378686 100644
--- a/engines/ngi/fullpipe/chaptermanager.h
+++ b/engines/ngi/fullpipe/chaptermanager.h
@@ -34,8 +34,7 @@ class Serializer;
namespace NGI {
-// A chapter of the 2015 revision (CChapter, data/chapter.xml): the texts of its start and finish dialogs, the
-// characters that become available in the catalog when it ends, and how often its dialogs were shown.
+// A chapter of the 2015 revision (CChapter, data/chapter.xml): dialog texts, catalog characters
class Chapter {
public:
Common::String _id;
diff --git a/engines/ngi/fullpipe/floaters.cpp b/engines/ngi/fullpipe/floaters.cpp
index ce85df08612..54f3b841754 100644
--- a/engines/ngi/fullpipe/floaters.cpp
+++ b/engines/ngi/fullpipe/floaters.cpp
@@ -114,8 +114,8 @@ void FlyPack::addFly(Scene *sc, int x, int y, int priority, int flags) {
}
void FlyPack::onUpdate(uint32 elapsed) {
- // Android (CFlyPack::OnUpdate) keeps the Windows logic but runs on milliseconds: the idle time and the step
- // (speed * elapsed) scale with the frame time, 83 ms per Windows tick (16600 = 200 * 83, 1660 = 20 * 83).
+ // CFlyPack::OnUpdate runs on milliseconds: idle time and step scale with the frame time,
+ // 83 ms per Windows tick (16600 = 200 * 83, 1660 = 20 * 83)
const bool android = g_ngi->_gameVersion >= 201509; // millisecond timers, see CFlyPack::OnUpdate
const double minSpeed = android ? 0.02 : 2.0;
diff --git a/engines/ngi/fullpipe/fpcontroller.cpp b/engines/ngi/fullpipe/fpcontroller.cpp
index 4182af6e0f2..d0efe8f85cc 100644
--- a/engines/ngi/fullpipe/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/fpcontroller.cpp
@@ -64,10 +64,6 @@ void sceneController_initInventory() {
}
}
-// The Android scene controllers (CFPController, the base class of all CScNNController) execute the USER commands
-// of the message queues: CMessageQueue::ExecuteUserCmd picks the scene (parameter "sc", else the scene of the
-// queue) and calls its controller, CFPController::ExecuteUserCmd dispatches on the "type" parameter. SET_LOGIC and
-// MOVE_TO_STATIC have their own command kinds in the loader and do not come here.
// CIDList::FindId: 0 for an unknown name
static int findId(const Common::String &name) {
@@ -152,7 +148,7 @@ void FPController::executeUserCmd(Command *cmd, MessageQueue *queue) {
execCmdMouse(cmd, queue);
} else if (type == "SET_CENTER" || type == "TUTORIAL_ACTIVATE" || type == "SHOW_CHAPTER_DIALOG" || type == "CATALOG" ||
type == "ENABLE_CHARACTER" || type == "HINT_ENABLE" || type == "SHOW_REVIEW") {
- // Handled by CFPController::ExecuteUserCmd, waiting for the subsystems they belong to (TASK_* are in taskmanager.cpp)
+ // handled by CFPController::ExecuteUserCmd, waiting for their subsystems
static Common::HashMap<Common::String, bool> reported;
if (!reported.contains(type)) {
reported[type] = true;
@@ -346,7 +342,7 @@ void FPController::limitScroll() {
}
}
-// CFPController::CheckBorders: 1 when the cursor is at the right edge and the scene goes on, -1 at the left edge (not on the top bar)
+// CFPController::CheckBorders: 1 at the right edge, -1 at the left (not on the top bar)
int FPController::checkBorders(float cursorX, float cursorY) const {
if (_swiped)
return 0;
@@ -488,7 +484,7 @@ bool FPController::touchScroll() {
return false;
}
-// CFPController::TestScroll: at most 3 pixels towards the target, the camera stops at the ends of the scene
+// CFPController::TestScroll: at most 3 pixels towards the target
void FPController::testScroll() {
if (_targetX == 0.0f && _targetY == 0.0f)
return;
diff --git a/engines/ngi/fullpipe/notebook.cpp b/engines/ngi/fullpipe/notebook.cpp
index a9843d00d04..2999284046c 100644
--- a/engines/ngi/fullpipe/notebook.cpp
+++ b/engines/ngi/fullpipe/notebook.cpp
@@ -103,7 +103,7 @@ Foil::Foil(int x, int y, int width, int height) : _x(x), _y(y) {
_covered.push_back(true);
_angles.push_back(g_ngi->_rnd.getRandomNumber(180)); // CFoil: a random angle up to pi
}
- // The picture of a piece is centered on its cell: the area starts half a piece before the first one
+ // the piece picture is centered on its cell
_area = Common::Rect(x - kPiece / 2, y - kPiece / 2, x + _columns * kPiece + 1, y + _rows * kPiece + 1);
}
@@ -223,7 +223,7 @@ bool Notebook::isTimerShowing() const {
return g_ngi->_taskManager->getTime() != -1;
}
-// CNotebookController::SortTasks: the tasks of the active chapter that were started, by their number
+// CNotebookController::SortTasks: started tasks of the active chapter, by number
void Notebook::sortTasks() {
_tasks.clear();
const int chapter = g_ngi->_chapterManager->getActiveChapter();
@@ -285,7 +285,7 @@ bool Notebook::isAllTasksClosed() const {
return true;
}
-// CNotebookController::CheckAngles: the stamp of a closed task is tilted by a random angle that is not close to 0
+// CNotebookController::CheckAngles: a closed task's stamp gets a random tilt away from 0
// and differs by more than 10 degrees from the one before when they lean the same way
void Notebook::checkAngles() {
if (_tasks.size() < _angles.size())
@@ -347,7 +347,7 @@ void Notebook::blockHints() {
}
}
-// CNotebookController::UnblockNextHint: the timer is over, the next hint of every open task can be shown
+// CNotebookController::UnblockNextHint: timer over, the next hint of every open task is allowed
void Notebook::unblockNextHint() {
for (Task *task : _tasks) {
if (task->_state == Task::kStateClosed)
@@ -388,8 +388,7 @@ void Notebook::showHint(int index) {
if (!task)
return;
- // The hints cost the achievements ACHIEVEMENT_HELPLESS_CHAPTER_n and ACHIEVEMENT_HELPLESS_FINISH points
- // (CAchievementsManager::BlockActivatingCounter, 50 in chapter 1 and 100 later)
+ // the hints cost ACHIEVEMENT_HELPLESS_CHAPTER_n / _FINISH points (50 or 100)
const int chapter = g_ngi->_chapterManager->getActiveChapter();
const int blocked = chapter == 1 ? 50 : 100;
g_ngi->_achievementsManager->blockActivatingCounter(Common::String::format("ACHIEVEMENT_HELPLESS_CHAPTER_%d", chapter), blocked);
@@ -415,7 +414,7 @@ void Notebook::showHint(int index) {
}
}
-// CNotebookController::ShowGiveButtonHint: the button for more hints is offered while the timer runs
+// CNotebookController::ShowGiveButtonHint: the more-hints button is offered while the timer runs
void Notebook::showGiveButtonHint(bool timerShowing) {
const Task *task = currentTask();
if (!timerShowing || isAllTasksClosed() || !task || task->_state == Task::kStateClosed) {
@@ -425,7 +424,7 @@ void Notebook::showGiveButtonHint(bool timerShowing) {
}
}
-// CNotebookController::UpdateBookMarks: the tabs on the left (the dialog draws them) and the buttons
+// CNotebookController::UpdateBookMarks: the left tabs (drawn by the dialog) and the buttons
void Notebook::updateBookMarks() {
// The tabs (PIC_INV_BOOKMARK_L / _ACT) are at x 60 and y 117 + 45 * i
_bookmarks.clear();
@@ -450,7 +449,7 @@ void Notebook::updateBookMarks() {
} else {
setElementVisible("GIVE_HINT", false);
setBonusesVisible(false);
- const bool paged = _page == kPageCatalog; // the pages of the catalog (CCatalogManager is not ported)
+ const bool paged = _page == kPageCatalog; // CCatalogManager is not ported
setElementVisible("BTN_TASK_PREV", paged);
setElementVisible("BTN_TASK_NEXT", paged);
}
diff --git a/engines/ngi/fullpipe/notebook.h b/engines/ngi/fullpipe/notebook.h
index 58522d212f1..4a202109480 100644
--- a/engines/ngi/fullpipe/notebook.h
+++ b/engines/ngi/fullpipe/notebook.h
@@ -34,9 +34,8 @@ namespace NGI {
class Task;
-// A cover over a hint that is scratched off with the pointer (CFoil): a grid of 18 pixel pieces. The hint counts as
-// revealed when a tenth of the pieces is gone; the same grid is cleaned in a zigzag when the hint is revealed for the
-// player (CFoil::NextPoint).
+// CFoil: a cover over a hint, scratched off with the pointer; a grid of 18 pixel pieces,
+// the hint counts as revealed when a tenth of them is gone
class Foil {
public:
static const int kPiece = 18;
diff --git a/engines/ngi/fullpipe/scene02.cpp b/engines/ngi/fullpipe/scene02.cpp
index f4c59f355a5..ccfa3367d86 100644
--- a/engines/ngi/fullpipe/scene02.cpp
+++ b/engines/ngi/fullpipe/scene02.cpp
@@ -36,7 +36,7 @@
namespace NGI {
-// Android timers are milliseconds, 83 ms per Windows tick (CSc02Controller: 8300 * rand + 12450 and 41500 * rand + 83000).
+// Android timers are ms, 83 per Windows tick (8300 * rand + 12450, 41500 * rand + 83000)
static int scene02_randomDelay(int rangeTicks, int baseTicks) {
const int scale = g_ngi->isAndroidFullPipe() ? 83 : 1;
return rangeTicks * scale * g_ngi->_rnd.getRandomNumber(32767) / 32767 + baseTicks * scale;
diff --git a/engines/ngi/fullpipe/sceneFinal.cpp b/engines/ngi/fullpipe/sceneFinal.cpp
index dfe257b624c..42579d8008f 100644
--- a/engines/ngi/fullpipe/sceneFinal.cpp
+++ b/engines/ngi/fullpipe/sceneFinal.cpp
@@ -127,7 +127,7 @@ void sceneHandlerFinal_fallCoin() {
}
void updateMusic() {
- if (g_vars->sceneFinal_trackHasStarted && !g_ngi->_mixer->isSoundHandleActive(g_ngi->_soundStream1)) { // loop music
+ if (g_vars->sceneFinal_trackHasStarted && !g_ngi->_mixer->isSoundHandleActive(g_ngi->_soundStream1)) {
sceneHandlerFinal_startMusic("track16.ogg");
}
}
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index d95b3de79b3..c98c4d00d3b 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -566,7 +566,7 @@ bool NGIEngine::initSceneLogic(Scene *scene, int entranceId) {
}
}
-// Android calls the scene controller's OnUpdate(ms) every frame; the shared scene handler gets the same as kMsgUpdate
+// Android calls the controller's OnUpdate(ms) every frame; the scene handler gets kMsgUpdate
// with the elapsed milliseconds in _param.
void NGIEngine::updateSceneLogic(uint32 elapsed) {
// CFPController::OnUpdate
@@ -619,7 +619,7 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
if (!source)
return false;
if (ref.type & 2) {
- // ADDPIC: the picture of this scene, else the one of the source scene, else a copy of it that the source scene owns
+ // ADDPIC: the picture of this scene, else the source scene's, else a copy it owns
PictureObject *picture = scene->findPictureObjectById(ref.objectId, ref.copyId);
if (!picture) {
picture = source->findPictureObjectById(ref.objectId, ref.copyId);
diff --git a/engines/ngi/fullpipe/taskmanager.cpp b/engines/ngi/fullpipe/taskmanager.cpp
index 45f45e4894d..6ed9539f563 100644
--- a/engines/ngi/fullpipe/taskmanager.cpp
+++ b/engines/ngi/fullpipe/taskmanager.cpp
@@ -147,7 +147,7 @@ private:
} // End of anonymous namespace
-// CScene::Message to the notebook scene: its controller (CNotebookController::OnMessage) keeps the task list
+// CScene::Message to the notebook scene (CNotebookController::OnMessage)
void notifyNotebook(const char *message, const Common::String ¶m) {
if (g_ngi->_notebook)
g_ngi->_notebook->onMessage(message, param, nullptr);
@@ -221,7 +221,7 @@ void Task::unblockHint(int index) {
_hints[index].blocked = false;
}
-// The original also writes for a closed task when the index is out of range, which is a bug: ignored
+// the original writes out of range for a closed task (a bug): ignored
void Task::blockHint(int index) {
if (index >= 0 && index < (int)_hints.size())
_hints[index].blocked = true;
@@ -310,7 +310,7 @@ bool TaskManager::init(const Common::Path &path, const ObjectIdList &objectIds)
}
if (g_ngi->_notebook)
- g_ngi->_notebook->sortTasks(); // the original ends CTaskManager's xml loading with CNotebookController::SortTasks
+ g_ngi->_notebook->sortTasks(); // ends the xml loading in the original
return true;
}
@@ -361,7 +361,7 @@ void TaskManager::activateTask(Task *task) {
return;
if (isTaskActivated(task->_id)) {
- // The original tells the notebook again when its list lacks the task (CNotebookController::IsExistTask)
+ // the original tells the notebook again when it lacks the task (IsExistTask)
warnOnce("CTaskManager::ActivateTask of an activated task: notebook list is not ported");
return;
}
@@ -449,7 +449,7 @@ void TaskManager::stopTimer() {
_timer = -1;
}
-// CTaskManager::GetSystemTimeInMSeconds uses the wall clock; the monotonic clock does the same job in a session
+// CTaskManager::GetSystemTimeInMSeconds (wall clock there)
uint32 TaskManager::getSystemTimeMs() const {
return g_system->getMillis();
}
@@ -525,7 +525,7 @@ int TaskManager::getHintUsedNumItem(int chapter, const Common::String &itemFind,
return count;
}
-// CTaskManager::ShowActiveTaskDialog: the notebook, with the tutorial flag of CNotebookController::SetTutorial
+// CTaskManager::ShowActiveTaskDialog
void TaskManager::showActiveTaskDialog(bool tutorial) {
g_ngi->_notebook->setTutorial(tutorial);
g_ngi->pushScene(SC_NOTEBOOK);
diff --git a/engines/ngi/fullpipe/taskmanager.h b/engines/ngi/fullpipe/taskmanager.h
index 6e2ffaf908d..c5983350039 100644
--- a/engines/ngi/fullpipe/taskmanager.h
+++ b/engines/ngi/fullpipe/taskmanager.h
@@ -36,9 +36,8 @@ namespace NGI {
class ObjectIdList;
-// The task list of the 2015 revision (CTask, CTaskManager, data/tasks.xml): what the player has to find, the hints
-// of each task and the hint timer. The task and hint texts (CHyperText) and the notebook that shows them
-// (CNotebookController) are not ported yet, see the warnings.
+// The task list of 2015 (CTask, CTaskManager, data/tasks.xml): tasks, hints and the hint timer.
+// Texts (CHyperText) and the notebook (CNotebookController) are not ported yet, see the warnings
// CTask::HINT
struct TaskHint {
diff --git a/engines/ngi/fullpipe/tremble.cpp b/engines/ngi/fullpipe/tremble.cpp
index e67eecbe8ab..3c7d9803548 100644
--- a/engines/ngi/fullpipe/tremble.cpp
+++ b/engines/ngi/fullpipe/tremble.cpp
@@ -256,7 +256,7 @@ void Tremble::repopulateItems() {
getGameLoaderInteractionController()->getAllRunnableInteractions(scene, _interactions);
- // an item that has neither an interaction that makes it shake nor a listed object goes away, one per call
+ // an item with no interaction and no listed object goes away, one per call
for (TrembleItem *item : _items) {
bool noInteraction = true;
for (Interact *interaction : _interactions) {
diff --git a/engines/ngi/fullpipe/tremble.h b/engines/ngi/fullpipe/tremble.h
index 7babe1d3a64..81f6eedccbc 100644
--- a/engines/ngi/fullpipe/tremble.h
+++ b/engines/ngi/fullpipe/tremble.h
@@ -36,13 +36,13 @@ class Interact;
class ObjectIdList;
class Scene;
-/** CTrembleItem: the shaking effect of one object (an ANI_TREMBLE_EFFECT copy that is drawn over the object). */
+/** CTrembleItem: the shaking effect of one object (an ANI_TREMBLE_EFFECT copy over it) */
class TrembleItem {
public:
TrembleItem(Scene &scene, GameObject *object, AniObject *effect, int offsetX, int offsetY);
~TrembleItem();
- /** the scene owns the effect (Scene::addAni) and removes it when it is destroyed: forget it, used when the scene may be gone */
+ /** the scene owns the effect (Scene::addAni): forget it when the scene may be gone */
void detach() { _effect = nullptr; }
void setDelay(int delay) { _delay = delay; }
/** the effect runs from the delay 0 on and the item is visible until 4000 ms */
@@ -61,11 +61,8 @@ private:
int _offsetY;
};
-/**
- * CTremble (the tutorial hint "tap what can be taken"): the objects whose interaction adds an inventory item and the
- * objects listed in tremble.xml shake one after another. tremble.xml: TREMBLES > INT_OBJ / VIS_OBJ with id, scene and
- * offset (a vector).
- */
+/** CTremble (tutorial hint: tap what can be taken): objects with an item interaction and those of
+ tremble.xml (INT_OBJ / VIS_OBJ: id, scene, offset) shake one after another */
class Tremble {
public:
Tremble();
@@ -73,16 +70,16 @@ public:
bool init(const Common::Path &path, const ObjectIdList &ids);
- /** CFPController::OnUpdate; idle: the tutorial is completed, none is shown and the scene lets the hero be moved */
+ /** CFPController::OnUpdate; idle: no tutorial is shown and the hero can be moved */
void onUpdate(uint32 elapsed, bool idle);
- /** CFPController::OnHide: forgets the items of the scene that is left (the destructor only forgets them, the scenes may be gone) */
+ /** CFPController::OnHide: forgets the items of the scene that is left */
void onHide();
/** CFPController::OnRenderBottom / OnRenderTop */
void preRender();
void postRender();
// the XML data
- Common::Array<uint16> _interactionObjects; // INT_OBJ: always shake when the object has any runnable interaction
+ Common::Array<uint16> _interactionObjects; // INT_OBJ: always shake
Common::Array<uint16> _visibleObjects; // VIS_OBJ: shake while visible
Common::HashMap<uint16, int> _visibleScene; // VIS_OBJ scene
Common::HashMap<uint16, Common::Point> _offsets;
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index c660b83a87e..4cbf3e9906d 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -287,8 +287,8 @@ GameObject::GameObject(GameObject *src) {
_filter = src->_filter;
}
-// The top left corner and the size of the texture of a picture or the current phase of an animation, drawn as in
-// PictureObject::render and AniObject::render. false when there is nothing to draw.
+// Top left and size of the texture of a picture or the current animation phase, as in
+// PictureObject::render and AniObject::render; false when there is nothing to draw
static bool textureQuad(const GameObject *object, Common::Point &topLeft, Dims &size, Common::Point &anchor) {
anchor = Common::Point();
if (object->_objtype == kObjTypePictureObject) {
@@ -688,8 +688,8 @@ void Texture::blitTo(Graphics::ManagedSurface &target, const Common::Point &posi
target.blitFrom(*_bitmap->_surface, origin);
}
-// CTexture::Render (no rotation) and CTexture::RenderRotate: the quad is texture size times the scale, positioned by its top left
-// corner, and the rotation turns it about its center. The window (u0, v0, u1, v1) selects the part of the texture that is drawn.
+// CTexture::Render (no rotation) and RenderRotate: texture size times the scale at the top left,
+// rotation about the center; the window (u0, v0, u1, v1) picks the drawn part of the texture
void Texture::blitTo(Graphics::ManagedSurface &target, const Common::Point &position, const RenderParams ¶ms) const {
if (!_bitmap || !_bitmap->_surface)
return;
diff --git a/engines/ngi/gfx.h b/engines/ngi/gfx.h
index 62b783c818c..d4a7be9d6e6 100644
--- a/engines/ngi/gfx.h
+++ b/engines/ngi/gfx.h
@@ -80,7 +80,7 @@ private:
Bitmap operator=(const Bitmap &);
};
-/** The drawing state of the Android CVisibleObject (+60 rot, +64 mirror, +52/+56 scale, +80..+92 window). */
+/** CVisibleObject drawing state (+60 rot, +64 mirror, +52/+56 scale, +80..+92 window) */
struct RenderParams {
bool mirror = false;
float rotation = 0.0f; // radians, as the XML attribute rot
@@ -120,7 +120,7 @@ public:
/** CVisibleObject::Render: a texture that is not loaded is loaded before it is drawn */
void loadIfNeeded();
void blitTo(Graphics::ManagedSurface &target, const Common::Point &position, bool mirror = false, int angle = 0) const;
- /** CTexture::Render / RenderRotate: scale, rotation about the center, mirror and the visible part of the texture. */
+ /** CTexture::Render / RenderRotate */
void blitTo(Graphics::ManagedSurface &target, const Common::Point &position, const struct RenderParams ¶ms) const;
void blitTo(Graphics::ManagedSurface &target, const Common::Rect &source, const Common::Point &position) const;
void setAOIDs();
@@ -137,7 +137,7 @@ public:
/** a texture without pixels that only has a size (CGridObject) */
void setDimensions(const Dims &size) { _width = size.x; _height = size.y; }
bool isPointInside(int x, int y);
- /** minAlpha: the XML projects (CTexture::Hit) hit a pixel from this alpha on, 0 = any visible pixel */
+ /** minAlpha: XML projects (CTexture::Hit) hit a pixel from this alpha on, 0 = any visible */
bool hit(int x, int y, int minAlpha = 0);
int getColor(int x, int y);
int getPixelAtPosEx(int x, int y);
@@ -197,7 +197,7 @@ class GameObject : public CObject {
float _windowRight = 1.0f;
float _windowBottom = 1.0f;
int _hitAlpha = 128; // XML hitAlpha: the alpha above which a pixel counts as hit
- int _filter = 0; // XML filter: the texture filter of the GPU (0 nearest, 2 linear), no meaning for the software renderer
+ int _filter = 0; // XML filter (0 nearest, 2 linear), no meaning for the software renderer
public:
GameObject();
@@ -218,7 +218,7 @@ class GameObject : public CObject {
void setPosition(Common::Point topLeft);
/** CVisibleObject::GetSize: the size of the drawn part of the texture, scale not applied */
Common::Point getSize() const;
- /** CVisibleObject::GetCenter / SetCenter: the center of the window of the texture (the whole texture by default) */
+ /** CVisibleObject::GetCenter / SetCenter: the center of the texture window */
Common::Point getCenter() const;
void setCenter(Common::Point center);
/** CVisibleObject::IsOnScreenEntirely (127682) / IsOnScreen (12755E) */
@@ -264,10 +264,7 @@ private:
int _oy2;
};
-/**
- * CGridObject (XML GRIDOBJECT): an invisible rectangle (x, y, width, height) that can be hit, found by id and used as the
- * object of an interaction or by the scene logic (GD_SC3_LIFT, ...). A picture without pixels whose hit region is the rectangle.
- */
+/** CGridObject (XML GRIDOBJECT): an invisible hit rectangle, found by id (GD_SC3_LIFT, ...) */
class GridObject : public PictureObject {
public:
GridObject(int width, int height);
diff --git a/engines/ngi/interaction.h b/engines/ngi/interaction.h
index 39642f641ab..708049e1c4e 100644
--- a/engines/ngi/interaction.h
+++ b/engines/ngi/interaction.h
@@ -55,7 +55,7 @@ class Interact : public CObject {
int _weight;
uint _flags;
Common::String _actionName;
- float _activity = 1.0f; // Android CInteract act: below 0.9999 the interaction cannot run (SET_ACTIVE_INTERACTION)
+ float _activity = 1.0f; // CInteract act: below 0.9999 the interaction cannot run
// CInteract fields at _gameVersion >= 201509; _messageQueue (+24) belongs to the scene
/** +12: child DESCRIPTION of the XML node */
@@ -189,13 +189,12 @@ public:
/** CInteractionController::Init (108054): restores ves, act and importance */
void init();
- // CInteractionController::SetActive: the first interaction with this name (in the scene and for the object,
- // when given) gets its activity set to act, or increased by add when add is not 0
+ // CInteractionController::SetActive: the first interaction with this name sets act, or adds it
bool setActive(const Common::String &name, int sceneId, int objectId, float act, float add);
/** CInteractionController::SetVes (106DC8) */
bool setVes(const Common::String &name, int sceneId, int objectId, int weight);
- /** CInteractionController::GetAllRunableInteractions: the interactions of the visible objects of the scene that can run now */
+ /** CInteractionController::GetAllRunableInteractions: those of visible objects that can run */
void getAllRunnableInteractions(Scene *scene, Common::Array<Interact *> &result);
};
diff --git a/engines/ngi/messages.h b/engines/ngi/messages.h
index a8d5d6987eb..0b7f38aa964 100644
--- a/engines/ngi/messages.h
+++ b/engines/ngi/messages.h
@@ -37,13 +37,7 @@ enum QueueFlags {
kBehaviorQueue = 8
};
-/**
- * Kinds of commands (Message::_cmd), in the numbering of the Windows engine.
- *
- * The Android build numbers its command types differently (CMessageQueue::Execute: SHOW is 1,
- * HIDE 2, START_MOVEMENT 3, ...): the XML loader translates them. Names with an Android
- * counterpart use its command names, the others are named after what their handler does.
- */
+/** Kinds of commands (Message::_cmd), Windows numbering; the loader translates Android ones */
enum CommandKind {
kCmdNone = 0,
kCmdStartMovement = 1, // Android START_MOVEMENT
@@ -83,14 +77,7 @@ enum CommandKind {
kCmdSetLogic = 66
};
-/**
- * Messages of the kCmdMessage command (_messageNum) that the engine itself posts or handles,
- * as opposed to the per-scene MSG_* ids of the id list (constants.h).
- *
- * Android has no numbers for them: input arrives through the On* handlers of the controllers,
- * and the few named ones are strings handled by CFPController::OnMessage. Only kMsgResetDest
- * has an original name (MSG_RESETDEST), the others are named after what they do.
- */
+/** Messages of kCmdMessage (_messageNum) that the engine handles itself, not the scene MSG_* ids */
enum MessageKind {
kMsgAniMovementStarted = 23, // posted by AniObject::startMovement / startSliding
kMsgAniMovementEnded = 24, // posted by AniObject::stopMovement
@@ -100,7 +87,7 @@ enum MessageKind {
kMsgLButtonDown = 29,
kMsgLButtonUp = 30,
kMsgMouseMove = 31,
- kMsgUpdate = 33, // Windows: once per frame to all handlers; Android: scene handler only, _param is the elapsed ms (OnUpdate(dt))
+ kMsgUpdate = 33, // Windows: all handlers; Android: scene handler only, _param in ms
kMsgKeyDown = 36, // also keymapper actions, _param is the action or key
kMsgKeyUp = 37,
kMsgPreloadScene = 61,
@@ -308,7 +295,7 @@ class MessageQueue : public CObject {
bool checkGlobalExCommandList2();
int calcDuration(AniObject *obj);
- /** CMessageQueue::GetCommandNumByType: the index of the first command of this kind, -1 when there is none */
+ /** CMessageQueue::GetCommandNumByType: index of the first command of this kind, -1 if none */
int getCommandNumByType(int kind);
/** CMessageQueue::CanInterrupt (10C7A0): state 0 allows it, 1 while no START_MOVEMENT is left */
bool canInterrupt();
diff --git a/engines/ngi/metaengine.cpp b/engines/ngi/metaengine.cpp
index 30b717937d2..6d33bf8386e 100644
--- a/engines/ngi/metaengine.cpp
+++ b/engines/ngi/metaengine.cpp
@@ -53,7 +53,7 @@ Common::Language NGIEngine::getLanguage() const {
}
bool NGIEngine::isAndroidFullPipe() const {
- // Only for the Full Pipe scene logic: the 2015 revision is the one where its scenes differ (see ngi.h)
+ // the scenes of the 2015 revision differ (see ngi.h)
return getGameGID() == GID_FULLPIPE && _gameVersion >= 201509;
}
diff --git a/engines/ngi/motion.cpp b/engines/ngi/motion.cpp
index d23b59b4f3f..5522cc3343f 100644
--- a/engines/ngi/motion.cpp
+++ b/engines/ngi/motion.cpp
@@ -38,8 +38,8 @@ bool MotionController::load(MfcArchive &file) {
void MotionController::lockLink(const char *linkName, bool enable) {
if (g_ngi->_gameVersion >= 201509) {
- // CMctlCompound/CMctlGraph::LockLink: GetGraphLink(name) returns the FIRST link with this title and only that one is
- // (un)locked (CMovGraphLink::Lock: flag 0x20000000). Scenes 6, 11, 20 and 35 have duplicate titles.
+ // LockLink takes the FIRST link of the title (CMovGraphLink::Lock, 0x20000000);
+ // scenes 6, 11, 20 and 35 have duplicate titles
if (MovGraphLink *lnk = getGraphLink(linkName)) {
if (enable)
lnk->_flags |= 0x20000000;
@@ -116,7 +116,7 @@ MovGraphLink *MotionController::getGraphLink(const char *name) {
return nullptr;
}
-// CMctlCompound::GetNearestPoint: the nearest of the points of the graphs (squared distance), (-1, -1) when there is none
+// CMctlCompound::GetNearestPoint: nearest of the graph points, (-1, -1) when none
Common::Point MctlCompound::getNearestWalkPoint(int x, int y) {
Common::Point best(-1, -1);
float bestDistance = 0.0f;
@@ -443,7 +443,7 @@ bool MctlLadder::fillData(AniObject *ani, LmctlAni *movement) {
movement->staticIds = nullptr;
GameVar *v;
- if (g_ngi->_gameVersion >= 201509) // CMctlLadder::FillData: the root data of the ani name, as MctlGraph::fillData
+ if (g_ngi->_gameVersion >= 201509) // CMctlLadder::FillData: as MctlGraph::fillData
v = g_ngi->_gameProject->_walkData.getSubVarByName(g_ngi->_gameProject->_objectIds.findName(static_cast<uint16>(ani->_id)));
else
v = g_ngi->getGameLoaderGameVar()->getSubVarByName(ani->getName());
@@ -624,7 +624,8 @@ MessageQueue *MctlLadder::makeQueue(AniObject *ani, int xpos, int ypos, int fuzz
int oy = topLeft.y;
Movement *upStop = ani->getMovement(_ladmovements[pos]->movementIds->upStopId);
- point = g_ngi->_gameVersion >= 201509 ? upStop->getCenterMovementSize(0, -1) : upStop->getMovementSize(0, -1); // CMovement::GetMovementSize
+ // CMovement::GetMovementSize
+ point = g_ngi->_gameVersion >= 201509 ? upStop->getCenterMovementSize(0, -1) : upStop->getMovementSize(0, -1);
mkQueue.ani = ani;
@@ -1056,8 +1057,8 @@ Common::Array<PathDesc *> *MovGraph::getPaths(AniObject *ani, int x, int y, int
return nullptr;
}
-// CMovGraph::GetNearestPoint(vector2) (@1AD998): for every link the projection of (x, y) on its line (the link ends are
-// not clamped, the reaction region decides), the nearest accepted one wins; without a link hit the nearest node
+// CMovGraph::GetNearestPoint(vector2) (1AD998): projection on every link (ends not clamped),
+// the nearest accepted wins, else the nearest node
Common::Point MovGraph::getNearestWalkPoint(int x, int y) {
float bestX = -1.0f, bestY = -1.0f, best = 0.0f;
const float px = x, py = y;
@@ -2276,7 +2277,7 @@ MessageQueue *MctlGraph::makeWholeQueue(GmctlMqStruct &mctlMQ) {
int MctlGraph::detachObject(AniObject *obj) {
debugC(4, kDebugPathfinding, "MctlGraph::detachObject(%d)", obj->_id);
- // CMctlGraph::DetachObject: CMovGraph::DetachObject, then the entry of the object in the walk table
+ // CMctlGraph::DetachObject: CMovGraph::DetachObject, then the walk table entry
MovGraph::detachObject(obj);
const int idx = getObjIndex(obj->_id);
if (idx < 0)
@@ -2313,7 +2314,7 @@ MessageQueue *MctlGraph::startMove(AniObject *ani, int xpos, int ypos, int fuzzy
if (interrupting)
ani->interruptQueue();
- // CMctlGraph::StartMove is MakeQueue + RunQueueWithAni: MakeQueue stops a running movement itself (stopMovementToPrev)
+ // CMctlGraph::StartMove = MakeQueue + RunQueueWithAni; MakeQueue stops a running movement itself
if (ani->_movement && g_ngi->_gameVersion < 201509) {
if (mq->getCount() <= 1 || mq->getCommandByIndex(0)->_cmd != kCmdSetStatic) {
PicAniInfo picAniInfo;
@@ -2394,8 +2395,8 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
const bool revised = g_ngi->_gameVersion >= 201509;
if (revised && (staticsId & 0x4000)) {
- // The scene code of the Windows games writes the facing of the target statics as 0x4000 | id; the 2015 build
- // passes it as a separate argument (CMctlGraph::MakeQueue a7)
+ // Windows scene code passes the facing as 0x4000 | id, the 2015 build as a separate argument
+ // (CMctlGraph::MakeQueue a7)
mirror = true;
staticsId &= ~0x4000;
}
@@ -2507,7 +2508,7 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
mq->addCommandToEnd(ex);
}
- // 2015: nothing to run, the object stays where the movement was stopped (the original returns the empty queue)
+ // 2015: the object stays where the movement stopped (the original returns the empty queue)
if (!revised)
obj->setPicAniInfo(picAniInfo);
@@ -2655,7 +2656,7 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
mq = nullptr;
}
- // 2015: on success the object stays stopped (the queue starts from there); on failure ResetObjMove restores it
+ // 2015: on success the object stays stopped; on failure ResetObjMove restores it
if (!revised)
obj->setPicAniInfo(picAniInfo);
else if (!mq)
@@ -2873,7 +2874,8 @@ MessageQueue *MctlGraph::makeLineQueue(GmctlMqStruct *info) {
ex->_param = _aniData[info->objectIndex]._ani->_copyId;
ex->_wait = 1;
ex->_excFlags |= 2;
- if (g_ngi->_gameVersion >= 201509) // CMctlGraph::MakeLineQueue: the Show command carries the "mirror" of its movement
+ // CMctlGraph::MakeLineQueue: Show carries the mirror of its movement
+ if (g_ngi->_gameVersion >= 201509)
ex->_auxParam = walk[1]._mirror;
} else {
ex = new Command(
@@ -2950,9 +2952,8 @@ MessageQueue *MctlGraph::makeLineQueue(GmctlMqStruct *info) {
mq->addCommandToEnd(ex);
}
- // The final Show puts the object on the exact destination. The 2015 revision adds it only for an exact destination
- // (flags & 1) and with the "mirror" of the stop movement: without it the command has no facing and the object
- // turns to face right after walking left.
+ // The final Show puts the object on the exact destination; the 2015 build only for an exact
+ // one (flags & 1), with the stop movement's mirror, else it faces right after walking left
if (g_ngi->_gameVersion < 201509 || (info->flags & 1)) {
ex = new Command(_aniData[info->objectIndex]._objectId, kCmdShow, -1, info->destPos.x, info->destPos.y, 0, 1, 0, 0, 0);
ex->_z = info->destZ;
diff --git a/engines/ngi/motion.h b/engines/ngi/motion.h
index dfa858f4910..6ce8b5ecb71 100644
--- a/engines/ngi/motion.h
+++ b/engines/ngi/motion.h
@@ -62,7 +62,7 @@ public:
virtual int checkCurrentPath() { return 0; }
virtual bool canDropInventory(AniObject *ani, int x, int y) { return false; }
virtual bool checkPoint(int x, int y) { return false; }
- // CMovGraph/CMctlCompound::GetNearestPoint(vector2): the nearest point of the graph to (x, y), (-1, -1) when there is none
+ // CMovGraph/CMctlCompound::GetNearestPoint(vector2): nearest graph point, (-1, -1) if none
virtual Common::Point getNearestWalkPoint(int x, int y) { return Common::Point(-1, -1); }
virtual int getStopStatics() { return -1; }
virtual MessageQueue *makeQueue(AniObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId, bool mirror = false) { return 0; }
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index ab446e5192b..39f899f927a 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -467,8 +467,7 @@ Common::Error NGIEngine::run() {
Common::Keymapper *mapper = _system->getEventManager()->getKeymapper();
mapper->disableAllGameKeymaps();
mapper->setGameKeymapState("ngi-default", true);
- // Debugging aid: --boot-param=N starts in scene N (1 to 38) instead of the intro.
- // The scene is entered through its first entrance, so the hero is placed and the entry queue runs.
+ // Debugging aid: --boot-param=N starts in scene N (1 to 38) through its first entrance
int startEntranceId = 0;
startSceneId = start->_sceneId;
if (ConfMan.getInt("boot_param")) {
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index df59855b386..d76063db65b 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -179,16 +179,11 @@ public:
// Detection related functions
const NGIGameDescription *_gameDescription;
- // Engine revision of the game build as YYYYMM (NGIGameDescription::gameVersion, release month of the build; the
- // engine has no version number of its own). Code that differs between builds compares it with the month of the
- // first build known to behave that way, like qdEngine does: if (_gameVersion >= 201509) ...
- // Known thresholds (details and evidence in NGI_PROJECT_NOTES.md):
- // 200502 XML game projects (popovich); data and scenes come from XML files and PNG instead of .gam archives
- // 201509 Full Pipe 2015 (Android): millisecond frame loop, revised motion graph, streamed sound, scene controllers
+ // Engine revision of the build as YYYYMM, compared in code that differs between builds
+ // (200502 XML projects, 201509 Full Pipe 2015 Android; NGI_PROJECT_NOTES.md)
const uint32 _gameVersion;
bool usesXMLProject() const { return _gameVersion >= 200502; }
- // Full Pipe scene logic only (fullpipe/*.cpp): the scenes of the 2015 revision differ from the older ones.
- // Common engine code must compare _gameVersion instead.
+ // Full Pipe scene logic only (fullpipe/*.cpp); common code compares _gameVersion instead
bool isAndroidFullPipe() const;
uint32 getFeatures() const;
bool isDemo();
@@ -416,7 +411,7 @@ public:
Common::String getState(const Common::String &name);
void sceneAutoScrolling();
- // XML projects: runs the shared per-scene logic (initScene, message handler) for scenes that have it.
+ // XML projects: the shared per-scene logic (initScene, message handler)
bool initSceneLogic(Scene *scene, int entranceId);
void updateSceneLogic(uint32 elapsed);
bool doSetScene(const Entrance &entrance);
diff --git a/engines/ngi/physics.h b/engines/ngi/physics.h
index bcea3cdeadb..38fbd9fe993 100644
--- a/engines/ngi/physics.h
+++ b/engines/ngi/physics.h
@@ -29,10 +29,7 @@
namespace NGI {
-// Physics of the Android engine (Box2D): the world (CPhysListener), the objects, their geometry, the joints and the debug drawing.
-// Generated by scripts/ngi_gen_stubs.py physics from the Android class inventory: every method of the Android classes is
-// declared here and warns "STUB/untested: Class::method" once when called. The parameter types are what the decompiler
-// shows (approximations), the field layouts are not known yet. Replace a stub by the real code and drop its warning.
+// Android physics (Box2D), stubs from scripts/ngi_gen_stubs.py (each warns "STUB/untested")
/** Android SGeomParams: the layout is not known yet. */
struct GeomParams {
@@ -103,7 +100,7 @@ public:
void findObjectsInRegion(int arg2, int arg3, int arg4, int arg5, int *arg6); // 119B60
};
-/** Android CPhysicalObject: XML PHYSOBJ: a body with geometries, a CVisibleObject in the original */
+/** Android CPhysicalObject (XML PHYSOBJ): a body with geometries */
class PhysicalObject : public GameObject {
public:
PhysicalObject();
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 48472caa0e7..20302c26ad2 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -968,8 +968,8 @@ void Scene::render(bool clear) {
sortRenderables(visibleObjects);
- // CScene::Render: the controller draws its bottom layer, then come the objects with z >= 0 (sorted from the back to the
- // front), the scene hook (OnRender), the GUI, the physics, the objects with z < 0 and the top layer of the controller
+ // CScene::Render: controller bottom layer, objects with z >= 0, OnRender hook, GUI, physics,
+ // objects with z < 0, controller top layer
if (_controller)
_controller->onRenderBottom(Common::Point(_x, _y));
bool renderedLayer = false;
@@ -1014,8 +1014,8 @@ void Scene::render(bool clear) {
drawContent(-1, priority, false);
}
-// CScene::RenderDbg, CVisibleObject::RenderDbg (a red outline of the quad), CHitregionObject::RenderDbg (a green outline of the region),
-// CZController::RenderDbg
+// CScene::RenderDbg, CVisibleObject::RenderDbg (red quad outline),
+// CHitregionObject::RenderDbg (green region outline), CZController::RenderDbg
void Scene::renderDebug() {
Graphics::ManagedSurface &target = g_ngi->_backgroundSurface;
const uint32 red = target.format.RGBToColor(255, 0, 0);
@@ -1336,7 +1336,7 @@ void Scene::renderMiddleLayer() {
if (_guiManager)
_guiManager->render(g_ngi->_backgroundSurface);
if (_physListener)
- _physListener->render(); // CPhysListener::Render does nothing, the physical objects are drawn as objects
+ _physListener->render(); // CPhysListener::Render does nothing, objects draw themselves
}
void Scene::updateScrolling() {
@@ -1636,7 +1636,7 @@ bool Scene::updateObjects(int counterdiff) {
changed |= _guiManager->update(counterdiff);
for (uint i = 0; i < _renderableAnis.size(); i++)
changed |= _renderableAnis[i]->update(counterdiff);
- // CScene::Update: after the objects and the GUI come the physics, the 8 direction controller and the z controller
+ // CScene::Update: after the objects and the GUI: physics, 8 direction controller, z controller
if (_physListener)
_physListener->update(counterdiff);
if (_zController)
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 62a6b1a2f48..392bca2e0f7 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -77,14 +77,14 @@ class Scene : public Background {
uint unloadAdditional();
Common::Array<Entrance> _entrances;
int16 _heroId = 0;
- /** CScene::GetSceneDims (CScene+312): the SCENE attributes width and height, the screen size when missing (Android) */
+ /** CScene::GetSceneDims (+312): SCENE width and height, the screen size when missing */
Dims _dims;
/** +348 (drawOffset): 0 draws into the widescreen margins, else black bars; -1 decides by width */
int _drawOffset = -1;
/** The widescreen flag of CRender::SetSrcRect (CRender +32): black bars over the margins */
bool hasWidescreenBars() const;
Common::ScopedPtr<GuiManager> _guiManager;
- /** XML PHYSICS (CScene+56): the Box2D world, drawn between the layers; not implemented yet (physics.h) */
+ /** XML PHYSICS (+56): the Box2D world, not implemented yet (physics.h) */
Common::ScopedPtr<PhysListener> _physListener;
/** XML PHYSOBJ / PHYSGROUND, owned (stubs, physics.h) */
Common::Array<PhysicalObject *> _physicalObjects;
@@ -167,7 +167,7 @@ class Scene : public Background {
void init();
virtual void render(bool clear = true);
void renderMiddleLayer();
- /** CScene::RenderDbg (nothing in the original calls it): outlines, enabled with --debugflags=bounds */
+ /** CScene::RenderDbg: outlines, enabled with --debugflags=bounds */
void renderDebug();
void drawContent(int minPri, int maxPri, bool drawBG);
void updateScrolling();
diff --git a/engines/ngi/sceneobjects.h b/engines/ngi/sceneobjects.h
index ad4cef3ce91..a0a2f92296d 100644
--- a/engines/ngi/sceneobjects.h
+++ b/engines/ngi/sceneobjects.h
@@ -28,10 +28,8 @@
namespace NGI {
-// Scene object types and helpers of the Android engine that the scene drawing refers to: the objects the XML builder creates besides PICTURE and ANI, the 8 direction grid, the composition of objects.
-// Generated by scripts/ngi_gen_stubs.py sceneobjects from the Android class inventory: every method of the Android classes is
-// declared here and warns "STUB/untested: Class::method" once when called. The parameter types are what the decompiler
-// shows (approximations), the field layouts are not known yet. Replace a stub by the real code and drop its warning.
+// Android scene object types: XML-built objects, the 8 direction grid, compositions.
+// Generated by scripts/ngi_gen_stubs.py; each method warns "STUB/untested" once.
class Selection;
class HitregionObject;
diff --git a/engines/ngi/stateloader.cpp b/engines/ngi/stateloader.cpp
index 1338d8a80f6..9d8ccfaa1ef 100644
--- a/engines/ngi/stateloader.cpp
+++ b/engines/ngi/stateloader.cpp
@@ -39,9 +39,8 @@
namespace NGI {
-// Frees a GameVar tree that was loaded from a savegame. Only the links to the children (_subVars, _nextVarObj)
-// can be trusted: the links back to the parent and the previous sibling of savegames written by ScummVM point to
-// the wrong objects (see MfcArchive::writeObject), so the destructor must not follow them.
+// Frees a GameVar tree loaded from a savegame. Only the links to the children can be trusted: the
+// parent and previous sibling links of ScummVM savegames are wrong (see MfcArchive::writeObject)
static void deleteLoadedVars(GameVar *var) {
GameVar *child = var->_subVars;
@@ -122,7 +121,7 @@ bool GameLoader::readSavegame(const char *fname) {
}
addVar(var, v);
- // The values are merged into the live tree, the loaded one is not needed any more (the original frees it too)
+ // the values are merged into the live tree, the loaded one goes (as in the original)
if (var)
deleteLoadedVars(var);
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 5e7a4a134d1..1808445d408 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -154,7 +154,6 @@ AniObject::AniObject(AniObject *src) : GameObject(src) {
if (src->_movements[i]->_currMovement) {
// This is weird code. Logically it should be
- // newmov = new Movement(src->getMovement(src->getMovementIdById(src->_movements[i]->_id)), this);
newmov = new Movement(getMovement(src->getMovementIdById(src->_movements[i]->_id)), this);
newmov->_id = src->_movements[i]->_id;
} else {
@@ -950,7 +949,6 @@ bool AniObject::updateAnimation(int counterdiff) {
setPos(_movement->_x, _movement->_y);
_counter = _initialCounter;
_movement->_curPhase->enter(_id);
- // Android ends the movement as soon as the next statics takes over.
} else if (timedMovement && _movement->_cycled && _movement->_curFrame >= lastFrame) {
_movement->setFrame(0, _flags & 8);
setPos(_movement->_x, _movement->_y);
@@ -1207,9 +1205,8 @@ L12:
}
}
-// CMovement::Stop of a movement that is cut before its last phase (a walk after a partial cycle): the ending statics
-// goes to the origin of the current phase plus the last step of the movement (mirrored: backwards). Nothing of the
-// unplayed phases is added. A statics is placed by its anchor, the origin plus its some-offset.
+// CMovement::Stop of a movement cut before its last phase (a walk): the end statics goes to
+// the phase origin plus the last step (mirrored: backwards)
void AniObject::stopCutMovement(const Common::Point &pending) {
Statics *statics = _movement->_nextStatic;
const bool mirrored = (_flags & 8) != 0;
@@ -1220,7 +1217,7 @@ void AniObject::stopCutMovement(const Common::Point &pending) {
_statics = statics;
_movement = nullptr;
_targetFrame = -1;
- // A statics is placed by its anchor: mirrored, the sprite extends to the right of the anchor by the some-offset
+ // the statics is placed by its anchor; mirrored, the sprite extends right of it by the some-offset
setPos(mirrored ? originX - some.x : originX + some.x, originY + some.y);
}
@@ -1232,9 +1229,8 @@ bool AniObject::isSlidingEnd(float endX, float endY) const {
return _movement->_cycled;
}
-// CAniObject::StopMovementToPrev (movement stopped by a new walk or a script): the object goes back to the previous statics of the
-// running movement, keeping the horizontal center of the sprite; the vertical position is that of the statics at the start of the
-// movement (the movement origin minus the steps taken since: the phase offsets and the sliding steps).
+// CAniObject::StopMovementToPrev: back to the previous statics, same horizontal center; the y is
+// that of the movement start minus the steps taken since
void AniObject::stopMovementToPrev(bool keepSounds, bool exact) {
if (!_movement || !(_flags & 1))
return;
@@ -1273,7 +1269,7 @@ void AniObject::stopMovementToPrev(bool keepSounds, bool exact) {
if (mov->_mirrorPrev)
_flags ^= 8;
- // Anchor of the statics for the kept center: left edge + some-offset, mirrored right edge - some-offset
+ // anchor for the kept center: left + some-offset, mirrored right - some-offset
const bool nowMirrored = (_flags & 8) != 0;
setPos(nowMirrored ? centerX + previous.x / 2 - some.x : centerX - previous.x / 2 + some.x, originY + some.y);
@@ -1903,7 +1899,7 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
if (timedMovement && _movement && (_flags & 1)) {
debugC(1, kDebugInfo, "INFO t %u movement %d of %d is started while %d runs (frame %d of %d, queue %d, new queue %d)", g_system->getMillis(), movementId, _id,
_movement->_id, _movement->_curFrame, (int)_movement->_phases.size(), _queue ? _queue->_id : 0, messageQueueId);
- stopMovementToPrev(false); // CAniObject::StartMovement: a running movement is rewound to its previous statics first
+ stopMovementToPrev(false); // CAniObject::StartMovement: rewind a running movement first
}
if (mov == _movement) {
@@ -1922,7 +1918,6 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
if (!timedMovement)
reverse = (_flags & 0x40) != 0;
if (timedMovement && !_movement) {
- // SetStatic reflects a change of facing about the old texture's center.
const bool startMirror = reverse ? mov->_mirrorNext : mov->_mirrorPrev;
const bool prevMirror = mirror != startMirror;
if (_statics && prevMirror != ((_flags & 8) != 0)) {
@@ -2378,8 +2373,8 @@ Common::Point Movement::getCurrDynamicPhaseXY() const {
}
Common::Point Movement::getCenterMovementSize(int idx, int dynidx) {
- // CMovement::GetMovementSize: the displacement of the sprite center, from the start (idx 0: the previous
- // statics, idx 1: the current phase) to the phase dynidx (-1: the end). Same terms as getCenterDisplacement.
+ // CMovement::GetMovementSize: displacement of the sprite center from the start (idx 0:
+ // previous statics, idx 1: current phase) to the phase dynidx (-1: the end)
const int last = (int)_phases.size() - 1;
const int target = dynidx < 0 || dynidx > last ? last : dynidx;
Dims startSize;
@@ -2437,13 +2432,13 @@ Common::Point Movement::getMovementSize(int idx, int dynidx) {
}
void Movement::getCenterDisplacement(float &dx, float &dy) const {
- // XML steps move texture origins. The Android motion graph measures center to center.
+ // XML steps move texture origins, the Android motion graph measures center to center
const Dims prev = _prevStatic->getDimensions();
const Dims next = _nextStatic->getDimensions();
dx = _prevStepX + (next.x - prev.x) * 0.5f;
dy = _prevStepY + (next.y - prev.y) * 0.5f;
- // Starting the movement uses the previous step in place of frame zero's offset.
- // The last offset in the engine's phase list is the step into the ending statics.
+ // the start uses the previous step instead of frame zero's offset; the last offset
+ // is the step into the end statics
for (uint i = 1; i < _framePosOffsets.size(); ++i) {
dx += _framePosOffsets[i].x;
dy += _framePosOffsets[i].y;
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index feeaf87c2ab..d0701f218f0 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -159,7 +159,7 @@ class Movement : public GameObject {
Dims getPhaseSize(int phaseIndex) const;
Common::Point getMovementSize(int idx, int dynidx);
- // 2015 revision (CMovement::GetMovementSize): displacement of the sprite center, used to plan walks
+ // 2015 (CMovement::GetMovementSize): displacement of the sprite center, used to plan walks
Common::Point getCenterMovementSize(int idx, int dynidx);
void getCenterDisplacement(float &dx, float &dy) const;
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index ca6e04076ce..cae40ee30ed 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -136,7 +136,7 @@ private:
return true;
if (node->depth == 2 && (node->name == "Test_walk" || node->name == "Test_Ladder")) {
- // One variable per object: ANI_MAN has Test_Ladder (CMctlLadder::FillData) and then Test_walk (CMctlGraph::FillData)
+ // One variable per object: ANI_MAN has Test_Ladder (CMctlLadder) and then Test_walk (CMctlGraph)
GameVar *object = _walkData.getSubVarByName(parent->name);
if (!object)
object = _walkData.addSubVarAsInt(parent->name, 0);
@@ -213,8 +213,7 @@ private:
}
};
-// data.xml: per-scene data (flies, cursors, scroll borders). It is stored in the layout of the Windows game
-// variables (SC_N / Fliers / flyIdleRegion ...) so the shared scene code reads it unchanged.
+// data.xml: per-scene data (flies, cursors, scroll borders), in the Windows variable layout
class XMLSceneDataParser : public Common::XMLParser {
public:
explicit XMLSceneDataParser(GameVar &root) : _root(root) {}
@@ -1030,8 +1029,7 @@ private:
_inventoryNodes.push_back(child);
}
- // CScene::SetXmlData ADDPIC: a picture of another scene (usually SC_COMMON) shown in this one; the attributes that are given
- // replace its position, z and flags when the scene is entered (see GameLoader::doSetScene, like ADDANI)
+ // CScene::SetXmlData ADDPIC: a picture of another scene; given attributes override on entry
bool parserCallback_ADDPIC(ParserNode *node) {
PicAniInfo ref;
ref.type = 2;
@@ -1144,8 +1142,7 @@ private:
return true;
}
- // ITEM of ZCONTROLLER (CZController::CZController): IdScene names the scene of an object that is not in this one.
- // The ITEM of PRELOAD is skipped with its parent.
+ // ITEM of ZCONTROLLER (CZController::CZController); the ITEM of PRELOAD is skipped with its parent
bool parserCallback_ITEM(ParserNode *node) {
if (getParentNode(node)->name == "PRELOAD") {
// CPreloadManager::AddItems (11AB0C): the scene, the animation and the movement
@@ -1326,7 +1323,7 @@ private:
return false;
picture->_picture = new Texture();
- // CPictureObject ignores a "scene" attribute (sc_19 has one that names scene 18 while the texture is in scene 19).
+ // CPictureObject ignores a "scene" attribute (sc_19 names scene 18 while the texture is in 19)
const Common::String resource = Common::String::format("%08hu/%08hu",
getParentNode(node)->name == "INVENTORY" ? 0 : static_cast<uint16>(_scene._sceneId), static_cast<uint16>(picture->_id));
loadTexture(*picture->_picture, resource, isLocalized(*node));
@@ -1509,8 +1506,7 @@ private:
if (idProperty) {
int16 id;
if (!readId(node->values.getValOrDefault(idProperty), id)) {
- // The shipped data names a few movements that exist nowhere (MV_MAN6_PUSHBUTTON, ...). The original
- // resolves them to id 0 and does nothing, so the command is dropped.
+ // the data names movements that exist nowhere (MV_MAN6_PUSHBUTTON ...); the original uses id 0
warning("Dropping %s command with unknown %s '%s'", kind.c_str(), idProperty, node->values.getValOrDefault(idProperty).c_str());
return true;
}
@@ -1557,7 +1553,7 @@ private:
// XML bit 0 and NGI runtime bit 2 both mean visible.
object._flags = (object._objectFlags & 1) ? 4 : 0;
object._cnum = _objectOrder++;
- // CVisibleObject::Init. fitTo shifts the object by the widescreen offsets of CRender, which are 0 at the base size.
+ // CVisibleObject::Init: fitTo shifts by the CRender widescreen offsets (0 at the base size)
object._rotation = strtof(node.values.getValOrDefault("rot").c_str(), nullptr);
object._hitAlpha = atoi(node.values.getValOrDefault("hitAlpha", "128").c_str());
object._filter = atoi(node.values.getValOrDefault("filter").c_str());
@@ -1859,8 +1855,7 @@ static void setManSpeed(GameVar *gameVar, float speed) {
}
Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTag *&start, int &width, int &height) {
- // XML projects may ship in zip containers (the 2015 build: an APK and an OBB), later entries win, so the
- // containers are added in reverse order of the detection entry. Loose files in the game directory also work.
+ // XML projects may ship in zip containers (APK and OBB), later entries win: added in reverse order
const auto &files = g_ngi->_gameDescription->desc.filesDescriptions;
const Common::FSNode gameDirectory(ConfMan.getPath("path"));
int fileCount = 0;
diff --git a/engines/ngi/zcontroller.cpp b/engines/ngi/zcontroller.cpp
index e13c0505c38..0325d0d3cd5 100644
--- a/engines/ngi/zcontroller.cpp
+++ b/engines/ngi/zcontroller.cpp
@@ -35,7 +35,7 @@ void ZController::addItem(GameObject *object, int startY, bool changeZ, bool cha
item.startY = startY;
item.changeZ = changeZ;
item.changeY = changeY;
- // the original takes the bottom edge when the object has neither a start value nor follows its position
+ // the original takes the bottom edge if there is no start value and no follow
item.pending = !changeY && startY == 0;
_items.push_back(item);
}
diff --git a/engines/ngi/zcontroller.h b/engines/ngi/zcontroller.h
index a44396e06f0..4f8e3fce68b 100644
--- a/engines/ngi/zcontroller.h
+++ b/engines/ngi/zcontroller.h
@@ -29,10 +29,7 @@ namespace NGI {
class GameObject;
-/**
- * CZController (XML ZCONTROLLER of a scene): keeps the objects in front of or behind each other by the bottom edge of
- * their pictures (the one lower on the screen is drawn in front). Not used by the 2015 data, so it is untested.
- */
+/** CZController (XML ZCONTROLLER): orders objects by bottom edge. Untested */
class ZController {
public:
struct Item {
@@ -40,7 +37,7 @@ public:
int startY; // the bottom edge, recomputed every update when changeY
bool changeZ; // the object gets its z from the order
bool changeY; // the bottom edge follows the object
- bool pending; // startY is taken from the object at the first update (its texture is not known when the XML is read)
+ bool pending; // startY is read from the object at the first update (no texture yet at XML load)
};
/** CZController::CZController, one ITEM */
More information about the Scummvm-git-logs
mailing list