ScummVM API documentation
dialogue_menu.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 BLADERUNNER_DIALOGUE_MENU_H
23 #define BLADERUNNER_DIALOGUE_MENU_H
24 
25 #include "bladerunner/shape.h"
26 
27 #include "common/array.h"
28 #include "common/str.h"
29 
30 #include "graphics/surface.h"
31 
32 namespace BladeRunner {
33 
34 class BladeRunnerEngine;
35 class SaveFileReadStream;
36 class SaveFileWriteStream;
37 class TextResource;
38 
39 class DialogueMenu {
40  static const int kMaxItems = 10;
41  static const int kMaxRepeatHistory = 100;
42  static const int kLineHeight = 9;
43  static const int kBorderSize = 10;
44 
45  struct DialogueItem {
46  Common::String text;
47  int answerValue;
48  int colorIntensity;
49  int priorityPolite;
50  int priorityNormal;
51  int prioritySurly;
52  int isDone;
53  };
54 
55  BladeRunnerEngine *_vm;
56 
57  TextResource *_textResource;
58  Shapes *_shapes;
59  bool _isVisible;
60  bool _waitingForInput;
61  int _selectedItemIndex;
62  int _listSize;
63 
64  // These track whether a dialogue option
65  // has previously been selected
66  int _neverRepeatListSize;
67  int _neverRepeatValues[kMaxRepeatHistory];
68  bool _neverRepeatWasSelected[kMaxRepeatHistory];
69 
70  int _centerX;
71  int _centerY;
72  int _screenX;
73  int _screenY;
74  int _maxItemWidth;
75  DialogueItem _items[kMaxItems];
76 
77  int _fadeInItemIndex;
78 
79 public:
81  ~DialogueMenu();
82 
83  void clear();
84 
85  bool loadResources();
86 
87  bool show();
88  bool hide();
89  bool addToList(int answer, bool done, int priorityPolite, int priorityNormal, int prioritySurly);
90  bool clearNeverRepeatWasSelectedFlag(int answer); // aux function - used in cut content mode to re-use some dialogue options for different characters
91  bool addToListNeverRepeatOnceSelected(int answer, int priorityPolite, int priorityNormal, int prioritySurly);
92  bool removeFromList(int answer);
93  bool clearList();
94  int queryInput();
95  int listSize() const;
96  bool isVisible() const;
97  bool isOpen() const;
98  void tick(int x, int y);
99  void draw(Graphics::Surface &s);
100 
101  void mouseUp();
102  bool waitingForInput() const;
103 
104  void save(SaveFileWriteStream &f);
105  void load(SaveFileReadStream &f);
106 
107 private:
108  bool showAt(int x, int y);
109  int getAnswerIndex(int answer) const;
110  const char *getText(int id) const;
111  void calculatePosition(int unusedX = 0, int unusedY = 0);
112  void reset();
113 
114  static void darkenRect(Graphics::Surface &s, int x1, int y1, int x2, int y2);
115 };
116 
117 } // End of namespace BladeRunner
118 
119 #endif
Definition: savefile.h:88
Definition: str.h:59
Definition: surface.h:66
Definition: actor.h:31
Definition: savefile.h:113
Definition: text_resource.h:32
Definition: bladerunner.h:113
Definition: shape.h:61
Definition: dialogue_menu.h:39