HUD supports more hudProperties. Palette looks at programmableObjectProperties. Fixed bug with level editor frames advancing.

This commit is contained in:
Nick Winter 2014-03-01 11:06:44 -08:00
parent 13c29b57ad
commit 2f130da090
4 changed files with 59 additions and 45 deletions
app
lib/surface
styles/play/level
views/play/level

View file

@ -501,7 +501,7 @@ module.exports = Surface = class Surface extends CocoClass
@trailmaster.tick() if @trailmaster
# Skip some frame updates unless we're playing and not at end (or we haven't drawn much yet)
frameAdvanced = (@playing and @currentFrame < @world.totalFrames) or @totalFramesDrawn < 2
@currentFrame += @world.frameRate / @options.frameRate if frameAdvanced
@currentFrame += @world.frameRate / @options.frameRate if frameAdvanced and @playing
newWorldFrame = Math.floor @currentFrame
worldFrameAdvanced = newWorldFrame isnt oldWorldFrame
if worldFrameAdvanced

View file

@ -86,49 +86,51 @@
@include gradient-radial-custom-stops(hsla(116,80%,74%,1), 20%, hsla(116,80%,31%,1), 70%)
.thang-props
width: 144px
height: 100px
margin: 8px 8px 0 0
overflow-y: auto
float: left
@include user-select(text)
.prop
img
margin-right: 5px
width: 16px
height: 16px
.text-prop
width: 50%
.prop-value.bar-prop
width: 100px
display: inline-block
height: 6px
background: #ddd
border: 1px solid black
border-radius: 6px
overflow: hidden
.bar
background: black
width: 100%
.thang-props-column
float: left
width: 144px
height: 100px
@include user-select(text)
.prop
img
margin-right: 5px
width: 16px
height: 16px
.text-prop
width: 50%
.prop-value.bar-prop
width: 100px
display: inline-block
height: 6px
background: #ddd
border: 1px solid black
border-radius: 6px
overflow: hidden
.bar
background: black
width: 100%
height: 100%
.prop[name="health"] .bar
background: #C5362B
.message
text-align: center
display: table
height: 100%
.prop[name="health"] .bar
background: #C5362B
.message
text-align: center
display: table
height: 100%
width: 100%
p
display: table-cell
vertical-align: middle
font-size: 20px
width: 100%
p
display: table-cell
vertical-align: middle
font-size: 20px
.thang-actions
width: 212px

View file

@ -135,13 +135,18 @@ module.exports = class HUDView extends View
props = @$el.find('.thang-props')
props.find(":not(.thang-name)").remove()
props.find('.thang-name').text(if @thang.type then "#{@thang.id} - #{@thang.type}" else @thang.id)
column = null
for prop in @thang.hudProperties ? []
continue if prop is 'action'
pel = @createPropElement prop
continue unless pel?
if pel.find('.bar').is('*') and props.find('.bar').is('*')
props.find('.bar-prop').last().after pel # Keep bars together
else
props.append pel
column ?= $('<div class="thang-props-column"></div>').appendTo props
column.append pel
column = null if column.find('.prop').length is 5
null
createActions: ->
actions = @$el.find('.thang-actions tbody').empty()
@ -248,6 +253,8 @@ module.exports = class HUDView extends View
updatePropElement: (prop, val) ->
pel = @$el.find '.thang-props *[name=' + prop + ']'
if prop in ["maxHealth"]
return # Don't show maxes--they're built into bar labels.
if prop in ["health"]
max = @thang["max" + prop.charAt(0).toUpperCase() + prop.slice(1)]
regen = @thang[prop + "ReplenishRate"]
@ -256,13 +263,15 @@ module.exports = class HUDView extends View
labelText = prop + ": " + @formatValue(prop, val) + " / " + @formatValue(prop, max)
if regen
labelText += " (+" + @formatValue(prop, regen) + "/s)"
pel.attr 'title', labelText
else if prop in ["maxHealth"]
return
else
s = @formatValue(prop, val)
labelText = "#{prop}: #{s}"
if prop is 'attackDamage'
cooldown = @thang.actions.attack.cooldown
dps = @thang.attackDamage / cooldown
labelText += " / #{cooldown.toFixed(2)}s (DPS: #{dps.toFixed(2)})"
pel.find('.prop-value').text s
pel.attr 'title', "#{prop}: #{s}"
pel.attr 'title', labelText
pel
formatValue: (prop, val) ->
@ -271,6 +280,8 @@ module.exports = class HUDView extends View
val = null if val?.isZero()
if prop is "rotation"
return (val * 180 / Math.PI).toFixed(0) + "˚"
if prop.search(/Range$/) isnt -1
return val + 'm'
if typeof val is 'number'
if Math.round(val) == val or prop is 'gold' then return val.toFixed(0) # int
if -10 < val < 10 then return val.toFixed(2)

View file

@ -53,6 +53,7 @@ module.exports = class SpellPaletteView extends View
more: 'moreProgrammableProperties'
Math: 'programmableMathProperties'
Array: 'programmableArrayProperties'
Object: 'programmableObjectProperties'
String: 'programmableStringProperties'
Vector: 'programmableVectorProperties'
snippets: 'programmableSnippets'