changeset 13254:5c5b2167f108 draft

(svn r17763) -Codechange: Rename 'wagon_btnstate' to 'replace_engines', and 'init_lists' to 'reset_sel_engine' in ReplaceVehicleWindow, add doxygen comments.
author alberth <alberth@openttd.org>
date Sun, 11 Oct 2009 12:51:15 +0000
parents 5b8c6c464036
children 2867b98a3a39
files src/autoreplace_gui.cpp
diffstat 1 files changed, 27 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -99,14 +99,14 @@
  * Window for the autoreplacing of vehicles.
  */
 class ReplaceVehicleWindow : public Window {
-	EngineID sel_engine[2];
-	bool wagon_btnstate; ///< true means engine is selected
-	GUIEngineList list[2];
-	bool update_left;
-	bool update_right;
-	bool init_lists;
-	GroupID sel_group;
-	static RailType sel_railtype;
+	EngineID sel_engine[2];       ///< Selected engine left and right.
+	GUIEngineList list[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 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.
+	GroupID sel_group;            ///< Group selected to replace.
+	static RailType sel_railtype; ///< Type of rail tracks selected.
 
 	/** Figure out if an engine should be added to a list.
 	 * @param e            The EngineID.
@@ -144,7 +144,7 @@
 		const Engine *e;
 		FOR_ALL_ENGINES_OF_TYPE(e, type) {
 			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) {
 				const GroupID selected_group = this->sel_group;
@@ -172,7 +172,7 @@
 			/* We need to rebuild the left list */
 			GenerateReplaceVehList(true);
 			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];
 			}
 		}
@@ -186,24 +186,24 @@
 			} else {
 				GenerateReplaceVehList(false);
 				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];
 				}
 			}
 		}
 		/* Reset the flags about needed updates */
-		this->update_left  = false;
-		this->update_right = false;
-		this->init_lists   = false;
+		this->update_left      = false;
+		this->update_right     = false;
+		this->reset_sel_engine = false;
 	}
 
 public:
 	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->update_left   = true;
-		this->update_right  = true;
-		this->init_lists    = true;
+		this->replace_engines  = true; // start with locomotives (all other vehicles will not read this bool)
+		this->update_left      = true;
+		this->update_right     = true;
+		this->reset_sel_engine = true;
 		this->sel_engine[0] = INVALID_ENGINE;
 		this->sel_engine[1] = INVALID_ENGINE;
 
@@ -269,7 +269,7 @@
 			SetDParam(1, c->settings.renew_keep_length ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
 
 			/* 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 */
 			this->widget[RVW_WIDGET_TRAIN_FLUFF_LEFT].colour  = _company_colours[_local_company];
@@ -326,9 +326,9 @@
 	{
 		switch (widget) {
 			case RVW_WIDGET_TRAIN_ENGINEWAGON_TOGGLE:
-				this->wagon_btnstate = !(this->wagon_btnstate);
-				this->update_left = true;
-				this->init_lists  = true;
+				this->replace_engines  = !(this->replace_engines);
+				this->update_left      = true;
+				this->reset_sel_engine = true;
 				this->SetDirty();
 				break;
 
@@ -376,8 +376,8 @@
 					if (e == this->sel_engine[click_side]) break; // we clicked the one we already selected
 					this->sel_engine[click_side] = e;
 					if (click_side == 0) {
-						this->update_right = true;
-						this->init_lists   = true;
+						this->update_right     = true;
+						this->reset_sel_engine = true;
 					}
 					this->SetDirty();
 					}
@@ -395,9 +395,9 @@
 		this->vscroll.SetPosition(0);
 		this->vscroll2.SetPosition(0);
 		/* Rebuild the lists */
-		this->update_left  = true;
-		this->update_right = true;
-		this->init_lists   = true;
+		this->update_left      = true;
+		this->update_right     = true;
+		this->reset_sel_engine = true;
 		this->SetDirty();
 	}