summaryrefslogtreecommitdiff
path: root/airport_gui.c
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2006-10-03 20:16:20 +0000
committerbelugas <belugas@openttd.org>2006-10-03 20:16:20 +0000
commit17eb65050b29b84e1a5b452d302c1a40931764cb (patch)
tree22b881cad1fc846e1fe14182d37c8f6e6261f820 /airport_gui.c
parentbdaab39e648891f3e86a290ade9b02fe4d215f45 (diff)
downloadopenttd-17eb65050b29b84e1a5b452d302c1a40931764cb.tar.xz
(svn r6631) -Codechange: Use accessors for click_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 'airport_gui.c')
-rw-r--r--airport_gui.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/airport_gui.c b/airport_gui.c
index b35bfb740..e1d55845a 100644
--- a/airport_gui.c
+++ b/airport_gui.c
@@ -99,8 +99,8 @@ static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
break;
case WE_ABORT_PLACE_OBJ:
- UnclickWindowButtons(w);
- SetWindowDirty(w);
+ RaiseWindowButtons(w);
+
w = FindWindowById(WC_BUILD_STATION, 0);
if (w != 0)
WP(w,def_d).close = true;
@@ -142,20 +142,26 @@ void ShowBuildAirToolbar(void)
static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
+ case WE_CREATE:
+ SetWidgetLoweredState(w, 16, !_station_show_coverage);
+ SetWidgetLoweredState(w, 17, _station_show_coverage);
+ LowerWindowWidget(w, _selected_airport_type + 7);
+ break;
+
case WE_PAINT: {
int i; // airport enabling loop
- int sel;
int rad = 4; // default catchment radious
uint32 avail_airports;
const AirportFTAClass *airport;
if (WP(w,def_d).close) return;
- sel = _selected_airport_type;
avail_airports = GetValidAirports();
- if (!HASBIT(avail_airports, 0) && sel == AT_SMALL) sel = AT_LARGE;
- if (!HASBIT(avail_airports, 1) && sel == AT_LARGE) sel = AT_SMALL;
+ RaiseWindowWidget(w, _selected_airport_type + 7);
+ if (!HASBIT(avail_airports, 0) && _selected_airport_type == AT_SMALL) _selected_airport_type = AT_LARGE;
+ if (!HASBIT(avail_airports, 1) && _selected_airport_type == AT_LARGE) _selected_airport_type = AT_SMALL;
+ LowerWindowWidget(w, _selected_airport_type + 7);
/* 'Country Airport' starts at widget 7, and if its bit is set, it is
* available, so take its opposite value to set the disabled state.
@@ -165,14 +171,12 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
*/
for (i = 0; i < 9; i++) SetWindowWidgetDisabledState(w, i + 7, !HASBIT(avail_airports, i));
- _selected_airport_type = sel;
// select default the coverage area to 'Off' (16)
- w->click_state = ((1<<7) << sel) | ((1<<16) << _station_show_coverage);
- airport = GetAirport(sel);
+ airport = GetAirport(_selected_airport_type);
SetTileSelectSize(airport->size_x, airport->size_y);
if (_patches.modified_catchment) {
- switch (sel) {
+ switch (_selected_airport_type) {
case AT_OILRIG: rad = CA_AIR_OILPAD; break;
case AT_HELIPORT: rad = CA_AIR_HELIPORT; break;
case AT_SMALL: rad = CA_AIR_SMALL; break;
@@ -198,12 +202,16 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
case WE_CLICK: {
switch (e->we.click.widget) {
case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15:
+ RaiseWindowWidget(w, _selected_airport_type + 7);
_selected_airport_type = e->we.click.widget - 7;
+ LowerWindowWidget(w, _selected_airport_type + 7);
SndPlayFx(SND_15_BEEP);
SetWindowDirty(w);
break;
case 16: case 17:
_station_show_coverage = e->we.click.widget - 16;
+ SetWidgetLoweredState(w, 16, !_station_show_coverage);
+ SetWidgetLoweredState(w, 17, _station_show_coverage);
SndPlayFx(SND_15_BEEP);
SetWindowDirty(w);
break;