Add ability to use character implants by default

This commit is contained in:
Maru Maru
2018-07-11 05:35:19 -04:00
parent 89efa9cbf9
commit 1699b8ceee
4 changed files with 20 additions and 2 deletions

View File

@@ -56,7 +56,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),
Column("implantLocation", Integer, nullable=False),
Column("notes", String, nullable=True),
Column("ignoreRestrictions", Boolean, default=0),
Column("created", DateTime, nullable=True, default=datetime.datetime.now),

View File

@@ -1580,6 +1580,7 @@ class Fit(object):
copy_ship.name = "%s copy" % self.name
copy_ship.damagePattern = self.damagePattern
copy_ship.targetResists = self.targetResists
copy_ship.implantLocation = self.implantLocation
copy_ship.notes = self.notes
toCopy = (

View File

@@ -38,6 +38,10 @@ class PFGeneralPref(PreferenceView):
0)
mainSizer.Add(self.cbGlobalChar, 0, wx.ALL | wx.EXPAND, 5)
self.cbDefaultCharImplants = wx.CheckBox(panel, wx.ID_ANY, "Use character implants by default for new fits",
wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbDefaultCharImplants, 0, wx.ALL | wx.EXPAND, 5)
self.cbGlobalDmgPattern = wx.CheckBox(panel, wx.ID_ANY, "Use global damage pattern", wx.DefaultPosition,
wx.DefaultSize, 0)
mainSizer.Add(self.cbGlobalDmgPattern, 0, wx.ALL | wx.EXPAND, 5)
@@ -119,6 +123,7 @@ class PFGeneralPref(PreferenceView):
self.sFit = Fit.getInstance()
self.cbGlobalChar.SetValue(self.sFit.serviceFittingOptions["useGlobalCharacter"])
self.cbDefaultCharImplants.SetValue(self.sFit.serviceFittingOptions["useCharacterImplantsByDefault"])
self.cbGlobalDmgPattern.SetValue(self.sFit.serviceFittingOptions["useGlobalDamagePattern"])
self.cbFitColorSlots.SetValue(self.sFit.serviceFittingOptions["colorFitBySlot"] or False)
self.cbRackSlots.SetValue(self.sFit.serviceFittingOptions["rackSlots"] or False)
@@ -136,6 +141,7 @@ class PFGeneralPref(PreferenceView):
self.intDelay.SetValue(self.sFit.serviceFittingOptions["marketSearchDelay"])
self.cbGlobalChar.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalCharStateChange)
self.cbDefaultCharImplants.Bind(wx.EVT_CHECKBOX, self.OnCBDefaultCharImplantsStateChange)
self.cbGlobalDmgPattern.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalDmgPatternStateChange)
self.cbFitColorSlots.Bind(wx.EVT_CHECKBOX, self.onCBGlobalColorBySlot)
self.cbRackSlots.Bind(wx.EVT_CHECKBOX, self.onCBGlobalRackSlots)
@@ -187,6 +193,10 @@ class PFGeneralPref(PreferenceView):
self.sFit.serviceFittingOptions["useGlobalCharacter"] = self.cbGlobalChar.GetValue()
event.Skip()
def OnCBDefaultCharImplantsStateChange(self, event):
self.sFit.serviceFittingOptions["useCharacterImplantsByDefault"] = self.cbDefaultCharImplants.GetValue()
event.Skip()
def OnCBGlobalDmgPatternStateChange(self, event):
self.sFit.serviceFittingOptions["useGlobalDamagePattern"] = self.cbGlobalDmgPattern.GetValue()
event.Skip()

View File

@@ -33,7 +33,7 @@ from eos.saveddata.fighter import Fighter as es_Fighter
from eos.saveddata.implant import Implant as es_Implant
from eos.saveddata.ship import Ship as es_Ship
from eos.saveddata.module import Module as es_Module, State, Slot
from eos.saveddata.fit import Fit as FitType
from eos.saveddata.fit import Fit as FitType, ImplantLocation
from service.character import Character
from service.damagePattern import DamagePattern
from service.settings import SettingsProvider
@@ -61,6 +61,7 @@ class Fit(object):
serviceFittingDefaultOptions = {
"useGlobalCharacter": False,
"useCharacterImplantsByDefault": True,
"useGlobalDamagePattern": False,
"defaultCharacter": self.character.ID,
"useGlobalForceReload": False,
@@ -147,6 +148,8 @@ class Fit(object):
fit.targetResists = self.targetResists
fit.character = self.character
fit.booster = self.booster
useCharImplants = self.serviceFittingOptions["useCharacterImplantsByDefault"]
fit.implantLocation = ImplantLocation.CHARACTER if useCharImplants else ImplantLocation.FIT
eos.db.save(fit)
self.recalc(fit)
return fit.ID
@@ -198,7 +201,11 @@ class Fit(object):
def copyFit(fitID):
pyfalog.debug("Creating copy of fit ID: {0}", fitID)
fit = eos.db.getFit(fitID)
pyfalog.error(fit.name)
pyfalog.error(fit.implantLocation)
newFit = copy.deepcopy(fit)
pyfalog.error(newFit.name)
pyfalog.error(newFit.implantLocation)
eos.db.save(newFit)
return newFit.ID