tweak pref enumerations
parent
b7ea05e4cb
commit
008de506ce
|
@ -56,21 +56,21 @@ object Dasher extends LilaController {
|
|||
"theme" -> Json.obj(
|
||||
"d2" -> Json.obj(
|
||||
"current" -> ctx.currentTheme.name,
|
||||
"list" -> lila.pref.Theme.list.map(_.name)
|
||||
"list" -> lila.pref.Theme.all.map(_.name)
|
||||
),
|
||||
"d3" -> Json.obj(
|
||||
"current" -> ctx.currentTheme3d.name,
|
||||
"list" -> lila.pref.Theme3d.list.map(_.name)
|
||||
"list" -> lila.pref.Theme3d.all.map(_.name)
|
||||
)
|
||||
),
|
||||
"piece" -> Json.obj(
|
||||
"d2" -> Json.obj(
|
||||
"current" -> ctx.currentPieceSet.name,
|
||||
"list" -> lila.pref.PieceSet.list.map(_.name)
|
||||
"list" -> lila.pref.PieceSet.all.map(_.name)
|
||||
),
|
||||
"d3" -> Json.obj(
|
||||
"current" -> ctx.currentPieceSet3d.name,
|
||||
"list" -> lila.pref.PieceSet3d.list.map(_.name)
|
||||
"list" -> lila.pref.PieceSet3d.all.map(_.name)
|
||||
)
|
||||
),
|
||||
"kid" -> ctx.me ?? (_.kid),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
@()(implicit ctx: Context)
|
||||
|
||||
@themeParameters() = {
|
||||
<li>- <strong>theme</strong>: Controls the board theme. Available themes: @lila.pref.Theme.list.map(_.name).mkString(", ").</li>
|
||||
<li>- <strong>theme</strong>: Controls the board theme. Available themes: @lila.pref.Theme.all.map(_.name).mkString(", ").</li>
|
||||
<li>- <strong>bg</strong>: Controls the background color. Available backgrounds: light, dark.</li>
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package lila.pref
|
||||
|
||||
import scalaz.NonEmptyList
|
||||
|
||||
sealed class PieceSet private[pref] (val name: String) {
|
||||
|
||||
override def toString = name
|
||||
|
@ -11,24 +9,20 @@ sealed class PieceSet private[pref] (val name: String) {
|
|||
|
||||
sealed trait PieceSetObject {
|
||||
|
||||
def all: NonEmptyList[PieceSet]
|
||||
val all: List[PieceSet]
|
||||
|
||||
lazy val list = all.list
|
||||
val allByName = all map { c => c.name -> c } toMap
|
||||
|
||||
lazy val listString = list mkString " "
|
||||
val default = all.head
|
||||
|
||||
lazy val allByName = list map { c => c.name -> c } toMap
|
||||
|
||||
lazy val default = all.head
|
||||
|
||||
def apply(name: String) = (allByName get name) | default
|
||||
def apply(name: String) = allByName.getOrElse(name, default)
|
||||
|
||||
def contains(name: String) = allByName contains name
|
||||
}
|
||||
|
||||
object PieceSet extends PieceSetObject {
|
||||
|
||||
val all = NonEmptyList(
|
||||
val all = List(
|
||||
"cburnett", "merida", "alpha", "pirouetti",
|
||||
"chessnut", "chess7", "reillycraig", "companion",
|
||||
"fantasy", "spatial", "shapes", "letter"
|
||||
|
@ -37,7 +31,7 @@ object PieceSet extends PieceSetObject {
|
|||
|
||||
object PieceSet3d extends PieceSetObject {
|
||||
|
||||
val all = NonEmptyList(
|
||||
val all = List(
|
||||
"Basic", "Wood", "Metal", "RedVBlue",
|
||||
"ModernJade", "ModernWood", "Glass", "Trimmed",
|
||||
"Experimental", "Staunton"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package lila.pref
|
||||
|
||||
import scalaz.NonEmptyList
|
||||
|
||||
sealed class SoundSet private[pref] (val key: String, val name: String) {
|
||||
|
||||
override def toString = key
|
||||
|
@ -9,28 +7,13 @@ sealed class SoundSet private[pref] (val key: String, val name: String) {
|
|||
def cssClass = key
|
||||
}
|
||||
|
||||
sealed trait SoundSetObject {
|
||||
object SoundSet {
|
||||
|
||||
def all: NonEmptyList[SoundSet]
|
||||
val default = new SoundSet("standard", "Standard")
|
||||
|
||||
lazy val list = all.list
|
||||
|
||||
lazy val listString = list mkString " "
|
||||
|
||||
lazy val allByKey = list map { c => c.key -> c } toMap
|
||||
|
||||
lazy val default = all.head
|
||||
|
||||
def apply(key: String) = allByKey.getOrElse(key.toLowerCase, default)
|
||||
|
||||
def contains(key: String) = allByKey contains key.toLowerCase
|
||||
}
|
||||
|
||||
object SoundSet extends SoundSetObject {
|
||||
|
||||
val all = NonEmptyList(
|
||||
val list = List(
|
||||
new SoundSet("silent", "Silent"),
|
||||
new SoundSet("standard", "Standard"),
|
||||
default,
|
||||
new SoundSet("piano", "Piano"),
|
||||
new SoundSet("nes", "NES"),
|
||||
new SoundSet("sfx", "SFX"),
|
||||
|
@ -38,4 +21,10 @@ object SoundSet extends SoundSetObject {
|
|||
new SoundSet("robot", "Robot"),
|
||||
new SoundSet("music", "Pentatonic")
|
||||
)
|
||||
|
||||
val allByKey = list map { c => c.key -> c } toMap
|
||||
|
||||
def apply(key: String) = allByKey.getOrElse(key.toLowerCase, default)
|
||||
|
||||
def contains(key: String) = allByKey contains key.toLowerCase
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package lila.pref
|
||||
|
||||
import scalaz.NonEmptyList
|
||||
|
||||
sealed class Theme private[pref] (val name: String, val colors: Theme.HexColors) {
|
||||
|
||||
override def toString = name
|
||||
|
@ -14,17 +12,13 @@ sealed class Theme private[pref] (val name: String, val colors: Theme.HexColors)
|
|||
|
||||
sealed trait ThemeObject {
|
||||
|
||||
def all: NonEmptyList[Theme]
|
||||
val all: List[Theme]
|
||||
|
||||
def default: Theme
|
||||
val default: Theme
|
||||
|
||||
lazy val list = all.list
|
||||
val allByName = all map { c => c.name -> c } toMap
|
||||
|
||||
lazy val listString = list mkString " "
|
||||
|
||||
lazy val allByName = list map { c => c.name -> c } toMap
|
||||
|
||||
def apply(name: String) = (allByName get name) | default
|
||||
def apply(name: String) = allByName.getOrElse(name, default)
|
||||
|
||||
def contains(name: String) = allByName contains name
|
||||
}
|
||||
|
@ -43,7 +37,7 @@ object Theme extends ThemeObject {
|
|||
"purple" -> (HexColor("9f90b0"), HexColor("7d4a8d"))
|
||||
)
|
||||
|
||||
val all = NonEmptyList(
|
||||
val all = List(
|
||||
"blue", "blue2", "blue3", "canvas",
|
||||
"wood", "wood2", "wood3", "maple",
|
||||
"green", "marble", "brown", "leather",
|
||||
|
@ -57,7 +51,7 @@ object Theme extends ThemeObject {
|
|||
|
||||
object Theme3d extends ThemeObject {
|
||||
|
||||
val all = NonEmptyList(
|
||||
val all = List(
|
||||
"Black-White-Aluminium",
|
||||
"Brushed-Aluminium",
|
||||
"China-Blue",
|
||||
|
|
Loading…
Reference in New Issue