#include "guiVolumeChange.h"
#include "debug.h"
+#include "guiButton.h"
#include "serialization.h"
#include <string>
#include <IGUICheckBox.h>
GUIVolumeChange::GUIVolumeChange(gui::IGUIEnvironment* env,
gui::IGUIElement* parent, s32 id,
- IMenuManager *menumgr
+ IMenuManager *menumgr, ISimpleTextureSource *tsrc
):
- GUIModalMenu(env, parent, id, menumgr)
+ GUIModalMenu(env, parent, id, menumgr),
+ m_tsrc(tsrc)
{
}
if (gui::IGUIElement *e = getElementFromId(ID_soundSlider))
e->remove();
+
+ if (gui::IGUIElement *e = getElementFromId(ID_soundMuteButton))
+ e->remove();
}
void GUIVolumeChange::regenerateGui(v2u32 screensize)
Remove stuff
*/
removeChildren();
-
/*
Calculate new sizes and positions
*/
+ const float s = m_gui_scale;
DesiredRect = core::rect<s32>(
- screensize.X/2 - 380/2,
- screensize.Y/2 - 200/2,
- screensize.X/2 + 380/2,
- screensize.Y/2 + 200/2
+ screensize.X / 2 - 380 * s / 2,
+ screensize.Y / 2 - 200 * s / 2,
+ screensize.X / 2 + 380 * s / 2,
+ screensize.Y / 2 + 200 * s / 2
);
recalculateAbsolutePosition(false);
Add stuff
*/
{
- core::rect<s32> rect(0, 0, 160, 20);
- rect = rect + v2s32(size.X / 2 - 80, size.Y / 2 - 70);
+ core::rect<s32> rect(0, 0, 160 * s, 20 * s);
+ rect = rect + v2s32(size.X / 2 - 80 * s, size.Y / 2 - 70 * s);
const wchar_t *text = wgettext("Sound Volume: ");
core::stringw volume_text = text;
true, this, ID_soundText);
}
{
- core::rect<s32> rect(0, 0, 80, 30);
- rect = rect + v2s32(size.X/2-80/2, size.Y/2+55);
+ core::rect<s32> rect(0, 0, 80 * s, 30 * s);
+ rect = rect + v2s32(size.X / 2 - 80 * s / 2, size.Y / 2 + 55 * s);
const wchar_t *text = wgettext("Exit");
- Environment->addButton(rect, this, ID_soundExitButton,
- text);
+ GUIButton::addButton(Environment, rect, m_tsrc, this, ID_soundExitButton, text);
delete[] text;
}
{
- core::rect<s32> rect(0, 0, 300, 20);
- rect = rect + v2s32(size.X / 2 - 150, size.Y / 2);
+ core::rect<s32> rect(0, 0, 300 * s, 20 * s);
+ rect = rect + v2s32(size.X / 2 - 150 * s, size.Y / 2);
gui::IGUIScrollBar *e = Environment->addScrollBar(true,
rect, this, ID_soundSlider);
e->setMax(100);
e->setPos(volume);
}
{
- core::rect<s32> rect(0, 0, 160, 20);
- rect = rect + v2s32(size.X / 2 - 80, size.Y / 2 - 35);
+ core::rect<s32> rect(0, 0, 160 * s, 20 * s);
+ rect = rect + v2s32(size.X / 2 - 80 * s, size.Y / 2 - 35 * s);
const wchar_t *text = wgettext("Muted");
Environment->addCheckBox(g_settings->getBool("mute_sound"), rect, this,
ID_soundMuteButton, text);
if (event.GUIEvent.EventType == gui::EGET_ELEMENT_FOCUS_LOST
&& isVisible()) {
if (!canTakeFocus(event.GUIEvent.Element)) {
- dstream << "GUIMainMenu: Not allowing focus change."
+ infostream << "GUIVolumeChange: Not allowing focus change."
<< std::endl;
// Returning true disables focus change
return true;
return Parent ? Parent->OnEvent(event) : false;
}
-