Merge branch 'master' of git://github.com/tmrdja/codecombat into tmrdja-master

This commit is contained in:
Nick Winter 2014-04-01 09:12:48 -07:00
commit 785cb342a2
2 changed files with 34 additions and 1 deletions
app
templates/editor/level
views/editor/level

View file

@ -17,6 +17,11 @@
.world-container.thangs-column
h3(data-i18n="editor.level_tab_thangs_conditions") Starting Conditions
#canvas-wrapper
ul.dropdown-menu#contextmenu
li#delete
a Delete
li#duplicate
a Duplicate
canvas(width=1848, height=1178)#surface
#canvas-left-gradient.gradient
#canvas-top-gradient.gradient

View file

@ -48,6 +48,8 @@ module.exports = class ThangsTabView extends View
events:
'click #extant-thangs-filter button': 'onFilterExtantThangs'
'click #delete': 'onDeleteClicked'
'click #duplicate': 'onDuplicateClicked'
shortcuts:
'esc': 'selectAddThang'
@ -61,6 +63,7 @@ module.exports = class ThangsTabView extends View
@thangTypes = @supermodel.getCollection new ThangTypeSearchCollection() # should load depended-on Components, too
@listenToOnce(@thangTypes, 'sync', @onThangTypesLoaded)
@thangTypes.fetch()
$(document).bind 'contextmenu', @preventDefaultContextMenu
# just loading all Components for now: https://github.com/codecombat/codecombat/issues/405
@componentCollection = @supermodel.getCollection new ComponentsCollection()
@ -185,11 +188,14 @@ module.exports = class ThangsTabView extends View
onSpriteMouseDown: (e) ->
# Sprite clicks happen after stage clicks, but we need to know whether a sprite is being clicked.
clearTimeout @backgroundAddClickTimeout
if e.originalEvent.nativeEvent.button == 2
@onSpriteContextMenu e
onStageMouseDown: (e) ->
if @addThangSprite
# If we click on the background, we need to add @addThangSprite, but not if onSpriteMouseDown will fire.
@backgroundAddClickTimeout = _.defer => @onExtantThangSelected {}
$('#contextmenu').hide()
onSpriteDragged: (e) ->
return unless @selectedExtantThang and e.thang?.id is @selectedExtantThang?.id
@ -418,7 +424,29 @@ module.exports = class ThangsTabView extends View
@editThangView = null
@onThangsChanged()
@$el.find('.thangs-column').show()
preventDefaultContextMenu: (e) ->
e.preventDefault()
onSpriteContextMenu: (e) ->
{clientX, clientY} = e.originalEvent.nativeEvent
if @addThangType
$('#duplicate a').html 'Stop Duplicate'
else
$('#duplicate a').html 'Duplicate'
$('#contextmenu').css { position: 'fixed', left: clientX, top: clientY }
$('#contextmenu').show()
onDeleteClicked: (e) ->
$('#contextmenu').hide()
@deleteSelectedExtantThang e
onDuplicateClicked: (e) ->
$('#contextmenu').hide()
if !@addThangType
thang = @selectedExtantThang.spriteName
e.target = $(".add-thang-palette-icon[data-thang-type='" + thang + "']").get 0
@selectAddThang e
class ThangsNode extends TreemaNode.nodeMap.array
valueClass: 'treema-array-replacement'