2019-10-26 20:03:15 +00:00
# include <filesystem>
# 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-27 21:16:42 +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 " ) ;
this - > pageInfoText = TextBlock : : New ( 10 , 109 , " Change application settings! " , 30 ) ;
2019-10-26 20:03:15 +00:00
this - > pageInfoText - > SetColor ( COLOR ( " #FFFFFFFF " ) ) ;
2019-10-27 03:36:45 +00:00
this - > butText = TextBlock : : New ( 10 , 676 , " (A)-Toggle (B)-Cancel " , 30 ) ;
this - > butText - > SetColor ( COLOR ( " #FFFFFFFF " ) ) ;
this - > menu = pu : : ui : : elm : : Menu : : New ( 0 , 153 , 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 ) ;
}
std : : string optionsPage : : getMenuOptionText ( bool ourBool ) {
if ( ourBool ) return " Enabled " ;
else return " Disabled " ;
}
void optionsPage : : setMenuText ( ) {
this - > menu - > ClearItems ( ) ;
auto ignoreFirmOption = pu : : ui : : elm : : MenuItem : : New ( ourMenuEntries [ 0 ] + getMenuOptionText ( inst : : config : : ignoreReqVers ) ) ;
ignoreFirmOption - > SetColor ( COLOR ( " #FFFFFFFF " ) ) ;
this - > menu - > AddItem ( ignoreFirmOption ) ;
auto gayModeOption = pu : : ui : : elm : : MenuItem : : New ( ourMenuEntries [ 1 ] + getMenuOptionText ( inst : : config : : gayMode ) ) ;
gayModeOption - > SetColor ( COLOR ( " #FFFFFFFF " ) ) ;
this - > menu - > AddItem ( gayModeOption ) ;
2019-10-27 21:16:42 +00:00
auto sigPatchesUrlOption = pu : : ui : : elm : : MenuItem : : New ( ourMenuEntries [ 2 ] + inst : : config : : sigPatchesUrl ) ;
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-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 ) ;
}
if ( Down & KEY_A ) {
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 :
inst : : ui : : mainApp - > CreateShowDialog ( " Thanks to the following people for helping me! \n \n -HookedBehemoth for screen-nx (A great reference!) \n -Adubbz for Tinfoil \n -XorTroll for Plutonium and Goldleaf \n -The kind folks at the AtlasNX Discuck \n -The also kind folks at the RetroNX Discuck \n -TheXzoron for being a baka " , " " , { " Close " } , true ) ;
break ;
2019-10-26 20:03:15 +00:00
default :
break ;
}
}
}
}