From 598e727500845f5b2fa83617e3e0eaf99ab3c4d7 Mon Sep 17 00:00:00 2001 From: Jayant Jain Date: Sun, 20 Jul 2014 22:34:21 +0530 Subject: [PATCH 01/11] Adds an initial dungeon preset, refactors border code to properly create dungeon walls --- .../editor/level/modal/terrain_randomize.jade | 2 +- .../level/modals/TerrainRandomizeModal.coffee | 48 ++++++++++++------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/app/templates/editor/level/modal/terrain_randomize.jade b/app/templates/editor/level/modal/terrain_randomize.jade index b80f80562..a4e45b2f2 100644 --- a/app/templates/editor/level/modal/terrain_randomize.jade +++ b/app/templates/editor/level/modal/terrain_randomize.jade @@ -12,5 +12,5 @@ block modal-body-content div.preset-size.name-label.capitalize span(data-i18n="editor."+size) #{size} div.preset-name.capitalize - span(data-i18n="editor.grassy") #{preset.type} + span(data-i18n="editor."+preset.type) #{preset.type} block modal-footer diff --git a/app/views/editor/level/modals/TerrainRandomizeModal.coffee b/app/views/editor/level/modals/TerrainRandomizeModal.coffee index 9a78f42f7..228378e47 100644 --- a/app/views/editor/level/modals/TerrainRandomizeModal.coffee +++ b/app/views/editor/level/modals/TerrainRandomizeModal.coffee @@ -10,18 +10,34 @@ clusters = { 'animals': ['Cow', 'Horse'] 'wood': ['Firewood 1', 'Firewood 2', 'Firewood 3', 'Barrel'] 'farm': ['Farm'] + 'cave': ['Cave'] + 'stone': ['Gargoyle', 'Rock Cluster 1', 'Rock Cluster 2', 'Rock Cluster 3'] } presets = { - # 'dungeon': { - # 'type':'dungeon' - # 'borders':['Dungeon Wall'] - # 'floors':['Dungeon Floor'] - # 'decorations':[] - # } + 'dungeon': { + 'type':'dungeon' + 'borders':['Dungeon Wall'] + 'borderNoise':0 + 'borderSize':4 + 'floors':['Dungeon Floor'] + 'decorations': { + 'cave': { + 'num':[1,1] + 'width': 20 + 'height': 20 + 'clusters': { + 'cave':[1,1] + 'stone':[2,4] + } + } + } + } 'grassy': { 'type':'grassy' 'borders':['Tree 1', 'Tree 2', 'Tree 3'] + 'borderNoise':1 + 'borderSize':0 'floors':['Grass01', 'Grass02', 'Grass03', 'Grass04', 'Grass05'] 'decorations': { 'house': { @@ -102,7 +118,7 @@ module.exports = class TerrainRandomizeModal extends ModalView presetSize = presetSizes[presetSize] @thangs = [] @randomizeFloor preset, presetSize - @randomizeBorder preset, presetSize + @randomizeBorder preset, presetSize, preset.borderNoise @randomizeDecorations preset, presetSize randomizeFloor: (preset, presetSize) -> @@ -116,21 +132,21 @@ module.exports = class TerrainRandomizeModal extends ModalView } } - randomizeBorder: (preset, presetSize) -> + randomizeBorder: (preset, presetSize, noiseFactor=1) -> for i in _.range(0, presetSize.x, thangSizes.borderSize.x) for j in _.range(thangSizes.borderSize.thickness) @thangs.push { 'id': @getRandomThang(preset.borders) 'pos': { - 'x': i + _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x/2) - 'y': 0 + _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y) + 'x': i + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x/2) + 'y': 0 + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y) } } @thangs.push { 'id': @getRandomThang(preset.borders) 'pos': { - 'x': i + _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x/2) - 'y': presetSize.y + _.random(-thangSizes.borderSize.y, thangSizes.borderSize.y/2) + 'x': i + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x/2) + 'y': presetSize.y - preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.y, thangSizes.borderSize.y/2) } } @@ -139,15 +155,15 @@ module.exports = class TerrainRandomizeModal extends ModalView @thangs.push { 'id': @getRandomThang(preset.borders) 'pos': { - 'x': 0 + _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x) - 'y': i + _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y/2) + 'x': 0 + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x) + 'y': i + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y/2) } } @thangs.push { 'id': @getRandomThang(preset.borders) 'pos': { - 'x': presetSize.x + _.random(-thangSizes.borderSize.x, thangSizes.borderSize.x/2) - 'y': i + _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y/2) + 'x': presetSize.x - preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.x, thangSizes.borderSize.x/2) + 'y': i + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y/2) } } From dce6254d4ad9b46f66b9fe7a63a11a9f2be8cacb Mon Sep 17 00:00:00 2001 From: Jayant Jain Date: Mon, 21 Jul 2014 00:40:35 +0530 Subject: [PATCH 02/11] Fix for flickering thangs due to exact same coordinates --- .../level/modals/TerrainRandomizeModal.coffee | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/app/views/editor/level/modals/TerrainRandomizeModal.coffee b/app/views/editor/level/modals/TerrainRandomizeModal.coffee index 228378e47..64aeb8ae5 100644 --- a/app/views/editor/level/modals/TerrainRandomizeModal.coffee +++ b/app/views/editor/level/modals/TerrainRandomizeModal.coffee @@ -135,66 +135,73 @@ module.exports = class TerrainRandomizeModal extends ModalView randomizeBorder: (preset, presetSize, noiseFactor=1) -> for i in _.range(0, presetSize.x, thangSizes.borderSize.x) for j in _.range(thangSizes.borderSize.thickness) - @thangs.push { + while not @addThang { 'id': @getRandomThang(preset.borders) 'pos': { 'x': i + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x/2) 'y': 0 + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y) } } - @thangs.push { + continue + while not @addThang { 'id': @getRandomThang(preset.borders) 'pos': { 'x': i + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x/2) 'y': presetSize.y - preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.y, thangSizes.borderSize.y/2) } } + continue for i in _.range(0, presetSize.y, thangSizes.borderSize.y) for j in _.range(3) - @thangs.push { + while not @addThang { 'id': @getRandomThang(preset.borders) 'pos': { 'x': 0 + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x) 'y': i + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y/2) } } - @thangs.push { + continue + while not @addThang { 'id': @getRandomThang(preset.borders) 'pos': { 'x': presetSize.x - preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.x, thangSizes.borderSize.x/2) 'y': i + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y/2) } } + continue randomizeDecorations: (preset, presetSize)-> for name, decoration of preset.decorations for num in _.range(_.random(decoration.num[0], decoration.num[1])) - center = - { + center = { 'x':_.random(decoration.width, presetSize.x - decoration.width), 'y':_.random(decoration.height, presetSize.y - decoration.height) } - min = - { + min = { 'x':center.x - decoration.width/2 'y':center.y - decoration.height/2 } - max = - { + max = { 'x':center.x + decoration.width/2 'y':center.y + decoration.height/2 } for cluster, range of decoration.clusters for i in _.range(_.random(range[0], range[1])) - @thangs.push { + while not @addThang { 'id':@getRandomThang(clusters[cluster]) 'pos':{ 'x':_.random(min.x, max.x) 'y':_.random(min.y, max.y) } } + continue + addThang: (thang) -> + for existingThang in @thangs + return false if thang.pos.x is existingThang.pos.x and thang.pos.y is existingThang.pos.y + @thangs.push thang + true getRandomThang: (thangList) -> return thangList[_.random(0, thangList.length-1)] From 3df2de8bec24be2034a64e36e6b76ab39d3c8c58 Mon Sep 17 00:00:00 2001 From: Jayant Jain Date: Mon, 21 Jul 2014 00:48:28 +0530 Subject: [PATCH 03/11] Number of decorations scales appropriately with preset size --- app/views/editor/level/modals/TerrainRandomizeModal.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/editor/level/modals/TerrainRandomizeModal.coffee b/app/views/editor/level/modals/TerrainRandomizeModal.coffee index 64aeb8ae5..6ca04261f 100644 --- a/app/views/editor/level/modals/TerrainRandomizeModal.coffee +++ b/app/views/editor/level/modals/TerrainRandomizeModal.coffee @@ -172,8 +172,9 @@ module.exports = class TerrainRandomizeModal extends ModalView continue randomizeDecorations: (preset, presetSize)-> + if presetSize is presetSizes['small'] then sizeFactor = 1 else sizeFactor = 2 for name, decoration of preset.decorations - for num in _.range(_.random(decoration.num[0], decoration.num[1])) + for num in _.range(sizeFactor * _.random(decoration.num[0], decoration.num[1])) center = { 'x':_.random(decoration.width, presetSize.x - decoration.width), 'y':_.random(decoration.height, presetSize.y - decoration.height) From 9a24341fa5b158aac641d5dd557634c9830705f7 Mon Sep 17 00:00:00 2001 From: Jayant Jain Date: Mon, 21 Jul 2014 19:25:35 +0530 Subject: [PATCH 04/11] Prevents overlapping of randomly generated thangs --- .../level/modals/TerrainRandomizeModal.coffee | 119 ++++++++++++------ 1 file changed, 80 insertions(+), 39 deletions(-) diff --git a/app/views/editor/level/modals/TerrainRandomizeModal.coffee b/app/views/editor/level/modals/TerrainRandomizeModal.coffee index 6ca04261f..4a66596f4 100644 --- a/app/views/editor/level/modals/TerrainRandomizeModal.coffee +++ b/app/views/editor/level/modals/TerrainRandomizeModal.coffee @@ -3,24 +3,63 @@ template = require 'templates/editor/level/modal/terrain_randomize' CocoModel = require 'models/CocoModel' clusters = { - 'rocks': ['Rock 1', 'Rock 2', 'Rock 3', 'Rock 4', 'Rock 5', 'Rock Cluster 1', 'Rock Cluster 2', 'Rock Cluster 3'] - 'trees': ['Tree 1', 'Tree 2', 'Tree 3', 'Tree 4'] - 'shrubs': ['Shrub 1', 'Shrub 2', 'Shrub 3'] - 'houses': ['House 1', 'House 2', 'House 3', 'House 4'] - 'animals': ['Cow', 'Horse'] - 'wood': ['Firewood 1', 'Firewood 2', 'Firewood 3', 'Barrel'] - 'farm': ['Farm'] - 'cave': ['Cave'] - 'stone': ['Gargoyle', 'Rock Cluster 1', 'Rock Cluster 2', 'Rock Cluster 3'] + 'rocks': { + 'thangs': ['Rock 1', 'Rock 2', 'Rock 3', 'Rock 4', 'Rock 5', 'Rock Cluster 1', 'Rock Cluster 2', 'Rock Cluster 3'] + 'margin': 1 + } + 'trees': { + 'thangs': ['Tree 1', 'Tree 2', 'Tree 3', 'Tree 4'] + 'margin': 0 + } + 'shrubs': { + 'thangs': ['Shrub 1', 'Shrub 2', 'Shrub 3'] + 'margin': 0 + } + 'houses': { + 'thangs': ['House 1', 'House 2', 'House 3', 'House 4'] + 'margin': 4 + } + 'animals': { + 'thangs': ['Cow', 'Horse'] + 'margin': 1 + } + 'wood': { + 'thangs': ['Firewood 1', 'Firewood 2', 'Firewood 3', 'Barrel'] + 'margin': 1 + } + 'farm': { + 'thangs': ['Farm'] + 'margin': 9 + } + 'cave': { + 'thangs': ['Cave'] + 'margin': 5 + } + 'stone': { + 'thangs': ['Gargoyle', 'Rock Cluster 1', 'Rock Cluster 2', 'Rock Cluster 3'] + 'margin': 1 + } + 'grass_floor': { + 'thangs': ['Grass01', 'Grass02', 'Grass03', 'Grass04', 'Grass05'] + 'margin': -1 + } + 'dungeon_wall': { + 'thangs': ['Dungeon Wall'] + 'margin': 0 + } + 'dungeon_floor': { + 'thangs': ['Dungeon Floor'] + 'margin': -1 + } } presets = { 'dungeon': { 'type':'dungeon' - 'borders':['Dungeon Wall'] + 'borders':'dungeon_wall' 'borderNoise':0 'borderSize':4 - 'floors':['Dungeon Floor'] + 'floors':'dungeon_floor' 'decorations': { 'cave': { 'num':[1,1] @@ -35,15 +74,15 @@ presets = { } 'grassy': { 'type':'grassy' - 'borders':['Tree 1', 'Tree 2', 'Tree 3'] + 'borders':'trees' 'borderNoise':1 'borderSize':0 - 'floors':['Grass01', 'Grass02', 'Grass03', 'Grass04', 'Grass05'] + 'floors':'grass_floor' 'decorations': { 'house': { 'num':[1,2] #min-max - 'width': 20 - 'height': 20 + 'width': 15 + 'height': 15 'clusters': { 'houses':[1,1] 'trees':[1,2] @@ -52,9 +91,9 @@ presets = { } } 'farm': { - 'num':[1,2] #min-max - 'width': 20 - 'height': 20 + 'num':[1,1] #min-max + 'width': 25 + 'height': 15 'clusters': { 'farm':[1,1] 'shrubs':[2,3] @@ -93,7 +132,6 @@ module.exports = class TerrainRandomizeModal extends ModalView id: 'terrain-randomize-modal' template: template thangs = [] - events: 'click .choose-option': 'onRandomize' @@ -125,49 +163,54 @@ module.exports = class TerrainRandomizeModal extends ModalView for i in _.range(0, presetSize.x, thangSizes.floorSize.x) for j in _.range(0, presetSize.y, thangSizes.floorSize.y) @thangs.push { - 'id': @getRandomThang(preset.floors) + 'id': @getRandomThang(clusters[preset.floors].thangs) 'pos': { 'x': i + thangSizes.floorSize.x/2 'y': j + thangSizes.floorSize.y/2 } + 'margin': clusters[preset.floors].margin } randomizeBorder: (preset, presetSize, noiseFactor=1) -> for i in _.range(0, presetSize.x, thangSizes.borderSize.x) for j in _.range(thangSizes.borderSize.thickness) while not @addThang { - 'id': @getRandomThang(preset.borders) + 'id': @getRandomThang(clusters[preset.borders].thangs) 'pos': { 'x': i + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x/2) 'y': 0 + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y) } + 'margin': clusters[preset.borders].margin } continue while not @addThang { - 'id': @getRandomThang(preset.borders) + 'id': @getRandomThang(clusters[preset.borders].thangs) 'pos': { 'x': i + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x/2) 'y': presetSize.y - preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.y, thangSizes.borderSize.y/2) } + 'margin': clusters[preset.borders].margin } continue for i in _.range(0, presetSize.y, thangSizes.borderSize.y) for j in _.range(3) while not @addThang { - 'id': @getRandomThang(preset.borders) + 'id': @getRandomThang(clusters[preset.borders].thangs) 'pos': { 'x': 0 + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x) 'y': i + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y/2) } + 'margin': clusters[preset.borders].margin } continue while not @addThang { - 'id': @getRandomThang(preset.borders) + 'id': @getRandomThang(clusters[preset.borders].thangs) 'pos': { 'x': presetSize.x - preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.x, thangSizes.borderSize.x/2) 'y': i + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y/2) } + 'margin': clusters[preset.borders].margin } continue @@ -175,32 +218,30 @@ module.exports = class TerrainRandomizeModal extends ModalView if presetSize is presetSizes['small'] then sizeFactor = 1 else sizeFactor = 2 for name, decoration of preset.decorations for num in _.range(sizeFactor * _.random(decoration.num[0], decoration.num[1])) - center = { - 'x':_.random(decoration.width, presetSize.x - decoration.width), - 'y':_.random(decoration.height, presetSize.y - decoration.height) - } - min = { - 'x':center.x - decoration.width/2 - 'y':center.y - decoration.height/2 - } - max = { - 'x':center.x + decoration.width/2 - 'y':center.y + decoration.height/2 + rect = { + 'x':_.random(decoration.width/2 + preset.borderSize/2 + thangSizes.borderSize.x, presetSize.x - decoration.width/2 - preset.borderSize/2 - thangSizes.borderSize.x), + 'y':_.random(decoration.height/2 + preset.borderSize/2 + thangSizes.borderSize.y, presetSize.y - decoration.height/2 - preset.borderSize/2 - thangSizes.borderSize.y) + 'width':decoration.width + 'height':decoration.height } for cluster, range of decoration.clusters for i in _.range(_.random(range[0], range[1])) while not @addThang { - 'id':@getRandomThang(clusters[cluster]) + 'id':@getRandomThang(clusters[cluster].thangs) 'pos':{ - 'x':_.random(min.x, max.x) - 'y':_.random(min.y, max.y) + 'x':_.random(rect.x - rect.width/2, rect.x + rect.width/2) + 'y':_.random(rect.y - rect.height/2, rect.y + rect.height/2) } + 'margin':clusters[cluster].margin } continue addThang: (thang) -> for existingThang in @thangs - return false if thang.pos.x is existingThang.pos.x and thang.pos.y is existingThang.pos.y + if existingThang.margin is -1 or thang.margin is -1 + continue + if Math.abs(existingThang.pos.x - thang.pos.x) <= thang.margin + existingThang.margin and Math.abs(existingThang.pos.y - thang.pos.y) <= thang.margin + existingThang.margin + return false @thangs.push thang true From dc66218c006388cae37e9900b8b6dd957ec1480c Mon Sep 17 00:00:00 2001 From: Jayant Jain Date: Fri, 25 Jul 2014 01:06:41 +0530 Subject: [PATCH 05/11] Adds undo and redo buttons in editor topbar --- app/templates/editor/level/edit.jade | 6 +++++ .../component/ThangComponentConfigView.coffee | 6 +++++ .../component/ThangComponentEditView.coffee | 6 +++++ app/views/editor/level/LevelEditView.coffee | 24 +++++++++++++++---- .../level/scripts/ScriptsTabView.coffee | 6 +++++ .../level/settings/SettingsTabView.coffee | 6 +++++ .../level/systems/LevelSystemEditView.coffee | 6 +++++ .../level/systems/SystemsTabView.coffee | 7 ++++++ .../level/thangs/LevelThangEditView.coffee | 8 +++++++ .../editor/level/thangs/ThangsTabView.coffee | 12 +++++----- 10 files changed, 76 insertions(+), 11 deletions(-) diff --git a/app/templates/editor/level/edit.jade b/app/templates/editor/level/edit.jade index 924949af8..aaa9f6048 100644 --- a/app/templates/editor/level/edit.jade +++ b/app/templates/editor/level/edit.jade @@ -38,6 +38,12 @@ block header span.navbar-brand #{level.attributes.name} ul.nav.navbar-nav.navbar-right + li#undo-button(title="Undo (Ctrl+Z)") + a + span.glyphicon-floppy-disk.glyphicon + li#redo-button(title="Redo (Ctrl+Shift+Z)") + a + span.glyphicon-floppy-disk.glyphicon if authorized li#commit-level-start-button a diff --git a/app/views/editor/component/ThangComponentConfigView.coffee b/app/views/editor/component/ThangComponentConfigView.coffee index b14f4d211..8b544465e 100644 --- a/app/views/editor/component/ThangComponentConfigView.coffee +++ b/app/views/editor/component/ThangComponentConfigView.coffee @@ -69,4 +69,10 @@ module.exports = class ThangComponentConfigView extends CocoView @changed = true @callback?(@data()) + undo: -> + @editThangTreema.undo() + + redo: -> + @editThangTreema.redo() + data: -> @editThangTreema.data diff --git a/app/views/editor/component/ThangComponentEditView.coffee b/app/views/editor/component/ThangComponentEditView.coffee index 3a4434710..a6dfc516f 100644 --- a/app/views/editor/component/ThangComponentEditView.coffee +++ b/app/views/editor/component/ThangComponentEditView.coffee @@ -184,6 +184,12 @@ module.exports = class ThangComponentEditView extends CocoView reportChanges: -> @callback?($.extend(true, [], @extantComponentsTreema.data)) + undo: -> + if @configView is null or @configView?.editing is false then @extantComponentsTreema.undo() else @configView.undo() + + redo: -> + if @configView is null or @configView?.editing is false then @extantComponentsTreema.redo() else @configView.redo() + class ThangComponentsArrayNode extends TreemaArrayNode valueClass: 'treema-thang-components-array' editable: false diff --git a/app/views/editor/level/LevelEditView.coffee b/app/views/editor/level/LevelEditView.coffee index 60ca1c010..293581c48 100644 --- a/app/views/editor/level/LevelEditView.coffee +++ b/app/views/editor/level/LevelEditView.coffee @@ -29,6 +29,8 @@ module.exports = class LevelEditView extends RootView 'click #commit-level-start-button': 'startCommittingLevel' 'click #fork-level-start-button': 'startForkingLevel' 'click #level-history-button': 'showVersionHistory' + 'click #undo-button': 'onUndo' + 'click #redo-button': 'onRedo' 'click #patches-tab': -> @patchesView.load() 'click #components-tab': -> @componentsTab.refreshLevelThangsTreema @level.get('thangs') 'click #level-patch-button': 'startPatchingLevel' @@ -40,6 +42,7 @@ module.exports = class LevelEditView extends RootView super options @supermodel.shouldSaveBackups = (model) -> model.constructor.className in ['Level', 'LevelComponent', 'LevelSystem', 'ThangType'] + @subViews = {} @levelLoader = new LevelLoader supermodel: @supermodel, levelID: @levelID, headless: true, editorMode: true @level = @levelLoader.level @files = new DocumentFiles(@levelLoader.level) @@ -66,11 +69,11 @@ module.exports = class LevelEditView extends RootView return unless @supermodel.finished() @$el.find('a[data-toggle="tab"]').on 'shown.bs.tab', (e) => Backbone.Mediator.publish 'level:view-switched', e - @thangsTab = @insertSubView new ThangsTabView world: @world, supermodel: @supermodel, level: @level - @settingsTab = @insertSubView new SettingsTabView supermodel: @supermodel - @scriptsTab = @insertSubView new ScriptsTabView world: @world, supermodel: @supermodel, files: @files - @componentsTab = @insertSubView new ComponentsTabView supermodel: @supermodel - @systemsTab = @insertSubView new SystemsTabView supermodel: @supermodel + @subViews['thangsTab'] = @insertSubView new ThangsTabView world: @world, supermodel: @supermodel, level: @level + @subViews['settingsTab'] = @insertSubView new SettingsTabView supermodel: @supermodel + @subViews['scriptsTab'] = @insertSubView new ScriptsTabView world: @world, supermodel: @supermodel, files: @files + @subViews['componentsTab'] = @insertSubView new ComponentsTabView supermodel: @supermodel + @subViews['systemsTab'] = @insertSubView new SystemsTabView supermodel: @supermodel Backbone.Mediator.publish 'level-loaded', level: @level @showReadOnly() if me.get('anonymous') @patchesView = @insertSubView(new PatchesView(@level), @$el.find('.patches-view')) @@ -101,6 +104,17 @@ module.exports = class LevelEditView extends RootView @childWindow.onPlayLevelViewLoaded = (e) => sendLevel() # still a hack @childWindow.focus() + onUndo: -> + @getCurrentView()?.undo() + + onRedo: -> + @getCurrentView()?.redo() + + getCurrentView: -> + tabText = $('li.active')[0]?.textContent.toLowerCase() + currentView = @subViews[tabText + 'Tab' ] + currentView + startPatchingLevel: (e) -> @openModalView new SaveVersionModal({model: @level}) Backbone.Mediator.publish 'level:view-switched', e diff --git a/app/views/editor/level/scripts/ScriptsTabView.coffee b/app/views/editor/level/scripts/ScriptsTabView.coffee index d221876ee..10f4ee248 100644 --- a/app/views/editor/level/scripts/ScriptsTabView.coffee +++ b/app/views/editor/level/scripts/ScriptsTabView.coffee @@ -86,6 +86,12 @@ module.exports = class ScriptsTabView extends CocoView onScriptChanged: => @scriptsTreema.set(@selectedScriptPath, @scriptTreema.data) + undo: -> + @scriptsTreema.undo() if @scriptTreema.undo() is undefined + + redo: -> + @scriptsTreema.redo() if @scriptTreema.redo() is undefined + class ScriptNode extends TreemaObjectNode valueClass: 'treema-script' collection: false diff --git a/app/views/editor/level/settings/SettingsTabView.coffee b/app/views/editor/level/settings/SettingsTabView.coffee index ba436ef23..5133dd6ba 100644 --- a/app/views/editor/level/settings/SettingsTabView.coffee +++ b/app/views/editor/level/settings/SettingsTabView.coffee @@ -53,3 +53,9 @@ module.exports = class SettingsTabView extends CocoView for key in @editableSettings continue if @settingsTreema.data[key] is undefined @level.set key, @settingsTreema.data[key] + + undo: -> + @settingsTreema.undo() + + redo: -> + @settingsTreema.redo() diff --git a/app/views/editor/level/systems/LevelSystemEditView.coffee b/app/views/editor/level/systems/LevelSystemEditView.coffee index b1bcf8f67..a2a658b2a 100644 --- a/app/views/editor/level/systems/LevelSystemEditView.coffee +++ b/app/views/editor/level/systems/LevelSystemEditView.coffee @@ -115,6 +115,12 @@ module.exports = class LevelSystemEditView extends CocoView @levelSystem.watch(button.find('.watch').is(':visible')) button.find('> span').toggleClass('secret') + undo: -> + if @$el.find('#editor-level-system-edit-view li.active a#system-config-schema-tab') + @configSchemaTreema.undo() + if @$el.find('#editor-level-system-edit-view li.active a#system-settings-tab') + @systemSettingsTreema.undo() + destroy: -> @editor?.destroy() super() diff --git a/app/views/editor/level/systems/SystemsTabView.coffee b/app/views/editor/level/systems/SystemsTabView.coffee index 89fa16bf1..df5908aa7 100644 --- a/app/views/editor/level/systems/SystemsTabView.coffee +++ b/app/views/editor/level/systems/SystemsTabView.coffee @@ -125,6 +125,13 @@ module.exports = class SystemsTabView extends CocoView {original: '528114e60268d018e300001a', majorVersion: 0} # UI {original: '528114040268d018e3000011', majorVersion: 0} # Physics ] + undo: -> + return unless @levelSystemEditView + @levelSystemEditView.undo() + + redo: -> + return unless @levelSystemEditView + @levelSystemEditView.redo() class LevelSystemNode extends TreemaObjectNode valueClass: 'treema-level-system' diff --git a/app/views/editor/level/thangs/LevelThangEditView.coffee b/app/views/editor/level/thangs/LevelThangEditView.coffee index f5a2a4387..96e2c7e1a 100644 --- a/app/views/editor/level/thangs/LevelThangEditView.coffee +++ b/app/views/editor/level/thangs/LevelThangEditView.coffee @@ -92,3 +92,11 @@ module.exports = class LevelThangEditView extends CocoView onComponentsChanged: (components) => @thangData.components = components @saveThang() + + undo: -> + return unless @thangComponentEditView + @thangComponentEditView.undo() + + redo: -> + return unless @thangComponentEditView + @thangComponentEditView.redo() diff --git a/app/views/editor/level/thangs/ThangsTabView.coffee b/app/views/editor/level/thangs/ThangsTabView.coffee index 7861c2539..d03d888da 100644 --- a/app/views/editor/level/thangs/ThangsTabView.coffee +++ b/app/views/editor/level/thangs/ThangsTabView.coffee @@ -58,8 +58,8 @@ module.exports = class ThangsTabView extends CocoView 'delete, del, backspace': 'deleteSelectedExtantThang' 'left': -> @moveAddThangSelection -1 'right': -> @moveAddThangSelection 1 - 'ctrl+z': 'undoAction' - 'ctrl+shift+z': 'redoAction' + 'ctrl+z': 'undo' + 'ctrl+shift+z': 'redo' constructor: (options) -> super options @@ -473,11 +473,11 @@ module.exports = class ThangsTabView extends CocoView $('#add-thangs-column').toggle() @onWindowResize e - undoAction: (e) -> - @thangsTreema.undo() + undo: (e) -> + if not @editThangView then @thangsTreema.undo() else @editThangView.undo() - redoAction: (e) -> - @thangsTreema.redo() + redo: (e) -> + if not @editThangView then @thangsTreema.redo() else @editThangView.redo() class ThangsNode extends TreemaNode.nodeMap.array valueClass: 'treema-array-replacement' From 1790215feaed1b037925e66b81ffb56aedef5aa0 Mon Sep 17 00:00:00 2001 From: Jayant Jain Date: Fri, 25 Jul 2014 04:33:03 +0530 Subject: [PATCH 06/11] Adds rooms and doors to dungeon preset --- .../level/modals/TerrainRandomizeModal.coffee | 90 ++++++++++++++++++- 1 file changed, 87 insertions(+), 3 deletions(-) diff --git a/app/views/editor/level/modals/TerrainRandomizeModal.coffee b/app/views/editor/level/modals/TerrainRandomizeModal.coffee index 4a66596f4..2a23cb9dc 100644 --- a/app/views/editor/level/modals/TerrainRandomizeModal.coffee +++ b/app/views/editor/level/modals/TerrainRandomizeModal.coffee @@ -39,13 +39,17 @@ clusters = { 'thangs': ['Gargoyle', 'Rock Cluster 1', 'Rock Cluster 2', 'Rock Cluster 3'] 'margin': 1 } + 'doors': { + 'thangs': ['Dungeon Door'] + 'margin': -1 + } 'grass_floor': { 'thangs': ['Grass01', 'Grass02', 'Grass03', 'Grass04', 'Grass05'] 'margin': -1 } 'dungeon_wall': { 'thangs': ['Dungeon Wall'] - 'margin': 0 + 'margin': -1 } 'dungeon_floor': { 'thangs': ['Dungeon Floor'] @@ -63,13 +67,20 @@ presets = { 'decorations': { 'cave': { 'num':[1,1] - 'width': 20 - 'height': 20 + 'width': 10 + 'height': 10 'clusters': { 'cave':[1,1] 'stone':[2,4] } } + 'Room': { + 'num': [1,1] + 'width': [12, 20] + 'height': [8, 16] + 'thickness': [2,2] + 'cluster': 'dungeon_wall' + } } } 'grassy': { @@ -152,6 +163,7 @@ module.exports = class TerrainRandomizeModal extends ModalView @hide() randomizeThangs: (presetName, presetSize) -> + @falseCount = 0 preset = presets[presetName] presetSize = presetSizes[presetSize] @thangs = [] @@ -218,6 +230,9 @@ module.exports = class TerrainRandomizeModal extends ModalView if presetSize is presetSizes['small'] then sizeFactor = 1 else sizeFactor = 2 for name, decoration of preset.decorations for num in _.range(sizeFactor * _.random(decoration.num[0], decoration.num[1])) + if @['build'+name] isnt undefined + @['build'+name](preset, presetSize, decoration) + continue rect = { 'x':_.random(decoration.width/2 + preset.borderSize/2 + thangSizes.borderSize.x, presetSize.x - decoration.width/2 - preset.borderSize/2 - thangSizes.borderSize.x), 'y':_.random(decoration.height/2 + preset.borderSize/2 + thangSizes.borderSize.y, presetSize.y - decoration.height/2 - preset.borderSize/2 - thangSizes.borderSize.y) @@ -236,11 +251,80 @@ module.exports = class TerrainRandomizeModal extends ModalView } continue + buildRoom: (preset, presetSize, room) -> + if presetSize is presetSizes['small'] then sizeFactor = 1 else sizeFactor = 2 + rect = { + 'width':sizeFactor * (room.width[0] + preset.borderSize * _.random(0, (room.width[1] - room.width[0])/preset.borderSize)) + 'height':sizeFactor * (room.height[0] + preset.borderSize * _.random(0, (room.height[1] - room.height[0])/preset.borderSize)) + } + roomThickness = _.random(room.thickness[0], room.thickness[1]) + rect.x = _.random(rect.width/2 + preset.borderSize * (roomThickness+2), presetSize.x - rect.width/2 - preset.borderSize * (roomThickness+2)) + rect.y = _.random(rect.height/2 + preset.borderSize * (roomThickness+2), presetSize.y - rect.height/2 - preset.borderSize * (roomThickness+2)) + + xRange = _.range(rect.x - rect.width/2 + preset.borderSize, rect.x + rect.width/2, preset.borderSize) + topDoor = _.random(1) > 0.5 + topDoorX = xRange[_.random(0, xRange.length-1)] + bottomDoor = if not topDoor then true else _.random(1) > 0.5 + bottomDoorX = xRange[_.random(0, xRange.length-1)] + + for t in _.range(0, roomThickness+1) + for i in _.range(rect.x - rect.width/2 - (t-1) * preset.borderSize, rect.x + rect.width/2 + t * preset.borderSize, preset.borderSize) + thang = { + 'id': @getRandomThang(clusters[room.cluster].thangs) + 'pos': { + 'x': i + 'y': rect.y - rect.height/2 - t * preset.borderSize + } + 'margin': clusters[room.cluster].margin + } + if i is bottomDoorX and bottomDoor + thang.id = @getRandomThang(clusters['doors'].thangs) + thang.pos.y -= preset.borderSize/3 + @addThang thang unless i is bottomDoorX and t isnt roomThickness and bottomDoor + + thang = { + 'id': @getRandomThang(clusters[room.cluster].thangs) + 'pos': { + 'x': i + 'y': rect.y + rect.height/2 + t * preset.borderSize + } + 'margin': clusters[room.cluster].margin + } + if i is topDoorX and topDoor + thang.id = @getRandomThang(clusters['doors'].thangs) + thang.pos.y -= preset.borderSize + @addThang thang unless i is topDoorX and t isnt roomThickness and topDoor + + for t in _.range(0, roomThickness) + for i in _.range(rect.y - rect.height/2 - t * preset.borderSize, rect.y + rect.height/2 + (t+1) * preset.borderSize, preset.borderSize) + @addThang { + 'id': @getRandomThang(clusters[room.cluster].thangs) + 'pos': { + 'x': rect.x - rect.width/2 - t * preset.borderSize + 'y': i + } + 'margin': clusters[room.cluster].margin + } + + @addThang { + 'id': @getRandomThang(clusters[room.cluster].thangs) + 'pos': { + 'x': rect.x + rect.width/2 + t * preset.borderSize + 'y': i + } + 'margin': clusters[room.cluster].margin + } + addThang: (thang) -> + # if @falseCount > 20 + # console.log 'infinite loop', thang + # @falseCount = 0 + # return true for existingThang in @thangs if existingThang.margin is -1 or thang.margin is -1 continue if Math.abs(existingThang.pos.x - thang.pos.x) <= thang.margin + existingThang.margin and Math.abs(existingThang.pos.y - thang.pos.y) <= thang.margin + existingThang.margin + # @falseCount++ return false @thangs.push thang true From f700ddea0c3cc5e12be891817c1d6ecc14ae60e1 Mon Sep 17 00:00:00 2001 From: Jayant Jain Date: Fri, 25 Jul 2014 05:08:42 +0530 Subject: [PATCH 07/11] Adds temporary hack for infinite loops in randomise --- .../editor/level/modals/TerrainRandomizeModal.coffee | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/editor/level/modals/TerrainRandomizeModal.coffee b/app/views/editor/level/modals/TerrainRandomizeModal.coffee index 2a23cb9dc..d31a231e8 100644 --- a/app/views/editor/level/modals/TerrainRandomizeModal.coffee +++ b/app/views/editor/level/modals/TerrainRandomizeModal.coffee @@ -316,15 +316,15 @@ module.exports = class TerrainRandomizeModal extends ModalView } addThang: (thang) -> - # if @falseCount > 20 - # console.log 'infinite loop', thang - # @falseCount = 0 - # return true + if @falseCount > 20 + console.log 'infinite loop', thang + @falseCount = 0 + return true for existingThang in @thangs if existingThang.margin is -1 or thang.margin is -1 continue if Math.abs(existingThang.pos.x - thang.pos.x) <= thang.margin + existingThang.margin and Math.abs(existingThang.pos.y - thang.pos.y) <= thang.margin + existingThang.margin - # @falseCount++ + @falseCount++ return false @thangs.push thang true From d3962c19bd55a88be2cd80b0d94cadbea63bab3f Mon Sep 17 00:00:00 2001 From: Jayant Jain Date: Fri, 25 Jul 2014 12:16:27 +0530 Subject: [PATCH 08/11] Ensures randomised thang clusters do not overlap each other --- .../level/modals/TerrainRandomizeModal.coffee | 52 +++++++++++++------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/app/views/editor/level/modals/TerrainRandomizeModal.coffee b/app/views/editor/level/modals/TerrainRandomizeModal.coffee index d31a231e8..632617678 100644 --- a/app/views/editor/level/modals/TerrainRandomizeModal.coffee +++ b/app/views/editor/level/modals/TerrainRandomizeModal.coffee @@ -142,7 +142,6 @@ thangSizes = { module.exports = class TerrainRandomizeModal extends ModalView id: 'terrain-randomize-modal' template: template - thangs = [] events: 'click .choose-option': 'onRandomize' @@ -167,6 +166,7 @@ module.exports = class TerrainRandomizeModal extends ModalView preset = presets[presetName] presetSize = presetSizes[presetSize] @thangs = [] + @rects = [] @randomizeFloor preset, presetSize @randomizeBorder preset, presetSize, preset.borderNoise @randomizeDecorations preset, presetSize @@ -233,12 +233,15 @@ module.exports = class TerrainRandomizeModal extends ModalView if @['build'+name] isnt undefined @['build'+name](preset, presetSize, decoration) continue - rect = { - 'x':_.random(decoration.width/2 + preset.borderSize/2 + thangSizes.borderSize.x, presetSize.x - decoration.width/2 - preset.borderSize/2 - thangSizes.borderSize.x), - 'y':_.random(decoration.height/2 + preset.borderSize/2 + thangSizes.borderSize.y, presetSize.y - decoration.height/2 - preset.borderSize/2 - thangSizes.borderSize.y) - 'width':decoration.width - 'height':decoration.height - } + while true + rect = { + 'x':_.random(decoration.width/2 + preset.borderSize/2 + thangSizes.borderSize.x, presetSize.x - decoration.width/2 - preset.borderSize/2 - thangSizes.borderSize.x), + 'y':_.random(decoration.height/2 + preset.borderSize/2 + thangSizes.borderSize.y, presetSize.y - decoration.height/2 - preset.borderSize/2 - thangSizes.borderSize.y) + 'width':decoration.width + 'height':decoration.height + } + break if @addRect rect + for cluster, range of decoration.clusters for i in _.range(_.random(range[0], range[1])) while not @addThang { @@ -253,13 +256,20 @@ module.exports = class TerrainRandomizeModal extends ModalView buildRoom: (preset, presetSize, room) -> if presetSize is presetSizes['small'] then sizeFactor = 1 else sizeFactor = 2 - rect = { - 'width':sizeFactor * (room.width[0] + preset.borderSize * _.random(0, (room.width[1] - room.width[0])/preset.borderSize)) - 'height':sizeFactor * (room.height[0] + preset.borderSize * _.random(0, (room.height[1] - room.height[0])/preset.borderSize)) - } - roomThickness = _.random(room.thickness[0], room.thickness[1]) - rect.x = _.random(rect.width/2 + preset.borderSize * (roomThickness+2), presetSize.x - rect.width/2 - preset.borderSize * (roomThickness+2)) - rect.y = _.random(rect.height/2 + preset.borderSize * (roomThickness+2), presetSize.y - rect.height/2 - preset.borderSize * (roomThickness+2)) + while true + rect = { + 'width':sizeFactor * (room.width[0] + preset.borderSize * _.random(0, (room.width[1] - room.width[0])/preset.borderSize)) + 'height':sizeFactor * (room.height[0] + preset.borderSize * _.random(0, (room.height[1] - room.height[0])/preset.borderSize)) + } + roomThickness = _.random(room.thickness[0], room.thickness[1]) + rect.x = _.random(rect.width/2 + preset.borderSize * (roomThickness+1), presetSize.x - rect.width/2 - preset.borderSize * (roomThickness+1)) + rect.y = _.random(rect.height/2 + preset.borderSize * (roomThickness+1), presetSize.y - rect.height/2 - preset.borderSize * (roomThickness+1)) + break if @addRect { + 'x': rect.x + 'y': rect.y + 'width': rect.width + 2 * roomThickness * preset.borderSize + 'height': rect.height + 2 * roomThickness * preset.borderSize + } xRange = _.range(rect.x - rect.width/2 + preset.borderSize, rect.x + rect.width/2, preset.borderSize) topDoor = _.random(1) > 0.5 @@ -316,7 +326,7 @@ module.exports = class TerrainRandomizeModal extends ModalView } addThang: (thang) -> - if @falseCount > 20 + if @falseCount > 100 console.log 'infinite loop', thang @falseCount = 0 return true @@ -329,6 +339,18 @@ module.exports = class TerrainRandomizeModal extends ModalView @thangs.push thang true + addRect: (rect) -> + if @falseCount > 100 + console.log 'infinite loop', rect + @falseCount = 0 + return true + for existingRect in @rects + if Math.abs(existingRect.x - rect.x) <= rect.width/2 + existingRect.width/2 and Math.abs(existingRect.y - rect.y) <= rect.height/2 + existingRect.height/2 + @falseCount++ + return false + @rects.push rect + true + getRandomThang: (thangList) -> return thangList[_.random(0, thangList.length-1)] From 3e9dbe0d0bd2d6dc3ebd1b774581b70dc2ff3b49 Mon Sep 17 00:00:00 2001 From: Jayant Jain Date: Fri, 25 Jul 2014 17:13:33 +0530 Subject: [PATCH 09/11] Fixes bug in undo/redo on SystemsTabView --- .../editor/level/systems/LevelSystemEditView.coffee | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/views/editor/level/systems/LevelSystemEditView.coffee b/app/views/editor/level/systems/LevelSystemEditView.coffee index a2a658b2a..89c52faae 100644 --- a/app/views/editor/level/systems/LevelSystemEditView.coffee +++ b/app/views/editor/level/systems/LevelSystemEditView.coffee @@ -116,11 +116,17 @@ module.exports = class LevelSystemEditView extends CocoView button.find('> span').toggleClass('secret') undo: -> - if @$el.find('#editor-level-system-edit-view li.active a#system-config-schema-tab') + if @$el.find('li.active > a#system-config-schema-tab') @configSchemaTreema.undo() - if @$el.find('#editor-level-system-edit-view li.active a#system-settings-tab') + if @$el.find('li.active > a#system-settings-tab') @systemSettingsTreema.undo() + redo: -> + if @$el.find('li.active > a#system-config-schema-tab') + @configSchemaTreema.redo() + if @$el.find('li.active > a#system-settings-tab') + @systemSettingsTreema.redo() + destroy: -> @editor?.destroy() super() From df554360fe9f922ac4c91f1832495e1d419df374 Mon Sep 17 00:00:00 2001 From: Jayant Jain Date: Sat, 26 Jul 2014 00:15:22 +0530 Subject: [PATCH 10/11] Updates glyphicons for undo-redo, adds placeholder text for add thangs search --- app/styles/editor/level/thangs_tab.sass | 2 ++ app/templates/editor/level/add_thangs.jade | 2 +- app/templates/editor/level/edit.jade | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/styles/editor/level/thangs_tab.sass b/app/styles/editor/level/thangs_tab.sass index 5fe9e2f10..5ccedfaf3 100644 --- a/app/styles/editor/level/thangs_tab.sass +++ b/app/styles/editor/level/thangs_tab.sass @@ -151,6 +151,8 @@ $mobile: 1050px input width: $addPaletteWidth margin: 0 + margin-top: 5px + padding-left: 5px @media screen and (max-width: $mobile) margin: 0 5px diff --git a/app/templates/editor/level/add_thangs.jade b/app/templates/editor/level/add_thangs.jade index fe9fbba39..cec7666f9 100644 --- a/app/templates/editor/level/add_thangs.jade +++ b/app/templates/editor/level/add_thangs.jade @@ -1,5 +1,5 @@ h3(data-i18n="editor.level_tab_thangs_add") Add Thangs -input(type="search", id="thang-search") +input(type="search", id="thang-search", placeholder="Search thangs") div.editor-nano-container.nano #thangs-list.nano-content for group in groups diff --git a/app/templates/editor/level/edit.jade b/app/templates/editor/level/edit.jade index aaa9f6048..ff4b7789b 100644 --- a/app/templates/editor/level/edit.jade +++ b/app/templates/editor/level/edit.jade @@ -39,11 +39,11 @@ block header ul.nav.navbar-nav.navbar-right li#undo-button(title="Undo (Ctrl+Z)") - a - span.glyphicon-floppy-disk.glyphicon + a + span.glyphicon-arrow-left.glyphicon li#redo-button(title="Redo (Ctrl+Shift+Z)") a - span.glyphicon-floppy-disk.glyphicon + span.glyphicon-repeat.glyphicon if authorized li#commit-level-start-button a From 69713f560331b71094bcba9029d0b855aeae64d7 Mon Sep 17 00:00:00 2001 From: Jayant Jain Date: Sat, 26 Jul 2014 01:51:10 +0530 Subject: [PATCH 11/11] Adds randomize button in case of level with no thangs --- app/styles/editor/level/thangs_tab.sass | 15 +++++++++++++++ app/templates/editor/level/thangs_tab.jade | 2 ++ .../editor/level/thangs/ThangsTabView.coffee | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/app/styles/editor/level/thangs_tab.sass b/app/styles/editor/level/thangs_tab.sass index 5ccedfaf3..ac5509f64 100644 --- a/app/styles/editor/level/thangs_tab.sass +++ b/app/styles/editor/level/thangs_tab.sass @@ -210,6 +210,21 @@ $mobile: 1050px #canvas-wrapper width: 100% position: relative + + #canvas-overlay + position: absolute + width: 100% + height: 100% + background: white + opacity: 0.5 + text-align: center + + #randomize-button + position: absolute + top: 45% + height: 40px + + // Below snatched from play/level.sass; should refactor? diff --git a/app/templates/editor/level/thangs_tab.jade b/app/templates/editor/level/thangs_tab.jade index e76a0f0d9..54eb93f7e 100644 --- a/app/templates/editor/level/thangs_tab.jade +++ b/app/templates/editor/level/thangs_tab.jade @@ -23,6 +23,8 @@ button.navbar-toggle.toggle.btn-primary#thangs-palette-toggle(type="button", dat .world-container.thangs-column h3(data-i18n="editor.level_tab_thangs_conditions") Starting Conditions #canvas-wrapper + #canvas-overlay + button.btn.btn-primary(id="randomize-button", data-toggle="coco-modal", data-target="editor/level/modals/TerrainRandomizeModal", data-i18n="editor.randomize", title="Randomize Terrain") Randomize ul.dropdown-menu#contextmenu li#delete a(data-i18n="editor.delete") Delete diff --git a/app/views/editor/level/thangs/ThangsTabView.coffee b/app/views/editor/level/thangs/ThangsTabView.coffee index d03d888da..45d652a94 100644 --- a/app/views/editor/level/thangs/ThangsTabView.coffee +++ b/app/views/editor/level/thangs/ThangsTabView.coffee @@ -116,6 +116,8 @@ module.exports = class ThangsTabView extends CocoView $(window).resize @onWindowResize @addThangsView = @insertSubView new AddThangsView world: @world, supermodel: @supermodel @buildInterface() # refactor to not have this trigger when this view re-renders? + if @thangsTreema.data.length + @$el.find('#canvas-overlay').css('display', 'none') onFilterExtantThangs: (e) -> @$el.find('#extant-thangs-filter button.active').button('toggle') @@ -233,6 +235,8 @@ module.exports = class ThangsTabView extends CocoView @addThang @addThangType, thang.pos, true @batchInsert() @selectAddThangType null + @$el.find('#canvas-overlay').css('display', 'none') + # TODO: figure out a good way to have all Surface clicks and Treema clicks just proxy in one direction, so we can maintain only one way of handling selection and deletion onExtantThangSelected: (e) ->