Merge pull request #1914 from pyfa-org/menu_overhaul

Main menu & stats menu overhaul
This commit is contained in:
Anton Vorobyov
2019-04-09 16:34:23 +03:00
committed by GitHub
4 changed files with 94 additions and 98 deletions

View File

@@ -7,7 +7,7 @@ from service.settings import ContextMenuSettings
class PFContextMenuPref(PreferenceView):
title = "Context Menu Panel"
title = "Context Menus"
def populatePanel(self, panel):
self.settings = ContextMenuSettings.getInstance()

View File

@@ -1,14 +1,11 @@
import wx
from gui.preferenceView import PreferenceView
from gui.bitmap_loader import BitmapLoader
from gui.utils import helpers_wxPython as wxHelpers
import config
from eos.db.saveddata.loadDefaultDatabaseValues import DefaultDatabaseValues
from eos.db.saveddata.queries import clearPrices, clearDamagePatterns, clearTargetResists
import logging
logger = logging.getLogger(__name__)
from gui.bitmap_loader import BitmapLoader
from gui.preferenceView import PreferenceView
from gui.utils import helpers_wxPython as wxHelpers
class PFGeneralPref(PreferenceView):
@@ -78,24 +75,36 @@ class PFGeneralPref(PreferenceView):
btnSizer = wx.BoxSizer(wx.VERTICAL)
btnSizer.AddStretchSpacer()
self.btnImportDefaults = wx.Button(panel, wx.ID_ANY, "Reimport Database Defaults", wx.DefaultPosition, wx.DefaultSize, 0)
btnSizer.Add(self.btnImportDefaults, 0, wx.ALL, 5)
self.btnImportDefaults.Bind(wx.EVT_BUTTON, self.loadDatabaseDefaults)
self.btnDeleteDamagePatterns = wx.Button(panel, wx.ID_ANY, "Delete All Damage Pattern Profiles", wx.DefaultPosition, wx.DefaultSize, 0)
btnSizer.Add(self.btnDeleteDamagePatterns, 0, wx.ALL, 5)
self.btnDeleteDamagePatterns.Bind(wx.EVT_BUTTON, self.DeleteDamagePatterns)
self.btnDeleteTargetResists = wx.Button(panel, wx.ID_ANY, "Delete All Target Resist Profiles", wx.DefaultPosition, wx.DefaultSize, 0)
btnSizer.Add(self.btnDeleteTargetResists, 0, wx.ALL, 5)
self.btnDeleteTargetResists.Bind(wx.EVT_BUTTON, self.DeleteTargetResists)
self.btnPrices = wx.Button(panel, wx.ID_ANY, "Delete All Prices", wx.DefaultPosition, wx.DefaultSize, 0)
btnSizer.Add(self.btnPrices, 0, wx.ALL, 5)
self.btnPrices.Bind(wx.EVT_BUTTON, self.DeletePrices)
mainSizer.Add(btnSizer, 0, wx.EXPAND, 5)
self.btnDeleteDamagePatterns.Bind(wx.EVT_BUTTON, self.DeleteDamagePatterns)
self.btnDeleteTargetResists.Bind(wx.EVT_BUTTON, self.DeleteTargetResists)
self.btnPrices.Bind(wx.EVT_BUTTON, self.DeletePrices)
panel.SetSizer(mainSizer)
panel.Layout()
def loadDatabaseDefaults(self, event):
# Import values that must exist otherwise Pyfa breaks
DefaultDatabaseValues.importRequiredDefaults()
# Import default values for damage profiles
DefaultDatabaseValues.importDamageProfileDefaults()
# Import default values for target resist profiles
DefaultDatabaseValues.importResistProfileDefaults()
def DeleteDamagePatterns(self, event):
question = "This is a destructive action that will delete all damage pattern profiles.\nAre you sure you want to do this?"
if wxHelpers.YesNoDialog(question, "Confirm"):

View File

@@ -36,7 +36,6 @@ from wx.lib.inspection import InspectionTool
import config
import gui.globalEvents as GE
from eos.config import gamedata_date, gamedata_version
from eos.db.saveddata.loadDefaultDatabaseValues import DefaultDatabaseValues
# import this to access override setting
from eos.modifiedAttributeDict import ModifiedAttributeDict
from gui import graphFrame
@@ -450,21 +449,10 @@ class MainFrame(wx.Frame):
def goForums(event):
webbrowser.open('https://forums.eveonline.com/t/27156')
@staticmethod
def loadDatabaseDefaults(event):
# Import values that must exist otherwise Pyfa breaks
DefaultDatabaseValues.importRequiredDefaults()
# Import default values for damage profiles
DefaultDatabaseValues.importDamageProfileDefaults()
# Import default values for target resist profiles
DefaultDatabaseValues.importResistProfileDefaults()
def registerMenu(self):
menuBar = self.GetMenuBar()
# Quit
self.Bind(wx.EVT_MENU, self.ExitApp, id=wx.ID_EXIT)
# Load Default Database values
self.Bind(wx.EVT_MENU, self.loadDatabaseDefaults, id=menuBar.importDatabaseDefaultsId)
# Widgets Inspector
if config.debug:
self.Bind(wx.EVT_MENU, self.openWXInspectTool, id=self.widgetInspectMenuID)
@@ -639,7 +627,7 @@ class MainFrame(wx.Frame):
wx.PostEvent(self, GE.FitChanged(fitID=self.getActiveFit()))
menu = self.GetMenuBar()
menu.SetLabel(menu.toggleOverridesId,
"Turn Overrides Off" if ModifiedAttributeDict.overrides_enabled else "Turn Overrides On")
"&Turn Overrides Off" if ModifiedAttributeDict.overrides_enabled else "&Turn Overrides On")
def saveChar(self, event):
sChr = Character.getInstance()

View File

@@ -54,7 +54,6 @@ class MainMenuBar(wx.MenuBar):
self.ssoLoginId = wx.NewId()
self.attrEditorId = wx.NewId()
self.toggleOverridesId = wx.NewId()
self.importDatabaseDefaultsId = wx.NewId()
self.toggleIgnoreRestrictionID = wx.NewId()
self.devToolsId = wx.NewId()
self.optimizeFitPrice = wx.NewId()
@@ -73,103 +72,103 @@ class MainMenuBar(wx.MenuBar):
fileMenu.Append(self.mainFrame.addPageId, "&New Tab\tCTRL+T", "Open a new fitting tab")
fileMenu.Append(self.mainFrame.closePageId, "&Close Tab\tCTRL+W", "Close the current fit")
fileMenu.AppendSeparator()
fileMenu.Append(self.backupFitsId, "&Backup All Fittings", "Backup all fittings to a XML file")
fileMenu.Append(wx.ID_OPEN, "&Import Fittings\tCTRL+O", "Import fittings into pyfa")
fileMenu.Append(wx.ID_SAVEAS, "&Export Fitting\tCTRL+S", "Export fitting to another format")
fileMenu.AppendSeparator()
fileMenu.Append(self.exportHtmlId, "Export HTML", "Export fits to HTML file (set in Preferences)")
fileMenu.Append(self.exportSkillsNeededId, "Export &Skills Needed", "Export skills needed for this fitting")
fileMenu.Append(self.importCharacterId, "Import C&haracter File", "Import characters into pyfa from file")
fileMenu.Append(self.backupFitsId, "&Backup All Fittings", "Backup all fittings to a XML file")
fileMenu.Append(self.exportHtmlId, "Export All Fittings to &HTML", "Export fits to HTML file (set in Preferences)")
fileMenu.AppendSeparator()
fileMenu.Append(wx.ID_EXIT)
# Edit menu
editMenu = wx.Menu()
self.Append(editMenu, "&Edit")
# Fit menu
fitMenu = wx.Menu()
self.Append(fitMenu, "Fi&t")
editMenu.Append(wx.ID_UNDO)
editMenu.Append(wx.ID_REDO)
fitMenu.Append(wx.ID_UNDO)
fitMenu.Append(wx.ID_REDO)
editMenu.Append(wx.ID_COPY, "To Clipboard\tCTRL+C", "Export a fit to the clipboard")
editMenu.Append(wx.ID_PASTE, "From Clipboard\tCTRL+V", "Import a fit from the clipboard")
editMenu.AppendSeparator()
editMenu.Append(self.saveCharId, "Save Character")
editMenu.Append(self.saveCharAsId, "Save Character As...")
editMenu.Append(self.revertCharId, "Revert Character")
editMenu.AppendSeparator()
self.ignoreRestrictionItem = editMenu.Append(self.toggleIgnoreRestrictionID, "Ignore Fitting Restrictions")
editMenu.AppendSeparator()
editMenu.Append(self.optimizeFitPrice, "Optimize Fit Price")
fitMenu.AppendSeparator()
fitMenu.Append(wx.ID_COPY, "&To Clipboard\tCTRL+C", "Export a fit to the clipboard")
fitMenu.Append(wx.ID_PASTE, "&From Clipboard\tCTRL+V", "Import a fit from the clipboard")
fitMenu.AppendSeparator()
fitMenu.Append(wx.ID_OPEN, "&Import Fittings\tCTRL+O", "Import fittings into pyfa")
fitMenu.Append(wx.ID_SAVEAS, "&Export Fitting\tCTRL+S", "Export fitting to another format")
# Character menu
windowMenu = wx.Menu()
self.Append(windowMenu, "&Window")
charEditItem = wx.MenuItem(windowMenu, self.characterEditorId, "&Character Editor\tCTRL+E")
charEditItem.SetBitmap(BitmapLoader.getBitmap("character_small", "gui"))
windowMenu.Append(charEditItem)
damagePatternEditItem = wx.MenuItem(windowMenu, self.damagePatternEditorId, "Damage Pattern Editor\tCTRL+D")
damagePatternEditItem.SetBitmap(BitmapLoader.getBitmap("damagePattern_small", "gui"))
windowMenu.Append(damagePatternEditItem)
targetResistsEditItem = wx.MenuItem(windowMenu, self.targetResistsEditorId, "Target Resists Editor\tCTRL+R")
targetResistsEditItem.SetBitmap(BitmapLoader.getBitmap("explosive_small", "gui"))
windowMenu.Append(targetResistsEditItem)
implantSetEditItem = wx.MenuItem(windowMenu, self.implantSetEditorId, "Implant Set Editor\tCTRL+I")
implantSetEditItem.SetBitmap(BitmapLoader.getBitmap("hardwire_small", "gui"))
windowMenu.Append(implantSetEditItem)
graphFrameItem = wx.MenuItem(windowMenu, self.graphFrameId, "Graphs\tCTRL+G")
fitMenu.AppendSeparator()
fitMenu.Append(self.optimizeFitPrice, "&Optimize Fit Price\tCTRL+D")
graphFrameItem = wx.MenuItem(fitMenu, self.graphFrameId, "&Graphs\tCTRL+G")
graphFrameItem.SetBitmap(BitmapLoader.getBitmap("graphs_small", "gui"))
windowMenu.Append(graphFrameItem)
fitMenu.Append(graphFrameItem)
if not gui.graphFrame.graphFrame_enabled:
self.Enable(self.graphFrameId, False)
self.ignoreRestrictionItem = fitMenu.Append(self.toggleIgnoreRestrictionID, "Disable Fitting Re&strictions")
preferencesShortCut = "CTRL+," if 'wxMac' in wx.PlatformInfo else "CTRL+P"
preferencesItem = wx.MenuItem(windowMenu, wx.ID_PREFERENCES, "Preferences\t" + preferencesShortCut)
preferencesItem.SetBitmap(BitmapLoader.getBitmap("preferences_small", "gui"))
windowMenu.Append(preferencesItem)
# CREST Menu
esiMMenu = wx.Menu()
self.Append(esiMMenu, "EVE &SSO")
esiMMenu.Append(self.ssoLoginId, "Manage Characters")
esiMMenu.Append(self.eveFittingsId, "Browse EVE Fittings")
esiMMenu.Append(self.exportToEveId, "Export To EVE")
# if self.sEsi.settings.get('mode') == CrestModes.IMPLICIT or len(self.sEsi.getCrestCharacters()) == 0:
fitMenu.AppendSeparator()
fitMenu.Append(self.eveFittingsId, "&Browse ESI Fittings\tCTRL+B")
fitMenu.Append(self.exportToEveId, "E&xport to ESI\tCTRL+E")
self.Enable(self.eveFittingsId, True)
self.Enable(self.exportToEveId, True)
# Character menu
characterMenu = wx.Menu()
self.Append(characterMenu, "&Character")
characterMenu.Append(self.saveCharId, "&Save Character")
characterMenu.Append(self.saveCharAsId, "Save Character &As...")
characterMenu.Append(self.revertCharId, "&Revert Character")
characterMenu.AppendSeparator()
characterMenu.Append(self.importCharacterId, "&Import Character File", "Import characters into pyfa from file")
characterMenu.Append(self.exportSkillsNeededId, "&Export Skills Needed", "Export skills needed for this fitting")
characterMenu.AppendSeparator()
characterMenu.Append(self.ssoLoginId, "&Manage ESI Characters")
# Global Menu
globalMenu = wx.Menu()
if not self.mainFrame.disableOverrideEditor:
windowMenu.AppendSeparator()
attrItem = wx.MenuItem(windowMenu, self.attrEditorId, "Attribute Overrides\tCTRL+B")
attrItem = wx.MenuItem(globalMenu, self.attrEditorId, "Attribute &Overrides\tCTRL+B")
attrItem.SetBitmap(BitmapLoader.getBitmap("fit_rename_small", "gui"))
windowMenu.Append(attrItem)
windowMenu.Append(self.toggleOverridesId, "Turn Overrides On")
globalMenu.Append(attrItem)
globalMenu.Append(self.toggleOverridesId, "&Turn Overrides On")
globalMenu.AppendSeparator()
self.Append(globalMenu, "&Global")
preferencesShortCut = "CTRL+," if 'wxMac' in wx.PlatformInfo else "CTRL+P"
preferencesItem = wx.MenuItem(globalMenu, wx.ID_PREFERENCES, "&Preferences\t" + preferencesShortCut)
preferencesItem.SetBitmap(BitmapLoader.getBitmap("preferences_small", "gui"))
globalMenu.Append(preferencesItem)
# Editors menu
editorsMenu = wx.Menu()
self.Append(editorsMenu, "&Editors")
charEditItem = wx.MenuItem(editorsMenu, self.characterEditorId, "&Character Editor\tCTRL+K")
charEditItem.SetBitmap(BitmapLoader.getBitmap("character_small", "gui"))
editorsMenu.Append(charEditItem)
implantSetEditItem = wx.MenuItem(editorsMenu, self.implantSetEditorId, "&Implant Set Editor\tCTRL+I")
implantSetEditItem.SetBitmap(BitmapLoader.getBitmap("hardwire_small", "gui"))
editorsMenu.Append(implantSetEditItem)
damagePatternEditItem = wx.MenuItem(editorsMenu, self.damagePatternEditorId, "&Damage Pattern Editor")
damagePatternEditItem.SetBitmap(BitmapLoader.getBitmap("damagePattern_small", "gui"))
editorsMenu.Append(damagePatternEditItem)
targetResistsEditItem = wx.MenuItem(editorsMenu, self.targetResistsEditorId, "&Target Resists Editor")
targetResistsEditItem.SetBitmap(BitmapLoader.getBitmap("explosive_small", "gui"))
editorsMenu.Append(targetResistsEditItem)
# Help menu
helpMenu = wx.Menu()
self.Append(helpMenu, "&Help")
helpMenu.Append(self.wikiId, "Wiki", "Go to wiki on GitHub")
helpMenu.Append(self.forumId, "Forums", "Go to EVE Online Forum thread")
helpMenu.AppendSeparator()
helpMenu.Append(self.importDatabaseDefaultsId, "Import D&atabase Defaults", "Imports missing database defaults")
helpMenu.Append(self.wikiId, "&Wiki", "Go to wiki on GitHub")
helpMenu.Append(self.forumId, "&Forums", "Go to EVE Online Forum thread")
helpMenu.AppendSeparator()
helpMenu.Append(wx.ID_ABOUT)
if config.debug:
helpMenu.Append(self.mainFrame.widgetInspectMenuID, "Open Widgets Inspect tool",
"Open Widgets Inspect tool")
helpMenu.Append(self.devToolsId, "Open Dev Tools",
"Dev Tools")
helpMenu.Append(self.mainFrame.widgetInspectMenuID, "Open Wid&gets Inspect tool", "Open Widgets Inspect tool")
helpMenu.Append(self.devToolsId, "Open &Dev Tools", "Dev Tools")
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
@@ -204,8 +203,8 @@ class MainMenuBar(wx.MenuBar):
fit = sFit.getFit(event.fitID)
if fit.ignoreRestrictions:
self.ignoreRestrictionItem.SetItemLabel("Enable Fitting Restrictions")
self.ignoreRestrictionItem.SetItemLabel("Enable Fitting Re&strictions")
else:
self.ignoreRestrictionItem.SetItemLabel("Disable Fitting Restrictions")
self.ignoreRestrictionItem.SetItemLabel("Disable Fitting Re&strictions")
event.Skip()