Added Settings menu.

In the Settings you can:
- disable/ enable the music
- disable/ enable rumble
- set the language
This commit is contained in:
Maschell 2017-05-07 18:44:34 +02:00
parent 11f9e7f55f
commit db5d26d9a0
30 changed files with 363 additions and 48 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-04-13 18:55+0200\n" "POT-Creation-Date: 2017-05-07 18:37+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -139,23 +139,17 @@ msgstr ""
#: src/menu/drc/content/ContentHome.cpp:23 #: src/menu/drc/content/ContentHome.cpp:23
#: src/menu/drc/content/ContentHome.cpp:23 #: src/menu/drc/content/ContentHome.cpp:23
msgid "" msgid "HID to VPAD allows you to use your USB controller on your WiiU. Currently you can emulate the Gamepad or a Pro Controller."
"HID to VPAD allows you to use your USB controller on your WiiU. Currently "
"you can emulate the Gamepad or a Pro Controller."
msgstr "" msgstr ""
#: src/menu/drc/content/ContentHome.cpp:24 #: src/menu/drc/content/ContentHome.cpp:24
#: src/menu/drc/content/ContentHome.cpp:24 #: src/menu/drc/content/ContentHome.cpp:24
msgid "" msgid "Before you use your controller, you may need to provide a valid config. More information and config files can be found in the help section or on gbatemp.net (gbatemp.net/threads/424127/)."
"Before you use your controller, you may need to provide a valid config. More "
"information and config files can be found in the help section or on gbatemp."
"net (gbatemp.net/threads/424127/)."
msgstr "" msgstr ""
#: src/menu/drc/content/ContentHome.cpp:25 #: src/menu/drc/content/ContentHome.cpp:25
#: src/menu/drc/content/ContentHome.cpp:25 #: src/menu/drc/content/ContentHome.cpp:25
msgid "" msgid "To map a device, select a controller from the list on the left hand side."
"To map a device, select a controller from the list on the left hand side."
msgstr "" msgstr ""
#: src/menu/drc/content/ContentNetworkHelp.cpp:20 #: src/menu/drc/content/ContentNetworkHelp.cpp:20
@ -227,8 +221,7 @@ msgstr ""
#: src/menu/drc/content/ContentNetworkHelp.cpp:126 #: src/menu/drc/content/ContentNetworkHelp.cpp:126
#: src/menu/drc/content/ContentNetworkHelp.cpp:126 #: src/menu/drc/content/ContentNetworkHelp.cpp:126
msgid "" msgid "quality of your signal. If it's possible, connect everything via Ethernet."
"quality of your signal. If it's possible, connect everything via Ethernet."
msgstr "" msgstr ""
#: src/menu/drc/content/ContentNetworkHelp.cpp:133 #: src/menu/drc/content/ContentNetworkHelp.cpp:133
@ -295,7 +288,8 @@ msgstr ""
msgid "Other" msgid "Other"
msgstr "" msgstr ""
#: src/menu/drc/MenuListDRC.cpp:42 src/menu/drc/MenuListDRC.cpp:42 #: src/menu/drc/MenuListDRC.cpp:42 src/menu/drc/MenuListDRC.cpp:43
#: src/menu/drc/MenuListDRC.cpp:43
msgid "About" msgid "About"
msgstr "" msgstr ""
@ -314,3 +308,32 @@ msgstr ""
#: src/menu/tv/TVControllerBanner.cpp:44 src/menu/tv/TVControllerBanner.cpp:44 #: src/menu/tv/TVControllerBanner.cpp:44 src/menu/tv/TVControllerBanner.cpp:44
msgid "Press to apply patches" msgid "Press to apply patches"
msgstr "" msgstr ""
#: src/menu/drc/content/ContentSettings.cpp:26
#: src/menu/drc/content/ContentSettings.cpp:43
#: src/menu/drc/content/ContentSettings.cpp:44
#: src/menu/drc/content/ContentSettings.cpp:48
msgid "Language"
msgstr ""
#: src/menu/drc/content/ContentSettings.cpp:31 src/menu/drc/MenuListDRC.cpp:42
#: src/menu/drc/content/ContentSettings.cpp:32 src/menu/drc/MenuListDRC.cpp:42
msgid "Settings"
msgstr ""
#: src/menu/drc/content/ContentSettings.cpp:61
#: src/menu/drc/content/ContentSettings.cpp:66
msgid "<Default>"
msgstr ""
#: src/menu/drc/content/ContentSettings.cpp:44
#: src/menu/drc/content/ContentSettings.cpp:45
#: src/menu/drc/content/ContentSettings.cpp:49
msgid "Rumble"
msgstr ""
#: src/menu/drc/content/ContentSettings.cpp:45
#: src/menu/drc/content/ContentSettings.cpp:46
#: src/menu/drc/content/ContentSettings.cpp:50
msgid "Music"
msgstr ""

View File

@ -2,9 +2,9 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-07 12:39+0200\n" "POT-Creation-Date: 2017-05-07 18:37+0200\n"
"PO-Revision-Date: 2017-04-13 16:51+0200\n" "PO-Revision-Date: 2017-04-13 16:51+0200\n"
"Last-Translator: <EMAIL@ADDRESS>\n" "Last-Translator: Maschell\n"
"Language-Team: German\n" "Language-Team: German\n"
"Language: de\n" "Language: de\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -247,16 +247,33 @@ msgstr " zurück zum HBL."
#: src/menu/tv/TVControllerBanner.cpp:44 #: src/menu/tv/TVControllerBanner.cpp:44
msgid "Press to apply patches" msgid "Press to apply patches"
msgstr "Drücke zum starten." msgstr " zum starten."
#: src/menu/drc/content/ContentSettings.cpp:26 #: src/menu/drc/content/ContentSettings.cpp:26
#: src/menu/drc/content/ContentSettings.cpp:43
#: src/menu/drc/content/ContentSettings.cpp:44
#: src/menu/drc/content/ContentSettings.cpp:48
msgid "Language" msgid "Language"
msgstr "" msgstr "Sprache"
#: src/menu/drc/content/ContentSettings.cpp:31 src/menu/drc/MenuListDRC.cpp:42 #: src/menu/drc/content/ContentSettings.cpp:31 src/menu/drc/MenuListDRC.cpp:42
#: src/menu/drc/content/ContentSettings.cpp:32
msgid "Settings" msgid "Settings"
msgstr "" msgstr "Einstellungen"
#: src/menu/drc/content/ContentSettings.cpp:61 #: src/menu/drc/content/ContentSettings.cpp:61
#: src/menu/drc/content/ContentSettings.cpp:66
msgid "<Default>" msgid "<Default>"
msgstr "" msgstr ""
#: src/menu/drc/content/ContentSettings.cpp:44
#: src/menu/drc/content/ContentSettings.cpp:45
#: src/menu/drc/content/ContentSettings.cpp:49
msgid "Rumble"
msgstr ""
#: src/menu/drc/content/ContentSettings.cpp:45
#: src/menu/drc/content/ContentSettings.cpp:46
#: src/menu/drc/content/ContentSettings.cpp:50
msgid "Music"
msgstr "Musik"

View File

@ -2,7 +2,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-07 12:39+0200\n" "POT-Creation-Date: 2017-05-07 18:37+0200\n"
"PO-Revision-Date: 2017-04-13 16:51+0200\n" "PO-Revision-Date: 2017-04-13 16:51+0200\n"
"Last-Translator: Victormr21\n" "Last-Translator: Victormr21\n"
"Language-Team: Spanish\n" "Language-Team: Spanish\n"
@ -250,13 +250,30 @@ msgid "Press to apply patches"
msgstr "Pulsa para aplicar cambios" msgstr "Pulsa para aplicar cambios"
#: src/menu/drc/content/ContentSettings.cpp:26 #: src/menu/drc/content/ContentSettings.cpp:26
#: src/menu/drc/content/ContentSettings.cpp:43
#: src/menu/drc/content/ContentSettings.cpp:44
#: src/menu/drc/content/ContentSettings.cpp:48
msgid "Language" msgid "Language"
msgstr "" msgstr ""
#: src/menu/drc/content/ContentSettings.cpp:31 src/menu/drc/MenuListDRC.cpp:42 #: src/menu/drc/content/ContentSettings.cpp:31 src/menu/drc/MenuListDRC.cpp:42
#: src/menu/drc/content/ContentSettings.cpp:32
msgid "Settings" msgid "Settings"
msgstr "" msgstr ""
#: src/menu/drc/content/ContentSettings.cpp:61 #: src/menu/drc/content/ContentSettings.cpp:61
#: src/menu/drc/content/ContentSettings.cpp:66
msgid "<Default>" msgid "<Default>"
msgstr "" msgstr ""
#: src/menu/drc/content/ContentSettings.cpp:44
#: src/menu/drc/content/ContentSettings.cpp:45
#: src/menu/drc/content/ContentSettings.cpp:49
msgid "Rumble"
msgstr ""
#: src/menu/drc/content/ContentSettings.cpp:45
#: src/menu/drc/content/ContentSettings.cpp:46
#: src/menu/drc/content/ContentSettings.cpp:50
msgid "Music"
msgstr ""

View File

@ -79,6 +79,7 @@ Application::~Application(){
log_printf("Application::~Application(line %d): Stop sound handler\n",__LINE__); log_printf("Application::~Application(line %d): Stop sound handler\n",__LINE__);
SoundHandler::DestroyInstance(); SoundHandler::DestroyInstance();
} }
s32 Application::exec(){ s32 Application::exec(){
@ -151,14 +152,16 @@ void Application::executeThread(void){
FreeTypeGX *fontSystem = new FreeTypeGX(Resources::GetFile("font.ttf"), Resources::GetFileSize("font.ttf"), true); FreeTypeGX *fontSystem = new FreeTypeGX(Resources::GetFile("font.ttf"), Resources::GetFileSize("font.ttf"), true);
GuiText::setPresetFont(fontSystem); GuiText::setPresetFont(fontSystem);
log_printf("Application::executeThread(line %d): Initialize main window\n",__LINE__);
reloadUIflag = true; reloadUIflag = true;
bgMusic->SetLoop(true); bgMusic->SetLoop(true);
bgMusic->SetVolume(50); bgMusic->SetVolume(50);
while(reloadUIflag){ while(reloadUIflag){
reloadUIflag = false; reloadUIflag = false;
exitCode = EXIT_RELAUNCH_ON_LOAD; exitCode = EXIT_RELAUNCH_ON_LOAD;
log_printf("Application::executeThread(line %d): Initialize the language\n",__LINE__);
loadLanguageFromConfig(); loadLanguageFromConfig();
log_printf("Application::executeThread(line %d): Initialize main window\n",__LINE__);
mainWindow = MainWindow::getInstance(video->getTvWidth(), video->getTvHeight()); mainWindow = MainWindow::getInstance(video->getTvWidth(), video->getTvHeight());
log_printf("Application::executeThread(line %d): Entering main loop\n",__LINE__); log_printf("Application::executeThread(line %d): Entering main loop\n",__LINE__);

View File

@ -120,11 +120,11 @@ f32 GuiElement::getTop()
//! TODO: the conversion from int to float and back to int is bad for performance, change that //! TODO: the conversion from int to float and back to int is bad for performance, change that
if(alignment & ALIGN_MIDDLE) if(alignment & ALIGN_MIDDLE)
{ {
y = pTop + pHeight * 0.5f * pScaleY - height * 0.5f * getScaleY(); y = pTop + pHeight * 0.5f * pScaleY - getHeight() * 0.5f * getScaleY();
} }
else if(alignment & ALIGN_BOTTOM) else if(alignment & ALIGN_BOTTOM)
{ {
y = pTop + pHeight * pScaleY - height * getScaleY(); y = pTop + pHeight * pScaleY - getHeight() * getScaleY();
} }
return y + yoffset; return y + yoffset;

View File

@ -162,7 +162,7 @@ class GuiElement : public AsyncDeleter::Element
pScale = parentElement->getScaleY(); pScale = parentElement->getScaleY();
} }
pCenterY += pHeight * 0.5f * pScale - height * 0.5f * getScaleY(); pCenterY += pHeight * 0.5f * pScale - getHeight() * 0.5f * getScaleY();
} }
else if(alignment & ALIGN_BOTTOM) else if(alignment & ALIGN_BOTTOM)
{ {
@ -175,7 +175,7 @@ class GuiElement : public AsyncDeleter::Element
pScale = parentElement->getScaleY(); pScale = parentElement->getScaleY();
} }
pCenterY -= pHeight * 0.5f * pScale - height * 0.5f * getScaleY(); pCenterY -= pHeight * 0.5f * pScale - getHeight() * 0.5f * getScaleY();
} }
return pCenterY; return pCenterY;
} }

View File

@ -94,7 +94,7 @@ void GuiSelectBox::SelectValue(u32 value){
const wchar_t* w_text = valueButtons[value].valueButtonText->getText(); const wchar_t* w_text = valueButtons[value].valueButtonText->getText();
std::wstring ws(w_text); std::wstring ws(w_text);
std::string text(ws.begin(), ws.end()); std::string text(ws.begin(), ws.end());
topValueText.setText(getCaptionWithValue(text).c_str()); topValueText.setText(text.c_str());
std::string real_value = buttonToValue[valueButtons[value].valueButton]; std::string real_value = buttonToValue[valueButtons[value].valueButton];
if(real_value.compare(std::string()) == 0) real_value = "<error>"; if(real_value.compare(std::string()) == 0) real_value = "<error>";
@ -103,12 +103,6 @@ void GuiSelectBox::SelectValue(u32 value){
ShowHideValues(false); ShowHideValues(false);
} }
} }
std::string GuiSelectBox::getCaptionWithValue(std::string value){
u32 pad = (38 - captionText.size() -2);
if(pad > value.size())
value.insert(0, pad - value.size(), ' ');
return strfmt("%s: %s",captionText.c_str(),value.c_str());
}
void GuiSelectBox::OnTopValueClicked(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) void GuiSelectBox::OnTopValueClicked(GuiButton *button, const GuiController *controller, GuiTrigger *trigger)
{ {
@ -169,7 +163,7 @@ void GuiSelectBox::Init(std::map<std::string,std::string> values, s32 valueID)
std::map<std::string, std::string>::iterator itr; std::map<std::string, std::string>::iterator itr;
for(itr = values.begin(); itr != values.end(); itr++) { for(itr = values.begin(); itr != values.end(); itr++) {
if(i == valueID){ if(i == valueID){
topValueText.setText(getCaptionWithValue(itr->first).c_str()); topValueText.setText(itr->first.c_str());
} }
valueButtons[i].valueButtonImg = new GuiImage(valueImageData); valueButtons[i].valueButtonImg = new GuiImage(valueImageData);
@ -196,12 +190,13 @@ void GuiSelectBox::Init(std::map<std::string,std::string> values, s32 valueID)
//valueButtons[i].valueButton->setState(STATE_HIDDEN); //Wont get disabled soon enough //valueButtons[i].valueButton->setState(STATE_HIDDEN); //Wont get disabled soon enough
buttonToValue[valueButtons[i].valueButton] = itr->second; buttonToValue[valueButtons[i].valueButton] = itr->second;
s32 ypos = (((valueButtons[i].valueButtonImg->getHeight()*getScale()) * (i))+ (topValueImage.getHeight()-5)*getScale())*-1.0f;
valueButtons[i].valueButton->setPosition(0, (((valueButtons[i].valueButtonImg->getHeight()*getScale()) * (i))+ (topValueImage.getHeight()-5)*getScale())*-1.0f); valueButtons[i].valueButton->setPosition(0, ypos);
valuesFrame.append(valueButtons[i].valueButton); valuesFrame.append(valueButtons[i].valueButton);
i++; i++;
} }
//Collapse the thing! //Collapse the thing!
showValues = false; showValues = false;
bChanged = true; bChanged = true;
@ -258,6 +253,15 @@ f32 GuiSelectBox::getTopValueWidth() {
return topValueImage.getWidth(); return topValueImage.getWidth();
} }
f32 GuiSelectBox::getHeight(){
return getTopValueHeight();
}
f32 GuiSelectBox::getWidth(){
return getTopValueWidth();
}
void GuiSelectBox::OnValueOpenEffectFinish(GuiElement *element) void GuiSelectBox::OnValueOpenEffectFinish(GuiElement *element)
{ {
valuesFrame.effectFinished.disconnect(this); valuesFrame.effectFinished.disconnect(this);

View File

@ -42,6 +42,9 @@ class GuiSelectBox : public GuiFrame, public sigslot::has_slots<>
virtual f32 getTopValueHeight(); virtual f32 getTopValueHeight();
virtual f32 getTopValueWidth(); virtual f32 getTopValueWidth();
virtual f32 getHeight();
virtual f32 getWidth();
protected: protected:
void DeleteValueData(); void DeleteValueData();
void update(GuiController * c); void update(GuiController * c);
@ -86,7 +89,6 @@ class GuiSelectBox : public GuiFrame, public sigslot::has_slots<>
GuiSound* buttonClickSound; GuiSound* buttonClickSound;
std::string getCaptionWithValue(std::string value);
typedef struct typedef struct
{ {
GuiImage *valueButtonImg; GuiImage *valueButtonImg;

View File

@ -70,3 +70,11 @@ void GuiSwitch::draw(CVideo *v){
switchOff_img.draw(v); switchOff_img.draw(v);
} }
} }
f32 GuiSwitch::getHeight(){
return switchOn_img.getHeight();
}
f32 GuiSwitch::getWidth(){
return switchbase_img.getWidth();
}

View File

@ -31,6 +31,9 @@ class GuiSwitch : public GuiToggle
//!Destructor //!Destructor
virtual ~GuiSwitch(); virtual ~GuiSwitch();
f32 getHeight();
f32 getWidth();
protected: protected:
GuiImageData * switchbase_imgdata; GuiImageData * switchbase_imgdata;

View File

@ -105,6 +105,7 @@ extern "C" s32 Menu_Main(void){
log_printf("Menu_Main (line %d): Release memory\n",__LINE__); log_printf("Menu_Main (line %d): Release memory\n",__LINE__);
memoryRelease(); memoryRelease();
ControllerPatcher::destroyConfigHelper(); ControllerPatcher::destroyConfigHelper();
CSettings::destroyInstance();
} }

View File

@ -19,6 +19,7 @@
#include "content/ContentHome.h" #include "content/ContentHome.h"
#include "content/ContentNetworkHelp.h" #include "content/ContentNetworkHelp.h"
#include "content/ContentHelp.h" #include "content/ContentHelp.h"
#include "content/ContentSettings.h"
#include "content/ContentAbout.h" #include "content/ContentAbout.h"
/** /**
@ -73,6 +74,7 @@ ContentTemplate * MenuElementInfo::createNewContent(){
case ContentTemplate::CONTENT_HOME: { return new ContentHome(); break;} case ContentTemplate::CONTENT_HOME: { return new ContentHome(); break;}
case ContentTemplate::CONTENT_ABOUT: { return new ContentAbout(); break;} case ContentTemplate::CONTENT_ABOUT: { return new ContentAbout(); break;}
case ContentTemplate::CONTENT_NETWORK_HELP: { return new ContentNetworkHelp(); break;} case ContentTemplate::CONTENT_NETWORK_HELP: { return new ContentNetworkHelp(); break;}
case ContentTemplate::CONTENT_SETTINGS: { return new ContentSettings(); break;}
case ContentTemplate::CONTENT_HELP: { return new ContentHelp(); break;} case ContentTemplate::CONTENT_HELP: { return new ContentHelp(); break;}
default: return NULL; default: return NULL;
} }

View File

@ -39,6 +39,7 @@ MenuListDRC::MenuListDRC(s32 w, s32 h,MainWindowContent * _contentWindow)
, otherSeperator(gettext("Other")) , otherSeperator(gettext("Other"))
, elementHelp(gettext("Help"), "helpIcon.png", ContentTemplate::CONTENT_HELP) , elementHelp(gettext("Help"), "helpIcon.png", ContentTemplate::CONTENT_HELP)
, elementNetworkHelp( gettext("Network Client"), "netbtn.png", ContentTemplate::CONTENT_NETWORK_HELP) , elementNetworkHelp( gettext("Network Client"), "netbtn.png", ContentTemplate::CONTENT_NETWORK_HELP)
, elementSettings( gettext("Settings"), "settingsbtn.png", ContentTemplate::CONTENT_SETTINGS)
, elementAbout(gettext("About"), "aboutIcon.png", ContentTemplate::CONTENT_ABOUT) , elementAbout(gettext("About"), "aboutIcon.png", ContentTemplate::CONTENT_ABOUT)
, buttonUpTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_UP | GuiTrigger::STICK_L_UP, true) , buttonUpTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_UP | GuiTrigger::STICK_L_UP, true)
, buttonDownTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_DOWN | GuiTrigger::STICK_L_DOWN, true) , buttonDownTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_DOWN | GuiTrigger::STICK_L_DOWN, true)
@ -65,6 +66,7 @@ MenuListDRC::MenuListDRC(s32 w, s32 h,MainWindowContent * _contentWindow)
listAppend(&otherSeperator); listAppend(&otherSeperator);
listAppend(&elementNetworkHelp); listAppend(&elementNetworkHelp);
listAppend(&elementHelp); listAppend(&elementHelp);
listAppend(&elementSettings);
listAppend(&elementAbout); listAppend(&elementAbout);
sizeListElementsAll = listElementsAll.size(); sizeListElementsAll = listElementsAll.size();
@ -258,5 +260,6 @@ MenuListDRC::~MenuListDRC(){
remove(&otherSeperator); remove(&otherSeperator);
remove(&elementNetworkHelp); remove(&elementNetworkHelp);
remove(&elementHelp); remove(&elementHelp);
remove(&elementSettings);
remove(&elementAbout); remove(&elementAbout);
} }

View File

@ -48,6 +48,7 @@ private:
MenuSeperator otherSeperator; MenuSeperator otherSeperator;
MenuElementInfo elementHelp; MenuElementInfo elementHelp;
MenuElementInfo elementNetworkHelp; MenuElementInfo elementNetworkHelp;
MenuElementInfo elementSettings;
MenuElementInfo elementAbout; MenuElementInfo elementAbout;
GuiTrigger buttonUpTrigger; GuiTrigger buttonUpTrigger;

View File

@ -0,0 +1,158 @@
/****************************************************************************
* Copyright (C) 2016,2017 Maschell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "ContentSettings.h"
#include "fs/DirList.h"
#include "settings/CSettings.h"
#include "common/common.h"
#include "Application.h"
#include "utils/StringTools.h"
ContentSettings::ContentSettings():ContentTemplate()
, touchTrigger(GuiTrigger::CHANNEL_1, GuiTrigger::VPAD_TOUCH)
, wpadTouchTrigger(GuiTrigger::CHANNEL_2 | GuiTrigger::CHANNEL_3 | GuiTrigger::CHANNEL_4 | GuiTrigger::CHANNEL_5, GuiTrigger::BUTTON_A)
, languageSelectBox("",NULL)
, rumbleSwitch(CSettings::instance()->getValueAsBool(CSettings::RumbleActivated))
, musicSwitch(CSettings::instance()->getValueAsBool(CSettings::MusicActivated))
, buttonClickSound(Resources::GetSound("settings_click_2.mp3"))
{
headLine.setText(gettext("Settings"));
headLine.setFontSize(60);
headLine.setAlignment(ALIGN_TOP_CENTER);
headLine.setPosition(0,-110);
headLine.setColor(glm::vec4(0.3f,0.3f,0.3f,1.0f));
append(&headLine);
settingsFrame.setAlignment(ALIGN_TOP_CENTER);
settingsFrame.setPosition(0,-80);
settingsFrame.setSize(getWidth(),getHeight());
append(&settingsFrame);
settings[gettext("Language")] = &languageSelectBox;
settings[gettext("Rumble")] = &rumbleSwitch;
settings[gettext("Music")] = &musicSwitch;
settingsOrder.push_back(gettext("Language"));
settingsOrder.push_back(gettext("Rumble"));
settingsOrder.push_back(gettext("Music"));
rumbleSwitch.setTrigger(&touchTrigger);
rumbleSwitch.setTrigger(&wpadTouchTrigger);
rumbleSwitch.setSoundClick(buttonClickSound);
rumbleSwitch.valueChanged.connect(this, &ContentSettings::OnRumbleValueChanged);
musicSwitch.setTrigger(&touchTrigger);
musicSwitch.setTrigger(&wpadTouchTrigger);
musicSwitch.setSoundClick(buttonClickSound);
musicSwitch.valueChanged.connect(this, &ContentSettings::OnMusicValueChanged);
DirList dirList(DEFAULT_LANG_PATH, LANGUAGE_FILE_EXT, DirList::Files);
dirList.SortList();
//Fill in the values for the select box
languagesNames[gettext("<Default>")] = "none";
int selectedID = 0;
std::string setting = CSettings::instance()->getValueAsString(CSettings::AppLanguage);
for(int i = 0; i < dirList.GetFilecount(); i++){
const char *filename = dirList.GetFilename(i);
std::string name(filename);
name = name.substr(0,name.length()-strlen(LANGUAGE_FILE_EXT));
std::string displayname = name;
displayname[0] = toupper(displayname[0]);
languagesNames[displayname] = name;
if(name.compare(setting) == 0) selectedID = i+1;
}
languageSelectBox.Init(languagesNames,selectedID);
languageSelectBox.valueChanged.connect(this, &ContentSettings::OnSelectBoxValueChanged);
f32 frameoffset = 0;
f32 frameheight = 80.0f;
for (std::vector<std::string>::iterator it = settingsOrder.begin() ; it != settingsOrder.end(); ++it){
std::string name = *it;
GuiElement * element =settings[*it];
GuiFrame * frame = new GuiFrame();
GuiFrame * left = new GuiFrame();
GuiFrame * right = new GuiFrame();
frame->append(left);
frame->append(right);
frame->setAlignment(ALIGN_TOP_CENTER);
frame->setSize(getWidth()*0.80f,frameheight);
GuiText * text = new GuiText(strfmt("%s:",name.c_str()).c_str());
text->setColor(glm::vec4(0.3f,0.3f,0.3f,1.0f));
text->setFontSize(40);
text->setAlignment(ALIGN_LEFT);
left->append(text);
left->setAlignment(ALIGN_LEFT);
right->setAlignment(ALIGN_RIGHT);
element->setAlignment(ALIGN_RIGHT);
element->setPosition(0,10);
right->append(element);
frameoffset -= frameheight;
frame->setPosition(0,frameoffset);
settingsFrame.append(frame);
settingsFrames[element] = frame;
toDelete.push_back(frame);
toDelete.push_back(left);
toDelete.push_back(right);
toDelete.push_back(text);
}
settingsFrame.bringToFront(settingsFrames.at(&languageSelectBox));
}
ContentSettings::~ContentSettings(){
remove(&headLine);
Resources::RemoveSound(buttonClickSound);
if(bChanged){
CSettings::instance()->Save();
}
for (std::vector<GuiElement*>::iterator it = toDelete.begin() ; it != toDelete.end(); ++it){
GuiElement * element = *it;
delete element;
}
}
void ContentSettings::OnSelectBoxValueChanged(GuiSelectBox * selectBox, std::string value){
if(selectBox == &languageSelectBox){
if(CSettings::getValueAsString(CSettings::AppLanguage).compare(value) != 0){
CSettings::setValueAsString(CSettings::AppLanguage,value);
bChanged = true;
Application::instance()->reloadUI();
}
}
}
void ContentSettings::OnMusicValueChanged(GuiToggle * toggle,bool value){
CSettings::setValueAsBool(CSettings::MusicActivated,value);
bChanged = true;
}
void ContentSettings::OnRumbleValueChanged(GuiToggle * toggle,bool value){
CSettings::setValueAsBool(CSettings::RumbleActivated,value);
bChanged = true;
}

View File

@ -0,0 +1,60 @@
/****************************************************************************
* Copyright (C) 2016,2017 Maschell
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef _CONTENT_SETTINGS_H
#define _CONTENT_SETTINGS_H
#include <map>
#include "gui/Gui.h"
#include "ContentTemplate.h"
#include "language/gettext.h"
class ContentSettings : public ContentTemplate{
public:
ContentSettings();
virtual ~ContentSettings();
private:
GuiTrigger touchTrigger;
GuiTrigger wpadTouchTrigger;
GuiSelectBox languageSelectBox;
std::map<std::string,std::string> languagesNames;
GuiFrame settingsFrame;
GuiText headLine;
GuiSwitch rumbleSwitch;
GuiSwitch musicSwitch;
GuiSound *buttonClickSound;
std::map<std::string,GuiElement*> settings;
std::vector<std::string> settingsOrder;
std::map<GuiElement*,GuiFrame *> settingsFrames;
std::vector<GuiElement*> toDelete;
bool bChanged = false;
void OnSelectBoxValueChanged(GuiSelectBox * selectBox, std::string value);
void OnMusicValueChanged(GuiToggle * toggle,bool value);
void OnRumbleValueChanged(GuiToggle * toggle,bool value);
};
#endif //_CONTENT_SETTINGS_H

View File

@ -26,6 +26,7 @@ public:
CONTENT_HOME, CONTENT_HOME,
CONTENT_HELP, CONTENT_HELP,
CONTENT_NETWORK_HELP, CONTENT_NETWORK_HELP,
CONTENT_SETTINGS,
CONTENT_ABOUT, CONTENT_ABOUT,
}; };

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* Loadiine resource files. * Loadiine resource files.
* This file is generated automatically. * This file is generated automatically.
* Includes 109 files. * Includes 111 files.
* *
* NOTE: * NOTE:
* Any manual modification of this file will be overwriten by the generation. * Any manual modification of this file will be overwriten by the generation.
@ -224,6 +224,12 @@ extern const u32 gameSettingsButton_png_size;
extern const u8 gameSettingsButtonEx_png[]; extern const u8 gameSettingsButtonEx_png[];
extern const u32 gameSettingsButtonEx_png_size; extern const u32 gameSettingsButtonEx_png_size;
extern const u8 gameSettingsButtonExEnd_png[];
extern const u32 gameSettingsButtonExEnd_png_size;
extern const u8 gameSettingsButtonExEndHighlighted_png[];
extern const u32 gameSettingsButtonExEndHighlighted_png_size;
extern const u8 gameSettingsButtonExHighlighted_png[]; extern const u8 gameSettingsButtonExHighlighted_png[];
extern const u32 gameSettingsButtonExHighlighted_png_size; extern const u32 gameSettingsButtonExHighlighted_png_size;
@ -417,6 +423,8 @@ static RecourceFile RecourceList[] =
{"gamepadIcon.png", gamepadIcon_png, gamepadIcon_png_size, NULL, 0}, {"gamepadIcon.png", gamepadIcon_png, gamepadIcon_png_size, NULL, 0},
{"gameSettingsButton.png", gameSettingsButton_png, gameSettingsButton_png_size, NULL, 0}, {"gameSettingsButton.png", gameSettingsButton_png, gameSettingsButton_png_size, NULL, 0},
{"gameSettingsButtonEx.png", gameSettingsButtonEx_png, gameSettingsButtonEx_png_size, NULL, 0}, {"gameSettingsButtonEx.png", gameSettingsButtonEx_png, gameSettingsButtonEx_png_size, NULL, 0},
{"gameSettingsButtonExEnd.png", gameSettingsButtonExEnd_png, gameSettingsButtonExEnd_png_size, NULL, 0},
{"gameSettingsButtonExEndHighlighted.png", gameSettingsButtonExEndHighlighted_png, gameSettingsButtonExEndHighlighted_png_size, NULL, 0},
{"gameSettingsButtonExHighlighted.png", gameSettingsButtonExHighlighted_png, gameSettingsButtonExHighlighted_png_size, NULL, 0}, {"gameSettingsButtonExHighlighted.png", gameSettingsButtonExHighlighted_png, gameSettingsButtonExHighlighted_png_size, NULL, 0},
{"gameSettingsButtonExSelected.png", gameSettingsButtonExSelected_png, gameSettingsButtonExSelected_png_size, NULL, 0}, {"gameSettingsButtonExSelected.png", gameSettingsButtonExSelected_png, gameSettingsButtonExSelected_png_size, NULL, 0},
{"gameSettingsButtonSelected.png", gameSettingsButtonSelected_png, gameSettingsButtonSelected_png_size, NULL, 0}, {"gameSettingsButtonSelected.png", gameSettingsButtonSelected_png, gameSettingsButtonSelected_png_size, NULL, 0},

View File

@ -24,6 +24,7 @@
#include "fs/CFile.hpp" #include "fs/CFile.hpp"
#include "fs/fs_utils.h" #include "fs/fs_utils.h"
#include "utils/StringTools.h" #include "utils/StringTools.h"
#include "utils/logger.h"
#include "language/gettext.h" #include "language/gettext.h"
#define VERSION_LINE "# HID to VPAD - Main settings file v" #define VERSION_LINE "# HID to VPAD - Main settings file v"
@ -36,7 +37,6 @@ CSettings::CSettings(){
bChanged = false; bChanged = false;
memset(&nullValue, 0, sizeof(nullValue)); memset(&nullValue, 0, sizeof(nullValue));
nullValue.strValue = new std::string(); nullValue.strValue = new std::string();
configPath = DEFAULT_HID_TO_VPAD_PATH; configPath = DEFAULT_HID_TO_VPAD_PATH;
this->SetDefault(); this->SetDefault();
} }
@ -81,18 +81,22 @@ bool CSettings::Load(){
std::string filepath = configPath; std::string filepath = configPath;
filepath += CONFIG_FILENAME; filepath += CONFIG_FILENAME;
log_printf("CSettings::Load(line %d): Loading Configuration from %s\n",__LINE__,filepath.c_str());
CFile file(filepath, CFile::ReadOnly); CFile file(filepath, CFile::ReadOnly);
if (!file.isOpen()) if (!file.isOpen())
return false; return false;
std::string strBuffer; std::string strBuffer;
strBuffer.resize(file.size()); strBuffer.resize(file.size());
file.read((u8 *) &strBuffer[0], strBuffer.size()); file.read((u8 *) &strBuffer[0], strBuffer.size());
file.close(); file.close();
//! remove all windows crap signs //! remove all windows crap signs
size_t position; size_t position;
while(1) while(1 && !strBuffer.empty())
{ {
position = strBuffer.find('\r'); position = strBuffer.find('\r');
if(position == std::string::npos) if(position == std::string::npos)

View File

@ -1,2 +1,2 @@
#define APP_VERION "v0.9i" #define APP_VERION "v0.9j"