Implement copy and delete too

This commit is contained in:
cncfanatics
2010-09-07 22:31:00 +02:00
parent bee02f625e
commit 2488d2f52d
2 changed files with 27 additions and 2 deletions

View File

@@ -19,6 +19,7 @@
import eos.db
import eos.types
import copy
class Character():
instance = None
@@ -68,3 +69,13 @@ class Character():
def getCharName(self, charID):
return eos.db.getCharacter(charID).name
def copy(self, charID):
char = eos.db.getCharacter(charID)
newChar = copy.deepcopy(char)
eos.db.save(newChar)
return newChar.ID
def delete(self, charID):
char = eos.db.getCharacter(charID)
eos.db.remove(char)

View File

@@ -212,10 +212,24 @@ class CharacterEditor (wx.Dialog):
self.skillTreeChoice.SetSelection(selection)
def copy(self, event):
pass
cChar = controller.Character.getInstance()
charID = cChar.copy(self.getActiveCharacter())
id = self.skillTreeChoice.Append(cChar.getCharName(charID), charID)
self.skillTreeChoice.SetSelection(id)
self.btnDelete.Enable(True)
self.btnRename.Enable(True)
self.rename(event)
def delete(self, event):
pass
cChar = controller.Character.getInstance()
cChar.delete(self.getActiveCharacter())
sel = self.skillTreeChoice.GetSelection()
self.skillTreeChoice.Delete(sel)
self.skillTreeChoice.SetSelection(sel - 1)
newSelection = self.getActiveCharacter()
if cChar.getCharName(newSelection) in ("All 0", "All 5"):
self.btnDelete.Enable(False)
self.btnRename.Enable(False)
class SkillTreeView (wx.Panel):
def __init__(self, parent):