(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 2918fab68d
commit 80125fd934
12 changed files with 331 additions and 417 deletions

View File

@@ -888,13 +888,14 @@ int32 CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->random_bits = VehicleRandomBits();
VehiclePositionChanged(v);
GetPlayer(_current_player)->num_engines[p1]++;
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
RebuildVehicleLists();
InvalidateWindow(WC_COMPANY, v->owner);
if (IsLocalPlayer())
InvalidateWindow(WC_REPLACE_VEHICLE, VEH_Ship); // updates the replace Ship window
InvalidateAutoreplaceWindow(VEH_Ship); // updates the replace Ship window
GetPlayer(_current_player)->num_engines[p1]++;
}
return value;
@@ -928,8 +929,6 @@ int32 CmdSellShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
DeleteDepotHighlightOfVehicle(v);
DeleteVehicle(v);
if (IsLocalPlayer())
InvalidateWindow(WC_REPLACE_VEHICLE, VEH_Ship); // updates the replace Ship window
}
return -(int32)v->value;