From d8418f7bb29fcec89fb234640d03ac313f55fefe Mon Sep 17 00:00:00 2001 From: Jayant Jain Date: Fri, 14 Mar 2014 18:32:57 +0530 Subject: [PATCH 1/6] Fixes issue where panning occurs upon mouse scroll at max/min zoom --- app/lib/surface/Camera.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/lib/surface/Camera.coffee b/app/lib/surface/Camera.coffee index 6f378381a..6427caec1 100644 --- a/app/lib/surface/Camera.coffee +++ b/app/lib/surface/Camera.coffee @@ -165,7 +165,8 @@ module.exports = class Camera extends CocoClass target = {x: newTargetX, y:newTargetY} else target = @target - @zoomTo target, newZoom, 0 + if not(newZoom >= MAX_ZOOM or newZoom <= Math.max(@minZoom, MIN_ZOOM)) + @zoomTo target, newZoom, 0 onMouseDown: (e) -> return if @dragDisabled From ece932595c05059e0e8d70ce26282270b1fb6fe1 Mon Sep 17 00:00:00 2001 From: Jayant Jain Date: Fri, 14 Mar 2014 18:33:57 +0530 Subject: [PATCH 2/6] Enables drag-panning for editor and region chooser --- app/lib/surface/RegionChooser.coffee | 3 ++- app/views/editor/level/thangs_tab_view.coffee | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/lib/surface/RegionChooser.coffee b/app/lib/surface/RegionChooser.coffee index d0dbdc82a..7d28131d4 100644 --- a/app/lib/surface/RegionChooser.coffee +++ b/app/lib/surface/RegionChooser.coffee @@ -7,7 +7,6 @@ module.exports = class RegionChooser extends CocoClass @options.stage.addEventListener 'stagemousedown', @onMouseDown @options.stage.addEventListener 'stagemousemove', @onMouseMove @options.stage.addEventListener 'stagemouseup', @onMouseUp - @options.camera.dragDisabled = true destroy: -> @options.stage.removeEventListener 'stagemousedown', @onMouseDown @@ -18,6 +17,7 @@ module.exports = class RegionChooser extends CocoClass onMouseDown: (e) => return unless key.shift @firstPoint = @options.camera.canvasToWorld {x: e.stageX, y: e.stageY} + @options.camera.dragDisabled = true onMouseMove: (e) => return unless @firstPoint @@ -30,6 +30,7 @@ module.exports = class RegionChooser extends CocoClass Backbone.Mediator.publish 'choose-region', points: [@firstPoint, @secondPoint] @firstPoint = null @secondPoint = null + @options.camera.dragDisabled = false restrictRegion: -> RATIO = 1.56876 # 924 / 589 diff --git a/app/views/editor/level/thangs_tab_view.coffee b/app/views/editor/level/thangs_tab_view.coffee index 0242e3fe7..2e1bb6888 100644 --- a/app/views/editor/level/thangs_tab_view.coffee +++ b/app/views/editor/level/thangs_tab_view.coffee @@ -146,7 +146,6 @@ module.exports = class ThangsTabView extends View @surface.playing = false @surface.setWorld @world @surface.camera.zoomTo({x:262, y:-164}, 1.66, 0) - @surface.camera.dragDisabled = true destroy: -> @selectAddThangType null @@ -168,6 +167,7 @@ module.exports = class ThangsTabView extends View onSpriteDragged: (e) -> return unless @selectedExtantThang and e.thang?.id is @selectedExtantThang?.id + @surface.camera.dragDisabled = true {stageX, stageY} = e.originalEvent wop = @surface.camera.canvasToWorld x: stageX, y: stageY wop.z = @selectedExtantThang.depth / 2 @@ -178,6 +178,7 @@ module.exports = class ThangsTabView extends View onSpriteMouseUp: (e) -> clearInterval(@movementInterval) if @movementInterval? @movementInterval = null + @surface.camera.dragDisabled = false return unless @selectedExtantThang and e.thang?.id is @selectedExtantThang?.id pos = @selectedExtantThang.pos physicalOriginal = componentOriginals["physics.Physical"] From 845d4cecefc4f7f11df4eadf3b438acaaee534bb Mon Sep 17 00:00:00 2001 From: bang honam Date: Sat, 15 Mar 2014 23:08:22 +0900 Subject: [PATCH 3/6] Added a space for coding convention --- server_setup.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server_setup.coffee b/server_setup.coffee index 437464f14..e0a72f4dc 100644 --- a/server_setup.coffee +++ b/server_setup.coffee @@ -20,7 +20,7 @@ config = require './server_config' # self.emit('pass',message) # next() -productionLogging = (tokens, req, res)-> +productionLogging = (tokens, req, res) -> status = res.statusCode color = 32 if status >= 500 then color = 31 From 70f3ca8f8edc1d21d32faf103b25787685ea85d5 Mon Sep 17 00:00:00 2001 From: bang honam Date: Sat, 15 Mar 2014 23:11:00 +0900 Subject: [PATCH 4/6] Added a line for coding convention --- app/views/admin_view.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/admin_view.coffee b/app/views/admin_view.coffee index e71c9acaf..cd06c0999 100644 --- a/app/views/admin_view.coffee +++ b/app/views/admin_view.coffee @@ -29,7 +29,8 @@ module.exports = class AdminView extends View espionageSuccess: (model) -> storage.save('whoami',model) window.location.reload() + espionageFailure: (jqxhr, status,error)-> console.log "There was an error entering espionage mode: #{error}" - \ No newline at end of file + From e63e787a30466f48527f6b2a818ca9f76fe73739 Mon Sep 17 00:00:00 2001 From: honam bang Date: Sat, 15 Mar 2014 23:56:44 +0900 Subject: [PATCH 5/6] Removed spaces for coding convention --- app/views/play/ladder/my_matches_tab.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/play/ladder/my_matches_tab.coffee b/app/views/play/ladder/my_matches_tab.coffee index ebcc63148..2772defa5 100644 --- a/app/views/play/ladder/my_matches_tab.coffee +++ b/app/views/play/ladder/my_matches_tab.coffee @@ -102,7 +102,7 @@ module.exports = class MyMatchesTabView extends CocoView @$el.find('.rank-button').each (i, el) => button = $(el) sessionID = button.data('session-id') - session = _.find @sessions.models, { id: sessionID } + session = _.find @sessions.models, {id: sessionID} rankingState = 'unavailable' if @readyToRank session rankingState = 'rank' @@ -119,14 +119,14 @@ module.exports = class MyMatchesTabView extends CocoView rankSession: (e) -> button = $(e.target).closest('.rank-button') sessionID = button.data('session-id') - session = _.find @sessions.models, { id: sessionID } + session = _.find @sessions.models, {id: sessionID} return unless @readyToRank(session) @setRankingButtonText(button, 'submitting') success = => @setRankingButtonText(button, 'submitted') failure = => @setRankingButtonText(button, 'failed') - ajaxData = { session: sessionID, levelID: @level.id, originalLevelID: @level.attributes.original, levelMajorVersion: @level.attributes.version.major } + ajaxData = {session: sessionID, levelID: @level.id, originalLevelID: @level.attributes.original, levelMajorVersion: @level.attributes.version.major} console.log "Posting game for ranking from My Matches view." $.ajax '/queue/scoring', { type: 'POST' From 2c6e667bb7411d6fdb496feaad52f21dce4ef20c Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Sat, 15 Mar 2014 09:20:13 -0700 Subject: [PATCH 6/6] Added API for queue messages count --- app/views/play/spectate_view.coffee | 4 ---- server/commons/queue.coffee | 3 ++- server/queues/scoring.coffee | 11 +++++++++++ server/routes/queue.coffee | 5 +++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/views/play/spectate_view.coffee b/app/views/play/spectate_view.coffee index 5d855be0a..66093c013 100644 --- a/app/views/play/spectate_view.coffee +++ b/app/views/play/spectate_view.coffee @@ -453,10 +453,6 @@ module.exports = class SpectateLevelView extends View else cb(null, $.parseJSON(jqxhr.responseText)) - - - - destroy: ()-> @supermodel?.off 'error', @onLevelLoadError @levelLoader?.off 'loaded-all', @onLevelLoaderLoaded diff --git a/server/commons/queue.coffee b/server/commons/queue.coffee index 1e86f99cd..10710e340 100644 --- a/server/commons/queue.coffee +++ b/server/commons/queue.coffee @@ -185,7 +185,8 @@ class MongoQueue extends events.EventEmitter subscribe: (eventName, callback) -> @on eventName, callback unsubscribe: (eventName, callback) -> @removeListener eventName, callback - + totalMessagesInQueue: (callback) -> @Message.count {}, callback + receiveMessage: (callback) -> conditions = queue: @queueName diff --git a/server/queues/scoring.coffee b/server/queues/scoring.coffee index cc4abe0a9..ee09a914f 100644 --- a/server/queues/scoring.coffee +++ b/server/queues/scoring.coffee @@ -24,6 +24,17 @@ connectToScoringQueue = -> if error? then throw new Error "There was an error registering the scoring queue: #{error}" scoringTaskQueue = data log.info "Connected to scoring task queue!" + +module.exports.messagesInQueueCount = (req, res) -> + scoringTaskQueue.totalMessagesInQueue (err, count) -> + if err? then return errors.serverError res, "There was an issue finding the Mongoose count:#{err}" + response = + point: + number: count + timestamp: Date.now() + res.send(response) + res.end() + module.exports.addPairwiseTaskToQueueFromRequest = (req, res) -> taskPair = req.body.sessions diff --git a/server/routes/queue.coffee b/server/routes/queue.coffee index 85ee0f8e3..10af6875f 100644 --- a/server/routes/queue.coffee +++ b/server/routes/queue.coffee @@ -9,6 +9,11 @@ module.exports.setup = (app) -> #app.post '/queue/scoring/pairwise', (req, res) -> # handler = loadQueueHandler 'scoring' # handler.addPairwiseTaskToQueue req, res + + app.get '/queue/messagesInQueueCount', (req, res) -> + handler = loadQueueHandler 'scoring' + handler.messagesInQueueCount req, res + app.all '/queue/*', (req, res) -> setResponseHeaderToJSONContentType res