summaryrefslogtreecommitdiff
path: root/aircraft_gui.c
diff options
context:
space:
mode:
Diffstat (limited to 'aircraft_gui.c')
-rw-r--r--aircraft_gui.c128
1 files changed, 64 insertions, 64 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c
index 7b501ea6a..6f358e1af 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -345,10 +345,10 @@ static void GenerateBuildList(EngineID **planes, uint16 *num_planes, EngineID **
static inline EngineID *GetEngineArray(Window *w)
{
- switch (WP(w,buildtrain_d).show_engine_button) {
- case 1: return WP(w, buildtrain_d).list_a;
- case 2: return WP(w, buildtrain_d).list_b;
- case 3: return WP(w, buildtrain_d).list_c;
+ switch (WP(w,buildvehicle_d).show_engine_button) {
+ case 1: return WP(w, buildvehicle_d).list_a;
+ case 2: return WP(w, buildvehicle_d).list_b;
+ case 3: return WP(w, buildvehicle_d).list_c;
default: NOT_REACHED();
}
return NULL;
@@ -356,10 +356,10 @@ static inline EngineID *GetEngineArray(Window *w)
static inline uint16 GetEngineArrayLength(Window *w)
{
- switch (WP(w,buildtrain_d).show_engine_button) {
- case 1: return WP(w, buildtrain_d).list_a_length;
- case 2: return WP(w, buildtrain_d).list_b_length;
- case 3: return WP(w, buildtrain_d).list_c_length;
+ switch (WP(w,buildvehicle_d).show_engine_button) {
+ case 1: return WP(w, buildvehicle_d).list_a_length;
+ case 2: return WP(w, buildvehicle_d).list_b_length;
+ case 3: return WP(w, buildvehicle_d).list_c_length;
default: NOT_REACHED();
}
return 0;
@@ -367,50 +367,50 @@ static inline uint16 GetEngineArrayLength(Window *w)
static void SortAircraftBuildList(Window *w)
{
- _internal_sort_order = WP(w,buildtrain_d).decenting_sort_order;
+ _internal_sort_order = WP(w,buildvehicle_d).decenting_sort_order;
qsort((void*)GetEngineArray(w), GetEngineArrayLength(w), sizeof(GetEngineArray(w)[0]),
- _engine_sorter[WP(w,buildtrain_d).sort_criteria]);
+ _engine_sorter[WP(w,buildvehicle_d).sort_criteria]);
}
static void DrawBuildAircraftWindow(Window *w)
{
- SetWindowWidgetLoweredState(w, BUILD_AIRCRAFT_WIDGET_PLANES, WP(w,buildtrain_d).show_engine_button == 1);
- SetWindowWidgetLoweredState(w, BUILD_AIRCRAFT_WIDGET_JETS, WP(w,buildtrain_d).show_engine_button == 2);
- SetWindowWidgetLoweredState(w, BUILD_AIRCRAFT_WIDGET_HELICOPTERS, WP(w,buildtrain_d).show_engine_button == 3);
+ SetWindowWidgetLoweredState(w, BUILD_AIRCRAFT_WIDGET_PLANES, WP(w,buildvehicle_d).show_engine_button == 1);
+ SetWindowWidgetLoweredState(w, BUILD_AIRCRAFT_WIDGET_JETS, WP(w,buildvehicle_d).show_engine_button == 2);
+ SetWindowWidgetLoweredState(w, BUILD_AIRCRAFT_WIDGET_HELICOPTERS, WP(w,buildvehicle_d).show_engine_button == 3);
SetWindowWidgetDisabledState(w, BUILD_AIRCRAFT_WIDGET_BUILD, w->window_number == 0);
- if (WP(w, buildtrain_d).data_invalidated) {
- GenerateBuildList(&WP(w, buildtrain_d).list_a, &WP(w, buildtrain_d).list_a_length,
- &WP(w, buildtrain_d).list_b, &WP(w, buildtrain_d).list_b_length,
- &WP(w, buildtrain_d).list_c, &WP(w, buildtrain_d).list_c_length);
- WP(w, buildtrain_d).data_invalidated = false;
+ if (WP(w, buildvehicle_d).data_invalidated) {
+ GenerateBuildList(&WP(w, buildvehicle_d).list_a, &WP(w, buildvehicle_d).list_a_length,
+ &WP(w, buildvehicle_d).list_b, &WP(w, buildvehicle_d).list_b_length,
+ &WP(w, buildvehicle_d).list_c, &WP(w, buildvehicle_d).list_c_length);
+ WP(w, buildvehicle_d).data_invalidated = false;
- if (WP(w,buildtrain_d).sel_engine != INVALID_ENGINE) {
+ if (WP(w,buildvehicle_d).sel_engine != INVALID_ENGINE) {
int i;
bool found = false;
- if (HASBIT(WP(w,buildtrain_d).show_engine_button, 0)) {
+ if (HASBIT(WP(w,buildvehicle_d).show_engine_button, 0)) {
for (i = 0; i < GetEngineArrayLength(w); i++) {
- if (WP(w,buildtrain_d).sel_engine != GetEngineArray(w)[i]) continue;
+ if (WP(w,buildvehicle_d).sel_engine != GetEngineArray(w)[i]) continue;
found = true;
break;
}
}
- if (!found) WP(w,buildtrain_d).sel_engine = INVALID_ENGINE;
+ if (!found) WP(w,buildvehicle_d).sel_engine = INVALID_ENGINE;
}
}
SetVScrollCount(w, GetEngineArrayLength(w));
DrawWindowWidgets(w);
- if (WP(w,buildtrain_d).sel_engine == INVALID_ENGINE && GetEngineArrayLength(w) != 0) {
- WP(w,buildtrain_d).sel_engine = GetEngineArray(w)[0];
+ if (WP(w,buildvehicle_d).sel_engine == INVALID_ENGINE && GetEngineArrayLength(w) != 0) {
+ WP(w,buildvehicle_d).sel_engine = GetEngineArray(w)[0];
}
{
int x = 2;
int y = 27;
- EngineID selected_id = WP(w,buildtrain_d).sel_engine;
+ EngineID selected_id = WP(w,buildvehicle_d).sel_engine;
EngineID eid = w->vscroll.pos;
EngineID *list = GetEngineArray(w);
uint16 list_length = GetEngineArrayLength(w);
@@ -428,8 +428,8 @@ static void DrawBuildAircraftWindow(Window *w)
DrawAircraftPurchaseInfo(x, w->widget[BUILD_AIRCRAFT_WIDGET_PANEL].top + 1, selected_id);
}
}
- DrawString(85, 15, _engine_sort_listing[WP(w,buildtrain_d).sort_criteria], 0x10);
- DoDrawString(WP(w,buildtrain_d).decenting_sort_order ? DOWNARROW : UPARROW, 69, 15, 0x10);
+ DrawString(85, 15, _engine_sort_listing[WP(w,buildvehicle_d).sort_criteria], 0x10);
+ DoDrawString(WP(w,buildvehicle_d).decenting_sort_order ? DOWNARROW : UPARROW, 69, 15, 0x10);
}
static void BuildAircraftClickEvent(Window *w, WindowEvent *e)
@@ -438,8 +438,8 @@ static void BuildAircraftClickEvent(Window *w, WindowEvent *e)
switch (e->we.click.widget) {
case BUILD_AIRCRAFT_WIDGET_SORT_ASSENDING_DESENTING:
- WP(w,buildtrain_d).decenting_sort_order = !WP(w,buildtrain_d).decenting_sort_order;
- _last_sort_order = WP(w,buildtrain_d).decenting_sort_order;
+ WP(w,buildvehicle_d).decenting_sort_order = !WP(w,buildvehicle_d).decenting_sort_order;
+ _last_sort_order = WP(w,buildvehicle_d).decenting_sort_order;
SortAircraftBuildList(w);
SetWindowDirty(w);
break;
@@ -450,39 +450,39 @@ static void BuildAircraftClickEvent(Window *w, WindowEvent *e)
i += w->vscroll.pos;
if (i < GetEngineArrayLength(w)) {
- WP(w,buildtrain_d).sel_engine = GetEngineArray(w)[i];
+ WP(w,buildvehicle_d).sel_engine = GetEngineArray(w)[i];
SetWindowDirty(w);
}
}
} break;
case BUILD_AIRCRAFT_WIDGET_SORT_TEXT: case BUILD_AIRCRAFT_WIDGET_SORT_DROPDOWN:/* Select sorting criteria dropdown menu */
- ShowDropDownMenu(w, _engine_sort_listing, WP(w,buildtrain_d).sort_criteria, BUILD_AIRCRAFT_WIDGET_SORT_DROPDOWN, 0, 0);
+ ShowDropDownMenu(w, _engine_sort_listing, WP(w,buildvehicle_d).sort_criteria, BUILD_AIRCRAFT_WIDGET_SORT_DROPDOWN, 0, 0);
return;
case BUILD_AIRCRAFT_WIDGET_HELICOPTERS: click_state++;
case BUILD_AIRCRAFT_WIDGET_JETS: click_state++;
case BUILD_AIRCRAFT_WIDGET_PLANES: click_state++;
- if (WP(w,buildtrain_d).show_engine_button == click_state) break; // We clicked the pressed button
+ if (WP(w,buildvehicle_d).show_engine_button == click_state) break; // We clicked the pressed button
- WP(w,buildtrain_d).sel_engine = INVALID_ENGINE;
- WP(w,buildtrain_d).show_engine_button = click_state;
+ WP(w,buildvehicle_d).sel_engine = INVALID_ENGINE;
+ WP(w,buildvehicle_d).show_engine_button = click_state;
w->vscroll.pos = 0;
SortAircraftBuildList(w);
SetWindowDirty(w);
break;
case BUILD_AIRCRAFT_WIDGET_BUILD: {
- EngineID sel_eng = WP(w,buildtrain_d).sel_engine;
+ EngineID sel_eng = WP(w,buildvehicle_d).sel_engine;
if (sel_eng != INVALID_ENGINE)
DoCommandP(w->window_number, sel_eng, 0, CcBuildAircraft, CMD_BUILD_AIRCRAFT | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT));
} break;
case BUILD_AIRCRAFT_WIDGET_RENAME: {
- EngineID sel_eng = WP(w,buildtrain_d).sel_engine;
+ EngineID sel_eng = WP(w,buildvehicle_d).sel_engine;
if (sel_eng != INVALID_ENGINE) {
- WP(w,buildtrain_d).rename_engine = sel_eng;
+ WP(w,buildvehicle_d).rename_engine = sel_eng;
ShowQueryString(GetCustomEngineName(sel_eng),
STR_A039_RENAME_AIRCRAFT_TYPE, 31, 160, w->window_class, w->window_number, CS_ALPHANUMERAL);
}
@@ -494,46 +494,46 @@ static void BuildAircraftWindowCreate(Window *w)
{
TileIndex tile = w->window_number;
- WP(w, buildtrain_d).list_a_length = 0;
- WP(w, buildtrain_d).list_b_length = 0;
- WP(w, buildtrain_d).list_c_length = 0;
- WP(w, buildtrain_d).list_a = NULL;
- WP(w, buildtrain_d).list_b = NULL;
- WP(w, buildtrain_d).list_c = NULL;
- WP(w, buildtrain_d).data_invalidated = false;
- WP(w, buildtrain_d).sel_engine = INVALID_ENGINE;
- WP(w, buildtrain_d).sort_criteria = _last_sort_criteria;
- WP(w, buildtrain_d).decenting_sort_order = _last_sort_order;
-
- GenerateBuildList(&WP(w, buildtrain_d).list_a, &WP(w, buildtrain_d).list_a_length,
- &WP(w, buildtrain_d).list_b, &WP(w, buildtrain_d).list_b_length,
- &WP(w, buildtrain_d).list_c, &WP(w, buildtrain_d).list_c_length);
+ WP(w, buildvehicle_d).list_a_length = 0;
+ WP(w, buildvehicle_d).list_b_length = 0;
+ WP(w, buildvehicle_d).list_c_length = 0;
+ WP(w, buildvehicle_d).list_a = NULL;
+ WP(w, buildvehicle_d).list_b = NULL;
+ WP(w, buildvehicle_d).list_c = NULL;
+ WP(w, buildvehicle_d).data_invalidated = false;
+ WP(w, buildvehicle_d).sel_engine = INVALID_ENGINE;
+ WP(w, buildvehicle_d).sort_criteria = _last_sort_criteria;
+ WP(w, buildvehicle_d).decenting_sort_order = _last_sort_order;
+
+ GenerateBuildList(&WP(w, buildvehicle_d).list_a, &WP(w, buildvehicle_d).list_a_length,
+ &WP(w, buildvehicle_d).list_b, &WP(w, buildvehicle_d).list_b_length,
+ &WP(w, buildvehicle_d).list_c, &WP(w, buildvehicle_d).list_c_length);
/* Disable the aircraft subtype buttons for the types, that can't be build at the current airport */
if (tile == 0) {
- WP(w, buildtrain_d).show_engine_button = 1;
+ WP(w, buildvehicle_d).show_engine_button = 1;
} else {
byte acc_planes = GetAirport(GetStationByTile(tile)->airport_type)->acc_planes;
- WP(w, buildtrain_d).show_engine_button = 0;
+ WP(w, buildvehicle_d).show_engine_button = 0;
if (acc_planes == HELICOPTERS_ONLY || acc_planes == ALL) {
- WP(w, buildtrain_d).show_engine_button = 3;
+ WP(w, buildvehicle_d).show_engine_button = 3;
} else {
DisableWindowWidget(w, BUILD_AIRCRAFT_WIDGET_HELICOPTERS);
}
if (acc_planes == AIRCRAFT_ONLY || acc_planes == ALL) {
/* Set the start clicked button to jets if the list isn't empty. If not, then show propeller planes */
- WP(w, buildtrain_d).show_engine_button = WP(w, buildtrain_d).list_b_length == 0 ? 1 : 2;
+ WP(w, buildvehicle_d).show_engine_button = WP(w, buildvehicle_d).list_b_length == 0 ? 1 : 2;
} else {
DisableWindowWidget(w, BUILD_AIRCRAFT_WIDGET_JETS);
DisableWindowWidget(w, BUILD_AIRCRAFT_WIDGET_PLANES);
}
- if (WP(w, buildtrain_d).show_engine_button == 0) {
+ if (WP(w, buildvehicle_d).show_engine_button == 0) {
/* No plane type are buildable here */
NOT_REACHED();
- WP(w, buildtrain_d).show_engine_button = 1;
+ WP(w, buildvehicle_d).show_engine_button = 1;
}
}
SortAircraftBuildList(w);
@@ -547,13 +547,13 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e)
break;
case WE_INVALIDATE_DATA:
- WP(w,buildtrain_d).data_invalidated = true;
+ WP(w,buildvehicle_d).data_invalidated = true;
break;
case WE_DESTROY:
- free((void*)WP(w, buildtrain_d).list_a);
- free((void*)WP(w, buildtrain_d).list_b);
- free((void*)WP(w, buildtrain_d).list_c);
+ free((void*)WP(w, buildvehicle_d).list_a);
+ free((void*)WP(w, buildvehicle_d).list_b);
+ free((void*)WP(w, buildvehicle_d).list_c);
break;
case WE_PAINT:
@@ -567,14 +567,14 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e)
case WE_ON_EDIT_TEXT: {
if (e->we.edittext.str[0] != '\0') {
_cmd_text = e->we.edittext.str;
- DoCommandP(0, WP(w, buildtrain_d).rename_engine, 0, NULL,
+ DoCommandP(0, WP(w, buildvehicle_d).rename_engine, 0, NULL,
CMD_RENAME_ENGINE | CMD_MSG(STR_A03A_CAN_T_RENAME_AIRCRAFT_TYPE));
}
} break;
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
- if (WP(w,buildtrain_d).sort_criteria != e->we.dropdown.index) {
- WP(w,buildtrain_d).sort_criteria = e->we.dropdown.index;
+ if (WP(w,buildvehicle_d).sort_criteria != e->we.dropdown.index) {
+ WP(w,buildvehicle_d).sort_criteria = e->we.dropdown.index;
_last_sort_criteria = e->we.dropdown.index;
SortAircraftBuildList(w);
}