From a4f19f83bbd11831559218617e9d7696c7d4717a Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Wed, 18 Aug 2010 22:04:37 +0200 Subject: [PATCH] Start work on an generic implementation for showing fitting/drone/implant/booster/etc. view columns. --- gui/builtinViewColumns/__init__.py | 8 +++ gui/builtinViewColumns/moduleNameOrSlot.py | 61 +++++++++++++++++++++ gui/builtinViewColumns/moduleState.py | 46 ++++++++++++++++ gui/fittingView.py | 30 +++++++++- gui/viewColumn.py | 49 +++++++++++++++++ icons/slot_high_small.png | Bin 0 -> 540 bytes icons/slot_low_small.png | Bin 0 -> 324 bytes icons/slot_med_small.png | Bin 0 -> 347 bytes icons/slot_rig_small.png | Bin 0 -> 716 bytes icons/slot_subsystem_small.png | Bin 0 -> 670 bytes icons/state_active_small.png | Bin 0 -> 632 bytes icons/state_offline_small.png | Bin 0 -> 731 bytes icons/state_online_small.png | Bin 0 -> 624 bytes icons/state_overheated_small.png | Bin 0 -> 1023 bytes 14 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 gui/builtinViewColumns/__init__.py create mode 100644 gui/builtinViewColumns/moduleNameOrSlot.py create mode 100644 gui/builtinViewColumns/moduleState.py create mode 100644 gui/viewColumn.py create mode 100644 icons/slot_high_small.png create mode 100644 icons/slot_low_small.png create mode 100644 icons/slot_med_small.png create mode 100644 icons/slot_rig_small.png create mode 100644 icons/slot_subsystem_small.png create mode 100644 icons/state_active_small.png create mode 100644 icons/state_offline_small.png create mode 100644 icons/state_online_small.png create mode 100644 icons/state_overheated_small.png diff --git a/gui/builtinViewColumns/__init__.py b/gui/builtinViewColumns/__init__.py new file mode 100644 index 000000000..7f88f7fb6 --- /dev/null +++ b/gui/builtinViewColumns/__init__.py @@ -0,0 +1,8 @@ +__all__ = ["moduleState", "moduleNameOrSlot"] + +columns = {} +def registerColumn(column): + columns[column.name] = column + +def getColumn(name): + return columns[name] diff --git a/gui/builtinViewColumns/moduleNameOrSlot.py b/gui/builtinViewColumns/moduleNameOrSlot.py new file mode 100644 index 000000000..d51015efe --- /dev/null +++ b/gui/builtinViewColumns/moduleNameOrSlot.py @@ -0,0 +1,61 @@ +#=============================================================================== +# Copyright (C) 2010 Diego Duclos +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with pyfa. If not, see . +#=============================================================================== + +from gui import builtinViewColumns +from gui.viewColumn import ViewColumn +from gui import bitmapLoader +from eos.types import Slot + +class ModuleNameOrSlot(ViewColumn): + name = "Module name/slot" + def __init__(self, fittingView, params): + ViewColumn.__init__(self, fittingView) + self.columnText = "Name" + self.slotNameMap = {} + for slot in Slot.__dict__: + if slot[0:2] == "__": + continue + + id = Slot.__dict__[slot] + self.slotNameMap[id] = slot + + def getText(self, mod): + if mod.isEmpty(): + return "%s Slot" % self.slotNameMap[mod.slot].capitalize() + else: + return mod.item.name + + def getImageId(self, mod): + if mod.isEmpty(): + bitmap = bitmapLoader.getBitmap("slot_%s_small" % self.slotNameMap[mod.state], "icons") + iconId = self.fittingView.imageList.Add(bitmap) + else: + iconFile = mod.item.icon.iconFile if mod.item.icon else "" + if iconFile: + bitmap = bitmapLoader.getBitmap(iconFile, "pack") + if bitmap is None: + iconId = -1 + else: + iconId = self.fittingView.imageList.Add(bitmap) + else: + iconId = -1 + + return iconId + +builtinViewColumns.registerColumn(ModuleNameOrSlot) diff --git a/gui/builtinViewColumns/moduleState.py b/gui/builtinViewColumns/moduleState.py new file mode 100644 index 000000000..ab5e6c81a --- /dev/null +++ b/gui/builtinViewColumns/moduleState.py @@ -0,0 +1,46 @@ +#=============================================================================== +# Copyright (C) 2010 Diego Duclos +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with pyfa. If not, see . +#=============================================================================== + +from gui import builtinViewColumns +from gui.viewColumn import ViewColumn +from gui import bitmapLoader +from eos.types import State + +class ModuleState(ViewColumn): + name = "Module state" + def __init__(self, fittingView, params): + ViewColumn.__init__(self, fittingView) + self.resizable = False + self.size = 16 + self.stateNameMap = {} + for state in State.__dict__: + if state[0:2] == "__": + continue + + id = State.__dict__[state] + self.stateNameMap[id] = state + + def getText(self, mod): + return "" + + def getImageId(self, mod): + bitmap = bitmapLoader.getBitmap("state_%s_small" % self.stateNameMap[mod.state], "icons") + return self.fittingView.imageList.Add(bitmap) + +builtinViewColumns.registerColumn(ModuleState) diff --git a/gui/fittingView.py b/gui/fittingView.py index 25b46e7e8..3ea287862 100644 --- a/gui/fittingView.py +++ b/gui/fittingView.py @@ -19,6 +19,32 @@ import wx -class FittingView(wx.TreeCtrl): +import gui.builtinViewColumns +from gui.builtinViewColumns import * + +class FittingView(wx.ListCtrl): + DEFAULT_COLS = ["Module state", "Module name/slot"] def __init__(self, parent): - wx.TreeCtrl.__init__(self, parent, wx.ID_ANY) + listStyle = wx.LC_REPORT | wx.BORDER_NONE + wx.ListCtrl.__init__(self, parent, wx.ID_ANY, style=listStyle) + + self.imageList = wx.ImageList(16, 16) + self.SetImageList(self.imageList, wx.IMAGE_LIST_SMALL) + self.activeColumns = [] + self.Bind(wx.EVT_LIST_COL_BEGIN_DRAG, self.resizeChecker) + i = 0 + for colName in FittingView.DEFAULT_COLS: + col = gui.builtinViewColumns.getColumn(colName)(self, None) + self.activeColumns.append(col) + + info = wx.ListItem() + info.m_mask = col.mask + info.m_image = col.imageId + info.m_text = col.columnText + self.InsertColumnInfo(i, info) + self.SetColumnWidth(i, wx.LIST_AUTOSIZE_USEHEADER if col.size is wx.LIST_AUTOSIZE else col.size) + i += 1 + + def resizeChecker(self, event): + if self.activeColumns[event.Column].resizable is False: + event.Veto() diff --git a/gui/viewColumn.py b/gui/viewColumn.py new file mode 100644 index 000000000..72c897d25 --- /dev/null +++ b/gui/viewColumn.py @@ -0,0 +1,49 @@ +#=============================================================================== +# Copyright (C) 2010 Diego Duclos +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with pyfa. If not, see . +#=============================================================================== + +import wx + +class ViewColumn(object): + ''' + Abstract class that columns can inherit from. + Once the missing methods are correctly implemented, + they can be used as columns in a view. + ''' + columns = [] + def __init__(self, fittingView): + ViewColumn.columns.append(self) + + self.fittingView = fittingView + self.columnText = "" + self.imageId = -1 + self.size = wx.LIST_AUTOSIZE + self.mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE + self.resizable = True + + def getRestrictions(self): + raise NotImplementedError() + + def getText(self, mod): + raise NotImplementedError() + + def getImage(self, mod): + raise NotImplementedError() + + def getParameters(self): + raise NotImplementedError() diff --git a/icons/slot_high_small.png b/icons/slot_high_small.png new file mode 100644 index 0000000000000000000000000000000000000000..ab46efb5788cfe19b586f1ef61df2da375a753f4 GIT binary patch literal 540 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4(FKV0`T9;uumfCn;e8NQ&YA|3wmv zU^?lDCL`k+9w7J+1iwMVjVn;8L&*%)E-pvzbe!m@?CI&5r02|; zGcrX*n-qb}T|lgL_W%D*U-^ZFwav}9Uwv{?nE%hu-_PeyoqE;9 zIQa50`}+TXW*en`DwLDUt4>QxGfS}rY60oFc1BcQ-u(6J?d$j7+f(~lUDNQNma%cM zoUrg@=aiHq3(fQ6|Nr~-_VxNBM}D{hE&gLr3)N}nuwdiHhc5N;=Y`|q?$xoeu@wVN z&QnuU69a-uxx9C$zJ0qEeK&S)xrBtomBc_$bOCKNYnVB4;>8J#jR%`%&YZ~~%Loh@ zYi8zVJ!R#^%s{rfj|@a1zk^y0BdhN{4K_$Xz#jpRprW9H1t=jY~DXFgoiYAz`u z@kK&X(sIK}X0UY9p_e9ZZfZc7mY0`j$HvCSt)`}ymh%cI3$*=ECWF+EKmY&#kH4V; z5mCCU~E5 literal 0 HcmV?d00001 diff --git a/icons/slot_med_small.png b/icons/slot_med_small.png new file mode 100644 index 0000000000000000000000000000000000000000..070b6ebc06509bb88f92f2ed82cdef2b623b068c GIT binary patch literal 347 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4(FKU{vySaSW-Lla#OkB*pOm{~`%S zqUfX+!x=yzDIqcA!ju08ms~vh|L^bb(;FKbA^MXN6M!HkCFRMpXJs#5yvT433yqAt zdFH@@59{~t-76RS=k#>_-5@>OVEd99cec!&8R_BW71Y@}bt><&3Dc)vfBXFW{Oub$ zcGvy-@{&ne`LQv?jZWW~{_n5#0K^{@_XmGyQiwRZW5cJNNeUY#WW2aB!y<5zjJe~^Vi4k z|EFhWRyKX{;>T8OY;7{e#+&~gIB>w#JpbOGlK1!ao>x**n##k&bI702eKt3q=jBF^XAyPqARx`H}oAMa-W%-c~4x4H`%fGi69&1)sDx0&TApIFz zsOiRk-&jGGHvMj$IyKbW#pTGapP!%4mz0qBW^7=v$E8@cyQ8Dyf4{uFi+%mSnyHPA z4<(qH5645Cn&cSv<@x#f$hzy^K@`Ha47rwy1jeL-``7jbUbLn=HZl_00a;}IJvF)^XHFZ`MW!nAm{x5{Os)R zGeGy)WnWvf86;5u{oP%DCMKqjJQJpHvO_ib2kHPl{V2e7zJx-c22lNh^9K%mn9C?+ ttZ@#c29eN|I1P=A42%~%1%(4poS7kQ>iVOKM`vb&_@1tQF6*2UngBV|LK*-7 literal 0 HcmV?d00001 diff --git a/icons/slot_subsystem_small.png b/icons/slot_subsystem_small.png new file mode 100644 index 0000000000000000000000000000000000000000..e56719d603d49b06e6b4f85ad2ec23215a3e47e6 GIT binary patch literal 670 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4(FKU`q9LaSW-Lla#OkB*pOm{~`%S zFr9Qn>DbxBhm%j9IC0|F+uPfv>;M0&J#+SK?&%{(j(q(4`@4Jnzdt*V9XRkoewhSV zhm&dV#EBR0-P`y3c)$Gry1&1^o-#&4pWibuG~8)mY+QWk z3&chz$2Du#?76)?f4_bHy*<@cRaM?UfBw{#l#qx?NlAIMcJ12d|Ni{^Jb&N5e@1L< zY`in%VEW#?dE?d2FJHH4-8#GG#>Ru4t*x!iot>SnjX(fo?_akrufMhRXcACc_Kfck zk2!s3G8Pt|EC6(unz6C5{Vp3IX$|D@07V&mcp$!an)Lk3hYv5FKYzYGH7RM=-|z45 z_eba?lol3h3JD1nB_|{#qyjO-B~8j^W@ek^?d$%SnwZ2KIdMXx>uk4sR*;n&ZSzkY2z-%kTF^AGQmQR`#PEK)%Qdm-AW|&i5D*8CRQvoFI>FVdQ&MBb@09lbL+5i9m literal 0 HcmV?d00001 diff --git a/icons/state_active_small.png b/icons/state_active_small.png new file mode 100644 index 0000000000000000000000000000000000000000..4f141179cae03a1a1e9397c17e4b8646c1b2491e GIT binary patch literal 632 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4(FKV6yjgaSW-Lla#OkB*pOm{~`%S zFs;OEXk@U68^TFaiqbb`Hr5trHdhAHn=BwoPBFNpv89#Su{maHtFed4vDLY$vF)&f z7<4F)VN$TqfRY@FFTx3ResNKfo+ z?3~)&=pHaNFx+^Ns~6tvRyd>z5<@XYb!{Q1j>i^oQm?{9uPVNgOzF;KZS02Q+gJq@=z-E2Ose zWRB9J155Iroe@cUb13KclNkJoSmUAl5lae3;+(@O?g8o4EPE z{Z${o+LuQNWv|<2TkPRyRek3>KM&9M?|-a+KbAfGw*J3FokNH-RO7cp|Lf}|>;BdJ z|Nr#o-uiVl)Bml1CU#8b^Nj!U?~h%Je{Of@cm0p^{%zAwY%?}6Fo0^~Jp#1--=CC< zuMZUuUoCe3zpqC7V|>BuZ}#isWB>1ef4sV_`2T;y8ux8;8yg!T(R0WnlBb79=gbT>q*{Hm`v-1GO>r~j+&-d1mIr@;S34B_t#uhQJaDGsB(ciG~MKZ|nz& Nd%F6$taD0e0syo^BZL3| literal 0 HcmV?d00001 diff --git a/icons/state_offline_small.png b/icons/state_offline_small.png new file mode 100644 index 0000000000000000000000000000000000000000..1d4cff94e6a2498a7f3367ce75c15753e370c1d5 GIT binary patch literal 731 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4(FKU|Qtq;uumfCn;e8NQ&YA|3wmv zU^?d1MqUO64rYZf|7WjVU8s7ceVL-llivp4^}*61XAJoo6a*MH@GYOw@aO+riDZww zgrpCQZ}mAAUF1L4ZuoOSLFhY`c(+Nnb-)^uoQygrb~iSjpE>iUe(%(+5v`q`?Lhu) zAda3oG0=Qs>(U!-ohQ2|H#Sb6*vOb?2+`(P#;eTCEN;%+Tx7%VZzIp${bkqo{O5*7 z1_o_L#>*{?jjXo({ck^YVq+uFq=(APSE_*;fgWj+{xHAs;eUR%w)yJ+|5k7K`uzNJ z#!HvxHP!#`GW_%BBR5AC&$K?T(|G4j zd7CR&|Ne`J{(U@$uh0EgPmk~pNeLcFNr@X1ze23?Ij<w31f^*lU0^@&mtdk(cpNJ>b|xER~++S3RGkn{&jhs+Gz WT5CdfWnMT5Qtj#L=d#Wzp$PyUK1O~3 literal 0 HcmV?d00001 diff --git a/icons/state_online_small.png b/icons/state_online_small.png new file mode 100644 index 0000000000000000000000000000000000000000..80dd7debf62a53a8adb6797c6349d26613e4b0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