mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-28 06:54:13 -04:00
Better pointing out of submit button when victory is ready.
This commit is contained in:
parent
a57cc0126e
commit
c1023b137f
6 changed files with 54 additions and 21 deletions
app
assets/javascripts/workers
lib
schemas/subscriptions
styles/play/level/tome
views/play/level/tome
|
@ -363,7 +363,7 @@ self.runWorld = function runWorld(args) {
|
||||||
for(var key in replacedLoDash)
|
for(var key in replacedLoDash)
|
||||||
_[key] = replacedLoDash[key];
|
_[key] = replacedLoDash[key];
|
||||||
self.postMessage({type: 'start-load-frames'});
|
self.postMessage({type: 'start-load-frames'});
|
||||||
self.world.loadFrames(self.onWorldLoaded, self.onWorldError, self.onWorldLoadProgress);
|
self.world.loadFrames(self.onWorldLoaded, self.onWorldError, self.onWorldLoadProgress, self.onWorldPreloaded);
|
||||||
};
|
};
|
||||||
|
|
||||||
self.serializeFramesSoFar = function serializeFramesSoFar() {
|
self.serializeFramesSoFar = function serializeFramesSoFar() {
|
||||||
|
@ -378,8 +378,9 @@ self.onWorldLoaded = function onWorldLoaded() {
|
||||||
if(self.world.ended)
|
if(self.world.ended)
|
||||||
self.goalManager.worldGenerationEnded();
|
self.goalManager.worldGenerationEnded();
|
||||||
var goalStates = self.goalManager.getGoalStates();
|
var goalStates = self.goalManager.getGoalStates();
|
||||||
|
var overallStatus = self.goalManager.checkOverallStatus();
|
||||||
if(self.world.ended)
|
if(self.world.ended)
|
||||||
self.postMessage({type: 'end-load-frames', goalStates: goalStates});
|
self.postMessage({type: 'end-load-frames', goalStates: goalStates, overallStatus: overallStatus});
|
||||||
var t1 = new Date();
|
var t1 = new Date();
|
||||||
var diff = t1 - self.t0;
|
var diff = t1 - self.t0;
|
||||||
if (self.world.headless)
|
if (self.world.headless)
|
||||||
|
@ -416,6 +417,13 @@ self.onWorldLoaded = function onWorldLoaded() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.onWorldPreloaded = function onWorldPreloaded() {
|
||||||
|
self.goalManager.worldGenerationEnded();
|
||||||
|
var goalStates = self.goalManager.getGoalStates();
|
||||||
|
var overallStatus = self.goalManager.checkOverallStatus();
|
||||||
|
self.postMessage({type: 'end-preload-frames', goalStates: goalStates, overallStatus: overallStatus});
|
||||||
|
};
|
||||||
|
|
||||||
self.onWorldError = function onWorldError(error) {
|
self.onWorldError = function onWorldError(error) {
|
||||||
if(error.isUserCodeProblem) {
|
if(error.isUserCodeProblem) {
|
||||||
var errorKey = error.userInfo.key;
|
var errorKey = error.userInfo.key;
|
||||||
|
|
|
@ -66,7 +66,11 @@ module.exports = class Angel extends CocoClass
|
||||||
clearTimeout @condemnTimeout
|
clearTimeout @condemnTimeout
|
||||||
when 'end-load-frames'
|
when 'end-load-frames'
|
||||||
clearTimeout @condemnTimeout
|
clearTimeout @condemnTimeout
|
||||||
@beholdGoalStates event.data.goalStates # Work ends here if we're headless.
|
@beholdGoalStates event.data.goalStates, event.data.overallStatus # Work ends here if we're headless.
|
||||||
|
when 'end-preload-frames'
|
||||||
|
clearTimeout @condemnTimeout
|
||||||
|
@beholdGoalStates event.data.goalStates, event.data.overallStatus, true
|
||||||
|
|
||||||
|
|
||||||
# We have to abort like an infinite loop if we see one of these; they're not really recoverable
|
# We have to abort like an infinite loop if we see one of these; they're not really recoverable
|
||||||
when 'non-user-code-problem'
|
when 'non-user-code-problem'
|
||||||
|
@ -105,9 +109,9 @@ module.exports = class Angel extends CocoClass
|
||||||
else
|
else
|
||||||
@log 'Received unsupported message:', event.data
|
@log 'Received unsupported message:', event.data
|
||||||
|
|
||||||
beholdGoalStates: (goalStates) ->
|
beholdGoalStates: (goalStates, overallStatus, preload=false) ->
|
||||||
return if @aborting
|
return if @aborting
|
||||||
Backbone.Mediator.publish 'god:goals-calculated', goalStates: goalStates
|
Backbone.Mediator.publish 'god:goals-calculated', goalStates: goalStates, preload: preload, overallStatus: overallStatus
|
||||||
@finishWork() if @shared.headless
|
@finishWork() if @shared.headless
|
||||||
|
|
||||||
beholdWorld: (serialized, goalStates, startFrame, endFrame, streamingWorld) ->
|
beholdWorld: (serialized, goalStates, startFrame, endFrame, streamingWorld) ->
|
||||||
|
|
|
@ -92,11 +92,11 @@ module.exports = class World
|
||||||
(@runtimeErrors ?= []).push error
|
(@runtimeErrors ?= []).push error
|
||||||
(@unhandledRuntimeErrors ?= []).push error
|
(@unhandledRuntimeErrors ?= []).push error
|
||||||
|
|
||||||
loadFrames: (loadedCallback, errorCallback, loadProgressCallback, skipDeferredLoading, loadUntilFrame) ->
|
loadFrames: (loadedCallback, errorCallback, loadProgressCallback, preloadedCallback, skipDeferredLoading, loadUntilFrame) ->
|
||||||
return if @aborted
|
return if @aborted
|
||||||
console.log 'Warning: loadFrames called on empty World (no thangs).' unless @thangs.length
|
console.log 'Warning: loadFrames called on empty World (no thangs).' unless @thangs.length
|
||||||
continueLaterFn = =>
|
continueLaterFn = =>
|
||||||
@loadFrames(loadedCallback, errorCallback, loadProgressCallback, skipDeferredLoading, loadUntilFrame) unless @destroyed
|
@loadFrames(loadedCallback, errorCallback, loadProgressCallback, preloadedCallback, skipDeferredLoading, loadUntilFrame) unless @destroyed
|
||||||
if @realTime and not @countdownFinished
|
if @realTime and not @countdownFinished
|
||||||
return setTimeout @finishCountdown(continueLaterFn), REAL_TIME_COUNTDOWN_DELAY
|
return setTimeout @finishCountdown(continueLaterFn), REAL_TIME_COUNTDOWN_DELAY
|
||||||
t1 = now()
|
t1 = now()
|
||||||
|
@ -117,13 +117,15 @@ module.exports = class World
|
||||||
for error in (@unhandledRuntimeErrors ? [])
|
for error in (@unhandledRuntimeErrors ? [])
|
||||||
return unless errorCallback error # errorCallback tells us whether the error is recoverable
|
return unless errorCallback error # errorCallback tells us whether the error is recoverable
|
||||||
@unhandledRuntimeErrors = []
|
@unhandledRuntimeErrors = []
|
||||||
@finishLoadingFrames loadProgressCallback, loadedCallback
|
@finishLoadingFrames loadProgressCallback, loadedCallback, preloadedCallback
|
||||||
|
|
||||||
finishLoadingFrames: (loadProgressCallback, loadedCallback) ->
|
finishLoadingFrames: (loadProgressCallback, loadedCallback, preloadedCallback) ->
|
||||||
unless @debugging
|
unless @debugging
|
||||||
@ended = true
|
@ended = true
|
||||||
system.finish @thangs for system in @systems
|
system.finish @thangs for system in @systems
|
||||||
unless @preloading
|
if @preloading
|
||||||
|
preloadedCallback()
|
||||||
|
else
|
||||||
loadProgressCallback? 1
|
loadProgressCallback? 1
|
||||||
loadedCallback()
|
loadedCallback()
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
c = require 'schemas/schemas'
|
c = require 'schemas/schemas'
|
||||||
|
|
||||||
goalStatesSchema =
|
goalStatesSchema =
|
||||||
type: 'object'
|
type: 'object'
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
type: 'object'
|
type: 'object'
|
||||||
|
@ -41,6 +41,8 @@ module.exports =
|
||||||
|
|
||||||
'god:goals-calculated': c.object {required: ['goalStates']},
|
'god:goals-calculated': c.object {required: ['goalStates']},
|
||||||
goalStates: goalStatesSchema
|
goalStates: goalStatesSchema
|
||||||
|
preload: {type: 'boolean'}
|
||||||
|
overallStatus: {type: ['string', 'null'], enum: ['success', 'failure', 'incomplete', null]}
|
||||||
|
|
||||||
'god:world-load-progress-changed': c.object {required: ['progress']},
|
'god:world-load-progress-changed': c.object {required: ['progress']},
|
||||||
progress: {type: 'number', minimum: 0, maximum: 1}
|
progress: {type: 'number', minimum: 0, maximum: 1}
|
||||||
|
|
|
@ -34,25 +34,37 @@
|
||||||
.btn
|
.btn
|
||||||
padding: 3px 10px
|
padding: 3px 10px
|
||||||
height: 40px
|
height: 40px
|
||||||
|
font-size: 22px
|
||||||
|
|
||||||
.submit-button
|
.submit-button
|
||||||
margin-left: 20px
|
margin-left: 20px
|
||||||
|
min-width: 150px
|
||||||
|
|
||||||
.cast-button
|
.cast-button
|
||||||
margin-left: 10px
|
margin-left: 10px
|
||||||
|
min-width: 150px
|
||||||
@include opacity(0.77)
|
@include opacity(0.77)
|
||||||
|
|
||||||
&:hover, &.castable
|
&:hover, &.castable
|
||||||
@include opacity(1)
|
@include opacity(1)
|
||||||
|
|
||||||
&:not(.winnable) .cast-button.castable
|
&:not(.winnable)
|
||||||
font-weight: bold
|
|
||||||
-webkit-animation-name: castablePulse
|
|
||||||
-webkit-animation-duration: 3s
|
|
||||||
-webkit-animation-iteration-count: infinite
|
|
||||||
|
|
||||||
&.winnable .submit-button
|
.cast-button.castable
|
||||||
font-weight: bold
|
font-weight: bold
|
||||||
-webkit-animation-name: winnablePulse
|
-webkit-animation-name: castablePulse
|
||||||
-webkit-animation-duration: 3s
|
-webkit-animation-duration: 3s
|
||||||
-webkit-animation-iteration-count: infinite
|
-webkit-animation-iteration-count: infinite
|
||||||
|
|
||||||
|
.submit-button
|
||||||
|
font-size: 16px
|
||||||
|
|
||||||
|
&.winnable
|
||||||
|
.submit-button
|
||||||
|
font-weight: bold
|
||||||
|
-webkit-animation-name: winnablePulse
|
||||||
|
-webkit-animation-duration: 3s
|
||||||
|
-webkit-animation-iteration-count: infinite
|
||||||
|
|
||||||
|
.cast-button
|
||||||
|
font-size: 16px
|
||||||
|
|
|
@ -17,6 +17,7 @@ module.exports = class CastButtonView extends CocoView
|
||||||
'real-time-multiplayer:joined-game': 'onJoinedRealTimeMultiplayerGame'
|
'real-time-multiplayer:joined-game': 'onJoinedRealTimeMultiplayerGame'
|
||||||
'real-time-multiplayer:left-game': 'onLeftRealTimeMultiplayerGame'
|
'real-time-multiplayer:left-game': 'onLeftRealTimeMultiplayerGame'
|
||||||
'goal-manager:new-goal-states': 'onNewGoalStates'
|
'goal-manager:new-goal-states': 'onNewGoalStates'
|
||||||
|
'god:goals-calculated': 'onGoalsCalculated'
|
||||||
|
|
||||||
constructor: (options) ->
|
constructor: (options) ->
|
||||||
super options
|
super options
|
||||||
|
@ -85,6 +86,10 @@ module.exports = class CastButtonView extends CocoView
|
||||||
if @winnable
|
if @winnable
|
||||||
@$el.find('.submit-button').show() # In case we hid it, like on the first level.
|
@$el.find('.submit-button').show() # In case we hid it, like on the first level.
|
||||||
|
|
||||||
|
onGoalsCalculated: (e) ->
|
||||||
|
return unless e.preload
|
||||||
|
@onNewGoalStates e
|
||||||
|
|
||||||
updateCastButton: ->
|
updateCastButton: ->
|
||||||
return if _.some @spells, (spell) => not spell.loaded
|
return if _.some @spells, (spell) => not spell.loaded
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue