summaryrefslogtreecommitdiff
path: root/train_gui.c
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2006-10-03 02:08:15 +0000
committerbelugas <belugas@openttd.org>2006-10-03 02:08:15 +0000
commitcf210fdf6b68f3ae0fd45c063d9f292bdf62faac (patch)
treedc2a5593c6d3da96528beb914da8807aea2325e7 /train_gui.c
parentbab116f6847f46360b0732f63a7e6f52c8287aff (diff)
downloadopenttd-cf210fdf6b68f3ae0fd45c063d9f292bdf62faac.tar.xz
(svn r6619) -Codechange: Use accessors for disabled_state.
Another step toward merging XTDwidget. The only two files not converted (window.h and widget.c) will be done at the very last commit)
Diffstat (limited to 'train_gui.c')
-rw-r--r--train_gui.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/train_gui.c b/train_gui.c
index 9e5a6986f..98376a878 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -206,7 +206,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
switch (e->event) {
case WE_PAINT:
- if (w->window_number == 0) SETBIT(w->disabled_state, 5);
+ SetWindowWidgetDisabledState(w, 5, w->window_number == 0);
{
int count = 0;
@@ -424,21 +424,23 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
case WE_PAINT: {
const Vehicle *v, *u;
StringID str;
+ bool is_localplayer;
v = GetVehicle(w->window_number);
- if (v->owner != _local_player) {
- w->disabled_state = 0x3380;
- } else {
- w->disabled_state = 0;
-
- SETBIT(w->disabled_state, 12);
+ is_localplayer = v->owner == _local_player;
+ SetWindowWidgetDisabledState(w, 7, !is_localplayer);
+ SetWindowWidgetDisabledState(w, 8, !is_localplayer);
+ SetWindowWidgetDisabledState(w, 9, !is_localplayer);
+ SetWindowWidgetDisabledState(w, 12, !is_localplayer);
+ SetWindowWidgetDisabledState(w, 13, !is_localplayer);
+ if (is_localplayer) {
/* See if any vehicle can be refitted */
for (u = v; u != NULL; u = u->next) {
if (EngInfo(u->engine_type)->refit_mask != 0 ||
(!(RailVehInfo(v->engine_type)->flags & RVI_WAGON) && v->cargo_cap != 0)) {
- CLRBIT(w->disabled_state, 12);
+ EnableWindowWidget(w, 12);
/* We have a refittable carriage, bail out */
break;
}
@@ -682,11 +684,12 @@ static void DrawTrainDetailsWindow(Window *w)
SetVScrollCount(w, num);
- w->disabled_state = 1 << (det_tab + 9);
- if (v->owner != _local_player) w->disabled_state |= (1 << 2);
+ DisableWindowWidget(w, det_tab + 9);
+ SetWindowWidgetDisabledState(w, 2, v->owner != _local_player);
- // disable service-scroller when interval is set to disabled
- if (!_patches.servint_trains) w->disabled_state |= (1 << 6) | (1 << 7);
+ /* disable service-scroller when interval is set to disabled */
+ SetWindowWidgetDisabledState(w, 6, !_patches.servint_trains);
+ SetWindowWidgetDisabledState(w, 7, !_patches.servint_trains);
SetDParam(0, v->string_id);
SetDParam(1, v->unitnumber);
@@ -801,11 +804,11 @@ do_change_service_int:
case 10: // Information
case 11: // Capacities
case 12: // Total cargo
- CLRBIT(w->disabled_state, 9);
- CLRBIT(w->disabled_state, 10);
- CLRBIT(w->disabled_state, 11);
- CLRBIT(w->disabled_state, 12);
- SETBIT(w->disabled_state, e->we.click.widget);
+ EnableWindowWidget(w, 9);
+ EnableWindowWidget(w, 10);
+ EnableWindowWidget(w, 11);
+ EnableWindowWidget(w, 12);
+ EnableWindowWidget(w, e->we.click.widget);
WP(w,traindetails_d).tab = e->we.click.widget - 9;
SetWindowDirty(w);
break;