Reworks undo-redo and undo-redo descriptions

This commit is contained in:
Jayant Jain 2014-08-13 06:56:03 +05:30
parent 094f26fc63
commit 1e52f237b7
8 changed files with 6 additions and 90 deletions

View file

@ -71,10 +71,4 @@ module.exports = class ThangComponentConfigView extends CocoView
@changed = true
@trigger 'changed', { component: @component, config: @data() }
undo: ->
@editThangTreema.undo()
redo: ->
@editThangTreema.redo()
data: -> @editThangTreema.data

View file

@ -110,16 +110,18 @@ module.exports = class LevelEditView extends RootView
@childWindow.focus()
onUndo: ->
@getCurrentView()?.undo?()
TreemaNode.getLastTreemaWithFocus()?.undo()
onRedo: ->
@getCurrentView()?.redo?()
TreemaNode.getLastTreemaWithFocus()?.redo()
showUndoDescription: ->
@getCurrentView()?.showUndoDescription()
undoDescription = TreemaNode.getLastTreemaWithFocus().getUndoDescription()
@$el.find('#undo-button').attr('title', 'Undo ' + undoDescription + ' (Ctrl+Z)')
showRedoDescription: ->
@getCurrentView()?.showRedoDescription()
redoDescription = TreemaNode.getLastTreemaWithFocus().getRedoDescription()
@$el.find('#redo-button').attr('title', 'Redo ' + redoDescription + ' (Ctrl+Shift+Z)')
getCurrentView: ->
tabText = _.string.underscored $('li.active')[0]?.textContent

View file

@ -107,26 +107,6 @@ module.exports = class ScriptsTabView extends CocoView
onScriptChanged: =>
@scriptsTreema.set(@selectedScriptPath, @scriptTreema.data)
undo: ->
if @scriptTreema.canUndo() then @scriptTreema.undo() else @scriptsTreema.undo()
redo: ->
if @scriptTreema.canRedo() then @scriptTreema.redo() else @scriptsTreema.redo()
showUndoDescription: ->
if @scriptTreema.canUndo()
undoDescription = @scriptTreema.getUndoDescription()
else
undoDescription = @scriptsTreema.getUndoDescription()
titleText = $('#undo-button').attr('title', 'Undo ' + undoDescription + ' (Ctrl+Z)')
showRedoDescription: ->
if @scriptTreema.canRedo()
redoDescription = @scriptTreema.getRedoDescription()
else
redoDescription = @scriptsTreema.getRedoDescription()
titleText = $('#redo-button').attr('title', 'Redo ' + redoDescription + ' (Ctrl+Shift+Z)')
class ScriptsNode extends TreemaArrayNode
nodeDescription: 'Script'
addNewChild: ->

View file

@ -55,18 +55,5 @@ module.exports = class SettingsTabView extends CocoView
continue if @settingsTreema.data[key] is undefined
@level.set key, @settingsTreema.data[key]
undo: ->
@settingsTreema.undo()
redo: ->
@settingsTreema.redo()
showUndoDescription: ->
titleText = $('#undo-button').attr('title', 'Undo ' + @settingsTreema.getUndoDescription() + ' (Ctrl+Z)')
showRedoDescription: ->
titleText = $('#redo-button').attr('title', 'Redo ' + @settingsTreema.getRedoDescription() + ' (Ctrl+Shift+Z)')
class SettingsNode extends TreemaObjectNode
nodeDescription: 'Settings'

View file

@ -115,18 +115,6 @@ module.exports = class LevelSystemEditView extends CocoView
@levelSystem.watch(button.find('.watch').is(':visible'))
button.find('> span').toggleClass('secret')
undo: ->
if @$el.find('li.active > a#system-config-schema-tab')
@configSchemaTreema.undo()
if @$el.find('li.active > a#system-settings-tab')
@systemSettingsTreema.undo()
redo: ->
if @$el.find('li.active > a#system-config-schema-tab')
@configSchemaTreema.redo()
if @$el.find('li.active > a#system-settings-tab')
@systemSettingsTreema.redo()
destroy: ->
@editor?.destroy()
super()

View file

@ -125,13 +125,6 @@ module.exports = class SystemsTabView extends CocoView
{original: '528114e60268d018e300001a', majorVersion: 0} # UI
{original: '528114040268d018e3000011', majorVersion: 0} # Physics
]
undo: ->
return unless @levelSystemEditView
@levelSystemEditView.undo()
redo: ->
return unless @levelSystemEditView
@levelSystemEditView.redo()
class LevelSystemNode extends TreemaObjectNode
valueClass: 'treema-level-system'

View file

@ -92,11 +92,3 @@ module.exports = class LevelThangEditView extends CocoView
onComponentsChanged: (components) =>
@thangData.components = components
@saveThang()
undo: ->
return unless @thangComponentEditView
@thangComponentEditView.undo()
redo: ->
return unless @thangComponentEditView
@thangComponentEditView.redo()

View file

@ -479,26 +479,6 @@ module.exports = class ThangsTabView extends CocoView
$('#add-thangs-column').toggle()
@onWindowResize e
undo: (e) ->
if not @editThangView then @thangsTreema.undo() else @editThangView.undo()
redo: (e) ->
if not @editThangView then @thangsTreema.redo() else @editThangView.redo()
showUndoDescription: ->
if @editThangView
@editThangView.showUndoDescription()
else
undoDescription = @thangsTreema.getUndoDescription()
titleText = $('#undo-button').attr('title', 'Undo ' + undoDescription + ' (Ctrl+Z)')
showRedoDescription: ->
if @editThangView
@editThangView.showRedoDescription()
else
redoDescription = @thangsTreema.getRedoDescription()
titleText = $('#redo-button').attr('title', 'Redo ' + redoDescription + ' (Ctrl+Shift+Z)')
class ThangsNode extends TreemaNode.nodeMap.array
valueClass: 'treema-array-replacement'
nodeDescription: 'Thang'