diff options
-rw-r--r-- | aircraft_gui.c | 45 | ||||
-rw-r--r-- | airport_gui.c | 20 | ||||
-rw-r--r-- | bridge_gui.c | 8 | ||||
-rw-r--r-- | console.c | 14 | ||||
-rw-r--r-- | dock_gui.c | 26 | ||||
-rw-r--r-- | engine_gui.c | 2 | ||||
-rw-r--r-- | genworld_gui.c | 62 | ||||
-rw-r--r-- | graph_gui.c | 32 | ||||
-rw-r--r-- | gui.h | 2 | ||||
-rw-r--r-- | industry_gui.c | 22 | ||||
-rw-r--r-- | intro_gui.c | 12 | ||||
-rw-r--r-- | main_gui.c | 90 | ||||
-rw-r--r-- | misc_gui.c | 56 | ||||
-rw-r--r-- | music_gui.c | 14 | ||||
-rw-r--r-- | network_gui.c | 68 | ||||
-rw-r--r-- | news_gui.c | 30 | ||||
-rw-r--r-- | order_gui.c | 12 | ||||
-rw-r--r-- | player_gui.c | 26 | ||||
-rw-r--r-- | rail_gui.c | 58 | ||||
-rw-r--r-- | road_gui.c | 38 | ||||
-rw-r--r-- | roadveh_gui.c | 44 | ||||
-rw-r--r-- | settings_gui.c | 56 | ||||
-rw-r--r-- | ship_gui.c | 42 | ||||
-rw-r--r-- | smallmap_gui.c | 32 | ||||
-rw-r--r-- | station_gui.c | 26 | ||||
-rw-r--r-- | subsidy_gui.c | 6 | ||||
-rw-r--r-- | terraform_gui.c | 24 | ||||
-rw-r--r-- | town_gui.c | 16 | ||||
-rw-r--r-- | train_gui.c | 58 | ||||
-rw-r--r-- | vehicle_gui.c | 22 | ||||
-rw-r--r-- | viewport.c | 16 | ||||
-rw-r--r-- | widget.c | 4 | ||||
-rw-r--r-- | window.c | 104 | ||||
-rw-r--r-- | window.h | 198 |
34 files changed, 636 insertions, 649 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c index 75a7a332b..53487d609 100644 --- a/aircraft_gui.c +++ b/aircraft_gui.c @@ -182,9 +182,9 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: { /* listbox */ - uint i = (e->click.pt.y - 14) / 24; + uint i = (e->we.click.pt.y - 14) / 24; if (i < w->vscroll.cap) { WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; SetWindowDirty(w); @@ -209,15 +209,15 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e) break; case WE_ON_EDIT_TEXT: { - if (e->edittext.str[0] != '\0') { - _cmd_text = e->edittext.str; + if (e->we.edittext.str[0] != '\0') { + _cmd_text = e->we.edittext.str; DoCommandP(0, WP(w, buildtrain_d).rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(STR_A03A_CAN_T_RENAME_AIRCRAFT_TYPE)); } } break; case WE_RESIZE: - w->vscroll.cap += e->sizing.diff.y / 24; + w->vscroll.cap += e->we.sizing.diff.y / 24; w->widget[2].data = (w->vscroll.cap << 8) + 1; break; } @@ -289,9 +289,9 @@ static void AircraftRefitWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: { /* listbox */ - int y = e->click.pt.y - 25; + int y = e->we.click.pt.y - 25; if (y >= 0) { WP(w,refit_d).sel = y / 10; SetWindowDirty(w); @@ -433,7 +433,7 @@ static void AircraftDetailsWndProc(Window *w, WindowEvent *e) case WE_CLICK: { int mod; const Vehicle *v; - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: /* rename */ v = GetVehicle(w->window_number); SetDParam(0, v->unitnumber); @@ -456,8 +456,8 @@ do_change_service_int: } break; case WE_ON_EDIT_TEXT: - if (e->edittext.str[0] != '\0') { - _cmd_text = e->edittext.str; + if (e->we.edittext.str[0] != '\0') { + _cmd_text = e->we.edittext.str; DoCommandP(0, w->window_number, 0, NULL, CMD_NAME_VEHICLE | CMD_MSG(STR_A031_CAN_T_NAME_AIRCRAFT)); } @@ -588,7 +588,7 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e) case WE_CLICK: { const Vehicle *v = GetVehicle(w->window_number); - switch (e->click.widget) { + switch (e->we.click.widget) { case 5: /* start stop */ DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT)); break; @@ -615,10 +615,10 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e) } break; case WE_RESIZE: - w->viewport->width += e->sizing.diff.x; - w->viewport->height += e->sizing.diff.y; - w->viewport->virtual_width += e->sizing.diff.x; - w->viewport->virtual_height += e->sizing.diff.y; + w->viewport->width += e->we.sizing.diff.x; + w->viewport->height += e->we.sizing.diff.y; + w->viewport->virtual_width += e->we.sizing.diff.x; + w->viewport->virtual_height += e->we.sizing.diff.y; break; case WE_DESTROY: @@ -661,11 +661,10 @@ void ShowAircraftViewWindow(const Vehicle *v) static void DrawAircraftDepotWindow(Window *w) { - TileIndex tile; + TileIndex tile = w->window_number; Vehicle *v; int num,x,y; - tile = w->window_number; /* setup disabled buttons */ w->disabled_state = @@ -811,9 +810,9 @@ static void AircraftDepotWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 5: /* click aircraft */ - AircraftDepotClickAircraft(w, e->click.pt.x, e->click.pt.y); + AircraftDepotClickAircraft(w, e->we.click.pt.x, e->we.click.pt.y); break; case 7: /* show build aircraft window */ @@ -862,7 +861,7 @@ static void AircraftDepotWndProc(Window *w, WindowEvent *e) break; case WE_DRAGDROP: - switch (e->click.widget) { + switch (e->we.click.widget) { case 5: { Vehicle *v; VehicleID sel = WP(w,traindepot_d).sel; @@ -870,7 +869,7 @@ static void AircraftDepotWndProc(Window *w, WindowEvent *e) WP(w,traindepot_d).sel = INVALID_VEHICLE; SetWindowDirty(w); - if (GetVehicleFromAircraftDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &v) == 0 && + if (GetVehicleFromAircraftDepotWndPt(w, e->we.dragdrop.pt.x, e->we.dragdrop.pt.y, &v) == 0 && v != NULL && sel == v->index) { ShowAircraftViewWindow(v); @@ -901,8 +900,8 @@ static void AircraftDepotWndProc(Window *w, WindowEvent *e) break; case WE_RESIZE: - w->vscroll.cap += e->sizing.diff.y / 24; - w->hscroll.cap += e->sizing.diff.x / 74; + w->vscroll.cap += e->we.sizing.diff.y / 24; + w->hscroll.cap += e->we.sizing.diff.x / 74; w->widget[5].data = (w->vscroll.cap << 8) + w->hscroll.cap; break; } diff --git a/airport_gui.c b/airport_gui.c index e2927c767..de039ad71 100644 --- a/airport_gui.c +++ b/airport_gui.c @@ -71,12 +71,12 @@ static void BuildAirToolbWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - if (e->click.widget - 3 >= 0) - _build_air_button_proc[e->click.widget - 3](w); + if (e->we.click.widget - 3 >= 0) + _build_air_button_proc[e->we.click.widget - 3](w); break; case WE_KEYPRESS: { - switch (e->keypress.keycode) { + switch (e->we.keypress.keycode) { case '1': BuildAirClick_Airport(w); break; case '2': BuildAirClick_Demolish(w); break; case 'l': BuildAirClick_Landscaping(w); break; @@ -85,16 +85,16 @@ static void BuildAirToolbWndProc(Window *w, WindowEvent *e) } break; case WE_PLACE_OBJ: - _place_proc(e->place.tile); + _place_proc(e->we.place.tile); break; case WE_PLACE_DRAG: - VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata); + VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata); break; case WE_PLACE_MOUSEUP: - if (e->place.pt.x != -1) { - DoCommandP(e->place.tile, e->place.starttile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); + if (e->we.place.pt.x != -1) { + DoCommandP(e->we.place.tile, e->we.place.starttile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); } break; @@ -192,14 +192,14 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e) } case WE_CLICK: { - switch (e->click.widget) { + switch (e->we.click.widget) { case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: - _selected_airport_type = e->click.widget - 7; + _selected_airport_type = e->we.click.widget - 7; SndPlayFx(SND_15_BEEP); SetWindowDirty(w); break; case 16: case 17: - _station_show_coverage = e->click.widget - 16; + _station_show_coverage = e->we.click.widget - 16; SndPlayFx(SND_15_BEEP); SetWindowDirty(w); break; diff --git a/bridge_gui.c b/bridge_gui.c index 1ee87f1cd..c3a808820 100644 --- a/bridge_gui.c +++ b/bridge_gui.c @@ -59,9 +59,9 @@ static void BuildBridgeWndProc(Window *w, WindowEvent *e) } break; case WE_KEYPRESS: { - uint i = e->keypress.keycode - '1'; + uint i = e->we.keypress.keycode - '1'; if (i < 9 && i < _bridgedata.count) { - e->keypress.cont = false; + e->we.keypress.cont = false; BuildBridge(w, i); } @@ -69,8 +69,8 @@ static void BuildBridgeWndProc(Window *w, WindowEvent *e) } case WE_CLICK: - if (e->click.widget == 2) { - uint ind = ((int)e->click.pt.y - 14) / 22; + if (e->we.click.widget == 2) { + uint ind = ((int)e->we.click.pt.y - 14) / 22; if (ind < 4 && (ind += w->vscroll.pos) < _bridgedata.count) BuildBridge(w, ind); } @@ -98,8 +98,8 @@ static void IConsoleWndProc(Window *w, WindowEvent *e) _iconsole_mode = ICONSOLE_CLOSED; break; case WE_KEYPRESS: - e->keypress.cont = false; - switch (e->keypress.keycode) { + e->we.keypress.cont = false; + switch (e->we.keypress.keycode) { case WKC_UP: IConsoleHistoryNavigate(+1); SetWindowDirty(w); @@ -169,25 +169,25 @@ static void IConsoleWndProc(Window *w, WindowEvent *e) SetWindowDirty(w); break; case WKC_BACKSPACE: case WKC_DELETE: - if (DeleteTextBufferChar(&_iconsole_cmdline, e->keypress.keycode)) { + if (DeleteTextBufferChar(&_iconsole_cmdline, e->we.keypress.keycode)) { IConsoleResetHistoryPos(); SetWindowDirty(w); } break; case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME: - if (MoveTextBufferPos(&_iconsole_cmdline, e->keypress.keycode)) { + if (MoveTextBufferPos(&_iconsole_cmdline, e->we.keypress.keycode)) { IConsoleResetHistoryPos(); SetWindowDirty(w); } break; default: - if (IsValidAsciiChar(e->keypress.ascii, CS_ALPHANUMERAL)) { + if (IsValidAsciiChar(e->we.keypress.ascii, CS_ALPHANUMERAL)) { _iconsole_scroll = ICON_BUFFER; - InsertTextBufferChar(&_iconsole_cmdline, e->keypress.ascii); + InsertTextBufferChar(&_iconsole_cmdline, e->we.keypress.ascii); IConsoleResetHistoryPos(); SetWindowDirty(w); } else { - e->keypress.cont = true; + e->we.keypress.cont = true; } break; } diff --git a/dock_gui.c b/dock_gui.c index 6f3c556d0..396c81694 100644 --- a/dock_gui.c +++ b/dock_gui.c @@ -121,11 +121,11 @@ static void BuildDocksToolbWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - if (e->click.widget - 3 >= 0 && e->click.widget != 5) _build_docks_button_proc[e->click.widget - 3](w); + if (e->we.click.widget - 3 >= 0 && e->we.click.widget != 5) _build_docks_button_proc[e->we.click.widget - 3](w); break; case WE_KEYPRESS: - switch (e->keypress.keycode) { + switch (e->we.keypress.keycode) { case '1': BuildDocksClick_Canal(w); break; case '2': BuildDocksClick_Lock(w); break; case '3': BuildDocksClick_Demolish(w); break; @@ -138,20 +138,20 @@ static void BuildDocksToolbWndProc(Window *w, WindowEvent *e) break; case WE_PLACE_OBJ: - _place_proc(e->place.tile); + _place_proc(e->we.place.tile); break; case WE_PLACE_DRAG: { - VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata); + VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata); return; } case WE_PLACE_MOUSEUP: - if (e->click.pt.x != -1) { - if ((e->place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions + if (e->we.click.pt.x != -1) { + if ((e->we.place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions GUIPlaceProcDragXY(e); - } else if (e->place.userdata == VPM_X_OR_Y) { - DoCommandP(e->place.tile, e->place.starttile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS)); + } else if (e->we.place.userdata == VPM_X_OR_Y) { + DoCommandP(e->we.place.tile, e->we.place.starttile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS)); } } break; @@ -171,7 +171,7 @@ static void BuildDocksToolbWndProc(Window *w, WindowEvent *e) TileIndex tile_from; TileIndex tile_to; - tile_from = tile_to = e->place.tile; + tile_from = tile_to = e->we.place.tile; switch (GetTileSlope(tile_from, NULL)) { case SLOPE_SW: tile_to += TileDiffXY(-1, 0); break; case SLOPE_SE: tile_to += TileDiffXY( 0, -1); break; @@ -240,10 +240,10 @@ static void BuildDockStationWndProc(Window *w, WindowEvent *e) } case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: case 4: - _station_show_coverage = e->click.widget - 3; + _station_show_coverage = e->we.click.widget - 3; SndPlayFx(SND_15_BEEP); SetWindowDirty(w); break; @@ -311,10 +311,10 @@ static void BuildDocksDepotWndProc(Window *w, WindowEvent *e) return; case WE_CLICK: { - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: case 4: - _ship_depot_direction = e->click.widget - 3; + _ship_depot_direction = e->we.click.widget - 3; SndPlayFx(SND_15_BEEP); UpdateDocksDirection(); SetWindowDirty(w); diff --git a/engine_gui.c b/engine_gui.c index d3b3c39c6..8009994ae 100644 --- a/engine_gui.c +++ b/engine_gui.c @@ -92,7 +92,7 @@ static void EnginePreviewWndProc(Window *w, WindowEvent *e) } case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: DeleteWindow(w); break; diff --git a/genworld_gui.c b/genworld_gui.c index 5edd2be09..0c33a8125 100644 --- a/genworld_gui.c +++ b/genworld_gui.c @@ -318,10 +318,10 @@ void GenerateLandscapeWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 0: DeleteWindow(w); break; case 3: case 4: case 5: case 6: - SetNewLandscapeType(e->click.widget - 3); + SetNewLandscapeType(e->we.click.widget - 3); break; case 7: case 8: // Mapsize X ShowDropDownMenu(w, mapsizes, _patches_newgame.map_x - 6, 8, 0, 0); @@ -353,10 +353,10 @@ void GenerateLandscapeWndProc(Window *w, WindowEvent *e) case 18: case 20: // Year buttons /* Don't allow too fast scrolling */ if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { - HandleButtonClick(w, e->click.widget); + HandleButtonClick(w, e->we.click.widget); SetWindowDirty(w); - _patches_newgame.starting_year = clamp(_patches_newgame.starting_year + e->click.widget - 19, MIN_YEAR, MAX_YEAR); + _patches_newgame.starting_year = clamp(_patches_newgame.starting_year + e->we.click.widget - 19, MIN_YEAR, MAX_YEAR); } _left_button_clicked = false; break; @@ -368,10 +368,10 @@ void GenerateLandscapeWndProc(Window *w, WindowEvent *e) case 21: case 23: // Snow line buttons /* Don't allow too fast scrolling */ if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { - HandleButtonClick(w, e->click.widget); + HandleButtonClick(w, e->we.click.widget); SetWindowDirty(w); - _patches_newgame.snow_line_height = clamp(_patches_newgame.snow_line_height + e->click.widget - 22, 2, 13); + _patches_newgame.snow_line_height = clamp(_patches_newgame.snow_line_height + e->we.click.widget - 22, 2, 13); } _left_button_clicked = false; break; @@ -429,52 +429,52 @@ void GenerateLandscapeWndProc(Window *w, WindowEvent *e) break; case WE_DROPDOWN_SELECT: - switch (e->dropdown.button) { - case 8: _patches_newgame.map_x = e->dropdown.index + 6; break; - case 10: _patches_newgame.map_y = e->dropdown.index + 6; break; + switch (e->we.dropdown.button) { + case 8: _patches_newgame.map_x = e->we.dropdown.index + 6; break; + case 10: _patches_newgame.map_y = e->we.dropdown.index + 6; break; case 12: - _opt_newgame.diff.number_towns = e->dropdown.index; + _opt_newgame.diff.number_towns = e->we.dropdown.index; if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0); DoCommandP(0, 2, _opt_newgame.diff.number_towns, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); break; case 14: - _opt_newgame.diff.number_industries = e->dropdown.index; + _opt_newgame.diff.number_industries = e->we.dropdown.index; if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0); DoCommandP(0, 3, _opt_newgame.diff.number_industries, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); break; case 25: - _patches_newgame.tree_placer = e->dropdown.index; + _patches_newgame.tree_placer = e->we.dropdown.index; break; case 27: if (mode == GLWP_HEIGHTMAP) { - _patches_newgame.heightmap_rotation = e->dropdown.index; + _patches_newgame.heightmap_rotation = e->we.dropdown.index; } else { - _patches_newgame.land_generator = e->dropdown.index; + _patches_newgame.land_generator = e->we.dropdown.index; } break; // case 29: case 28: - _opt_newgame.diff.terrain_type = e->dropdown.index; + _opt_newgame.diff.terrain_type = e->we.dropdown.index; if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0); DoCommandP(0, 12, _opt_newgame.diff.terrain_type, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); break; // case 31: case 29: - _opt_newgame.diff.quantity_sea_lakes = e->dropdown.index; + _opt_newgame.diff.quantity_sea_lakes = e->we.dropdown.index; if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0); DoCommandP(0, 13, _opt_newgame.diff.quantity_sea_lakes, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); break; // case 33: case 31: - _patches_newgame.tgen_smoothness = e->dropdown.index; + _patches_newgame.tgen_smoothness = e->we.dropdown.index; break; } SetWindowDirty(w); break; case WE_ON_EDIT_TEXT: { - if (e->edittext.str != NULL) { - int32 value = atoi(e->edittext.str); + if (e->we.edittext.str != NULL) { + int32 value = atoi(e->we.edittext.str); switch (WP(w, def_d).data_3) { case START_DATE_QUERY: @@ -600,10 +600,10 @@ void CreateScenarioWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 0: DeleteWindow(w); break; case 3: case 4: case 5: case 6: - SetNewLandscapeType(e->click.widget - 3); + SetNewLandscapeType(e->we.click.widget - 3); break; case 7: case 8: // Mapsize X ShowDropDownMenu(w, mapsizes, _patches_newgame.map_x - 6, 8, 0, 0); @@ -625,10 +625,10 @@ void CreateScenarioWndProc(Window *w, WindowEvent *e) case 14: case 16: // Year buttons /* Don't allow too fast scrolling */ if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { - HandleButtonClick(w, e->click.widget); + HandleButtonClick(w, e->we.click.widget); SetWindowDirty(w); - _patches_newgame.starting_year = clamp(_patches_newgame.starting_year + e->click.widget - 15, MIN_YEAR, MAX_YEAR); + _patches_newgame.starting_year = clamp(_patches_newgame.starting_year + e->we.click.widget - 15, MIN_YEAR, MAX_YEAR); } _left_button_clicked = false; break; @@ -640,10 +640,10 @@ void CreateScenarioWndProc(Window *w, WindowEvent *e) case 17: case 19: // Height level buttons /* Don't allow too fast scrolling */ if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) { - HandleButtonClick(w, e->click.widget); + HandleButtonClick(w, e->we.click.widget); SetWindowDirty(w); - _patches_newgame.se_flat_world_height = clamp(_patches_newgame.se_flat_world_height + e->click.widget - 18, 0, 15); + _patches_newgame.se_flat_world_height = clamp(_patches_newgame.se_flat_world_height + e->we.click.widget - 18, 0, 15); } _left_button_clicked = false; break; @@ -656,9 +656,9 @@ void CreateScenarioWndProc(Window *w, WindowEvent *e) break; case WE_DROPDOWN_SELECT: - switch (e->dropdown.button) { - case 8: _patches_newgame.map_x = e->dropdown.index + 6; break; - case 10: _patches_newgame.map_y = e->dropdown.index + 6; break; + switch (e->we.dropdown.button) { + case 8: _patches_newgame.map_x = e->we.dropdown.index + 6; break; + case 10: _patches_newgame.map_y = e->we.dropdown.index + 6; break; } SetWindowDirty(w); break; @@ -668,8 +668,8 @@ void CreateScenarioWndProc(Window *w, WindowEvent *e) break; case WE_ON_EDIT_TEXT: { - if (e->edittext.str != NULL) { - int32 value = atoi(e->edittext.str); + if (e->we.edittext.str != NULL) { + int32 value = atoi(e->we.edittext.str); switch (WP(w, def_d).data_3) { case START_DATE_QUERY: @@ -760,7 +760,7 @@ static void ShowTerrainProgressProc(Window* w, WindowEvent* e) { switch (e->event) { case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE); ShowQuery(STR_GENERATION_ABORT_CAPTION, STR_GENERATION_ABORT_MESSAGE, AbortGeneratingWorldCallback, WC_GENERATE_PROGRESS_WINDOW, 0); diff --git a/graph_gui.c b/graph_gui.c index 58f4ac638..a24f17019 100644 --- a/graph_gui.c +++ b/graph_gui.c @@ -243,8 +243,8 @@ static void GraphLegendWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - if (IS_INT_INSIDE(e->click.widget, 3, 11)) { - _legend_excludebits ^= (1 << (e->click.widget - 3)); + if (IS_INT_INSIDE(e->we.click.widget, 3, 11)) { + _legend_excludebits ^= (1 << (e->we.click.widget - 3)); SetWindowDirty(w); InvalidateWindow(WC_INCOME_GRAPH, 0); InvalidateWindow(WC_OPERATING_PROFIT, 0); @@ -358,7 +358,7 @@ static void OperatingProfitWndProc(Window *w, WindowEvent *e) DrawGraph(&gd); } break; case WE_CLICK: - if (e->click.widget == 2) /* Clicked on Legend */ + if (e->we.click.widget == 2) /* Clicked on Legend */ ShowGraphLegend(); break; } @@ -433,7 +433,7 @@ static void IncomeGraphWndProc(Window *w, WindowEvent *e) } case WE_CLICK: - if (e->click.widget == 2) + if (e->we.click.widget == 2) ShowGraphLegend(); break; } @@ -506,7 +506,7 @@ static void DeliveredCargoGraphWndProc(Window *w, WindowEvent *e) } case WE_CLICK: - if (e->click.widget == 2) + if (e->we.click.widget == 2) ShowGraphLegend(); break; } @@ -579,9 +579,9 @@ static void PerformanceHistoryWndProc(Window *w, WindowEvent *e) } case WE_CLICK: - if (e->click.widget == 2) + if (e->we.click.widget == 2) ShowGraphLegend(); - if (e->click.widget == 3) + if (e->we.click.widget == 3) ShowPerformanceRatingDetail(); break; } @@ -655,7 +655,7 @@ static void CompanyValueGraphWndProc(Window *w, WindowEvent *e) } case WE_CLICK: - if (e->click.widget == 2) + if (e->we.click.widget == 2) ShowGraphLegend(); break; } @@ -739,11 +739,11 @@ static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: { - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: - _legend_cargobits ^= 1 << (e->click.widget - 3); + _legend_cargobits ^= 1 << (e->we.click.widget - 3); SetWindowDirty(w); break; } @@ -998,10 +998,10 @@ static void PerformanceRatingDetailWndProc(Window *w, WindowEvent *e) case WE_CLICK: // Check which button is clicked - if (IS_INT_INSIDE(e->click.widget, 13, 21)) { + if (IS_INT_INSIDE(e->we.click.widget, 13, 21)) { // Is it no on disable? - if ((w->disabled_state & (1 << e->click.widget)) == 0) { - w->click_state = 1 << e->click.widget; + if ((w->disabled_state & (1 << e->we.click.widget)) == 0) { + w->click_state = 1 << e->we.click.widget; SetWindowDirty(w); } } @@ -1175,9 +1175,9 @@ static void SignListWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: { - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: { - uint32 id_v = (e->click.pt.y - 15) / 10; + uint32 id_v = (e->we.click.pt.y - 15) / 10; const Sign *si; if (id_v >= w->vscroll.cap) @@ -1195,7 +1195,7 @@ static void SignListWndProc(Window *w, WindowEvent *e) } break; case WE_RESIZE: - w->vscroll.cap += e->sizing.diff.y / 10; + w->vscroll.cap += e->we.sizing.diff.y / 10; break; } } @@ -72,7 +72,7 @@ void ShowHeightmapLoad(void); void PlaceProc_DemolishArea(TileIndex tile); void PlaceProc_LevelLand(TileIndex tile); -bool GUIPlaceProcDragXY(const WindowEvent *we); +bool GUIPlaceProcDragXY(const WindowEvent *e); enum { // max 32 - 4 = 28 types GUI_PlaceProc_DemolishArea = 0 << 4, diff --git a/industry_gui.c b/industry_gui.c index 1671098be..49ee097ba 100644 --- a/industry_gui.c +++ b/industry_gui.c @@ -37,7 +37,7 @@ static void BuildIndustryWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: { - int wid = e->click.widget; + int wid = e->we.click.widget; if (wid >= 3) { if (HandlePlacePushButton(w, wid, SPR_CURSOR_INDUSTRY, 1, NULL)) WP(w,def_d).data_1 = wid - 3; @@ -45,7 +45,7 @@ static void BuildIndustryWndProc(Window *w, WindowEvent *e) } break; case WE_PLACE_OBJ: - if (DoCommandP(e->place.tile, _build_industry_types[_opt_ptr->landscape][WP(w,def_d).data_1], 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY))) + if (DoCommandP(e->we.place.tile, _build_industry_types[_opt_ptr->landscape][WP(w,def_d).data_1], 0, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY))) ResetObjectToPlace(); break; @@ -347,7 +347,7 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e) case WE_CLICK: { Industry *i; - switch (e->click.widget) { + switch (e->we.click.widget) { case 5: { int line, x; @@ -356,9 +356,9 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e) // We should work if needed.. if (!IsProductionAlterable(i)) return; - x = e->click.pt.x; - line = (e->click.pt.y - 127) / 10; - if (e->click.pt.y >= 127 && IS_INT_INSIDE(line, 0, 2) && i->produced_cargo[line] != CT_INVALID) { + x = e->we.click.pt.x; + line = (e->we.click.pt.y - 127) / 10; + if (e->we.click.pt.y >= 127 && IS_INT_INSIDE(line, 0, 2) && i->produced_cargo[line] != CT_INVALID) { if (IS_INT_INSIDE(x, 5, 25) ) { /* Clicked buttons, decrease or increase production */ if (x < 15) { @@ -399,11 +399,11 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e) break; case WE_ON_EDIT_TEXT: - if (e->edittext.str[0] != '\0') { + if (e->we.edittext.str[0] != '\0') { Industry* i = GetIndustry(w->window_number); int line = WP(w,vp2_d).data_1; - i->production_rate[line] = clampu(atoi(e->edittext.str), 0, 255); + i->production_rate[line] = clampu(atoi(e->we.edittext.str), 0, 255); UpdateIndustryProduction(i); SetWindowDirty(w); } @@ -623,7 +623,7 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: { _industry_sort_order = _industry_sort_order==0 ? 1 : 0; _industry_sort_dirty = true; @@ -649,7 +649,7 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e) } break; case 8: { - int y = (e->click.pt.y - 28) / 10; + int y = (e->we.click.pt.y - 28) / 10; uint16 p; if (!IS_INT_INSIDE(y, 0, w->vscroll.cap)) return; @@ -666,7 +666,7 @@ static void IndustryDirectoryWndProc(Window *w, WindowEvent *e) break; case WE_RESIZE: - w->vscroll.cap += e->sizing.diff.y / 10; + w->vscroll.cap += e->we.sizing.diff.y / 10; break; } } diff --git a/intro_gui.c b/intro_gui.c index 9b12a1a5b..c386feb59 100644 --- a/intro_gui.c +++ b/intro_gui.c @@ -54,7 +54,7 @@ static void SelectGameWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: ShowGenerateLandscape(); break; case 3: ShowSaveLoadDialog(SLD_LOAD_GAME); break; case 4: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break; @@ -72,7 +72,7 @@ static void SelectGameWndProc(Window *w, WindowEvent *e) #endif break; case 8: case 9: case 10: case 11: - SetNewLandscapeType(e->click.widget - 8); + SetNewLandscapeType(e->we.click.widget - 8); break; case 12: ShowGameOptions(); break; case 13: ShowGameDifficulty(); break; @@ -131,14 +131,14 @@ static void AskAbandonGameWndProc(Window *w, WindowEvent *e) return; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: DeleteWindow(w); break; case 4: _exit_game = true; break; } break; case WE_KEYPRESS: /* Exit game on pressing 'Enter' */ - switch (e->keypress.keycode) { + switch (e->we.keypress.keycode) { case WKC_RETURN: case WKC_NUM_ENTER: _exit_game = true; @@ -185,14 +185,14 @@ static void AskQuitGameWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: DeleteWindow(w); break; case 4: _switch_mode = SM_MENU; break; } break; case WE_KEYPRESS: /* Return to main menu on pressing 'Enter' */ - if (e->keypress.keycode == WKC_RETURN) _switch_mode = SM_MENU; + if (e->we.keypress.keycode == WKC_RETURN) _switch_mode = SM_MENU; break; } } diff --git a/main_gui.c b/main_gui.c index 8be237ece..9eb0681d8 100644 --- a/main_gui.c +++ b/main_gui.c @@ -50,7 +50,7 @@ extern bool GenerateTowns(void); void HandleOnEditText(WindowEvent *e) { - const char *b = e->edittext.str; + const char *b = e->we.edittext.str; int id; _cmd_text = b; @@ -68,7 +68,7 @@ void HandleOnEditText(WindowEvent *e) #ifdef ENABLE_NETWORK case 3: { /* Give money, you can only give money in excess of loan */ const Player *p = GetPlayer(_current_player); - int32 money = min(p->money64 - p->current_loan, atoi(e->edittext.str) / _currency->rate); + int32 money = min(p->money64 - p->current_loan, atoi(e->we.edittext.str) / _currency->rate); char msg[20]; money = clamp(money, 0, 20000000); // Clamp between 20 million and 0 @@ -475,13 +475,13 @@ static void MenuWndProc(Window *w, WindowEvent *e) } case WE_POPUPMENU_SELECT: { - int index = GetMenuItemIndex(w, e->popupmenu.pt.x, e->popupmenu.pt.y); + int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); int action_id; if (index < 0) { Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0); - if (GetWidgetFromPos(w2, e->popupmenu.pt.x - w2->left, e->popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button) + if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button) index = WP(w,menu_d).sel_index; } @@ -494,7 +494,7 @@ static void MenuWndProc(Window *w, WindowEvent *e) } case WE_POPUPMENU_OVER: { - int index = GetMenuItemIndex(w, e->popupmenu.pt.x, e->popupmenu.pt.y); + int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); if (index == -1 || index == WP(w,menu_d).sel_index) return; @@ -612,7 +612,7 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e) } case WE_POPUPMENU_SELECT: { - int index = GetMenuItemIndex(w, e->popupmenu.pt.x, e->popupmenu.pt.y); + int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); int action_id = WP(w,menu_d).action_id; // We have a new entry at the top of the list of menu 9 when networking @@ -625,7 +625,7 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e) if (index < 0) { Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0); - if (GetWidgetFromPos(w2, e->popupmenu.pt.x - w2->left, e->popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button) + if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button) index = WP(w,menu_d).sel_index; } @@ -640,7 +640,7 @@ static void PlayerMenuWndProc(Window *w, WindowEvent *e) case WE_POPUPMENU_OVER: { int index; UpdatePlayerMenuHeight(w); - index = GetMenuItemIndex(w, e->popupmenu.pt.x, e->popupmenu.pt.y); + index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); // We have a new entry at the top of the list of menu 9 when networking // so keep that in count @@ -1265,8 +1265,8 @@ static void ScenEditLandGenWndProc(Window *w, WindowEvent *e) uint i; for (i = 0; i != lengthof(_editor_terraform_keycodes); i++) { - if (e->keypress.keycode == _editor_terraform_keycodes[i]) { - e->keypress.cont = false; + if (e->we.keypress.keycode == _editor_terraform_keycodes[i]) { + e->we.keypress.cont = false; _editor_terraform_button_proc[i](w); break; } @@ -1274,13 +1274,13 @@ static void ScenEditLandGenWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: - _editor_terraform_button_proc[e->click.widget - 4](w); + _editor_terraform_button_proc[e->we.click.widget - 4](w); break; case 12: case 13: { /* Increase/Decrease terraform size */ - int size = (e->click.widget == 12) ? 1 : -1; - HandleButtonClick(w, e->click.widget); + int size = (e->we.click.widget == 12) ? 1 : -1; + HandleButtonClick(w, e->we.click.widget); size += _terraform_size; if (!IS_INT_INSIDE(size, 1, 8 + 1)) return; @@ -1300,15 +1300,15 @@ static void ScenEditLandGenWndProc(Window *w, WindowEvent *e) UnclickSomeWindowButtons(w, ~(1<<4 | 1<<5 | 1<<6 | 1<<7 | 1<<8 | 1<<9 | 1<<10 | 1<<11)); break; case WE_PLACE_OBJ: - _place_proc(e->place.tile); + _place_proc(e->we.place.tile); break; case WE_PLACE_DRAG: - VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata & 0xF); + VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF); break; case WE_PLACE_MOUSEUP: - if (e->click.pt.x != -1) { - if ((e->place.userdata & 0xF) == VPM_X_AND_Y) // dragged actions + if (e->we.click.pt.x != -1) { + if ((e->we.place.userdata & 0xF) == VPM_X_AND_Y) // dragged actions GUIPlaceProcDragXY(e); } break; @@ -1383,7 +1383,7 @@ static void ScenEditTownGenWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 4: /* new town */ HandlePlacePushButton(w, 4, SPR_CURSOR_TOWN, 1, PlaceProc_Town); break; @@ -1413,7 +1413,7 @@ static void ScenEditTownGenWndProc(Window *w, WindowEvent *e) } case 7: case 8: case 9: - w->click_state = 1 << e->click.widget; + w->click_state = 1 << e->we.click.widget; SetWindowDirty(w); break; } @@ -1423,7 +1423,7 @@ static void ScenEditTownGenWndProc(Window *w, WindowEvent *e) UnclickSomeWindowButtons(w, 1<<5 | 1<<6); break; case WE_PLACE_OBJ: - _place_proc(e->place.tile); + _place_proc(e->we.place.tile); break; case WE_ABORT_PLACE_OBJ: w->click_state &= (1 << 7 | 1 << 8 | 1 << 9); @@ -1594,7 +1594,7 @@ static void ScenEditIndustryWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - if (e->click.widget == 3) { + if (e->we.click.widget == 3) { HandleButtonClick(w, 3); if (!AnyTownExists()) { @@ -1607,7 +1607,7 @@ static void ScenEditIndustryWndProc(Window *w, WindowEvent *e) _generating_world = false; } - if ((button=e->click.widget) >= 4) { + if ((button=e->we.click.widget) >= 4) { if (HandlePlacePushButton(w, button, SPR_CURSOR_INDUSTRY, 1, NULL)) _industry_type_to_place = _industry_type_list[_opt.landscape][button - 4]; } @@ -1619,16 +1619,16 @@ static void ScenEditIndustryWndProc(Window *w, WindowEvent *e) type = _industry_type_to_place; if (!AnyTownExists()) { SetDParam(0, type + STR_4802_COAL_MINE); - ShowErrorMessage(STR_0286_MUST_BUILD_TOWN_FIRST,STR_0285_CAN_T_BUILD_HERE,e->place.pt.x, e->place.pt.y); + ShowErrorMessage(STR_0286_MUST_BUILD_TOWN_FIRST, STR_0285_CAN_T_BUILD_HERE, e->we.place.pt.x, e->we.place.pt.y); return; } _current_player = OWNER_NONE; _generating_world = true; _ignore_restrictions = true; - if (!TryBuildIndustry(e->place.tile,type)) { + if (!TryBuildIndustry(e->we.place.tile,type)) { SetDParam(0, type + STR_4802_COAL_MINE); - ShowErrorMessage(_error_message, STR_0285_CAN_T_BUILD_HERE, e->place.pt.x, e->place.pt.y); + ShowErrorMessage(_error_message, STR_0285_CAN_T_BUILD_HERE, e->we.place.pt.x, e->we.place.pt.y); } _ignore_restrictions = false; _generating_world = false; @@ -1770,14 +1770,14 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e) } case WE_CLICK: { - if (_game_mode != GM_MENU && !HASBIT(w->disabled_state, e->click.widget)) - _toolbar_button_procs[e->click.widget](w); + if (_game_mode != GM_MENU && !HASBIT(w->disabled_state, e->we.click.widget)) + _toolbar_button_procs[e->we.click.widget](w); } break; case WE_KEYPRESS: { PlayerID local = (_local_player != OWNER_SPECTATOR) ? _local_player : 0; - switch (e->keypress.keycode) { + switch (e->we.keypress.keycode) { case WKC_F1: case WKC_PAUSE: ToolbarPauseClick(w); break; @@ -1811,11 +1811,11 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e) case 'L': ShowTerraformToolbar(); break; default: return; } - e->keypress.cont = false; + e->we.keypress.cont = false; } break; case WE_PLACE_OBJ: { - _place_proc(e->place.tile); + _place_proc(e->we.place.tile); } break; case WE_ABORT_PLACE_OBJ: { @@ -1988,11 +1988,11 @@ static void ScenEditToolbarWndProc(Window *w, WindowEvent *e) case WE_CLICK: { if (_game_mode == GM_MENU) return; - _scen_toolbar_button_procs[e->click.widget](w); + _scen_toolbar_button_procs[e->we.click.widget](w); } break; case WE_KEYPRESS: - switch (e->keypress.keycode) { + switch (e->we.keypress.keycode) { case WKC_F1: ToolbarPauseClick(w); break; case WKC_F2: ShowGameOptions(); break; case WKC_F3: MenuClickSaveLoad(0); break; @@ -2011,7 +2011,7 @@ static void ScenEditToolbarWndProc(Window *w, WindowEvent *e) break; case WE_PLACE_OBJ: { - _place_proc(e->place.tile); + _place_proc(e->we.place.tile); } break; case WE_ABORT_PLACE_OBJ: { @@ -2134,12 +2134,12 @@ static void StatusBarWndProc(Window *w, WindowEvent *e) } break; case WE_MESSAGE: - w->message.msg = e->message.msg; + w->message.msg = e->we.message.msg; SetWindowDirty(w); break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 1: ShowLastNewsMessage(); break; case 2: if (_local_player != OWNER_SPECTATOR) ShowPlayerFinances(_local_player); break; default: ResetObjectToPlace(); @@ -2223,7 +2223,7 @@ static void MainWindowWndProc(Window *w, WindowEvent *e) break; case WE_KEYPRESS: - switch (e->keypress.keycode) { + switch (e->we.keypress.keycode) { case 'Q' | WKC_CTRL: case 'Q' | WKC_META: HandleExitGameRequest(); @@ -2236,21 +2236,21 @@ static void MainWindowWndProc(Window *w, WindowEvent *e) * assertions that are hard to trigger and debug */ if (IsGeneratingWorld()) break; - if (e->keypress.keycode == WKC_BACKQUOTE) { + if (e->we.keypress.keycode == WKC_BACKQUOTE) { IConsoleSwitch(); - e->keypress.cont = false; + e->we.keypress.cont = false; break; } if (_game_mode == GM_MENU) break; - switch (e->keypress.keycode) { + switch (e->we.keypress.keycode) { case 'C': case 'Z': { Point pt = GetTileBelowCursor(); if (pt.x != -1) { ScrollMainWindowTo(pt.x, pt.y); - if (e->keypress.keycode == 'Z') MaxZoomIn(); + if (e->we.keypress.keycode == 'Z') MaxZoomIn(); } break; } @@ -2291,7 +2291,7 @@ static void MainWindowWndProc(Window *w, WindowEvent *e) default: return; } - e->keypress.cont = false; + e->we.keypress.cont = false; break; case WE_SCROLL: { @@ -2302,12 +2302,12 @@ static void MainWindowWndProc(Window *w, WindowEvent *e) _scrolling_viewport = false; } - WP(w, vp_d).scrollpos_x += e->scroll.delta.x << vp->zoom; - WP(w, vp_d).scrollpos_y += e->scroll.delta.y << vp->zoom; + WP(w, vp_d).scrollpos_x += e->we.scroll.delta.x << vp->zoom; + WP(w, vp_d).scrollpos_y += e->we.scroll.delta.y << vp->zoom; } break; case WE_MOUSEWHEEL: - ZoomInOrOutToCursorWindow(e->wheel.wheel < 0, w); + ZoomInOrOutToCursorWindow(e->we.wheel.wheel < 0, w); break; } } diff --git a/misc_gui.c b/misc_gui.c index 491f0912e..3654e6fc2 100644 --- a/misc_gui.c +++ b/misc_gui.c @@ -332,7 +332,7 @@ static void BuildTreesWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: { - int wid = e->click.widget; + int wid = e->we.click.widget; switch (wid) { case 0: @@ -364,17 +364,17 @@ static void BuildTreesWndProc(Window *w, WindowEvent *e) } break; case WE_PLACE_OBJ: - VpStartPlaceSizing(e->place.tile, VPM_X_AND_Y_LIMITED); + VpStartPlaceSizing(e->we.place.tile, VPM_X_AND_Y_LIMITED); VpSetPlaceSizingLimit(20); break; case WE_PLACE_DRAG: - VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata); + VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata); return; case WE_PLACE_MOUSEUP: - if (e->click.pt.x != -1) { - DoCommandP(e->place.tile, _tree_to_plant, e->place.starttile, NULL, + if (e->we.click.pt.x != -1) { + DoCommandP(e->we.place.tile, _tree_to_plant, e->we.place.starttile, NULL, CMD_PLANT_TREE | CMD_AUTO | CMD_MSG(STR_2805_CAN_T_PLANT_TREE_HERE)); } break; @@ -528,9 +528,9 @@ static void ErrmsgWndProc(Window *w, WindowEvent *e) break; case WE_KEYPRESS: - if (e->keypress.keycode == WKC_SPACE) { + if (e->we.keypress.keycode == WKC_SPACE) { // Don't continue. - e->keypress.cont = false; + e->we.keypress.cont = false; DeleteWindow(w); } break; @@ -900,11 +900,11 @@ void UpdateTextBufferSize(Textbuf *tb) tb->caretxoffs = tb->width; } -int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *we, CharSetFilter afilter) +int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *e, CharSetFilter afilter) { - we->keypress.cont = false; + e->we.keypress.cont = false; - switch (we->keypress.keycode) { + switch (e->we.keypress.keycode) { case WKC_ESC: return 2; case WKC_RETURN: case WKC_NUM_ENTER: return 1; case (WKC_CTRL | 'V'): @@ -916,19 +916,19 @@ int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *we, Ch InvalidateWidget(w, wid); break; case WKC_BACKSPACE: case WKC_DELETE: - if (DeleteTextBufferChar(&string->text, we->keypress.keycode)) + if (DeleteTextBufferChar(&string->text, e->we.keypress.keycode)) InvalidateWidget(w, wid); break; case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME: - if (MoveTextBufferPos(&string->text, we->keypress.keycode)) + if (MoveTextBufferPos(&string->text, e->we.keypress.keycode)) InvalidateWidget(w, wid); break; default: - if (IsValidAsciiChar(we->keypress.ascii, afilter)) { - if (InsertTextBufferChar(&string->text, we->keypress.ascii)) + if (IsValidAsciiChar(e->we.keypress.ascii, afilter)) { + if (InsertTextBufferChar(&string->text, e->we.keypress.ascii)) InvalidateWidget(w, wid); } else { // key wasn't caught. Continue only if standard entry specified - we->keypress.cont = (afilter == CS_ALPHANUMERAL); + e->we.keypress.cont = (afilter == CS_ALPHANUMERAL); } } @@ -979,7 +979,7 @@ static void QueryStringWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: DeleteWindow(w); break; case 4: press_ok:; @@ -1001,7 +1001,7 @@ press_ok:; if (parent != NULL) { WindowEvent e; e.event = WE_ON_EDIT_TEXT; - e.edittext.str = buf; + e.we.edittext.str = buf; parent->wndproc(parent, &e); } } @@ -1108,11 +1108,11 @@ static void QueryWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: case 4: WP(w, query_d).calledback = true; - if (WP(w, query_d).ok_cancel_callback != NULL) WP(w, query_d).ok_cancel_callback(e->click.widget == 4); + if (WP(w, query_d).ok_cancel_callback != NULL) WP(w, query_d).ok_cancel_callback(e->we.click.widget == 4); DeleteWindow(w); break; } @@ -1379,7 +1379,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e) } case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: /* Sort save names by name */ _savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ? SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME; @@ -1401,7 +1401,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e) break; case 7: { /* Click the listbox */ - int y = (e->click.pt.y - w->widget[e->click.widget].top - 1) / 10; + int y = (e->we.click.pt.y - w->widget[e->we.click.widget].top - 1) / 10; char *name; const FiosItem *file; @@ -1448,7 +1448,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e) HandleEditBox(w, &WP(w, querystr_d), 10); break; case WE_KEYPRESS: - if (e->keypress.keycode == WKC_ESC) { + if (e->we.keypress.keycode == WKC_ESC) { DeleteWindow(w); return; } @@ -1488,19 +1488,19 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e) break; case WE_RESIZE: { /* Widget 2 and 3 have to go with halve speed, make it so obiwan */ - uint diff = e->sizing.diff.x / 2; + uint diff = e->we.sizing.diff.x / 2; w->widget[2].right += diff; w->widget[3].left += diff; - w->widget[3].right += e->sizing.diff.x; + w->widget[3].right += e->we.sizing.diff.x; /* Same for widget 11 and 12 in save-dialog */ if (_saveload_mode == SLD_SAVE_GAME || _saveload_mode == SLD_SAVE_SCENARIO) { w->widget[11].right += diff; w->widget[12].left += diff; - w->widget[12].right += e->sizing.diff.x; + w->widget[12].right += e->we.sizing.diff.x; } - w->vscroll.cap += e->sizing.diff.y / 10; + w->vscroll.cap += e->we.sizing.diff.y / 10; } break; } } @@ -1795,9 +1795,9 @@ static void CheatsWndProc(Window *w, WindowEvent *e) case WE_CLICK: { const CheatEntry *ce; - uint btn = (e->click.pt.y - 46) / 12; + uint btn = (e->we.click.pt.y - 46) / 12; int32 value, oldvalue; - uint x = e->click.pt.x; + uint x = e->we.click.pt.x; // not clicking a button? if (!IS_INT_INSIDE(x, 20, 40) || btn >= lengthof(_cheats_ui)) break; diff --git a/music_gui.c b/music_gui.c index 79d443169..c98ead015 100644 --- a/music_gui.c +++ b/music_gui.c @@ -239,9 +239,9 @@ static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e) } case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: { /* add to playlist */ - int y = (e->click.pt.y - 23) / 6; + int y = (e->we.click.pt.y - 23) / 6; uint i; byte *p; @@ -261,7 +261,7 @@ static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e) } break; case 4: { /* remove from playlist */ - int y = (e->click.pt.y - 23) / 6; + int y = (e->we.click.pt.y - 23) / 6; uint i; byte *p; @@ -291,7 +291,7 @@ static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e) #endif case 5: case 6: case 7: case 8: case 9: case 10: /* set playlist */ - msf.playlist = e->click.widget - 5; + msf.playlist = e->we.click.widget - 5; SetWindowDirty(w); InvalidateWindow(WC_MUSIC_WINDOW, 0); StopMusic(); @@ -402,7 +402,7 @@ static void MusicWindowWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: // skip to prev if (!_song_is_active) return; @@ -421,7 +421,7 @@ static void MusicWindowWndProc(Window *w, WindowEvent *e) break; case 6:{ // volume sliders byte *vol,new_vol; - int x = e->click.pt.x - 88; + int x = e->we.click.pt.x - 88; if (x < 0) return; @@ -451,7 +451,7 @@ static void MusicWindowWndProc(Window *w, WindowEvent *e) ShowMusicTrackSelection(); break; case 12: case 13: case 14: case 15: case 16: case 17: // playlist - msf.playlist = e->click.widget - 12; + msf.playlist = e->we.click.widget - 12; SetWindowDirty(w); InvalidateWindow(WC_MUSIC_TRACK_SELECTION, 0); StopMusic(); diff --git a/network_gui.c b/network_gui.c index bc1eea67e..5f843c05a 100644 --- a/network_gui.c +++ b/network_gui.c @@ -385,8 +385,8 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - nd->field = e->click.widget; - switch (e->click.widget) { + nd->field = e->we.click.widget; + switch (e->we.click.widget) { case 0: case 14: /* Close 'X' | Cancel button */ DeleteWindowById(WC_NETWORK_WINDOW, 0); break; @@ -396,9 +396,9 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e) case 6: /* Sort by name */ case 7: /* Sort by connected clients */ case 8: /* Connectivity (green dot) */ - if (ld->sort_type == e->click.widget - 6) ld->flags ^= VL_DESC; + if (ld->sort_type == e->we.click.widget - 6) ld->flags ^= VL_DESC; ld->flags |= VL_RESORT; - ld->sort_type = e->click.widget - 6; + ld->sort_type = e->we.click.widget - 6; _ng_sorting.order = !!(ld->flags & VL_DESC); _ng_sorting.criteria = ld->sort_type; @@ -406,7 +406,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e) break; case 9: { /* Matrix to show networkgames */ NetworkGameList *cur_item; - uint32 id_v = (e->click.pt.y - NET_PRC__OFFSET_TOP_WIDGET) / NET_PRC__SIZE_OF_ROW; + uint32 id_v = (e->we.click.pt.y - NET_PRC__OFFSET_TOP_WIDGET) / NET_PRC__SIZE_OF_ROW; if (id_v >= w->vscroll.cap) return; // click out of bounds id_v += w->vscroll.pos; @@ -450,9 +450,9 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e) } break; case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ - switch (e->dropdown.button) { + switch (e->we.dropdown.button) { case 5: - _network_lan_internet = e->dropdown.index; + _network_lan_internet = e->we.dropdown.index; break; } @@ -471,7 +471,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e) case WE_KEYPRESS: if (nd->field != 3) { if (nd->server != NULL) { - if (e->keypress.keycode == WKC_DELETE) { /* Press 'delete' to remove servers */ + if (e->we.keypress.keycode == WKC_DELETE) { /* Press 'delete' to remove servers */ NetworkGameListRemoveItem(nd->server); NetworkRebuildHostList(); nd->server = NULL; @@ -492,7 +492,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e) break; case WE_ON_EDIT_TEXT: - NetworkAddServer(e->edittext.str); + NetworkAddServer(e->we.edittext.str); NetworkRebuildHostList(); break; @@ -642,8 +642,8 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - nd->field = e->click.widget; - switch (e->click.widget) { + nd->field = e->we.click.widget; + switch (e->we.click.widget) { case 0: /* Close 'X' */ case 19: /* Cancel button */ ShowNetworkGameWindow(); @@ -655,7 +655,7 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e) break; case 5: { /* Select map */ - int y = (e->click.pt.y - NSSWND_START) / NSSWND_ROWSIZE; + int y = (e->we.click.pt.y - NSSWND_START) / NSSWND_ROWSIZE; y += w->vscroll.pos; if (y >= w->vscroll.count) return; @@ -706,12 +706,12 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e) break; case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ - switch (e->dropdown.button) { - case 8: _network_advertise = (e->dropdown.index != 0); break; - case 10: _network_game_info.clients_max = e->dropdown.index; break; - case 12: _network_game_info.companies_max = e->dropdown.index; break; - case 14: _network_game_info.spectators_max = e->dropdown.index; break; - case 16: _network_game_info.server_lang = e->dropdown.index; break; + switch (e->we.dropdown.button) { + case 8: _network_advertise = (e->we.dropdown.index != 0); break; + case 10: _network_game_info.clients_max = e->we.dropdown.index; break; + case 12: _network_game_info.companies_max = e->we.dropdown.index; break; + case 14: _network_game_info.spectators_max = e->we.dropdown.index; break; + case 16: _network_game_info.server_lang = e->we.dropdown.index; break; } SetWindowDirty(w); @@ -731,7 +731,7 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e) break; case WE_ON_EDIT_TEXT: { - ttd_strlcpy(_network_server_password, e->edittext.str, lengthof(_network_server_password)); + ttd_strlcpy(_network_server_password, e->we.edittext.str, lengthof(_network_server_password)); _network_game_info.use_password = (_network_server_password[0] != '\0'); SetWindowDirty(w); } break; @@ -918,12 +918,12 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 0: case 11: /* Close 'X' | Cancel button */ ShowNetworkGameWindow(); break; case 4: { /* Company list */ - uint32 id_v = (e->click.pt.y - NET_PRC__OFFSET_TOP_WIDGET_COMPANY) / NET_PRC__SIZE_OF_ROW; + uint32 id_v = (e->we.click.pt.y - NET_PRC__OFFSET_TOP_WIDGET_COMPANY) / NET_PRC__SIZE_OF_ROW; if (id_v >= w->vscroll.cap) return; @@ -1276,9 +1276,9 @@ static void ClientListPopupWndProc(Window *w, WindowEvent *e) case WE_POPUPMENU_SELECT: { // We selected an action - int index = (e->popupmenu.pt.y - w->top) / CLNWND_ROWSIZE; + int index = (e->we.popupmenu.pt.y - w->top) / CLNWND_ROWSIZE; - if (index >= 0 && e->popupmenu.pt.y >= w->top) + if (index >= 0 && e->we.popupmenu.pt.y >= w->top) HandleClientListPopupClick(index, WP(w,menu_d).main_button); // Sometimes, because of the bad DeleteWindow-proc, the 'w' pointer is @@ -1291,7 +1291,7 @@ static void ClientListPopupWndProc(Window *w, WindowEvent *e) case WE_POPUPMENU_OVER: { // Our mouse hoovers over an action? Select it! - int index = (e->popupmenu.pt.y - w->top) / CLNWND_ROWSIZE; + int index = (e->we.popupmenu.pt.y - w->top) / CLNWND_ROWSIZE; if (index == -1 || index == WP(w,menu_d).sel_index) return; @@ -1349,26 +1349,26 @@ static void ClientListWndProc(Window *w, WindowEvent *e) case WE_CLICK: // Show the popup with option if (_selected_clientlist_item != 255) { - PopupClientList(w, _selected_clientlist_item, e->click.pt.x + w->left, e->click.pt.y + w->top); + PopupClientList(w, _selected_clientlist_item, e->we.click.pt.x + w->left, e->we.click.pt.y + w->top); } break; case WE_MOUSEOVER: // -1 means we left the current window - if (e->mouseover.pt.y == -1) { + if (e->we.mouseover.pt.y == -1) { _selected_clientlist_y = 0; _selected_clientlist_item = 255; SetWindowDirty(w); break; } // It did not change.. no update! - if (e->mouseover.pt.y == _selected_clientlist_y) break; + if (e->we.mouseover.pt.y == _selected_clientlist_y) break; // Find the new selected item (if any) - _selected_clientlist_y = e->mouseover.pt.y; - if (e->mouseover.pt.y > CLNWND_OFFSET) { - _selected_clientlist_item = (e->mouseover.pt.y - CLNWND_OFFSET) / CLNWND_ROWSIZE; + _selected_clientlist_y = e->we.mouseover.pt.y; + if (e->we.mouseover.pt.y > CLNWND_OFFSET) { + _selected_clientlist_item = (e->we.mouseover.pt.y - CLNWND_OFFSET) / CLNWND_ROWSIZE; } else { _selected_clientlist_item = 255; } @@ -1440,7 +1440,7 @@ static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 0: /* Close 'X' */ case 3: /* Disconnect button */ NetworkDisconnect(); @@ -1457,7 +1457,7 @@ static void NetworkJoinStatusWindowWndProc(Window *w, WindowEvent *e) break; case WE_ON_EDIT_TEXT: - SEND_COMMAND(PACKET_CLIENT_PASSWORD)(pw_type, e->edittext.str); + SEND_COMMAND(PACKET_CLIENT_PASSWORD)(pw_type, e->we.edittext.str); break; } } @@ -1658,7 +1658,7 @@ static void ChatWindowWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: /* Send */ SendChat(WP(w, querystr_d).text.buf); /* FALLTHROUGH */ case 3: /* Cancel */ DeleteWindow(w); break; } @@ -1669,7 +1669,7 @@ static void ChatWindowWndProc(Window *w, WindowEvent *e) break; case WE_KEYPRESS: - if (e->keypress.keycode == WKC_TAB) { + if (e->we.keypress.keycode == WKC_TAB) { ChatTabCompletion(w); } else { _chat_tab_completion_active = false; diff --git a/news_gui.c b/news_gui.c index a426b7d4f..2dbe63294 100644 --- a/news_gui.c +++ b/news_gui.c @@ -167,7 +167,7 @@ static void NewsWindowProc(Window *w, WindowEvent *e) } break; case WE_CLICK: { - switch (e->click.widget) { + switch (e->we.click.widget) { case 1: { NewsItem *ni = WP(w, news_d).ni; DeleteWindow(w); @@ -188,16 +188,16 @@ static void NewsWindowProc(Window *w, WindowEvent *e) } break; case WE_KEYPRESS: - if (e->keypress.keycode == WKC_SPACE) { + if (e->we.keypress.keycode == WKC_SPACE) { // Don't continue. - e->keypress.cont = false; + e->we.keypress.cont = false; DeleteWindow(w); } break; case WE_MESSAGE: /* The chatbar has notified us that is was either created or closed */ - switch (e->message.msg) { - case WE_CREATE: w->message.msg = e->message.wparam; break; + switch (e->we.message.msg) { + case WE_CREATE: w->message.msg = e->we.message.wparam; break; case WE_DESTROY: w->message.msg = 0; break; } break; @@ -604,9 +604,9 @@ static void MessageHistoryWndProc(Window *w, WindowEvent *e) } case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: { - int y = (e->click.pt.y - 19) / 12; + int y = (e->we.click.pt.y - 19) / 12; byte p, q; #if 0 // === DEBUG code only @@ -636,7 +636,7 @@ static void MessageHistoryWndProc(Window *w, WindowEvent *e) break; case WE_RESIZE: - w->vscroll.cap += e->sizing.diff.y / 12; + w->vscroll.cap += e->we.sizing.diff.y / 12; break; } } @@ -749,10 +749,10 @@ static void MessageOptionsWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: /* Clicked on any of the fake widgets */ - if (e->click.pt.x > 13 && e->click.pt.x < 89 && e->click.pt.y > 26 && e->click.pt.y < 146) { - int element = (e->click.pt.y - 26) / 12; + if (e->we.click.pt.x > 13 && e->we.click.pt.x < 89 && e->we.click.pt.y > 26 && e->we.click.pt.y < 146) { + int element = (e->we.click.pt.y - 26) / 12; byte val = (GetNewsDisplayValue(element) + 1) % 3; SetMessageButtonStates(w, val, element); @@ -768,11 +768,11 @@ static void MessageOptionsWndProc(Window *w, WindowEvent *e) break; case 25: /* Change ticker sound on/off */ _news_ticker_sound ^= 1; - TOGGLEBIT(w->click_state, e->click.widget); - InvalidateWidget(w, e->click.widget); + TOGGLEBIT(w->click_state, e->we.click.widget); + InvalidateWidget(w, e->we.click.widget); break; default: { /* Clicked on the [<] .. [>] widgets */ - int wid = e->click.widget; + int wid = e->we.click.widget; if (wid > 2 && wid < 23) { int element = (wid - 3) / 2; byte val = (GetNewsDisplayValue(element) + ((wid & 1) ? -1 : 1)) % 3; @@ -785,7 +785,7 @@ static void MessageOptionsWndProc(Window *w, WindowEvent *e) } break; case WE_DROPDOWN_SELECT: /* Select all settings for newsmessages */ - WP(w, def_d).data_2 = e->dropdown.index; + WP(w, def_d).data_2 = e->we.dropdown.index; _news_display_opt = message_val[WP(w, def_d).data_2]; w->disabled_state = message_dis[WP(w, def_d).data_2]; SetWindowDirty(w); diff --git a/order_gui.c b/order_gui.c index feb1e8179..2bcf0ed76 100644 --- a/order_gui.c +++ b/order_gui.c @@ -408,9 +408,9 @@ static void OrdersWndProc(Window *w, WindowEvent *e) case WE_CLICK: { Vehicle *v = GetVehicle(w->window_number); - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: { /* orders list */ - int sel = (e->click.pt.y - 15) / 10; + int sel = (e->we.click.pt.y - 15) / 10; if ((uint)sel >= w->vscroll.cap) return; @@ -479,8 +479,8 @@ static void OrdersWndProc(Window *w, WindowEvent *e) uint i; for (i = 0; i < lengthof(_order_keycodes); i++) { - if (e->keypress.keycode == _order_keycodes[i]) { - e->keypress.cont = false; + if (e->we.keypress.keycode == _order_keycodes[i]) { + e->we.keypress.cont = false; //see if the button is disabled if (!HASBIT(w->disabled_state, i + 4)) _order_button_proc[i](w, v); break; @@ -493,7 +493,7 @@ static void OrdersWndProc(Window *w, WindowEvent *e) const Vehicle *v = GetVehicle(w->window_number); int s = OrderGetSel(w); - if (e->click.widget != 8) break; + if (e->we.click.widget != 8) break; if (s == v->num_orders || GetVehicleOrder(v, s)->type != OT_GOTO_DEPOT) { GuiShowTooltips(STR_8857_MAKE_THE_HIGHLIGHTED_ORDER); } else { @@ -502,7 +502,7 @@ static void OrdersWndProc(Window *w, WindowEvent *e) } break; case WE_PLACE_OBJ: { - OrdersPlaceObj(GetVehicle(w->window_number), e->place.tile, w); + OrdersPlaceObj(GetVehicle(w->window_number), e->we.place.tile, w); } break; case WE_ABORT_PLACE_OBJ: { diff --git a/player_gui.c b/player_gui.c index f4e9fc598..bfe8da281 100644 --- a/player_gui.c +++ b/player_gui.c @@ -166,7 +166,7 @@ static void PlayerFinancesWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: {/* toggle size */ byte mode = (byte)WP(w,def_d).data_1; bool stickied = !!(w->flags4 & WF_STICKY); @@ -361,7 +361,7 @@ static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e) } case WE_CLICK: { - switch (e->click.widget) { + switch (e->we.click.widget) { /* Livery Class buttons */ case 2: case 3: @@ -370,7 +370,7 @@ static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e) case 6: { LiveryScheme scheme; - WP(w, livery_d).livery_class = e->click.widget - 2; + WP(w, livery_d).livery_class = e->we.click.widget - 2; WP(w, livery_d).sel = 0; /* Select the first item in the list */ @@ -380,7 +380,7 @@ static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e) break; } } - w->click_state = 1 << e->click.widget; + w->click_state = 1 << e->we.click.widget; w->height = 49 + livery_height[WP(w, livery_d).livery_class] * 14; w->widget[13].bottom = w->height - 1; w->widget[13].data = livery_height[WP(w, livery_d).livery_class] << 8 | 1; @@ -400,7 +400,7 @@ static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e) case 13: { LiveryScheme scheme; - LiveryScheme j = (e->click.pt.y - 48) / 14; + LiveryScheme j = (e->we.click.pt.y - 48) / 14; for (scheme = 0; scheme <= j; scheme++) { if (livery_class[scheme] != WP(w, livery_d).livery_class) j++; @@ -409,7 +409,7 @@ static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e) if (j >= LS_END) return; /* If clicking on the left edge, toggle using the livery */ - if (e->click.pt.x < 10) { + if (e->we.click.pt.x < 10) { DoCommandP(0, j | (2 << 8), !GetPlayer(w->window_number)->livery[j].in_use, NULL, CMD_SET_PLAYER_COLOR); } @@ -430,7 +430,7 @@ static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e) for (scheme = LS_DEFAULT; scheme < LS_END; scheme++) { if (HASBIT(WP(w, livery_d).sel, scheme)) { - DoCommandP(0, scheme | (e->dropdown.button == 10 ? 0 : 256), e->dropdown.index, NULL, CMD_SET_PLAYER_COLOR); + DoCommandP(0, scheme | (e->we.dropdown.button == 10 ? 0 : 256), e->we.dropdown.index, NULL, CMD_SET_PLAYER_COLOR); } } break; @@ -476,7 +476,7 @@ static void SelectPlayerFaceWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: DeleteWindow(w); break; case 4: /* ok click */ DoCommandP(0, 0, WP(w,facesel_d).face, NULL, CMD_SET_PLAYER_FACE); @@ -484,7 +484,7 @@ static void SelectPlayerFaceWndProc(Window *w, WindowEvent *e) break; case 5: /* male click */ case 6: /* female click */ - WP(w,facesel_d).gender = e->click.widget - 5; + WP(w,facesel_d).gender = e->we.click.widget - 5; SetWindowDirty(w); break; case 7: @@ -704,7 +704,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: { /* select face */ Window *wf = AllocateWindowDescFront(&_select_player_face_desc, w->window_number); if (wf != NULL) { @@ -779,7 +779,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e) break; case WE_PLACE_OBJ: { - if (DoCommandP(e->place.tile, 0, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS))) + if (DoCommandP(e->we.place.tile, 0, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS))) ResetObjectToPlace(); break; } @@ -790,7 +790,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e) break; case WE_ON_EDIT_TEXT: { - char *b = e->edittext.str; + char *b = e->we.edittext.str; // empty string is allowed for password if (*b == '\0' && WP(w,def_d).byte_1 != 2) return; @@ -860,7 +860,7 @@ static void BuyCompanyWndProc(Window *w, WindowEvent *e) } case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: DeleteWindow(w); break; diff --git a/rail_gui.c b/rail_gui.c index 2c2be4a5d..25d9b2f6a 100644 --- a/rail_gui.c +++ b/rail_gui.c @@ -418,9 +418,9 @@ static void BuildRailToolbWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - if (e->click.widget >= 4) { + if (e->we.click.widget >= 4) { _remove_button_clicked = false; - _build_railroad_button_proc[e->click.widget - 4](w); + _build_railroad_button_proc[e->we.click.widget - 4](w); } break; @@ -428,8 +428,8 @@ static void BuildRailToolbWndProc(Window *w, WindowEvent *e) uint i; for (i = 0; i != lengthof(_rail_keycodes); i++) { - if (e->keypress.keycode == _rail_keycodes[i]) { - e->keypress.cont = false; + if (e->we.keypress.keycode == _rail_keycodes[i]) { + e->we.keypress.cont = false; _remove_button_clicked = false; _build_railroad_button_proc[i](w); break; @@ -440,38 +440,38 @@ static void BuildRailToolbWndProc(Window *w, WindowEvent *e) } case WE_PLACE_OBJ: - _place_proc(e->place.tile); + _place_proc(e->we.place.tile); return; case WE_PLACE_DRAG: { - VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata & 0xF); + VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF); return; } case WE_PLACE_MOUSEUP: - if (e->click.pt.x != -1) { - TileIndex start_tile = e->place.starttile; - TileIndex end_tile = e->place.tile; + if (e->we.click.pt.x != -1) { + TileIndex start_tile = e->we.place.starttile; + TileIndex end_tile = e->we.place.tile; - if (e->place.userdata == VPM_X_OR_Y) { + if (e->we.place.userdata == VPM_X_OR_Y) { ResetObjectToPlace(); ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype); - } else if (e->place.userdata == VPM_RAILDIRS) { + } else if (e->we.place.userdata == VPM_RAILDIRS) { bool old = _remove_button_clicked; if (_ctrl_pressed) _remove_button_clicked = true; HandleAutodirPlacement(); _remove_button_clicked = old; - } else if (e->place.userdata == VPM_SIGNALDIRS) { + } else if (e->we.place.userdata == VPM_SIGNALDIRS) { HandleAutoSignalPlacement(); - } else if ((e->place.userdata & 0xF) == VPM_X_AND_Y) { + } else if ((e->we.place.userdata & 0xF) == VPM_X_AND_Y) { if (GUIPlaceProcDragXY(e)) break; - if ((e->place.userdata >> 4) == GUI_PlaceProc_ConvertRailArea >> 4) + if ((e->we.place.userdata >> 4) == GUI_PlaceProc_ConvertRailArea >> 4) DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL)); - } else if (e->place.userdata == VPM_X_AND_Y_LIMITED) { + } else if (e->we.place.userdata == VPM_X_AND_Y_LIMITED) { HandleStationPlacement(start_tile, end_tile); } else { - DoRailroadTrack(e->place.userdata & 1); + DoRailroadTrack(e->we.place.userdata & 1); } } break; @@ -487,7 +487,7 @@ static void BuildRailToolbWndProc(Window *w, WindowEvent *e) break; case WE_PLACE_PRESIZE: { - TileIndex tile = e->place.tile; + TileIndex tile = e->we.place.tile; DoCommand(tile, 0, 0, DC_AUTO, CMD_BUILD_TUNNEL); VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile); @@ -723,10 +723,10 @@ static void StationBuildWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: { - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: case 4: - _railstation.orientation = e->click.widget - 3; + _railstation.orientation = e->we.click.widget - 3; SndPlayFx(SND_15_BEEP); SetWindowDirty(w); break; @@ -738,7 +738,7 @@ static void StationBuildWndProc(Window *w, WindowEvent *e) case 9: case 10: case 11: - _railstation.numtracks = (e->click.widget - 5) + 1; + _railstation.numtracks = (e->we.click.widget - 5) + 1; _railstation.dragdrop = false; SndPlayFx(SND_15_BEEP); SetWindowDirty(w); @@ -751,7 +751,7 @@ static void StationBuildWndProc(Window *w, WindowEvent *e) case 16: case 17: case 18: - _railstation.platlength = (e->click.widget - 12) + 1; + _railstation.platlength = (e->we.click.widget - 12) + 1; _railstation.dragdrop = false; SndPlayFx(SND_15_BEEP); SetWindowDirty(w); @@ -765,7 +765,7 @@ static void StationBuildWndProc(Window *w, WindowEvent *e) case 20: case 21: - _station_show_coverage = e->click.widget - 20; + _station_show_coverage = e->we.click.widget - 20; SndPlayFx(SND_15_BEEP); SetWindowDirty(w); break; @@ -777,7 +777,7 @@ static void StationBuildWndProc(Window *w, WindowEvent *e) case 24: { const StationSpec *statspec; - int y = (e->click.pt.y - 32) / 14; + int y = (e->we.click.pt.y - 32) / 14; if (y >= w->vscroll.cap) return; y += w->vscroll.pos; @@ -798,8 +798,8 @@ static void StationBuildWndProc(Window *w, WindowEvent *e) } break; case WE_DROPDOWN_SELECT: - if (_railstation.station_class != e->dropdown.index) { - _railstation.station_class = e->dropdown.index; + if (_railstation.station_class != e->we.dropdown.index) { + _railstation.station_class = e->we.dropdown.index; _railstation.station_type = 0; _railstation.station_count = GetNumCustomStations(_railstation.station_class); @@ -940,12 +940,12 @@ static void BuildTrainDepotWndProc(Window *w, WindowEvent *e) } case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: case 4: case 5: case 6: - _build_depot_direction = e->click.widget - 3; + _build_depot_direction = e->we.click.widget - 3; SndPlayFx(SND_15_BEEP); SetWindowDirty(w); break; @@ -1012,9 +1012,9 @@ static void BuildWaypointWndProc(Window *w, WindowEvent *e) break; } case WE_CLICK: { - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: case 4: case 5: case 6: case 7: { - byte type = e->click.widget - 3 + w->hscroll.pos; + byte type = e->we.click.widget - 3 + w->hscroll.pos; /* Check station availability callback */ const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, type); diff --git a/road_gui.c b/road_gui.c index 7e0353b82..332842e3d 100644 --- a/road_gui.c +++ b/road_gui.c @@ -193,11 +193,11 @@ static void BuildRoadToolbWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: { - if (e->click.widget >= 3) _build_road_button_proc[e->click.widget - 3](w); + if (e->we.click.widget >= 3) _build_road_button_proc[e->we.click.widget - 3](w); } break; case WE_KEYPRESS: - switch (e->keypress.keycode) { + switch (e->we.keypress.keycode) { case '1': BuildRoadClick_NE(w); break; case '2': BuildRoadClick_NW(w); break; case '3': BuildRoadClick_Demolish(w); break; @@ -211,12 +211,12 @@ static void BuildRoadToolbWndProc(Window *w, WindowEvent *e) default: return; } MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection - e->keypress.cont = false; + e->we.keypress.cont = false; break; case WE_PLACE_OBJ: _remove_button_clicked = (w->click_state & (1 << 11)) != 0; - _place_proc(e->place.tile); + _place_proc(e->we.place.tile); break; case WE_ABORT_PLACE_OBJ: @@ -233,15 +233,15 @@ static void BuildRoadToolbWndProc(Window *w, WindowEvent *e) case WE_PLACE_DRAG: { int sel_method; - switch (e->place.userdata) { + switch (e->we.place.userdata) { case 1: sel_method = VPM_FIX_X; - _place_road_flag = (_place_road_flag & ~2) | ((e->place.pt.y & 8) >> 2); + _place_road_flag = (_place_road_flag & ~2) | ((e->we.place.pt.y & 8) >> 2); break; case 2: sel_method = VPM_FIX_Y; - _place_road_flag = (_place_road_flag & ~2) | ((e->place.pt.x & 8) >> 2); + _place_road_flag = (_place_road_flag & ~2) | ((e->we.place.pt.x & 8) >> 2); break; case 4: @@ -253,19 +253,19 @@ static void BuildRoadToolbWndProc(Window *w, WindowEvent *e) break; } - VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, sel_method); + VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, sel_method); return; } case WE_PLACE_MOUSEUP: - if (e->place.pt.x != -1) { - TileIndex start_tile = e->place.starttile; - TileIndex end_tile = e->place.tile; + if (e->we.place.pt.x != -1) { + TileIndex start_tile = e->we.place.starttile; + TileIndex end_tile = e->we.place.tile; - if (e->place.userdata == 0) { + if (e->we.place.userdata == 0) { ResetObjectToPlace(); ShowBuildBridgeWindow(start_tile, end_tile, 0x80); - } else if (e->place.userdata != 4) { + } else if (e->we.place.userdata != 4) { DoCommandP(end_tile, start_tile, _place_road_flag, CcPlaySound1D, _remove_button_clicked ? CMD_REMOVE_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1805_CAN_T_REMOVE_ROAD_FROM) : @@ -277,7 +277,7 @@ static void BuildRoadToolbWndProc(Window *w, WindowEvent *e) break; case WE_PLACE_PRESIZE: { - TileIndex tile = e->place.tile; + TileIndex tile = e->we.place.tile; DoCommand(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL); VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile); @@ -369,9 +369,9 @@ static void BuildRoadDepotWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: { - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: case 4: case 5: case 6: - _road_depot_orientation = e->click.widget - 3; + _road_depot_orientation = e->we.click.widget - 3; SndPlayFx(SND_15_BEEP); SetWindowDirty(w); break; @@ -445,14 +445,14 @@ static void RoadStationPickerWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: { - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: case 4: case 5: case 6: - _road_station_picker_orientation = e->click.widget - 3; + _road_station_picker_orientation = e->we.click.widget - 3; SndPlayFx(SND_15_BEEP); SetWindowDirty(w); break; case 7: case 8: - _station_show_coverage = e->click.widget - 7; + _station_show_coverage = e->we.click.widget - 7; SndPlayFx(SND_15_BEEP); SetWindowDirty(w); break; diff --git a/roadveh_gui.c b/roadveh_gui.c index 7c85142cf..4e0c649e7 100644 --- a/roadveh_gui.c +++ b/roadveh_gui.c @@ -105,9 +105,9 @@ static void RoadVehRefitWndProc(Window *w, WindowEvent *e) } case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: { /* List box */ - int y = e->click.pt.y - 25; + int y = e->we.click.pt.y - 25; if (y >= 0) { WP(w,refit_d).sel = y / 10; SetWindowDirty(w); @@ -236,7 +236,7 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e) case WE_CLICK: { int mod; const Vehicle *v; - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: /* rename */ v = GetVehicle(w->window_number); SetDParam(0, v->unitnumber); @@ -260,8 +260,8 @@ do_change_service_int: } break; case WE_ON_EDIT_TEXT: { - if (e->edittext.str[0] != '\0') { - _cmd_text = e->edittext.str; + if (e->we.edittext.str[0] != '\0') { + _cmd_text = e->we.edittext.str; DoCommandP(0, w->window_number, 0, NULL, CMD_NAME_VEHICLE | CMD_MSG(STR_902D_CAN_T_NAME_ROAD_VEHICLE)); } @@ -375,7 +375,7 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e) case WE_CLICK: { const Vehicle *v = GetVehicle(w->window_number); - switch (e->click.widget) { + switch (e->we.click.widget) { case 5: /* start stop */ DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE)); break; @@ -404,10 +404,10 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e) } break; case WE_RESIZE: - w->viewport->width += e->sizing.diff.x; - w->viewport->height += e->sizing.diff.y; - w->viewport->virtual_width += e->sizing.diff.x; - w->viewport->virtual_height += e->sizing.diff.y; + w->viewport->width += e->we.sizing.diff.x; + w->viewport->height += e->we.sizing.diff.y; + w->viewport->virtual_width += e->we.sizing.diff.x; + w->viewport->virtual_height += e->we.sizing.diff.y; break; case WE_DESTROY: @@ -529,9 +529,9 @@ static void NewRoadVehWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: { /* listbox */ - uint i = (e->click.pt.y - 14) / 14; + uint i = (e->we.click.pt.y - 14) / 14; if (i < w->vscroll.cap) { WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; SetWindowDirty(w); @@ -556,17 +556,17 @@ static void NewRoadVehWndProc(Window *w, WindowEvent *e) break; case WE_ON_EDIT_TEXT: - if (e->edittext.str[0] != '\0') { - _cmd_text = e->edittext.str; + if (e->we.edittext.str[0] != '\0') { + _cmd_text = e->we.edittext.str; DoCommandP(0, WP(w, buildtrain_d).rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(STR_9037_CAN_T_RENAME_ROAD_VEHICLE)); } break; case WE_RESIZE: { - if (e->sizing.diff.y == 0) break; + if (e->we.sizing.diff.y == 0) break; - w->vscroll.cap += e->sizing.diff.y / 14; + w->vscroll.cap += e->we.sizing.diff.y / 14; w->widget[2].data = (w->vscroll.cap << 8) + 1; } break; @@ -760,9 +760,9 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: { - switch (e->click.widget) { + switch (e->we.click.widget) { case 5: - RoadDepotClickVeh(w, e->click.pt.x, e->click.pt.y); + RoadDepotClickVeh(w, e->we.click.pt.x, e->we.click.pt.y); break; case 7: @@ -811,7 +811,7 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e) break; case WE_DRAGDROP: - switch (e->click.widget) { + switch (e->we.click.widget) { case 5: { Vehicle *v; VehicleID sel = WP(w,traindepot_d).sel; @@ -819,7 +819,7 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e) WP(w,traindepot_d).sel = INVALID_VEHICLE; SetWindowDirty(w); - if (GetVehicleFromRoadDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &v) == 0 && + if (GetVehicleFromRoadDepotWndPt(w, e->we.dragdrop.pt.x, e->we.dragdrop.pt.y, &v) == 0 && v != NULL && sel == v->index) { ShowRoadVehViewWindow(v); @@ -852,8 +852,8 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e) case WE_RESIZE: /* Update the scroll + matrix */ - w->vscroll.cap += e->sizing.diff.y / 14; - w->hscroll.cap += e->sizing.diff.x / 56; + w->vscroll.cap += e->we.sizing.diff.y / 14; + w->hscroll.cap += e->we.sizing.diff.x / 56; w->widget[5].data = (w->vscroll.cap << 8) + w->hscroll.cap; break; diff --git a/settings_gui.c b/settings_gui.c index 15db71374..cbe3b5f79 100644 --- a/settings_gui.c +++ b/settings_gui.c @@ -113,7 +113,7 @@ static void GameOptionsWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 4: case 5: /* Setup currencies dropdown */ ShowDropDownMenu(w, BuildCurrencyDropdown(), _opt_ptr->currency, 5, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0);; return; @@ -161,9 +161,9 @@ static void GameOptionsWndProc(Window *w, WindowEvent *e) break; case WE_DROPDOWN_SELECT: - switch (e->dropdown.button) { + switch (e->we.dropdown.button) { case 20: /* Vehicle design names */ - if (e->dropdown.index == 0) { + if (e->we.dropdown.index == 0) { DeleteCustomEngineNames(); MarkWholeScreenDirty(); } else if (!(_vehicle_design_names & 1)) { @@ -172,40 +172,40 @@ static void GameOptionsWndProc(Window *w, WindowEvent *e) } break; case 5: /* Currency */ - if (e->dropdown.index == CUSTOM_CURRENCY_ID) ShowCustCurrency(); - _opt_ptr->currency = e->dropdown.index; + if (e->we.dropdown.index == CUSTOM_CURRENCY_ID) ShowCustCurrency(); + _opt_ptr->currency = e->we.dropdown.index; MarkWholeScreenDirty(); break; case 8: /* Measuring units */ - _opt_ptr->units = e->dropdown.index; + _opt_ptr->units = e->we.dropdown.index; MarkWholeScreenDirty(); break; case 11: /* Road side */ - if (_opt_ptr->road_side != e->dropdown.index) { // only change if setting changed - DoCommandP(0, e->dropdown.index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS)); + if (_opt_ptr->road_side != e->we.dropdown.index) { // only change if setting changed + DoCommandP(0, e->we.dropdown.index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS)); MarkWholeScreenDirty(); } break; case 14: /* Town names */ if (_game_mode == GM_MENU) { - _opt_ptr->town_name = e->dropdown.index; + _opt_ptr->town_name = e->we.dropdown.index; InvalidateWindow(WC_GAME_OPTIONS, 0); } break; case 17: /* Autosave options */ - _opt.autosave = _opt_newgame.autosave = e->dropdown.index; + _opt.autosave = _opt_newgame.autosave = e->we.dropdown.index; SetWindowDirty(w); break; case 24: /* Change interface language */ - ReadLanguagePack(e->dropdown.index); + ReadLanguagePack(e->we.dropdown.index); MarkWholeScreenDirty(); break; case 27: /* Change resolution */ - if (e->dropdown.index < _num_resolutions && ChangeResInGame(_resolutions[e->dropdown.index][0],_resolutions[e->dropdown.index][1])) + if (e->we.dropdown.index < _num_resolutions && ChangeResInGame(_resolutions[e->we.dropdown.index][0],_resolutions[e->we.dropdown.index][1])) SetWindowDirty(w); break; case 31: /* Change screenshot format */ - SetScreenshotFormat(e->dropdown.index); + SetScreenshotFormat(e->we.dropdown.index); SetWindowDirty(w); break; } @@ -432,7 +432,7 @@ static void GameDifficultyWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 8: { /* Difficulty settings widget, decode click */ const GameSettingData *info; int x, y; @@ -443,11 +443,11 @@ static void GameDifficultyWndProc(Window *w, WindowEvent *e) if (_networking && !_network_server) return; - x = e->click.pt.x - 5; + x = e->we.click.pt.x - 5; if (!IS_INT_INSIDE(x, 0, 21)) // Button area return; - y = e->click.pt.y - GAMEDIFF_WND_TOP_OFFSET; + y = e->we.click.pt.y - GAMEDIFF_WND_TOP_OFFSET; if (y < 0) return; @@ -484,7 +484,7 @@ static void GameDifficultyWndProc(Window *w, WindowEvent *e) } break; case 3: case 4: case 5: case 6: /* Easy / Medium / Hard / Custom */ // temporarily change difficulty level - SetDifficultyLevel(e->click.widget - 3, &_opt_mod_temp); + SetDifficultyLevel(e->we.click.widget - 3, &_opt_mod_temp); SetWindowDirty(w); break; case 7: /* Highscore Table */ @@ -760,7 +760,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e) } case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: { const PatchPage *page = &_patches_page[WP(w,def_d).data_1]; const SettingDesc *sd; @@ -769,10 +769,10 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e) int x, y; byte btn; - y = e->click.pt.y - 46 - 1; + y = e->we.click.pt.y - 46 - 1; if (y < 0) return; - x = e->click.pt.x - 5; + x = e->we.click.pt.x - 5; if (x < 0) return; btn = y / 11; @@ -848,7 +848,7 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e) break; } case 4: case 5: case 6: case 7: case 8: case 9: - WP(w,def_d).data_1 = e->click.widget - 4; + WP(w,def_d).data_1 = e->we.click.widget - 4; DeleteWindowById(WC_QUERY_STRING, 0); SetWindowDirty(w); break; @@ -861,11 +861,11 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e) break; case WE_ON_EDIT_TEXT: { - if (e->edittext.str != NULL) { + if (e->we.edittext.str != NULL) { const PatchEntry *pe = &_patches_page[WP(w,def_d).data_1].entries[WP(w,def_d).data_3]; const SettingDesc *sd = pe->setting; void *var = ini_get_variable(&sd->save, patches_ptr); - int32 value = atoi(e->edittext.str); + int32 value = atoi(e->we.edittext.str); /* Save the correct currency-translated value */ if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate; @@ -967,9 +967,9 @@ static void NewgrfWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: { // select a grf file - int y = (e->click.pt.y - NEWGRF_WND_PROC_OFFSET_TOP_WIDGET) / NEWGRF_WND_PROC_ROWSIZE; + int y = (e->we.click.pt.y - NEWGRF_WND_PROC_OFFSET_TOP_WIDGET) / NEWGRF_WND_PROC_ROWSIZE; if (y >= w->vscroll.cap) return; // click out of bounds @@ -1127,9 +1127,9 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) } case WE_CLICK: { - int line = (e->click.pt.y - 20) / 12; + int line = (e->we.click.pt.y - 20) / 12; int len = 0; - int x = e->click.pt.x; + int x = e->we.click.pt.x; StringID str = 0; CharSetFilter afilter = CS_ALPHANUMERAL; @@ -1212,7 +1212,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) } case WE_ON_EDIT_TEXT: { - const char *b = e->edittext.str; + const char *b = e->we.edittext.str; switch (WP(w,def_d).data_2) { case 0: /* Exchange rate */ diff --git a/ship_gui.c b/ship_gui.c index 9b31190c2..3853200dd 100644 --- a/ship_gui.c +++ b/ship_gui.c @@ -104,9 +104,9 @@ static void ShipRefitWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: { /* listbox */ - int y = e->click.pt.y - 25; + int y = e->we.click.pt.y - 25; if (y >= 0) { WP(w,refit_d).sel = y / 10; SetWindowDirty(w); @@ -234,7 +234,7 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e) case WE_CLICK: { int mod; const Vehicle *v; - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: /* rename */ v = GetVehicle(w->window_number); SetDParam(0, v->unitnumber); @@ -257,8 +257,8 @@ do_change_service_int: } break; case WE_ON_EDIT_TEXT: - if (e->edittext.str[0] != '\0') { - _cmd_text = e->edittext.str; + if (e->we.edittext.str[0] != '\0') { + _cmd_text = e->we.edittext.str; DoCommandP(0, w->window_number, 0, NULL, CMD_NAME_VEHICLE | CMD_MSG(STR_9832_CAN_T_NAME_SHIP)); } @@ -363,9 +363,9 @@ static void NewShipWndProc(Window *w, WindowEvent *e) } case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: { /* listbox */ - uint i = (e->click.pt.y - 14) / 24; + uint i = (e->we.click.pt.y - 14) / 24; if (i < w->vscroll.cap) { WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; SetWindowDirty(w); @@ -389,15 +389,15 @@ static void NewShipWndProc(Window *w, WindowEvent *e) break; case WE_ON_EDIT_TEXT: - if (e->edittext.str[0] != '\0') { - _cmd_text = e->edittext.str; + if (e->we.edittext.str[0] != '\0') { + _cmd_text = e->we.edittext.str; DoCommandP(0, WP(w, buildtrain_d).rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(STR_9839_CAN_T_RENAME_SHIP_TYPE)); } break; case WE_RESIZE: - w->vscroll.cap += e->sizing.diff.y / 24; + w->vscroll.cap += e->we.sizing.diff.y / 24; w->widget[2].data = (w->vscroll.cap << 8) + 1; break; @@ -516,7 +516,7 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) case WE_CLICK: { const Vehicle *v = GetVehicle(w->window_number); - switch (e->click.widget) { + switch (e->we.click.widget) { case 5: /* start stop */ DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP)); break; @@ -543,10 +543,10 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) } break; case WE_RESIZE: - w->viewport->width += e->sizing.diff.x; - w->viewport->height += e->sizing.diff.y; - w->viewport->virtual_width += e->sizing.diff.x; - w->viewport->virtual_height += e->sizing.diff.y; + w->viewport->width += e->we.sizing.diff.x; + w->viewport->height += e->we.sizing.diff.y; + w->viewport->virtual_width += e->we.sizing.diff.x; + w->viewport->virtual_height += e->we.sizing.diff.y; break; case WE_DESTROY: @@ -751,9 +751,9 @@ static void ShipDepotWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 5: - ShipDepotClick(w, e->click.pt.x, e->click.pt.y); + ShipDepotClick(w, e->we.click.pt.x, e->we.click.pt.y); break; case 7: @@ -802,7 +802,7 @@ static void ShipDepotWndProc(Window *w, WindowEvent *e) break; case WE_DRAGDROP: - switch (e->click.widget) { + switch (e->we.click.widget) { case 5: { Vehicle *v; VehicleID sel = WP(w,traindepot_d).sel; @@ -810,7 +810,7 @@ static void ShipDepotWndProc(Window *w, WindowEvent *e) WP(w,traindepot_d).sel = INVALID_VEHICLE; SetWindowDirty(w); - if (GetVehicleFromShipDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &v) == 0 && + if (GetVehicleFromShipDepotWndPt(w, e->we.dragdrop.pt.x, e->we.dragdrop.pt.y, &v) == 0 && v != NULL && sel == v->index) { ShowShipViewWindow(v); @@ -841,8 +841,8 @@ static void ShipDepotWndProc(Window *w, WindowEvent *e) break; case WE_RESIZE: - w->vscroll.cap += e->sizing.diff.y / 24; - w->hscroll.cap += e->sizing.diff.x / 90; + w->vscroll.cap += e->we.sizing.diff.y / 24; + w->hscroll.cap += e->we.sizing.diff.x / 90; w->widget[5].data = (w->vscroll.cap << 8) + w->hscroll.cap; break; } diff --git a/smallmap_gui.c b/smallmap_gui.c index e52ca7ca2..248b2c604 100644 --- a/smallmap_gui.c +++ b/smallmap_gui.c @@ -838,7 +838,7 @@ static void SmallMapWindowProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 4: { // Map window Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0); Point pt; @@ -866,8 +866,8 @@ static void SmallMapWindowProc(Window *w, WindowEvent *e) case 9: // Show vegetation case 10: // Show land owners w->click_state &= ~( 1 << 5 | 1 << 6 | 1 << 7 | 1 << 8 | 1 << 9 | 1 << 10); - w->click_state |= 1 << e->click.widget; - _smallmap_type = e->click.widget - 5; + w->click_state |= 1 << e->we.click.widget; + _smallmap_type = e->we.click.widget - 5; SetWindowDirty(w); SndPlayFx(SND_15_BEEP); @@ -891,7 +891,7 @@ static void SmallMapWindowProc(Window *w, WindowEvent *e) break; case WE_RCLICK: - if (e->click.widget == 4) { + if (e->we.click.widget == 4) { if (_scrolling_viewport) return; _scrolling_viewport = true; _cursor.delta.x = 0; @@ -918,16 +918,16 @@ static void SmallMapWindowProc(Window *w, WindowEvent *e) x = WP(w, smallmap_d).scroll_x; y = WP(w, smallmap_d).scroll_y; - sub = WP(w, smallmap_d).subscroll + e->scroll.delta.x; + sub = WP(w, smallmap_d).subscroll + e->we.scroll.delta.x; x -= (sub >> 2) << 4; y += (sub >> 2) << 4; sub &= 3; - x += (e->scroll.delta.y >> 1) << 4; - y += (e->scroll.delta.y >> 1) << 4; + x += (e->we.scroll.delta.y >> 1) << 4; + y += (e->we.scroll.delta.y >> 1) << 4; - if (e->scroll.delta.y & 1) { + if (e->we.scroll.delta.y & 1) { x += TILE_SIZE; sub += 2; if (sub > 3) { @@ -1022,7 +1022,7 @@ static void ExtraViewPortWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 5: DoZoomInOutWindow(ZOOM_IN, w); break; case 6: DoZoomInOutWindow(ZOOM_OUT, w); break; @@ -1048,10 +1048,10 @@ static void ExtraViewPortWndProc(Window *w, WindowEvent *e) break; case WE_RESIZE: - w->viewport->width += e->sizing.diff.x; - w->viewport->height += e->sizing.diff.y; - w->viewport->virtual_width += e->sizing.diff.x; - w->viewport->virtual_height += e->sizing.diff.y; + w->viewport->width += e->we.sizing.diff.x; + w->viewport->height += e->we.sizing.diff.y; + w->viewport->virtual_width += e->we.sizing.diff.x; + w->viewport->virtual_height += e->we.sizing.diff.y; break; case WE_SCROLL: { @@ -1062,12 +1062,12 @@ static void ExtraViewPortWndProc(Window *w, WindowEvent *e) _scrolling_viewport = false; } - WP(w, vp_d).scrollpos_x += e->scroll.delta.x << vp->zoom; - WP(w, vp_d).scrollpos_y += e->scroll.delta.y << vp->zoom; + WP(w, vp_d).scrollpos_x += e->we.scroll.delta.x << vp->zoom; + WP(w, vp_d).scrollpos_y += e->we.scroll.delta.y << vp->zoom; } break; case WE_MOUSEWHEEL: - ZoomInOrOutToCursorWindow(e->wheel.wheel < 0, w); + ZoomInOrOutToCursorWindow(e->we.wheel.wheel < 0, w); break; } } diff --git a/station_gui.c b/station_gui.c index 2b2fad1e0..a7d9b1143 100644 --- a/station_gui.c +++ b/station_gui.c @@ -327,11 +327,11 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e) } } break; case WE_CLICK: { - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: { const Station* st; - uint32 id_v = (e->click.pt.y - 41) / 10; + uint32 id_v = (e->we.click.pt.y - 41) / 10; if (id_v >= w->vscroll.cap) return; // click out of bounds @@ -351,10 +351,10 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e) case 9: /* airport */ case 10: /* dock */ if (_ctrl_pressed) { - TOGGLEBIT(facilities, e->click.widget - 6); + TOGGLEBIT(facilities, e->we.click.widget - 6); } else { facilities = 0; - SETBIT(facilities, e->click.widget - 6); + SETBIT(facilities, e->we.click.widget - 6); } sl->flags |= SL_REBUILD; SetWindowDirty(w); @@ -378,12 +378,12 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e) ShowDropDownMenu(w, _station_sort_listing, sl->sort_type, 30, 0, 0); break; default: - if (e->click.widget >= 12 && e->click.widget <= 24) { //change cargo_filter + if (e->we.click.widget >= 12 && e->we.click.widget <= 24) { //change cargo_filter if (_ctrl_pressed) { - TOGGLEBIT(cargo_filter, e->click.widget - 12); + TOGGLEBIT(cargo_filter, e->we.click.widget - 12); } else { cargo_filter = 0; - SETBIT(cargo_filter, e->click.widget - 12); + SETBIT(cargo_filter, e->we.click.widget - 12); } sl->flags |= SL_REBUILD; SetWindowDirty(w); @@ -391,9 +391,9 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e) } } break; case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ - if (sl->sort_type != e->dropdown.index) { + if (sl->sort_type != e->we.dropdown.index) { // value has changed -> resort - sl->sort_type = e->dropdown.index; + sl->sort_type = e->we.dropdown.index; sl->flags |= SL_RESORT; } SetWindowDirty(w); @@ -416,7 +416,7 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e) break; case WE_RESIZE: - w->vscroll.cap += e->sizing.diff.y / 10; + w->vscroll.cap += e->we.sizing.diff.y / 10; break; } } @@ -652,7 +652,7 @@ static void StationViewWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 7: ScrollMainWindowToTile(GetStation(w->window_number)->xy); break; @@ -708,8 +708,8 @@ static void StationViewWndProc(Window *w, WindowEvent *e) break; case WE_ON_EDIT_TEXT: - if (e->edittext.str[0] != '\0') { - _cmd_text = e->edittext.str; + if (e->we.edittext.str[0] != '\0') { + _cmd_text = e->we.edittext.str; DoCommandP(0, w->window_number, 0, NULL, CMD_RENAME_STATION | CMD_MSG(STR_3031_CAN_T_RENAME_STATION)); } diff --git a/subsidy_gui.c b/subsidy_gui.c index daba50675..c71b1b2a2 100644 --- a/subsidy_gui.c +++ b/subsidy_gui.c @@ -144,8 +144,10 @@ static void SubsidiesListWndProc(Window *w, WindowEvent *e) case WE_PAINT: DrawSubsidiesWindow(w); break; case WE_CLICK: - switch (e->click.widget) { - case 3: HandleSubsidyClick(e->click.pt.y - 25); break; + switch (e->we.click.widget) { + case 3: + HandleSubsidyClick(e->we.click.pt.y - 25); + break; } break; } diff --git a/terraform_gui.c b/terraform_gui.c index 42e24f16d..eee61dcb0 100644 --- a/terraform_gui.c +++ b/terraform_gui.c @@ -85,18 +85,18 @@ static void GenerateRockyArea(TileIndex end, TileIndex start) /** * A central place to handle all X_AND_Y dragged GUI functions. - * @param we @WindowEvent variable holding in its higher bits (excluding the lower + * @param e @WindowEvent variable holding in its higher bits (excluding the lower * 4, since that defined the X_Y drag) the type of action to be performed * @return Returns true if the action was found and handled, and false otherwise. This * allows for additional implements that are more local. For example X_Y drag * of convertrail which belongs in rail_gui.c and not terraform_gui.c **/ -bool GUIPlaceProcDragXY(const WindowEvent *we) +bool GUIPlaceProcDragXY(const WindowEvent *e) { - TileIndex start_tile = we->place.starttile; - TileIndex end_tile = we->place.tile; + TileIndex start_tile = e->we.place.starttile; + TileIndex end_tile = e->we.place.tile; - switch (we->place.userdata >> 4) { + switch (e->we.place.userdata >> 4) { case GUI_PlaceProc_DemolishArea >> 4: DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); break; @@ -210,15 +210,15 @@ static void TerraformToolbWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - if (e->click.widget >= 4) _terraform_button_proc[e->click.widget - 4](w); + if (e->we.click.widget >= 4) _terraform_button_proc[e->we.click.widget - 4](w); break; case WE_KEYPRESS: { uint i; for (i = 0; i != lengthof(_terraform_keycodes); i++) { - if (e->keypress.keycode == _terraform_keycodes[i]) { - e->keypress.cont = false; + if (e->we.keypress.keycode == _terraform_keycodes[i]) { + e->we.keypress.cont = false; _terraform_button_proc[i](w); break; } @@ -227,16 +227,16 @@ static void TerraformToolbWndProc(Window *w, WindowEvent *e) } case WE_PLACE_OBJ: - _place_proc(e->place.tile); + _place_proc(e->we.place.tile); return; case WE_PLACE_DRAG: - VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata & 0xF); + VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF); break; case WE_PLACE_MOUSEUP: - if (e->click.pt.x != -1 && - (e->place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions + if (e->we.click.pt.x != -1 && + (e->we.place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions GUIPlaceProcDragXY(e); } break; diff --git a/town_gui.c b/town_gui.c index cc765b730..f83b1c077 100644 --- a/town_gui.c +++ b/town_gui.c @@ -181,10 +181,10 @@ static void TownAuthorityWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: { /* listbox */ const Town *t = GetTown(w->window_number); - int y = (e->click.pt.y - 0x6B) / 10; + int y = (e->we.click.pt.y - 0x6B) / 10; if (!IS_INT_INSIDE(y, 0, 5)) return; @@ -255,7 +255,7 @@ static void TownViewWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 6: /* scroll to location */ ScrollMainWindowToTile(t->xy); break; @@ -280,8 +280,8 @@ static void TownViewWndProc(Window *w, WindowEvent *e) break; case WE_ON_EDIT_TEXT: - if (e->edittext.str[0] != '\0') { - _cmd_text = e->edittext.str; + if (e->we.edittext.str[0] != '\0') { + _cmd_text = e->we.edittext.str; DoCommandP(0, w->window_number, 0, NULL, CMD_RENAME_TOWN | CMD_MSG(STR_2008_CAN_T_RENAME_TOWN)); } @@ -462,7 +462,7 @@ static void TownDirectoryWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: { /* Sort by Name ascending/descending */ _town_sort_order = (_town_sort_order == 0) ? 1 : 0; _town_sort_dirty = true; @@ -478,7 +478,7 @@ static void TownDirectoryWndProc(Window *w, WindowEvent *e) case 5: { /* Click on Town Matrix */ const Town* t; - uint16 id_v = (e->click.pt.y - 28) / 10; + uint16 id_v = (e->we.click.pt.y - 28) / 10; if (id_v >= w->vscroll.cap) return; // click out of bounds @@ -499,7 +499,7 @@ static void TownDirectoryWndProc(Window *w, WindowEvent *e) break; case WE_RESIZE: - w->vscroll.cap += e->sizing.diff.y / 10; + w->vscroll.cap += e->we.sizing.diff.y / 10; break; } } diff --git a/train_gui.c b/train_gui.c index d1266cbcd..8d8d1b67b 100644 --- a/train_gui.c +++ b/train_gui.c @@ -259,9 +259,9 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: { - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: { - uint i = (e->click.pt.y - 14) / 14; + uint i = (e->we.click.pt.y - 14) / 14; if (i < w->vscroll.cap) { WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; SetWindowDirty(w); @@ -284,18 +284,18 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e) } break; case WE_ON_EDIT_TEXT: { - if (e->edittext.str[0] != '\0') { - _cmd_text = e->edittext.str; + if (e->we.edittext.str[0] != '\0') { + _cmd_text = e->we.edittext.str; DoCommandP(0, WP(w,buildtrain_d).rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(STR_886B_CAN_T_RENAME_TRAIN_VEHICLE)); } } break; case WE_RESIZE: { - if (e->sizing.diff.y == 0) + if (e->we.sizing.diff.y == 0) break; - w->vscroll.cap += e->sizing.diff.y / 14; + w->vscroll.cap += e->we.sizing.diff.y / 14; w->widget[2].data = (w->vscroll.cap << 8) + 1; } break; } @@ -653,7 +653,7 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e) break; case WE_CLICK: { - switch (e->click.widget) { + switch (e->we.click.widget) { case 8: ResetObjectToPlace(); ShowBuildTrainWindow(w->window_number); @@ -662,7 +662,7 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e) case 10: ScrollMainWindowToTile(w->window_number); break; case 6: - TrainDepotClickTrain(w, e->click.pt.x, e->click.pt.y); + TrainDepotClickTrain(w, e->we.click.pt.x, e->we.click.pt.y); break; case 9: /* clone button */ InvalidateWidget(w, 9); @@ -705,13 +705,13 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e) break; case WE_DRAGDROP: { - switch (e->click.widget) { + switch (e->we.click.widget) { case 4: case 5: { Vehicle *v; int sell_cmd; /* sell vehicle */ - if (w->disabled_state & (1 << e->click.widget)) + if (w->disabled_state & (1 << e->we.click.widget)) return; if (WP(w,traindepot_d).sel == INVALID_VEHICLE) @@ -722,9 +722,9 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e) WP(w,traindepot_d).sel = INVALID_VEHICLE; SetWindowDirty(w); - HandleButtonClick(w, e->click.widget); + HandleButtonClick(w, e->we.click.widget); - sell_cmd = (e->click.widget == 5 || _ctrl_pressed) ? 1 : 0; + sell_cmd = (e->we.click.widget == 5 || _ctrl_pressed) ? 1 : 0; if (!IsFrontEngine(v)) { DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE)); @@ -743,7 +743,7 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e) WP(w,traindepot_d).sel = INVALID_VEHICLE; SetWindowDirty(w); - if (GetVehicleFromTrainDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &gdvp) == 0 && + if (GetVehicleFromTrainDepotWndPt(w, e->we.dragdrop.pt.x, e->we.dragdrop.pt.y, &gdvp) == 0 && sel != INVALID_VEHICLE) { if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) { DoCommandP(GetVehicle(sel)->tile, GetVehicle(sel)->index, true, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN)); @@ -763,8 +763,8 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e) } break; case WE_RESIZE: { /* Update the scroll + matrix */ - w->vscroll.cap += e->sizing.diff.y / 14; - w->hscroll.cap += e->sizing.diff.x; + w->vscroll.cap += e->we.sizing.diff.y / 14; + w->hscroll.cap += e->we.sizing.diff.x; w->widget[6].data = (w->vscroll.cap << 8) + 1; } break; } @@ -844,9 +844,9 @@ static void RailVehicleRefitWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: { /* listbox */ - int y = e->click.pt.y - 25; + int y = e->we.click.pt.y - 25; if (y >= 0) { WP(w,refit_d).sel = y / 10; SetWindowDirty(w); @@ -1012,7 +1012,7 @@ static void TrainViewWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: { - int wid = e->click.widget; + int wid = e->we.click.widget; Vehicle *v = GetVehicle(w->window_number); switch (wid) { @@ -1048,10 +1048,10 @@ static void TrainViewWndProc(Window *w, WindowEvent *e) } break; case WE_RESIZE: - w->viewport->width += e->sizing.diff.x; - w->viewport->height += e->sizing.diff.y; - w->viewport->virtual_width += e->sizing.diff.x; - w->viewport->virtual_height += e->sizing.diff.y; + w->viewport->width += e->we.sizing.diff.x; + w->viewport->height += e->we.sizing.diff.y; + w->viewport->virtual_width += e->we.sizing.diff.x; + w->viewport->virtual_height += e->we.sizing.diff.y; break; case WE_DESTROY: @@ -1269,7 +1269,7 @@ static void TrainDetailsWndProc(Window *w, WindowEvent *e) case WE_CLICK: { int mod; const Vehicle *v; - switch (e->click.widget) { + switch (e->we.click.widget) { case 2: /* name train */ v = GetVehicle(w->window_number); SetDParam(0, v->unitnumber); @@ -1298,25 +1298,25 @@ do_change_service_int: CLRBIT(w->disabled_state, 10); CLRBIT(w->disabled_state, 11); CLRBIT(w->disabled_state, 12); - SETBIT(w->disabled_state, e->click.widget); - WP(w,traindetails_d).tab = e->click.widget - 9; + SETBIT(w->disabled_state, e->we.click.widget); + WP(w,traindetails_d).tab = e->we.click.widget - 9; SetWindowDirty(w); break; } } break; case WE_ON_EDIT_TEXT: - if (e->edittext.str[0] != '\0') { - _cmd_text = e->edittext.str; + if (e->we.edittext.str[0] != '\0') { + _cmd_text = e->we.edittext.str; DoCommandP(0, w->window_number, 0, NULL, CMD_NAME_VEHICLE | CMD_MSG(STR_8866_CAN_T_NAME_TRAIN)); } break; case WE_RESIZE: - if (e->sizing.diff.y == 0) break; + if (e->we.sizing.diff.y == 0) break; - w->vscroll.cap += e->sizing.diff.y / 14; + w->vscroll.cap += e->we.sizing.diff.y / 14; w->widget[4].data = (w->vscroll.cap << 8) + 1; break; } diff --git a/vehicle_gui.c b/vehicle_gui.c index 6f574a561..ee039ad4e 100644 --- a/vehicle_gui.c +++ b/vehicle_gui.c @@ -862,7 +862,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e) uint16 click_scroll_cap = w->vscroll2.cap; byte click_side = 1; - switch (e->click.widget) { + switch (e->we.click.widget) { case 12: WP(w, replaceveh_d).wagon_btnstate = !(WP(w, replaceveh_d).wagon_btnstate); SetWindowDirty(w); @@ -899,7 +899,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e) /* FALL THROUGH */ case 9: { - uint i = (e->click.pt.y - 14) / w->resize.step_height; + uint i = (e->we.click.pt.y - 14) / w->resize.step_height; if (i < click_scroll_cap) { WP(w,replaceveh_d).sel_index[click_side] = i + click_scroll_pos; SetWindowDirty(w); @@ -911,7 +911,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e) } case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ - _railtype_selected_in_replace_gui = e->dropdown.index; + _railtype_selected_in_replace_gui = e->we.dropdown.index; /* Reset scrollbar positions */ w->vscroll.pos = 0; w->vscroll2.pos = 0; @@ -919,8 +919,8 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e) break; case WE_RESIZE: - w->vscroll.cap += e->sizing.diff.y / (int)w->resize.step_height; - w->vscroll2.cap += e->sizing.diff.y / (int)w->resize.step_height; + w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height; + w->vscroll2.cap += e->we.sizing.diff.y / (int)w->resize.step_height; w->widget[7].data = (w->vscroll.cap << 8) + 1; w->widget[9].data = (w->vscroll2.cap << 8) + 1; @@ -1278,7 +1278,7 @@ void PlayerVehWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: { - switch (e->click.widget) { + switch (e->we.click.widget) { case 3: /* Flip sorting method ascending/descending */ vl->l.flags ^= VL_DESC; vl->l.flags |= VL_RESORT; @@ -1290,7 +1290,7 @@ void PlayerVehWndProc(Window *w, WindowEvent *e) ShowDropDownMenu(w, _vehicle_sort_listing, vl->l.sort_type, 5, 0, 0); return; case 7: { /* Matrix to show vehicles */ - uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / w->resize.step_height; + uint32 id_v = (e->we.click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / w->resize.step_height; const Vehicle *v; if (id_v >= w->vscroll.cap) return; // click out of bounds @@ -1325,10 +1325,10 @@ void PlayerVehWndProc(Window *w, WindowEvent *e) } break; case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ - if (vl->l.sort_type != e->dropdown.index) { + if (vl->l.sort_type != e->we.dropdown.index) { // value has changed -> resort vl->l.flags |= VL_RESORT; - vl->l.sort_type = e->dropdown.index; + vl->l.sort_type = e->we.dropdown.index; vl->_sorting->criteria = vl->l.sort_type; } SetWindowDirty(w); @@ -1351,8 +1351,8 @@ void PlayerVehWndProc(Window *w, WindowEvent *e) break; case WE_RESIZE: /* Update the scroll + matrix */ - if (vl->vehicle_type == VEH_Train) w->hscroll.cap += e->sizing.diff.x; - w->vscroll.cap += e->sizing.diff.y / (int)w->resize.step_height; + if (vl->vehicle_type == VEH_Train) w->hscroll.cap += e->we.sizing.diff.x; + w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height; w->widget[7].data = (w->vscroll.cap << 8) + 1; break; } diff --git a/viewport.c b/viewport.c index f21b5b0a7..3dbd915eb 100644 --- a/viewport.c +++ b/viewport.c @@ -1760,8 +1760,8 @@ void PlaceObject(void) WindowEvent e; e.event = WE_PLACE_OBJ; - e.place.pt = pt; - e.place.tile = TileVirtXY(pt.x, pt.y); + e.we.place.pt = pt; + e.we.place.tile = TileVirtXY(pt.x, pt.y); w->wndproc(w, &e); } } @@ -2161,7 +2161,7 @@ bool VpHandlePlaceSizingDrag(void) if (_special_mouse_mode != WSM_SIZING) return true; - e.place.userdata = _thd.userdata; + e.we.place.userdata = _thd.userdata; // stop drag mode if the window has been closed w = FindWindowById(_thd.window_class,_thd.window_number); @@ -2173,7 +2173,7 @@ bool VpHandlePlaceSizingDrag(void) // while dragging execute the drag procedure of the corresponding window (mostly VpSelectTilesWithMethod() ) if (_left_button_down) { e.event = WE_PLACE_DRAG; - e.place.pt = GetTileBelowCursor(); + e.we.place.pt = GetTileBelowCursor(); w->wndproc(w, &e); return false; } @@ -2183,7 +2183,7 @@ bool VpHandlePlaceSizingDrag(void) _special_mouse_mode = WSM_NONE; if (_thd.next_drawstyle == HT_RECT) { _thd.place_mode = VHM_RECT; - } else if ((e.place.userdata & 0xF) == VPM_SIGNALDIRS) { // some might call this a hack... -- Dominik + } else if ((e.we.place.userdata & 0xF) == VPM_SIGNALDIRS) { // some might call this a hack... -- Dominik _thd.place_mode = VHM_RECT; } else if (_thd.next_drawstyle & HT_LINE) { _thd.place_mode = VHM_RAIL; @@ -2196,9 +2196,9 @@ bool VpHandlePlaceSizingDrag(void) // and call the mouseup event. e.event = WE_PLACE_MOUSEUP; - e.place.pt = _thd.selend; - e.place.tile = TileVirtXY(e.place.pt.x, e.place.pt.y); - e.place.starttile = TileVirtXY(_thd.selstart.x, _thd.selstart.y); + e.we.place.pt = _thd.selend; + e.we.place.tile = TileVirtXY(e.we.place.pt.x, e.we.place.pt.y); + e.we.place.starttile = TileVirtXY(_thd.selstart.x, _thd.selstart.y); w->wndproc(w, &e); return false; @@ -562,8 +562,8 @@ static void DropdownMenuWndProc(Window *w, WindowEvent *e) if (WP(w,dropdown_d).click_delay != 0 && --WP(w,dropdown_d).click_delay == 0) { WindowEvent e; e.event = WE_DROPDOWN_SELECT; - e.dropdown.button = WP(w,dropdown_d).parent_button; - e.dropdown.index = WP(w,dropdown_d).selected_index; + e.we.dropdown.button = WP(w,dropdown_d).parent_button; + e.we.dropdown.index = WP(w,dropdown_d).selected_index; w2->wndproc(w2, &e); DeleteWindow(w); return; @@ -33,40 +33,40 @@ static void DispatchLeftClickEvent(Window *w, int x, int y) WindowEvent e; const Widget *wi; - e.click.pt.x = x; - e.click.pt.y = y; + e.we.click.pt.x = x; + e.we.click.pt.y = y; e.event = WE_CLICK; if (w->desc_flags & WDF_DEF_WIDGET) { - e.click.widget = GetWidgetFromPos(w, x, y); - if (e.click.widget < 0) return; /* exit if clicked outside of widgets */ + e.we.click.widget = GetWidgetFromPos(w, x, y); + if (e.we.click.widget < 0) return; /* exit if clicked outside of widgets */ - wi = &w->widget[e.click.widget]; + wi = &w->widget[e.we.click.widget]; /* don't allow any interaction if the button has been disabled */ - if (HASBIT(w->disabled_state, e.click.widget)) return; + if (HASBIT(w->disabled_state, e.we.click.widget)) return; if (wi->type & 0xE0) { /* special widget handling for buttons*/ switch (wi->type) { case WWT_IMGBTN | WWB_PUSHBUTTON: /* WWT_PUSHIMGBTN */ case WWT_TEXTBTN | WWB_PUSHBUTTON: /* WWT_PUSHTXTBTN */ - HandleButtonClick(w, e.click.widget); + HandleButtonClick(w, e.we.click.widget); break; case WWT_NODISTXTBTN: break; } } else if (wi->type == WWT_SCROLLBAR || wi->type == WWT_SCROLL2BAR || wi->type == WWT_HSCROLLBAR) { - ScrollbarClickHandler(w, wi, e.click.pt.x, e.click.pt.y); + ScrollbarClickHandler(w, wi, e.we.click.pt.x, e.we.click.pt.y); } if (w->desc_flags & WDF_STD_BTN) { - if (e.click.widget == 0) { /* 'X' */ + if (e.we.click.widget == 0) { /* 'X' */ DeleteWindow(w); return; } - if (e.click.widget == 1) { /* 'Title bar' */ + if (e.we.click.widget == 1) { /* 'Title bar' */ StartWindowDrag(w); // if not return then w = StartWindowDrag(w); to get correct pointer return; } @@ -79,7 +79,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y) if (w->desc_flags & WDF_STICKY_BUTTON && wi->type == WWT_STICKYBOX) { w->flags4 ^= WF_STICKY; - InvalidateWidget(w, e.click.widget); + InvalidateWidget(w, e.we.click.widget); return; } } @@ -93,19 +93,19 @@ static void DispatchRightClickEvent(Window *w, int x, int y) /* default tooltips handler? */ if (w->desc_flags & WDF_STD_TOOLTIPS) { - e.click.widget = GetWidgetFromPos(w, x, y); - if (e.click.widget < 0) + e.we.click.widget = GetWidgetFromPos(w, x, y); + if (e.we.click.widget < 0) return; /* exit if clicked outside of widgets */ - if (w->widget[e.click.widget].tooltips != 0) { - GuiShowTooltips(w->widget[e.click.widget].tooltips); + if (w->widget[e.we.click.widget].tooltips != 0) { + GuiShowTooltips(w->widget[e.we.click.widget].tooltips); return; } } e.event = WE_RCLICK; - e.click.pt.x = x; - e.click.pt.y = y; + e.we.click.pt.x = x; + e.we.click.pt.y = y; w->wndproc(w, &e); } @@ -774,12 +774,12 @@ static void HandlePlacePresize(void) w = GetCallbackWnd(); if (w == NULL) return; - e.place.pt = GetTileBelowCursor(); - if (e.place.pt.x == -1) { + e.we.place.pt = GetTileBelowCursor(); + if (e.we.place.pt.x == -1) { _thd.selend.x = -1; return; } - e.place.tile = TileVirtXY(e.place.pt.x, e.place.pt.y); + e.we.place.tile = TileVirtXY(e.we.place.pt.x, e.we.place.pt.y); e.event = WE_PLACE_PRESIZE; w->wndproc(w, &e); } @@ -800,9 +800,9 @@ static bool HandleDragDrop(void) if (w != NULL) { // send an event in client coordinates. e.event = WE_DRAGDROP; - e.dragdrop.pt.x = _cursor.pos.x - w->left; - e.dragdrop.pt.y = _cursor.pos.y - w->top; - e.dragdrop.widget = GetWidgetFromPos(w, e.dragdrop.pt.x, e.dragdrop.pt.y); + e.we.dragdrop.pt.x = _cursor.pos.x - w->left; + e.we.dragdrop.pt.y = _cursor.pos.y - w->top; + e.we.dragdrop.widget = GetWidgetFromPos(w, e.we.dragdrop.pt.x, e.we.dragdrop.pt.y); w->wndproc(w, &e); } return false; @@ -823,11 +823,11 @@ static bool HandlePopupMenu(void) if (_left_button_down) { e.event = WE_POPUPMENU_OVER; - e.popupmenu.pt = _cursor.pos; + e.we.popupmenu.pt = _cursor.pos; } else { _popup_menu_active = false; e.event = WE_POPUPMENU_SELECT; - e.popupmenu.pt = _cursor.pos; + e.we.popupmenu.pt = _cursor.pos; } w->wndproc(w, &e); @@ -846,8 +846,8 @@ static bool HandleMouseOver(void) // We changed window, put a MOUSEOVER event to the last window if (last_w != NULL && last_w != w) { e.event = WE_MOUSEOVER; - e.mouseover.pt.x = -1; - e.mouseover.pt.y = -1; + e.we.mouseover.pt.x = -1; + e.we.mouseover.pt.y = -1; if (last_w->wndproc) last_w->wndproc(last_w, &e); } last_w = w; @@ -855,10 +855,10 @@ static bool HandleMouseOver(void) if (w != NULL) { // send an event in client coordinates. e.event = WE_MOUSEOVER; - e.mouseover.pt.x = _cursor.pos.x - w->left; - e.mouseover.pt.y = _cursor.pos.y - w->top; + e.we.mouseover.pt.x = _cursor.pos.x - w->left; + e.we.mouseover.pt.y = _cursor.pos.y - w->top; if (w->widget != NULL) { - e.mouseover.widget = GetWidgetFromPos(w, e.mouseover.pt.x, e.mouseover.pt.y); + e.we.mouseover.widget = GetWidgetFromPos(w, e.we.mouseover.pt.x, e.we.mouseover.pt.y); } w->wndproc(w, &e); } @@ -1084,10 +1084,10 @@ static bool HandleWindowDragging(void) } e.event = WE_RESIZE; - e.sizing.size.x = x + w->width; - e.sizing.size.y = y + w->height; - e.sizing.diff.x = x; - e.sizing.diff.y = y; + e.we.sizing.size.x = x + w->width; + e.we.sizing.size.y = y + w->height; + e.we.sizing.diff.x = x; + e.we.sizing.diff.y = y; w->wndproc(w, &e); SetWindowDirty(w); @@ -1188,11 +1188,11 @@ static bool HandleViewportScroll(void) } if (_patches.reverse_scroll) { - e.scroll.delta.x = -_cursor.delta.x; - e.scroll.delta.y = -_cursor.delta.y; + e.we.scroll.delta.x = -_cursor.delta.x; + e.we.scroll.delta.y = -_cursor.delta.y; } else { - e.scroll.delta.x = _cursor.delta.x; - e.scroll.delta.y = _cursor.delta.y; + e.we.scroll.delta.x = _cursor.delta.x; + e.we.scroll.delta.y = _cursor.delta.y; } /* Create a scroll-event and send it to the window */ @@ -1246,10 +1246,10 @@ static void SendWindowMessageW(Window *w, uint msg, uint wparam, uint lparam) { WindowEvent e; - e.message.event = WE_MESSAGE; - e.message.msg = msg; - e.message.wparam = wparam; - e.message.lparam = lparam; + e.event = WE_MESSAGE; + e.we.message.msg = msg; + e.we.message.wparam = wparam; + e.we.message.lparam = lparam; w->wndproc(w, &e); } @@ -1270,17 +1270,17 @@ void SendWindowMessage(WindowClass wnd_class, WindowNumber wnd_num, uint msg, ui static void HandleKeypress(uint32 key) { Window *w; - WindowEvent we; + WindowEvent e; /* Stores if a window with a textfield for typing is open * If this is the case, keypress events are only passed to windows with text fields and * to thein this main toolbar. */ bool query_open = false; // Setup event - we.keypress.event = WE_KEYPRESS; - we.keypress.ascii = key & 0xFF; - we.keypress.keycode = key >> 16; - we.keypress.cont = true; + e.event = WE_KEYPRESS; + e.we.keypress.ascii = key & 0xFF; + e.we.keypress.keycode = key >> 16; + e.we.keypress.cont = true; // check if we have a query string window open before allowing hotkeys if (FindWindowById(WC_QUERY_STRING, 0) != NULL || @@ -1303,14 +1303,14 @@ static void HandleKeypress(uint32 key) w->window_class != WC_SAVELOAD) { continue; } - w->wndproc(w, &we); - if (!we.keypress.cont) break; + w->wndproc(w, &e); + if (!e.we.keypress.cont) break; } - if (we.keypress.cont) { + if (e.we.keypress.cont) { w = FindWindowById(WC_MAIN_TOOLBAR, 0); // When there is no toolbar w is null, check for that - if (w != NULL) w->wndproc(w, &we); + if (w != NULL) w->wndproc(w, &e); } } @@ -1376,7 +1376,7 @@ static void MouseLoop(int click, int mousewheel) /* Send WE_MOUSEWHEEL event to window */ e.event = WE_MOUSEWHEEL; - e.wheel.wheel = mousewheel; + e.we.wheel.wheel = mousewheel; w->wndproc(w, &e); /* Dispatch a MouseWheelEvent for widgets if it is not a viewport */ @@ -5,7 +5,7 @@ #include "string.h" -typedef union WindowEvent WindowEvent; +typedef struct WindowEvent WindowEvent; typedef void WindowProc(Window *w, WindowEvent *e); @@ -70,83 +70,98 @@ typedef enum FrameFlags { void DrawFrameRect(int left, int top, int right, int bottom, int color, FrameFlags flags); -/* XXX - outside "byte event" so you can set event directly without going into - * the union elements at first. Because of this every first element of the union - * MUST BE 'byte event'. Whoever did this must get shot! Scheduled for immediate - * rewrite after 0.4.0 */ -union WindowEvent { +enum WindowEventCodes { + WE_CLICK = 0, + WE_PAINT = 1, + WE_MOUSELOOP = 2, + WE_TICK = 3, + WE_4 = 4, + WE_TIMEOUT = 5, + WE_PLACE_OBJ = 6, + WE_ABORT_PLACE_OBJ = 7, + WE_DESTROY = 8, + WE_ON_EDIT_TEXT = 9, + WE_POPUPMENU_SELECT = 10, + WE_POPUPMENU_OVER = 11, + WE_DRAGDROP = 12, + WE_PLACE_DRAG = 13, + WE_PLACE_MOUSEUP = 14, + WE_PLACE_PRESIZE = 15, + WE_DROPDOWN_SELECT = 16, + WE_RCLICK = 17, + WE_KEYPRESS = 18, + WE_CREATE = 19, + WE_MOUSEOVER = 20, + WE_ON_EDIT_TEXT_CANCEL = 21, + WE_RESIZE = 22, + WE_MESSAGE = 23, + WE_SCROLL = 24, + WE_MOUSEWHEEL = 25, +}; + +struct WindowEvent { byte event; - struct { - byte event; - Point pt; - int widget; - } click; - - struct { - byte event; - Point pt; - TileIndex tile; - TileIndex starttile; - int userdata; - } place; - - struct { - byte event; - Point pt; - int widget; - } dragdrop; - - struct { - byte event; - Point size; - Point diff; - } sizing; - - struct { - byte event; - char *str; - } edittext; - - struct { - byte event; - Point pt; - } popupmenu; - - struct { - byte event; - int button; - int index; - } dropdown; - - struct { - byte event; - Point pt; - int widget; - } mouseover; - - struct { - byte event; - bool cont; // continue the search? (default true) - byte ascii; // 8-bit ASCII-value of the key - uint16 keycode;// untranslated key (including shift-state) - } keypress; - - struct { - byte event; - uint msg; // message to be sent - uint wparam; // additional message-specific information - uint lparam; // additional message-specific information - } message; - - struct { - byte event; - Point delta; // delta position against position of last call - } scroll; - - struct { - byte event; - int wheel; // how much was 'wheel'd' - } wheel; + union { + struct{ + Point pt; + int widget; + } click; + + struct { + Point pt; + TileIndex tile; + TileIndex starttile; + int userdata; + } place; + + struct { + Point pt; + int widget; + } dragdrop; + + struct { + Point size; + Point diff; + } sizing; + + struct { + char *str; + } edittext; + + struct { + Point pt; + } popupmenu; + + struct { + int button; + int index; + } dropdown; + + struct { + Point pt; + int widget; + } mouseover; + + struct { + bool cont; // continue the search? (default true) + byte ascii; // 8-bit ASCII-value of the key + uint16 keycode;// untranslated key (including shift-state) + } keypress; + + struct { + uint msg; // message to be sent + uint wparam; // additional message-specific information + uint lparam; // additional message-specific information + } message; + + struct { + Point delta; // delta position against position of last call + } scroll; + + struct { + int wheel; // how much was 'wheel'd' + } wheel; + } we; }; enum WindowKeyCodes { @@ -489,35 +504,6 @@ typedef struct dropdown_d { } dropdown_d; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d)); -enum WindowEvents { - WE_CLICK = 0, - WE_PAINT = 1, - WE_MOUSELOOP = 2, - WE_TICK = 3, - WE_4 = 4, - WE_TIMEOUT = 5, - WE_PLACE_OBJ = 6, - WE_ABORT_PLACE_OBJ = 7, - WE_DESTROY = 8, - WE_ON_EDIT_TEXT = 9, - WE_POPUPMENU_SELECT = 10, - WE_POPUPMENU_OVER = 11, - WE_DRAGDROP = 12, - WE_PLACE_DRAG = 13, - WE_PLACE_MOUSEUP = 14, - WE_PLACE_PRESIZE = 15, - WE_DROPDOWN_SELECT = 16, - WE_RCLICK = 17, - WE_KEYPRESS = 18, - WE_CREATE = 19, - WE_MOUSEOVER = 20, - WE_ON_EDIT_TEXT_CANCEL = 21, - WE_RESIZE = 22, - WE_MESSAGE = 23, - WE_SCROLL = 24, - WE_MOUSEWHEEL = 25, -}; - /****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/ enum WindowWidgetBehaviours { |