Merge pull request #41 from cl05tomp/master
Added new traits tab to Ship Basic Stats window
This commit is contained in:
@@ -23,7 +23,7 @@ from sqlalchemy.ext.associationproxy import association_proxy
|
||||
from sqlalchemy.orm.collections import attribute_mapped_collection
|
||||
|
||||
from eos.db import gamedata_meta
|
||||
from eos.types import Icon, Attribute, Item, Effect, MetaType, Group
|
||||
from eos.types import Icon, Attribute, Item, Effect, MetaType, Group, Traits
|
||||
|
||||
items_table = Table("invtypes", gamedata_meta,
|
||||
Column("typeID", Integer, primary_key = True),
|
||||
@@ -38,9 +38,8 @@ items_table = Table("invtypes", gamedata_meta,
|
||||
Column("iconID", Integer, ForeignKey("icons.iconID")),
|
||||
Column("groupID", Integer, ForeignKey("invgroups.groupID"), index=True))
|
||||
|
||||
|
||||
|
||||
from .metaGroup import metatypes_table
|
||||
from .traits import traits_table
|
||||
|
||||
mapper(Item, items_table,
|
||||
properties = {"group" : relation(Group, backref = "items"),
|
||||
@@ -52,6 +51,11 @@ mapper(Item, items_table,
|
||||
uselist = False),
|
||||
"ID" : synonym("typeID"),
|
||||
"name" : synonym("typeName"),
|
||||
"description" : deferred(items_table.c.description)})
|
||||
"description" : deferred(items_table.c.description),
|
||||
"traits" : relation(Traits,
|
||||
primaryjoin = traits_table.c.typeID == items_table.c.typeID,
|
||||
order_by = traits_table.c.typeID,
|
||||
uselist = True)
|
||||
})
|
||||
|
||||
Item.category = association_proxy("group", "category")
|
||||
|
||||
31
eos/db/gamedata/traits.py
Normal file
31
eos/db/gamedata/traits.py
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
from sqlalchemy import Column, Table, Integer, Float, String, ForeignKey, and_, select
|
||||
from sqlalchemy.orm import mapper, column_property
|
||||
from eos.types import Item, Traits
|
||||
from eos.db import gamedata_meta
|
||||
|
||||
traits_table = Table("invtraits", gamedata_meta,
|
||||
Column("traitID", Integer, primary_key=True),
|
||||
Column("typeID", Integer, ForeignKey("invtypes.typeID")),
|
||||
Column("skillID", Integer, ForeignKey("invtypes.typeID")),
|
||||
Column("bonus", Float),
|
||||
Column("bonusText", String),
|
||||
Column("unitID", Integer))
|
||||
|
||||
|
||||
from .item import items_table
|
||||
from .unit import groups_table
|
||||
|
||||
mapper(Traits, traits_table,
|
||||
properties = {"skillName" : column_property(
|
||||
select([items_table.c.typeName],
|
||||
and_(
|
||||
items_table.c.typeID == traits_table.c.skillID,
|
||||
traits_table.c.skillID != -1
|
||||
))),
|
||||
"unit" : column_property(
|
||||
select([groups_table.c.displayName],
|
||||
and_(
|
||||
groups_table.c.unitID == traits_table.c.unitID
|
||||
)))
|
||||
});
|
||||
@@ -357,3 +357,6 @@ class MetaType(EqBase):
|
||||
|
||||
class Unit(EqBase):
|
||||
pass
|
||||
|
||||
class Traits(EqBase):
|
||||
pass
|
||||
@@ -18,7 +18,7 @@
|
||||
#===============================================================================
|
||||
|
||||
from eos.gamedata import Attribute, Category, Effect, Group, Icon, Item, MarketGroup, \
|
||||
MetaGroup, AttributeInfo, Unit, EffectInfo, MetaType, MetaData
|
||||
MetaGroup, AttributeInfo, Unit, EffectInfo, MetaType, MetaData, Traits
|
||||
from eos.saveddata.price import Price
|
||||
from eos.saveddata.user import User
|
||||
from eos.saveddata.damagePattern import DamagePattern
|
||||
|
||||
@@ -26,6 +26,7 @@ import wx.lib.mixins.listctrl as listmix
|
||||
import wx.html
|
||||
from eos.types import Ship, Module, Skill, Booster, Implant, Drone
|
||||
from gui.utils.numberFormatter import formatAmount
|
||||
from collections import OrderedDict
|
||||
import service
|
||||
|
||||
class ItemStatsDialog(wx.Dialog):
|
||||
@@ -133,6 +134,10 @@ class ItemStatsContainer ( wx.Panel ):
|
||||
self.nbContainer = wx.Notebook( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
mainSizer.Add( self.nbContainer, 1, wx.EXPAND |wx.ALL, 2 )
|
||||
|
||||
if len(item.traits) != 0:
|
||||
self.traits = ItemTraits(self.nbContainer, stuff, item)
|
||||
self.nbContainer.AddPage(self.traits, "Traits")
|
||||
|
||||
self.desc = ItemDescription(self.nbContainer, stuff, item)
|
||||
self.nbContainer.AddPage(self.desc, "Description")
|
||||
|
||||
@@ -184,6 +189,60 @@ class AutoListCtrlNoHighlight(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listm
|
||||
wx.ListCtrl.__init__(self, parent, ID, pos, size, style)
|
||||
listmix.ListCtrlAutoWidthMixin.__init__(self)
|
||||
|
||||
###########################################################################
|
||||
## Class ItemTraits
|
||||
###########################################################################
|
||||
|
||||
class ItemTraits ( wx.Panel ):
|
||||
|
||||
def __init__(self, parent, stuff, item):
|
||||
wx.Panel.__init__ (self, parent)
|
||||
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
||||
self.SetSizer(mainSizer)
|
||||
|
||||
bgcolor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)
|
||||
fgcolor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT)
|
||||
|
||||
self.traits = wx.html.HtmlWindow(self)
|
||||
|
||||
traitsMap = OrderedDict()
|
||||
|
||||
for trait in item.traits:
|
||||
text = ""
|
||||
bonusText = re.sub("<( *)a(.*?)>(?P<inside>.*?)<( *)/( *)a( *)>", "\g<inside>", trait.bonusText)
|
||||
bonusAmountText = str(trait.bonus)
|
||||
|
||||
if trait.skillName is not None:
|
||||
skillText = trait.skillName + " bonuses (per skill level):"
|
||||
else:
|
||||
skillText = "Role Bonus:"
|
||||
|
||||
if bonusAmountText == "":
|
||||
bonusAmountText = ""
|
||||
else:
|
||||
bonusAmountText += trait.unit
|
||||
|
||||
text += bonusAmountText + " " + bonusText
|
||||
|
||||
if skillText in traitsMap:
|
||||
traitsMap[skillText].append(text)
|
||||
else:
|
||||
traitsMap[skillText] = [text]
|
||||
fullText = ""
|
||||
|
||||
firstSkill = True
|
||||
for skill in traitsMap:
|
||||
if firstSkill:
|
||||
firstSkill = False
|
||||
else:
|
||||
fullText += "<br>"
|
||||
fullText += "<b>" + skill + "</b><br>"
|
||||
for t in traitsMap[skill]:
|
||||
fullText += t + "<br>"
|
||||
self.traits.SetPage(fullText)
|
||||
|
||||
mainSizer.Add(self.traits, 1, wx.ALL|wx.EXPAND, 0)
|
||||
self.Layout()
|
||||
|
||||
###########################################################################
|
||||
## Class ItemDescription
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user