From 4af04b01232a0fbb2080f426f823311839c04df3 Mon Sep 17 00:00:00 2001 From: Alayan Date: Fri, 12 Oct 2018 03:12:44 +0200 Subject: [PATCH] Make multiplayer selection focus colored by the theme --- data/skins/Coal.stkskin | 5 ++++- data/skins/Forest.stkskin | 5 ++++- data/skins/Ocean.stkskin | 5 ++++- data/skins/Peach.stkskin | 5 ++++- data/skins/Ruby.stkskin | 5 ++++- src/guiengine/skin.cpp | 38 +++++++++++++++++++++++++++----------- 6 files changed, 47 insertions(+), 16 deletions(-) diff --git a/data/skins/Coal.stkskin b/data/skins/Coal.stkskin index d14477465..a82a92d12 100644 --- a/data/skins/Coal.stkskin +++ b/data/skins/Coal.stkskin @@ -147,7 +147,7 @@ when the border that intersect at this corner are enabled. - + diff --git a/data/skins/Forest.stkskin b/data/skins/Forest.stkskin index a3f28feb8..868e2e694 100644 --- a/data/skins/Forest.stkskin +++ b/data/skins/Forest.stkskin @@ -147,7 +147,7 @@ when the border that intersect at this corner are enabled. - + diff --git a/data/skins/Ocean.stkskin b/data/skins/Ocean.stkskin index b9fa4dad8..4ded0bb1a 100644 --- a/data/skins/Ocean.stkskin +++ b/data/skins/Ocean.stkskin @@ -146,7 +146,7 @@ when the border that intersect at this corner are enabled. - + diff --git a/data/skins/Peach.stkskin b/data/skins/Peach.stkskin index 21adff54a..e348498d6 100644 --- a/data/skins/Peach.stkskin +++ b/data/skins/Peach.stkskin @@ -146,7 +146,7 @@ when the border that intersect at this corner are enabled. - + diff --git a/data/skins/Ruby.stkskin b/data/skins/Ruby.stkskin index 7f43d05b8..ad3fd1762 100644 --- a/data/skins/Ruby.stkskin +++ b/data/skins/Ruby.stkskin @@ -147,7 +147,7 @@ when the border that intersect at this corner are enabled. - + diff --git a/src/guiengine/skin.cpp b/src/guiengine/skin.cpp index e67240f99..64136db10 100644 --- a/src/guiengine/skin.cpp +++ b/src/guiengine/skin.cpp @@ -1192,7 +1192,7 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, return; drawBoxFromStretchableTexture(parentRibbonWidget, rect, - SkinConfig::m_render_params["squareFocusHalo::neutral"]); + SkinConfig::m_render_params["squareFocusHalo1::neutral"]); nPlayersOnThisItem++; } } // end if mark_focused @@ -1209,11 +1209,24 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, short green_previous = parentRibbonWidget->m_skin_g; short blue_previous = parentRibbonWidget->m_skin_b; - SColorf color_rgb = getPlayerColor(i); + if (i>=4) + { + SColorf color_rgb = getPlayerColor(i); - parentRibbonWidget->m_skin_r = short(color_rgb.r * 255.0f); - parentRibbonWidget->m_skin_g = short(color_rgb.g * 255.0f); - parentRibbonWidget->m_skin_b = short(color_rgb.b * 255.0f); + parentRibbonWidget->m_skin_r = short(color_rgb.r * 255.0f); + parentRibbonWidget->m_skin_g = short(color_rgb.g * 255.0f); + parentRibbonWidget->m_skin_b = short(color_rgb.b * 255.0f); + } + + std::string square_focus; + + // 1 = player n°2 + // TODO : current skins support 5 custom colors before using the coloring + // but dynamic detection of the number of colors supported would be better + if (i>=5) + square_focus = "squareFocusHaloBW::neutral"; + else + square_focus = "squareFocusHalo" + StringUtils::toString(i+1) + "::neutral"; if (nPlayersOnThisItem > 0) { @@ -1225,16 +1238,19 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, rect2.LowerRightCorner.Y += enlarge; drawBoxFromStretchableTexture(parentRibbonWidget, rect2, - SkinConfig::m_render_params["squareFocusHaloBW::neutral"]); + SkinConfig::m_render_params[square_focus.c_str()]); } else { drawBoxFromStretchableTexture(parentRibbonWidget, rect, - SkinConfig::m_render_params["squareFocusHaloBW::neutral"]); + SkinConfig::m_render_params[square_focus.c_str()]); + } + if (i>=5) + { + parentRibbonWidget->m_skin_r = red_previous; + parentRibbonWidget->m_skin_g = green_previous; + parentRibbonWidget->m_skin_b = blue_previous; } - parentRibbonWidget->m_skin_r = red_previous; - parentRibbonWidget->m_skin_g = green_previous; - parentRibbonWidget->m_skin_b = blue_previous; nPlayersOnThisItem++; } } @@ -1295,7 +1311,7 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget, BoxRenderParams* params; SpinnerWidget* q = dynamic_cast(widget); - std::string texture = "squareFocusHalo::neutral"; + std::string texture = "squareFocusHalo1::neutral"; SColorf color_rgb = { 1,1,1,1 }; if(q->getUseBackgroundColor()) {