Merge commit 'a8b575671894ffe1329ef37dca4989c0e60d70f5'
These merges are becoming more awful every time Conflicts: src/ai/ai_gui.cpp src/build_vehicle_gui.cpp src/cheat_gui.cpp src/company_gui.cpp src/depot_gui.cpp src/dock_gui.cpp src/error_gui.cpp src/genworld_gui.cpp src/misc_gui.cpp src/network/network_content_gui.cpp src/network/network_gui.cpp src/newgrf_gui.cpp src/news_gui.cpp src/rail_gui.cpp src/rev.cpp.in src/road_gui.cpp src/settings_gui.cpp src/settings_gui.h src/signs_gui.cpp src/station_gui.cpp src/table/settings.ini src/terraform_gui.cpp src/toolbar_gui.cpp src/toolbar_gui.h src/vehicle_gui.cpp src/video/sdl_v.cpp src/viewport.cpp src/widget.cpp src/widgets/settings_widget.h
This commit is contained in:
@@ -108,7 +108,7 @@ public:
|
||||
this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_YEARS, STR_NETWORK_SERVER_LIST_YEARS_CAPTION, STR_NETWORK_SERVER_LIST_YEARS_CAPTION_TOOLTIP));
|
||||
|
||||
leaf = new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_INFO, STR_EMPTY, STR_NETWORK_SERVER_LIST_INFO_ICONS_TOOLTIP);
|
||||
leaf->SetMinimalSize(40, 12);
|
||||
leaf->SetMinimalSize(14 + GetSpriteSize(SPR_LOCK).width + GetSpriteSize(SPR_BLOT).width + GetSpriteSize(SPR_FLAGS_BASE).width, 12);
|
||||
leaf->SetFill(0, 1);
|
||||
this->Add(leaf);
|
||||
|
||||
@@ -235,6 +235,10 @@ protected:
|
||||
QueryString name_editbox; ///< Client name editbox.
|
||||
QueryString filter_editbox; ///< Editbox for filter on servers
|
||||
|
||||
int lock_offset; ///< Left offset for lock icon.
|
||||
int blot_offset; ///< Left offset for green/yellow/red compatibility icon.
|
||||
int flag_offset; ///< Left offset for langauge flag icon.
|
||||
|
||||
/**
|
||||
* (Re)build the GUI network game list (a.k.a. this->servers) as some
|
||||
* major change has occurred. It ensures appropriate filtering and
|
||||
@@ -379,9 +383,13 @@ protected:
|
||||
const NWidgetBase *nwi_info = this->GetWidget<NWidgetBase>(WID_NG_INFO);
|
||||
|
||||
/* show highlighted item with a different colour */
|
||||
if (highlight) GfxFillRect(nwi_name->pos_x + 1, y - 2, nwi_info->pos_x + nwi_info->current_x - 2, y + FONT_HEIGHT_NORMAL - 1, PC_GREY);
|
||||
if (highlight) GfxFillRect(nwi_name->pos_x + 1, y + 1, nwi_info->pos_x + nwi_info->current_x - 2, y + this->resize.step_height - 2, PC_GREY);
|
||||
|
||||
DrawString(nwi_name->pos_x + WD_FRAMERECT_LEFT, nwi_name->pos_x + nwi_name->current_x - WD_FRAMERECT_RIGHT, y, cur_item->info.server_name, TC_BLACK);
|
||||
/* offsets to vertically centre text and icons */
|
||||
int text_y_offset = (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2 + 1;
|
||||
int icon_y_offset = (this->resize.step_height - GetSpriteSize(SPR_BLOT).height) / 2;
|
||||
|
||||
DrawString(nwi_name->pos_x + WD_FRAMERECT_LEFT, nwi_name->pos_x + nwi_name->current_x - WD_FRAMERECT_RIGHT, y + text_y_offset, cur_item->info.server_name, TC_BLACK);
|
||||
|
||||
/* only draw details if the server is online */
|
||||
if (cur_item->online) {
|
||||
@@ -393,7 +401,7 @@ protected:
|
||||
SetDParam(1, cur_item->info.clients_max);
|
||||
SetDParam(2, cur_item->info.companies_on);
|
||||
SetDParam(3, cur_item->info.companies_max);
|
||||
DrawString(nwi_clients->pos_x, nwi_clients->pos_x + nwi_clients->current_x - 1, y, STR_NETWORK_SERVER_LIST_GENERAL_ONLINE, TC_FROMSTRING, SA_HOR_CENTER);
|
||||
DrawString(nwi_clients->pos_x, nwi_clients->pos_x + nwi_clients->current_x - 1, y + text_y_offset, STR_NETWORK_SERVER_LIST_GENERAL_ONLINE, TC_FROMSTRING, SA_HOR_CENTER);
|
||||
}
|
||||
|
||||
if (nwi_header->IsWidgetVisible(WID_NG_MAPSIZE)) {
|
||||
@@ -401,7 +409,7 @@ protected:
|
||||
const NWidgetBase *nwi_mapsize = this->GetWidget<NWidgetBase>(WID_NG_MAPSIZE);
|
||||
SetDParam(0, cur_item->info.map_width);
|
||||
SetDParam(1, cur_item->info.map_height);
|
||||
DrawString(nwi_mapsize->pos_x, nwi_mapsize->pos_x + nwi_mapsize->current_x - 1, y, STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT, TC_FROMSTRING, SA_HOR_CENTER);
|
||||
DrawString(nwi_mapsize->pos_x, nwi_mapsize->pos_x + nwi_mapsize->current_x - 1, y + text_y_offset, STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT, TC_FROMSTRING, SA_HOR_CENTER);
|
||||
}
|
||||
|
||||
if (nwi_header->IsWidgetVisible(WID_NG_DATE)) {
|
||||
@@ -410,7 +418,7 @@ protected:
|
||||
YearMonthDay ymd;
|
||||
ConvertDateToYMD(cur_item->info.game_date, &ymd);
|
||||
SetDParam(0, ymd.year);
|
||||
DrawString(nwi_date->pos_x, nwi_date->pos_x + nwi_date->current_x - 1, y, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER);
|
||||
DrawString(nwi_date->pos_x, nwi_date->pos_x + nwi_date->current_x - 1, y + text_y_offset, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER);
|
||||
}
|
||||
|
||||
if (nwi_header->IsWidgetVisible(WID_NG_YEARS)) {
|
||||
@@ -420,20 +428,17 @@ protected:
|
||||
ConvertDateToYMD(cur_item->info.game_date, &ymd_cur);
|
||||
ConvertDateToYMD(cur_item->info.start_date, &ymd_start);
|
||||
SetDParam(0, ymd_cur.year - ymd_start.year);
|
||||
DrawString(nwi_years->pos_x, nwi_years->pos_x + nwi_years->current_x - 1, y, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER);
|
||||
DrawString(nwi_years->pos_x, nwi_years->pos_x + nwi_years->current_x - 1, y + text_y_offset, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER);
|
||||
}
|
||||
|
||||
/* Align the sprites */
|
||||
y += (FONT_HEIGHT_NORMAL - 10) / 2;
|
||||
|
||||
/* draw a lock if the server is password protected */
|
||||
if (cur_item->info.use_password) DrawSprite(SPR_LOCK, PAL_NONE, nwi_info->pos_x + 5, y - 1);
|
||||
if (cur_item->info.use_password) DrawSprite(SPR_LOCK, PAL_NONE, nwi_info->pos_x + this->lock_offset, y + icon_y_offset - 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)), nwi_info->pos_x + 15, y);
|
||||
DrawSprite(SPR_BLOT, (cur_item->info.compatible ? PALETTE_TO_GREEN : (cur_item->info.version_compatible ? PALETTE_TO_YELLOW : PALETTE_TO_RED)), nwi_info->pos_x + this->blot_offset, y + icon_y_offset);
|
||||
|
||||
/* draw flag according to server language */
|
||||
DrawSprite(SPR_FLAGS_BASE + cur_item->info.server_lang, PAL_NONE, nwi_info->pos_x + 25, y);
|
||||
DrawSprite(SPR_FLAGS_BASE + cur_item->info.server_lang, PAL_NONE, nwi_info->pos_x + this->flag_offset, y + icon_y_offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,6 +461,10 @@ public:
|
||||
this->list_pos = SLP_INVALID;
|
||||
this->server = NULL;
|
||||
|
||||
this->lock_offset = 5;
|
||||
this->blot_offset = this->lock_offset + 3 + GetSpriteSize(SPR_LOCK).width;
|
||||
this->flag_offset = this->blot_offset + 2 + GetSpriteSize(SPR_BLOT).width;
|
||||
|
||||
this->CreateNestedTree();
|
||||
this->vscroll = this->GetScrollbar(WID_NG_SCROLLBAR);
|
||||
this->FinishInitNested(WN_NETWORK_WINDOW_GAME);
|
||||
@@ -495,18 +504,18 @@ public:
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_NG_CONN_BTN:
|
||||
*size = maxdim(GetStringBoundingBox(_lan_internet_types_dropdown[0]), GetStringBoundingBox(_lan_internet_types_dropdown[1]));
|
||||
size->width += padding.width + GetMinSizing(NWST_STEP, 11U);
|
||||
*size = maxdim(*size, maxdim(GetStringBoundingBox(_lan_internet_types_dropdown[0]), GetStringBoundingBox(_lan_internet_types_dropdown[1])));
|
||||
size->width += padding.width + GetMinSizing(NWST_STEP, 11U);;
|
||||
size->height += padding.height;
|
||||
break;
|
||||
|
||||
case WID_NG_MATRIX:
|
||||
resize->height = GetMinSizing(NWST_STEP, WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM);
|
||||
resize->height = GetMinSizing(NWST_STEP, WD_MATRIX_TOP + max(GetSpriteSize(SPR_BLOT).height, (uint)FONT_HEIGHT_NORMAL) + WD_MATRIX_BOTTOM);
|
||||
size->height = 5 * resize->height;
|
||||
break;
|
||||
|
||||
case WID_NG_LASTJOINED:
|
||||
size->height = GetMinSizing(NWST_STEP, WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM);
|
||||
size->height = GetMinSizing(NWST_STEP, WD_MATRIX_TOP + max(GetSpriteSize(SPR_BLOT).height, (uint)FONT_HEIGHT_NORMAL) + WD_MATRIX_BOTTOM);
|
||||
break;
|
||||
|
||||
case WID_NG_LASTJOINED_SPACER:
|
||||
@@ -514,11 +523,11 @@ public:
|
||||
break;
|
||||
|
||||
case WID_NG_NAME:
|
||||
size->width += 2 * WD_SORTBUTTON_ARROW_WIDTH; // Make space for the arrow
|
||||
size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
|
||||
break;
|
||||
|
||||
case WID_NG_CLIENTS:
|
||||
size->width += 2 * WD_SORTBUTTON_ARROW_WIDTH; // Make space for the arrow
|
||||
size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
|
||||
SetDParamMaxValue(0, MAX_CLIENTS);
|
||||
SetDParamMaxValue(1, MAX_CLIENTS);
|
||||
SetDParamMaxValue(2, MAX_COMPANIES);
|
||||
@@ -527,7 +536,7 @@ public:
|
||||
break;
|
||||
|
||||
case WID_NG_MAPSIZE:
|
||||
size->width += 2 * WD_SORTBUTTON_ARROW_WIDTH; // Make space for the arrow
|
||||
size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
|
||||
SetDParamMaxValue(0, MAX_MAP_SIZE);
|
||||
SetDParamMaxValue(1, MAX_MAP_SIZE);
|
||||
*size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT));
|
||||
@@ -535,7 +544,7 @@ public:
|
||||
|
||||
case WID_NG_DATE:
|
||||
case WID_NG_YEARS:
|
||||
size->width += 2 * WD_SORTBUTTON_ARROW_WIDTH; // Make space for the arrow
|
||||
size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow
|
||||
SetDParamMaxValue(0, 5);
|
||||
*size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT));
|
||||
break;
|
||||
@@ -564,7 +573,7 @@ public:
|
||||
|
||||
case WID_NG_LASTJOINED:
|
||||
/* Draw the last joined server, if any */
|
||||
if (this->last_joined != NULL) this->DrawServerLine(this->last_joined, r.top + WD_MATRIX_TOP, this->last_joined == this->server);
|
||||
if (this->last_joined != NULL) this->DrawServerLine(this->last_joined, r.top, this->last_joined == this->server);
|
||||
break;
|
||||
|
||||
case WID_NG_DETAILS:
|
||||
@@ -1851,7 +1860,9 @@ struct NetworkClientListWindow : Window {
|
||||
int selected_item;
|
||||
|
||||
uint server_client_width;
|
||||
uint company_icon_width;
|
||||
uint line_height;
|
||||
|
||||
Dimension icon_size;
|
||||
|
||||
NetworkClientListWindow(WindowDesc *desc, WindowNumber window_number) :
|
||||
Window(desc),
|
||||
@@ -1873,7 +1884,7 @@ struct NetworkClientListWindow : Window {
|
||||
if (ci->client_playas != COMPANY_INACTIVE_CLIENT) num++;
|
||||
}
|
||||
|
||||
num *= FONT_HEIGHT_NORMAL;
|
||||
num *= this->line_height;
|
||||
|
||||
int diff = (num + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM) - (this->GetWidget<NWidgetBase>(WID_CL_PANEL)->current_y);
|
||||
/* If height is changed */
|
||||
@@ -1889,7 +1900,8 @@ struct NetworkClientListWindow : Window {
|
||||
if (widget != WID_CL_PANEL) return;
|
||||
|
||||
this->server_client_width = max(GetStringBoundingBox(STR_NETWORK_SERVER).width, GetStringBoundingBox(STR_NETWORK_CLIENT).width) + WD_FRAMERECT_RIGHT;
|
||||
this->company_icon_width = GetSpriteSize(SPR_COMPANY_ICON).width + WD_FRAMERECT_LEFT;
|
||||
this->icon_size = GetSpriteSize(SPR_COMPANY_ICON);
|
||||
this->line_height = max(this->icon_size.height + 2U, (uint)FONT_HEIGHT_NORMAL);
|
||||
|
||||
uint width = 100; // Default width
|
||||
const NetworkClientInfo *ci;
|
||||
@@ -1897,7 +1909,7 @@ struct NetworkClientListWindow : Window {
|
||||
width = max(width, GetStringBoundingBox(ci->client_name).width);
|
||||
}
|
||||
|
||||
size->width = WD_FRAMERECT_LEFT + this->server_client_width + this->company_icon_width + width + WD_FRAMERECT_RIGHT;
|
||||
size->width = WD_FRAMERECT_LEFT + this->server_client_width + this->icon_size.width + WD_FRAMERECT_LEFT + width + WD_FRAMERECT_RIGHT;
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
@@ -1913,11 +1925,13 @@ struct NetworkClientListWindow : Window {
|
||||
if (widget != WID_CL_PANEL) return;
|
||||
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
int icon_y_offset = 1 + (FONT_HEIGHT_NORMAL - 10) / 2;
|
||||
int icon_offset = (this->line_height - icon_size.height) / 2;
|
||||
int text_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2;
|
||||
|
||||
uint y = r.top + WD_FRAMERECT_TOP;
|
||||
uint left = r.left + WD_FRAMERECT_LEFT;
|
||||
uint right = r.right - WD_FRAMERECT_RIGHT;
|
||||
uint type_icon_width = this->server_client_width + this->company_icon_width;
|
||||
uint type_icon_width = this->server_client_width + this->icon_size.width + WD_FRAMERECT_LEFT;
|
||||
|
||||
|
||||
uint type_left = rtl ? right - this->server_client_width : left;
|
||||
@@ -1931,24 +1945,24 @@ struct NetworkClientListWindow : Window {
|
||||
FOR_ALL_CLIENT_INFOS(ci) {
|
||||
TextColour colour;
|
||||
if (this->selected_item == i++) { // Selected item, highlight it
|
||||
GfxFillRect(r.left + 1, y, r.right - 1, y + FONT_HEIGHT_NORMAL - 1, PC_BLACK);
|
||||
GfxFillRect(r.left + 1, y, r.right - 1, y + this->line_height - 1, PC_BLACK);
|
||||
colour = TC_WHITE;
|
||||
} else {
|
||||
colour = TC_BLACK;
|
||||
}
|
||||
|
||||
if (ci->client_id == CLIENT_ID_SERVER) {
|
||||
DrawString(type_left, type_right, y, STR_NETWORK_SERVER, colour);
|
||||
DrawString(type_left, type_right, y + text_offset, STR_NETWORK_SERVER, colour);
|
||||
} else {
|
||||
DrawString(type_left, type_right, y, STR_NETWORK_CLIENT, colour);
|
||||
DrawString(type_left, type_right, y + text_offset, STR_NETWORK_CLIENT, colour);
|
||||
}
|
||||
|
||||
/* Filter out spectators */
|
||||
if (Company::IsValidID(ci->client_playas)) DrawCompanyIcon(ci->client_playas, icon_left, y + icon_y_offset);
|
||||
if (Company::IsValidID(ci->client_playas)) DrawCompanyIcon(ci->client_playas, icon_left, y + icon_offset);
|
||||
|
||||
DrawString(name_left, name_right, y, ci->client_name, colour);
|
||||
DrawString(name_left, name_right, y + text_offset, ci->client_name, colour);
|
||||
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
y += line_height;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1981,7 +1995,7 @@ struct NetworkClientListWindow : Window {
|
||||
pt.y -= this->GetWidget<NWidgetBase>(WID_CL_PANEL)->pos_y;
|
||||
int item = -1;
|
||||
if (IsInsideMM(pt.y, WD_FRAMERECT_TOP, this->GetWidget<NWidgetBase>(WID_CL_PANEL)->current_y - WD_FRAMERECT_BOTTOM)) {
|
||||
item = (pt.y - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL;
|
||||
item = (pt.y - WD_FRAMERECT_TOP) / this->line_height;
|
||||
}
|
||||
|
||||
/* It did not change.. no update! */
|
||||
@@ -2188,7 +2202,7 @@ static const NWidgetPart _nested_network_company_password_window_widgets[] = {
|
||||
NWidget(NWID_VERTICAL), SetPIP(5, 5, 5),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(5, 5, 5),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY, WID_NCP_LABEL), SetDataTip(STR_COMPANY_VIEW_PASSWORD, STR_NULL),
|
||||
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_NCP_PASSWORD), SetMinimalSize(194, 12), SetDataTip(STR_COMPANY_VIEW_SET_PASSWORD, STR_NULL),
|
||||
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_NCP_PASSWORD), SetFill(1, 0), SetMinimalSize(194, 12), SetDataTip(STR_COMPANY_VIEW_SET_PASSWORD, STR_NULL),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL), SetPIP(5, 0, 5),
|
||||
NWidget(NWID_SPACER), SetFill(1, 0),
|
||||
|
||||
Reference in New Issue
Block a user