Changed some names, made "bind" a type instead
parent
017c45eacf
commit
a222ebd63e
|
@ -89,6 +89,11 @@ default:
|
||||||
- "-moveright"
|
- "-moveright"
|
||||||
- "maybe_move_left"
|
- "maybe_move_left"
|
||||||
- "unalias maybe_move_right"
|
- "unalias maybe_move_right"
|
||||||
|
|
||||||
|
# both do something different for engi
|
||||||
|
bind mouse5: +jump
|
||||||
|
bind 4: slot4
|
||||||
|
|
||||||
# This just stops an error message the first time you release
|
# This just stops an error message the first time you release
|
||||||
# either of 'a' or 'd'
|
# either of 'a' or 'd'
|
||||||
impulse maybe_move_left:
|
impulse maybe_move_left:
|
||||||
|
@ -134,6 +139,28 @@ engi:
|
||||||
press:
|
press:
|
||||||
- destroy sentry
|
- destroy sentry
|
||||||
- build sentry
|
- build sentry
|
||||||
|
double 4:
|
||||||
|
type: double
|
||||||
|
condition: mouse4
|
||||||
|
|
||||||
|
primary:
|
||||||
|
type: impulse
|
||||||
|
condition: mouse5
|
||||||
|
primary:
|
||||||
|
- destroy dispenser
|
||||||
|
- build dispenser
|
||||||
|
secondary:
|
||||||
|
- destroy exit
|
||||||
|
- build exit
|
||||||
|
secondary:
|
||||||
|
type: impulse
|
||||||
|
condition: mouse5
|
||||||
|
primary:
|
||||||
|
- destroy entrance
|
||||||
|
- build entrance
|
||||||
|
secondary:
|
||||||
|
- destroy entrance
|
||||||
|
- build entrance
|
||||||
|
|
||||||
medic:
|
medic:
|
||||||
# "Radar" feature: causes all teammates to autocall for medic, allowing
|
# "Radar" feature: causes all teammates to autocall for medic, allowing
|
||||||
|
@ -147,21 +174,3 @@ medic:
|
||||||
condition: mouse4
|
condition: mouse4
|
||||||
primary: voice medic
|
primary: voice medic
|
||||||
secondary: voice uber ready
|
secondary: voice uber ready
|
||||||
|
|
||||||
soldier:
|
|
||||||
double mouse1:
|
|
||||||
type: hold
|
|
||||||
condition: mouse4
|
|
||||||
cancel: both
|
|
||||||
# normal firing
|
|
||||||
primary: +attack
|
|
||||||
# rocket jump
|
|
||||||
secondary:
|
|
||||||
press:
|
|
||||||
- +attack
|
|
||||||
- +duck
|
|
||||||
- +jump
|
|
||||||
release:
|
|
||||||
- -attack
|
|
||||||
- -duck
|
|
||||||
- -jump
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ validKeyList = [
|
||||||
|
|
||||||
popErrors = (AttributeError, KeyError, TypeError)
|
popErrors = (AttributeError, KeyError, TypeError)
|
||||||
|
|
||||||
class Bind(object):
|
class ScriptBind(object):
|
||||||
'''
|
'''
|
||||||
Parent class for all bind types.
|
Parent class for all bind types.
|
||||||
Verifies key, creates local variables
|
Verifies key, creates local variables
|
||||||
|
@ -47,7 +47,7 @@ class Bind(object):
|
||||||
# and some other universal fields like alias and finds targetType
|
# and some other universal fields like alias and finds targetType
|
||||||
self.verify()
|
self.verify()
|
||||||
|
|
||||||
if type(self) is Bind:
|
if type(self) is ScriptBind:
|
||||||
# not using isinstance(), because all subclasses are also instances
|
# not using isinstance(), because all subclasses are also instances
|
||||||
# of bind.
|
# of bind.
|
||||||
return
|
return
|
||||||
|
@ -137,7 +137,7 @@ class Bind(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Impulse(Bind):
|
class Impulse(ScriptBind):
|
||||||
def verify(self):
|
def verify(self):
|
||||||
self.command: list = None
|
self.command: list = None
|
||||||
if not isinstance(self.fields, dict):
|
if not isinstance(self.fields, dict):
|
||||||
|
@ -231,7 +231,7 @@ class Impulse(Bind):
|
||||||
return buildingNums.get(building, building)
|
return buildingNums.get(building, building)
|
||||||
|
|
||||||
|
|
||||||
class Hold(Bind):
|
class Hold(ScriptBind):
|
||||||
def verify(self):
|
def verify(self):
|
||||||
self.press: list = None
|
self.press: list = None
|
||||||
self.release: list = None
|
self.release: list = None
|
||||||
|
@ -293,7 +293,7 @@ class Hold(Bind):
|
||||||
return code
|
return code
|
||||||
|
|
||||||
|
|
||||||
class Toggle(Bind):
|
class Toggle(ScriptBind):
|
||||||
def verify(self):
|
def verify(self):
|
||||||
self.on : list = None
|
self.on : list = None
|
||||||
self.off: list = None
|
self.off: list = None
|
||||||
|
@ -349,7 +349,7 @@ class Toggle(Bind):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Double(Bind):
|
class Double(ScriptBind):
|
||||||
defaultDict = {}
|
defaultDict = {}
|
||||||
condDict = {}
|
condDict = {}
|
||||||
bindNames = []
|
bindNames = []
|
||||||
|
@ -360,8 +360,8 @@ class Double(Bind):
|
||||||
self.isToggle = False
|
self.isToggle = False
|
||||||
self.cancelBoth = False
|
self.cancelBoth = False
|
||||||
|
|
||||||
self.primary: Bind = None
|
self.primary: ScriptBind = None
|
||||||
self.secondary: Bind = None
|
self.secondary: ScriptBind = None
|
||||||
self.condition: str = None
|
self.condition: str = None
|
||||||
self.type: str = None
|
self.type: str = None
|
||||||
|
|
||||||
|
@ -427,9 +427,9 @@ class Double(Bind):
|
||||||
if self.primary is self.secondary is None:
|
if self.primary is self.secondary is None:
|
||||||
self.err('has neither primary nor secondary')
|
self.err('has neither primary nor secondary')
|
||||||
|
|
||||||
def getSection(self, popName, key, /) -> Bind:
|
def getSection(self, popName, key, /) -> ScriptBind:
|
||||||
section = self.fields.pop(popName)
|
section = self.fields.pop(popName)
|
||||||
bind = Bind(f'{self.type} {key}', section)
|
bind = ScriptBind(f'{self.type} {key}', section)
|
||||||
bind = bind.toTargetType()
|
bind = bind.toTargetType()
|
||||||
|
|
||||||
bind.errors.remove(f'invalid key name: "{key}"')
|
bind.errors.remove(f'invalid key name: "{key}"')
|
||||||
|
@ -543,7 +543,7 @@ class Double(Bind):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Repeat(Bind):
|
class Repeat(ScriptBind):
|
||||||
def verify(self):
|
def verify(self):
|
||||||
self.interval = None
|
self.interval = None
|
||||||
self.command = None
|
self.command = None
|
||||||
|
@ -573,7 +573,7 @@ class Repeat(Bind):
|
||||||
return f'// repeat {self.key}\n'
|
return f'// repeat {self.key}\n'
|
||||||
|
|
||||||
|
|
||||||
class Literal(Bind):
|
class Literal(ScriptBind):
|
||||||
def verify(self):
|
def verify(self):
|
||||||
self.text = ''
|
self.text = ''
|
||||||
self.run = False
|
self.run = False
|
||||||
|
@ -617,8 +617,23 @@ class Literal(Bind):
|
||||||
result += f'\n{self.key}'
|
result += f'\n{self.key}'
|
||||||
return result + '\n'
|
return result + '\n'
|
||||||
|
|
||||||
|
|
||||||
|
class Bind(ScriptBind):
|
||||||
|
def verify(self):
|
||||||
|
# just set self.text, and if it's not a string, make an error
|
||||||
|
self.text = self.fields
|
||||||
|
if isinstance(self.text, str):
|
||||||
|
# clear self.fields to assure no "extra field" warnings
|
||||||
|
self.fields = {}
|
||||||
|
else:
|
||||||
|
# not passed string ==> error
|
||||||
|
self.err('argument must be a string')
|
||||||
|
|
||||||
|
def toTF2(self) -> str:
|
||||||
|
return f'bind {self.key} {self.text}\n'
|
||||||
|
|
||||||
# This is at the bottom because it has to happen after
|
# This is at the bottom because it has to happen after
|
||||||
# all inheritances have been completed
|
# all inheritances have been completed
|
||||||
|
|
||||||
Bind.bindTypes = Bind.__subclasses__()
|
ScriptBind.bindTypes = ScriptBind.__subclasses__()
|
||||||
Double.bindNames = [ bind.__name__.lower() for bind in Bind.bindTypes ]
|
Double.bindNames = [ bind.__name__.lower() for bind in ScriptBind.bindTypes ]
|
|
@ -47,7 +47,7 @@ def verifyConfig(cfg: dict) -> (dict, dict):
|
||||||
errMessages = []
|
errMessages = []
|
||||||
warnMessages = []
|
warnMessages = []
|
||||||
for key, data in classCFG.items():
|
for key, data in classCFG.items():
|
||||||
bind = tftypes.Bind(key, data)
|
bind = tftypes.ScriptBind(key, data)
|
||||||
|
|
||||||
bind = bind.toTargetType()
|
bind = bind.toTargetType()
|
||||||
if isclass:
|
if isclass:
|
||||||
|
|
Loading…
Reference in New Issue