mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-25 21:43:47 -04:00
Added helpful keyboard shortcuts modal.
This commit is contained in:
parent
cb1c21e80a
commit
b89615cea4
8 changed files with 126 additions and 6 deletions
app
locale
styles/play/level/modal
templates/play/level
views
kinds
play/level
|
@ -274,6 +274,7 @@
|
|||
editor_config_indentguides_description: "Displays vertical lines to see indentation better."
|
||||
editor_config_behaviors_label: "Smart Behaviors"
|
||||
editor_config_behaviors_description: "Autocompletes brackets, braces, and quotes."
|
||||
keyboard_shortcuts: "Key Shortcuts"
|
||||
loading_ready: "Ready!"
|
||||
tip_insert_positions: "Shift+Click a point on the map to insert it into the spell editor."
|
||||
tip_toggle_play: "Toggle play/paused with Ctrl+P."
|
||||
|
@ -310,6 +311,23 @@
|
|||
infinite_loop_reset_level: "Reset Level"
|
||||
infinite_loop_comment_out: "Comment Out My Code"
|
||||
|
||||
keyboard_shortcuts:
|
||||
keyboard_shortcuts: "Keyboard Shortcuts"
|
||||
space: "Space"
|
||||
enter: "Enter"
|
||||
escape: "Escape"
|
||||
cast_spell: "Cast current spell."
|
||||
continue_script: "Continue past current script."
|
||||
skip_scripts: "Skip past all skippable scripts."
|
||||
toggle_playback: "Toggle play/pause."
|
||||
scrub_playback: "Scrub back and forward through time."
|
||||
scrub_execution: "Scrub through current spell execution."
|
||||
toggle_debug: "Toggle debug display."
|
||||
toggle_grid: "Toggle grid overlay."
|
||||
toggle_pathfinding: "Toggle pathfinding overlay."
|
||||
beautify: "Beautify your code by standardizing its formatting."
|
||||
move_wizard: "Move your Wizard around the level."
|
||||
|
||||
admin:
|
||||
av_title: "Admin Views"
|
||||
av_entities_sub_title: "Entities"
|
||||
|
|
12
app/styles/play/level/modal/keyboard_shortcuts.sass
Normal file
12
app/styles/play/level/modal/keyboard_shortcuts.sass
Normal file
|
@ -0,0 +1,12 @@
|
|||
#keyboard-shortcuts-modal
|
||||
dl.dl-horizontal
|
||||
dt
|
||||
width: 120px
|
||||
|
||||
code
|
||||
color: #333
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif
|
||||
font-size: 100%
|
||||
|
||||
dd
|
||||
margin-left: 140px
|
63
app/templates/play/level/modal/keyboard_shortcuts.jade
Normal file
63
app/templates/play/level/modal/keyboard_shortcuts.jade
Normal file
|
@ -0,0 +1,63 @@
|
|||
extends /templates/modal/modal_base
|
||||
|
||||
block modal-header-content
|
||||
h3(data-i18n="keyboard_shortcuts.keyboard_shortcuts") Keyboard Shortcuts
|
||||
|
||||
block modal-body-content
|
||||
dl.dl-horizontal
|
||||
dt(title="Shift+" + enter)
|
||||
code ⇧+#{enter}
|
||||
dd(data-i18n="keyboard_shortcuts.cast_spell") Cast current spell.
|
||||
dl.dl-horizontal
|
||||
dt(title="Shift+" + space)
|
||||
code ⇧+#{space}
|
||||
dd(data-i18n="keyboard_shortcuts.continue_script") Continue past current script.
|
||||
dl.dl-horizontal
|
||||
dt(title=escapeKey)
|
||||
code Esc
|
||||
dd(data-i18n="keyboard_shortcuts.skip_scripts") Skip past all skippable scripts.
|
||||
dl.dl-horizontal
|
||||
dt(title=ctrlName + "+P")
|
||||
code #{ctrl}+P
|
||||
dd(data-i18n="keyboard_shortcuts.toggle_playback") Toggle play/pause.
|
||||
dl.dl-horizontal
|
||||
dt(title=ctrlName + "+[, " + ctrlName + "+]")
|
||||
code #{ctrl}+[
|
||||
| ,
|
||||
code #{ctrl}+]
|
||||
dd(data-i18n="keyboard_shortcuts.scrub_playback") Scrub back and forward through time.
|
||||
dl.dl-horizontal
|
||||
dt(title=ctrlName + "+" + altName + "+[, " + ctrlName + "+" + altName + "+]")
|
||||
code #{ctrl}+#{alt}+[
|
||||
| ,
|
||||
code #{ctrl}+#{alt}+]
|
||||
dd(data-i18n="keyboard_shortcuts.scrub_execution") Scrub through current spell execution.
|
||||
dl.dl-horizontal
|
||||
dt(title=ctrlName + "+\\")
|
||||
code #{ctrl}+\
|
||||
dd(data-i18n="keyboard_shortcuts.toggle_debug") Toggle debug display.
|
||||
dl.dl-horizontal
|
||||
dt(title=ctrlName + "+G")
|
||||
code #{ctrl}+G
|
||||
dd(data-i18n="keyboard_shortcuts.toggle_grid") Toggle grid overlay.
|
||||
dl.dl-horizontal
|
||||
dt(title=ctrlName + "+O")
|
||||
code #{ctrl}+O
|
||||
dd(data-i18n="keyboard_shortcuts.toggle_pathfinding") Toggle pathfinding overlay.
|
||||
dl.dl-horizontal
|
||||
dt(title=ctrlName + "+Shift+B")
|
||||
code #{ctrl}+⇧+B
|
||||
dd(data-i18n="keyboard_shortcuts.beautify") Beautify your code by standardizing its formatting.
|
||||
dl.dl-horizontal
|
||||
dt(title="Arrow keys")
|
||||
code ←
|
||||
| ,
|
||||
code →
|
||||
| ,
|
||||
code ↑
|
||||
| ,
|
||||
code ↓
|
||||
dd(data-i18n="keyboard_shortcuts.move_wizard") Move your Wizard around the level.
|
||||
|
||||
block modal-footer-content
|
||||
a(href='#', data-dismiss="modal", aria-hidden="true", data-i18n="modal.close").btn.btn-primary Close
|
|
@ -34,6 +34,9 @@ button.btn.btn-xs.btn-inverse#music-button(title="Toggle Music")
|
|||
i.icon-globe
|
||||
| Debug Mode
|
||||
i.icon-ok.secret
|
||||
li.selectable#view-keyboard-shortcuts
|
||||
i.icon-info-sign
|
||||
span(data-i18n="play_level.keyboard_shortcuts") Key Shortcuts
|
||||
li(title="Ctrl/Cmd + G: Toggle grid display").selectable#grid-toggle
|
||||
i.icon-th
|
||||
span(data-i18n="play_level.grid") Grid
|
||||
|
|
|
@ -38,7 +38,7 @@ module.exports = class CocoView extends Backbone.View
|
|||
@supermodel.models = options.supermodel.models
|
||||
@supermodel.collections = options.supermodel.collections
|
||||
@supermodel.shouldSaveBackups = options.supermodel.shouldSaveBackups
|
||||
|
||||
|
||||
@subscriptions = utils.combineAncestralObject(@, 'subscriptions')
|
||||
@events = utils.combineAncestralObject(@, 'events')
|
||||
@scope = makeScopeName()
|
||||
|
@ -118,7 +118,7 @@ module.exports = class CocoView extends Backbone.View
|
|||
updateProgress: (progress) ->
|
||||
@loadProgress.progress = progress if progress > @loadProgress.progress
|
||||
@updateProgressBar(progress)
|
||||
|
||||
|
||||
updateProgressBar: (progress) =>
|
||||
prog = "#{parseInt(progress*100)}%"
|
||||
@$el?.find('.loading-container .progress-bar').css('width', prog)
|
||||
|
@ -134,11 +134,11 @@ module.exports = class CocoView extends Backbone.View
|
|||
resourceIndex: r.rid,
|
||||
responseText: r.jqxhr?.responseText
|
||||
})).i18n()
|
||||
|
||||
|
||||
onRetryResource: (e) ->
|
||||
res = @supermodel.getResource($(e.target).data('resource-index'))
|
||||
# different views may respond to this call, and not all have the resource to reload
|
||||
return unless res and res.isFailed
|
||||
return unless res and res.isFailed
|
||||
res.load()
|
||||
$(e.target).closest('.loading-error-alert').remove()
|
||||
|
||||
|
@ -278,6 +278,9 @@ module.exports = class CocoView extends Backbone.View
|
|||
ua = navigator.userAgent or navigator.vendor or window.opera
|
||||
return ua.search("MSIE") != -1
|
||||
|
||||
isMac: ->
|
||||
navigator.platform.toUpperCase().indexOf('MAC') isnt -1
|
||||
|
||||
initSlider: ($el, startValue, changeCallback) ->
|
||||
slider = $el.slider({ animate: "fast" })
|
||||
slider.slider('value', startValue)
|
||||
|
|
17
app/views/play/level/modal/keyboard_shortcuts_modal.coffee
Normal file
17
app/views/play/level/modal/keyboard_shortcuts_modal.coffee
Normal file
|
@ -0,0 +1,17 @@
|
|||
View = require 'views/kinds/ModalView'
|
||||
template = require 'templates/play/level/modal/keyboard_shortcuts'
|
||||
|
||||
module.exports = class KeyboardShortcutsModal extends View
|
||||
id: 'keyboard-shortcuts-modal'
|
||||
template: template
|
||||
|
||||
getRenderData: ->
|
||||
c = super()
|
||||
c.ctrl = if @isMac() then '⌘' else '^'
|
||||
c.ctrlName = if @isMac() then 'Cmd' else 'Ctrl'
|
||||
c.alt = if @isMac() then '⌥' else 'alt'
|
||||
c.altName = if @isMac() then 'Opt' else 'Alt'
|
||||
c.enter = $.i18n.t 'keyboard_shortcuts.enter'
|
||||
c.space = $.i18n.t 'keyboard_shortcuts.space'
|
||||
c.escapeKey = $.i18n.t 'keyboard_shortcuts.escape'
|
||||
c
|
|
@ -3,6 +3,7 @@ template = require 'templates/play/level/playback'
|
|||
{me} = require 'lib/auth'
|
||||
|
||||
EditorConfigModal = require './modal/editor_config_modal'
|
||||
KeyboardShortcutsModal = require './modal/keyboard_shortcuts_modal'
|
||||
|
||||
module.exports = class PlaybackView extends View
|
||||
id: "playback-view"
|
||||
|
@ -29,6 +30,7 @@ module.exports = class PlaybackView extends View
|
|||
'click #grid-toggle': 'onToggleGrid'
|
||||
'click #edit-wizard-settings': 'onEditWizardSettings'
|
||||
'click #edit-editor-config': 'onEditEditorConfig'
|
||||
'click #view-keyboard-shortcuts': 'onViewKeyboardShortcuts'
|
||||
'click #music-button': 'onToggleMusic'
|
||||
'click #zoom-in-button': -> Backbone.Mediator.publish('camera-zoom-in') unless @shouldIgnore()
|
||||
'click #zoom-out-button': -> Backbone.Mediator.publish('camera-zoom-out') unless @shouldIgnore()
|
||||
|
@ -181,6 +183,9 @@ module.exports = class PlaybackView extends View
|
|||
onEditEditorConfig: ->
|
||||
@openModalView new EditorConfigModal session: @options.session
|
||||
|
||||
onViewKeyboardShortcuts: ->
|
||||
@openModalView new KeyboardShortcutsModal()
|
||||
|
||||
onCastSpells: (e) ->
|
||||
return if e.preload
|
||||
@casting = true
|
||||
|
|
|
@ -20,7 +20,6 @@ module.exports = class CastButtonView extends View
|
|||
super options
|
||||
@spells = options.spells
|
||||
@levelID = options.levelID
|
||||
isMac = navigator.platform.toUpperCase().indexOf('MAC') isnt -1
|
||||
@castShortcut = "⇧↵"
|
||||
@castShortcutVerbose = "Shift+Enter"
|
||||
|
||||
|
@ -79,7 +78,7 @@ module.exports = class CastButtonView extends View
|
|||
async.some _.values(@spells), (spell, callback) =>
|
||||
spell.hasChangedSignificantly spell.getSource(), null, callback
|
||||
, (castable) =>
|
||||
Backbone.Mediator.publish 'tome:spell-has-changed-significantly-calculation', hasChangedSignificantly: castable
|
||||
Backbone.Mediator.publish 'tome:spell-has-changed-significantly-calculation', hasChangedSignificantly: castable
|
||||
@castButtonGroup.toggleClass('castable', castable).toggleClass('casting', @casting)
|
||||
if @casting
|
||||
s = $.i18n.t("play_level.tome_cast_button_casting", defaultValue: "Casting")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue