Nothing text ##54
This commit is contained in:
parent
fefda5a2a5
commit
21097bb8bd
2 changed files with 16 additions and 2 deletions
|
@ -143,7 +143,7 @@ class Message(object):
|
||||||
# self.logger.debug(f"Getting text for {self.id}")
|
# self.logger.debug(f"Getting text for {self.id}")
|
||||||
for var in self.variables:
|
for var in self.variables:
|
||||||
self.logger.debug(f"try replacing ${var} with {self.variableValues[var]} in {text}")
|
self.logger.debug(f"try replacing ${var} with {self.variableValues[var]} in {text}")
|
||||||
replacement = self.variableValues[var] if (self.variableValues[var] is not None) else "nothing" #TODO: translate nothing to each language
|
replacement = self.variableValues[var] if (self.variableValues[var] is not None) else self.story.configuration.nothing_text #TODO: translate nothing to each language
|
||||||
text = text.replace('$'+var, replacement)
|
text = text.replace('$'+var, replacement)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
@ -942,7 +942,8 @@ class Diversion(object):
|
||||||
|
|
||||||
class Configuration(object):
|
class Configuration(object):
|
||||||
id = 'configuration'
|
id = 'configuration'
|
||||||
volume = 1
|
volume = 1 # Volume multiplier for 'play' command
|
||||||
|
nothing_text = "nothing" # When variable is not set, but used in sentence, replace it with this word.
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def initFromJson(configClass, data, story):
|
def initFromJson(configClass, data, story):
|
||||||
|
|
|
@ -889,6 +889,19 @@ class Graph {
|
||||||
},
|
},
|
||||||
'value': this.configuration.hasOwnProperty('volume') ? this.configuration.volume : 1
|
'value': this.configuration.hasOwnProperty('volume') ? this.configuration.volume : 1
|
||||||
})
|
})
|
||||||
|
),
|
||||||
|
crel(
|
||||||
|
'label',
|
||||||
|
"Text replacement when no variable is set: ",
|
||||||
|
crel('input', {
|
||||||
|
'type': 'text',
|
||||||
|
'on': {
|
||||||
|
'change': function(e){
|
||||||
|
panopticon.graph.configuration['nothing_text'] = parseFloat(e.target.value)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'value': this.configuration.hasOwnProperty('nothing_text') ? this.configuration.nothing_text : "nothing"
|
||||||
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue