summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-08-23 22:25:50 +0000
committeryexo <yexo@openttd.org>2010-08-23 22:25:50 +0000
commitf6f218cf6b360fa8524f851d2e33aad275f1fe39 (patch)
tree5e736a48b08573c407c783e6121c4fb23432ec47
parentda4dc61f7619da291524c9f1dec6cff220adbdc8 (diff)
downloadopenttd-f6f218cf6b360fa8524f851d2e33aad275f1fe39.tar.xz
(svn r20604) -Feature: add a reset button to the newgrf parameters window
-rw-r--r--src/ai/ai_gui.cpp2
-rw-r--r--src/lang/english.txt2
-rw-r--r--src/newgrf_config.cpp3
-rw-r--r--src/newgrf_gui.cpp10
4 files changed, 15 insertions, 2 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index 91a1fd00c..d52d00f5c 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -203,7 +203,7 @@ static const NWidgetPart _nested_ai_list_widgets[] = {
EndContainer(),
NWidget(WWT_PANEL, COLOUR_MAUVE, AIL_WIDGET_INFO_BG), SetMinimalTextLines(8, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM), SetResize(1, 0),
EndContainer(),
- NWidget(NWID_HORIZONTAL),
+ NWidget(NWID_HORIZONTAL),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, AIL_WIDGET_ACCEPT), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_AI_LIST_ACCEPT, STR_AI_LIST_ACCEPT_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, AIL_WIDGET_CANCEL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_AI_LIST_CANCEL, STR_AI_LIST_CANCEL_TOOLTIP),
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 9ab03877c..63307eed8 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -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}
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index 01521cd54..2d2e6f856 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -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++) {
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index 8bfc02843..bc20c61a4 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -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(WWT_PUSHTXTBTN, COLOUR_MAUVE, GRFPAR_WIDGET_ACCEPT), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_NEWGRF_PARAMETERS_CLOSE, STR_NULL),
+ 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(),
};