Add PvP weather to abyssal weather menu

This commit is contained in:
DarkPhoenix
2018-11-22 16:17:54 +03:00
parent 8f0e8f72cd
commit 4845b3b0ce
4 changed files with 49 additions and 38 deletions

View File

@@ -3,6 +3,7 @@
# Used by:
# Modules from group: Drone Damage Modules (11 of 11)
# Modules named like: C3 'Hivaa Saitsuo' Ballistic Control System (2 of 2)
# Module: Abyssal Ballistic Control System
type = "passive"

View File

@@ -3,7 +3,7 @@
# Used by:
# Structure Modules from group: Structure Citadel Service Module (2 of 2)
# Structure Modules from group: Structure Engineering Service Module (6 of 6)
# Structure Modules from group: Structure Navigation Service Module (2 of 2)
# Structure Modules from group: Structure Navigation Service Module (3 of 3)
# Structure Modules from group: Structure Resource Processing Service Module (4 of 4)
# Structure Module: Standup Moon Drill I
type = "passive"

View File

@@ -4,6 +4,7 @@
# Celestial: darkness_weather_1
# Celestial: darkness_weather_2
# Celestial: darkness_weather_3
# Celestial: pvp_weather_1
runTime = "early"
type = ("projected", "passive", "gang")

View File

@@ -15,7 +15,7 @@ class WhProjector(ContextMenu):
# CCP doesn't currently provide a mapping between the general Environment, and the specific environment effect
# (which can be random when going into Abyssal space). This is how we currently define it:
# environment type: specific type name previx
# environment type: specific type name prefix
abyssal_mapping = {
'caustic_toxin_weather': 47862, # Exotic Particle Storm
'darkness_weather': 47863, # Dark Matter Field
@@ -50,13 +50,13 @@ class WhProjector(ContextMenu):
wormhole_item.SetSubMenu(wormhole_menu)
sub.Append(wormhole_item)
effdata = self.getEffectBeacons()
self.buildMenu(effdata, wormhole_menu, rootMenu, msw)
grouped_data, flat_data = self.getEffectBeacons()
self.buildMenu(grouped_data, flat_data, wormhole_menu, rootMenu, msw)
# Incursions
effdata = self.getEffectBeacons(incursions=True)
self.buildMenu(effdata, sub, rootMenu, msw)
grouped_data, flat_data = self.getEffectBeacons(incursions=True)
self.buildMenu(grouped_data, flat_data, sub, rootMenu, msw)
# Abyssal Weather
@@ -65,8 +65,8 @@ class WhProjector(ContextMenu):
abyssal_item.SetSubMenu(abyssal_menu)
sub.Append(abyssal_item)
effdata = self.getAbyssalWeather()
self.buildMenu(effdata, abyssal_menu, rootMenu, msw)
grouped_data, flat_data = self.getAbyssalWeather()
self.buildMenu(grouped_data, flat_data, abyssal_menu, rootMenu, msw)
# Localized Weather
@@ -75,8 +75,8 @@ class WhProjector(ContextMenu):
local_item.SetSubMenu(local_menu)
sub.Append(local_item)
effdata = self.getLocalizedEnvironments()
self.buildMenu(effdata, local_menu, rootMenu, msw)
grouped_data, flat_data = self.getLocalizedEnvironments()
self.buildMenu(grouped_data, flat_data, local_menu, rootMenu, msw)
return sub
@@ -91,33 +91,38 @@ class WhProjector(ContextMenu):
fitID = self.mainFrame.getActiveFit()
self.mainFrame.command.Submit(cmd.GuiAddProjectedCommand(fitID, swObj.ID, 'item'))
def buildMenu(self, data, local_menu, rootMenu, msw):
for swType in sorted(data):
def buildMenu(self, grouped_data, flat_data, local_menu, rootMenu, msw):
def processFlat(data, root, sub):
for swData in sorted(data, key=lambda tpl: tpl[2]):
wxid = ContextMenu.nextID()
swObj, swName, swClass = swData
self.idmap[wxid] = (swObj, swName)
subItem = wx.MenuItem(sub, wxid, swClass)
if msw:
root.Bind(wx.EVT_MENU, self.handleSelection, subItem)
else:
sub.Bind(wx.EVT_MENU, self.handleSelection, subItem)
sub.Append(subItem)
for swType in sorted(grouped_data):
subItem = wx.MenuItem(local_menu, wx.ID_ANY, swType)
grandSub = wx.Menu()
subItem.SetSubMenu(grandSub)
local_menu.Append(subItem)
processFlat(grouped_data[swType], rootMenu, grandSub)
for swData in sorted(data[swType], key=lambda tpl: tpl[2]):
wxid = ContextMenu.nextID()
swObj, swName, swClass = swData
self.idmap[wxid] = (swObj, swName)
grandSubItem = wx.MenuItem(grandSub, wxid, swClass)
if msw:
rootMenu.Bind(wx.EVT_MENU, self.handleSelection, grandSubItem)
else:
grandSub.Bind(wx.EVT_MENU, self.handleSelection, grandSubItem)
grandSub.Append(grandSubItem)
processFlat(flat_data, rootMenu, local_menu)
def getEffectBeacons(self, incursions=False):
"""
Get dictionary with system-wide effects
Get dictionary with wormhole system-wide effects
"""
sMkt = Market.getInstance()
# todo: rework this
# Container for system-wide effects
effects = {}
grouped = {}
# Expressions for matching when detecting effects we're looking for
if incursions:
@@ -158,13 +163,13 @@ class WhProjector(ContextMenu):
groupname = re.sub(garbage, "", groupname)
groupname = re.sub(" {2,}", " ", groupname).strip()
# Add stuff to dictionary
if groupname not in effects:
effects[groupname] = set()
effects[groupname].add((beacon, beaconname, shortname))
if groupname not in grouped:
grouped[groupname] = set()
grouped[groupname].add((beacon, beaconname, shortname))
# Break loop on 1st result
break
return effects
return grouped, ()
def getAbyssalWeather(self):
sMkt = Market.getInstance()
@@ -172,7 +177,8 @@ class WhProjector(ContextMenu):
environments = {x.ID: x for x in sMkt.getGroup("Abyssal Environment").items}
items = chain(sMkt.getGroup("MassiveEnvironments").items, sMkt.getGroup("Non-Interactable Object").items)
effects = {}
grouped = {}
flat = set()
for beacon in items:
if not beacon.isType('projected'):
@@ -183,20 +189,23 @@ class WhProjector(ContextMenu):
if type is None:
continue
if type.name not in effects:
effects[type.name] = set()
if type.name not in grouped:
grouped[type.name] = set()
display_name = "{} {}".format(type.name, beacon.name[-1:])
effects[type.name].add((beacon, display_name, display_name))
grouped[type.name].add((beacon, display_name, display_name))
return effects
# PVP weather
flat.add((sMkt.getItem(49766), 'PvP Weather', 'PvP Weather'))
return grouped, flat
def getLocalizedEnvironments(self):
sMkt = Market.getInstance()
grp = sMkt.getGroup("Abyssal Hazards")
effects = dict()
grouped = dict()
for beacon in grp.items:
if not beacon.isType('projected'):
@@ -206,12 +215,12 @@ class WhProjector(ContextMenu):
name_parts = beacon.name.split(" ")
key = name_parts[1].strip()
if key not in effects:
effects[key] = set()
if key not in grouped:
grouped[key] = set()
effects[key].add((beacon, beacon.name, beacon.name))
grouped[key].add((beacon, beacon.name, beacon.name))
return effects
return grouped, ()
WhProjector.register()