44
44
#include " Core/System.h"
45
45
#include " Core/WebServer.h"
46
46
#include " UI/RemoteISOScreen.h"
47
+ #include " UI/OnScreenDisplay.h"
47
48
48
49
using namespace UI ;
49
50
@@ -271,10 +272,22 @@ static bool LoadGameList(const Path &url, std::vector<Path> &games) {
271
272
return !games.empty ();
272
273
}
273
274
274
- RemoteISOScreen::RemoteISOScreen (const Path &filename) : UIDialogScreenWithGameBackground(filename) {}
275
+ RemoteISOScreen::RemoteISOScreen (const Path &filename) : TabbedUIDialogScreenWithGameBackground(filename) {}
276
+
277
+
278
+ void RemoteISOScreen::CreateTabs () {
279
+ auto ri = GetI18NCategory (I18NCat::REMOTEISO);
280
+
281
+ UI::LinearLayout *connect = AddTab (" Connect" , ri->T (" Connect" ));
282
+ connect->SetSpacing (5 .0f );
283
+ CreateConnectTab (connect);
284
+
285
+ UI::LinearLayout *settings = AddTab (" Settings" , ri->T (" Settings" ));
286
+ CreateSettingsTab (settings);
287
+ }
275
288
276
289
void RemoteISOScreen::update () {
277
- UIDialogScreenWithBackground ::update ();
290
+ TabbedUIDialogScreenWithGameBackground ::update ();
278
291
279
292
if (!WebServerStopped (WebServerFlags::DISCS)) {
280
293
auto result = IsServerAllowed (g_Config.iRemoteISOPort );
@@ -296,17 +309,24 @@ void RemoteISOScreen::update() {
296
309
serverRunning_ = nowRunning;
297
310
}
298
311
299
- void RemoteISOScreen::CreateViews ( ) {
312
+ void RemoteISOScreen::CreateConnectTab (UI::ViewGroup *tab ) {
300
313
auto di = GetI18NCategory (I18NCat::DIALOG);
301
314
auto ri = GetI18NCategory (I18NCat::REMOTEISO);
302
315
303
316
Margins actionMenuMargins (0 , 20 , 15 , 0 );
304
317
Margins contentMargins (0 , 20 , 5 , 5 );
318
+
305
319
ViewGroup *leftColumn = new ScrollView (ORIENT_VERTICAL, new LinearLayoutParams (FILL_PARENT, FILL_PARENT, 0 .4f , contentMargins));
306
320
LinearLayout *leftColumnItems = new LinearLayout (ORIENT_VERTICAL, new LayoutParams (WRAP_CONTENT, FILL_PARENT));
307
321
ViewGroup *rightColumn = new ScrollView (ORIENT_VERTICAL, new LinearLayoutParams (300 , FILL_PARENT, actionMenuMargins));
308
322
LinearLayout *rightColumnItems = new LinearLayout (ORIENT_VERTICAL);
309
323
324
+ if (serverRunning_) {
325
+ leftColumnItems->Add (new NoticeView (NoticeLevel::SUCCESS, ri->T (" Currently sharing" ), " " , new LinearLayoutParams (Margins (12 , 5 , 0 , 5 ))));
326
+ } else {
327
+ leftColumnItems->Add (new NoticeView (NoticeLevel::INFO, ri->T (" Not currently sharing" ), " " , new LinearLayoutParams (Margins (12 , 5 , 0 , 5 ))));
328
+ }
329
+
310
330
if ((RemoteISOShareType)g_Config.iRemoteISOShareType == RemoteISOShareType::RECENT) {
311
331
leftColumnItems->Add (new TextView (ri->T (" RemoteISODesc" , " Games in your recent list will be shared" ), new LinearLayoutParams (Margins (12 , 5 , 0 , 5 ))));
312
332
} else {
@@ -330,18 +350,73 @@ void RemoteISOScreen::CreateViews() {
330
350
rightColumnItems->Add (new Choice (ri->T (" Share Games (Server)" )))->OnClick .Handle (this , &RemoteISOScreen::HandleStartServer);
331
351
browseChoice->SetEnabled (true );
332
352
}
333
- Choice *settingsChoice = new Choice (ri->T (" Settings" ));
334
- rightColumnItems->Add (settingsChoice)->OnClick .Handle (this , &RemoteISOScreen::HandleSettings);
335
353
336
- LinearLayout *beforeBack = new LinearLayout (ORIENT_HORIZONTAL, new AnchorLayoutParams (FILL_PARENT, FILL_PARENT));
354
+ LinearLayout *beforeBack = new LinearLayout (ORIENT_HORIZONTAL, new LayoutParams (FILL_PARENT, FILL_PARENT));
337
355
beforeBack->Add (leftColumn);
338
356
beforeBack->Add (rightColumn);
339
- root_ = new AnchorLayout (new LayoutParams (FILL_PARENT, FILL_PARENT));
340
- root_->Add (beforeBack);
341
- root_->Add (new Choice (di->T (" Back" ), " " , false , new AnchorLayoutParams (150 , WRAP_CONTENT, 10 , NONE, NONE, 10 )))->OnClick .Handle <UIScreen>(this , &UIScreen::OnBack);
342
357
343
358
leftColumn->Add (leftColumnItems);
344
359
rightColumn->Add (rightColumnItems);
360
+ tab->Add (beforeBack);
361
+ }
362
+
363
+ void RemoteISOScreen::CreateSettingsTab (UI::ViewGroup *remoteisoSettings) {
364
+ serverRunning_ = !WebServerStopped (WebServerFlags::DISCS);
365
+
366
+ auto ri = GetI18NCategory (I18NCat::REMOTEISO);
367
+
368
+ remoteisoSettings->Add (new ItemHeader (ri->T (" Remote disc streaming" )));
369
+ remoteisoSettings->Add (new CheckBox (&g_Config.bRemoteShareOnStartup , ri->T (" Share on PPSSPP startup" )));
370
+ remoteisoSettings->Add (new CheckBox (&g_Config.bRemoteISOManual , ri->T (" Manual Mode Client" , " Manually configure client" )));
371
+ remoteisoSettings->Add (new CheckBox (&g_Config.bRemoteTab , ri->T (" Show Remote tab on main screen" )));
372
+
373
+ if (System_GetPropertyBool (SYSPROP_HAS_FOLDER_BROWSER)) {
374
+ static const char *shareTypes[] = { " Recent files" , " Choose directory" };
375
+ remoteisoSettings->Add (new PopupMultiChoice (&g_Config.iRemoteISOShareType , ri->T (" Files to share" ), shareTypes, 0 , ARRAY_SIZE (shareTypes), I18NCat::REMOTEISO, screenManager ()));
376
+ FolderChooserChoice *folderChooser = remoteisoSettings->Add (new FolderChooserChoice (GetRequesterToken (), &g_Config.sRemoteISOSharedDir , ri->T (" Files to share" )));
377
+ folderChooser->SetEnabledFunc ([=]() {
378
+ return g_Config.iRemoteISOShareType == (int )RemoteISOShareType::LOCAL_FOLDER;
379
+ });
380
+ } else {
381
+ // Can't pick a folder, only allow sharing recent stuff.
382
+ g_Config.iRemoteISOShareType = (int )RemoteISOShareType::RECENT;
383
+ }
384
+
385
+ UI::Choice *remoteServer = new PopupTextInputChoice (GetRequesterToken (), &g_Config.sLastRemoteISOServer , ri->T (" Remote Server" ), " " , 255 , screenManager ());
386
+ remoteisoSettings->Add (remoteServer);
387
+ remoteServer->SetEnabledPtr (&g_Config.bRemoteISOManual );
388
+
389
+ PopupSliderChoice *remotePort = remoteisoSettings->Add (new PopupSliderChoice (&g_Config.iLastRemoteISOPort , 0 , 65535 , 0 , ri->T (" Remote Port" ), 100 , screenManager ()));
390
+ remotePort->SetEnabledPtr (&g_Config.bRemoteISOManual );
391
+
392
+ UI::Choice *remoteSubdir;
393
+ {
394
+ PopupTextInputChoice *remoteSubdirInput = new PopupTextInputChoice (GetRequesterToken (), &g_Config.sRemoteISOSubdir , ri->T (" Remote Subdirectory" ), " " , 255 , screenManager ());
395
+ remoteSubdirInput->OnChange .Handle (this , &RemoteISOScreen::OnChangeRemoteISOSubdir);
396
+ remoteSubdir = remoteSubdirInput;
397
+ }
398
+ remoteisoSettings->Add (remoteSubdir);
399
+ remoteSubdir->SetEnabledPtr (&g_Config.bRemoteISOManual );
400
+
401
+ PopupSliderChoice *portChoice = new PopupSliderChoice (&g_Config.iRemoteISOPort , 0 , 65535 , 0 , ri->T (" Local Server Port" , " Local Server Port" ), 100 , screenManager ());
402
+ remoteisoSettings->Add (portChoice);
403
+ portChoice->SetDisabledPtr (&serverRunning_);
404
+ }
405
+
406
+ static void CleanupRemoteISOSubdir () {
407
+ // Replace spaces and force forward slashes.
408
+ // TODO: Maybe we should uri escape this after?
409
+ ReplaceAll (g_Config.sRemoteISOSubdir , " " , " %20" );
410
+ ReplaceAll (g_Config.sRemoteISOSubdir , " \\ " , " /" );
411
+ // Make sure it begins with /.
412
+ if (g_Config.sRemoteISOSubdir .empty () || g_Config.sRemoteISOSubdir [0 ] != ' /' )
413
+ g_Config.sRemoteISOSubdir = " /" + g_Config.sRemoteISOSubdir ;
414
+ }
415
+
416
+
417
+ UI::EventReturn RemoteISOScreen::OnChangeRemoteISOSubdir (UI::EventParams &e) {
418
+ CleanupRemoteISOSubdir ();
419
+ return UI::EVENT_DONE;
345
420
}
346
421
347
422
UI::EventReturn RemoteISOScreen::HandleStartServer (UI::EventParams &e) {
@@ -368,11 +443,6 @@ UI::EventReturn RemoteISOScreen::HandleBrowse(UI::EventParams &e) {
368
443
return EVENT_DONE;
369
444
}
370
445
371
- UI::EventReturn RemoteISOScreen::HandleSettings (UI::EventParams &e) {
372
- screenManager ()->push (new RemoteISOSettingsScreen ());
373
- return EVENT_DONE;
374
- }
375
-
376
446
RemoteISOConnectScreen::RemoteISOConnectScreen () {
377
447
scanCancelled = false ;
378
448
scanAborted = false ;
@@ -570,84 +640,3 @@ void RemoteISOBrowseScreen::CreateViews() {
570
640
571
641
upgradeBar_ = 0 ;
572
642
}
573
-
574
- RemoteISOSettingsScreen::RemoteISOSettingsScreen () {
575
- serverRunning_ = !WebServerStopped (WebServerFlags::DISCS);
576
- }
577
-
578
- void RemoteISOSettingsScreen::update () {
579
- UIDialogScreenWithBackground::update ();
580
-
581
- bool nowRunning = !WebServerStopped (WebServerFlags::DISCS);
582
- if (serverRunning_ != nowRunning) {
583
- RecreateViews ();
584
- }
585
- serverRunning_ = nowRunning;
586
- }
587
-
588
- void RemoteISOSettingsScreen::CreateViews () {
589
- auto ri = GetI18NCategory (I18NCat::REMOTEISO);
590
-
591
- ViewGroup *remoteisoSettingsScroll = new ScrollView (ORIENT_VERTICAL, new LayoutParams (FILL_PARENT, FILL_PARENT));
592
- remoteisoSettingsScroll->SetTag (" RemoteISOSettings" );
593
- LinearLayout *remoteisoSettings = new LinearLayoutList (ORIENT_VERTICAL);
594
- remoteisoSettings->SetSpacing (0 );
595
- remoteisoSettingsScroll->Add (remoteisoSettings);
596
-
597
- remoteisoSettings->Add (new ItemHeader (ri->T (" Remote disc streaming" )));
598
- remoteisoSettings->Add (new CheckBox (&g_Config.bRemoteShareOnStartup , ri->T (" Share on PPSSPP startup" )));
599
- remoteisoSettings->Add (new CheckBox (&g_Config.bRemoteISOManual , ri->T (" Manual Mode Client" , " Manually configure client" )));
600
- remoteisoSettings->Add (new CheckBox (&g_Config.bRemoteTab , ri->T (" Show Remote tab on main screen" )));
601
-
602
- if (System_GetPropertyBool (SYSPROP_HAS_FOLDER_BROWSER)) {
603
- static const char *shareTypes[] = { " Recent files" , " Choose directory" };
604
- remoteisoSettings->Add (new PopupMultiChoice (&g_Config.iRemoteISOShareType , ri->T (" Files to share" ), shareTypes, 0 , ARRAY_SIZE (shareTypes), I18NCat::REMOTEISO, screenManager ()));
605
- FolderChooserChoice *folderChooser = remoteisoSettings->Add (new FolderChooserChoice (GetRequesterToken (), &g_Config.sRemoteISOSharedDir , ri->T (" Files to share" )));
606
- folderChooser->SetEnabledFunc ([=]() {
607
- return g_Config.iRemoteISOShareType == (int )RemoteISOShareType::LOCAL_FOLDER;
608
- });
609
- } else {
610
- // Can't pick a folder, only allow sharing recent stuff.
611
- g_Config.iRemoteISOShareType = (int )RemoteISOShareType::RECENT;
612
- }
613
-
614
- UI::Choice *remoteServer = new PopupTextInputChoice (GetRequesterToken (), &g_Config.sLastRemoteISOServer , ri->T (" Remote Server" ), " " , 255 , screenManager ());
615
- remoteisoSettings->Add (remoteServer);
616
- remoteServer->SetEnabledPtr (&g_Config.bRemoteISOManual );
617
-
618
- PopupSliderChoice *remotePort = remoteisoSettings->Add (new PopupSliderChoice (&g_Config.iLastRemoteISOPort , 0 , 65535 , 0 , ri->T (" Remote Port" ), 100 , screenManager ()));
619
- remotePort->SetEnabledPtr (&g_Config.bRemoteISOManual );
620
-
621
- UI::Choice *remoteSubdir;
622
- {
623
- PopupTextInputChoice *remoteSubdirInput = new PopupTextInputChoice (GetRequesterToken (), &g_Config.sRemoteISOSubdir , ri->T (" Remote Subdirectory" ), " " , 255 , screenManager ());
624
- remoteSubdirInput->OnChange .Handle (this , &RemoteISOSettingsScreen::OnChangeRemoteISOSubdir);
625
- remoteSubdir = remoteSubdirInput;
626
- }
627
- remoteisoSettings->Add (remoteSubdir);
628
- remoteSubdir->SetEnabledPtr (&g_Config.bRemoteISOManual );
629
-
630
- PopupSliderChoice *portChoice = new PopupSliderChoice (&g_Config.iRemoteISOPort , 0 , 65535 , 0 , ri->T (" Local Server Port" , " Local Server Port" ), 100 , screenManager ());
631
- remoteisoSettings->Add (portChoice);
632
- portChoice->SetDisabledPtr (&serverRunning_);
633
- remoteisoSettings->Add (new Spacer (25.0 ));
634
-
635
- root_ = new AnchorLayout (new LayoutParams (FILL_PARENT, FILL_PARENT));
636
- root_->Add (remoteisoSettingsScroll);
637
- AddStandardBack (root_);
638
- }
639
-
640
- static void CleanupRemoteISOSubdir () {
641
- // Replace spaces and force forward slashes.
642
- // TODO: Maybe we should uri escape this after?
643
- ReplaceAll (g_Config.sRemoteISOSubdir , " " , " %20" );
644
- ReplaceAll (g_Config.sRemoteISOSubdir , " \\ " , " /" );
645
- // Make sure it begins with /.
646
- if (g_Config.sRemoteISOSubdir .empty () || g_Config.sRemoteISOSubdir [0 ] != ' /' )
647
- g_Config.sRemoteISOSubdir = " /" + g_Config.sRemoteISOSubdir ;
648
- }
649
-
650
- UI::EventReturn RemoteISOSettingsScreen::OnChangeRemoteISOSubdir (UI::EventParams &e) {
651
- CleanupRemoteISOSubdir ();
652
- return UI::EVENT_DONE;
653
- }
0 commit comments