mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Spell list updates based on the existence of thangs now.
This commit is contained in:
parent
597ace25cc
commit
663a09ed4b
3 changed files with 12 additions and 4 deletions
|
@ -31,7 +31,7 @@ module.exports = class SpellListEntryView extends View
|
||||||
context = super context
|
context = super context
|
||||||
context.spell = @spell
|
context.spell = @spell
|
||||||
context.parameters = (@spell.parameters or []).join ', '
|
context.parameters = (@spell.parameters or []).join ', '
|
||||||
context.thangNames = (thangID for thangID of @spell.thangs).join(', ') # + ", Marcus, Robert, Phoebe, Will Smith, Zap Brannigan, You, Gandaaaaalf"
|
context.thangNames = (thangID for thangID, spellThang of @spell.thangs when spellThang.thang.exists).join(', ') # + ", Marcus, Robert, Phoebe, Will Smith, Zap Brannigan, You, Gandaaaaalf"
|
||||||
context.showTopDivider = @showTopDivider
|
context.showTopDivider = @showTopDivider
|
||||||
context
|
context
|
||||||
|
|
||||||
|
@ -40,12 +40,14 @@ module.exports = class SpellListEntryView extends View
|
||||||
spellThang = _.find @spell.thangs, (spellThang) => spellThang.thang.id is @lastSelectedThang.id
|
spellThang = _.find @spell.thangs, (spellThang) => spellThang.thang.id is @lastSelectedThang.id
|
||||||
return spellThang if spellThang
|
return spellThang if spellThang
|
||||||
for thangID, spellThang of @spell.thangs
|
for thangID, spellThang of @spell.thangs
|
||||||
|
continue unless spellThang.thang.exists
|
||||||
return spellThang # Just do the first one else
|
return spellThang # Just do the first one else
|
||||||
|
|
||||||
afterRender: ->
|
afterRender: ->
|
||||||
super()
|
super()
|
||||||
return unless @options.showTopDivider # Don't repeat Thang avatars when not changed from previous entry
|
return unless @options.showTopDivider # Don't repeat Thang avatars when not changed from previous entry
|
||||||
return unless spellThang = @getPrimarySpellThang()
|
return @$el.hide() unless spellThang = @getPrimarySpellThang()
|
||||||
|
@$el.show()
|
||||||
@avatar?.destroy()
|
@avatar?.destroy()
|
||||||
@avatar = new ThangAvatarView thang: spellThang.thang, includeName: false, supermodel: @supermodel
|
@avatar = new ThangAvatarView thang: spellThang.thang, includeName: false, supermodel: @supermodel
|
||||||
@$el.prepend @avatar.el # Before rendering, so render can use parent for popover
|
@$el.prepend @avatar.el # Before rendering, so render can use parent for popover
|
||||||
|
@ -71,7 +73,9 @@ module.exports = class SpellListEntryView extends View
|
||||||
showThangs: ->
|
showThangs: ->
|
||||||
clearTimeout @hideThangsTimeout if @hideThangsTimeout
|
clearTimeout @hideThangsTimeout if @hideThangsTimeout
|
||||||
return if @thangsView
|
return if @thangsView
|
||||||
@thangsView = new SpellListEntryThangsView thangs: (spellThang.thang for thangID, spellThang of @spell.thangs), thang: @getPrimarySpellThang().thang, spell: @spell, supermodel: @supermodel
|
spellThang = @getPrimarySpellThang()
|
||||||
|
return unless spellThang
|
||||||
|
@thangsView = new SpellListEntryThangsView thangs: (spellThang.thang for thangID, spellThang of @spell.thangs), thang: spellTHang.thang, spell: @spell, supermodel: @supermodel
|
||||||
@thangsView.render()
|
@thangsView.render()
|
||||||
@$el.append @thangsView.el
|
@$el.append @thangsView.el
|
||||||
@thangsView.$el.mouseenter (e) => @onMouseEnterAvatar()
|
@thangsView.$el.mouseenter (e) => @onMouseEnterAvatar()
|
||||||
|
|
|
@ -66,6 +66,9 @@ module.exports = class SpellListView extends View
|
||||||
for entry in newEntries
|
for entry in newEntries
|
||||||
@$el.append entry.el
|
@$el.append entry.el
|
||||||
entry.render() # Render after appending so that we can access parent container for popover
|
entry.render() # Render after appending so that we can access parent container for popover
|
||||||
|
|
||||||
|
rerenderEntries: ->
|
||||||
|
entry.render() for entry in @entries
|
||||||
|
|
||||||
onNewWorld: (e) ->
|
onNewWorld: (e) ->
|
||||||
@thang = e.world.thangMap[@thang.id] if @thang
|
@thang = e.world.thangMap[@thang.id] if @thang
|
||||||
|
|
|
@ -134,6 +134,7 @@ module.exports = class TomeView extends View
|
||||||
Backbone.Mediator.publish 'tome:cast-spells', spells: @spells
|
Backbone.Mediator.publish 'tome:cast-spells', spells: @spells
|
||||||
|
|
||||||
onToggleSpellList: (e) ->
|
onToggleSpellList: (e) ->
|
||||||
|
@spellList.rerenderEntries()
|
||||||
@spellList.$el.toggle()
|
@spellList.$el.toggle()
|
||||||
|
|
||||||
onSpellViewClick: (e) ->
|
onSpellViewClick: (e) ->
|
||||||
|
|
Loading…
Reference in a new issue