diff --git a/CMakeLists.txt b/CMakeLists.txt index a8f0b3c06c..0e448e5582 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1576,6 +1576,8 @@ list(APPEND NativeAppSource UI/MiscViews.cpp UI/PauseScreen.h UI/PauseScreen.cpp + UI/SimpleDialogScreen.h + UI/SimpleDialogScreen.cpp UI/TabbedDialogScreen.h UI/TabbedDialogScreen.cpp UI/GameScreen.h diff --git a/Common/Render/AtlasGen.cpp b/Common/Render/AtlasGen.cpp index 20d92bff4a..743026d6eb 100644 --- a/Common/Render/AtlasGen.cpp +++ b/Common/Render/AtlasGen.cpp @@ -40,7 +40,7 @@ bool Image::LoadPNG(const char *png_name) { size_t sz; const uint8_t *file_data = g_VFS.ReadFile(png_name, &sz); if (!file_data) { - printf("Failed to load png from VFS"); + printf("Failed to load png from VFS: %s\n", png_name); return false; } diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 9bf7b791cc..cae61a9545 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -187,7 +187,6 @@ private: class GestureMappingScreen : public UITabbedBaseDialogScreen { public: GestureMappingScreen(const Path &gamePath) : UITabbedBaseDialogScreen(gamePath) {} - void CreateViews() override; void CreateTabs() override; const char *tag() const override { return "GestureMapping"; } diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 1efa2ce861..6eab028ab6 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -478,7 +478,12 @@ private: double dragYOffsetStart_ = 0.0; }; -void CreditsScreen::CreateViews() { +std::string_view CreditsScreen::GetTitle() const { + auto mm = GetI18NCategory(I18NCat::MAINMENU); + return mm->T("About PPSSPP"); +} + +void CreditsScreen::CreateDialogViews(UI::ViewGroup *root) { using namespace UI; ignoreBottomInset_ = false; @@ -489,11 +494,6 @@ void CreditsScreen::CreateViews() { const bool portrait = UsePortraitLayout(); - root_ = new LinearLayout(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, FILL_PARENT)); - - TopBar *topBar = root_->Add(new TopBar(mm->T("About PPSSPP"))); - root_->SetDefaultFocusView(topBar->GetBackButton()); - const bool gold = System_GetPropertyBool(SYSPROP_APP_GOLD); /* @@ -503,9 +503,9 @@ void CreditsScreen::CreateViews() { root_->Add(new ImageView(ImageID("I_ICON"), "", IS_DEFAULT, new AnchorLayoutParams(WRAP_CONTENT, WRAP_CONTENT, 10, 10, NONE, NONE, false)))->SetScale(1.5f); }*/ - root_->Add(new CreditsScroller(new LinearLayoutParams(1.0f))); + root->Add(new CreditsScroller(new LinearLayoutParams(1.0f))); - LinearLayout *columns = root_->Add(new LinearLayout(ORIENT_HORIZONTAL)); + LinearLayout *columns = root->Add(new LinearLayout(ORIENT_HORIZONTAL)); LinearLayout *left = columns->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(250.0f, WRAP_CONTENT, Margins(10)))); LinearLayout *middle = columns->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f))); diff --git a/UI/MiscScreens.h b/UI/MiscScreens.h index bf8593d57c..0ce81762ee 100644 --- a/UI/MiscScreens.h +++ b/UI/MiscScreens.h @@ -27,6 +27,7 @@ #include "Common/File/DirListing.h" #include "Common/File/Path.h" #include "UI/BaseScreens.h" +#include "UI/SimpleDialogScreen.h" struct ShaderInfo; struct TextureShaderInfo; @@ -116,11 +117,15 @@ private: AfterLogoScreen afterLogoScreen_; }; -class CreditsScreen : public UIBaseDialogScreen { +class CreditsScreen : public UISimpleBaseDialogScreen { public: + CreditsScreen() : UISimpleBaseDialogScreen() {} void update() override; protected: - void CreateViews() override; + std::string_view GetTitle() const override; + + void CreateDialogViews(UI::ViewGroup *parent) override; + bool CanScroll() const override { return false; } const char *tag() const override { return "Credits"; } }; diff --git a/UI/SimpleDialogScreen.cpp b/UI/SimpleDialogScreen.cpp new file mode 100644 index 0000000000..e067ec128e --- /dev/null +++ b/UI/SimpleDialogScreen.cpp @@ -0,0 +1,27 @@ +#include "Common/UI/ScrollView.h" +#include "UI/SimpleDialogScreen.h" +#include "UI/MiscViews.h" + +void UISimpleBaseDialogScreen::CreateViews() { + using namespace UI; + + const bool canScroll = CanScroll(); + ignoreBottomInset_ = canScroll; + + const bool portrait = UsePortraitLayout(); + + root_ = new LinearLayout(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, FILL_PARENT)); + root_->Add(new TopBar(GetTitle())); + + if (canScroll) { + ScrollView *scroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT, 1.0f)); + LinearLayout *contents = new LinearLayoutList(ORIENT_VERTICAL); + contents->SetSpacing(0); + CreateDialogViews(contents); + scroll->Add(contents); + root_->Add(scroll); + } else { + CreateDialogViews(root_); + } +} + diff --git a/UI/SimpleDialogScreen.h b/UI/SimpleDialogScreen.h new file mode 100644 index 0000000000..1602132d83 --- /dev/null +++ b/UI/SimpleDialogScreen.h @@ -0,0 +1,25 @@ +#pragma once + +#include "Common/UI/View.h" +#include "Common/UI/ViewGroup.h" + +#include "UI/BaseScreens.h" + +// The simpler cousin of TabbedDialogScreen, without tabs or the other bling, +// but with a consistent portrait-compatible back button and title. +class UISimpleBaseDialogScreen : public UIBaseDialogScreen { +public: + UISimpleBaseDialogScreen(const Path &gamePath = Path()) : UIBaseDialogScreen(gamePath) { + // We need to check CanScroll before we know whether to ignore + // bottom inset. Can't do that here, we do it in CreateViews + } + + // Override this, don't override CreateViews. And don't touch root_ directly. + virtual void CreateDialogViews(UI::ViewGroup *parent) = 0; + virtual std::string_view GetTitle() const { return ""; } +protected: + virtual bool CanScroll() const { return true; } + +private: + void CreateViews() override; +}; diff --git a/UI/UI.vcxproj b/UI/UI.vcxproj index a70d1a2e1c..4b4294e814 100644 --- a/UI/UI.vcxproj +++ b/UI/UI.vcxproj @@ -72,6 +72,7 @@ + @@ -369,4 +370,4 @@ - \ No newline at end of file + diff --git a/UI/UI.vcxproj.filters b/UI/UI.vcxproj.filters index 3f404c20af..4909ae8325 100644 --- a/UI/UI.vcxproj.filters +++ b/UI/UI.vcxproj.filters @@ -88,6 +88,9 @@ Screens + + + Screens Screens @@ -294,4 +297,4 @@ {fda6bc55-1386-4650-a274-44fac9605ea3} - \ No newline at end of file + diff --git a/UWP/UI_UWP/UI_UWP.vcxproj b/UWP/UI_UWP/UI_UWP.vcxproj index 7337d2cc23..dacc3e0a04 100644 --- a/UWP/UI_UWP/UI_UWP.vcxproj +++ b/UWP/UI_UWP/UI_UWP.vcxproj @@ -173,6 +173,7 @@ + @@ -210,4 +211,4 @@ - \ No newline at end of file + diff --git a/UWP/UI_UWP/UI_UWP.vcxproj.filters b/UWP/UI_UWP/UI_UWP.vcxproj.filters index b0e968fa18..d077dce01f 100644 --- a/UWP/UI_UWP/UI_UWP.vcxproj.filters +++ b/UWP/UI_UWP/UI_UWP.vcxproj.filters @@ -114,6 +114,9 @@ Screens + + + Screens Screens @@ -274,4 +277,4 @@ {38b8413d-438d-4197-9db8-7bd123fc7431} - \ No newline at end of file + diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 5e6c8697a3..0d0db04fff 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -909,6 +909,7 @@ LOCAL_SRC_FILES := \ $(SRC)/UI/EmuScreen.cpp \ $(SRC)/UI/MainScreen.cpp \ $(SRC)/UI/TabbedDialogScreen.cpp \ + $(SRC)/UI/SimpleDialogScreen.cpp \ $(SRC)/UI/MemStickScreen.cpp \ $(SRC)/UI/IAPScreen.cpp \ $(SRC)/UI/MiscScreens.cpp \