diff --git a/Common/UI/View.cpp b/Common/UI/View.cpp index 8a8bf00291..30ffc0da73 100644 --- a/Common/UI/View.cpp +++ b/Common/UI/View.cpp @@ -490,7 +490,7 @@ void Choice::GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, totalW += textW; } - w = totalW + 24; + w = totalW + (text_.empty() ? 16 : 24); h = totalH + 16; h = std::max(h, ITEM_HEIGHT); } diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 315c868845..118af2a515 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -1121,9 +1121,9 @@ GameBrowser *MainScreen::CreateBrowserTab(const Path &path, std::string_view tit return gameBrowser; } -UI::ViewGroup *MainScreen::CreateLogoView() { +UI::ViewGroup *MainScreen::CreateLogoView(UI::LayoutParams *layoutParams) { using namespace UI; - AnchorLayout *logos = new AnchorLayout(new AnchorLayoutParams(FILL_PARENT, 80.0f, false)); + AnchorLayout *logos = new AnchorLayout(layoutParams); if (System_GetPropertyBool(SYSPROP_APP_GOLD)) { logos->Add(new ImageView(ImageID("I_ICON_GOLD"), "", IS_DEFAULT, new AnchorLayoutParams(64, 64, 0, 0, NONE, NONE, false))); } else { @@ -1167,6 +1167,40 @@ UI::ViewGroup *MainScreen::CreateLogoView() { return logos; } +void MainScreen::CreateMainButtons(UI::ViewGroup *parent, bool vertical) { + using namespace UI; + auto mm = GetI18NCategory(I18NCat::MAINMENU); + + if (System_GetPropertyBool(SYSPROP_HAS_FILE_BROWSER)) { + parent->Add(vertical ? new Choice(ImageID("I_FOLDER_OPEN")) : new Choice(mm->T("Load", "Load...")))->OnClick.Handle(this, &MainScreen::OnLoadFile); + } + parent->Add(vertical ? new Choice(ImageID("I_GEAR")) : new Choice(mm->T("Game Settings", "Settings")))->OnClick.Handle(this, &MainScreen::OnGameSettings); + parent->Add(vertical ? new Choice(ImageID("I_INFO")) : new Choice(mm->T("About PPSSPP")))->OnClick.Handle(this, &MainScreen::OnCredits); + + if (!vertical) { + parent->Add(new Choice(mm->T("www.ppsspp.org")))->OnClick.Handle(this, &MainScreen::OnPPSSPPOrg); + } + + if (!System_GetPropertyBool(SYSPROP_APP_GOLD) && (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) != DEVICE_TYPE_VR)) { + Choice *gold = parent->Add(vertical ? new Choice(ImageID("I_ICON_GOLD")) : new Choice(mm->T("Buy PPSSPP Gold"))); + gold->OnClick.Add([this](UI::EventParams &) { + LaunchBuyGold(this->screenManager()); + }); + gold->SetIcon(ImageID("I_ICON_GOLD"), 0.5f); + gold->SetImageScale(0.6f); // for the left-icon in case of vertical. + gold->SetShine(true); + } + + if (!vertical) { + parent->Add(new Spacer(25.0)); + } + +#if !PPSSPP_PLATFORM(IOS_APP_STORE) + // Officially, iOS apps should not have exit buttons. Remove it to maximize app store review chances. + parent->Add(new Choice(mm->T("Exit")))->OnClick.Handle(this, &MainScreen::OnExit); +#endif +} + void MainScreen::CreateViews() { // Information in the top left. // Back button to the bottom left. @@ -1259,59 +1293,39 @@ void MainScreen::CreateViews() { leftColumn->Add(new Spacer(new LinearLayoutParams(0.1f))); } - ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL); - LinearLayout *rightColumnItems = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); - rightColumnItems->SetSpacing(0.0f); - rightColumnItems->Add(CreateLogoView()); - - LinearLayout *rightColumnChoices = rightColumnItems; if (vertical) { + ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); + LinearLayout *rightColumnItems = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); + rightColumnItems->SetSpacing(0.0f); + rightColumnItems->Add(CreateLogoView(new LinearLayoutParams(FILL_PARENT, 80.0f, false))); + + LinearLayout *rightColumnChoices = rightColumnItems; ScrollView *rightColumnScroll = new ScrollView(ORIENT_HORIZONTAL); rightColumnChoices = new LinearLayout(ORIENT_HORIZONTAL); rightColumnScroll->Add(rightColumnChoices); rightColumnItems->Add(rightColumnScroll); - } - if (System_GetPropertyBool(SYSPROP_HAS_FILE_BROWSER)) { - rightColumnChoices->Add(vertical ? new Choice(ImageID("I_FOLDER_OPEN")) : new Choice(mm->T("Load", "Load...")))->OnClick.Handle(this, &MainScreen::OnLoadFile); - } - rightColumnChoices->Add(vertical ? new Choice(ImageID("I_GEAR")) : new Choice(mm->T("Game Settings", "Settings")))->OnClick.Handle(this, &MainScreen::OnGameSettings); - rightColumnChoices->Add(vertical ? new Choice(ImageID("I_INFO")) : new Choice(mm->T("About PPSSPP")))->OnClick.Handle(this, &MainScreen::OnCredits); + CreateMainButtons(rightColumnChoices, vertical); - if (!vertical) { - rightColumnChoices->Add(new Choice(mm->T("www.ppsspp.org")))->OnClick.Handle(this, &MainScreen::OnPPSSPPOrg); - } + rightColumn->Add(rightColumnItems); - if (!System_GetPropertyBool(SYSPROP_APP_GOLD) && (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) != DEVICE_TYPE_VR)) { - Choice *gold = rightColumnChoices->Add(vertical ? new Choice(ImageID("I_ICON_GOLD")) : new Choice(mm->T("Buy PPSSPP Gold"))); - gold->OnClick.Add([this](UI::EventParams &) { - LaunchBuyGold(this->screenManager()); - }); - gold->SetIcon(ImageID("I_ICON_GOLD"), 0.5f); - gold->SetImageScale(0.5f); // for the left-icon in case of vertical. - gold->SetShine(true); - } - - if (!vertical) { - rightColumnChoices->Add(new Spacer(25.0)); - } - -#if !PPSSPP_PLATFORM(IOS_APP_STORE) - // Officially, iOS apps should not have exit buttons. Remove it to maximize app store review chances. - rightColumnChoices->Add(new Choice(mm->T("Exit")))->OnClick.Handle(this, &MainScreen::OnExit); -#endif - rightColumn->Add(rightColumnItems); - - if (vertical) { root_ = new LinearLayout(ORIENT_VERTICAL); - rightColumn->ReplaceLayoutParams(new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); leftColumn->ReplaceLayoutParams(new LinearLayoutParams(1.0f)); root_->Add(rightColumn); root_->Add(leftColumn); } else { - Margins actionMenuMargins(0, 10, 10, 0); + const Margins actionMenuMargins(0, 10, 10, 0); + ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins)); + LinearLayout *rightColumnItems = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)); + rightColumnItems->SetSpacing(0.0f); + rightColumnItems->Add(CreateLogoView(new LinearLayoutParams(FILL_PARENT, 80.0f, false))); + + LinearLayout *rightColumnChoices = rightColumnItems; + CreateMainButtons(rightColumnChoices, vertical); + + rightColumn->Add(rightColumnItems); + root_ = new LinearLayout(ORIENT_HORIZONTAL); - rightColumn->ReplaceLayoutParams(new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins)); root_->Add(leftColumn); root_->Add(rightColumn); } diff --git a/UI/MainScreen.h b/UI/MainScreen.h index 2ad4b1e9d0..40da0b1945 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -135,7 +135,8 @@ protected: void CreateViews() override; void CreateRecentTab(); GameBrowser *CreateBrowserTab(const Path &path, std::string_view title, std::string_view howToTitle, std::string_view howToUri, BrowseFlags browseFlags, bool *bGridView, float *scrollPos); - UI::ViewGroup *MainScreen::CreateLogoView(); + UI::ViewGroup *CreateLogoView(UI::LayoutParams *layoutParams); + void CreateMainButtons(UI::ViewGroup *parent, bool vertical); void DrawBackground(UIContext &dc) override; void update() override;