Fix some bugs and add forgotten files

This commit is contained in:
cncfanatics
2010-10-29 11:29:49 +02:00
parent c6daf72682
commit 5c8b18aa28
6 changed files with 148 additions and 6 deletions

View File

@@ -8,11 +8,16 @@ class ItemStats(ContextMenu):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def display(self, context, selection):
return context in ("item", "ship", "module", "ammo", "skill", "itemSearch", "drone", "implant", "booster")
return context in ("item", "ship", "module", "ammo", "skill",
"itemSearch", "drone", "implant", "booster",
"projectedModule", "projectedDrone")
def getText(self, context, selection):
return "%s stats" % (context.capitalize() if context != "itemSearch" else "Item")
return "%s stats" % (context.capitalize() if context not in self.REPLACES else self.REPLACES[context])
REPLACES = {"itemSearch": "Item",
"projectedModule": "Module",
"projectedDrone": "Drone"}
def activate(self, context, selection, i):
if context == "ship":
fitID = self.mainFrame.getActiveFit()
@@ -24,6 +29,6 @@ class ItemStats(ContextMenu):
if context == "module" and stuff.isEmpty:
return
dlg=ItemStatsDialog(stuff, context if context != "itemSearch" else "Item")
dlg=ItemStatsDialog(stuff, context.capitalize() if context not in self.REPLACES else self.REPLACES[context])
ItemStats.register()

View File

@@ -0,0 +1,27 @@
from gui.contextMenu import ContextMenu
import gui.mainFrame
import service
import gui.fittingView
import wx
class Project(ContextMenu):
def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def display(self, context, selection):
if context not in ("item", "itemSearch") or self.mainFrame.getActiveFit() is None:
return False
item = selection[0]
return item.isType("projected")
def getText(self, context, selection):
return "Project onto Fit"
def activate(self, context, selection, i):
sFit = service.Fit.getInstance()
fitID = self.mainFrame.getActiveFit()
sFit.project(fitID, selection[0])
wx.PostEvent(self.mainFrame, gui.fittingView.FitChanged(fitID=fitID))
Project.register()

View File

@@ -0,0 +1,45 @@
#===============================================================================
# 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/>.
#===============================================================================
from gui.viewColumn import ViewColumn
import gui.builtinViewColumns.name
import gui.builtinViewColumns.droneNameAmount
from eos.types import Drone
class ProjectedName(ViewColumn):
name = "Projected Name"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
self.columnText = "Name"
self.slave = gui.builtinViewColumns.name.StuffName(fittingView, params)
self.droneSlave = gui.builtinViewColumns.droneNameAmount.DroneNameAmount(fittingView, params)
def getText(self, stuff):
if isinstance(stuff, Drone):
return self.droneSlave.getText(stuff)
else:
return self.slave.getText(stuff)
def getImageId(self, thing):
if isinstance(thing, Drone):
return self.droneSlave.getImageId(thing)
else:
return self.slave.getImageId(thing)
ProjectedName.register()

View File

@@ -0,0 +1,55 @@
#===============================================================================
# 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/>.
#===============================================================================
from gui import builtinViewColumns
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
from eos.types import Slot
import gui.builtinViewColumns.moduleState
import gui.builtinViewColumns.droneCheckbox
from eos.types import Module, Drone, Fit
import gui.bitmapLoader
class ProjectedState(ViewColumn):
name = "Projected State"
def __init__(self, view, params):
ViewColumn.__init__(self, view)
self.columnText = ""
self.size = 20
self.fitImageId = view.imageList.Add(gui.bitmapLoader.getBitmap("fit_small", "icons"))
self.moduleSlave = gui.builtinViewColumns.moduleState.ModuleState(view, params)
self.droneSlave = gui.builtinViewColumns.droneCheckbox.DroneCheckbox(view, params)
def getText(self, stuff):
if isinstance(stuff, Module):
return self.moduleSlave.getText(stuff)
elif isinstance(stuff, Drone):
return self.droneSlave.getText(stuff)
else:
return ""
def getImageId(self, stuff):
if isinstance(stuff, Module):
return self.moduleSlave.getImageId(stuff)
elif isinstance(stuff, Drone):
return self.droneSlave.getImageId(stuff)
else:
return self.fitImageId
ProjectedState.register()

View File

@@ -68,7 +68,7 @@ class ContextMenu(object):
if amount > 0 and i != len(contexts) - 1:
menu.AppendSeparator()
return menu if not empty else None
return menu
@classmethod
def handler(cls, event):

View File

@@ -24,6 +24,7 @@ import service
import gui.droneView
from gui.builtinViewColumns.projectedState import ProjectedState
from gui.contextMenu import ContextMenu
import eos.types
class ProjectedView(d.Display):
DEFAULT_COLS = ["Projected State",
@@ -86,14 +87,23 @@ class ProjectedView(d.Display):
event.Skip()
row, _ = self.HitTest(event.Position)
if row != -1:
item = self.get(row)
col = self.getColumn(event.Position)
if col == self.getColIndex(ProjectedState):
fitID = self.mainFrame.getActiveFit()
cFit = service.Fit.getInstance()
cFit.toggleProjected(fitID, self.get(row), "right" if event.Button == 3 else "left")
cFit.toggleProjected(fitID, item, "right" if event.Button == 3 else "left")
wx.PostEvent(self.mainFrame, fv.FitChanged(fitID=fitID))
elif event.Button == 3:
menu = ContextMenu.getMenu((self.get(row),), "projectedDrone")
if isinstance(item, eos.types.Drone):
context = "projectedDrone"
elif isinstance(item, eos.types.Module):
context = "projectedModule"
else:
context = "projectedFit"
print item, context
menu = ContextMenu.getMenu((item,), context)
self.PopupMenu(menu)
def remove(self, event):