(svn r17803) -Codechange: Remove update_(left|right) in favour of the rebuild flag of GUIList.

This commit is contained in:
frosch 2009-10-18 16:31:27 +00:00
parent 60188f496d
commit 41037308c0
1 changed files with 13 additions and 15 deletions

View File

@ -102,8 +102,6 @@ class ReplaceVehicleWindow : public Window {
EngineID sel_engine[2]; ///< Selected engine left and right. EngineID sel_engine[2]; ///< Selected engine left and right.
GUIEngineList engines[2]; ///< Left and right list of engines. GUIEngineList engines[2]; ///< Left and right list of engines.
bool replace_engines; ///< If \c true, engines are replaced, if \c false, wagons are replaced (only for trains). bool replace_engines; ///< If \c true, engines are replaced, if \c false, wagons are replaced (only for trains).
bool update_left; ///< Rebuild left list.
bool update_right; ///< Rebuild right list.
bool reset_sel_engine; ///< Also reset #sel_engine while updating left and/or right (#update_left and/or #update_right) and no valid engine selected. bool reset_sel_engine; ///< Also reset #sel_engine while updating left and/or right (#update_left and/or #update_right) and no valid engine selected.
GroupID sel_group; ///< Group selected to replace. GroupID sel_group; ///< Group selected to replace.
int details_height; ///< Minimal needed height of the details panels (found so far). int details_height; ///< Minimal needed height of the details panels (found so far).
@ -168,7 +166,7 @@ class ReplaceVehicleWindow : public Window {
{ {
EngineID e = this->sel_engine[0]; EngineID e = this->sel_engine[0];
if (this->update_left == true) { if (this->engines[0].NeedRebuild()) {
/* We need to rebuild the left engines list */ /* We need to rebuild the left engines list */
this->GenerateReplaceVehList(true); this->GenerateReplaceVehList(true);
this->vscroll.SetCount(this->engines[0].Length()); this->vscroll.SetCount(this->engines[0].Length());
@ -177,7 +175,7 @@ class ReplaceVehicleWindow : public Window {
} }
} }
if (this->update_right || e != this->sel_engine[0]) { if (this->engines[1].NeedRebuild() || e != this->sel_engine[0]) {
/* Either we got a request to rebuild the right engines list, or the left engines list selected a different engine */ /* Either we got a request to rebuild the right engines list, or the left engines list selected a different engine */
if (this->sel_engine[0] == INVALID_ENGINE) { if (this->sel_engine[0] == INVALID_ENGINE) {
/* Always empty the right engines list when nothing is selected in the left engines list */ /* Always empty the right engines list when nothing is selected in the left engines list */
@ -192,8 +190,8 @@ class ReplaceVehicleWindow : public Window {
} }
} }
/* Reset the flags about needed updates */ /* Reset the flags about needed updates */
this->update_left = false; this->engines[0].RebuildDone();
this->update_right = false; this->engines[1].RebuildDone();
this->reset_sel_engine = false; this->reset_sel_engine = false;
} }
@ -201,8 +199,8 @@ public:
ReplaceVehicleWindow(const WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window() ReplaceVehicleWindow(const WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window()
{ {
this->replace_engines = true; // start with locomotives (all other vehicles will not read this bool) this->replace_engines = true; // start with locomotives (all other vehicles will not read this bool)
this->update_left = true; this->engines[0].ForceRebuild();
this->update_right = true; this->engines[1].ForceRebuild();
this->reset_sel_engine = true; this->reset_sel_engine = true;
this->details_height = ((vehicletype == VEH_TRAIN) ? 10 : 9) * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; this->details_height = ((vehicletype == VEH_TRAIN) ? 10 : 9) * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
this->sel_engine[0] = INVALID_ENGINE; this->sel_engine[0] = INVALID_ENGINE;
@ -327,7 +325,7 @@ public:
virtual void OnPaint() virtual void OnPaint()
{ {
if (this->update_left || this->update_right) this->GenerateLists(); if (this->engines[0].NeedRebuild() || this->engines[1].NeedRebuild()) this->GenerateLists();
Company *c = Company::Get(_local_company); Company *c = Company::Get(_local_company);
@ -384,7 +382,7 @@ public:
switch (widget) { switch (widget) {
case RVW_WIDGET_TRAIN_ENGINEWAGON_TOGGLE: case RVW_WIDGET_TRAIN_ENGINEWAGON_TOGGLE:
this->replace_engines = !(this->replace_engines); this->replace_engines = !(this->replace_engines);
this->update_left = true; this->engines[0].ForceRebuild();
this->reset_sel_engine = true; this->reset_sel_engine = true;
this->SetDirty(); this->SetDirty();
break; break;
@ -433,7 +431,7 @@ public:
if (e == this->sel_engine[click_side]) break; // we clicked the one we already selected if (e == this->sel_engine[click_side]) break; // we clicked the one we already selected
this->sel_engine[click_side] = e; this->sel_engine[click_side] = e;
if (click_side == 0) { if (click_side == 0) {
this->update_right = true; this->engines[1].ForceRebuild();
this->reset_sel_engine = true; this->reset_sel_engine = true;
} }
this->SetDirty(); this->SetDirty();
@ -452,8 +450,8 @@ public:
this->vscroll.SetPosition(0); this->vscroll.SetPosition(0);
this->vscroll2.SetPosition(0); this->vscroll2.SetPosition(0);
/* Rebuild the lists */ /* Rebuild the lists */
this->update_left = true; this->engines[0].ForceRebuild();
this->update_right = true; this->engines[1].ForceRebuild();
this->reset_sel_engine = true; this->reset_sel_engine = true;
this->SetDirty(); this->SetDirty();
} }
@ -470,9 +468,9 @@ public:
virtual void OnInvalidateData(int data) virtual void OnInvalidateData(int data)
{ {
if (data != 0) { if (data != 0) {
this->update_left = true; this->engines[0].ForceRebuild();
} else { } else {
this->update_right = true; this->engines[1].ForceRebuild();
} }
} }
}; };