Merge branch 'master' into jgrpp

# Conflicts:
#	src/station_cmd.cpp
#	src/vehicle_gui.cpp
This commit is contained in:
Jonathan G Rennison
2022-09-21 18:07:02 +01:00
8 changed files with 35 additions and 29 deletions

View File

@@ -583,8 +583,8 @@ Company *DoStartupNewCompany(DoStartupNewCompanyFlag flags, CompanyID company)
c->inaugurated_year = _cur_year; c->inaugurated_year = _cur_year;
/* If starting a player company in singleplayer and a favorite company manager face is selected, choose it. Otherwise, use a random face. /* If starting a player company in singleplayer and a favorite company manager face is selected, choose it. Otherwise, use a random face.
* In a network game, we'll choose the favorite face later in CmdCompanyCtrl to sync it to all clients. */ * In a network game, we'll choose the favorite face later in CmdCompanyCtrl to sync it to all clients, but we choose it here for the first (host) company. */
if (_company_manager_face != 0 && !is_ai && !_networking) { if (_company_manager_face != 0 && !is_ai) {
c->face = _company_manager_face; c->face = _company_manager_face;
} else { } else {
RandomCompanyManagerFaceBits(c->face, (GenderEthnicity)Random(), false, false); RandomCompanyManagerFaceBits(c->face, (GenderEthnicity)Random(), false, false);

View File

@@ -212,9 +212,11 @@ static void DrawCategories(const Rect &r)
static void DrawPrice(Money amount, int left, int right, int top, TextColour colour) static void DrawPrice(Money amount, int left, int right, int top, TextColour colour)
{ {
StringID str = STR_FINANCES_NEGATIVE_INCOME; StringID str = STR_FINANCES_NEGATIVE_INCOME;
if (amount < 0) { if (amount == 0) {
str = STR_FINANCES_ZERO_INCOME;
} else if (amount < 0) {
amount = -amount; amount = -amount;
str++; str = STR_FINANCES_POSITIVE_INCOME;
} }
SetDParam(0, amount); SetDParam(0, amount);
DrawString(left, right, top, str, colour, SA_RIGHT); DrawString(left, right, top, str, colour, SA_RIGHT);

View File

@@ -4736,6 +4736,7 @@ STR_FINANCES_SECTION_INFRASTRUCTURE_COSTS :{GOLD}Infrastru
STR_FINANCES_SECTION_INFRASTRUCTURE_INCOME :{GOLD}Infrastructure Sharing STR_FINANCES_SECTION_INFRASTRUCTURE_INCOME :{GOLD}Infrastructure Sharing
STR_FINANCES_NEGATIVE_INCOME :-{CURRENCY_LONG} STR_FINANCES_NEGATIVE_INCOME :-{CURRENCY_LONG}
STR_FINANCES_ZERO_INCOME :{CURRENCY_LONG}
STR_FINANCES_POSITIVE_INCOME :+{CURRENCY_LONG} STR_FINANCES_POSITIVE_INCOME :+{CURRENCY_LONG}
STR_FINANCES_NET_PROFIT :{WHITE}Net Profit STR_FINANCES_NET_PROFIT :{WHITE}Net Profit
STR_FINANCES_BANK_BALANCE_TITLE :{WHITE}Bank Balance STR_FINANCES_BANK_BALANCE_TITLE :{WHITE}Bank Balance

View File

@@ -127,11 +127,11 @@ void MusicSystem::BuildPlaylists()
/* Load custom playlists /* Load custom playlists
* Song index offsets are 1-based, zero indicates invalid/end-of-list value */ * Song index offsets are 1-based, zero indicates invalid/end-of-list value */
for (uint i = 0; i < NUM_SONGS_PLAYLIST; i++) { for (uint i = 0; i < NUM_SONGS_PLAYLIST; i++) {
if (_settings_client.music.custom_1[i] > 0) { if (_settings_client.music.custom_1[i] > 0 && _settings_client.music.custom_1[i] <= NUM_SONGS_AVAILABLE) {
PlaylistEntry entry(set, _settings_client.music.custom_1[i] - 1); PlaylistEntry entry(set, _settings_client.music.custom_1[i] - 1);
if (entry.IsValid()) this->standard_playlists[PLCH_CUSTOM1].push_back(entry); if (entry.IsValid()) this->standard_playlists[PLCH_CUSTOM1].push_back(entry);
} }
if (_settings_client.music.custom_2[i] > 0) { if (_settings_client.music.custom_2[i] > 0 && _settings_client.music.custom_2[i] <= NUM_SONGS_AVAILABLE) {
PlaylistEntry entry(set, _settings_client.music.custom_2[i] - 1); PlaylistEntry entry(set, _settings_client.music.custom_2[i] - 1);
if (entry.IsValid()) this->standard_playlists[PLCH_CUSTOM2].push_back(entry); if (entry.IsValid()) this->standard_playlists[PLCH_CUSTOM2].push_back(entry);
} }

View File

@@ -1350,15 +1350,17 @@ static const NWidgetPart _nested_client_list_widgets[] = {
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_CL_CLIENT_NAME_EDIT), SetMinimalSize(12, 14), SetDataTip(SPR_RENAME, STR_NETWORK_CLIENT_LIST_PLAYER_NAME_EDIT_TOOLTIP), NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_CL_CLIENT_NAME_EDIT), SetMinimalSize(12, 14), SetDataTip(SPR_RENAME, STR_NETWORK_CLIENT_LIST_PLAYER_NAME_EDIT_TOOLTIP),
EndContainer(), EndContainer(),
EndContainer(), EndContainer(),
NWidget(NWID_HORIZONTAL), EndContainer(),
NWidget(NWID_VERTICAL), NWidget(NWID_HORIZONTAL),
NWidget(WWT_MATRIX, COLOUR_GREY, WID_CL_MATRIX), SetMinimalSize(180, 0), SetResize(1, 1), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_NULL), SetScrollbar(WID_CL_SCROLLBAR), NWidget(NWID_VERTICAL),
NWidget(WWT_MATRIX, COLOUR_GREY, WID_CL_MATRIX), SetMinimalSize(180, 0), SetResize(1, 1), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_NULL), SetScrollbar(WID_CL_SCROLLBAR),
NWidget(WWT_PANEL, COLOUR_GREY),
NWidget(WWT_TEXT, COLOUR_GREY, WID_CL_CLIENT_COMPANY_COUNT), SetFill(1, 0), SetMinimalTextLines(1, 0), SetResize(1, 0), SetPadding(2, 1, 2, 1), SetAlignment(SA_CENTER), SetDataTip(STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT, STR_NULL), NWidget(WWT_TEXT, COLOUR_GREY, WID_CL_CLIENT_COMPANY_COUNT), SetFill(1, 0), SetMinimalTextLines(1, 0), SetResize(1, 0), SetPadding(2, 1, 2, 1), SetAlignment(SA_CENTER), SetDataTip(STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT, STR_NULL),
EndContainer(), EndContainer(),
NWidget(NWID_VERTICAL), EndContainer(),
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_CL_SCROLLBAR), NWidget(NWID_VERTICAL),
NWidget(WWT_RESIZEBOX, COLOUR_GREY), NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_CL_SCROLLBAR),
EndContainer(), NWidget(WWT_RESIZEBOX, COLOUR_GREY),
EndContainer(), EndContainer(),
EndContainer(), EndContainer(),
}; };
@@ -2129,21 +2131,19 @@ public:
} }
} }
virtual void OnMouseLoop() override void OnMouseOver(Point pt, int widget) override
{ {
if (GetWidgetFromPos(this, _cursor.pos.x - this->left, _cursor.pos.y - this->top) != WID_CL_MATRIX) { if (widget != WID_CL_MATRIX) {
this->hover_index = -1; if (this->hover_index != -1) {
this->SetDirty(); this->hover_index = -1;
return; this->SetWidgetDirty(WID_CL_MATRIX);
} }
} else {
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_CL_MATRIX); int index = this->GetRowFromWidget(pt.y, widget, 0, -1);
int y = _cursor.pos.y - this->top - nwi->pos_y - 2; if (index != this->hover_index) {
int index = y / this->line_height; this->hover_index = index;
this->SetWidgetDirty(WID_CL_MATRIX);
if (index != this->hover_index) { }
this->hover_index = index;
this->SetDirty();
} }
} }
}; };

View File

@@ -498,7 +498,7 @@ void Station::UpdateVirtCoord()
SetDParam(0, this->index); SetDParam(0, this->index);
SetDParam(1, this->facilities); SetDParam(1, this->facilities);
this->sign.UpdatePosition(ShouldShowBaseStationViewportLabel(this) ? ZOOM_LVL_DRAW_SPR : ZOOM_LVL_END, pt.x, pt.y, STR_VIEWPORT_STATION); this->sign.UpdatePosition(ShouldShowBaseStationViewportLabel(this) ? ZOOM_LVL_DRAW_SPR : ZOOM_LVL_END, pt.x, pt.y, STR_VIEWPORT_STATION, STR_VIEWPORT_STATION_TINY);
if (_viewport_sign_kdtree_valid) _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeStation(this->index)); if (_viewport_sign_kdtree_valid) _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeStation(this->index));

View File

@@ -3651,6 +3651,9 @@ public:
if (v->type == VEH_TRAIN) { if (v->type == VEH_TRAIN) {
this->SetWidgetLoweredState(WID_VV_FORCE_PROCEED, Train::From(v)->force_proceed == TFP_SIGNAL); this->SetWidgetLoweredState(WID_VV_FORCE_PROCEED, Train::From(v)->force_proceed == TFP_SIGNAL);
this->SetWidgetDisabledState(WID_VV_FORCE_PROCEED, !can_control); this->SetWidgetDisabledState(WID_VV_FORCE_PROCEED, !can_control);
}
if (v->type == VEH_TRAIN || v->type == VEH_ROAD) {
this->SetWidgetDisabledState(WID_VV_TURN_AROUND, !can_control); this->SetWidgetDisabledState(WID_VV_TURN_AROUND, !can_control);
} }

View File

@@ -43,7 +43,7 @@ void Waypoint::UpdateVirtCoord()
if (_viewport_sign_kdtree_valid && this->sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeWaypoint(this->index)); if (_viewport_sign_kdtree_valid && this->sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeWaypoint(this->index));
SetDParam(0, this->index); SetDParam(0, this->index);
this->sign.UpdatePosition(ShouldShowBaseStationViewportLabel(this) ? ZOOM_LVL_DRAW_SPR : ZOOM_LVL_END, pt.x, pt.y - 32 * ZOOM_LVL_BASE, STR_VIEWPORT_WAYPOINT); this->sign.UpdatePosition(ShouldShowBaseStationViewportLabel(this) ? ZOOM_LVL_DRAW_SPR : ZOOM_LVL_END, pt.x, pt.y - 32 * ZOOM_LVL_BASE, STR_VIEWPORT_WAYPOINT, STR_VIEWPORT_WAYPOINT_TINY);
if (_viewport_sign_kdtree_valid) _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeWaypoint(this->index)); if (_viewport_sign_kdtree_valid) _viewport_sign_kdtree.Insert(ViewportSignKdtreeItem::MakeWaypoint(this->index));