Ignore:
Timestamp:
07/05/12 17:51:58 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Reworked fuel handling so that the model can tell what tanks there are

Location:
src/mlx/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/flight.py

    r262 r274  
    11631163            gui.beginBusy(xstr("fuel_get_busy"))
    11641164           
    1165             gui.simulator.getFuel(gui.flight.aircraft.fuelTanks,
    1166                                   self._handleFuel)
     1165            gui.simulator.getFuel(self._handleFuel)
    11671166        else:
    11681167            self._wizard.nextPage()
     
    13741373        self.setMainWidget(self._fuelAlignment)
    13751374
    1376         tanks = acft.MostFuelTankAircraft.fuelTanks
    1377         tankData = ((2500, 3900),) * len(tanks)
    1378         self._setupTanks(tanks, tankData)
     1375        tankData = [(tank, 2500, 3900) for tank in acft.mostFuelTanks]
     1376        self._setupTanks(tankData)
    13791377
    13801378        self.addCancelFlightButton()
     
    13871385    def activate(self):
    13881386        """Activate the page."""
    1389         gui = self._wizard.gui
    1390 
    1391         self._setupTanks(gui.flight.aircraft.fuelTanks,
    1392                          self._wizard._fuelData)
     1387        self._setupTanks(self._wizard._fuelData)
    13931388
    13941389    def finalize(self):
     
    14101405            self._wizard.nextPage()       
    14111406
    1412     def _setupTanks(self, tanks, tankData):
     1407    def _setupTanks(self, tankData):
    14131408        """Setup the tanks for the given data."""
    1414         numTanks = len(tanks)
     1409        numTanks = len(tankData)
    14151410        if self._fuelTable is not None:
    14161411            self._fuelAlignment.remove(self._fuelTable)
     
    14191414        self._fuelTable = gtk.Table(numTanks, 1)
    14201415        self._fuelTable.set_col_spacings(16)
    1421         for i in range(0, numTanks):
    1422             tank = tanks[i]
    1423             (current, capacity) = tankData[i]
    1424 
     1416        index = 0
     1417        for (tank, current, capacity) in tankData:
    14251418            fuelTank = FuelTank(tank,
    14261419                                xstr("fuel_tank_" +
    14271420                                     const.fuelTank2string(tank)),
    14281421                                capacity, current)
    1429             self._fuelTable.attach(fuelTank, i, i+1, 0, 1)
     1422            self._fuelTable.attach(fuelTank, index, index+1, 0, 1)
    14301423            self._fuelTanks.append(fuelTank)
     1424            index += 1
    14311425           
    14321426        self._fuelAlignment.add(self._fuelTable)
  • src/mlx/gui/monitor.py

    r263 r274  
    281281
    282282            fuelStr = ""
    283             for fuel in aircraftState.fuel:
     283            for (_tank, fuel) in aircraftState.fuel:
    284284                if fuelStr: fuelStr += ", "
    285285                fuelStr += "%.0f" % (fuel,)               
Note: See TracChangeset for help on using the changeset viewer.