1
0
Fork 0

Compare commits

...

4 Commits

Author SHA1 Message Date
SamuXarick 43118e8e25
Merge 3c56c0fe2e into b8e56cd05d 2025-07-19 04:45:23 +00:00
translators b8e56cd05d Update: Translations from eints
chinese (traditional): 3 changes by KogentaSan
chinese (simplified): 1 change by ahyangyi
2025-07-19 04:43:14 +00:00
Peter Nelson df5237e721
Fix: Vehicle liveries did not update when switching company. (#14456)
Vehicle liveries must be refreshed if "Show vehicle-type specific liveries" is set to "Own company".
2025-07-18 23:43:07 +00:00
SamuXarick 3c56c0fe2e Add: [Script] Default button in query string to reset an integer setting 2025-06-08 23:15:20 +01:00
7 changed files with 59 additions and 11 deletions

View File

@ -141,6 +141,8 @@ void SetLocalCompany(CompanyID new_company)
MarkWholeScreenDirty();
InvalidateWindowClassesData(WC_SIGN_LIST, -1);
InvalidateWindowClassesData(WC_GOALS_LIST);
InvalidateWindowClassesData(WC_COMPANY_COLOUR, -1);
ResetVehicleColourMap();
}
/**

View File

@ -325,7 +325,7 @@ struct GSConfigWindow : public Window {
}
} else if (!bool_item && !config_item.complete_labels) {
/* Display a query box so users can enter a custom value. */
ShowQueryString(GetString(STR_JUST_INT, old_val), STR_CONFIG_SETTING_QUERY_CAPTION, INT32_DIGITS_WITH_SIGN_AND_TERMINATION, this, CS_NUMERAL_SIGNED, {});
ShowQueryString(GetString(STR_JUST_INT, old_val), STR_CONFIG_SETTING_QUERY_CAPTION, INT32_DIGITS_WITH_SIGN_AND_TERMINATION, this, CS_NUMERAL_SIGNED, QueryStringFlag::EnableDefault);
}
this->SetDirty();
break;
@ -347,10 +347,17 @@ struct GSConfigWindow : public Window {
void OnQueryTextFinished(std::optional<std::string> str) override
{
/* The user pressed cancel */
if (!str.has_value()) return;
auto value = ParseInteger<int32_t>(*str, 10, true);
if (!value.has_value()) return;
this->SetValue(*value);
if (!str->empty()) {
auto value = ParseInteger<int32_t>(*str, 10, true);
if (!value.has_value()) return;
this->SetValue(*value);
} else {
this->SetDefaultValue();
}
}
void OnDropdownSelect(WidgetID widget, int index, int) override
@ -419,6 +426,14 @@ private:
this->gs_config->SetSetting(config_item.name, value);
this->SetDirty();
}
void SetDefaultValue()
{
const ScriptConfigItem &config_item = *this->visible_settings[this->clicked_row];
if (_game_mode == GM_NORMAL && !config_item.flags.Test(ScriptConfigFlag::InGame)) return;
this->gs_config->ResetSetting(config_item.name);
this->SetDirty();
}
};
/** Open the GS config window. */

View File

@ -5001,6 +5001,7 @@ STR_ERROR_FLAT_LAND_REQUIRED :{WHITE}需要
STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION :{WHITE}土地倾斜的方向不对
STR_ERROR_CAN_T_DO_THIS :{WHITE}不能这样做……
STR_ERROR_BUILDING_MUST_BE_DEMOLISHED :{WHITE}必须先摧毁建筑
STR_ERROR_BUILDING_IS_PROTECTED :{WHITE}……建筑物被保护
STR_ERROR_CAN_T_CLEAR_THIS_AREA :{WHITE}无法清除这个区域……
STR_ERROR_SITE_UNSUITABLE :{WHITE}……地点不合适
STR_ERROR_ALREADY_BUILT :{WHITE}……已经建成

View File

@ -1356,8 +1356,8 @@ STR_CONFIG_SETTING_AUTOSLOPE_HELPTEXT :可以在建築
STR_CONFIG_SETTING_CATCHMENT :容許更真實的服務範圍設定:{STRING}
STR_CONFIG_SETTING_CATCHMENT_HELPTEXT :使車站和機場的服務範圍根據其種類和大小而改變。
STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES :公司車站可以為自帶車站的工業設施提供服務{STRING}
STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES_HELPTEXT :啟用後,公司車站可以為附近自帶車站的工業設施(如油井)提供服務。禁用後,這些工業設施只能由其自帶的車站提供服務,並且這些車站不會提供除了該工業設施以外的產品
STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES :公司車站可以服務附設車站的工業設施{STRING}
STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES_HELPTEXT :啟用後,公司車站可以為附近附設車站的工業(如鑽油平台)提供服務。停用後,這些工業只能由其附設的車站提供服務,並且附設車站不會提供除了該工業設施以外的任何服務
STR_CONFIG_SETTING_EXTRADYNAMITE :允許移除更多市鎮擁有的道路、橋樑及隧道:{STRING}
STR_CONFIG_SETTING_EXTRADYNAMITE_HELPTEXT :使玩家更容易地移除市鎮擁有的基礎建設和建築物。
@ -5001,7 +5001,7 @@ STR_ERROR_FLAT_LAND_REQUIRED :{WHITE}需要
STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION :{WHITE}地面斜坡方向不對
STR_ERROR_CAN_T_DO_THIS :{WHITE}不能執行以下動作...
STR_ERROR_BUILDING_MUST_BE_DEMOLISHED :{WHITE}必須先摧毀建築物
STR_ERROR_BUILDING_IS_PROTECTED :{WHITE}……建築物受到保護
STR_ERROR_BUILDING_IS_PROTECTED :{WHITE}……建築物保護
STR_ERROR_CAN_T_CLEAR_THIS_AREA :{WHITE}不能清除這個地段...
STR_ERROR_SITE_UNSUITABLE :{WHITE}... 地點不適合
STR_ERROR_ALREADY_BUILT :{WHITE}……經已建成

View File

@ -106,6 +106,16 @@ void ScriptConfig::ResetSettings()
this->settings.clear();
}
void ScriptConfig::ResetSetting(std::string_view name)
{
if (this->info == nullptr) return;
const ScriptConfigItem *config_item = this->info->GetConfigItem(name);
if (config_item == nullptr) return;
this->settings.erase(std::string{name});
}
void ScriptConfig::ResetEditableSettings(bool yet_to_start)
{
if (this->info == nullptr) return ResetSettings();

View File

@ -129,6 +129,11 @@ public:
*/
void ResetSettings();
/**
* Reset a setting to its default value.
*/
void ResetSetting(std::string_view name);
/**
* Reset only editable and visible settings to their default value.
*/

View File

@ -470,7 +470,7 @@ struct ScriptSettingsWindow : public Window {
}
} else if (!bool_item && !config_item.complete_labels) {
/* Display a query box so users can enter a custom value. */
ShowQueryString(GetString(STR_JUST_INT, old_val), STR_CONFIG_SETTING_QUERY_CAPTION, INT32_DIGITS_WITH_SIGN_AND_TERMINATION, this, CS_NUMERAL_SIGNED, {});
ShowQueryString(GetString(STR_JUST_INT, old_val), STR_CONFIG_SETTING_QUERY_CAPTION, INT32_DIGITS_WITH_SIGN_AND_TERMINATION, this, CS_NUMERAL_SIGNED, QueryStringFlag::EnableDefault);
}
this->SetDirty();
break;
@ -485,10 +485,17 @@ struct ScriptSettingsWindow : public Window {
void OnQueryTextFinished(std::optional<std::string> str) override
{
/* The user pressed cancel */
if (!str.has_value()) return;
auto value = ParseInteger<int32_t>(*str, 10, true);
if (!value.has_value()) return;
this->SetValue(*value);
if (!str->empty()) {
auto value = ParseInteger<int32_t>(*str, 10, true);
if (!value.has_value()) return;
this->SetValue(*value);
} else {
this->SetDefaultValue();
}
}
void OnDropdownSelect(WidgetID widget, int index, int) override
@ -552,6 +559,14 @@ private:
this->script_config->SetSetting(config_item.name, value);
this->SetDirty();
}
void SetDefaultValue()
{
const ScriptConfigItem &config_item = *this->visible_settings[this->clicked_row];
if (_game_mode == GM_NORMAL && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && !config_item.flags.Test(ScriptConfigFlag::InGame)) return;
this->script_config->ResetSetting(config_item.name);
this->SetDirty();
}
};
/** Widgets for the Script settings window. */