2016-01-20 23:45:09 +01:00
|
|
|
/*****************************************************************************
|
2022-10-01 09:42:14 +02:00
|
|
|
* Copyright (c) 2014-2022 OpenRCT2 developers
|
2016-01-20 23:45:09 +01:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2016-01-20 23:45:09 +01:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2016-01-20 23:45:09 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2-ui/interface/Dropdown.h>
|
2018-01-03 00:13:37 +01:00
|
|
|
#include <openrct2-ui/interface/Widget.h>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2-ui/windows/Window.h>
|
2018-11-19 23:10:54 +01:00
|
|
|
#include <openrct2/Game.h>
|
Split actions hpp files into separate h and cpp files (#13548)
* Split up SmallSceneryPlace/Remove
Added undo function for Remove Scenery
* Refactor: Balloon and Banner actions hpp=>h/cpp
* Refactor: rename all action *.hpp files to *.cpp
This is preparation for separation in later commits. Note that without
the complete set of commits in this branch, the code will not build.
* Refactor Clear, Climate, Custom, and Footpath actions hpp=>h/cpp
* VSCode: add src subdirectories to includePath
* Refactor Guest actions hpp=>h/cpp
* Refactor Land actions hpp=>h/cpp
* Refactor LargeScenery actions hpp=>h/cpp
* Refactor Load, Maze, Network actions hpp=>h/cpp
* Refactor Park actions hpp=>h/cpp
* Refactor/style: move private function declarations in actions *.h
Previous action .h files included private function declarations with
private member variables, before public function declarations. This
commit re-orders the header files to the following order:
- public member variables
- private member variables
- public functions
- private functions
* Refactor Pause action hpp=>h/cpp
* Refactor Peep, Place, Player actions hpp=>h/cpp
* Refactor Ride actions hpp=>h/cpp
* Refactor Scenario, Set*, Sign* actions hpp=>h/cpp
* Refactor SmallScenerySetColourAction hpp=>h/cpp
* Refactor Staff actions hpp=>h/cpp
* Refactor Surface, Tile, Track* actions hpp=>h/cpp
* Refactor Wall and Water actions hpp=>h/cpp
* Fix various includes and other compile errors
Update includes for tests.
Move static function declarations to .h files
Add explicit includes to various files that were previously implicit
(the required header was a nested include in an action hpp file, and the
action .h file does not include that header)
Move RideSetStatus string enum to the cpp file to avoid unused imports
* Xcode: modify project file for actions refactor
* Cleanup whitespace and end-of-file newlines
Co-authored-by: duncanspumpkin <duncans_pumpkin@hotmail.co.uk>
2020-12-10 07:39:10 +01:00
|
|
|
#include <openrct2/actions/NetworkModifyGroupAction.h>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2/config/Config.h>
|
2022-07-21 08:50:43 +02:00
|
|
|
#include <openrct2/core/String.hpp>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2/drawing/Drawing.h>
|
2018-01-06 18:32:25 +01:00
|
|
|
#include <openrct2/localisation/Localisation.h>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2/network/network.h>
|
2017-09-18 17:05:28 +02:00
|
|
|
#include <openrct2/sprites.h>
|
2017-12-13 13:02:24 +01:00
|
|
|
#include <openrct2/util/Util.h>
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2018-05-16 20:41:29 +02:00
|
|
|
// clang-format off
|
2016-01-20 23:45:09 +01:00
|
|
|
enum {
|
2017-06-06 23:24:18 +02:00
|
|
|
WINDOW_MULTIPLAYER_PAGE_INFORMATION,
|
|
|
|
WINDOW_MULTIPLAYER_PAGE_PLAYERS,
|
|
|
|
WINDOW_MULTIPLAYER_PAGE_GROUPS,
|
|
|
|
WINDOW_MULTIPLAYER_PAGE_OPTIONS
|
2016-01-20 23:45:09 +01:00
|
|
|
};
|
|
|
|
|
2021-11-26 15:25:34 +01:00
|
|
|
enum WindowMultiplayerWidgetIdx {
|
2017-06-06 23:24:18 +02:00
|
|
|
WIDX_BACKGROUND,
|
|
|
|
WIDX_TITLE,
|
|
|
|
WIDX_CLOSE,
|
|
|
|
WIDX_CONTENT_PANEL,
|
|
|
|
WIDX_TAB1,
|
|
|
|
WIDX_TAB2,
|
|
|
|
WIDX_TAB3,
|
|
|
|
WIDX_TAB4,
|
|
|
|
|
2018-03-09 21:01:11 +01:00
|
|
|
WIDX_HEADER_PLAYER = 8,
|
|
|
|
WIDX_HEADER_GROUP,
|
|
|
|
WIDX_HEADER_LAST_ACTION,
|
|
|
|
WIDX_HEADER_PING,
|
|
|
|
WIDX_LIST,
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
WIDX_DEFAULT_GROUP = 8,
|
|
|
|
WIDX_DEFAULT_GROUP_DROPDOWN,
|
|
|
|
WIDX_ADD_GROUP,
|
|
|
|
WIDX_REMOVE_GROUP,
|
|
|
|
WIDX_RENAME_GROUP,
|
|
|
|
WIDX_SELECTED_GROUP,
|
|
|
|
WIDX_SELECTED_GROUP_DROPDOWN,
|
|
|
|
WIDX_PERMISSIONS_LIST,
|
|
|
|
|
|
|
|
WIDX_LOG_CHAT_CHECKBOX = 8,
|
|
|
|
WIDX_LOG_SERVER_ACTIONS_CHECKBOX,
|
|
|
|
WIDX_KNOWN_KEYS_ONLY_CHECKBOX,
|
2016-01-20 23:45:09 +01:00
|
|
|
};
|
|
|
|
|
2016-05-26 20:34:37 +02:00
|
|
|
#define MAIN_MULTIPLAYER_WIDGETS \
|
2020-11-27 04:14:20 +01:00
|
|
|
MakeWidget({ 0, 0}, {340, 240}, WindowWidgetType::Frame, WindowColour::Primary ), /* panel / background */ \
|
|
|
|
MakeWidget({ 1, 1}, {338, 14}, WindowWidgetType::Caption, WindowColour::Primary, STR_NONE, STR_WINDOW_TITLE_TIP ), /* title bar */ \
|
|
|
|
MakeWidget({327, 2}, { 11, 12}, WindowWidgetType::CloseBox, WindowColour::Primary, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP ), /* close x button */ \
|
|
|
|
MakeWidget({ 0, 43}, {340, 197}, WindowWidgetType::Resize, WindowColour::Secondary ), /* content panel */ \
|
2020-08-29 04:31:31 +02:00
|
|
|
MakeTab ({ 3, 17}, STR_SHOW_SERVER_INFO_TIP), /* tab */ \
|
|
|
|
MakeTab ({ 34, 17}, STR_PLAYERS_TIP ), /* tab */ \
|
|
|
|
MakeTab ({ 65, 17}, STR_GROUPS_TIP ), /* tab */ \
|
|
|
|
MakeTab ({ 96, 17}, STR_OPTIONS_TIP ) /* tab */
|
2016-05-26 20:34:37 +02:00
|
|
|
|
2016-05-30 21:54:50 +02:00
|
|
|
static rct_widget window_multiplayer_information_widgets[] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
MAIN_MULTIPLAYER_WIDGETS,
|
2021-09-26 11:11:42 +02:00
|
|
|
WIDGETS_END,
|
2016-05-30 21:54:50 +02:00
|
|
|
};
|
|
|
|
|
2016-01-20 23:45:09 +01:00
|
|
|
static rct_widget window_multiplayer_players_widgets[] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
MAIN_MULTIPLAYER_WIDGETS,
|
2020-11-27 04:14:20 +01:00
|
|
|
MakeWidget({ 3, 46}, {173, 15}, WindowWidgetType::TableHeader, WindowColour::Primary , STR_PLAYER ), // Player name
|
|
|
|
MakeWidget({176, 46}, { 83, 15}, WindowWidgetType::TableHeader, WindowColour::Primary , STR_GROUP ), // Player name
|
|
|
|
MakeWidget({259, 46}, {100, 15}, WindowWidgetType::TableHeader, WindowColour::Primary , STR_LAST_ACTION), // Player name
|
|
|
|
MakeWidget({359, 46}, { 42, 15}, WindowWidgetType::TableHeader, WindowColour::Primary , STR_PING ), // Player name
|
|
|
|
MakeWidget({ 3, 60}, {334, 177}, WindowWidgetType::Scroll, WindowColour::Secondary, SCROLL_VERTICAL), // list
|
2021-09-26 11:11:42 +02:00
|
|
|
WIDGETS_END,
|
2016-01-20 23:45:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static rct_widget window_multiplayer_groups_widgets[] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
MAIN_MULTIPLAYER_WIDGETS,
|
2020-11-27 04:14:20 +01:00
|
|
|
MakeWidget({141, 46}, {175, 12}, WindowWidgetType::DropdownMenu, WindowColour::Secondary ), // default group
|
|
|
|
MakeWidget({305, 47}, { 11, 10}, WindowWidgetType::Button, WindowColour::Secondary, STR_DROPDOWN_GLYPH),
|
|
|
|
MakeWidget({ 11, 65}, { 92, 12}, WindowWidgetType::Button, WindowColour::Secondary, STR_ADD_GROUP ), // add group button
|
|
|
|
MakeWidget({113, 65}, { 92, 12}, WindowWidgetType::Button, WindowColour::Secondary, STR_REMOVE_GROUP ), // remove group button
|
|
|
|
MakeWidget({215, 65}, { 92, 12}, WindowWidgetType::Button, WindowColour::Secondary, STR_RENAME_GROUP ), // rename group button
|
|
|
|
MakeWidget({ 72, 80}, {175, 12}, WindowWidgetType::DropdownMenu, WindowColour::Secondary ), // selected group
|
|
|
|
MakeWidget({236, 81}, { 11, 10}, WindowWidgetType::Button, WindowColour::Secondary, STR_DROPDOWN_GLYPH),
|
|
|
|
MakeWidget({ 3, 94}, {314, 207}, WindowWidgetType::Scroll, WindowColour::Secondary, SCROLL_VERTICAL ), // permissions list
|
2021-09-26 11:11:42 +02:00
|
|
|
WIDGETS_END,
|
2016-05-26 20:34:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static rct_widget window_multiplayer_options_widgets[] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
MAIN_MULTIPLAYER_WIDGETS,
|
2020-11-27 04:14:20 +01:00
|
|
|
MakeWidget({3, 50}, {295, 12}, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_LOG_CHAT, STR_LOG_CHAT_TIP ),
|
|
|
|
MakeWidget({3, 64}, {295, 12}, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_LOG_SERVER_ACTIONS, STR_LOG_SERVER_ACTIONS_TIP ),
|
|
|
|
MakeWidget({3, 78}, {295, 12}, WindowWidgetType::Checkbox, WindowColour::Secondary, STR_ALLOW_KNOWN_KEYS_ONLY, STR_ALLOW_KNOWN_KEYS_ONLY_TIP),
|
2021-09-26 11:11:42 +02:00
|
|
|
WIDGETS_END,
|
2016-01-20 23:45:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static rct_widget *window_multiplayer_page_widgets[] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
window_multiplayer_information_widgets,
|
|
|
|
window_multiplayer_players_widgets,
|
|
|
|
window_multiplayer_groups_widgets,
|
2021-10-17 15:31:56 +02:00
|
|
|
window_multiplayer_options_widgets,
|
2016-01-20 23:45:09 +01:00
|
|
|
};
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2022-07-31 14:22:58 +02:00
|
|
|
static constexpr StringId WindowMultiplayerPageTitles[] = {
|
2018-03-30 20:23:25 +02:00
|
|
|
STR_MULTIPLAYER_INFORMATION_TITLE,
|
|
|
|
STR_MULTIPLAYER_PLAYERS_TITLE,
|
|
|
|
STR_MULTIPLAYER_GROUPS_TITLE,
|
|
|
|
STR_MULTIPLAYER_OPTIONS_TITLE,
|
|
|
|
};
|
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
static uint8_t _selectedGroup = 0;
|
2016-01-22 04:32:51 +01:00
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
static void WindowMultiplayerInformationMouseup(rct_window *w, WidgetIndex widgetIndex);
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerInformationResize(rct_window *w);
|
|
|
|
static void WindowMultiplayerInformationUpdate(rct_window *w);
|
|
|
|
static void WindowMultiplayerInformationInvalidate(rct_window *w);
|
|
|
|
static void WindowMultiplayerInformationPaint(rct_window *w, rct_drawpixelinfo *dpi);
|
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
static void WindowMultiplayerPlayersMouseup(rct_window *w, WidgetIndex widgetIndex);
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerPlayersResize(rct_window *w);
|
|
|
|
static void WindowMultiplayerPlayersUpdate(rct_window *w);
|
|
|
|
static void WindowMultiplayerPlayersScrollgetsize(rct_window *w, int32_t scrollIndex, int32_t *width, int32_t *height);
|
|
|
|
static void WindowMultiplayerPlayersScrollmousedown(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
|
|
|
static void WindowMultiplayerPlayersScrollmouseover(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
|
|
|
static void WindowMultiplayerPlayersInvalidate(rct_window *w);
|
|
|
|
static void WindowMultiplayerPlayersPaint(rct_window *w, rct_drawpixelinfo *dpi);
|
|
|
|
static void WindowMultiplayerPlayersScrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int32_t scrollIndex);
|
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
static void WindowMultiplayerGroupsMouseup(rct_window *w, WidgetIndex widgetIndex);
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerGroupsResize(rct_window *w);
|
2022-08-21 18:49:23 +02:00
|
|
|
static void WindowMultiplayerGroupsMousedown(rct_window *w, WidgetIndex widgetIndex, rct_widget* widget);
|
|
|
|
static void WindowMultiplayerGroupsDropdown(rct_window *w, WidgetIndex widgetIndex, int32_t dropdownIndex);
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerGroupsUpdate(rct_window *w);
|
|
|
|
static void WindowMultiplayerGroupsScrollgetsize(rct_window *w, int32_t scrollIndex, int32_t *width, int32_t *height);
|
|
|
|
static void WindowMultiplayerGroupsScrollmousedown(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
|
|
|
static void WindowMultiplayerGroupsScrollmouseover(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
2022-08-21 18:49:23 +02:00
|
|
|
static void WindowMultiplayerGroupsTextInput(rct_window *w, WidgetIndex widgetIndex, char *text);
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerGroupsInvalidate(rct_window *w);
|
|
|
|
static void WindowMultiplayerGroupsPaint(rct_window *w, rct_drawpixelinfo *dpi);
|
|
|
|
static void WindowMultiplayerGroupsScrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int32_t scrollIndex);
|
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
static void WindowMultiplayerOptionsMouseup(rct_window *w, WidgetIndex widgetIndex);
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerOptionsResize(rct_window *w);
|
|
|
|
static void WindowMultiplayerOptionsUpdate(rct_window *w);
|
|
|
|
static void WindowMultiplayerOptionsInvalidate(rct_window *w);
|
|
|
|
static void WindowMultiplayerOptionsPaint(rct_window *w, rct_drawpixelinfo *dpi);
|
2016-05-26 20:34:37 +02:00
|
|
|
|
2022-08-27 16:56:52 +02:00
|
|
|
static WindowEventList window_multiplayer_information_events([](auto& events)
|
2020-09-28 20:36:15 +02:00
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
events.mouse_up = &WindowMultiplayerInformationMouseup;
|
|
|
|
events.resize = &WindowMultiplayerInformationResize;
|
|
|
|
events.update = &WindowMultiplayerInformationUpdate;
|
|
|
|
events.invalidate = &WindowMultiplayerInformationInvalidate;
|
|
|
|
events.paint = &WindowMultiplayerInformationPaint;
|
2020-09-28 20:36:15 +02:00
|
|
|
});
|
|
|
|
|
2022-08-27 16:56:52 +02:00
|
|
|
static WindowEventList window_multiplayer_players_events([](auto& events)
|
2020-09-28 20:36:15 +02:00
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
events.mouse_up = &WindowMultiplayerPlayersMouseup;
|
|
|
|
events.resize = &WindowMultiplayerPlayersResize;
|
|
|
|
events.update = &WindowMultiplayerPlayersUpdate;
|
|
|
|
events.get_scroll_size = &WindowMultiplayerPlayersScrollgetsize;
|
|
|
|
events.scroll_mousedown = &WindowMultiplayerPlayersScrollmousedown;
|
|
|
|
events.scroll_mouseover = &WindowMultiplayerPlayersScrollmouseover;
|
|
|
|
events.invalidate = &WindowMultiplayerPlayersInvalidate;
|
|
|
|
events.paint = &WindowMultiplayerPlayersPaint;
|
|
|
|
events.scroll_paint = &WindowMultiplayerPlayersScrollpaint;
|
2020-09-28 20:36:15 +02:00
|
|
|
});
|
|
|
|
|
2022-08-27 16:56:52 +02:00
|
|
|
static WindowEventList window_multiplayer_groups_events([](auto& events)
|
2020-09-28 20:36:15 +02:00
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
events.mouse_up = &WindowMultiplayerGroupsMouseup;
|
|
|
|
events.resize = &WindowMultiplayerGroupsResize;
|
|
|
|
events.mouse_down = &WindowMultiplayerGroupsMousedown;
|
|
|
|
events.dropdown = &WindowMultiplayerGroupsDropdown;
|
|
|
|
events.update = &WindowMultiplayerGroupsUpdate;
|
|
|
|
events.get_scroll_size = &WindowMultiplayerGroupsScrollgetsize;
|
|
|
|
events.scroll_mousedown = &WindowMultiplayerGroupsScrollmousedown;
|
|
|
|
events.scroll_mouseover = &WindowMultiplayerGroupsScrollmouseover;
|
|
|
|
events.text_input = &WindowMultiplayerGroupsTextInput;
|
|
|
|
events.invalidate = &WindowMultiplayerGroupsInvalidate;
|
|
|
|
events.paint = &WindowMultiplayerGroupsPaint;
|
|
|
|
events.scroll_paint = &WindowMultiplayerGroupsScrollpaint;
|
2020-09-28 20:36:15 +02:00
|
|
|
});
|
|
|
|
|
2022-08-27 16:56:52 +02:00
|
|
|
static WindowEventList window_multiplayer_options_events([](auto& events)
|
2020-09-28 20:36:15 +02:00
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
events.mouse_up = &WindowMultiplayerOptionsMouseup;
|
|
|
|
events.resize = &WindowMultiplayerOptionsResize;
|
|
|
|
events.update = &WindowMultiplayerOptionsUpdate;
|
|
|
|
events.invalidate = &WindowMultiplayerOptionsInvalidate;
|
|
|
|
events.paint = &WindowMultiplayerOptionsPaint;
|
2020-09-28 20:36:15 +02:00
|
|
|
});
|
2016-05-26 20:34:37 +02:00
|
|
|
|
2022-08-27 16:56:52 +02:00
|
|
|
static WindowEventList *window_multiplayer_page_events[] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
&window_multiplayer_information_events,
|
|
|
|
&window_multiplayer_players_events,
|
|
|
|
&window_multiplayer_groups_events,
|
2021-10-17 15:31:56 +02:00
|
|
|
&window_multiplayer_options_events,
|
2016-01-20 23:45:09 +01:00
|
|
|
};
|
2018-05-16 20:41:29 +02:00
|
|
|
// clang-format on
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2021-10-17 15:31:56 +02:00
|
|
|
static constexpr const int32_t window_multiplayer_animation_divisor[] = {
|
|
|
|
4,
|
|
|
|
4,
|
|
|
|
2,
|
|
|
|
2,
|
|
|
|
};
|
|
|
|
static constexpr const int32_t window_multiplayer_animation_frames[] = {
|
|
|
|
8,
|
|
|
|
8,
|
|
|
|
7,
|
|
|
|
4,
|
|
|
|
};
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerDrawTabImages(rct_window* w, rct_drawpixelinfo* dpi);
|
|
|
|
static void WindowMultiplayerSetPage(rct_window* w, int32_t page);
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2016-05-30 21:54:50 +02:00
|
|
|
static bool _windowInformationSizeDirty;
|
2020-03-01 21:24:44 +01:00
|
|
|
static ScreenCoordsXY _windowInformationSize;
|
2016-05-30 21:54:50 +02:00
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
rct_window* WindowMultiplayerOpen()
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Check if window is already open
|
2022-08-21 18:38:25 +02:00
|
|
|
rct_window* window = window_bring_to_front_by_class(WindowClass::Multiplayer);
|
2018-06-22 23:21:44 +02:00
|
|
|
if (window == nullptr)
|
|
|
|
{
|
2022-08-21 18:38:25 +02:00
|
|
|
window = WindowCreateAutoPos(
|
|
|
|
320, 144, &window_multiplayer_players_events, WindowClass::Multiplayer, WF_10 | WF_RESIZABLE);
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMultiplayerSetPage(window, WINDOW_MULTIPLAYER_PAGE_INFORMATION);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2017-08-06 05:22:00 +02:00
|
|
|
|
|
|
|
return window;
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerSetPage(rct_window* w, int32_t page)
|
2016-05-30 21:54:50 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
_windowInformationSizeDirty = true;
|
2016-05-30 21:54:50 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
w->page = page;
|
|
|
|
w->frame_no = 0;
|
|
|
|
w->no_list_items = 0;
|
|
|
|
w->selected_list_item = -1;
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
w->hold_down_widgets = 0;
|
|
|
|
w->event_handlers = window_multiplayer_page_events[page];
|
|
|
|
w->pressed_widgets = 0;
|
|
|
|
w->widgets = window_multiplayer_page_widgets[page];
|
2018-03-30 21:27:06 +02:00
|
|
|
w->widgets[WIDX_TITLE].text = WindowMultiplayerPageTitles[page];
|
2016-05-26 20:34:37 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
window_event_resize_call(w);
|
|
|
|
window_event_invalidate_call(w);
|
2022-07-30 21:59:47 +02:00
|
|
|
WindowInitScrollWidgets(*w);
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerAnchorBorderWidgets(rct_window* w)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->widgets[WIDX_BACKGROUND].right = w->width - 1;
|
|
|
|
w->widgets[WIDX_BACKGROUND].bottom = w->height - 1;
|
|
|
|
w->widgets[WIDX_TITLE].right = w->width - 2;
|
|
|
|
w->widgets[WIDX_CONTENT_PANEL].right = w->width - 1;
|
|
|
|
w->widgets[WIDX_CONTENT_PANEL].bottom = w->height - 1;
|
|
|
|
w->widgets[WIDX_CLOSE].left = w->width - 13;
|
|
|
|
w->widgets[WIDX_CLOSE].right = w->width - 3;
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerSetPressedTab(rct_window* w)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
for (int32_t i = 0; i < 2; i++)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->pressed_widgets &= ~(1 << (WIDX_TAB1 + i));
|
|
|
|
}
|
|
|
|
w->pressed_widgets |= 1LL << (WIDX_TAB1 + w->page);
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerGroupsShowGroupDropdown(rct_window* w, rct_widget* widget)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_widget* dropdownWidget;
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t numItems, i;
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
dropdownWidget = widget - 1;
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
numItems = network_get_num_groups();
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2020-11-03 09:16:06 +01:00
|
|
|
WindowDropdownShowTextCustomWidth(
|
2020-06-25 03:44:00 +02:00
|
|
|
{ w->windowPos.x + dropdownWidget->left, w->windowPos.y + dropdownWidget->top }, dropdownWidget->height() + 1,
|
|
|
|
w->colours[1], 0, 0, numItems, widget->right - dropdownWidget->left);
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
for (i = 0; i < network_get_num_groups(); i++)
|
|
|
|
{
|
2022-02-12 23:57:22 +01:00
|
|
|
gDropdownItems[i].Format = STR_OPTIONS_DROPDOWN_ITEM;
|
|
|
|
gDropdownItems[i].Args = reinterpret_cast<uintptr_t>(network_get_group_name(i));
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2018-06-22 23:21:44 +02:00
|
|
|
if (widget == &window_multiplayer_groups_widgets[WIDX_DEFAULT_GROUP_DROPDOWN])
|
|
|
|
{
|
2020-11-03 09:16:06 +01:00
|
|
|
Dropdown::SetChecked(network_get_group_index(network_get_default_group()), true);
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
|
|
|
else if (widget == &window_multiplayer_groups_widgets[WIDX_SELECTED_GROUP_DROPDOWN])
|
|
|
|
{
|
2020-11-03 09:16:06 +01:00
|
|
|
Dropdown::SetChecked(network_get_group_index(_selectedGroup), true);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2016-05-30 21:54:50 +02:00
|
|
|
#pragma region Information page
|
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
static void WindowMultiplayerInformationMouseup(rct_window* w, WidgetIndex widgetIndex)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_CLOSE:
|
2022-07-31 00:25:33 +02:00
|
|
|
window_close(*w);
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_TAB1:
|
|
|
|
case WIDX_TAB2:
|
|
|
|
case WIDX_TAB3:
|
|
|
|
case WIDX_TAB4:
|
|
|
|
if (w->page != widgetIndex - WIDX_TAB1)
|
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMultiplayerSetPage(w, widgetIndex - WIDX_TAB1);
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-05-30 21:54:50 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static ScreenCoordsXY WindowMultiplayerInformationGetSize()
|
2016-05-30 21:54:50 +02:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
if (!_windowInformationSizeDirty)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
return _windowInformationSize;
|
|
|
|
}
|
2016-05-30 21:54:50 +02:00
|
|
|
|
2021-02-27 12:40:20 +01:00
|
|
|
int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM);
|
2019-01-07 12:17:37 +01:00
|
|
|
|
|
|
|
// Base dimensions.
|
|
|
|
const int32_t width = 450;
|
|
|
|
int32_t height = 55;
|
2021-02-27 12:40:20 +01:00
|
|
|
int32_t numLines;
|
2019-01-07 12:17:37 +01:00
|
|
|
|
|
|
|
// Server name is displayed word-wrapped, so figure out how high it will be.
|
|
|
|
{
|
2022-07-28 19:19:38 +02:00
|
|
|
u8string buffer = network_get_server_name();
|
|
|
|
gfx_wrap_string(buffer.data(), width, FontSpriteBase::MEDIUM, &numLines);
|
2019-01-07 12:17:37 +01:00
|
|
|
height += ++numLines * lineHeight + (LIST_ROW_HEIGHT / 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Likewise, for the optional server description -- which can be a little longer.
|
|
|
|
const utf8* descString = network_get_server_description();
|
|
|
|
if (!str_is_null_or_empty(descString))
|
|
|
|
{
|
2022-07-28 19:19:38 +02:00
|
|
|
u8string buffer = descString;
|
|
|
|
gfx_wrap_string(buffer.data(), width, FontSpriteBase::MEDIUM, &numLines);
|
2019-01-07 12:17:37 +01:00
|
|
|
height += ++numLines * lineHeight + (LIST_ROW_HEIGHT / 2);
|
|
|
|
}
|
2016-06-13 20:02:37 +02:00
|
|
|
|
2019-01-07 12:17:37 +01:00
|
|
|
// Finally, account for provider info, if present.
|
|
|
|
{
|
|
|
|
const utf8* providerName = network_get_server_provider_name();
|
|
|
|
if (!str_is_null_or_empty(providerName))
|
|
|
|
height += LIST_ROW_HEIGHT;
|
|
|
|
|
|
|
|
const utf8* providerEmail = network_get_server_provider_email();
|
|
|
|
if (!str_is_null_or_empty(providerEmail))
|
|
|
|
height += LIST_ROW_HEIGHT;
|
|
|
|
|
|
|
|
const utf8* providerWebsite = network_get_server_provider_website();
|
|
|
|
if (!str_is_null_or_empty(providerWebsite))
|
|
|
|
height += LIST_ROW_HEIGHT;
|
|
|
|
}
|
2016-05-30 21:54:50 +02:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
_windowInformationSizeDirty = false;
|
2020-04-18 13:32:48 +02:00
|
|
|
_windowInformationSize = { static_cast<int16_t>(width), static_cast<int16_t>(height) };
|
2017-06-06 23:24:18 +02:00
|
|
|
return _windowInformationSize;
|
2016-05-30 21:54:50 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerInformationResize(rct_window* w)
|
2016-05-30 21:54:50 +02:00
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
auto size = WindowMultiplayerInformationGetSize();
|
2022-07-31 00:25:33 +02:00
|
|
|
window_set_resize(*w, size.x, size.y, size.x, size.y);
|
2016-05-30 21:54:50 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerInformationUpdate(rct_window* w)
|
2016-05-30 21:54:50 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->frame_no++;
|
2022-07-31 00:25:33 +02:00
|
|
|
widget_invalidate(*w, WIDX_TAB1 + w->page);
|
2016-05-30 21:54:50 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerInformationInvalidate(rct_window* w)
|
2016-05-30 21:54:50 +02:00
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMultiplayerSetPressedTab(w);
|
|
|
|
WindowMultiplayerAnchorBorderWidgets(w);
|
2017-06-06 23:24:18 +02:00
|
|
|
window_align_tabs(w, WIDX_TAB1, WIDX_TAB4);
|
2016-05-30 21:54:50 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerInformationPaint(rct_window* w, rct_drawpixelinfo* dpi)
|
2016-05-30 21:54:50 +02:00
|
|
|
{
|
2022-07-30 21:59:47 +02:00
|
|
|
WindowDrawWidgets(*w, dpi);
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMultiplayerDrawTabImages(w, dpi);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
rct_drawpixelinfo clippedDPI;
|
2020-07-02 19:06:28 +02:00
|
|
|
if (clip_drawpixelinfo(&clippedDPI, dpi, w->windowPos, w->width, w->height))
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
dpi = &clippedDPI;
|
|
|
|
|
2020-06-20 16:56:36 +02:00
|
|
|
auto screenCoords = ScreenCoordsXY{ 3, 50 };
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t width = w->width - 6;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
const utf8* name = network_get_server_name();
|
2017-06-06 23:24:18 +02:00
|
|
|
{
|
2021-08-21 09:42:05 +02:00
|
|
|
auto ft = Formatter();
|
|
|
|
ft.Add<const char*>(name);
|
|
|
|
screenCoords.y += DrawTextWrapped(dpi, screenCoords, width, STR_STRING, ft, { w->colours[1] });
|
2020-06-20 16:56:36 +02:00
|
|
|
screenCoords.y += LIST_ROW_HEIGHT / 2;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
const utf8* description = network_get_server_description();
|
|
|
|
if (!str_is_null_or_empty(description))
|
|
|
|
{
|
2021-08-21 09:42:05 +02:00
|
|
|
auto ft = Formatter();
|
|
|
|
ft.Add<const char*>(description);
|
|
|
|
screenCoords.y += DrawTextWrapped(dpi, screenCoords, width, STR_STRING, ft, { w->colours[1] });
|
2020-06-20 16:56:36 +02:00
|
|
|
screenCoords.y += LIST_ROW_HEIGHT / 2;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
const utf8* providerName = network_get_server_provider_name();
|
|
|
|
if (!str_is_null_or_empty(providerName))
|
|
|
|
{
|
2021-07-27 20:32:27 +02:00
|
|
|
auto ft = Formatter();
|
|
|
|
ft.Add<const char*>(providerName);
|
|
|
|
DrawTextBasic(dpi, screenCoords, STR_PROVIDER_NAME, ft);
|
2020-06-20 16:56:36 +02:00
|
|
|
screenCoords.y += LIST_ROW_HEIGHT;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
const utf8* providerEmail = network_get_server_provider_email();
|
|
|
|
if (!str_is_null_or_empty(providerEmail))
|
|
|
|
{
|
2021-07-27 20:32:27 +02:00
|
|
|
auto ft = Formatter();
|
|
|
|
ft.Add<const char*>(providerEmail);
|
|
|
|
DrawTextBasic(dpi, screenCoords, STR_PROVIDER_EMAIL, ft);
|
2020-06-20 16:56:36 +02:00
|
|
|
screenCoords.y += LIST_ROW_HEIGHT;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
const utf8* providerWebsite = network_get_server_provider_website();
|
|
|
|
if (!str_is_null_or_empty(providerWebsite))
|
|
|
|
{
|
2021-07-27 20:32:27 +02:00
|
|
|
auto ft = Formatter();
|
|
|
|
ft.Add<const char*>(providerWebsite);
|
|
|
|
DrawTextBasic(dpi, screenCoords, STR_PROVIDER_WEBSITE, ft);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
2016-05-30 21:54:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma endregion
|
|
|
|
|
2016-05-26 20:34:37 +02:00
|
|
|
#pragma region Players page
|
|
|
|
|
2022-02-15 13:31:59 +01:00
|
|
|
static bool IsServerPlayerInvisible()
|
|
|
|
{
|
|
|
|
return network_is_server_player_invisible() && !gConfigGeneral.debugging_tools;
|
|
|
|
}
|
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
static void WindowMultiplayerPlayersMouseup(rct_window* w, WidgetIndex widgetIndex)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_CLOSE:
|
2022-07-31 00:25:33 +02:00
|
|
|
window_close(*w);
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_TAB1:
|
|
|
|
case WIDX_TAB2:
|
|
|
|
case WIDX_TAB3:
|
|
|
|
case WIDX_TAB4:
|
|
|
|
if (w->page != widgetIndex - WIDX_TAB1)
|
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMultiplayerSetPage(w, widgetIndex - WIDX_TAB1);
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerPlayersResize(rct_window* w)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2022-07-31 00:25:33 +02:00
|
|
|
window_set_resize(*w, 420, 124, 500, 450);
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2022-02-15 13:31:59 +01:00
|
|
|
w->no_list_items = (IsServerPlayerInvisible() ? network_get_num_visible_players() : network_get_num_players());
|
2017-06-06 23:24:18 +02:00
|
|
|
w->list_item_positions[0] = 0;
|
2016-01-22 04:32:51 +01:00
|
|
|
|
2018-03-09 21:01:11 +01:00
|
|
|
w->widgets[WIDX_HEADER_PING].right = w->width - 5;
|
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
w->selected_list_item = -1;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerPlayersUpdate(rct_window* w)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->frame_no++;
|
2022-07-31 00:25:33 +02:00
|
|
|
widget_invalidate(*w, WIDX_TAB1 + w->page);
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerPlayersScrollgetsize(rct_window* w, int32_t scrollIndex, int32_t* width, int32_t* height)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t i;
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
if (w->selected_list_item != -1)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->selected_list_item = -1;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2018-03-09 20:45:50 +01:00
|
|
|
*height = network_get_num_players() * SCROLLABLE_ROW_HEIGHT;
|
2017-06-06 23:24:18 +02:00
|
|
|
i = *height - window_multiplayer_players_widgets[WIDX_LIST].bottom + window_multiplayer_players_widgets[WIDX_LIST].top + 21;
|
|
|
|
if (i < 0)
|
|
|
|
i = 0;
|
2018-06-22 23:21:44 +02:00
|
|
|
if (i < w->scrolls[0].v_top)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->scrolls[0].v_top = i;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerPlayersScrollmousedown(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t index;
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2019-11-14 12:40:40 +01:00
|
|
|
index = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
2017-06-06 23:24:18 +02:00
|
|
|
if (index >= w->no_list_items)
|
|
|
|
return;
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
w->selected_list_item = index;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2022-02-15 13:31:59 +01:00
|
|
|
int32_t player = (IsServerPlayerInvisible() ? index + 1 : index);
|
|
|
|
WindowPlayerOpen(network_get_player_id(player));
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerPlayersScrollmouseover(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t index;
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2019-11-14 12:40:40 +01:00
|
|
|
index = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
2017-06-06 23:24:18 +02:00
|
|
|
if (index >= w->no_list_items)
|
|
|
|
return;
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
w->selected_list_item = index;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerPlayersInvalidate(rct_window* w)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMultiplayerSetPressedTab(w);
|
|
|
|
WindowMultiplayerAnchorBorderWidgets(w);
|
2017-06-06 23:24:18 +02:00
|
|
|
window_multiplayer_players_widgets[WIDX_LIST].right = w->width - 4;
|
|
|
|
window_multiplayer_players_widgets[WIDX_LIST].bottom = w->height - 0x0F;
|
|
|
|
window_align_tabs(w, WIDX_TAB1, WIDX_TAB4);
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerPlayersPaint(rct_window* w, rct_drawpixelinfo* dpi)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2022-07-31 14:22:58 +02:00
|
|
|
StringId stringId;
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2022-07-30 21:59:47 +02:00
|
|
|
WindowDrawWidgets(*w, dpi);
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMultiplayerDrawTabImages(w, dpi);
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// Number of players
|
|
|
|
stringId = w->no_list_items == 1 ? STR_MULTIPLAYER_PLAYER_COUNT : STR_MULTIPLAYER_PLAYER_COUNT_PLURAL;
|
2020-06-20 16:56:36 +02:00
|
|
|
auto screenCoords = w->windowPos + ScreenCoordsXY{ 4, w->widgets[WIDX_LIST].bottom + 2 };
|
2021-07-27 20:32:27 +02:00
|
|
|
auto ft = Formatter();
|
|
|
|
ft.Add<uint16_t>(w->no_list_items);
|
|
|
|
DrawTextBasic(dpi, screenCoords, stringId, ft, { w->colours[2] });
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerPlayersScrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2020-05-10 14:49:15 +02:00
|
|
|
ScreenCoordsXY screenCoords;
|
|
|
|
screenCoords.y = 0;
|
2022-02-15 13:31:59 +01:00
|
|
|
|
|
|
|
const int32_t firstPlayerInList = (IsServerPlayerInvisible() ? 1 : 0);
|
|
|
|
int32_t listPosition = 0;
|
|
|
|
|
|
|
|
for (int32_t player = firstPlayerInList; player < network_get_num_players(); player++)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2020-05-10 14:49:15 +02:00
|
|
|
if (screenCoords.y > dpi->y + dpi->height)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-05-10 14:49:15 +02:00
|
|
|
if (screenCoords.y + SCROLLABLE_ROW_HEIGHT + 1 >= dpi->y)
|
2018-03-09 20:45:50 +01:00
|
|
|
{
|
2021-11-24 18:08:41 +01:00
|
|
|
thread_local std::string _buffer;
|
|
|
|
_buffer.reserve(512);
|
|
|
|
_buffer.clear();
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Draw player name
|
2021-02-27 18:35:32 +01:00
|
|
|
colour_t colour = COLOUR_BLACK;
|
2022-02-15 13:31:59 +01:00
|
|
|
if (listPosition == w->selected_list_item)
|
2018-03-09 20:45:50 +01:00
|
|
|
{
|
2020-12-05 19:13:59 +01:00
|
|
|
gfx_filter_rect(
|
2021-10-21 00:43:32 +02:00
|
|
|
dpi, { 0, screenCoords.y, 800, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1 },
|
|
|
|
FilterPaletteID::PaletteDarken1);
|
2022-02-15 13:31:59 +01:00
|
|
|
_buffer += network_get_player_name(player);
|
2017-06-06 23:24:18 +02:00
|
|
|
colour = w->colours[2];
|
2018-03-09 20:45:50 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-15 13:31:59 +01:00
|
|
|
if (network_get_player_flags(player) & NETWORK_PLAYER_FLAG_ISSERVER)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2021-11-24 18:08:41 +01:00
|
|
|
_buffer += "{BABYBLUE}";
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-24 18:08:41 +01:00
|
|
|
_buffer += "{BLACK}";
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2022-02-15 13:31:59 +01:00
|
|
|
_buffer += network_get_player_name(player);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2020-05-10 14:49:15 +02:00
|
|
|
screenCoords.x = 0;
|
2021-11-24 18:08:41 +01:00
|
|
|
gfx_clip_string(_buffer.data(), 230, FontSpriteBase::MEDIUM);
|
|
|
|
gfx_draw_string(dpi, screenCoords, _buffer.c_str(), { colour });
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Draw group name
|
2021-11-24 18:08:41 +01:00
|
|
|
_buffer.resize(0);
|
2022-02-15 13:31:59 +01:00
|
|
|
int32_t group = network_get_group_index(network_get_player_group(player));
|
2018-06-22 23:21:44 +02:00
|
|
|
if (group != -1)
|
|
|
|
{
|
2021-11-24 18:08:41 +01:00
|
|
|
_buffer += "{BLACK}";
|
2020-05-10 14:49:15 +02:00
|
|
|
screenCoords.x = 173;
|
2021-11-24 18:08:41 +01:00
|
|
|
_buffer += network_get_group_name(group);
|
|
|
|
gfx_clip_string(_buffer.data(), 80, FontSpriteBase::MEDIUM);
|
|
|
|
gfx_draw_string(dpi, screenCoords, _buffer.c_str(), { colour });
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Draw last action
|
2022-02-15 13:31:59 +01:00
|
|
|
int32_t action = network_get_player_last_action(player, 2000);
|
2020-09-30 23:42:04 +02:00
|
|
|
auto ft = Formatter();
|
2018-06-22 23:21:44 +02:00
|
|
|
if (action != -999)
|
|
|
|
{
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(network_get_action_name_string_id(action));
|
2020-06-03 11:20:29 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-31 14:22:58 +02:00
|
|
|
ft.Add<StringId>(STR_ACTION_NA);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2021-02-28 00:22:24 +01:00
|
|
|
DrawTextEllipsised(dpi, { 256, screenCoords.y }, 100, STR_BLACK_STRING, ft);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Draw ping
|
2021-11-24 18:08:41 +01:00
|
|
|
_buffer.resize(0);
|
2022-02-15 13:31:59 +01:00
|
|
|
int32_t ping = network_get_player_ping(player);
|
2018-06-22 23:21:44 +02:00
|
|
|
if (ping <= 100)
|
|
|
|
{
|
2021-11-24 18:08:41 +01:00
|
|
|
_buffer += "{GREEN}";
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
|
|
|
else if (ping <= 250)
|
|
|
|
{
|
2021-11-24 18:08:41 +01:00
|
|
|
_buffer += "{YELLOW}";
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-24 18:08:41 +01:00
|
|
|
_buffer += "{RED}";
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2020-10-14 00:34:18 +02:00
|
|
|
|
|
|
|
char pingBuffer[64]{};
|
|
|
|
snprintf(pingBuffer, sizeof(pingBuffer), "%d ms", ping);
|
2021-11-24 18:08:41 +01:00
|
|
|
_buffer += pingBuffer;
|
2020-10-14 00:34:18 +02:00
|
|
|
|
2020-05-10 14:49:15 +02:00
|
|
|
screenCoords.x = 356;
|
2021-11-24 18:08:41 +01:00
|
|
|
gfx_draw_string(dpi, screenCoords, _buffer.c_str(), { colour });
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2020-05-10 14:49:15 +02:00
|
|
|
screenCoords.y += SCROLLABLE_ROW_HEIGHT;
|
2022-02-15 13:31:59 +01:00
|
|
|
listPosition++;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2016-05-26 20:34:37 +02:00
|
|
|
#pragma endregion
|
|
|
|
|
|
|
|
#pragma region Groups page
|
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
static void WindowMultiplayerGroupsMouseup(rct_window* w, WidgetIndex widgetIndex)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_CLOSE:
|
2022-07-31 00:25:33 +02:00
|
|
|
window_close(*w);
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_TAB1:
|
|
|
|
case WIDX_TAB2:
|
|
|
|
case WIDX_TAB3:
|
|
|
|
case WIDX_TAB4:
|
|
|
|
if (w->page != widgetIndex - WIDX_TAB1)
|
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMultiplayerSetPage(w, widgetIndex - WIDX_TAB1);
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WIDX_ADD_GROUP:
|
2019-05-12 19:54:41 +02:00
|
|
|
{
|
|
|
|
auto networkModifyGroup = NetworkModifyGroupAction(ModifyGroupType::AddGroup);
|
|
|
|
GameActions::Execute(&networkModifyGroup);
|
|
|
|
}
|
|
|
|
break;
|
2018-06-22 23:21:44 +02:00
|
|
|
case WIDX_REMOVE_GROUP:
|
2019-05-12 19:54:41 +02:00
|
|
|
{
|
|
|
|
auto networkModifyGroup = NetworkModifyGroupAction(ModifyGroupType::RemoveGroup, _selectedGroup);
|
|
|
|
GameActions::Execute(&networkModifyGroup);
|
|
|
|
}
|
|
|
|
break;
|
2018-06-22 23:21:44 +02:00
|
|
|
case WIDX_RENAME_GROUP:;
|
|
|
|
int32_t groupIndex = network_get_group_index(_selectedGroup);
|
|
|
|
const utf8* groupName = network_get_group_name(groupIndex);
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowTextInputRawOpen(w, widgetIndex, STR_GROUP_NAME, STR_ENTER_NEW_NAME_FOR_THIS_GROUP, {}, groupName, 32);
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerGroupsResize(rct_window* w)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2022-07-31 00:25:33 +02:00
|
|
|
window_set_resize(*w, 320, 200, 320, 500);
|
2016-01-22 04:32:51 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
w->no_list_items = network_get_num_actions();
|
|
|
|
w->list_item_positions[0] = 0;
|
2016-01-22 04:32:51 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
w->selected_list_item = -1;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
static void WindowMultiplayerGroupsMousedown(rct_window* w, WidgetIndex widgetIndex, rct_widget* widget)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_DEFAULT_GROUP_DROPDOWN:
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMultiplayerGroupsShowGroupDropdown(w, widget);
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_SELECTED_GROUP_DROPDOWN:
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMultiplayerGroupsShowGroupDropdown(w, widget);
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
static void WindowMultiplayerGroupsDropdown(rct_window* w, WidgetIndex widgetIndex, int32_t dropdownIndex)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
if (dropdownIndex == -1)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
|
|
|
}
|
2016-01-22 04:32:51 +01:00
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_DEFAULT_GROUP_DROPDOWN:
|
2019-05-12 19:54:41 +02:00
|
|
|
{
|
|
|
|
auto networkModifyGroup = NetworkModifyGroupAction(
|
|
|
|
ModifyGroupType::SetDefault, network_get_group_id(dropdownIndex));
|
|
|
|
GameActions::Execute(&networkModifyGroup);
|
|
|
|
}
|
|
|
|
break;
|
2018-06-22 23:21:44 +02:00
|
|
|
case WIDX_SELECTED_GROUP_DROPDOWN:
|
|
|
|
_selectedGroup = network_get_group_id(dropdownIndex);
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-22 04:32:51 +01:00
|
|
|
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerGroupsUpdate(rct_window* w)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->frame_no++;
|
2022-07-31 00:25:33 +02:00
|
|
|
widget_invalidate(*w, WIDX_TAB1 + w->page);
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerGroupsScrollgetsize(rct_window* w, int32_t scrollIndex, int32_t* width, int32_t* height)
|
2016-01-22 04:32:51 +01:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t i;
|
2016-01-22 04:32:51 +01:00
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
if (w->selected_list_item != -1)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->selected_list_item = -1;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-22 04:32:51 +01:00
|
|
|
|
2018-03-09 20:45:50 +01:00
|
|
|
*height = network_get_num_actions() * SCROLLABLE_ROW_HEIGHT;
|
2017-06-06 23:24:18 +02:00
|
|
|
i = *height - window_multiplayer_groups_widgets[WIDX_LIST].bottom + window_multiplayer_groups_widgets[WIDX_LIST].top + 21;
|
|
|
|
if (i < 0)
|
|
|
|
i = 0;
|
2018-06-22 23:21:44 +02:00
|
|
|
if (i < w->scrolls[0].v_top)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->scrolls[0].v_top = i;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-22 04:32:51 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerGroupsScrollmousedown(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
2016-01-22 04:32:51 +01:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t index;
|
2016-01-22 04:32:51 +01:00
|
|
|
|
2019-11-14 12:40:40 +01:00
|
|
|
index = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
2017-06-06 23:24:18 +02:00
|
|
|
if (index >= w->no_list_items)
|
|
|
|
return;
|
2016-01-22 04:32:51 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
w->selected_list_item = index;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2016-01-22 04:32:51 +01:00
|
|
|
|
2019-05-13 20:53:33 +02:00
|
|
|
auto networkModifyGroup = NetworkModifyGroupAction(
|
|
|
|
ModifyGroupType::SetPermissions, _selectedGroup, "", index, PermissionState::Toggle);
|
2019-05-12 19:54:41 +02:00
|
|
|
GameActions::Execute(&networkModifyGroup);
|
2016-01-22 04:32:51 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerGroupsScrollmouseover(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords)
|
2016-01-22 04:32:51 +01:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t index;
|
2016-01-22 04:32:51 +01:00
|
|
|
|
2019-11-14 12:40:40 +01:00
|
|
|
index = screenCoords.y / SCROLLABLE_ROW_HEIGHT;
|
2017-06-06 23:24:18 +02:00
|
|
|
if (index >= w->no_list_items)
|
|
|
|
return;
|
2016-01-22 04:32:51 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
w->selected_list_item = index;
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2016-01-22 04:32:51 +01:00
|
|
|
}
|
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
static void WindowMultiplayerGroupsTextInput(rct_window* w, WidgetIndex widgetIndex, char* text)
|
2016-01-22 07:32:40 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
if (widgetIndex != WIDX_RENAME_GROUP)
|
|
|
|
return;
|
2016-01-22 07:32:40 +01:00
|
|
|
|
2017-08-15 10:07:44 +02:00
|
|
|
if (text == nullptr)
|
2017-06-06 23:24:18 +02:00
|
|
|
return;
|
2016-01-22 07:32:40 +01:00
|
|
|
|
2019-05-13 20:53:33 +02:00
|
|
|
auto networkModifyGroup = NetworkModifyGroupAction(ModifyGroupType::SetName, _selectedGroup, text);
|
2019-05-12 19:54:41 +02:00
|
|
|
GameActions::Execute(&networkModifyGroup);
|
2016-01-22 07:32:40 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerGroupsInvalidate(rct_window* w)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMultiplayerSetPressedTab(w);
|
|
|
|
WindowMultiplayerAnchorBorderWidgets(w);
|
2017-06-06 23:24:18 +02:00
|
|
|
window_multiplayer_groups_widgets[WIDX_PERMISSIONS_LIST].right = w->width - 4;
|
|
|
|
window_multiplayer_groups_widgets[WIDX_PERMISSIONS_LIST].bottom = w->height - 0x0F;
|
|
|
|
window_align_tabs(w, WIDX_TAB1, WIDX_TAB4);
|
2016-01-22 07:32:40 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
// select other group if one is removed
|
2018-06-22 23:21:44 +02:00
|
|
|
while (network_get_group_index(_selectedGroup) == -1 && _selectedGroup > 0)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
_selectedGroup--;
|
|
|
|
}
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerGroupsPaint(rct_window* w, rct_drawpixelinfo* dpi)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2021-11-24 18:08:41 +01:00
|
|
|
thread_local std::string _buffer;
|
2020-10-14 00:34:18 +02:00
|
|
|
|
2022-07-30 21:59:47 +02:00
|
|
|
WindowDrawWidgets(*w, dpi);
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMultiplayerDrawTabImages(w, dpi);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
rct_widget* widget = &window_multiplayer_groups_widgets[WIDX_DEFAULT_GROUP];
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t group = network_get_group_index(network_get_default_group());
|
2018-06-22 23:21:44 +02:00
|
|
|
if (group != -1)
|
|
|
|
{
|
2021-11-24 18:08:41 +01:00
|
|
|
_buffer.assign("{WINDOW_COLOUR_2}");
|
|
|
|
_buffer += network_get_group_name(group);
|
2020-10-14 00:34:18 +02:00
|
|
|
|
2020-09-30 23:42:04 +02:00
|
|
|
auto ft = Formatter();
|
2021-11-24 18:08:41 +01:00
|
|
|
ft.Add<const char*>(_buffer.c_str());
|
2020-08-28 18:03:51 +02:00
|
|
|
DrawTextEllipsised(
|
|
|
|
dpi, w->windowPos + ScreenCoordsXY{ widget->midX() - 5, widget->top }, widget->width() - 8, STR_STRING, ft,
|
2021-02-28 00:22:24 +01:00
|
|
|
{ TextAlignment::CENTRE });
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2020-06-11 23:04:57 +02:00
|
|
|
auto screenPos = w->windowPos
|
|
|
|
+ ScreenCoordsXY{ window_multiplayer_groups_widgets[WIDX_CONTENT_PANEL].left + 4,
|
|
|
|
window_multiplayer_groups_widgets[WIDX_CONTENT_PANEL].top + 4 };
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2021-02-27 16:49:13 +01:00
|
|
|
DrawTextBasic(dpi, screenPos, STR_DEFAULT_GROUP, {}, { w->colours[2] });
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-06-11 23:04:57 +02:00
|
|
|
screenPos.y += 20;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-06-11 23:04:57 +02:00
|
|
|
gfx_fill_rect_inset(
|
2021-03-27 03:51:10 +01:00
|
|
|
dpi, { screenPos - ScreenCoordsXY{ 0, 6 }, screenPos + ScreenCoordsXY{ 310, -5 } }, w->colours[1],
|
|
|
|
INSET_RECT_FLAG_BORDER_INSET);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
widget = &window_multiplayer_groups_widgets[WIDX_SELECTED_GROUP];
|
|
|
|
group = network_get_group_index(_selectedGroup);
|
2018-06-22 23:21:44 +02:00
|
|
|
if (group != -1)
|
|
|
|
{
|
2021-11-24 18:08:41 +01:00
|
|
|
_buffer.assign("{WINDOW_COLOUR_2}");
|
|
|
|
_buffer += network_get_group_name(group);
|
2020-09-30 23:42:04 +02:00
|
|
|
auto ft = Formatter();
|
2021-11-24 18:08:41 +01:00
|
|
|
ft.Add<const char*>(_buffer.c_str());
|
2020-08-28 18:03:51 +02:00
|
|
|
DrawTextEllipsised(
|
|
|
|
dpi, w->windowPos + ScreenCoordsXY{ widget->midX() - 5, widget->top }, widget->width() - 8, STR_STRING, ft,
|
2021-02-28 00:22:24 +01:00
|
|
|
{ TextAlignment::CENTRE });
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerGroupsScrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2020-06-20 16:56:36 +02:00
|
|
|
auto screenCoords = ScreenCoordsXY{ 0, 0 };
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2020-07-16 03:34:57 +02:00
|
|
|
auto dpiCoords = ScreenCoordsXY{ dpi->x, dpi->y };
|
|
|
|
gfx_fill_rect(
|
|
|
|
dpi, { dpiCoords, dpiCoords + ScreenCoordsXY{ dpi->width - 1, dpi->height - 1 } }, ColourMapA[w->colours[1]].mid_light);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
for (int32_t i = 0; i < network_get_num_actions(); i++)
|
|
|
|
{
|
|
|
|
if (i == w->selected_list_item)
|
|
|
|
{
|
2020-12-05 19:13:59 +01:00
|
|
|
gfx_filter_rect(
|
2021-10-21 00:43:32 +02:00
|
|
|
dpi, { 0, screenCoords.y, 800, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1 }, FilterPaletteID::PaletteDarken1);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2020-05-10 20:22:47 +02:00
|
|
|
if (screenCoords.y > dpi->y + dpi->height)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-05-10 20:22:47 +02:00
|
|
|
if (screenCoords.y + SCROLLABLE_ROW_HEIGHT + 1 >= dpi->y)
|
2018-03-09 20:45:50 +01:00
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t groupindex = network_get_group_index(_selectedGroup);
|
2018-06-22 23:21:44 +02:00
|
|
|
if (groupindex != -1)
|
|
|
|
{
|
2020-09-04 20:05:27 +02:00
|
|
|
if (network_can_perform_action(groupindex, static_cast<NetworkPermission>(i)))
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
2020-05-10 20:22:47 +02:00
|
|
|
screenCoords.x = 0;
|
2021-02-27 18:35:32 +01:00
|
|
|
gfx_draw_string(dpi, screenCoords, u8"{WINDOW_COLOUR_2}✓", {});
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw action name
|
2020-09-30 23:42:04 +02:00
|
|
|
auto ft = Formatter();
|
2020-06-03 11:20:29 +02:00
|
|
|
ft.Add<uint16_t>(network_get_action_name_string_id(i));
|
2021-02-27 16:49:13 +01:00
|
|
|
DrawTextBasic(dpi, { 10, screenCoords.y }, STR_WINDOW_COLOUR_2_STRINGID, ft);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2020-05-10 20:22:47 +02:00
|
|
|
screenCoords.y += SCROLLABLE_ROW_HEIGHT;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2016-05-26 20:34:37 +02:00
|
|
|
#pragma endregion
|
|
|
|
|
|
|
|
#pragma region Options page
|
|
|
|
|
2022-08-21 18:49:23 +02:00
|
|
|
static void WindowMultiplayerOptionsMouseup(rct_window* w, WidgetIndex widgetIndex)
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_CLOSE:
|
2022-07-31 00:25:33 +02:00
|
|
|
window_close(*w);
|
2018-06-22 23:21:44 +02:00
|
|
|
break;
|
|
|
|
case WIDX_TAB1:
|
|
|
|
case WIDX_TAB2:
|
|
|
|
case WIDX_TAB3:
|
|
|
|
case WIDX_TAB4:
|
|
|
|
if (w->page != widgetIndex - WIDX_TAB1)
|
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMultiplayerSetPage(w, widgetIndex - WIDX_TAB1);
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WIDX_LOG_CHAT_CHECKBOX:
|
|
|
|
gConfigNetwork.log_chat = !gConfigNetwork.log_chat;
|
|
|
|
config_save_default();
|
|
|
|
break;
|
|
|
|
case WIDX_LOG_SERVER_ACTIONS_CHECKBOX:
|
|
|
|
gConfigNetwork.log_server_actions = !gConfigNetwork.log_server_actions;
|
|
|
|
config_save_default();
|
|
|
|
break;
|
|
|
|
case WIDX_KNOWN_KEYS_ONLY_CHECKBOX:
|
|
|
|
gConfigNetwork.known_keys_only = !gConfigNetwork.known_keys_only;
|
|
|
|
config_save_default();
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-05-26 20:34:37 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerOptionsResize(rct_window* w)
|
2016-05-26 20:34:37 +02:00
|
|
|
{
|
2022-07-31 00:25:33 +02:00
|
|
|
window_set_resize(*w, 300, 100, 300, 100);
|
2016-05-26 20:34:37 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerOptionsUpdate(rct_window* w)
|
2016-05-26 20:34:37 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->frame_no++;
|
2022-07-31 00:25:33 +02:00
|
|
|
widget_invalidate(*w, WIDX_TAB1 + w->page);
|
2016-05-26 20:34:37 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerOptionsInvalidate(rct_window* w)
|
2016-05-26 20:34:37 +02:00
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMultiplayerSetPressedTab(w);
|
|
|
|
WindowMultiplayerAnchorBorderWidgets(w);
|
2017-06-06 23:24:18 +02:00
|
|
|
window_align_tabs(w, WIDX_TAB1, WIDX_TAB4);
|
2016-05-26 20:34:37 +02:00
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
if (network_get_mode() == NETWORK_MODE_CLIENT)
|
|
|
|
{
|
2020-11-27 04:14:20 +01:00
|
|
|
w->widgets[WIDX_KNOWN_KEYS_ONLY_CHECKBOX].type = WindowWidgetType::Empty;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-05-30 19:01:17 +02:00
|
|
|
|
2022-07-30 22:21:51 +02:00
|
|
|
WidgetSetCheckboxValue(*w, WIDX_LOG_CHAT_CHECKBOX, gConfigNetwork.log_chat);
|
|
|
|
WidgetSetCheckboxValue(*w, WIDX_LOG_SERVER_ACTIONS_CHECKBOX, gConfigNetwork.log_server_actions);
|
|
|
|
WidgetSetCheckboxValue(*w, WIDX_KNOWN_KEYS_ONLY_CHECKBOX, gConfigNetwork.known_keys_only);
|
2016-05-26 20:34:37 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerOptionsPaint(rct_window* w, rct_drawpixelinfo* dpi)
|
2016-05-26 20:34:37 +02:00
|
|
|
{
|
2022-07-30 21:59:47 +02:00
|
|
|
WindowDrawWidgets(*w, dpi);
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMultiplayerDrawTabImages(w, dpi);
|
2016-05-26 20:34:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma endregion
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerDrawTabImage(rct_window* w, rct_drawpixelinfo* dpi, int32_t page, int32_t spriteIndex)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2022-08-21 18:49:23 +02:00
|
|
|
WidgetIndex widgetIndex = WIDX_TAB1 + page;
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2022-07-30 22:21:51 +02:00
|
|
|
if (!WidgetIsDisabled(*w, widgetIndex))
|
2018-06-22 23:21:44 +02:00
|
|
|
{
|
|
|
|
if (w->page == page)
|
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t numFrames = window_multiplayer_animation_frames[w->page];
|
2018-06-22 23:21:44 +02:00
|
|
|
if (numFrames > 1)
|
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t frame = w->frame_no / window_multiplayer_animation_divisor[w->page];
|
2017-06-06 23:24:18 +02:00
|
|
|
spriteIndex += (frame % numFrames);
|
|
|
|
}
|
|
|
|
}
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2020-03-01 20:32:35 +01:00
|
|
|
gfx_draw_sprite(
|
2021-03-23 11:58:09 +01:00
|
|
|
dpi, ImageId(spriteIndex),
|
|
|
|
w->windowPos + ScreenCoordsXY{ w->widgets[widgetIndex].left, w->widgets[widgetIndex].top });
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2021-11-23 14:18:07 +01:00
|
|
|
static void WindowMultiplayerDrawTabImages(rct_window* w, rct_drawpixelinfo* dpi)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2021-11-23 14:18:07 +01:00
|
|
|
WindowMultiplayerDrawTabImage(w, dpi, WINDOW_MULTIPLAYER_PAGE_INFORMATION, SPR_TAB_KIOSKS_AND_FACILITIES_0);
|
|
|
|
WindowMultiplayerDrawTabImage(w, dpi, WINDOW_MULTIPLAYER_PAGE_PLAYERS, SPR_TAB_GUESTS_0);
|
|
|
|
WindowMultiplayerDrawTabImage(w, dpi, WINDOW_MULTIPLAYER_PAGE_GROUPS, SPR_TAB_STAFF_OPTIONS_0);
|
|
|
|
WindowMultiplayerDrawTabImage(w, dpi, WINDOW_MULTIPLAYER_PAGE_OPTIONS, SPR_TAB_GEARS_0);
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|