OpenTTD Source 20261112-master-gbcbec5e63f
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
9
10#include "../stdafx.h"
11#include "../strings_func.h"
12#include "../autocompletion.h"
14#include "../console_func.h"
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"
23#include "network.h"
24#include "network_client.h"
25#include "network_base.h"
26#include "network_func.h"
27
29
30#include "table/strings.h"
31
32#include "../safeguards.h"
33
35static const uint NETWORK_CHAT_LINE_SPACING = 3;
36
39 std::string message;
41 std::chrono::steady_clock::time_point remove_time;
42};
43
44/* used for chat window */
45static std::deque<ChatMessage> _chatmsg_list;
46static bool _chatmessage_dirty = false;
47static bool _chatmessage_visible = false;
48static uint MAX_CHAT_MESSAGES = 0;
49
54static std::chrono::steady_clock::time_point _chatmessage_dirty_time;
55
62
68static inline bool HaveChatMessages(bool show_all)
69{
70 if (show_all) return !_chatmsg_list.empty();
71
72 auto now = std::chrono::steady_clock::now();
73 for (auto &cmsg : _chatmsg_list) {
74 if (cmsg.remove_time >= now) return true;
75 }
76
77 return false;
78}
79
86void CDECL NetworkAddChatMessage(ExtendedTextColour colour, uint duration, const std::string &message)
87{
88 if (_chatmsg_list.size() == MAX_CHAT_MESSAGES) {
89 _chatmsg_list.pop_back();
90 }
91
92 _chatmsg_list.emplace_front(message, colour, std::chrono::steady_clock::now() + std::chrono::seconds(duration));
93 _chatmessage_dirty_time = std::chrono::steady_clock::now();
94 _chatmessage_dirty = true;
95}
96
103
106{
107 MAX_CHAT_MESSAGES = _settings_client.gui.network_chat_box_height;
108
109 _chatmsg_list.clear();
111 _chatmsg_box.width = _settings_client.gui.network_chat_box_width_pct * _screen.width / 100;
113 _chatmessage_visible = false;
114}
115
118{
119 /* Sometimes we also need to hide the cursor
120 * This is because both textmessage and the cursor take a shot of the
121 * screen before drawing.
122 * Now the textmessage takes its shot and paints its data before the cursor
123 * does, so in the shot of the cursor is the screen-data of the textmessage
124 * included when the cursor hangs somewhere over the textmessage. To
125 * avoid wrong repaints, we undraw the cursor in that case, and everything
126 * looks nicely ;)
127 * (and now hope this story above makes sense to you ;))
128 */
129 if (_cursor.visible &&
130 _cursor.draw_pos.x + _cursor.draw_size.x >= _chatmsg_box.x &&
131 _cursor.draw_pos.x <= _chatmsg_box.x + _chatmsg_box.width &&
132 _cursor.draw_pos.y + _cursor.draw_size.y >= _screen.height - _chatmsg_box.y - _chatmsg_box.height &&
133 _cursor.draw_pos.y <= _screen.height - _chatmsg_box.y) {
134 UndrawMouseCursor();
135 }
136
139 int x = _chatmsg_box.x;
140 int y = _screen.height - _chatmsg_box.y - _chatmsg_box.height;
141 int width = _chatmsg_box.width;
142 int height = _chatmsg_box.height;
143 if (y < 0) {
144 height = std::max(height + y, std::min(_chatmsg_box.height, _screen.height));
145 y = 0;
146 }
147 if (x + width >= _screen.width) {
148 width = _screen.width - x;
149 }
150 if (width <= 0 || height <= 0) return;
151
152 _chatmessage_visible = false;
153 /* Put our 'shot' back to the screen */
154 blitter->CopyFromBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup.GetBuffer(), width, height);
155 /* And make sure it is updated next time */
156 VideoDriver::GetInstance()->MakeDirty(x, y, width, height);
157
158 _chatmessage_dirty_time = std::chrono::steady_clock::now();
159 _chatmessage_dirty = true;
160 }
161}
162
164static const IntervalTimer<TimerWindow> network_message_expired_interval(std::chrono::seconds(1), [](auto) {
165 auto now = std::chrono::steady_clock::now();
166 for (auto &cmsg : _chatmsg_list) {
167 /* Message has expired, remove from the list */
168 if (now > cmsg.remove_time && _chatmessage_dirty_time < cmsg.remove_time) {
170 _chatmessage_dirty = true;
171 break;
172 }
173 }
174});
175
178{
180 if (!_chatmessage_dirty) return;
181
182 const Window *w = FindWindowByClass(WindowClass::NetworkChat);
183 bool show_all = (w != nullptr);
184
185 /* First undraw if needed */
187
188 if (_iconsole_mode == IConsoleMode::Full) return;
189
190 /* Check if we have anything to draw at all */
191 if (!HaveChatMessages(show_all)) return;
192
193 int x = _chatmsg_box.x;
194 int y = _screen.height - _chatmsg_box.y - _chatmsg_box.height;
195 int width = _chatmsg_box.width;
196 int height = _chatmsg_box.height;
197 if (y < 0) {
198 height = std::max(height + y, std::min(_chatmsg_box.height, _screen.height));
199 y = 0;
200 }
201 if (x + width >= _screen.width) {
202 width = _screen.width - x;
203 }
204 if (width <= 0 || height <= 0) return;
205
206 /* Make a copy of the screen as it is before painting (for undraw) */
207 uint8_t *buffer = _chatmessage_backup.Allocate(BlitterFactory::GetCurrentBlitter()->BufferSize(width, height));
208 blitter->CopyToBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), buffer, width, height);
209
210 _cur_dpi = &_screen; // switch to _screen painting
211
212 auto now = std::chrono::steady_clock::now();
213 int string_height = 0;
214 for (auto &cmsg : _chatmsg_list) {
215 if (!show_all && cmsg.remove_time < now) continue;
216 string_height += GetStringLineCount(GetString(STR_JUST_RAW_STRING, cmsg.message), width - 1) * GetCharacterHeight(FontSize::Normal) + NETWORK_CHAT_LINE_SPACING;
217 }
218
219 string_height = std::min<uint>(string_height, MAX_CHAT_MESSAGES * (GetCharacterHeight(FontSize::Normal) + NETWORK_CHAT_LINE_SPACING));
220
221 int top = _screen.height - _chatmsg_box.y - string_height - 2;
222 int bottom = _screen.height - _chatmsg_box.y - 2;
223 /* Paint a half-transparent box behind the chat messages */
224 GfxFillRect(_chatmsg_box.x, top - 2, _chatmsg_box.x + _chatmsg_box.width - 1, bottom,
225 PALETTE_TO_TRANSPARENT, FillRectMode::Recolour // black, but with some alpha for background
226 );
227
228 /* Paint the chat messages starting with the lowest at the bottom */
229 int ypos = bottom - 2;
230
231 for (auto &cmsg : _chatmsg_list) {
232 if (!show_all && cmsg.remove_time < now) continue;
233 ypos = DrawStringMultiLine(_chatmsg_box.x + ScaleGUITrad(3), _chatmsg_box.x + _chatmsg_box.width - 1, top, ypos, cmsg.message, cmsg.colour, {AlignmentH::ForceLeft, AlignmentV::Bottom}) - NETWORK_CHAT_LINE_SPACING;
234 if (ypos < top) break;
235 }
236
237 /* Make sure the data is updated next flush */
238 VideoDriver::GetInstance()->MakeDirty(x, y, width, height);
239
241 _chatmessage_dirty = false;
242}
243
250static void SendChat(std::string_view buf, NetworkChatDestinationType type, int dest)
251{
252 if (buf.empty()) return;
253
254 NetworkAction action;
255 switch (type) {
259 default: NOT_REACHED();
260 }
261
262 if (!_network_server) {
263 MyClient::SendChat(action, type, dest, buf, 0);
264 } else {
265 NetworkServerSendChat(action, type, dest, buf, ClientID::Server);
266 }
267}
268
270class NetworkChatAutoCompletion final : public AutoCompletion {
271public:
272 using AutoCompletion::AutoCompletion;
273
274private:
275 std::vector<std::string> GetSuggestions([[maybe_unused]] std::string_view prefix, std::string_view query) override
276 {
277 std::vector<std::string> suggestions;
279 if (ci->client_name.starts_with(query)) {
280 suggestions.push_back(ci->client_name);
281 }
282 }
283 for (const Town *t : Town::Iterate()) {
284 /* Get the town-name via the string-system */
285 std::string town_name = GetString(STR_TOWN_NAME, t->index);
286 if (town_name.starts_with(query)) {
287 suggestions.push_back(std::move(town_name));
288 }
289 }
290 return suggestions;
291 }
292
293 void ApplySuggestion(std::string_view prefix, std::string_view suggestion) override
294 {
295 /* Add ': ' if we are at the start of the line (pretty) */
296 if (prefix.empty()) {
297 this->textbuf->Assign(fmt::format("{}: ", suggestion));
298 } else {
299 this->textbuf->Assign(fmt::format("{}{} ", prefix, suggestion));
300 }
301 }
302};
303
305struct NetworkChatWindow : public Window {
307 int dest = 0;
310
319 {
320 this->querystrings[WID_NC_TEXTBOX] = &this->message_editbox;
321 this->message_editbox.cancel_button = WID_NC_CLOSE;
322 this->message_editbox.ok_button = WID_NC_SENDBUTTON;
323
324 this->CreateNestedTree();
325 this->FinishInitNested(type);
326
328 InvalidateWindowData(WindowClass::News, 0, this->height);
329
331 }
332
333 void Close([[maybe_unused]] int data = 0) override
334 {
335 InvalidateWindowData(WindowClass::News, 0, 0);
336 this->Window::Close();
337 }
338
339 void FindWindowPlacementAndResize(int, int def_height, bool allow_resize) override
340 {
341 Window::FindWindowPlacementAndResize(_toolbar_width, def_height, allow_resize);
342 }
343
348 {
349 if (this->chat_tab_completion.AutoComplete()) {
350 this->SetDirty();
351 }
352 }
353
354 Point OnInitialPosition([[maybe_unused]] int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]] int window_number) override
355 {
356 Point pt = { 0, _screen.height - sm_height - FindWindowById(WindowClass::Statusbar, 0)->height };
357 return pt;
358 }
359
360 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
361 {
362 if (widget != WID_NC_DESTINATION) return this->Window::GetWidgetString(widget, stringid);
363
364 if (this->dtype == NetworkChatDestinationType::Client) {
365 return GetString(STR_NETWORK_CHAT_CLIENT_CAPTION, NetworkClientInfo::GetByClientID(static_cast<ClientID>(this->dest))->client_name);
366 }
367
368 return GetString(this->dtype == NetworkChatDestinationType::Broadcast ? STR_NETWORK_CHAT_ALL_CAPTION : STR_NETWORK_CHAT_COMPANY_CAPTION);
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 = EventState::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
426
429 WindowPosition::Manual, {}, 0, 0,
430 WindowClass::NetworkChat, WindowClass::None,
431 {},
433);
434
435
442{
443 CloseWindowByClass(WindowClass::NetworkChat);
444 new NetworkChatWindow(_chat_window_desc, type, dest);
445}
Generic auto-completion engine.
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:139
How all blitters should look like.
Definition base.hpp:28
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, NetworkChatDestinationType 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
Implementation of AutoCompletion for nicknames and town names in the chat.
std::vector< std::string > GetSuggestions(std::string_view prefix, std::string_view query) override
Get suggestions for auto completion with the given 'query' input text.
void ApplySuggestion(std::string_view prefix, std::string_view suggestion) override
Format the given suggestion after the given prefix, and write that to the buffer.
A reusable buffer that can be used for places that temporary allocate a bit of memory and do that ver...
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:59
Console functions used outside of the console code.
IConsoleMode _iconsole_mode
Console modes.
@ Full
In-game console is opened, whole screen.
Factory to 'query' all available blitters.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition fontcache.cpp:88
@ End
Align to the end, LTR/RTL aware.
@ Middle
Align to the middle.
int GetStringLineCount(std::string_view str, int maxw)
Calculates number of lines of string.
Definition gfx.cpp:735
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:111
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, ExtendedTextColour colour, Alignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition gfx.cpp:782
@ Normal
Index of the normal font in the font tables.
Definition gfx_type.h:249
@ Invalid
Invalid marker.
Definition gfx_type.h:302
@ Grey
Grey.
Definition gfx_type.h:299
@ Recolour
Apply a recolour sprite to the screen content.
Definition gfx_type.h:394
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(Alignment 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:1013
#define Point
Macro that prevents name conflicts between included headers.
bool _network_server
network-server is active
Definition network.cpp:64
Basic functions/variables used all over the place.
Base core network types and some helper functions to access them.
static void SendChat(std::string_view buf, NetworkChatDestinationType type, int dest)
Send an actual chat message.
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.
static bool HaveChatMessages(bool show_all)
Test if there are any chat messages to display.
void NetworkAddChatMessage(ExtendedTextColour 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.
void ShowNetworkChatQueryWindow(NetworkChatDestinationType type, int dest)
Show the chat window.
static const uint NETWORK_CHAT_LINE_SPACING
Spacing between chat lines.
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.
static WindowDesc _chat_window_desc(WindowPosition::Manual, {}, 0, 0, WindowClass::NetworkChat, WindowClass::None, {}, _nested_chat_window_widgets)
The description of the chat window.
Types related to the network chat widgets.
@ 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.
Network functions used by other parts of OpenTTD.
void NetworkServerSendChat(NetworkAction action, NetworkChatDestinationType type, int dest, std::string_view msg, ClientID from_id, int64_t data=0, bool from_admin=false)
Send an actual chat message.
NetworkAction
Actions that can be used for NetworkTextMessage.
@ ChatTeam
A chat sent to all clients of a team/company.
@ ChatClient
A chat sent to a specific client.
@ ChatBroadcast
A chat broadcast to all clients.
NetworkChatDestinationType
Destination of our chat messages.
@ Client
Send message/notice to only a certain client (Private).
@ Team
Send message/notice to everyone playing the same company (Team).
@ Broadcast
Send message/notice to all clients (All).
ClientID
'Unique' identifier to be given to clients
@ Server
Servers always have this ID.
Base for the GUIs that have an edit box in them.
A number of safeguards to prevent using unsafe methods.
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:1791
Definition of base types and functions in a cross-platform compatible way.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:423
Functions related to OTTD's strings.
StrongType::Typedef< uint32_t, struct StringIDTag, StrongType::Compare, StrongType::Integer > StringID
Numeric value that represents a string, independent of the selected language.
Container for a message.
ExtendedTextColour 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.
Container for the text colour and some text colour related flags for drawing.
Definition gfx_type.h:349
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.
void OnEditboxChanged(WidgetID widget) override
The text in an editbox has been edited.
NetworkChatWindow(WindowDesc &desc, NetworkChatDestinationType type, int dest)
Create a chat input window.
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.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
QueryString message_editbox
Message editbox.
NetworkChatDestinationType dtype
The type of destination.
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:114
Specification of a rectangle with an absolute top-left coordinate and a (relative) width/height.
static Pool::IterateWrapper< NetworkClientInfo > Iterate(size_t from=0)
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:283
Town data structure.
Definition town.h:64
High level window description.
Definition window_gui.h:171
Data structure for an opened window.
Definition window_gui.h:272
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Definition window.cpp:1150
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition window.cpp:1855
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition window_gui.h:319
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
Definition window.cpp:513
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition window.cpp:1845
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
Definition window.cpp:494
virtual void FindWindowPlacementAndResize(int def_width, int def_height, bool allow_resize)
Resize window towards the default size.
Definition window.cpp:1523
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition window.cpp:1879
int height
Height of the window (number of pixels down in y direction).
Definition window_gui.h:311
WindowNumber window_number
Window number within the window class.
Definition window_gui.h:301
Definition of Interval and OneShot timers.
Definition of the Window system.
uint _toolbar_width
Width of the toolbar, shared by statusbar.
Stuff related to the (main) toolbar.
Base of the town class.
Base of all video drivers.
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:3582
Window * FindWindowByClass(WindowClass cls)
Find any window by its class.
Definition window.cpp:1214
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition window.cpp:1255
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:3377
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition window.cpp:1199
Window functions not directly related to making/drawing windows.
@ Manual
Manually align the window (so no automatic location finding).
Definition window_gui.h:144
int WidgetID
Widget ID.
Definition window_type.h:21
EventState
State of handling an event.
@ Handled
The passed event is handled.
@ NotHandled
The passed event is not handled.
Functions related to zooming.