From 1e52f237b78564285d1ddadf5f9d76634239f4f3 Mon Sep 17 00:00:00 2001 From: Jayant Jain Date: Wed, 13 Aug 2014 06:56:03 +0530 Subject: [PATCH] Reworks undo-redo and undo-redo descriptions --- .../component/ThangComponentConfigView.coffee | 6 ------ app/views/editor/level/LevelEditView.coffee | 10 ++++++---- .../level/scripts/ScriptsTabView.coffee | 20 ------------------- .../level/settings/SettingsTabView.coffee | 13 ------------ .../level/systems/LevelSystemEditView.coffee | 12 ----------- .../level/systems/SystemsTabView.coffee | 7 ------- .../level/thangs/LevelThangEditView.coffee | 8 -------- .../editor/level/thangs/ThangsTabView.coffee | 20 ------------------- 8 files changed, 6 insertions(+), 90 deletions(-) diff --git a/app/views/editor/component/ThangComponentConfigView.coffee b/app/views/editor/component/ThangComponentConfigView.coffee index 81c86d331..1d2a78bb1 100644 --- a/app/views/editor/component/ThangComponentConfigView.coffee +++ b/app/views/editor/component/ThangComponentConfigView.coffee @@ -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 diff --git a/app/views/editor/level/LevelEditView.coffee b/app/views/editor/level/LevelEditView.coffee index 02ba073d5..c5a542f5f 100644 --- a/app/views/editor/level/LevelEditView.coffee +++ b/app/views/editor/level/LevelEditView.coffee @@ -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 diff --git a/app/views/editor/level/scripts/ScriptsTabView.coffee b/app/views/editor/level/scripts/ScriptsTabView.coffee index e3ea56388..b6bbe6f7f 100644 --- a/app/views/editor/level/scripts/ScriptsTabView.coffee +++ b/app/views/editor/level/scripts/ScriptsTabView.coffee @@ -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: -> diff --git a/app/views/editor/level/settings/SettingsTabView.coffee b/app/views/editor/level/settings/SettingsTabView.coffee index 9497fa78e..cf2c57196 100644 --- a/app/views/editor/level/settings/SettingsTabView.coffee +++ b/app/views/editor/level/settings/SettingsTabView.coffee @@ -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' \ No newline at end of file diff --git a/app/views/editor/level/systems/LevelSystemEditView.coffee b/app/views/editor/level/systems/LevelSystemEditView.coffee index 89c52faae..b1bcf8f67 100644 --- a/app/views/editor/level/systems/LevelSystemEditView.coffee +++ b/app/views/editor/level/systems/LevelSystemEditView.coffee @@ -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() diff --git a/app/views/editor/level/systems/SystemsTabView.coffee b/app/views/editor/level/systems/SystemsTabView.coffee index df5908aa7..89fa16bf1 100644 --- a/app/views/editor/level/systems/SystemsTabView.coffee +++ b/app/views/editor/level/systems/SystemsTabView.coffee @@ -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' diff --git a/app/views/editor/level/thangs/LevelThangEditView.coffee b/app/views/editor/level/thangs/LevelThangEditView.coffee index effcea1af..7ed5dce9e 100644 --- a/app/views/editor/level/thangs/LevelThangEditView.coffee +++ b/app/views/editor/level/thangs/LevelThangEditView.coffee @@ -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() diff --git a/app/views/editor/level/thangs/ThangsTabView.coffee b/app/views/editor/level/thangs/ThangsTabView.coffee index 31b6e9dba..43bbe5032 100644 --- a/app/views/editor/level/thangs/ThangsTabView.coffee +++ b/app/views/editor/level/thangs/ThangsTabView.coffee @@ -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'