Removed unneede catiline lib. Trying speedups for updating HUD property values and Lank Thang inventory.

This commit is contained in:
Nick Winter 2014-11-29 13:09:38 -08:00
parent 17f2d76512
commit 155ead86cf
4 changed files with 15 additions and 5 deletions

View file

@ -130,3 +130,13 @@ module.exports.kindaEqual = compare = (l, r) ->
return true return true
else else
return false return false
# Fast, basic way to replace text in an element when you don't need much.
# http://stackoverflow.com/a/4962398/540620
if document?
dummy = document.createElement 'div'
dummy.innerHTML = 'text'
TEXT = if dummy.textContent is 'text' then 'textContent' else 'innerText'
module.exports.replaceText = (elems, text) ->
elem[TEXT] = text for elem in elems
null

View file

@ -192,7 +192,7 @@ module.exports = class LankBoss extends CocoClass
updatedObstacles = [] updatedObstacles = []
itemsJustEquipped = [] itemsJustEquipped = []
for thang in @world.thangs when thang.exists and thang.pos for thang in @world.thangs when thang.exists and thang.pos
itemsJustEquipped = itemsJustEquipped.concat @equipNewItems thang itemsJustEquipped = itemsJustEquipped.concat @equipNewItems thang if thang.equip
if lank = @lanks[thang.id] if lank = @lanks[thang.id]
lank.setThang thang # make sure Lank has latest Thang lank.setThang thang # make sure Lank has latest Thang
else else

View file

@ -2,6 +2,7 @@ CocoView = require 'views/core/CocoView'
template = require 'templates/play/level/hud' template = require 'templates/play/level/hud'
prop_template = require 'templates/play/level/hud_prop' prop_template = require 'templates/play/level/hud_prop'
LevelOptions = require 'lib/LevelOptions' LevelOptions = require 'lib/LevelOptions'
utils = require 'core/utils'
module.exports = class LevelHUDView extends CocoView module.exports = class LevelHUDView extends CocoView
id: 'thang-hud' id: 'thang-hud'
@ -104,7 +105,7 @@ module.exports = class LevelHUDView extends CocoView
name = {knight: 'Tharin', captain: 'Anya', librarian: 'Hushbaum', sorcerer: 'Pender', 'potion-master': 'Omarn', samurai: 'Hattori', ninja: 'Amara'}[@thang.type] ? 'Hero' name = {knight: 'Tharin', captain: 'Anya', librarian: 'Hushbaum', sorcerer: 'Pender', 'potion-master': 'Omarn', samurai: 'Hattori', ninja: 'Amara'}[@thang.type] ? 'Hero'
else else
name = if @thang.type then "#{@thang.id} - #{@thang.type}" else @thang.id name = if @thang.type then "#{@thang.id} - #{@thang.type}" else @thang.id
@$el.find('.thang-name').text name utils.replaceText @$el.find('.thang-name'), name
props = @$el.find('.thang-props') props = @$el.find('.thang-props')
props.find('.prop').remove() props.find('.prop').remove()
#propNames = _.without @thang.hudProperties ? [], 'action' #propNames = _.without @thang.hudProperties ? [], 'action'
@ -145,7 +146,7 @@ module.exports = class LevelHUDView extends CocoView
labelText = prop + ': ' + @formatValue(prop, val) + ' / ' + @formatValue(prop, max) labelText = prop + ': ' + @formatValue(prop, val) + ' / ' + @formatValue(prop, max)
if regen if regen
labelText += ' (+' + @formatValue(prop, regen) + '/s)' labelText += ' (+' + @formatValue(prop, regen) + '/s)'
pel.find('.bar-prop-value').text(Math.round(max)) if max utils.replaceText pel.find('.bar-prop-value'), Math.round(val)
else else
s = @formatValue(prop, val) s = @formatValue(prop, val)
labelText = "#{prop}: #{s}" labelText = "#{prop}: #{s}"
@ -153,7 +154,7 @@ module.exports = class LevelHUDView extends CocoView
cooldown = @thang.actions.attack.cooldown cooldown = @thang.actions.attack.cooldown
dps = @thang.attackDamage / cooldown dps = @thang.attackDamage / cooldown
labelText += " / #{cooldown.toFixed(2)}s (DPS: #{dps.toFixed(2)})" labelText += " / #{cooldown.toFixed(2)}s (DPS: #{dps.toFixed(2)})"
pel.find('.prop-value').text s utils.replaceText pel.find('.prop-value'), s
pel.attr 'title', labelText pel.attr 'title', labelText
pel pel

View file

@ -35,7 +35,6 @@
"aether": "~0.2.39", "aether": "~0.2.39",
"underscore.string": "~2.3.3", "underscore.string": "~2.3.3",
"firebase": "~1.0.2", "firebase": "~1.0.2",
"catiline": "~2.9.3",
"d3": "~3.4.4", "d3": "~3.4.4",
"jsondiffpatch": "0.1.8", "jsondiffpatch": "0.1.8",
"nanoscroller": "~0.8.0", "nanoscroller": "~0.8.0",