@@ -30,10 +30,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30
30
31
31
#include " gettext.h"
32
32
33
- const int ID_soundText1 = 263 ;
34
- const int ID_soundText2 = 264 ;
35
- const int ID_soundExitButton = 265 ;
36
- const int ID_soundSlider = 266 ;
33
+ const int ID_soundText = 263 ;
34
+ const int ID_soundExitButton = 264 ;
35
+ const int ID_soundSlider = 265 ;
37
36
38
37
GUIVolumeChange::GUIVolumeChange (gui::IGUIEnvironment* env,
39
38
gui::IGUIElement* parent, s32 id,
@@ -50,10 +49,7 @@ GUIVolumeChange::~GUIVolumeChange()
50
49
51
50
void GUIVolumeChange::removeChildren ()
52
51
{
53
- if (gui::IGUIElement *e = getElementFromId (ID_soundText1))
54
- e->remove ();
55
-
56
- if (gui::IGUIElement *e = getElementFromId (ID_soundText2))
52
+ if (gui::IGUIElement *e = getElementFromId (ID_soundText))
57
53
e->remove ();
58
54
59
55
if (gui::IGUIElement *e = getElementFromId (ID_soundExitButton))
@@ -73,34 +69,31 @@ void GUIVolumeChange::regenerateGui(v2u32 screensize)
73
69
/*
74
70
Calculate new sizes and positions
75
71
*/
76
- core::rect<s32> rect (
77
- screensize.X /2 - 380 /2 ,
78
- screensize.Y /2 - 200 /2 ,
79
- screensize.X /2 + 380 /2 ,
80
- screensize.Y /2 + 200 /2
72
+ DesiredRect = core::rect<s32>(
73
+ screensize.X /2 - 380 /2 ,
74
+ screensize.Y /2 - 200 /2 ,
75
+ screensize.X /2 + 380 /2 ,
76
+ screensize.Y /2 + 200 /2
81
77
);
82
-
83
- DesiredRect = rect;
84
78
recalculateAbsolutePosition (false );
85
79
86
- v2s32 size = rect.getSize ();
87
- int volume = (int )(g_settings->getFloat (" sound_volume" )*100 );
80
+ v2s32 size = DesiredRect.getSize ();
81
+ int volume = (int )(g_settings->getFloat (" sound_volume" ) * 100 );
82
+
88
83
/*
89
84
Add stuff
90
85
*/
91
86
{
92
- core::rect<s32> rect (0 , 0 , 120 , 20 );
93
- rect = rect + v2s32 (size.X /2 -60 , size.Y /2 -35 );
87
+ core::rect<s32> rect (0 , 0 , 160 , 20 );
88
+ rect = rect + v2s32 (size.X / 2 - 80 , size.Y / 2 - 35 );
89
+
94
90
const wchar_t *text = wgettext (" Sound Volume: " );
95
- Environment->addStaticText (text, rect, false ,
96
- true , this , ID_soundText1);
97
- delete[] text;
98
- }
99
- {
100
- core::rect<s32> rect (0 , 0 , 30 , 20 );
101
- rect = rect + v2s32 (size.X /2 +40 , size.Y /2 -35 );
102
- Environment->addStaticText (core::stringw (volume).c_str (), rect, false ,
103
- true , this , ID_soundText2);
91
+ core::stringw volume_text = text;
92
+ delete [] text;
93
+
94
+ volume_text += core::stringw (volume) + core::stringw (" %" );
95
+ Environment->addStaticText (volume_text.c_str (), rect, false ,
96
+ true , this , ID_soundText);
104
97
}
105
98
{
106
99
core::rect<s32> rect (0 , 0 , 80 , 30 );
@@ -155,10 +148,15 @@ bool GUIVolumeChange::OnEvent(const SEvent& event)
155
148
if (event.GUIEvent .EventType == gui::EGET_SCROLL_BAR_CHANGED) {
156
149
if (event.GUIEvent .Caller ->getID () == ID_soundSlider) {
157
150
s32 pos = ((gui::IGUIScrollBar*)event.GUIEvent .Caller )->getPos ();
158
- g_settings->setFloat (" sound_volume" , (float )pos/100 );
151
+ g_settings->setFloat (" sound_volume" , (float ) pos / 100 );
152
+
153
+ gui::IGUIElement *e = getElementFromId (ID_soundText);
154
+ const wchar_t *text = wgettext (" Sound Volume: " );
155
+ core::stringw volume_text = text;
156
+ delete [] text;
159
157
160
- gui::IGUIElement *e = getElementFromId (ID_soundText2 );
161
- e->setText (core::stringw (pos) .c_str ());
158
+ volume_text += core::stringw (pos) + core::stringw ( " % " );
159
+ e->setText (volume_text .c_str ());
162
160
return true ;
163
161
}
164
162
}
0 commit comments