From 7ee293891798c59efba3f160fed4470bbffa01ae Mon Sep 17 00:00:00 2001 From: Kyzentun Date: Mon, 22 Dec 2014 00:10:34 -0700 Subject: [PATCH] Wrapped CustomDifficulty color functions to report a nice error when a color doesn't exist. --- Themes/_fallback/Scripts/02 Colors.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Themes/_fallback/Scripts/02 Colors.lua b/Themes/_fallback/Scripts/02 Colors.lua index 31b2036ba6..98c0bc43f1 100644 --- a/Themes/_fallback/Scripts/02 Colors.lua +++ b/Themes/_fallback/Scripts/02 Colors.lua @@ -145,17 +145,22 @@ function PlayerDarkColor( pn ) return color("1,1,1,1") end +local function GameColorDifficultyWrapper(diff) + assert(GameColor.Difficulty[diff], "GameColor: There is no entry in GameColor.Difficulty for CustomDifficulty '" .. tostring(diff) .. "'.") + return GameColor.Difficulty[diff] +end + function CustomDifficultyToColor( sCustomDifficulty ) - return GameColor.Difficulty[sCustomDifficulty] + return GameColorDifficultyWrapper(sCustomDifficulty) end function CustomDifficultyToDarkColor( sCustomDifficulty ) - local c = GameColor.Difficulty[sCustomDifficulty] + local c = GameColorDifficultyWrapper(sCustomDifficulty) return { c[1]/2, c[2]/2, c[3]/2, c[4] } end function CustomDifficultyToLightColor( sCustomDifficulty ) - local c = GameColor.Difficulty[sCustomDifficulty] + local c = GameColorDifficultyWrapper(sCustomDifficulty) return { scale(c[1],0,1,0.5,1), scale(c[2],0,1,0.5,1), scale(c[3],0,1,0.5,1), c[4] } end