mirror of https://github.com/OpenTTD/OpenTTD
Change: Remove Apply button from NewGRF config window when unneeded. (#14254)
When configuring NewGRFs outside of a game, the changes are always applied when the window is closed, even if the Apply button is not used. The Apply button only needs appear during a game when changes are not automatically applied.pull/14235/head
parent
d107b7c8c0
commit
d37d4c18b5
|
@ -636,7 +636,8 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||||
this->vscroll2 = this->GetScrollbar(WID_NS_SCROLL2BAR);
|
this->vscroll2 = this->GetScrollbar(WID_NS_SCROLL2BAR);
|
||||||
|
|
||||||
this->GetWidget<NWidgetStacked>(WID_NS_SHOW_REMOVE)->SetDisplayedPlane(this->editable ? 0 : 1);
|
this->GetWidget<NWidgetStacked>(WID_NS_SHOW_REMOVE)->SetDisplayedPlane(this->editable ? 0 : 1);
|
||||||
this->GetWidget<NWidgetStacked>(WID_NS_SHOW_APPLY)->SetDisplayedPlane(this->editable ? 0 : this->show_params ? 1 : SZSP_HORIZONTAL);
|
this->GetWidget<NWidgetStacked>(WID_NS_SHOW_EDIT)->SetDisplayedPlane(this->editable ? 0 : (this->show_params ? 1 : SZSP_HORIZONTAL));
|
||||||
|
this->GetWidget<NWidgetStacked>(WID_NS_SHOW_APPLY)->SetDisplayedPlane(this->editable && this->execute ? 0 : SZSP_VERTICAL);
|
||||||
this->FinishInitNested(WN_GAME_OPTIONS_NEWGRF_STATE);
|
this->FinishInitNested(WN_GAME_OPTIONS_NEWGRF_STATE);
|
||||||
|
|
||||||
this->querystrings[WID_NS_FILTER] = &this->filter_editbox;
|
this->querystrings[WID_NS_FILTER] = &this->filter_editbox;
|
||||||
|
@ -1080,19 +1081,14 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||||
|
|
||||||
case WID_NS_APPLY_CHANGES: // Apply changes made to GRF list
|
case WID_NS_APPLY_CHANGES: // Apply changes made to GRF list
|
||||||
if (!this->editable) break;
|
if (!this->editable) break;
|
||||||
if (this->execute) {
|
|
||||||
ShowQuery(
|
ShowQuery(
|
||||||
GetEncodedString(STR_NEWGRF_POPUP_CAUTION_CAPTION),
|
GetEncodedString(STR_NEWGRF_POPUP_CAUTION_CAPTION),
|
||||||
GetEncodedString(STR_NEWGRF_CONFIRMATION_TEXT),
|
GetEncodedString(STR_NEWGRF_CONFIRMATION_TEXT),
|
||||||
this,
|
this,
|
||||||
NewGRFConfirmationCallback
|
NewGRFConfirmationCallback
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
CopyGRFConfigList(this->orig_list, this->actives, true);
|
|
||||||
ResetGRFConfig(false);
|
|
||||||
ReloadNewGRFData();
|
|
||||||
this->InvalidateData(GOID_NEWGRF_CHANGES_APPLIED);
|
|
||||||
}
|
|
||||||
this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window
|
this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1233,11 +1229,6 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||||
this->modified = true;
|
this->modified = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GOID_NEWGRF_CHANGES_APPLIED:
|
|
||||||
/* No changes have been made to the list of active NewGRFs since the last time the changes got applied */
|
|
||||||
this->modified = false;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->BuildAvailables();
|
this->BuildAvailables();
|
||||||
|
@ -1861,7 +1852,7 @@ static constexpr NWidgetPart _nested_newgrf_infopanel_widgets[] = {
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
|
||||||
/* Right side, config buttons. */
|
/* Right side, config buttons. */
|
||||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NS_SHOW_APPLY),
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NS_SHOW_EDIT),
|
||||||
NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
|
NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
|
||||||
NWidget(NWID_VERTICAL),
|
NWidget(NWID_VERTICAL),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_SET_PARAMETERS), SetFill(1, 0), SetResize(1, 0),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_SET_PARAMETERS), SetFill(1, 0), SetResize(1, 0),
|
||||||
|
@ -1869,9 +1860,11 @@ static constexpr NWidgetPart _nested_newgrf_infopanel_widgets[] = {
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_TOGGLE_PALETTE), SetFill(1, 0), SetResize(1, 0),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_TOGGLE_PALETTE), SetFill(1, 0), SetResize(1, 0),
|
||||||
SetStringTip(STR_NEWGRF_SETTINGS_TOGGLE_PALETTE, STR_NEWGRF_SETTINGS_TOGGLE_PALETTE_TOOLTIP),
|
SetStringTip(STR_NEWGRF_SETTINGS_TOGGLE_PALETTE, STR_NEWGRF_SETTINGS_TOGGLE_PALETTE_TOOLTIP),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_NS_SHOW_APPLY),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_APPLY_CHANGES), SetFill(1, 0), SetResize(1, 0),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_APPLY_CHANGES), SetFill(1, 0), SetResize(1, 0),
|
||||||
SetStringTip(STR_NEWGRF_SETTINGS_APPLY_CHANGES),
|
SetStringTip(STR_NEWGRF_SETTINGS_APPLY_CHANGES),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
EndContainer(),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_VIEW_PARAMETERS), SetFill(1, 0), SetResize(1, 0),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_NS_VIEW_PARAMETERS), SetFill(1, 0), SetResize(1, 0),
|
||||||
SetStringTip(STR_NEWGRF_SETTINGS_SHOW_PARAMETERS),
|
SetStringTip(STR_NEWGRF_SETTINGS_SHOW_PARAMETERS),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
|
|
@ -58,7 +58,8 @@ enum NewGRFStateWidgets : WidgetID {
|
||||||
WID_NS_CONTENT_DOWNLOAD, ///< Open content download (available NewGRFs).
|
WID_NS_CONTENT_DOWNLOAD, ///< Open content download (available NewGRFs).
|
||||||
WID_NS_CONTENT_DOWNLOAD2, ///< Open content download (active NewGRFs).
|
WID_NS_CONTENT_DOWNLOAD2, ///< Open content download (active NewGRFs).
|
||||||
WID_NS_SHOW_REMOVE, ///< Select active list buttons (0 = normal, 1 = simple layout).
|
WID_NS_SHOW_REMOVE, ///< Select active list buttons (0 = normal, 1 = simple layout).
|
||||||
WID_NS_SHOW_APPLY, ///< Select display of the buttons below the 'details'.
|
WID_NS_SHOW_EDIT, ///< Select display of the buttons below the 'details'.
|
||||||
|
WID_NS_SHOW_APPLY, ///< Select display of the apply button.
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Widgets of the #SavePresetWindow class. */
|
/** Widgets of the #SavePresetWindow class. */
|
||||||
|
|
|
@ -733,7 +733,6 @@ enum GameOptionsInvalidationData : uint8_t {
|
||||||
GOID_NEWGRF_CURRENT_LOADED, ///< The current list of active NewGRF has been loaded.
|
GOID_NEWGRF_CURRENT_LOADED, ///< The current list of active NewGRF has been loaded.
|
||||||
GOID_NEWGRF_LIST_EDITED, ///< List of active NewGRFs is being edited.
|
GOID_NEWGRF_LIST_EDITED, ///< List of active NewGRFs is being edited.
|
||||||
GOID_NEWGRF_CHANGES_MADE, ///< Changes have been made to a given NewGRF either through the palette or its parameters.
|
GOID_NEWGRF_CHANGES_MADE, ///< Changes have been made to a given NewGRF either through the palette or its parameters.
|
||||||
GOID_NEWGRF_CHANGES_APPLIED, ///< The active NewGRF list changes have been applied.
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Window;
|
struct Window;
|
||||||
|
|
Loading…
Reference in New Issue