Prepare for detailed overlay messages

This commit is contained in:
Henrik Rydgård 2023-06-20 23:40:36 +02:00
parent ff75eced70
commit c76b6a48ab
3 changed files with 11 additions and 4 deletions

View file

@ -40,7 +40,7 @@ std::vector<OnScreenDisplay::ProgressBar> OnScreenDisplay::ProgressBars() {
return bars_; // makes a copy.
}
void OnScreenDisplay::Show(OSDType type, const std::string &text, float duration_s, const char *id) {
void OnScreenDisplay::Show(OSDType type, const std::string &text, const std::string &text2, float duration_s, const char *id) {
// Automatic duration based on type.
if (duration_s <= 0.0f) {
switch (type) {
@ -68,7 +68,9 @@ void OnScreenDisplay::Show(OSDType type, const std::string &text, float duration
Entry msg = *iter;
msg.endTime = now + duration_s;
msg.text = text;
msg.text2 = text2;
msg.type = type;
// Move to top (should we? maybe not?)
entries_.erase(iter);
entries_.insert(entries_.begin(), msg);
return;
@ -78,6 +80,7 @@ void OnScreenDisplay::Show(OSDType type, const std::string &text, float duration
Entry msg;
msg.text = text;
msg.text2 = text2;
msg.endTime = now + duration_s;
msg.type = type;
msg.id = id;

View file

@ -228,7 +228,10 @@ enum class OSDType {
class OnScreenDisplay {
public:
// If you specify 0.0f as duration, a duration will be chosen automatically depending on type.
void Show(OSDType type, const std::string &message, float duration_s = 0.0f, const char *id = nullptr);
void Show(OSDType type, const std::string &text, float duration_s = 0.0f, const char *id = nullptr) {
Show(type, text, "", duration_s, id);
}
void Show(OSDType type, const std::string &text, const std::string &text2, float duration_s = 0.0f, const char *id = nullptr);
void ShowOnOff(const std::string &message, bool on, float duration_s = 0.0f);
bool IsEmpty() const { return entries_.empty(); } // Shortcut to skip rendering.
@ -244,6 +247,7 @@ public:
struct Entry {
OSDType type;
std::string text;
std::string text2;
const char *id;
double endTime;
double duration;

View file

@ -229,6 +229,8 @@ bool EmuScreen::bootAllowStorage(const Path &filename) {
}
void EmuScreen::bootGame(const Path &filename) {
auto sc = GetI18NCategory(I18NCat::SCREEN);
if (PSP_IsRebooting())
return;
if (PSP_IsInited()) {
@ -259,8 +261,6 @@ void EmuScreen::bootGame(const Path &filename) {
if (!bootAllowStorage(filename))
return;
auto sc = GetI18NCategory(I18NCat::SCREEN);
invalid_ = true;
// We don't want to boot with the wrong game specific config, so wait until info is ready.