Files
ppsspp/Common/System/OSD.h
T
Henrik RydgårdandClaude Opus 5.5 b91bd6af86 Settings: Build the settings screen from pages described as data
Each tab is now a SettingsPage: a list of items (headers, settings, buttons,
hints, links to other pages) that a function builds and views are created
from. Settings are added with page->Setting(&g_Config.x), which takes
the label, the kind of view, the range or choices, units, labels for special
values and the default from the config. The pages keep what depends on the
UI (which settings to show and when, enable rules, and behavior that needs the
screen), and reach the screen through the page's SettingsPageHost.

A page can link to other pages, which open on top of it in the same tab,
under a bar showing where you are, like Tools > Developer tools > Graphics,
where the earlier pages can be clicked to go back to them. The bar has back,
search and help buttons, and the back key also goes back a page (or out of a
search) before leaving the screen. Each page remembers its scroll position.
In portrait there's no tab strip: a page links to the tabs, and the bar shows
just the current page's title. Rotating keeps showing the same page. Moving
between pages only focuses an item when navigating with a keyboard or
controller.

The developer tools are now pages linked from the Tools tab, instead of a
screen of their own. The in-game developer menu and
--start-screen=developertools open the settings on that page. The toggles of
live state (the remote debugger and the MIPS tracer) show and change it
through functions, and pretending to be in-game for the notification tests is
a flag on the OSD. The memory map and memstick tests, only reachable from
commented-out code, are removed.

Search lists the matching settings from all tabs and the pages they link to,
grouped by where they are. Each result goes to the setting on its page,
scrolled to and highlighted (outlined, when picked with a mouse or touch), or
for a page, opens it. This replaces the search tab and the old filter that
hid the views that didn't match, and with them ShowSearchControls. Changing
tabs leaves the search.

The pages, the bar and search are in SettingsPagesDialogScreen, between the
tabbed dialog screen and the settings screen, so the other tabbed screens
keep plain tabs.

Other visible changes:
- Reset buttons that went to the wrong value now go to the real default: the
  touch control auto-hide delay (was 20 seconds instead of 8), the mouse
  wheel delay (1 ms, below its own range, instead of 80) and the UI size (0
  instead of -1 on desktop). The alternative speeds get a reset button.
- Units are shown on more sliders (frames, MHz, seconds, Hz), and popups no
  longer spell out what 0 means in the units, since the zero label does.
  Units of up to three characters (%, x, ms, MHz) aren't translated.
- The Android HW scaler hides the scales the display is too small for,
  instead of cutting the list short.
- Choices are translated in the setting's own section.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-25 15:26:58 +01:00

138 lines
4.5 KiB
C++

#pragma once
#include <string>
#include <string_view>
#include <vector>
#include <mutex>
#include <functional>
#include "Common/Common.h"
// Shows a visible message to the user.
// The default implementation in NativeApp.cpp uses our "osm" system (on screen messaging).
enum class OSDType {
MESSAGE_INFO,
MESSAGE_SUCCESS,
MESSAGE_WARNING,
MESSAGE_ERROR,
MESSAGE_ERROR_DUMP, // displays lots of text (after the first line), small size
MESSAGE_FILE_LINK,
MESSAGE_CENTERED_WARNING,
MESSAGE_CENTERED_ERROR,
ACHIEVEMENT_UNLOCKED,
// Side entries
ACHIEVEMENT_PROGRESS, // Achievement icon + "measured_progress" text, auto-hide after 2s
ACHIEVEMENT_CHALLENGE_INDICATOR, // Achievement icon ONLY, no auto-hide
LEADERBOARD_TRACKER,
LEADERBOARD_STARTED_FAILED,
LEADERBOARD_SUBMITTED,
PROGRESS_BAR,
STATUS_ICON, // Use icons from the atlas
VALUE_COUNT,
};
#undef None // X11, sigh.
enum class OSDMessageFlags {
None = 0,
SpinLeft = 1,
SpinRight = 2,
Transparent = 4,
};
ENUM_CLASS_BITOPS(OSDMessageFlags);
// Data holder for on-screen messages.
class OnScreenDisplay {
public:
// If you specify 0.0f as duration, a duration will be chosen automatically depending on type.
void Show(OSDType type, std::string_view text, float duration_s = 0.0f, const char *id = nullptr) {
Show(type, text, "", duration_s, id);
}
void Show(OSDType type, std::string_view text, std::string_view text2, float duration_s = 0.0f, const char *id = nullptr) {
Show(type, text, text2, "", duration_s, id);
}
void Show(OSDType type, std::string_view text, std::string_view text2, std::string_view icon, float duration_s = 0.0f, const char *id = nullptr);
void ShowOnOff(std::string_view message, bool on, float duration_s = 0.0f);
void CancelById(std::string_view id); // Deletes the message immediately with no animation.
bool IsEmpty() const { return entries_.empty(); } // Shortcut to skip rendering.
// Call this every frame, cleans up old entries.
void Update();
// Specialized achievement-related types. These go to the side notifications, not the top-middle.
void ShowAchievementUnlocked(int achievementID);
void ShowAchievementProgress(int achievementID, bool show); // call with show=false to hide. There can only be one of these. When hiding it's ok to not pass a valid achievementID.
void ShowChallengeIndicator(int achievementID, bool show); // call with show=false to hide.
void ShowLeaderboardTracker(int leaderboardTrackerID, std::string_view trackerText, bool show); // show=true is used both for create and update.
void ShowLeaderboardStartEnd(std::string_view title, std::string_view description, bool started); // started = true for started, false for ended.
void ShowLeaderboardSubmitted(std::string_view title, std::string_view value);
// Progress bar controls
// Set is both create and update. If you set maxValue <= minValue, you'll create an "indeterminate" progress
// bar that doesn't show a specific amount of progress.
void SetProgressBar(std::string_view id, std::string_view message, float minValue, float maxValue, float progress, float delay_s);
void RemoveProgressBar(std::string_view id, bool success, float delay_s);
// Call every frame to keep the sidebar visible. Otherwise it'll fade out.
void NudgeIngameNotifications();
float IngameAlpha() const;
// Shows the in-game notifications outside a game too, for testing how they look.
void SetPretendIngame(bool pretend) { pretendIngame_ = pretend; }
bool PretendIngame() const { return pretendIngame_; }
// Fades out everything related to achievements. Should be used on game shutdown.
void ClearAchievementStuff();
// Can't add an infinite number of "Show" functions, so starting to offer post-modification.
void SetFlags(std::string_view id, OSDMessageFlags flag);
void SetClickCallback(std::string_view id, std::function<void()> callback);
struct Entry {
OSDType type;
std::string text;
std::string text2;
std::string iconName;
int numericID;
std::string id;
OSDMessageFlags flags;
std::function<void()> clickCallback;
int instanceID;
double startTime;
double endTime;
// Progress-bar-only data:
float minValue;
float maxValue;
float progress;
};
std::vector<Entry> Entries();
// TODO: Use something more stable than the index.
void ClickEntry(size_t index, double now);
static float FadeinTime() { return 0.1f; }
static float FadeoutTime() { return 0.25f; }
void ClearNonAchievementEntries();
private:
std::vector<Entry> entries_;
std::mutex mutex_;
double sideBarShowTime_ = 0.0;
bool pretendIngame_ = false;
};
extern OnScreenDisplay g_OSD;