Add the ability to change a skill's level via right-click

This commit is contained in:
cncfanatics
2010-09-09 15:32:01 +02:00
parent ca80583001
commit d850aac7ad
3 changed files with 52 additions and 3 deletions

View File

@@ -55,6 +55,7 @@ class Character():
def getSkillLevel(self, charID, skillID):
skill = eos.db.getCharacter(charID).getSkill(skillID)
eos.db.commit()
return skill.level if skill.learned else "Not learned"
def rename(self, charID, newName):
@@ -93,3 +94,13 @@ class Character():
char = eos.db.getCharacter(charID)
char.apiFetch(charName)
eos.db.commit()
def changeLevel(self, charID, skillID, level):
char = eos.db.getCharacter(charID)
skill = char.getSkill(skillID)
if level == "Unlearned":
skill.learned = False
else:
skill.level = level
eos.db.commit()

2
eos

Submodule eos updated: 9dac01cdad...925a4d0a32

View File

@@ -133,7 +133,6 @@ class CharacterEditor(wx.Dialog):
self.aview.btnFetchCharList.Enable(True)
def charChanged(self, event):
event.Skip()
self.sview.skillTreeListCtrl.DeleteChildren(self.sview.root)
self.sview.populateSkillTree()
cChar = controller.Character.getInstance()
@@ -155,6 +154,7 @@ class CharacterEditor(wx.Dialog):
self.unrestrict()
self.btnSave.SetLabel("Create")
self.rename(None)
self.charChanged(None)
def rename(self, event):
if event is not None:
@@ -242,8 +242,23 @@ class SkillTreeView (wx.Panel):
self.populateSkillTree()
tree.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.expandLookup)
tree.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.spawnMenu)
self.levelChangeMenu = wx.Menu()
self.levelIds = {}
idUnlearned = wx.NewId()
self.levelIds[idUnlearned] = "Not Learned"
self.levelChangeMenu.Append(idUnlearned, "Unlearn")
for level in xrange(6):
id = wx.NewId()
self.levelIds[id] = level
self.levelChangeMenu.Append(id, "Level %d" % level)
self.levelChangeMenu.Bind(wx.EVT_MENU, self.changeLevel)
self.SetSizer(pmainSizer)
self.Layout()
def populateSkillTree(self):
@@ -273,10 +288,33 @@ class SkillTreeView (wx.Panel):
for id, name in cChar.getSkills(tree.GetPyData(root)):
iconId = self.skillBookImageId
childId = tree.AppendItem(root, name, iconId, data=wx.TreeItemData(id))
tree.SetItemText(childId, str(cChar.getSkillLevel(char, id)), 1)
level = cChar.getSkillLevel(char, id)
tree.SetItemText(childId, "Level %d" % level if isinstance(level, int) else level, 1)
tree.SortChildren(root)
def spawnMenu(self, event):
item = event.Item
self.skillTreeListCtrl.SelectItem(item)
if self.skillTreeListCtrl.GetChildrenCount(item) > 0:
return
cChar = controller.Character.getInstance()
charID = self.Parent.Parent.getActiveCharacter()
if cChar.getCharName(charID) not in ("All 0", "All 5"):
self.PopupMenu(self.levelChangeMenu)
def changeLevel(self, event):
cChar = controller.Character.getInstance()
charID = self.Parent.Parent.getActiveCharacter()
selection = self.skillTreeListCtrl.GetSelection()
skillID = self.skillTreeListCtrl.GetPyData(selection)
level = self.levelIds[event.Id]
self.skillTreeListCtrl.SetItemText(selection, "Level %d" % level if isinstance(level, int) else level, 1)
cChar.changeLevel(charID, skillID, level)
class ImplantsTreeView (wx.Panel):
def __init__(self, parent):
wx.Panel.__init__ (self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.Size(500, 300), style=wx.TAB_TRAVERSAL)