diff --git a/media/baseset/openttd.grf b/media/baseset/openttd.grf index c4511f55ea9f..837e4b12d255 100644 Binary files a/media/baseset/openttd.grf and b/media/baseset/openttd.grf differ diff --git a/media/baseset/openttd/openttdgui.nfo b/media/baseset/openttd/openttdgui.nfo index 9a13fa8000a2..2fd5a5bb4cbc 100644 --- a/media/baseset/openttd/openttdgui.nfo +++ b/media/baseset/openttd/openttdgui.nfo @@ -4,7 +4,7 @@ // See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . // -1 * 0 0C "OpenTTD GUI graphics" - -1 * 3 05 15 \b 189 // OPENTTD_SPRITE_COUNT + -1 * 3 05 15 \b 191 // OPENTTD_SPRITE_COUNT -1 sprites/openttdgui.png 8bpp 66 8 64 31 -31 7 normal -1 sprites/openttdgui.png 8bpp 146 8 64 31 -31 7 normal -1 sprites/openttdgui.png 8bpp 226 8 64 31 -31 7 normal @@ -194,3 +194,5 @@ -1 sprites/openttdgui.png 8bpp 539 440 12 10 0 0 normal -1 sprites/openttdgui.png 8bpp 553 440 12 10 0 0 normal -1 sprites/openttdgui.png 8bpp 567 440 12 10 0 0 normal + -1 sprites/openttdgui.png 8bpp 581 440 10 10 0 0 normal + -1 sprites/openttdgui.png 8bpp 593 440 10 10 0 0 normal diff --git a/media/baseset/openttd/openttdgui.png b/media/baseset/openttd/openttdgui.png index dc0976a97164..5b80c3326047 100644 Binary files a/media/baseset/openttd/openttdgui.png and b/media/baseset/openttd/openttdgui.png differ diff --git a/src/lang/english.txt b/src/lang/english.txt index 33ccca2a4102..dbf0a82d0ff2 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -2137,8 +2137,6 @@ STR_NETWORK_CLIENT_LIST_PLAYER_NAME :{BLACK}Name STR_NETWORK_CLIENT_LIST_PLAYER_NAME_TOOLTIP :{BLACK}Your player name STR_NETWORK_CLIENT_LIST_PLAYER_NAME_EDIT_TOOLTIP :{BLACK}Edit your player name STR_NETWORK_CLIENT_LIST_PLAYER_NAME_QUERY_CAPTION :Your player name -STR_NETWORK_CLIENT_LIST_PLAYER_HOST :{WHITE}(host) {BLACK}{RAW_STRING} -STR_NETWORK_CLIENT_LIST_PLAYER_SELF :{WHITE}(you) {BLACK}{RAW_STRING} STR_NETWORK_CLIENT_LIST_ADMIN_CLIENT_TOOLTIP :{BLACK}Administrative actions to perform for this client STR_NETWORK_CLIENT_LIST_ADMIN_COMPANY_TOOLTIP :{BLACK}Administrative actions to perform for this company STR_NETWORK_CLIENT_LIST_JOIN_TOOLTIP :{BLACK}Join this company @@ -2148,6 +2146,8 @@ STR_NETWORK_CLIENT_LIST_CHAT_SPECTATOR_TOOLTIP :{BLACK}Send a m STR_NETWORK_CLIENT_LIST_SPECTATORS :Spectators STR_NETWORK_CLIENT_LIST_NEW_COMPANY :(New company) STR_NETWORK_CLIENT_LIST_NEW_COMPANY_TOOLTIP :{BLACK}Create a new company and join it +STR_NETWORK_CLIENT_LIST_PLAYER_ICON_SELF_TOOLTIP :{BLACK}This is you +STR_NETWORK_CLIENT_LIST_PLAYER_ICON_HOST_TOOLTIP :{BLACK}This is the host of the game STR_NETWORK_CLIENT_LIST_ADMIN_CLIENT_KICK :Kick STR_NETWORK_CLIENT_LIST_ADMIN_CLIENT_BAN :Ban diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index e76500f091d2..68208ee3fc0c 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -1756,6 +1756,8 @@ struct NetworkClientListWindow : Window { uint line_height; ///< Current lineheight of each entry in the matrix. uint line_count; ///< Amount of lines in the matrix. int hover_index; ///< Index of the current line we are hovering over, or -1 if none. + int player_self_index; ///< The line the current player is on. + int player_host_index; ///< The line the host is on. std::map>> buttons; ///< Per line which buttons are available. @@ -1870,7 +1872,7 @@ struct NetworkClientListWindow : Window { { ButtonCommon *chat_button = new CompanyButton(SPR_CHAT, company_id == COMPANY_SPECTATOR ? STR_NETWORK_CLIENT_LIST_CHAT_SPECTATOR_TOOLTIP : STR_NETWORK_CLIENT_LIST_CHAT_COMPANY_TOOLTIP, COLOUR_ORANGE, company_id, &NetworkClientListWindow::OnClickCompanyChat); - if (_network_server) this->buttons[line_count].emplace_back(new CompanyButton(SPR_ADMIN, STR_NETWORK_CLIENT_LIST_ADMIN_COMPANY_TOOLTIP, COLOUR_RED, company_id, &NetworkClientListWindow::OnClickCompanyAdmin)); + if (_network_server) this->buttons[line_count].emplace_back(new CompanyButton(SPR_ADMIN, STR_NETWORK_CLIENT_LIST_ADMIN_COMPANY_TOOLTIP, COLOUR_RED, company_id, &NetworkClientListWindow::OnClickCompanyAdmin, company_id == COMPANY_SPECTATOR)); this->buttons[line_count].emplace_back(chat_button); if (own_ci->client_playas != company_id) this->buttons[line_count].emplace_back(new CompanyButton(SPR_JOIN, STR_NETWORK_CLIENT_LIST_JOIN_TOOLTIP, COLOUR_ORANGE, company_id, &NetworkClientListWindow::OnClickCompanyJoin)); @@ -1884,6 +1886,12 @@ struct NetworkClientListWindow : Window { if (_network_server) this->buttons[line_count].emplace_back(new ClientButton(SPR_ADMIN, STR_NETWORK_CLIENT_LIST_ADMIN_CLIENT_TOOLTIP, COLOUR_RED, ci->client_id, &NetworkClientListWindow::OnClickClientAdmin, _network_own_client_id == ci->client_id)); if (_network_own_client_id != ci->client_id) this->buttons[line_count].emplace_back(new ClientButton(SPR_CHAT, STR_NETWORK_CLIENT_LIST_CHAT_CLIENT_TOOLTIP, COLOUR_ORANGE, ci->client_id, &NetworkClientListWindow::OnClickClientChat)); + if (ci->client_id == _network_own_client_id) { + this->player_self_index = this->line_count; + } else if (ci->client_id == CLIENT_ID_SERVER) { + this->player_host_index = this->line_count; + } + this->line_count += 1; } @@ -1900,6 +1908,8 @@ struct NetworkClientListWindow : Window { this->buttons.clear(); this->line_count = 0; + this->player_host_index = -1; + this->player_self_index = -1; /* As spectator, show a line to create a new company. */ if (own_ci->client_playas == COMPANY_SPECTATOR && !NetworkMaxCompaniesReached()) { @@ -1959,7 +1969,10 @@ struct NetworkClientListWindow : Window { public: NetworkClientListWindow(WindowDesc *desc, WindowNumber window_number) : - Window(desc) + Window(desc), + hover_index(-1), + player_self_index(-1), + player_host_index(-1) { this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_CL_SCROLLBAR); @@ -2057,6 +2070,30 @@ struct NetworkClientListWindow : Window { { switch (widget) { case WID_CL_MATRIX: { + int index = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_CL_MATRIX); + + bool rtl = _current_text_dir == TD_RTL; + NWidgetBase *widget_matrix = this->GetWidget(WID_CL_MATRIX); + + Dimension d = GetSpriteSize(SPR_COMPANY_ICON); + uint text_left = widget_matrix->pos_x + (rtl ? (uint)WD_FRAMERECT_LEFT : d.width + 8); + uint text_right = widget_matrix->pos_x + widget_matrix->current_x - (rtl ? d.width + 8 : (uint)WD_FRAMERECT_RIGHT); + + Dimension d2 = GetSpriteSize(SPR_PLAYER_SELF); + uint offset_x = CLIENT_OFFSET_LEFT - d2.width - 3; + + uint player_icon_x = rtl ? text_right - offset_x - d2.width : text_left + offset_x; + + if (IsInsideMM(pt.x, player_icon_x, player_icon_x + d2.width)) { + if (index == this->player_self_index) { + GuiShowTooltips(this, STR_NETWORK_CLIENT_LIST_PLAYER_ICON_SELF_TOOLTIP, 0, nullptr, close_cond); + return true; + } else if (index == this->player_host_index) { + GuiShowTooltips(this, STR_NETWORK_CLIENT_LIST_PLAYER_ICON_HOST_TOOLTIP, 0, nullptr, close_cond); + return true; + } + } + ButtonCommon *button = this->GetButtonAtPoint(pt); if (button == nullptr) return false; @@ -2267,17 +2304,22 @@ struct NetworkClientListWindow : Window { this->DrawButtons(x, y, button_find->second); } - StringID client_string = STR_JUST_RAW_STRING; - - if (ci->client_id == CLIENT_ID_SERVER) { - client_string = STR_NETWORK_CLIENT_LIST_PLAYER_HOST; - } + SpriteID player_icon = 0; if (ci->client_id == _network_own_client_id) { - client_string = STR_NETWORK_CLIENT_LIST_PLAYER_SELF; + player_icon = SPR_PLAYER_SELF; + } else if (ci->client_id == CLIENT_ID_SERVER) { + player_icon = SPR_PLAYER_HOST; + } + + if (player_icon != 0) { + Dimension d2 = GetSpriteSize(player_icon); + uint offset_x = CLIENT_OFFSET_LEFT - 3; + int offset_y = std::max(0, ((int)(this->line_height + 1) - (int)d2.height) / 2); + DrawSprite(player_icon, PALETTE_TO_GREY, rtl ? text_right - offset_x : text_left + offset_x - d2.width, y + offset_y); } SetDParamStr(0, ci->client_name); - DrawString(rtl ? x : text_left + CLIENT_OFFSET_LEFT, rtl ? text_right - CLIENT_OFFSET_LEFT : x, y + text_y_offset, client_string, TC_BLACK); + DrawString(rtl ? x : text_left + CLIENT_OFFSET_LEFT, rtl ? text_right - CLIENT_OFFSET_LEFT : x, y + text_y_offset, STR_JUST_RAW_STRING, TC_BLACK); } y += this->line_height; diff --git a/src/table/sprites.h b/src/table/sprites.h index 039d50b9deaf..b7bb91020334 100644 --- a/src/table/sprites.h +++ b/src/table/sprites.h @@ -54,7 +54,7 @@ static const SpriteID SPR_LARGE_SMALL_WINDOW = 682; /** Extra graphic spritenumbers */ static const SpriteID SPR_OPENTTD_BASE = 4896; -static const uint16 OPENTTD_SPRITE_COUNT = 189; +static const uint16 OPENTTD_SPRITE_COUNT = 191; /* Halftile-selection sprites */ static const SpriteID SPR_HALFTILE_SELECTION_FLAT = SPR_OPENTTD_BASE; @@ -169,6 +169,8 @@ static const SpriteID SPR_GOTO_LOCATION = SPR_OPENTTD_BASE + 185; static const SpriteID SPR_CHAT = SPR_OPENTTD_BASE + 186; static const SpriteID SPR_ADMIN = SPR_OPENTTD_BASE + 187; static const SpriteID SPR_JOIN = SPR_OPENTTD_BASE + 188; +static const SpriteID SPR_PLAYER_SELF = SPR_OPENTTD_BASE + 189; +static const SpriteID SPR_PLAYER_HOST = SPR_OPENTTD_BASE + 190; static const SpriteID SPR_IMG_CARGOFLOW = SPR_OPENTTD_BASE + 174;