@@ -126,8 +126,8 @@ class GameButton : public UI::Clickable {
126126 void Draw (UIContext &dc) override ;
127127 void GetContentDimensions (const UIContext &dc, float &w, float &h) const override {
128128 if (gridStyle_) {
129- w = 144 ;
130- h = 80 ;
129+ w = 144 *g_Config. fGameGridScale ;
130+ h = 80 *g_Config. fGameGridScale ;
131131 } else {
132132 w = 500 ;
133133 h = 50 ;
@@ -234,7 +234,7 @@ void GameButton::Draw(UIContext &dc) {
234234
235235 int x = bounds_.x ;
236236 int y = bounds_.y ;
237- int w = 144 ;
237+ int w = gridStyle_ ? bounds_. w : 144 ;
238238 int h = bounds_.h ;
239239
240240 UI::Style style = dc.theme ->itemStyle ;
@@ -262,7 +262,7 @@ void GameButton::Draw(UIContext &dc) {
262262
263263 // Adjust position so we don't stretch the image vertically or horizontally.
264264 // Make sure it's not wider than 144 (like Doom Legacy homebrew), ugly in the grid mode.
265- float nw = std::min (h * tw / th, 144 . 0f );
265+ float nw = std::min (h * tw / th, ( float )w );
266266 x += (w - nw) / 2 .0f ;
267267 w = nw;
268268 }
@@ -375,7 +375,7 @@ void GameButton::Draw(UIContext &dc) {
375375 const AtlasImage *gearImage = dc.Draw ()->GetAtlas ()->getImage (ImageID (" I_GEAR" ));
376376 if (gearImage) {
377377 if (gridStyle_) {
378- dc.Draw ()->DrawImage (ImageID (" I_GEAR" ), x, y + h - gearImage->h , 1 . 0f );
378+ dc.Draw ()->DrawImage (ImageID (" I_GEAR" ), x, y + h - gearImage->h *g_Config. fGameGridScale , g_Config. fGameGridScale );
379379 } else {
380380 dc.Draw ()->DrawImage (ImageID (" I_GEAR" ), x - gearImage->w , y, 1 .0f );
381381 }
@@ -394,14 +394,15 @@ void GameButton::Draw(UIContext &dc) {
394394 const AtlasImage *image = dc.Draw ()->GetAtlas ()->getImage (regionIcons[ginfo->region ]);
395395 if (image) {
396396 if (gridStyle_) {
397- dc.Draw ()->DrawImage (regionIcons[ginfo->region ], x + w - image->w - 5 , y + h - image->h - 5 , 1 .0f );
397+ dc.Draw ()->DrawImage (regionIcons[ginfo->region ], x + w - (image->w + 5 )*g_Config.fGameGridScale ,
398+ y + h - (image->h + 5 )*g_Config.fGameGridScale , g_Config.fGameGridScale );
398399 } else {
399400 dc.Draw ()->DrawImage (regionIcons[ginfo->region ], x - 2 - image->w - 3 , y + h - image->h - 5 , 1 .0f );
400401 }
401402 }
402403 }
403404 if (gridStyle_ && g_Config.bShowIDOnGameIcon ) {
404- dc.SetFontScale (0 .5f , 0 .5f );
405+ dc.SetFontScale (0 .5f *g_Config. fGameGridScale , 0 .5f *g_Config. fGameGridScale );
405406 dc.DrawText (ginfo->id_version .c_str (), x+5 , y+1 , 0xFF000000 , ALIGN_TOPLEFT);
406407 dc.DrawText (ginfo->id_version .c_str (), x+4 , y, 0xFFffFFff , ALIGN_TOPLEFT);
407408 dc.SetFontScale (1 .0f , 1 .0f );
@@ -414,10 +415,10 @@ void GameButton::Draw(UIContext &dc) {
414415
415416class DirButton : public UI ::Button {
416417public:
417- DirButton (const std::string &path, UI::LayoutParams *layoutParams)
418- : UI::Button(path, layoutParams), path_(path), absolute_(false ) {}
419- DirButton (const std::string &path, const std::string &text, UI::LayoutParams *layoutParams = 0 )
420- : UI::Button(text, layoutParams), path_(path), absolute_(true ) {}
418+ DirButton (const std::string &path, bool gridStyle, UI::LayoutParams *layoutParams)
419+ : UI::Button(path, layoutParams), path_(path), gridStyle_(gridStyle), absolute_(false ) {}
420+ DirButton (const std::string &path, const std::string &text, bool gridStyle, UI::LayoutParams *layoutParams = 0 )
421+ : UI::Button(text, layoutParams), path_(path), gridStyle_(gridStyle), absolute_(true ) {}
421422
422423 virtual void Draw (UIContext &dc);
423424
@@ -432,6 +433,7 @@ class DirButton : public UI::Button {
432433private:
433434 std::string path_;
434435 bool absolute_;
436+ bool gridStyle_;
435437};
436438
437439void DirButton::Draw (UIContext &dc) {
@@ -452,17 +454,20 @@ void DirButton::Draw(UIContext &dc) {
452454 }
453455
454456 float tw, th;
455- dc.MeasureText (dc.GetFontStyle (), 1 . 0f , 1 . 0f , text.c_str (), &tw, &th, 0 );
457+ dc.MeasureText (dc.GetFontStyle (), gridStyle_ ? g_Config. fGameGridScale : 1.0 , gridStyle_ ? g_Config. fGameGridScale : 1.0 , text.c_str (), &tw, &th, 0 );
456458
457- bool compact = bounds_.w < 180 ;
459+ bool compact = bounds_.w < 180 * (gridStyle_ ? g_Config. fGameGridScale : 1.0 ) ;
458460
461+ if (gridStyle_) {
462+ dc.SetFontScale (g_Config.fGameGridScale , g_Config.fGameGridScale );
463+ }
459464 if (compact) {
460465 // No icon, except "up"
461466 dc.PushScissor (bounds_);
462467 if (image == ImageID (" I_FOLDER" )) {
463468 dc.DrawText (text.c_str (), bounds_.x + 5 , bounds_.centerY (), style.fgColor , ALIGN_VCENTER);
464469 } else {
465- dc.Draw ()->DrawImage (image, bounds_.centerX (), bounds_.centerY (), 1 . 0f , 0xFFFFFFFF , ALIGN_CENTER);
470+ dc.Draw ()->DrawImage (image, bounds_.centerX (), bounds_.centerY (), gridStyle_ ? g_Config. fGameGridScale : 1.0 , 0xFFFFFFFF , ALIGN_CENTER);
466471 }
467472 dc.PopScissor ();
468473 } else {
@@ -471,18 +476,20 @@ void DirButton::Draw(UIContext &dc) {
471476 dc.PushScissor (bounds_);
472477 scissor = true ;
473478 }
474-
475- dc.Draw ()->DrawImage (image, bounds_.x + 72 , bounds_.centerY (), .88f , 0xFFFFFFFF , ALIGN_CENTER);
479+ dc.Draw ()->DrawImage (image, bounds_.x + 72 , bounds_.centerY (), 0 .88f *(gridStyle_ ? g_Config.fGameGridScale : 1.0 ), 0xFFFFFFFF , ALIGN_CENTER);
476480 dc.DrawText (text.c_str (), bounds_.x + 150 , bounds_.centerY (), style.fgColor , ALIGN_VCENTER);
477481
478482 if (scissor) {
479483 dc.PopScissor ();
480484 }
481485 }
486+ if (gridStyle_) {
487+ dc.SetFontScale (1.0 , 1.0 );
488+ }
482489}
483490
484- GameBrowser::GameBrowser (std::string path, BrowseFlags browseFlags, bool *gridStyle, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams)
485- : LinearLayout(UI::ORIENT_VERTICAL, layoutParams), path_(path), gridStyle_(gridStyle), browseFlags_(browseFlags), lastText_(lastText), lastLink_(lastLink) {
491+ GameBrowser::GameBrowser (std::string path, BrowseFlags browseFlags, bool *gridStyle, ScreenManager *screenManager, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams)
492+ : LinearLayout(UI::ORIENT_VERTICAL, layoutParams), path_(path), gridStyle_(gridStyle), screenManager_(screenManager), browseFlags_(browseFlags), lastText_(lastText), lastLink_(lastLink) {
486493 using namespace UI ;
487494 Refresh ();
488495}
@@ -558,9 +565,45 @@ void GameBrowser::Update() {
558565 }
559566}
560567
568+ void GameBrowser::Draw (UIContext &dc) {
569+ using namespace UI ;
570+
571+ if (lastScale_ != g_Config.fGameGridScale || lastLayoutWasGrid_ != *gridStyle_) {
572+ Refresh ();
573+ }
574+
575+ if (hasDropShadow_) {
576+ // Darken things behind.
577+ dc.FillRect (UI::Drawable (0x60000000 ), dc.GetBounds ().Expand (dropShadowExpand_));
578+ float dropsize = 30 .0f ;
579+ dc.Draw ()->DrawImage4Grid (dc.theme ->dropShadow4Grid ,
580+ bounds_.x - dropsize, bounds_.y ,
581+ bounds_.x2 () + dropsize, bounds_.y2 ()+dropsize*1 .5f , 0xDF000000 , 3 .0f );
582+ }
583+
584+ if (clip_) {
585+ dc.PushScissor (bounds_);
586+ }
587+
588+ dc.FillRect (bg_, bounds_);
589+ for (View *view : views_) {
590+ if (view->GetVisibility () == V_VISIBLE) {
591+ // Check if bounds are in current scissor rectangle.
592+ if (dc.GetScissorBounds ().Intersects (dc.TransformBounds (view->GetBounds ())))
593+ view->Draw (dc);
594+ }
595+ }
596+ if (clip_) {
597+ dc.PopScissor ();
598+ }
599+ }
600+
561601void GameBrowser::Refresh () {
562602 using namespace UI ;
563603
604+ lastScale_ = g_Config.fGameGridScale ;
605+ lastLayoutWasGrid_ = *gridStyle_;
606+
564607 homebrewStoreButton_ = nullptr ;
565608 // Kill all the contents
566609 Clear ();
@@ -582,23 +625,40 @@ void GameBrowser::Refresh() {
582625 } else {
583626 topBar->Add (new Spacer (new LinearLayoutParams (FILL_PARENT, 64 .0f , 1 .0f )));
584627 }
585-
586628 ChoiceStrip *layoutChoice = topBar->Add (new ChoiceStrip (ORIENT_HORIZONTAL));
587629 layoutChoice->AddChoice (ImageID (" I_GRID" ));
588630 layoutChoice->AddChoice (ImageID (" I_LINES" ));
589631 layoutChoice->SetSelection (*gridStyle_ ? 0 : 1 );
590632 layoutChoice->OnChoice .Handle (this , &GameBrowser::LayoutChange);
633+ topBar->Add (new Choice (ImageID (" I_GEAR" ), new LayoutParams (64 .0f , 64 .0f )))->OnClick .Handle (this , &GameBrowser::GridSettingsClick);
591634 Add (topBar);
592- }
593635
594- if (*gridStyle_) {
595- gameList_ = new UI::GridLayout (UI::GridLayoutSettings (150 , 85 ), new LinearLayoutParams (FILL_PARENT, WRAP_CONTENT));
636+ if (*gridStyle_) {
637+ gameList_ = new UI::GridLayout (UI::GridLayoutSettings (150 *g_Config.fGameGridScale , 85 *g_Config.fGameGridScale ), new LinearLayoutParams (FILL_PARENT, WRAP_CONTENT));
638+ Add (gameList_);
639+ } else {
640+ UI::LinearLayout *gl = new UI::LinearLayout (UI::ORIENT_VERTICAL, new LinearLayoutParams (FILL_PARENT, WRAP_CONTENT));
641+ gl->SetSpacing (4 .0f );
642+ gameList_ = gl;
643+ Add (gameList_);
644+ }
596645 } else {
597- UI::LinearLayout *gl = new UI::LinearLayout (UI::ORIENT_VERTICAL, new LinearLayoutParams (FILL_PARENT, WRAP_CONTENT));
598- gl->SetSpacing (4 .0f );
599- gameList_ = gl;
646+ if (*gridStyle_) {
647+ gameList_ = new UI::GridLayout (UI::GridLayoutSettings (150 *g_Config.fGameGridScale , 85 *g_Config.fGameGridScale ), new LinearLayoutParams (FILL_PARENT, WRAP_CONTENT));
648+ } else {
649+ UI::LinearLayout *gl = new UI::LinearLayout (UI::ORIENT_VERTICAL, new LinearLayoutParams (FILL_PARENT, WRAP_CONTENT));
650+ gl->SetSpacing (4 .0f );
651+ gameList_ = gl;
652+ }
653+ LinearLayout *gridOptionColumn = new LinearLayout (ORIENT_VERTICAL, new LinearLayoutParams (64.0 , 64 .0f ));
654+ gridOptionColumn->Add (new Spacer (12.0 ));
655+ gridOptionColumn->Add (new Choice (ImageID (" I_GEAR" ), new LayoutParams (64 .0f , 64 .0f )))->OnClick .Handle (this , &GameBrowser::GridSettingsClick);
656+ LinearLayout *grid = new LinearLayout (ORIENT_HORIZONTAL);
657+ gameList_->ReplaceLayoutParams (new LinearLayoutParams (FILL_PARENT, WRAP_CONTENT, 0.75 ));
658+ grid->Add (gameList_);
659+ grid->Add (gridOptionColumn);
660+ Add (grid);
600661 }
601- Add (gameList_);
602662
603663 // Find games in the current directory and create new ones.
604664 std::vector<DirButton *> dirButtons;
@@ -627,7 +687,7 @@ void GameBrowser::Refresh() {
627687
628688 if (!isGame && !isSaveData) {
629689 if (browseFlags_ & BrowseFlags::NAVIGATE) {
630- dirButtons.push_back (new DirButton (fileInfo[i].fullName , fileInfo[i].name , new UI::LinearLayoutParams (UI::FILL_PARENT, UI::FILL_PARENT)));
690+ dirButtons.push_back (new DirButton (fileInfo[i].fullName , fileInfo[i].name , *gridStyle_, new UI::LinearLayoutParams (UI::FILL_PARENT, UI::FILL_PARENT)));
631691 }
632692 } else {
633693 gameButtons.push_back (new GameButton (fileInfo[i].fullName , *gridStyle_, new UI::LinearLayoutParams (*gridStyle_ == true ? UI::WRAP_CONTENT : UI::FILL_PARENT, UI::WRAP_CONTENT)));
@@ -655,13 +715,13 @@ void GameBrowser::Refresh() {
655715 }
656716
657717 if (browseFlags_ & BrowseFlags::NAVIGATE) {
658- gameList_->Add (new DirButton (" .." , new UI::LinearLayoutParams (UI::FILL_PARENT, UI::FILL_PARENT)))->
718+ gameList_->Add (new DirButton (" .." , *gridStyle_, new UI::LinearLayoutParams (UI::FILL_PARENT, UI::FILL_PARENT)))->
659719 OnClick.Handle (this , &GameBrowser::NavigateClick);
660720
661721 // Add any pinned paths before other directories.
662722 auto pinnedPaths = GetPinnedPaths ();
663723 for (auto it = pinnedPaths.begin (), end = pinnedPaths.end (); it != end; ++it) {
664- gameList_->Add (new DirButton (*it, GetBaseName (*it), new UI::LinearLayoutParams (UI::FILL_PARENT, UI::FILL_PARENT)))->
724+ gameList_->Add (new DirButton (*it, GetBaseName (*it), *gridStyle_, new UI::LinearLayoutParams (UI::FILL_PARENT, UI::FILL_PARENT)))->
665725 OnClick.Handle (this , &GameBrowser::NavigateClick);
666726 }
667727 }
@@ -842,7 +902,7 @@ void MainScreen::CreateViews() {
842902 ScrollView *scrollRecentGames = new ScrollView (ORIENT_VERTICAL, new LinearLayoutParams (FILL_PARENT, WRAP_CONTENT));
843903 scrollRecentGames->SetTag (" MainScreenRecentGames" );
844904 GameBrowser *tabRecentGames = new GameBrowser (
845- " !RECENT" , BrowseFlags::NONE, &g_Config.bGridView1 , " " , " " ,
905+ " !RECENT" , BrowseFlags::NONE, &g_Config.bGridView1 , screenManager (), " " , " " ,
846906 new LinearLayoutParams (FILL_PARENT, FILL_PARENT));
847907 scrollRecentGames->Add (tabRecentGames);
848908 gameBrowsers_.push_back (tabRecentGames);
@@ -860,10 +920,10 @@ void MainScreen::CreateViews() {
860920 ScrollView *scrollHomebrew = new ScrollView (ORIENT_VERTICAL, new LinearLayoutParams (FILL_PARENT, WRAP_CONTENT));
861921 scrollHomebrew->SetTag (" MainScreenHomebrew" );
862922
863- GameBrowser *tabAllGames = new GameBrowser (g_Config.currentDirectory , BrowseFlags::STANDARD, &g_Config.bGridView2 ,
923+ GameBrowser *tabAllGames = new GameBrowser (g_Config.currentDirectory , BrowseFlags::STANDARD, &g_Config.bGridView2 , screenManager (),
864924 mm->T (" How to get games" ), " https://www.ppsspp.org/getgames.html" ,
865925 new LinearLayoutParams (FILL_PARENT, FILL_PARENT));
866- GameBrowser *tabHomebrew = new GameBrowser (GetSysDirectory (DIRECTORY_GAME), BrowseFlags::HOMEBREW_STORE, &g_Config.bGridView3 ,
926+ GameBrowser *tabHomebrew = new GameBrowser (GetSysDirectory (DIRECTORY_GAME), BrowseFlags::HOMEBREW_STORE, &g_Config.bGridView3 , screenManager (),
867927 mm->T (" How to get homebrew & demos" , " How to get homebrew && demos" ), " https://www.ppsspp.org/gethomebrew.html" ,
868928 new LinearLayoutParams (FILL_PARENT, FILL_PARENT));
869929
@@ -1221,6 +1281,16 @@ UI::EventReturn MainScreen::OnRecentChange(UI::EventParams &e) {
12211281 return UI::EVENT_DONE;
12221282}
12231283
1284+ UI::EventReturn GameBrowser::GridSettingsClick (UI::EventParams &e) {
1285+ auto sy = GetI18NCategory (" System" );
1286+ auto *gridSettings = new GridSettingsScreen (sy->T (" Games list settings" ));
1287+ if (e.v )
1288+ gridSettings->SetPopupOrigin (e.v );
1289+
1290+ screenManager_->push (gridSettings);
1291+ return UI::EVENT_DONE;
1292+ }
1293+
12241294UI::EventReturn MainScreen::OnCredits (UI::EventParams &e) {
12251295 screenManager ()->push (new CreditsScreen ());
12261296 return UI::EVENT_DONE;
@@ -1314,7 +1384,7 @@ void UmdReplaceScreen::CreateViews() {
13141384 ScrollView *scrollRecentGames = new ScrollView (ORIENT_VERTICAL, new LinearLayoutParams (FILL_PARENT, WRAP_CONTENT));
13151385 scrollRecentGames->SetTag (" UmdReplaceRecentGames" );
13161386 GameBrowser *tabRecentGames = new GameBrowser (
1317- " !RECENT" , BrowseFlags::NONE, &g_Config.bGridView1 , " " , " " ,
1387+ " !RECENT" , BrowseFlags::NONE, &g_Config.bGridView1 , screenManager (), " " , " " ,
13181388 new LinearLayoutParams (FILL_PARENT, FILL_PARENT));
13191389 scrollRecentGames->Add (tabRecentGames);
13201390 leftColumn->AddTab (mm->T (" Recent" ), scrollRecentGames);
@@ -1324,7 +1394,7 @@ void UmdReplaceScreen::CreateViews() {
13241394 ScrollView *scrollAllGames = new ScrollView (ORIENT_VERTICAL, new LinearLayoutParams (FILL_PARENT, WRAP_CONTENT));
13251395 scrollAllGames->SetTag (" UmdReplaceAllGames" );
13261396
1327- GameBrowser *tabAllGames = new GameBrowser (g_Config.currentDirectory , BrowseFlags::STANDARD, &g_Config.bGridView2 ,
1397+ GameBrowser *tabAllGames = new GameBrowser (g_Config.currentDirectory , BrowseFlags::STANDARD, &g_Config.bGridView2 , screenManager (),
13281398 mm->T (" How to get games" ), " https://www.ppsspp.org/getgames.html" ,
13291399 new LinearLayoutParams (FILL_PARENT, FILL_PARENT));
13301400
@@ -1376,3 +1446,39 @@ UI::EventReturn UmdReplaceScreen::OnGameSelectedInstant(UI::EventParams &e) {
13761446 TriggerFinish (DR_OK);
13771447 return UI::EVENT_DONE;
13781448}
1449+
1450+ void GridSettingsScreen::CreatePopupContents (UI::ViewGroup *parent) {
1451+ using namespace UI ;
1452+
1453+ auto di = GetI18NCategory (" Dialog" );
1454+ auto sy = GetI18NCategory (" System" );
1455+
1456+ ScrollView *scroll = new ScrollView (ORIENT_VERTICAL, new LinearLayoutParams (FILL_PARENT, WRAP_CONTENT, 1 .0f ));
1457+ LinearLayout *items = new LinearLayout (ORIENT_VERTICAL);
1458+
1459+ items->Add (new ItemHeader (sy->T (" View style" )));
1460+ items->Add (new CheckBox (&g_Config.bGridView1 , sy->T (" Display Recent on a grid" )));
1461+ items->Add (new CheckBox (&g_Config.bGridView2 , sy->T (" Display Games on a grid" )));
1462+ items->Add (new CheckBox (&g_Config.bGridView3 , sy->T (" Display Homebrew on a grid" )));
1463+
1464+ items->Add (new ItemHeader (sy->T (" Grid icon size" )));
1465+ items->Add (new Choice (sy->T (" Increase size" )))->OnClick .Handle (this , &GridSettingsScreen::GridPlusClick);
1466+ items->Add (new Choice (sy->T (" Decrease size" )))->OnClick .Handle (this , &GridSettingsScreen::GridMinusClick);
1467+
1468+ items->Add (new ItemHeader (sy->T (" Extra info" )));
1469+ items->Add (new CheckBox (&g_Config.bShowIDOnGameIcon , sy->T (" Show ID on game selection screen" )));
1470+ items->Add (new CheckBox (&g_Config.bShowRegionOnGameIcon , sy->T (" Show region flag on game selection screen" )));
1471+
1472+ scroll->Add (items);
1473+ parent->Add (scroll);
1474+ }
1475+
1476+ UI::EventReturn GridSettingsScreen::GridPlusClick (UI::EventParams &e) {
1477+ g_Config.fGameGridScale = std::min (g_Config.fGameGridScale *1 .25f , MAX_GAME_GRID_SCALE);
1478+ return UI::EVENT_DONE;
1479+ }
1480+
1481+ UI::EventReturn GridSettingsScreen::GridMinusClick (UI::EventParams &e) {
1482+ g_Config.fGameGridScale = std::max (g_Config.fGameGridScale /1 .25f , MIN_GAME_GRID_SCALE);
1483+ return UI::EVENT_DONE;
1484+ }
0 commit comments