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