Added filters to the extant thangs column.

This commit is contained in:
Scott Erickson 2014-01-21 10:42:09 -08:00
parent c771936f45
commit 01a43bb3d7
3 changed files with 62 additions and 2 deletions
app
styles/editor/level
templates/editor/level
views/editor/level

View file

@ -22,11 +22,41 @@
#thangs-treema
position: absolute
top: 40px
top: 80px
left: 0
right: 0
bottom: 0
overflow: scroll
&.hide-except-Unit
.treema-node
display: none
.treema-node.treema-Unit
display: block
&.hide-except-Doodad
.treema-node
display: none
.treema-node.treema-Doodad
display: block
&.hide-except-Floor
.treema-node
display: none
.treema-node.treema-Floor
display: block
&.hide-except-Wall
.treema-node
display: none
.treema-node.treema-Wall
display: block
&.hide-except-Misc
.treema-node
display: none
.treema-node.treema-Misc
display: block
.treema-children .treema-row *
cursor: pointer !important

View file

@ -1,5 +1,17 @@
.thangs-container.thangs-column
h3(data-i18n="editor.level_tab_thangs_title") Current Thangs
.btn-group(data-toggle="buttons-radio")#extant-thangs-filter
button.btn.btn-primary All
button.btn.btn-primary(value="Unit")
i.icon-user
button.btn.btn-primary(value="Wall")
i.icon-home
button.btn.btn-primary(value="Floor")
i.icon-globe
button.btn.btn-primary(value="Doodad")
i.icon-leaf
button.btn.btn-primary(value="Misc")
i.icon-question-sign
#thangs-treema(title="Double click to configure a thang")
.world-container.thangs-column

View file

@ -43,10 +43,21 @@ module.exports = class ThangsTabView extends View
'sprite:mouse-up': 'onSpriteMouseUp'
'sprite:double-clicked': 'onSpriteDoubleClicked'
'surface:stage-mouse-down': 'onStageMouseDown'
events:
'click #extant-thangs-filter button': 'onFilterExtantThangs'
shortcuts:
'esc': -> @selectAddThang()
onFilterExtantThangs: (e) ->
button = $(e.target).closest('button')
button.button('toggle')
val = button.val()
@thangsTreema.$el.removeClass(@lastHideClass) if @lastHideClass
@thangsTreema.$el.addClass(@lastHideClass = "hide-except-#{val}") if val
constructor: (options) ->
super options
@world = options.world
@ -88,6 +99,9 @@ module.exports = class ThangsTabView extends View
super()
$('.tab-content').click @selectAddThang
$('#thangs-list').bind 'mousewheel', @preventBodyScrollingInThangList
@$el.find('#extant-thangs-filter button:first').button('toggle')
# TODO: move these into the shortcuts list
key 'left', _.bind @moveAddThangSelection, @, -1
key 'right', _.bind @moveAddThangSelection, @, 1
key 'delete, del, backspace', @deleteSelectedExtantThang
@ -375,6 +389,7 @@ class ThangNode extends TreemaObjectNode
valueClass: 'treema-thang'
collection: false
@thangNameMap: {}
@thangKindMap: {}
buildValueForDisplay: (valEl) ->
pos = _.find(@data.components, (c) -> c.config?.pos?)?.config.pos # TODO: hack
s = "#{@data.thangType}"
@ -382,6 +397,9 @@ class ThangNode extends TreemaObjectNode
unless name = ThangNode.thangNameMap[s]
thangType = _.find @settings.supermodel.getModels(ThangType), (m) -> m.get('original') is s
name = ThangNode.thangNameMap[s] = thangType.get 'name'
ThangNode.thangKindMap[s] = thangType.get 'kind'
kind = ThangNode.thangKindMap[s]
@$el.addClass "treema-#{kind}"
s = name
s += " - " + @data.id if @data.id isnt s
if pos