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/dialogue.h"
30 #include "harvester/inventory.h"
31 #include "harvester/menu.h"
32 #include "harvester/room.h"
33 #include "harvester/script.h"
34 
35 namespace Common {
36 struct Event;
37 }
38 
39 namespace Harvester {
40 
41 class HarvesterEngine;
42 class DialogueFlowAccess;
43 class RoomInteractionProcessor;
44 struct IndexedBitmap;
45 
46 class Flow {
47 public:
48  explicit Flow(HarvesterEngine &engine);
49 
50  bool load();
51  bool buildDialogueSaveStateBlob(Common::Array<byte> &blob, uint32 saveVersion);
52  bool loadDialogueSaveStateBlob(const Common::Array<byte> &blob, uint32 saveVersion);
53  Common::Error run();
54 
55 private:
56  friend class HarvesterEngine;
57  friend class DialogueFlowAccess;
58  friend class DialogueSystem;
59  friend class InventorySystem;
60  friend class MenuSystem;
61  friend class RoomInteractionProcessor;
62  friend class RoomSystem;
63 
64  bool loadQuickTips();
65  bool loadMenuItems();
66  Common::Error runQuickTips();
67  Common::Error runDemoIntroduction();
68  Common::Error runDemoEnding();
69  Common::Error runMainMenuStub();
70  Common::Error runRoomMenuStub(const IndexedBitmap &backdrop, const byte *palette,
71  float paletteBrightness, bool canSaveGame);
72  Common::Error runRoomNpcDialogue(const IndexedBitmap &backdrop, const byte *palette,
73  float paletteBrightness, const NpcRecord &npc, const Common::String &usedItemName);
74  Common::Error runTownMapSelector(const Common::String &mapEntryName, Common::String &destinationEntranceName);
75  Common::Error runRoomLoop(const Common::String &entranceName);
76  Common::Error resolveRoomTransitionTarget(const Common::String &targetName, Common::String &resolvedTargetName);
77  bool ensureCursorEntity();
78  bool populateRoomSceneEntities(RoomSetupState &state,
79  const Common::Array<ObjectRecord> &drawableObjects,
80  const Common::Array<AnimRecord> &drawableAnimations);
81  Common::Error beginRoomSetupTransition();
82  Common::Error waitForRoomSetupTransitionHold();
83  Common::Error fadeInRoomScene(const byte *palette, float targetBrightness);
84  Common::Error fadePalette(const byte *palette, float fromBrightness, float toBrightness);
85  bool pumpTransitionEvents(Common::Error &result);
86  void executeStartupAudioCommands(const Common::Array<AudioCommand> &commands);
87  void queueDialogueInteraction(const InteractionResult &interaction);
88  bool takeQueuedDialogueInteraction(InteractionResult &interaction);
89  bool hasQueuedDebugInteraction() const { return _hasQueuedDebugInteraction; }
90  bool queueDebugInteraction(const InteractionResult &interaction);
91  bool takeQueuedDebugInteraction(InteractionResult &interaction);
92  void prepareForNewGame();
93  void requestNewGameRestart();
94  bool hasPendingNewGameRestart() const;
95  bool takePendingNewGameRestart();
96  void clearPendingNewGameRestart();
97  void requestGameOverReturn();
98  bool hasPendingGameOverReturn() const;
99  bool takePendingGameOverReturn();
100  void clearPendingGameOverReturn();
101  void requestMainMenuReturn();
102  bool hasPendingMainMenuReturn() const;
103  bool takePendingMainMenuReturn();
104  void clearPendingMainMenuReturn();
105  void requestCloseupParentRestart();
106  bool hasPendingCloseupParentRestart() const;
107  bool takePendingCloseupParentRestart();
108  void clearPendingCloseupParentRestart();
109  bool requestDebugRoomChange(const Common::String &roomName);
110  bool hasPendingDebugRoomChange() const { return !_pendingDebugRoomName.empty(); }
111  Common::String takePendingDebugRoomChange();
112  void resetRoomNpcDialogueState();
113  void resetCursorAnimationSequence();
114  bool tickRuntimeEntities();
115  bool handleSystemEvent(const Common::Event &event, Common::Error &result);
116 
117  HarvesterEngine &_engine;
120  Common::Point _mousePos;
121  DialogueSystem _dialogue;
122  InventorySystem _inventory;
123  MenuSystem _menu;
124  RoomSystem _room;
125  InteractionResult _queuedDialogueInteraction;
126  bool _hasQueuedDialogueInteraction = false;
127  InteractionResult _queuedDebugInteraction;
128  bool _hasQueuedDebugInteraction = false;
129  bool _pendingNewGameRestart = false;
130  bool _pendingGameOverReturn = false;
131  bool _pendingMainMenuReturn = false;
132  bool _pendingCloseupParentRestart = false;
133  Common::String _pendingDebugRoomName;
134  uint _roomLoopDepth = 0;
135  uint32 _roomSetupTransitionShownTick = 0;
136 };
137 
138 } // End of namespace Harvester
139 
140 #endif // HARVESTER_FLOW_H
Definition: flow.h:46
Definition: script.h:237
Definition: dialogue.h:44
Definition: str.h:59
Definition: art.h:31
Definition: menu.h:40
Definition: room_interaction.h:56
Definition: script.h:132
Definition: error.h:81
Definition: art.h:35
Definition: room.h:35
Definition: inventory.h:53
Definition: events.h:218
Definition: algorithm.h:29
Definition: rect.h:144
Definition: harvester.h:47
Definition: script.h:288