ScummVM API documentation
flow.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef HARVESTER_FLOW_H
23#define HARVESTER_FLOW_H
24
25#include "common/array.h"
26#include "common/error.h"
27#include "common/rect.h"
28#include "common/str.h"
29#include "harvester/cheats.h"
30#include "harvester/dialogue/dialogue.h"
31#include "harvester/inventory.h"
32#include "harvester/menu/menu.h"
33#include "harvester/scene/scene.h"
34#include "harvester/script/script.h"
35
36namespace Common {
37struct Event;
38}
39
40namespace Harvester {
41
42class HarvesterEngine;
43struct IndexedBitmap;
44
45class Flow {
46public:
47 explicit Flow(HarvesterEngine &engine);
48
49 bool load();
50 bool buildDialogueSaveStateBlob(Common::Array<byte> &blob, uint32 saveVersion);
51 bool loadDialogueSaveStateBlob(const Common::Array<byte> &blob, uint32 saveVersion);
52 Common::Error run();
53 Common::Error showCdChangePrompt(int discNumber);
54 bool handleSystemEvent(const Common::Event &event, Common::Error &result);
55
56 const MenuTextConfig &getMenuTextConfig() const { return _menuTextConfig; }
57 const Common::Point &getMousePos() const { return _mousePos; }
58 uint getQuickTipCount() const { return _quickTips.size(); }
59 const Common::String &getQuickTip(uint index) const { return _quickTips[index]; }
60 bool hasRoomNpcHandler(const Common::String &npcName) const { return _dialogue.hasRoomNpcHandler(npcName); }
61 bool isNestedRoomLoop() const { return _roomLoopDepth > 1; }
62 RoomHoverState getRoomHoverState(const SceneState &scene) const;
63 void logStartupRoomProbe(const SceneState &scene, const Common::String &entranceName);
64
65 void executeStartupAudioCommands(const Common::Array<AudioCommand> &commands);
66 void queueDialogueInteraction(const InteractionResult &interaction);
67 void requestGameOverReturn();
68
69 bool hasQueuedDebugInteraction() const { return _hasQueuedDebugInteraction; }
70 bool queueDebugInteraction(const InteractionResult &interaction);
71 bool requestDebugRoomChange(const Common::String &roomName, int discNumber);
72
73 Common::Error runDemoEnding();
74 Common::Error runHelpScreen(const byte *palette, float paletteBrightness);
75 Common::Error runRoomMenu(const IndexedBitmap &backdrop, const byte *palette,
76 float paletteBrightness, bool canSaveGame);
77 Common::Error runRoomNpcDialogue(const IndexedBitmap &backdrop, const byte *palette,
78 float paletteBrightness, const ScriptExecutionContext &executionContext,
79 const NpcRecord &npc, const Common::String &usedItemName);
80 Common::Error runRoomLoop(const Common::String &entranceName);
81 Common::Error resolveRoomTransitionTarget(const Common::String &targetName, Common::String &resolvedTargetName);
82
83 bool populateRoomSceneEntities(RoomSetupState &state,
84 const Common::Array<ObjectRecord> &drawableObjects,
85 const Common::Array<AnimRecord> &drawableAnimations);
86 Common::Error beginRoomSetupTransition();
87 Common::Error waitForRoomSetupTransitionHold();
88 Common::Error fadeInRoomScene(const byte *palette, float targetBrightness);
89 void resetCursorAnimationSequence();
90 bool tickRuntimeEntities();
91
92 bool takeQueuedDialogueInteraction(InteractionResult &interaction);
93 bool takeQueuedDebugInteraction(InteractionResult &interaction);
94
95 void prepareForNewGame();
96 void requestNewGameRestart();
97 bool takePendingNewGameRestart();
98 bool takePendingGameOverReturn();
99 void requestMainMenuReturn();
100 bool hasPendingMainMenuReturn() const;
101 bool takePendingMainMenuReturn();
102 void requestCloseupParentRestart();
103 bool takePendingCloseupParentRestart();
104 bool hasPendingDebugRoomChange() const { return !_pendingDebugRoomName.empty(); }
105 void resetRoomNpcDialogueState();
106
107private:
108 bool loadQuickTips();
109 bool loadMenuItems();
110 Common::Error runQuickTips();
111 Common::Error runQuickTipsOverlay(const SceneState &scene);
112 Common::Error runDemoIntroduction();
113 Common::Error runMainMenu();
114 Common::Error runTownMapSelector(const Common::String &mapEntryName, Common::String &destinationEntranceName);
115 bool ensureCursorEntity();
116 Common::Error fadePalette(const byte *palette, float fromBrightness, float toBrightness);
117 bool waitForPaletteFadeTick(uint32 startTick, Common::Error &result);
118 bool pumpTransitionEvents(Common::Error &result);
119 bool hasPendingNewGameRestart() const;
120 void clearPendingNewGameRestart();
121 bool hasPendingGameOverReturn() const;
122 void clearPendingGameOverReturn();
123 void clearPendingMainMenuReturn();
124 bool hasPendingCloseupParentRestart() const;
125 void clearPendingCloseupParentRestart();
126 Common::String takePendingDebugRoomChange(int &discNumber);
127
128 HarvesterEngine &_engine;
131 MenuTextConfig _menuTextConfig;
132 Common::Point _mousePos;
133 DialogueSystem _dialogue;
134 InventorySystem _inventory;
135 MenuSystem _menu;
136 CheatSystem _cheats;
137 SceneRunner _room;
138 InteractionResult _queuedDialogueInteraction;
139 bool _hasQueuedDialogueInteraction = false;
140 InteractionResult _queuedDebugInteraction;
141 bool _hasQueuedDebugInteraction = false;
142 bool _pendingNewGameRestart = false;
143 bool _pendingGameOverReturn = false;
144 bool _pendingMainMenuReturn = false;
145 bool _pendingCloseupParentRestart = false;
146 Common::String _pendingDebugRoomName;
147 int _pendingDebugRoomDisc = 0;
148 uint _roomLoopDepth = 0;
149 uint32 _roomSetupTransitionShownTick = 0;
150};
151
152} // End of namespace Harvester
153
154#endif // HARVESTER_FLOW_H
size_type size() const
Definition: array.h:316
Definition: error.h:81
Definition: str.h:59
Definition: cheats.h:52
Definition: dialogue.h:44
Definition: flow.h:45
Definition: harvester.h:47
Definition: inventory.h:54
Definition: menu.h:90
Definition: scene.h:42
Definition: script.h:269
Definition: algorithm.h:29
Definition: events.h:218
Definition: rect.h:144
Definition: bitmap.h:33
Definition: script.h:311
Definition: menu.h:45
Definition: script.h:132
Definition: room_support.h:57
Definition: script.h:237
Definition: room_support.h:46