Merge branch 'master' into jgrpp
# Conflicts: # .github/workflows/release.yml # bin/CMakeLists.txt # src/dock_gui.cpp # src/lang/brazilian_portuguese.txt # src/lang/catalan.txt # src/lang/czech.txt # src/lang/dutch.txt # src/lang/english.txt # src/lang/english_US.txt # src/lang/estonian.txt # src/lang/finnish.txt # src/lang/french.txt # src/lang/german.txt # src/lang/hungarian.txt # src/lang/indonesian.txt # src/lang/italian.txt # src/lang/japanese.txt # src/lang/korean.txt # src/lang/lithuanian.txt # src/lang/luxembourgish.txt # src/lang/norwegian_bokmal.txt # src/lang/polish.txt # src/lang/portuguese.txt # src/lang/romanian.txt # src/lang/russian.txt # src/lang/serbian.txt # src/lang/simplified_chinese.txt # src/lang/slovak.txt # src/lang/spanish.txt # src/lang/spanish_MX.txt # src/lang/swedish.txt # src/lang/tamil.txt # src/lang/ukrainian.txt # src/lang/vietnamese.txt # src/newgrf.cpp # src/newgrf_gui.cpp # src/object_gui.cpp # src/pathfinder/yapf/yapf_costrail.hpp # src/pathfinder/yapf/yapf_node_rail.hpp # src/rail_cmd.cpp # src/roadveh_cmd.cpp # src/town_cmd.cpp # src/vehicle.cpp # src/water_cmd.cpp
This commit is contained in:
@@ -613,6 +613,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
bool execute; ///< On pressing 'apply changes' are grf changes applied immediately, or only list is updated.
|
||||
int preset; ///< Selected preset or \c -1 if none selected.
|
||||
int active_over; ///< Active GRF item over which another one is dragged, \c -1 if none.
|
||||
bool modified; ///< The list of active NewGRFs has been modified since the last time they got saved.
|
||||
|
||||
Scrollbar *vscroll;
|
||||
Scrollbar *vscroll2;
|
||||
@@ -655,7 +656,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
this->avails.SetFilterFuncs(this->filter_funcs);
|
||||
this->avails.ForceRebuild();
|
||||
|
||||
this->OnInvalidateData(GOID_NEWGRF_LIST_EDITED);
|
||||
this->OnInvalidateData(GOID_NEWGRF_CURRENT_LOADED);
|
||||
}
|
||||
|
||||
~NewGRFWindow()
|
||||
@@ -664,7 +665,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
DeleteWindowByClass(WC_TEXTFILE);
|
||||
DeleteWindowByClass(WC_SAVE_PRESET);
|
||||
|
||||
if (this->editable && !this->execute && !_exit_game) {
|
||||
if (this->editable && this->modified && !this->execute && !_exit_game) {
|
||||
CopyGRFConfigList(this->orig_list, this->actives, true);
|
||||
ResetGRFConfig(false);
|
||||
ReloadNewGRFData();
|
||||
@@ -978,7 +979,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
}
|
||||
this->vscroll->ScrollTowards(pos);
|
||||
this->preset = -1;
|
||||
this->InvalidateData();
|
||||
this->InvalidateData(GOID_NEWGRF_LIST_EDITED);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -997,7 +998,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
}
|
||||
this->vscroll->ScrollTowards(pos);
|
||||
this->preset = -1;
|
||||
this->InvalidateData();
|
||||
this->InvalidateData(GOID_NEWGRF_LIST_EDITED);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1104,6 +1105,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
ResetGRFConfig(false);
|
||||
ReloadNewGRFData();
|
||||
PostCheckNewGRFLoadWarnings();
|
||||
this->InvalidateData(GOID_NEWGRF_CHANGES_APPLIED);
|
||||
}
|
||||
this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window
|
||||
break;
|
||||
@@ -1113,6 +1115,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
if (this->active_sel == nullptr || !this->show_params || this->active_sel->num_valid_params == 0) break;
|
||||
|
||||
OpenGRFParameterWindow(this->active_sel, this->editable);
|
||||
this->InvalidateData(GOID_NEWGRF_CHANGES_MADE);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1120,6 +1123,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
if (this->active_sel != nullptr && this->editable) {
|
||||
this->active_sel->palette ^= GRFP_USE_MASK;
|
||||
this->SetDirty();
|
||||
this->InvalidateData(GOID_NEWGRF_CHANGES_MADE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1166,7 +1170,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
DeleteWindowByClass(WC_GRF_PARAMETERS);
|
||||
DeleteWindowByClass(WC_TEXTFILE);
|
||||
this->active_sel = nullptr;
|
||||
this->InvalidateData(GOID_NEWGRF_PRESET_LOADED);
|
||||
this->InvalidateData(GOID_NEWGRF_CHANGES_MADE);
|
||||
}
|
||||
|
||||
void OnQueryTextFinished(char *str) override
|
||||
@@ -1187,6 +1191,20 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
this->InvalidateData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the scroll bars for the active and inactive NewGRF lists.
|
||||
*/
|
||||
void UpdateScrollBars()
|
||||
{
|
||||
/* Update scrollbars */
|
||||
int i = 0;
|
||||
for (const GRFConfig *c = this->actives; c != nullptr; c = c->next, i++) {}
|
||||
|
||||
this->vscroll->SetCount(i + 1); // Reserve empty space for drag and drop handling.
|
||||
|
||||
if (this->avail_pos >= 0) this->vscroll2->ScrollTowards(this->avail_pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Some data on this window has become invalid.
|
||||
* @param data Information about the changed data. @see GameOptionsInvalidationData
|
||||
@@ -1221,27 +1239,34 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
||||
this->avails.ForceRebuild();
|
||||
FALLTHROUGH;
|
||||
|
||||
case GOID_NEWGRF_CURRENT_LOADED:
|
||||
this->modified = false;
|
||||
UpdateScrollBars();
|
||||
break;
|
||||
|
||||
case GOID_NEWGRF_LIST_EDITED:
|
||||
this->preset = -1;
|
||||
FALLTHROUGH;
|
||||
|
||||
case GOID_NEWGRF_PRESET_LOADED: {
|
||||
/* Update scrollbars */
|
||||
int i = 0;
|
||||
for (const GRFConfig *c = this->actives; c != nullptr; c = c->next, i++) {}
|
||||
case GOID_NEWGRF_CHANGES_MADE:
|
||||
UpdateScrollBars();
|
||||
|
||||
this->vscroll->SetCount(i + 1); // Reserve empty space for drag and drop handling.
|
||||
/* Changes have been made to the list of active NewGRFs */
|
||||
this->modified = true;
|
||||
|
||||
if (this->avail_pos >= 0) this->vscroll2->ScrollTowards(this->avail_pos);
|
||||
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->SetWidgetDisabledState(WID_NS_APPLY_CHANGES, !this->editable || !this->modified);
|
||||
this->SetWidgetsDisabledState(!this->editable,
|
||||
WID_NS_PRESET_LIST,
|
||||
WID_NS_APPLY_CHANGES,
|
||||
WID_NS_TOGGLE_PALETTE,
|
||||
WIDGET_LIST_END
|
||||
);
|
||||
@@ -1994,6 +2019,7 @@ static void NewGRFConfirmationCallback(Window *w, bool confirmed)
|
||||
for (c = nw->actives; c != nullptr && i > 0; c = c->next, i--) {}
|
||||
nw->active_sel = c;
|
||||
nw->avails.ForceRebuild();
|
||||
nw->modified = false;
|
||||
|
||||
w->InvalidateData();
|
||||
|
||||
|
Reference in New Issue
Block a user