mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Merge branch 'master' of git://github.com/jayant1992/codecombat
This commit is contained in:
commit
f9822b65e4
6 changed files with 40 additions and 23 deletions
|
@ -499,6 +499,9 @@
|
|||
back: "Back"
|
||||
revert: "Revert"
|
||||
revert_models: "Revert Models"
|
||||
pick_a_terrain: "Pick A Terrain"
|
||||
small: "Small"
|
||||
grassy: "Grassy"
|
||||
fork_title: "Fork New Version"
|
||||
fork_creating: "Creating Fork..."
|
||||
randomize: "Randomize"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#terrain-randomise-modal
|
||||
#terrain-randomize-modal
|
||||
|
||||
.choose-option
|
||||
margin-bottom: 15px
|
|
@ -80,7 +80,7 @@ block header
|
|||
li(class=anonymous ? "disabled": "")
|
||||
a(data-toggle="coco-modal", data-target="modal/revert", data-i18n="editor.revert")#revert-button Revert
|
||||
li(class=anonymous ? "disabled": "")
|
||||
a(data-toggle="coco-modal", data-target="modal/terrain_randomise", data-i18n="editor.randomize")#randomise-button Randomise
|
||||
a(data-toggle="coco-modal", data-target="editor/level/modal/terrain_randomize", data-i18n="editor.randomize")#randomize-button Randomize
|
||||
li(class=anonymous ? "disabled": "")
|
||||
a(data-i18n="editor.pop_i18n")#pop-level-i18n-button Populate i18n
|
||||
li.divider
|
||||
|
|
|
@ -8,8 +8,8 @@ block modal-body-content
|
|||
a(href="#")
|
||||
div.choose-option(data-preset-type="grassy", data-preset-size="small")
|
||||
div.preset-size.name-label
|
||||
span(data-i18n="ladder.small") Small
|
||||
span(data-i18n="editor.small") Small
|
||||
div.preset-name
|
||||
span(data-i18n="ladder.grassy") Grassy
|
||||
span(data-i18n="editor.grassy") Grassy
|
||||
//- for model in models
|
||||
block modal-footer
|
|
@ -1,5 +1,5 @@
|
|||
ModalView = require 'views/kinds/ModalView'
|
||||
template = require 'templates/modal/terrain_randomise'
|
||||
template = require 'templates/editor/level/modal/terrain_randomize'
|
||||
CocoModel = require 'models/CocoModel'
|
||||
|
||||
clusters = {
|
||||
|
@ -69,13 +69,13 @@ sizes = {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = class TerrainRandomiseModal extends ModalView
|
||||
id: 'terrain-randomise-modal'
|
||||
module.exports = class TerrainRandomizeModal extends ModalView
|
||||
id: 'terrain-randomize-modal'
|
||||
template: template
|
||||
thangs = []
|
||||
|
||||
events:
|
||||
'click .choose-option': 'onRandomise'
|
||||
'click .choose-option': 'onRandomize'
|
||||
|
||||
onRevertModel: (e) ->
|
||||
id = $(e.target).val()
|
||||
|
@ -83,25 +83,25 @@ module.exports = class TerrainRandomiseModal extends ModalView
|
|||
$(e.target).closest('tr').remove()
|
||||
@reloadOnClose = true
|
||||
|
||||
onRandomise: (e) ->
|
||||
onRandomize: (e) ->
|
||||
target = $(e.target)
|
||||
presetType = target.attr 'data-preset-type'
|
||||
presetSize = target.attr 'data-preset-size'
|
||||
@randomiseThangs presetType, presetSize
|
||||
Backbone.Mediator.publish('randomise:terrain-generated',
|
||||
@randomizeThangs presetType, presetSize
|
||||
Backbone.Mediator.publish('randomize:terrain-generated',
|
||||
'thangs': @thangs
|
||||
)
|
||||
@hide()
|
||||
|
||||
randomiseThangs: (presetName, presetSize) ->
|
||||
randomizeThangs: (presetName, presetSize) ->
|
||||
preset = presets[presetName]
|
||||
presetSize = sizes[presetSize]
|
||||
@thangs = []
|
||||
@randomiseFloor preset, presetSize
|
||||
@randomiseBorder preset, presetSize
|
||||
@randomiseDecorations preset, presetSize
|
||||
@randomizeFloor preset, presetSize
|
||||
@randomizeBorder preset, presetSize
|
||||
@randomizeDecorations preset, presetSize
|
||||
|
||||
randomiseFloor: (preset, presetSize) ->
|
||||
randomizeFloor: (preset, presetSize) ->
|
||||
for i in _.range(0, presetSize.x, sizes.floorSize.x)
|
||||
for j in _.range(0, presetSize.y, sizes.floorSize.y)
|
||||
@thangs.push {
|
||||
|
@ -112,7 +112,7 @@ module.exports = class TerrainRandomiseModal extends ModalView
|
|||
}
|
||||
}
|
||||
|
||||
randomiseBorder: (preset, presetSize) ->
|
||||
randomizeBorder: (preset, presetSize) ->
|
||||
for i in _.range(0-sizes.floorSize.x/2+sizes.borderSize.x, presetSize.x-sizes.floorSize.x/2, sizes.borderSize.x)
|
||||
@thangs.push {
|
||||
'id': @getRandomThang(preset.borders)
|
||||
|
@ -145,7 +145,7 @@ module.exports = class TerrainRandomiseModal extends ModalView
|
|||
}
|
||||
}
|
||||
|
||||
randomiseDecorations: (preset, presetSize)->
|
||||
randomizeDecorations: (preset, presetSize)->
|
||||
for name, decoration of preset.decorations
|
||||
for num in _.range(_.random(decoration.num[0], decoration.num[1]))
|
||||
center =
|
|
@ -43,7 +43,7 @@ module.exports = class ThangsTabView extends View
|
|||
'sprite:mouse-up': 'onSpriteMouseUp'
|
||||
'sprite:double-clicked': 'onSpriteDoubleClicked'
|
||||
'surface:stage-mouse-up': 'onStageMouseUp'
|
||||
'randomise:terrain-generated': 'onRandomiseTerrain'
|
||||
'randomize:terrain-generated': 'onRandomizeTerrain'
|
||||
|
||||
events:
|
||||
'click #extant-thangs-filter button': 'onFilterExtantThangs'
|
||||
|
@ -224,10 +224,16 @@ module.exports = class ThangsTabView extends View
|
|||
return unless e.thang
|
||||
@editThang thangID: e.thang.id
|
||||
|
||||
onRandomiseTerrain: (e) ->
|
||||
onRandomizeTerrain: (e) ->
|
||||
console.log 'here'
|
||||
@thangsBatch = []
|
||||
for id in @randomizeThangIDs?
|
||||
@thangsTreema.delete "id=#{id}"
|
||||
@randomizeThangIDs = []
|
||||
for thang in e.thangs
|
||||
@selectAddThangType thang.id
|
||||
@addThang @addThangType, thang.pos
|
||||
@addThang @addThangType, thang.pos, true
|
||||
@batchInsert()
|
||||
@selectAddThangType null
|
||||
|
||||
# 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
|
||||
|
@ -397,8 +403,13 @@ module.exports = class ThangsTabView extends View
|
|||
id = treema?.data?.id
|
||||
@editThang thangID: id if id
|
||||
|
||||
addThang: (thangType, pos) ->
|
||||
batchInsert: ->
|
||||
@thangsTreema.set '', @thangsBatch
|
||||
@thangsBatch = []
|
||||
|
||||
addThang: (thangType, pos, batchInsert = false) ->
|
||||
thangID = Thang.nextID(thangType.get('name'), @world) until thangID and not @thangsTreema.get "id=#{thangID}"
|
||||
@randomizeThangIDs.push thangID
|
||||
if @cloneSourceThang
|
||||
components = _.cloneDeep @thangsTreema.get "id=#{@cloneSourceThang.id}/components"
|
||||
@selectAddThang null
|
||||
|
@ -408,7 +419,10 @@ module.exports = class ThangsTabView extends View
|
|||
physical = _.find components, (c) -> c.config?.pos?
|
||||
physical.config.pos = x: pos.x, y: pos.y, z: physical.config.pos.z if physical
|
||||
thang = thangType: thangType.get('original'), id: thangID, components: components
|
||||
@thangsTreema.insert '', thang
|
||||
if batchInsert
|
||||
@thangsBatch.push thang
|
||||
else
|
||||
@thangsTreema.insert '', thang
|
||||
|
||||
editThang: (e) ->
|
||||
if e.target # click event
|
||||
|
|
Loading…
Reference in a new issue