Changeset - r24493:4293afd64bae
[Not reviewed]
master
0 5 0
frosch - 3 years ago 2020-12-24 18:00:53
frosch@openttd.org
Change: Remove the LAN/Internet combobox from the server list in favour of adding two separate search buttons.
5 files changed with 19 insertions and 79 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -1944,16 +1944,12 @@ STR_FACE_COLLAR_TOOLTIP                 
 
STR_FACE_TIE                                                    :Tie:
 
STR_FACE_EARRING                                                :Earring:
 
STR_FACE_TIE_EARRING_TOOLTIP                                    :{BLACK}Change tie or earring
 

	
 
# Network server list
 
STR_NETWORK_SERVER_LIST_CAPTION                                 :{WHITE}Multiplayer
 
STR_NETWORK_SERVER_LIST_ADVERTISED                              :{BLACK}Advertised
 
STR_NETWORK_SERVER_LIST_ADVERTISED_TOOLTIP                      :{BLACK}Choose between an advertised (internet) and a not advertised (Local Area Network, LAN) game
 
STR_NETWORK_SERVER_LIST_ADVERTISED_NO                           :No
 
STR_NETWORK_SERVER_LIST_ADVERTISED_YES                          :Yes
 
STR_NETWORK_SERVER_LIST_PLAYER_NAME                             :{BLACK}Player name:
 
STR_NETWORK_SERVER_LIST_ENTER_NAME_TOOLTIP                      :{BLACK}This is the name other players will identify you by
 

	
 
STR_NETWORK_SERVER_LIST_GAME_NAME                               :{BLACK}Name
 
STR_NETWORK_SERVER_LIST_GAME_NAME_TOOLTIP                       :{BLACK}Name of the game
 
STR_NETWORK_SERVER_LIST_GENERAL_ONLINE                          :{BLACK}{COMMA}/{COMMA} - {COMMA}/{COMMA}
 
@@ -1988,14 +1984,16 @@ STR_NETWORK_SERVER_LIST_VERSION_MISMATCH
 
STR_NETWORK_SERVER_LIST_GRF_MISMATCH                            :{SILVER}NEWGRF MISMATCH
 

	
 
STR_NETWORK_SERVER_LIST_JOIN_GAME                               :{BLACK}Join game
 
STR_NETWORK_SERVER_LIST_REFRESH                                 :{BLACK}Refresh server
 
STR_NETWORK_SERVER_LIST_REFRESH_TOOLTIP                         :{BLACK}Refresh the server info
 

	
 
STR_NETWORK_SERVER_LIST_FIND_SERVER                             :{BLACK}Find server
 
STR_NETWORK_SERVER_LIST_FIND_SERVER_TOOLTIP                     :{BLACK}Search network for a server
 
STR_NETWORK_SERVER_LIST_SEARCH_SERVER_INTERNET                  :{BLACK}Search internet
 
STR_NETWORK_SERVER_LIST_SEARCH_SERVER_INTERNET_TOOLTIP          :{BLACK}Search internet for public servers
 
STR_NETWORK_SERVER_LIST_SEARCH_SERVER_LAN                       :{BLACK}Search LAN
 
STR_NETWORK_SERVER_LIST_SEARCH_SERVER_LAN_TOOLTIP               :{BLACK}Search local area network for servers
 
STR_NETWORK_SERVER_LIST_ADD_SERVER                              :{BLACK}Add server
 
STR_NETWORK_SERVER_LIST_ADD_SERVER_TOOLTIP                      :{BLACK}Adds a server to the list which will always be checked for running games
 
STR_NETWORK_SERVER_LIST_START_SERVER                            :{BLACK}Start server
 
STR_NETWORK_SERVER_LIST_START_SERVER_TOOLTIP                    :{BLACK}Start your own server
 

	
 
STR_NETWORK_SERVER_LIST_PLAYER_NAME_OSKTITLE                    :{BLACK}Enter your name
 
@@ -2006,12 +2004,14 @@ STR_NETWORK_START_SERVER_CAPTION        
 

	
 
STR_NETWORK_START_SERVER_NEW_GAME_NAME                          :{BLACK}Game name:
 
STR_NETWORK_START_SERVER_NEW_GAME_NAME_TOOLTIP                  :{BLACK}The game name will be displayed to other players in the multiplayer game selection menu
 
STR_NETWORK_START_SERVER_SET_PASSWORD                           :{BLACK}Set password
 
STR_NETWORK_START_SERVER_PASSWORD_TOOLTIP                       :{BLACK}Protect your game with a password if you don't want it to be publicly accessible
 

	
 
STR_NETWORK_SERVER_LIST_ADVERTISED                              :{BLACK}Advertised
 
STR_NETWORK_SERVER_LIST_ADVERTISED_TOOLTIP                      :{BLACK}Choose between an advertised (internet) and a not advertised (Local Area Network, LAN) game
 
STR_NETWORK_START_SERVER_UNADVERTISED                           :No
 
STR_NETWORK_START_SERVER_ADVERTISED                             :Yes
 
STR_NETWORK_START_SERVER_CLIENTS_SELECT                         :{BLACK}{NUM} client{P "" s}
 
STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS                      :{BLACK}Maximum number of clients:
 
STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS_TOOLTIP              :{BLACK}Choose the maximum number of clients. Not all slots need to be filled
 
STR_NETWORK_START_SERVER_COMPANIES_SELECT                       :{BLACK}{NUM} compan{P y ies}
src/network/network_gui.cpp
Show inline comments
 
@@ -52,21 +52,12 @@ static void ShowNetworkLobbyWindow(Netwo
 
static const StringID _connection_types_dropdown[] = {
 
	STR_NETWORK_START_SERVER_UNADVERTISED,
 
	STR_NETWORK_START_SERVER_ADVERTISED,
 
	INVALID_STRING_ID
 
};
 

	
 
/**
 
 * Advertisement options in the server list
 
 */
 
static const StringID _lan_internet_types_dropdown[] = {
 
	STR_NETWORK_SERVER_LIST_ADVERTISED_NO,
 
	STR_NETWORK_SERVER_LIST_ADVERTISED_YES,
 
	INVALID_STRING_ID
 
};
 

	
 
static std::vector<StringID> _language_dropdown;
 

	
 
void SortNetworkLanguages()
 
{
 
	/* Init the strings */
 
	if (_language_dropdown.empty()) {
 
@@ -500,33 +491,18 @@ public:
 

	
 
	~NetworkGameWindow()
 
	{
 
		this->last_sorting = this->servers.GetListing();
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	{
 
		switch (widget) {
 
			case WID_NG_CONN_BTN:
 
				SetDParam(0, _lan_internet_types_dropdown[_settings_client.network.lan_internet]);
 
				break;
 
		}
 
	}
 

	
 
	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
 
	{
 
		switch (widget) {
 
			case WID_NG_CONN_BTN:
 
				*size = maxdim(*size, maxdim(GetStringBoundingBox(_lan_internet_types_dropdown[0]), GetStringBoundingBox(_lan_internet_types_dropdown[1])));
 
				size->width += padding.width;
 
				size->height += padding.height;
 
				break;
 

	
 
			case WID_NG_MATRIX:
 
				resize->height = WD_MATRIX_TOP + max(GetSpriteSize(SPR_BLOT).height, (uint)FONT_HEIGHT_NORMAL) + WD_MATRIX_BOTTOM;
 
				size->height = 10 * resize->height;
 
				size->height = 12 * resize->height;
 
				break;
 

	
 
			case WID_NG_LASTJOINED:
 
				size->height = WD_MATRIX_TOP + max(GetSpriteSize(SPR_BLOT).height, (uint)FONT_HEIGHT_NORMAL) + WD_MATRIX_BOTTOM;
 
				break;
 

	
 
@@ -557,16 +533,12 @@ public:
 
			case WID_NG_DATE:
 
			case WID_NG_YEARS:
 
				size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
 
				SetDParamMaxValue(0, 5);
 
				*size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT));
 
				break;
 

	
 
			case WID_NG_DETAILS_SPACER:
 
				size->height = 20 + 12 * FONT_HEIGHT_NORMAL;
 
				break;
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		switch (widget) {
 
@@ -624,13 +596,14 @@ public:
 

	
 
		/* 'NewGRF Settings' button invisible if no NewGRF is used */
 
		this->GetWidget<NWidgetStacked>(WID_NG_NEWGRF_SEL)->SetDisplayedPlane(sel == nullptr || !sel->online || sel->info.grfconfig == nullptr);
 
		this->GetWidget<NWidgetStacked>(WID_NG_NEWGRF_MISSING_SEL)->SetDisplayedPlane(sel == nullptr || !sel->online || sel->info.grfconfig == nullptr || !sel->info.version_compatible || sel->info.compatible);
 

	
 
#ifdef __EMSCRIPTEN__
 
		this->SetWidgetDisabledState(WID_NG_FIND, true);
 
		this->SetWidgetDisabledState(WID_NG_SEARCH_INTERNET, true);
 
		this->SetWidgetDisabledState(WID_NG_SEARCH_LAN, true);
 
		this->SetWidgetDisabledState(WID_NG_ADD, true);
 
		this->SetWidgetDisabledState(WID_NG_START, true);
 
#endif
 

	
 
		this->DrawWidgets();
 
	}
 
@@ -712,16 +685,12 @@ public:
 
	{
 
		switch (widget) {
 
			case WID_NG_CANCEL: // Cancel button
 
				DeleteWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME);
 
				break;
 

	
 
			case WID_NG_CONN_BTN: // 'Connection' droplist
 
				ShowDropDownMenu(this, _lan_internet_types_dropdown, _settings_client.network.lan_internet, WID_NG_CONN_BTN, 0, 0); // do it for widget WID_NSS_CONN_BTN
 
				break;
 

	
 
			case WID_NG_NAME:    // Sort by name
 
			case WID_NG_CLIENTS: // Sort by connected clients
 
			case WID_NG_MAPSIZE: // Sort by map size
 
			case WID_NG_DATE:    // Sort by date
 
			case WID_NG_YEARS:   // Sort by years
 
			case WID_NG_INFO:    // Connectivity (green dot)
 
@@ -760,17 +729,18 @@ public:
 
					/* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
 
					if (click_count > 1 && !this->IsWidgetDisabled(WID_NG_JOIN)) this->OnClick(pt, WID_NG_JOIN, 1);
 
				}
 
				break;
 
			}
 

	
 
			case WID_NG_FIND: // Find server automatically
 
				switch (_settings_client.network.lan_internet) {
 
					case 0: NetworkUDPSearchGame(); break;
 
					case 1: NetworkUDPQueryMasterServer(); break;
 
				}
 
			case WID_NG_SEARCH_INTERNET:
 
				NetworkUDPQueryMasterServer();
 
				break;
 

	
 
			case WID_NG_SEARCH_LAN:
 
				NetworkUDPSearchGame();
 
				break;
 

	
 
			case WID_NG_ADD: // Add a server
 
				SetDParamStr(0, _settings_client.network.connect_to_ip);
 
				ShowQueryString(
 
					STR_JUST_RAW_STRING,
 
@@ -802,26 +772,12 @@ public:
 
			case WID_NG_NEWGRF_MISSING: // Find missing content online
 
				if (this->server != nullptr) ShowMissingContentWindow(this->server->info.grfconfig);
 
				break;
 
		}
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
 
	{
 
		switch (widget) {
 
			case WID_NG_CONN_BTN:
 
				_settings_client.network.lan_internet = index;
 
				break;
 

	
 
			default:
 
				NOT_REACHED();
 
		}
 

	
 
		this->SetDirty();
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	void OnInvalidateData(int data = 0, bool gui_scope = true) override
 
@@ -962,18 +918,12 @@ static const NWidgetPart _nested_network
 
	NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_NG_MAIN),
 
		NWidget(NWID_VERTICAL), SetPIP(10, 7, 0),
 
			NWidget(NWID_HORIZONTAL), SetPIP(10, 7, 10),
 
				/* LEFT SIDE */
 
				NWidget(NWID_VERTICAL), SetPIP(0, 7, 0),
 
					NWidget(NWID_HORIZONTAL), SetPIP(0, 7, 0),
 
						NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NG_CONNECTION), SetDataTip(STR_NETWORK_SERVER_LIST_ADVERTISED, STR_NULL),
 
						NWidget(WWT_DROPDOWN, COLOUR_LIGHT_BLUE, WID_NG_CONN_BTN),
 
											SetDataTip(STR_BLACK_STRING, STR_NETWORK_SERVER_LIST_ADVERTISED_TOOLTIP),
 
						NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
 
					EndContainer(),
 
					NWidget(NWID_HORIZONTAL), SetPIP(0, 7, 0),
 
						NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NG_FILTER_LABEL), SetDataTip(STR_LIST_FILTER_TITLE, STR_NULL),
 
						NWidget(WWT_EDITBOX, COLOUR_LIGHT_BLUE, WID_NG_FILTER), SetMinimalSize(251, 12), SetFill(1, 0), SetResize(1, 0),
 
											SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
 
					EndContainer(),
 
					NWidget(NWID_HORIZONTAL),
 
						NWidget(NWID_VERTICAL),
 
@@ -1026,13 +976,14 @@ static const NWidgetPart _nested_network
 
				EndContainer(),
 
			EndContainer(),
 
			/* BOTTOM */
 
			NWidget(NWID_HORIZONTAL),
 
				NWidget(NWID_VERTICAL),
 
					NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(10, 7, 4),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_FIND), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_FIND_SERVER, STR_NETWORK_SERVER_LIST_FIND_SERVER_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_SEARCH_INTERNET), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_SEARCH_SERVER_INTERNET, STR_NETWORK_SERVER_LIST_SEARCH_SERVER_INTERNET_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_SEARCH_LAN), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_SEARCH_SERVER_LAN, STR_NETWORK_SERVER_LIST_SEARCH_SERVER_LAN_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_ADD), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_ADD_SERVER, STR_NETWORK_SERVER_LIST_ADD_SERVER_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_START), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NETWORK_SERVER_LIST_START_SERVER, STR_NETWORK_SERVER_LIST_START_SERVER_TOOLTIP),
 
						NWidget(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_CANCEL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
 
					EndContainer(),
 
					NWidget(NWID_SPACER), SetMinimalSize(0, 6), SetResize(1, 0), SetFill(1, 0),
 
				EndContainer(),
src/settings_type.h
Show inline comments
 
@@ -252,13 +252,12 @@ struct NetworkSettings {
 
	bool   server_admin_chat;                             ///< allow private chat for the server to be distributed to the admin network
 
	char   server_name[NETWORK_NAME_LENGTH];              ///< name of the server
 
	char   server_password[NETWORK_PASSWORD_LENGTH];      ///< password for joining this server
 
	char   rcon_password[NETWORK_PASSWORD_LENGTH];        ///< password for rconsole (server side)
 
	char   admin_password[NETWORK_PASSWORD_LENGTH];       ///< password for the admin network
 
	bool   server_advertise;                              ///< advertise the server to the masterserver
 
	uint8  lan_internet;                                  ///< search on the LAN or internet for servers
 
	char   client_name[NETWORK_CLIENT_NAME_LENGTH];       ///< name of the player (as client)
 
	char   default_company_pass[NETWORK_PASSWORD_LENGTH]; ///< default password for new companies in encrypted form
 
	char   connect_to_ip[NETWORK_HOSTNAME_LENGTH];        ///< default for the "Add server" query
 
	char   network_id[NETWORK_SERVER_ID_LENGTH];          ///< network ID for servers
 
	bool   autoclean_companies;                           ///< automatically remove companies that are not in use
 
	uint8  autoclean_unprotected;                         ///< remove passwordless companies after this many months
src/table/settings.ini
Show inline comments
 
@@ -3798,21 +3798,12 @@ cat      = SC_EXPERT
 
[SDTC_BOOL]
 
var      = network.server_advertise
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = false
 

	
 
[SDTC_VAR]
 
var      = network.lan_internet
 
type     = SLE_UINT8
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NETWORK_ONLY
 
def      = 1
 
min      = 0
 
max      = 1
 

	
 
[SDTC_STR]
 
var      = network.client_name
 
type     = SLE_STRB
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
def      = nullptr
 
proc     = UpdateClientName
src/widgets/network_widget.h
Show inline comments
 
@@ -11,14 +11,12 @@
 
#define WIDGETS_NETWORK_WIDGET_H
 

	
 
/** Widgets of the #NetworkGameWindow class. */
 
enum NetworkGameWidgets {
 
	WID_NG_MAIN,               ///< Main panel.
 

	
 
	WID_NG_CONNECTION,         ///< Label in front of connection droplist.
 
	WID_NG_CONN_BTN,           ///< 'Connection' droplist button.
 
	WID_NG_CLIENT_LABEL,       ///< Label in front of client name edit box.
 
	WID_NG_CLIENT,             ///< Panel with editbox to set client name.
 
	WID_NG_FILTER_LABEL,       ///< Label in front of the filter/search edit box.
 
	WID_NG_FILTER,             ///< Panel with the edit box to enter the search text.
 

	
 
	WID_NG_HEADER,             ///< Header container of the matrix.
 
@@ -42,13 +40,14 @@ enum NetworkGameWidgets {
 
	WID_NG_REFRESH,            ///< 'Refresh server' button.
 
	WID_NG_NEWGRF,             ///< 'NewGRF Settings' button.
 
	WID_NG_NEWGRF_SEL,         ///< Selection 'widget' to hide the NewGRF settings.
 
	WID_NG_NEWGRF_MISSING,     ///< 'Find missing NewGRF online' button.
 
	WID_NG_NEWGRF_MISSING_SEL, ///< Selection widget for the above button.
 

	
 
	WID_NG_FIND,               ///< 'Find server' button.
 
	WID_NG_SEARCH_INTERNET,    ///< 'Search internet server' button.
 
	WID_NG_SEARCH_LAN,         ///< 'Search LAN server' button.
 
	WID_NG_ADD,                ///< 'Add server' button.
 
	WID_NG_START,              ///< 'Start server' button.
 
	WID_NG_CANCEL,             ///< 'Cancel' button.
 
};
 

	
 
/** Widgets of the #NetworkStartServerWindow class. */
0 comments (0 inline, 0 general)