diff --git a/eos/db/saveddata/fit.py b/eos/db/saveddata/fit.py index 07375dcaf..0c34d5279 100644 --- a/eos/db/saveddata/fit.py +++ b/eos/db/saveddata/fit.py @@ -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=True), Column("notes", String, nullable=True), Column("ignoreRestrictions", Boolean, default=0), Column("created", DateTime, nullable=True, default=datetime.datetime.now), diff --git a/eos/effects/skillbonusdronedurability.py b/eos/effects/skillbonusdronedurability.py index 1023c8412..f36e82a3f 100644 --- a/eos/effects/skillbonusdronedurability.py +++ b/eos/effects/skillbonusdronedurability.py @@ -6,7 +6,7 @@ type = "passive" def handler(fit, src, context): - lvl = src.level + lvl = src.level if "skill" in context else 1 fit.drones.filteredItemBoost(lambda mod: mod.item.requiresSkill("Drones"), "hp", src.getModifiedItemAttr("hullHpBonus") * lvl) fit.drones.filteredItemBoost(lambda mod: mod.item.requiresSkill("Drones"), "armorHP", diff --git a/eos/effects/skillbonusdroneinterfacing.py b/eos/effects/skillbonusdroneinterfacing.py index 4aec63e83..d832d432b 100644 --- a/eos/effects/skillbonusdroneinterfacing.py +++ b/eos/effects/skillbonusdroneinterfacing.py @@ -6,7 +6,7 @@ type = "passive" def handler(fit, src, context): - lvl = src.level + lvl = src.level if "skill" in context else 1 fit.drones.filteredItemBoost(lambda mod: mod.item.requiresSkill("Drones"), "damageMultiplier", src.getModifiedItemAttr("damageMultiplierBonus") * lvl) fit.fighters.filteredItemBoost(lambda mod: mod.item.requiresSkill("Fighters"), diff --git a/eos/gamedata.py b/eos/gamedata.py index 342a4caf4..243f71bad 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -592,7 +592,7 @@ class Unit(EqBase): lambda d: d * 1000.0, lambda u: u), "Boolean": ( - lambda v, u: "Yes" if v == 1 else "No", + lambda v: "Yes" if v == 1 else "No", lambda d: 1.0 if d == "Yes" else 0.0, lambda u: ""), "typeID": ( diff --git a/gui/builtinPreferenceViews/pyfaGeneralPreferences.py b/gui/builtinPreferenceViews/pyfaGeneralPreferences.py index 412e1a988..6dc9b8ecb 100644 --- a/gui/builtinPreferenceViews/pyfaGeneralPreferences.py +++ b/gui/builtinPreferenceViews/pyfaGeneralPreferences.py @@ -34,6 +34,10 @@ class PFGeneralPref(PreferenceView): self.m_staticline1 = wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) mainSizer.Add(self.m_staticline1, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) + self.cbDefaultCharImplants = wx.CheckBox(panel, wx.ID_ANY, "Have new fits default to character implants", + wx.DefaultPosition, wx.DefaultSize, 0) + mainSizer.Add(self.cbDefaultCharImplants, 0, wx.ALL | wx.EXPAND, 5) + self.cbGlobalChar = wx.CheckBox(panel, wx.ID_ANY, "Use global character", wx.DefaultPosition, wx.DefaultSize, 0) mainSizer.Add(self.cbGlobalChar, 0, wx.ALL | wx.EXPAND, 5) @@ -118,6 +122,7 @@ class PFGeneralPref(PreferenceView): self.sFit = Fit.getInstance() + self.cbDefaultCharImplants.SetValue(self.sFit.serviceFittingOptions["useCharecterImplantsByDefault"]) self.cbGlobalChar.SetValue(self.sFit.serviceFittingOptions["useGlobalCharacter"]) self.cbGlobalDmgPattern.SetValue(self.sFit.serviceFittingOptions["useGlobalDamagePattern"]) self.cbFitColorSlots.SetValue(self.sFit.serviceFittingOptions["colorFitBySlot"] or False) @@ -135,6 +140,7 @@ class PFGeneralPref(PreferenceView): self.cbShowShipBrowserTooltip.SetValue(self.sFit.serviceFittingOptions["showShipBrowserTooltip"]) self.intDelay.SetValue(self.sFit.serviceFittingOptions["marketSearchDelay"]) + self.cbDefaultCharImplants.Bind(wx.EVT_CHECKBOX, self.OnCBDefaultCharImplantsStateChange) self.cbGlobalChar.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalCharStateChange) self.cbGlobalDmgPattern.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalDmgPatternStateChange) self.cbFitColorSlots.Bind(wx.EVT_CHECKBOX, self.onCBGlobalColorBySlot) @@ -183,6 +189,10 @@ class PFGeneralPref(PreferenceView): wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) event.Skip() + def OnCBDefaultCharImplantsStateChange(self, event): + self.sFit.serviceFittingOptions["useCharecterImplantsByDefault"] = self.cbDefaultCharImplants.GetValue() + event.Skip() + def OnCBGlobalCharStateChange(self, event): self.sFit.serviceFittingOptions["useGlobalCharacter"] = self.cbGlobalChar.GetValue() event.Skip() diff --git a/gui/characterSelection.py b/gui/characterSelection.py index 051ce69b4..b6b034a4c 100644 --- a/gui/characterSelection.py +++ b/gui/characterSelection.py @@ -45,8 +45,15 @@ class CharacterSelection(wx.Panel): # cache current selection to fall back in case we choose to open char editor self.charCache = None - self.charChoice = wx.Choice(self) - mainSizer.Add(self.charChoice, 1, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT | wx.LEFT, 3) + #self.charChoice = wx.Choice(self) + #self.charChoice.Append('blarg') + #self.charChoice = wx.Choice(self, wx.ID_ANY, wx.Point(-1,0), wx.DefaultSize, [], style=0, validator=wx.DefaultValidator, name='welp') + self.charChoice = wx.ComboBox( + self, id=wx.ID_ANY, value="", pos=wx.DefaultPosition, + size=wx.DefaultSize, choices=[], style=wx.CB_READONLY, validator=wx.DefaultValidator, + name='welp' + ) + mainSizer.Add(self.charChoice, 1, wx.ALIGN_RIGHT | wx.RIGHT | wx.LEFT, 3) self.refreshCharacterList() @@ -74,7 +81,8 @@ class CharacterSelection(wx.Panel): self.skillReqsStaticBitmap.Bind(wx.EVT_RIGHT_UP, self.OnContextMenu) - self.Bind(wx.EVT_CHOICE, self.charChanged) + #self.Bind(wx.EVT_CHOICE, self.charChanged) + self.Bind(wx.EVT_COMBOBOX, self.charChanged) self.mainFrame.Bind(GE.CHAR_LIST_UPDATED, self.refreshCharacterList) self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged) @@ -120,6 +128,91 @@ class CharacterSelection(wx.Panel): selection = self.charChoice.GetCurrentSelection() return self.charChoice.GetClientData(selection) if selection is not -1 else None + def padChoice(self, ind): + return; + from logbook import Logger + pyfalog = Logger(__name__) + #sChar = Character.getInstance() + #activeChar = self.getActiveCharacter() + #charList = sorted(sChar.getCharacterList(), key=lambda c: (not c.ro, c.name)) + charList = list(self.charChoice.GetItems()) + selection = charList[ind] + maxOverallLength = max(map(lambda c: self.mainFrame.GetTextExtent(c).x, charList)) + maxOverallLength = max(self.mainFrame.GetTextExtent("\u2015 Open Character Editor \u2015").x, maxOverallLength) + summedSizeO = sum([ + self.btnRefresh.GetSize().x if 'btnRefresh' in dir(self) else 0, + self.skillReqsStaticBitmap.GetSize().x if 'skillReqsStaticBitmap' in dir(self) else 0, + self.mainFrame.GetTextExtent("Character: ").x, + self.charChoice.GetSize().x if 'charChoice' in dir(self) \ + and self.charChoice is not None and 'GetSize' in dir(self.charChoice) else 0, + ]) + summedSize = sum([ + self.btnRefresh.GetSize().x if 'btnRefresh' in dir(self) else 0, + self.skillReqsStaticBitmap.GetSize().x if 'skillReqsStaticBitmap' in dir(self) else 0, + self.mainFrame.GetTextExtent("Character: ").x, + self.charCache.GetSize().x if 'charCache' in dir(self) \ + and self.charCache is not None and 'GetSize' in dir(self.charCache) else 0 + ]) + realSize = self.GetSize().x + #sizeGap = summedSize - realSize + sizeGap = self.GetBestVirtualSize().x - realSize + paddedName = selection + + maxFromContent = self.mainFrame.GetTextExtent(paddedName).x + sizeGap + maxLength = min(maxFromContent, maxOverallLength) + paddingOccured = False + while self.mainFrame.GetTextExtent(' ' + paddedName).x <= maxLength: + paddingOccured = True + paddedName = ' ' + paddedName + charIDRef = int(self.charChoice.GetClientData(ind)) + pyfalog.error('wwwww') + pyfalog.error(paddedName) + pyfalog.error(self.mainFrame.GetTextExtent(paddedName).x) + pyfalog.error(maxFromContent) + pyfalog.error(maxOverallLength) + pyfalog.error('\n') + pyfalog.error(self.charChoice.GetContainingSizer().GetSize().x) + pyfalog.error(realSize) + pyfalog.error(self.GetBestSize().x) + pyfalog.error(self.GetBestVirtualSize().x) + pyfalog.error('\n') + pyfalog.error(summedSizeO) + pyfalog.error(summedSize) + pyfalog.error( + self.charChoice.GetSize().x if 'charChoice' in dir(self) \ + and self.charChoice is not None and 'GetSize' in dir(self.charChoice) else 0 + ) + pyfalog.error( + self.charCache.GetSize().x if 'charCache' in dir(self) \ + and self.charCache is not None and 'GetSize' in dir(self.charCache) else 0 + ) + pyfalog.error(charIDRef) + pyfalog.error(ind) + pyfalog.error(list(self.charChoice.GetItems())) + ### + import re + for i in range(len(self.charChoice.GetItems())): + origStr = list(self.charChoice.GetItems())[i] + idStore = int(self.charChoice.GetClientData(i)) + self.charChoice.Delete(i) + trimmedStr = '' + for n in range(len(origStr)): + if trimmedStr is not '' or origStr[n] != ' ': + trimmedStr += origStr[n] + possibleName = trimmedStr#re.split(" *", origStr) + pyfalog.error('uuu') + pyfalog.error(possibleName) + self.charChoice.Insert(possibleName, i, idStore) + + if paddingOccured: + self.charChoice.Delete(ind) + pyfalog.error(list(self.charChoice.GetItems())) + self.charChoice.Insert(paddedName, ind, charIDRef) + self.charChoice.Select(ind) + pyfalog.error(list(self.charChoice.GetItems())) + pyfalog.error(int(self.charChoice.GetClientData(ind))) + pyfalog.error('wwwww') + def refreshCharacterList(self, event=None): choice = self.charChoice sChar = Character.getInstance() @@ -128,10 +221,30 @@ class CharacterSelection(wx.Panel): choice.Clear() charList = sorted(sChar.getCharacterList(), key=lambda c: (not c.ro, c.name)) picked = False - + from logbook import Logger + pyfalog = Logger(__name__) + maxOverallLength = max(map(lambda c: self.mainFrame.GetTextExtent(c.name).x, charList)) + maxOverallLength = max(self.mainFrame.GetTextExtent("\u2015 Open Character Editor \u2015").x, maxOverallLength) + #summedSize = sum([ + # self.btnRefresh.GetSize().x if 'btnRefresh' in dir(self) else 0, + # self.skillReqsStaticBitmap.GetSize().x if 'skillReqsStaticBitmap' in dir(self) else 0, + # self.mainFrame.GetTextExtent("Character: ").x, + # self.charCache.GetSize().x if 'charCache' in dir(self) and self.charCache is not None else 0, + # ]) + #realSize = self.GetSize().x + #sizeGap = summedSize - realSize for char in charList: - currId = choice.Append(char.name, char.ID) + paddedName = char.name + #maxFromContent = self.mainFrame.GetTextExtent(paddedName).x + self.mainFrame.GetTextExtent("Character: ").x + #maxFromContent = self.mainFrame.GetTextExtent(paddedName).x + sizeGap + #maxLength = min(maxFromContent, maxOverallLength) + #while self.mainFrame.GetTextExtent(paddedName).x < maxLength: + # paddedName = ' ' + paddedName + #currId = choice.Append(str(maxFromContent) + ' ' + \ + # str(self.mainFrame.GetTextExtent(paddedName).x) + ' ' + str(maxLength), char.ID) + currId = choice.Append(paddedName, char.ID) if char.ID == activeChar: + self.padChoice(currId) choice.SetSelection(currId) self.charChanged(None) picked = True @@ -173,16 +286,27 @@ class CharacterSelection(wx.Panel): if charID == -1: # revert to previous character + self.padChoice(self.charCache) + pyfalog.error('GGG') self.charChoice.SetSelection(self.charCache) + pyfalog.error('GGG') self.mainFrame.showCharacterEditor(event) + pyfalog.error('GGG') return - + self.padChoice(self.charChoice.GetCurrentSelection()) + fitID = self.mainFrame.getActiveFit() + charID = self.getActiveCharacter() + pyfalog.error(self.getActiveCharacter()) self.toggleRefreshButton() + pyfalog.error('RRR') sFit = Fit.getInstance() sFit.changeChar(fitID, charID) self.charCache = self.charChoice.GetCurrentSelection() + pyfalog.error('RRR') + pyfalog.error(fitID) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) + pyfalog.error('RRR') def toggleRefreshButton(self): charID = self.getActiveCharacter() @@ -199,6 +323,8 @@ class CharacterSelection(wx.Panel): for i in range(numItems): id_ = choice.GetClientData(i) if id_ == charID: + print((list(choice.GetItems())[0])) + self.padChoice(i) choice.SetSelection(i) return True diff --git a/gui/itemStats.py b/gui/itemStats.py index 6a75b543d..3768780e2 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -102,7 +102,7 @@ class ItemStatsDialog(wx.Dialog): if "wxGTK" in wx.PlatformInfo: self.closeBtn = wx.Button(self, wx.ID_ANY, "Close", wx.DefaultPosition, wx.DefaultSize, 0) self.mainSizer.Add(self.closeBtn, 0, wx.ALL | wx.ALIGN_RIGHT, 5) - self.closeBtn.Bind(wx.EVT_BUTTON, self.closeEvent) + self.closeBtn.Bind(wx.EVT_BUTTON, (lambda e: self.Close())) self.SetSizer(self.mainSizer) diff --git a/service/fit.py b/service/fit.py index dccb58e5e..4772f87af 100644 --- a/service/fit.py +++ b/service/fit.py @@ -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 @@ -60,6 +60,7 @@ class Fit(object): self.dirtyFitIDs = set() serviceFittingDefaultOptions = { + "useCharecterImplantsByDefault": True, "useGlobalCharacter": False, "useGlobalDamagePattern": False, "defaultCharacter": self.character.ID, @@ -147,6 +148,9 @@ class Fit(object): fit.targetResists = self.targetResists fit.character = self.character fit.booster = self.booster + fit.implantLocation = ImplantLocation.CHARACTER if\ + self.serviceFittingOptions["useCharecterImplantsByDefault"] else\ + ImplantLocation.FIT eos.db.save(fit) self.recalc(fit) return fit.ID