Start defining grouping in another file to keep it contained
This commit is contained in:
233
gui/builtinItemStatsViews/attributeGrouping.py
Normal file
233
gui/builtinItemStatsViews/attributeGrouping.py
Normal file
@@ -0,0 +1,233 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class AttrGroupingType(Enum):
|
||||
# These are self-explanatory
|
||||
LABEL = 0
|
||||
NORMAL = 1
|
||||
RESIST = 2
|
||||
SENSOR = 3
|
||||
|
||||
|
||||
# Define the various groups of attributes
|
||||
class AttrGroup(Enum):
|
||||
FITTING = 0
|
||||
STRUCTURE = 1
|
||||
SHIELD = 2
|
||||
ARMOR = 3
|
||||
TARGETING = 4
|
||||
EWAR_RESISTS = 5
|
||||
CAPACITOR = 6
|
||||
SHARED_FACILITIES = 7
|
||||
FIGHTER_FACILITIES = 8
|
||||
ON_DEATH = 9
|
||||
JUMP_SYSTEMS = 10
|
||||
PROPULSIONS = 11
|
||||
FIGHTERS = 12
|
||||
|
||||
|
||||
RequiredSkillAttrs = sum((["requiredSkill{}".format(x), "requiredSkill{}Level".format(x)] for x in range(1, 7)), [])
|
||||
|
||||
|
||||
AttrGroupDict = {
|
||||
AttrGroup.FITTING : {
|
||||
AttrGroupingType.LABEL: "Fitting",
|
||||
AttrGroupingType.NORMAL: [
|
||||
"cpu",
|
||||
"power",
|
||||
"rigSize",
|
||||
"upgradeCost",
|
||||
"attributeMass", ]
|
||||
},
|
||||
AttrGroup.STRUCTURE : {
|
||||
AttrGroupingType.LABEL: "Structure",
|
||||
AttrGroupingType.NORMAL: [
|
||||
"hp",
|
||||
"capacity",
|
||||
"mass",
|
||||
"volume",
|
||||
"agility",
|
||||
"droneCapacity",
|
||||
"droneBandwidth",
|
||||
"specialOreHoldCapacity",
|
||||
"specialGasHoldCapacity",
|
||||
"specialMineralHoldCapacity",
|
||||
"specialSalvageHoldCapacity",
|
||||
"specialShipHoldCapacity",
|
||||
"specialSmallShipHoldCapacity",
|
||||
"specialMediumShipHoldCapacity",
|
||||
"specialLargeShipHoldCapacity",
|
||||
"specialIndustrialShipHoldCapacity",
|
||||
"specialAmmoHoldCapacity",
|
||||
"specialCommandCenterHoldCapacity",
|
||||
"specialPlanetaryCommoditiesHoldCapacity",
|
||||
"structureDamageLimit",
|
||||
"specialSubsystemHoldCapacity",
|
||||
],
|
||||
AttrGroupingType.RESIST: [
|
||||
("em", "emDamageResonance"),
|
||||
("thermal", "thermalDamageResonance"),
|
||||
("kinetic", "kineticDamageResonance"),
|
||||
("explosive", "explosiveDamageResonance")
|
||||
]
|
||||
},
|
||||
AttrGroup.ARMOR : {
|
||||
AttrGroupingType.LABEL: "Armor",
|
||||
AttrGroupingType.NORMAL: [
|
||||
"armorHP",
|
||||
"armorDamageLimit"
|
||||
],
|
||||
AttrGroupingType.RESIST: [
|
||||
("em", "armorEmDamageResonance"),
|
||||
("thermal", "armorThermalDamageResonance"),
|
||||
("kinetic", "armorKineticDamageResonance"),
|
||||
("explosive", "armorExplosiveDamageResonance")
|
||||
]
|
||||
|
||||
},
|
||||
AttrGroup.SHIELD : {
|
||||
AttrGroupingType.LABEL: "Shield",
|
||||
AttrGroupingType.NORMAL: [
|
||||
"shieldCapacity",
|
||||
"shieldRechargeRate",
|
||||
"shieldDamageLimit"
|
||||
],
|
||||
AttrGroupingType.RESIST: [
|
||||
("em", "shieldEmDamageResonance"),
|
||||
("thermal", "shieldExplosiveDamageResonance"),
|
||||
("kinetic", "shieldKineticDamageResonance"),
|
||||
("explosive", "shieldThermalDamageResonance")
|
||||
]
|
||||
|
||||
},
|
||||
AttrGroup.EWAR_RESISTS : {
|
||||
AttrGroupingType.LABEL: "Electronic Warfare",
|
||||
AttrGroupingType.NORMAL: [
|
||||
"ECMResistance",
|
||||
"remoteAssistanceImpedance",
|
||||
"remoteRepairImpedance",
|
||||
"energyWarfareResistance",
|
||||
"sensorDampenerResistance",
|
||||
"stasisWebifierResistance",
|
||||
"targetPainterResistance",
|
||||
"weaponDisruptionResistance",
|
||||
]
|
||||
},
|
||||
AttrGroup.CAPACITOR : {
|
||||
AttrGroupingType.LABEL: "Capacitor",
|
||||
AttrGroupingType.NORMAL: [
|
||||
"capacitorCapacity",
|
||||
"rechargeRate",
|
||||
]
|
||||
},
|
||||
AttrGroup.TARGETING : {
|
||||
AttrGroupingType.LABEL: "Targeting",
|
||||
AttrGroupingType.NORMAL: [
|
||||
"maxTargetRange",
|
||||
"maxRange",
|
||||
"maxLockedTargets",
|
||||
"signatureRadius",
|
||||
"optimalSigRadius",
|
||||
"scanResolution",
|
||||
"proximityRange",
|
||||
"falloff",
|
||||
"trackingSpeed",
|
||||
],
|
||||
AttrGroupingType.SENSOR: [
|
||||
"scanLadarStrength",
|
||||
"scanMagnetometricStrength",
|
||||
"scanGravimetricStrength",
|
||||
"scanRadarStrength",
|
||||
]
|
||||
},
|
||||
AttrGroup.SHARED_FACILITIES : {
|
||||
AttrGroupingType.LABEL: "Shared Facilities",
|
||||
AttrGroupingType.NORMAL: [
|
||||
"shipMaintenanceBayCapacity",
|
||||
"fleetHangarCapacity",
|
||||
"maxJumpClones",
|
||||
]
|
||||
},
|
||||
AttrGroup.FIGHTER_FACILITIES: {
|
||||
AttrGroupingType.LABEL: "Fighter Squadron Facilities",
|
||||
AttrGroupingType.NORMAL: [
|
||||
"fighterCapacity",
|
||||
"fighterTubes",
|
||||
"fighterLightSlots",
|
||||
"fighterSupportSlots",
|
||||
"fighterHeavySlots",
|
||||
"fighterStandupLightSlots",
|
||||
"fighterStandupSupportSlots",
|
||||
"fighterStandupHeavySlots",
|
||||
]
|
||||
},
|
||||
AttrGroup.ON_DEATH : {
|
||||
AttrGroupingType.LABEL: "On Death",
|
||||
AttrGroupingType.NORMAL: [
|
||||
"onDeathDamageEM",
|
||||
"onDeathDamageTherm",
|
||||
"onDeathDamageKin",
|
||||
"onDeathDamageExp",
|
||||
"onDeathAOERadius",
|
||||
"onDeathSignatureRadius",
|
||||
]
|
||||
},
|
||||
AttrGroup.JUMP_SYSTEMS : {
|
||||
AttrGroupingType.LABEL: "Jump Drive Systems",
|
||||
AttrGroupingType.NORMAL: [
|
||||
"jumpDriveCapacitorNeed",
|
||||
"jumpDriveRange",
|
||||
"jumpDriveConsumptionType",
|
||||
"jumpDriveConsumptionAmount",
|
||||
"jumpPortalCapacitorNeed",
|
||||
"jumpDriveDuration",
|
||||
"specialFuelBayCapacity",
|
||||
"jumpPortalConsumptionMassFactor",
|
||||
"jumpPortalDuration",
|
||||
]
|
||||
},
|
||||
AttrGroup.PROPULSIONS : {
|
||||
AttrGroupingType.LABEL: "Propulsion",
|
||||
AttrGroupingType.NORMAL: [
|
||||
"maxVelocity"
|
||||
]
|
||||
},
|
||||
AttrGroup.FIGHTERS : {
|
||||
AttrGroupingType.LABEL: "Fighters",
|
||||
AttrGroupingType.NORMAL: [
|
||||
"mass",
|
||||
"maxVelocity",
|
||||
"agility",
|
||||
"volume",
|
||||
"signatureRadius",
|
||||
"fighterSquadronMaxSize",
|
||||
"fighterSquadronOrbitRange",
|
||||
"fighterRefuelingTime",
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
Group1 = [
|
||||
AttrGroup.STRUCTURE,
|
||||
AttrGroup.ARMOR,
|
||||
AttrGroup.SHIELD,
|
||||
AttrGroup.EWAR_RESISTS,
|
||||
AttrGroup.CAPACITOR,
|
||||
AttrGroup.TARGETING,
|
||||
AttrGroup.SHARED_FACILITIES,
|
||||
AttrGroup.FIGHTER_FACILITIES,
|
||||
AttrGroup.ON_DEATH,
|
||||
AttrGroup.JUMP_SYSTEMS,
|
||||
AttrGroup.PROPULSIONS,
|
||||
]
|
||||
|
||||
CategoryGroups = {
|
||||
"Fighter" : [
|
||||
AttrGroup.FIGHTERS,
|
||||
AttrGroup.SHIELD,
|
||||
AttrGroup.TARGETING,
|
||||
],
|
||||
"Ship" : Group1,
|
||||
"Drone" : Group1,
|
||||
"Structure": Group1
|
||||
}
|
||||
@@ -10,198 +10,9 @@ from gui.builtinItemStatsViews.helpers import AutoListCtrl
|
||||
from gui.bitmap_loader import BitmapLoader
|
||||
from gui.utils.numberFormatter import formatAmount
|
||||
from enum import Enum
|
||||
from gui.builtinItemStatsViews.attributeGrouping import *
|
||||
|
||||
|
||||
class AttrGrouping(Enum):
|
||||
# These are self-explanatory
|
||||
NORMAL = 1
|
||||
RESIST = 2
|
||||
SENSOR = 3
|
||||
|
||||
|
||||
attr_order = {
|
||||
"Fighter": {
|
||||
"Fighters":{
|
||||
AttrGrouping.NORMAL: [
|
||||
"mass",
|
||||
"maxVelocity",
|
||||
"agility",
|
||||
"volume",
|
||||
"signatureRadius",
|
||||
"fighterSquadronMaxSize",
|
||||
"fighterSquadronOrbitRange",
|
||||
"fighterRefuelingTime",
|
||||
]
|
||||
},
|
||||
"Shield": { # break these up into various constants, since this can be used in fighters as well as ships maybe?
|
||||
AttrGrouping.NORMAL: [
|
||||
"shieldCapacity",
|
||||
"shieldRechargeRate"
|
||||
],
|
||||
AttrGrouping.RESIST: [
|
||||
("em", "shieldEmDamageResonance"),
|
||||
("thermal","shieldExplosiveDamageResonance"),
|
||||
("kinetic", "shieldKineticDamageResonance"),
|
||||
("explosive", "shieldThermalDamageResonance")
|
||||
]
|
||||
},
|
||||
"Targeting": {
|
||||
AttrGrouping.NORMAL: [
|
||||
"maxTargetRange",
|
||||
"maxLockedTargets",
|
||||
"scanRadarStrength",
|
||||
"scanLadarStrength",
|
||||
"scanMagnetometricStrength",
|
||||
"scanGravimetricStrength",
|
||||
"scanResolution",
|
||||
]
|
||||
}
|
||||
},
|
||||
'default': {
|
||||
"Structure": {
|
||||
AttrGrouping.NORMAL: [
|
||||
"hp",
|
||||
"capacity",
|
||||
"mass",
|
||||
"volume",
|
||||
"agility",
|
||||
"droneCapacity",
|
||||
"droneBandwidth",
|
||||
"specialOreHoldCapacity",
|
||||
"specialGasHoldCapacity",
|
||||
"specialMineralHoldCapacity",
|
||||
"specialSalvageHoldCapacity",
|
||||
"specialShipHoldCapacity",
|
||||
"specialSmallShipHoldCapacity",
|
||||
"specialMediumShipHoldCapacity",
|
||||
"specialLargeShipHoldCapacity",
|
||||
"specialIndustrialShipHoldCapacity",
|
||||
"specialAmmoHoldCapacity",
|
||||
"specialCommandCenterHoldCapacity",
|
||||
"specialPlanetaryCommoditiesHoldCapacity",
|
||||
"structureDamageLimit",
|
||||
"specialSubsystemHoldCapacity",
|
||||
],
|
||||
AttrGrouping.RESIST: [
|
||||
("em", "emDamageResonance"),
|
||||
("thermal", "thermalDamageResonance"),
|
||||
("kinetic", "kineticDamageResonance"),
|
||||
("explosive", "explosiveDamageResonance")
|
||||
]
|
||||
},
|
||||
"Armor": {
|
||||
AttrGrouping.NORMAL: [
|
||||
"armorHP",
|
||||
"armorDamageLimit"
|
||||
],
|
||||
AttrGrouping.RESIST: [
|
||||
("em","armorEmDamageResonance"),
|
||||
("thermal","armorThermalDamageResonance"),
|
||||
("kinetic", "armorKineticDamageResonance"),
|
||||
("explosive","armorExplosiveDamageResonance")
|
||||
]
|
||||
|
||||
},
|
||||
"Shield": {
|
||||
AttrGrouping.NORMAL: [
|
||||
"shieldCapacity",
|
||||
"shieldRechargeRate",
|
||||
"shieldDamageLimit"
|
||||
],
|
||||
AttrGrouping.RESIST: [
|
||||
("em", "shieldEmDamageResonance"),
|
||||
("thermal", "shieldExplosiveDamageResonance"),
|
||||
("kinetic", "shieldKineticDamageResonance"),
|
||||
("explosive", "shieldThermalDamageResonance")
|
||||
]
|
||||
|
||||
},
|
||||
"Electronic Resistances": {
|
||||
AttrGrouping.NORMAL: [
|
||||
"ECMResistance",
|
||||
"remoteAssistanceImpedance",
|
||||
"remoteRepairImpedance",
|
||||
"energyWarfareResistance",
|
||||
"sensorDampenerResistance",
|
||||
"stasisWebifierResistance",
|
||||
"targetPainterResistance",
|
||||
"weaponDisruptionResistance",
|
||||
]
|
||||
},
|
||||
"Capacitor": {
|
||||
AttrGrouping.NORMAL: [
|
||||
"capacitorCapacity",
|
||||
"rechargeRate",
|
||||
]
|
||||
},
|
||||
"Targeting": {
|
||||
AttrGrouping.NORMAL: [
|
||||
"maxTargetRange",
|
||||
"maxRange",
|
||||
"maxLockedTargets",
|
||||
"signatureRadius",
|
||||
"optimalSigRadius",
|
||||
"scanResolution",
|
||||
"proximityRange",
|
||||
"falloff",
|
||||
"trackingSpeed",
|
||||
],
|
||||
AttrGrouping.SENSOR: [
|
||||
"scanLadarStrength",
|
||||
"scanMagnetometricStrength",
|
||||
"scanGravimetricStrength",
|
||||
"scanRadarStrength",
|
||||
]
|
||||
},
|
||||
"Shared Facilities": {
|
||||
AttrGrouping.NORMAL: ["shipMaintenanceBayCapacity",
|
||||
"fleetHangarCapacity",
|
||||
"maxJumpClones",
|
||||
]
|
||||
},
|
||||
"Fighter Squadron Facilities": {
|
||||
AttrGrouping.NORMAL: [
|
||||
"fighterCapacity",
|
||||
"fighterTubes",
|
||||
"fighterLightSlots",
|
||||
"fighterSupportSlots",
|
||||
"fighterHeavySlots",
|
||||
"fighterStandupLightSlots",
|
||||
"fighterStandupSupportSlots",
|
||||
"fighterStandupHeavySlots",
|
||||
]
|
||||
},
|
||||
"On Death": {
|
||||
AttrGrouping.NORMAL: [
|
||||
"onDeathDamageEM",
|
||||
"onDeathDamageTherm",
|
||||
"onDeathDamageKin",
|
||||
"onDeathDamageExp",
|
||||
"onDeathAOERadius",
|
||||
"onDeathSignatureRadius",
|
||||
]
|
||||
},
|
||||
"Jump Drive Systems": {
|
||||
AttrGrouping.NORMAL: [
|
||||
"jumpDriveCapacitorNeed",
|
||||
"jumpDriveRange",
|
||||
"jumpDriveConsumptionType",
|
||||
"jumpDriveConsumptionAmount",
|
||||
"jumpPortalCapacitorNeed",
|
||||
"jumpDriveDuration",
|
||||
"specialFuelBayCapacity",
|
||||
"jumpPortalConsumptionMassFactor",
|
||||
"jumpPortalDuration",
|
||||
]
|
||||
},
|
||||
"Propulsion": {
|
||||
AttrGrouping.NORMAL: [
|
||||
"maxVelocity"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ItemParams(wx.Panel):
|
||||
def __init__(self, parent, stuff, item, context=None):
|
||||
wx.Panel.__init__(self, parent)
|
||||
@@ -268,10 +79,10 @@ class ItemParams(wx.Panel):
|
||||
|
||||
def UpdateList(self):
|
||||
self.Freeze()
|
||||
self.paramList.ClearAll()
|
||||
self.paramList.DeleteRoot()
|
||||
self.PopulateList()
|
||||
self.Thaw()
|
||||
self.paramList.resizeLastColumn(100)
|
||||
# self.paramList.resizeLastColumn(100)
|
||||
|
||||
def RefreshValues(self, event):
|
||||
self._fetchValues()
|
||||
@@ -350,7 +161,7 @@ class ItemParams(wx.Panel):
|
||||
self.paramList.AddColumn("Base Value")
|
||||
|
||||
self.paramList.SetMainColumn(0) # the one with the tree in it...
|
||||
self.paramList.SetColumnWidth(0, 175)
|
||||
self.paramList.SetColumnWidth(0, 300)
|
||||
|
||||
root = self.paramList.AddRoot("The Root Item")
|
||||
# self.paramList.setResizeColumn(0)
|
||||
@@ -362,12 +173,14 @@ class ItemParams(wx.Panel):
|
||||
misc_parent = root
|
||||
|
||||
if self.item.category.categoryName in ("Ship", "Fighter"):
|
||||
order = attr_order.get(self.item.category.categoryName, attr_order.get("default"))
|
||||
order = CategoryGroups.get(self.item.category.categoryName, {})
|
||||
# start building out the tree
|
||||
for heading, data in order.items():
|
||||
for data in [AttrGroupDict[o] for o in order]:
|
||||
heading = data.get(AttrGroupingType.LABEL)
|
||||
|
||||
header_item = self.paramList.AppendItem(root, heading)
|
||||
|
||||
for attr in data.get(AttrGrouping.NORMAL, []):
|
||||
for attr in data.get(AttrGroupingType.NORMAL, []):
|
||||
if attr in self.attrValues:
|
||||
attrIcon, attrName, currentVal, baseVal = self.GetData(attr)
|
||||
attr_item = self.paramList.AppendItem(header_item, attrName)
|
||||
@@ -381,10 +194,10 @@ class ItemParams(wx.Panel):
|
||||
print("{} has x: {}".format(attrName, attr_item.GetTextX()))
|
||||
processed_attribs.add(attr)
|
||||
|
||||
resists = data.get(AttrGrouping.RESIST, [])
|
||||
resists = data.get(AttrGroupingType.RESIST, [])
|
||||
if len(resists) > 0:
|
||||
resist_item = self.paramList.AppendItem(header_item, "Resistances")
|
||||
for _, attr in data.get(AttrGrouping.RESIST, []):
|
||||
for _, attr in data.get(AttrGroupingType.RESIST, []):
|
||||
if attr in self.attrValues:
|
||||
attrIcon, attrName, currentVal, baseVal = self.GetData(attr)
|
||||
attr_item = self.paramList.AppendItem(resist_item , attrName)
|
||||
@@ -397,10 +210,10 @@ class ItemParams(wx.Panel):
|
||||
print("{} has x: {}".format(attrName, attr_item.GetTextX()))
|
||||
self.paramList.Expand(resist_item)
|
||||
|
||||
sensors = data.get(AttrGrouping.SENSOR, [])
|
||||
sensors = data.get(AttrGroupingType.SENSOR, [])
|
||||
if len(sensors) > 0:
|
||||
sensor_item = self.paramList.AppendItem(header_item, "Sensor Strengths")
|
||||
for attr in data.get(AttrGrouping.SENSOR, []):
|
||||
for attr in data.get(AttrGroupingType.SENSOR, []):
|
||||
if attr in self.attrValues:
|
||||
attrIcon, attrName, currentVal, baseVal = self.GetData(attr)
|
||||
attr_item = self.paramList.AppendItem(sensor_item, attrName)
|
||||
@@ -533,8 +346,9 @@ if __name__ == "__main__":
|
||||
config.defPaths(None)
|
||||
|
||||
class Frame(wx.Frame):
|
||||
def __init__(self, title):
|
||||
super().__init__(None, title=title, size=(1000, 500))
|
||||
def __init__(self, ):
|
||||
item = eos.db.getItem(23773) # Ragnarok
|
||||
super().__init__(None, title="Test Attribute Window | {} - {}".format(item.ID, item.name), size=(1000, 500))
|
||||
|
||||
if 'wxMSW' in wx.PlatformInfo:
|
||||
color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)
|
||||
@@ -542,7 +356,7 @@ if __name__ == "__main__":
|
||||
|
||||
main_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
||||
item = eos.db.getItem(22452) # Ragnarok
|
||||
|
||||
|
||||
panel = ItemParams(self, None, item)
|
||||
|
||||
@@ -552,6 +366,6 @@ if __name__ == "__main__":
|
||||
self.SetSizer(main_sizer)
|
||||
|
||||
app = wx.App(redirect=False) # Error messages go to popup window
|
||||
top = Frame("Test Item Attributes")
|
||||
top = Frame()
|
||||
top.Show()
|
||||
app.MainLoop()
|
||||
|
||||
Reference in New Issue
Block a user