Properly using the skill docs i18n. Fixed issue with markdown getting to #{spriteName} before our replacer did.
This commit is contained in:
parent
294a37e2a2
commit
0b97ef5f0b
2 changed files with 9 additions and 2 deletions
app/views/play/level/tome
|
@ -116,13 +116,18 @@ module.exports = class DocFormatter
|
||||||
obj[prop] = _.template val, context
|
obj[prop] = _.template val, context
|
||||||
catch e
|
catch e
|
||||||
console.error "Couldn't create docs template of", val, "\nwith context", context, "\nError:", e
|
console.error "Couldn't create docs template of", val, "\nwith context", context, "\nError:", e
|
||||||
|
obj[prop] = @replaceSpriteName obj[prop] # Do this before using the template, otherwise marked might get us first.
|
||||||
|
|
||||||
formatPopover: ->
|
formatPopover: ->
|
||||||
content = popoverTemplate doc: @doc, language: @options.language, value: @formatValue(), marked: marked, argumentExamples: (arg.example or arg.default or arg.name for arg in @doc.args ? []), writable: @options.writable, selectedMethod: @options.selectedMethod, cooldowns: @inferCooldowns(), item: @options.item
|
content = popoverTemplate doc: @doc, language: @options.language, value: @formatValue(), marked: marked, argumentExamples: (arg.example or arg.default or arg.name for arg in @doc.args ? []), writable: @options.writable, selectedMethod: @options.selectedMethod, cooldowns: @inferCooldowns(), item: @options.item
|
||||||
owner = if @doc.owner is 'this' then @options.thang else window[@doc.owner]
|
owner = if @doc.owner is 'this' then @options.thang else window[@doc.owner]
|
||||||
content = content.replace /#{spriteName}/g, @options.thang.type ? @options.thang.spriteName # Prefer type, and excluded the quotes we'd get with @formatValue
|
content = @replaceSpriteName content
|
||||||
content.replace /\#\{(.*?)\}/g, (s, properties) => @formatValue downTheChain(owner, properties.split('.'))
|
content.replace /\#\{(.*?)\}/g, (s, properties) => @formatValue downTheChain(owner, properties.split('.'))
|
||||||
|
|
||||||
|
replaceSpriteName: (s) ->
|
||||||
|
# Prefer type, and excluded the quotes we'd get with @formatValue
|
||||||
|
s.replace /#{spriteName}/g, @options.thang.type ? @options.thang.spriteName
|
||||||
|
|
||||||
formatValue: (v) ->
|
formatValue: (v) ->
|
||||||
return null if @doc.type is 'snippet'
|
return null if @doc.type is 'snippet'
|
||||||
return @options.thang.now() if @doc.name is 'now'
|
return @options.thang.now() if @doc.name is 'now'
|
||||||
|
|
|
@ -46,10 +46,12 @@ module.exports = class SpellPaletteEntryView extends CocoView
|
||||||
content: @docFormatter.formatPopover()
|
content: @docFormatter.formatPopover()
|
||||||
container: 'body'
|
container: 'body'
|
||||||
template: @overridePopoverTemplate
|
template: @overridePopoverTemplate
|
||||||
).on 'show.bs.popover', =>
|
).on 'shown.bs.popover', =>
|
||||||
Backbone.Mediator.publish 'tome:palette-hovered', thang: @thang, prop: @doc.name, entry: @
|
Backbone.Mediator.publish 'tome:palette-hovered', thang: @thang, prop: @doc.name, entry: @
|
||||||
soundIndex = Math.floor(Math.random() * 4)
|
soundIndex = Math.floor(Math.random() * 4)
|
||||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: "spell-palette-entry-open-#{soundIndex}", volume: 0.75
|
Backbone.Mediator.publish 'audio-player:play-sound', trigger: "spell-palette-entry-open-#{soundIndex}", volume: 0.75
|
||||||
|
popover = @$el.data('bs.popover')
|
||||||
|
popover?.$tip?.i18n()
|
||||||
|
|
||||||
onMouseEnter: (e) ->
|
onMouseEnter: (e) ->
|
||||||
# Make sure the doc has the updated Thang so it can regenerate its prop value
|
# Make sure the doc has the updated Thang so it can regenerate its prop value
|
||||||
|
|
Reference in a new issue