diff --git a/data/images/gameSettingsButton.png b/data/images/gameSettingsButton.png index 28f59b7..d6b4a6d 100644 Binary files a/data/images/gameSettingsButton.png and b/data/images/gameSettingsButton.png differ diff --git a/data/images/gameSettingsButtonEx.png b/data/images/gameSettingsButtonEx.png index c88b255..288ffae 100644 Binary files a/data/images/gameSettingsButtonEx.png and b/data/images/gameSettingsButtonEx.png differ diff --git a/data/images/gameSettingsButtonExEnd.png b/data/images/gameSettingsButtonExEnd.png new file mode 100644 index 0000000..f09e8c5 Binary files /dev/null and b/data/images/gameSettingsButtonExEnd.png differ diff --git a/data/images/gameSettingsButtonExEndHighlighted.png b/data/images/gameSettingsButtonExEndHighlighted.png new file mode 100644 index 0000000..de059aa Binary files /dev/null and b/data/images/gameSettingsButtonExEndHighlighted.png differ diff --git a/data/images/gameSettingsButtonExHighlighted.png b/data/images/gameSettingsButtonExHighlighted.png index e716e40..f088e54 100644 Binary files a/data/images/gameSettingsButtonExHighlighted.png and b/data/images/gameSettingsButtonExHighlighted.png differ diff --git a/data/images/gameSettingsButtonExSelected.png b/data/images/gameSettingsButtonExSelected.png index abe6ce8..f088e54 100644 Binary files a/data/images/gameSettingsButtonExSelected.png and b/data/images/gameSettingsButtonExSelected.png differ diff --git a/data/images/gameSettingsButtonSelected.png b/data/images/gameSettingsButtonSelected.png index 2c0fda7..e5c3d89 100644 Binary files a/data/images/gameSettingsButtonSelected.png and b/data/images/gameSettingsButtonSelected.png differ diff --git a/data/images/switchIconBase.png b/data/images/switchIconBase.png index dc49798..83c80fd 100644 Binary files a/data/images/switchIconBase.png and b/data/images/switchIconBase.png differ diff --git a/data/images/switchIconOff.png b/data/images/switchIconOff.png index 0c14a52..7ec097f 100644 Binary files a/data/images/switchIconOff.png and b/data/images/switchIconOff.png differ diff --git a/data/images/switchIconOn.png b/data/images/switchIconOn.png index 9cce440..17e6552 100644 Binary files a/data/images/switchIconOn.png and b/data/images/switchIconOn.png differ diff --git a/languages/english.lang b/languages/english.lang index 21a6bb0..30ac330 100644 --- a/languages/english.lang +++ b/languages/english.lang @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\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" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -139,23 +139,17 @@ msgstr "" #: src/menu/drc/content/ContentHome.cpp:23 #: src/menu/drc/content/ContentHome.cpp:23 -msgid "" -"HID to VPAD allows you to use your USB controller on your WiiU. Currently " -"you can emulate the Gamepad or a Pro Controller." +msgid "HID to VPAD allows you to use your USB controller on your WiiU. Currently you can emulate the Gamepad or a Pro Controller." msgstr "" #: src/menu/drc/content/ContentHome.cpp:24 #: src/menu/drc/content/ContentHome.cpp:24 -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/)." +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/)." msgstr "" #: src/menu/drc/content/ContentHome.cpp:25 #: src/menu/drc/content/ContentHome.cpp:25 -msgid "" -"To map a device, select a controller from the list on the left hand side." +msgid "To map a device, select a controller from the list on the left hand side." msgstr "" #: 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 -msgid "" -"quality of your signal. If it's possible, connect everything via Ethernet." +msgid "quality of your signal. If it's possible, connect everything via Ethernet." msgstr "" #: src/menu/drc/content/ContentNetworkHelp.cpp:133 @@ -295,7 +288,8 @@ msgstr "" msgid "Other" 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" msgstr "" @@ -314,3 +308,32 @@ msgstr "" #: src/menu/tv/TVControllerBanner.cpp:44 src/menu/tv/TVControllerBanner.cpp:44 msgid "Press to apply patches" 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 "" +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 "" diff --git a/languages/german.lang b/languages/german.lang index 870c464..045c3d6 100644 --- a/languages/german.lang +++ b/languages/german.lang @@ -2,9 +2,9 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\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" -"Last-Translator: \n" +"Last-Translator: Maschell\n" "Language-Team: German\n" "Language: de\n" "MIME-Version: 1.0\n" @@ -247,16 +247,33 @@ msgstr " zurück zum HBL." #: src/menu/tv/TVControllerBanner.cpp:44 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:43 +#: src/menu/drc/content/ContentSettings.cpp:44 +#: src/menu/drc/content/ContentSettings.cpp:48 msgid "Language" -msgstr "" +msgstr "Sprache" #: src/menu/drc/content/ContentSettings.cpp:31 src/menu/drc/MenuListDRC.cpp:42 +#: src/menu/drc/content/ContentSettings.cpp:32 msgid "Settings" -msgstr "" +msgstr "Einstellungen" #: src/menu/drc/content/ContentSettings.cpp:61 +#: src/menu/drc/content/ContentSettings.cpp:66 msgid "" 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" diff --git a/languages/spanish.lang b/languages/spanish.lang index 05fdf77..efd02bb 100644 --- a/languages/spanish.lang +++ b/languages/spanish.lang @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\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" "Last-Translator: Victormr21\n" "Language-Team: Spanish\n" @@ -250,13 +250,30 @@ msgid "Press to apply patches" msgstr "Pulsa para aplicar cambios" #: 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 msgid "Settings" msgstr "" #: src/menu/drc/content/ContentSettings.cpp:61 +#: src/menu/drc/content/ContentSettings.cpp:66 msgid "" 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 "" diff --git a/src/Application.cpp b/src/Application.cpp index 098f0f5..4aeb00f 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -79,6 +79,7 @@ Application::~Application(){ log_printf("Application::~Application(line %d): Stop sound handler\n",__LINE__); SoundHandler::DestroyInstance(); + } s32 Application::exec(){ @@ -151,14 +152,16 @@ void Application::executeThread(void){ FreeTypeGX *fontSystem = new FreeTypeGX(Resources::GetFile("font.ttf"), Resources::GetFileSize("font.ttf"), true); GuiText::setPresetFont(fontSystem); - log_printf("Application::executeThread(line %d): Initialize main window\n",__LINE__); reloadUIflag = true; bgMusic->SetLoop(true); bgMusic->SetVolume(50); + while(reloadUIflag){ reloadUIflag = false; exitCode = EXIT_RELAUNCH_ON_LOAD; + log_printf("Application::executeThread(line %d): Initialize the language\n",__LINE__); loadLanguageFromConfig(); + log_printf("Application::executeThread(line %d): Initialize main window\n",__LINE__); mainWindow = MainWindow::getInstance(video->getTvWidth(), video->getTvHeight()); log_printf("Application::executeThread(line %d): Entering main loop\n",__LINE__); diff --git a/src/gui/GuiElement.cpp b/src/gui/GuiElement.cpp index ac26d0a..ace8f0d 100644 --- a/src/gui/GuiElement.cpp +++ b/src/gui/GuiElement.cpp @@ -120,11 +120,11 @@ f32 GuiElement::getTop() //! TODO: the conversion from int to float and back to int is bad for performance, change that 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) { - y = pTop + pHeight * pScaleY - height * getScaleY(); + y = pTop + pHeight * pScaleY - getHeight() * getScaleY(); } return y + yoffset; diff --git a/src/gui/GuiElement.h b/src/gui/GuiElement.h index 7b313a9..e6232ff 100644 --- a/src/gui/GuiElement.h +++ b/src/gui/GuiElement.h @@ -162,7 +162,7 @@ class GuiElement : public AsyncDeleter::Element 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) { @@ -175,7 +175,7 @@ class GuiElement : public AsyncDeleter::Element pScale = parentElement->getScaleY(); } - pCenterY -= pHeight * 0.5f * pScale - height * 0.5f * getScaleY(); + pCenterY -= pHeight * 0.5f * pScale - getHeight() * 0.5f * getScaleY(); } return pCenterY; } diff --git a/src/gui/GuiSelectBox.cpp b/src/gui/GuiSelectBox.cpp index 7353777..6ebccef 100644 --- a/src/gui/GuiSelectBox.cpp +++ b/src/gui/GuiSelectBox.cpp @@ -94,7 +94,7 @@ void GuiSelectBox::SelectValue(u32 value){ const wchar_t* w_text = valueButtons[value].valueButtonText->getText(); std::wstring ws(w_text); 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]; if(real_value.compare(std::string()) == 0) real_value = ""; @@ -103,12 +103,6 @@ void GuiSelectBox::SelectValue(u32 value){ 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) { @@ -169,7 +163,7 @@ void GuiSelectBox::Init(std::map values, s32 valueID) std::map::iterator itr; for(itr = values.begin(); itr != values.end(); itr++) { if(i == valueID){ - topValueText.setText(getCaptionWithValue(itr->first).c_str()); + topValueText.setText(itr->first.c_str()); } valueButtons[i].valueButtonImg = new GuiImage(valueImageData); @@ -196,12 +190,13 @@ void GuiSelectBox::Init(std::map values, s32 valueID) //valueButtons[i].valueButton->setState(STATE_HIDDEN); //Wont get disabled soon enough buttonToValue[valueButtons[i].valueButton] = itr->second; - - valueButtons[i].valueButton->setPosition(0, (((valueButtons[i].valueButtonImg->getHeight()*getScale()) * (i))+ (topValueImage.getHeight()-5)*getScale())*-1.0f); + s32 ypos = (((valueButtons[i].valueButtonImg->getHeight()*getScale()) * (i))+ (topValueImage.getHeight()-5)*getScale())*-1.0f; + valueButtons[i].valueButton->setPosition(0, ypos); valuesFrame.append(valueButtons[i].valueButton); i++; } + //Collapse the thing! showValues = false; bChanged = true; @@ -258,6 +253,15 @@ f32 GuiSelectBox::getTopValueWidth() { return topValueImage.getWidth(); } +f32 GuiSelectBox::getHeight(){ + return getTopValueHeight(); +} + +f32 GuiSelectBox::getWidth(){ + return getTopValueWidth(); +} + + void GuiSelectBox::OnValueOpenEffectFinish(GuiElement *element) { valuesFrame.effectFinished.disconnect(this); diff --git a/src/gui/GuiSelectBox.h b/src/gui/GuiSelectBox.h index deb12bd..feb7e47 100644 --- a/src/gui/GuiSelectBox.h +++ b/src/gui/GuiSelectBox.h @@ -42,6 +42,9 @@ class GuiSelectBox : public GuiFrame, public sigslot::has_slots<> virtual f32 getTopValueHeight(); virtual f32 getTopValueWidth(); + virtual f32 getHeight(); + virtual f32 getWidth(); + protected: void DeleteValueData(); void update(GuiController * c); @@ -86,7 +89,6 @@ class GuiSelectBox : public GuiFrame, public sigslot::has_slots<> GuiSound* buttonClickSound; - std::string getCaptionWithValue(std::string value); typedef struct { GuiImage *valueButtonImg; diff --git a/src/gui/GuiSwitch.cpp b/src/gui/GuiSwitch.cpp index 206a456..1124691 100644 --- a/src/gui/GuiSwitch.cpp +++ b/src/gui/GuiSwitch.cpp @@ -70,3 +70,11 @@ void GuiSwitch::draw(CVideo *v){ switchOff_img.draw(v); } } + +f32 GuiSwitch::getHeight(){ + return switchOn_img.getHeight(); +} + +f32 GuiSwitch::getWidth(){ + return switchbase_img.getWidth(); +} diff --git a/src/gui/GuiSwitch.h b/src/gui/GuiSwitch.h index 4988d2d..296564f 100644 --- a/src/gui/GuiSwitch.h +++ b/src/gui/GuiSwitch.h @@ -31,21 +31,24 @@ class GuiSwitch : public GuiToggle //!Destructor virtual ~GuiSwitch(); + f32 getHeight(); + f32 getWidth(); + protected: - GuiImageData * switchbase_imgdata; - GuiImage switchbase_img; + GuiImageData * switchbase_imgdata; + GuiImage switchbase_img; - GuiImageData * switchbase_highlighted_imgdata; - GuiImage switchbase_highlighted_img; + GuiImageData * switchbase_highlighted_imgdata; + GuiImage switchbase_highlighted_img; - GuiImageData * switchOn_imgdata; - GuiImage switchOn_img; + GuiImageData * switchOn_imgdata; + GuiImage switchOn_img; - GuiImageData * switchOff_imgdata; - GuiImage switchOff_img; + GuiImageData * switchOff_imgdata; + GuiImage switchOff_img; - void draw(CVideo * v); + void draw(CVideo * v); }; #endif diff --git a/src/main.cpp b/src/main.cpp index ee91446..aa7f4a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -105,6 +105,7 @@ extern "C" s32 Menu_Main(void){ log_printf("Menu_Main (line %d): Release memory\n",__LINE__); memoryRelease(); ControllerPatcher::destroyConfigHelper(); + CSettings::destroyInstance(); } diff --git a/src/menu/drc/MenuElementInfo.cpp b/src/menu/drc/MenuElementInfo.cpp index 58b1ab4..2a78a35 100644 --- a/src/menu/drc/MenuElementInfo.cpp +++ b/src/menu/drc/MenuElementInfo.cpp @@ -19,6 +19,7 @@ #include "content/ContentHome.h" #include "content/ContentNetworkHelp.h" #include "content/ContentHelp.h" +#include "content/ContentSettings.h" #include "content/ContentAbout.h" /** @@ -73,6 +74,7 @@ ContentTemplate * MenuElementInfo::createNewContent(){ case ContentTemplate::CONTENT_HOME: { return new ContentHome(); break;} case ContentTemplate::CONTENT_ABOUT: { return new ContentAbout(); 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;} default: return NULL; } diff --git a/src/menu/drc/MenuListDRC.cpp b/src/menu/drc/MenuListDRC.cpp index d26384a..685f193 100644 --- a/src/menu/drc/MenuListDRC.cpp +++ b/src/menu/drc/MenuListDRC.cpp @@ -39,6 +39,7 @@ MenuListDRC::MenuListDRC(s32 w, s32 h,MainWindowContent * _contentWindow) , otherSeperator(gettext("Other")) , elementHelp(gettext("Help"), "helpIcon.png", ContentTemplate::CONTENT_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) , buttonUpTrigger(GuiTrigger::CHANNEL_ALL, GuiTrigger::BUTTON_UP | GuiTrigger::STICK_L_UP, 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(&elementNetworkHelp); listAppend(&elementHelp); + listAppend(&elementSettings); listAppend(&elementAbout); sizeListElementsAll = listElementsAll.size(); @@ -258,5 +260,6 @@ MenuListDRC::~MenuListDRC(){ remove(&otherSeperator); remove(&elementNetworkHelp); remove(&elementHelp); + remove(&elementSettings); remove(&elementAbout); } diff --git a/src/menu/drc/MenuListDRC.h b/src/menu/drc/MenuListDRC.h index 4f9e84f..eede402 100644 --- a/src/menu/drc/MenuListDRC.h +++ b/src/menu/drc/MenuListDRC.h @@ -48,6 +48,7 @@ private: MenuSeperator otherSeperator; MenuElementInfo elementHelp; MenuElementInfo elementNetworkHelp; + MenuElementInfo elementSettings; MenuElementInfo elementAbout; GuiTrigger buttonUpTrigger; diff --git a/src/menu/drc/content/ContentSettings.cpp b/src/menu/drc/content/ContentSettings.cpp new file mode 100644 index 0000000..9f0c4ab --- /dev/null +++ b/src/menu/drc/content/ContentSettings.cpp @@ -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 . + ****************************************************************************/ +#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("")] = "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::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::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; +} + diff --git a/src/menu/drc/content/ContentSettings.h b/src/menu/drc/content/ContentSettings.h new file mode 100644 index 0000000..f8535d7 --- /dev/null +++ b/src/menu/drc/content/ContentSettings.h @@ -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 . + ****************************************************************************/ +#ifndef _CONTENT_SETTINGS_H +#define _CONTENT_SETTINGS_H + +#include + +#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 languagesNames; + + GuiFrame settingsFrame; + + GuiText headLine; + GuiSwitch rumbleSwitch; + GuiSwitch musicSwitch; + GuiSound *buttonClickSound; + + std::map settings; + std::vector settingsOrder; + std::map settingsFrames; + + std::vector 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 diff --git a/src/menu/drc/content/ContentTemplate.h b/src/menu/drc/content/ContentTemplate.h index fa8b1b0..bcf0ba7 100644 --- a/src/menu/drc/content/ContentTemplate.h +++ b/src/menu/drc/content/ContentTemplate.h @@ -26,6 +26,7 @@ public: CONTENT_HOME, CONTENT_HELP, CONTENT_NETWORK_HELP, + CONTENT_SETTINGS, CONTENT_ABOUT, }; diff --git a/src/resources/filelist.h b/src/resources/filelist.h index 2b6772b..d0afa23 100644 --- a/src/resources/filelist.h +++ b/src/resources/filelist.h @@ -1,7 +1,7 @@ /**************************************************************************** * Loadiine resource files. * This file is generated automatically. - * Includes 109 files. + * Includes 111 files. * * NOTE: * 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 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 u32 gameSettingsButtonExHighlighted_png_size; @@ -417,6 +423,8 @@ static RecourceFile RecourceList[] = {"gamepadIcon.png", gamepadIcon_png, gamepadIcon_png_size, NULL, 0}, {"gameSettingsButton.png", gameSettingsButton_png, gameSettingsButton_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}, {"gameSettingsButtonExSelected.png", gameSettingsButtonExSelected_png, gameSettingsButtonExSelected_png_size, NULL, 0}, {"gameSettingsButtonSelected.png", gameSettingsButtonSelected_png, gameSettingsButtonSelected_png_size, NULL, 0}, diff --git a/src/settings/CSettings.cpp b/src/settings/CSettings.cpp index 9b764f9..45c4191 100644 --- a/src/settings/CSettings.cpp +++ b/src/settings/CSettings.cpp @@ -24,6 +24,7 @@ #include "fs/CFile.hpp" #include "fs/fs_utils.h" #include "utils/StringTools.h" +#include "utils/logger.h" #include "language/gettext.h" #define VERSION_LINE "# HID to VPAD - Main settings file v" @@ -36,7 +37,6 @@ CSettings::CSettings(){ bChanged = false; memset(&nullValue, 0, sizeof(nullValue)); nullValue.strValue = new std::string(); - configPath = DEFAULT_HID_TO_VPAD_PATH; this->SetDefault(); } @@ -81,18 +81,22 @@ bool CSettings::Load(){ std::string filepath = configPath; filepath += CONFIG_FILENAME; + log_printf("CSettings::Load(line %d): Loading Configuration from %s\n",__LINE__,filepath.c_str()); + CFile file(filepath, CFile::ReadOnly); if (!file.isOpen()) return false; + std::string strBuffer; strBuffer.resize(file.size()); file.read((u8 *) &strBuffer[0], strBuffer.size()); file.close(); + //! remove all windows crap signs size_t position; - while(1) + while(1 && !strBuffer.empty()) { position = strBuffer.find('\r'); if(position == std::string::npos) diff --git a/src/version.h b/src/version.h index 894d283..be32cd6 100644 --- a/src/version.h +++ b/src/version.h @@ -1,2 +1,2 @@ -#define APP_VERION "v0.9i" +#define APP_VERION "v0.9j"