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