diff --git a/eos/db/gamedata/item.py b/eos/db/gamedata/item.py index 66d32e642..e8283e6aa 100755 --- a/eos/db/gamedata/item.py +++ b/eos/db/gamedata/item.py @@ -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") diff --git a/eos/db/gamedata/traits.py b/eos/db/gamedata/traits.py new file mode 100644 index 000000000..f5b40c47e --- /dev/null +++ b/eos/db/gamedata/traits.py @@ -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 + ))) + }); \ No newline at end of file diff --git a/eos/gamedata.py b/eos/gamedata.py index 6378e9bf0..c514a051b 100755 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -357,3 +357,6 @@ class MetaType(EqBase): class Unit(EqBase): pass + +class Traits(EqBase): + pass \ No newline at end of file diff --git a/eos/types.py b/eos/types.py index 502caafd3..0b0e791da 100755 --- a/eos/types.py +++ b/eos/types.py @@ -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 diff --git a/gui/itemStats.py b/gui/itemStats.py index 5340165bf..6277d6b57 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -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.*?)<( *)/( *)a( *)>", "\g", 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 += "
" + fullText += "" + skill + "
" + for t in traitsMap[skill]: + fullText += t + "
" + self.traits.SetPage(fullText) + + mainSizer.Add(self.traits, 1, wx.ALL|wx.EXPAND, 0) + self.Layout() ########################################################################### ## Class ItemDescription diff --git a/staticdata/eve.db b/staticdata/eve.db index fcf6029fa..cf57163d9 100644 Binary files a/staticdata/eve.db and b/staticdata/eve.db differ