pywargame 0.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pywargame/__init__.py +2 -0
- pywargame/common/__init__.py +3 -0
- pywargame/common/collector.py +87 -0
- pywargame/common/dicedraw.py +363 -0
- pywargame/common/drawdice.py +40 -0
- pywargame/common/singleton.py +22 -0
- pywargame/common/test.py +25 -0
- pywargame/common/verbose.py +59 -0
- pywargame/common/verboseguard.py +53 -0
- pywargame/cyberboard/__init__.py +18 -0
- pywargame/cyberboard/archive.py +283 -0
- pywargame/cyberboard/base.py +63 -0
- pywargame/cyberboard/board.py +462 -0
- pywargame/cyberboard/cell.py +200 -0
- pywargame/cyberboard/collect.py +49 -0
- pywargame/cyberboard/collectgbx0pwd.py +30 -0
- pywargame/cyberboard/collectgbxext.py +30 -0
- pywargame/cyberboard/collectgsnexp.py +32 -0
- pywargame/cyberboard/collectgsnext.py +30 -0
- pywargame/cyberboard/draw.py +396 -0
- pywargame/cyberboard/exporter.py +1132 -0
- pywargame/cyberboard/extractor.py +240 -0
- pywargame/cyberboard/features.py +17 -0
- pywargame/cyberboard/gamebox.py +81 -0
- pywargame/cyberboard/gbxexp.py +76 -0
- pywargame/cyberboard/gbxext.py +64 -0
- pywargame/cyberboard/gsnexp.py +147 -0
- pywargame/cyberboard/gsnext.py +59 -0
- pywargame/cyberboard/head.py +111 -0
- pywargame/cyberboard/image.py +76 -0
- pywargame/cyberboard/main.py +47 -0
- pywargame/cyberboard/mark.py +102 -0
- pywargame/cyberboard/palette.py +36 -0
- pywargame/cyberboard/piece.py +169 -0
- pywargame/cyberboard/player.py +36 -0
- pywargame/cyberboard/scenario.py +115 -0
- pywargame/cyberboard/testgrid.py +156 -0
- pywargame/cyberboard/tile.py +121 -0
- pywargame/cyberboard/tray.py +68 -0
- pywargame/cyberboard/windows.py +41 -0
- pywargame/cyberboard/zeropwd.py +45 -0
- pywargame/cyberboard.py +2728 -0
- pywargame/gbx0pwd.py +2776 -0
- pywargame/gbxextract.py +2795 -0
- pywargame/gsnexport.py +16499 -0
- pywargame/gsnextract.py +2790 -0
- pywargame/latex/__init__.py +2 -0
- pywargame/latex/collect.py +34 -0
- pywargame/latex/latexexporter.py +4010 -0
- pywargame/latex/main.py +184 -0
- pywargame/vassal/__init__.py +66 -0
- pywargame/vassal/base.py +139 -0
- pywargame/vassal/board.py +243 -0
- pywargame/vassal/buildfile.py +60 -0
- pywargame/vassal/chart.py +79 -0
- pywargame/vassal/chessclock.py +197 -0
- pywargame/vassal/collect.py +98 -0
- pywargame/vassal/collectpatch.py +28 -0
- pywargame/vassal/command.py +21 -0
- pywargame/vassal/documentation.py +322 -0
- pywargame/vassal/dumpcollect.py +28 -0
- pywargame/vassal/dumpvsav.py +28 -0
- pywargame/vassal/element.py +439 -0
- pywargame/vassal/exporter.py +89 -0
- pywargame/vassal/extension.py +101 -0
- pywargame/vassal/folder.py +103 -0
- pywargame/vassal/game.py +940 -0
- pywargame/vassal/gameelements.py +1091 -0
- pywargame/vassal/globalkey.py +127 -0
- pywargame/vassal/globalproperty.py +433 -0
- pywargame/vassal/grid.py +573 -0
- pywargame/vassal/map.py +1061 -0
- pywargame/vassal/mapelements.py +1020 -0
- pywargame/vassal/merge.py +57 -0
- pywargame/vassal/merger.py +460 -0
- pywargame/vassal/moduledata.py +275 -0
- pywargame/vassal/mrgcollect.py +31 -0
- pywargame/vassal/patch.py +44 -0
- pywargame/vassal/patchcollect.py +28 -0
- pywargame/vassal/player.py +83 -0
- pywargame/vassal/save.py +495 -0
- pywargame/vassal/skel.py +380 -0
- pywargame/vassal/trait.py +224 -0
- pywargame/vassal/traits/__init__.py +36 -0
- pywargame/vassal/traits/area.py +50 -0
- pywargame/vassal/traits/basic.py +35 -0
- pywargame/vassal/traits/calculatedproperty.py +22 -0
- pywargame/vassal/traits/cargo.py +29 -0
- pywargame/vassal/traits/click.py +41 -0
- pywargame/vassal/traits/clone.py +28 -0
- pywargame/vassal/traits/delete.py +24 -0
- pywargame/vassal/traits/deselect.py +32 -0
- pywargame/vassal/traits/dynamicproperty.py +112 -0
- pywargame/vassal/traits/globalcommand.py +55 -0
- pywargame/vassal/traits/globalhotkey.py +26 -0
- pywargame/vassal/traits/globalproperty.py +54 -0
- pywargame/vassal/traits/hide.py +67 -0
- pywargame/vassal/traits/label.py +76 -0
- pywargame/vassal/traits/layer.py +105 -0
- pywargame/vassal/traits/mark.py +20 -0
- pywargame/vassal/traits/mask.py +85 -0
- pywargame/vassal/traits/mat.py +26 -0
- pywargame/vassal/traits/moved.py +35 -0
- pywargame/vassal/traits/movefixed.py +51 -0
- pywargame/vassal/traits/nonrect.py +95 -0
- pywargame/vassal/traits/nostack.py +55 -0
- pywargame/vassal/traits/place.py +104 -0
- pywargame/vassal/traits/prototype.py +20 -0
- pywargame/vassal/traits/report.py +34 -0
- pywargame/vassal/traits/restrictaccess.py +28 -0
- pywargame/vassal/traits/restrictcommand.py +32 -0
- pywargame/vassal/traits/return.py +40 -0
- pywargame/vassal/traits/rotate.py +62 -0
- pywargame/vassal/traits/sendto.py +59 -0
- pywargame/vassal/traits/sheet.py +129 -0
- pywargame/vassal/traits/skel.py +9 -0
- pywargame/vassal/traits/stack.py +28 -0
- pywargame/vassal/traits/submenu.py +27 -0
- pywargame/vassal/traits/trail.py +61 -0
- pywargame/vassal/traits/trigger.py +72 -0
- pywargame/vassal/turn.py +272 -0
- pywargame/vassal/upgrade.py +191 -0
- pywargame/vassal/vmod.py +323 -0
- pywargame/vassal/vsav.py +100 -0
- pywargame/vassal/widget.py +358 -0
- pywargame/vassal/withtraits.py +634 -0
- pywargame/vassal/xml.py +4 -0
- pywargame/vassal/zone.py +399 -0
- pywargame/vassal.py +12500 -0
- pywargame/vmodpatch.py +12548 -0
- pywargame/vsavdump.py +12533 -0
- pywargame/vslmerge.py +13015 -0
- pywargame/wgexport.py +16689 -0
- pywargame/ztexport.py +14351 -0
- pywargame/zuntzu/__init__.py +5 -0
- pywargame/zuntzu/base.py +82 -0
- pywargame/zuntzu/collect.py +38 -0
- pywargame/zuntzu/countersheet.py +250 -0
- pywargame/zuntzu/dicehand.py +48 -0
- pywargame/zuntzu/exporter.py +936 -0
- pywargame/zuntzu/gamebox.py +154 -0
- pywargame/zuntzu/map.py +36 -0
- pywargame/zuntzu/piece.py +37 -0
- pywargame/zuntzu/scenario.py +208 -0
- pywargame/zuntzu/ztexp.py +115 -0
- pywargame-0.3.1.dist-info/METADATA +353 -0
- pywargame-0.3.1.dist-info/RECORD +150 -0
- pywargame-0.3.1.dist-info/WHEEL +5 -0
- pywargame-0.3.1.dist-info/licenses/LICENSE +5 -0
- pywargame-0.3.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1091 @@
|
|
1
|
+
## BEGIN_IMPORT
|
2
|
+
from common import VerboseGuard
|
3
|
+
from . base import *
|
4
|
+
from . element import Element
|
5
|
+
from . withtraits import *
|
6
|
+
from . globalkey import *
|
7
|
+
## END_IMPORT
|
8
|
+
|
9
|
+
# --------------------------------------------------------------------
|
10
|
+
class GameElementService:
|
11
|
+
def getGame(self):
|
12
|
+
return self.getParentOfClass(Game)
|
13
|
+
|
14
|
+
# --------------------------------------------------------------------
|
15
|
+
class GameElement(Element,GameElementService):
|
16
|
+
def __init__(self,game,tag,node=None,**kwargs):
|
17
|
+
super(GameElement,self).__init__(game,tag,node=node,**kwargs)
|
18
|
+
|
19
|
+
# --------------------------------------------------------------------
|
20
|
+
class Notes(ToolbarElement,GameElementService):
|
21
|
+
TAG = Element.MODULE+'NotesWindow'
|
22
|
+
UNIQUE = ['name']
|
23
|
+
def __init__(self,elem,node=None,
|
24
|
+
name = 'Notes', # Toolbar element name
|
25
|
+
tooltip = 'Show notes window', # Tool tip
|
26
|
+
text = '', # Button text
|
27
|
+
icon = '/images/notes.gif', # Button icon,
|
28
|
+
hotkey = key('N',ALT), # Named key or key stroke
|
29
|
+
canDisable = False,
|
30
|
+
propertyGate = '',
|
31
|
+
disabledIcon = '',
|
32
|
+
description = ''):
|
33
|
+
super(Notes,self).__init__(elem,self.TAG,
|
34
|
+
node = node,
|
35
|
+
name = name,
|
36
|
+
tooltip = tooltip,
|
37
|
+
text = text,
|
38
|
+
icon = icon,
|
39
|
+
hotkey = hotkey,
|
40
|
+
canDisable = canDisable,
|
41
|
+
propertyGate = propertyGate,
|
42
|
+
disabledIcon = disabledIcon,
|
43
|
+
description = description)
|
44
|
+
def encode(self):
|
45
|
+
return ['NOTES\t\\','PNOTES']
|
46
|
+
|
47
|
+
registerElement(Notes)
|
48
|
+
|
49
|
+
# --------------------------------------------------------------------
|
50
|
+
class PredefinedSetup(GameElement):
|
51
|
+
TAG = Element.MODULE+'PredefinedSetup'
|
52
|
+
UNIQUE = ['name'] #,'file','useFile']
|
53
|
+
def __init__(self,elem,node=None,
|
54
|
+
name = '',
|
55
|
+
file = '',
|
56
|
+
useFile = False,
|
57
|
+
isMenu = False,
|
58
|
+
description = ''):
|
59
|
+
useFile = ((useFile or not isMenu) and
|
60
|
+
(file is not None and len(file) > 0))
|
61
|
+
if file is None: file = ''
|
62
|
+
super(PredefinedSetup,self).__init__(elem,self.TAG,node=node,
|
63
|
+
name = name,
|
64
|
+
file = file,
|
65
|
+
useFile = useFile,
|
66
|
+
isMenu = isMenu,
|
67
|
+
description = description)
|
68
|
+
def addPredefinedSetup(self,**kwargs):
|
69
|
+
'''Add a `PredefinedSetup` element to this
|
70
|
+
|
71
|
+
Parameters
|
72
|
+
----------
|
73
|
+
kwargs : dict
|
74
|
+
Dictionary of attribute key-value pairs
|
75
|
+
|
76
|
+
Returns
|
77
|
+
-------
|
78
|
+
element : PredefinedSetup
|
79
|
+
The added element
|
80
|
+
'''
|
81
|
+
return self.add(PredefinedSetup,**kwargs)
|
82
|
+
def getPredefinedSetups(self,asdict=True):
|
83
|
+
'''Get all PredefinedSetup element(s) from this
|
84
|
+
|
85
|
+
Parameters
|
86
|
+
----------
|
87
|
+
asdict : bool
|
88
|
+
If `True`, return a dictonary that maps key to `PredefinedSetup` elements. If `False`, return a list of all PredefinedSetup` children.
|
89
|
+
|
90
|
+
Returns
|
91
|
+
-------
|
92
|
+
children : dict or list
|
93
|
+
Dictionary or list of `PredefinedSetup` children
|
94
|
+
'''
|
95
|
+
return self.getElementsByKey(PredefinedSetup,'name',asdict)
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
registerElement(PredefinedSetup)
|
101
|
+
|
102
|
+
# --------------------------------------------------------------------
|
103
|
+
class GlobalTranslatableMessages(GameElement):
|
104
|
+
TAG=Element.MODULE+'properties.GlobalTranslatableMessages'
|
105
|
+
UNIQUE = ['name']
|
106
|
+
def __init__(self,elem,node=None,
|
107
|
+
name='',
|
108
|
+
initialValue = '',
|
109
|
+
description = ''):
|
110
|
+
'''Translations
|
111
|
+
|
112
|
+
Parameters
|
113
|
+
----------
|
114
|
+
doc : Element
|
115
|
+
Parent
|
116
|
+
node : xml.dom.Element
|
117
|
+
Node to read state from
|
118
|
+
'''
|
119
|
+
super(GlobalTranslatableMessages,self).\
|
120
|
+
__init__(elem,self.TAG,node=node,
|
121
|
+
name = name,
|
122
|
+
initialValue = initialValue,
|
123
|
+
description = description)
|
124
|
+
|
125
|
+
registerElement(GlobalTranslatableMessages)
|
126
|
+
|
127
|
+
# --------------------------------------------------------------------
|
128
|
+
class Language(GameElement):
|
129
|
+
TAG = 'VASSAL.i18n.Language'
|
130
|
+
def __init__(self,elem,node=None,**kwargs):
|
131
|
+
super(Language,self).__init__(elem,self.TAG,node=node,**kwargs)
|
132
|
+
|
133
|
+
registerElement(Language)
|
134
|
+
|
135
|
+
# --------------------------------------------------------------------
|
136
|
+
class Chatter(GameElement):
|
137
|
+
TAG=Element.MODULE+'Chatter'
|
138
|
+
def __init__(self,elem,node=None,**kwargs):
|
139
|
+
'''Chat
|
140
|
+
|
141
|
+
Parameters
|
142
|
+
----------
|
143
|
+
doc : Element
|
144
|
+
Parent
|
145
|
+
node : xml.dom.Element
|
146
|
+
Node to read state from
|
147
|
+
kwargs : dict
|
148
|
+
Attributes
|
149
|
+
'''
|
150
|
+
super(Chatter,self).__init__(elem,self.TAG,node=node,**kwargs)
|
151
|
+
|
152
|
+
registerElement(Chatter)
|
153
|
+
|
154
|
+
# --------------------------------------------------------------------
|
155
|
+
class KeyNamer(GameElement):
|
156
|
+
TAG=Element.MODULE+'KeyNamer'
|
157
|
+
def __init__(self,elem,node=None,**kwargs):
|
158
|
+
'''Key namer (or help menu)
|
159
|
+
|
160
|
+
Parameters
|
161
|
+
----------
|
162
|
+
doc : Element
|
163
|
+
Parent
|
164
|
+
node : xml.dom.Element
|
165
|
+
Node to read state from
|
166
|
+
kwargs : dict
|
167
|
+
Attributes
|
168
|
+
'''
|
169
|
+
super(KeyNamer,self).__init__(elem,self.TAG,node=node,**kwargs)
|
170
|
+
|
171
|
+
registerElement(KeyNamer)
|
172
|
+
|
173
|
+
|
174
|
+
# --------------------------------------------------------------------
|
175
|
+
# <VASSAL.build.module.GlobalOptions
|
176
|
+
# autoReport="Always"
|
177
|
+
# centerOnMove="Use Preferences Setting"
|
178
|
+
# chatterHTMLSupport="Always"
|
179
|
+
# hotKeysOnClosedWindows="Always"
|
180
|
+
# inventoryForAll="Never"
|
181
|
+
# nonOwnerUnmaskable="Always"
|
182
|
+
# playerIdFormat="$PlayerName$"
|
183
|
+
# promptString="Opponents can unmask pieces"
|
184
|
+
# sendToLocationMoveTrails="Always"
|
185
|
+
# storeLeadingZeroIntegersAsStrings="true">
|
186
|
+
# <option name="stepIcon">/images/StepForward16.gif</option>
|
187
|
+
# <option name="stepHotKey">39,130</option>
|
188
|
+
# <option name="undoIcon">/images/Undo16.gif</option>
|
189
|
+
# <option name="undoHotKey">90,130</option>
|
190
|
+
# <option name="serverControlsIcon">/images/connect.gif</option>
|
191
|
+
# <option name="serverControlsHotKey">65,195</option>
|
192
|
+
# <option name="debugControlsIcon"/>
|
193
|
+
# <option name="debugControlsHotKey">68,195</option>
|
194
|
+
# </VASSAL.build.module.GlobalOptions>
|
195
|
+
class GlobalOptions(GameElement):
|
196
|
+
NEVER = 'Never'
|
197
|
+
ALWAYS = 'Always'
|
198
|
+
PROMPT = 'Use Preferences Setting'
|
199
|
+
TAG = Element.MODULE+'GlobalOptions'
|
200
|
+
def __init__(self,doc,node=None,
|
201
|
+
autoReport = PROMPT,
|
202
|
+
centerOnMove = PROMPT,
|
203
|
+
chatterHTMLSupport = ALWAYS,
|
204
|
+
hotKeysOnClosedWindows = NEVER,
|
205
|
+
inventoryForAll = ALWAYS,
|
206
|
+
nonOwnerUnmaskable = PROMPT,
|
207
|
+
playerIdFormat = "$playerName$",
|
208
|
+
promptString = "Opponents can unmask pieces",
|
209
|
+
sendToLocationMoveTrails = NEVER,
|
210
|
+
storeLeadingZeroIntegersAsStrings = False,
|
211
|
+
description = 'Global options',
|
212
|
+
dragThreshold = 10):
|
213
|
+
'''Set global options on the module
|
214
|
+
|
215
|
+
Parameters
|
216
|
+
----------
|
217
|
+
doc : Element
|
218
|
+
Parent
|
219
|
+
node : xml.dom.Element
|
220
|
+
Node to read state from
|
221
|
+
|
222
|
+
autoReport : str='always'
|
223
|
+
centerOnMove : str Option
|
224
|
+
chatterHTMLSupport : str='never'
|
225
|
+
hotKeysOnClosedWindows : str='never'
|
226
|
+
inventoryForAll : str='always'
|
227
|
+
nonOwnerUnmaskable : str='never'
|
228
|
+
playerIdFormat : str='$PlayerName$'
|
229
|
+
promptString : str=?
|
230
|
+
sendToLocationMoveTrails : bool=false
|
231
|
+
storeLeadingZeroIntegersAsStrings : bool=False
|
232
|
+
'''
|
233
|
+
super(GlobalOptions,self).\
|
234
|
+
__init__(doc,self.TAG,node=node,
|
235
|
+
autoReport = autoReport,
|
236
|
+
centerOnMove = centerOnMove,
|
237
|
+
chatterHTMLSupport = chatterHTMLSupport,
|
238
|
+
hotKeysOnClosedWindows = hotKeysOnClosedWindows,
|
239
|
+
inventoryForAll = inventoryForAll,
|
240
|
+
nonOwnerUnmaskable = nonOwnerUnmaskable,
|
241
|
+
playerIdFormat = playerIdFormat,
|
242
|
+
promptString = promptString,
|
243
|
+
sendToLocationMoveTrails = sendToLocationMoveTrails,
|
244
|
+
storeLeadingZeroIntegersAsStrings = storeLeadingZeroIntegersAsStrings,
|
245
|
+
dragThreshold = dragThreshold,
|
246
|
+
description = description)
|
247
|
+
|
248
|
+
def addOption(self,**kwargs):
|
249
|
+
'''Add a `Option` element to this
|
250
|
+
|
251
|
+
Options known
|
252
|
+
- newHotKey - key - start new log
|
253
|
+
- endHotKey - key - end current log
|
254
|
+
- stepIcon - image file name (/images/StepForward16.gif)
|
255
|
+
- stepHotKey - key
|
256
|
+
- undoIcon - image file name (/images/Undo16.gif)
|
257
|
+
- undoHotKey - key
|
258
|
+
- serverControlsIcon - image file name (/images/connect.gif)
|
259
|
+
- serverControlsHotKey - key
|
260
|
+
- debugControlsIcon - image file name
|
261
|
+
- debugControlsHotKey - key
|
262
|
+
- scenarioPropertiesIcon - image file name
|
263
|
+
- scenarioPropertiesHotKey - key
|
264
|
+
|
265
|
+
Parameters
|
266
|
+
----------
|
267
|
+
kwargs : dict
|
268
|
+
Dictionary of attribute key-value pairs
|
269
|
+
- name : str
|
270
|
+
- value : str
|
271
|
+
|
272
|
+
Returns
|
273
|
+
-------
|
274
|
+
element : Option
|
275
|
+
The added element
|
276
|
+
'''
|
277
|
+
return self.add(Option,**kwargs)
|
278
|
+
def getOptions(self):
|
279
|
+
return self.getElementsByKey(Option,'name')
|
280
|
+
|
281
|
+
def addPreference(self,cls,**kwargs):
|
282
|
+
return self.add(cls,**kwargs)
|
283
|
+
|
284
|
+
def addIntPreference(self,**kwargs):
|
285
|
+
return self.add(IntPreference,**kwargs)
|
286
|
+
|
287
|
+
def addFloatPreference(self,**kwargs):
|
288
|
+
return self.add(FloatPreference,**kwargs)
|
289
|
+
|
290
|
+
def addBoolPreference(self,**kwargs):
|
291
|
+
return self.add(BoolPreference,**kwargs)
|
292
|
+
|
293
|
+
def addStrPreference(self,**kwargs):
|
294
|
+
return self.add(StrPreference,**kwargs)
|
295
|
+
|
296
|
+
def addTextPreference(self,**kwargs):
|
297
|
+
return self.add(TextPreference,**kwargs)
|
298
|
+
|
299
|
+
def addEnumPreference(self,**kwargs):
|
300
|
+
return self.add(EnumPreference,**kwargs)
|
301
|
+
|
302
|
+
def getIntPreferences(self):
|
303
|
+
return self.getElementsByKey(IntPreference,'name')
|
304
|
+
|
305
|
+
def getFloatPreferences(self):
|
306
|
+
return self.getElementsByKey(FloatPreference,'name')
|
307
|
+
|
308
|
+
def getBoolPreferences(self):
|
309
|
+
return self.getElementsByKey(BoolPreference,'name')
|
310
|
+
|
311
|
+
def getStrPreferences(self):
|
312
|
+
return self.getElementsByKey(StrPreference,'name')
|
313
|
+
|
314
|
+
def getTextPreferences(self):
|
315
|
+
return self.getElementsByKey(TextPreference,'name')
|
316
|
+
|
317
|
+
def getEnumPreferences(self):
|
318
|
+
return self.getElementsByKey(EnumPreference,'name')
|
319
|
+
|
320
|
+
def getPreferences(self):
|
321
|
+
retd = {}
|
322
|
+
for cls in [IntPreference,
|
323
|
+
FloatPreference,
|
324
|
+
BoolPreference,
|
325
|
+
StrPreference,
|
326
|
+
TextPreference,
|
327
|
+
EnumPreference]:
|
328
|
+
retd.update(self.getElementsByKey(cls,'name'))
|
329
|
+
|
330
|
+
return retd
|
331
|
+
|
332
|
+
registerElement(GlobalOptions)
|
333
|
+
|
334
|
+
# --------------------------------------------------------------------
|
335
|
+
class Option(Element):
|
336
|
+
TAG = 'option'
|
337
|
+
UNIQUE = ['name']
|
338
|
+
def __init__(self,doc,node=None,name='',value=''):
|
339
|
+
super(Option,self).__init__(doc,tag=self.TAG,node=node,name=name)
|
340
|
+
self.addText(value)
|
341
|
+
|
342
|
+
def getGlobalOptions(self):
|
343
|
+
return self.getParent(GlobalOptions)
|
344
|
+
|
345
|
+
registerElement(Option)
|
346
|
+
|
347
|
+
# --------------------------------------------------------------------
|
348
|
+
class Preference(Element):
|
349
|
+
PREFS = 'VASSAL.preferences.'
|
350
|
+
UNIQUE = ['name','tab']
|
351
|
+
def __init__(self,
|
352
|
+
doc,
|
353
|
+
tag,
|
354
|
+
node = None,
|
355
|
+
name = '',
|
356
|
+
default = '',
|
357
|
+
desc = '',
|
358
|
+
tab = '',
|
359
|
+
**kwargs):
|
360
|
+
'''Add a preference
|
361
|
+
|
362
|
+
Parameters
|
363
|
+
----------
|
364
|
+
name : str
|
365
|
+
Name of property
|
366
|
+
default : str
|
367
|
+
Default value
|
368
|
+
desc : str
|
369
|
+
Description
|
370
|
+
tab : str
|
371
|
+
Preference tab to put in to
|
372
|
+
'''
|
373
|
+
super(Preference,self).__init__(doc,
|
374
|
+
tag = tag,
|
375
|
+
node = node,
|
376
|
+
name = name,
|
377
|
+
default = default,
|
378
|
+
desc = desc,
|
379
|
+
tab = tab)
|
380
|
+
|
381
|
+
def getGlobalOptions(self):
|
382
|
+
return self.getParent(GlobalOptions)
|
383
|
+
|
384
|
+
# --------------------------------------------------------------------
|
385
|
+
class IntPreference(Preference):
|
386
|
+
TAG = Preference.PREFS+'IntegerPreference'
|
387
|
+
def __init__(self,
|
388
|
+
doc,
|
389
|
+
node = None,
|
390
|
+
name = '',
|
391
|
+
default = 0,
|
392
|
+
desc = '',
|
393
|
+
tab = ''):
|
394
|
+
super(IntPreference,self).__init__(doc,
|
395
|
+
tag = self.TAG,
|
396
|
+
node = node,
|
397
|
+
name = name,
|
398
|
+
default = str(default),
|
399
|
+
desc = desc,
|
400
|
+
tab = tab)
|
401
|
+
|
402
|
+
registerElement(IntPreference)
|
403
|
+
|
404
|
+
# --------------------------------------------------------------------
|
405
|
+
class FloatPreference(Preference):
|
406
|
+
TAG = Preference.PREFS+'DoublePreference'
|
407
|
+
def __init__(self,
|
408
|
+
doc,
|
409
|
+
node = None,
|
410
|
+
name = '',
|
411
|
+
default = 0.,
|
412
|
+
desc = '',
|
413
|
+
tab = ''):
|
414
|
+
super(FloatPreference,self).__init__(doc,
|
415
|
+
tag = self.TAG,
|
416
|
+
node = node,
|
417
|
+
name = name,
|
418
|
+
default = str(default),
|
419
|
+
desc = desc,
|
420
|
+
tab = tab)
|
421
|
+
|
422
|
+
registerElement(FloatPreference)
|
423
|
+
|
424
|
+
# --------------------------------------------------------------------
|
425
|
+
class BoolPreference(Preference):
|
426
|
+
TAG = Preference.PREFS+'BooleanPreference'
|
427
|
+
def __init__(self,
|
428
|
+
doc,
|
429
|
+
node = None,
|
430
|
+
name = '',
|
431
|
+
default = False,
|
432
|
+
desc = '',
|
433
|
+
tab = ''):
|
434
|
+
super(BoolPreference,self).__init__(doc,
|
435
|
+
tag = self.TAG,
|
436
|
+
node = node,
|
437
|
+
name = name,
|
438
|
+
default = ('true' if default
|
439
|
+
else 'false'),
|
440
|
+
desc = desc,
|
441
|
+
tab = tab)
|
442
|
+
|
443
|
+
registerElement(BoolPreference)
|
444
|
+
|
445
|
+
# --------------------------------------------------------------------
|
446
|
+
class StrPreference(Preference):
|
447
|
+
TAG = Preference.PREFS+'StringPreference'
|
448
|
+
def __init__(self,
|
449
|
+
doc,
|
450
|
+
node = None,
|
451
|
+
name = '',
|
452
|
+
default = '',
|
453
|
+
desc = '',
|
454
|
+
tab = ''):
|
455
|
+
super(StrPreference,self).__init__(doc,
|
456
|
+
tag = self.TAG,
|
457
|
+
node = node,
|
458
|
+
name = name,
|
459
|
+
default = default,
|
460
|
+
desc = desc,
|
461
|
+
tab = tab)
|
462
|
+
|
463
|
+
registerElement(StrPreference)
|
464
|
+
|
465
|
+
# --------------------------------------------------------------------
|
466
|
+
class TextPreference(Preference):
|
467
|
+
TAG = Preference.PREFS+'TextPreference'
|
468
|
+
def __init__(self,
|
469
|
+
doc,
|
470
|
+
node = None,
|
471
|
+
name = '',
|
472
|
+
default = '',
|
473
|
+
desc = '',
|
474
|
+
tab = ''):
|
475
|
+
super(TextPreference,self).__init__(doc,
|
476
|
+
tag = self.TAG,
|
477
|
+
node = node,
|
478
|
+
name = name,
|
479
|
+
default = (default
|
480
|
+
.replace('\n',' ')),
|
481
|
+
desc = desc,
|
482
|
+
tab = tab)
|
483
|
+
|
484
|
+
registerElement(TextPreference)
|
485
|
+
|
486
|
+
# --------------------------------------------------------------------
|
487
|
+
class EnumPreference(Preference):
|
488
|
+
TAG = Preference.PREFS+'EnumPreference'
|
489
|
+
def __init__(self,
|
490
|
+
doc,
|
491
|
+
node = None,
|
492
|
+
name = '',
|
493
|
+
values = [],
|
494
|
+
default = '',
|
495
|
+
desc = '',
|
496
|
+
tab = ''):
|
497
|
+
ce = lambda v : str(v).replace(',',r'\,')
|
498
|
+
sl = [ce(v) for v in values]
|
499
|
+
df = ce(v)
|
500
|
+
assert df in sl, \
|
501
|
+
f'Default value "{default}" not in list {":".join(values)}'
|
502
|
+
super(EnumPreference,self).__init__(doc,
|
503
|
+
tag = self.TAG,
|
504
|
+
node = node,
|
505
|
+
name = name,
|
506
|
+
default = df,
|
507
|
+
desc = desc,
|
508
|
+
tab = tab,
|
509
|
+
list = sl)
|
510
|
+
|
511
|
+
|
512
|
+
registerElement(EnumPreference)
|
513
|
+
|
514
|
+
|
515
|
+
# --------------------------------------------------------------------
|
516
|
+
# CurrentMap == "Board"
|
517
|
+
class Inventory(ToolbarElement,GameElementService):
|
518
|
+
TAG = Element.MODULE+'Inventory'
|
519
|
+
ALPHA = 'alpha'
|
520
|
+
LENGTH = 'length',
|
521
|
+
NUMERIC = 'numeric'
|
522
|
+
UNIQUE = ['name']
|
523
|
+
def __init__(self,doc,node=None,
|
524
|
+
name = '',
|
525
|
+
icon = '/images/inventory.gif',
|
526
|
+
text = '',
|
527
|
+
tooltip = 'Show inventory of all pieces',
|
528
|
+
hotkey = key('I',ALT),
|
529
|
+
canDisable = False,
|
530
|
+
propertyGate = '',
|
531
|
+
disabledIcon = '',
|
532
|
+
centerOnPiece = True,
|
533
|
+
drawPieces = True,
|
534
|
+
foldersOnly = False,
|
535
|
+
forwardKeystroke = True,
|
536
|
+
groupBy = '',
|
537
|
+
include = '{}',
|
538
|
+
launchFunction = 'functionHide',
|
539
|
+
leafFormat = '$PieceName$',
|
540
|
+
nonLeafFormat = '$PropertyValue$',
|
541
|
+
pieceZoom = '0.33',
|
542
|
+
pieceZoom2 = '0.5',
|
543
|
+
pieceZoom3 = '0.6',
|
544
|
+
refreshHotkey = key('I',ALT_SHIFT),
|
545
|
+
showMenu = True,
|
546
|
+
sides = '',
|
547
|
+
sortFormat = '$PieceName$',
|
548
|
+
sortPieces = True,
|
549
|
+
sorting = ALPHA,
|
550
|
+
zoomOn = False):
|
551
|
+
super(Inventory,self).__init__(doc,self.TAG,node=node,
|
552
|
+
canDisable = canDisable,
|
553
|
+
centerOnPiece = centerOnPiece,
|
554
|
+
disabledIcon = disabledIcon,
|
555
|
+
drawPieces = drawPieces,
|
556
|
+
foldersOnly = foldersOnly,
|
557
|
+
forwardKeystroke = forwardKeystroke,
|
558
|
+
groupBy = groupBy,
|
559
|
+
hotkey = hotkey,
|
560
|
+
icon = icon,
|
561
|
+
include = include,
|
562
|
+
launchFunction = launchFunction,
|
563
|
+
leafFormat = leafFormat,
|
564
|
+
name = name,
|
565
|
+
nonLeafFormat = nonLeafFormat,
|
566
|
+
pieceZoom = pieceZoom,
|
567
|
+
pieceZoom2 = pieceZoom2,
|
568
|
+
pieceZoom3 = pieceZoom3,
|
569
|
+
propertyGate = propertyGate,
|
570
|
+
refreshHotkey = refreshHotkey,
|
571
|
+
showMenu = showMenu,
|
572
|
+
sides = sides,
|
573
|
+
sortFormat = sortFormat,
|
574
|
+
sortPieces = sortPieces,
|
575
|
+
sorting = sorting,
|
576
|
+
text = text,
|
577
|
+
tooltip = tooltip,
|
578
|
+
zoomOn = zoomOn)
|
579
|
+
|
580
|
+
registerElement(Inventory)
|
581
|
+
|
582
|
+
# --------------------------------------------------------------------
|
583
|
+
class Prototypes(GameElement):
|
584
|
+
TAG = Element.MODULE+'PrototypesContainer'
|
585
|
+
def __init__(self,game,node=None,**kwargs):
|
586
|
+
super(Prototypes,self).\
|
587
|
+
__init__(game,self.TAG,node=node,**kwargs)
|
588
|
+
|
589
|
+
def addPrototype(self,**kwargs):
|
590
|
+
'''Add a `Prototype` element to this
|
591
|
+
|
592
|
+
Parameters
|
593
|
+
----------
|
594
|
+
kwargs : dict
|
595
|
+
Dictionary of attribute key-value pairs
|
596
|
+
|
597
|
+
Returns
|
598
|
+
-------
|
599
|
+
element : Prototype
|
600
|
+
The added element
|
601
|
+
'''
|
602
|
+
return self.add(Prototype,**kwargs)
|
603
|
+
def addFolder(self,**kwargs):
|
604
|
+
'''Add a `ModuleFolder` element to this
|
605
|
+
|
606
|
+
Parameters
|
607
|
+
----------
|
608
|
+
kwargs : dict
|
609
|
+
Dictionary of attribute key-value pairs
|
610
|
+
|
611
|
+
Returns
|
612
|
+
-------
|
613
|
+
element : ModuleFolder
|
614
|
+
The added element
|
615
|
+
'''
|
616
|
+
return self.add(PrototypeFolder,**kwargs)
|
617
|
+
def getPrototypes(self,asdict=True):
|
618
|
+
'''Get all Prototype element(s) from this
|
619
|
+
|
620
|
+
Parameters
|
621
|
+
----------
|
622
|
+
asdict : bool
|
623
|
+
If `True`, return a dictonary that maps key to `Prototype` elements. If `False`, return a list of all Prototype` children.
|
624
|
+
|
625
|
+
Returns
|
626
|
+
-------
|
627
|
+
children : dict or list
|
628
|
+
Dictionary or list of `Prototype` children
|
629
|
+
'''
|
630
|
+
return self.getElementsByKey(Prototype,'name',asdict=asdict)
|
631
|
+
def getFolders(self,asdict=True):
|
632
|
+
'''Get all Menu element(s) from this
|
633
|
+
|
634
|
+
Parameters
|
635
|
+
----------
|
636
|
+
asdict : bool
|
637
|
+
If `True`, return a dictonary that maps key to `Folder`
|
638
|
+
elements. If `False`, return a list of all `Folder`
|
639
|
+
children.
|
640
|
+
|
641
|
+
Returns
|
642
|
+
-------
|
643
|
+
children : dict or list
|
644
|
+
Dictionary or list of `Folder` children
|
645
|
+
|
646
|
+
'''
|
647
|
+
return self.getElementsByKey(PrototypeFolder,'name',asdict)
|
648
|
+
|
649
|
+
registerElement(Prototypes)
|
650
|
+
|
651
|
+
# --------------------------------------------------------------------
|
652
|
+
class DiceButton(ToolbarElement,GameElementService):
|
653
|
+
TAG=Element.MODULE+'DiceButton'
|
654
|
+
UNIQUE = ['name']
|
655
|
+
def __init__(self,elem,node=None,
|
656
|
+
name = '1d6',
|
657
|
+
tooltip = 'Roll a 1d6',
|
658
|
+
text = '1d6',
|
659
|
+
icon = '/images/die.gif',
|
660
|
+
hotkey = key('6',ALT),
|
661
|
+
canDisable = False,
|
662
|
+
propertyGate = '',
|
663
|
+
disabledIcon = '',
|
664
|
+
addToTotal = 0,
|
665
|
+
keepCount = 1,
|
666
|
+
keepDice = False,
|
667
|
+
keepOption = '>',
|
668
|
+
lockAdd = False,
|
669
|
+
lockDice = False,
|
670
|
+
lockPlus = False,
|
671
|
+
lockSides = False,
|
672
|
+
nDice = 1,
|
673
|
+
nSides = 6,
|
674
|
+
plus = 0,
|
675
|
+
prompt = False,
|
676
|
+
reportFormat = '$name$ = $result$',
|
677
|
+
reportTotal = False,
|
678
|
+
sortDice = False):
|
679
|
+
super(DiceButton,self).\
|
680
|
+
__init__(elem,self.TAG,node=node,
|
681
|
+
addToTotal = addToTotal,
|
682
|
+
canDisable = canDisable,
|
683
|
+
disabledIcon = disabledIcon,
|
684
|
+
hotkey = hotkey,
|
685
|
+
icon = icon,
|
686
|
+
keepCount = keepCount,
|
687
|
+
keepDice = keepDice,
|
688
|
+
keepOption = keepOption,
|
689
|
+
lockAdd = lockAdd,
|
690
|
+
lockDice = lockDice,
|
691
|
+
lockPlus = lockPlus,
|
692
|
+
lockSides = lockSides,
|
693
|
+
nDice = nDice,
|
694
|
+
nSides = nSides,
|
695
|
+
name = name,
|
696
|
+
plus = plus,
|
697
|
+
prompt = prompt,
|
698
|
+
propertyGate = propertyGate,
|
699
|
+
reportFormat = reportFormat,
|
700
|
+
reportTotal = reportTotal,
|
701
|
+
sortDice = sortDice,
|
702
|
+
text = text,
|
703
|
+
tooltip = tooltip)
|
704
|
+
|
705
|
+
registerElement(DiceButton)
|
706
|
+
|
707
|
+
# --------------------------------------------------------------------
|
708
|
+
class GameMassKey(GlobalKey,GameElementService):
|
709
|
+
TAG = Element.MODULE+'GlobalKeyCommand'
|
710
|
+
def __init__(self,map,node=None,
|
711
|
+
name = '',
|
712
|
+
buttonText = '',
|
713
|
+
tooltip = '',
|
714
|
+
icon = '',
|
715
|
+
canDisable = False,
|
716
|
+
propertyGate = '',
|
717
|
+
disabledIcon = '',
|
718
|
+
buttonHotkey = '',
|
719
|
+
hotkey = '',
|
720
|
+
deckCount = '-1',
|
721
|
+
filter = '',
|
722
|
+
reportFormat = '',
|
723
|
+
reportSingle = False,
|
724
|
+
singleMap = True,
|
725
|
+
target = GlobalKey.SELECTED):
|
726
|
+
'''Default targets are selected units'''
|
727
|
+
super(GameMassKey,self).\
|
728
|
+
__init__(map,
|
729
|
+
self.TAG,
|
730
|
+
node = node,
|
731
|
+
name = name,
|
732
|
+
buttonHotkey = buttonHotkey, # This hot key
|
733
|
+
hotkey = hotkey, # Target hot key
|
734
|
+
buttonText = buttonText,
|
735
|
+
canDisable = canDisable,
|
736
|
+
deckCount = deckCount,
|
737
|
+
filter = filter,
|
738
|
+
propertyGate = propertyGate,
|
739
|
+
reportFormat = reportFormat,
|
740
|
+
reportSingle = reportSingle,
|
741
|
+
singleMap = singleMap,
|
742
|
+
target = target,
|
743
|
+
tooltip = tooltip,
|
744
|
+
icon = icon)
|
745
|
+
|
746
|
+
registerElement(GameMassKey)
|
747
|
+
|
748
|
+
# --------------------------------------------------------------------
|
749
|
+
class StartupMassKey(GlobalKey,GameElementService):
|
750
|
+
TAG = Element.MODULE+'StartupGlobalKeyCommand'
|
751
|
+
FIRST_LAUNCH = 'firstLaunchOfSession'
|
752
|
+
EVERY_LAUNCH = 'everyLaunchOfSession'
|
753
|
+
START_GAME = 'startOfGameOnly'
|
754
|
+
def __init__(self,
|
755
|
+
map,
|
756
|
+
node = None,
|
757
|
+
name = '',
|
758
|
+
buttonHotkey = '',
|
759
|
+
hotkey = '',
|
760
|
+
buttonText = '',
|
761
|
+
canDisable = False,
|
762
|
+
deckCount = '-1',
|
763
|
+
filter = '',
|
764
|
+
propertyGate = '',
|
765
|
+
reportFormat = '',
|
766
|
+
reportSingle = False,
|
767
|
+
singleMap = True,
|
768
|
+
target = GlobalKey.SELECTED,
|
769
|
+
tooltip = '',
|
770
|
+
icon = '',
|
771
|
+
whenToApply = EVERY_LAUNCH):
|
772
|
+
'''Default targets are selected units'''
|
773
|
+
super(StartupMassKey,self).\
|
774
|
+
__init__(map,
|
775
|
+
self.TAG,
|
776
|
+
node = node,
|
777
|
+
name = name,
|
778
|
+
buttonHotkey = buttonHotkey, # This hot key
|
779
|
+
hotkey = hotkey, # Target hot key
|
780
|
+
buttonText = buttonText,
|
781
|
+
canDisable = canDisable,
|
782
|
+
deckCount = deckCount,
|
783
|
+
filter = filter,
|
784
|
+
propertyGate = propertyGate,
|
785
|
+
reportFormat = reportFormat,
|
786
|
+
reportSingle = reportSingle,
|
787
|
+
singleMap = singleMap,
|
788
|
+
target = target,
|
789
|
+
tooltip = tooltip,
|
790
|
+
icon = icon)
|
791
|
+
if node is None:
|
792
|
+
self['whenToApply'] = whenToApply
|
793
|
+
|
794
|
+
registerElement(StartupMassKey)
|
795
|
+
|
796
|
+
# --------------------------------------------------------------------
|
797
|
+
class Menu(GameElement):
|
798
|
+
TAG = Element.MODULE+'ToolbarMenu'
|
799
|
+
UNIQUE = ['name']
|
800
|
+
def __init__(self,
|
801
|
+
game,
|
802
|
+
node = None,
|
803
|
+
name = '',
|
804
|
+
tooltip = '',
|
805
|
+
text = '', # Menu name
|
806
|
+
canDisable = False,
|
807
|
+
propertyGate = '',
|
808
|
+
disabledIcon = '',
|
809
|
+
description = '',
|
810
|
+
hotkey = '',
|
811
|
+
icon = '',
|
812
|
+
menuItems = []):
|
813
|
+
if len(description) <= 0 and len(tooltip) > 0:
|
814
|
+
description = tooltip
|
815
|
+
if len(tooltip) <= 0 and len(description) > 0:
|
816
|
+
tooltip = description
|
817
|
+
super(Menu,self).\
|
818
|
+
__init__(game,
|
819
|
+
self.TAG,
|
820
|
+
node = node,
|
821
|
+
name = name,
|
822
|
+
canDisable = canDisable,
|
823
|
+
description = description,
|
824
|
+
disabledIcon = disabledIcon,
|
825
|
+
hotkey = hotkey,
|
826
|
+
icon = icon,
|
827
|
+
menuItems = ','.join(menuItems),
|
828
|
+
propertyGate = propertyGate,
|
829
|
+
text = text,
|
830
|
+
tooltip = tooltip)
|
831
|
+
|
832
|
+
registerElement(Menu)
|
833
|
+
|
834
|
+
|
835
|
+
# --------------------------------------------------------------------
|
836
|
+
class SymbolicDice(GameElement):
|
837
|
+
TAG = Element.MODULE+'SpecialDiceButton'
|
838
|
+
UNIQUE = ['name']
|
839
|
+
def __init__(self,
|
840
|
+
game,
|
841
|
+
node = None,
|
842
|
+
canDisable = False,
|
843
|
+
disabledIcon = '',
|
844
|
+
hotkey = key('6',ALT),
|
845
|
+
name = "Dice", # GP prefix
|
846
|
+
text = '', # Text on button
|
847
|
+
icon = '/images/die.gif', # Icon on button
|
848
|
+
format = '{name+": "+result1}', # Report
|
849
|
+
tooltip = 'Die roll', # Help
|
850
|
+
propertyGate = '', # Property to disable when T
|
851
|
+
resultButton = False, # Result on button?
|
852
|
+
resultChatter = True, # Result in Chatter?
|
853
|
+
resultWindow = False, # Result window?
|
854
|
+
backgroundColor = rgb(0xdd,0xdd,0xdd), # Window background
|
855
|
+
windowTitleResultFormat = "$name$", # Window title
|
856
|
+
windowX = '67', # Window size
|
857
|
+
windowY = '65',
|
858
|
+
doHotkey = False,
|
859
|
+
doLoop = False,
|
860
|
+
doReport = False,
|
861
|
+
doSound = False,
|
862
|
+
hideWhenDisabled = False,
|
863
|
+
hotkeys = '',
|
864
|
+
index = False,
|
865
|
+
indexProperty = '',
|
866
|
+
indexStart = 1,
|
867
|
+
indexStep = 1,
|
868
|
+
loopCount = 1,
|
869
|
+
loopType = 'counted',
|
870
|
+
postLoopKey = '',
|
871
|
+
reportFormat = '',
|
872
|
+
soundClip = '',
|
873
|
+
untilExpression = '',
|
874
|
+
whileExpression = ''
|
875
|
+
):
|
876
|
+
super(SymbolicDice,self).\
|
877
|
+
__init__(game,
|
878
|
+
self.TAG,
|
879
|
+
node = node,
|
880
|
+
canDisable = canDisable,
|
881
|
+
disabledIcon = disabledIcon,
|
882
|
+
hotkey = hotkey,
|
883
|
+
name = name,
|
884
|
+
text = text,
|
885
|
+
icon = icon,
|
886
|
+
format = format,
|
887
|
+
tooltip = tooltip,
|
888
|
+
propertyGate = propertyGate,
|
889
|
+
resultButton = resultButton,
|
890
|
+
resultChatter = resultChatter,
|
891
|
+
resultWindow = resultWindow,
|
892
|
+
backgroundColor = backgroundColor,
|
893
|
+
windowTitleResultFormat = windowTitleResultFormat,
|
894
|
+
windowX = windowX,
|
895
|
+
windowY = windowY,
|
896
|
+
doHotkey = doHotkey,
|
897
|
+
doLoop = doLoop,
|
898
|
+
doReport = doReport,
|
899
|
+
doSound = doSound,
|
900
|
+
hideWhenDisabled = hideWhenDisabled,
|
901
|
+
hotkeys = hotkeys,
|
902
|
+
index = index,
|
903
|
+
indexProperty = indexProperty,
|
904
|
+
indexStart = indexStart,
|
905
|
+
indexStep = indexStep,
|
906
|
+
loopCount = loopCount,
|
907
|
+
loopType = loopType,
|
908
|
+
postLoopKey = postLoopKey,
|
909
|
+
reportFormat = reportFormat,
|
910
|
+
soundClip = soundClip,
|
911
|
+
untilExpression = untilExpression,
|
912
|
+
whileExpression = whileExpression)
|
913
|
+
|
914
|
+
|
915
|
+
def addDie(self,**kwargs):
|
916
|
+
return self.add(SpecialDie,**kwargs)
|
917
|
+
|
918
|
+
def getSymbolicDice(self):
|
919
|
+
return self.getParent(SymbolicDice)
|
920
|
+
|
921
|
+
registerElement(SymbolicDice)
|
922
|
+
|
923
|
+
|
924
|
+
# --------------------------------------------------------------------
|
925
|
+
class SpecialDie(GameElement):
|
926
|
+
TAG = Element.MODULE+'SpecialDie'
|
927
|
+
UNIQUE = ['name']
|
928
|
+
def __init__(self,
|
929
|
+
symbolic, # Symblic dice
|
930
|
+
node = None,
|
931
|
+
name = '', # Name of dice (no GP)
|
932
|
+
report = '{name+": "+result}',
|
933
|
+
faces = None):
|
934
|
+
super(SpecialDie,self).\
|
935
|
+
__init__(symbolic,
|
936
|
+
self.TAG,
|
937
|
+
node = node,
|
938
|
+
name = name,
|
939
|
+
report = report)
|
940
|
+
if node is not None or faces is None:
|
941
|
+
return
|
942
|
+
if isinstance(faces,list):
|
943
|
+
faces = {i+1: f for i,f in enumerate(faces)}
|
944
|
+
for v,f in faces:
|
945
|
+
self.addFace(text = str(v), value = v, icon = f)
|
946
|
+
|
947
|
+
def addFace(self,**kwargs):
|
948
|
+
self.add(DieFace,**kwargs)
|
949
|
+
|
950
|
+
def getSymbolicDice(self):
|
951
|
+
return self.getParent(SymbolicDice)
|
952
|
+
|
953
|
+
def getFaces(self):
|
954
|
+
return self.getAllElements(DieFace,single=False)
|
955
|
+
|
956
|
+
registerElement(SpecialDie)
|
957
|
+
|
958
|
+
# --------------------------------------------------------------------
|
959
|
+
class DieFace(GameElement):
|
960
|
+
TAG = Element.MODULE+'SpecialDieFace'
|
961
|
+
# Is this OK? Multiple faces can have the same icon, text and value
|
962
|
+
UNIQUE = ['icon','text','value']
|
963
|
+
def __init__(self,
|
964
|
+
special, # Special dice
|
965
|
+
node, # existing node
|
966
|
+
icon = '', # graphical representation
|
967
|
+
text = '', # Text representation
|
968
|
+
value = 0): # Value representation
|
969
|
+
super(DieFace,self).\
|
970
|
+
__init__(special,
|
971
|
+
self.TAG,
|
972
|
+
node = node,
|
973
|
+
icon = icon,
|
974
|
+
text = text,
|
975
|
+
value = value)
|
976
|
+
|
977
|
+
def getSpecialDie(self):
|
978
|
+
return self.getParent(SpecialDie)
|
979
|
+
|
980
|
+
# -- This one is tricky! --
|
981
|
+
# def __hash__(self):
|
982
|
+
# return super().__hash__()+getSpecialDie()
|
983
|
+
|
984
|
+
registerElement(DieFace)
|
985
|
+
|
986
|
+
# --------------------------------------------------------------------
|
987
|
+
class ImageDefinitions(GameElement):
|
988
|
+
#TAG = Element.MODULE+'gamepieceimage.GamePieceImageDefinitions'
|
989
|
+
TAG = Element.MODULE+'gamepieceimage.GamePieceImageDefinitions'
|
990
|
+
def __init__(self,
|
991
|
+
game,
|
992
|
+
node,
|
993
|
+
**kwargs):
|
994
|
+
super().__init__(game,self.TAG,node=node,**kwargs)
|
995
|
+
|
996
|
+
registerElement(ImageDefinitions)
|
997
|
+
|
998
|
+
# --------------------------------------------------------------------
|
999
|
+
class LayoutsContainer(GameElement):
|
1000
|
+
#TAG = Element.MODULE+'gamepieceimage.GamePieceLayoutsContainer'
|
1001
|
+
TAG = Element.MODULE+'gamepieceimage.GamePieceLayoutsContainer'
|
1002
|
+
def __init__(self,
|
1003
|
+
game,
|
1004
|
+
node,
|
1005
|
+
**kwargs):
|
1006
|
+
super().__init__(game,self.TAG,node=node,**kwargs)
|
1007
|
+
|
1008
|
+
registerElement(LayoutsContainer)
|
1009
|
+
|
1010
|
+
# --------------------------------------------------------------------
|
1011
|
+
class ColorManager(GameElement):
|
1012
|
+
#TAG = Element.MODULE+'gamepieceimage.ColorManager'
|
1013
|
+
TAG = Element.MODULE+'gamepieceimage.ColorManager'
|
1014
|
+
def __init__(self,
|
1015
|
+
game,
|
1016
|
+
node,
|
1017
|
+
**kwargs):
|
1018
|
+
super().__init__(game,self.TAG,node=node,**kwargs)
|
1019
|
+
|
1020
|
+
registerElement(ColorManager)
|
1021
|
+
|
1022
|
+
# --------------------------------------------------------------------
|
1023
|
+
class FontManager(GameElement):
|
1024
|
+
#TAG = Element.MODULE+'gamepieceimage.FontManager'
|
1025
|
+
TAG = Element.MODULE+'gamepieceimage.FontManager'
|
1026
|
+
def __init__(self,
|
1027
|
+
game,
|
1028
|
+
node,
|
1029
|
+
**kwargs):
|
1030
|
+
super().__init__(game,self.TAG,node=node,**kwargs)
|
1031
|
+
|
1032
|
+
registerElement(FontManager)
|
1033
|
+
|
1034
|
+
# --------------------------------------------------------------------
|
1035
|
+
class FontStyle(GameElement):
|
1036
|
+
#TAG = Element.MODULE+'gamepieceimage.FontStyle'
|
1037
|
+
TAG = Element.MODULE+'gamepieceimage.FontStyle'
|
1038
|
+
def __init__(self,
|
1039
|
+
game,
|
1040
|
+
node,
|
1041
|
+
**kwargs):
|
1042
|
+
super().__init__(game,self.TAG,node=node,**kwargs)
|
1043
|
+
|
1044
|
+
registerElement(FontStyle)
|
1045
|
+
|
1046
|
+
# --------------------------------------------------------------------
|
1047
|
+
class MultiActionButton(GameElement):
|
1048
|
+
TAG = Element.MODULE+'MultiActionButton'
|
1049
|
+
def __init__(self,
|
1050
|
+
game,
|
1051
|
+
node,
|
1052
|
+
description = '', # Reminder
|
1053
|
+
text = '', # Text on button
|
1054
|
+
tooltip = '', # Button tooltip
|
1055
|
+
icon = '', # Image on button
|
1056
|
+
hotkey = '', # Key-stroke or command
|
1057
|
+
canDisable = False, # Can it be disabled
|
1058
|
+
propertyGate = '', # Disable when propety true
|
1059
|
+
disabledIcon = '', # image when disabled
|
1060
|
+
menuItems = []): # Button texts
|
1061
|
+
'''
|
1062
|
+
<VASSAL.build.module.MultiActionButton
|
1063
|
+
canDisable="false"
|
1064
|
+
description="Menu"
|
1065
|
+
disabledIcon="" hideWhenDisabled="false"
|
1066
|
+
hotkey="67,130"
|
1067
|
+
icon="C.png"
|
1068
|
+
menuItems="Attacked,Defended"
|
1069
|
+
propertyGate=""
|
1070
|
+
text=""
|
1071
|
+
tooltip="Clear combat status flags."
|
1072
|
+
/>
|
1073
|
+
'''
|
1074
|
+
super().__init__(game,
|
1075
|
+
self.TAG,
|
1076
|
+
node = node,
|
1077
|
+
description = description,
|
1078
|
+
text = text,
|
1079
|
+
tooltip = tooltip,
|
1080
|
+
icon = icon,
|
1081
|
+
hotkey = hotkey,
|
1082
|
+
canDisable = canDisable,
|
1083
|
+
propertyGate = propertyGate,
|
1084
|
+
disabledIcon = disabledIcon,
|
1085
|
+
menuItems = ','.join(menuItems))
|
1086
|
+
|
1087
|
+
registerElement(MultiActionButton)
|
1088
|
+
|
1089
|
+
#
|
1090
|
+
# EOF
|
1091
|
+
#
|