(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window

-The user will notice the following changes:
      All vehicle types behaves in the same way
      Adding/removing an engine (new design and so on) can no longer result in the window selecting a new engine
      All valid replacements will be displayed since it looks at refitting options as well (this solves the missing ships with the newships GRF)
      Since you can't replace an engine into itself, the engine selected in the left list will no longer appear in the right list

   -The code changes:
      Instead of looping all engines all the time, each list generates a list like the build windows
        This ensures consistent list generation since only one function can loop all engines
      Unified code for all vehicle types
      It now use the lists to call the drawing code in the build vehicle window
      Works on selected EngineIDs instead of selected index in the list
This commit is contained in:
bjarni
2007-02-06 11:11:12 +00:00
parent ec301e0f8a
commit f626458af7
12 changed files with 331 additions and 417 deletions

View File

@@ -101,9 +101,11 @@ static void CalcEngineReliability(Engine *e)
* We will now completely retire this design */
e->player_avail = 0;
e->reliability = e->reliability_final;
InvalidateWindowClassesData(WC_BUILD_VEHICLE); // Kick this engine out of the lists
/* Kick this engine out of the lists */
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
}
InvalidateWindowClasses(WC_BUILD_VEHICLE); // Update to show the new reliability
InvalidateWindowClasses(WC_REPLACE_VEHICLE);
}
void AddTypeToEngines(void)
@@ -195,8 +197,7 @@ static void AcceptEnginePreview(EngineID eid, PlayerID player)
e->preview_player = INVALID_PLAYER;
if (player == _local_player) {
InvalidateWindowClassesData(WC_BUILD_VEHICLE);
InvalidateWindowClasses(WC_REPLACE_VEHICLE);
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
}
}
@@ -319,8 +320,7 @@ static void NewVehicleAvailable(Engine *e)
}
e->flags = (e->flags & ~ENGINE_INTRODUCING) | ENGINE_AVAILABLE;
InvalidateWindowClassesData(WC_BUILD_VEHICLE);
InvalidateWindowClasses(WC_REPLACE_VEHICLE);
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
// Now available for all players
e->player_avail = (byte)-1;