def SaveCharacterAs(parent, charID): sChar = Character.getInstance() name = sChar.getCharName(charID) dlg = TextEntryValidatedDialog(parent, CharacterTextValidor, "Enter a name for your new Character:", "Save Character As...") dlg.SetValue("{} Copy".format(name)) dlg.txtctrl.SetInsertionPointEnd() dlg.CenterOnParent() if dlg.ShowModal() == wx.ID_OK: sChar = Character.getInstance() return sChar.saveCharacterAs(charID, dlg.txtctrl.GetValue().strip())
def fitChanged(self, event): """ When fit is changed, or new fit is selected """ self.charChoice.Enable(event.fitID is not None) choice = self.charChoice sFit = Fit.getInstance() currCharID = choice.GetClientData(choice.GetCurrentSelection()) fit = sFit.getFit(event.fitID) newCharID = fit.character.ID if fit is not None else None if event.fitID is None: self.skillReqsStaticBitmap.SetBitmap(self.cleanSkills) self.skillReqsStaticBitmap.SetToolTip("No active fit") else: sCharacter = Character.getInstance() self.reqs = sCharacter.checkRequirements(fit) sCharacter.skillReqsDict = {'charname': fit.character.name, 'skills': []} if len(self.reqs) == 0: self.needsSkills = False tip = "All skill prerequisites have been met" self.skillReqsStaticBitmap.SetBitmap(self.greenSkills) else: self.needsSkills = True tip = "Skills required:\n" condensed = sFit.serviceFittingOptions["compactSkills"] if condensed: dict_ = self._buildSkillsTooltipCondensed(self.reqs, skillsMap={}) for key in sorted(dict_): tip += "%s: %d\n" % (key, dict_[key][0]) else: tip += self._buildSkillsTooltip(self.reqs) self.skillReqsStaticBitmap.SetBitmap(self.redSkills) self.skillReqsStaticBitmap.SetToolTip(tip.strip()) if newCharID is None: sChar = Character.getInstance() self.selectChar(sChar.all5ID()) elif currCharID != newCharID: self.selectChar(newCharID) if not fit.calculated: self.charChanged(None) self.toggleRefreshButton() event.Skip()
def populateSkillTree(self, event=None): sChar = Character.getInstance() char = self.charEditor.entityEditor.getActiveEntity() dirtyGroups = set([skill.item.group.ID for skill in char.dirtySkills]) if char.name in ("All 0", "All 5"): self.clonesChoice.Disable() self.btnSecStatus.Disable() else: self.clonesChoice.Enable() self.btnSecStatus.Enable() groups = sChar.getSkillGroups() root = self.root tree = self.skillTreeListCtrl tree.DeleteAllItems() for id, name in groups: imageId = self.skillBookImageId if id in dirtyGroups: imageId = self.skillBookDirtyImageId childId = tree.AppendItem(root, name, imageId, data=('group', id)) tree.AppendItem(childId, "dummy") if event: event.Skip()
def fetchSkills(self, event): charName = self.charChoice.GetString(self.charChoice.GetSelection()) if charName: sChar = Character.getInstance() activeChar = self.charEditor.entityEditor.getActiveEntity() sChar.apiFetch(activeChar.ID, charName, self.__fetchCallback) self.stStatus.SetLabel("Getting skills for {}".format(charName))
def charChanged(self, event): sChar = Character.getInstance() activeChar = self.charEditor.entityEditor.getActiveEntity() ID, key, char, chars = sChar.getApiDetails(activeChar.ID) self.inputID.SetValue(str(ID)) self.inputKey.SetValue(key) self.charChoice.Clear() if chars: for charName in chars: self.charChoice.Append(charName) self.charChoice.SetStringSelection(char) self.charChoice.Enable(True) self.btnFetchSkills.Enable(True) else: self.charChoice.Append("No characters...", 0) self.charChoice.SetSelection(0) self.charChoice.Enable(False) self.btnFetchSkills.Enable(False) if activeChar.name in ("All 0", "All 5"): self.Enable(False) self.stDisabledTip.Show() self.Layout() else: self.Enable() self.stDisabledTip.Hide() self.Layout() if event is not None: event.Skip()
def refreshCharacterList(self, event=None): choice = self.charChoice sChar = Character.getInstance() activeChar = self.getActiveCharacter() choice.Clear() charList = sorted(sChar.getCharacterList(), key=lambda c: (not c.ro, c.name)) picked = False for char in charList: currId = choice.Append(char.name, char.ID) if char.ID == activeChar: choice.SetSelection(currId) self.charChanged(None) picked = True if not picked: charID = sChar.all5ID() self.selectChar(charID) fitID = self.mainFrame.getActiveFit() sFit = Fit.getInstance() sFit.changeChar(fitID, charID) choice.Append(u"\u2015 Open Character Editor \u2015", -1) self.charCache = self.charChoice.GetCurrentSelection() if event is not None: event.Skip()
def _buildSkillsTooltipCondensed(self, reqs, currItem="", tabulationLevel=0, skillsMap=None): if skillsMap is None: skillsMap = {} sCharacter = Character.getInstance() if tabulationLevel == 0: for item, subReqs in reqs.iteritems(): skillsMap = self._buildSkillsTooltipCondensed(subReqs, item.name, 1, skillsMap) sorted(skillsMap, key=skillsMap.get) else: for name, info in reqs.iteritems(): level, ID, more = info sCharacter.skillReqsDict['skills'].append({ 'item': currItem, 'skillID': ID, 'skill': name, 'level': level, 'indent': tabulationLevel, }) if name not in skillsMap: skillsMap[name] = level elif skillsMap[name] < level: skillsMap[name] = level skillsMap = self._buildSkillsTooltipCondensed(more, currItem, tabulationLevel + 1, skillsMap) return skillsMap
def fitChanged(self, event): enable = event.fitID is not None self.Enable(wx.ID_SAVEAS, enable) self.Enable(wx.ID_COPY, enable) self.Enable(self.exportSkillsNeededId, enable) sChar = Character.getInstance() charID = self.mainFrame.charSelection.getActiveCharacter() char = sChar.getCharacter(charID) # enable/disable character saving stuff self.Enable(self.saveCharId, not char.ro and char.isDirty) self.Enable(self.saveCharAsId, char.isDirty) self.Enable(self.revertCharId, char.isDirty) self.Enable(self.toggleIgnoreRestrictionID, enable) if event.fitID: sFit = Fit.getInstance() fit = sFit.getFit(event.fitID) if fit.ignoreRestrictions: self.ignoreRestrictionItem.SetItemLabel("Enable Fitting Restrictions") else: self.ignoreRestrictionItem.SetItemLabel("Disable Fitting Restrictions") event.Skip()
def change(self, event): sChar = Character.getInstance() sChar.saveCharacterAs(self.charID, self.input.GetLineText(0)) wx.PostEvent(self.parent, GE.CharListUpdated()) event.Skip() self.Close()
def exportSkillsNeeded(self, event): """ Exports skills needed for active fit and active character """ sCharacter = Character.getInstance() saveDialog = wx.FileDialog( self, "Export Skills Needed As...", wildcard=("EVEMon skills training file (*.emp)|*.emp|" "EVEMon skills training XML file (*.xml)|*.xml|" "Text skills training file (*.txt)|*.txt"), style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT, ) if saveDialog.ShowModal() == wx.ID_OK: saveFmtInt = saveDialog.GetFilterIndex() if saveFmtInt == 0: # Per ordering of wildcards above saveFmt = "emp" elif saveFmtInt == 1: saveFmt = "xml" else: saveFmt = "txt" filePath = saveDialog.GetPath() if '.' not in os.path.basename(filePath): filePath += ".{0}".format(saveFmt) self.waitDialog = wx.BusyInfo("Exporting skills needed...") sCharacter.backupSkills(filePath, saveFmt, self.getActiveFit(), self.closeWaitDialog) saveDialog.Destroy()
def changeLevel(self, event): level = self.levelIds.get(event.Id) sChar = Character.getInstance() char = self.charEditor.entityEditor.getActiveEntity() selection = self.skillTreeListCtrl.GetSelection() skillID = self.skillTreeListCtrl.GetPyData(selection) if level is not None: self.skillTreeListCtrl.SetItemText(selection, "Level %d" % level if isinstance(level, int) else level, 1) sChar.changeLevel(char.ID, skillID, level, persist=True) elif event.Id == self.revertID: sChar.revertLevel(char.ID, skillID) elif event.Id == self.saveID: sChar.saveSkill(char.ID, skillID) self.skillTreeListCtrl.SetItemTextColour(selection, None) dirtySkills = sChar.getDirtySkills(char.ID) dirtyGroups = set([skill.item.group.ID for skill in dirtySkills]) parentID = self.skillTreeListCtrl.GetItemParent(selection) groupID = self.skillTreeListCtrl.GetPyData(parentID) if groupID not in dirtyGroups: self.skillTreeListCtrl.SetItemTextColour(parentID, None) event.Skip()
def __init__(self): self.pattern = DamagePattern.getInstance().getDamagePattern("Uniform") self.targetResists = None self.character = Character.getInstance().all5() self.booster = False self.dirtyFitIDs = set() serviceFittingDefaultOptions = { "useGlobalCharacter": False, "useGlobalDamagePattern": False, "defaultCharacter": self.character.ID, "useGlobalForceReload": False, "colorFitBySlot": False, "rackSlots": True, "rackLabels": True, "compactSkills": True, "showTooltip": True, "showMarketShortcuts": False, "enableGaugeAnimation": True, "exportCharges": True, "openFitInNew":False } self.serviceFittingOptions = SettingsProvider.getInstance().getSettings( "pyfaServiceFittingOptions", serviceFittingDefaultOptions)
def populateSkillTree(self, event=None): sChar = Character.getInstance() char = self.charEditor.entityEditor.getActiveEntity() dirtyGroups = set([skill.item.group.ID for skill in char.dirtySkills]) if char.name in ("All 0", "All 5"): self.clonesChoice.Disable() self.btnSecStatus.Disable() else: self.clonesChoice.Enable() self.btnSecStatus.Enable() groups = sChar.getSkillGroups() imageId = self.skillBookImageId root = self.root tree = self.skillTreeListCtrl tree.DeleteChildren(root) for id, name in groups: childId = tree.AppendItem(root, name, imageId) tree.SetPyData(childId, ('group', id)) tree.AppendItem(childId, "dummy") if id in dirtyGroups: tree.SetItemTextColour(childId, wx.BLUE) tree.SortChildren(root) if event: event.Skip()
def DoRename(self, entity, name): sChar = Character.getInstance() if entity.alphaCloneID: trimmed_name = re.sub('[ \(\u03B1\)]+$', '', name) sChar.rename(entity, trimmed_name) else: sChar.rename(entity, name)
def __init__(self): self.pattern = DamagePattern.getInstance().getDamagePattern("Uniform") self.character = Character.getInstance().all5() self.dirtyFitIDs = set() serviceFittingDefaultOptions = {"useGlobalCharacter": False, "useGlobalDamagePattern": False, "defaultCharacter": self.character.ID, "useGlobalForceReload": False} self.serviceFittingOptions = SettingsProvider.getInstance().getSettings("pyfaServiceFittingOptions", serviceFittingDefaultOptions)
def toggleRefreshButton(self): charID = self.getActiveCharacter() sChar = Character.getInstance() char = sChar.getCharacter(charID) if sChar.getCharName(charID) not in ("All 0", "All 5") and sChar.getSsoCharacter(char.ID) is not None: self.btnRefresh.Enable(True) else: self.btnRefresh.Enable(False)
def changeLevel(self, event): level = self.levelIds.get(event.Id) sChar = Character.getInstance() char = self.charEditor.entityEditor.getActiveEntity() selection = self.skillTreeListCtrl.GetSelection() dataType, skillID = self.skillTreeListCtrl.GetItemData(selection) if level is not None: sChar.changeLevel(char.ID, skillID, level, persist=True) elif event.Id == self.revertID: sChar.revertLevel(char.ID, skillID) elif event.Id == self.saveID: sChar.saveSkill(char.ID, skillID) # After saving the skill, we need to update not just the selected skill, but all open skills due to strict skill # level setting. We don't want to refresh tree, as that will lose all expanded categories and users location # within the tree. Thus, we loop through the tree and refresh the info. # @todo: when collapsing branch, remove the data. This will make this loop more performant child = self.skillTreeListCtrl.GetFirstChild(self.root) def _setTreeSkillLevel(treeItem, skillID): lvl, dirty = sChar.getSkillLevel(char.ID, skillID) self.skillTreeListCtrl.SetItemText(treeItem, 1, "Level {}".format(int(lvl)) if not isinstance(lvl, str) else lvl) if not dirty: self.skillTreeListCtrl.SetItemImage(treeItem, self.skillBookImageId) while child.IsOk(): # child = Skill category dataType, id = self.skillTreeListCtrl.GetItemData(child) if dataType == 'skill': _setTreeSkillLevel(child, id) else: grand = self.skillTreeListCtrl.GetFirstChild(child) while grand.IsOk(): if self.skillTreeListCtrl.GetItemText(grand) != "dummy": _, skillID = self.skillTreeListCtrl.GetItemData(grand) _setTreeSkillLevel(grand, skillID) grand = self.skillTreeListCtrl.GetNextSibling(grand) child = self.skillTreeListCtrl.GetNextSibling(child) dirtySkills = sChar.getDirtySkills(char.ID) dirtyGroups = set([skill.item.group.ID for skill in dirtySkills]) parentID = self.skillTreeListCtrl.GetItemParent(selection) parent = self.skillTreeListCtrl.GetItemData(parentID) if parent: if parent[1] in dirtyGroups: self.skillTreeListCtrl.SetItemImage(parentID, self.skillBookImageId) event.Skip()
def ssoCharChanged(self, event): sChar = Character.getInstance() activeChar = self.charEditor.entityEditor.getActiveEntity() ssoChar = self.getActiveCharacter() sChar.setSsoCharacter(activeChar.ID, ssoChar) self.fetchButton.Enable(ssoChar is not None) event.Skip()
def fetchSkills(self, event): charName = self.charChoice.GetString(self.charChoice.GetSelection()) if charName: try: sChar = Character.getInstance() activeChar = self.charEditor.entityEditor.getActiveEntity() sChar.apiFetch(activeChar.ID, charName) self.stStatus.SetLabel("Successfully fetched %s\'s skills from EVE API." % charName) except Exception, e: self.stStatus.SetLabel("Unable to retrieve %s\'s skills. Error message:\n%s" % (charName, e))
def refreshApi(self, event): sChar = Character.getInstance() ID, key, charName, chars = sChar.getApiDetails(self.getActiveCharacter()) if charName: try: sChar.apiFetch(self.getActiveCharacter(), charName) except: # can we do a popup, notifying user of API error? pass self.refreshCharacterList()
def changeChar(self, fitID, charID): if fitID is None or charID is None: if charID is not None: self.character = Character.getInstance().all5() return fit = eos.db.getFit(fitID) fit.character = self.character = eos.db.getCharacter(charID) self.recalc(fit)
def grantMissingSkills(self, evt): charID = self.getActiveCharacter() sChar = Character.getInstance() skillsMap = self._buildSkillsTooltipCondensed(self.reqs, skillsMap={}) for index in skillsMap: sChar.changeLevel(charID, skillsMap[index][1], skillsMap[index][0], ifHigher=True) self.refreshCharacterList()
def onSecStatus(self, event): sChar = Character.getInstance() char = self.charEditor.entityEditor.getActiveEntity() myDlg = SecStatusDialog(self, char.secStatus or 0.0) res = myDlg.ShowModal() if res == wx.ID_OK: value = myDlg.floatSpin.GetValue() sChar.setSecStatus(char, value) self.btnSecStatus.SetLabel("Sec Status: {0:.2f}".format(value)) myDlg.Destroy()
def changeChar(self, fitID, charID): pyfalog.debug("Changing character ({0}) for fit ID: {1}", charID, fitID) if fitID is None or charID is None: if charID is not None: self.character = Character.getInstance().all5() return fit = eos.db.getFit(fitID) fit.character = self.character = eos.db.getCharacter(charID) self.recalc(fit)
def fetchCharList(self, event): self.stStatus.SetLabel("") if self.inputID.GetLineText(0) == "" or self.inputKey.GetLineText(0) == "": self.stStatus.SetLabel("Invalid keyID or vCode!") return sChar = Character.getInstance() try: activeChar = self.charEditor.entityEditor.getActiveEntity() list = sChar.apiCharList(activeChar.ID, self.inputID.GetLineText(0), self.inputKey.GetLineText(0)) except AuthenticationError, e: self.stStatus.SetLabel("Authentication failure. Please check keyID and vCode combination.")
def display(self, srcContext, mainItem): if not self.settings.get('changeAffectingSkills'): return False if srcContext not in ( "fittingModule", "fittingCharge", "fittingShip", "droneItem", "fighterItem" ): return False fitID = self.mainFrame.getActiveFit() if fitID is None: return False if (mainItem is None or getattr(mainItem, "isEmpty", False)) and srcContext != "fittingShip": return False self.sChar = Character.getInstance() self.sFit = Fit.getInstance() fit = self.sFit.getFit(fitID) self.charID = fit.character.ID # if self.sChar.getCharName(self.charID) in ("All 0", "All 5"): # return False if srcContext == "fittingShip": sFit = Fit.getInstance() self.stuff = sFit.getFit(fitID).ship cont = sFit.getFit(fitID).ship.itemModifiedAttributes elif srcContext == "fittingCharge": cont = mainItem.chargeModifiedAttributes else: cont = mainItem.itemModifiedAttributes skills = set() for attrName in cont.iterAfflictions(): if cont[attrName] == 0: continue for fit, afflictors in cont.getAfflictions(attrName).items(): for afflictor, modifier, amount, used in afflictors: # only add Skills if not isinstance(afflictor, Skill): continue skills.add(afflictor) self.skills = sorted(skills, key=lambda x: x.item.name) return len(self.skills) > 0
def importCharacter(self, event): """ Imports character XML file from EVE API """ dlg = wx.FileDialog( self, "Open One Or More Character Files", wildcard="EVE API XML character files (*.xml)|*.xml|All Files (*)|*", style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE ) if dlg.ShowModal() == wx.ID_OK: self.waitDialog = wx.BusyInfo("Importing Character...") sCharacter = Character.getInstance() sCharacter.importCharacter(dlg.GetPaths(), self.importCharacterCallback)
def charChanged(self, event): sChar = Character.getInstance() sEsi = Esi.getInstance() activeChar = self.charEditor.entityEditor.getActiveEntity() if event and event.EventType == GE.EVT_SSO_LOGIN.typeId and hasattr(event, 'character'): # Automatically assign the character that was just logged into sChar.setSsoCharacter(activeChar.ID, event.character.ID) sso = sChar.getSsoCharacter(activeChar.ID) self.fetchButton.Enable(sso is not None) ssoChars = sEsi.getSsoCharacters() self.charChoice.Clear() noneID = self.charChoice.Append("None", None) for char in ssoChars: currId = self.charChoice.Append(char.characterName, char.ID) if sso is not None and char.ID == sso.ID: self.charChoice.SetSelection(currId) if sso is None: self.charChoice.SetSelection(noneID) # # if chars: # for charName in chars: # self.charChoice.Append(charName) # self.charChoice.SetStringSelection(char) # else: # self.charChoice.Append("No characters...", 0) # self.charChoice.SetSelection(0) # if activeChar.name in ("All 0", "All 5"): self.Enable(False) self.stDisabledTip.Show() self.Layout() else: self.Enable() self.stDisabledTip.Hide() self.Layout() if event is not None: event.Skip()
def getEntitiesFromContext(self): sChar = Character.getInstance() charList = sorted(sChar.getCharacterList(), key=lambda c: (not c.ro, c.name)) # Do some processing to ensure that we have All 0 and All 5 at the top all5 = sChar.all5() all0 = sChar.all0() charList.remove(all5) charList.remove(all0) charList.insert(0, all5) charList.insert(0, all0) return charList
def grantMissingSkills(self, evt): charID = self.getActiveCharacter() sChar = Character.getInstance() skillsMap = {} for item, stuff in self.reqs.iteritems(): for things in stuff.values(): if things[1] not in skillsMap: skillsMap[things[1]] = things[0] elif things[0] > skillsMap[things[1]]: skillsMap[things[1]] = things[0] for skillID, level in skillsMap.iteritems(): sChar.changeLevel(charID, skillID, level, ifHigher=True) self.refreshCharacterList()
def expandLookup(self, event): root = event.GetItem() tree = self.skillTreeListCtrl child = tree.GetFirstChild(root) if tree.GetItemText(child) == "dummy": tree.DeleteItem(child) # Get the real intrestin' stuff sChar = Character.getInstance() char = self.charEditor.entityEditor.getActiveEntity() data = tree.GetItemData(root) for id, name in sChar.getSkills(data[1]): iconId = self.skillBookImageId level, dirty = sChar.getSkillLevel(char.ID, id) if dirty: iconId = self.skillBookDirtyImageId childId = tree.AppendItem(root, name, iconId, data=('skill', id)) tree.SetItemText(childId, 1, "Level %d" % int(level) if isinstance(level, float) else level)
def _buildSkillsTooltipCondensed(self, reqs, currItem="", tabulationLevel=0, skillsMap=None): if skillsMap is None: skillsMap = {} sCharacter = Character.getInstance() if tabulationLevel == 0: for item, subReqs in reqs.items(): skillsMap = self._buildSkillsTooltipCondensed( subReqs, item.name, 1, skillsMap) else: for name, info in reqs.items(): level, ID, more = info sCharacter.skillReqsDict['skills'].append({ 'item': currItem, 'skillID': ID, 'skill': name, 'level': level, 'indent': tabulationLevel, }) if name not in skillsMap: skillsMap[name] = level, ID elif skillsMap[name][0] < level: skillsMap[name] = level, ID skillsMap = self._buildSkillsTooltipCondensed( more, currItem, tabulationLevel + 1, skillsMap) return skillsMap
def populateSkillTreeSkillSearch(self, event=None): sChar = Character.getInstance() char = self.charEditor.entityEditor.getActiveEntity() search = self.searchInput.GetLineText(0) root = self.root tree = self.skillTreeListCtrl tree.DeleteChildren(root) for id, name in sChar.getSkillsByName(search): iconId = self.skillBookImageId childId = tree.AppendItem(root, name, iconId, data=wx.TreeItemData(('skill', id))) level, dirty = sChar.getSkillLevel(char.ID, id) tree.SetItemText( childId, "Level %d" % int(level) if isinstance(level, float) else level, 1) if dirty: tree.SetItemTextColour(childId, wx.BLUE)
def _buildSkillsTooltip(self, reqs, currItem="", tabulationLevel=0): tip = "" sCharacter = Character.getInstance() if tabulationLevel == 0: for item, subReqs in reqs.items(): tip += "%s:\n" % item.name tip += self._buildSkillsTooltip(subReqs, item.name, 1) else: for name, info in reqs.items(): level, ID, more = info sCharacter.skillReqsDict['skills'].append({ 'item': currItem, 'skillID': ID, 'skill': name, 'level': level, 'indent': tabulationLevel, }) tip += "%s%s: %d\n" % (" " * tabulationLevel, name, level) tip += self._buildSkillsTooltip(more, currItem, tabulationLevel + 1) return tip
def __init__(self): self.pattern = DamagePattern.getInstance().getDamagePattern("Uniform") self.targetResists = None self.character = Character.getInstance().all5() self.booster = False self.dirtyFitIDs = set() serviceFittingDefaultOptions = { "useGlobalCharacter": False, "useGlobalDamagePattern": False, "defaultCharacter": self.character.ID, "useGlobalForceReload": False, "colorFitBySlot": False, "rackSlots": True, "rackLabels": True, "compactSkills": True, "showTooltip": True, "showMarketShortcuts": False, "enableGaugeAnimation": True, "exportCharges": True} self.serviceFittingOptions = SettingsProvider.getInstance().getSettings( "pyfaServiceFittingOptions", serviceFittingDefaultOptions)
def expandLookup(self, event): root = event.Item tree = self.skillTreeListCtrl child, cookie = tree.GetFirstChild(root) if tree.GetItemText(child) == "dummy": tree.Delete(child) # Get the real intrestin' stuff sChar = Character.getInstance() char = self.charEditor.entityEditor.getActiveEntity() for id, name in sChar.getSkills(tree.GetPyData(root)): iconId = self.skillBookImageId childId = tree.AppendItem(root, name, iconId, data=wx.TreeItemData(id)) level, dirty = sChar.getSkillLevel(char.ID, id) tree.SetItemText( childId, "Level %d" % level if isinstance(level, int) else level, 1) if dirty: tree.SetItemTextColour(childId, wx.BLUE) tree.SortChildren(root)
def __init__(self, parent): wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL) self.charEditor = self.Parent.Parent # first parent is Notebook, second is Character Editor self.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) pmainSizer = wx.BoxSizer(wx.VERTICAL) hSizer = wx.BoxSizer(wx.HORIZONTAL) self.clonesChoice = wx.Choice(self, wx.ID_ANY, style=0) i = self.clonesChoice.Append("Omega Clone", None) self.clonesChoice.SetSelection(i) hSizer.Add(self.clonesChoice, 5, wx.ALL | wx.EXPAND, 5) self.searchInput = PlaceholderTextCtrl(self, wx.ID_ANY, placeholder="Search...") hSizer.Add(self.searchInput, 1, wx.ALL | wx.EXPAND, 5) self.searchInput.Bind(wx.EVT_TEXT, self.delaySearch) sChar = Character.getInstance() self.alphaClones = sChar.getAlphaCloneList() char = self.charEditor.entityEditor.getActiveEntity() for clone in self.alphaClones: i = self.clonesChoice.Append(clone.alphaCloneName, clone.ID) if clone.ID == char.alphaCloneID: self.clonesChoice.SetSelection(i) self.clonesChoice.Bind(wx.EVT_CHOICE, self.cloneChanged) self.clonesChoice.SetToolTip( wx.ToolTip( "Setting an Alpha clone does not replace the character's skills, but rather caps them to Alpha levels." )) pmainSizer.Add(hSizer, 0, wx.EXPAND | wx.ALL, 5) # Set up timer for skill search self.searchTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.populateSkillTreeSkillSearch, self.searchTimer) tree = self.skillTreeListCtrl = wx.gizmos.TreeListCtrl( self, wx.ID_ANY, style=wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT) pmainSizer.Add(tree, 1, wx.EXPAND | wx.ALL, 5) self.imageList = wx.ImageList(16, 16) tree.SetImageList(self.imageList) self.skillBookImageId = self.imageList.Add( BitmapLoader.getBitmap("skill_small", "gui")) tree.AddColumn("Skill") tree.AddColumn("Level") tree.SetMainColumn(0) self.root = tree.AddRoot("Skills") tree.SetItemText(self.root, "Levels", 1) tree.SetColumnWidth(0, 500) self.btnSecStatus = wx.Button( self, wx.ID_ANY, "Sec Status: {0:.2f}".format(char.secStatus or 0.0)) self.btnSecStatus.Bind(wx.EVT_BUTTON, self.onSecStatus) self.populateSkillTree() tree.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.expandLookup) tree.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.scheduleMenu) bSizerButtons = wx.BoxSizer(wx.HORIZONTAL) bSizerButtons.Add(self.btnSecStatus, 0, wx.ALL, 5) pmainSizer.Add(bSizerButtons, 0, wx.EXPAND, 5) # bind the Character selection event self.charEditor.entityEditor.Bind(wx.EVT_CHOICE, self.charChanged) self.charEditor.Bind(GE.CHAR_LIST_UPDATED, self.populateSkillTree) srcContext = "skillItem" itemContext = "Skill" context = (srcContext, itemContext) self.statsMenu = ContextMenu.getMenu(None, context) self.levelChangeMenu = ContextMenu.getMenu(None, context) or wx.Menu() self.levelChangeMenu.AppendSeparator() 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.AppendSeparator() self.revertID = wx.NewId() self.levelChangeMenu.Append(self.revertID, "Revert") self.saveID = wx.NewId() self.levelChangeMenu.Append(self.saveID, "Save") self.levelChangeMenu.Bind(wx.EVT_MENU, self.changeLevel) self.SetSizer(pmainSizer) self.Layout()
def revertChar(self, event): sChr = Character.getInstance() char = self.entityEditor.getActiveEntity() sChr.revertCharacter(char.ID) wx.PostEvent(self, GE.CharListUpdated())
def DoDelete(self, entity): sChar = Character.getInstance() sChar.delete(entity)
def DoCopy(self, entity, name): sChar = Character.getInstance() copy = sChar.copy(entity) sChar.rename(copy, name) return copy
def __init__(self, parent): wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL) self.charEditor = self.Parent.Parent # first parent is Notebook, second is Character Editor self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)) pmainSizer = wx.BoxSizer(wx.VERTICAL) hSizer = wx.BoxSizer(wx.HORIZONTAL) self.clonesChoice = wx.Choice(self, wx.ID_ANY, style=0) i = self.clonesChoice.Append("Omega Clone", None) self.clonesChoice.SetSelection(i) hSizer.Add(self.clonesChoice, 5, wx.ALL | wx.EXPAND, 5) self.searchInput = PlaceholderTextCtrl(self, wx.ID_ANY, placeholder="Search...") hSizer.Add(self.searchInput, 1, wx.ALL | wx.EXPAND, 5) self.searchInput.Bind(wx.EVT_TEXT, self.delaySearch) sChar = Character.getInstance() self.alphaClones = sChar.getAlphaCloneList() char = self.charEditor.entityEditor.getActiveEntity() for clone in self.alphaClones: i = self.clonesChoice.Append(clone.alphaCloneName, clone.ID) if clone.ID == char.alphaCloneID: self.clonesChoice.SetSelection(i) self.clonesChoice.Bind(wx.EVT_CHOICE, self.cloneChanged) self.clonesChoice.SetToolTip( wx.ToolTip("Setting an Alpha clone does not replace the character's skills, but rather caps them to Alpha levels.")) pmainSizer.Add(hSizer, 0, wx.EXPAND | wx.ALL, 5) # Set up timer for skill search self.searchTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.populateSkillTreeSkillSearch, self.searchTimer) tree = self.skillTreeListCtrl = TreeListCtrl(self, wx.ID_ANY, style=wx.dataview.TL_DEFAULT_STYLE) pmainSizer.Add(tree, 1, wx.EXPAND | wx.ALL, 5) self.imageList = wx.ImageList(16, 16) tree.SetImageList(self.imageList) self.skillBookImageId = self.imageList.Add(wx.Icon(BitmapLoader.getBitmap("skill_small", "gui"))) self.skillBookDirtyImageId = self.imageList.Add(wx.Icon(BitmapLoader.getBitmap("skill_small_red", "gui"))) tree.AppendColumn("Skill") tree.AppendColumn("Level", align=wx.ALIGN_CENTER) # tree.SetMainColumn(0) self.root = tree.GetRootItem() # self.root = tree.AppendItem(root, "Skills") # # tree.SetItemText(self.root, 1, "Levels") # first one doesn't work right in Windows. Second one doesn't work right in GTK. Together, we make sure it works. # Gotta love wx tree.SetColumnWidth(0, 525) tree.SetColumnWidth(1, 100) self.btnSecStatus = wx.Button(self, wx.ID_ANY, "Sec Status: {0:.2f}".format(char.secStatus or 0.0)) self.btnSecStatus.Bind(wx.EVT_BUTTON, self.onSecStatus) self.populateSkillTree() tree.Bind(wx.dataview.EVT_TREELIST_ITEM_ACTIVATED, self.expand) tree.Bind(wx.dataview.EVT_TREELIST_ITEM_EXPANDING, self.expandLookup) tree.Bind(wx.dataview.EVT_TREELIST_ITEM_CONTEXT_MENU, self.spawnMenu) bSizerButtons = wx.BoxSizer(wx.HORIZONTAL) bSizerButtons.Add(self.btnSecStatus, 0, wx.ALL, 5) bSizerButtons.AddStretchSpacer() importExport = (("Import", wx.ART_FILE_OPEN, "from"), ("Export", wx.ART_FILE_SAVE_AS, "to")) for name, art, direction in importExport: bitmap = wx.ArtProvider.GetBitmap(art, wx.ART_BUTTON) btn = wx.BitmapButton(self, wx.ID_ANY, bitmap) btn.SetMinSize(btn.GetSize()) btn.SetMaxSize(btn.GetSize()) btn.Layout() setattr(self, "{}Btn".format(name.lower()), btn) btn.Enable(True) btn.SetToolTip("%s skills %s clipboard" % (name, direction)) bSizerButtons.Add(btn, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_RIGHT | wx.ALL, 5) btn.Bind(wx.EVT_BUTTON, getattr(self, "{}Skills".format(name.lower()))) pmainSizer.Add(bSizerButtons, 0, wx.EXPAND, 5) # bind the Character selection event self.charEditor.entityEditor.Bind(wx.EVT_CHOICE, self.charChanged) self.charEditor.Bind(GE.CHAR_LIST_UPDATED, self.populateSkillTree) # Context menu stuff self.idUnlearned = wx.NewId() self.levelIds = {} self.idLevels = {} self.levelIds[self.idUnlearned] = "Not learned" for level in range(6): id = wx.NewId() self.levelIds[id] = level self.idLevels[level] = id self.revertID = wx.NewId() self.saveID = wx.NewId() self.SetSizer(pmainSizer)
def refreshApi(self, event): self.btnRefresh.Enable(False) sChar = Character.getInstance() ID, key, charName, chars = sChar.getApiDetails(self.getActiveCharacter()) if charName: sChar.apiFetch(self.getActiveCharacter(), charName, self.refreshAPICallback)
def addImplantToContext(self, item): sChar = Character.getInstance() char = self.Parent.Parent.entityEditor.getActiveEntity() sChar.addImplant(char.ID, item.ID)
def refreshApi(self, event): self.btnRefresh.Enable(False) sChar = Character.getInstance() sChar.apiFetch(self.getActiveCharacter(), self.refreshAPICallback)
def changeLevel(self, event): level = self.levelIds.get(event.Id) sChar = Character.getInstance() char = self.charEditor.entityEditor.getActiveEntity() if char.name in ("All 0", "All 5"): return selection = self.skillTreeListCtrl.GetSelection() dataType, skillID = self.skillTreeListCtrl.GetItemData(selection) if level is not None: sChar.changeLevel(char.ID, skillID, level, persist=True) elif event.Id == self.revertID: sChar.revertLevel(char.ID, skillID) elif event.Id == self.saveID: sChar.saveSkill(char.ID, skillID) # After saving the skill, we need to update not just the selected skill, but all open skills due to strict skill # level setting. We don't want to refresh tree, as that will lose all expanded categories and users location # within the tree. Thus, we loop through the tree and refresh the info. # @todo: when collapsing branch, remove the data. This will make this loop more performant child = self.skillTreeListCtrl.GetFirstChild(self.root) def _setTreeSkillLevel(treeItem, skillID): lvl, dirty = sChar.getSkillLevel(char.ID, skillID) self.skillTreeListCtrl.SetItemText( treeItem, 1, "Level {}".format(int(lvl)) if not isinstance(lvl, str) else lvl) if not dirty: self.skillTreeListCtrl.SetItemImage(treeItem, self.skillBookImageId) while child.IsOk(): # child = Skill category dataType, id = self.skillTreeListCtrl.GetItemData(child) if dataType == 'skill': _setTreeSkillLevel(child, id) else: grand = self.skillTreeListCtrl.GetFirstChild(child) while grand.IsOk(): if self.skillTreeListCtrl.GetItemText(grand) != "dummy": _, skillID = self.skillTreeListCtrl.GetItemData(grand) _setTreeSkillLevel(grand, skillID) grand = self.skillTreeListCtrl.GetNextSibling(grand) child = self.skillTreeListCtrl.GetNextSibling(child) dirtySkills = sChar.getDirtySkills(char.ID) dirtyGroups = set([skill.item.group.ID for skill in dirtySkills]) parentID = self.skillTreeListCtrl.GetItemParent(selection) parent = self.skillTreeListCtrl.GetItemData(parentID) if parent: if parent[1] in dirtyGroups: self.skillTreeListCtrl.SetItemImage(parentID, self.skillBookImageId) event.Skip()
def revertChar(self, event): sChr = Character.getInstance() charID = self.charSelection.getActiveCharacter() sChr.revertCharacter(charID) wx.PostEvent(self, GE.CharListUpdated())
def ssoCharChanged(self, event): sChar = Character.getInstance() activeChar = self.charEditor.entityEditor.getActiveEntity() sChar.setSsoCharacter(activeChar.ID, self.getActiveCharacter()) event.Skip()
def cloneChanged(self, event): sChar = Character.getInstance() sChar.setAlphaClone(self.charEditor.entityEditor.getActiveEntity(), event.ClientData) self.populateSkillTree()
def getImplantsFromContext(self): sChar = Character.getInstance() char = self.Parent.Parent.entityEditor.getActiveEntity() return sChar.getImplants(char.ID)
def DoNew(self, name): sChar = Character.getInstance() return sChar.new(name)
def removeImplantFromContext(self, implant): sChar = Character.getInstance() char = self.Parent.Parent.entityEditor.getActiveEntity() sChar.removeImplant(char.ID, implant)
def DoRename(self, entity, name): sChar = Character.getInstance() sChar.rename(entity, name)
def __init__(self, parent): wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.TAB_TRAVERSAL) self.charEditor = self.Parent.Parent # first parent is Notebook, second is Character Editor self.SetBackgroundColour( wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) pmainSizer = wx.BoxSizer(wx.VERTICAL) self.clonesChoice = wx.Choice(self, wx.ID_ANY, style=0) i = self.clonesChoice.Append("Omega Clone", None) self.clonesChoice.SetSelection(i) pmainSizer.Add(self.clonesChoice, 0, wx.ALL | wx.EXPAND, 5) sChar = Character.getInstance() self.alphaClones = sChar.getAlphaCloneList() char = self.charEditor.entityEditor.getActiveEntity() for clone in self.alphaClones: i = self.clonesChoice.Append(clone.alphaCloneName, clone.ID) if clone.ID == char.alphaCloneID: self.clonesChoice.SetSelection(i) self.clonesChoice.Bind(wx.EVT_CHOICE, self.cloneChanged) tree = self.skillTreeListCtrl = wx.gizmos.TreeListCtrl( self, wx.ID_ANY, style=wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT) pmainSizer.Add(tree, 1, wx.EXPAND | wx.ALL, 5) self.imageList = wx.ImageList(16, 16) tree.SetImageList(self.imageList) self.skillBookImageId = self.imageList.Add( BitmapLoader.getBitmap("skill_small", "gui")) tree.AddColumn("Skill") tree.AddColumn("Level") tree.SetMainColumn(0) self.root = tree.AddRoot("Skills") tree.SetItemText(self.root, "Levels", 1) tree.SetColumnWidth(0, 500) self.populateSkillTree() tree.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.expandLookup) tree.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.scheduleMenu) # bind the Character selection event self.charEditor.entityEditor.Bind(wx.EVT_CHOICE, self.charChanged) self.charEditor.Bind(GE.CHAR_LIST_UPDATED, self.populateSkillTree) srcContext = "skillItem" itemContext = "Skill" context = (srcContext, itemContext) self.statsMenu = ContextMenu.getMenu(None, context) self.levelChangeMenu = ContextMenu.getMenu(None, context) or wx.Menu() self.levelChangeMenu.AppendSeparator() 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.AppendSeparator() self.revertID = wx.NewId() self.levelChangeMenu.Append(self.revertID, "Revert") self.saveID = wx.NewId() self.levelChangeMenu.Append(self.saveID, "Save") self.levelChangeMenu.Bind(wx.EVT_MENU, self.changeLevel) self.SetSizer(pmainSizer) self.Layout()
def fetchSkills(self, evt): sChar = Character.getInstance() char = self.charEditor.entityEditor.getActiveEntity() sChar.apiFetch(char.ID, self.__fetchCallback)