Changeset - r9660:abcf33a526dc
[Not reviewed]
master
0 3 0
rubidium - 16 years ago 2008-07-18 20:44:35
rubidium@openttd.org
(svn r13732) -Feature: add a few extra columns with information to the server list. Patch by Pegasus.
3 files changed with 146 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -1375,24 +1375,35 @@ STR_NETWORK_CLICK_GAME_TO_SELECT        
 
STR_NETWORK_LAST_JOINED_SERVER                                  :{BLACK}The server you joined last time:
 
STR_NETWORK_CLICK_TO_SELECT_LAST                                :{BLACK}Click to select the server you played last time
 

	
 
STR_NETWORK_FIND_SERVER                                         :{BLACK}Find server
 
STR_NETWORK_FIND_SERVER_TIP                                     :{BLACK}Search network for a server
 
STR_NETWORK_ADD_SERVER                                          :{BLACK}Add server
 
STR_NETWORK_ADD_SERVER_TIP                                      :{BLACK}Adds a server to the list which will always be checked for running games.
 
STR_NETWORK_ENTER_IP                                            :{BLACK}Enter the address of the host
 

	
 
STR_NETWORK_GENERAL_ONLINE                                      :{BLACK}{COMMA}/{COMMA} - {COMMA}/{COMMA}
 
STR_NETWORK_CLIENTS_CAPTION                                     :{BLACK}Clients
 
STR_NETWORK_CLIENTS_CAPTION_TIP                                 :{BLACK}Clients online / clients max{}Companies online / companies max
 

	
 
STR_NETWORK_MAP_SIZE_SHORT                                      :{BLACK}{COMMA}x{COMMA}
 
STR_NETWORK_MAP_SIZE_CAPTION                                    :{BLACK}Map size
 
STR_NETWORK_MAP_SIZE_CAPTION_TIP                                :{BLACK}Map size of the game{}Click to sort by area
 

	
 
STR_NETWORK_DATE_CAPTION                                        :{BLACK}Date
 
STR_NETWORK_DATE_CAPTION_TIP                                    :{BLACK}Current date
 

	
 
STR_NETWORK_YEARS_CAPTION                                       :{BLACK}Years
 
STR_NETWORK_YEARS_CAPTION_TIP                                   :{BLACK}Number of years{}the game is running
 

	
 
STR_NETWORK_GAME_INFO                                           :{SILVER}GAME INFO
 
STR_NETWORK_CLIENTS                                             :{SILVER}Clients:  {WHITE}{COMMA} / {COMMA} - {COMMA} / {COMMA}
 
STR_NETWORK_LANGUAGE                                            :{SILVER}Language:  {WHITE}{STRING}
 
STR_NETWORK_TILESET                                             :{SILVER}Tileset:  {WHITE}{STRING}
 
STR_NETWORK_MAP_SIZE                                            :{SILVER}Map size:  {WHITE}{COMMA}x{COMMA}
 
STR_NETWORK_SERVER_VERSION                                      :{SILVER}Server version:  {WHITE}{RAW_STRING}
 
STR_NETWORK_SERVER_ADDRESS                                      :{SILVER}Server address:  {WHITE}{RAW_STRING} : {NUM}
 
STR_NETWORK_START_DATE                                          :{SILVER}Start date:  {WHITE}{DATE_SHORT}
 
STR_NETWORK_CURRENT_DATE                                        :{SILVER}Current date:  {WHITE}{DATE_SHORT}
 
STR_NETWORK_PASSWORD                                            :{SILVER}Password protected!
 
STR_NETWORK_SERVER_OFFLINE                                      :{SILVER}SERVER OFFLINE
 
STR_NETWORK_SERVER_FULL                                         :{SILVER}SERVER FULL
src/network/network_gui.cpp
Show inline comments
 
@@ -88,24 +88,27 @@ void UpdateNetworkGameWindow(bool unsele
 
/** Enum for NetworkGameWindow, referring to _network_game_window_widgets */
 
enum NetworkGameWindowWidgets {
 
	NGWW_CLOSE,         ///< Close 'X' button
 
	NGWW_CAPTION,       ///< Caption of the window
 
	NGWW_RESIZE,        ///< Resize button
 

	
 
	NGWW_CONNECTION,    ///< Label in from of connection droplist
 
	NGWW_CONN_BTN,      ///< 'Connection' droplist button
 
	NGWW_PLAYER,        ///< Panel with editbox to set player name
 

	
 
	NGWW_NAME,          ///< 'Name' button
 
	NGWW_CLIENTS,       ///< 'Clients' button
 
	NGWW_MAPSIZE,       ///< 'Map size' button
 
	NGWW_DATE,          ///< 'Date' button
 
	NGWW_YEARS,         ///< 'Years' button
 
	NGWW_INFO,          ///< Third button in the game list panel
 

	
 
	NGWW_MATRIX,        ///< Panel with list of games
 
	NGWW_SCROLLBAR,     ///< Scrollbar of matrix
 

	
 
	NGWW_LASTJOINED_LABEL, ///< Label "Last joined server:"
 
	NGWW_LASTJOINED,    ///< Info about the last joined server
 

	
 
	NGWW_DETAILS,       ///< Panel with game details
 
	NGWW_JOIN,          ///< 'Join game' button
 
	NGWW_REFRESH,       ///< 'Refresh server' button
 
	NGWW_NEWGRF,        ///< 'NewGRF Settings' button
 
@@ -160,24 +163,48 @@ protected:
 
	 * higher maximum is preferred. */
 
	static int CDECL NGameClientSorter(NetworkGameList* const *a, NetworkGameList* const *b)
 
	{
 
		/* Reverse as per default we are interested in most-clients first */
 
		int r = (*a)->info.clients_on - (*b)->info.clients_on;
 

	
 
		if (r == 0) r = (*a)->info.clients_max - (*b)->info.clients_max;
 
		if (r == 0) r = NGameNameSorter(a, b);
 

	
 
		return r;
 
	}
 

	
 
	/** Sort servers by map size */
 
	static int CDECL NGameMapSizeSorter(NetworkGameList* const *a, NetworkGameList* const *b)
 
	{
 
		/* Sort by the area of the map. */
 
		int r = ((*a)->info.map_height) * ((*a)->info.map_width) - ((*b)->info.map_height) * ((*b)->info.map_width);
 

	
 
		if (r == 0) r = (*a)->info.map_width - (*b)->info.map_width;
 
		return (r != 0) ? r : NGameClientSorter(a, b);
 
	}
 

	
 
	/** Sort servers by current date */
 
	static int CDECL NGameDateSorter(NetworkGameList* const *a, NetworkGameList* const *b)
 
	{
 
		int r = (*a)->info.game_date - (*b)->info.game_date;
 
		return (r != 0) ? r : NGameClientSorter(a, b);
 
	}
 

	
 
	/** Sort servers by the number of days the game is running */
 
	static int CDECL NGameYearsSorter(NetworkGameList* const *a, NetworkGameList* const *b)
 
	{
 
		int r = (*a)->info.game_date - (*a)->info.start_date - (*b)->info.game_date + (*b)->info.start_date;
 
		return (r != 0) ? r : NGameDateSorter(a, b);
 
	}
 

	
 
	/** Sort servers by joinability. If both servers are the
 
	 * same, prefer the non-passworded server first. */
 
	static int CDECL NGameAllowedSorter(NetworkGameList* const *a, NetworkGameList* const *b)
 
	{
 
		/* The servers we do not know anything about (the ones that did not reply) should be at the bottom) */
 
		int r = StrEmpty((*a)->info.server_revision) - StrEmpty((*b)->info.server_revision);
 

	
 
		/* Reverse default as we are interested in version-compatible clients first */
 
		if (r == 0) r = (*b)->info.version_compatible - (*a)->info.version_compatible;
 
		/* The version-compatible ones are then sorted with NewGRF compatible first, incompatible last */
 
		if (r == 0) r = (*b)->info.compatible - (*a)->info.compatible;
 
		/* Passworded servers should be below unpassworded servers */
 
@@ -210,32 +237,56 @@ protected:
 
	 * @param cur_item  the server to draw.
 
	 * @param y         from where to draw?
 
	 * @param highlight does the line need to be highlighted?
 
	 */
 
	void DrawServerLine(const NetworkGameList *cur_item, uint y, bool highlight)
 
	{
 
		/* show highlighted item with a different colour */
 
		if (highlight) GfxFillRect(this->widget[NGWW_NAME].left + 1, y - 2, this->widget[NGWW_INFO].right - 1, y + 9, 10);
 

	
 
		SetDParamStr(0, cur_item->info.server_name);
 
		DrawStringTruncated(this->widget[NGWW_NAME].left + 5, y, STR_JUST_RAW_STRING, TC_BLACK, this->widget[NGWW_NAME].right - this->widget[NGWW_NAME].left - 5);
 

	
 
		SetDParam(0, cur_item->info.clients_on);
 
		SetDParam(1, cur_item->info.clients_max);
 
		SetDParam(2, cur_item->info.companies_on);
 
		SetDParam(3, cur_item->info.companies_max);
 
		DrawStringCentered(this->widget[NGWW_CLIENTS].left + 39, y, STR_NETWORK_GENERAL_ONLINE, TC_GOLD);
 
		/* only draw details if the server is online */
 
		if (cur_item->online) {
 
			SetDParam(0, cur_item->info.clients_on);
 
			SetDParam(1, cur_item->info.clients_max);
 
			SetDParam(2, cur_item->info.companies_on);
 
			SetDParam(3, cur_item->info.companies_max);
 
			DrawStringCentered(this->widget[NGWW_CLIENTS].left + 39, y, STR_NETWORK_GENERAL_ONLINE, TC_GOLD);
 

	
 
			/* map size */
 
			if (!this->IsWidgetHidden(NGWW_MAPSIZE)) {
 
				SetDParam(0, cur_item->info.map_width);
 
				SetDParam(1, cur_item->info.map_height);
 
				DrawStringCentered(this->widget[NGWW_MAPSIZE].left + 39, y, STR_NETWORK_MAP_SIZE_SHORT, TC_BLACK);
 
			}
 

	
 
		/* only draw icons if the server is online */
 
		if (cur_item->online) {
 
			/* current date */
 
			if (!this->IsWidgetHidden(NGWW_DATE)) {
 
				YearMonthDay ymd;
 
				ConvertDateToYMD(cur_item->info.game_date, &ymd);
 
				SetDParam(0, ymd.year);
 
				DrawStringCentered(this->widget[NGWW_DATE].left + 29, y, STR_JUST_INT, TC_BLACK);
 
			}
 

	
 
			/* number of years the game is running */
 
			if (!this->IsWidgetHidden(NGWW_YEARS)) {
 
				YearMonthDay ymd_cur, ymd_start;
 
				ConvertDateToYMD(cur_item->info.game_date, &ymd_cur);
 
				ConvertDateToYMD(cur_item->info.start_date, &ymd_start);
 
				SetDParam(0, ymd_cur.year - ymd_start.year);
 
				DrawStringCentered(this->widget[NGWW_YEARS].left + 29, y, STR_JUST_INT, TC_BLACK);
 
			}
 

	
 
			/* draw a lock if the server is password protected */
 
			if (cur_item->info.use_password) DrawSprite(SPR_LOCK, PAL_NONE, this->widget[NGWW_INFO].left + 5, y - 1);
 

	
 
			/* draw red or green icon, depending on compatibility with server */
 
			DrawSprite(SPR_BLOT, (cur_item->info.compatible ? PALETTE_TO_GREEN : (cur_item->info.version_compatible ? PALETTE_TO_YELLOW : PALETTE_TO_RED)), this->widget[NGWW_INFO].left + 15, y);
 

	
 
			/* draw flag according to server language */
 
			DrawSprite(SPR_FLAGS_BASE + cur_item->info.server_lang, PAL_NONE, this->widget[NGWW_INFO].left + 25, y);
 
		}
 
	}
 

	
 
public:
 
@@ -294,24 +345,27 @@ public:
 
		SetDParam(1, _lan_internet_types_dropdown[_settings_client.network.lan_internet]);
 
		this->DrawWidgets();
 

	
 
		/* Edit box to set player name */
 
		this->DrawEditBox(NGWW_PLAYER);
 

	
 
		DrawString(this->widget[NGWW_PLAYER].left - 100, 23, STR_NETWORK_PLAYER_NAME, TC_GOLD);
 

	
 
		/* Sort based on widgets: name, clients, compatibility */
 
		switch (this->servers.SortType()) {
 
			case NGWW_NAME    - NGWW_NAME: this->DrawSortButtonState(NGWW_NAME,    arrow); break;
 
			case NGWW_CLIENTS - NGWW_NAME: this->DrawSortButtonState(NGWW_CLIENTS, arrow); break;
 
			case NGWW_MAPSIZE - NGWW_NAME: if (!this->IsWidgetHidden(NGWW_MAPSIZE)) this->DrawSortButtonState(NGWW_MAPSIZE, arrow); break;
 
			case NGWW_DATE    - NGWW_NAME: if (!this->IsWidgetHidden(NGWW_DATE))    this->DrawSortButtonState(NGWW_DATE,    arrow); break;
 
			case NGWW_YEARS   - NGWW_NAME: if (!this->IsWidgetHidden(NGWW_YEARS))   this->DrawSortButtonState(NGWW_YEARS,   arrow); break;
 
			case NGWW_INFO    - NGWW_NAME: this->DrawSortButtonState(NGWW_INFO,    arrow); break;
 
		}
 

	
 
		uint16 y = NET_PRC__OFFSET_TOP_WIDGET + 3;
 

	
 
		const int max = min(this->vscroll.pos + this->vscroll.cap, (int)this->servers.Length());
 

	
 
		for (int i = this->vscroll.pos; i < max; ++i) {
 
			const NetworkGameList *ngl = this->servers[i];
 
			this->DrawServerLine(ngl, y, ngl == sel);
 
			y += NET_PRC__SIZE_OF_ROW;
 
		}
 
@@ -401,27 +455,30 @@ public:
 
			case NGWW_PLAYER:
 
				ShowOnScreenKeyboard(this, NGWW_PLAYER, 0, 0);
 
				break;
 

	
 
			case NGWW_CANCEL: // Cancel button
 
				DeleteWindowById(WC_NETWORK_WINDOW, 0);
 
				break;
 

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

	
 
			case NGWW_NAME: // Sort by name
 
			case NGWW_NAME:    // Sort by name
 
			case NGWW_CLIENTS: // Sort by connected clients
 
			case NGWW_INFO: // Connectivity (green dot)
 
			case NGWW_MAPSIZE: // Sort by map size
 
			case NGWW_DATE:    // Sort by date
 
			case NGWW_YEARS:   // Sort by years
 
			case NGWW_INFO:    // Connectivity (green dot)
 
				if (this->servers.SortType() == widget - NGWW_NAME) {
 
					this->servers.ToggleSortOrder();
 
				} else {
 
					this->servers.SetSortType(widget - NGWW_NAME);
 
					this->servers.ForceResort();
 
				}
 
				this->SetDirty();
 
				break;
 

	
 
			case NGWW_MATRIX: { // Matrix to show networkgames
 
				uint32 id_v = (pt.y - NET_PRC__OFFSET_TOP_WIDGET) / NET_PRC__SIZE_OF_ROW;
 

	
 
@@ -537,59 +594,97 @@ public:
 
			NetworkRebuildHostList();
 
		}
 
	}
 

	
 
	virtual void OnResize(Point new_size, Point delta)
 
	{
 
		this->vscroll.cap += delta.y / (int)this->resize.step_height;
 

	
 
		this->widget[NGWW_MATRIX].data = (this->vscroll.cap << 8) + 1;
 

	
 
		SetVScrollCount(this, this->servers.Length());
 

	
 
		/* Additional colums in server list */
 
		if (this->width > NetworkGameWindow::MIN_EXTRA_COLUMNS_WIDTH + GetWidgetWidth(NGWW_MAPSIZE)
 
				+ GetWidgetWidth(NGWW_DATE) + GetWidgetWidth(NGWW_YEARS)) {
 
			/* show columns 'Map size', 'Date' and 'Years' */
 
			this->SetWidgetsHiddenState(false, NGWW_MAPSIZE, NGWW_DATE, NGWW_YEARS, WIDGET_LIST_END);
 
			AlignWidgetRight(NGWW_YEARS,   NGWW_INFO);
 
			AlignWidgetRight(NGWW_DATE,    NGWW_YEARS);
 
			AlignWidgetRight(NGWW_MAPSIZE, NGWW_DATE);
 
			AlignWidgetRight(NGWW_CLIENTS, NGWW_MAPSIZE);
 
		} else if (this->width > NetworkGameWindow::MIN_EXTRA_COLUMNS_WIDTH + GetWidgetWidth(NGWW_MAPSIZE) + GetWidgetWidth(NGWW_DATE)) {
 
			/* show columns 'Map size' and 'Date' */
 
			this->SetWidgetsHiddenState(false, NGWW_MAPSIZE, NGWW_DATE, WIDGET_LIST_END);
 
			this->HideWidget(NGWW_YEARS);
 
			AlignWidgetRight(NGWW_DATE,    NGWW_INFO);
 
			AlignWidgetRight(NGWW_MAPSIZE, NGWW_DATE);
 
			AlignWidgetRight(NGWW_CLIENTS, NGWW_MAPSIZE);
 
		} else if (this->width > NetworkGameWindow::MIN_EXTRA_COLUMNS_WIDTH + GetWidgetWidth(NGWW_MAPSIZE)) {
 
			/* show column 'Map size' */
 
			this->ShowWidget(NGWW_MAPSIZE);
 
			this->SetWidgetsHiddenState(true, NGWW_DATE, NGWW_YEARS, WIDGET_LIST_END);
 
			AlignWidgetRight(NGWW_MAPSIZE, NGWW_INFO);
 
			AlignWidgetRight(NGWW_CLIENTS, NGWW_MAPSIZE);
 
		} else {
 
			/* hide columns 'Map size', 'Date' and 'Years' */
 
			this->SetWidgetsHiddenState(true, NGWW_MAPSIZE, NGWW_DATE, NGWW_YEARS, WIDGET_LIST_END);
 
			AlignWidgetRight(NGWW_CLIENTS, NGWW_INFO);
 
		}
 
		this->widget[NGWW_NAME].right = this->widget[NGWW_CLIENTS].left - 1;
 

	
 
		/* BOTTOM */
 
		int widget_width = this->widget[NGWW_FIND].right - this->widget[NGWW_FIND].left;
 
		int space = (this->width - 4 * widget_width - 25) / 3;
 

	
 
		int offset = 10;
 
		for (uint i = 0; i < 4; i++) {
 
			this->widget[NGWW_FIND + i].left  = offset;
 
			offset += widget_width;
 
			this->widget[NGWW_FIND + i].right = offset;
 
			offset += space;
 
		}
 
	}
 

	
 
	static const int MIN_EXTRA_COLUMNS_WIDTH = 550;   ///< default width of the window
 
};
 

	
 
Listing NetworkGameWindow::last_sorting = {false, 2};
 
Listing NetworkGameWindow::last_sorting = {false, 5};
 
GUIGameServerList::SortFunction *const NetworkGameWindow::sorter_funcs[] = {
 
	&NGameNameSorter,
 
	&NGameClientSorter,
 
	&NGameMapSizeSorter,
 
	&NGameDateSorter,
 
	&NGameYearsSorter,
 
	&NGameAllowedSorter
 
};
 

	
 

	
 
static const Widget _network_game_window_widgets[] = {
 
/* TOP */
 
{   WWT_CLOSEBOX,   RESIZE_NONE,   BGC,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},            // NGWW_CLOSE
 
{    WWT_CAPTION,   RESIZE_RIGHT,  BGC,    11,   449,     0,    13, STR_NETWORK_MULTIPLAYER,          STR_NULL},                         // NGWW_CAPTION
 
{      WWT_PANEL,   RESIZE_RB,     BGC,     0,   449,    14,   263, 0x0,                              STR_NULL},                         // NGWW_RESIZE
 

	
 
{       WWT_TEXT,   RESIZE_NONE,   BGC,     9,    85,    23,    35, STR_NETWORK_CONNECTION,           STR_NULL},                         // NGWW_CONNECTION
 
{ WWT_DROPDOWNIN,   RESIZE_NONE,   BGC,    90,   181,    22,    33, STR_NETWORK_LAN_INTERNET_COMBO,   STR_NETWORK_CONNECTION_TIP},       // NGWW_CONN_BTN
 

	
 
{    WWT_EDITBOX,   RESIZE_LR,     BGC,   290,   440,    22,    33, STR_NETWORK_PLAYER_NAME_OSKTITLE, STR_NETWORK_ENTER_NAME_TIP},       // NGWW_PLAYER
 

	
 
/* LEFT SIDE */
 
{ WWT_PUSHTXTBTN,   RESIZE_RIGHT,  BTC,    10,    70,    42,    53, STR_NETWORK_GAME_NAME,            STR_NETWORK_GAME_NAME_TIP},        // NGWW_NAME
 
{ WWT_PUSHTXTBTN,   RESIZE_LR,     BTC,    71,   150,    42,    53, STR_NETWORK_CLIENTS_CAPTION,      STR_NETWORK_CLIENTS_CAPTION_TIP},  // NGWW_CLIENTS
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    10,    70,    42,    53, STR_NETWORK_GAME_NAME,            STR_NETWORK_GAME_NAME_TIP},        // NGWW_NAME
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    71,   150,    42,    53, STR_NETWORK_CLIENTS_CAPTION,      STR_NETWORK_CLIENTS_CAPTION_TIP},  // NGWW_CLIENTS
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    71,   150,    42,    53, STR_NETWORK_MAP_SIZE_CAPTION,     STR_NETWORK_MAP_SIZE_CAPTION_TIP}, // NGWW_MAPSIZE
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    71,   130,    42,    53, STR_NETWORK_DATE_CAPTION,         STR_NETWORK_DATE_CAPTION_TIP},     // NGWW_DATE
 
{ WWT_PUSHTXTBTN,   RESIZE_NONE,   BTC,    71,   130,    42,    53, STR_NETWORK_YEARS_CAPTION,        STR_NETWORK_YEARS_CAPTION_TIP},    // NGWW_YEARS
 
{ WWT_PUSHTXTBTN,   RESIZE_LR,     BTC,   151,   190,    42,    53, STR_EMPTY,                        STR_NETWORK_INFO_ICONS_TIP},       // NGWW_INFO
 

	
 
{     WWT_MATRIX,   RESIZE_RB,     BGC,    10,   190,    54,   208, (11 << 8) + 1,                    STR_NETWORK_CLICK_GAME_TO_SELECT}, // NGWW_MATRIX
 
{  WWT_SCROLLBAR,   RESIZE_LRB,    BGC,   191,   202,    42,   208, 0x0,                              STR_0190_SCROLL_BAR_SCROLLS_LIST}, // NGWW_SCROLLBAR
 
{       WWT_TEXT,   RESIZE_RTB,    BGC,    10,   190,   211,   222, STR_NETWORK_LAST_JOINED_SERVER,   STR_NULL},                         // NGWW_LASTJOINED_LABEL
 
{      WWT_PANEL,   RESIZE_RTB,    BGC,    10,   190,   223,   236, 0x0,                              STR_NETWORK_CLICK_TO_SELECT_LAST}, // NGWW_LASTJOINED
 

	
 
/* RIGHT SIDE */
 
{      WWT_PANEL,   RESIZE_LRB,    BGC,   210,   440,    42,   236, 0x0,                              STR_NULL},                         // NGWW_DETAILS
 

	
 
{ WWT_PUSHTXTBTN,   RESIZE_LRTB,   BTC,   215,   315,   215,   226, STR_NETWORK_JOIN_GAME,            STR_NULL},                         // NGWW_JOIN
 
{ WWT_PUSHTXTBTN,   RESIZE_LRTB,   BTC,   330,   435,   215,   226, STR_NETWORK_REFRESH,              STR_NETWORK_REFRESH_TIP},          // NGWW_REFRESH
 
@@ -599,25 +694,25 @@ static const Widget _network_game_window
 
/* BOTTOM */
 
{ WWT_PUSHTXTBTN,   RESIZE_TB,     BTC,    10,   110,   246,   257, STR_NETWORK_FIND_SERVER,          STR_NETWORK_FIND_SERVER_TIP},      // NGWW_FIND
 
{ WWT_PUSHTXTBTN,   RESIZE_TB,     BTC,   118,   218,   246,   257, STR_NETWORK_ADD_SERVER,           STR_NETWORK_ADD_SERVER_TIP},       // NGWW_ADD
 
{ WWT_PUSHTXTBTN,   RESIZE_TB,     BTC,   226,   326,   246,   257, STR_NETWORK_START_SERVER,         STR_NETWORK_START_SERVER_TIP},     // NGWW_START
 
{ WWT_PUSHTXTBTN,   RESIZE_TB,     BTC,   334,   434,   246,   257, STR_012E_CANCEL,                  STR_NULL},                         // NGWW_CANCEL
 

	
 
{  WWT_RESIZEBOX,   RESIZE_LRTB,   BGC,   438,   449,   252,   263, 0x0,                              STR_RESIZE_BUTTON },
 

	
 
{   WIDGETS_END},
 
};
 

	
 
static const WindowDesc _network_game_window_desc = {
 
	WDP_CENTER, WDP_CENTER, 450, 264, 550, 264,
 
	WDP_CENTER, WDP_CENTER, 450, 264, 780, 264,
 
	WC_NETWORK_WINDOW, WC_NONE,
 
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
 
	_network_game_window_widgets,
 
};
 

	
 
void ShowNetworkGameWindow()
 
{
 
	static bool first = true;
 
	DeleteWindowById(WC_NETWORK_WINDOW, 0);
 

	
 
	/* Only show once */
 
	if (first) {
src/window_gui.h
Show inline comments
 
@@ -229,24 +229,26 @@ public:
 
	void DisableWidget(byte widget_index);
 
	void EnableWidget(byte widget_index);
 
	bool IsWidgetDisabled(byte widget_index) const;
 
	void SetWidgetHiddenState(byte widget_index, bool hidden_stat);
 
	void HideWidget(byte widget_index);
 
	void ShowWidget(byte widget_index);
 
	bool IsWidgetHidden(byte widget_index) const;
 
	void SetWidgetLoweredState(byte widget_index, bool lowered_stat);
 
	void ToggleWidgetLoweredState(byte widget_index);
 
	void LowerWidget(byte widget_index);
 
	void RaiseWidget(byte widget_index);
 
	bool IsWidgetLowered(byte widget_index) const;
 
	void AlignWidgetRight(byte widget_index_a, byte widget_index_b);
 
	int  GetWidgetWidth(byte widget_index) const;
 

	
 
	void RaiseButtons();
 
	void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets, ...);
 
	void CDECL SetWidgetsHiddenState(bool hidden_stat, int widgets, ...);
 
	void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets, ...);
 
	void InvalidateWidget(byte widget_index) const;
 

	
 
	void DrawWidgets() const;
 
	void DrawViewport() const;
 
	void DrawSortButtonState(int widget, SortButtonState state) const;
 

	
 
	void SetDirty() const;
 
@@ -707,13 +709,38 @@ inline void Window::RaiseWidget(byte wid
 

	
 
/**
 
 * Gets the lowered state of a widget.
 
 * @param widget_index : index of this widget in the window
 
 * @return status of the widget ie: lowered = true, raised= false
 
 */
 
inline bool Window::IsWidgetLowered(byte widget_index) const
 
{
 
	assert(widget_index < this->widget_count);
 
	return HasBit(this->widget[widget_index].display_flags, WIDG_LOWERED);
 
}
 

	
 
/**
 
 * Align widgets a and b next to each other.
 
 * @param widget_index_a  the left widget
 
 * @param widget_index_b  the right widget (fixed)
 
 */
 
inline void Window::AlignWidgetRight(byte widget_index_a, byte widget_index_b)
 
{
 
	assert(widget_index_a < this->widget_count);
 
	assert(widget_index_b < this->widget_count);
 
	int w = this->widget[widget_index_a].right - this->widget[widget_index_a].left;
 
	this->widget[widget_index_a].right = this->widget[widget_index_b].left - 1;
 
	this->widget[widget_index_a].left  = this->widget[widget_index_a].right - w;
 
}
 

	
 
/**
 
 * Get the width of a widget.
 
 * @param widget_index  the widget
 
 * @return width of the widget
 
 */
 
inline int Window::GetWidgetWidth(byte widget_index) const
 
{
 
	assert(widget_index < this->widget_count);
 
	return this->widget[widget_index].right - this->widget[widget_index].left + 1;
 
}
 

	
 
#endif /* WINDOW_GUI_H */
0 comments (0 inline, 0 general)