OpenTTD Source 20251213-master-g1091fa6071
network_chat_gui.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#include "../stdafx.h"
11#include "../strings_func.h"
12#include "../autocompletion.h"
13#include "../blitter/factory.hpp"
14#include "../console_func.h"
15#include "../video/video_driver.hpp"
16#include "../querystring_gui.h"
17#include "../town.h"
18#include "../window_func.h"
19#include "../toolbar_gui.h"
20#include "../zoom_func.h"
21#include "../timer/timer.h"
22#include "../timer/timer_window.h"
23#include "network.h"
24#include "network_client.h"
25#include "network_base.h"
26
27#include "../widgets/network_chat_widget.h"
28
29#include "table/strings.h"
30
31#include "../safeguards.h"
32
34static const uint NETWORK_CHAT_LINE_SPACING = 3;
35
38 std::string message;
40 std::chrono::steady_clock::time_point remove_time;
41};
42
43/* used for chat window */
44static std::deque<ChatMessage> _chatmsg_list;
45static bool _chatmessage_dirty = false;
46static bool _chatmessage_visible = false;
47static uint MAX_CHAT_MESSAGES = 0;
48
53static std::chrono::steady_clock::time_point _chatmessage_dirty_time;
54
61
67static inline bool HaveChatMessages(bool show_all)
68{
69 if (show_all) return !_chatmsg_list.empty();
70
71 auto now = std::chrono::steady_clock::now();
72 for (auto &cmsg : _chatmsg_list) {
73 if (cmsg.remove_time >= now) return true;
74 }
75
76 return false;
77}
78
85void CDECL NetworkAddChatMessage(TextColour colour, uint duration, const std::string &message)
86{
87 if (_chatmsg_list.size() == MAX_CHAT_MESSAGES) {
88 _chatmsg_list.pop_back();
89 }
90
91 ChatMessage *cmsg = &_chatmsg_list.emplace_front();
92 cmsg->message = message;
93 cmsg->colour = colour;
94 cmsg->remove_time = std::chrono::steady_clock::now() + std::chrono::seconds(duration);
95
96 _chatmessage_dirty_time = std::chrono::steady_clock::now();
97 _chatmessage_dirty = true;
98}
99
106
118
121{
122 /* Sometimes we also need to hide the cursor
123 * This is because both textmessage and the cursor take a shot of the
124 * screen before drawing.
125 * Now the textmessage takes its shot and paints its data before the cursor
126 * does, so in the shot of the cursor is the screen-data of the textmessage
127 * included when the cursor hangs somewhere over the textmessage. To
128 * avoid wrong repaints, we undraw the cursor in that case, and everything
129 * looks nicely ;)
130 * (and now hope this story above makes sense to you ;))
131 */
132 if (_cursor.visible &&
133 _cursor.draw_pos.x + _cursor.draw_size.x >= _chatmsg_box.x &&
134 _cursor.draw_pos.x <= _chatmsg_box.x + _chatmsg_box.width &&
135 _cursor.draw_pos.y + _cursor.draw_size.y >= _screen.height - _chatmsg_box.y - _chatmsg_box.height &&
136 _cursor.draw_pos.y <= _screen.height - _chatmsg_box.y) {
137 UndrawMouseCursor();
138 }
139
142 int x = _chatmsg_box.x;
143 int y = _screen.height - _chatmsg_box.y - _chatmsg_box.height;
144 int width = _chatmsg_box.width;
145 int height = _chatmsg_box.height;
146 if (y < 0) {
147 height = std::max(height + y, std::min(_chatmsg_box.height, _screen.height));
148 y = 0;
149 }
150 if (x + width >= _screen.width) {
151 width = _screen.width - x;
152 }
153 if (width <= 0 || height <= 0) return;
154
155 _chatmessage_visible = false;
156 /* Put our 'shot' back to the screen */
157 blitter->CopyFromBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup.GetBuffer(), width, height);
158 /* And make sure it is updated next time */
159 VideoDriver::GetInstance()->MakeDirty(x, y, width, height);
160
161 _chatmessage_dirty_time = std::chrono::steady_clock::now();
162 _chatmessage_dirty = true;
163 }
164}
165
167static const IntervalTimer<TimerWindow> network_message_expired_interval(std::chrono::seconds(1), [](auto) {
168 auto now = std::chrono::steady_clock::now();
169 for (auto &cmsg : _chatmsg_list) {
170 /* Message has expired, remove from the list */
171 if (now > cmsg.remove_time && _chatmessage_dirty_time < cmsg.remove_time) {
173 _chatmessage_dirty = true;
174 break;
175 }
176 }
177});
178
181{
183 if (!_chatmessage_dirty) return;
184
186 bool show_all = (w != nullptr);
187
188 /* First undraw if needed */
190
191 if (_iconsole_mode == ICONSOLE_FULL) return;
192
193 /* Check if we have anything to draw at all */
194 if (!HaveChatMessages(show_all)) return;
195
196 int x = _chatmsg_box.x;
197 int y = _screen.height - _chatmsg_box.y - _chatmsg_box.height;
198 int width = _chatmsg_box.width;
199 int height = _chatmsg_box.height;
200 if (y < 0) {
201 height = std::max(height + y, std::min(_chatmsg_box.height, _screen.height));
202 y = 0;
203 }
204 if (x + width >= _screen.width) {
205 width = _screen.width - x;
206 }
207 if (width <= 0 || height <= 0) return;
208
209 /* Make a copy of the screen as it is before painting (for undraw) */
210 uint8_t *buffer = _chatmessage_backup.Allocate(BlitterFactory::GetCurrentBlitter()->BufferSize(width, height));
211 blitter->CopyToBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), buffer, width, height);
212
213 _cur_dpi = &_screen; // switch to _screen painting
214
215 auto now = std::chrono::steady_clock::now();
216 int string_height = 0;
217 for (auto &cmsg : _chatmsg_list) {
218 if (!show_all && cmsg.remove_time < now) continue;
219 string_height += GetStringLineCount(GetString(STR_JUST_RAW_STRING, cmsg.message), width - 1) * GetCharacterHeight(FS_NORMAL) + NETWORK_CHAT_LINE_SPACING;
220 }
221
222 string_height = std::min<uint>(string_height, MAX_CHAT_MESSAGES * (GetCharacterHeight(FS_NORMAL) + NETWORK_CHAT_LINE_SPACING));
223
224 int top = _screen.height - _chatmsg_box.y - string_height - 2;
225 int bottom = _screen.height - _chatmsg_box.y - 2;
226 /* Paint a half-transparent box behind the chat messages */
227 GfxFillRect(_chatmsg_box.x, top - 2, _chatmsg_box.x + _chatmsg_box.width - 1, bottom,
228 PALETTE_TO_TRANSPARENT, FILLRECT_RECOLOUR // black, but with some alpha for background
229 );
230
231 /* Paint the chat messages starting with the lowest at the bottom */
232 int ypos = bottom - 2;
233
234 for (auto &cmsg : _chatmsg_list) {
235 if (!show_all && cmsg.remove_time < now) continue;
236 ypos = DrawStringMultiLine(_chatmsg_box.x + ScaleGUITrad(3), _chatmsg_box.x + _chatmsg_box.width - 1, top, ypos, cmsg.message, cmsg.colour, SA_LEFT | SA_BOTTOM | SA_FORCE) - NETWORK_CHAT_LINE_SPACING;
237 if (ypos < top) break;
238 }
239
240 /* Make sure the data is updated next flush */
241 VideoDriver::GetInstance()->MakeDirty(x, y, width, height);
242
244 _chatmessage_dirty = false;
245}
246
253static void SendChat(std::string_view buf, DestType type, int dest)
254{
255 if (buf.empty()) return;
256 if (!_network_server) {
257 MyClient::SendChat((NetworkAction)(NETWORK_ACTION_CHAT + type), type, dest, buf, 0);
258 } else {
259 NetworkServerSendChat((NetworkAction)(NETWORK_ACTION_CHAT + type), type, dest, buf, CLIENT_ID_SERVER);
260 }
261}
262
264public:
265 using AutoCompletion::AutoCompletion;
266
267private:
268 std::vector<std::string> GetSuggestions([[maybe_unused]] std::string_view prefix, std::string_view query) override
269 {
270 std::vector<std::string> suggestions;
272 if (ci->client_name.starts_with(query)) {
273 suggestions.push_back(ci->client_name);
274 }
275 }
276 for (const Town *t : Town::Iterate()) {
277 /* Get the town-name via the string-system */
278 std::string town_name = GetString(STR_TOWN_NAME, t->index);
279 if (town_name.starts_with(query)) {
280 suggestions.push_back(std::move(town_name));
281 }
282 }
283 return suggestions;
284 }
285
286 void ApplySuggestion(std::string_view prefix, std::string_view suggestion) override
287 {
288 /* Add ': ' if we are at the start of the line (pretty) */
289 if (prefix.empty()) {
290 this->textbuf->Assign(fmt::format("{}: ", suggestion));
291 } else {
292 this->textbuf->Assign(fmt::format("{}{} ", prefix, suggestion));
293 }
294 }
295};
296
298struct NetworkChatWindow : public Window {
300 int dest = 0;
303
312 {
314 this->message_editbox.cancel_button = WID_NC_CLOSE;
315 this->message_editbox.ok_button = WID_NC_SENDBUTTON;
316
317 this->CreateNestedTree();
318 this->FinishInitNested(type);
319
322
324 }
325
326 void Close([[maybe_unused]] int data = 0) override
327 {
329 this->Window::Close();
330 }
331
332 void FindWindowPlacementAndResize(int, int def_height, bool allow_resize) override
333 {
334 Window::FindWindowPlacementAndResize(_toolbar_width, def_height, allow_resize);
335 }
336
341 {
342 if (this->chat_tab_completion.AutoComplete()) {
343 this->SetDirty();
344 }
345 }
346
347 Point OnInitialPosition([[maybe_unused]] int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]] int window_number) override
348 {
349 Point pt = { 0, _screen.height - sm_height - FindWindowById(WC_STATUS_BAR, 0)->height };
350 return pt;
351 }
352
353 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
354 {
355 if (widget != WID_NC_DESTINATION) return this->Window::GetWidgetString(widget, stringid);
356
357 static const StringID chat_captions[] = {
358 STR_NETWORK_CHAT_ALL_CAPTION,
359 STR_NETWORK_CHAT_COMPANY_CAPTION,
360 STR_NETWORK_CHAT_CLIENT_CAPTION
361 };
362 assert((uint)this->dtype < lengthof(chat_captions));
363
364 if (this->dtype == DESTTYPE_CLIENT) {
365 return GetString(STR_NETWORK_CHAT_CLIENT_CAPTION, NetworkClientInfo::GetByClientID((ClientID)this->dest)->client_name);
366 }
367
368 return GetString(chat_captions[this->dtype]);
369 }
370
371 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
372 {
373 switch (widget) {
374 case WID_NC_SENDBUTTON: /* Send */
375 SendChat(this->message_editbox.text.GetText(), this->dtype, this->dest);
376 [[fallthrough]];
377
378 case WID_NC_CLOSE: /* Cancel */
379 this->Close();
380 break;
381 }
382 }
383
384 EventState OnKeyPress([[maybe_unused]] char32_t key, uint16_t keycode) override
385 {
387 if (keycode == WKC_TAB) {
389 state = ES_HANDLED;
390 }
391 return state;
392 }
393
394 void OnEditboxChanged(WidgetID widget) override
395 {
396 if (widget == WID_NC_TEXTBOX) {
397 this->chat_tab_completion.Reset();
398 }
399 }
400
406 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
407 {
408 if (data == this->dest) this->Close();
409 }
410};
411
413static constexpr std::initializer_list<NWidgetPart> _nested_chat_window_widgets = {
415 NWidget(WWT_CLOSEBOX, COLOUR_GREY, WID_NC_CLOSE),
416 NWidget(WWT_PANEL, COLOUR_GREY, WID_NC_BACKGROUND),
419 NWidget(WWT_EDITBOX, COLOUR_GREY, WID_NC_TEXTBOX), SetMinimalSize(100, 0), SetPadding(1, 0, 1, 0), SetResize(1, 0),
420 SetStringTip(STR_NETWORK_CHAT_OSKTITLE),
421 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NC_SENDBUTTON), SetMinimalSize(62, 12), SetPadding(1, 0, 1, 0), SetStringTip(STR_NETWORK_CHAT_SEND),
422 EndContainer(),
423 EndContainer(),
424 EndContainer(),
425};
426
429 WDP_MANUAL, {}, 0, 0,
431 {},
433);
434
435
std::string_view query
Last token of the text. This is used to based the suggestions on.
std::string_view prefix
Prefix of the text before the last space.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
Definition factory.hpp:136
How all blitters should look like.
Definition base.hpp:29
virtual void * MoveTo(void *video, int x, int y)=0
Move the destination pointer the requested amount x and y, keeping in mind any pitch and bpp of the r...
virtual void CopyToBuffer(const void *video, void *dst, int width, int height)=0
Copy from the screen to a buffer.
virtual void CopyFromBuffer(void *video, const void *src, int width, int height)=0
Copy from a buffer to the screen.
static NetworkRecvStatus SendChat(NetworkAction action, DestType type, int dest, std::string_view msg, int64_t data)
Send a chat-packet over the network.
An interval timer will fire every interval, and will continue to fire until it is deleted.
Definition timer.h:76
A reusable buffer that can be used for places that temporary allocate a bit of memory and do that ver...
const T * GetBuffer() const
Get the currently allocated buffer.
T * Allocate(size_t count)
Get buffer of at least count times T.
virtual void MakeDirty(int left, int top, int width, int height)=0
Mark a particular area dirty.
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
static const uint NETWORK_CHAT_LENGTH
The maximum length of a chat message, in bytes including '\0'.
Definition config.h:61
@ ICONSOLE_FULL
In-game console is opened, whole screen.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
int GetStringLineCount(std::string_view str, int maxw)
Calculates number of lines of string.
Definition gfx.cpp:733
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition gfx.cpp:779
void GfxFillRect(int left, int top, int right, int bottom, const std::variant< PixelColour, PaletteID > &colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
Definition gfx.cpp:115
@ FS_NORMAL
Index of the normal font in the font tables.
Definition gfx_type.h:249
@ SA_LEFT
Left align the text.
Definition gfx_type.h:388
@ SA_RIGHT
Right align the text (must be a single bit).
Definition gfx_type.h:390
@ SA_FORCE
Force the alignment, i.e. don't swap for RTL languages.
Definition gfx_type.h:400
@ SA_BOTTOM
Bottom align the text.
Definition gfx_type.h:395
@ SA_VERT_CENTER
Vertically center the text.
Definition gfx_type.h:394
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition gfx_type.h:307
@ FILLRECT_RECOLOUR
Apply a recolour sprite to the screen content.
Definition gfx_type.h:347
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
constexpr NWidgetPart SetAlignment(StringAlignment align)
Widget part function for setting the alignment of text/images.
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition window.cpp:966
bool _network_server
network-server is active
Definition network.cpp:67
Basic functions/variables used all over the place.
Base core network types and some helper functions to access them.
static uint MAX_CHAT_MESSAGES
The limit of chat messages to show.
void NetworkDrawChatMessage()
Draw the chat message-box.
static ReusableBuffer< uint8_t > _chatmessage_backup
Backup in case text is moved.
void ShowNetworkChatQueryWindow(DestType type, int dest)
Show the chat window.
static bool HaveChatMessages(bool show_all)
Test if there are any chat messages to display.
void CDECL NetworkAddChatMessage(TextColour colour, uint duration, const std::string &message)
Add a text message to the 'chat window' to be shown.
static constexpr std::initializer_list< NWidgetPart > _nested_chat_window_widgets
The widgets of the chat window.
static std::chrono::steady_clock::time_point _chatmessage_dirty_time
Time the chat history was marked dirty.
void NetworkReInitChatBoxSize()
Initialize all font-dependent chat box sizes.
static void SendChat(std::string_view buf, DestType type, int dest)
Send an actual chat message.
static const uint NETWORK_CHAT_LINE_SPACING
Spacing between chat lines.
static WindowDesc _chat_window_desc(WDP_MANUAL, {}, 0, 0, WC_SEND_NETWORK_MSG, WC_NONE, {}, _nested_chat_window_widgets)
The description of the chat window.
void NetworkInitChatMessage()
Initialize all buffers of the chat visualisation.
static const IntervalTimer< TimerWindow > network_message_expired_interval(std::chrono::seconds(1), [](auto) { auto now=std::chrono::steady_clock::now();for(auto &cmsg :_chatmsg_list) { if(now > cmsg.remove_time &&_chatmessage_dirty_time< cmsg.remove_time) { _chatmessage_dirty_time=now;_chatmessage_dirty=true;break;} } })
Check if a message is expired on a regular interval.
void NetworkUndrawChatMessage()
Hide the chatbox.
static PointDimension _chatmsg_box
The chatbox grows from the bottom so the coordinates are pixels from the left and pixels from the bot...
static bool _chatmessage_dirty
Does the chat message need repainting?
static bool _chatmessage_visible
Is a chat message visible.
static std::deque< ChatMessage > _chatmsg_list
The actual chat message list.
@ WID_NC_SENDBUTTON
Send button.
@ WID_NC_BACKGROUND
Background of the window.
@ WID_NC_CLOSE
Close button.
@ WID_NC_TEXTBOX
Textbox.
@ WID_NC_DESTINATION
Destination.
Client part of the network protocol.
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, std::string_view msg, ClientID from_id, int64_t data=0, bool from_admin=false)
Send an actual chat message.
DestType
Destination of our chat messages.
@ DESTTYPE_CLIENT
Send message/notice to only a certain client (Private)
NetworkAction
Actions that can be used for NetworkTextMessage.
ClientID
'Unique' identifier to be given to clients
@ CLIENT_ID_SERVER
Servers always have this ID.
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
static const PaletteID PALETTE_TO_TRANSPARENT
This sets the sprite to transparent.
Definition sprites.h:1616
#define lengthof(array)
Return the length of an fixed size array.
Definition stdafx.h:271
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:424
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Container for a message.
TextColour colour
The colour of the message.
std::chrono::steady_clock::time_point remove_time
The time to remove the message.
std::string message
The action message.
GUISettings gui
settings related to the GUI
T y
Y coordinate.
T x
X coordinate.
bool visible
cursor is visible
Definition gfx_type.h:145
Point draw_size
position and size bounding-box for drawing
Definition gfx_type.h:139
uint8_t network_chat_box_height
height of the chat box in lines
uint16_t network_chat_box_width_pct
width of the chat box in percent
Window to enter the chat message in.
void FindWindowPlacementAndResize(int, int def_height, bool allow_resize) override
Resize window towards the default size.
NetworkChatAutoCompletion chat_tab_completion
Holds the state and logic of auto-completion of player names and towns on Tab press.
EventState OnKeyPress(char32_t key, uint16_t keycode) override
A key has been pressed.
NetworkChatWindow(WindowDesc &desc, DestType type, int dest)
Create a chat input window.
void OnEditboxChanged(WidgetID widget) override
The text in an editbox has been edited.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void ChatTabCompletion()
See if we can auto-complete the current text of the user.
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
int dest
The identifier of the destination.
DestType dtype
The type of destination.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
QueryString message_editbox
Message editbox.
Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override
Compute the initial position of the window.
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Container for all information known about a client.
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
Definition network.cpp:117
Specification of a rectangle with an absolute top-left coordinate and a (relative) width/height.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Data stored about a string that can be modified in the GUI.
int ok_button
Widget button of parent window to simulate when pressing OK in OSK.
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
std::string_view GetText() const
Get the current text.
Definition textbuf.cpp:284
void Assign(std::string_view text)
Copy a string into the textbuffer.
Definition textbuf.cpp:420
Town data structure.
Definition town.h:63
High level window description.
Definition window_gui.h:168
Data structure for an opened window.
Definition window_gui.h:274
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Definition window.cpp:1102
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition window.cpp:1807
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition window_gui.h:321
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
Definition window.cpp:504
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition window.cpp:1797
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
Definition window.cpp:485
virtual void FindWindowPlacementAndResize(int def_width, int def_height, bool allow_resize)
Resize window towards the default size.
Definition window.cpp:1474
int height
Height of the window (number of pixels down in y direction)
Definition window_gui.h:313
WindowNumber window_number
Window number within the window class.
Definition window_gui.h:303
uint _toolbar_width
Width of the toolbar, shared by statusbar.
static RectPadding ScaleGUITrad(const RectPadding &r)
Scale a RectPadding to GUI zoom level.
Definition widget.cpp:49
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
@ WWT_EDITBOX
a textbox for typing
Definition widget_type.h:62
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:39
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:60
@ WWT_TEXT
Pure simple text.
Definition widget_type.h:49
int PositionNetworkChatWindow(Window *w)
(Re)position network chat window at the screen.
Definition window.cpp:3498
Window * FindWindowByClass(WindowClass cls)
Find any window by its class.
Definition window.cpp:1166
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition window.cpp:1205
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
Definition window.cpp:3294
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition window.cpp:1151
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
Definition window_gui.h:143
int WidgetID
Widget ID.
Definition window_type.h:20
EventState
State of handling an event.
@ ES_HANDLED
The passed event is handled.
@ ES_NOT_HANDLED
The passed event is not handled.
@ WC_NEWS_WINDOW
News window; Window numbers:
@ WC_STATUS_BAR
Statusbar (at the bottom of your screen); Window numbers:
Definition window_type.h:69
@ WC_SEND_NETWORK_MSG
Chatbox; Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition window_type.h:50