mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Made a real-time playback button.
This commit is contained in:
parent
c79541f669
commit
8777a87774
4 changed files with 28 additions and 11 deletions
|
@ -82,7 +82,9 @@
|
|||
height: 40px
|
||||
|
||||
.cast-button
|
||||
width: 100%
|
||||
width: 80%
|
||||
width: -webkit-calc(100% - 40px)
|
||||
width: calc(100% - 40px)
|
||||
border-top-left-radius: 6px
|
||||
border-bottom-left-radius: 6px
|
||||
|
||||
|
@ -92,3 +94,8 @@
|
|||
font-size: 14px
|
||||
@media screen and (max-width: 1024px)
|
||||
font-size: 12px
|
||||
|
||||
.cast-real-time-button
|
||||
width: 20%
|
||||
width: -webkit-calc(40px)
|
||||
width: calc(40px)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
div.btn-group.btn-group-lg.cast-button-group.dropup
|
||||
div.btn-group.btn-group-lg.cast-button-group
|
||||
.button-progress-overlay
|
||||
button.btn.btn-inverse.banner.cast-button(title=castShortcutVerbose + ": Cast current spell", data-i18n="play_level.tome_cast_button_cast") Spell Cast
|
||||
button.btn.btn-inverse.banner.cast-real-time-button(title=castRealTimeShortcutVerbose + ": Cast in real time")
|
||||
i.glyphicon.glyphicon-play
|
|
@ -8,7 +8,7 @@ module.exports = class CastButtonView extends CocoView
|
|||
|
||||
events:
|
||||
'click .cast-button': 'onCastButtonClick'
|
||||
'click .autocast-delays a': 'onCastOptionsClick'
|
||||
'click .cast-real-time-button': 'onCastRealTimeButtonClick'
|
||||
|
||||
subscriptions:
|
||||
'tome:spell-changed': 'onSpellChanged'
|
||||
|
@ -22,10 +22,12 @@ module.exports = class CastButtonView extends CocoView
|
|||
@levelID = options.levelID
|
||||
@castShortcut = '⇧↵'
|
||||
@castShortcutVerbose = 'Shift+Enter'
|
||||
@castRealTimeShortcutVerbose = 'Ctrl+Shift+Enter'
|
||||
|
||||
getRenderData: (context={}) ->
|
||||
context = super context
|
||||
context.castShortcutVerbose = @castShortcutVerbose
|
||||
context.castRealTimeShortcutVerbose = @castRealTimeShortcutVerbose
|
||||
context
|
||||
|
||||
afterRender: ->
|
||||
|
@ -34,17 +36,20 @@ module.exports = class CastButtonView extends CocoView
|
|||
@castButtonGroup = $('.cast-button-group', @$el)
|
||||
@castOptions = $('.autocast-delays', @$el)
|
||||
delay = me.get('autocastDelay')
|
||||
delay ?= 5000
|
||||
unless @levelID in ['rescue-mission', 'grab-the-mushroom', 'drink-me', 'its-a-trap', 'break-the-prison', 'taunt', 'cowardly-taunt', 'commanding-followers', 'mobile-artillery']
|
||||
delay = 90019001
|
||||
delay ?= 90019001
|
||||
@setAutocastDelay delay
|
||||
|
||||
attachTo: (spellView) ->
|
||||
@$el.detach().prependTo(spellView.toolbarView.$el).show()
|
||||
|
||||
onCastButtonClick: (e) ->
|
||||
console.log "cas fast yo"
|
||||
Backbone.Mediator.publish 'tome:manual-cast', {}
|
||||
|
||||
onCastRealTimeButtonClick: (e) ->
|
||||
console.log "cas real time yo"
|
||||
Backbone.Mediator.publish 'tome:manual-cast', {realTime: true}
|
||||
|
||||
onCastOptionsClick: (e) =>
|
||||
Backbone.Mediator.publish 'tome:focus-editor'
|
||||
@castButtonGroup.removeClass 'open'
|
||||
|
|
|
@ -305,11 +305,14 @@ module.exports = class SpellView extends CocoView
|
|||
|
||||
recompile: (cast=true, realTime=false) ->
|
||||
@setRecompileNeeded false
|
||||
return if @spell.source is @getSource()
|
||||
@spell.transpile @getSource()
|
||||
@updateAether true, false
|
||||
@cast(false, realTime) if cast
|
||||
@notifySpellChanged()
|
||||
hasChanged = @spell.source isnt @getSource()
|
||||
if hasChanged
|
||||
@spell.transpile @getSource()
|
||||
@updateAether true, false
|
||||
if cast and (hasChanged or realTime)
|
||||
@cast(false, realTime)
|
||||
if hasChanged
|
||||
@notifySpellChanged()
|
||||
|
||||
updateACEText: (source) ->
|
||||
@eventsSuppressed = true
|
||||
|
|
Loading…
Reference in a new issue