Merge branch 'master' into feature/defaults

This commit is contained in:
Scott Erickson 2014-08-28 15:26:04 -07:00
commit 2dde77f8b0
27 changed files with 77 additions and 85 deletions

View file

@ -17,7 +17,7 @@ module.exports = initializeFacebook = ->
if response.status is 'connected'
# They have logged in to the app.
Backbone.Mediator.publish 'facebook-logged-in', response: response
Backbone.Mediator.publish 'auth:logged-in-with-facebook', response: response
else if response.status is 'not_authorized'
#

View file

@ -53,6 +53,7 @@ module.exports = class CoordinateDisplay extends createjs.Container
wop = @camera.screenToWorld x: e.x, y: e.y
wop.x = Math.round wop.x
wop.y = Math.round wop.y
Backbone.Mediator.publish 'tome:focus-editor', {}
Backbone.Mediator.publish 'surface:coordinate-selected', wop
onZoomUpdated: (e) ->

View file

@ -26,7 +26,6 @@ module.exports = class Dimmer extends CocoClass
build: ->
@dimLayer = new createjs.Container()
@dimLayer.mouseEnabled = @dimLayer.mouseChildren = false
@dimLayer.layerIndex = -10
@dimLayer.addChild @dimScreen = new createjs.Shape()
@dimLayer.addChild @dimMask = new createjs.Shape()
@dimScreen.graphics.beginFill('rgba(0,0,0,0.5)').rect 0, 0, @camera.canvasWidth, @camera.canvasHeight

View file

@ -45,6 +45,13 @@ module.exports = class Mark extends CocoClass
@mark.visible = true
@
setLayer: (layer) ->
return if layer is @layer
wasOn = @on
@toggle false
@layer = layer
@toggle true if wasOn
setSprite: (sprite) ->
return if sprite is @sprite
@sprite = sprite
@ -131,7 +138,6 @@ module.exports = class Mark extends CocoClass
@mark.graphics.endFill()
@mark.regX = width / 2
@mark.regY = height / 2
@mark.layerIndex = 10
@mark.cache -1, -1, width + 2, height + 2 # not actually faster than simple ellipse draw
buildRadius: (range) ->

View file

@ -15,7 +15,6 @@ module.exports = class PlaybackOverScreen extends CocoClass
build: ->
@dimLayer = new createjs.Container()
@dimLayer.mouseEnabled = @dimLayer.mouseChildren = false
@dimLayer.layerIndex = -12
@dimLayer.addChild @dimScreen = new createjs.Shape()
@dimScreen.graphics.beginFill('rgba(0,0,0,0.4)').rect 0, 0, @camera.canvasWidth, @camera.canvasHeight
@dimLayer.cache 0, 0, @camera.canvasWidth, @camera.canvasHeight

View file

@ -21,7 +21,6 @@ module.exports = class PointChooser extends CocoClass
@shape.mouseEnabled = false
@shape.graphics.setStrokeStyle(1, 'round').beginStroke('#000000').beginFill('#fedcba')
@shape.graphics.drawCircle(0, 0, 4).endFill()
@shape.layerIndex = 100
onMouseDown: (e) =>
return unless key.shift

View file

@ -373,6 +373,11 @@ module.exports = class SpriteBoss extends CocoClass
@updateTarget()
return unless @selectionMark
@selectedSprite = null if @selectedSprite and (@selectedSprite.destroyed or not @selectedSprite.thang)
# The selection mark should be on the ground layer, unless we're not a normal sprite (like a wall), in which case we'll place it higher so we can see it.
if @selectedSprite and @selectedSprite.imageObject.parent isnt @spriteLayers.Default
@selectionMark.setLayer @spriteLayers.Default
else if @selectedSprite
@selectionMark.setLayer @spriteLayers.Ground
@selectionMark.toggle @selectedSprite?
@selectionMark.setSprite @selectedSprite
@selectionMark.update()

View file

@ -424,7 +424,7 @@ module.exports = Surface = class Surface extends CocoClass
oldHeight = parseInt @canvas.attr('height'), 10
aspectRatio = oldWidth / oldHeight
pageWidth = $('#page-container').width() - 17 # 17px nano scroll bar
if @realTime
if @realTime or @options.spectateGame
pageHeight = $('#page-container').height() - $('#control-bar-view').outerHeight() - $('#playback-view').outerHeight()
newWidth = Math.min pageWidth, pageHeight * aspectRatio
newHeight = newWidth / aspectRatio
@ -483,11 +483,13 @@ module.exports = Surface = class Surface extends CocoClass
worldPos = @camera.screenToWorld x: e.stageX, y: e.stageY
event = onBackground: onBackground, x: e.stageX, y: e.stageY, originalEvent: e, worldPos: worldPos
Backbone.Mediator.publish 'surface:stage-mouse-down', event
Backbone.Mediator.publish 'tome:focus-editor', {}
onMouseUp: (e) =>
return if @disabled
onBackground = not @stage.hitTest e.stageX, e.stageY
Backbone.Mediator.publish 'surface:stage-mouse-up', onBackground: onBackground, x: e.stageX, y: e.stageY, originalEvent: e
Backbone.Mediator.publish 'tome:focus-editor', {}
onMouseWheel: (e) =>
# https://github.com/brandonaaron/jquery-mousewheel

View file

@ -126,8 +126,8 @@ module.exports = nativeDescription: "Português (Portugal)", englishDescription:
level_difficulty: "Dificuldade: "
play_as: "Jogar Como"
spectate: "Espectar"
# players: "players"
# hours_played: "hours played"
players: "jogadores"
hours_played: "horas jogadas"
contact:
contact_us: "Contacte o CodeCombat"
@ -513,7 +513,7 @@ module.exports = nativeDescription: "Português (Portugal)", englishDescription:
toggle_grid: "Ativar/desativar a sobreposição da grelha."
toggle_pathfinding: "Ativar/desativar a sobreposição do encontrador de caminho."
beautify: "Embelezar o código ao estandardizar a formatação."
# maximize_editor: "Maximize/minimize code editor."
maximize_editor: "Maximizar/minimizar o editor de código."
move_wizard: "Mover o seu Feiticeiro pelo nível."
admin:
@ -910,7 +910,7 @@ module.exports = nativeDescription: "Português (Portugal)", englishDescription:
unknown: "Erro desconhecido."
resources:
# sessions: "Sessions"
sessions: "Sessões"
your_sessions: "As Suas Sessões"
level: "Nível"
social_network_apis: "APIs das Redes Sociais"
@ -926,7 +926,7 @@ module.exports = nativeDescription: "Português (Portugal)", englishDescription:
patched_model: "Documento Fonte"
model: "Modelo"
system: "Sistema"
# systems: "Systems"
systems: "Sistemas"
component: "Componente"
components: "Componentes"
thang: "Thang"
@ -941,16 +941,16 @@ module.exports = nativeDescription: "Português (Portugal)", englishDescription:
source_document: "Documento Fonte"
document: "Documento"
sprite_sheet: "Folha de Sprite"
# employers: "Employers"
# candidates: "Candidates"
employers: "Empregadores"
candidates: "Candidatos"
candidate_sessions: "Sessões de Candidatos"
user_remark: "Observação do Utilizador"
# user_remarks: "User Remarks"
user_remarks: "Observações de Utilizador"
versions: "Versões"
items: "Itens"
# wizard: "Wizard"
# achievement: "Achievement"
# clas: "CLAs"
wizard: "Feiticeiro"
achievement: "Conquista"
clas: "CLAs"
# play_counts: "Play Counts"
delta:

View file

@ -210,6 +210,11 @@ class CocoModel extends Backbone.Model
return false
getOwner: ->
return null unless permissions = @get 'permissions'
ownerPermission = _.find permissions, access: 'owner'
ownerPermission?.target
getDelta: ->
differ = deltasLib.makeJSONDiffer()
differ.diff @_revertAttributes, @attributes

View file

@ -23,5 +23,5 @@ module.exports =
bus: {$ref: 'bus'}
'bus:player-states-changed': c.object {title: 'Player state changes', description: 'State of the players has changed'},
states: c.array {}, {type: 'object'}
states: {type: 'object', additionalProperties: {type: 'object'}}
bus: {$ref: 'bus'}

View file

@ -22,7 +22,7 @@ module.exports =
'router:navigate': c.object {required: ['route']},
route: {type: 'string'}
view: {type: 'object'}
viewClass: {type: 'object'}
viewClass: {type: 'function'}
viewArgs: {type: 'array'}
'achievements:new': c.object {required: 'earnedAchievements'},

View file

@ -66,6 +66,7 @@ module.exports = # /app/lib/surface
'surface:coordinate-selected': c.object {required: ['x', 'y']},
x: {type: 'number'}
y: {type: 'number'}
z: {type: 'number'}
'surface:coordinates-shown': c.object {}

View file

@ -16,6 +16,9 @@
overflow: hidden
text-overflow: ellipsis
tr.mine
background-color: #f8ecaa
.loading
text-align: center

View file

@ -38,17 +38,12 @@
margin: 0px auto
#canvas-wrapper
height: 100%
width: 100%
position: relative
margin: 0 auto
canvas#surface
background-color: #333
max-height: 93%
max-height: -webkit-calc(100% - 60px)
max-height: calc(100% - 60px)
height: auto
max-width: 100%
display: block
z-index: 1
margin: 0 auto

View file

@ -1,21 +1 @@
table.table
tr
th(colspan=3)
span(data-i18n="general.results")
| Results
span
|: #{documents.length}
tr
th(data-i18n="general.name") Name
th(data-i18n="general.description") Description
th(data-i18n="general.version") Version
for data in documents
- data = data.attributes;
tr
td
a(href="/editor/article/#{data.slug || data._id}")
| #{data.name}
td.body-row #{data.description}
td #{data.version.major}.#{data.version.minor}
extends /templates/kinds/table

View file

@ -1,21 +1 @@
table.table
tr
th(colspan=3)
span(data-i18n="general.results")
| Results
span
|: #{documents.length}
tr
th(data-i18n="general.name") Name
th(data-i18n="general.description") Description
th(data-i18n="general.version") Version
for data in documents
- data = data.attributes;
tr
td
a(href="/editor/level/#{data.slug || data._id}")
| #{data.name}
td.body-row #{data.description}
td #{data.version.major}.#{data.version.minor}
extends /templates/kinds/table

View file

@ -1,17 +1,21 @@
table.table
extends /templates/kinds/table
block tableResultsHeader
tr
th(colspan=3)
th(colspan=4)
span(data-i18n="general.results")
| Results
span
|: #{documents.length}
block tableHeader
tr
th#portrait-col
th(data-i18n="general.name") Name
th(data-i18n="general.description") Description
th(data-i18n="general.version") Version
block tableBody
for thang in documents
tr
td

View file

@ -1,10 +1,11 @@
table.table
tr
th(colspan=3)
span(data-i18n="general.results")
| Results
span
|: #{documents.length}
block tableResultsHeader
tr
th(colspan=3)
span(data-i18n="general.results")
| Results
span
|: #{documents.length}
block tableHeader
tr
@ -13,9 +14,9 @@ table.table
th(data-i18n="general.version") Version
block tableBody
for data in documents
- data = data.attributes;
tr
for document in documents
- var data = document.attributes;
tr(class=document.getOwner() == me.id ? 'mine' : '')
td
a(href="/editor/#{page}/#{data.slug || data._id}")
| #{data.name}

View file

@ -3,7 +3,7 @@
.level-content
#control-bar-view
#canvas-wrapper
canvas(width=1848, height=1178)#surface
canvas(width=924, height=589)#surface
#canvas-left-gradient.gradient
#canvas-top-gradient.gradient
#gold-view.secret.expanded

View file

@ -6,6 +6,7 @@ module.exports = class ArticleSearchView extends SearchView
model: require 'models/Article'
modelURL: '/db/article'
tableTemplate: require 'templates/editor/article/table'
page: 'article'
getRenderData: ->
context = super()

View file

@ -6,6 +6,7 @@ module.exports = class LevelSearchView extends SearchView
model: require 'models/Level'
modelURL: '/db/level'
tableTemplate: require 'templates/editor/level/table'
page: 'level'
getRenderData: ->
context = super()

View file

@ -7,6 +7,7 @@ module.exports = class ThangTypeSearchView extends SearchView
modelURL: '/db/thang.type'
tableTemplate: require 'templates/editor/thang/table'
projection: ['original', 'name', 'version', 'description', 'slug', 'kind', 'rasterIcon']
page: 'thang'
getRenderData: ->
context = super()

View file

@ -7,11 +7,19 @@ class SearchCollection extends Backbone.Collection
initialize: (modelURL, @model, @term, @projection) ->
@url = "#{modelURL}?project="
if @projection? and not (@projection == [])
@url += projection[0]
@url += ',' + projected for projected in projection[1..]
@url += 'created,permissions'
@url += ',' + projected for projected in projection
else @url += 'true'
@url += "&term=#{term}" if @term
comparator: (a, b) ->
score = 0
score -= 9001900190019001 if a.getOwner() is me.id
score += 9001900190019001 if b.getOwner() is me.id
score -= new Date(a.get 'created')
score -= -(new Date(b.get 'created'))
if score < 0 then -1 else (if score > 0 then 1 else 0)
module.exports = class SearchView extends RootView
template: template
className: 'search-view'
@ -67,8 +75,9 @@ module.exports = class SearchView extends RootView
onSearchChange: ->
@hideLoading()
@collection.sort()
documents = @collection.models
table = $(@tableTemplate(documents:documents))
table = $(@tableTemplate(documents: documents, me: me, page: @page))
@$el.find('table').replaceWith(table)
@$el.find('table').i18n()

View file

@ -50,10 +50,11 @@ module.exports = class WizardSettingsModal extends ModalView
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()
@hide() unless @destroyed
@enableModalInProgress(@$el)

View file

@ -221,7 +221,6 @@ module.exports = class SpectateLevelView extends RootView
else
console.log 'World scripts don\'t exist!'
nonVictoryPlaybackScripts = []
console.log nonVictoryPlaybackScripts
@scriptManager = new ScriptManager({scripts: nonVictoryPlaybackScripts, view:@, session: @session})
@scriptManager.loadFromSession()

View file

@ -7,7 +7,7 @@ Patch = require '../patches/Patch'
User = require '../users/User'
sendwithus = require '../sendwithus'
PROJECT = {original: 1, name: 1, version: 1, description: 1, slug: 1, kind: 1}
PROJECT = {original: 1, name: 1, version: 1, description: 1, slug: 1, kind: 1, created: 1, permissions: 1}
FETCH_LIMIT = 300
module.exports = class Handler