-
Notifications
You must be signed in to change notification settings - Fork 412
/
Copy pathmainMenuBar.py
178 lines (147 loc) · 7.89 KB
/
mainMenuBar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#===============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
#
# pyfa is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyfa is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
import wx
import config
from gui.bitmapLoader import BitmapLoader
import gui.mainFrame
import gui.graphFrame
import gui.globalEvents as GE
import service
if not 'wxMac' in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3,0)):
from service.crest import CrestModes
class MainMenuBar(wx.MenuBar):
def __init__(self):
self.characterEditorId = wx.NewId()
self.damagePatternEditorId = wx.NewId()
self.targetResistsEditorId = wx.NewId()
self.implantSetEditorId = wx.NewId()
self.graphFrameId = wx.NewId()
self.backupFitsId = wx.NewId()
self.exportSkillsNeededId = wx.NewId()
self.importCharacterId = wx.NewId()
self.exportHtmlId = wx.NewId()
self.wikiId = wx.NewId()
self.forumId = wx.NewId()
self.saveCharId = wx.NewId()
self.saveCharAsId = wx.NewId()
self.revertCharId = wx.NewId()
self.eveFittingsId = wx.NewId()
self.exportToEveId = wx.NewId()
self.ssoLoginId = wx.NewId()
self.attrEditorId = wx.NewId()
self.toggleOverridesId = wx.NewId()
self.importDatabaseDefaultsId = wx.NewId()
if 'wxMac' in wx.PlatformInfo and wx.VERSION >= (3,0):
wx.ID_COPY = wx.NewId()
wx.ID_PASTE = wx.NewId()
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
wx.MenuBar.__init__(self)
# File menu
fileMenu = wx.Menu()
self.Append(fileMenu, "&File")
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.AppendSeparator()
fileMenu.Append(wx.ID_EXIT)
# Edit menu
editMenu = wx.Menu()
self.Append(editMenu, "&Edit")
#editMenu.Append(wx.ID_UNDO)
#editMenu.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")
# 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.AppendItem(charEditItem)
damagePatternEditItem = wx.MenuItem(windowMenu, self.damagePatternEditorId, "Damage Pattern Editor\tCTRL+D")
damagePatternEditItem.SetBitmap(BitmapLoader.getBitmap("damagePattern_small", "gui"))
windowMenu.AppendItem(damagePatternEditItem)
targetResistsEditItem = wx.MenuItem(windowMenu, self.targetResistsEditorId, "Target Resists Editor\tCTRL+R")
targetResistsEditItem.SetBitmap(BitmapLoader.getBitmap("explosive_small", "gui"))
windowMenu.AppendItem(targetResistsEditItem)
implantSetEditItem = wx.MenuItem(windowMenu, self.implantSetEditorId, "Implant Set Editor\tCTRL+I")
implantSetEditItem.SetBitmap(BitmapLoader.getBitmap("hardwire_small", "gui"))
windowMenu.AppendItem(implantSetEditItem)
graphFrameItem = wx.MenuItem(windowMenu, self.graphFrameId, "Graphs\tCTRL+G")
graphFrameItem.SetBitmap(BitmapLoader.getBitmap("graphs_small", "gui"))
windowMenu.AppendItem(graphFrameItem)
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.AppendItem(preferencesItem)
if not 'wxMac' in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3,0)):
self.sCrest = service.Crest.getInstance()
# CREST Menu
crestMenu = wx.Menu()
self.Append(crestMenu, "&CREST")
if self.sCrest.settings.get('mode') != CrestModes.IMPLICIT:
crestMenu.Append(self.ssoLoginId, "Manage Characters")
else:
crestMenu.Append(self.ssoLoginId, "Login to EVE")
crestMenu.Append(self.eveFittingsId, "Browse EVE Fittings")
crestMenu.Append(self.exportToEveId, "Export To EVE")
if self.sCrest.settings.get('mode') == CrestModes.IMPLICIT or len(self.sCrest.getCrestCharacters()) == 0:
self.Enable(self.eveFittingsId, False)
self.Enable(self.exportToEveId, False)
if not gui.mainFrame.disableOverrideEditor:
windowMenu.AppendSeparator()
attrItem = wx.MenuItem(windowMenu, self.attrEditorId, "Attribute Overrides\tCTRL+B")
attrItem.SetBitmap(BitmapLoader.getBitmap("fit_rename_small", "gui"))
windowMenu.AppendItem(attrItem)
windowMenu.Append(self.toggleOverridesId, "Turn Overrides On")
# 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.AppendSeparator()
helpMenu.Append(wx.ID_ABOUT)
if config.debug:
helpMenu.Append( self.mainFrame.widgetInspectMenuID, "Open Widgets Inspect tool", "Open Widgets Inspect tool")
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
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 = service.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)
event.Skip()