Merge branch 'master' into production

This commit is contained in:
Nick Winter 2014-11-29 17:35:41 -08:00
commit 0d4a384787
25 changed files with 62 additions and 61 deletions

View file

@ -59,15 +59,25 @@ module.exports = ModuleLoader = class ModuleLoader extends CocoClass
onFileLoad: (e) => onFileLoad: (e) =>
$("#module-loading-list li[data-path='#{e.item.id}']").removeClass('loading').addClass('success') $("#module-loading-list li[data-path='#{e.item.id}']").removeClass('loading').addClass('success')
have = window.require.list()
console.group('Dependencies', e.item.id) if LOG # load dependencies if it's not a vendor library
@recentLoadedBytes += e.rawResult.length if not _.string.startsWith(e.item.id, 'vendor')
dependencies = @parseDependencies(e.rawResult) have = window.require.list()
console.groupEnd() if LOG console.group('Dependencies', e.item.id) if LOG
missing = _.difference dependencies, have @recentLoadedBytes += e.rawResult.length
@load(module, false) for module in missing dependencies = @parseDependencies(e.rawResult)
locale.update() if _.string.startsWith(e.item.id, 'locale') console.groupEnd() if LOG
missing = _.difference dependencies, have
@load(module, false) for module in missing
# update locale data
if _.string.startsWith(e.item.id, 'locale')
locale.update()
# just a bit of cleanup to get the script objects out of the body element
$(e.result).remove() $(e.result).remove()
# a module and its dependencies have loaded!
if @queue.progress is 1 if @queue.progress is 1
$('#module-loading-list').modal('hide') $('#module-loading-list').modal('hide')
@recentPaths.sort() @recentPaths.sort()
@ -96,6 +106,7 @@ module.exports = ModuleLoader = class ModuleLoader extends CocoClass
console.groupEnd() if LOG console.groupEnd() if LOG
return dependencies return dependencies
# basically ripped out of commonjs definition
expand: (root, name) -> expand: (root, name) ->
results = [] results = []
if /^\.\.?(\/|$)/.test(name) if /^\.\.?(\/|$)/.test(name)

View file

@ -84,8 +84,8 @@ module.exports = class CocoRouter extends Backbone.Router
'play-old': go('play/MainPlayView') # This used to be 'play'. 'play-old': go('play/MainPlayView') # This used to be 'play'.
'play': go('play/WorldMapView') 'play': go('play/WorldMapView')
'play/ladder/:levelID': go('play/ladder/LadderView') 'play/ladder/:levelID': go('ladder/LadderView')
'play/ladder': go('play/ladder/MainLadderView') 'play/ladder': go('ladder/MainLadderView')
'play/level/:levelID': go('play/level/PlayLevelView') 'play/level/:levelID': go('play/level/PlayLevelView')
'play/spectate/:levelID': go('play/SpectateView') 'play/spectate/:levelID': go('play/SpectateView')
'play/:map': go('play/WorldMapView') 'play/:map': go('play/WorldMapView')
@ -185,6 +185,14 @@ module.exports = class CocoRouter extends Backbone.Router
window.tracker?.trackPageView() window.tracker?.trackPageView()
onNavigate: (e) -> onNavigate: (e) ->
if _.isString e.viewClass
ViewClass = @tryToLoadModule e.viewClass
if not ViewClass and application.moduleLoader.load(e.viewClass)
@listenToOnce application.moduleLoader, 'load-complete', ->
@onNavigate(e)
return
e.viewClass = ViewClass
manualView = e.view or e.viewClass manualView = e.view or e.viewClass
if (e.route is document.location.pathname) and not manualView if (e.route is document.location.pathname) and not manualView
return document.location.reload() return document.location.reload()

View file

@ -89,8 +89,8 @@ module.exports = class LevelSetupManager extends CocoClass
onInventoryModalPlayClicked: -> onInventoryModalPlayClicked: ->
@navigatingToPlay = true @navigatingToPlay = true
PlayLevelView = require 'views/play/level/PlayLevelView' PlayLevelView = 'views/play/level/PlayLevelView'
LadderView = require 'views/play/ladder/LadderView' LadderView = 'views/ladder/LadderView'
viewClass = if @options.levelPath is 'ladder' then LadderView else PlayLevelView viewClass = if @options.levelPath is 'ladder' then LadderView else PlayLevelView
Backbone.Mediator.publish 'router:navigate', { Backbone.Mediator.publish 'router:navigate', {
route: "/play/#{@options.levelPath || 'level'}/#{@options.levelID}" route: "/play/#{@options.levelPath || 'level'}/#{@options.levelID}"

View file

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

View file

@ -320,7 +320,7 @@ $itemSlotGridHeight: 51px
position: relative position: relative
width: 60px width: 60px
&:not(.equipped):not(.restricted):not(.silhouette) &:not(.equipped):not(.restricted)
cursor: pointer cursor: pointer
&:hover &:hover
@ -347,18 +347,6 @@ $itemSlotGridHeight: 51px
padding: 0 padding: 0
@include transition(0.1s ease) @include transition(0.1s ease)
.required-level
@include opacity(0)
@include transition(0.6s ease-in)
pointer-events: none
font-size: 14px
text-align: center
width: 100%
bottom: 20px
top: inherit
position: absolute
color: white
&.active &.active
background-color: rgb(81,153,236) background-color: rgb(81,153,236)
@ -402,16 +390,6 @@ $itemSlotGridHeight: 51px
&.locked:not(:hover) &.locked:not(:hover)
@include filter(contrast(75%)) @include filter(contrast(75%))
&.silhouette
img
@include filter(contrast(25%) brightness(25%))
opacity: 0.5
&:hover
.required-level
@include opacity(1)
text-shadow: 0 1px 0 black, 1px 0 0 black, 0 -1px 0 black, -1px 0 0 black
//- Hero/Play buttons //- Hero/Play buttons

View file

@ -270,14 +270,15 @@
.item-img .item-img
z-index: 1 z-index: 1
.item-shadow // Not performant, takes too much memory with filter.
left: 5px //.item-shadow
@include filter(contrast(0%) brightness(0%)) // left: 5px
opacity: 0.2 // @include filter(contrast(0%) brightness(0%))
// opacity: 0.2
.item-silhouette .item-silhouette
@include filter(contrast(0%) brightness(0%)) opacity: 0.2
opacity: 0.3 //@include filter(contrast(0%) brightness(0%))
.required-level .required-level
position: absolute position: absolute

View file

@ -50,10 +50,6 @@
for item in itemGroups.lockedItems.models for item in itemGroups.lockedItems.models
.item(class=item.classes, data-item-id=item.id) .item(class=item.classes, data-item-id=item.id)
img(src=item.getPortraitURL(), draggable="false") img(src=item.getPortraitURL(), draggable="false")
if item.level
.required-level
span(data-i18n="general.player_level")
span.spl= item.level
.clearfix .clearfix
#item-details-view #item-details-view

View file

@ -37,7 +37,6 @@
if item && !item.owned if item && !item.owned
if item.unequippable if item.unequippable
// Temp, while we only have Warriors: prevent them from buying non-Warrior stuff
button.btn.big-font.disabled.unequippable #{item.get('heroClass')} Only button.btn.big-font.disabled.unequippable #{item.get('heroClass')} Only
else else
button#selected-item-unlock-button.btn.big-font.unlock-button(data-item-id=item.id) button#selected-item-unlock-button.btn.big-font.unlock-button(data-item-id=item.id)

View file

@ -39,7 +39,7 @@
else else
strong.big-font= item.name strong.big-font= item.name
img.item-img(src=item.getPortraitURL(), draggable="false") img.item-img(src=item.getPortraitURL(), draggable="false")
img.item-shadow(src=item.getPortraitURL(), draggable="false") //img.item-shadow(src=item.getPortraitURL(), draggable="false") // Not performant, takes too much memory with filter
if item.owned if item.owned
span.big-font.owned(data-i18n="play.owned") span.big-font.owned(data-i18n="play.owned")
@ -50,7 +50,6 @@
img(src="/images/common/gem.png", draggable="false") img(src="/images/common/gem.png", draggable="false")
span.big-font= item.get('gems') span.big-font= item.get('gems')
if item.unequippable if item.unequippable
// Temp, while we only have Warriors: prevent them from buying non-Warrior stuff
span.big-font.unequippable= item.get('heroClass') span.big-font.unequippable= item.get('heroClass')
else else
button.btn.unlock-button.big-font(data-i18n="play.unlock", data-item-id=item.id) button.btn.unlock-button.big-font(data-i18n="play.unlock", data-item-id=item.id)

View file

@ -1,6 +1,8 @@
CocoView = require 'views/core/CocoView' CocoView = require 'views/core/CocoView'
template = require 'templates/editor/delta' template = require 'templates/editor/delta'
deltasLib = require 'core/deltas' deltasLib = require 'core/deltas'
require 'vendor/diffview'
require 'vendor/difflib'
TEXTDIFF_OPTIONS = TEXTDIFF_OPTIONS =
baseTextName: "Old" baseTextName: "Old"

View file

@ -26,6 +26,8 @@ SystemsDocumentationView = require 'views/editor/docs/SystemsDocumentationView'
LevelFeedbackView = require 'views/editor/level/LevelFeedbackView' LevelFeedbackView = require 'views/editor/level/LevelFeedbackView'
storage = require 'core/storage' storage = require 'core/storage'
require 'vendor/coffeescript' # this is tenuous, since the LevelSession and LevelComponent models are what compile the code
module.exports = class LevelEditView extends RootView module.exports = class LevelEditView extends RootView
id: 'editor-level-view' id: 'editor-level-view'
className: 'editor' className: 'editor'

View file

@ -55,7 +55,7 @@ module.exports = class LadderView extends RootView
ctx._ = _ ctx._ = _
if tournamentDate = {greed: 1402444800000, 'criss-cross': 1410912000000}[@levelID] if tournamentDate = {greed: 1402444800000, 'criss-cross': 1410912000000}[@levelID]
ctx.tournamentTimeLeft = moment(new Date(tournamentDate)).fromNow() ctx.tournamentTimeLeft = moment(new Date(tournamentDate)).fromNow()
ctx.winners = require('views/play/ladder/tournament_results')[@levelID] ctx.winners = require('./tournament_results')[@levelID]
ctx ctx
afterRender: -> afterRender: ->

View file

@ -63,18 +63,18 @@ module.exports = class ControlBarView extends CocoView
if @level.get('type', true) in ['ladder', 'ladder-tutorial', 'hero-ladder'] if @level.get('type', true) in ['ladder', 'ladder-tutorial', 'hero-ladder']
levelID = @level.get('slug').replace /\-tutorial$/, '' levelID = @level.get('slug').replace /\-tutorial$/, ''
@homeLink = c.homeLink = '/play/ladder/' + levelID @homeLink = c.homeLink = '/play/ladder/' + levelID
@homeViewClass = require 'views/play/ladder/LadderView' @homeViewClass = 'views/ladder/LadderView'
@homeViewArgs.push levelID @homeViewArgs.push levelID
else if @level.get('type', true) in ['hero', 'hero-coop'] else if @level.get('type', true) in ['hero', 'hero-coop']
@homeLink = c.homeLink = '/play' @homeLink = c.homeLink = '/play'
@homeViewClass = require 'views/play/WorldMapView' @homeViewClass = 'views/play/WorldMapView'
campaign = CampaignOptions.getCampaignForSlug @level.get 'slug' campaign = CampaignOptions.getCampaignForSlug @level.get 'slug'
if campaign isnt 'dungeon' if campaign isnt 'dungeon'
@homeLink += '/' + campaign @homeLink += '/' + campaign
@homeViewArgs.push campaign @homeViewArgs.push campaign
else else
@homeLink = c.homeLink = '/' @homeLink = c.homeLink = '/'
@homeViewClass = require 'views/HomeView' @homeViewClass = 'views/HomeView'
c.editorLink = "/editor/level/#{@level.get('slug')}" c.editorLink = "/editor/level/#{@level.get('slug')}"
c.homeLink = @homeLink c.homeLink = @homeLink
c c

View file

@ -340,6 +340,7 @@ module.exports = class PlayLevelView extends RootView
application.tracker?.trackEvent 'Started Level', category:'Play Level', levelID: @levelID application.tracker?.trackEvent 'Started Level', category:'Play Level', levelID: @levelID
playAmbientSound: -> playAmbientSound: ->
return if @destroyed
return if @ambientSound return if @ambientSound
return unless file = {Dungeon: 'ambient-dungeon', Grass: 'ambient-grass'}[@level.get('terrain')] return unless file = {Dungeon: 'ambient-dungeon', Grass: 'ambient-grass'}[@level.get('terrain')]
src = "/file/interface/#{file}#{AudioPlayer.ext}" src = "/file/interface/#{file}#{AudioPlayer.ext}"

View file

@ -260,7 +260,7 @@ module.exports = class HeroVictoryModal extends ModalView
onGameSubmitted: (e) -> onGameSubmitted: (e) ->
ladderURL = "/play/ladder/#{@level.get('slug')}#my-matches" ladderURL = "/play/ladder/#{@level.get('slug')}#my-matches"
# Preserve the supermodel as we navigate back to the ladder. # Preserve the supermodel as we navigate back to the ladder.
Backbone.Mediator.publish 'router:navigate', route: ladderURL, viewClass: require('views/play/ladder/LadderView'), viewArgs: [{supermodel: @supermodel}, @level.get('slug')] Backbone.Mediator.publish 'router:navigate', route: ladderURL, viewClass: 'views/ladder/LadderView', viewArgs: [{supermodel: @supermodel}, @level.get('slug')]
playSelectionSound: (hero, preload=false) -> playSelectionSound: (hero, preload=false) ->
return unless sounds = hero.get('soundTriggers')?.selected return unless sounds = hero.get('soundTriggers')?.selected
@ -324,4 +324,4 @@ module.exports = class HeroVictoryModal extends ModalView
e.preventDefault() e.preventDefault()
route = $(e.target).data('href') route = $(e.target).data('href')
# Preserve the supermodel as we navigate back to the ladder. # Preserve the supermodel as we navigate back to the ladder.
Backbone.Mediator.publish 'router:navigate', route: route, viewClass: require('views/play/ladder/LadderView'), viewArgs: [{supermodel: if @options.hasReceivedMemoryWarning then null else @supermodel}, @level.get('slug')] Backbone.Mediator.publish 'router:navigate', route: route, viewClass: 'views/ladder/LadderView', viewArgs: [{supermodel: if @options.hasReceivedMemoryWarning then null else @supermodel}, @level.get('slug')]

View file

@ -94,10 +94,12 @@ module.exports = class InventoryModal extends ModalView
if not item.getFrontFacingStats().props.length and not _.size(item.getFrontFacingStats().stats) and locked # Temp: while there are placeholder items if not item.getFrontFacingStats().props.length and not _.size(item.getFrontFacingStats().stats) and locked # Temp: while there are placeholder items
null # Don't put into a collection null # Don't put into a collection
else if locked and item.get('slug') isnt 'simple-boots' else if locked and item.get('slug') isnt 'simple-boots'
@itemGroups.lockedItems.add(item)
item.classes.push 'locked' item.classes.push 'locked'
item.classes.push 'silhouette' if item.isSilhouettedItem() if item.isSilhouettedItem or not item.get('gems')
item.classes.push 'hidden' unless item.get('gems') # Don't even load/show these--don't add to a collection. (Bandwidth optimization.)
null
else
@itemGroups.lockedItems.add(item)
else if item.get('slug') in _.values(LevelOptions[@options.levelID]?.restrictedGear ? {}) else if item.get('slug') in _.values(LevelOptions[@options.levelID]?.restrictedGear ? {})
@itemGroups.restrictedItems.add(item) @itemGroups.restrictedItems.add(item)
item.classes.push 'restricted' item.classes.push 'restricted'
@ -216,7 +218,6 @@ module.exports = class InventoryModal extends ModalView
onUnequippedItemClick: (e) -> onUnequippedItemClick: (e) ->
return if @justDoubleClicked return if @justDoubleClicked
itemEl = $(e.target).closest('.item') itemEl = $(e.target).closest('.item')
return if itemEl.hasClass('silhouette')
@playSound 'menu-button-click' @playSound 'menu-button-click'
@selectUnequippedItem(itemEl) @selectUnequippedItem(itemEl)

View file

@ -63,8 +63,8 @@ exports.config =
#- vendor.js, all the vendor libraries #- vendor.js, all the vendor libraries
'javascripts/vendor.js': [ 'javascripts/vendor.js': [
regJoin('^vendor/(?!scripts/Box2d)') regJoin('^vendor/scripts/(?!(Box2d|coffeescript))')
regJoin('^bower_components/(?!(aether|d3))') regJoin('^bower_components/(?!(aether|d3|difflib|diffview))')
] ]
#- Other vendor libraries in separate bunches #- Other vendor libraries in separate bunches
@ -78,6 +78,9 @@ exports.config =
# Any vendor libraries we don't want the client to load immediately # Any vendor libraries we don't want the client to load immediately
'javascripts/app/vendor/d3.js': regJoin('^bower_components/d3') 'javascripts/app/vendor/d3.js': regJoin('^bower_components/d3')
'javascripts/app/vendor/coffeescript.js': 'vendor/scripts/coffeescript.js'
'javascripts/app/vendor/difflib.js': 'vendor/scripts/difflib.js'
'javascripts/app/vendor/diffview.js': 'vendor/scripts/diffview.js'
#- test, demo libraries #- test, demo libraries
'javascripts/test-app.js': regJoin('^test/app/') 'javascripts/test-app.js': regJoin('^test/app/')