mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-09 19:10:38 +00:00
(svn r8333) -Codechange: when invalidating a build window list, set a flag instead of rebuilding the list and then rebuild it the next time it's redrawn
This should save CPU time in the (maybe unlikely) event that the list is invalidated more than once between two redraws
This commit is contained in:
parent
f87494587e
commit
ade2af8ac6
@ -654,7 +654,7 @@ static void BuildVehicleClickEvent(Window *w, WindowEvent *e)
|
|||||||
case VEH_Train: _last_sort_order_train = bv->descending_sort_order; break;
|
case VEH_Train: _last_sort_order_train = bv->descending_sort_order; break;
|
||||||
case VEH_Aircraft: _last_sort_order_aircraft = bv->descending_sort_order; break;
|
case VEH_Aircraft: _last_sort_order_aircraft = bv->descending_sort_order; break;
|
||||||
}
|
}
|
||||||
GenerateBuildList(w);
|
bv->regenerate_list = true;
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -716,7 +716,8 @@ static void NewVehicleWndProc(Window *w, WindowEvent *e)
|
|||||||
|
|
||||||
switch (e->event) {
|
switch (e->event) {
|
||||||
case WE_INVALIDATE_DATA:
|
case WE_INVALIDATE_DATA:
|
||||||
GenerateBuildList(w);
|
bv->regenerate_list = true;
|
||||||
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_DESTROY:
|
case WE_DESTROY:
|
||||||
@ -724,6 +725,10 @@ static void NewVehicleWndProc(Window *w, WindowEvent *e)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_PAINT:
|
case WE_PAINT:
|
||||||
|
if (bv->regenerate_list) {
|
||||||
|
bv->regenerate_list = false;
|
||||||
|
GenerateBuildList(w);
|
||||||
|
}
|
||||||
DrawBuildVehicleWindow(w);
|
DrawBuildVehicleWindow(w);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -751,7 +756,7 @@ static void NewVehicleWndProc(Window *w, WindowEvent *e)
|
|||||||
case VEH_Train: _last_sort_criteria_train = bv->sort_criteria; break;
|
case VEH_Train: _last_sort_criteria_train = bv->sort_criteria; break;
|
||||||
case VEH_Aircraft: _last_sort_criteria_aircraft = bv->sort_criteria; break;
|
case VEH_Aircraft: _last_sort_criteria_aircraft = bv->sort_criteria; break;
|
||||||
}
|
}
|
||||||
GenerateBuildList(w);
|
bv->regenerate_list = true;
|
||||||
}
|
}
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
@ -793,9 +798,10 @@ void ShowBuildVehicleWindow(TileIndex tile, byte type)
|
|||||||
|
|
||||||
bv = &WP(w, buildvehicle_d);
|
bv = &WP(w, buildvehicle_d);
|
||||||
EngList_Create(&bv->eng_list);
|
EngList_Create(&bv->eng_list);
|
||||||
bv->sel_engine = INVALID_ENGINE;
|
bv->sel_engine = INVALID_ENGINE;
|
||||||
|
|
||||||
bv->vehicle_type = type;
|
bv->vehicle_type = type;
|
||||||
|
bv->regenerate_list = false;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case VEH_Train:
|
case VEH_Train:
|
||||||
@ -818,7 +824,7 @@ void ShowBuildVehicleWindow(TileIndex tile, byte type)
|
|||||||
w->resize.width = w->width;
|
w->resize.width = w->width;
|
||||||
w->resize.height = w->height;
|
w->resize.height = w->height;
|
||||||
|
|
||||||
GenerateBuildList(w);
|
GenerateBuildList(w); // generate the list, since we need it in the next line
|
||||||
/* Select the first engine in the list as default when opening the window */
|
/* Select the first engine in the list as default when opening the window */
|
||||||
if (EngList_Count(&bv->eng_list) > 0) bv->sel_engine = bv->eng_list[0];
|
if (EngList_Count(&bv->eng_list) > 0) bv->sel_engine = bv->eng_list[0];
|
||||||
}
|
}
|
||||||
|
@ -326,6 +326,7 @@ typedef struct {
|
|||||||
byte sel_index; // deprecated value, used for 'unified' ship and road
|
byte sel_index; // deprecated value, used for 'unified' ship and road
|
||||||
bool descending_sort_order;
|
bool descending_sort_order;
|
||||||
byte sort_criteria;
|
byte sort_criteria;
|
||||||
|
bool regenerate_list;
|
||||||
EngineID sel_engine;
|
EngineID sel_engine;
|
||||||
EngineID rename_engine;
|
EngineID rename_engine;
|
||||||
EngineList eng_list;
|
EngineList eng_list;
|
||||||
|
Loading…
Reference in New Issue
Block a user