ScummVM API documentation
GameEventInfo.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 /*
23  * This code is based on the CRAB engine
24  *
25  * Copyright (c) Arvind Raja Yadav
26  *
27  * Licensed under MIT
28  *
29  */
30 
31 #ifndef CRAB_GAMEEVENTINFO_H
32 #define CRAB_GAMEEVENTINFO_H
33 
34 #include "crab/stat/StatTemplate.h"
35 #include "crab/ui/Inventory.h"
36 #include "crab/ui/journal.h"
37 
38 namespace Crab {
39 
40 namespace pyrodactyl {
41 namespace event {
42 bool isChar(char c);
43 
44 class Info {
45  // The characters in the game
47 
48  // The stat templates used in declaring person objects
50 
51  // The variables set by the events so far
53  VarMap _var;
54 
55  // The last object player interacted with
56  Common::String _lastobj;
57 
58  // Is the game Iron Man or not?
59  // Iron man means only one save - no reloading
60  bool _ironman;
61 
62  // The player's current location
63  struct PlayerLoc {
64  // id of the player's current location
65  Common::String _id;
66 
67  // The name of the player's current location
68  Common::String _name;
69 
70  PlayerLoc() {}
71  } _loc;
72 
73  // This image changes to reflect the playable character
74  int _playerImg;
75 
76  void loadPeople(const Common::Path &filename);
77 
78 public:
79  // The player's one stop shop for objectives and lore
80  pyrodactyl::ui::Journal _journal;
81 
82  // The current player inventory
84 
85  // This structure keeps track of unread indicators
86  struct UnreadData {
87  bool _inventory, _journal, _trait, _map;
88 
89  UnreadData() {
90  _inventory = false;
91  _journal = false;
92  _trait = true;
93  _map = false;
94  }
95  } _unread;
96 
97  // This is the variable corresponding to money that is drawn
98  Common::String _moneyVar;
99 
100  // Has the player pressed the talk key
101  bool _talkKeyDown;
102 
103  // Used so we only play one sound per event
104  struct NotifySounds {
105  bool _notify, _repInc, _repDec;
106 
107  NotifySounds() {
108  _notify = false;
109  _repInc = false;
110  _repDec = false;
111  }
112  } _sound;
113 
114  Info() {
115  Init();
116  }
117 
118  ~Info() {}
119 
120  void Init() {
121  _lastobj = "";
122  _ironman = false;
123  _playerImg = 0;
124  _talkKeyDown = false;
125  }
126 
127  void load(rapidxml::xml_node<char> *node);
128 
129  // Person related stuff
130  void type(const Common::String &id, const pyrodactyl::people::PersonType &val);
131  pyrodactyl::people::PersonType type(const Common::String &id);
132 
133  void state(const Common::String &id, const pyrodactyl::people::PersonState &val);
134  pyrodactyl::people::PersonState state(const Common::String &id);
135 
136  // Opinion
137  bool opinionGet(const Common::String &name, const pyrodactyl::people::OpinionType &type, int &val);
138  void opinionSet(const Common::String &name, const pyrodactyl::people::OpinionType &type, int val);
139  void opinionChange(const Common::String &name, const pyrodactyl::people::OpinionType &type, int val);
140 
141  // Stats
142  bool statGet(const Common::String &name, const pyrodactyl::stat::StatType &type, int &num);
143  void statSet(const Common::String &name, const pyrodactyl::stat::StatType &type, const int &num);
144  void statChange(const Common::String &name, const pyrodactyl::stat::StatType &type, const int &num);
145 
146  // Variables
147  bool varGet(const Common::String &name, int &val);
148  void varSet(const Common::String &name, const Common::String &val);
149  void varAdd(const Common::String &name, const int &val);
150  void varSub(const Common::String &name, const int &val);
151  void varMul(const Common::String &name, const int &val);
152  void varDiv(const Common::String &name, const int &val);
153  void varDel(const Common::String &name);
154 
155  // The trait functions
156  void traitAdd(const Common::String &perId, const int &traitId);
157  void traitDel(const Common::String &perId, const int &traitId);
158 
159  // Player character button
160  void playerImg(const int &val) {
161  _playerImg = val;
162  }
163 
164  int playerImg() {
165  return _playerImg;
166  }
167 
168  Common::String curLocID() {
169  return _loc._id;
170  }
171 
172  void curLocID(const Common::String &id) {
173  _loc._id = id;
174  }
175 
176  Common::String curLocName() {
177  return _loc._name;
178  }
179 
180  void curLocName(const Common::String &name) {
181  _loc._name = name;
182  }
183 
184  // Player stuff
185  Common::String lastPerson() {
186  return _lastobj;
187  }
188 
189  void lastPerson(const Common::String &name) {
190  _lastobj = name;
191  }
192 
193  // Return the variable map for stuff like visibility checks
194  VarMap &mapGet() {
195  return _var;
196  }
197 
198  bool personGet(const Common::String &id, pyrodactyl::people::Person &p);
199 
200  bool personValid(const Common::String &id);
201  pyrodactyl::people::Person &personGet(const Common::String &id);
202 
203  // Is an object colliding with a trigger area
204  bool collideWithTrigger(const Common::String &id, int rectIndex);
205 
206  // Replace all #values with their appropriate names in a string
207  void insertName(Common::String &msg);
208  Common::String getName(const Common::String &id);
209 
210  // Draw the inventory
211  void invDraw(const Common::String &id) {
212  if (_var.contains(_moneyVar))
213  _inv.draw(_people[id], _var[_moneyVar]);
214  else
215  _inv.draw(_people[id], 0);
216  }
217 
218  // Get whether game is iron man or not
219  bool ironMan() {
220  return _ironman;
221  }
222 
223  void ironMan(const bool &val) {
224  _ironman = val;
225  }
226 
227  void loadIronMan(rapidxml::xml_node<char> *node) {
228  Common::String str;
229  loadStr(str, "diff", node);
230  _ironman = (str == "Iron Man");
231  }
232 
233  void saveState(rapidxml::xml_document<> &doc, rapidxml::xml_node<char> *root);
234  void loadState(rapidxml::xml_node<char> *node);
235 
236  void setUI();
237 };
238 } // End of namespace event
239 } // End of namespace pyrodactyl
240 
241 } // End of namespace Crab
242 
243 #endif // CRAB_GAMEEVENTINFO_H
Definition: GameEventInfo.h:104
Definition: str.h:59
Definition: path.h:52
Definition: GameEventInfo.h:44
Definition: person.h:43
Definition: StatTemplate.h:42
bool contains(const Key &key) const
Definition: hashmap.h:594
Definition: moveeffect.h:37
Definition: journal.h:58
Definition: GameEventInfo.h:86
Definition: Inventory.h:43