Changed login box to show currently logged in character with timer, and we now fetch the character image.

This commit is contained in:
blitzmann
2015-10-23 00:52:03 -04:00
parent e0f99ee133
commit 6e04c64ffb
3 changed files with 48 additions and 28 deletions

View File

@@ -10,7 +10,7 @@ from eos.types import Cargo
from eos.db import getItem
from service.server import *
import config
import time
class CrestFittings(wx.Frame):
@@ -136,39 +136,48 @@ class ExportToEve(wx.Frame):
except ValueError:
self.statusbar.SetStatusText("", 1)
class CrestLogin(wx.Frame):
class CrestCharacterInfo(wx.Dialog):
def __init__(self, parent):
wx.Frame.__init__(self, parent, id=wx.ID_ANY, title="Login", pos=wx.DefaultPosition, size=wx.Size( -1,-1 ), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title="Character Info", pos=wx.DefaultPosition, size = wx.Size( 200,240 ))
self.mainFrame = parent
sCrest = service.Crest.getInstance()
mainSizer = wx.BoxSizer( wx.HORIZONTAL )
self.loginBtn = wx.Button( self, wx.ID_ANY, u"Login via SSO", wx.DefaultPosition, wx.DefaultSize, 5 )
mainSizer.Add( self.loginBtn, 0, wx.ALL, 5 )
self.char = sCrest.implicitCharacter
self.bitmapSet = False
self.loginBtn.Bind(wx.EVT_BUTTON, self.startServer)
mainSizer = wx.BoxSizer( wx.VERTICAL )
self.SetSizer(mainSizer)
self.Layout()
self.headingText = wx.StaticText(self, wx.ID_ANY, "Currently logged in", wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE )
self.headingText.Wrap( -1 )
self.headingText.SetFont( wx.Font( 12, 74, 90, 92, False) )
mainSizer.Add( self.headingText, 0, wx.EXPAND|wx.ALL, 5 )
pub.subscribe(self.sso_login, 'sso_login')
self.Centre(wx.BOTH)
self.pic = wx.StaticBitmap(self, -1, wx.EmptyBitmap(128, 128))
mainSizer.Add(self.pic, 0, wx.EXPAND, 5 )
def sso_login(self, message):
self.httpd.stop()
con = config.pycrest_eve.authorize(message)
sCrest = service.Crest.getInstance()
sCrest.newChar(con)
self.Close()
self.characterText = wx.StaticText(self, wx.ID_ANY, self.char.name, wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE )
self.characterText.Wrap( -1 )
self.characterText.SetFont( wx.Font( 11, 74, 90, 92, False) )
mainSizer.Add( self.characterText, 0, wx.EXPAND|wx.ALL, 5 )
def startServer(self, event):
self.httpd = StoppableHTTPServer(('', 6461), AuthHandler)
thread.start_new_thread(self.httpd.serve, ())
uri = config.pycrest_eve.auth_uri(scopes=['characterFittingsRead', 'characterFittingsWrite'])
wx.LaunchDefaultBrowser(uri)
self.coutdownText = wx.StaticText( self, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE)
self.coutdownText.Wrap( -1 )
mainSizer.Add( self.coutdownText, 0, wx.EXPAND, 5 )
self.SetSizer( mainSizer )
self.Centre( wx.BOTH )
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.update, self.timer)
self.timer.Start(1)
def update(self, event):
t = time.gmtime(self.char.eve.expires-time.time())
if not self.bitmapSet and hasattr(self.char, 'img'):
self.pic.SetBitmap(wx.ImageFromStream(self.char.img).ConvertToBitmap())
self.Layout()
self.bitmapSet = True
self.coutdownText.SetLabel(time.strftime("%H:%M:%S", t))
class FittingsTreeView(wx.Panel):

View File

@@ -44,7 +44,7 @@ from gui.multiSwitch import MultiSwitch
from gui.statsPane import StatsPane
from gui.shipBrowser import ShipBrowser, FitSelected, ImportSelected, Stage3Selected
from gui.characterEditor import CharacterEditor, SaveCharacterAs
from gui.crestFittings import CrestFittings, ExportToEve, CrestLogin
from gui.crestFittings import CrestFittings, ExportToEve, CrestCharacterInfo
from gui.characterSelection import CharacterSelection
from gui.patternEditor import DmgPatternEditorDlg
from gui.resistsEditor import ResistsEditorDlg
@@ -57,6 +57,9 @@ from gui.updateDialog import UpdateDialog
from gui.builtinViews import *
from time import gmtime, strftime
from wx.lib.pubsub import setupkwargs
from wx.lib.pubsub import pub
#dummy panel(no paint no erasebk)
class PFPanel(wx.Panel):
def __init__(self,parent):
@@ -192,6 +195,8 @@ class MainFrame(wx.Frame):
self.sUpdate = service.Update.getInstance()
self.sUpdate.CheckUpdate(self.ShowUpdateBox)
pub.subscribe(self.showCharacterMgmt, 'login_success')
def ShowUpdateBox(self, release):
dlg = UpdateDialog(self, release)
dlg.ShowModal()
@@ -489,13 +494,19 @@ class MainFrame(wx.Frame):
dlg=CrestFittings(self)
dlg.Show()
def showCharacterMgmt(self, type):
if type == 0:
print "login type is implicit"
dlg=CrestCharacterInfo(self)
dlg.Show()
def ssoLogin(self, event):
sCrest = service.Crest.getInstance()
if sCrest.settings.get('mode') == 0: # Implicit, go directly to login
uri = sCrest.startServer()
wx.LaunchDefaultBrowser(uri)
else:
dlg=CrestLogin(self)
dlg=CrestCharacterInfo(self)
dlg.Show()
def exportToEve(self, event):

View File

@@ -9,7 +9,6 @@ import uuid
from wx.lib.pubsub import setupkwargs
from wx.lib.pubsub import pub
# TODO:
# With implicit grant, make sure we know when it expires and delete/inactive char
class Crest():
@@ -102,6 +101,7 @@ class Crest():
info = eve.whoami()
self.implicitCharacter = CrestUser(info['CharacterID'], info['CharacterName'])
self.implicitCharacter.eve = eve
self.implicitCharacter.fetchImage()
wx.CallAfter(pub.sendMessage, 'login_success', type=0)
elif 'code' in message: