mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Tweaked the randomize buttons and modal (also changing it to "generate terrain" and refactoring related files accordingly).
This commit is contained in:
parent
4a100a501a
commit
621c684c74
8 changed files with 34 additions and 29 deletions
|
@ -557,7 +557,7 @@
|
||||||
grassy: "Grassy"
|
grassy: "Grassy"
|
||||||
fork_title: "Fork New Version"
|
fork_title: "Fork New Version"
|
||||||
fork_creating: "Creating Fork..."
|
fork_creating: "Creating Fork..."
|
||||||
randomize: "Randomize"
|
generate_terrain: "Generate Terrain"
|
||||||
more: "More"
|
more: "More"
|
||||||
wiki: "Wiki"
|
wiki: "Wiki"
|
||||||
live_chat: "Live Chat"
|
live_chat: "Live Chat"
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
#terrain-randomize-modal
|
#generate-terrain-modal
|
||||||
|
|
||||||
.choose-option
|
.choose-option
|
||||||
margin-bottom: 15px
|
margin-bottom: 15px
|
||||||
width: 100%
|
width: 48%
|
||||||
|
margin-right: 1%
|
||||||
|
margin-left: 1%
|
||||||
height: 200px
|
height: 200px
|
||||||
overflow: hidden
|
overflow: hidden
|
||||||
background: white
|
background: white
|
||||||
border: 1px solid #333
|
border: 1px solid #333
|
||||||
position: relative
|
position: relative
|
||||||
|
float: left
|
||||||
|
|
||||||
-webkit-transition: opacity 0.3s ease-in-out
|
-webkit-transition: opacity 0.3s ease-in-out
|
||||||
-moz-transition: opacity 0.3s ease-in-out
|
-moz-transition: opacity 0.3s ease-in-out
|
|
@ -12,6 +12,9 @@
|
||||||
|
|
||||||
#thangs-container-toggle, #thangs-palette-toggle
|
#thangs-container-toggle, #thangs-palette-toggle
|
||||||
top: 5px
|
top: 5px
|
||||||
|
position: absolute
|
||||||
|
z-index: 12
|
||||||
|
padding: 8px
|
||||||
|
|
||||||
#thangs-container-toggle
|
#thangs-container-toggle
|
||||||
left: 5px
|
left: 5px
|
||||||
|
@ -21,11 +24,6 @@
|
||||||
right: 5px
|
right: 5px
|
||||||
box-shadow: -1px 1px 5px black
|
box-shadow: -1px 1px 5px black
|
||||||
|
|
||||||
.toggle
|
|
||||||
position: absolute
|
|
||||||
z-index: 12
|
|
||||||
padding: 8px
|
|
||||||
|
|
||||||
.thangs-container
|
.thangs-container
|
||||||
background: white
|
background: white
|
||||||
width: $extantThangsWidth
|
width: $extantThangsWidth
|
||||||
|
@ -73,10 +71,10 @@
|
||||||
position: relative
|
position: relative
|
||||||
text-align: center
|
text-align: center
|
||||||
|
|
||||||
#randomize-button
|
.generate-terrain-button
|
||||||
position: absolute
|
position: absolute
|
||||||
top: 45%
|
top: 45%
|
||||||
height: 40px
|
//height: 40px
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ block header
|
||||||
li(class=anonymous ? "disabled": "")
|
li(class=anonymous ? "disabled": "")
|
||||||
a(data-toggle="coco-modal", data-target="modal/RevertModal", data-i18n="editor.revert")#revert-button Revert
|
a(data-toggle="coco-modal", data-target="modal/RevertModal", data-i18n="editor.revert")#revert-button Revert
|
||||||
li(class=anonymous ? "disabled": "")
|
li(class=anonymous ? "disabled": "")
|
||||||
a(data-toggle="coco-modal", data-target="editor/level/modals/TerrainRandomizeModal", data-i18n="editor.randomize")#randomize-button Randomize
|
a(data-toggle="coco-modal", data-target="editor/level/modals/GenerateTerrainModal", data-i18n="editor.generate_terrain").generate-terrain-button Generate Terrain
|
||||||
li(class=anonymous ? "disabled": "")
|
li(class=anonymous ? "disabled": "")
|
||||||
a(data-i18n="editor.pop_i18n")#pop-level-i18n-button Populate i18n
|
a(data-i18n="editor.pop_i18n")#pop-level-i18n-button Populate i18n
|
||||||
li.divider
|
li.divider
|
||||||
|
|
|
@ -13,4 +13,5 @@ block modal-body-content
|
||||||
span(data-i18n="editor."+size) #{size}
|
span(data-i18n="editor."+size) #{size}
|
||||||
div.preset-name.capitalize
|
div.preset-name.capitalize
|
||||||
span(data-i18n="editor."+preset.type) #{preset.type}
|
span(data-i18n="editor."+preset.type) #{preset.type}
|
||||||
|
.clearfix
|
||||||
block modal-footer
|
block modal-footer
|
|
@ -1,6 +1,6 @@
|
||||||
button.toggle.btn#thangs-container-toggle
|
button.btn#thangs-container-toggle
|
||||||
span.icon-list
|
span.icon-list
|
||||||
button.toggle.btn#thangs-palette-toggle
|
button.btn#thangs-palette-toggle
|
||||||
span.icon-plus
|
span.icon-plus
|
||||||
.thangs-container.hide#all-thangs
|
.thangs-container.hide#all-thangs
|
||||||
h3(data-i18n="editor.level_tab_thangs_title") Current Thangs
|
h3(data-i18n="editor.level_tab_thangs_title") Current Thangs
|
||||||
|
@ -8,7 +8,7 @@ button.toggle.btn#thangs-palette-toggle
|
||||||
|
|
||||||
.world-container
|
.world-container
|
||||||
#canvas-wrapper
|
#canvas-wrapper
|
||||||
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
|
button.generate-terrain-button.btn.btn-info.btn-lg(data-toggle="coco-modal", data-target="editor/level/modals/GenerateTerrainModal", data-i18n="editor.generate_terrain", title="Generate Terrain") Generate Terrain
|
||||||
ul.dropdown-menu#contextmenu
|
ul.dropdown-menu#contextmenu
|
||||||
li#delete
|
li#delete
|
||||||
a(data-i18n="editor.delete") Delete
|
a(data-i18n="editor.delete") Delete
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
ModalView = require 'views/kinds/ModalView'
|
ModalView = require 'views/kinds/ModalView'
|
||||||
template = require 'templates/editor/level/modal/terrain_randomize'
|
template = require 'templates/editor/level/modal/generate-terrain-modal'
|
||||||
CocoModel = require 'models/CocoModel'
|
CocoModel = require 'models/CocoModel'
|
||||||
|
|
||||||
clusters = {
|
clusters = {
|
||||||
|
@ -229,11 +229,14 @@ thangSizes = {
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
module.exports = class TerrainRandomizeModal extends ModalView
|
module.exports = class GenerateTerrainModal extends ModalView
|
||||||
id: 'terrain-randomize-modal'
|
id: 'generate-terrain-modal'
|
||||||
template: template
|
template: template
|
||||||
|
plain: true
|
||||||
|
modalWidthPercent: 90
|
||||||
|
|
||||||
events:
|
events:
|
||||||
'click .choose-option': 'onRandomize'
|
'click .choose-option': 'onGenerate'
|
||||||
|
|
||||||
onRevertModel: (e) ->
|
onRevertModel: (e) ->
|
||||||
id = $(e.target).val()
|
id = $(e.target).val()
|
||||||
|
@ -241,25 +244,25 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
||||||
$(e.target).closest('tr').remove()
|
$(e.target).closest('tr').remove()
|
||||||
@reloadOnClose = true
|
@reloadOnClose = true
|
||||||
|
|
||||||
onRandomize: (e) ->
|
onGenerate: (e) ->
|
||||||
target = $(e.target)
|
target = $(e.target)
|
||||||
presetType = target.attr 'data-preset-type'
|
presetType = target.attr 'data-preset-type'
|
||||||
presetSize = target.attr 'data-preset-size'
|
presetSize = target.attr 'data-preset-size'
|
||||||
@randomizeThangs presetType, presetSize
|
@generateThangs presetType, presetSize
|
||||||
Backbone.Mediator.publish 'editor:random-terrain-generated', thangs: @thangs, terrain: presets[presetType].terrainName
|
Backbone.Mediator.publish 'editor:random-terrain-generated', thangs: @thangs, terrain: presets[presetType].terrainName
|
||||||
@hide()
|
@hide()
|
||||||
|
|
||||||
randomizeThangs: (presetName, presetSize) ->
|
generateThangs: (presetName, presetSize) ->
|
||||||
@falseCount = 0
|
@falseCount = 0
|
||||||
preset = presets[presetName]
|
preset = presets[presetName]
|
||||||
presetSize = presetSizes[presetSize]
|
presetSize = presetSizes[presetSize]
|
||||||
@thangs = []
|
@thangs = []
|
||||||
@rects = []
|
@rects = []
|
||||||
@randomizeFloor preset, presetSize
|
@generateFloor preset, presetSize
|
||||||
@randomizeBorder preset, presetSize, preset.borderNoise
|
@generateBorder preset, presetSize, preset.borderNoise
|
||||||
@randomizeDecorations preset, presetSize
|
@generateDecorations preset, presetSize
|
||||||
|
|
||||||
randomizeFloor: (preset, presetSize) ->
|
generateFloor: (preset, presetSize) ->
|
||||||
for i in _.range(0, presetSize.x, thangSizes.floorSize.x)
|
for i in _.range(0, presetSize.x, thangSizes.floorSize.x)
|
||||||
for j in _.range(0, presetSize.y, thangSizes.floorSize.y)
|
for j in _.range(0, presetSize.y, thangSizes.floorSize.y)
|
||||||
@thangs.push {
|
@thangs.push {
|
||||||
|
@ -271,7 +274,7 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
||||||
'margin': clusters[preset.floors].margin
|
'margin': clusters[preset.floors].margin
|
||||||
}
|
}
|
||||||
|
|
||||||
randomizeBorder: (preset, presetSize, noiseFactor=1) ->
|
generateBorder: (preset, presetSize, noiseFactor=1) ->
|
||||||
for i in _.range(0, presetSize.x, thangSizes.borderSize.x)
|
for i in _.range(0, presetSize.x, thangSizes.borderSize.x)
|
||||||
for j in _.range(preset.borderThickness)
|
for j in _.range(preset.borderThickness)
|
||||||
# Bottom wall
|
# Bottom wall
|
||||||
|
@ -349,7 +352,7 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
|
|
||||||
randomizeDecorations: (preset, presetSize)->
|
generateDecorations: (preset, presetSize)->
|
||||||
for name, decoration of preset.decorations
|
for name, decoration of preset.decorations
|
||||||
for num in _.range(presetSize.sizeFactor * _.random(decoration.num[0], decoration.num[1]))
|
for num in _.range(presetSize.sizeFactor * _.random(decoration.num[0], decoration.num[1]))
|
||||||
if @['build'+name] isnt undefined
|
if @['build'+name] isnt undefined
|
|
@ -152,7 +152,7 @@ module.exports = class ThangsTabView extends CocoView
|
||||||
oldHeight = $('#thangs-list').height()
|
oldHeight = $('#thangs-list').height()
|
||||||
$('#thangs-list').height(oldHeight - thangsHeaderHeight)
|
$('#thangs-list').height(oldHeight - thangsHeaderHeight)
|
||||||
if data.thangs?.length
|
if data.thangs?.length
|
||||||
@$el.find('#randomize-button').hide()
|
@$el.find('.generate-terrain-button').hide()
|
||||||
|
|
||||||
initSurface: ->
|
initSurface: ->
|
||||||
surfaceCanvas = $('canvas#surface', @$el)
|
surfaceCanvas = $('canvas#surface', @$el)
|
||||||
|
@ -415,7 +415,7 @@ module.exports = class ThangsTabView extends CocoView
|
||||||
@thangsBatch = []
|
@thangsBatch = []
|
||||||
|
|
||||||
addThang: (thangType, pos, batchInsert=false) ->
|
addThang: (thangType, pos, batchInsert=false) ->
|
||||||
@$el.find('#randomize-button').hide()
|
@$el.find('.generate-terrain-button').hide()
|
||||||
if batchInsert
|
if batchInsert
|
||||||
if thangType.get('name') is 'Hero Placeholder'
|
if thangType.get('name') is 'Hero Placeholder'
|
||||||
thangID = 'Hero Placeholder'
|
thangID = 'Hero Placeholder'
|
||||||
|
|
Loading…
Reference in a new issue