Fixed floor y scaling. Fixed issues with client-side disabling of new model / fork / revert population actions without permissions. Ameliorated some ensure_comprehensions warnings.

This commit is contained in:
Nick Winter 2014-12-20 16:02:41 -08:00
parent 8528f5039b
commit f26b43f8a5
16 changed files with 36 additions and 29 deletions

View file

@ -58,7 +58,7 @@ module.exports = GPlusHandler = class GPlusHandler extends CocoClass
console.error 'Unable to save G+ token key', e
@accessToken = e
@trigger 'logged-in'
loginCodeCombat: ->
# email and profile data loaded separately
gapi.client.request(path: plusURL, callback: @onPersonEntityReceived)
@ -71,7 +71,8 @@ module.exports = GPlusHandler = class GPlusHandler extends CocoClass
for gpProp, userProp of userPropsToSave
keys = gpProp.split('.')
value = r
value = value[key] for key in keys
for key in keys
value = value[key]
if value and not me.get(userProp)
@shouldSave = true
me.set(userProp, value)

View file

@ -62,9 +62,9 @@ module.exports = class SpriteParser
break
continue unless container.bounds and instructions.length
@addContainer {c: instructions, b: container.bounds}, container.name
childrenMovieClips = []
for movieClip, index in movieClips
lastBounds = null
# fill in bounds which are null...
@ -73,7 +73,7 @@ module.exports = class SpriteParser
movieClip.frameBounds[boundsIndex] = _.clone(lastBounds)
else
lastBounds = bounds
localGraphics = @getGraphicsFromBlock(movieClip, source)
[shapeKeys, localShapes] = @getShapesFromBlock movieClip, source
localContainers = @getContainersFromMovieClip movieClip, source, true
@ -90,7 +90,7 @@ module.exports = class SpriteParser
bounds: movieClip.bounds
frameBounds: movieClip.frameBounds
}, movieClip.name
for movieClip in movieClips
if movieClip.name not in childrenMovieClips
for bounds in movieClip.frameBounds
@ -390,7 +390,7 @@ module.exports = class SpriteParser
name = node.callee.property?.name
return unless name in ['get', 'to', 'wait']
return if name is 'get' and callExpressions.length # avoid Ease calls in the tweens
flattenedRanges = _.flatten [a.range for a in node.arguments]
flattenedRanges = _.flatten [(a.range for a in node.arguments)]
range = [_.min(flattenedRanges), _.max(flattenedRanges)]
# Replace 'this.<local>' references with just the 'name'
argsSource = @subSourceFromRange(range, source)

View file

@ -326,7 +326,7 @@ module.exports = Lank = class Lank extends CocoClass
newScaleFactorX = @thang?.scaleFactorX ? @thang?.scaleFactor ? 1
newScaleFactorY = @thang?.scaleFactorY ? @thang?.scaleFactor ? 1
if @thang?.spriteName is 'Beam'
if @layer?.name is 'Land' or @thang?.spriteName is 'Beam'
@scaleFactorX = newScaleFactorX
@scaleFactorY = newScaleFactorY
else if @thang and (newScaleFactorX isnt @targetScaleFactorX or newScaleFactorY isnt @targetScaleFactorY)

View file

@ -65,12 +65,12 @@ module.exports = class SingularSprite extends createjs.Sprite
@regY = -reg.y * scale
@scaleX = @scaleY = 1 / @resolutionFactor
if @camera and @thangType.get('name') in floors
@baseScaleY *= @camera.y2x
@scaleX *= -1 if action.flipX
@scaleY *= -1 if action.flipY
@baseScaleX = @scaleX
@baseScaleY = @scaleY
if @camera and @thangType.get('name') in floors
@baseScaleY *= @camera.y2x
@currentAnimation = actionName
return

View file

@ -46,7 +46,8 @@ module.exports = class System
hashString: (s) ->
return @hashes[s] if s of @hashes
hash = 0
hash = hash * 31 + s.charCodeAt(i) for i in [0 ... Math.min(s.length, 100)]
for i in [0 ... Math.min(s.length, 100)]
hash = hash * 31 + s.charCodeAt(i)
hash = @hashes[s] = hash % 3.141592653589793
hash

View file

@ -9,10 +9,11 @@ block content
li.active(data-i18n="#{currentEditor}")
| #{currentEditor}
if me.get('anonymous')
a.btn.btn-primary.open-modal-button(data-toggle="coco-modal", data-target="core/AuthModal", role="button", data-i18n="#{currentNewSignup}") Log in to Create a New Content
else
a.btn.btn-primary.open-modal-button#new-model-button(data-i18n="#{currentNew}") Create a New Something
if me.isAdmin() || !newModelsAdminOnly
if me.get('anonymous')
a.btn.btn-primary.open-modal-button(data-toggle="coco-modal", data-target="core/AuthModal", role="button", data-i18n="#{currentNewSignup}") Log in to Create a New Something
else
a.btn.btn-primary.open-modal-button#new-model-button(data-i18n="#{currentNew}") Create a New Something
input#search(data-i18n="[placeholder]#{currentSearch}")
hr
div.results

View file

@ -92,9 +92,9 @@ block header
li(class=anonymous ? "disabled": "")
a(data-i18n="common.fork")#fork-start-button Fork
li(class=anonymous ? "disabled": "")
a(data-toggle="coco-modal", data-target="modal/RevertModal", data-i18n="editor.revert")#revert-button Revert
a(data-toggle="coco-modal", data-target="modal/RevertModal", data-i18n="editor.revert", disabled=anonymous)#revert-button Revert
li(class=anonymous ? "disabled": "")
a(data-toggle="coco-modal", data-target="editor/level/modals/GenerateTerrainModal", data-i18n="editor.generate_terrain").generate-terrain-button Generate Terrain
a(data-toggle="coco-modal", data-target="editor/level/modals/GenerateTerrainModal", data-i18n="editor.generate_terrain", disabled=anonymous).generate-terrain-button Generate Terrain
li(class=anonymous ? "disabled": "")
a(data-i18n="editor.pop_i18n")#pop-level-i18n-button Populate i18n
li.divider

View file

@ -52,11 +52,11 @@ block header
span.glyphicon-chevron-down.glyphicon
ul.dropdown-menu
li.dropdown-header(data-i18n="common.actions") Actions
li(class=anonymous ? "disabled": "")
li(class=!me.isAdmin() ? "disabled": "")
a(data-i18n="common.fork")#fork-start-button Fork
li(class=anonymous ? "disabled": "")
a(data-toggle="coco-modal", data-target="modal/RevertModal", data-i18n="editor.revert")#revert-button Revert
li(class=anonymous ? "disabled": "")
li(class=!authorized ? "disabled": "")
a(data-toggle="coco-modal", data-target="modal/RevertModal", data-i18n="editor.revert", disabled=!authorized)#revert-button Revert
li(class=!authorized ? "disabled": "")
a(data-i18n="editor.pop_i18n")#pop-level-i18n-button Populate i18n
li.divider
li.dropdown-header(data-i18n="common.info") Info

View file

@ -199,6 +199,7 @@ module.exports = class CocoView extends Backbone.View
# special handler for opening modals that are dynamically loaded, rather than static in the page. It works (or should work) like Bootstrap's modals, except use coco-modal for the data-toggle value.
elem = $(e.target)
return unless elem.data('toggle') is 'coco-modal'
return if elem.attr('disabled')
target = elem.data('target')
Modal = require 'views/'+target
e.stopPropagation()

View file

@ -6,7 +6,6 @@ module.exports = class ForkModal extends ModalView
id: 'fork-modal'
template: template
instant: false
modalWidthPercent: 60
events:
'click #fork-model-confirm-button': 'forkModel'

View file

@ -14,6 +14,7 @@ module.exports = class AchievementSearchView extends SearchView
context.currentNew = 'editor.new_achievement_title'
context.currentNewSignup = 'editor.new_achievement_title_login'
context.currentSearch = 'editor.achievement_search_title'
context.newModelsAdminOnly = true
context.unauthorized = true unless me.isAdmin()
@$el.i18n()
context

View file

@ -14,5 +14,6 @@ module.exports = class ArticleSearchView extends SearchView
context.currentNew = 'editor.new_article_title'
context.currentNewSignup = 'editor.new_article_title_login'
context.currentSearch = 'editor.article_search_title'
context.newModelsAdminOnly = true
@$el.i18n()
context

View file

@ -40,7 +40,7 @@ module.exports = class LevelEditView extends RootView
'click .play-with-team-button': 'onPlayLevel'
'click .play-with-team-parent': 'onPlayLevelTeamSelect'
'click #commit-level-start-button': 'startCommittingLevel'
'click #fork-start-button': 'startForking'
'click li:not(.disabled) > #fork-start-button': 'startForking'
'click #level-history-button': 'showVersionHistory'
'click #undo-button': 'onUndo'
'mouseenter #undo-button': 'showUndoDescription'
@ -50,7 +50,7 @@ module.exports = class LevelEditView extends RootView
'click #components-tab': -> @subviews.editor_level_components_tab_view.refreshLevelThangsTreema @level.get('thangs')
'click #level-patch-button': 'startPatchingLevel'
'click #level-watch-button': 'toggleWatchLevel'
'click #pop-level-i18n-button': 'onPopulateI18N'
'click li:not(.disabled) > #pop-level-i18n-button': 'onPopulateI18N'
'click a[href="#editor-level-documentation"]': 'onClickDocumentationTab'
'mouseup .nav-tabs > li a': 'toggleTab'
@ -66,7 +66,7 @@ module.exports = class LevelEditView extends RootView
showLoading: ($el) ->
$el ?= @$el.find('.outer-content')
super($el)
getTitle: -> "LevelEditor - " + (@level.get('name') or '...')
onLoaded: ->
@ -170,7 +170,7 @@ module.exports = class LevelEditView extends RootView
button = @$el.find('#level-watch-button')
@level.watch(button.find('.watch').is(':visible'))
button.find('> span').toggleClass('secret')
onPopulateI18N: ->
@level.populateI18N()
f = -> document.location.reload()

View file

@ -45,13 +45,13 @@ module.exports = class ThangTypeEditView extends RootView
'click #stop-button': 'stopAnimation'
'click #play-button': 'playAnimation'
'click #history-button': 'showVersionHistory'
'click #fork-start-button': 'startForking'
'click li:not(.disabled) > #fork-start-button': 'startForking'
'click #save-button': 'openSaveModal'
'click #patches-tab': -> @patchesView.load()
'click .play-with-level-button': 'onPlayLevel'
'click .play-with-level-parent': 'onPlayLevelSelect'
'keyup .play-with-level-input': 'onPlayLevelKeyUp'
'click #pop-level-i18n-button': 'onPopulateLevelI18N'
'click li:not(.disabled) > #pop-level-i18n-button': 'onPopulateLevelI18N'
onClickSetVectorIcon: ->

View file

@ -15,6 +15,7 @@ module.exports = class ThangTypeSearchView extends SearchView
context.currentNew = 'editor.new_thang_title'
context.currentNewSignup = 'editor.new_thang_title_login'
context.currentSearch = 'editor.thang_search_title'
context.newModelsAdminOnly = true
@$el.i18n()
context

View file

@ -312,7 +312,8 @@ module.exports = class SpellView extends CocoView
# Lock contiguous section of default code
# Only works for languages without closing delimeters on blocks currently
lines = @aceDoc.getAllLines()
lastRow = row for line, row in lines when not /^\s*$/.test(line)
for line, row in lines when not /^\s*$/.test(line)
lastRow = row
if lastRow?
@readOnlyRanges.push new Range 0, 0, lastRow, lines[lastRow].length - 1