本文整理汇总了Python中service.fit.Fit类的典型用法代码示例。如果您正苦于以下问题:Python Fit类的具体用法?Python Fit怎么用?Python Fit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Fit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: click
def click(self, event):
mainRow, _ = self.HitTest(event.Position)
if mainRow != -1:
col = self.getColumn(event.Position)
if col == self.getColIndex(State):
mainItem = self.get(mainRow)
if mainItem is None:
return
selection = self.getSelectedProjectors()
if mainItem not in selection:
selection = [mainItem]
modPressed = wx.GetMouseState().GetModifiers() == wx.MOD_ALT
fitID = self.mainFrame.getActiveFit()
if isinstance(mainItem, EosModule) and modPressed:
fit = Fit.getInstance().getFit(fitID)
positions = getSimilarModPositions(fit.projectedModules, mainItem)
selection = [fit.projectedModules[p] for p in positions]
elif isinstance(mainItem, EosFighter) and modPressed:
fit = Fit.getInstance().getFit(fitID)
selection = getSimilarFighters(fit.projectedFighters, mainItem)
self.mainFrame.command.Submit(cmd.GuiChangeProjectedItemStatesCommand(
fitID=fitID,
mainItem=mainItem,
items=selection,
click='right' if event.GetButton() == 3 else 'left'))
return
event.Skip()
示例2: __handleProjectedItem
def __handleProjectedItem(self, mainItem, selection):
fitID = self.mainFrame.getActiveFit()
if isinstance(mainItem, EosFit):
self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand(
fitID=fitID, items=selection, amount=math.inf))
elif isinstance(mainItem, EosModule):
if wx.GetMouseState().GetModifiers() == wx.MOD_ALT:
fit = Fit.getInstance().getFit(fitID)
positions = getSimilarModPositions(fit.projectedModules, mainItem)
items = [fit.projectedModules[p] for p in positions]
else:
items = selection
self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand(
fitID=fitID, items=items, amount=math.inf))
elif isinstance(mainItem, EosDrone):
self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand(
fitID=fitID, items=selection, amount=math.inf))
elif isinstance(mainItem, EosFighter):
if wx.GetMouseState().GetModifiers() == wx.MOD_ALT:
fit = Fit.getInstance().getFit(fitID)
items = getSimilarFighters(fit.projectedFighters, mainItem)
else:
items = selection
self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand(
fitID=fitID, items=items, amount=math.inf))
else:
self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand(
fitID=fitID, items=selection, amount=math.inf))
示例3: Undo
def Undo(self):
for _ in self.internal_history.Commands:
self.internal_history.Undo()
eos.db.commit()
Fit.getInstance().recalc(self.fitID)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
return True
示例4: importCrest
def importCrest(str_):
fit = json.loads(str_)
sMkt = Market.getInstance()
f = Fit()
f.name = fit['name']
try:
try:
f.ship = Ship(sMkt.getItem(fit['ship']['id']))
except ValueError:
f.ship = Citadel(sMkt.getItem(fit['ship']['id']))
except:
return None
items = fit['items']
items.sort(key=lambda k: k['flag'])
moduleList = []
for module in items:
try:
item = sMkt.getItem(module['type']['id'], eager="group.category")
if module['flag'] == INV_FLAG_DRONEBAY:
d = Drone(item)
d.amount = module['quantity']
f.drones.append(d)
elif module['flag'] == INV_FLAG_CARGOBAY:
c = Cargo(item)
c.amount = module['quantity']
f.cargo.append(c)
elif module['flag'] == INV_FLAG_FIGHTER:
fighter = Fighter(item)
f.fighters.append(fighter)
else:
try:
m = Module(item)
# When item can't be added to any slot (unknown item or just charge), ignore it
except ValueError:
continue
# Add subsystems before modules to make sure T3 cruisers have subsystems installed
if item.category.name == "Subsystem":
if m.fits(f):
f.modules.append(m)
else:
if m.isValidState(State.ACTIVE):
m.state = State.ACTIVE
moduleList.append(m)
except:
continue
# Recalc to get slot numbers correct for T3 cruisers
svcFit.getInstance().recalc(f)
for module in moduleList:
if module.fits(f):
f.modules.append(module)
return f
示例5: getText
def getText(self, stuff):
if isinstance(stuff, Drone):
return "%dx %s" % (stuff.amount, stuff.item.name)
elif isinstance(stuff, Fighter):
return "%d/%d %s" % \
(stuff.amountActive, stuff.getModifiedItemAttr("fighterSquadronMaxSize"), stuff.item.name)
elif isinstance(stuff, Cargo):
return "%dx %s" % (stuff.amount, stuff.item.name)
elif isinstance(stuff, Fit):
if self.projectedView:
# we need a little more information for the projected view
fitID = self.mainFrame.getActiveFit()
info = stuff.getProjectionInfo(fitID)
if info:
return "%dx %s (%s)" % (stuff.getProjectionInfo(fitID).amount, stuff.name, stuff.ship.item.name)
pyfalog.warning("Projected View trying to display things that aren't there. stuff: {}, info: {}", repr(stuff),
info)
return "<unknown>"
else:
return "%s (%s)" % (stuff.name, stuff.ship.item.name)
elif isinstance(stuff, Rack):
if FitSvc.getInstance().serviceFittingOptions["rackLabels"]:
if stuff.slot == FittingSlot.MODE:
return '─ Tactical Mode ─'
else:
return '─ {} {} Slot{}─'.format(stuff.num, FittingSlot(stuff.slot).name.capitalize(), '' if stuff.num == 1 else 's')
else:
return ""
elif isinstance(stuff, Module):
if self.projectedView:
# check for projected abyssal name
name_check = stuff.item.name[0:-2]
type = WhProjector.abyssal_mapping.get(name_check, None)
if type:
sMkt = Market.getInstance()
type = sMkt.getItem(type)
return "{} {}".format(type.name, stuff.item.name[-1:])
if stuff.isEmpty:
return "%s Slot" % FittingSlot(stuff.slot).name.capitalize()
else:
return stuff.item.name
elif isinstance(stuff, Implant):
return stuff.item.name
else:
item = getattr(stuff, "item", stuff)
if FitSvc.getInstance().serviceFittingOptions["showMarketShortcuts"]:
marketShortcut = getattr(item, "marketShortcut", None)
if marketShortcut:
# use unicode subscript to display shortcut value
shortcut = chr(marketShortcut + 8320) + " "
del item.marketShortcut
return shortcut + item.name
return item.name
示例6: test_getAllFits
def test_getAllFits(DB, RifterFit, KeepstarFit):
assert len(Fit.getAllFits()) == 0
DB['db'].save(RifterFit)
DB['db'].save(KeepstarFit)
# For some reason in Travis this adds the first fit twice. WHY?!?
assert len(Fit.getAllFits()) != 0
# Cleanup after ourselves
DB['db'].remove(RifterFit)
DB['db'].remove(KeepstarFit)
示例7: display
def display(self, srcContext, mainItem):
if not self.settings.get('changeAffectingSkills'):
return False
if srcContext not in (
"fittingModule", "fittingCharge",
"fittingShip", "droneItem",
"fighterItem"
):
return False
fitID = self.mainFrame.getActiveFit()
if fitID is None:
return False
if (mainItem is None or getattr(mainItem, "isEmpty", False)) and srcContext != "fittingShip":
return False
self.sChar = Character.getInstance()
self.sFit = Fit.getInstance()
fit = self.sFit.getFit(fitID)
self.charID = fit.character.ID
# if self.sChar.getCharName(self.charID) in ("All 0", "All 5"):
# return False
if srcContext == "fittingShip":
sFit = Fit.getInstance()
self.stuff = sFit.getFit(fitID).ship
cont = sFit.getFit(fitID).ship.itemModifiedAttributes
elif srcContext == "fittingCharge":
cont = mainItem.chargeModifiedAttributes
else:
cont = mainItem.itemModifiedAttributes
skills = set()
for attrName in cont.iterAfflictions():
if cont[attrName] == 0:
continue
for fit, afflictors in cont.getAfflictions(attrName).items():
for afflictor, modifier, amount, used in afflictors:
# only add Skills
if not isinstance(afflictor, Skill):
continue
skills.add(afflictor)
self.skills = sorted(skills, key=lambda x: x.item.name)
return len(self.skills) > 0
示例8: getText
def getText(self, stuff):
if isinstance(stuff, Drone):
return "%dx %s" % (stuff.amount, stuff.item.name)
elif isinstance(stuff, Fighter):
return "%d/%d %s" % \
(stuff.amountActive, stuff.getModifiedItemAttr("fighterSquadronMaxSize"), stuff.item.name)
elif isinstance(stuff, Cargo):
return "%dx %s" % (stuff.amount, stuff.item.name)
elif isinstance(stuff, Fit):
if self.projectedView:
# we need a little more information for the projected view
fitID = self.mainFrame.getActiveFit()
info = stuff.getProjectionInfo(fitID)
if info:
return "%dx %s (%s)" % (stuff.getProjectionInfo(fitID).amount, stuff.name, stuff.ship.item.name)
pyfalog.warning("Projected View trying to display things that aren't there. stuff: {}, info: {}", repr(stuff),
info)
return "<unknown>"
else:
return "%s (%s)" % (stuff.name, stuff.ship.item.name)
elif isinstance(stuff, Rack):
if FitSvc.getInstance().serviceFittingOptions["rackLabels"]:
if stuff.slot == Slot.MODE:
return u'─ Tactical Mode ─'
else:
return u'─ {} Slots ─'.format(Slot.getName(stuff.slot).capitalize())
else:
return ""
elif isinstance(stuff, Module):
if stuff.isEmpty:
return "%s Slot" % Slot.getName(stuff.slot).capitalize()
else:
return stuff.item.name
elif isinstance(stuff, Implant):
return stuff.item.name
else:
item = getattr(stuff, "item", stuff)
if FitSvc.getInstance().serviceFittingOptions["showMarketShortcuts"]:
marketShortcut = getattr(item, "marketShortcut", None)
if marketShortcut:
# use unicode subscript to display shortcut value
shortcut = unichr(marketShortcut + 8320) + u" "
del item.marketShortcut
return shortcut + item.name
return item.name
示例9: fitChanged
def fitChanged(self, event):
sFit = Fit.getInstance()
fit = sFit.getFit(event.fitID)
self.Parent.Parent.Parent.DisablePage(self.Parent, not fit)
# Clear list and get out if current fitId is None
if event.fitID is None and self.lastFitId is not None:
self.DeleteAllItems()
self.lastFitId = None
event.Skip()
return
self.original = fit.fighters if fit is not None else None
self.fighters = fit.fighters[:] if fit is not None else None
if self.fighters is not None:
self.fighters.sort(key=self.fighterKey)
if event.fitID != self.lastFitId:
self.lastFitId = event.fitID
item = self.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_DONTCARE)
if item != -1:
self.EnsureVisible(item)
self.deselectItems()
self.update(self.fighters)
event.Skip()
示例10: 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 = 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)
self.Enable(self.toggleIgnoreRestrictionID, enable)
if event.fitID:
sFit = Fit.getInstance()
fit = sFit.getFit(event.fitID)
if fit.ignoreRestrictions:
self.ignoreRestrictionItem.SetItemLabel("Enable Fitting Restrictions")
else:
self.ignoreRestrictionItem.SetItemLabel("Disable Fitting Restrictions")
event.Skip()
示例11: fitChanged
def fitChanged(self, event):
sFit = Fit.getInstance()
fit = sFit.getFit(event.fitID)
self.Parent.Parent.DisablePage(self, not fit or fit.isStructure)
# Clear list and get out if current fitId is None
if event.fitID is None and self.lastFitId is not None:
self.DeleteAllItems()
self.lastFitId = None
event.Skip()
return
self.origional = fit.boosters if fit is not None else None
self.boosters = stuff = fit.boosters[:] if fit is not None else None
if event.fitID != self.lastFitId:
self.lastFitId = event.fitID
item = self.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_DONTCARE)
if item != -1:
self.EnsureVisible(item)
self.deselectItems()
self.populate(stuff)
self.refresh(stuff)
event.Skip()
示例12: fitSelected
def fitSelected(self, event):
count = -1
# @todo pheonix: _pages is supposed to be private?
for index, page in enumerate(self.multiSwitch._pages):
if not isinstance(page, gui.builtinViews.emptyView.BlankPage): # Don't try and process it if it's a blank page.
try:
if page.activeFitID == event.fitID:
count += 1
self.multiSwitch.SetSelection(index)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=event.fitID))
break
except Exception as e:
pyfalog.critical("Caught exception in fitSelected")
pyfalog.critical(e)
if count < 0:
startup = getattr(event, "startup", False) # see OpenFitsThread in gui.mainFrame
from_import = getattr(event, "from_import", False) # always open imported into a new tab
sFit = Fit.getInstance()
openFitInNew = sFit.serviceFittingOptions["openFitInNew"]
mstate = wx.GetMouseState()
if from_import or (not openFitInNew and mstate.CmdDown()) or startup or (openFitInNew and not mstate.CmdDown()):
self.multiSwitch.AddPage()
view = self.multiSwitch.GetSelectedPage()
if not isinstance(view, FittingView):
view = FittingView(self.multiSwitch)
pyfalog.debug("###################### Created new view:" + repr(view))
self.multiSwitch.ReplaceActivePage(view)
view.fitSelected(event)
示例13: appendItem
def appendItem(self, event):
"""
Adds items that are double clicks from the market browser. We handle both modules and ammo
"""
if not self:
event.Skip()
return
if self.parent.IsActive(self):
itemID = event.itemID
fitID = self.activeFitID
if fitID is not None:
sFit = Fit.getInstance()
if sFit.isAmmo(itemID):
# If we've selected ammo, then apply to the selected module(s)
modules = []
sel = self.GetFirstSelected()
while sel != -1 and sel not in self.blanks:
mod = self.mods[self.GetItemData(sel)]
if isinstance(mod, Module) and not mod.isEmpty:
modules.append(self.mods[self.GetItemData(sel)])
sel = self.GetNextSelected(sel)
if len(modules) > 0:
self.mainFrame.command.Submit(cmd.GuiModuleAddChargeCommand(fitID, itemID, modules))
else:
self.mainFrame.command.Submit(cmd.GuiModuleAddCommand(fitID, itemID))
event.Skip()
示例14: fitChanged
def fitChanged(self, event):
sFit = Fit.getInstance()
fit = sFit.getFit(event.fitID)
self.Parent.Parent.Parent.DisablePage(self.Parent, not fit or fit.isStructure)
# Clear list and get out if current fitId is None
if event.fitID is None and self.lastFitId is not None:
self.DeleteAllItems()
self.lastFitId = None
event.Skip()
return
self.original = fit.implants if fit is not None else None
self.implants = stuff = fit.appliedImplants if fit is not None else None
if stuff is not None:
stuff.sort(key=lambda implant: implant.slot)
if event.fitID != self.lastFitId:
self.lastFitId = event.fitID
item = self.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_DONTCARE)
if item != -1:
self.EnsureVisible(item)
self.deselectItems()
self.update(stuff)
event.Skip()
示例15: _merge
def _merge(self, src, dst):
dstDrone = self.get(dst)
if isinstance(dstDrone, es_Drone):
sFit = Fit.getInstance()
fitID = self.mainFrame.getActiveFit()
if sFit.mergeDrones(fitID, self.get(src), dstDrone, True):
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))