(svn r14390) -Codechange: replace magic constants with symbolic constants.
authorrubidium
Tue, 23 Sep 2008 15:24:15 +0000
changeset 10180 a99cf854c6d0
parent 10179 8d79cda44991
child 10181 3c3e31214f4c
(svn r14390) -Codechange: replace magic constants with symbolic constants.
src/cheat_gui.cpp
src/genworld_gui.cpp
src/industry_gui.cpp
src/network/network_gui.cpp
src/settings_gui.cpp
src/station_gui.cpp
src/toolbar_gui.cpp
src/tree_gui.cpp
src/window.cpp
src/window_gui.h
--- a/src/cheat_gui.cpp	Mon Sep 22 19:58:46 2008 +0000
+++ b/src/cheat_gui.cpp	Tue Sep 23 15:24:15 2008 +0000
@@ -216,7 +216,7 @@
 
 		if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
 
-		flags4 |= 5 << WF_TIMEOUT_SHL;
+		this->flags4 |= WF_TIMEOUT_BEGIN;
 
 		SetDirty();
 	}
--- a/src/genworld_gui.cpp	Mon Sep 22 19:58:46 2008 +0000
+++ b/src/genworld_gui.cpp	Tue Sep 23 15:24:15 2008 +0000
@@ -403,7 +403,7 @@
 			case GLAND_START_DATE_DOWN:
 			case GLAND_START_DATE_UP: // Year buttons
 				/* Don't allow too fast scrolling */
-				if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
+				if ((this->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
 					this->HandleButtonClick(widget);
 					this->SetDirty();
 
@@ -421,7 +421,7 @@
 			case GLAND_SNOW_LEVEL_DOWN:
 			case GLAND_SNOW_LEVEL_UP: // Snow line buttons
 				/* Don't allow too fast scrolling */
-				if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
+				if ((this->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
 					this->HandleButtonClick(widget);
 					this->SetDirty();
 
@@ -697,7 +697,7 @@
 			case CSCEN_START_DATE_DOWN:
 			case CSCEN_START_DATE_UP: // Year buttons
 				/* Don't allow too fast scrolling */
-				if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
+				if ((this->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
 					this->HandleButtonClick(widget);
 					this->SetDirty();
 
@@ -715,7 +715,7 @@
 			case CSCEN_FLAT_LAND_HEIGHT_DOWN:
 			case CSCEN_FLAT_LAND_HEIGHT_UP: // Height level buttons
 				/* Don't allow too fast scrolling */
-				if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
+				if ((this->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
 					this->HandleButtonClick(widget);
 					this->SetDirty();
 
--- a/src/industry_gui.cpp	Mon Sep 22 19:58:46 2008 +0000
+++ b/src/industry_gui.cpp	Tue Sep 23 15:24:15 2008 +0000
@@ -598,7 +598,7 @@
 
 						UpdateIndustryProduction(i);
 						this->SetDirty();
-						this->flags4 |= 5 << WF_TIMEOUT_SHL;
+						this->flags4 |= WF_TIMEOUT_BEGIN;
 						this->clicked_line = line + 1;
 						this->clicked_button = (x < 15 ? 1 : 2);
 					} else if (IsInsideMM(x, 34, 160)) {
--- a/src/network/network_gui.cpp	Mon Sep 22 19:58:46 2008 +0000
+++ b/src/network/network_gui.cpp	Tue Sep 23 15:24:15 2008 +0000
@@ -855,7 +855,7 @@
 			case NSSW_COMPANIES_BTND:  case NSSW_COMPANIES_BTNU:  // Click on up/down button for number of companies
 			case NSSW_SPECTATORS_BTND: case NSSW_SPECTATORS_BTNU: // Click on up/down button for number of spectators
 				/* Don't allow too fast scrolling */
-				if ((this->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
+				if ((this->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
 					this->HandleButtonClick(widget);
 					this->SetDirty();
 					switch (widget) {
--- a/src/settings_gui.cpp	Mon Sep 22 19:58:46 2008 +0000
+++ b/src/settings_gui.cpp	Tue Sep 23 15:24:15 2008 +0000
@@ -890,8 +890,8 @@
 						uint32 step = (sdb->interval == 0) ? ((sdb->max - sdb->min) / 50) : sdb->interval;
 						if (step == 0) step = 1;
 
-						// don't allow too fast scrolling
-						if ((this->flags4 & WF_TIMEOUT_MASK) > 2 << WF_TIMEOUT_SHL) {
+						/* don't allow too fast scrolling */
+						if ((this->flags4 & WF_TIMEOUT_MASK) > WF_TIMEOUT_TRIGGER) {
 							_left_button_clicked = false;
 							return;
 						}
@@ -908,7 +908,7 @@
 						/* Set up scroller timeout for numeric values */
 						if (value != oldvalue && !(sd->desc.flags & SGF_MULTISTRING)) {
 							this->click = btn * 2 + 1 + ((x >= 10) ? 1 : 0);
-							this->flags4 |= 5 << WF_TIMEOUT_SHL;
+							this->flags4 |= WF_TIMEOUT_BEGIN;
 							_left_button_clicked = false;
 						}
 					} break;
@@ -1168,7 +1168,7 @@
 			ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, 250, this, afilter, QSF_NONE);
 		}
 
-		this->flags4 |= 5 << WF_TIMEOUT_SHL;
+		this->flags4 |= WF_TIMEOUT_BEGIN;
 		this->SetDirty();
 	}
 
--- a/src/station_gui.cpp	Mon Sep 22 19:58:46 2008 +0000
+++ b/src/station_gui.cpp	Tue Sep 23 15:24:15 2008 +0000
@@ -434,7 +434,7 @@
 
 			case SLW_SORTBY: // flip sorting method asc/desc
 				this->stations.ToggleSortOrder();
-				this->flags4 |= 5 << WF_TIMEOUT_SHL;
+				this->flags4 |= WF_TIMEOUT_BEGIN;
 				this->LowerWidget(SLW_SORTBY);
 				this->SetDirty();
 				break;
--- a/src/toolbar_gui.cpp	Mon Sep 22 19:58:46 2008 +0000
+++ b/src/toolbar_gui.cpp	Tue Sep 23 15:24:15 2008 +0000
@@ -747,7 +747,7 @@
 static void ToolbarScenDateBackward(Window *w)
 {
 	/* don't allow too fast scrolling */
-	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
+	if ((w->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
 		w->HandleButtonClick(TBSE_DATEBACKWARD);
 		w->SetDirty();
 
@@ -760,7 +760,7 @@
 static void ToolbarScenDateForward(Window *w)
 {
 	/* don't allow too fast scrolling */
-	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
+	if ((w->flags4 & WF_TIMEOUT_MASK) <= WF_TIMEOUT_TRIGGER) {
 		w->HandleButtonClick(TBSE_DATEFORWARD);
 		w->SetDirty();
 
--- a/src/tree_gui.cpp	Mon Sep 22 19:58:46 2008 +0000
+++ b/src/tree_gui.cpp	Tue Sep 23 15:24:15 2008 +0000
@@ -111,7 +111,7 @@
 
 			case BTW_MANY_RANDOM: // place trees randomly over the landscape
 				this->LowerWidget(BTW_MANY_RANDOM);
-				this->flags4 |= 5 << WF_TIMEOUT_SHL;
+				this->flags4 |= WF_TIMEOUT_BEGIN;
 				SndPlayFx(SND_15_BEEP);
 				PlaceTreesRandomly();
 				MarkWholeScreenDirty();
--- a/src/window.cpp	Mon Sep 22 19:58:46 2008 +0000
+++ b/src/window.cpp	Tue Sep 23 15:24:15 2008 +0000
@@ -116,7 +116,7 @@
 void Window::HandleButtonClick(byte widget)
 {
 	this->LowerWidget(widget);
-	this->flags4 |= 5 << WF_TIMEOUT_SHL;
+	this->flags4 |= WF_TIMEOUT_BEGIN;
 	this->InvalidateWidget(widget);
 }
 
--- a/src/window_gui.h	Mon Sep 22 19:58:46 2008 +0000
+++ b/src/window_gui.h	Tue Sep 23 15:24:15 2008 +0000
@@ -487,8 +487,9 @@
  * Window flags
  */
 enum WindowFlags {
-	WF_TIMEOUT_SHL       = 0,       ///< Window timeout counter shift
-	WF_TIMEOUT_MASK      = 7,       ///< Window timeout counter bit mask (3 bits), @see WF_TIMEOUT_SHL
+	WF_TIMEOUT_TRIGGER   = 2,       ///< When the timeout should start triggering
+	WF_TIMEOUT_BEGIN     = 5,       ///< The initial value for the timeout
+	WF_TIMEOUT_MASK      = 7,       ///< Window timeout counter bit mask (3 bits)
 	WF_DRAGGING          = 1 <<  3, ///< Window is being dragged
 	WF_SCROLL_UP         = 1 <<  4, ///< Upper scroll button has been pressed, @see ScrollbarClickHandler()
 	WF_SCROLL_DOWN       = 1 <<  5, ///< Lower scroll button has been pressed, @see ScrollbarClickHandler()