Merge branch 'feature/booster-side-effects' into development
This commit is contained in:
@@ -49,6 +49,7 @@ class BoosterView(d.Display):
|
||||
"State",
|
||||
"attr:boosterness",
|
||||
"Base Name",
|
||||
"Side Effects",
|
||||
"Price",
|
||||
]
|
||||
|
||||
|
||||
64
gui/builtinContextMenus/boosterSideEffects.py
Normal file
64
gui/builtinContextMenus/boosterSideEffects.py
Normal 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()
|
||||
@@ -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"]
|
||||
|
||||
46
gui/builtinViewColumns/sideEffects.py
Normal file
46
gui/builtinViewColumns/sideEffects.py
Normal 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()
|
||||
@@ -206,6 +206,7 @@ from gui.builtinContextMenus import ( # noqa: E402,F401
|
||||
metaSwap,
|
||||
implantSets,
|
||||
fighterAbilities,
|
||||
boosterSideEffects,
|
||||
commandFits,
|
||||
tabbedFits
|
||||
)
|
||||
|
||||
@@ -79,5 +79,6 @@ from gui.builtinViewColumns import ( # noqa: E402, F401
|
||||
misc,
|
||||
price,
|
||||
propertyDisplay,
|
||||
state
|
||||
state,
|
||||
sideEffects
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user