diff options
author | belugas <belugas@openttd.org> | 2006-10-03 02:08:15 +0000 |
---|---|---|
committer | belugas <belugas@openttd.org> | 2006-10-03 02:08:15 +0000 |
commit | 753b5724001079c3352d23a911488044884dcf5b (patch) | |
tree | dc2a5593c6d3da96528beb914da8807aea2325e7 /rail_gui.c | |
parent | e383584988a99dbdfbcd4a63b1f11213a4274355 (diff) | |
download | openttd-753b5724001079c3352d23a911488044884dcf5b.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 'rail_gui.c')
-rw-r--r-- | rail_gui.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/rail_gui.c b/rail_gui.c index 25d9b2f6a..635c63e2b 100644 --- a/rail_gui.c +++ b/rail_gui.c @@ -292,7 +292,7 @@ static void BuildRailClick_Tunnel(Window *w) static void BuildRailClick_Remove(Window *w) { - if (HASBIT(w->disabled_state, 16)) return; + if (IsWindowWidgetDisabled(w, 16)) return; SetWindowDirty(w); SndPlayFx(SND_15_BEEP); @@ -405,24 +405,25 @@ static const uint16 _rail_keycodes[] = { }; +static void UpdateRemoveWidgetStatus(Window *w, int clicked_widget) +{ + switch (clicked_widget) { + case 4: case 5: case 6: case 7: case 8: case 11: case 12: case 13: EnableWindowWidget(w, 16); break; + default: DisableWindowWidget(w, 16); w->click_state &= ~(1 << 16); break; + } +} + static void BuildRailToolbWndProc(Window *w, WindowEvent *e) { switch (e->event) { - case WE_PAINT: - w->disabled_state &= ~(1 << 16); - if (!(w->click_state & ((1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<11)|(1<<12)|(1<<13)))) { - w->disabled_state |= (1 << 16); - w->click_state &= ~(1<<16); - } - DrawWindowWidgets(w); - break; - + case WE_PAINT: DrawWindowWidgets(w); break; case WE_CLICK: if (e->we.click.widget >= 4) { _remove_button_clicked = false; _build_railroad_button_proc[e->we.click.widget - 4](w); } - break; + UpdateRemoveWidgetStatus(w, e->we.click.widget); + break; case WE_KEYPRESS: { uint i; @@ -432,6 +433,7 @@ static void BuildRailToolbWndProc(Window *w, WindowEvent *e) e->we.keypress.cont = false; _remove_button_clicked = false; _build_railroad_button_proc[i](w); + UpdateRemoveWidgetStatus(w, i); break; } } @@ -651,10 +653,9 @@ static void StationBuildWndProc(Window *w, WindowEvent *e) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); /* Update buttons for correct spread value */ - w->disabled_state = 0; for (bits = _patches.station_spread; bits < 7; bits++) { - SETBIT(w->disabled_state, bits + 5); - SETBIT(w->disabled_state, bits + 12); + DisableWindowWidget(w, bits + 5); + DisableWindowWidget(w, bits + 12); } if (newstations) { @@ -662,8 +663,8 @@ static void StationBuildWndProc(Window *w, WindowEvent *e) if (statspec != NULL) { for (bits = 0; bits < 7; bits++) { - if (HASBIT(statspec->disallowed_platforms, bits)) SETBIT(w->disabled_state, bits + 5); - if (HASBIT(statspec->disallowed_lengths, bits)) SETBIT(w->disabled_state, bits + 12); + SetWindowWidgetDisabledState(w, bits + 5, HASBIT(statspec->disallowed_platforms, bits)); + SetWindowWidgetDisabledState(w, bits + 12, HASBIT(statspec->disallowed_lengths, bits)); } } } |