| 714 | |
| 715 | |
| 716 | class ImplantEditorView(BaseImplantEditorView): |
| 717 | def __init__(self, parent, charEditor): |
| 718 | BaseImplantEditorView.__init__(self, parent) |
| 719 | |
| 720 | self.determineEnabled() |
| 721 | charEditor.Bind(GE.CHAR_CHANGED, self.contextChanged) |
| 722 | |
| 723 | self.pluggedImplantsTree.Bind(wx.EVT_CONTEXT_MENU, self.spawnMenu) |
| 724 | |
| 725 | def bindContext(self): |
| 726 | self.Parent.Parent.entityEditor.Bind(wx.EVT_CHOICE, self.contextChanged) |
| 727 | |
| 728 | def contextChanged(self, event): |
| 729 | BaseImplantEditorView.contextChanged(self, event) |
| 730 | self.determineEnabled() |
| 731 | |
| 732 | def getImplantsFromContext(self): |
| 733 | sChar = Character.getInstance() |
| 734 | char = self.Parent.Parent.entityEditor.getActiveEntity() |
| 735 | |
| 736 | return sChar.getImplants(char.ID) |
| 737 | |
| 738 | def addImplantToContext(self, item): |
| 739 | sChar = Character.getInstance() |
| 740 | char = self.Parent.Parent.entityEditor.getActiveEntity() |
| 741 | |
| 742 | sChar.addImplant(char.ID, item.ID) |
| 743 | |
| 744 | def removeImplantFromContext(self, implant): |
| 745 | sChar = Character.getInstance() |
| 746 | char = self.Parent.Parent.entityEditor.getActiveEntity() |
| 747 | |
| 748 | sChar.removeImplant(char.ID, implant) |
| 749 | |
| 750 | def addImplants(self, implants): |
| 751 | charEditor = self.Parent.Parent |
| 752 | char = charEditor.entityEditor.getActiveEntity() |
| 753 | |
| 754 | sChar = Character.getInstance() |
| 755 | for implant in implants: |
| 756 | sChar.addImplant(char.ID, implant.item.ID) |
| 757 | |
| 758 | wx.PostEvent(charEditor, GE.CharChanged()) |
| 759 | |
| 760 | def spawnMenu(self, event): |
| 761 | context = (("implantEditor",),) |
| 762 | menu = ContextMenu.getMenu(self, None, None, *context) |
| 763 | |
| 764 | if menu: |
| 765 | self.PopupMenu(menu) |
| 766 | else: |
| 767 | pyfalog.debug("ContextMenu.getMenu returned false do not attempt PopupMenu") |
| 768 | |
| 769 | def determineEnabled(self): |
| 770 | char = self.Parent.Parent.entityEditor.getActiveEntity() |
| 771 | |
| 772 | if char.name in ("All 0", "All 5"): |
| 773 | self.Enable(False) |