mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-16 07:50:28 +02:00
Refactor main screen code some more
This commit is contained in:
1 parent
2404fc330d
commit
0397fe5e91
3 files changed
+58
-43
No files matched your search
+55
-41
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user