ScummVM API documentation
converse_gump.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 NUVIE_CORE_CONVERSE_GUMP_H
23 #define NUVIE_CORE_CONVERSE_GUMP_H
24 
25 #include "ultima/nuvie/misc/call_back.h"
26 #include "ultima/nuvie/gui/widgets/gui_widget.h"
27 #include "common/str.h"
28 
29 namespace Ultima {
30 namespace Nuvie {
31 
32 
33 class Configuration;
34 class Font;
35 class MsgScroll;
36 class Actor;
37 
38 class ConverseGump: public MsgScroll {
39  Common::List<MsgText> conv_keywords;
40  Common::List<MsgText> permitted_input_keywords;
41 
42  Common::List<MsgText> *keyword_list;
43 
44  unsigned char *npc_portrait;
45  unsigned char *avatar_portrait;
46 
47  bool found_break_char;
48  bool solid_bg;
49  bool force_solid_bg;
50  uint8 converse_bg_color;
51 
52  uint16 cursor_position;
53 
54  uint8 portrait_width;
55  uint8 portrait_height;
56  uint8 frame_w;
57  uint8 frame_h;
58  uint16 min_w;
59 
60  nuvie_game_t game_type;
61 
62 public:
63 
64  ConverseGump(const Configuration *cfg, Font *f, Screen *s);
65  ~ConverseGump() override;
66 
67  void set_actor_portrait(Actor *a);
68  unsigned char *create_framed_portrait(Actor *a);
69  bool parse_token(MsgText *token) override;
70  Common::String get_token_string_at_pos(uint16 x, uint16 y) override;
71  void display_string(const Common::String &s, Font *f, bool include_on_map_window) override;
72  void set_talking(bool state, Actor *actor = nullptr) override;
73  void set_font(uint8 font_type) override {}
74 //bool get_solid_bg() { return solid_bg; }
75  void set_solid_bg(bool val) {
76  solid_bg = val;
77  }
78 
79  void Display(bool full_redraw) override;
80 
81  GUI_status KeyDown(const Common::KeyState &key) override;
82  GUI_status MouseUp(int x, int y, Events::MouseButton button) override;
83 
84  GUI_status MouseDown(int x, int y, Events::MouseButton button) override {
85  return GUI_YUM;
86  }
87  GUI_status MouseMotion(int x, int y, uint8 state) override {
88  return GUI_YUM;
89  }
90  GUI_status MouseEnter(uint8 state) override {
91  return GUI_YUM;
92  }
93  GUI_status MouseLeave(uint8 state) override {
94  return GUI_YUM;
95  }
96  GUI_status MouseClick(int x, int y, Events::MouseButton button) override {
97  return GUI_YUM;
98  }
99  GUI_status MouseDouble(int x, int y, Events::MouseButton button) override {
100  return GUI_YUM;
101  }
102  GUI_status MouseDelayed(int x, int y, Events::MouseButton button) override {
103  return GUI_YUM;
104  }
105  GUI_status MouseHeld(int x, int y, Events::MouseButton button) override {
106  return GUI_YUM;
107  }
108 
109  void set_found_break_char(bool val) {
110  found_break_char = val;
111  }
112 
113  bool input_buf_add_char(char c) override;
114  bool input_buf_remove_char() override;
115 
116  bool is_converse_finished() override {
117  return (is_holding_buffer_empty() && msg_buf.size() == 1 && msg_buf.back()->total_length == 0);
118  }
119 
120  void drawCursor(uint16 x, uint16 y) override;
121 
122 protected:
123  Common::String strip_whitespace_after_break(Common::String s);
124  void add_keyword(Common::String keyword);
125 
126  void set_permitted_input(const char *allowed) override;
127  void clear_permitted_input() override;
128 
129  bool cursor_at_input_section() const {
130  return (keyword_list && cursor_position == keyword_list->size());
131  }
132  void cursor_reset() {
133  cursor_position = 0;
134  }
135  void cursor_move_to_input() {
136  cursor_position = keyword_list ? keyword_list->size() : 0;
137  }
138 
139  void input_add_string(Common::String token_str);
140 
141  Common::String get_token_at_cursor();
142 
143  bool is_permanent_keyword(const Common::String &keyword);
144  void parse_fm_towns_token(MsgText *token);
145 
146 private:
147  unsigned char *get_portrait_data(Actor *a);
148 };
149 
150 } // End of namespace Nuvie
151 } // End of namespace Ultima
152 
153 #endif
Definition: actor.h:174
Definition: str.h:59
Definition: msg_scroll.h:90
Definition: configuration.h:60
Definition: list.h:44
size_type size() const
Definition: list.h:237
Definition: screen.h:41
Definition: converse_gump.h:38
Definition: detection.h:27
Definition: msg_scroll.h:51
Definition: keyboard.h:294
Definition: font.h:42