Introduce SimpleBaseDialogScreen, TabbedBaseDialogScreen's simpler cousin

This commit is contained in:
Henrik Rydgård
2025-10-29 00:52:52 +01:00
parent a4f588adfb
commit e37c0cbef3
12 changed files with 83 additions and 16 deletions
+2
View File
@@ -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
+1 -1
View File
@@ -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;
}
-1
View File
@@ -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"; }
+8 -8
View File
@@ -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)));
+7 -2
View File
@@ -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"; }
};
+27
View File
@@ -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_);
}
}
+25
View File
@@ -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;
};
+2 -1
View File
@@ -72,6 +72,7 @@
<ClCompile Include="AudioCommon.cpp" />
<ClCompile Include="SystemInfoScreen.cpp" />
<ClCompile Include="TabbedDialogScreen.cpp" />
<ClCompile Include="SimpleDialogScreen.cpp" />
<ClCompile Include="TiltAnalogSettingsScreen.cpp" />
<ClCompile Include="TouchControlLayoutScreen.cpp" />
<ClCompile Include="TouchControlVisibilityScreen.cpp" />
@@ -369,4 +370,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
+4 -1
View File
@@ -88,6 +88,9 @@
</ClCompile>
<ClCompile Include="TabbedDialogScreen.cpp">
<Filter>Screens</Filter>
</ClCompile>
<ClCompile Include="SimpleDialogScreen.cpp">
<Filter>Screens</Filter>
</ClCompile>
<ClCompile Include="RetroAchievementScreens.cpp">
<Filter>Screens</Filter>
@@ -294,4 +297,4 @@
<UniqueIdentifier>{fda6bc55-1386-4650-a274-44fac9605ea3}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
</Project>
+2 -1
View File
@@ -173,6 +173,7 @@
<ClCompile Include="..\..\UI\MiscViews.cpp" />
<ClCompile Include="..\..\UI\SystemInfoScreen.cpp" />
<ClCompile Include="..\..\UI\TabbedDialogScreen.cpp" />
<ClCompile Include="..\..\UI\SimpleDialogScreen.cpp" />
<ClCompile Include="..\..\UI\RetroAchievementScreens.cpp" />
<ClCompile Include="..\..\UI\Theme.cpp" />
<ClCompile Include="..\..\UI\MainScreen.cpp" />
@@ -210,4 +211,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
+4 -1
View File
@@ -114,6 +114,9 @@
</ClCompile>
<ClCompile Include="..\..\UI\TabbedDialogScreen.cpp">
<Filter>Screens</Filter>
</ClCompile>
<ClCompile Include="..\..\UI\SimpleDialogScreen.cpp">
<Filter>Screens</Filter>
</ClCompile>
<ClCompile Include="..\..\UI\TiltAnalogSettingsScreen.cpp">
<Filter>Screens</Filter>
@@ -274,4 +277,4 @@
<UniqueIdentifier>{38b8413d-438d-4197-9db8-7bd123fc7431}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
</Project>
+1
View File
@@ -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 \