Merge branch 'development' into feature/commandmenu
This commit is contained in:
@@ -29,6 +29,7 @@ pyfaPath = None
|
||||
savePath = None
|
||||
saveDB = None
|
||||
gameDB = None
|
||||
logPath = None
|
||||
|
||||
|
||||
def isFrozen():
|
||||
|
||||
@@ -22,7 +22,7 @@ else:
|
||||
pyfalog.debug("Saveddata connection string: {0}", saveddata_connectionstring)
|
||||
|
||||
settings = {
|
||||
"setting1": True
|
||||
"useStaticAdaptiveArmorHardener": False
|
||||
}
|
||||
|
||||
# Autodetect path, only change if the autodetection bugs out.
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
# Used by:
|
||||
# Module: Reactive Armor Hardener
|
||||
from logbook import Logger
|
||||
import eos.config
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
@@ -13,6 +14,12 @@ type = "active"
|
||||
def handler(fit, module, context):
|
||||
damagePattern = fit.damagePattern
|
||||
|
||||
static_adaptive_behavior = eos.config.settings['useStaticAdaptiveArmorHardener']
|
||||
|
||||
if (damagePattern.emAmount == damagePattern.thermalAmount == damagePattern.kineticAmount == damagePattern.explosiveAmount) and static_adaptive_behavior:
|
||||
pyfalog.debug("Setting adaptivearmorhardener resists to uniform profile.")
|
||||
return
|
||||
|
||||
# Skip if there is no damage pattern. Example: projected ships or fleet boosters
|
||||
if damagePattern:
|
||||
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
#
|
||||
# Used by:
|
||||
# Modules from group: Tractor Beam (4 of 4)
|
||||
from eos.config import settings
|
||||
type = "active"
|
||||
|
||||
|
||||
def handler(fit, module, context):
|
||||
print settings['setting1']
|
||||
pass
|
||||
|
||||
@@ -32,6 +32,8 @@ except ImportError:
|
||||
from logbook import Logger
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
# Keep a list of handlers that fail to import so we don't keep trying repeatedly.
|
||||
badHandlers = []
|
||||
|
||||
|
||||
class Effect(EqBase):
|
||||
@@ -159,34 +161,51 @@ class Effect(EqBase):
|
||||
Grab the handler, type and runTime from the effect code if it exists,
|
||||
if it doesn't, set dummy values and add a dummy handler
|
||||
"""
|
||||
try:
|
||||
self.__effectModule = effectModule = __import__('eos.effects.' + self.handlerName, fromlist=True)
|
||||
self.__handler = getattr(effectModule, "handler", effectDummy)
|
||||
self.__runTime = getattr(effectModule, "runTime", "normal")
|
||||
self.__activeByDefault = getattr(effectModule, "activeByDefault", True)
|
||||
t = getattr(effectModule, "type", None)
|
||||
global badHandlers
|
||||
|
||||
t = t if isinstance(t, tuple) or t is None else (t,)
|
||||
self.__type = t
|
||||
except (ImportError) as e:
|
||||
# Effect probably doesn't exist, so create a dummy effect and flag it with a warning.
|
||||
# Skip if we've tried to import before and failed
|
||||
if self.handlerName not in badHandlers:
|
||||
try:
|
||||
self.__effectModule = effectModule = __import__('eos.effects.' + self.handlerName, fromlist=True)
|
||||
self.__handler = getattr(effectModule, "handler", effectDummy)
|
||||
self.__runTime = getattr(effectModule, "runTime", "normal")
|
||||
self.__activeByDefault = getattr(effectModule, "activeByDefault", True)
|
||||
t = getattr(effectModule, "type", None)
|
||||
|
||||
t = t if isinstance(t, tuple) or t is None else (t,)
|
||||
self.__type = t
|
||||
except (ImportError) as e:
|
||||
# Effect probably doesn't exist, so create a dummy effect and flag it with a warning.
|
||||
self.__handler = effectDummy
|
||||
self.__runTime = "normal"
|
||||
self.__activeByDefault = True
|
||||
self.__type = None
|
||||
pyfalog.debug("ImportError generating handler: {0}", e)
|
||||
badHandlers.append(self.handlerName)
|
||||
except (AttributeError) as e:
|
||||
# Effect probably exists but there is an issue with it. Turn it into a dummy effect so we can continue, but flag it with an error.
|
||||
self.__handler = effectDummy
|
||||
self.__runTime = "normal"
|
||||
self.__activeByDefault = True
|
||||
self.__type = None
|
||||
pyfalog.error("AttributeError generating handler: {0}", e)
|
||||
badHandlers.append(self.handlerName)
|
||||
except Exception as e:
|
||||
self.__handler = effectDummy
|
||||
self.__runTime = "normal"
|
||||
self.__activeByDefault = True
|
||||
self.__type = None
|
||||
pyfalog.critical("Exception generating handler:")
|
||||
pyfalog.critical(e)
|
||||
badHandlers.append(self.handlerName)
|
||||
|
||||
self.__generated = True
|
||||
else:
|
||||
# We've already failed on this one, just pass a dummy effect back
|
||||
self.__handler = effectDummy
|
||||
self.__runTime = "normal"
|
||||
self.__activeByDefault = True
|
||||
self.__type = None
|
||||
pyfalog.warning("ImportError generating handler: {0}", e)
|
||||
except (AttributeError) as e:
|
||||
# Effect probably exists but there is an issue with it. Turn it into a dummy effect so we can continue, but flag it with an error.
|
||||
self.__handler = effectDummy
|
||||
self.__runTime = "normal"
|
||||
self.__activeByDefault = True
|
||||
self.__type = None
|
||||
pyfalog.error("AttributeError generating handler: {0}", e)
|
||||
except Exception as e:
|
||||
pyfalog.critical("Exception generating handler:")
|
||||
pyfalog.critical(e)
|
||||
|
||||
self.__generated = True
|
||||
|
||||
def getattr(self, key):
|
||||
if not self.__generated:
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
18
pyfa.py
18
pyfa.py
@@ -47,7 +47,7 @@ class PassThroughOptionParser(OptionParser):
|
||||
largs.append(e.opt_str)
|
||||
|
||||
|
||||
class LoggerWriter:
|
||||
class LoggerWriter(object):
|
||||
def __init__(self, level):
|
||||
# self.level is really like using log.debug(message)
|
||||
# at least in my case
|
||||
@@ -164,8 +164,6 @@ if __name__ == "__main__":
|
||||
# Import everything
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
import os
|
||||
import os.path
|
||||
|
||||
try:
|
||||
# convert to unicode if it is set
|
||||
@@ -190,8 +188,9 @@ if __name__ == "__main__":
|
||||
else:
|
||||
savePath_filename = "Pyfa.log"
|
||||
|
||||
savePath_Destination = os.path.join(config.savePath, savePath_filename)
|
||||
config.logPath = os.path.join(config.savePath, savePath_filename)
|
||||
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
if options.debug:
|
||||
logging_mode = "Debug"
|
||||
@@ -205,7 +204,7 @@ if __name__ == "__main__":
|
||||
level=options.logginglevel
|
||||
),
|
||||
TimedRotatingFileHandler(
|
||||
savePath_Destination,
|
||||
config.logPath,
|
||||
level=0,
|
||||
backup_count=3,
|
||||
bubble=True,
|
||||
@@ -220,7 +219,7 @@ if __name__ == "__main__":
|
||||
NullHandler(),
|
||||
FingersCrossedHandler(
|
||||
TimedRotatingFileHandler(
|
||||
savePath_Destination,
|
||||
config.logPath,
|
||||
level=0,
|
||||
backup_count=3,
|
||||
bubble=False,
|
||||
@@ -271,15 +270,18 @@ if __name__ == "__main__":
|
||||
# Output all stdout (print) messages as warnings
|
||||
try:
|
||||
sys.stdout = LoggerWriter(pyfalog.warning)
|
||||
except ValueError, Exception:
|
||||
except (ValueError, Exception) as e:
|
||||
pyfalog.critical("Cannot access log file. Continuing without writing stdout to log.")
|
||||
pyfalog.critical(e)
|
||||
|
||||
# Don't redirect stderr (stacktrace) messages if we're in debug mode. Developers want to see them in the console.
|
||||
if not options.debug:
|
||||
# Output all stderr (stacktrace) messages as critical
|
||||
try:
|
||||
sys.stderr = LoggerWriter(pyfalog.critical)
|
||||
except ValueError, Exception:
|
||||
except (ValueError, Exception) as e:
|
||||
pyfalog.critical("Cannot access log file. Continuing without writing stderr to log.")
|
||||
pyfalog.critical(e)
|
||||
|
||||
pyfalog.info("Starting Pyfa")
|
||||
pyfalog.info("Running in logging mode: {0}", logging_mode)
|
||||
|
||||
@@ -73,6 +73,7 @@ class Fit(object):
|
||||
"exportCharges": True,
|
||||
"openFitInNew": False,
|
||||
"priceSystem": "Jita",
|
||||
"showShipBrowserTooltip": True,
|
||||
}
|
||||
|
||||
self.serviceFittingOptions = SettingsProvider.getInstance().getSettings(
|
||||
|
||||
@@ -74,8 +74,6 @@ class SettingsProvider(object):
|
||||
info[item] = defaults[item]
|
||||
|
||||
self.settings[area] = s = Settings(p, info)
|
||||
else:
|
||||
s = None
|
||||
|
||||
return s
|
||||
|
||||
|
||||
Reference in New Issue
Block a user