Migrate files from #868

This commit is contained in:
Ebag333
2017-02-16 08:20:09 -08:00
parent 343331c667
commit fff67906d6
5 changed files with 695 additions and 0 deletions

View File

@@ -0,0 +1,121 @@
import wx
from gui.preferenceView import PreferenceView
from gui.bitmapLoader import BitmapLoader
import gui.mainFrame
import service
import config
import logging
logger = logging.getLogger(__name__)
from eos.db.saveddata.loadDefaultDatabaseValues import DefaultDatabaseValues
class PFGeneralPref ( PreferenceView):
title = "Database"
def populatePanel( self, panel ):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.dirtySettings = False
#self.openFitsSettings = service.SettingsProvider.getInstance().getSettings("pyfaPrevOpenFits", {"enabled": False, "pyfaOpenFits": []})
mainSizer = wx.BoxSizer( wx.VERTICAL )
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 ) )
mainSizer.Add( self.stTitle, 0, wx.ALL, 5 )
self.stSubTitle = wx.StaticText( panel, wx.ID_ANY, u"(Cannot be changed while Pyfa is running.)", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stSubTitle.Wrap( -1 )
self.stSubTitle.SetFont( wx.Font( 10, 70, 90, 90, False, wx.EmptyString ) )
mainSizer.Add( self.stSubTitle, 0, wx.ALL, 5 )
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 )
#Save in Root
self.cbsaveInRoot = wx.CheckBox( panel, wx.ID_ANY, u"Using Executable Path for Saved Fit Database and Settings", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbsaveInRoot, 0, wx.ALL|wx.EXPAND, 5 )
#Database path
self.stSetUserPath = wx.StaticText( panel, wx.ID_ANY, u"Pyfa User Path:", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stSetUserPath.Wrap( -1 )
mainSizer.Add( self.stSetUserPath, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.inputUserPath = wx.TextCtrl(panel, wx.ID_ANY, config.savePath, wx.DefaultPosition, wx.DefaultSize, 0)
self.inputUserPath.SetEditable(False)
self.inputUserPath.SetBackgroundColour((200, 200, 200))
mainSizer.Add(self.inputUserPath, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5)
#Save DB
self.stFitDB = wx.StaticText( panel, wx.ID_ANY, u"Fitting Database:", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stFitDB.Wrap( -1 )
mainSizer.Add( self.stFitDB, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.inputFitDB = wx.TextCtrl(panel, wx.ID_ANY, config.saveDB, wx.DefaultPosition, wx.DefaultSize, 0)
self.inputFitDB.SetEditable(False)
self.inputFitDB.SetBackgroundColour((200, 200, 200))
mainSizer.Add(self.inputFitDB, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5)
#Game Data DB
self.stGameDB = wx.StaticText( panel, wx.ID_ANY, u"Game Database:", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stGameDB.Wrap( -1 )
mainSizer.Add( self.stGameDB, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.inputGameDB = wx.TextCtrl(panel, wx.ID_ANY, config.gameDB, wx.DefaultPosition, wx.DefaultSize, 0)
self.inputGameDB.SetEditable(False)
self.inputGameDB.SetBackgroundColour((200, 200, 200))
mainSizer.Add(self.inputGameDB, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5)
defCharSizer = wx.BoxSizer( wx.HORIZONTAL )
self.cbsaveInRoot.SetValue(config.saveInRoot)
self.cbsaveInRoot.Bind(wx.EVT_CHECKBOX, self.onCBsaveInRoot)
self.inputUserPath.Bind(wx.EVT_LEAVE_WINDOW, self.OnWindowLeave)
self.inputFitDB.Bind(wx.EVT_LEAVE_WINDOW, self.OnWindowLeave)
self.inputGameDB.Bind(wx.EVT_LEAVE_WINDOW, self.OnWindowLeave)
panel.SetSizer( mainSizer )
panel.Layout()
def onCBsaveInRoot(self, event):
# We don't want users to be able to actually change this,
# so if they try and change it, set it back to the current setting
self.cbsaveInRoot.SetValue(config.saveInRoot)
# If we ever enable it might need this.
'''
config.saveInRoot = self.cbsaveInRoot.GetValue()
'''
def getImage(self):
return BitmapLoader.getBitmap("prefs_settings", "gui")
def OnWindowLeave(self, event):
# We don't want to do anything when they leave,
# but in the future we'd want to make sure settings
# changed get saved.
pass
'''
#Set database path
config.defPaths(self.inputFitDBPath.GetValue())
logger.debug("Running database import")
if self.cbimportDefaults is True:
# Import default database values
# Import values that must exist otherwise Pyfa breaks
DefaultDatabaseValues.importRequiredDefaults()
# Import default values for damage profiles
DefaultDatabaseValues.importDamageProfileDefaults()
# Import default values for target resist profiles
DefaultDatabaseValues.importResistProfileDefaults()
'''
PFGeneralPref.register()

View File

@@ -0,0 +1,89 @@
import logging
import wx
import gui.globalEvents as GE
import gui.mainFrame
import service
from gui.bitmapLoader import BitmapLoader
from gui.preferenceView import PreferenceView
logger = logging.getLogger(__name__)
class PFFittingEnginePref ( PreferenceView):
title = "Fitting Engine"
def populatePanel( self, panel ):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.dirtySettings = False
#self.openFitsSettings = service.SettingsProvider.getInstance().getSettings("pyfaPrevOpenFits", {"enabled": False, "pyfaOpenFits": []})
mainSizer = wx.BoxSizer( wx.VERTICAL )
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 ) )
mainSizer.Add( self.stTitle, 0, wx.ALL, 5 )
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 )
self.cbGlobalForceReload = wx.CheckBox( panel, wx.ID_ANY, u"Factor in reload time", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbGlobalForceReload, 0, wx.ALL|wx.EXPAND, 5 )
self.cbGlobalForceReloadText = wx.StaticText( panel, wx.ID_ANY, u" Ignores reload when calculating capacitor usage,\n damage, and tank.", wx.DefaultPosition, wx.DefaultSize, 0 )
self.cbGlobalForceReloadText.Wrap( -1 )
self.cbGlobalForceReloadText.SetFont( wx.Font( 10, 70, 90, 90, False, wx.EmptyString ) )
mainSizer.Add( self.cbGlobalForceReloadText, 0, wx.ALL, 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 )
mainSizer.Add( self.cbGlobalForceReactivationTimer, 0, wx.ALL|wx.EXPAND, 5 )
self.cbGlobalForceReactivationTimerText = wx.StaticText( panel, wx.ID_ANY, u" Ignores reactivation timer when calculating capacitor usage,\n damage, and tank.", wx.DefaultPosition, wx.DefaultSize, 0 )
self.cbGlobalForceReactivationTimerText.Wrap( -1 )
self.cbGlobalForceReactivationTimerText.SetFont( wx.Font( 10, 70, 90, 90, False, wx.EmptyString ) )
mainSizer.Add( self.cbGlobalForceReactivationTimerText, 0, wx.ALL, 5 )
'''
# Future code once for mining laser crystal
'''
self.cbGlobalMiningSpecialtyCrystal = wx.CheckBox( panel, wx.ID_ANY, u"Factor in reactivation timer", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbGlobalMiningSpecialtyCrystal, 0, wx.ALL|wx.EXPAND, 5 )
self.cbGlobalMiningSpecialtyCrystalText = wx.StaticText( panel, wx.ID_ANY, u" If enabled, displays the Specialty Crystal mining amount.\n This is the amount mined when using crystals and mining the matching asteroid.", wx.DefaultPosition, wx.DefaultSize, 0 )
self.cbGlobalMiningSpecialtyCrystalText.Wrap( -1 )
self.cbGlobalMiningSpecialtyCrystalText.SetFont( wx.Font( 10, 70, 90, 90, False, wx.EmptyString ) )
mainSizer.Add( self.cbGlobalMiningSpecialtyCrystalText, 0, wx.ALL, 5 )
'''
self.sFit = service.Fit.getInstance()
self.cbGlobalForceReload.SetValue(self.sFit.serviceFittingOptions["useGlobalForceReload"])
self.cbGlobalForceReload.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalForceReloadStateChange)
panel.SetSizer( mainSizer )
panel.Layout()
def OnCBGlobalForceReloadStateChange(self, event):
self.sFit.serviceFittingOptions["useGlobalForceReload"] = self.cbGlobalForceReload.GetValue()
fitID = self.mainFrame.getActiveFit()
self.sFit.refreshFit(fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
event.Skip()
def getImage(self):
return BitmapLoader.getBitmap("prefs_settings", "gui")
def OnWindowLeave(self, event):
# We don't want to do anything when they leave,
# but in the future we might.
pass
PFFittingEnginePref.register()

View File

@@ -0,0 +1,67 @@
import wx
from gui.preferenceView import PreferenceView
from gui.bitmapLoader import BitmapLoader
import gui.mainFrame
import service
import config
class PFGeneralPref ( PreferenceView):
title = "Logging"
def populatePanel( self, panel ):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.dirtySettings = False
#self.openFitsSettings = service.SettingsProvider.getInstance().getSettings("pyfaPrevOpenFits", {"enabled": False, "pyfaOpenFits": []})
mainSizer = wx.BoxSizer( wx.VERTICAL )
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 ) )
mainSizer.Add( self.stTitle, 0, wx.ALL, 5 )
self.stSubTitle = wx.StaticText( panel, wx.ID_ANY, u"(Cannot be changed while Pyfa is running.)", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stSubTitle.Wrap( -1 )
self.stSubTitle.SetFont( wx.Font( 10, 70, 90, 90, False, wx.EmptyString ) )
mainSizer.Add( self.stSubTitle, 0, wx.ALL, 5 )
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 )
#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 )
defCharSizer = wx.BoxSizer( wx.HORIZONTAL )
self.cbdebugLogging.SetValue(config.debug)
self.cbdebugLogging.Bind(wx.EVT_CHECKBOX, self.onCBdebugLogging)
panel.SetSizer( mainSizer )
panel.Layout()
def onCBdebugLogging(self, event):
# We don't want users to be able to actually change this,
# so if they try and change it, set it back to the current setting
self.cbdebugLogging.SetValue(config.debug)
# In case we do, down there road, here's a bit of a start.
'''
if self.cbdebugLogging.GetValue() is True:
self.cbdebugLogging.SetValue(False)
config.Debug = self.cbdebugLogging.GetValue()
else:
self.cbdebugLogging.SetValue(True)
config.Debug = self.cbdebugLogging.GetValue()
'''
def getImage(self):
return BitmapLoader.getBitmap("prefs_settings", "gui")
PFGeneralPref.register()

View File

@@ -0,0 +1,167 @@
import wx
from gui.preferenceView import PreferenceView
from gui.bitmapLoader import BitmapLoader
import gui.mainFrame
import service
from service.crest import CrestModes
from wx.lib.intctrl import IntCtrl
class PFStatViewPref(PreferenceView):
title = "Statistics Panel"
def populatePanel(self, panel):
self.settings = service.settings.statViewSettings.getInstance()
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.dirtySettings = False
dlgWidth = panel.GetParent().GetParent().ClientSize.width
mainSizer = wx.BoxSizer(wx.VERTICAL)
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))
mainSizer.Add(self.stTitle, 0, wx.ALL, 5)
self.stInfo = wx.StaticText(panel, wx.ID_ANY, u"Changes require restart of Pyfa to take effect.",
wx.DefaultPosition, wx.DefaultSize, 0)
self.stInfo.Wrap(dlgWidth - 50)
mainSizer.Add(self.stInfo, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
# Row 1
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)
rbSizerRow1 = wx.BoxSizer(wx.HORIZONTAL)
self.rbResources = wx.RadioBox(panel, -1, "Resources", wx.DefaultPosition, wx.DefaultSize,
['None', 'Minimal', 'Full'], 1, wx.RA_SPECIFY_COLS)
# Disable minimal as we don't have a view for this yet
self.rbResources.EnableItem(1, False)
self.rbResources.SetSelection(self.settings.get('resources'))
rbSizerRow1.Add(self.rbResources, 1, wx.TOP | wx.RIGHT, 5)
self.rbResources.Bind(wx.EVT_RADIOBOX, self.OnResourcesChange)
self.rbResistances = wx.RadioBox(panel, -1, "Resistances", wx.DefaultPosition, wx.DefaultSize,
['None', 'Minimal', 'Full'], 1, wx.RA_SPECIFY_COLS)
# Disable minimal as we don't have a view for this yet
self.rbResistances.EnableItem(1, False)
self.rbResistances.SetSelection(self.settings.get('resistances'))
rbSizerRow1.Add(self.rbResistances, 1, wx.ALL, 5)
self.rbResistances.Bind(wx.EVT_RADIOBOX, self.OnResistancesChange)
self.rbRecharge = wx.RadioBox(panel, -1, "Shield/Armor Tank", wx.DefaultPosition, wx.DefaultSize,
['None', 'Minimal', 'Full'], 1, wx.RA_SPECIFY_COLS)
# Disable minimal as we don't have a view for this yet
self.rbRecharge.EnableItem(1, False)
self.rbRecharge.SetSelection(self.settings.get('recharge'))
rbSizerRow1.Add(self.rbRecharge, 1, wx.ALL, 5)
self.rbRecharge.Bind(wx.EVT_RADIOBOX, self.OnRechargeChange)
mainSizer.Add(rbSizerRow1, 1, wx.ALL | wx.EXPAND, 0)
# Row 2
self.m_staticline2 = wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
mainSizer.Add(self.m_staticline2, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
rbSizerRow2 = wx.BoxSizer(wx.HORIZONTAL)
self.rbFirepower = wx.RadioBox(panel, -1, "Firepower", wx.DefaultPosition, wx.DefaultSize,
['None', 'Minimal', 'Full'], 1, wx.RA_SPECIFY_COLS)
# Disable minimal as we don't have a view for this yet
self.rbFirepower.EnableItem(1, False)
self.rbFirepower.SetSelection(self.settings.get('firepower'))
rbSizerRow2.Add(self.rbFirepower, 1, wx.TOP | wx.RIGHT, 5)
self.rbFirepower.Bind(wx.EVT_RADIOBOX, self.OnFirepowerChange)
self.rbCapacitor = wx.RadioBox(panel, -1, "Capacitor", wx.DefaultPosition, wx.DefaultSize,
['None', 'Minimal', 'Full'], 1, wx.RA_SPECIFY_COLS)
# Disable minimal as we don't have a view for this yet
self.rbCapacitor.EnableItem(1, False)
self.rbCapacitor.SetSelection(self.settings.get('capacitor'))
rbSizerRow2.Add(self.rbCapacitor, 1, wx.ALL, 5)
self.rbCapacitor.Bind(wx.EVT_RADIOBOX, self.OnCapacitorChange)
self.rbMisc = wx.RadioBox(panel, -1, "Misc", wx.DefaultPosition, wx.DefaultSize, ['None', 'Minimal', 'Full'], 1,
wx.RA_SPECIFY_COLS)
# Disable full as we don't have a view for this yet
self.rbMisc.EnableItem(2, False)
self.rbMisc.SetSelection(self.settings.get('targetingmisc'))
rbSizerRow2.Add(self.rbMisc, 1, wx.ALL, 5)
self.rbMisc.Bind(wx.EVT_RADIOBOX, self.OnTargetingMiscChange)
mainSizer.Add(rbSizerRow2, 1, wx.ALL | wx.EXPAND, 0)
# Row 3
self.m_staticline3 = wx.StaticLine(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
mainSizer.Add(self.m_staticline3, 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
rbSizerRow3 = wx.BoxSizer(wx.HORIZONTAL)
self.rbPrice = wx.RadioBox(panel, -1, "Price", wx.DefaultPosition, wx.DefaultSize, ['None', 'Minimal', 'Full'],
1, wx.RA_SPECIFY_COLS)
# Disable minimal as we don't have a view for this yet
self.rbPrice.EnableItem(1, False)
self.rbPrice.SetSelection(self.settings.get('price'))
rbSizerRow3.Add(self.rbPrice, 1, wx.TOP | wx.RIGHT, 5)
self.rbPrice.Bind(wx.EVT_RADIOBOX, self.OnPriceChange)
# We don't have views for these.....yet
'''
self.rbMining = wx.RadioBox(panel, -1, "Mining", wx.DefaultPosition, wx.DefaultSize,
['None', 'Minimal', 'Full'], 1, wx.RA_SPECIFY_COLS)
self.rbMining.SetSelection(self.settings.get('miningyield'))
rbSizerRow3.Add(self.rbMining, 1, wx.ALL, 5)
self.rbMining.Bind(wx.EVT_RADIOBOX, self.OnMiningYieldChange)
self.rbDrones = wx.RadioBox(panel, -1, "Drones", wx.DefaultPosition, wx.DefaultSize,
['None', 'Minimal', 'Full'], 1, wx.RA_SPECIFY_COLS)
self.rbDrones.SetSelection(self.settings.get('drones'))
rbSizerRow3.Add(self.rbDrones, 1, wx.ALL, 5)
self.rbDrones.Bind(wx.EVT_RADIOBOX, self.OnDroneChange)
'''
mainSizer.Add(rbSizerRow3, 1, wx.ALL | wx.EXPAND, 0)
panel.SetSizer(mainSizer)
panel.Layout()
# serviceStatViewDefaultSettings = {"resources": 2, "resistances": 2, "recharge": 2, "firepower": 2, "capacitor": 1,
# "targetingmisc": 2, "price": 2, "miningyield": 0}
def OnResourcesChange(self, event):
self.settings.set('resources', event.GetInt())
def OnResistancesChange(self, event):
self.settings.set('resistances', event.GetInt())
def OnRechargeChange(self, event):
self.settings.set('recharge', event.GetInt())
def OnFirepowerChange(self, event):
self.settings.set('firepower', event.GetInt())
def OnCapacitorChange(self, event):
self.settings.set('capacitor', event.GetInt())
def OnTargetingMiscChange(self, event):
self.settings.set('targetingmisc', event.GetInt())
def OnPriceChange(self, event):
self.settings.set('price', event.GetInt())
def OnMiningYieldChange(self, event):
self.settings.set('miningyield', event.GetInt())
def OnDroneChange(self, event):
self.settings.set('drones', event.GetInt())
def getImage(self):
return BitmapLoader.getBitmap("pref-gauges_big", "gui")
PFStatViewPref.register()