From 253d3107a04798b364f1a59b6b032f4ec37f73c1 Mon Sep 17 00:00:00 2001 From: Ryan Holmes Date: Sun, 24 Mar 2019 18:55:25 -0400 Subject: [PATCH 01/15] First pass at cleaning up context menu events (#1895) --- gui/builtinAdditionPanes/boosterView.py | 12 ++---------- gui/builtinAdditionPanes/cargoView.py | 12 ++---------- gui/builtinAdditionPanes/commandView.py | 13 ++----------- gui/builtinAdditionPanes/droneView.py | 12 ++---------- gui/builtinAdditionPanes/fighterView.py | 12 ++---------- gui/builtinAdditionPanes/implantView.py | 12 ++---------- gui/builtinAdditionPanes/projectedView.py | 13 ++----------- gui/builtinViews/fittingView.py | 13 ++----------- 8 files changed, 16 insertions(+), 83 deletions(-) diff --git a/gui/builtinAdditionPanes/boosterView.py b/gui/builtinAdditionPanes/boosterView.py index e050d853a..da2bf2daa 100644 --- a/gui/builtinAdditionPanes/boosterView.py +++ b/gui/builtinAdditionPanes/boosterView.py @@ -69,10 +69,7 @@ class BoosterView(d.Display): self.SetDropTarget(BoosterViewDrop(self.handleListDrag)) - if "__WXGTK__" in wx.PlatformInfo: - self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu) - else: - self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu) + self.Bind(wx.EVT_CONTEXT_MENU, self.spawnMenu) def handleListDrag(self, x, y, data): """ @@ -163,12 +160,7 @@ class BoosterView(d.Display): fitID = self.mainFrame.getActiveFit() self.mainFrame.command.Submit(cmd.GuiToggleBoosterCommand(fitID, row)) - def scheduleMenu(self, event): - event.Skip() - if self.getColumn(event.Position) != self.getColIndex(State): - wx.CallAfter(self.spawnMenu) - - def spawnMenu(self): + def spawnMenu(self, event): sel = self.GetFirstSelected() if sel != -1: sFit = Fit.getInstance() diff --git a/gui/builtinAdditionPanes/cargoView.py b/gui/builtinAdditionPanes/cargoView.py index 29721603c..cc6958f5d 100644 --- a/gui/builtinAdditionPanes/cargoView.py +++ b/gui/builtinAdditionPanes/cargoView.py @@ -64,10 +64,7 @@ class CargoView(d.Display): self.SetDropTarget(CargoViewDrop(self.handleListDrag)) self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag) - if "__WXGTK__" in wx.PlatformInfo: - self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu) - else: - self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu) + self.Bind(wx.EVT_CONTEXT_MENU, self.spawnMenu) def handleListDrag(self, x, y, data): """ @@ -180,12 +177,7 @@ class CargoView(d.Display): sFit.removeCargo(fitID, self.original.index(cargo)) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) - def scheduleMenu(self, event): - event.Skip() - if self.getColumn(event.Position) != self.getColIndex(State): - wx.CallAfter(self.spawnMenu) - - def spawnMenu(self): + def spawnMenu(self,event): sel = self.GetFirstSelected() if sel != -1: sFit = Fit.getInstance() diff --git a/gui/builtinAdditionPanes/commandView.py b/gui/builtinAdditionPanes/commandView.py index ce73e06b8..9b1fb1d0c 100644 --- a/gui/builtinAdditionPanes/commandView.py +++ b/gui/builtinAdditionPanes/commandView.py @@ -72,16 +72,12 @@ class CommandView(d.Display): self.mainFrame.Bind(EVT_FIT_REMOVED, CommandFits.populateFits) self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged) self.Bind(wx.EVT_LEFT_DOWN, self.click) - self.Bind(wx.EVT_RIGHT_DOWN, self.click) self.Bind(wx.EVT_LEFT_DCLICK, self.remove) self.Bind(wx.EVT_KEY_UP, self.kbEvent) self.droneView = gui.builtinAdditionPanes.droneView.DroneView - if "__WXGTK__" in wx.PlatformInfo: - self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu) - else: - self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu) + self.Bind(wx.EVT_RIGHT_UP, self.spawnMenu) self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag) self.SetDropTarget(CommandViewDrop(self.handleListDrag)) @@ -188,12 +184,7 @@ class CommandView(d.Display): fitID = self.mainFrame.getActiveFit() self.mainFrame.command.Submit(cmd.GuiToggleCommandCommand(fitID, item.ID)) - def scheduleMenu(self, event): - event.Skip() - if self.getColumn(event.Position) != self.getColIndex(State): - wx.CallAfter(self.spawnMenu) - - def spawnMenu(self): + def spawnMenu(self, event): fitID = self.mainFrame.getActiveFit() if fitID is None: return diff --git a/gui/builtinAdditionPanes/droneView.py b/gui/builtinAdditionPanes/droneView.py index 9da438953..fe509f0b3 100644 --- a/gui/builtinAdditionPanes/droneView.py +++ b/gui/builtinAdditionPanes/droneView.py @@ -78,10 +78,7 @@ class DroneView(Display): self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow) - if "__WXGTK__" in wx.PlatformInfo: - self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu) - else: - self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu) + self.Bind(wx.EVT_CONTEXT_MENU, self.spawnMenu) self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag) self.SetDropTarget(DroneViewDrop(self.handleDragDrop)) @@ -242,12 +239,7 @@ class DroneView(Display): drone = self.drones[row] self.mainFrame.command.Submit(cmd.GuiToggleDroneCommand(fitID, self.original.index(drone))) - def scheduleMenu(self, event): - event.Skip() - if self.getColumn(event.Position) != self.getColIndex(State): - wx.CallAfter(self.spawnMenu) - - def spawnMenu(self): + def spawnMenu(self, event): sel = self.GetFirstSelected() if sel != -1: drone = self.drones[sel] diff --git a/gui/builtinAdditionPanes/fighterView.py b/gui/builtinAdditionPanes/fighterView.py index f9025851b..5be649ac9 100644 --- a/gui/builtinAdditionPanes/fighterView.py +++ b/gui/builtinAdditionPanes/fighterView.py @@ -142,10 +142,7 @@ class FighterDisplay(d.Display): self.Bind(wx.EVT_MOTION, self.OnMouseMove) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow) - if "__WXGTK__" in wx.PlatformInfo: - self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu) - else: - self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu) + self.Bind(wx.EVT_CONTEXT_MENU, self.spawnMenu) self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag) self.SetDropTarget(FighterViewDrop(self.handleDragDrop)) @@ -289,12 +286,7 @@ class FighterDisplay(d.Display): fighter = self.fighters[row] self.mainFrame.command.Submit(cmd.GuiToggleFighterCommand(fitID, self.original.index(fighter))) - def scheduleMenu(self, event): - event.Skip() - if self.getColumn(event.Position) != self.getColIndex(State): - wx.CallAfter(self.spawnMenu) - - def spawnMenu(self): + def spawnMenu(self, event): sel = self.GetFirstSelected() if sel != -1: fighter = self.fighters[sel] diff --git a/gui/builtinAdditionPanes/implantView.py b/gui/builtinAdditionPanes/implantView.py index 84c437ea3..b28a3b6c5 100644 --- a/gui/builtinAdditionPanes/implantView.py +++ b/gui/builtinAdditionPanes/implantView.py @@ -118,11 +118,8 @@ class ImplantDisplay(d.Display): self.Bind(wx.EVT_KEY_UP, self.kbEvent) self.SetDropTarget(ImplantViewDrop(self.handleListDrag)) + self.Bind(wx.EVT_CONTEXT_MENU, self.spawnMenu) - if "__WXGTK__" in wx.PlatformInfo: - self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu) - else: - self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu) def handleListDrag(self, x, y, data): """ @@ -223,12 +220,7 @@ class ImplantDisplay(d.Display): fitID = self.mainFrame.getActiveFit() self.mainFrame.command.Submit(cmd.GuiToggleImplantCommand(fitID, row)) - def scheduleMenu(self, event): - event.Skip() - if self.getColumn(event.Position) != self.getColIndex(State): - wx.CallAfter(self.spawnMenu) - - def spawnMenu(self): + def spawnMenu(self, event): sel = self.GetFirstSelected() menu = None diff --git a/gui/builtinAdditionPanes/projectedView.py b/gui/builtinAdditionPanes/projectedView.py index 59d046761..1457fcb37 100644 --- a/gui/builtinAdditionPanes/projectedView.py +++ b/gui/builtinAdditionPanes/projectedView.py @@ -78,16 +78,12 @@ class ProjectedView(d.Display): self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged) self.Bind(wx.EVT_LEFT_DOWN, self.click) - self.Bind(wx.EVT_RIGHT_DOWN, self.click) self.Bind(wx.EVT_LEFT_DCLICK, self.remove) self.Bind(wx.EVT_KEY_UP, self.kbEvent) self.droneView = gui.builtinAdditionPanes.droneView.DroneView - if "__WXGTK__" in wx.PlatformInfo: - self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu) - else: - self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu) + self.Bind(wx.EVT_CONTEXT_MENU, self.spawnMenu) self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag) self.SetDropTarget(ProjectedViewDrop(self.handleListDrag)) @@ -271,12 +267,7 @@ class ProjectedView(d.Display): sFit.toggleProjected(fitID, item, "right" if event.Button == 3 else "left") wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID)) - def scheduleMenu(self, event): - event.Skip() - if self.getColumn(event.Position) != self.getColIndex(State): - wx.CallAfter(self.spawnMenu) - - def spawnMenu(self): + def spawnMenu(self, event): fitID = self.mainFrame.getActiveFit() if fitID is None: return diff --git a/gui/builtinViews/fittingView.py b/gui/builtinViews/fittingView.py index 9801f4af0..f60159daf 100644 --- a/gui/builtinViews/fittingView.py +++ b/gui/builtinViews/fittingView.py @@ -153,10 +153,7 @@ class FittingView(d.Display): self.Bind(wx.EVT_LEFT_DCLICK, self.removeItem) self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.startDrag) - if "__WXGTK__" in wx.PlatformInfo: - self.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu) - else: - self.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu) + self.Bind(wx.EVT_CONTEXT_MENU, self.spawnMenu) self.SetDropTarget(FittingViewDrop(self.handleListDrag)) self.activeFitID = None @@ -168,7 +165,6 @@ class FittingView(d.Display): self.Bind(wx.EVT_KEY_UP, self.kbEvent) self.Bind(wx.EVT_LEFT_DOWN, self.click) - self.Bind(wx.EVT_RIGHT_DOWN, self.click) self.Bind(wx.EVT_MIDDLE_DOWN, self.click) self.Bind(wx.EVT_SHOW, self.OnShow) self.Bind(wx.EVT_MOTION, self.OnMouseMove) @@ -535,12 +531,7 @@ class FittingView(d.Display): finally: event.Skip() - def scheduleMenu(self, event): - event.Skip() - if self.getColumn(event.Position) != self.getColIndex(State): - wx.CallAfter(self.spawnMenu) - - def spawnMenu(self): + def spawnMenu(self, event): if self.activeFitID is None: return From a9a9fd1b1a2dd622c9c9997e21ad41f281c221fa Mon Sep 17 00:00:00 2001 From: Ryan Holmes Date: Sun, 24 Mar 2019 19:08:31 -0400 Subject: [PATCH 02/15] Clean up another context menu --- gui/characterEditor.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/gui/characterEditor.py b/gui/characterEditor.py index 60dbcd3e5..a7a66ca97 100644 --- a/gui/characterEditor.py +++ b/gui/characterEditor.py @@ -677,10 +677,7 @@ class ImplantEditorView(BaseImplantEditorView): self.determineEnabled() charEditor.Bind(GE.CHAR_CHANGED, self.contextChanged) - if "__WXGTK__" in wx.PlatformInfo: - self.pluggedImplantsTree.Bind(wx.EVT_RIGHT_UP, self.scheduleMenu) - else: - self.pluggedImplantsTree.Bind(wx.EVT_RIGHT_DOWN, self.scheduleMenu) + self.pluggedImplantsTree.Bind(wx.EVT_CONTEXT_MENU, self.spawnMenu) def bindContext(self): self.Parent.Parent.entityEditor.Bind(wx.EVT_CHOICE, self.contextChanged) @@ -707,11 +704,7 @@ class ImplantEditorView(BaseImplantEditorView): sChar.removeImplant(char.ID, implant) - def scheduleMenu(self, event): - event.Skip() - wx.CallAfter(self.spawnMenu) - - def spawnMenu(self): + def spawnMenu(self, event): context = (("implantEditor",),) # fuck good coding practices, passing a pointer to the character editor here for [reasons] =D # (see implantSets context class for info) From 9c79fb666b58e937e25f9b75e44a5f4b36c1af64 Mon Sep 17 00:00:00 2001 From: Ryan Holmes Date: Sun, 24 Mar 2019 19:24:46 -0400 Subject: [PATCH 03/15] Convert context menu spawning of "affected by" listing --- gui/builtinItemStatsViews/itemAffectedBy.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/gui/builtinItemStatsViews/itemAffectedBy.py b/gui/builtinItemStatsViews/itemAffectedBy.py index 94808b734..cd25df1a9 100644 --- a/gui/builtinItemStatsViews/itemAffectedBy.py +++ b/gui/builtinItemStatsViews/itemAffectedBy.py @@ -65,13 +65,10 @@ class ItemAffectedBy(wx.Panel): self.SetSizer(mainSizer) self.PopulateTree() self.Layout() - self.affectedBy.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.scheduleMenu) + self.affectedBy.Bind(wx.EVT_CONTEXT_MENU, self.spawnMenu) - def scheduleMenu(self, event): - event.Skip() - wx.CallAfter(self.spawnMenu, event.Item) - - def spawnMenu(self, item): + def spawnMenu(self, event): + item, _ = self.affectedBy.HitTest(self.ScreenToClient(event.Position)) self.affectedBy.SelectItem(item) stuff = self.affectedBy.GetItemData(item) From f95420d7bf48d68b026fbb3a5eda1fd8a0e75aca Mon Sep 17 00:00:00 2001 From: Ryan Holmes Date: Sun, 24 Mar 2019 20:59:40 -0400 Subject: [PATCH 04/15] Fix character editor context menu on Linux (#1895) --- gui/characterEditor.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/gui/characterEditor.py b/gui/characterEditor.py index a7a66ca97..14934910f 100644 --- a/gui/characterEditor.py +++ b/gui/characterEditor.py @@ -373,7 +373,7 @@ class SkillTreeView(wx.Panel): 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.scheduleMenu) + tree.Bind(wx.dataview.EVT_TREELIST_ITEM_CONTEXT_MENU, self.spawnMenu) bSizerButtons = wx.BoxSizer(wx.HORIZONTAL) @@ -590,11 +590,8 @@ class SkillTreeView(wx.Panel): tree.SetItemText(childId, 1, "Level %d" % int(level) if isinstance(level, float) else level) - def scheduleMenu(self, event): - event.Skip() - wx.CallAfter(self.spawnMenu, event.GetItem()) - - def spawnMenu(self, item): + def spawnMenu(self, event): + item = event.GetItem() self.skillTreeListCtrl.Select(item) thing = self.skillTreeListCtrl.GetFirstChild(item).IsOk() if thing: From 26cba1c47ae5c6f9e68929715d011dd41195f836 Mon Sep 17 00:00:00 2001 From: Ryan Holmes Date: Sun, 24 Mar 2019 21:48:05 -0400 Subject: [PATCH 05/15] Fix a long standing bug due to misuse of context menu bindings in stats panels (see #651, and probably others) --- gui/builtinStatsViews/miningyieldViewFull.py | 1 - gui/statsPane.py | 10 +--------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/gui/builtinStatsViews/miningyieldViewFull.py b/gui/builtinStatsViews/miningyieldViewFull.py index 7793a2850..104a9ad2b 100644 --- a/gui/builtinStatsViews/miningyieldViewFull.py +++ b/gui/builtinStatsViews/miningyieldViewFull.py @@ -123,7 +123,6 @@ class MiningYieldViewFull(StatsView): # Get the TogglePanel tp = self.panel.GetParent() # Bind the new panel's children to allow context menu access - self.parent.applyBinding(self.parent, tp.content_panel) tp.SetLabel(view.getHeaderText(fit)) view.refreshPanel(fit) diff --git a/gui/statsPane.py b/gui/statsPane.py index b3984ccfa..ec13c5ff8 100644 --- a/gui/statsPane.py +++ b/gui/statsPane.py @@ -114,9 +114,7 @@ class StatsPane(wx.Panel): tp.SetLabel(view.getHeaderText(None)) view.refreshPanel(None) - contentPanel.Bind(wx.EVT_RIGHT_DOWN, self.contextHandler(contentPanel)) - for child in contentPanel.GetChildren(): - child.Bind(wx.EVT_RIGHT_DOWN, self.contextHandler(contentPanel)) + contentPanel.Bind(wx.EVT_CONTEXT_MENU, self.contextHandler(contentPanel)) mainSizer.Add(tp, 0, wx.EXPAND | wx.LEFT, 3) if i < maxviews - 1: @@ -143,9 +141,3 @@ class StatsPane(wx.Panel): event.Skip() return handler - - @staticmethod - def applyBinding(self, contentPanel): - pyfalog.debug("Attempt applyBinding to children of {0}", contentPanel.viewName) - for child in contentPanel.GetChildren(): - child.Bind(wx.EVT_RIGHT_DOWN, self.contextHandler(contentPanel)) From 5d012d6959ae8b27f01df65929cb05e1c422aa35 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Tue, 26 Mar 2019 07:57:51 +0300 Subject: [PATCH 06/15] Fix EFS export --- service/port/efs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/service/port/efs.py b/service/port/efs.py index fc00d5dfb..71ea9660f 100755 --- a/service/port/efs.py +++ b/service/port/efs.py @@ -523,18 +523,18 @@ class EfsPort: tf.mode = fit.mode preTraitMultipliers = getCurrentMultipliers(tf) for effect in fit.ship.item.effects.values(): - if effect._Effect__effectModule is not None: + if effect.isImplemented: effect.handler(tf, tf.ship, []) # Factor in mode effects for T3 Destroyers if fit.mode is not None: for effect in fit.mode.item.effects.values(): - if effect._Effect__effectModule is not None: + if effect.isImplemented: effect.handler(tf, fit.mode, []) if fit.ship.item.groupID == getGroup("Strategic Cruiser").ID: subSystems = list(filter(lambda mod: mod.slot == FittingSlot.SUBSYSTEM and mod.item, fit.modules)) for sub in subSystems: for effect in sub.item.effects.values(): - if effect._Effect__effectModule is not None: + if effect.isImplemented: effect.handler(tf, sub, []) postTraitMultipliers = getCurrentMultipliers(tf) getMaxRatio = lambda dictA, dictB, key: max(map(lambda a, b: b / a, dictA[key], dictB[key])) From 6dd737cdd108843a79f92675583a866530d6195e Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Tue, 26 Mar 2019 07:58:53 +0300 Subject: [PATCH 07/15] Revert "Fix EFS export" This reverts commit 5d012d6959ae8b27f01df65929cb05e1c422aa35. --- service/port/efs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/service/port/efs.py b/service/port/efs.py index 71ea9660f..fc00d5dfb 100755 --- a/service/port/efs.py +++ b/service/port/efs.py @@ -523,18 +523,18 @@ class EfsPort: tf.mode = fit.mode preTraitMultipliers = getCurrentMultipliers(tf) for effect in fit.ship.item.effects.values(): - if effect.isImplemented: + if effect._Effect__effectModule is not None: effect.handler(tf, tf.ship, []) # Factor in mode effects for T3 Destroyers if fit.mode is not None: for effect in fit.mode.item.effects.values(): - if effect.isImplemented: + if effect._Effect__effectModule is not None: effect.handler(tf, fit.mode, []) if fit.ship.item.groupID == getGroup("Strategic Cruiser").ID: subSystems = list(filter(lambda mod: mod.slot == FittingSlot.SUBSYSTEM and mod.item, fit.modules)) for sub in subSystems: for effect in sub.item.effects.values(): - if effect.isImplemented: + if effect._Effect__effectModule is not None: effect.handler(tf, sub, []) postTraitMultipliers = getCurrentMultipliers(tf) getMaxRatio = lambda dictA, dictB, key: max(map(lambda a, b: b / a, dictA[key], dictB[key])) From facb0b1023ac5b9a35a3a0547d2de07ea4e9fe74 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Tue, 26 Mar 2019 08:00:57 +0300 Subject: [PATCH 08/15] Fix EFS export --- service/port/efs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/service/port/efs.py b/service/port/efs.py index fc00d5dfb..71ea9660f 100755 --- a/service/port/efs.py +++ b/service/port/efs.py @@ -523,18 +523,18 @@ class EfsPort: tf.mode = fit.mode preTraitMultipliers = getCurrentMultipliers(tf) for effect in fit.ship.item.effects.values(): - if effect._Effect__effectModule is not None: + if effect.isImplemented: effect.handler(tf, tf.ship, []) # Factor in mode effects for T3 Destroyers if fit.mode is not None: for effect in fit.mode.item.effects.values(): - if effect._Effect__effectModule is not None: + if effect.isImplemented: effect.handler(tf, fit.mode, []) if fit.ship.item.groupID == getGroup("Strategic Cruiser").ID: subSystems = list(filter(lambda mod: mod.slot == FittingSlot.SUBSYSTEM and mod.item, fit.modules)) for sub in subSystems: for effect in sub.item.effects.values(): - if effect._Effect__effectModule is not None: + if effect.isImplemented: effect.handler(tf, sub, []) postTraitMultipliers = getCurrentMultipliers(tf) getMaxRatio = lambda dictA, dictB, key: max(map(lambda a, b: b / a, dictA[key], dictB[key])) From 1a5fc31e25abd40d135249d1183017c77246bbb8 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Tue, 26 Mar 2019 08:10:40 +0300 Subject: [PATCH 09/15] Switch to safeloader Seems like we do not use any custom data structures in yaml --- config.py | 2 +- dist_assets/win/dist.py | 2 +- scripts/dump_version.py | 2 +- scripts/sdeReadIcons.py | 2 +- service/jargon/loader.py | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config.py b/config.py index 6a4e2e95c..ff79be839 100644 --- a/config.py +++ b/config.py @@ -113,7 +113,7 @@ def defPaths(customSavePath=None): # Version data with open(os.path.join(pyfaPath, "version.yml"), 'r') as file: - data = yaml.load(file, Loader=yaml.FullLoader) + data = yaml.load(file, Loader=yaml.SafeLoader) version = data['version'] # Where we store the saved fits etc, default is the current users home directory diff --git a/dist_assets/win/dist.py b/dist_assets/win/dist.py index e8d6f4ae5..82342fbd2 100644 --- a/dist_assets/win/dist.py +++ b/dist_assets/win/dist.py @@ -8,7 +8,7 @@ import yaml with open("version.yml", 'r') as file: - data = yaml.load(file, Loader=yaml.FullLoader) + data = yaml.load(file, Loader=yaml.SafeLoader) version = data['version'] os.environ["PYFA_DIST_DIR"] = os.path.join(os.getcwd(), 'dist') diff --git a/scripts/dump_version.py b/scripts/dump_version.py index c506bfdb9..b872cf84a 100644 --- a/scripts/dump_version.py +++ b/scripts/dump_version.py @@ -10,7 +10,7 @@ import os with open("version.yml", 'r+') as file: - data = yaml.load(file, Loader=yaml.FullLoader) + data = yaml.load(file, Loader=yaml.SafeLoader) file.seek(0) file.truncate() # todo: run Version() on the tag to ensure that it's of proper formatting - fail a test if not and prevent building diff --git a/scripts/sdeReadIcons.py b/scripts/sdeReadIcons.py index aba3866fe..a1c571e93 100644 --- a/scripts/sdeReadIcons.py +++ b/scripts/sdeReadIcons.py @@ -10,7 +10,7 @@ import json iconDict = {} stream = open('iconIDs.yaml', 'r') -docs = yaml.load_all(stream, Loader=yaml.FullLoader) +docs = yaml.load_all(stream, Loader=yaml.SafeLoader) for doc in docs: for k,v in list(doc.items()): diff --git a/service/jargon/loader.py b/service/jargon/loader.py index 541bd0a4b..f0eb8f05b 100644 --- a/service/jargon/loader.py +++ b/service/jargon/loader.py @@ -43,9 +43,9 @@ class JargonLoader(object): self.jargon_mtime != self._get_jargon_file_mtime()) def _load_jargon(self): - jargondata = yaml.load(DEFAULT_DATA, Loader=yaml.FullLoader) + jargondata = yaml.load(DEFAULT_DATA, Loader=yaml.SafeLoader) with open(JARGON_PATH) as f: - userdata = yaml.load(f, Loader=yaml.FullLoader) + userdata = yaml.load(f, Loader=yaml.SafeLoader) jargondata.update(userdata) self.jargon_mtime = self._get_jargon_file_mtime() self._jargon = Jargon(jargondata) @@ -57,7 +57,7 @@ class JargonLoader(object): @staticmethod def init_user_jargon(jargon_path): - values = yaml.load(DEFAULT_DATA, Loader=yaml.FullLoader) + values = yaml.load(DEFAULT_DATA, Loader=yaml.SafeLoader) # Disabled for issue/1533; do not overwrite existing user config # if os.path.exists(jargon_path): From 9c5fe56981c0f4f3c9af196593d795a7aa64fc94 Mon Sep 17 00:00:00 2001 From: Ryan Holmes Date: Tue, 26 Mar 2019 18:46:26 -0400 Subject: [PATCH 10/15] Fix right click on state not toggling overheat --- gui/builtinViews/fittingView.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gui/builtinViews/fittingView.py b/gui/builtinViews/fittingView.py index f60159daf..4c1918017 100644 --- a/gui/builtinViews/fittingView.py +++ b/gui/builtinViews/fittingView.py @@ -165,6 +165,7 @@ class FittingView(d.Display): self.Bind(wx.EVT_KEY_UP, self.kbEvent) self.Bind(wx.EVT_LEFT_DOWN, self.click) + self.Bind(wx.EVT_RIGHT_DOWN, self.click) self.Bind(wx.EVT_MIDDLE_DOWN, self.click) self.Bind(wx.EVT_SHOW, self.OnShow) self.Bind(wx.EVT_MOTION, self.OnMouseMove) @@ -532,7 +533,7 @@ class FittingView(d.Display): event.Skip() def spawnMenu(self, event): - if self.activeFitID is None: + if self.activeFitID is None or self.getColumn(self.ScreenToClient(event.Position)) == self.getColIndex(State): return sMkt = Market.getInstance() @@ -588,6 +589,7 @@ class FittingView(d.Display): and we have clicked the State column, iterate through the selections and change State """ + row, _, col = self.HitTestSubItem(event.Position) # only do State column and ignore invalid rows From 6a2bdade8092ef7a56cc843528941b001d909f32 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Fri, 29 Mar 2019 01:09:52 +0300 Subject: [PATCH 11/15] Fix attr tab original value column fetching module attributes for charges --- eos/modifiedAttributeDict.py | 9 ++++++++- gui/builtinItemStatsViews/itemAttributes.py | 8 ++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/eos/modifiedAttributeDict.py b/eos/modifiedAttributeDict.py index 756a9f806..c2540b066 100644 --- a/eos/modifiedAttributeDict.py +++ b/eos/modifiedAttributeDict.py @@ -33,13 +33,20 @@ class ItemAttrShortcut(object): return return_value or default - def getBaseAttrValue(self, key, default=0): + def getItemBaseAttrValue(self, key, default=0): """ Gets base value in this order: Mutated value > override value > attribute value """ return_value = self.itemModifiedAttributes.getOriginal(key) + return return_value or default + def getChargeBaseAttrValue(self, key, default=0): + """ + Gets base value in this order: + Mutated value > override value > attribute value + """ + return_value = self.chargeModifiedAttributes.getOriginal(key) return return_value or default diff --git a/gui/builtinItemStatsViews/itemAttributes.py b/gui/builtinItemStatsViews/itemAttributes.py index 324e64c22..b19b3f3e4 100644 --- a/gui/builtinItemStatsViews/itemAttributes.py +++ b/gui/builtinItemStatsViews/itemAttributes.py @@ -266,12 +266,16 @@ class ItemParams(wx.Panel): info = self.attrInfo.get(attr) att = self.attrValues[attr] - # If we're working with a stuff object, we should get the original value from our getBaseAttrValue function, + # If we're working with a stuff object, we should get the original value from our getItemBaseAttrValue function, # which will return the value with respect to the effective base (with mutators / overrides in place) valDefault = getattr(info, "value", None) # Get default value from attribute if self.stuff is not None: # if it's a stuff, overwrite default (with fallback to current value) - valDefault = self.stuff.getBaseAttrValue(attr, valDefault) + if self.stuff.item == self.item: + valDefault = self.stuff.getItemBaseAttrValue(attr, valDefault) + elif self.stuff.charge == self.item: + valDefault = self.stuff.getChargeBaseAttrValue(attr, valDefault) + valueDefault = valDefault if valDefault is not None else att val = getattr(att, "value", None) From 96e0a02d5c16c027a35818887cd4853b47b5d287 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Sat, 30 Mar 2019 10:33:01 +0300 Subject: [PATCH 12/15] Ensure we do not attempt to import mutated module when we have no fit open --- service/port/port.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/service/port/port.py b/service/port/port.py index a82f6c27b..009569216 100644 --- a/service/port/port.py +++ b/service/port/port.py @@ -241,10 +241,11 @@ class Port(object): return "DNA", (cls.importDna(string),) # Assume that we import stand-alone abyssal module if all else fails - try: - return "MutatedItem", (parseMutant(lines),) - except: - pass + if activeFit is not None: + try: + return "MutatedItem", (parseMutant(lines),) + except: + pass # EFT-related methods From 7d8768ca3e287f6be3396f04e52564fcaa9e0de0 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Sat, 30 Mar 2019 10:52:54 +0300 Subject: [PATCH 13/15] Add extra check on command level to ensure no errors --- gui/fitCommands/calc/fitImportMutatedModule.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gui/fitCommands/calc/fitImportMutatedModule.py b/gui/fitCommands/calc/fitImportMutatedModule.py index bae0ef0d8..2a41679f5 100644 --- a/gui/fitCommands/calc/fitImportMutatedModule.py +++ b/gui/fitCommands/calc/fitImportMutatedModule.py @@ -25,6 +25,9 @@ class FitImportMutatedCommand(wx.Command): def Do(self): sFit = Fit.getInstance() fitID = self.fitID + if fitID is None: + return False + fit = eos.db.getFit(fitID) if self.baseItem is None: From a6b8381e25b44963e5729ee4c16e74a1db445f1f Mon Sep 17 00:00:00 2001 From: MaruMaruOO <37426450+MaruMaruOO@users.noreply.github.com> Date: Sat, 30 Mar 2019 09:15:48 -0400 Subject: [PATCH 14/15] Additional fix for #1902 Adds checks to make sure effects return correct `isImplemented` and `isType` values when they are called before handler generation. --- eos/gamedata.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/eos/gamedata.py b/eos/gamedata.py index a2f4962dc..50bd66d94 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -140,12 +140,18 @@ class Effect(EqBase): Whether this effect is implemented in code or not, unimplemented effects simply do nothing at all when run """ + if not self.__generated: + self.__generateHandler() + return self.__effectDef is not None def isType(self, type): """ Check if this effect is of the passed type """ + if not self.__generated: + self.__generateHandler() + return self.type is not None and type in self.type def __generateHandler(self): From 768c1d37b19429bc9f92080d3f789e387c75739e Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Sun, 31 Mar 2019 16:08:48 +0300 Subject: [PATCH 15/15] Fix fit export --- gui/fitCommands/calc/fitImportMutatedModule.py | 2 +- service/port/port.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/gui/fitCommands/calc/fitImportMutatedModule.py b/gui/fitCommands/calc/fitImportMutatedModule.py index 2a41679f5..948f0b511 100644 --- a/gui/fitCommands/calc/fitImportMutatedModule.py +++ b/gui/fitCommands/calc/fitImportMutatedModule.py @@ -27,7 +27,7 @@ class FitImportMutatedCommand(wx.Command): fitID = self.fitID if fitID is None: return False - + fit = eos.db.getFit(fitID) if self.baseItem is None: diff --git a/service/port/port.py b/service/port/port.py index 009569216..f078a8279 100644 --- a/service/port/port.py +++ b/service/port/port.py @@ -76,8 +76,7 @@ class Port(object): success = True try: iportuser.on_port_process_start() - backedUpFits = Port.exportXml(iportuser, - *svcFit.getInstance().getAllFits()) + backedUpFits = Port.exportXml(svcFit.getInstance().getAllFits(), iportuser) backupFile = open(path, "w", encoding="utf-8") backupFile.write(backedUpFits) backupFile.close()