1
0
Fork 0

(svn r17763) -Codechange: Rename 'wagon_btnstate' to 'replace_engines', and 'init_lists' to 'reset_sel_engine' in ReplaceVehicleWindow, add doxygen comments.

release/1.0
alberth 2009-10-11 12:51:15 +00:00
parent 8f090ec4a8
commit 54b8523936
1 changed files with 27 additions and 27 deletions

View File

@ -99,14 +99,14 @@ void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type)
* Window for the autoreplacing of vehicles. * Window for the autoreplacing of vehicles.
*/ */
class ReplaceVehicleWindow : public Window { class ReplaceVehicleWindow : public Window {
EngineID sel_engine[2]; EngineID sel_engine[2]; ///< Selected engine left and right.
bool wagon_btnstate; ///< true means engine is selected GUIEngineList list[2]; ///< Left and right list of engines.
GUIEngineList list[2]; bool replace_engines; ///< If \c true, engines are replaced, if \c false, wagons are replaced (only for trains).
bool update_left; bool update_left; ///< Rebuild left list.
bool update_right; bool update_right; ///< Rebuild right list.
bool init_lists; 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; GroupID sel_group; ///< Group selected to replace.
static RailType sel_railtype; static RailType sel_railtype; ///< Type of rail tracks selected.
/** Figure out if an engine should be added to a list. /** Figure out if an engine should be added to a list.
* @param e The EngineID. * @param e The EngineID.
@ -144,7 +144,7 @@ class ReplaceVehicleWindow : public Window {
const Engine *e; const Engine *e;
FOR_ALL_ENGINES_OF_TYPE(e, type) { FOR_ALL_ENGINES_OF_TYPE(e, type) {
EngineID eid = e->index; EngineID eid = e->index;
if (type == VEH_TRAIN && !GenerateReplaceRailList(eid, draw_left, this->wagon_btnstate)) continue; // special rules for trains if (type == VEH_TRAIN && !GenerateReplaceRailList(eid, draw_left, this->replace_engines)) continue; // special rules for trains
if (draw_left) { if (draw_left) {
const GroupID selected_group = this->sel_group; const GroupID selected_group = this->sel_group;
@ -172,7 +172,7 @@ class ReplaceVehicleWindow : public Window {
/* We need to rebuild the left list */ /* We need to rebuild the left list */
GenerateReplaceVehList(true); GenerateReplaceVehList(true);
this->vscroll.SetCount(this->list[0].Length()); this->vscroll.SetCount(this->list[0].Length());
if (this->init_lists && this->sel_engine[0] == INVALID_ENGINE && this->list[0].Length() != 0) { if (this->reset_sel_engine && this->sel_engine[0] == INVALID_ENGINE && this->list[0].Length() != 0) {
this->sel_engine[0] = this->list[0][0]; this->sel_engine[0] = this->list[0][0];
} }
} }
@ -186,24 +186,24 @@ class ReplaceVehicleWindow : public Window {
} else { } else {
GenerateReplaceVehList(false); GenerateReplaceVehList(false);
this->vscroll2.SetCount(this->list[1].Length()); this->vscroll2.SetCount(this->list[1].Length());
if (this->init_lists && this->sel_engine[1] == INVALID_ENGINE && this->list[1].Length() != 0) { if (this->reset_sel_engine && this->sel_engine[1] == INVALID_ENGINE && this->list[1].Length() != 0) {
this->sel_engine[1] = this->list[1][0]; this->sel_engine[1] = this->list[1][0];
} }
} }
} }
/* Reset the flags about needed updates */ /* Reset the flags about needed updates */
this->update_left = false; this->update_left = false;
this->update_right = false; this->update_right = false;
this->init_lists = false; this->reset_sel_engine = false;
} }
public: public:
ReplaceVehicleWindow(const WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc, vehicletype) ReplaceVehicleWindow(const WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc, vehicletype)
{ {
this->wagon_btnstate = 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->update_left = true;
this->update_right = true; this->update_right = true;
this->init_lists = true; this->reset_sel_engine = true;
this->sel_engine[0] = INVALID_ENGINE; this->sel_engine[0] = INVALID_ENGINE;
this->sel_engine[1] = INVALID_ENGINE; this->sel_engine[1] = INVALID_ENGINE;
@ -269,7 +269,7 @@ public:
SetDParam(1, c->settings.renew_keep_length ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF); SetDParam(1, c->settings.renew_keep_length ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
/* set wagon/engine button */ /* set wagon/engine button */
SetDParam(2, this->wagon_btnstate ? STR_REPLACE_ENGINES : STR_REPLACE_WAGONS); SetDParam(2, this->replace_engines ? STR_REPLACE_ENGINES : STR_REPLACE_WAGONS);
/* sets the colour of that art thing */ /* sets the colour of that art thing */
this->widget[RVW_WIDGET_TRAIN_FLUFF_LEFT].colour = _company_colours[_local_company]; this->widget[RVW_WIDGET_TRAIN_FLUFF_LEFT].colour = _company_colours[_local_company];
@ -326,9 +326,9 @@ public:
{ {
switch (widget) { switch (widget) {
case RVW_WIDGET_TRAIN_ENGINEWAGON_TOGGLE: case RVW_WIDGET_TRAIN_ENGINEWAGON_TOGGLE:
this->wagon_btnstate = !(this->wagon_btnstate); this->replace_engines = !(this->replace_engines);
this->update_left = true; this->update_left = true;
this->init_lists = true; this->reset_sel_engine = true;
this->SetDirty(); this->SetDirty();
break; break;
@ -376,8 +376,8 @@ 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->update_right = true;
this->init_lists = true; this->reset_sel_engine = true;
} }
this->SetDirty(); this->SetDirty();
} }
@ -395,9 +395,9 @@ 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->update_left = true;
this->update_right = true; this->update_right = true;
this->init_lists = true; this->reset_sel_engine = true;
this->SetDirty(); this->SetDirty();
} }