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