From 938ea4f3d5daa15dd266eed01d297b0f8104415a Mon Sep 17 00:00:00 2001 From: bdew Date: Mon, 24 Feb 2014 11:34:29 +0200 Subject: [PATCH] EntryNumList can be converted used as color --- src/net/bdew/lib/recipes/gencfg/ConfigSection.scala | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/net/bdew/lib/recipes/gencfg/ConfigSection.scala b/src/net/bdew/lib/recipes/gencfg/ConfigSection.scala index d71ec0d..332a387 100644 --- a/src/net/bdew/lib/recipes/gencfg/ConfigSection.scala +++ b/src/net/bdew/lib/recipes/gencfg/ConfigSection.scala @@ -9,6 +9,8 @@ package net.bdew.lib.recipes.gencfg +import net.bdew.lib.gui.Color + abstract class CfgEntry case class EntryDouble(v: Double) extends CfgEntry @@ -57,6 +59,11 @@ case class ConfigSection(pfx: String = "") extends CfgEntry with Iterable[(Strin def getFloat(id: String) = getDouble(id).toFloat def getIntList(id: String) = getDoubleList(id).map(_.round.toInt).toList def getFloatList(id: String) = getDoubleList(id).map(_.toFloat).toList + + def getColor(id: String) = getFloatList(id) match { + case r :: g :: b :: Nil => Color(r, g, b) + case _ => sys.error("Color definition must be 3 numbers") + } }