mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -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"
|
||||
fork_title: "Fork New Version"
|
||||
fork_creating: "Creating Fork..."
|
||||
randomize: "Randomize"
|
||||
generate_terrain: "Generate Terrain"
|
||||
more: "More"
|
||||
wiki: "Wiki"
|
||||
live_chat: "Live Chat"
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
#terrain-randomize-modal
|
||||
#generate-terrain-modal
|
||||
|
||||
.choose-option
|
||||
margin-bottom: 15px
|
||||
width: 100%
|
||||
width: 48%
|
||||
margin-right: 1%
|
||||
margin-left: 1%
|
||||
height: 200px
|
||||
overflow: hidden
|
||||
background: white
|
||||
border: 1px solid #333
|
||||
position: relative
|
||||
float: left
|
||||
|
||||
-webkit-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
|
||||
top: 5px
|
||||
position: absolute
|
||||
z-index: 12
|
||||
padding: 8px
|
||||
|
||||
#thangs-container-toggle
|
||||
left: 5px
|
||||
|
@ -21,11 +24,6 @@
|
|||
right: 5px
|
||||
box-shadow: -1px 1px 5px black
|
||||
|
||||
.toggle
|
||||
position: absolute
|
||||
z-index: 12
|
||||
padding: 8px
|
||||
|
||||
.thangs-container
|
||||
background: white
|
||||
width: $extantThangsWidth
|
||||
|
@ -73,10 +71,10 @@
|
|||
position: relative
|
||||
text-align: center
|
||||
|
||||
#randomize-button
|
||||
.generate-terrain-button
|
||||
position: absolute
|
||||
top: 45%
|
||||
height: 40px
|
||||
//height: 40px
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ block header
|
|||
li(class=anonymous ? "disabled": "")
|
||||
a(data-toggle="coco-modal", data-target="modal/RevertModal", data-i18n="editor.revert")#revert-button Revert
|
||||
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": "")
|
||||
a(data-i18n="editor.pop_i18n")#pop-level-i18n-button Populate i18n
|
||||
li.divider
|
||||
|
|
|
@ -13,4 +13,5 @@ block modal-body-content
|
|||
span(data-i18n="editor."+size) #{size}
|
||||
div.preset-name.capitalize
|
||||
span(data-i18n="editor."+preset.type) #{preset.type}
|
||||
.clearfix
|
||||
block modal-footer
|
|
@ -1,6 +1,6 @@
|
|||
button.toggle.btn#thangs-container-toggle
|
||||
button.btn#thangs-container-toggle
|
||||
span.icon-list
|
||||
button.toggle.btn#thangs-palette-toggle
|
||||
button.btn#thangs-palette-toggle
|
||||
span.icon-plus
|
||||
.thangs-container.hide#all-thangs
|
||||
h3(data-i18n="editor.level_tab_thangs_title") Current Thangs
|
||||
|
@ -8,7 +8,7 @@ button.toggle.btn#thangs-palette-toggle
|
|||
|
||||
.world-container
|
||||
#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
|
||||
li#delete
|
||||
a(data-i18n="editor.delete") Delete
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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'
|
||||
|
||||
clusters = {
|
||||
|
@ -229,11 +229,14 @@ thangSizes = {
|
|||
}}
|
||||
|
||||
|
||||
module.exports = class TerrainRandomizeModal extends ModalView
|
||||
id: 'terrain-randomize-modal'
|
||||
module.exports = class GenerateTerrainModal extends ModalView
|
||||
id: 'generate-terrain-modal'
|
||||
template: template
|
||||
plain: true
|
||||
modalWidthPercent: 90
|
||||
|
||||
events:
|
||||
'click .choose-option': 'onRandomize'
|
||||
'click .choose-option': 'onGenerate'
|
||||
|
||||
onRevertModel: (e) ->
|
||||
id = $(e.target).val()
|
||||
|
@ -241,25 +244,25 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
|||
$(e.target).closest('tr').remove()
|
||||
@reloadOnClose = true
|
||||
|
||||
onRandomize: (e) ->
|
||||
onGenerate: (e) ->
|
||||
target = $(e.target)
|
||||
presetType = target.attr 'data-preset-type'
|
||||
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
|
||||
@hide()
|
||||
|
||||
randomizeThangs: (presetName, presetSize) ->
|
||||
generateThangs: (presetName, presetSize) ->
|
||||
@falseCount = 0
|
||||
preset = presets[presetName]
|
||||
presetSize = presetSizes[presetSize]
|
||||
@thangs = []
|
||||
@rects = []
|
||||
@randomizeFloor preset, presetSize
|
||||
@randomizeBorder preset, presetSize, preset.borderNoise
|
||||
@randomizeDecorations preset, presetSize
|
||||
@generateFloor preset, presetSize
|
||||
@generateBorder preset, presetSize, preset.borderNoise
|
||||
@generateDecorations preset, presetSize
|
||||
|
||||
randomizeFloor: (preset, presetSize) ->
|
||||
generateFloor: (preset, presetSize) ->
|
||||
for i in _.range(0, presetSize.x, thangSizes.floorSize.x)
|
||||
for j in _.range(0, presetSize.y, thangSizes.floorSize.y)
|
||||
@thangs.push {
|
||||
|
@ -271,7 +274,7 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
|||
'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 j in _.range(preset.borderThickness)
|
||||
# Bottom wall
|
||||
|
@ -349,7 +352,7 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
|||
}
|
||||
continue
|
||||
|
||||
randomizeDecorations: (preset, presetSize)->
|
||||
generateDecorations: (preset, presetSize)->
|
||||
for name, decoration of preset.decorations
|
||||
for num in _.range(presetSize.sizeFactor * _.random(decoration.num[0], decoration.num[1]))
|
||||
if @['build'+name] isnt undefined
|
|
@ -152,7 +152,7 @@ module.exports = class ThangsTabView extends CocoView
|
|||
oldHeight = $('#thangs-list').height()
|
||||
$('#thangs-list').height(oldHeight - thangsHeaderHeight)
|
||||
if data.thangs?.length
|
||||
@$el.find('#randomize-button').hide()
|
||||
@$el.find('.generate-terrain-button').hide()
|
||||
|
||||
initSurface: ->
|
||||
surfaceCanvas = $('canvas#surface', @$el)
|
||||
|
@ -415,7 +415,7 @@ module.exports = class ThangsTabView extends CocoView
|
|||
@thangsBatch = []
|
||||
|
||||
addThang: (thangType, pos, batchInsert=false) ->
|
||||
@$el.find('#randomize-button').hide()
|
||||
@$el.find('.generate-terrain-button').hide()
|
||||
if batchInsert
|
||||
if thangType.get('name') is 'Hero Placeholder'
|
||||
thangID = 'Hero Placeholder'
|
||||
|
|
Loading…
Reference in a new issue