Implement selectable booster side effects and persist them to the database, very much based on the fighter ability code. Still need to name them and enable the effects.

This also removes the old boosterActiveSideEffect table definition (migration script to drop table still needs to be written)
This commit is contained in:
blitzmann
2017-06-04 23:31:52 -04:00
parent cf02c74272
commit c2cb5d763f
10 changed files with 215 additions and 73 deletions

View File

@@ -49,6 +49,7 @@ class BoosterView(d.Display):
"State",
"attr:boosterness",
"Base Name",
"Side Effects",
"Price",
]

View File

@@ -0,0 +1,64 @@
# noinspection PyPackageRequirements
import wx
from gui.contextMenu import ContextMenu
import gui.mainFrame
import gui.globalEvents as GE
from service.fit import Fit
from service.settings import ContextMenuSettings
class BoosterSideEffect(ContextMenu):
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.settings = ContextMenuSettings.getInstance()
def display(self, srcContext, selection):
# if not self.settings.get('fighterAbilities'):
# return False
if self.mainFrame.getActiveFit() is None or srcContext not in ("boosterItem"):
return False
self.booster = selection[0]
return True
def getText(self, itmContext, selection):
return "Side Effects"
def addEffect(self, menu, ability):
label = ability.name
id = ContextMenu.nextID()
self.effectIds[id] = ability
menuItem = wx.MenuItem(menu, id, label, kind=wx.ITEM_CHECK)
menu.Bind(wx.EVT_MENU, self.handleMode, menuItem)
return menuItem
def getSubMenu(self, context, selection, rootMenu, i, pitem):
msw = True if "wxMSW" in wx.PlatformInfo else False
self.context = context
self.effectIds = {}
sub = wx.Menu()
for effect in self.booster.sideEffects:
if not effect.effect.isImplemented:
continue
menuItem = self.addEffect(rootMenu if msw else sub, effect)
sub.AppendItem(menuItem)
menuItem.Check(effect.active)
return sub
def handleMode(self, event):
effect = self.effectIds[event.Id]
if effect is False or effect not in self.booster.sideEffects:
event.Skip()
return
sFit = Fit.getInstance()
fitID = self.mainFrame.getActiveFit()
sFit.toggleBoosterSideEffect(fitID, effect)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
BoosterSideEffect.register()

View File

@@ -1,2 +1,2 @@
__all__ = ["ammo", "ammoIcon", "attributeDisplay", "baseIcon", "baseName",
"capacitorUse", "maxRange", "price", "propertyDisplay", "state", "misc", "abilities"]
"capacitorUse", "maxRange", "price", "propertyDisplay", "state", "misc", "abilities", "sideEffects"]

View File

@@ -0,0 +1,46 @@
# =============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
#
# pyfa is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyfa is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
# =============================================================================
# noinspection PyPackageRequirements
import wx
from eos.saveddata.booster import Booster
from gui.viewColumn import ViewColumn
import gui.mainFrame
class SideEffects(ViewColumn):
name = "Side Effects"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.columnText = "Active Side Effects"
self.mask = wx.LIST_MASK_TEXT
def getText(self, stuff):
if isinstance(stuff, Booster):
active = [x.name for x in stuff.sideEffects if x.active]
if len(active) == 0:
return "None"
return ", ".join(active)
SideEffects.register()

View File

@@ -206,6 +206,7 @@ from gui.builtinContextMenus import ( # noqa: E402,F401
metaSwap,
implantSets,
fighterAbilities,
boosterSideEffects,
commandFits,
tabbedFits
)

View File

@@ -79,5 +79,6 @@ from gui.builtinViewColumns import ( # noqa: E402, F401
misc,
price,
propertyDisplay,
state
state,
sideEffects
)