mirror of https://github.com/OpenTTD/OpenTTD
(svn r20604) -Feature: add a reset button to the newgrf parameters window
parent
da4dc61f76
commit
f6f218cf6b
|
@ -2398,6 +2398,8 @@ STR_NEWGRF_SETTINGS_PARAMETER_QUERY :{BLACK}Enter Ne
|
|||
# NewGRF parameters window
|
||||
STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Change NewGRF parameters
|
||||
STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Close
|
||||
STR_NEWGRF_PARAMETERS_RESET :{BLACK}Reset
|
||||
STR_NEWGRF_PARAMETERS_RESET_TOOLTIP :{BLACK}Set all parameters to their default value
|
||||
STR_NEWGRF_PARAMETERS_DEFAULT_NAME :Parameter {NUM}
|
||||
STR_NEWGRF_PARAMETERS_SETTING :{STRING1}: {ORANGE}{STRING1}
|
||||
|
||||
|
|
|
@ -101,6 +101,9 @@ const char *GRFConfig::GetDescription() const
|
|||
/** Set the default value for all parameters as specified by action14. */
|
||||
void GRFConfig::SetParameterDefaults()
|
||||
{
|
||||
this->num_params = 0;
|
||||
MemSetT<uint32>(this->param, 0, lengthof(this->param));
|
||||
|
||||
if (!this->has_param_defaults) return;
|
||||
|
||||
for (uint i = 0; i < this->param_info.Length(); i++) {
|
||||
|
|
|
@ -128,6 +128,7 @@ enum ShowNewGRFParametersWidgets {
|
|||
GRFPAR_WIDGET_BACKGROUND, ///< Panel to draw the settings on
|
||||
GRFPAR_WIDGET_SCROLLBAR, ///< Scrollbar to scroll through all settings
|
||||
GRFPAR_WIDGET_ACCEPT, ///< Accept button
|
||||
GRFPAR_WIDGET_RESET, ///< Reset button
|
||||
GRFPAR_WIDGET_DESCRIPTION, ///< Multi-line description of a parameter
|
||||
};
|
||||
|
||||
|
@ -293,6 +294,10 @@ struct NewGRFParametersWindow : public Window {
|
|||
break;
|
||||
}
|
||||
|
||||
case GRFPAR_WIDGET_RESET:
|
||||
this->grf_config->SetParameterDefaults();
|
||||
break;
|
||||
|
||||
case GRFPAR_WIDGET_ACCEPT:
|
||||
delete this;
|
||||
break;
|
||||
|
@ -340,7 +345,10 @@ static const NWidgetPart _nested_newgrf_parameter_widgets[] = {
|
|||
NWidget(WWT_PANEL, COLOUR_MAUVE, GRFPAR_WIDGET_DESCRIPTION), SetResize(1, 0), SetFill(1, 0),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, GRFPAR_WIDGET_ACCEPT), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NEWGRF_PARAMETERS_CLOSE, STR_NULL),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, GRFPAR_WIDGET_RESET), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NEWGRF_PARAMETERS_RESET, STR_NEWGRF_PARAMETERS_RESET_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
|
||||
EndContainer(),
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue