Added rotation buttons in the context menu and shortcuts to the level editor.

This commit is contained in:
Scott Erickson 2014-10-21 15:19:12 -07:00
parent 20595b50da
commit 1f7d098b2e
4 changed files with 39 additions and 1 deletions

View file

@ -494,6 +494,7 @@
level_tab_thangs_add: "Add Thangs"
delete: "Delete"
duplicate: "Duplicate"
rotate: "Rotate"
level_settings_title: "Settings"
level_component_tab_title: "Current Components"
level_component_btn_new: "Create New Component"

View file

@ -122,3 +122,6 @@
left: 0
top: 0
pointer-events: none
#contextmenu
text-align: left

View file

@ -14,6 +14,17 @@ button.btn#thangs-palette-toggle
a(data-i18n="editor.delete") Delete
li#duplicate
a(data-i18n="editor.duplicate") Duplicate
li.divider
li.dropdown-header#rotation-menu-item
span(data-i18n="editor.rotate").spr Rotate
button.btn.btn-xs.spr(data-rotation='-0.5')
span.glyphicon.glyphicon-arrow-up
button.btn.btn-xs.spr(data-rotation='1')
span.glyphicon.glyphicon-arrow-left
button.btn.btn-xs.spr(data-rotation='0')
span.glyphicon.glyphicon-arrow-right
button.btn.btn-xs(data-rotation='0.5')
span.glyphicon.glyphicon-arrow-down
canvas(width=924, height=589)#webgl-surface
canvas(width=924, height=589)#normal-surface
#canvas-left-gradient.gradient

View file

@ -51,7 +51,8 @@ module.exports = class ThangsTabView extends CocoView
'click #thangs-container-toggle': 'toggleThangsContainer'
'click #thangs-palette-toggle': 'toggleThangsPalette'
# 'click .add-thang-palette-icon': 'toggleThangsPalette'
'click #rotation-menu-item button': 'onClickRotationButton'
shortcuts:
'esc': 'selectAddThang'
'delete, del, backspace': 'deleteSelectedExtantThang'
@ -59,6 +60,10 @@ module.exports = class ThangsTabView extends CocoView
'right': -> @moveAddThangSelection 1
'ctrl+z, ⌘+z': 'undo'
'ctrl+shift+z, ⌘+shift+z': 'redo'
'alt+left': -> @rotateSelectedThangBy(Math.PI)
'alt+right': -> @rotateSelectedThangBy(0)
'alt+up': -> @rotateSelectedThangBy(-Math.PI/2)
'alt+down': -> @rotateSelectedThangBy(Math.PI/2)
constructor: (options) ->
super options
@ -615,6 +620,8 @@ module.exports = class ThangsTabView extends CocoView
$('#contextmenu').css { position: 'fixed', left: clientX, top: clientY }
$('#contextmenu').show()
#- Context menu callbacks
onDeleteClicked: (e) ->
$('#contextmenu').hide()
@deleteSelectedExtantThang e
@ -623,6 +630,22 @@ module.exports = class ThangsTabView extends CocoView
$('#contextmenu').hide()
@selectAddThangType @selectedExtantThang.spriteName, @selectedExtantThang
onClickRotationButton: (e) ->
$('#contextmenu').hide()
rotation = parseFloat($(e.target).closest('button').data('rotation'))
@rotateSelectedThangBy rotation * Math.PI
rotateSelectedThangBy: (radians) ->
return unless @selectedExtantThang
@hush = true
thangData = @getThangByID(@selectedExtantThang.id)
thangData = $.extend(true, {}, thangData)
component = _.find thangData.components, {original: LevelComponent.PhysicalID}
component.config.rotation = radians
@thangsTreema.set(@pathForThang(thangData), thangData)
@hush = false
@onThangsChanged()
toggleThangsContainer: (e) ->
$('#all-thangs').toggleClass('hide')