From 1ab8274c4343ccd0ebd0aeab7c34e83b0f5cdc21 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Wed, 25 Feb 2015 11:09:11 -0800 Subject: [PATCH] Added a clear storage button to the campaign editor. --- app/lib/surface/Lank.coffee | 1 + app/locale/en.coffee | 1 + app/styles/play/campaign-view.sass | 19 ++++++------------- app/templates/play/campaign-view.jade | 10 +++++++--- app/views/play/CampaignView.coffee | 10 ++++++++++ 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/app/lib/surface/Lank.coffee b/app/lib/surface/Lank.coffee index 8f86a3788..565b66dc9 100644 --- a/app/lib/surface/Lank.coffee +++ b/app/lib/surface/Lank.coffee @@ -103,6 +103,7 @@ module.exports = Lank = class Lank extends CocoClass setSprite: (newSprite) -> if @sprite + @sprite.off 'animationend', @playNextAction @sprite.destroy?() if parent = @sprite.parent parent.removeChild @sprite diff --git a/app/locale/en.coffee b/app/locale/en.coffee index 6e22cbda2..e221d3290 100644 --- a/app/locale/en.coffee +++ b/app/locale/en.coffee @@ -780,6 +780,7 @@ level_completion: "Level Completion" pop_i18n: "Populate I18N" tasks: "Tasks" + clear_storage: "Clear your local changes" article: edit_btn_preview: "Preview" diff --git a/app/styles/play/campaign-view.sass b/app/styles/play/campaign-view.sass index a188629c2..023a42fa4 100644 --- a/app/styles/play/campaign-view.sass +++ b/app/styles/play/campaign-view.sass @@ -427,8 +427,7 @@ $gameControlMargin: 30px &.sorcerer background-position: (-12 * $spriteSheetSize) 0 - - #volume-button + .campaign-control-button position: absolute right: 1% top: 1% @@ -439,9 +438,12 @@ $gameControlMargin: 30px @include opacity(1.0) .glyphicon - display: none font-size: 32px + #volume-button + .glyphicon + display: none + &.vol-up .glyphicon.glyphicon-volume-up display: inline-block @@ -454,20 +456,11 @@ $gameControlMargin: 30px &.vol-down .glyphicon.glyphicon-volume-down display: inline-block - #back-button + #back-button, #clear-storage-button position: absolute right: 70px right: -webkit-calc(1% + 55px) right: calc(1% + 55px) - top: 1% - padding: 3px 8px - @include opacity(0.75) - - &:hover - @include opacity(1.0) - - .glyphicon - font-size: 32px #campaign-status position: absolute diff --git a/app/templates/play/campaign-view.jade b/app/templates/play/campaign-view.jade index 90ed2be79..5baebb9f5 100644 --- a/app/templates/play/campaign-view.jade +++ b/app/templates/play/campaign-view.jade @@ -107,15 +107,19 @@ else button.btn.btn-illustrated.btn-primary(data-i18n="nav.contact", data-toggle="coco-modal", data-target="core/ContactModal") Contact -button.btn.btn-lg.btn-inverse#volume-button(data-i18n="[title]play.adjust_volume", title="Adjust volume") +button.btn.btn-lg.btn-inverse.campaign-control-button#volume-button(data-i18n="[title]play.adjust_volume", title="Adjust volume") .glyphicon.glyphicon-volume-off .glyphicon.glyphicon-volume-down .glyphicon.glyphicon-volume-up -if campaign - button.btn.btn-lg.btn-inverse#back-button(data-i18n="[title]resources.campaigns", title="Campaigns") +if campaign && !editorMode + button.btn.btn-lg.btn-inverse.campaign-control-button#back-button(data-i18n="[title]resources.campaigns", title="Campaigns") .glyphicon.glyphicon-globe +if editorMode + button.btn.btn-lg.btn-inverse.campaign-control-button#clear-storage-button(data-i18n="[title]editor.clear_storage", title="Clear your local changes") + .glyphicon.glyphicon-refresh + if campaign && campaign.loaded h1#campaign-status .campaign-status-background diff --git a/app/views/play/CampaignView.coffee b/app/views/play/CampaignView.coffee index 5b1e2d732..ed9533eec 100644 --- a/app/views/play/CampaignView.coffee +++ b/app/views/play/CampaignView.coffee @@ -48,6 +48,7 @@ module.exports = class CampaignView extends RootView 'click .level-info-container .view-solutions': 'onClickViewSolutions' 'click #volume-button': 'onToggleVolume' 'click #back-button': 'onClickBack' + 'click #clear-storage-button': 'onClickClearStorage' 'click .portal .campaign': 'onClickPortalCampaign' 'mouseenter .portals': 'onMouseEnterPortals' 'mouseleave .portals': 'onMouseLeavePortals' @@ -531,6 +532,15 @@ module.exports = class CampaignView extends RootView viewClass: CampaignView viewArgs: [{supermodel: @supermodel}] + onClickClearStorage: (e) -> + localStorage.clear() + noty { + text: 'Local storage cleared. Reload to view the original campaign.' + layout: 'topCenter' + timeout: 5000 + type: 'information' + } + updateHero: -> return unless hero = me.get('heroConfig')?.thangType for slug, original of ThangType.heroes when original is hero