Merge branch 'development' into PreferencesPaneV2
This commit is contained in:
@@ -22,4 +22,6 @@ __all__ = [
|
||||
"metaSwap",
|
||||
"implantSets",
|
||||
"fighterAbilities",
|
||||
"cargoAmmo",
|
||||
"droneStack"
|
||||
]
|
||||
|
||||
35
gui/builtinContextMenus/cargoAmmo.py
Normal file
35
gui/builtinContextMenus/cargoAmmo.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
import service
|
||||
import gui.globalEvents as GE
|
||||
import wx
|
||||
|
||||
|
||||
class CargoAmmo(ContextMenu):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None:
|
||||
return False
|
||||
|
||||
for selected_item in selection:
|
||||
if selected_item.category.ID in (
|
||||
8, # Charge
|
||||
):
|
||||
return True
|
||||
|
||||
def getText(self, itmContext, selection):
|
||||
return "Add {0} to Cargo (x1000)".format(itmContext)
|
||||
|
||||
def activate(self, fullContext, selection, i):
|
||||
sFit = service.Fit.getInstance()
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
|
||||
typeID = int(selection[0].ID)
|
||||
sFit.addCargo(fitID, typeID, 1000)
|
||||
self.mainFrame.additionsPane.select("Cargo")
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
|
||||
|
||||
CargoAmmo.register()
|
||||
37
gui/builtinContextMenus/droneStack.py
Normal file
37
gui/builtinContextMenus/droneStack.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from gui.contextMenu import ContextMenu
|
||||
import gui.mainFrame
|
||||
import service
|
||||
import gui.globalEvents as GE
|
||||
import wx
|
||||
|
||||
|
||||
class CargoAmmo(ContextMenu):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, selection):
|
||||
if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None:
|
||||
return False
|
||||
|
||||
for selected_item in selection:
|
||||
if selected_item.category.ID in (
|
||||
18, # Drones
|
||||
):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def getText(self, itmContext, selection):
|
||||
return "Add {0} to Drone Bay (x5)".format(itmContext)
|
||||
|
||||
def activate(self, fullContext, selection, i):
|
||||
sFit = service.Fit.getInstance()
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
|
||||
typeID = int(selection[0].ID)
|
||||
sFit.addDrone(fitID, typeID, 5)
|
||||
self.mainFrame.additionsPane.select("Drones")
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
|
||||
|
||||
CargoAmmo.register()
|
||||
@@ -9,6 +9,11 @@ import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
from gui.contextMenu import ContextMenu
|
||||
from service.settings import ContextMenuSettings
|
||||
from eos.saveddata.booster import Booster
|
||||
from eos.saveddata.module import Module
|
||||
from eos.saveddata.drone import Drone
|
||||
from eos.saveddata.fighter import Fighter
|
||||
from eos.saveddata.implant import Implant
|
||||
|
||||
|
||||
class MetaSwap(ContextMenu):
|
||||
@@ -20,7 +25,13 @@ class MetaSwap(ContextMenu):
|
||||
if not self.settings.get('metaSwap'):
|
||||
return False
|
||||
|
||||
if self.mainFrame.getActiveFit() is None or srcContext not in ("fittingModule",):
|
||||
if self.mainFrame.getActiveFit() is None or srcContext not in (
|
||||
"fittingModule",
|
||||
"droneItem",
|
||||
"fighterItem",
|
||||
"boosterItem",
|
||||
"implantItem",
|
||||
):
|
||||
return False
|
||||
|
||||
# Check if list of variations is same for all of selection
|
||||
@@ -56,6 +67,17 @@ class MetaSwap(ContextMenu):
|
||||
def get_metagroup(x):
|
||||
return x.metaGroup.ID if x.metaGroup is not None else 0
|
||||
|
||||
def get_boosterrank(x):
|
||||
# If we're returning a lot of items, sort my name
|
||||
if len(self.variations) > 7:
|
||||
return x.name
|
||||
# Sort by booster chance to get some sort of pseudorank.
|
||||
elif 'boosterEffectChance1' in x.attributes:
|
||||
return x.attributes['boosterEffectChance1'].value
|
||||
# the "first" rank (Synth) doesn't have boosterEffectChance1. If we're not pulling back all boosters, return 0 for proper sorting
|
||||
else:
|
||||
return 0
|
||||
|
||||
m = wx.Menu()
|
||||
|
||||
# If on Windows we need to bind out events into the root menu, on other
|
||||
@@ -67,8 +89,17 @@ class MetaSwap(ContextMenu):
|
||||
|
||||
# Sort items by metalevel, and group within that metalevel
|
||||
items = list(self.variations)
|
||||
items.sort(key=get_metalevel)
|
||||
items.sort(key=get_metagroup)
|
||||
print context
|
||||
if "implantItem" in context:
|
||||
# sort implants based on name
|
||||
items.sort(key=lambda x: x.name)
|
||||
elif "boosterItem" in context:
|
||||
# boosters don't have meta or anything concrete that we can rank by. Go by chance to inflict side effect
|
||||
items.sort(key=get_boosterrank)
|
||||
else:
|
||||
# sort by group and meta level
|
||||
items.sort(key=get_metalevel)
|
||||
items.sort(key=get_metagroup)
|
||||
|
||||
group = None
|
||||
for item in items:
|
||||
@@ -78,7 +109,7 @@ class MetaSwap(ContextMenu):
|
||||
else:
|
||||
thisgroup = item.metaGroup.name
|
||||
|
||||
if thisgroup != group:
|
||||
if thisgroup != group and context not in ("implantItem", "boosterItem"):
|
||||
group = thisgroup
|
||||
id = ContextMenu.nextID()
|
||||
m.Append(id, u'─ %s ─' % group)
|
||||
@@ -101,9 +132,56 @@ class MetaSwap(ContextMenu):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
fit = sFit.getFit(fitID)
|
||||
|
||||
for mod in self.selection:
|
||||
pos = fit.modules.index(mod)
|
||||
sFit.changeModule(fitID, pos, item.ID)
|
||||
for selected_item in self.selection:
|
||||
if isinstance(selected_item, Module):
|
||||
pos = fit.modules.index(selected_item)
|
||||
sFit.changeModule(fitID, pos, item.ID)
|
||||
|
||||
elif isinstance(selected_item, Drone):
|
||||
drone_count = None
|
||||
|
||||
for idx, drone_stack in enumerate(fit.drones):
|
||||
if drone_stack is selected_item:
|
||||
drone_count = drone_stack.amount
|
||||
sFit.removeDrone(fitID, idx, drone_count)
|
||||
break
|
||||
|
||||
if drone_count:
|
||||
sFit.addDrone(fitID, item.ID, drone_count)
|
||||
|
||||
elif isinstance(selected_item, Fighter):
|
||||
fighter_count = None
|
||||
|
||||
for idx, fighter_stack in enumerate(fit.fighters):
|
||||
# Right now fighters always will have max stack size.
|
||||
# Including this for future improvement, so if adjustable
|
||||
# fighter stacks get added we're ready for it.
|
||||
if fighter_stack is selected_item:
|
||||
if fighter_stack.amount > 0:
|
||||
fighter_count = fighter_stack.amount
|
||||
elif fighter_stack.amount == -1:
|
||||
fighter_count = fighter_stack.amountActive
|
||||
else:
|
||||
fighter_count.amount = 0
|
||||
|
||||
sFit.removeFighter(fitID, idx)
|
||||
break
|
||||
|
||||
sFit.addFighter(fitID, item.ID)
|
||||
|
||||
elif isinstance(selected_item, Booster):
|
||||
for idx, booster_stack in enumerate(fit.boosters):
|
||||
if booster_stack is selected_item:
|
||||
sFit.removeBooster(fitID, idx)
|
||||
sFit.addBooster(fitID, item.ID)
|
||||
break
|
||||
|
||||
elif isinstance(selected_item, Implant):
|
||||
for idx, implant_stack in enumerate(fit.implants):
|
||||
if implant_stack is selected_item:
|
||||
sFit.removeImplant(fitID, idx)
|
||||
sFit.addImplant(fitID, item.ID, False)
|
||||
break
|
||||
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ __all__ = [
|
||||
"rechargeViewFull",
|
||||
"firepowerViewFull",
|
||||
"capacitorViewFull",
|
||||
"outgoingViewFull",
|
||||
"targetingMiscViewMinimal",
|
||||
"priceViewFull",
|
||||
]
|
||||
|
||||
106
gui/builtinStatsViews/outgoingViewFull.py
Normal file
106
gui/builtinStatsViews/outgoingViewFull.py
Normal file
@@ -0,0 +1,106 @@
|
||||
# ===============================================================================
|
||||
# Copyright (C) 2014 Alexandros Kosiaris
|
||||
#
|
||||
# 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 gui.statsView import StatsView
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
from gui.utils.numberFormatter import formatAmount
|
||||
|
||||
|
||||
class OutgoingViewFull(StatsView):
|
||||
name = "outgoingViewFull"
|
||||
|
||||
def __init__(self, parent):
|
||||
StatsView.__init__(self)
|
||||
self.parent = parent
|
||||
self._cachedValues = []
|
||||
|
||||
def getHeaderText(self, fit):
|
||||
return "Remote Reps"
|
||||
|
||||
def getTextExtentW(self, text):
|
||||
width, height = self.parent.GetTextExtent(text)
|
||||
return width
|
||||
|
||||
def populatePanel(self, contentPanel, headerPanel):
|
||||
contentSizer = contentPanel.GetSizer()
|
||||
parent = self.panel = contentPanel
|
||||
self.headerPanel = headerPanel
|
||||
|
||||
sizerOutgoing = wx.GridSizer(1, 4)
|
||||
|
||||
contentSizer.Add(sizerOutgoing, 0, wx.EXPAND, 0)
|
||||
|
||||
counter = 0
|
||||
|
||||
rr_list = [
|
||||
("RemoteCapacitor", "Capacitor:", "capacitorInfo", "Capacitor GJ/s per second transferred remotely."),
|
||||
("RemoteShield", "Shield:", "shieldActive", "Shield hitpoints per second repaired remotely."),
|
||||
("RemoteArmor", "Armor:", "armorActive", "Armor hitpoints per second repaired remotely."),
|
||||
("RemoteHull", "Hull:", "hullActive", "Hull hitpoints per second repaired remotely."),
|
||||
]
|
||||
|
||||
for outgoingType, label, image, tooltip in rr_list:
|
||||
baseBox = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
baseBox.Add(BitmapLoader.getStaticBitmap("%s_big" % image, parent, "gui"), 0, wx.ALIGN_CENTER)
|
||||
|
||||
if "Capacitor" in outgoingType:
|
||||
lbl = wx.StaticText(parent, wx.ID_ANY, u"0 GJ/s")
|
||||
else:
|
||||
lbl = wx.StaticText(parent, wx.ID_ANY, u"0 HP/s")
|
||||
|
||||
lbl.SetToolTip(wx.ToolTip(tooltip))
|
||||
|
||||
setattr(self, "label%s" % outgoingType, lbl)
|
||||
|
||||
baseBox.Add(lbl, 0, wx.ALIGN_CENTER)
|
||||
self._cachedValues.append(0)
|
||||
counter += 1
|
||||
|
||||
sizerOutgoing.Add(baseBox, 1, wx.ALIGN_LEFT)
|
||||
|
||||
def refreshPanel(self, fit):
|
||||
# If we did anything intresting, we'd update our labels to reflect the new fit's stats here
|
||||
|
||||
stats = [
|
||||
("labelRemoteArmor", lambda: fit.remoteReps["Armor"], 3, 0, 0, u"%s HP/s", None),
|
||||
("labelRemoteShield", lambda: fit.remoteReps["Shield"], 3, 0, 0, u"%s HP/s", None),
|
||||
("labelRemoteHull", lambda: fit.remoteReps["Hull"], 3, 0, 0, u"%s HP/s", None),
|
||||
("labelRemoteCapacitor", lambda: fit.remoteReps["Capacitor"], 3, 0, 0, u"%s GJ/s", None),
|
||||
]
|
||||
|
||||
counter = 0
|
||||
for labelName, value, prec, lowest, highest, valueFormat, altFormat in stats:
|
||||
label = getattr(self, labelName)
|
||||
value = value() if fit is not None else 0
|
||||
value = value if value is not None else 0
|
||||
if self._cachedValues[counter] != value:
|
||||
valueStr = formatAmount(value, prec, lowest, highest)
|
||||
label.SetLabel(valueFormat % valueStr)
|
||||
tipStr = valueFormat % valueStr if altFormat is None else altFormat % value
|
||||
label.SetToolTip(wx.ToolTip(tipStr))
|
||||
self._cachedValues[counter] = value
|
||||
counter += 1
|
||||
self.panel.Layout()
|
||||
self.headerPanel.Layout()
|
||||
|
||||
|
||||
OutgoingViewFull.register()
|
||||
106
gui/builtinStatsViews/outgoingViewMinimal.py
Normal file
106
gui/builtinStatsViews/outgoingViewMinimal.py
Normal file
@@ -0,0 +1,106 @@
|
||||
# ===============================================================================
|
||||
# Copyright (C) 2014 Alexandros Kosiaris
|
||||
#
|
||||
# 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 gui.statsView import StatsView
|
||||
from gui.bitmapLoader import BitmapLoader
|
||||
from gui.utils.numberFormatter import formatAmount
|
||||
|
||||
|
||||
class OutgoingViewFull(StatsView):
|
||||
name = "outgoingViewFull"
|
||||
|
||||
def __init__(self, parent):
|
||||
StatsView.__init__(self)
|
||||
self.parent = parent
|
||||
self._cachedValues = []
|
||||
|
||||
def getHeaderText(self, fit):
|
||||
return "Remote Reps"
|
||||
|
||||
def getTextExtentW(self, text):
|
||||
width, height = self.parent.GetTextExtent(text)
|
||||
return width
|
||||
|
||||
def populatePanel(self, contentPanel, headerPanel):
|
||||
contentSizer = contentPanel.GetSizer()
|
||||
parent = self.panel = contentPanel
|
||||
self.headerPanel = headerPanel
|
||||
|
||||
sizerOutgoing = wx.GridSizer(1, 4)
|
||||
|
||||
contentSizer.Add(sizerOutgoing, 0, wx.EXPAND, 0)
|
||||
|
||||
counter = 0
|
||||
|
||||
rr_list = [
|
||||
("RemoteCapacitor", "Capacitor:", "capacitorInfo", "Capacitor GJ/s per second transferred remotely."),
|
||||
("RemoteShield", "Shield:", "shieldActive", "Shield hitpoints per second repaired remotely."),
|
||||
("RemoteArmor", "Armor:", "armorActive", "Armor hitpoints per second repaired remotely."),
|
||||
("RemoteHull", "Hull:", "hullActive", "Hull hitpoints per second repaired remotely."),
|
||||
]
|
||||
|
||||
for outgoingType, label, image, tooltip in rr_list:
|
||||
baseBox = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
baseBox.Add(BitmapLoader.getStaticBitmap("%s_big" % image, parent, "gui"), 0, wx.ALIGN_CENTER)
|
||||
|
||||
if "Capacitor" in outgoingType:
|
||||
lbl = wx.StaticText(parent, wx.ID_ANY, u"0 GJ/s")
|
||||
else:
|
||||
lbl = wx.StaticText(parent, wx.ID_ANY, u"0 HP/s")
|
||||
|
||||
lbl.SetToolTip(wx.ToolTip(tooltip))
|
||||
|
||||
setattr(self, "label%s" % outgoingType, lbl)
|
||||
|
||||
baseBox.Add(lbl, 0, wx.ALIGN_CENTER)
|
||||
self._cachedValues.append(0)
|
||||
counter += 1
|
||||
|
||||
sizerOutgoing.Add(baseBox, 1, wx.ALIGN_LEFT)
|
||||
|
||||
def refreshPanel(self, fit):
|
||||
# If we did anything intresting, we'd update our labels to reflect the new fit's stats here
|
||||
|
||||
stats = [
|
||||
("labelRemoteArmor", lambda: fit.remoteReps["Armor"], 3, 0, 0, u"%s HP/s", None),
|
||||
("labelRemoteShield", lambda: fit.remoteReps["Shield"], 3, 0, 0, u"%s HP/s", None),
|
||||
("labelRemoteHull", lambda: fit.remoteReps["Hull"], 3, 0, 0, u"%s HP/s", None),
|
||||
("labelRemoteCapacitor", lambda: fit.remoteReps["Capacitor"], 3, 0, 0, u"%s GJ/s", None),
|
||||
]
|
||||
|
||||
counter = 0
|
||||
for labelName, value, prec, lowest, highest, valueFormat, altFormat in stats:
|
||||
label = getattr(self, labelName)
|
||||
value = value() if fit is not None else 0
|
||||
value = value if value is not None else 0
|
||||
if self._cachedValues[counter] != value:
|
||||
valueStr = formatAmount(value, prec, lowest, highest)
|
||||
label.SetLabel(valueFormat % valueStr)
|
||||
tipStr = valueFormat % valueStr if altFormat is None else altFormat % value
|
||||
label.SetToolTip(wx.ToolTip(tipStr))
|
||||
self._cachedValues[counter] = value
|
||||
counter += 1
|
||||
self.panel.Layout()
|
||||
self.headerPanel.Layout()
|
||||
|
||||
|
||||
OutgoingViewFull.register()
|
||||
@@ -40,6 +40,7 @@ class StatsPane(wx.Panel):
|
||||
"resistances",
|
||||
"recharge",
|
||||
"firepower",
|
||||
"outgoingView",
|
||||
"capacitor",
|
||||
"targetingMisc",
|
||||
"price",
|
||||
|
||||
@@ -52,4 +52,5 @@ from gui.builtinStatsViews import ( # noqa: E402, F401
|
||||
rechargeViewFull,
|
||||
targetingMiscViewMinimal,
|
||||
priceViewFull,
|
||||
outgoingViewFull,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user