ScummVM API documentation
inventory.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 HOLLYWOOD_RUNAWAY_INVENTORY_H
23#define HOLLYWOOD_RUNAWAY_INVENTORY_H
24
25#include "common/array.h"
26#include "common/ustr.h"
27#include "hollywood/runaway/detection.h"
28#include "hollywood/runaway/saveload.h"
29
30namespace Common {
31class RandomSource;
32}
33
34namespace Hollywood {
35
36class RunawayStrings;
37struct RunawaySaveState;
38
39enum RunawayVerb { kVerbWalk, kVerbLook, kVerbUse };
40
42public:
43 enum { kItemCount = 26 };
44 struct Reply {
45 uint16 cue;
46 byte variation;
47 byte nextVariation = 0xff;
48 uint16 action = 0;
49 Reply(uint16 c = 1, byte v = 0) : cue(c), variation(v) {}
50 static Reply fromAction(uint16 action) {
51 Reply reply;
52 reply.action = action;
53 return reply;
54 }
55 };
56 RunawayInventory(const RunawayStrings &strings, RunawayGameType game) :
57 _strings(strings), _museumDemo(game == kRunawayMuseumDemo), _fullGame(game == kRunawayFullGame), _chapter(game == kRunawayFullGame ? 1 : game == kRunawayMuseumDemo ? 2 : 3) {}
58 void setChapter(byte chapter) { _chapter = chapter; }
59 void startChapter(byte chapter);
60 RunawaySaveState::MuseumItems &museum() { return _museum; }
61 RunawaySaveState::DesertItems &desert() { return _desert; }
62 RunawaySaveState::TownItems &town() { return _town; }
63 RunawaySaveState::HopiItems &hopi() { return _hopi; }
64 RunawaySaveState::FinaleItems &finale() { return _finale; }
65 bool contains(byte item) const;
66 uint maxItemId() const;
67 bool add(byte item);
68 void remove(byte item);
69 uint size() const { return _items.size(); }
70 byte itemAt(uint slot) const { return slot < size() ? _items[slot] : 0; }
71 byte selected() const { return _selected; }
72 void select(byte item) { _selected = contains(item) ? item : 0; }
73 byte takeNewItem() { const byte item = _newItem; _newItem = 0; return item; }
74 Common::U32String name(byte item) const;
75 Common::U32String combinationCaption(byte item, byte target) const;
76 static Reply randomReply(Common::RandomSource &random);
77 uint icon(byte item) const;
78 uint cursor(byte item) const;
79 Reply examine(byte item) const;
80 Reply combine(byte first, byte second);
81 byte clothState() const { return _clothState; }
82 void soilCloth() { _clothState = 2; }
83 byte water() const { return _water; }
84 void setWater(byte water) { _water = water; }
85 bool chartWritten() const { return _chartWritten; }
86 bool headWig() const { return _headWig; }
87 void captureState(RunawaySaveState &state) const;
88 void restoreState(const RunawaySaveState &state);
89
90private:
91 Reply combineHospitalItems(byte first, byte second);
92 Reply combineMuseumItems(byte first, byte second);
93 Reply combineTownItems(byte first, byte second);
94 Reply combineHopiItems(byte first, byte second);
95 const RunawayStrings &_strings;
96 const bool _museumDemo;
97 const bool _fullGame;
98 byte _chapter;
99 RunawaySaveState::MuseumItems _museum;
100 RunawaySaveState::DesertItems _desert;
101 RunawaySaveState::TownItems _town;
102 RunawaySaveState::HopiItems _hopi;
103 RunawaySaveState::FinaleItems _finale;
104 Common::Array<byte> _items;
105 byte _selected = 0, _newItem = 0, _clothState = 0;
106 byte _water = 0;
107 byte _markerInk = 0, _syringeFilled = 0, _chartWritten = 0, _headWig = 0;
108};
109
110} // End of namespace Hollywood
111
112#endif
size_type size() const
Definition: array.h:316
Definition: random.h:44
Definition: ustr.h:57
Definition: inventory.h:41
Definition: strings.h:37
Definition: algorithm.h:29
Definition: inventory.h:44