mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-29 01:03:41 +01:00
Support for extra text in OSD messages (drawn smaller, on darker background)
This commit is contained in:
1 parent
c76b6a48ab
commit
266b85d22d
5 files changed
+35
-14
No files matched your search
@@ -72,6 +72,9 @@ struct Bounds {
|
||||
Bounds Offset(float xAmount, float yAmount) const {
|
||||
return Bounds(x + xAmount, y + yAmount, w, h);
|
||||
}
|
||||
Bounds Inset(float left, float top, float right, float bottom) {
|
||||
return Bounds(x + left, y + top, w - left - right, h - bottom - top);
|
||||
}
|
||||
|
||||
float x;
|
||||
float y;
|
||||
|
||||
@@ -73,13 +73,13 @@ u32 BlockDevice::CalculateCRC(volatile bool *cancel) {
|
||||
void BlockDevice::NotifyReadError() {
|
||||
auto err = GetI18NCategory(I18NCat::ERRORS);
|
||||
if (!reportedError_) {
|
||||
g_OSD.Show(OSDType::MESSAGE_ERROR, err->T("Game disc read error - ISO corrupt"), 6.0f);
|
||||
g_OSD.Show(OSDType::MESSAGE_WARNING, err->T("Game disc read error - ISO corrupt"), fileLoader_->GetPath().ToVisualString(), 6.0f);
|
||||
reportedError_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
FileBlockDevice::FileBlockDevice(FileLoader *fileLoader)
|
||||
: fileLoader_(fileLoader) {
|
||||
: BlockDevice(fileLoader) {
|
||||
filesize_ = fileLoader->FileSize();
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ typedef struct ciso_header
|
||||
static const u32 CSO_READ_BUFFER_SIZE = 256 * 1024;
|
||||
|
||||
CISOFileBlockDevice::CISOFileBlockDevice(FileLoader *fileLoader)
|
||||
: fileLoader_(fileLoader)
|
||||
: BlockDevice(fileLoader)
|
||||
{
|
||||
// CISO format is fairly simple, but most tools do not write the header_size.
|
||||
|
||||
@@ -382,7 +382,7 @@ bool CISOFileBlockDevice::ReadBlocks(u32 minBlock, int count, u8 *outPtr) {
|
||||
}
|
||||
|
||||
NPDRMDemoBlockDevice::NPDRMDemoBlockDevice(FileLoader *fileLoader)
|
||||
: fileLoader_(fileLoader)
|
||||
: BlockDevice(fileLoader)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mutex_);
|
||||
MAC_KEY mkey;
|
||||
|
||||
@@ -32,6 +32,7 @@ class FileLoader;
|
||||
|
||||
class BlockDevice {
|
||||
public:
|
||||
BlockDevice(FileLoader *fileLoader) : fileLoader_(fileLoader) {}
|
||||
virtual ~BlockDevice() {}
|
||||
virtual bool ReadBlock(int blockNumber, u8 *outPtr, bool uncached = false) = 0;
|
||||
virtual bool ReadBlocks(u32 minBlock, int count, u8 *outPtr) {
|
||||
@@ -51,6 +52,7 @@ public:
|
||||
void NotifyReadError();
|
||||
|
||||
protected:
|
||||
FileLoader *fileLoader_;
|
||||
bool reportedError_ = false;
|
||||
};
|
||||
|
||||
@@ -64,7 +66,6 @@ public:
|
||||
bool IsDisc() override { return true; }
|
||||
|
||||
private:
|
||||
FileLoader *fileLoader_;
|
||||
u32 *index;
|
||||
u8 *readBuffer;
|
||||
u8 *zlibBuffer;
|
||||
@@ -88,7 +89,6 @@ public:
|
||||
bool IsDisc() override { return true; }
|
||||
|
||||
private:
|
||||
FileLoader *fileLoader_;
|
||||
u64 filesize_;
|
||||
};
|
||||
|
||||
@@ -113,7 +113,6 @@ public:
|
||||
bool IsDisc() override { return false; }
|
||||
|
||||
private:
|
||||
FileLoader *fileLoader_;
|
||||
static std::mutex mutex_;
|
||||
u32 lbaSize;
|
||||
|
||||
|
||||
+1
-1
@@ -804,7 +804,7 @@ void SystemInfoScreen::CreateTabs() {
|
||||
return UI::EVENT_DONE;
|
||||
});
|
||||
internals->Add(new Choice(si->T("Warning")))->OnClick.Add([&](UI::EventParams &) {
|
||||
g_OSD.Show(OSDType::MESSAGE_WARNING, si->T("Warning"));
|
||||
g_OSD.Show(OSDType::MESSAGE_WARNING, si->T("Warning"), "Some\nAdditional\nDetail");
|
||||
return UI::EVENT_DONE;
|
||||
});
|
||||
internals->Add(new Choice(si->T("Info")))->OnClick.Add([&](UI::EventParams &) {
|
||||
|
||||
+25
-6
@@ -40,9 +40,19 @@ ImageID GetOSDIcon(OSDType type) {
|
||||
|
||||
static const float iconSize = 36.0f;
|
||||
|
||||
static const float extraTextScale = 0.7f;
|
||||
|
||||
// Align only matters here for the ASCII-only flag.
|
||||
static void MeasureOSDEntry(UIContext &dc, const OnScreenDisplay::Entry &entry, int align, float *width, float *height) {
|
||||
static void MeasureOSDEntry(UIContext &dc, const OnScreenDisplay::Entry &entry, int align, float *width, float *height, float *height1) {
|
||||
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, entry.text.c_str(), width, height, align);
|
||||
*height1 = *height;
|
||||
|
||||
float width2 = 0.0f, height2 = 0.0f;
|
||||
if (!entry.text2.empty()) {
|
||||
dc.MeasureText(dc.theme->uiFont, extraTextScale, extraTextScale, entry.text2.c_str(), &width2, &height2, align);
|
||||
*width = std::max(*width, width2);
|
||||
*height += 5.0f + height2;
|
||||
}
|
||||
|
||||
if (!GetOSDIcon(entry.type).isInvalid()) {
|
||||
*width += iconSize + 5.0f;
|
||||
@@ -52,7 +62,7 @@ static void MeasureOSDEntry(UIContext &dc, const OnScreenDisplay::Entry &entry,
|
||||
*height = std::max(*height, iconSize + 5.0f);
|
||||
}
|
||||
|
||||
static void RenderOSDEntry(UIContext &dc, const OnScreenDisplay::Entry &entry, Bounds bounds, int align, float alpha) {
|
||||
static void RenderOSDEntry(UIContext &dc, const OnScreenDisplay::Entry &entry, Bounds bounds, float height1, int align, float alpha) {
|
||||
UI::Drawable background = UI::Drawable(colorAlpha(GetOSDBackgroundColor(entry.type), alpha));
|
||||
|
||||
uint32_t foreGround = whiteAlpha(alpha);
|
||||
@@ -74,7 +84,16 @@ static void RenderOSDEntry(UIContext &dc, const OnScreenDisplay::Entry &entry, B
|
||||
bounds.w -= iconSize + 5.0f;
|
||||
}
|
||||
|
||||
dc.DrawTextShadowRect(entry.text.c_str(), bounds, colorAlpha(0xFFFFFFFF, alpha), (align & FLAG_DYNAMIC_ASCII) | ALIGN_CENTER);
|
||||
dc.DrawTextShadowRect(entry.text.c_str(), bounds.Inset(0.0f, 1.0f, 0.0f, 0.0f), colorAlpha(0xFFFFFFFF, alpha), (align & FLAG_DYNAMIC_ASCII));
|
||||
|
||||
if (!entry.text2.empty()) {
|
||||
Bounds bottomTextBounds = bounds.Inset(3.0f, height1 + 5.0f, 3.0f, 3.0f);
|
||||
UI::Drawable backgroundDark = UI::Drawable(colorAlpha(darkenColor(GetOSDBackgroundColor(entry.type)), alpha));
|
||||
dc.FillRect(backgroundDark, bottomTextBounds);
|
||||
dc.SetFontScale(extraTextScale, extraTextScale);
|
||||
dc.DrawTextRect(entry.text2.c_str(), bottomTextBounds, colorAlpha(0xFFFFFFFF, alpha), (align & FLAG_DYNAMIC_ASCII) | ALIGN_LEFT);
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
static void MeasureOSDProgressBar(UIContext &dc, const OnScreenDisplay::ProgressBar &bar, float *width, float *height) {
|
||||
@@ -159,8 +178,8 @@ void OnScreenMessagesView::Draw(UIContext &dc) {
|
||||
align |= FLAG_DYNAMIC_ASCII;
|
||||
}
|
||||
|
||||
float tw, th;
|
||||
MeasureOSDEntry(dc, *iter, align, &tw, &th);
|
||||
float tw, th, h1;
|
||||
MeasureOSDEntry(dc, *iter, align, &tw, &th, &h1);
|
||||
|
||||
Bounds b(0.0f, y, tw, th);
|
||||
|
||||
@@ -183,7 +202,7 @@ void OnScreenMessagesView::Draw(UIContext &dc) {
|
||||
}
|
||||
|
||||
float alpha = Clamp((float)(iter->endTime - now) * 4.0f, 0.0f, 1.0f);
|
||||
RenderOSDEntry(dc, *iter, b, align, alpha);
|
||||
RenderOSDEntry(dc, *iter, b, h1, align, alpha);
|
||||
y += (b.h * scale + 4.0f) * alpha; // including alpha here gets us smooth animations.
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user