From 53c244a93a1a6cd92f4f89caa8ad69cf424d37b4 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Fri, 2 Aug 2013 23:17:49 +0200 Subject: [PATCH] show game names in TV chat --- app/views/round/watcherRoomInner.scala.html | 3 +++ app/views/tv/index.scala.html | 2 ++ modules/game/src/main/Env.scala | 2 +- modules/game/src/main/Featured.scala | 6 +++--- modules/game/src/main/actorApi.scala | 2 +- modules/hub/src/main/Env.scala | 1 + modules/round/src/main/Env.scala | 19 +++++++++++++++++-- modules/round/src/main/SocketHub.scala | 4 ++-- public/javascripts/big.js | 6 +++++- public/javascripts/monitor.js | 2 +- public/stylesheets/board.css | 6 ++++++ public/stylesheets/dark.css | 1 + 12 files changed, 43 insertions(+), 11 deletions(-) diff --git a/app/views/round/watcherRoomInner.scala.html b/app/views/round/watcherRoomInner.scala.html index 0be6680e7f..f0b3daa721 100644 --- a/app/views/round/watcherRoomInner.scala.html +++ b/app/views/round/watcherRoomInner.scala.html @@ -1,6 +1,9 @@ @(messages: List[(Option[String], String)])(implicit ctx: Context) @messages.map { +case (Some("lichess"), text) => { +
  • @text
  • +} case (username, text) => {
  • @usernameLink(username, withOnline = false, truncate = 12.some)@text
  • } diff --git a/app/views/tv/index.scala.html b/app/views/tv/index.scala.html index 54d3216d91..764e30e5ea 100644 --- a/app/views/tv/index.scala.html +++ b/app/views/tv/index.scala.html @@ -22,7 +22,9 @@ cssClass = "spectators")(roomHtml) @confrontation.map { c => @user.confrontation(c) }.getOrElse { +
    @playerLink(pov.game.creator, withElo = false, withOnline = false) vs @playerLink(pov.game.invited, withElo = false, withOnline = false)
    +
    }
    @shortClockName(pov.game.clock) diff --git a/modules/game/src/main/Env.scala b/modules/game/src/main/Env.scala index 56855570a5..446d1fd537 100644 --- a/modules/game/src/main/Env.scala +++ b/modules/game/src/main/Env.scala @@ -41,7 +41,7 @@ final class Env( lazy val featured = new Featured( lobbySocket = hub.socket.lobby, - roundSocket = hub.socket.round, + roundActor = hub.actor.round, rendererActor = hub.actor.renderer, system = system) diff --git a/modules/game/src/main/Featured.scala b/modules/game/src/main/Featured.scala index 2834e40e90..68943088af 100644 --- a/modules/game/src/main/Featured.scala +++ b/modules/game/src/main/Featured.scala @@ -16,7 +16,7 @@ import tube.gameTube final class Featured( lobbySocket: lila.hub.ActorLazyRef, - roundSocket: lila.hub.ActorLazyRef, + roundActor: lila.hub.ActorLazyRef, rendererActor: lila.hub.ActorLazyRef, system: ActorSystem) { @@ -37,7 +37,7 @@ final class Featured( case Set(game) ⇒ { oneId = game.id.some - roundSocket ! actorApi.ChangeFeaturedId(game.id) + roundActor ! actorApi.ChangeFeaturedGame(game) rendererActor ? actorApi.RenderFeaturedJs(game) onSuccess { case html: Html ⇒ lobbySocket ! actorApi.ChangeFeatured(html) } @@ -72,7 +72,7 @@ final class Featured( } def isWayBetter(g1: Game, g2: Game) = - score(g2.resetTurns) > (score(g1.resetTurns) * 1.3) + score(g2.resetTurns) > (score(g1.resetTurns) * 1.2) def rematch(game: Game): Fuog = game.next ?? $find.byId[Game] diff --git a/modules/game/src/main/actorApi.scala b/modules/game/src/main/actorApi.scala index 03fb20ab35..cf29a89ed5 100644 --- a/modules/game/src/main/actorApi.scala +++ b/modules/game/src/main/actorApi.scala @@ -5,7 +5,7 @@ import play.api.libs.json.JsObject import play.api.templates.Html case class ChangeFeatured(html: Html) -case class ChangeFeaturedId(id: String) +case class ChangeFeaturedGame(game: Game) case class RenderFeaturedJs(game: Game) case class TellWatchers(msg: JsObject) diff --git a/modules/hub/src/main/Env.scala b/modules/hub/src/main/Env.scala index 2ec7fd22cf..3c0d6c319c 100644 --- a/modules/hub/src/main/Env.scala +++ b/modules/hub/src/main/Env.scala @@ -27,6 +27,7 @@ final class Env(config: Config, system: ActorSystem) { val timeline = actorLazyRef("timeline.user") val bookmark = actorLazyRef("bookmark") val roundMap = actorLazyRef("round.map") + val round = actorLazyRef("round.actor") val lobby = actorLazyRef("lobby") val relation = actorLazyRef("relation") val challenger = actorLazyRef("challenger") diff --git a/modules/round/src/main/Env.scala b/modules/round/src/main/Env.scala index 6a482f52d0..396ce30184 100644 --- a/modules/round/src/main/Env.scala +++ b/modules/round/src/main/Env.scala @@ -3,11 +3,11 @@ package lila.round import akka.actor._ import akka.pattern.ask import com.typesafe.config.Config +import makeTimeout.large import lila.common.PimpedConfig._ -import lila.socket.actorApi.GetVersion import lila.hub.actorApi.map.Ask -import makeTimeout.large +import lila.socket.actorApi.GetVersion final class Env( config: Config, @@ -18,6 +18,7 @@ final class Env( hub: lila.hub.Env, ai: () ⇒ Fu[lila.ai.Ai], getUsername: String ⇒ Fu[Option[String]], + getUsernameOrAnon: String ⇒ Fu[String], i18nKeys: lila.i18n.I18nKeys, scheduler: lila.common.Scheduler) { @@ -36,6 +37,7 @@ final class Env( val HijackTimeout = config duration "hijack.timeout" val NetDomain = config getString "net.domain" val ActorMapName = config getString "actor.map.name" + val ActorName = config getString "actor.name" } import settings._ @@ -108,6 +110,18 @@ final class Env( private[round] def animationDelay = AnimationDelay private[round] def moretimeSeconds = Moretime.toSeconds + system.actorOf(Props(new Actor { + def receive = { + case msg @ lila.game.actorApi.ChangeFeaturedGame(game) ⇒ { + socketHub ! msg + def playerName(p: lila.game.Player) = lila.game.Namer.player(p, false)(getUsernameOrAnon) + (game.players map playerName).sequenceFu foreach { names ⇒ + WatcherRoomRepo.addMessage("tv", "lichess".some, names mkString " vs ") + } + } + } + }), name = ActorName) + { import scala.concurrent.duration._ @@ -148,6 +162,7 @@ object Env { hub = lila.hub.Env.current, ai = lila.ai.Env.current.ai, getUsername = lila.user.Env.current.usernameOption, + getUsernameOrAnon = lila.user.Env.current.usernameOrAnonymous, i18nKeys = lila.i18n.Env.current.keys, scheduler = lila.common.PlayApp.scheduler) } diff --git a/modules/round/src/main/SocketHub.scala b/modules/round/src/main/SocketHub.scala index d292eb16d3..221afd83e1 100644 --- a/modules/round/src/main/SocketHub.scala +++ b/modules/round/src/main/SocketHub.scala @@ -24,8 +24,8 @@ private[round] final class SocketHub( def _receive: Receive = { - case lila.game.actorApi.ChangeFeaturedId(id) ⇒ tellAll { - lila.game.actorApi.TellWatchers(makeMessage("featured_id", id)) + case lila.game.actorApi.ChangeFeaturedGame(game) ⇒ tellAll { + lila.game.actorApi.TellWatchers(makeMessage("featured_id", game.id)) } } diff --git a/public/javascripts/big.js b/public/javascripts/big.js index dd73f0a119..998bf7975b 100644 --- a/public/javascripts/big.js +++ b/public/javascripts/big.js @@ -806,7 +806,11 @@ var storage = { resize: true, render: function(u, t) { if (self.options.player.spectator) { - return '
  • ' + $.userLinkLimit(u, 14) + '' + urlToLink(t) + '
  • '; + if (u == 'lichess') { + return '
  • ' + urlToLink(t) + '
  • '; + } else { + return '
  • ' + $.userLinkLimit(u, 14) + '' + urlToLink(t) + '
  • '; + } } else { return '
  • ' + urlToLink(t) + '
  • '; } diff --git a/public/javascripts/monitor.js b/public/javascripts/monitor.js index d42efbe458..11ed5ef029 100644 --- a/public/javascripts/monitor.js +++ b/public/javascripts/monitor.js @@ -86,7 +86,7 @@ app.thread = new SpeedOMeter({ name : "THREAD", - maxVal : 500, + maxVal : 1000, threshold: 0.8, container : container }); diff --git a/public/stylesheets/board.css b/public/stylesheets/board.css index 6b7094ace8..ca4e4ed356 100644 --- a/public/stylesheets/board.css +++ b/public/stylesheets/board.css @@ -585,6 +585,12 @@ div.lichess_chat li { line-height: 14px; margin: 0.6em 0 0.6em 3px; } +div.lichess_chat li.system { + padding: 3px; + background: #e0e0e0; + margin-left: 0; + text-align: center; +} div.lichess_chat.kings ol.lichess_messages { padding-left: 5px; } diff --git a/public/stylesheets/dark.css b/public/stylesheets/dark.css index e3f3af5a5c..0a8c245878 100644 --- a/public/stylesheets/dark.css +++ b/public/stylesheets/dark.css @@ -160,6 +160,7 @@ body.dark #top a.bgpicker:hover, body.dark a#sound_state:hover, body.dark #top .dropdown, body.dark #GameText a:hover, +body.dark div.lichess_chat li.system, body.dark #hooks_wrap a.filter:hover, body.dark #hooks_wrap a.filter.active, body.dark div.content_box_inter a.intertab:hover,