Save autocastDelay as a setting on User re #627

This commit is contained in:
dpen2000 2014-03-21 20:04:16 +00:00
parent 5a2b5667cf
commit b1b0579cb3
3 changed files with 5 additions and 5 deletions

View file

@ -32,8 +32,7 @@ module.exports = class CastButtonView extends View
@castOptions = $('.autocast-delays', @$el)
@castButton.on 'click', @onCastButtonClick
@castOptions.find('a').on 'click', @onCastOptionsClick
# TODO: use a User setting instead of localStorage
delay = localStorage.getItem 'autocastDelay'
delay = me.get('autocastDelay')
delay ?= 5000
if @levelID in ['brawlwood', 'brawlwood-tutorial', 'dungeon-arena', 'dungeon-arena-tutorial']
delay = 90019001
@ -88,7 +87,8 @@ module.exports = class CastButtonView extends View
#console.log "Set autocast delay to", delay
return unless delay
@autocastDelay = delay = parseInt delay
localStorage.setItem 'autocastDelay', delay
me.set('autocastDelay', delay)
me.save()
spell.view.setAutocastDelay delay for spellKey, spell of @spells
@castOptions.find('a').each ->
$(@).toggleClass('selected', parseInt($(@).attr('data-delay')) is delay)

View file

@ -18,7 +18,7 @@ UserHandler = class UserHandler extends Handler
'name', 'photoURL', 'password', 'anonymous', 'wizardColor1', 'volume',
'firstName', 'lastName', 'gender', 'facebookID', 'emailSubscriptions',
'testGroupNumber', 'music', 'hourOfCode', 'hourOfCodeComplete', 'preferredLanguage',
'wizard', 'aceConfig', 'simulatedBy', 'simulatedFor'
'wizard', 'aceConfig', 'simulatedBy', 'simulatedFor', 'autocastDelay'
]
jsonSchema: schema

View file

@ -17,7 +17,7 @@ UserSchema = c.object {},
wizardColor1: c.pct({title: 'Wizard Clothes Color'})
volume: c.pct({title: 'Volume'})
music: {type: 'boolean', default: true}
#autocastDelay, or more complex autocast options? I guess I'll see what I need when trying to hook up Scott's suggested autocast behavior
autocastDelay: {type: 'integer', 'default': 5000 }
emailSubscriptions: c.array {uniqueItems: true, 'default': ['announcement', 'notification']}, {'enum': emailSubscriptions}