From 4655035d77b783cd298f0c7a897dcebfb49ebfb4 Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Sat, 30 Oct 2010 19:37:06 +0200 Subject: [PATCH] When opening the character editor, always select the currently used character by default --- gui/characterEditor.py | 14 +++++++++----- gui/characterSelection.py | 4 +++- service/character.py | 4 +++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/gui/characterEditor.py b/gui/characterEditor.py index de1cc2137..1314260f6 100644 --- a/gui/characterEditor.py +++ b/gui/characterEditor.py @@ -49,6 +49,7 @@ class CharacterEditor(wx.Frame): cChar = service.Character.getInstance() charList = cChar.getCharacterList() + charList.sort(key=lambda t: t[1]) self.btnSave = wx.Button(self, wx.ID_SAVE) self.btnSave.Hide() @@ -60,14 +61,17 @@ class CharacterEditor(wx.Frame): self.skillTreeChoice = wx.Choice(self, wx.ID_ANY, style=0) - for id, name in charList: - self.skillTreeChoice.Append(name, id) - - self.skillTreeChoice.SetSelection(0) + for id, name, active in charList: + i = self.skillTreeChoice.Append(name, id) + if active: + self.skillTreeChoice.SetSelection(i) self.navSizer.Add(self.skillTreeChoice, 1, wx.ALL | wx.EXPAND, 5) - buttons = (("new", wx.ART_NEW), (("rename", bitmapLoader.getBitmap("rename", "icons")), "copy", wx.ART_COPY), ("delete", wx.ART_DELETE)) + buttons = (("new", wx.ART_NEW), + ("rename", bitmapLoader.getBitmap("rename", "icons")), + ("copy", wx.ART_COPY), + ("delete", wx.ART_DELETE)) size = None for name, art in buttons: diff --git a/gui/characterSelection.py b/gui/characterSelection.py index 493611dfd..fede934d3 100644 --- a/gui/characterSelection.py +++ b/gui/characterSelection.py @@ -58,7 +58,9 @@ class CharacterSelection(wx.Panel): activeChar = self.getActiveCharacter() choice.Clear() - for id, name in cChar.getCharacterList(): + charList = cChar.getCharacterList() + cChar.getCharacterList() + for id, name, active in charList: currId = choice.Append(name, id) if id == activeChar: choice.SetSelection(currId) diff --git a/service/character.py b/service/character.py index 56df2b0f8..8d8a2e6c3 100644 --- a/service/character.py +++ b/service/character.py @@ -20,6 +20,7 @@ import eos.db import eos.types import copy +import service class Character(): instance = None @@ -42,7 +43,8 @@ class Character(): baseChars = [eos.types.Character.getAll0(), eos.types.Character.getAll5()] # Flush incase all0 & all5 weren't in the db yet eos.db.commit() - return map(lambda c: (c.ID, c.name), eos.db.getCharacterList()) + sFit = service.Fit.getInstance() + return map(lambda c: (c.ID, c.name, c == sFit.character), eos.db.getCharacterList()) def getSkillGroups(self): cat = eos.db.getCategory(16)