Adding new widget types

This commit is contained in:
Mark Mine 2003-10-11 00:56:58 +00:00
parent 41d7c6d6dd
commit 41232c24d9
2 changed files with 93 additions and 82 deletions

View File

@ -6,10 +6,11 @@ class AttribDesc:
name == name of attribute name == name of attribute
default == default value for attrib default == default value for attrib
""" """
def __init__(self, name, default, datatype='string'): def __init__(self, name, default, datatype='string', params = {}):
self.name = name self.name = name
self.default = default self.default = default
self.datatype = datatype self.datatype = datatype
self.params = params
def getName(self): def getName(self):
return self.name return self.name
@ -17,6 +18,8 @@ class AttribDesc:
return self.default return self.default
def getDatatype(self): def getDatatype(self):
return self.datatype return self.datatype
def getParams(self):
return self.params
def __str__(self): def __str__(self):
return self.name return self.name

View File

@ -12,23 +12,23 @@ class Entity:
class ActiveCell(Entity): class ActiveCell(Entity):
type = 'activeCell' type = 'activeCell'
attribs = ( attribs = (
('row', 0), ('row', 0, 'int'),
('col', 0), ('col', 0, 'int'),
('gridId', None) ('gridId', None, 'entId', {'type':'grid'})
) )
class DirectionalCell(ActiveCell): class DirectionalCell(ActiveCell):
type = 'directionalCell' type = 'directionalCell'
attribs = ( attribs = (
('dir', [0,0]), ('dir', [0,0], 'choice', {'choiceSet':['l','r','up','dn']}),
) )
class LevelMgr(Entity): class LevelMgr(Entity):
type = 'levelMgr' type = 'levelMgr'
attribs = ( attribs = (
('cogLevel', 0), ('cogLevel', 0, 'int', {'min':0, 'max':11}),
('cogTrack', 'c'), ('cogTrack', 'c', 'choice', {'choiceSet':['c','s','l','m']}),
('modelFilename', None), ('modelFilename', None, 'modelpath'),
) )
class EditMgr(Entity): class EditMgr(Entity):
@ -40,18 +40,20 @@ class EditMgr(Entity):
class LogicGate(Entity): class LogicGate(Entity):
type = 'logicGate' type = 'logicGate'
output = 'bool'
attribs = ( attribs = (
('input_input1_bool', 0, 'boolean'), ('input_input1_bool', 0, 'entId', {'output':'bool'}),
('input_input2_bool', 0, 'boolean'), ('input_input2_bool', 0, 'entId', {'output':'bool'}),
('isInput1', 0), ('isInput1', 0, 'bool'),
('isInput2', 0), ('isInput2', 0, 'bool'),
('logicType', 'or'), ('logicType', 'or', 'choice',
('output', 'bool'), {'choiceSet':['or','and','xor','nand','nor','xnor']}),
) )
class NodepathImpl: class NodepathImpl:
isNodePath = 1
attribs = ( attribs = (
('parent', 0), ('parent', 0, 'entId', {'type':'isNodePath'}),
('pos', Point3(0,0,0), 'pos'), ('pos', Point3(0,0,0), 'pos'),
('hpr', Vec3(0,0,0), 'hpr'), ('hpr', Vec3(0,0,0), 'hpr'),
) )
@ -59,10 +61,12 @@ class NodepathImpl:
# Note: this covers Nodepath and DistributedNodepath # Note: this covers Nodepath and DistributedNodepath
class Nodepath(Entity, NodepathImpl): class Nodepath(Entity, NodepathImpl):
type = 'nodepath' type = 'nodepath'
isNodePath = 1
class NodepathAttribs: class NodepathAttribs:
isNodePath = 1
attribs = ( attribs = (
('parent', 0), ('parent', 0, 'entId', {'type':'isNodePath'}),
('pos', Point3(0,0,0), 'pos'), ('pos', Point3(0,0,0), 'pos'),
('hpr', Vec3(0,0,0), 'hpr'), ('hpr', Vec3(0,0,0), 'hpr'),
) )
@ -76,8 +80,8 @@ class Zone(Entity, NodepathAttribs):
) )
attribs = ( attribs = (
('description', ''), ('description', ''),
('modelZoneNum', None), ('modelZoneNum', None, 'int'),
('visibility', []), ('visibility', [], 'modelZoneList'),
) )
class CutScene(Entity): class CutScene(Entity):
@ -97,7 +101,7 @@ class BarrelBase(Nodepath):
'hpr', 'hpr',
) )
attribs = ( attribs = (
('h', 0, 'float'), ('h', 0, 'float', {'min':0, 'max':360}),
) )
class BeanBarrel(BarrelBase): class BeanBarrel(BarrelBase):
@ -106,19 +110,19 @@ class BeanBarrel(BarrelBase):
class GagBarrel(BarrelBase): class GagBarrel(BarrelBase):
type = 'gagBarrel' type = 'gagBarrel'
attribs = ( attribs = (
('gagLevel', 0), ('gagLevel', 0, 'int', {'min':0,'max':5}),
('gagTrack', 0), ('gagTrack', 0, 'choice', {'choiceSet':range(7)}),
) )
class Switch(Entity, NodepathImpl): class Switch(Entity, NodepathImpl):
output = 'bool'
attribs = ( attribs = (
('scale', 1), ('scale', Vec3(1), 'scale'),
('color', Vec4(1,1,1,1), 'color'), ('color', Vec4(1,1,1,1), 'color'),
('model', None), ('model', '', 'bamfilename'),
('input_isOn_bool', 0, 'boolean'), ('input_isOn_bool', 0, 'entId', {'output':'bool'}),
('isOn', 0), ('isOn', 0, 'bool'),
('output', 'bool'), ('secondsOn', 1, 'float'),
('secondsOn', 1),
) )
class Button(Switch): class Button(Switch):
@ -130,11 +134,11 @@ class Trigger(Switch):
class ConveyorBelt(Nodepath): class ConveyorBelt(Nodepath):
type = 'conveyorBelt' type = 'conveyorBelt'
attribs = ( attribs = (
('speed', 1.0), ('speed', 1.0, 'float'),
('length', 1.0), ('length', 1.0, 'float'),
('widthScale', 1.0), ('widthScale', 1.0, 'float'),
('treadLength', 1.0), ('treadLength', 1.0, 'float'),
('treadModelPath', 'phase_7/models/cogHQ/platform1'), ('treadModelPath', 'phase_7/models/cogHQ/platform1', 'bamfilename'),
('floorName', 'platformcollision'), ('floorName', 'platformcollision'),
) )
@ -144,33 +148,33 @@ class Crate(Nodepath):
'hpr', 'hpr',
) )
attribs = ( attribs = (
('scale', 1), ('scale', Vec3(1), 'scale'),
('gridId', None), ('gridId', None, 'entId', {'type':'grid'}),
('pushable', 1), ('pushable', 1, 'bool'),
) )
class Door(Entity): class Door(Entity):
type = 'door' type = 'door'
output = 'bool'
attribs = ( attribs = (
('parent', 0), ('parent', 0, 'entId'),
('pos', Point3(0,0,0), 'pos'), ('pos', Point3(0,0,0), 'pos'),
('hpr', Vec3(0,0,0), 'hpr'), ('hpr', Vec3(0,0,0), 'hpr'),
('scale', 1), ('scale', Vec3(1,1,1), 'scale'),
('color', Vec4(1,1,1,1), 'color'), ('color', Vec4(1,1,1,1), 'color'),
('model', None), ('model', "", 'bamfilename'),
('doorwayNum', 0), ('doorwayNum', 0), # Obsolete
('input_Lock0_bool', 0, 'boolean'), ('input_Lock0_bool', 0, 'entId', {'output':'bool'}),
('input_Lock1_bool', 0, 'boolean'), ('input_Lock1_bool', 0, 'entId', {'output':'bool'}),
('input_Lock2_bool', 0, 'boolean'), ('input_Lock2_bool', 0, 'entId', {'output':'bool'}),
('input_Lock3_bool', 0, 'boolean'), ('input_Lock3_bool', 0, 'entId', {'output':'bool'}),
('input_isOpen_bool', 0, 'boolean'), ('input_isOpen_bool', 0, 'entId', {'output':'bool'}),
('isLock0Unlocked', 0), ('isLock0Unlocked', 0, 'bool'),
('isLock1Unlocked', 0), ('isLock1Unlocked', 0, 'bool'),
('isLock2Unlocked', 0), ('isLock2Unlocked', 0, 'bool'),
('isLock3Unlocked', 0), ('isLock3Unlocked', 0, 'bool'),
('isOpen', 0), ('isOpen', 0, 'bool'),
('output', 'bool'), ('secondsOpen', 1, 'float'),
('secondsOpen', 1),
) )
class Grid(Nodepath): class Grid(Nodepath):
@ -179,20 +183,20 @@ class Grid(Nodepath):
'hpr', 'hpr',
) )
attribs = ( attribs = (
('cellSize', 3), ('cellSize', 3, 'float'),
('numCol', 3), ('numCol', 3, 'int'),
('numRow', 3), ('numRow', 3, 'int'),
) )
class Lift(Nodepath): class Lift(Nodepath):
type = 'lift' type = 'lift'
attribs = ( attribs = (
('duration', 1), ('duration', 1, 'float'),
('startPos', Point3(0,0,0), 'pos'), ('startPos', Point3(0,0,0), 'pos'),
('endPos', Point3(0,0,0), 'pos'), ('endPos', Point3(0,0,0), 'pos'),
('modelPath', ''), ('modelPath', '', 'bamfilename'),
('floorName', ''), ('floorName', ''),
('modelScale', 1), ('modelScale', Vec3(1), 'scale'),
) )
class Platform(Nodepath): class Platform(Nodepath):
@ -203,9 +207,9 @@ class Platform(Nodepath):
attribs = ( attribs = (
('startPos', Point3(0,0,0), 'pos'), ('startPos', Point3(0,0,0), 'pos'),
('endPos', Point3(0,0,0), 'pos'), ('endPos', Point3(0,0,0), 'pos'),
('speed', 1), ('speed', 1, 'float'),
('waitDur', 1), ('waitDur', 1, 'float'),
('phaseShift', 0.), ('phaseShift', 0., 'float', {'min':0,'max':1}),
) )
class SinkingPlatform(Nodepath): class SinkingPlatform(Nodepath):
@ -215,41 +219,45 @@ class SinkingPlatform(Nodepath):
) )
attribs = ( attribs = (
('endPos', Point3(0,0,0), 'pos'), ('endPos', Point3(0,0,0), 'pos'),
('phaseShift', 0.), ('phaseShift', 0., 'float', {'min':0,'max':1}),
('startPos', Point3(0,0,0), 'pos'), ('startPos', Point3(0,0,0), 'pos'),
('verticalRange', 1), ('verticalRange', 1, 'float'),
('sinkRate', 1), ('sinkRate', 1, 'float'),
('riseRate', 1), ('riseRate', 1, 'float'),
('speed', 1), ('speed', 1, 'float'),
('waitDur', 1), ('waitDur', 1, 'float'),
) )
class Stomper(Nodepath): class Stomper(Nodepath):
type = 'stomper' type = 'stomper'
attribs = ( attribs = (
('headScale', Vec3(1,1,1), 'scale'), ('headScale', Vec3(1,1,1), 'scale'),
('motion', 3), ('motion', 3, 'choice',
('period', 2.), {'choiceSet':['linear','sinus','half sinus','slow fast']}),
('phaseShift', 0.), ('period', 2., 'float'),
('range', 6), ('phaseShift', 0., 'float', {'min':0, 'max':1}),
('range', 6, 'float'),
('shaftScale', Vec3(1,1,1), 'scale'), ('shaftScale', Vec3(1,1,1), 'scale'),
('soundLen', 0), ('soundLen', 0, 'float'),
('soundOn', 0), ('soundOn', 0, 'bool'),
('style', 'horizontal'), ('style', 'horizontal', 'choice',
('zOffset', 0), {'choiceSet':['horizontal', 'vertical']}),
('zOffset', 0, 'float'),
) )
class StomperPair(Nodepath): class StomperPair(Nodepath):
type = 'stomperPair' type = 'stomperPair'
attribs = ( attribs = (
('headScale', Vec3(1,1,1), 'scale'), ('headScale', Vec3(1,1,1), 'scale'),
('motion', 3), ('motion', 3, 'choice',
('period', 2.), {'choiceSet':['linear','sinus','half sinus','slow fast']}),
('phaseShift', 0.), ('period', 2., 'float'),
('range', 6), ('phaseShift', 0., {'min':0, 'max':1}),
('range', 6, 'float'),
('shaftScale', Vec3(1,1,1), 'scale'), ('shaftScale', Vec3(1,1,1), 'scale'),
('soundLen', 0), ('soundLen', 0, 'float'),
('soundOn', 0), ('soundOn', 0, 'bool'),
('stomperIds', []), ('stomperIds', [], 'entId', {'type':'stomper', 'num':2}),
('style', 'horizontal'), ('style', 'horizontal', 'choice',
{'choiceSet':['horizontal', 'vertical']}),
) )