Fix for refresh API button

This fix enables and disabled the API refresh button on main view.
Button is disable by default, and only enabled when both of the
following are true:
- Character is user created (no All 0/All 5), and
- Character has api data in database (including default character),
otherwise it obviously wouldn't work
This commit is contained in:
blitzmann
2013-08-10 01:22:39 -04:00
parent ebddc44463
commit 4dc4679d03
2 changed files with 21 additions and 8 deletions

View File

@@ -49,16 +49,16 @@ class CharacterSelection(wx.Panel):
self.skillReqsStaticBitmap.SetBitmap(self.cleanSkills)
btn = wx.BitmapButton(self, wx.ID_ANY, self.refresh)
size = btn.GetSize()
self.btnRefresh = wx.BitmapButton(self, wx.ID_ANY, self.refresh)
size = self.btnRefresh.GetSize()
btn.SetMinSize(size)
btn.SetMaxSize(size)
btn.SetToolTipString("Refresh API")
self.btnRefresh.SetMinSize(size)
self.btnRefresh.SetMaxSize(size)
self.btnRefresh.SetToolTipString("Refresh API")
btn.Bind(wx.EVT_BUTTON, self.refreshApi)
#btn.Enable(False)
mainSizer.Add(btn, 0, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.RIGHT | wx.LEFT, 2)
self.btnRefresh.Bind(wx.EVT_BUTTON, self.refreshApi)
self.btnRefresh.Enable(False)
mainSizer.Add(self.btnRefresh, 0, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.RIGHT | wx.LEFT, 2)
self.Bind(wx.EVT_CHOICE, self.charChanged)
self.mainFrame.Bind(GE.CHAR_LIST_UPDATED, self.refreshCharacterList)
@@ -114,6 +114,12 @@ class CharacterSelection(wx.Panel):
def charChanged(self, event):
fitID = self.mainFrame.getActiveFit()
charID = self.getActiveCharacter()
cChar = service.Character.getInstance()
if cChar.getCharName(charID) not in ("All 0", "All 5") and cChar.apiEnabled(charID):
self.btnRefresh.Enable(True)
else:
self.btnRefresh.Enable(False)
cFit = service.Fit.getInstance()
cFit.changeChar(fitID, charID)
@@ -157,9 +163,12 @@ class CharacterSelection(wx.Panel):
if newCharID == None:
cChar = service.Character.getInstance()
self.selectChar(cChar.all5ID())
elif currCharID != newCharID:
self.selectChar(newCharID)
self.charChanged(None)
event.Skip()
def _buildSkillsTooltip(self, reqs, currItem = "", tabulationLevel = 0):

View File

@@ -234,6 +234,10 @@ class Character(object):
chars = None
return (char.apiID or "", char.apiKey or "", char.defaultChar or "", chars or [])
def apiEnabled(self, charID):
id, key, default, _ = self.getApiDetails(charID)
return id is not "" and key is not "" and default is not ""
def charList(self, charID, userID, apiKey):
char = eos.db.getCharacter(charID)
try: