Add a toggle between fit-specific implants and character implants. This avoids a lot of the problems of how to mix these two sources of implants. Character implants cannot change stage.
This commit is contained in:
@@ -28,7 +28,7 @@ from eos.db.saveddata.module import modules_table
|
||||
from eos.db.saveddata.drone import drones_table
|
||||
from eos.db.saveddata.cargo import cargo_table
|
||||
from eos.db.saveddata.implant import fitImplants_table
|
||||
from eos.types import Fit, Module, User, Booster, Drone, Cargo, Implant, Character, DamagePattern, TargetResists
|
||||
from eos.types import Fit, Module, User, Booster, Drone, Cargo, Implant, Character, DamagePattern, TargetResists, ImplantLocation
|
||||
from eos.effectHandlerHelpers import *
|
||||
|
||||
fits_table = Table("fits", saveddata_meta,
|
||||
@@ -42,6 +42,7 @@ fits_table = Table("fits", saveddata_meta,
|
||||
Column("booster", Boolean, nullable = False, index = True, default = 0),
|
||||
Column("targetResistsID", ForeignKey("targetResists.ID"), nullable=True),
|
||||
Column("modeID", Integer, nullable=True),
|
||||
Column("implantLocation", Integer, nullable=False, default=ImplantLocation.FIT),
|
||||
)
|
||||
|
||||
projectedFits_table = Table("projectedFits", saveddata_meta,
|
||||
|
||||
@@ -31,6 +31,8 @@ import eos.db
|
||||
import time
|
||||
import copy
|
||||
from utils.timer import Timer
|
||||
from eos.enum import Enum
|
||||
|
||||
|
||||
import logging
|
||||
|
||||
@@ -41,6 +43,10 @@ try:
|
||||
except ImportError:
|
||||
from utils.compat import OrderedDict
|
||||
|
||||
class ImplantLocation(Enum):
|
||||
FIT = 0
|
||||
CHARACTER = 1
|
||||
|
||||
class Fit(object):
|
||||
"""Represents a fitting, with modules, ship, implants, etc."""
|
||||
|
||||
@@ -318,17 +324,20 @@ class Fit(object):
|
||||
|
||||
return -log(0.25) * agility * mass / 1000000
|
||||
|
||||
@property
|
||||
def implantSource(self):
|
||||
return self.implantLocation
|
||||
|
||||
@implantSource.setter
|
||||
def implantSource(self, source):
|
||||
self.implantLocation = source
|
||||
|
||||
@property
|
||||
def appliedImplants(self):
|
||||
implantsBySlot = {}
|
||||
if self.character:
|
||||
for implant in self.character.implants:
|
||||
implantsBySlot[implant.slot] = implant
|
||||
|
||||
for implant in self.implants:
|
||||
implantsBySlot[implant.slot] = implant
|
||||
|
||||
return implantsBySlot.values()
|
||||
if self.implantLocation == ImplantLocation.CHARACTER:
|
||||
return self.character.implants
|
||||
else:
|
||||
return self.implants
|
||||
|
||||
@validates("ID", "ownerID", "shipID")
|
||||
def validator(self, key, val):
|
||||
|
||||
@@ -32,7 +32,7 @@ from eos.saveddata.implant import Implant
|
||||
from eos.saveddata.booster import SideEffect
|
||||
from eos.saveddata.booster import Booster
|
||||
from eos.saveddata.ship import Ship
|
||||
from eos.saveddata.fit import Fit
|
||||
from eos.saveddata.fit import Fit, ImplantLocation
|
||||
from eos.saveddata.mode import Mode
|
||||
from eos.saveddata.fleet import Fleet, Wing, Squad
|
||||
from eos.saveddata.miscData import MiscData
|
||||
|
||||
@@ -22,7 +22,7 @@ from gui.bitmapLoader import BitmapLoader
|
||||
import gui.mainFrame
|
||||
|
||||
import wx
|
||||
from eos.types import Drone, Module, Rack, Fit
|
||||
from eos.types import Drone, Module, Rack, Fit, Implant
|
||||
from eos.types import State as State_
|
||||
|
||||
class State(ViewColumn):
|
||||
@@ -67,6 +67,9 @@ class State(ViewColumn):
|
||||
if projectionInfo.active:
|
||||
return generic_active
|
||||
return generic_inactive
|
||||
elif isinstance(stuff, Implant) and stuff.character:
|
||||
# if we're showing character implants, show an "online" state, which should not be changed
|
||||
return self.fittingView.imageList.GetImageIndex("state_%s_small" % State_.getName(0).lower(), "gui")
|
||||
else:
|
||||
active = getattr(stuff, "active", None)
|
||||
if active is None:
|
||||
|
||||
@@ -21,10 +21,60 @@ import wx
|
||||
import service
|
||||
import gui.display as d
|
||||
import gui.marketBrowser as mb
|
||||
import gui.mainFrame
|
||||
from gui.builtinViewColumns.state import State
|
||||
from gui.contextMenu import ContextMenu
|
||||
import globalEvents as GE
|
||||
class ImplantView(d.Display):
|
||||
from eos.types import ImplantLocation
|
||||
|
||||
|
||||
class ImplantView(wx.Panel):
|
||||
def __init__(self, parent):
|
||||
wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, style=wx.TAB_TRAVERSAL )
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
radioSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
||||
self.rbFit = wx.RadioButton(self, id=wx.ID_ANY, label="Use Fit-specific Implants", style=wx.RB_GROUP)
|
||||
self.rbChar = wx.RadioButton(self, id=wx.ID_ANY, label="Use Character Implants")
|
||||
radioSizer.Add(self.rbFit, 0, wx.EXPAND, 5)
|
||||
radioSizer.Add(self.rbChar, 0, wx.EXPAND, 5)
|
||||
|
||||
mainSizer.Add(radioSizer)
|
||||
self.implantDisplay = ImplantDisplay(self)
|
||||
mainSizer.Add(self.implantDisplay, 1, wx.EXPAND, 0 )
|
||||
self.SetSizer( mainSizer )
|
||||
self.SetAutoLayout(True)
|
||||
|
||||
self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioSelect, self.rbFit)
|
||||
self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioSelect, self.rbChar)
|
||||
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
|
||||
|
||||
def fitChanged(self, event):
|
||||
sFit = service.Fit.getInstance()
|
||||
activeFitID = self.mainFrame.getActiveFit()
|
||||
fit = sFit.getFit(activeFitID)
|
||||
if fit:
|
||||
if fit.implantSource == ImplantLocation.FIT:
|
||||
self.rbFit.SetValue(True)
|
||||
else:
|
||||
self.rbChar.SetValue(True)
|
||||
|
||||
def OnRadioSelect(self, event):
|
||||
sFit = service.Fit.getInstance()
|
||||
activeFitID = self.mainFrame.getActiveFit()
|
||||
fit = sFit.getFit(activeFitID)
|
||||
if self.rbFit.GetValue():
|
||||
fit.implantSource = ImplantLocation.FIT
|
||||
else:
|
||||
fit.implantSource = ImplantLocation.CHARACTER
|
||||
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=activeFitID))
|
||||
|
||||
|
||||
class ImplantDisplay(d.Display):
|
||||
DEFAULT_COLS = ["State",
|
||||
"attr:implantness",
|
||||
"Base Icon",
|
||||
@@ -79,8 +129,7 @@ class ImplantView(d.Display):
|
||||
|
||||
self.deselectItems()
|
||||
|
||||
self.populate(stuff)
|
||||
self.refresh(stuff)
|
||||
self.update(stuff)
|
||||
event.Skip()
|
||||
|
||||
def addItem(self, event):
|
||||
|
||||
Reference in New Issue
Block a user