ScummVM API documentation
log_input.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 ULTIMA3_VIEWS_INTERACTIONS_LOG_INPUT_H
23#define ULTIMA3_VIEWS_INTERACTIONS_LOG_INPUT_H
24
25#include "ultima/ultima3/views/interactions/interaction.h"
26#include "ultima/ultima3/views/menu_input.h"
27
28namespace Ultima {
29namespace Ultima3 {
30namespace Views {
31namespace Interactions {
32
37class LogMenu {
38private:
39 MenuChoice _menu;
40 Common::String _echo;
41
42public:
47 void setup(const char *keys, const char *const *words, int count);
48
52 bool handleKey(const KeypressMessage &msg);
53
57 char key() const {
58 return _menu.key();
59 }
60};
61
65class LogYesNo {
66private:
67 LogMenu _menu;
68
69public:
70 LogYesNo();
71
75 bool handleKey(const KeypressMessage &msg) {
76 return _menu.handleKey(msg);
77 }
78
79 bool yes() const {
80 return _menu.key() == 'Y';
81 }
82};
83
87class LogText {
88private:
89 uint _maxChars = 0;
90 Common::String _text;
91
92public:
93 void setup(uint maxChars);
94
98 bool handleKey(const KeypressMessage &msg);
99
104};
105
111private:
112 int _maxDigits = 0;
113 bool _rejectLetters = false;
114 Common::String _text;
115
116 // What was entered, read one digit at a time as BCD
117 int _bcd = 0;
118 bool _hasLetters = false;
119
124 bool evaluate();
125
126public:
132 void setup(int maxDigits, bool rejectLetters = false);
133
138 bool handleKey(const KeypressMessage &msg);
139
143 int bcd() const {
144 return _bcd;
145 }
146
150 int value() const {
151 return Data::fromBcdWord(_bcd);
152 }
153
158 bool hasLetters() const {
159 return _hasLetters;
160 }
161};
162
163} // namespace Interactions
164} // namespace Views
165} // namespace Ultima3
166} // namespace Ultima
167
168#endif
Definition: str.h:59
void setup(const char *keys, const char *const *words, int count)
char key() const
Definition: log_input.h:57
bool handleKey(const KeypressMessage &msg)
bool handleKey(const KeypressMessage &msg)
int bcd() const
Definition: log_input.h:143
void setup(int maxDigits, bool rejectLetters=false)
bool hasLetters() const
Definition: log_input.h:158
int value() const
Definition: log_input.h:150
bool handleKey(const KeypressMessage &msg)
bool handleKey(const KeypressMessage &msg)
Definition: log_input.h:75
Definition: menu_input.h:53
char key() const
Definition: menu_input.h:96
Definition: messages.h:54