Preliminary gang UI stuff
This commit is contained in:
@@ -24,6 +24,7 @@ from gui.droneView import DroneView
|
||||
from gui.implantView import ImplantView
|
||||
from gui.projectedView import ProjectedView
|
||||
from gui.pyfatogglepanel import TogglePanel
|
||||
from gui.gangView import GangView
|
||||
from gui import bitmapLoader
|
||||
|
||||
import gui.chromeTabs
|
||||
@@ -60,6 +61,9 @@ class AdditionsPane(TogglePanel):
|
||||
|
||||
self.projectedPage = ProjectedView(self.notebook)
|
||||
self.notebook.AddPage(self.projectedPage, "Projected", tabImage = projectedImg, showClose = False)
|
||||
|
||||
self.gangPage = GangView(self.notebook)
|
||||
self.notebook.AddPage(self.gangPage, "Gang", showClose = False)
|
||||
self.notebook.SetSelection(0)
|
||||
|
||||
|
||||
|
||||
187
gui/gangView.py
Normal file
187
gui/gangView.py
Normal file
@@ -0,0 +1,187 @@
|
||||
#===============================================================================
|
||||
# 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
|
||||
from wx.lib.scrolledpanel import ScrolledPanel
|
||||
|
||||
import service
|
||||
import gui.mainFrame
|
||||
import gui.globalEvents as GE
|
||||
|
||||
from gui import characterEditor as CharEditor
|
||||
|
||||
class GangView ( ScrolledPanel ):
|
||||
|
||||
def __init__( self, parent ):
|
||||
ScrolledPanel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( 691,172 ), style = wx.TAB_TRAVERSAL )
|
||||
mainSizer = wx.BoxSizer( wx.VERTICAL )
|
||||
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
self.draggedFitID = None
|
||||
|
||||
self.FitDNDPopupMenu = wx.Menu()
|
||||
|
||||
self.options = ["Fleet booster", "Wing booster", "Squad booster"]
|
||||
|
||||
for option in self.options:
|
||||
item = self.FitDNDPopupMenu.Append(-1, option)
|
||||
self.Bind(wx.EVT_MENU, self.OnPopupItemSelected, item)
|
||||
|
||||
contentFGSizer = wx.FlexGridSizer( 5, 3, 0, 0 )
|
||||
contentFGSizer.AddGrowableCol( 1 )
|
||||
contentFGSizer.SetFlexibleDirection( wx.BOTH )
|
||||
contentFGSizer.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
|
||||
|
||||
self.oneonePlaceholder = wx.StaticText( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
self.oneonePlaceholder.Wrap( -1 )
|
||||
contentFGSizer.Add( self.oneonePlaceholder, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5 )
|
||||
|
||||
self.stFits = wx.StaticText( self, wx.ID_ANY, u"Fits", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
self.stFits.Wrap( -1 )
|
||||
contentFGSizer.Add( self.stFits, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
|
||||
|
||||
self.stCharacters = wx.StaticText( self, wx.ID_ANY, u"Characters", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
self.stCharacters.Wrap( -1 )
|
||||
contentFGSizer.Add( self.stCharacters, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
|
||||
|
||||
self.m_staticline2 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
|
||||
contentFGSizer.Add( self.m_staticline2, 0, wx.EXPAND, 5 )
|
||||
|
||||
self.m_staticline3 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
|
||||
contentFGSizer.Add( self.m_staticline3, 0, wx.EXPAND, 5 )
|
||||
|
||||
self.m_staticline4 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
|
||||
contentFGSizer.Add( self.m_staticline4, 0, wx.EXPAND, 5 )
|
||||
|
||||
self.stFleet = wx.StaticText( self, wx.ID_ANY, u"Fleet", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
self.stFleet.Wrap( -1 )
|
||||
self.stFleet.SetFont( wx.Font( wx.NORMAL_FONT.GetPointSize(), 70, 90, 90, False, wx.EmptyString ) )
|
||||
|
||||
contentFGSizer.Add( self.stFleet, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
|
||||
|
||||
self.stFleetFit = wx.StaticText( self, wx.ID_ANY, u"None", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
self.stFleetFit.Wrap( -1 )
|
||||
self.stFleetFit.SetFont( wx.Font( wx.NORMAL_FONT.GetPointSize(), 70, 90, 90, False, wx.EmptyString ) )
|
||||
|
||||
contentFGSizer.Add( self.stFleetFit, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
|
||||
|
||||
chFleetCharChoices = []
|
||||
self.chFleetChar = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, chFleetCharChoices, 0 )
|
||||
self.chFleetChar.SetSelection( 0 )
|
||||
contentFGSizer.Add( self.chFleetChar, 0, wx.EXPAND|wx.ALL, 5 )
|
||||
|
||||
self.stWing = wx.StaticText( self, wx.ID_ANY, u"Wing", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
self.stWing.Wrap( -1 )
|
||||
contentFGSizer.Add( self.stWing, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
|
||||
|
||||
self.stWingFit = wx.StaticText( self, wx.ID_ANY, u"None", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
self.stWingFit.Wrap( -1 )
|
||||
contentFGSizer.Add( self.stWingFit, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
|
||||
|
||||
chWingCharChoices = []
|
||||
self.chWingChar = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, chWingCharChoices, 0 )
|
||||
self.chWingChar.SetSelection( 0 )
|
||||
contentFGSizer.Add( self.chWingChar, 0, wx.ALL|wx.EXPAND, 5 )
|
||||
|
||||
self.stSquad = wx.StaticText( self, wx.ID_ANY, u"Squad", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
self.stSquad.Wrap( -1 )
|
||||
contentFGSizer.Add( self.stSquad, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
|
||||
|
||||
self.stSquadFit = wx.StaticText( self, wx.ID_ANY, u"None", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
self.stSquadFit.Wrap( -1 )
|
||||
contentFGSizer.Add( self.stSquadFit, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
|
||||
|
||||
chSquadCharChoices = []
|
||||
self.chSquadChar = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, chSquadCharChoices, 0 )
|
||||
self.chSquadChar.SetSelection( 0 )
|
||||
contentFGSizer.Add( self.chSquadChar, 0, wx.EXPAND|wx.ALL, 5 )
|
||||
|
||||
mainSizer.Add( contentFGSizer, 0, 0, 0 )
|
||||
|
||||
self.stBoosters = []
|
||||
self.stBoosters.append(self.stFleetFit)
|
||||
self.stBoosters.append(self.stWingFit)
|
||||
self.stBoosters.append(self.stSquadFit)
|
||||
|
||||
|
||||
self.chCharacters = []
|
||||
self.chCharacters.append(self.chFleetChar)
|
||||
self.chCharacters.append(self.chWingChar)
|
||||
self.chCharacters.append(self.chSquadChar)
|
||||
|
||||
self.SetSizer( mainSizer )
|
||||
self.SetAutoLayout(1)
|
||||
self.SetupScrolling()
|
||||
|
||||
self.mainFrame.Bind(CharEditor.CHAR_LIST_UPDATED, self.RefreshCharacterList)
|
||||
self.RefreshCharacterList()
|
||||
|
||||
def RefreshCharacterList(self, event = None):
|
||||
cChar = service.Character.getInstance()
|
||||
charList = cChar.getCharacterList()
|
||||
|
||||
for choice in self.chCharacters:
|
||||
chCurrSelection = choice.GetSelection()
|
||||
chCurrData = -1
|
||||
if chCurrSelection != -1:
|
||||
chCurrData = choice.GetClientData(chCurrSelection)
|
||||
chCurrSelString = choice.GetString(chCurrSelection)
|
||||
choice.Clear()
|
||||
currSelFound = False
|
||||
for char in charList:
|
||||
id,name,_ = char
|
||||
choice.Append(name, id)
|
||||
if chCurrData == id:
|
||||
currSelFound = True
|
||||
|
||||
if chCurrSelection == -1:
|
||||
choice.SetSelection(1)
|
||||
else:
|
||||
if currSelFound:
|
||||
choice.SetStringSelection(chCurrSelString)
|
||||
else:
|
||||
choice.SetSelection(1)
|
||||
|
||||
def handleDrag(self, type, fitID):
|
||||
#Those are drags coming from pyfa sources, NOT builtin wx drags
|
||||
self.draggedFitID = None
|
||||
if type == "fit":
|
||||
activeFit = self.mainFrame.getActiveFit()
|
||||
if activeFit:
|
||||
self.draggedFitID = fitID
|
||||
|
||||
pos = wx.GetMousePosition()
|
||||
pos = self.ScreenToClient(pos)
|
||||
|
||||
self.PopupMenu(self.FitDNDPopupMenu, pos)
|
||||
|
||||
# sFit.project(activeFit,draggedFit)
|
||||
# wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=activeFit))
|
||||
|
||||
def OnPopupItemSelected(self, event):
|
||||
item = self.FitDNDPopupMenu.FindItemById(event.GetId())
|
||||
text = item.GetText()
|
||||
booster = self.options.index(text)
|
||||
if self.draggedFitID:
|
||||
sFit = service.Fit.getInstance()
|
||||
draggedFit = sFit.getFit(self.draggedFitID)
|
||||
|
||||
self.stBoosters[booster].SetLabel(draggedFit.name)
|
||||
self.Layout()
|
||||
|
||||
@@ -1427,6 +1427,13 @@ class FitItem(SFItem.SFBrowserItem):
|
||||
self.selTimer = wx.Timer(self,self.selTimerID)
|
||||
self.selTimer.Start(100)
|
||||
|
||||
self.Bind(wx.EVT_RIGHT_UP, self.OnContextMenu)
|
||||
|
||||
def OnContextMenu(self, event):
|
||||
self.mainFrame.additionsPane.gangPage.handleDrag("fit", self.fitID)
|
||||
|
||||
event.Skip()
|
||||
|
||||
def GetType(self):
|
||||
return 3
|
||||
|
||||
|
||||
Reference in New Issue
Block a user