2019-10-26 20:03:15 +00:00
# include <filesystem>
2019-10-31 14:31:15 +00:00
# include <switch.h>
2019-10-26 20:03:15 +00:00
# include "ui/MainApplication.hpp"
# include "ui/mainPage.hpp"
2019-10-27 03:36:45 +00:00
# include "ui/instPage.hpp"
2019-10-26 20:03:15 +00:00
# include "ui/optionsPage.hpp"
# include "util/util.hpp"
# include "util/config.hpp"
# define COLOR(hex) pu::ui::Color::FromHex(hex)
namespace inst : : ui {
extern MainApplication * mainApp ;
2019-10-28 00:05:51 +00:00
std : : vector < std : : string > ourMenuEntries = { " Ignore Required Firmware Version " , " Remove Anime " , " Signature Patches Source URL: " } ;
2019-10-26 20:03:15 +00:00
optionsPage : : optionsPage ( ) : Layout : : Layout ( ) {
this - > SetBackgroundColor ( COLOR ( " #670000FF " ) ) ;
2019-10-27 03:36:45 +00:00
this - > SetBackgroundImage ( " romfs:/background.jpg " ) ;
this - > topRect = Rectangle : : New ( 0 , 0 , 1280 , 93 , COLOR ( " #170909FF " ) ) ;
this - > infoRect = Rectangle : : New ( 0 , 93 , 1280 , 60 , COLOR ( " #17090980 " ) ) ;
this - > botRect = Rectangle : : New ( 0 , 660 , 1280 , 60 , COLOR ( " #17090980 " ) ) ;
this - > titleImage = Image : : New ( 0 , 0 , " romfs:/logo.png " ) ;
2019-10-27 23:06:55 +00:00
this - > pageInfoText = TextBlock : : New ( 10 , 109 , " Change Awoo Installer's settings! " , 30 ) ;
2019-10-26 20:03:15 +00:00
this - > pageInfoText - > SetColor ( COLOR ( " #FFFFFFFF " ) ) ;
2019-11-02 01:13:15 +00:00
this - > butText = TextBlock : : New ( 10 , 678 , " \ue0e0 Select/Change \ue0e1 Cancel " , 24 ) ;
2019-10-27 03:36:45 +00:00
this - > butText - > SetColor ( COLOR ( " #FFFFFFFF " ) ) ;
2019-11-03 18:36:07 +00:00
this - > menu = pu : : ui : : elm : : Menu : : New ( 0 , 154 , 1280 , COLOR ( " #FFFFFF00 " ) , 84 , ( 506 / 84 ) ) ;
2019-10-26 20:03:15 +00:00
this - > menu - > SetOnFocusColor ( COLOR ( " #00000033 " ) ) ;
2019-10-27 03:36:45 +00:00
this - > menu - > SetScrollbarColor ( COLOR ( " #17090980 " ) ) ;
this - > Add ( this - > topRect ) ;
this - > Add ( this - > infoRect ) ;
this - > Add ( this - > botRect ) ;
this - > Add ( this - > titleImage ) ;
this - > Add ( this - > butText ) ;
2019-10-26 20:03:15 +00:00
this - > Add ( this - > pageInfoText ) ;
optionsPage : : setMenuText ( ) ;
this - > Add ( this - > menu ) ;
}
2019-10-28 00:05:51 +00:00
std : : string optionsPage : : getMenuOptionIcon ( bool ourBool ) {
if ( ourBool ) return " romfs:/check-box-outline.png " ;
else return " romfs:/checkbox-blank-outline.png " ;
2019-10-26 20:03:15 +00:00
}
void optionsPage : : setMenuText ( ) {
this - > menu - > ClearItems ( ) ;
2019-10-28 00:05:51 +00:00
auto ignoreFirmOption = pu : : ui : : elm : : MenuItem : : New ( ourMenuEntries [ 0 ] ) ;
2019-10-26 20:03:15 +00:00
ignoreFirmOption - > SetColor ( COLOR ( " #FFFFFFFF " ) ) ;
2019-10-28 00:05:51 +00:00
ignoreFirmOption - > SetIcon ( optionsPage : : getMenuOptionIcon ( inst : : config : : ignoreReqVers ) ) ;
2019-10-26 20:03:15 +00:00
this - > menu - > AddItem ( ignoreFirmOption ) ;
2019-10-28 00:05:51 +00:00
auto gayModeOption = pu : : ui : : elm : : MenuItem : : New ( ourMenuEntries [ 1 ] ) ;
2019-10-26 20:03:15 +00:00
gayModeOption - > SetColor ( COLOR ( " #FFFFFFFF " ) ) ;
2019-10-28 00:05:51 +00:00
gayModeOption - > SetIcon ( optionsPage : : getMenuOptionIcon ( inst : : config : : gayMode ) ) ;
2019-10-26 20:03:15 +00:00
this - > menu - > AddItem ( gayModeOption ) ;
2019-10-28 23:47:49 +00:00
auto sigPatchesUrlOption = pu : : ui : : elm : : MenuItem : : New ( ourMenuEntries [ 2 ] + inst : : util : : shortenString ( inst : : config : : sigPatchesUrl , 42 , false ) ) ;
2019-10-27 21:16:42 +00:00
sigPatchesUrlOption - > SetColor ( COLOR ( " #FFFFFFFF " ) ) ;
this - > menu - > AddItem ( sigPatchesUrlOption ) ;
auto creditsOption = pu : : ui : : elm : : MenuItem : : New ( " Credits " ) ;
creditsOption - > SetColor ( COLOR ( " #FFFFFFFF " ) ) ;
this - > menu - > AddItem ( creditsOption ) ;
2019-11-01 20:35:31 +00:00
auto licenseOption = pu : : ui : : elm : : MenuItem : : New ( " Third Party Licenses " ) ;
licenseOption - > SetColor ( COLOR ( " #FFFFFFFF " ) ) ;
this - > menu - > AddItem ( licenseOption ) ;
2019-10-26 20:03:15 +00:00
}
void optionsPage : : onInput ( u64 Down , u64 Up , u64 Held , pu : : ui : : Touch Pos ) {
if ( Down & KEY_B ) {
mainApp - > LoadLayout ( mainApp - > mainPage ) ;
}
2019-10-31 15:42:40 +00:00
if ( ( Down & KEY_A ) | | ( Up & KEY_TOUCH ) ) {
2019-10-27 21:16:42 +00:00
Result rc = 0 ;
char tmpoutstr [ 128 ] = { 0 } ;
2019-10-26 20:03:15 +00:00
switch ( this - > menu - > GetSelectedIndex ( ) ) {
case 0 :
if ( inst : : config : : ignoreReqVers ) inst : : config : : ignoreReqVers = false ;
else inst : : config : : ignoreReqVers = true ;
inst : : config : : setConfig ( ) ;
optionsPage : : setMenuText ( ) ;
break ;
case 1 :
2019-10-27 03:36:45 +00:00
if ( inst : : config : : gayMode ) {
inst : : config : : gayMode = false ;
mainApp - > mainPage - > awooImage - > SetVisible ( true ) ;
mainApp - > instpage - > awooImage - > SetVisible ( true ) ;
}
else {
inst : : config : : gayMode = true ;
mainApp - > mainPage - > awooImage - > SetVisible ( false ) ;
mainApp - > instpage - > awooImage - > SetVisible ( false ) ;
}
2019-10-26 20:03:15 +00:00
inst : : config : : setConfig ( ) ;
optionsPage : : setMenuText ( ) ;
break ;
2019-10-27 21:16:42 +00:00
case 2 :
SwkbdConfig kbd ;
rc = swkbdCreate ( & kbd , 0 ) ;
if ( R_SUCCEEDED ( rc ) ) {
swkbdConfigMakePresetDefault ( & kbd ) ;
swkbdConfigSetGuideText ( & kbd , " Enter the URL to obtain Signature Patches from " ) ;
swkbdConfigSetInitialText ( & kbd , inst : : config : : sigPatchesUrl . c_str ( ) ) ;
rc = swkbdShow ( & kbd , tmpoutstr , sizeof ( tmpoutstr ) ) ;
swkbdClose ( & kbd ) ;
if ( R_SUCCEEDED ( rc ) & & tmpoutstr [ 0 ] ! = 0 ) {
inst : : config : : sigPatchesUrl = tmpoutstr ;
inst : : config : : setConfig ( ) ;
optionsPage : : setMenuText ( ) ;
}
}
break ;
case 3 :
2019-11-03 18:18:42 +00:00
inst : : ui : : mainApp - > CreateShowDialog ( " Thanks to the following people! " , " - HookedBehemoth for screen-nx and his Plutonium fork \n - Adubbz and other contributors for Tinfoil \n - XorTroll for Plutonium and Goldleaf \n - blawar (wife beater) and nicoboss for NSZ support \n - The kind folks at the AtlasNX Discuck \n - The also kind folks at the RetroNX Discuck \n - namako8982 for the Momiji art \n - TheXzoron for being a baka " , { " Close " } , true ) ;
2019-11-01 20:35:31 +00:00
break ;
case 4 :
2019-11-02 01:13:15 +00:00
inst : : ui : : mainApp - > CreateShowDialog ( " Third Party Licenses " , " Licenses to the libraries and software used in Awoo Installer are packaged with each release \n within the source code, or are distributed upon compilation of the software. \n Please see the releases page for a copy of the source code and license information. " , { " Close " } , true ) ;
2019-10-27 21:16:42 +00:00
break ;
2019-10-26 20:03:15 +00:00
default :
break ;
}
}
}
}