From 4f93cf68cc0a3fa99a947e92887c7bce7558ead0 Mon Sep 17 00:00:00 2001 From: luk3yx Date: Wed, 8 Mar 2023 11:59:21 +1300 Subject: [PATCH] Make guiVolumeChange use custom scrollbar --- src/gui/guiVolumeChange.cpp | 17 ++++++++++++----- textures/base/pack/gui/scrollbar_horiz_bg.png | Bin 0 -> 78 bytes textures/base/pack/gui/scrollbar_minus.png | Bin 0 -> 465 bytes textures/base/pack/gui/scrollbar_plus.png | Bin 0 -> 479 bytes textures/base/pack/gui/scrollbar_slider.png | Bin 0 -> 361 bytes 5 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 textures/base/pack/gui/scrollbar_horiz_bg.png create mode 100644 textures/base/pack/gui/scrollbar_minus.png create mode 100644 textures/base/pack/gui/scrollbar_plus.png create mode 100644 textures/base/pack/gui/scrollbar_slider.png diff --git a/src/gui/guiVolumeChange.cpp b/src/gui/guiVolumeChange.cpp index 45444c47c..fbd192108 100644 --- a/src/gui/guiVolumeChange.cpp +++ b/src/gui/guiVolumeChange.cpp @@ -21,11 +21,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "debug.h" #include "guiBackgroundImage.h" #include "guiButton.h" +#include "guiScrollBar.h" #include "serialization.h" #include #include #include -#include #include #include #include "settings.h" @@ -139,12 +139,19 @@ void GUIVolumeChange::regenerateGui(v2u32 screensize) e->setStyles(StyleSpec::getButtonStyle()); } { - core::rect rect(0, 0, 320 * s, 25 * s); + core::rect rect(0, 0, 320 * s, 30 * s); rect = rect + v2s32(size.X / 2 - 160 * s, size.Y / 2 - 12 * s); // 30 - gui::IGUIScrollBar *e = Environment->addScrollBar(true, - rect, this, ID_soundSlider); + GUIScrollBar *e = new GUIScrollBar(Environment, this, + ID_soundSlider, rect, true, false); e->setMax(100); e->setPos(volume); + e->setArrowsVisible(GUIScrollBar::ArrowVisibility::SHOW); + e->setTextures({ + m_tsrc->getTexture("gui/scrollbar_horiz_bg.png"), + m_tsrc->getTexture("gui/scrollbar_slider.png"), + m_tsrc->getTexture("gui/scrollbar_minus.png"), + m_tsrc->getTexture("gui/scrollbar_plus.png"), + }); } /*{ core::rect rect(0, 0, 150 * s, 25 * s); @@ -219,7 +226,7 @@ bool GUIVolumeChange::OnEvent(const SEvent& event) } if (event.GUIEvent.EventType == gui::EGET_SCROLL_BAR_CHANGED) { if (event.GUIEvent.Caller->getID() == ID_soundSlider) { - s32 pos = ((gui::IGUIScrollBar*)event.GUIEvent.Caller)->getPos(); + s32 pos = ((GUIScrollBar*)event.GUIEvent.Caller)->getPos(); g_settings->setFloat("sound_volume", (float) pos / 100); // unmute sound when changing the volume diff --git a/textures/base/pack/gui/scrollbar_horiz_bg.png b/textures/base/pack/gui/scrollbar_horiz_bg.png new file mode 100644 index 0000000000000000000000000000000000000000..0cfff289f348c3fb0844830b6647b93ee426a3dc GIT binary patch literal 78 zcmeAS@N?(olHy`uVBq!ia0vp^j6m$b!2~2jio3*tl&GhRV@L&K@`dhr#$$%2;ch~0 bKcyKeSTa>LK1kRD6)zJ(QE?=l_ir&P~@_m-#|Ns9TJZhDy z=#Zu6K6S>2pXKWB_C0mPh@a)$U@H01!h_GjqA!|2{h&gUoc4#P2)0A(Juf>r_d?0x-@pON;vAQNL2!=DI8Z z<1Qdb$D=tBka?hGnXi3oZ;N$bg$U@pC@c%(<;DaXkojor&l)mZp#J-U059=30zn3( z?K%4R=m-+f&86WyU&wC*;5Zz>vhW3#=4cE!5($t1V7^1}0iC}Fh@$%e#cB@%q%GjH z@7Vx`KicDfI9>*pGEF}4{vJysKr+q0#a;zq{!Cyk0Itgd>f6+*)0q!QS1ziq#01XY zSX{}r89&SE#Ww49yBW{3_Y(bIY5#)+R=yY zN(&_p&=IZ%1S5obo>KuOY}?(*o5TW;EuBM%0Fd3vK?L9*tbfeWONxEl00000NkvXX Hu0mjf@_5zT literal 0 HcmV?d00001 diff --git a/textures/base/pack/gui/scrollbar_plus.png b/textures/base/pack/gui/scrollbar_plus.png new file mode 100644 index 0000000000000000000000000000000000000000..cbf5a2d5f900efe1a2efda37aa3ef10b83187489 GIT binary patch literal 479 zcmV<50U-W~P)3PjSot|NnxTzNzBmptu2mk||s{j)h$Q9sR29iWoIRkzFb)c^GlUOb=j@bk7 z9#{+X%D@@&1%}~c;4CZ|pyv#zt}_LIfuM#FLZIvLL5gZvDlo!J0}%r?WebGA3H^2M zK>VOA7zjQOl%*{I;*SMt2ydU7=M69s<_vJo!0A+iClJo+1B~?Jlg_W#vYh9l@CTUC zI7a|%0r=U0rkEQ8bdfmb+#BGFs3W(CO5ofT;2|3+WnzW`e1X-Eh_NX!{YnAWz#F-P V;~}QQXrz|NpBzjEsv2mSM6$=M!vJ+{i9AB%cn$+79o5>Jog8))(7q`qa6sP^kc{<< zLIw;_;atDT6G&hjLqKO521j6lbZ%bc2oFdJ0;m`;JH>#Mc)-u|1QM9%6PT%g2b4Mi zMSTXG0AnbiX?_- z0?LkUVOuB=K(db7pZd8mIKVxOd^`yS_<1>k0jk2LAOLU!_1k#?_q$(t00000NkvXX Hu0mjf6;qt& literal 0 HcmV?d00001