2016-01-20 23:45:09 +01:00
|
|
|
/*****************************************************************************
|
2020-07-21 15:04:34 +02:00
|
|
|
* Copyright (c) 2014-2020 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>
|
2019-05-12 19:54:41 +02:00
|
|
|
#include <openrct2/actions/NetworkModifyGroupAction.hpp>
|
2018-06-22 23:21:44 +02:00
|
|
|
#include <openrct2/config/Config.h>
|
|
|
|
#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
|
|
|
};
|
|
|
|
|
|
|
|
enum WINDOW_MULTIPLAYER_WIDGET_IDX {
|
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,
|
|
|
|
{ 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
|
2017-06-06 23:24:18 +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
|
2017-06-06 23:24:18 +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),
|
2017-06-06 23:24:18 +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,
|
|
|
|
window_multiplayer_options_widgets
|
2016-01-20 23:45:09 +01:00
|
|
|
};
|
2016-11-13 20:17:49 +01:00
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
static constexpr const uint64_t window_multiplayer_page_enabled_widgets[] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
(1 << WIDX_CLOSE) | (1 << WIDX_TAB1) | (1 << WIDX_TAB2) | (1 << WIDX_TAB3) | (1 << WIDX_TAB4),
|
|
|
|
(1 << WIDX_CLOSE) | (1 << WIDX_TAB1) | (1 << WIDX_TAB2) | (1 << WIDX_TAB3) | (1 << WIDX_TAB4),
|
|
|
|
(1 << WIDX_CLOSE) | (1 << WIDX_TAB1) | (1 << WIDX_TAB2) | (1 << WIDX_TAB3) | (1 << WIDX_TAB4) | (1 << WIDX_DEFAULT_GROUP) | (1 << WIDX_DEFAULT_GROUP_DROPDOWN) | (1 << WIDX_ADD_GROUP) | (1 << WIDX_REMOVE_GROUP) | (1 << WIDX_RENAME_GROUP) | (1 << WIDX_SELECTED_GROUP) | (1 << WIDX_SELECTED_GROUP_DROPDOWN),
|
|
|
|
(1 << WIDX_CLOSE) | (1 << WIDX_TAB1) | (1 << WIDX_TAB2) | (1 << WIDX_TAB3) | (1 << WIDX_TAB4) | (1 << WIDX_LOG_CHAT_CHECKBOX) | (1 << WIDX_LOG_SERVER_ACTIONS_CHECKBOX) | (1 << WIDX_KNOWN_KEYS_ONLY_CHECKBOX),
|
2016-01-20 23:45:09 +01:00
|
|
|
};
|
|
|
|
|
2018-03-30 21:27:06 +02:00
|
|
|
static constexpr rct_string_id 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
|
|
|
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_multiplayer_information_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
2016-05-30 21:54:50 +02:00
|
|
|
static void window_multiplayer_information_resize(rct_window *w);
|
|
|
|
static void window_multiplayer_information_update(rct_window *w);
|
|
|
|
static void window_multiplayer_information_invalidate(rct_window *w);
|
|
|
|
static void window_multiplayer_information_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
|
|
|
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_multiplayer_players_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
2016-01-20 23:45:09 +01:00
|
|
|
static void window_multiplayer_players_resize(rct_window *w);
|
|
|
|
static void window_multiplayer_players_update(rct_window *w);
|
2018-06-20 17:28:51 +02:00
|
|
|
static void window_multiplayer_players_scrollgetsize(rct_window *w, int32_t scrollIndex, int32_t *width, int32_t *height);
|
2020-02-29 03:43:29 +01:00
|
|
|
static void window_multiplayer_players_scrollmousedown(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
|
|
|
static void window_multiplayer_players_scrollmouseover(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
2016-01-20 23:45:09 +01:00
|
|
|
static void window_multiplayer_players_invalidate(rct_window *w);
|
|
|
|
static void window_multiplayer_players_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
2018-06-20 17:28:51 +02:00
|
|
|
static void window_multiplayer_players_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int32_t scrollIndex);
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_multiplayer_groups_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
2016-01-20 23:45:09 +01:00
|
|
|
static void window_multiplayer_groups_resize(rct_window *w);
|
2017-07-03 23:09:46 +02:00
|
|
|
static void window_multiplayer_groups_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct_widget* widget);
|
2018-06-20 17:28:51 +02:00
|
|
|
static void window_multiplayer_groups_dropdown(rct_window *w, rct_widgetindex widgetIndex, int32_t dropdownIndex);
|
2016-01-20 23:45:09 +01:00
|
|
|
static void window_multiplayer_groups_update(rct_window *w);
|
2018-06-20 17:28:51 +02:00
|
|
|
static void window_multiplayer_groups_scrollgetsize(rct_window *w, int32_t scrollIndex, int32_t *width, int32_t *height);
|
2020-02-29 03:43:29 +01:00
|
|
|
static void window_multiplayer_groups_scrollmousedown(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
|
|
|
static void window_multiplayer_groups_scrollmouseover(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_multiplayer_groups_text_input(rct_window *w, rct_widgetindex widgetIndex, char *text);
|
2016-01-20 23:45:09 +01:00
|
|
|
static void window_multiplayer_groups_invalidate(rct_window *w);
|
|
|
|
static void window_multiplayer_groups_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
2018-06-20 17:28:51 +02:00
|
|
|
static void window_multiplayer_groups_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int32_t scrollIndex);
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_multiplayer_options_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
2016-05-26 20:34:37 +02:00
|
|
|
static void window_multiplayer_options_resize(rct_window *w);
|
|
|
|
static void window_multiplayer_options_update(rct_window *w);
|
|
|
|
static void window_multiplayer_options_invalidate(rct_window *w);
|
|
|
|
static void window_multiplayer_options_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
|
|
|
|
2020-09-28 20:36:15 +02:00
|
|
|
static rct_window_event_list window_multiplayer_information_events([](auto& events)
|
|
|
|
{
|
|
|
|
events.mouse_up = &window_multiplayer_information_mouseup;
|
|
|
|
events.resize = &window_multiplayer_information_resize;
|
|
|
|
events.update = &window_multiplayer_information_update;
|
|
|
|
events.invalidate = &window_multiplayer_information_invalidate;
|
|
|
|
events.paint = &window_multiplayer_information_paint;
|
|
|
|
});
|
|
|
|
|
|
|
|
static rct_window_event_list window_multiplayer_players_events([](auto& events)
|
|
|
|
{
|
|
|
|
events.mouse_up = &window_multiplayer_players_mouseup;
|
|
|
|
events.resize = &window_multiplayer_players_resize;
|
|
|
|
events.update = &window_multiplayer_players_update;
|
|
|
|
events.get_scroll_size = &window_multiplayer_players_scrollgetsize;
|
|
|
|
events.scroll_mousedown = &window_multiplayer_players_scrollmousedown;
|
|
|
|
events.scroll_mouseover = &window_multiplayer_players_scrollmouseover;
|
|
|
|
events.invalidate = &window_multiplayer_players_invalidate;
|
|
|
|
events.paint = &window_multiplayer_players_paint;
|
|
|
|
events.scroll_paint = &window_multiplayer_players_scrollpaint;
|
|
|
|
});
|
|
|
|
|
|
|
|
static rct_window_event_list window_multiplayer_groups_events([](auto& events)
|
|
|
|
{
|
|
|
|
events.mouse_up = &window_multiplayer_groups_mouseup;
|
|
|
|
events.resize = &window_multiplayer_groups_resize;
|
|
|
|
events.mouse_down = &window_multiplayer_groups_mousedown;
|
|
|
|
events.dropdown = &window_multiplayer_groups_dropdown;
|
|
|
|
events.update = &window_multiplayer_groups_update;
|
|
|
|
events.get_scroll_size = &window_multiplayer_groups_scrollgetsize;
|
|
|
|
events.scroll_mousedown = &window_multiplayer_groups_scrollmousedown;
|
|
|
|
events.scroll_mouseover = &window_multiplayer_groups_scrollmouseover;
|
|
|
|
events.text_input = &window_multiplayer_groups_text_input;
|
|
|
|
events.invalidate = &window_multiplayer_groups_invalidate;
|
|
|
|
events.paint = &window_multiplayer_groups_paint;
|
|
|
|
events.scroll_paint = &window_multiplayer_groups_scrollpaint;
|
|
|
|
});
|
|
|
|
|
|
|
|
static rct_window_event_list window_multiplayer_options_events([](auto& events)
|
|
|
|
{
|
|
|
|
events.mouse_up = &window_multiplayer_options_mouseup;
|
|
|
|
events.resize = &window_multiplayer_options_resize;
|
|
|
|
events.update = &window_multiplayer_options_update;
|
|
|
|
events.invalidate = &window_multiplayer_options_invalidate;
|
|
|
|
events.paint = &window_multiplayer_options_paint;
|
|
|
|
});
|
2016-05-26 20:34:37 +02:00
|
|
|
|
2016-01-20 23:45:09 +01:00
|
|
|
static rct_window_event_list *window_multiplayer_page_events[] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
&window_multiplayer_information_events,
|
|
|
|
&window_multiplayer_players_events,
|
|
|
|
&window_multiplayer_groups_events,
|
|
|
|
&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
|
|
|
|
2018-06-20 17:28:51 +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
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_draw_tab_images(rct_window* w, rct_drawpixelinfo* dpi);
|
2018-06-20 17:28:51 +02:00
|
|
|
static void window_multiplayer_set_page(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
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_window* window_multiplayer_open()
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Check if window is already open
|
2018-06-22 23:21:44 +02:00
|
|
|
rct_window* window = window_bring_to_front_by_class(WC_MULTIPLAYER);
|
|
|
|
if (window == nullptr)
|
|
|
|
{
|
2020-11-04 05:52:23 +01:00
|
|
|
window = WindowCreateAutoPos(320, 144, &window_multiplayer_players_events, WC_MULTIPLAYER, WF_10 | WF_RESIZABLE);
|
2017-06-06 23:24:18 +02:00
|
|
|
window_multiplayer_set_page(window, WINDOW_MULTIPLAYER_PAGE_INFORMATION);
|
|
|
|
}
|
2017-08-06 05:22:00 +02:00
|
|
|
|
|
|
|
return window;
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2018-06-20 17:28:51 +02:00
|
|
|
static void window_multiplayer_set_page(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->enabled_widgets = window_multiplayer_page_enabled_widgets[page];
|
|
|
|
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);
|
2020-11-04 05:52:23 +01:00
|
|
|
WindowInitScrollWidgets(w);
|
2019-06-15 17:20:16 +02:00
|
|
|
w->Invalidate();
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_anchor_border_widgets(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
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_set_pressed_tab(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
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_groups_show_group_dropdown(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++)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
gDropdownItemsFormat[i] = STR_OPTIONS_DROPDOWN_ITEM;
|
2020-04-18 13:32:48 +02:00
|
|
|
gDropdownItemsArgs[i] = 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
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_information_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
|
|
|
{
|
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_CLOSE:
|
|
|
|
window_close(w);
|
|
|
|
break;
|
|
|
|
case WIDX_TAB1:
|
|
|
|
case WIDX_TAB2:
|
|
|
|
case WIDX_TAB3:
|
|
|
|
case WIDX_TAB4:
|
|
|
|
if (w->page != widgetIndex - WIDX_TAB1)
|
|
|
|
{
|
|
|
|
window_multiplayer_set_page(w, widgetIndex - WIDX_TAB1);
|
|
|
|
}
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-05-30 21:54:50 +02:00
|
|
|
}
|
|
|
|
|
2020-03-01 21:24:44 +01:00
|
|
|
static ScreenCoordsXY window_multiplayer_information_get_size()
|
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
|
|
|
|
2019-01-07 12:17:37 +01:00
|
|
|
// Reset font sprite base and compute line height
|
2017-06-06 23:24:18 +02:00
|
|
|
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
2019-01-07 12:17:37 +01:00
|
|
|
int32_t lineHeight = font_get_line_height(gCurrentFontSpriteBase);
|
|
|
|
|
|
|
|
// Base dimensions.
|
|
|
|
const int32_t width = 450;
|
|
|
|
int32_t height = 55;
|
|
|
|
int32_t numLines, fontSpriteBase;
|
|
|
|
|
|
|
|
// Server name is displayed word-wrapped, so figure out how high it will be.
|
|
|
|
{
|
|
|
|
utf8* buffer = _strdup(network_get_server_name());
|
|
|
|
gfx_wrap_string(buffer, width, &numLines, &fontSpriteBase);
|
|
|
|
free(buffer);
|
|
|
|
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))
|
|
|
|
{
|
|
|
|
utf8* buffer = _strdup(descString);
|
|
|
|
gfx_wrap_string(buffer, width, &numLines, &fontSpriteBase);
|
|
|
|
free(buffer);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_information_resize(rct_window* w)
|
2016-05-30 21:54:50 +02:00
|
|
|
{
|
2020-03-01 21:24:44 +01:00
|
|
|
auto size = window_multiplayer_information_get_size();
|
2017-06-06 23:24:18 +02:00
|
|
|
window_set_resize(w, size.x, size.y, size.x, size.y);
|
2016-05-30 21:54:50 +02:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_information_update(rct_window* w)
|
2016-05-30 21:54:50 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->frame_no++;
|
|
|
|
widget_invalidate(w, WIDX_TAB1 + w->page);
|
2016-05-30 21:54:50 +02:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_information_invalidate(rct_window* w)
|
2016-05-30 21:54:50 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
window_multiplayer_set_pressed_tab(w);
|
|
|
|
window_multiplayer_anchor_border_widgets(w);
|
|
|
|
window_align_tabs(w, WIDX_TAB1, WIDX_TAB4);
|
2016-05-30 21:54:50 +02:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_information_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
2016-05-30 21:54:50 +02:00
|
|
|
{
|
2020-11-04 05:52:23 +01:00
|
|
|
WindowDrawWidgets(w, dpi);
|
2017-06-06 23:24:18 +02:00
|
|
|
window_multiplayer_draw_tab_images(w, dpi);
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2020-06-20 16:56:36 +02:00
|
|
|
screenCoords.y += gfx_draw_string_left_wrapped(
|
|
|
|
dpi, static_cast<void*>(&name), screenCoords, width, STR_STRING, w->colours[1]);
|
|
|
|
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))
|
|
|
|
{
|
2020-06-20 16:56:36 +02:00
|
|
|
screenCoords.y += gfx_draw_string_left_wrapped(
|
|
|
|
dpi, static_cast<void*>(&description), screenCoords, width, STR_STRING, w->colours[1]);
|
|
|
|
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))
|
|
|
|
{
|
2020-06-20 16:56:36 +02:00
|
|
|
gfx_draw_string_left(dpi, STR_PROVIDER_NAME, static_cast<void*>(&providerName), COLOUR_BLACK, screenCoords);
|
|
|
|
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))
|
|
|
|
{
|
2020-06-20 16:56:36 +02:00
|
|
|
gfx_draw_string_left(dpi, STR_PROVIDER_EMAIL, static_cast<void*>(&providerEmail), COLOUR_BLACK, screenCoords);
|
|
|
|
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))
|
|
|
|
{
|
2020-06-20 16:56:36 +02:00
|
|
|
gfx_draw_string_left(dpi, STR_PROVIDER_WEBSITE, static_cast<void*>(&providerWebsite), COLOUR_BLACK, screenCoords);
|
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
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_players_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
|
|
|
{
|
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_CLOSE:
|
|
|
|
window_close(w);
|
|
|
|
break;
|
|
|
|
case WIDX_TAB1:
|
|
|
|
case WIDX_TAB2:
|
|
|
|
case WIDX_TAB3:
|
|
|
|
case WIDX_TAB4:
|
|
|
|
if (w->page != widgetIndex - WIDX_TAB1)
|
|
|
|
{
|
|
|
|
window_multiplayer_set_page(w, widgetIndex - WIDX_TAB1);
|
|
|
|
}
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_players_resize(rct_window* w)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
window_set_resize(w, 420, 124, 500, 450);
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
w->no_list_items = network_get_num_players();
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_players_update(rct_window* w)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->frame_no++;
|
|
|
|
widget_invalidate(w, WIDX_TAB1 + w->page);
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_players_scrollgetsize(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
|
|
|
}
|
|
|
|
|
2020-02-29 03:43:29 +01:00
|
|
|
static void window_multiplayer_players_scrollmousedown(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
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
window_player_open(network_get_player_id(index));
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2020-02-29 03:43:29 +01:00
|
|
|
static void window_multiplayer_players_scrollmouseover(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
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_players_invalidate(rct_window* w)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
window_multiplayer_set_pressed_tab(w);
|
|
|
|
window_multiplayer_anchor_border_widgets(w);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_players_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_string_id stringId;
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2020-11-04 05:52:23 +01:00
|
|
|
WindowDrawWidgets(w, dpi);
|
2017-06-06 23:24:18 +02:00
|
|
|
window_multiplayer_draw_tab_images(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 };
|
|
|
|
gfx_draw_string_left(dpi, stringId, &w->no_list_items, w->colours[2], screenCoords);
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_players_scrollpaint(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;
|
2018-06-22 23:21:44 +02:00
|
|
|
for (int32_t i = 0; i < network_get_num_players(); i++)
|
|
|
|
{
|
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
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
char buffer[300];
|
|
|
|
|
|
|
|
// Draw player name
|
|
|
|
char* lineCh = buffer;
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t colour = COLOUR_BLACK;
|
2018-03-09 20:45:50 +01:00
|
|
|
if (i == w->selected_list_item)
|
|
|
|
{
|
2020-05-10 14:49:15 +02:00
|
|
|
gfx_filter_rect(dpi, 0, screenCoords.y, 800, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1, PALETTE_DARKEN_1);
|
2017-06-06 23:24:18 +02:00
|
|
|
safe_strcpy(buffer, network_get_player_name(i), sizeof(buffer));
|
|
|
|
colour = w->colours[2];
|
2018-03-09 20:45:50 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-06-22 23:21:44 +02:00
|
|
|
if (network_get_player_flags(i) & NETWORK_PLAYER_FLAG_ISSERVER)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
lineCh = utf8_write_codepoint(lineCh, FORMAT_BABYBLUE);
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
lineCh = utf8_write_codepoint(lineCh, FORMAT_BLACK);
|
|
|
|
}
|
|
|
|
safe_strcpy(lineCh, network_get_player_name(i), sizeof(buffer) - (lineCh - buffer));
|
|
|
|
}
|
2020-05-10 14:49:15 +02:00
|
|
|
screenCoords.x = 0;
|
2017-06-06 23:24:18 +02:00
|
|
|
gfx_clip_string(buffer, 230);
|
2020-05-10 14:49:15 +02:00
|
|
|
gfx_draw_string(dpi, buffer, colour, screenCoords);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Draw group name
|
|
|
|
lineCh = buffer;
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t group = network_get_group_index(network_get_player_group(i));
|
2018-06-22 23:21:44 +02:00
|
|
|
if (group != -1)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
lineCh = utf8_write_codepoint(lineCh, FORMAT_BLACK);
|
2020-05-10 14:49:15 +02:00
|
|
|
screenCoords.x = 173;
|
2017-06-06 23:24:18 +02:00
|
|
|
safe_strcpy(lineCh, network_get_group_name(group), sizeof(buffer) - (lineCh - buffer));
|
|
|
|
gfx_clip_string(buffer, 80);
|
2020-05-10 14:49:15 +02:00
|
|
|
gfx_draw_string(dpi, buffer, colour, screenCoords);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Draw last action
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t action = network_get_player_last_action(i, 2000);
|
2020-09-30 23:42:04 +02:00
|
|
|
auto ft = Formatter();
|
2018-06-22 23:21:44 +02:00
|
|
|
if (action != -999)
|
|
|
|
{
|
2020-06-03 11:20:29 +02:00
|
|
|
ft.Add<rct_string_id>(network_get_action_name_string_id(action));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ft.Add<rct_string_id>(STR_ACTION_NA);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2020-08-28 18:03:51 +02:00
|
|
|
DrawTextEllipsised(dpi, { 256, screenCoords.y }, 100, STR_BLACK_STRING, ft, COLOUR_BLACK);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Draw ping
|
|
|
|
lineCh = buffer;
|
2018-06-20 17:28:51 +02:00
|
|
|
int32_t ping = network_get_player_ping(i);
|
2018-06-22 23:21:44 +02:00
|
|
|
if (ping <= 100)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
lineCh = utf8_write_codepoint(lineCh, FORMAT_GREEN);
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
|
|
|
else if (ping <= 250)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
lineCh = utf8_write_codepoint(lineCh, FORMAT_YELLOW);
|
2018-06-22 23:21:44 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
lineCh = utf8_write_codepoint(lineCh, FORMAT_RED);
|
|
|
|
}
|
|
|
|
snprintf(lineCh, sizeof(buffer) - (lineCh - buffer), "%d ms", ping);
|
2020-05-10 14:49:15 +02:00
|
|
|
screenCoords.x = 356;
|
|
|
|
gfx_draw_string(dpi, buffer, colour, screenCoords);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2020-05-10 14:49:15 +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 Groups page
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_groups_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
|
|
|
{
|
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_CLOSE:
|
|
|
|
window_close(w);
|
|
|
|
break;
|
|
|
|
case WIDX_TAB1:
|
|
|
|
case WIDX_TAB2:
|
|
|
|
case WIDX_TAB3:
|
|
|
|
case WIDX_TAB4:
|
|
|
|
if (w->page != widgetIndex - WIDX_TAB1)
|
|
|
|
{
|
|
|
|
window_multiplayer_set_page(w, widgetIndex - WIDX_TAB1);
|
|
|
|
}
|
|
|
|
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);
|
2020-03-28 13:00:33 +01:00
|
|
|
window_text_input_raw_open(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
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_groups_resize(rct_window* w)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +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
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_groups_mousedown(rct_window* w, rct_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:
|
|
|
|
window_multiplayer_groups_show_group_dropdown(w, widget);
|
|
|
|
break;
|
|
|
|
case WIDX_SELECTED_GROUP_DROPDOWN:
|
|
|
|
window_multiplayer_groups_show_group_dropdown(w, widget);
|
|
|
|
break;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_groups_dropdown(rct_window* w, rct_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
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_groups_update(rct_window* w)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->frame_no++;
|
|
|
|
widget_invalidate(w, WIDX_TAB1 + w->page);
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_groups_scrollgetsize(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
|
|
|
}
|
|
|
|
|
2020-02-29 03:43:29 +01:00
|
|
|
static void window_multiplayer_groups_scrollmousedown(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
|
|
|
}
|
|
|
|
|
2020-02-29 03:43:29 +01:00
|
|
|
static void window_multiplayer_groups_scrollmouseover(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
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_groups_text_input(rct_window* w, rct_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
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_groups_invalidate(rct_window* w)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
window_multiplayer_set_pressed_tab(w);
|
|
|
|
window_multiplayer_anchor_border_widgets(w);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_groups_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2020-11-04 05:52:23 +01:00
|
|
|
WindowDrawWidgets(w, dpi);
|
2017-06-06 23:24:18 +02:00
|
|
|
window_multiplayer_draw_tab_images(w, dpi);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
char buffer[300];
|
|
|
|
char* lineCh;
|
|
|
|
lineCh = buffer;
|
|
|
|
lineCh = utf8_write_codepoint(lineCh, FORMAT_WINDOW_COLOUR_2);
|
|
|
|
safe_strcpy(lineCh, network_get_group_name(group), sizeof(buffer) - (lineCh - buffer));
|
2020-09-30 23:42:04 +02:00
|
|
|
auto ft = Formatter();
|
2020-06-03 11:20:29 +02:00
|
|
|
ft.Add<const char*>(buffer);
|
2020-08-28 18:03:51 +02:00
|
|
|
DrawTextEllipsised(
|
|
|
|
dpi, w->windowPos + ScreenCoordsXY{ widget->midX() - 5, widget->top }, widget->width() - 8, STR_STRING, ft,
|
|
|
|
COLOUR_BLACK, 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
|
|
|
|
2020-06-20 16:56:36 +02:00
|
|
|
gfx_draw_string_left(dpi, STR_DEFAULT_GROUP, nullptr, w->colours[2], screenPos);
|
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(
|
|
|
|
dpi, screenPos.x, screenPos.y - 6, screenPos.x + 310, screenPos.y - 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)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
char buffer[300];
|
|
|
|
char* lineCh;
|
|
|
|
lineCh = buffer;
|
|
|
|
lineCh = utf8_write_codepoint(lineCh, FORMAT_WINDOW_COLOUR_2);
|
|
|
|
safe_strcpy(lineCh, network_get_group_name(group), sizeof(buffer) - (lineCh - buffer));
|
2020-09-30 23:42:04 +02:00
|
|
|
auto ft = Formatter();
|
2020-06-03 11:20:29 +02:00
|
|
|
ft.Add<const char*>(buffer);
|
2020-08-28 18:03:51 +02:00
|
|
|
DrawTextEllipsised(
|
|
|
|
dpi, w->windowPos + ScreenCoordsXY{ widget->midX() - 5, widget->top }, widget->width() - 8, STR_STRING, ft,
|
|
|
|
COLOUR_BLACK, TextAlignment::CENTRE);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_groups_scrollpaint(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-05-10 20:22:47 +02:00
|
|
|
gfx_filter_rect(dpi, 0, screenCoords.y, 800, screenCoords.y + SCROLLABLE_ROW_HEIGHT - 1, PALETTE_DARKEN_1);
|
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-22 23:21:44 +02:00
|
|
|
char buffer[300] = { 0 };
|
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
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
char* lineCh = buffer;
|
|
|
|
lineCh = utf8_write_codepoint(lineCh, FORMAT_WINDOW_COLOUR_2);
|
2018-09-21 20:38:50 +02:00
|
|
|
lineCh = utf8_write_codepoint(lineCh, UnicodeChar::tick);
|
2020-05-10 20:22:47 +02:00
|
|
|
screenCoords.x = 0;
|
|
|
|
gfx_draw_string(dpi, buffer, COLOUR_BLACK, screenCoords);
|
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));
|
2020-09-30 23:42:04 +02:00
|
|
|
gfx_draw_string_left(dpi, STR_WINDOW_COLOUR_2_STRINGID, ft.Data(), COLOUR_BLACK, { 10, screenCoords.y });
|
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
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_options_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
|
|
|
{
|
|
|
|
switch (widgetIndex)
|
|
|
|
{
|
|
|
|
case WIDX_CLOSE:
|
|
|
|
window_close(w);
|
|
|
|
break;
|
|
|
|
case WIDX_TAB1:
|
|
|
|
case WIDX_TAB2:
|
|
|
|
case WIDX_TAB3:
|
|
|
|
case WIDX_TAB4:
|
|
|
|
if (w->page != widgetIndex - WIDX_TAB1)
|
|
|
|
{
|
|
|
|
window_multiplayer_set_page(w, widgetIndex - WIDX_TAB1);
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_options_resize(rct_window* w)
|
2016-05-26 20:34:37 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
window_set_resize(w, 300, 100, 300, 100);
|
2016-05-26 20:34:37 +02:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_options_update(rct_window* w)
|
2016-05-26 20:34:37 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->frame_no++;
|
|
|
|
widget_invalidate(w, WIDX_TAB1 + w->page);
|
2016-05-26 20:34:37 +02:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_options_invalidate(rct_window* w)
|
2016-05-26 20:34:37 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
window_multiplayer_set_pressed_tab(w);
|
|
|
|
window_multiplayer_anchor_border_widgets(w);
|
|
|
|
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
|
|
|
|
2020-11-03 22:29:22 +01: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
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_options_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
2016-05-26 20:34:37 +02:00
|
|
|
{
|
2020-11-04 05:52:23 +01:00
|
|
|
WindowDrawWidgets(w, dpi);
|
2017-06-06 23:24:18 +02:00
|
|
|
window_multiplayer_draw_tab_images(w, dpi);
|
2016-05-26 20:34:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma endregion
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_draw_tab_image(rct_window* w, rct_drawpixelinfo* dpi, int32_t page, int32_t spriteIndex)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_widgetindex widgetIndex = WIDX_TAB1 + page;
|
2016-01-20 23:45:09 +01:00
|
|
|
|
2020-11-03 22:29:22 +01: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(
|
2020-06-24 17:48:17 +02:00
|
|
|
dpi, spriteIndex, w->windowPos + ScreenCoordsXY{ w->widgets[widgetIndex].left, w->widgets[widgetIndex].top }, 0);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:21:44 +02:00
|
|
|
static void window_multiplayer_draw_tab_images(rct_window* w, rct_drawpixelinfo* dpi)
|
2016-01-20 23:45:09 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
window_multiplayer_draw_tab_image(w, dpi, WINDOW_MULTIPLAYER_PAGE_INFORMATION, SPR_TAB_KIOSKS_AND_FACILITIES_0);
|
|
|
|
window_multiplayer_draw_tab_image(w, dpi, WINDOW_MULTIPLAYER_PAGE_PLAYERS, SPR_TAB_GUESTS_0);
|
|
|
|
window_multiplayer_draw_tab_image(w, dpi, WINDOW_MULTIPLAYER_PAGE_GROUPS, SPR_TAB_STAFF_OPTIONS_0);
|
|
|
|
window_multiplayer_draw_tab_image(w, dpi, WINDOW_MULTIPLAYER_PAGE_OPTIONS, SPR_TAB_GEARS_0);
|
2016-01-20 23:45:09 +01:00
|
|
|
}
|