Merge branch 'master' into jgrpp

# Conflicts:
#	.github/workflows/release-windows.yml
#	src/autoreplace_gui.cpp
#	src/cargotype.cpp
#	src/company_base.h
#	src/company_cmd.cpp
#	src/company_gui.cpp
#	src/currency.h
#	src/date_gui.cpp
#	src/dropdown.cpp
#	src/dropdown_func.h
#	src/dropdown_type.h
#	src/game/game_gui.cpp
#	src/genworld.cpp
#	src/genworld_gui.cpp
#	src/ground_vehicle.hpp
#	src/group_gui.cpp
#	src/house.h
#	src/industry_gui.cpp
#	src/network/network_client.cpp
#	src/network/network_server.cpp
#	src/network/network_type.h
#	src/newgrf_class_func.h
#	src/newgrf_house.cpp
#	src/newgrf_roadstop.h
#	src/openttd.cpp
#	src/order_gui.cpp
#	src/saveload/saveload.cpp
#	src/saveload/saveload.h
#	src/screenshot_gui.cpp
#	src/settings_gui.cpp
#	src/settings_type.h
#	src/slider.cpp
#	src/smallmap_gui.cpp
#	src/station_cmd.cpp
#	src/stdafx.h
#	src/survey.cpp
#	src/tile_map.h
#	src/town_cmd.cpp
#	src/town_gui.cpp
#	src/vehicle.cpp
#	src/vehicle_gui.cpp
#	src/vehicle_gui_base.h
This commit is contained in:
Jonathan G Rennison
2024-05-28 19:48:40 +01:00
173 changed files with 2504 additions and 1971 deletions

View File

@@ -19,9 +19,9 @@
#include "strings_func.h"
#include "window_func.h"
#include "string_func.h"
#include "widgets/dropdown_type.h"
#include "widgets/dropdown_func.h"
#include "widgets/slider_func.h"
#include "dropdown_type.h"
#include "dropdown_func.h"
#include "slider_func.h"
#include "highscore.h"
#include "base_media_base.h"
#include "company_base.h"
@@ -48,6 +48,7 @@
#include "network/network_survey.h"
#include "video/video_driver.hpp"
#include "social_integration.h"
#include "sound_func.h"
#include <vector>
#include <functional>
@@ -411,7 +412,7 @@ struct GameOptionsWindow : Window {
/* Add non-custom currencies; sorted naturally */
for (const CurrencySpec &currency : _currency_specs) {
int i = &currency - _currency_specs;
int i = &currency - _currency_specs.data();
if (i == CURRENCY_CUSTOM) continue;
if (currency.code.empty()) {
list.push_back(std::make_unique<DropDownListStringItem>(currency.name, i, HasBit(disabled, i)));
@@ -976,13 +977,7 @@ struct GameOptionsWindow : Window {
break;
case WID_GO_BASE_SFX_DROPDOWN:
if (_game_mode == GM_MENU) {
auto set = BaseSounds::GetSet(index);
BaseSounds::ini_set = set->name;
BaseSounds::SetSet(set);
this->reload = true;
this->InvalidateData();
}
ChangeSoundSet(index);
break;
case WID_GO_BASE_MUSIC_DROPDOWN:
@@ -1044,7 +1039,6 @@ struct GameOptionsWindow : Window {
this->SetWidgetLoweredState(WID_GO_GUI_SCALE_MAIN_TOOLBAR, _settings_client.gui.bigger_main_toolbar);
this->SetWidgetDisabledState(WID_GO_BASE_GRF_DROPDOWN, _game_mode != GM_MENU);
this->SetWidgetDisabledState(WID_GO_BASE_SFX_DROPDOWN, _game_mode != GM_MENU);
this->SetWidgetDisabledState(WID_GO_BASE_GRF_PARAMETERS, BaseGraphics::GetUsedSet() == nullptr || !BaseGraphics::GetUsedSet()->IsConfigurable());
@@ -3213,7 +3207,7 @@ struct GameSettingsWindow : Window {
if (this->last_clicked == pe && !sd->IsBoolSetting() && !(sd->flags & (SF_GUI_DROPDOWN | SF_ENUM))) {
int64_t value64 = value;
/* Show the correct currency or velocity translated value */
if (sd->flags & SF_GUI_CURRENCY) value64 *= _currency->rate;
if (sd->flags & SF_GUI_CURRENCY) value64 *= GetCurrency().rate;
if (sd->flags & SF_GUI_VELOCITY) value64 = ConvertKmhishSpeedToDisplaySpeed((uint)value64, VEH_TRAIN);
this->valuewindow_entry = pe;
@@ -3263,7 +3257,7 @@ struct GameSettingsWindow : Window {
}
/* Save the correct currency-translated value */
if (sd->flags & SF_GUI_CURRENCY) llvalue /= _currency->rate;
if (sd->flags & SF_GUI_CURRENCY) llvalue /= GetCurrency().rate;
value = ClampTo<int32_t>(llvalue);
@@ -3520,22 +3514,22 @@ struct CustomCurrencyWindow : Window {
void SetButtonState()
{
this->SetWidgetDisabledState(WID_CC_RATE_DOWN, _custom_currency.rate == 1);
this->SetWidgetDisabledState(WID_CC_RATE_UP, _custom_currency.rate == UINT16_MAX);
this->SetWidgetDisabledState(WID_CC_YEAR_DOWN, _custom_currency.to_euro == CF_NOEURO);
this->SetWidgetDisabledState(WID_CC_YEAR_UP, _custom_currency.to_euro == CalTime::MAX_YEAR);
this->SetWidgetDisabledState(WID_CC_RATE_DOWN, GetCustomCurrency().rate == 1);
this->SetWidgetDisabledState(WID_CC_RATE_UP, GetCustomCurrency().rate == UINT16_MAX);
this->SetWidgetDisabledState(WID_CC_YEAR_DOWN, GetCustomCurrency().to_euro == CF_NOEURO);
this->SetWidgetDisabledState(WID_CC_YEAR_UP, GetCustomCurrency().to_euro == CalTime::MAX_YEAR);
}
void SetStringParameters(WidgetID widget) const override
{
switch (widget) {
case WID_CC_RATE: SetDParam(0, 1); SetDParam(1, 1); break;
case WID_CC_SEPARATOR: SetDParamStr(0, _custom_currency.separator); break;
case WID_CC_PREFIX: SetDParamStr(0, _custom_currency.prefix); break;
case WID_CC_SUFFIX: SetDParamStr(0, _custom_currency.suffix); break;
case WID_CC_SEPARATOR: SetDParamStr(0, GetCustomCurrency().separator); break;
case WID_CC_PREFIX: SetDParamStr(0, GetCustomCurrency().prefix); break;
case WID_CC_SUFFIX: SetDParamStr(0, GetCustomCurrency().suffix); break;
case WID_CC_YEAR:
SetDParam(0, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER);
SetDParam(1, _custom_currency.to_euro);
SetDParam(0, (GetCustomCurrency().to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER);
SetDParam(1, GetCustomCurrency().to_euro);
break;
case WID_CC_PREVIEW:
@@ -3580,19 +3574,19 @@ struct CustomCurrencyWindow : Window {
switch (widget) {
case WID_CC_RATE_DOWN:
if (_custom_currency.rate > 1) _custom_currency.rate--;
if (_custom_currency.rate == 1) this->DisableWidget(WID_CC_RATE_DOWN);
if (GetCustomCurrency().rate > 1) GetCustomCurrency().rate--;
if (GetCustomCurrency().rate == 1) this->DisableWidget(WID_CC_RATE_DOWN);
this->EnableWidget(WID_CC_RATE_UP);
break;
case WID_CC_RATE_UP:
if (_custom_currency.rate < UINT16_MAX) _custom_currency.rate++;
if (_custom_currency.rate == UINT16_MAX) this->DisableWidget(WID_CC_RATE_UP);
if (GetCustomCurrency().rate < UINT16_MAX) GetCustomCurrency().rate++;
if (GetCustomCurrency().rate == UINT16_MAX) this->DisableWidget(WID_CC_RATE_UP);
this->EnableWidget(WID_CC_RATE_DOWN);
break;
case WID_CC_RATE:
SetDParam(0, _custom_currency.rate);
SetDParam(0, GetCustomCurrency().rate);
str = STR_JUST_INT;
len = 5;
line = WID_CC_RATE;
@@ -3601,7 +3595,7 @@ struct CustomCurrencyWindow : Window {
case WID_CC_SEPARATOR_EDIT:
case WID_CC_SEPARATOR:
SetDParamStr(0, _custom_currency.separator);
SetDParamStr(0, GetCustomCurrency().separator);
str = STR_JUST_RAW_STRING;
len = 7;
line = WID_CC_SEPARATOR;
@@ -3609,7 +3603,7 @@ struct CustomCurrencyWindow : Window {
case WID_CC_PREFIX_EDIT:
case WID_CC_PREFIX:
SetDParamStr(0, _custom_currency.prefix);
SetDParamStr(0, GetCustomCurrency().prefix);
str = STR_JUST_RAW_STRING;
len = 15;
line = WID_CC_PREFIX;
@@ -3617,26 +3611,26 @@ struct CustomCurrencyWindow : Window {
case WID_CC_SUFFIX_EDIT:
case WID_CC_SUFFIX:
SetDParamStr(0, _custom_currency.suffix);
SetDParamStr(0, GetCustomCurrency().suffix);
str = STR_JUST_RAW_STRING;
len = 15;
line = WID_CC_SUFFIX;
break;
case WID_CC_YEAR_DOWN:
_custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ? CF_NOEURO : _custom_currency.to_euro - 1;
if (_custom_currency.to_euro == CF_NOEURO) this->DisableWidget(WID_CC_YEAR_DOWN);
GetCustomCurrency().to_euro = (GetCustomCurrency().to_euro <= 2000) ? CF_NOEURO : GetCustomCurrency().to_euro - 1;
if (GetCustomCurrency().to_euro == CF_NOEURO) this->DisableWidget(WID_CC_YEAR_DOWN);
this->EnableWidget(WID_CC_YEAR_UP);
break;
case WID_CC_YEAR_UP:
_custom_currency.to_euro = Clamp<CalTime::Year>(_custom_currency.to_euro + 1, 2000, CalTime::MAX_YEAR);
if (_custom_currency.to_euro == CalTime::MAX_YEAR) this->DisableWidget(WID_CC_YEAR_UP);
GetCustomCurrency().to_euro = Clamp<CalTime::Year>(GetCustomCurrency().to_euro + 1, 2000, CalTime::MAX_YEAR);
if (GetCustomCurrency().to_euro == CalTime::MAX_YEAR) this->DisableWidget(WID_CC_YEAR_UP);
this->EnableWidget(WID_CC_YEAR_DOWN);
break;
case WID_CC_YEAR:
SetDParam(0, _custom_currency.to_euro);
SetDParam(0, GetCustomCurrency().to_euro);
str = STR_JUST_INT;
len = 7;
line = WID_CC_YEAR;
@@ -3659,25 +3653,25 @@ struct CustomCurrencyWindow : Window {
switch (this->query_widget) {
case WID_CC_RATE:
_custom_currency.rate = Clamp(atoi(str), 1, UINT16_MAX);
GetCustomCurrency().rate = Clamp(atoi(str), 1, UINT16_MAX);
break;
case WID_CC_SEPARATOR: // Thousands separator
_custom_currency.separator = str;
GetCustomCurrency().separator = str;
break;
case WID_CC_PREFIX:
_custom_currency.prefix = str;
GetCustomCurrency().prefix = str;
break;
case WID_CC_SUFFIX:
_custom_currency.suffix = str;
GetCustomCurrency().suffix = str;
break;
case WID_CC_YEAR: { // Year to switch to euro
int val = atoi(str);
_custom_currency.to_euro = (val < 2000 ? CF_NOEURO : std::min<CalTime::Year>(val, CalTime::MAX_YEAR));
GetCustomCurrency().to_euro = (val < 2000 ? CF_NOEURO : std::min<CalTime::Year>(val, CalTime::MAX_YEAR));
break;
}
}