ScummVM API documentation
interaction.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_INTERACTION_H
23 #define HARVESTER_INTERACTION_H
24 
25 #include "common/error.h"
26 #include "harvester/bitmap.h"
27 #include "harvester/room_support.h"
28 #include "harvester/saveload.h"
29 
30 namespace Harvester {
31 
32 class Flow;
33 class HarvesterEngine;
34 class InventorySystem;
35 class Interaction;
36 class SceneEntities;
37 class Player;
38 struct IndexedBitmap;
39 
40 extern const char *const kExitCloseupPendingRoomChange;
41 
43 public:
44  virtual ~InteractionCallbacks() {}
45 
46  virtual bool refreshCurrentScene(bool preservePlayerPlacement) = 0;
47  virtual bool applyCurrentRoomRuntimeMutationsInPlace(bool preservePaletteState) = 0;
48  virtual void syncGlobalTimerEntities(const Common::Array<TimerRecord> &previousTimerRecords) = 0;
49  virtual bool captureDialogueBackdrop(IndexedBitmap &dialogueBackdrop) = 0;
50  virtual Common::Error showCdChangePrompt(int discNumber) = 0;
51  virtual Common::Error runRoomExitCommands() = 0;
52  virtual Common::Error applyLightingCommand(StartupLightingCommand lightingCommand) = 0;
53  virtual void applyPlayerGotoXZ(int x, int z) = 0;
54  virtual Common::Error runModalShowText(const ResolvedText &modalText) = 0;
55  virtual void resetIdleState() = 0;
56  virtual void notePlayerActivity() = 0;
57  virtual void stopPlayerRegionInteraction() = 0;
58  virtual void startPlayerDefeatSequence(const char *reason, const Common::String &sourceName,
59  int damageType) = 0;
60 };
61 
63 public:
65  SceneEntities &sceneRuntime, InventorySystem &inventory, const Common::String &pendingRoomChange);
66 
67  const Common::String &getCarriedRoomItemLabel() const { return _carriedRoomItemLabel; }
68  const IndexedBitmap &getCarriedRoomItemBitmap() const { return _carriedRoomItemBitmap; }
69  bool hasCarriedRoomItem() const;
70  bool hasSelectedItem() const;
71  Common::String getSelectedItemName() const;
72  void clearSelectedItem();
73  void hideCarriedRoomItem();
74  bool stowCarriedRoomItemToInventory();
75  Common::Error handleSelectedItemTargetInteraction(const ObjectRecord &target,
76  Interaction &interactionProcessor, bool &needsRedraw);
77  const Entity *findSelectedItemTarget(const Common::Point &point, bool opaquePixels = true);
78  Common::Error handleSelectedItemMiss(Interaction &interactionProcessor, bool &needsRedraw);
79  Common::Error handleRoomItemPickup(const ObjectRecord &object, bool playerPresent,
80  Interaction &interactionProcessor, InteractionCallbacks &callbacks, bool &needsRedraw);
81 
82 private:
83  void clearCarriedRoomItem();
84  void hideSceneObject(const Common::String &objectName, const Common::String *ownerOrRoom);
85  bool shouldCancelDeniedPickup(const InteractionResult &interaction, bool didTransition) const;
86  Common::Error restoreDeniedPickup(Script &script, const ObjectRecord &savedObject, bool clearCarryState,
87  InteractionCallbacks &callbacks, bool &needsRedraw);
88  Common::Error moveRoomItemDirectlyToInventory(const ObjectRecord &object,
89  Interaction &interactionProcessor, InteractionCallbacks &callbacks, bool &needsRedraw);
90  Common::Error beginRoomItemCarry(const ObjectRecord &object,
91  Interaction &interactionProcessor, InteractionCallbacks &callbacks, bool &needsRedraw);
92 
93  HarvesterEngine &_engine;
94  SceneState &_scene;
95  SceneEntities &_sceneRuntime;
96  InventorySystem &_inventory;
97  const Common::String &_pendingRoomChange;
98  Common::String _carriedRoomItemName;
99  Common::String _carriedRoomItemLabel;
100  IndexedBitmap _carriedRoomItemBitmap;
101 };
102 
103 class Interaction {
104 public:
105  Interaction(HarvesterEngine &engine, Flow &flow, SceneState &scene,
106  Player &player, Common::String &pendingRegionName,
107  Common::String &pendingRoomChange, bool &pendingRoomChangeIsRoomName,
108  bool &pendingRoomChangeUsesSavedRoomState, SaveRoomState &pendingRoomChangeSavedRoomState,
109  bool canExitCloseupToParent, InteractionCallbacks &callbacks);
110 
111  void queueRegionInteraction(const RegionRecord &region, const Common::Point &mousePos);
112  Common::Error runRegionInteraction(const RegionRecord &region,
113  InventorySystem &inventory, bool &needsRedraw);
114  Common::Error tryActivatePendingRegion(InventorySystem &inventory, bool &needsRedraw);
115  Common::Error tryActivatePassiveRegion(InventorySystem &inventory, bool &needsRedraw);
116  int getPendingRegionFacing() const;
117 
118  bool hasPendingMainMenuReturn() const;
119  Common::Error handleCombatInteraction(const InteractionResult &interaction, bool &needsRedraw);
120  Common::Error handleInteractionResult(const InteractionResult &interaction,
121  bool &didTransition, const Common::String &usedItemName, bool interruptPlayerMovement = true);
122  Common::Error runScriptedDialogue(const Common::String &npcName, const Common::String &usedItemName,
123  const Common::String &continuationTag, bool &didTransition);
124 
125 private:
126  HarvesterEngine &_engine;
127  Flow &_flow;
128  SceneState &_scene;
129  Player &_player;
130  Common::String &_pendingRegionName;
131  Common::String &_pendingRoomChange;
132  bool &_pendingRoomChangeIsRoomName;
133  bool &_pendingRoomChangeUsesSavedRoomState;
134  SaveRoomState &_pendingRoomChangeSavedRoomState;
135  bool _canExitCloseupToParent;
136  InteractionCallbacks &_callbacks;
137 };
138 
139 bool hasRoomEntryInteraction(const InteractionResult &interaction);
140 
141 } // End of namespace Harvester
142 
143 #endif // HARVESTER_INTERACTION_H
Definition: flow.h:45
Definition: str.h:59
Definition: art.h:31
Definition: saveload.h:29
Definition: error.h:81
Definition: bitmap.h:33
Definition: array.h:52
Definition: script.h:342
Definition: room_support.h:46
Definition: interaction.h:42
Definition: script.h:86
Definition: entity.h:66
Definition: inventory.h:54
Definition: scene_entities.h:31
Definition: interaction.h:103
Definition: interaction.h:62
Definition: script.h:306
Definition: rect.h:144
Definition: player.h:94
Definition: harvester.h:47
Definition: script.h:164
Definition: script.h:311