diff --git a/app/assets/images/pages/editor/level/preset_grassy_large.jpg b/app/assets/images/pages/editor/level/preset_grassy_large.jpg new file mode 100644 index 000000000..53c8bc2a7 Binary files /dev/null and b/app/assets/images/pages/editor/level/preset_grassy_large.jpg differ diff --git a/app/assets/images/pages/editor/level/preset_grassy_small.jpg b/app/assets/images/pages/editor/level/preset_grassy_small.jpg new file mode 100644 index 000000000..ed9356944 Binary files /dev/null and b/app/assets/images/pages/editor/level/preset_grassy_small.jpg differ diff --git a/app/styles/editor/level/modal/terrain_randomize.sass b/app/styles/editor/level/modal/terrain_randomize.sass index 892d4d52f..b6d1064e1 100644 --- a/app/styles/editor/level/modal/terrain_randomize.sass +++ b/app/styles/editor/level/modal/terrain_randomize.sass @@ -3,7 +3,7 @@ .choose-option margin-bottom: 15px width: 100% - height: 100px + height: 200px overflow: hidden background: white border: 1px solid #333 @@ -125,4 +125,7 @@ .hard-option .preset-name border-top: 25px solid black - color: white \ No newline at end of file + color: white + + .capitalize + text-transform: capitalize \ No newline at end of file diff --git a/app/templates/editor/level/modal/terrain_randomize.jade b/app/templates/editor/level/modal/terrain_randomize.jade index 8ea39185e..b80f80562 100644 --- a/app/templates/editor/level/modal/terrain_randomize.jade +++ b/app/templates/editor/level/modal/terrain_randomize.jade @@ -5,11 +5,12 @@ block modal-header-content block modal-body-content div#normal-view - a(href="#") - div.choose-option(data-preset-type="grassy", data-preset-size="small") - div.preset-size.name-label - span(data-i18n="editor.small") Small - div.preset-name - span(data-i18n="editor.grassy") Grassy - //- for model in models + each sizeObject, size in presetSizes + each preset in presets + a(href="#") + div.choose-option(data-preset-type=preset.type, data-preset-size=size, style="background:url(/images/pages/editor/level/preset_"+preset.type+"_"+size+".jpg) no-repeat center; background-size: cover") + div.preset-size.name-label.capitalize + span(data-i18n="editor."+size) #{size} + div.preset-name.capitalize + span(data-i18n="editor.grassy") #{preset.type} block modal-footer diff --git a/app/views/editor/level/modals/TerrainRandomizeModal.coffee b/app/views/editor/level/modals/TerrainRandomizeModal.coffee index 34dfc4756..9a78f42f7 100644 --- a/app/views/editor/level/modals/TerrainRandomizeModal.coffee +++ b/app/views/editor/level/modals/TerrainRandomizeModal.coffee @@ -50,7 +50,7 @@ presets = { } } -sizes = { +presetSizes = { 'small': { 'x':80 'y':68 @@ -59,6 +59,9 @@ sizes = { 'x':160 'y':136 } +} + +thangSizes = { 'floorSize': { 'x':20 'y':17 @@ -96,55 +99,55 @@ module.exports = class TerrainRandomizeModal extends ModalView randomizeThangs: (presetName, presetSize) -> preset = presets[presetName] - presetSize = sizes[presetSize] + presetSize = presetSizes[presetSize] @thangs = [] @randomizeFloor preset, presetSize @randomizeBorder preset, presetSize @randomizeDecorations 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) + 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) 'pos': { - 'x': i + sizes.floorSize.x/2 - 'y': j + sizes.floorSize.y/2 + 'x': i + thangSizes.floorSize.x/2 + 'y': j + thangSizes.floorSize.y/2 } } randomizeBorder: (preset, presetSize) -> - for i in _.range(0, presetSize.x, sizes.borderSize.x) - for j in _.range(sizes.borderSize.thickness) + 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(-sizes.borderSize.x/2, sizes.borderSize.x/2) - 'y': 0 + _.random(-sizes.borderSize.y/2, sizes.borderSize.y) + 'x': i + _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x/2) + 'y': 0 + _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y) } } @thangs.push { 'id': @getRandomThang(preset.borders) 'pos': { - 'x': i + _.random(-sizes.borderSize.x/2, sizes.borderSize.x/2) - 'y': presetSize.y + _.random(-sizes.borderSize.y, sizes.borderSize.y/2) + 'x': i + _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x/2) + 'y': presetSize.y + _.random(-thangSizes.borderSize.y, thangSizes.borderSize.y/2) } } - for i in _.range(0, presetSize.y, sizes.borderSize.y) + for i in _.range(0, presetSize.y, thangSizes.borderSize.y) for j in _.range(3) @thangs.push { 'id': @getRandomThang(preset.borders) 'pos': { - 'x': 0 + _.random(-sizes.borderSize.x/2, sizes.borderSize.x) - 'y': i + _.random(-sizes.borderSize.y/2, sizes.borderSize.y/2) + 'x': 0 + _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x) + 'y': i + _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y/2) } } @thangs.push { 'id': @getRandomThang(preset.borders) 'pos': { - 'x': presetSize.x + _.random(-sizes.borderSize.x, sizes.borderSize.x/2) - 'y': i + _.random(-sizes.borderSize.y/2, sizes.borderSize.y/2) + 'x': presetSize.x + _.random(-thangSizes.borderSize.x, thangSizes.borderSize.x/2) + 'y': i + _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y/2) } } @@ -182,9 +185,8 @@ module.exports = class TerrainRandomizeModal extends ModalView getRenderData: -> c = super() - models = _.values CocoModel.backedUp - models = (m for m in models when m.hasLocalChanges()) - c.models = models + c.presets = presets + c.presetSizes = presetSizes c onHidden: ->