aboutsummaryrefslogtreecommitdiff
path: root/games/minimal/mods/legacy
diff options
context:
space:
mode:
authorVincent Glize <vincentglize@hotmail.fr>2017-06-21 08:28:57 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-06-21 08:28:57 +0200
commit8daf5b5338647373baffe045d728ea1734c63789 (patch)
tree945a21e5c5b94b8e62eb43400a124205bc6b5d27 /games/minimal/mods/legacy
parentaf3badf7a9307acd4993764cd805718849e4f942 (diff)
downloadminetest-8daf5b5338647373baffe045d728ea1734c63789.tar.gz
minetest-8daf5b5338647373baffe045d728ea1734c63789.tar.bz2
minetest-8daf5b5338647373baffe045d728ea1734c63789.zip
C++11 cleanup on constructors dir network (#6021)
* C++11 cleanup on constructors dir network
Diffstat (limited to 'games/minimal/mods/legacy')
0 files changed, 0 insertions, 0 deletions
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
/*
Part of Minetest
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2013 Ciaran Gultnieks <ciaran@ciarang.com>
Copyright (C) 2013 RealBadAngel, Maciej Kasatkin <mk@realbadangel.pl>

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include "guiVolumeChange.h"
#include "debug.h"
#include "serialization.h"
#include <string>
#include <IGUICheckBox.h>
#include <IGUIButton.h>
#include <IGUIScrollBar.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
#include "main.h"
#include "settings.h"

#include "gettext.h"

const int ID_soundText1 = 263;
const int ID_soundText2 = 264;
const int ID_soundExitButton = 265;
const int ID_soundSlider = 266;

GUIVolumeChange::GUIVolumeChange(gui::IGUIEnvironment* env,
		gui::IGUIElement* parent, s32 id,
		IMenuManager *menumgr,
		Client* client
):
	GUIModalMenu(env, parent, id, menumgr)
{
}

GUIVolumeChange::~GUIVolumeChange()
{
	removeChildren();
}

void GUIVolumeChange::removeChildren()
{
	{
		gui::IGUIElement *e = getElementFromId(ID_soundText1);
		if(e != NULL)
			e->remove();
	}
	{
		gui::IGUIElement *e = getElementFromId(ID_soundText2);
		if(e != NULL)
			e->remove();
	}
	{
		gui::IGUIElement *e = getElementFromId(ID_soundExitButton);
		if(e != NULL)
			e->remove();
	}
	{
		gui::IGUIElement *e = getElementFromId(ID_soundSlider);
		if(e != NULL)
			e->remove();
	}
}

void GUIVolumeChange::regenerateGui(v2u32 screensize)
{
	/*
		Remove stuff
	*/
	removeChildren();
	
	/*
		Calculate new sizes and positions
	*/
	core::rect<s32> rect(
			screensize.X/2 - 380/2,
			screensize.Y/2 - 200/2,
			screensize.X/2 + 380/2,
			screensize.Y/2 + 200/2
	);
	
	DesiredRect = rect;
	recalculateAbsolutePosition(false);

	v2s32 size = rect.getSize();
	v2s32 topleft_client(40, 0);
	int volume=(int)(g_settings->getFloat("sound_volume")*100);
	/*
		Add stuff
	*/
	{
		core::rect<s32> rect(0, 0, 120, 20);
		rect = rect + v2s32(size.X/2-60, size.Y/2-35);
		const wchar_t *text = wgettext("Sound Volume: ");
		Environment->addStaticText(text, rect, false,
				true, this, ID_soundText1);
		delete[] text;
	}
	{
		core::rect<s32> rect(0, 0, 30, 20);
		rect = rect + v2s32(size.X/2+40, size.Y/2-35);
		Environment->addStaticText(core::stringw(volume).c_str(), rect, false,
				true, this, ID_soundText2);
	}