use a rainbow kart color slider

This commit is contained in:
riso 2021-08-13 21:09:24 -05:00
parent 11ccdda699
commit 7045f8dbf7
17 changed files with 141 additions and 8 deletions

View File

@ -13,7 +13,7 @@
</div>
<spacer height="20" width="10"/>
<div height="fit" width="100%" layout="horizontal-row">
<gauge id="color-slider" min_value="1" max_value="100" proportion="1" wrap_around="true"/>
<gauge id="color-slider" min_value="1" max_value="100" proportion="1" wrap_around="true" color_slider="true"/>
</div>
<spacer height="10" width="10"/>
<buttonbar id="buttons" height="20%" width="30%" align="center">

View File

@ -135,6 +135,8 @@ all types of ttf.
<element type="progress" state="fill" image="gauge_fill.png"
left_border="7" right_border="7" top_border="7" bottom_border="7"
preserve_h_aspect_ratios="false" />
<!-- used for the color slider. -->
<element type="gaugefillrainbow" common="y" image="gauge_fill_rainbow.png" />
<element type="progress" state="neutral" image="section.png"
left_border="7" right_border="7" top_border="7" bottom_border="7"
@ -208,6 +210,19 @@ all types of ttf.
left_border="110" right_border="110" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" />
<!-- color spinner in kart color selection -->
<element type="spinner_rainbow" state="neutral" image="spinner_rainbow.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<element type="spinner_rainbow" state="focused" image="spinner_rainbow_focus.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<element type="spinner_rainbow" state="deactivated" image="spinner_rainbow_deactivated.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<!-- player name spinner color in multiplayer-->
<element type="spinner1" state="neutral" image="spinner_red.png"
left_border="110" right_border="110" top_border="0" bottom_border="36"

View File

@ -112,6 +112,7 @@ when the border that intersect at this corner are enabled.
<element type="progress" state="fill" image="glasssgauge_fill.png"
left_border="5" right_border="5" top_border="5" bottom_border="5" />
<element type="gaugefillrainbow" common="y" image="gauge_fill_rainbow.png" />
<element type="progress" state="neutral" common="y" image="progress_bg.png"
left_border="31" right_border="31" top_border="15" bottom_border="15" />
@ -184,6 +185,19 @@ when the border that intersect at this corner are enabled.
left_border="110" right_border="110" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" />
<!-- color spinner in kart color selection -->
<element type="spinner_rainbow" state="neutral" image="spinner_rainbow.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<element type="spinner_rainbow" state="focused" image="spinner_rainbow_focus.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<element type="spinner_rainbow" state="deactivated" image="spinner_rainbow_deactivated.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<!-- player name spinner color in multiplayer-->
<element type="spinner1" state="neutral" common="y" image="glass_square_black.png"
left_border="110" right_border="110" top_border="0" bottom_border="36"

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -112,6 +112,7 @@ when the border that intersect at this corner are enabled.
<element type="progress" state="fill" image="glasssgauge_fill.png"
left_border="5" right_border="5" top_border="5" bottom_border="5" />
<element type="gaugefillrainbow" common="y" image="gauge_fill_rainbow.png" />
<element type="progress" state="neutral" common="y" image="progress_bg.png"
left_border="31" right_border="31" top_border="15" bottom_border="15" />
@ -184,6 +185,19 @@ when the border that intersect at this corner are enabled.
left_border="110" right_border="110" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" />
<!-- color spinner in kart color selection -->
<element type="spinner_rainbow" state="neutral" image="spinner_rainbow.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<element type="spinner_rainbow" state="focused" image="spinner_rainbow_focus.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<element type="spinner_rainbow" state="deactivated" image="spinner_rainbow_deactivated.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<!-- player name spinner color in multiplayer-->
<element type="spinner1" state="neutral" common="y" image="glass_square_green.png"
left_border="110" right_border="110" top_border="0" bottom_border="36"

View File

@ -111,6 +111,7 @@ when the border that intersect at this corner are enabled.
<element type="progress" state="fill" image="glasssgauge_fill.png"
left_border="5" right_border="5" top_border="5" bottom_border="5" />
<element type="gaugefillrainbow" common="y" image="gauge_fill_rainbow.png" />
<element type="progress" state="neutral" common="y" image="progress_bg.png"
left_border="31" right_border="31" top_border="15" bottom_border="15" />
@ -183,6 +184,19 @@ when the border that intersect at this corner are enabled.
left_border="110" right_border="110" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" />
<!-- color spinner in kart color selection -->
<element type="spinner_rainbow" state="neutral" image="spinner_rainbow.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<element type="spinner_rainbow" state="focused" image="spinner_rainbow_focus.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<element type="spinner_rainbow" state="deactivated" image="spinner_rainbow_deactivated.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<!-- player name spinner color in multiplayer-->
<element type="spinner1" state="neutral" common="y" image="glass_square_cyan.png"
left_border="110" right_border="110" top_border="0" bottom_border="36"

View File

@ -131,6 +131,7 @@ all types of ttf.
<element type="progress" state="fill" image="glasssgauge_fill.png"
left_border="10" right_border="10" top_border="10" bottom_border="10" />
<element type="gaugefillrainbow" common="y" image="gauge_fill_rainbow.png" />
<element type="progress" state="neutral" common="y" image="progress_bg.png"
left_border="31" right_border="31" top_border="15" bottom_border="15" />
@ -203,6 +204,19 @@ all types of ttf.
left_border="110" right_border="110" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" />
<!-- color spinner in kart color selection -->
<element type="spinner_rainbow" state="neutral" image="spinner_rainbow.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<element type="spinner_rainbow" state="focused" image="spinner_rainbow_focus.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<element type="spinner_rainbow" state="deactivated" image="spinner_rainbow_deactivated.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<!-- player name spinner color in multiplayer-->
<element type="spinner1" state="neutral" common="y" image="glass_square_red.png"
left_border="110" right_border="110" top_border="0" bottom_border="36"

View File

@ -112,6 +112,7 @@ when the border that intersect at this corner are enabled.
<element type="progress" state="fill" image="glasssgauge_fill.png"
left_border="10" right_border="10" top_border="10" bottom_border="10" />
<element type="gaugefillrainbow" common="y" image="gauge_fill_rainbow.png" />
<element type="progress" state="neutral" common="y" image="progress_bg.png"
left_border="31" right_border="31" top_border="15" bottom_border="15" />
@ -184,6 +185,19 @@ when the border that intersect at this corner are enabled.
left_border="110" right_border="110" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" />
<!-- color spinner in kart color selection -->
<element type="spinner_rainbow" state="neutral" image="spinner_rainbow.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<element type="spinner_rainbow" state="focused" image="spinner_rainbow_focus.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<element type="spinner_rainbow" state="deactivated" image="spinner_rainbow_deactivated.png"
left_border="104" right_border="104" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" common="y"/>
<!-- player name spinner color in multiplayer-->
<element type="spinner1" state="neutral" common="y" image="glass_square_pink.png"
left_border="110" right_border="110" top_border="0" bottom_border="36"

View File

@ -496,6 +496,14 @@ namespace GUIEngine
even when it doesn't have the focus
\n
\subsection prop21 PROP_COLOR_SLIDER
<em> Name in XML files: </em> \c "color_slider"
Used for gauges only, to indicate if it is a color slider.
Value can be "true" or "false"
\n
<HR>
\section code Using the engine in code

View File

@ -253,6 +253,7 @@ if(prop_name != NULL) widget.m_properties[prop_flag] = core::stringc(prop_name).
READ_PROPERTY(label_location, PROP_LABELS_LOCATION);
READ_PROPERTY(max_rows, PROP_MAX_ROWS);
READ_PROPERTY(wrap_around, PROP_WRAP_AROUND);
READ_PROPERTY(color_slider, PROP_COLOR_SLIDER);
READ_PROPERTY(padding, PROP_DIV_PADDING);
READ_PROPERTY(keep_selection, PROP_KEEP_SELECTION);
#undef READ_PROPERTY

View File

@ -1568,15 +1568,36 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget,
}
else if (widget->m_deactivated)
{
params=&SkinConfig::m_render_params["spinner::deactivated"];
if (q->isColorSlider())
{
params=&SkinConfig::m_render_params["spinner_rainbow::deactivated"];
}
else
{
params=&SkinConfig::m_render_params["spinner::deactivated"];
}
}
else if (focused || pressed)
{
params=&SkinConfig::m_render_params["spinner::focused"];
if (q->isColorSlider())
{
params=&SkinConfig::m_render_params["spinner_rainbow::focused"];
}
else
{
params=&SkinConfig::m_render_params["spinner::focused"];
}
}
else
{
params=&SkinConfig::m_render_params["spinner::neutral"];
if (q->isColorSlider())
{
params=&SkinConfig::m_render_params["spinner_rainbow::neutral"];
}
else
{
params=&SkinConfig::m_render_params["spinner::neutral"];
}
}
for (unsigned i = 1; i < MAX_PLAYER_COUNT + 1; i++)
@ -1650,9 +1671,17 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget,
(int)((widget->m_w
- 2*handle_size)*value),
rect.UpperLeftCorner.Y + widget->m_h);
const ITexture* texture =
SkinConfig::m_render_params["gaugefill::neutral"].getImage();
ITexture* texture;
if (w->isColorSlider())
{
texture = SkinConfig::m_render_params["gaugefillrainbow::neutral"].getImage();
}
else
{
texture = SkinConfig::m_render_params["gaugefill::neutral"].getImage();
}
const int texture_w = texture->getSize().Width;
const int texture_h = texture->getSize().Height;

View File

@ -118,6 +118,7 @@ namespace GUIEngine
PROP_KEEP_SELECTION,
PROP_CUSTOM_RATIO,
PROP_ICON_ALIGN,
PROP_COLOR_SLIDER, // this one is used to identify if a gauge is used as the color slider
};
bool isWithinATextBox();

View File

@ -121,6 +121,7 @@ void SpinnerWidget::add()
std::string max_s = m_properties[PROP_MAX_VALUE];
m_wrap_around = (m_properties[PROP_WRAP_AROUND] == "true");
m_color_slider = (m_properties[PROP_COLOR_SLIDER] == "true");
if (min_s.size() > 0)
{

View File

@ -78,6 +78,9 @@ namespace GUIEngine
/** \brief Whether to wrap back to the first value when going "beyond" the last value */
bool m_wrap_around;
/** \brief Whether this widget is a color slider */
bool m_color_slider;
/** \brief Whether the left arrow is the currently selected one */
bool m_left_selected;
@ -185,7 +188,12 @@ namespace GUIEngine
* \return whether this spinner is of "gauge" type
*/
bool isGauge() const { return m_gauge; }
/**
* \return whether this spinner is of "color_slider" type
*/
bool isColorSlider() const { return m_color_slider; }
/**
* \brief retrieve the current value of the spinner
* \return the current value of the spinner, in a int form