summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2008-07-30 17:13:55 +0000
committerbelugas <belugas@openttd.org>2008-07-30 17:13:55 +0000
commit63f7214abd8baea3e861eb94e5ba12fa62a8f2c1 (patch)
tree7afc2c725b862d8c422e41bd2b52214c3cec19c2 /src
parentc840a63dfd8da71f165ffe834474da1537d265b9 (diff)
downloadopenttd-63f7214abd8baea3e861eb94e5ba12fa62a8f2c1.tar.xz
(svn r13882) -Codechange: Replace widget numbers with appropriate enums
Diffstat (limited to 'src')
-rw-r--r--src/graph_gui.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index 2c31abf90..c2cdcef84 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -856,6 +856,13 @@ void ShowCompanyLeagueTable()
/*****************************/
struct PerformanceRatingDetailWindow : Window {
+private:
+ enum PerformanteRatingWidgets {
+ PRW_PLAYER_FIRST = 13,
+ PRW_PLAYER_LAST = 20,
+ };
+
+public:
static PlayerID player;
int timeout;
@@ -863,12 +870,12 @@ struct PerformanceRatingDetailWindow : Window {
{
/* Disable the players who are not active */
for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
- this->SetWidgetDisabledState(i + 13, !IsValidPlayerID(i));
+ this->SetWidgetDisabledState(i + PRW_PLAYER_FIRST, !IsValidPlayerID(i));
}
this->UpdatePlayerStats();
- if (player != INVALID_PLAYER) this->LowerWidget(player + 13);
+ if (player != INVALID_PLAYER) this->LowerWidget(player + PRW_PLAYER_FIRST);
this->FindWindowPlacementAndResize(desc);
}
@@ -900,8 +907,8 @@ struct PerformanceRatingDetailWindow : Window {
if (player == INVALID_PLAYER || !IsValidPlayerID(player)) {
if (player != INVALID_PLAYER) {
/* Raise and disable the widget for the previous selection. */
- this->RaiseWidget(player + 13);
- this->DisableWidget(player + 13);
+ this->RaiseWidget(player + PRW_PLAYER_FIRST);
+ this->DisableWidget(player + PRW_PLAYER_FIRST);
this->SetDirty();
player = INVALID_PLAYER;
@@ -910,7 +917,7 @@ struct PerformanceRatingDetailWindow : Window {
for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
if (IsValidPlayerID(i)) {
/* Lower the widget corresponding to this player. */
- this->LowerWidget(i + 13);
+ this->LowerWidget(i + PRW_PLAYER_FIRST);
this->SetDirty();
player = i;
@@ -926,9 +933,9 @@ struct PerformanceRatingDetailWindow : Window {
for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
if (!IsValidPlayerID(i)) {
/* Check if we have the player as an active player */
- if (!this->IsWidgetDisabled(i + 13)) {
+ if (!this->IsWidgetDisabled(i + PRW_PLAYER_FIRST)) {
/* Bah, player gone :( */
- this->DisableWidget(i + 13);
+ this->DisableWidget(i + PRW_PLAYER_FIRST);
/* We need a repaint */
this->SetDirty();
@@ -937,9 +944,9 @@ struct PerformanceRatingDetailWindow : Window {
}
/* Check if we have the player marked as inactive */
- if (this->IsWidgetDisabled(i + 13)) {
+ if (this->IsWidgetDisabled(i + PRW_PLAYER_FIRST)) {
/* New player! Yippie :p */
- this->EnableWidget(i + 13);
+ this->EnableWidget(i + PRW_PLAYER_FIRST);
/* We need a repaint */
this->SetDirty();
}
@@ -1017,12 +1024,12 @@ struct PerformanceRatingDetailWindow : Window {
virtual void OnClick(Point pt, int widget)
{
/* Check which button is clicked */
- if (IsInsideMM(widget, 13, 21)) {
+ if (IsInsideMM(widget, PRW_PLAYER_FIRST, PRW_PLAYER_LAST + 1)) {
/* Is it no on disable? */
if (!this->IsWidgetDisabled(widget)) {
- this->RaiseWidget(player + 13);
- player = (PlayerID)(widget - 13);
- this->LowerWidget(player + 13);
+ this->RaiseWidget(player + PRW_PLAYER_FIRST);
+ player = (PlayerID)(widget - PRW_PLAYER_FIRST);
+ this->LowerWidget(player + PRW_PLAYER_FIRST);
this->SetDirty();
}
}