From 9439f0d47d330a99fe8ceb158a7d0e7b78eb657f Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Wed, 3 Sep 2014 15:38:34 -0700 Subject: [PATCH] Some tweaks and fixes to the folderized thangs in the level editor. --- app/styles/editor/level/thangs-tab-view.sass | 9 +++++- .../editor/level/thangs/ThangsTabView.coffee | 31 +++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/app/styles/editor/level/thangs-tab-view.sass b/app/styles/editor/level/thangs-tab-view.sass index ad8f66681..e2dd18cb7 100644 --- a/app/styles/editor/level/thangs-tab-view.sass +++ b/app/styles/editor/level/thangs-tab-view.sass @@ -60,7 +60,14 @@ .treema-children .treema-row * cursor: pointer !important - + + img + float: left + width: 18px + margin-right: 5px + position: relative + top: 2px + .world-container margin-left: 0 margin-right: 0 diff --git a/app/views/editor/level/thangs/ThangsTabView.coffee b/app/views/editor/level/thangs/ThangsTabView.coffee index ce6cd9124..b480adb75 100644 --- a/app/views/editor/level/thangs/ThangsTabView.coffee +++ b/app/views/editor/level/thangs/ThangsTabView.coffee @@ -138,7 +138,7 @@ module.exports = class ThangsTabView extends CocoView { type: 'object' format: 'thang' - required: ['thangType', 'id', 'index'] + required: ['thangType', 'id'] } { $ref: '#' } ] @@ -432,7 +432,7 @@ module.exports = class ThangsTabView extends CocoView folderForThang: (thang) -> thangType = @supermodel.getModelByOriginal ThangType, thang.thangType - [thangType.get('kind')] + [thangType.get('kind'), thangType.get('name')] pathForThang: (thang) -> folder = @folderForThang(thang) @@ -572,6 +572,7 @@ module.exports = class ThangsTabView extends CocoView class ThangsFolderNode extends TreemaNode.nodeMap.object valueClass: 'treema-thangs-folder' nodeDescription: 'Thang' + @nameToThangTypeMap: null getTrackedActionDescription: (trackedAction) -> trackedActionDescription = super(trackedAction) @@ -582,7 +583,31 @@ class ThangsFolderNode extends TreemaNode.nodeMap.object trackedActionDescription buildValueForDisplay: (valEl, data) -> - @buildValueForDisplaySimply valEl, _.keys(data).length + @buildValueForDisplaySimply valEl, @countThangs(data) + + countThangs: (data) -> + return 0 if data.thangType and data.id + num = 0 + for key, value of data + if value.thangType and value.id + num += 1 + else + num += @countThangs(value) + num + + build: -> + res = super(arguments...) + if thangType = @nameToThangType(@keyForParent) + @$el.prepend($("")) + res + + nameToThangType: (name) -> + if not ThangsFolderNode.nameToThangTypeMap + thangTypes = @settings.supermodel.getModels(ThangType) + map = {} + map[thangType.get('name')] = thangType for thangType in thangTypes + ThangsFolderNode.nameToThangTypeMap = map + ThangsFolderNode.nameToThangTypeMap[name] class ThangNode extends TreemaObjectNode valueClass: 'treema-thang'