Merge branch 'development' into ErrorDialog_and_miscfixes

This commit is contained in:
Ebag333
2017-03-27 21:00:51 -07:00
committed by GitHub
19 changed files with 230 additions and 65 deletions

View File

@@ -0,0 +1,96 @@
# noinspection PyPackageRequirements
import wx
from service.fit import Fit
from service.market import Market
import gui.mainFrame
import gui.globalEvents as GE
from gui.contextMenu import ContextMenu
from service.settings import ContextMenuSettings
class CommandFits(ContextMenu):
# Get list of items that define a command fit
sMkt = Market.getInstance()
grp = sMkt.getGroup(1770) # Command burst group
commandTypeIDs = [item.ID for item in grp.items]
commandFits = []
menu = None
@classmethod
def populateFits(cls, evt):
if evt is None or (getattr(evt, 'action', None) in ("modadd", "moddel") and getattr(evt, 'typeID', None) in cls.commandTypeIDs):
# we are adding or removing an item that defines a command fit. Need to refresh fit list
sFit = Fit.getInstance()
cls.commandFits = sFit.getFitsWithModules(cls.commandTypeIDs)
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.settings = ContextMenuSettings.getInstance()
def display(self, srcContext, selection):
if self.mainFrame.getActiveFit() is None or len(self.__class__.commandFits) == 0 or srcContext != "commandView":
return False
return True
def getText(self, itmContext, selection):
return "Command Fits"
def addFit(self, menu, fit, includeShip=False):
label = fit.name if not includeShip else "({}) {}".format(fit.ship.item.name, fit.name)
id = ContextMenu.nextID()
self.fitMenuItemIds[id] = fit
menuItem = wx.MenuItem(menu, id, label)
menu.Bind(wx.EVT_MENU, self.handleSelection, menuItem)
return menuItem
def getSubMenu(self, context, selection, rootMenu, i, pitem):
msw = True if "wxMSW" in wx.PlatformInfo else False
self.context = context
self.fitMenuItemIds = {}
sub = wx.Menu()
if len(self.__class__.commandFits) < 15:
for fit in sorted(self.__class__.commandFits, key=lambda x: x.name):
print fit
menuItem = self.addFit(rootMenu if msw else sub, fit, True)
sub.AppendItem(menuItem)
else:
typeDict = {}
for fit in self.__class__.commandFits:
shipName = fit.ship.item.name
if shipName not in typeDict:
typeDict[shipName] = []
typeDict[shipName].append(fit)
for ship in sorted(typeDict.keys()):
shipItem = wx.MenuItem(sub, ContextMenu.nextID(), ship)
grandSub = wx.Menu()
shipItem.SetSubMenu(grandSub)
for fit in sorted(typeDict[ship], key=lambda x: x.name):
fitItem = self.addFit(rootMenu if msw else grandSub, fit, False)
grandSub.AppendItem(fitItem)
sub.AppendItem(shipItem)
return sub
def handleSelection(self, event):
fit = self.fitMenuItemIds[event.Id]
if fit is False or fit not in self.__class__.commandFits:
event.Skip()
return
sFit = Fit.getInstance()
fitID = self.mainFrame.getActiveFit()
sFit.addCommandFit(fitID, fit)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
CommandFits.populateFits(None)
CommandFits.register()

View File

@@ -14,7 +14,6 @@ class PFGeneralPref(PreferenceView):
def populatePanel(self, panel):
self.dirtySettings = False
# self.openFitsSettings = service.SettingsProvider.getInstance().getSettings("pyfaPrevOpenFits", {"enabled": False, "pyfaOpenFits": []})
mainSizer = wx.BoxSizer(wx.VERTICAL)

View File

@@ -5,6 +5,7 @@ import wx
from service.fit import Fit
from gui.bitmapLoader import BitmapLoader
from gui.preferenceView import PreferenceView
from service.settings import EOSSettings
logger = logging.getLogger(__name__)
@@ -20,10 +21,11 @@ class PFFittingEnginePref(PreferenceView):
# noinspection PyAttributeOutsideInit
def populatePanel(self, panel):
# self.openFitsSettings = service.SettingsProvider.getInstance().getSettings("pyfaPrevOpenFits", {"enabled": False, "pyfaOpenFits": []})
mainSizer = wx.BoxSizer(wx.VERTICAL)
self.engine_settings = EOSSettings.getInstance()
self.stTitle = wx.StaticText(panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0)
self.stTitle.Wrap(-1)
self.stTitle.SetFont(wx.Font(12, 70, 90, 90, False, wx.EmptyString))
@@ -36,6 +38,12 @@ class PFFittingEnginePref(PreferenceView):
wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbGlobalForceReload, 0, wx.ALL | wx.EXPAND, 5)
self.cbUniversalAdaptiveArmorHardener = wx.CheckBox(panel, wx.ID_ANY,
u"When damage profile is Uniform, set Reactive Armor " +
u"Hardener to match (old behavior).",
wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbUniversalAdaptiveArmorHardener, 0, wx.ALL | wx.EXPAND, 5)
# Future code once new cap sim is implemented
'''
self.cbGlobalForceReactivationTimer = wx.CheckBox( panel, wx.ID_ANY, u"Factor in reactivation timer", wx.DefaultPosition, wx.DefaultSize, 0 )
@@ -63,15 +71,20 @@ class PFFittingEnginePref(PreferenceView):
self.sFit = Fit.getInstance()
self.cbGlobalForceReload.SetValue(self.sFit.serviceFittingOptions["useGlobalForceReload"])
self.cbGlobalForceReload.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalForceReloadStateChange)
self.cbUniversalAdaptiveArmorHardener.SetValue(self.engine_settings.get("useStaticAdaptiveArmorHardener"))
self.cbUniversalAdaptiveArmorHardener.Bind(wx.EVT_CHECKBOX, self.OnCBUniversalAdaptiveArmorHardenerChange)
panel.SetSizer(mainSizer)
panel.Layout()
def OnCBGlobalForceReloadStateChange(self, event):
self.sFit.serviceFittingOptions["useGlobalForceReload"] = self.cbGlobalForceReload.GetValue()
def OnCBUniversalAdaptiveArmorHardenerChange(self, event):
self.engine_settings.set("useStaticAdaptiveArmorHardener", self.cbUniversalAdaptiveArmorHardener.GetValue())
def getImage(self):
return BitmapLoader.getBitmap("settings_fitting", "gui")

View File

@@ -78,6 +78,10 @@ class PFGeneralPref(PreferenceView):
wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbOpenFitInNew, 0, wx.ALL | wx.EXPAND, 5)
self.cbShowShipBrowserTooltip = wx.CheckBox(panel, wx.ID_ANY, u"Show ship browser tooltip",
wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbShowShipBrowserTooltip, 0, wx.ALL | wx.EXPAND, 5)
priceSizer = wx.BoxSizer(wx.HORIZONTAL)
self.stDefaultSystem = wx.StaticText(panel, wx.ID_ANY, u"Default Market Prices:", wx.DefaultPosition, wx.DefaultSize, 0)
@@ -104,6 +108,7 @@ class PFGeneralPref(PreferenceView):
self.cbExportCharges.SetValue(self.sFit.serviceFittingOptions["exportCharges"])
self.cbOpenFitInNew.SetValue(self.sFit.serviceFittingOptions["openFitInNew"])
self.chPriceSystem.SetStringSelection(self.sFit.serviceFittingOptions["priceSystem"])
self.cbShowShipBrowserTooltip.SetValue(self.sFit.serviceFittingOptions["showShipBrowserTooltip"])
self.cbGlobalChar.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalCharStateChange)
self.cbGlobalDmgPattern.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalDmgPatternStateChange)
@@ -118,6 +123,7 @@ class PFGeneralPref(PreferenceView):
self.cbExportCharges.Bind(wx.EVT_CHECKBOX, self.onCBExportCharges)
self.cbOpenFitInNew.Bind(wx.EVT_CHECKBOX, self.onCBOpenFitInNew)
self.chPriceSystem.Bind(wx.EVT_CHOICE, self.onPriceSelection)
self.cbShowShipBrowserTooltip.Bind(wx.EVT_CHECKBOX, self.onCBShowShipBrowserTooltip)
self.cbRackLabels.Enable(self.sFit.serviceFittingOptions["rackSlots"] or False)
@@ -179,6 +185,9 @@ class PFGeneralPref(PreferenceView):
def onCBOpenFitInNew(self, event):
self.sFit.serviceFittingOptions["openFitInNew"] = self.cbOpenFitInNew.GetValue()
def onCBShowShipBrowserTooltip(self, event):
self.sFit.serviceFittingOptions["showShipBrowserTooltip"] = self.cbShowShipBrowserTooltip.GetValue()
def getImage(self):
return BitmapLoader.getBitmap("prefs_settings", "gui")

View File

@@ -3,6 +3,13 @@ import wx
from gui.preferenceView import PreferenceView
from gui.bitmapLoader import BitmapLoader
import config
from logbook import Logger
pyfalog = Logger(__name__)
def OnDumpLogs(event):
pyfalog.critical("Dump log button was pressed. Writing all logs to log file.")
class PFGeneralPref(PreferenceView):
@@ -10,7 +17,6 @@ class PFGeneralPref(PreferenceView):
def populatePanel(self, panel):
self.dirtySettings = False
# self.openFitsSettings = service.SettingsProvider.getInstance().getSettings("pyfaPrevOpenFits", {"enabled": False, "pyfaOpenFits": []})
mainSizer = wx.BoxSizer(wx.VERTICAL)
@@ -27,10 +33,26 @@ 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)
# Database path
self.stLogPath = wx.StaticText(panel, wx.ID_ANY, u"Log file location:", wx.DefaultPosition, wx.DefaultSize, 0)
self.stLogPath.Wrap(-1)
mainSizer.Add(self.stLogPath, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.inputLogPath = wx.TextCtrl(panel, wx.ID_ANY, config.logPath, wx.DefaultPosition, wx.DefaultSize, 0)
self.inputLogPath.SetEditable(False)
self.inputLogPath.SetBackgroundColour((200, 200, 200))
mainSizer.Add(self.inputLogPath, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5)
# Debug Logging
self.cbdebugLogging = wx.CheckBox(panel, wx.ID_ANY, u"Debug Logging Enabled", wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.cbdebugLogging, 0, wx.ALL | wx.EXPAND, 5)
self.stDumpLogs = wx.StaticText(panel, wx.ID_ANY, u"Pressing this button will cause all logs in memory to write to the log file:",
wx.DefaultPosition, wx.DefaultSize, 0)
mainSizer.Add(self.stDumpLogs, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
self.btnDumpLogs = wx.Button(panel, wx.ID_ANY, u"Dump All Logs", wx.DefaultPosition, wx.DefaultSize, 0)
self.btnDumpLogs.Bind(wx.EVT_BUTTON, OnDumpLogs)
mainSizer.Add(self.btnDumpLogs, 0, wx.ALIGN_LEFT, 5)
self.cbdebugLogging.SetValue(config.debug)
self.cbdebugLogging.Bind(wx.EVT_CHECKBOX, self.onCBdebugLogging)

View File

@@ -334,7 +334,7 @@ class FittingView(d.Display):
populate = sFit.appendModule(fitID, itemID)
if populate is not None:
self.slotsChanged()
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID, action="modadd", typeID=itemID))
event.Skip()
@@ -355,7 +355,7 @@ class FittingView(d.Display):
if populate is not None:
self.slotsChanged()
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.activeFitID))
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.activeFitID, action="moddel", typeID=module.item.ID))
def addModule(self, x, y, srcIdx):
"""Add a module from the market browser"""
@@ -368,7 +368,8 @@ class FittingView(d.Display):
if moduleChanged is None:
# the new module doesn't fit in specified slot, try to simply append it
wx.PostEvent(self.mainFrame, gui.marketBrowser.ItemSelected(itemID=srcIdx))
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit(), action="modadd", typeID=srcIdx))
def swapCargo(self, x, y, srcIdx):
"""Swap a module from cargo to fitting window"""
@@ -379,10 +380,13 @@ class FittingView(d.Display):
module = self.mods[dstRow]
sFit = Fit.getInstance()
fit = sFit.getFit(self.activeFitID)
typeID = fit.cargo[srcIdx].item.ID
sFit.moveCargoToModule(self.mainFrame.getActiveFit(), module.modPosition, srcIdx,
mstate.CmdDown() and module.isEmpty)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit(), action="modadd", typeID=typeID))
def swapItems(self, x, y, srcIdx):
"""Swap two modules in fitting window"""

View File

@@ -125,7 +125,7 @@ class CargoView(d.Display):
if not mstate.CmdDown(): # if not copying, remove module
sFit.removeModule(self.mainFrame.getActiveFit(), module.position)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit(), action="moddel", typeID=module.item.ID))
def fitChanged(self, event):
sFit = Fit.getInstance()

View File

@@ -25,6 +25,7 @@ import gui.globalEvents as GE
import gui.droneView
from gui.builtinViewColumns.state import State
from gui.contextMenu import ContextMenu
from gui.builtinContextMenus.commandFits import CommandFits
from service.fit import Fit
from eos.saveddata.drone import Drone as es_Drone
@@ -63,6 +64,7 @@ class CommandView(d.Display):
self.lastFitId = None
self.mainFrame.Bind(GE.FIT_CHANGED, CommandFits.populateFits)
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
self.Bind(wx.EVT_LEFT_DOWN, self.click)
self.Bind(wx.EVT_RIGHT_DOWN, self.click)
@@ -194,13 +196,13 @@ class CommandView(d.Display):
fitSrcContext = "commandFit"
fitItemContext = item.name
context = ((fitSrcContext, fitItemContext),)
context += ("command",),
context += ("commandView",),
menu = ContextMenu.getMenu((item,), *context)
elif sel == -1:
fitID = self.mainFrame.getActiveFit()
if fitID is None:
return
context = (("command",),)
context = (("commandView",),)
menu = ContextMenu.getMenu([], *context)
if menu is not None:
self.PopupMenu(menu)

View File

@@ -205,4 +205,5 @@ from gui.builtinContextMenus import ( # noqa: E402,F401
metaSwap,
implantSets,
fighterAbilities,
commandFits,
)

View File

@@ -1156,7 +1156,9 @@ class ShipItem(SFItem.SFBrowserItem):
self.raceDropShadowBmp = drawUtils.CreateDropShadowBitmap(self.raceBmp, 0.2)
self.SetToolTip(wx.ToolTip(self.shipTrait))
sFit = Fit.getInstance()
if self.shipTrait and sFit.serviceFittingOptions["showShipBrowserTooltip"]:
self.SetToolTip(wx.ToolTip(self.shipTrait))
self.shipBrowser = self.Parent.Parent
@@ -1492,7 +1494,9 @@ class FitItem(SFItem.SFBrowserItem):
self.dragTLFBmp = None
self.bkBitmap = None
if self.shipTrait != "": # show no tooltip if no trait available
sFit = Fit.getInstance()
# show no tooltip if no trait available or setting is disabled
if self.shipTrait and sFit.serviceFittingOptions["showShipBrowserTooltip"]:
self.SetToolTip(wx.ToolTip(u'{}\n{}\n{}'.format(self.shipName, u'' * 20, self.shipTrait)))
self.padding = 4
self.editWidth = 150