mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +00:00
(svn r6680) -Codechange r6679: [train build window] only generate the list when the window data is invalidated or the window is generated, not on each redraw
This commit is contained in:
parent
db66567799
commit
208e258f4c
8
engine.c
8
engine.c
@ -209,8 +209,11 @@ static void AcceptEnginePreview(Engine *e, PlayerID player)
|
||||
SETBIT(p->avail_railtypes, e->railtype);
|
||||
|
||||
e->preview_player = 0xFF;
|
||||
InvalidateWindowClasses(WC_BUILD_VEHICLE);
|
||||
InvalidateWindowClasses(WC_REPLACE_VEHICLE);
|
||||
if (player == _local_player) {
|
||||
InvalidateWindowClassesData(WC_BUILD_VEHICLE);
|
||||
InvalidateWindowClasses(WC_BUILD_VEHICLE);
|
||||
InvalidateWindowClasses(WC_REPLACE_VEHICLE);
|
||||
}
|
||||
}
|
||||
|
||||
static PlayerID GetBestPlayer(PlayerID pp)
|
||||
@ -332,6 +335,7 @@ static void NewVehicleAvailable(Engine *e)
|
||||
}
|
||||
|
||||
e->flags = (e->flags & ~ENGINE_INTRODUCING) | ENGINE_AVAILABLE;
|
||||
InvalidateWindowClassesData(WC_BUILD_VEHICLE);
|
||||
InvalidateWindowClasses(WC_BUILD_VEHICLE);
|
||||
InvalidateWindowClasses(WC_REPLACE_VEHICLE);
|
||||
|
||||
|
@ -168,6 +168,7 @@ void MarkTileDirtyByTile(TileIndex tile);
|
||||
void InvalidateWindow(WindowClass cls, WindowNumber number);
|
||||
void InvalidateWindowWidget(WindowClass cls, WindowNumber number, byte widget_index);
|
||||
void InvalidateWindowClasses(WindowClass cls);
|
||||
void InvalidateWindowClassesData(WindowClass cls);
|
||||
void DeleteWindowById(WindowClass cls, WindowNumber number);
|
||||
void DeleteWindowByClass(WindowClass cls);
|
||||
|
||||
|
10
train_gui.c
10
train_gui.c
@ -273,7 +273,10 @@ static void DrawTrainBuildWindow(Window *w)
|
||||
SetWindowWidgetLoweredState(w, BUILD_TRAIN_WIDGET_WAGONS, WP(w,buildtrain_d).show_engine_wagon == 2);
|
||||
SetWindowWidgetLoweredState(w, BUILD_TRAIN_WIDGET_BOTH, WP(w,buildtrain_d).show_engine_wagon == 3);
|
||||
|
||||
GenerateBuildList(&WP(w,buildtrain_d).engines, &WP(w,buildtrain_d).num_engines, &WP(w,buildtrain_d).wagons, &WP(w,buildtrain_d).num_wagons, WP(w,buildtrain_d).railtype);
|
||||
if (WP(w,buildtrain_d).data_invalidated) {
|
||||
GenerateBuildList(&WP(w,buildtrain_d).engines, &WP(w,buildtrain_d).num_engines, &WP(w,buildtrain_d).wagons, &WP(w,buildtrain_d).num_wagons, WP(w,buildtrain_d).railtype);
|
||||
WP(w,buildtrain_d).data_invalidated = false;
|
||||
}
|
||||
|
||||
if (HASBIT(WP(w,buildtrain_d).show_engine_wagon, 0)) scrollcount += WP(w,buildtrain_d).num_engines;
|
||||
if (HASBIT(WP(w,buildtrain_d).show_engine_wagon, 1)) scrollcount += WP(w,buildtrain_d).num_wagons;
|
||||
@ -326,6 +329,11 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
|
||||
WP(w,buildtrain_d).engines = NULL;
|
||||
WP(w,buildtrain_d).wagons = NULL;
|
||||
WP(w,buildtrain_d).show_engine_wagon = 3;
|
||||
WP(w,buildtrain_d).data_invalidated = true;
|
||||
break;
|
||||
|
||||
case WE_INVALIDATE_DATA:
|
||||
WP(w,buildtrain_d).data_invalidated = true;
|
||||
break;
|
||||
|
||||
case WE_DESTROY:
|
||||
|
16
window.c
16
window.c
@ -1609,12 +1609,26 @@ void InvalidateWindowClasses(WindowClass cls)
|
||||
}
|
||||
}
|
||||
|
||||
void InvalidateThisWindowData(Window *w)
|
||||
{
|
||||
CallWindowEventNP(w, WE_INVALIDATE_DATA);
|
||||
}
|
||||
|
||||
void InvalidateWindowData(WindowClass cls, WindowNumber number)
|
||||
{
|
||||
Window *w;
|
||||
|
||||
for (w = _windows; w != _last_window; w++) {
|
||||
if (w->window_class == cls && w->window_number == number) CallWindowEventNP(w, WE_INVALIDATE_DATA);
|
||||
if (w->window_class == cls && w->window_number == number) InvalidateThisWindowData(w);
|
||||
}
|
||||
}
|
||||
|
||||
void InvalidateWindowClassesData(WindowClass cls)
|
||||
{
|
||||
Window *w;
|
||||
|
||||
for (w = _windows; w != _last_window; w++) {
|
||||
if (w->window_class == cls) InvalidateThisWindowData(w);
|
||||
}
|
||||
}
|
||||
|
||||
|
2
window.h
2
window.h
@ -394,6 +394,7 @@ typedef struct {
|
||||
byte railtype;
|
||||
byte sel_index;
|
||||
byte show_engine_wagon;
|
||||
bool data_invalidated;
|
||||
EngineID sel_engine;
|
||||
EngineID rename_engine;
|
||||
EngineID *engines;
|
||||
@ -789,6 +790,7 @@ int GetMenuItemIndex(const Window *w, int x, int y);
|
||||
void InputLoop(void);
|
||||
void UpdateWindows(void);
|
||||
void InvalidateWidget(const Window *w, byte widget_index);
|
||||
void InvalidateThisWindowData(Window *w);
|
||||
void InvalidateWindowData(WindowClass cls, WindowNumber number);
|
||||
void RaiseWindowButtons(Window *w);
|
||||
void RelocateAllWindows(int neww, int newh);
|
||||
|
Loading…
Reference in New Issue
Block a user