Don't require CocoModel instantiation before schemas are included. Reload neutral spells on reload. Fix for adding Components to Thangs. Surface background: darkness, no parents.

This commit is contained in:
Nick Winter 2014-04-22 11:11:08 -07:00
parent 1e50ef36ce
commit 675db1b76f
16 changed files with 32 additions and 22 deletions

View file

@ -2,5 +2,6 @@ CocoModel = require('./CocoModel')
module.exports = class Article extends CocoModel
@className: "Article"
@schema: require 'schemas/models/article'
urlRoot: "/db/article"
saveBackups: true

View file

@ -11,7 +11,6 @@ class CocoModel extends Backbone.Model
initialize: ->
super()
@constructor.schema ?= require "schemas/models/#{@urlRoot[4..].replace '.', '_'}"
if not @constructor.className
console.error("#{@} needs a className set.")
@markToRevert()

View file

@ -2,4 +2,5 @@ CocoModel = require('./CocoModel')
module.exports = class File extends CocoModel
@className: "File"
@schema: require 'schemas/models/file'
urlRoot: "/db/file"

View file

@ -5,6 +5,7 @@ ThangType = require './ThangType'
module.exports = class Level extends CocoModel
@className: "Level"
@schema: require 'schemas/models/level'
urlRoot: "/db/level"
serialize: (supermodel) ->

View file

@ -2,6 +2,7 @@ CocoModel = require('./CocoModel')
module.exports = class LevelComponent extends CocoModel
@className: "LevelComponent"
@schema: require 'schemas/models/level_component'
urlRoot: "/db/level.component"
set: (key, val, options) ->

View file

@ -2,4 +2,5 @@ CocoModel = require('./CocoModel')
module.exports = class LevelFeedback extends CocoModel
@className: "LevelFeedback"
@schema: require 'schemas/models/level_feedback'
urlRoot: "/db/level.feedback"

View file

@ -2,6 +2,7 @@ CocoModel = require('./CocoModel')
module.exports = class LevelSession extends CocoModel
@className: "LevelSession"
@schema: require 'schemas/models/level_session'
urlRoot: "/db/level.session"
initialize: ->

View file

@ -3,6 +3,7 @@ SystemNameLoader = require('lib/SystemNameLoader')
module.exports = class LevelSystem extends CocoModel
@className: "LevelSystem"
@schema: require 'schemas/models/level_system'
urlRoot: "/db/level.system"
set: (key, val, options) ->

View file

@ -2,6 +2,7 @@ CocoModel = require('./CocoModel')
module.exports = class PatchModel extends CocoModel
@className: "Patch"
@schema: require 'schemas/models/patch'
urlRoot: "/db/patch"
setStatus: (status) ->

View file

@ -5,6 +5,7 @@ buildQueue = []
module.exports = class ThangType extends CocoModel
@className: "ThangType"
@schema: require 'schemas/models/thang_type'
urlRoot: "/db/thang.type"
building: {}

View file

@ -4,6 +4,7 @@ CocoModel = require('./CocoModel')
module.exports = class User extends CocoModel
@className: "User"
@schema: require 'schemas/models/user'
urlRoot: "/db/user"
initialize: ->

View file

@ -1,5 +1,5 @@
c = require './../schemas'
ThangComponentSchema = require './../models/thang_component'
ThangComponentSchema = require './thang_component'
SpecificArticleSchema = c.object()
c.extendNamedProperties SpecificArticleSchema # name first

View file

@ -18,7 +18,7 @@ body.is-playing
position: relative
canvas#surface
background-color: #ddd
background-color: #333
width: 100%
display: block
z-index: 1

View file

@ -156,17 +156,18 @@ module.exports = class ThangComponentEditView extends CocoView
@reportChanges()
onAddComponentEnterPressed: (node) =>
extantSystems =
(@supermodel.getModelByOriginalAndMajorVersion LevelSystem, sn.original, sn.majorVersion).attributes.name.toLowerCase() for idx, sn of @level.get('systems')
requireSystem = node.data.system.toLowerCase()
if extantSystems
extantSystems =
(@supermodel.getModelByOriginalAndMajorVersion LevelSystem, sn.original, sn.majorVersion).attributes.name.toLowerCase() for idx, sn of @level.get('systems')
requireSystem = node.data.system.toLowerCase()
if requireSystem not in extantSystems
warn_element = 'Component <b>' + node.data.name + '</b> requires system <b>' + requireSystem + '</b> which is currently not specified in this level.'
noty({
text: warn_element,
layout: 'bottomLeft',
type: 'warning'
})
if requireSystem not in extantSystems
warn_element = 'Component <b>' + node.data.name + '</b> requires system <b>' + requireSystem + '</b> which is currently not specified in this level.'
noty({
text: warn_element,
layout: 'bottomLeft',
type: 'warning'
})
currentSelection = @addComponentsTreema?.getLastSelectedTreema()?.data._id

View file

@ -112,7 +112,7 @@ module.exports = class PlaybackView extends View
@$el.find('.toggle-fullscreen').hide()
updatePopupContent: ->
@timePopup.updateContent "<h2>#{@timeToString @newTime}</h2>#{@formatTime(@current, @currentTime)}<br/>#{@formatTime(@total, @totalTime)}"
@timePopup?.updateContent "<h2>#{@timeToString @newTime}</h2>#{@formatTime(@current, @currentTime)}<br/>#{@formatTime(@total, @totalTime)}"
# These functions could go to some helper class

View file

@ -222,7 +222,7 @@ module.exports = class TomeView extends View
@spellPaletteView.toggleControls {}, spell.view.controlsEnabled # TODO: know when palette should have been disabled but didn't exist
reloadAllCode: ->
spell.view.reloadCode false for spellKey, spell of @spells when spell.team is me.team
spell.view.reloadCode false for spellKey, spell of @spells when spell.team is me.team or (spell.team in ["common", "neutral", null])
Backbone.Mediator.publish 'tome:cast-spells', spells: @spells
updateLanguageForAllSpells: ->