Merge branch 'master' into chaos

This commit is contained in:
DarkPhoenix
2011-12-24 00:32:29 +04:00
10 changed files with 284 additions and 14 deletions

View File

@@ -13,10 +13,10 @@ debug = False
saveInRoot = False
# Version data
version = "1.1"
version = "1.1.1"
tag = "git"
expansionName = "Crucible"
expansionVersion = "1.0"
expansionVersion = "1.0.3"
pyfaPath = None
savePath = None

2
eos

Submodule eos updated: f5ecf03eb6...a2d54b1fa3

View File

@@ -17,8 +17,9 @@ class FactorReload(ContextMenu):
def activate(self, fullContext, selection, i):
sFit = service.Fit.getInstance()
sFit.serviceFittingOptions["useGlobalForceReload"] = not sFit.serviceFittingOptions["useGlobalForceReload"]
fitID = self.mainFrame.getActiveFit()
sFit.toggleFactorReload(fitID)
sFit.refreshFit(fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
def getBitmap(self, context, selection):

View File

@@ -1,5 +1,6 @@
import wx
import service
import urllib2
from gui.preferenceView import PreferenceView
from gui import bitmapLoader
@@ -15,6 +16,15 @@ class PFGlobalPref ( PreferenceView):
def populatePanel( self, panel ):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
self.proxySettings = service.settings.ProxySettings.getInstance()
self.dirtySettings = False
self.nMode = self.proxySettings.getMode()
self.nAddr = self.proxySettings.getAddress()
self.nPort = self.proxySettings.getPort()
self.nType = self.proxySettings.getType()
mainSizer = wx.BoxSizer( wx.VERTICAL )
self.stTitle = wx.StaticText( panel, wx.ID_ANY, self.title, wx.DefaultPosition, wx.DefaultSize, 0 )
@@ -23,8 +33,8 @@ class PFGlobalPref ( PreferenceView):
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, 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, 5 )
self.cbGlobalChar = wx.CheckBox( panel, wx.ID_ANY, u"Use global character", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbGlobalChar, 0, wx.ALL|wx.EXPAND, 5 )
@@ -32,7 +42,7 @@ class PFGlobalPref ( PreferenceView):
self.cbGlobalDmgPattern = wx.CheckBox( panel, wx.ID_ANY, u"Use global damage pattern", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.cbGlobalDmgPattern, 0, wx.ALL|wx.EXPAND, 5 )
self.cbGlobalForceReload = wx.CheckBox( panel, wx.ID_ANY, u"Use force reload", wx.DefaultPosition, wx.DefaultSize, 0 )
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 )
defCharSizer = wx.BoxSizer( wx.HORIZONTAL )
@@ -48,6 +58,82 @@ class PFGlobalPref ( PreferenceView):
mainSizer.Add( defCharSizer, 0, wx.EXPAND, 5 )
self.m_staticline2 = wx.StaticLine( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
mainSizer.Add( self.m_staticline2, 0, wx.EXPAND, 5 )
self.stPTitle = wx.StaticText( panel, wx.ID_ANY, "Proxy settings", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stPTitle.Wrap( -1 )
self.stPTitle.SetFont( wx.Font( 12, 70, 90, 90, False, wx.EmptyString ) )
mainSizer.Add( self.stPTitle, 0, wx.ALL, 5 )
ptypeSizer = wx.BoxSizer( wx.HORIZONTAL )
self.stPType = wx.StaticText( panel, wx.ID_ANY, u"Mode:", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stPType.Wrap( -1 )
ptypeSizer.Add( self.stPType, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.chProxyTypeChoices = [ u"No proxy", u"Auto-detected proxy settings", u"Manual proxy settings" ]
self.chProxyType = wx.Choice( panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, self.chProxyTypeChoices, 0 )
self.chProxyType.SetSelection( self.nMode )
ptypeSizer.Add( self.chProxyType, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
mainSizer.Add( ptypeSizer, 0, wx.EXPAND, 5 )
fgAddrSizer = wx.FlexGridSizer( 2, 2, 0, 0 )
fgAddrSizer.AddGrowableCol( 1 )
fgAddrSizer.SetFlexibleDirection( wx.BOTH )
fgAddrSizer.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
self.stPSetAddr = wx.StaticText( panel, wx.ID_ANY, u"Addr:", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stPSetAddr.Wrap( -1 )
fgAddrSizer.Add( self.stPSetAddr, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.editProxySettingsAddr = wx.TextCtrl( panel, wx.ID_ANY, self.nAddr, wx.DefaultPosition, wx.DefaultSize, 0 )
fgAddrSizer.Add( self.editProxySettingsAddr, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5 )
self.stPSetPort = wx.StaticText( panel, wx.ID_ANY, u"Port:", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stPSetPort.Wrap( -1 )
fgAddrSizer.Add( self.stPSetPort, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
self.editProxySettingsPort = wx.TextCtrl( panel, wx.ID_ANY, self.nPort, wx.DefaultPosition, wx.DefaultSize, 0 )
fgAddrSizer.Add( self.editProxySettingsPort, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5 )
mainSizer.Add( fgAddrSizer, 0, wx.EXPAND, 5)
self.stPSAutoDetected = wx.StaticText( panel, wx.ID_ANY, u"Auto-detected: ", wx.DefaultPosition, wx.DefaultSize, 0 )
self.stPSAutoDetected.Wrap( -1 )
mainSizer.Add( self.stPSAutoDetected, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
btnSizer = wx.BoxSizer( wx.HORIZONTAL )
btnSizer.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
self.btnApply = wx.Button( panel, wx.ID_ANY, u"Apply", wx.DefaultPosition, wx.DefaultSize, 0 )
btnSizer.Add( self.btnApply, 0, wx.ALL, 5 )
mainSizer.Add(btnSizer, 0, wx.EXPAND,5)
proxy = self.proxySettings.autodetect()
if proxy is not None:
addr,port = proxy
txt = addr + ":" + str(port)
else:
txt = "None"
self.stPSAutoDetected.SetLabel("Auto-detected: " + txt)
self.stPSAutoDetected.Disable()
cChar = service.Character.getInstance()
charList = cChar.getCharacterList()
@@ -70,13 +156,86 @@ class PFGlobalPref ( PreferenceView):
self.cbGlobalForceReload.Bind(wx.EVT_CHECKBOX, self.OnCBGlobalForceReloadStateChange)
self.chDefaultChar.Disable()
self.chDefaultChar.Show(False)
self.stDefChar.Show(False)
self.chProxyType.Bind(wx.EVT_CHOICE, self.OnCHProxyTypeSelect)
self.editProxySettingsAddr.Bind(wx.EVT_TEXT, self.OnEditPSAddrText)
self.editProxySettingsPort.Bind(wx.EVT_TEXT, self.OnEditPSPortText)
self.btnApply.Bind(wx.EVT_BUTTON, self.OnBtnApply)
self.UpdateApplyButtonState()
if self.nMode is not 2:
self.ToggleProxySettings(False)
else:
self.ToggleProxySettings(True)
panel.SetSizer( mainSizer )
panel.Layout()
def OnEditPSAddrText(self, event):
self.nAddr = self.editProxySettingsAddr.GetValue()
self.dirtySettings = True
self.UpdateApplyButtonState()
def OnEditPSPortText(self, event):
self.nPort = self.editProxySettingsPort.GetValue()
self.dirtySettings = True
self.UpdateApplyButtonState()
def OnBtnApply(self, event):
self.dirtySettings = False
self.UpdateApplyButtonState()
self.SaveSettings()
def SaveSettings(self):
self.proxySettings.setMode(self.nMode)
self.proxySettings.setAddress(self.nAddr)
self.proxySettings.setPort(self.nPort)
self.proxySettings.setType(self.nType)
def UpdateApplyButtonState(self):
if self.dirtySettings:
self.btnApply.Enable()
else:
self.btnApply.Disable()
def OnCHProxyTypeSelect(self, event):
choice = self.chProxyType.GetSelection()
self.nMode = choice
self.dirtySettings = True
self.UpdateApplyButtonState()
if choice is not 2:
self.ToggleProxySettings(False)
else:
self.ToggleProxySettings(True)
def ToggleProxySettings(self, mode):
if mode:
self.stPSetAddr.Enable()
self.editProxySettingsAddr.Enable()
self.stPSetPort.Enable()
self.editProxySettingsPort.Enable()
else:
self.stPSetAddr.Disable()
self.editProxySettingsAddr.Disable()
self.stPSetPort.Disable()
self.editProxySettingsPort.Disable()
def OnCBProxySettingsStateChange(self, event):
self.ToggleProxySettings(self.cbProxySettings.GetValue())
event.Skip()
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()

View File

@@ -141,6 +141,11 @@ class DmgPatternEditorDlg (wx.Dialog):
mainSizer.Add(contentSizer, 1, wx.EXPAND, 0)
if "wxGTK" in wx.PlatformInfo:
self.closeBtn = wx.Button( self, wx.ID_ANY, u"Close", wx.DefaultPosition, wx.DefaultSize, 0 )
mainSizer.Add( self.closeBtn, 0, wx.ALL|wx.ALIGN_RIGHT, 5 )
self.closeBtn.Bind(wx.EVT_BUTTON, self.closeEvent)
self.SetSizer(mainSizer)
importExport = (("Import", wx.ART_FILE_OPEN, "from"),
@@ -192,6 +197,9 @@ class DmgPatternEditorDlg (wx.Dialog):
self.patternChanged()
def closeEvent(self, event):
self.Destroy()
def ValuesUpdated(self, event=None):
if self.block:
return

View File

@@ -37,7 +37,16 @@ class PreferenceDialog(wx.Dialog):
self.imageList = wx.ImageList(64,64)
self.listbook.SetImageList(self.imageList)
mainSizer.Add(self.listbook, 1, wx.EXPAND | wx.ALL, 5)
mainSizer.Add(self.listbook, 1, wx.EXPAND | wx.TOP|wx.BOTTOM|wx.LEFT, 5)
self.m_staticline2 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
mainSizer.Add( self.m_staticline2, 0, wx.EXPAND, 5 )
btnSizer = wx.BoxSizer( wx.HORIZONTAL )
btnSizer.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
self.btnOK = wx.Button( self, wx.ID_ANY, u"OK", wx.DefaultPosition, wx.DefaultSize, 0 )
btnSizer.Add( self.btnOK, 0, wx.ALL, 5 )
mainSizer.Add(btnSizer,0 , wx.EXPAND, 5)
self.SetSizer(mainSizer)
self.Centre(wx.BOTH)
@@ -53,4 +62,9 @@ class PreferenceDialog(wx.Dialog):
self.listbook.AddPage(page, title, imageId = imgID)
self.Fit()
self.Layout()
self.Layout()
self.btnOK.Bind(wx.EVT_BUTTON, self.OnBtnOK)
def OnBtnOK(self, event):
self.Destroy()

View File

@@ -118,13 +118,13 @@ class Character():
try:
char.apiID = userID
char.apiKey = apiKey
return char.apiCharList()
return char.apiCharList(proxy = service.settings.ProxySettings.getInstance().getProxySettings())
except:
return None
def apiFetch(self, charID, charName):
char = eos.db.getCharacter(charID)
char.apiFetch(charName)
char.apiFetch(charName, proxy = service.settings.ProxySettings.getInstance().getProxySettings())
eos.db.commit()
def changeLevel(self, charID, skillID, level):

View File

@@ -665,7 +665,16 @@ class Fit(object):
else:
return currState
def refreshFit(self, fitID):
if fitID is None:
return None
fit = eos.db.getFit(fitID)
eos.db.commit()
self.recalc(fit)
def recalc(self, fit, withBoosters=False):
if fit.factorReload is not self.serviceFittingOptions["useGlobalForceReload"]:
fit.factorReload = self.serviceFittingOptions["useGlobalForceReload"]
fit.clear()
fit.forceReload = self.serviceFittingOptions["useGlobalForceReload"]
fit.calculateModifiedAttributes(withBoosters=withBoosters, dirtyStorage=self.dirtyFitIDs)

View File

@@ -26,7 +26,7 @@ import Queue
import eos.db
import eos.types
from service.settings import SettingsProvider
from service.settings import SettingsProvider, ProxySettings
try:
from collections import OrderedDict
@@ -79,7 +79,10 @@ class PriceWorkerThread(threading.Thread):
# Grab prices, this is the time-consuming part
if len(requests) > 0:
eos.types.Price.fetchPrices(*requests)
proxy = ProxySettings.getInstance().getProxySettings()
if proxy is not None:
proxy = "{0}:{1}".format(*proxy)
eos.types.Price.fetchPrices(requests, proxy=proxy)
wx.CallAfter(callback)
queue.task_done()

View File

@@ -20,6 +20,7 @@
import cPickle
import os.path
import config
import urllib2
class SettingsProvider():
BASE_PATH = os.path.join(config.savePath, "settings")
@@ -104,3 +105,78 @@ class Settings():
def items(self):
return self.info.items()
class ProxySettings():
_instance = None
@classmethod
def getInstance(cls):
if cls._instance == None:
cls._instance = ProxySettings()
return cls._instance
def __init__(self):
# mode
# 0 - No proxy
# 1 - Auto-detected proxy settings
# 2 - Manual proxy settings
serviceProxyDefaultSettings = {"mode": 0, "type": "https", "address": "", "port": ""}
self.serviceProxySettings = SettingsProvider.getInstance().getSettings("pyfaServiceProxySettings", serviceProxyDefaultSettings)
def getMode(self):
return self.serviceProxySettings["mode"]
def getAddress(self):
return self.serviceProxySettings["address"]
def getPort(self):
return self.serviceProxySettings["port"]
def getType(self):
return self.serviceProxySettings["type"]
def setMode(self, mode):
self.serviceProxySettings["mode"] = mode
def setAddress(self, addr):
self.serviceProxySettings["address"] = addr
def setPort(self, port):
self.serviceProxySettings["port"] = port
def setType(self, type):
self.serviceProxySettings["type"] = type
def autodetect(self):
proxy = None
proxAddr = proxPort = ""
proxydict = urllib2.ProxyHandler().proxies
txt = "Auto-detected: "
validPrefixes = ("http", "https")
for prefix in validPrefixes:
if not prefix in proxydict:
continue
proxyline = proxydict[prefix]
proto = "{0}://".format(prefix)
if proxyline[:len(proto)] == proto:
proxyline = proxyline[len(proto):]
proxAddr, proxPort = proxyline.split(":")
proxPort = int(proxPort.rstrip("/"))
proxy = (proxAddr, proxPort)
break
return proxy
def getProxySettings(self):
if self.getMode() == 0:
return None
if self.getMode() == 1:
return self.autodetect()
if self.getMode() == 2:
return (self.getAddress(), int(self.getPort()))