Button to copy invite code to clipboard in the server options dialog

This commit is contained in:
Sergii Pylypenko
2021-12-12 02:12:12 +02:00
parent 0eaaeecaad
commit f21bf64f8f
4 changed files with 11 additions and 2 deletions

View File

@@ -30,6 +30,7 @@
#include "../company_func.h"
#include "../command_func.h"
#include "../core/geometry_func.hpp"
#include "../video/video_driver.hpp"
#include "../genworld.h"
#include "../map_type.h"
#include "../guitimer_func.h"
@@ -1319,6 +1320,10 @@ static const NWidgetPart _nested_client_list_widgets[] = {
NWidget(NWID_SPACER), SetMinimalSize(10, 0),
NWidget(WWT_TEXT, COLOUR_GREY, WID_CL_SERVER_INVITE_CODE), SetFill(1, 0), SetMinimalTextLines(1, 0), SetResize(1, 0), SetDataTip(STR_BLACK_RAW_STRING, STR_NETWORK_CLIENT_LIST_SERVER_INVITE_CODE_TOOLTIP), SetAlignment(SA_VERT_CENTER | SA_RIGHT),
EndContainer(),
NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
NWidget(NWID_SPACER), SetMinimalSize(10, 0), SetFill(1, 0), SetResize(1, 0),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CL_SERVER_COPY_TO_CLIPBOARD), SetDataTip(STR_NETWORK_CLIENT_LIST_SERVER_COPY_TO_CLIPBOARD, STR_NETWORK_CLIENT_LIST_SERVER_COPY_TO_CLIPBOARD),
EndContainer(),
NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalTextLines(1, 0), SetDataTip(STR_NETWORK_CLIENT_LIST_SERVER_CONNECTION_TYPE, STR_NULL),
NWidget(NWID_SPACER), SetMinimalSize(10, 0),
@@ -1806,6 +1811,10 @@ public:
ShowQueryString(STR_JUST_RAW_STRING, STR_NETWORK_CLIENT_LIST_PLAYER_NAME_QUERY_CAPTION, NETWORK_CLIENT_NAME_LENGTH, this, CS_ALPHANUMERAL, QSF_LEN_IN_CHARS);
break;
case WID_CL_SERVER_COPY_TO_CLIPBOARD:
VideoDriver::GetInstance()->SetClipboardContents(_network_server_invite_code);
break;
case WID_CL_SERVER_VISIBILITY:
if (!_network_server) break;