1
0
Fork 0

Improve change keys, change volume and change password menus (#94)

Co-authored-by: Maksym H <Maksym48@pm.me>
main-2-0-3
luk3yx 2022-09-08 21:52:31 +12:00 committed by GitHub
parent 087a56cf06
commit 4918f6a50f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 187 additions and 76 deletions

View File

@ -1957,7 +1957,7 @@ msgstr "La tecla s'està utilitzant"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr ""
"Combinacions de tecles. (Si aquest menú espatlla, esborrar coses de minetest."
"Combinacions de tecles. (Si aquest menú espatlla, esborrar coses de multicraft."
"conf)"
#: src/gui/guiKeyChangeMenu.cpp

View File

@ -1919,7 +1919,7 @@ msgstr "Tast allerede i brug"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr ""
"Tastebindinger. (Hvis denne menu fucker op, fjern elementer fra minetest."
"Tastebindinger. (Hvis denne menu fucker op, fjern elementer fra multicraft."
"conf)"
#: src/gui/guiKeyChangeMenu.cpp

View File

@ -1869,7 +1869,7 @@ msgstr "Taste bereits in Benutzung"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr ""
"Steuerung (Falls dieses Menü defekt ist, entfernen Sie Zeugs aus minetest."
"Steuerung (Falls dieses Menü defekt ist, entfernen Sie Zeugs aus multicraft."
"conf)"
#: src/gui/guiKeyChangeMenu.cpp

View File

@ -1868,7 +1868,7 @@ msgstr "La tecla ya se está utilizando"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr ""
"Combinaciones de teclas. (Si este menú da error, elimina líneas en minetest."
"Combinaciones de teclas. (Si este menú da error, elimina líneas en multicraft."
"conf)"
#: src/gui/guiKeyChangeMenu.cpp

View File

@ -1859,7 +1859,7 @@ msgstr "Nupp juba kasutuses"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr ""
"Nupusätted. (Kui see menüü sassi läheb, siis kustuta asju failist minetest."
"Nupusätted. (Kui see menüü sassi läheb, siis kustuta asju failist multicraft."
"conf)"
#: src/gui/guiKeyChangeMenu.cpp

View File

@ -1848,7 +1848,7 @@ msgid "Key already in use"
msgstr ""
#: src/gui/guiKeyChangeMenu.cpp
msgid "Keybindings. (If this menu screws up, remove stuff from minetest.conf)"
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr ""
#: src/gui/guiKeyChangeMenu.cpp

View File

@ -1818,7 +1818,7 @@ msgid "Key already in use"
msgstr ""
#: src/gui/guiKeyChangeMenu.cpp
msgid "Keybindings. (If this menu screws up, remove stuff from minetest.conf)"
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr ""
#: src/gui/guiKeyChangeMenu.cpp

View File

@ -1857,7 +1857,7 @@ msgstr "מקש כבר בשימוש"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr "קישור מקשים (אם התפריט מתקלקל, הסר דברים מminetest.conf)"
msgstr "קישור מקשים (אם התפריט מתקלקל, הסר דברים מmulticraft.conf)"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Local command"

View File

@ -1870,9 +1870,9 @@ msgid "Key already in use"
msgstr "ککونچي تله دݢوناکن اونتوق فوڠسي لاٴين"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Keybindings. (If this menu screws up, remove stuff from minetest.conf)"
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr ""
"ايکتن ککونچي. (جيک مينو اين برسليرق⹁ ڤادم سستڠه بندا دري فايل minetest.conf)"
"ايکتن ککونچي. (جيک مينو اين برسليرق⹁ ڤادم سستڠه بندا دري فايل multicraft.conf)"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Local command"

View File

@ -1867,7 +1867,7 @@ msgstr "Tast allerede i bruk"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr ""
"Tastaturtilknytninger. (Hvis dette byr på problemer, fjern ting fra minetest."
"Tastaturtilknytninger. (Hvis dette byr på problemer, fjern ting fra multicraft."
"conf)"
#: src/gui/guiKeyChangeMenu.cpp

View File

@ -1886,7 +1886,7 @@ msgstr "Knapp er allereie i bruk"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr ""
"Knappebindinger. (Om denne menyen går galen, ta bort tinga fra \"minetest."
"Knappebindinger. (Om denne menyen går galen, ta bort tinga fra \"multicraft."
"conf\")"
#: src/gui/guiKeyChangeMenu.cpp

View File

@ -1866,7 +1866,7 @@ msgstr "Essa tecla já está em uso"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr ""
"Teclas (se este menu estiver com problema, remova itens do arquivo minetest."
"Teclas (se este menu estiver com problema, remova itens do arquivo multicraft."
"conf)"
#: src/gui/guiKeyChangeMenu.cpp

View File

@ -1866,7 +1866,7 @@ msgstr "Клавиша уже используется"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr ""
"Привязки клавиш. (Если это меню сломается, удалите настройки из minetest."
"Привязки клавиш. (Если это меню сломается, удалите настройки из multicraft."
"conf)"
#: src/gui/guiKeyChangeMenu.cpp

View File

@ -1869,9 +1869,9 @@ msgid "Key already in use"
msgstr "Klávesa sa už používa"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Keybindings. (If this menu screws up, remove stuff from minetest.conf)"
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr ""
"Priradenie kláves. (ak je toto menu rozbité, zmaž zbytočnosti z minetest."
"Priradenie kláves. (ak je toto menu rozbité, zmaž zbytočnosti z multicraft."
"conf)"
#: src/gui/guiKeyChangeMenu.cpp

View File

@ -1908,7 +1908,7 @@ msgstr "Tipka je že v uporabi"
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr ""
"Vloge tipk (če ta meni preneha delovati, odstranite nastavitve tipk iz "
"datoteke minetest.conf)"
"datoteke multicraft.conf)"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Local command"

View File

@ -1926,7 +1926,7 @@ msgstr "Tangent används redan"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr ""
"Tangentbindningar. (Om den här menyn strular, radera saker från minetest."
"Tangentbindningar. (Om den här menyn strular, radera saker från multicraft."
"conf)"
#: src/gui/guiKeyChangeMenu.cpp

View File

@ -1872,7 +1872,7 @@ msgstr "Клавіша вже використовується"
#: src/gui/guiKeyChangeMenu.cpp
msgid "Keybindings. (If this menu screws up, remove stuff from multicraft.conf)"
msgstr ""
"Комбінації клавіш. (Якщо це меню зламалося, видаліть налаштування з minetest."
"Комбінації клавіш. (Якщо це меню зламалося, видаліть налаштування з multicraft."
"conf)"
#: src/gui/guiKeyChangeMenu.cpp

View File

@ -4363,9 +4363,9 @@ void Game::showPauseMenu()
<< "no_prepend[]"
<< "bgcolor[#00000060;true]"
<< "style_type[image_button_exit,image_button;bgimg=gui_button.png;bgimg_middle=20;padding=-5]"
<< "style_type[image_button_exit,image_button:hovered;bgimg=gui_button_hovered.png;bgimg_middle=20]"
<< "style_type[image_button_exit,image_button:pressed;bgimg=gui_button_pressed.png;bgimg_middle=20]"
<< "style_type[image_button_exit,image_button;bgimg=gui_button.png;bgimg_middle=20;padding=-10]"
<< "style_type[image_button_exit,image_button:hovered;bgimg=gui_button_hovered.png]"
<< "style_type[image_button_exit,image_button:pressed;bgimg=gui_button_pressed.png]"
<< "image_button_exit[3.5," << (ypos++) << ";4,0.9;;btn_continue;"
<< strgettext("Continue") << ";;false]";
@ -4375,13 +4375,13 @@ void Game::showPauseMenu()
<< strgettext("Change Password") << ";;false]";
}
#if !defined(__ANDROID__) && !defined(__IOS__)
#if USE_SOUND
if (g_settings->getBool("enable_sound")) {
os << "image_button_exit[3.5," << (ypos++) << ";4,0.9;;btn_sound;"
<< strgettext("Sound Volume") << ";;false]";
}
#endif
#if !defined(__ANDROID__) && !defined(__IOS__)
os << "image_button_exit[3.5," << (ypos++) << ";4,0.9;;btn_key_config;"
<< strgettext("Change Keys") << ";;false]";
#endif
@ -4457,18 +4457,21 @@ void Game::showChangePasswordDialog(std::string old_pw, std::string new_pw,
std::ostringstream os;
os << "formspec_version[5]"
<< "size[10.5,7.9]"
<< "size[10.5,7.5]"
<< "no_prepend[]"
<< "bgcolor[#320000b4;true]"
<< "background9[0,0;0,0;bg_common.png;true;40]"
<< "pwdfield[1,1.4;8.5,0.8;old_pw;" << strgettext("Old Password") << ":;" << old_pw << "]"
<< "pwdfield[1,3;8.5,0.8;new_pw;" << strgettext("New Password") << ":;" << new_pw << "]"
<< "pwdfield[1,4.6;8.5,0.8;confirm_pw;" << strgettext("Confirm Password") << ":;" << confirm_pw << "]"
<< "button[1,5.9;4.1,0.8;btn_change_pw;" << strgettext("Change") << "]"
<< "button_exit[5.4,5.9;4.1,0.8;btn_cancel;" << strgettext("Cancel") << "]";
<< "pwdfield[1,1.2;8.5,0.8;old_pw;" << strgettext("Old Password") << ":;" << old_pw << "]"
<< "pwdfield[1,2.8;8.5,0.8;new_pw;" << strgettext("New Password") << ":;" << new_pw << "]"
<< "pwdfield[1,4.4;8.5,0.8;confirm_pw;" << strgettext("Confirm Password") << ":;" << confirm_pw << "]"
<< "style_type[image_button_exit,image_button;bgimg=gui_button.png;bgimg_middle=20;padding=-10]"
<< "style_type[image_button_exit,image_button:hovered;bgimg=gui_button_hovered.png]"
<< "style_type[image_button_exit,image_button:pressed;bgimg=gui_button_pressed.png]"
<< "image_button[1,5.9;4.1,0.8;;btn_change_pw;" << strgettext("Change") << ";;false]"
<< "image_button_exit[5.4,5.9;4.1,0.8;;btn_cancel;" << strgettext("Cancel") << ";;false]";
if (new_pw != confirm_pw)
os << "label[1,7.2;\x1b(c@red)" << strgettext("Passwords do not match!") << "]";
os << "label[1,7.1;\x1b(c@red)" << strgettext("Passwords do not match!") << "]";
/* Create menu */
/* Note: FormspecFormSource and LocalFormspecHandler *

View File

@ -70,6 +70,30 @@ public:
STATE_INVALID = 1 << 3,
};
// Used in guiKeyChangeMenu.cpp and guiVolumeChange.h
// Is this the best place to put this function?
static std::array<StyleSpec, NUM_STATES> getButtonStyle(const std::string texture_path = "") {
std::array<StyleSpec, NUM_STATES> ret;
StyleSpec btn_spec;
btn_spec.set(BGIMG, texture_path + "gui_button.png");
btn_spec.set(BGIMG_MIDDLE, "20");
btn_spec.set(BORDER, "false");
btn_spec.set(PADDING, "-10");
ret[STATE_DEFAULT] = btn_spec;
StyleSpec hovered_spec;
hovered_spec.set(BGIMG, texture_path + "gui_button_hovered.png");
ret[STATE_HOVERED] = hovered_spec;
StyleSpec pressed_spec;
pressed_spec.set(BGIMG, texture_path + "gui_button_pressed.png");
ret[STATE_PRESSED] = pressed_spec;
return ret;
}
private:
std::array<bool, NUM_PROPERTIES> property_set{};
std::array<std::string, NUM_PROPERTIES> properties;

View File

@ -21,6 +21,7 @@
#include "guiKeyChangeMenu.h"
#include "debug.h"
#include "guiBackgroundImage.h"
#include "guiButton.h"
#include "serialization.h"
#include <string>
@ -29,7 +30,10 @@
#include <IGUIButton.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
#include "filesys.h"
#include "porting.h"
#include "settings.h"
#include "StyleSpec.h"
#include <algorithm>
#include "mainmenumanager.h" // for g_gamecallback
@ -42,6 +46,7 @@ extern MainGameCallback *g_gamecallback;
enum
{
GUI_ID_BACK_BUTTON = 101, GUI_ID_ABORT_BUTTON, GUI_ID_SCROLL_BAR,
GUI_ID_BACKGROUND_IMG,
// buttons
GUI_ID_KEY_FORWARD_BUTTON,
GUI_ID_KEY_BACKWARD_BUTTON,
@ -84,11 +89,21 @@ enum
GUIKeyChangeMenu::GUIKeyChangeMenu(gui::IGUIEnvironment* env,
gui::IGUIElement* parent, s32 id, IMenuManager *menumgr,
ISimpleTextureSource *tsrc) :
ISimpleTextureSource *tsrc, bool main_menu) :
GUIModalMenu(env, parent, id, menumgr),
m_tsrc(tsrc)
m_tsrc(tsrc),
m_main_menu(main_menu)
{
init_keys();
if (m_main_menu) return;
v3f formspec_bgcolor = g_settings->getV3F("formspec_fullscreen_bg_color");
m_fullscreen_bgcolor = video::SColor(
(u8) MYMIN(MYMAX(g_settings->getS32("formspec_fullscreen_bg_opacity"), 0), 255),
MYMIN(MYMAX(myround(formspec_bgcolor.X), 0), 255),
MYMIN(MYMAX(myround(formspec_bgcolor.Y), 0), 255),
MYMIN(MYMAX(myround(formspec_bgcolor.Z), 0), 255)
);
}
GUIKeyChangeMenu::~GUIKeyChangeMenu()
@ -120,13 +135,20 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
{
removeChildren();
#ifdef HAVE_TOUCHSCREENGUI
const float s = m_gui_scale * RenderingEngine::getDisplayDensity() / 1.5;
#elif defined(__MACH__) && defined(__APPLE__) && !defined(__IOS__)
const float s = m_gui_scale * RenderingEngine::getDisplayDensity() * 1.5;
float s = MYMIN(screensize.X / 835.f, screensize.Y / 430.f);
#if HAVE_TOUCHSCREENGUI
s *= g_settings->getBool("device_is_tablet") ? 0.8f : 0.9f;
#else
const float s = m_gui_scale;
s *= 0.75f;
#endif
// Make sure the GUI will fit on the screen
// The change keys GUI is 835x430 pixels (with a scaling of 1)
if (835 * s > screensize.X)
s = screensize.X / 835.f;
if (430 * s > screensize.Y)
s = screensize.Y / 430.f;
DesiredRect = core::rect<s32>(
screensize.X / 2 - 835 * s / 2,
screensize.Y / 2 - 430 * s / 2,
@ -138,11 +160,29 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
v2s32 size = DesiredRect.getSize();
v2s32 topleft(0, 0);
std::string texture_path = "";
if (m_main_menu)
texture_path = porting::path_share + DIR_DELIM "textures" DIR_DELIM
"base" DIR_DELIM "pack" DIR_DELIM;
// Background image
{
core::rect<s32> rect(0, 0, 600 * s, 40 * s);
rect += topleft + v2s32(25 * s, 3 * s);
const std::string texture = texture_path + "bg_common.png";
const core::rect<s32> rect(0, 0, 0, 0);
const core::rect<s32> middle(40, 40, -40, -40);
new GUIBackgroundImage(Environment, this, GUI_ID_BACKGROUND_IMG, rect,
texture, middle, m_tsrc, true);
}
{
core::rect<s32> rect(0, 0, 795 * s, 50 * s);
rect += topleft + v2s32(25 * s, 10 * s);
//gui::IGUIStaticText *t =
#if !defined(__ANDROID__) && !defined(__IOS__)
const wchar_t *text = wgettext("Keybindings. (If this menu screws up, remove stuff from multicraft.conf)");
#else
const wchar_t *text = wgettext("Change Keys");
#endif
Environment->addStaticText(text,
rect, false, true, this, -1);
delete[] text;
@ -180,7 +220,7 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
{
s32 option_x = offset.X;
s32 option_y = offset.Y + 5 * s;
u32 option_w = 180 * s;
u32 option_w = 300 * s;
{
core::rect<s32> rect(0, 0, option_w, 30 * s);
rect += topleft + v2s32(option_x, option_y);
@ -195,7 +235,7 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
{
s32 option_x = offset.X;
s32 option_y = offset.Y + 5 * s;
u32 option_w = 280 * s;
u32 option_w = 300 * s;
{
core::rect<s32> rect(0, 0, option_w, 30 * s);
rect += topleft + v2s32(option_x, option_y);
@ -210,7 +250,7 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
{
s32 option_x = offset.X;
s32 option_y = offset.Y + 5 * s;
u32 option_w = 280;
u32 option_w = 300 * s;
{
core::rect<s32> rect(0, 0, option_w, 30 * s);
rect += topleft + v2s32(option_x, option_y);
@ -222,18 +262,23 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
offset += v2s32(0, 25);
}
const std::array<StyleSpec, StyleSpec::NUM_STATES> styles =
StyleSpec::getButtonStyle(texture_path);
{
core::rect<s32> rect(0, 0, 100 * s, 30 * s);
rect += topleft + v2s32(size.X / 2 - 105 * s, size.Y - 40 * s);
const wchar_t *text = wgettext("Save");
GUIButton::addButton(Environment, rect, m_tsrc, this, GUI_ID_BACK_BUTTON, text);
core::rect<s32> rect(0, 0, 150 * s, 35 * s);
rect += topleft + v2s32(size.X / 2 - 165 * s, size.Y - 50 * s);
const wchar_t *text = wgettext("Save");
GUIButton *e = GUIButton::addButton(Environment, rect, m_tsrc, this, GUI_ID_BACK_BUTTON, text);
e->setStyles(styles);
delete[] text;
}
{
core::rect<s32> rect(0, 0, 100 * s, 30 * s);
rect += topleft + v2s32(size.X / 2 + 5 * s, size.Y - 40 * s);
core::rect<s32> rect(0, 0, 150 * s, 35 * s);
rect += topleft + v2s32(size.X / 2 + 15 * s, size.Y - 50 * s);
const wchar_t *text = wgettext("Cancel");
GUIButton::addButton(Environment, rect, m_tsrc, this, GUI_ID_ABORT_BUTTON, text);
GUIButton *e = GUIButton::addButton(Environment, rect, m_tsrc, this, GUI_ID_ABORT_BUTTON, text);
e->setStyles(styles);
delete[] text;
}
}
@ -243,10 +288,13 @@ void GUIKeyChangeMenu::drawMenu()
gui::IGUISkin* skin = Environment->getSkin();
if (!skin)
return;
video::IVideoDriver* driver = Environment->getVideoDriver();
video::SColor bgcolor(140, 0, 0, 0);
driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect);
if (!m_main_menu) {
video::IVideoDriver* driver = Environment->getVideoDriver();
v2u32 screenSize = driver->getScreenSize();
core::rect<s32> allbg(0, 0, screenSize.X, screenSize.Y);
driver->draw2DRectangle(m_fullscreen_bgcolor, allbg, &allbg);
}
gui::IGUIElement::draw();
}

View File

@ -43,7 +43,8 @@ class GUIKeyChangeMenu : public GUIModalMenu
{
public:
GUIKeyChangeMenu(gui::IGUIEnvironment *env, gui::IGUIElement *parent, s32 id,
IMenuManager *menumgr, ISimpleTextureSource *tsrc);
IMenuManager *menumgr, ISimpleTextureSource *tsrc,
bool main_menu = false);
~GUIKeyChangeMenu();
void removeChildren();
@ -77,4 +78,7 @@ private:
gui::IGUIStaticText *key_used_text = nullptr;
std::vector<key_setting *> key_settings;
ISimpleTextureSource *m_tsrc;
bool m_main_menu = false;
video::SColor m_fullscreen_bgcolor;
};

View File

@ -19,6 +19,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "guiVolumeChange.h"
#include "debug.h"
#include "guiBackgroundImage.h"
#include "guiButton.h"
#include "serialization.h"
#include <string>
@ -28,10 +29,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <IGUIStaticText.h>
#include <IGUIFont.h>
#include "settings.h"
#include "StyleSpec.h"
#include "gettext.h"
#include "client/renderingengine.h"
const int ID_backgroundImage = 262;
const int ID_soundText = 263;
const int ID_soundExitButton = 264;
const int ID_soundSlider = 265;
@ -44,6 +47,13 @@ GUIVolumeChange::GUIVolumeChange(gui::IGUIEnvironment* env,
GUIModalMenu(env, parent, id, menumgr),
m_tsrc(tsrc)
{
v3f formspec_bgcolor = g_settings->getV3F("formspec_fullscreen_bg_color");
m_fullscreen_bgcolor = video::SColor(
(u8) MYMIN(MYMAX(g_settings->getS32("formspec_fullscreen_bg_opacity"), 0), 255),
MYMIN(MYMAX(myround(formspec_bgcolor.X), 0), 255),
MYMIN(MYMAX(myround(formspec_bgcolor.Y), 0), 255),
MYMIN(MYMAX(myround(formspec_bgcolor.Z), 0), 255)
);
}
GUIVolumeChange::~GUIVolumeChange()
@ -53,6 +63,9 @@ GUIVolumeChange::~GUIVolumeChange()
void GUIVolumeChange::removeChildren()
{
if (gui::IGUIElement *e = getElementFromId(ID_backgroundImage))
e->remove();
if (gui::IGUIElement *e = getElementFromId(ID_soundText))
e->remove();
@ -75,18 +88,18 @@ void GUIVolumeChange::regenerateGui(v2u32 screensize)
/*
Calculate new sizes and positions
*/
#ifdef HAVE_TOUCHSCREENGUI
const float s = m_gui_scale * RenderingEngine::getDisplayDensity() / 1.5;
#elif defined(__MACH__) && defined(__APPLE__) && !defined(__IOS__)
const float s = m_gui_scale * RenderingEngine::getDisplayDensity() * 1.5;
float s = MYMIN(screensize.X / 380.f, screensize.Y / 180.f);
#if HAVE_TOUCHSCREENGUI
s *= g_settings->getBool("device_is_tablet") ? 0.4f : 0.5f;
#else
const float s = m_gui_scale;
s *= 0.35f;
#endif
DesiredRect = core::rect<s32>(
screensize.X / 2 - 380 * s / 2,
screensize.Y / 2 - 200 * s / 2,
screensize.Y / 2 - 180 * s / 2,
screensize.X / 2 + 380 * s / 2,
screensize.Y / 2 + 200 * s / 2
screensize.Y / 2 + 180 * s / 2 // 200
);
recalculateAbsolutePosition(false);
@ -97,8 +110,15 @@ void GUIVolumeChange::regenerateGui(v2u32 screensize)
Add stuff
*/
{
core::rect<s32> rect(0, 0, 160 * s, 20 * s);
rect = rect + v2s32(size.X / 2 - 80 * s, size.Y / 2 - 70 * s);
const std::string texture = "bg_common.png";
const core::rect<s32> rect(0, 0, 0, 0);
const core::rect<s32> middle(40, 40, -40, -40);
new GUIBackgroundImage(Environment, this, ID_backgroundImage, rect,
texture, middle, m_tsrc, true);
}
{
core::rect<s32> rect(0, 0, 320 * s, 25 * s);
rect = rect + v2s32(30 * s, size.Y / 2 - 35 * s); // 55
const wchar_t *text = wgettext("Sound Volume: ");
core::stringw volume_text = text;
@ -109,28 +129,31 @@ void GUIVolumeChange::regenerateGui(v2u32 screensize)
true, this, ID_soundText);
}
{
core::rect<s32> rect(0, 0, 80 * s, 30 * s);
rect = rect + v2s32(size.X / 2 - 80 * s / 2, size.Y / 2 + 55 * s);
core::rect<s32> rect(0, 0, 80 * s, 35 * s);
rect = rect + v2s32(size.X / 2 - 40 * s, size.Y / 2 + 35 * s); // 45
const wchar_t *text = wgettext("Exit");
GUIButton::addButton(Environment, rect, m_tsrc, this, ID_soundExitButton, text);
GUIButton *e = GUIButton::addButton(Environment, rect, m_tsrc, this,
ID_soundExitButton, text);
delete[] text;
e->setStyles(StyleSpec::getButtonStyle());
}
{
core::rect<s32> rect(0, 0, 300 * s, 20 * s);
rect = rect + v2s32(size.X / 2 - 150 * s, size.Y / 2);
core::rect<s32> rect(0, 0, 320 * s, 25 * 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);
e->setMax(100);
e->setPos(volume);
}
{
core::rect<s32> rect(0, 0, 160 * s, 20 * s);
rect = rect + v2s32(size.X / 2 - 80 * s, size.Y / 2 - 35 * s);
/*{
core::rect<s32> rect(0, 0, 150 * s, 25 * s);
rect = rect + v2s32(30 * s, size.Y / 2 + 5 * s);
const wchar_t *text = wgettext("Muted");
Environment->addCheckBox(g_settings->getBool("mute_sound"), rect, this,
ID_soundMuteButton, text);
delete[] text;
}
}*/
}
void GUIVolumeChange::drawMenu()
@ -139,8 +162,11 @@ void GUIVolumeChange::drawMenu()
if (!skin)
return;
video::IVideoDriver* driver = Environment->getVideoDriver();
video::SColor bgcolor(140, 0, 0, 0);
driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect);
v2u32 screenSize = driver->getScreenSize();
core::rect<s32> allbg(0, 0, screenSize.X, screenSize.Y);
driver->draw2DRectangle(m_fullscreen_bgcolor, allbg, &allbg);
gui::IGUIElement::draw();
}
@ -157,7 +183,7 @@ bool GUIVolumeChange::OnEvent(const SEvent& event)
return true;
}
} else if (event.EventType == EET_GUI_EVENT) {
if (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED) {
/*if (event.GUIEvent.EventType == gui::EGET_CHECKBOX_CHANGED) {
gui::IGUIElement *e = getElementFromId(ID_soundMuteButton);
if (e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) {
g_settings->setBool("mute_sound", ((gui::IGUICheckBox*)e)->isChecked());
@ -165,7 +191,7 @@ bool GUIVolumeChange::OnEvent(const SEvent& event)
Environment->setFocus(this);
return true;
}
}*/
if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED) {
if (event.GUIEvent.Caller->getID() == ID_soundExitButton) {
@ -189,6 +215,10 @@ bool GUIVolumeChange::OnEvent(const SEvent& event)
s32 pos = ((gui::IGUIScrollBar*)event.GUIEvent.Caller)->getPos();
g_settings->setFloat("sound_volume", (float) pos / 100);
// unmute sound when changing the volume
if (g_settings->getBool("mute_sound"))
g_settings->setBool("mute_sound", false);
gui::IGUIElement *e = getElementFromId(ID_soundText);
const wchar_t *text = wgettext("Sound Volume: ");
core::stringw volume_text = text;

View File

@ -51,4 +51,5 @@ protected:
private:
ISimpleTextureSource *m_tsrc;
video::SColor m_fullscreen_bgcolor;
};

View File

@ -409,7 +409,8 @@ int ModApiMainMenu::l_show_keys_menu(lua_State *L)
engine->m_parent,
-1,
engine->m_menumanager,
engine->m_texture_source);
engine->m_texture_source,
true);
kmenu->drop();
return 0;
}