mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-24 11:50:58 -04:00
Deleted WizardSettingsView.
This commit is contained in:
parent
62cab1e76b
commit
bba78970ea
9 changed files with 0 additions and 275 deletions
app
schemas/subscriptions
styles
templates
views
account
core
modal
play/level
|
@ -167,8 +167,6 @@ module.exports =
|
|||
]
|
||||
timedOut: {type: 'boolean'}
|
||||
|
||||
'level:edit-wizard-settings': c.object {}
|
||||
|
||||
'level:hero-config-changed': c.object {}
|
||||
|
||||
'level:hero-selection-updated': c.object {required: ['hero']},
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
#wizard-settings-view
|
||||
h3
|
||||
text-align: center
|
||||
|
||||
#tinting-display
|
||||
float: right
|
||||
|
||||
width: 450px
|
||||
margin: 0 auto
|
||||
|
||||
label
|
||||
cursor: pointer
|
||||
|
||||
#color-settings table
|
||||
float: left
|
||||
width: 250px
|
||||
cursor: pointer
|
||||
|
||||
.minicolors-input
|
||||
display: none
|
||||
|
||||
.minicolors-swatch
|
||||
position: static
|
||||
width: 40px
|
||||
cursor: pointer
|
||||
|
||||
.enabled-cell
|
||||
width: 30px
|
||||
|
||||
.color-cell
|
||||
width: 50px
|
|
@ -1,17 +0,0 @@
|
|||
#wizard-settings-modal
|
||||
color: black
|
||||
|
||||
#wizard-settings-view #color-settings
|
||||
width: 480px
|
||||
|
||||
canvas
|
||||
margin: 0px auto 20px
|
||||
display: block
|
||||
float: none
|
||||
background: white
|
||||
|
||||
#wizard-settings-name-wrapper
|
||||
padding-left: 0px !important
|
||||
|
||||
.help-block
|
||||
text-align: center
|
|
@ -1,18 +0,0 @@
|
|||
#color-settings
|
||||
table.table.table-bordered.table-hover
|
||||
tr
|
||||
th(data-i18n="wizard_settings.active") Active
|
||||
th(data-i18n="wizard_settings.color") Color
|
||||
th(data-i18n="wizard_settings.group") Group
|
||||
for group in colorGroups
|
||||
tr.color-group(data-name=group.name)
|
||||
td.enabled-cell
|
||||
input(type='checkbox', checked=group.exists, id=group.name).color-group-checkbox
|
||||
td.color-cell
|
||||
input.minicolors(type=hidden, value=group.rgb, name=group.name)
|
||||
td.group-cell
|
||||
label(for=group.name, data-i18n='wizard_settings.' + group.dasherized)= group.humanized
|
||||
|
||||
canvas#tinting-display(width=200, height=200).img-rounded
|
||||
|
||||
div.clearfix
|
|
@ -1,23 +0,0 @@
|
|||
extends /templates/core/modal-base
|
||||
|
||||
block modal-header-content
|
||||
h3(data-i18n="wizard_settings.title2") Customize Your Character
|
||||
|
||||
block modal-body-content
|
||||
form.form-horizontal
|
||||
div.form-group
|
||||
.row
|
||||
label.control-label.col-sm-6(for="name")
|
||||
| Your Wizardly Name:
|
||||
#wizard-settings-name-wrapper.col-sm-4
|
||||
input#wizard-settings-name.form-control.input-sm(name="name", type="text", value="#{me.get('name')||''}")
|
||||
|
||||
#wizard-settings-view
|
||||
|
||||
block modal-body-wait-content
|
||||
h3 Saving...
|
||||
.progress.progress-striped.active
|
||||
.progress-bar
|
||||
|
||||
block modal-footer-content
|
||||
button.btn.btn-primary.btn-large#wizard-settings-done(data-dismiss="modal", type="button") Done
|
|
@ -1,113 +0,0 @@
|
|||
CocoView = require 'views/core/CocoView'
|
||||
template = require 'templates/account/wizard-settings-view'
|
||||
{me} = require 'core/auth'
|
||||
ThangType = require 'models/ThangType'
|
||||
SpriteBuilder = require 'lib/sprites/SpriteBuilder'
|
||||
{hslToHex, hexToHSL} = require 'core/utils'
|
||||
|
||||
module.exports = class WizardSettingsView extends CocoView
|
||||
id: 'wizard-settings-view'
|
||||
template: template
|
||||
|
||||
events:
|
||||
'click .color-group': (e) ->
|
||||
return if $(e.target).closest('.minicolors')[0]
|
||||
return if $(e.target).closest('.color-group-checkbox')[0]
|
||||
return if $(e.target).closest('label')[0]
|
||||
$(e.target).closest('.color-group').find('.color-group-checkbox').click()
|
||||
'change .color-group-checkbox': (e) ->
|
||||
colorGroup = $(e.target).closest('.color-group')
|
||||
@updateColorSettings(colorGroup)
|
||||
@updateSwatchVisibility(colorGroup)
|
||||
|
||||
constructor: ->
|
||||
super(arguments...)
|
||||
@loadWizard()
|
||||
|
||||
loadWizard: ->
|
||||
@wizardThangType = new ThangType()
|
||||
@wizardThangType.setURL '/db/thang.type/wizard'
|
||||
@supermodel.loadModel @wizardThangType, 'wizard'
|
||||
|
||||
onLoaded: ->
|
||||
super()
|
||||
@spriteBuilder = new SpriteBuilder(@wizardThangType)
|
||||
@initStage()
|
||||
|
||||
getRenderData: ->
|
||||
c = super()
|
||||
wizardSettings = me.get('wizard')?.colorConfig or {}
|
||||
|
||||
colorGroups = @wizardThangType.get('colorGroups') or {}
|
||||
f = (name) ->
|
||||
hslObj = wizardSettings[name]
|
||||
hsl = if hslObj then [hslObj.hue, hslObj.saturation, hslObj.lightness] else [0, 0.5, 0.5]
|
||||
return {
|
||||
dasherized: _.string.dasherize(name)
|
||||
humanized: _.string.humanize name
|
||||
name: name
|
||||
exists: wizardSettings[name]
|
||||
rgb: hslToHex(hsl)
|
||||
}
|
||||
c.colorGroups = (f(colorName) for colorName in _.keys colorGroups when colorName isnt 'team')
|
||||
c
|
||||
|
||||
afterRender: ->
|
||||
return unless @supermodel.finished()
|
||||
wizardSettings = me.get('wizard') or {}
|
||||
wizardSettings.colorConfig ?= {}
|
||||
|
||||
@$el.find('.minicolors').each (e, minicolor) =>
|
||||
$(minicolor).minicolors({
|
||||
change: => @updateColorSettings($(minicolor).closest('.color-group'))
|
||||
changeDelay: 200
|
||||
})
|
||||
|
||||
@$el.find('.color-group').each (i, colorGroup) =>
|
||||
@updateSwatchVisibility($(colorGroup))
|
||||
|
||||
updateSwatchVisibility: (colorGroup) ->
|
||||
enabled = colorGroup.find('.color-group-checkbox').prop('checked')
|
||||
colorGroup.find('.minicolors-swatch').toggle Boolean(enabled)
|
||||
|
||||
updateColorSettings: (colorGroup) =>
|
||||
wizardSettings = $.extend(true, {}, me.get('wizard')) or {}
|
||||
wizardSettings.colorConfig ?= {}
|
||||
colorName = colorGroup.data('name')
|
||||
wizardSettings.colorConfig[colorName] ?= {}
|
||||
if colorGroup.find('.color-group-checkbox').prop('checked')
|
||||
input = colorGroup.find('.minicolors-input')
|
||||
hex = input.val()
|
||||
hsl = hexToHSL(hex)
|
||||
config = {hue: hsl[0], saturation: hsl[1], lightness: hsl[2]}
|
||||
wizardSettings.colorConfig[colorName] = config
|
||||
else
|
||||
delete wizardSettings.colorConfig[colorName]
|
||||
|
||||
me.set('wizard', wizardSettings)
|
||||
@updateMovieClip()
|
||||
@trigger 'change'
|
||||
|
||||
initStage: ->
|
||||
@stage = new createjs.Stage(@$el.find('canvas')[0])
|
||||
@updateMovieClip()
|
||||
|
||||
updateMovieClip: ->
|
||||
return unless @wizardThangType.loaded
|
||||
wizardSettings = me.get('wizard') or {}
|
||||
wizardSettings.colorConfig ?= {}
|
||||
|
||||
@stage.removeChild(@movieClip) if @movieClip
|
||||
options = {colorConfig: wizardSettings.colorConfig}
|
||||
@spriteBuilder.setOptions options
|
||||
@spriteBuilder.buildColorMaps()
|
||||
castAction = @wizardThangType.get('actions')?.cast
|
||||
return unless castAction?.animation
|
||||
@movieClip = @spriteBuilder.buildMovieClip castAction.animation
|
||||
@movieClip.scaleY = @movieClip.scaleX = 1.7 * (castAction.scale or 1)
|
||||
reg = castAction.positions?.registration
|
||||
if reg
|
||||
@movieClip.regX = reg.x
|
||||
@movieClip.regY = reg.y
|
||||
@stage.addChild @movieClip
|
||||
@stage.update()
|
|
@ -50,11 +50,6 @@ module.exports = class RootView extends CocoView
|
|||
window.tracker?.trackEvent 'Log Out', category:'Homepage', ['Google Analytics'] if @id is 'home-view'
|
||||
logoutUser($('#login-email').val())
|
||||
|
||||
showWizardSettingsModal: ->
|
||||
WizardSettingsModal = require('views/modal/WizardSettingsModal')
|
||||
subview = new WizardSettingsModal {}
|
||||
@openModalView subview
|
||||
|
||||
onClickSignupButton: ->
|
||||
AuthModal = require 'views/core/AuthModal'
|
||||
window.tracker?.trackEvent 'Sign Up', category: 'Homepage', ['Google Analytics'] if @id is 'home-view'
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
ModalView = require 'views/core/ModalView'
|
||||
template = require 'templates/modal/wizard-settings-modal'
|
||||
WizardLank = require 'lib/surface/WizardLank'
|
||||
ThangType = require 'models/ThangType'
|
||||
{me} = require 'core/auth'
|
||||
forms = require 'core/forms'
|
||||
User = require 'models/User'
|
||||
|
||||
module.exports = class WizardSettingsModal extends ModalView
|
||||
id: 'wizard-settings-modal'
|
||||
template: template
|
||||
closesOnClickOutside: false
|
||||
|
||||
events:
|
||||
'keyup #wizard-settings-name': -> @trigger 'nameChanged'
|
||||
'click #wizard-settings-done': 'onWizardSettingsDone'
|
||||
|
||||
constructor: (options) ->
|
||||
@onNameChange = _.debounce(@checkNameExists, 500)
|
||||
@on 'nameChanged', @onNameChange
|
||||
super options
|
||||
|
||||
afterRender: ->
|
||||
WizardSettingsView = require 'views/account/WizardSettingsView'
|
||||
view = new WizardSettingsView()
|
||||
@insertSubView view
|
||||
super()
|
||||
|
||||
checkNameExists: =>
|
||||
forms.clearFormAlerts(@$el)
|
||||
name = $('#wizard-settings-name').val()
|
||||
User.getUnconflictedName name, (newName) =>
|
||||
forms.clearFormAlerts(@$el)
|
||||
if name isnt newName
|
||||
forms.setErrorToProperty @$el, 'name', 'This name is already taken so you won\'t be able to keep it.', true
|
||||
|
||||
onWizardSettingsDone: ->
|
||||
me.set('name', $('#wizard-settings-name').val())
|
||||
forms.clearFormAlerts(@$el)
|
||||
res = me.validate()
|
||||
if res?
|
||||
forms.applyErrorsToForm(@$el, res)
|
||||
return
|
||||
|
||||
res = me.patch()
|
||||
return unless res
|
||||
save = $('#save-button', @$el).text($.i18n.t('common.saving', defaultValue: 'Saving...'))
|
||||
.addClass('btn-info').show().removeClass('btn-danger')
|
||||
|
||||
res.error =>
|
||||
errors = JSON.parse(res.responseText)
|
||||
console.warn 'Got errors saving user:', errors
|
||||
return if @destroyed
|
||||
forms.applyErrorsToForm(@$el, errors)
|
||||
@disableModalInProgress(@$el)
|
||||
|
||||
res.success (model, response, options) =>
|
||||
@hide() unless @destroyed
|
||||
|
||||
@enableModalInProgress(@$el)
|
|
@ -62,12 +62,10 @@ module.exports = class PlayLevelView extends RootView
|
|||
'level:reload-from-data': 'onLevelReloadFromData'
|
||||
'level:reload-thang-type': 'onLevelReloadThangType'
|
||||
'level:play-next-level': 'onPlayNextLevel'
|
||||
'level:edit-wizard-settings': 'showWizardSettingsModal'
|
||||
'level:session-will-save': 'onSessionWillSave'
|
||||
'level:started': 'onLevelStarted'
|
||||
'level:loading-view-unveiling': 'onLoadingViewUnveiling'
|
||||
'level:loading-view-unveiled': 'onLoadingViewUnveiled'
|
||||
'level:loaded': 'onLevelLoaded'
|
||||
'level:session-loaded': 'onSessionLoaded'
|
||||
'playback:real-time-playback-waiting': 'onRealTimePlaybackWaiting'
|
||||
'playback:real-time-playback-started': 'onRealTimePlaybackStarted'
|
||||
|
@ -265,10 +263,6 @@ module.exports = class PlayLevelView extends RootView
|
|||
|
||||
# Load Completed Setup ######################################################
|
||||
|
||||
onLevelLoaded: (e) ->
|
||||
# Just the level has been loaded by the level loader
|
||||
@showWizardSettingsModal() if not me.get('name') and not @isIPadApp() and not (e.level.get('type', true) in ['hero', 'hero-ladder', 'hero-coop'])
|
||||
|
||||
onSessionLoaded: (e) ->
|
||||
Backbone.Mediator.publish "ipad:language-chosen", language: e.session.get('codeLanguage') ? "python"
|
||||
# Just the level and session have been loaded by the level loader
|
||||
|
|
Loading…
Add table
Reference in a new issue