aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/3ds/osystem-graphics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform/3ds/osystem-graphics.cpp')
-rw-r--r--backends/platform/3ds/osystem-graphics.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/backends/platform/3ds/osystem-graphics.cpp b/backends/platform/3ds/osystem-graphics.cpp
index 8d4047b6ed..1e340f84d9 100644
--- a/backends/platform/3ds/osystem-graphics.cpp
+++ b/backends/platform/3ds/osystem-graphics.cpp
@@ -24,6 +24,7 @@
#include "backends/platform/3ds/osystem.h"
#include "backends/platform/3ds/shader_shbin.h"
#include "common/rect.h"
+#include "graphics/fontman.h"
#include "options-dialog.h"
#include "config.h"
@@ -278,6 +279,10 @@ void OSystem_3DS::updateScreen() {
// updateFocus();
updateMagnify();
+ if (_osdMessage.getPixels() && _osdMessageEndTime <= getMillis(true)) {
+ _osdMessage.free();
+ }
+
C3D_FrameBegin(0);
_gameTopTexture.transfer();
if (_overlayVisible) {
@@ -286,6 +291,7 @@ void OSystem_3DS::updateScreen() {
if (_cursorVisible && config.showCursor) {
_cursorTexture.transfer();
}
+ _osdMessage.transfer();
_activityIcon.transfer();
C3D_FrameEnd(0);
@@ -306,6 +312,11 @@ void OSystem_3DS::updateScreen() {
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _activityIcon.getMatrix());
_activityIcon.render();
}
+ if (_osdMessage.getPixels() && config.screen == kScreenTop) {
+ _osdMessage.setPosition((400 - _osdMessage.actualWidth) / 2, (240 - _osdMessage.actualHeight) / 2);
+ C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _osdMessage.getMatrix());
+ _osdMessage.render();
+ }
if (_cursorVisible && config.showCursor && config.screen == kScreenTop) {
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _cursorTexture.getMatrix());
_cursorTexture.render();
@@ -328,6 +339,11 @@ void OSystem_3DS::updateScreen() {
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _activityIcon.getMatrix());
_activityIcon.render();
}
+ if (_osdMessage.getPixels()) {
+ _osdMessage.setPosition((320 - _osdMessage.actualWidth) / 2, (240 - _osdMessage.actualHeight) / 2);
+ C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _osdMessage.getMatrix());
+ _osdMessage.render();
+ }
if (_cursorVisible && config.showCursor) {
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, _modelviewLocation, _cursorTexture.getMatrix());
_cursorTexture.render();
@@ -472,6 +488,57 @@ void OSystem_3DS::copyRectToOverlay(const void *buf, int pitch, int x,
_overlay.markDirty();
}
+void OSystem_3DS::displayMessageOnOSD(const char *msg) {
+ // The font we are going to use:
+ const Graphics::Font *font = FontMan.getFontByUsage(Graphics::FontManager::kLocalizedFont);
+ if (!font) {
+ warning("No available font to render OSD messages");
+ return;
+ }
+
+ // Split the message into separate lines.
+ Common::Array<Common::String> lines;
+ const char *ptr;
+ for (ptr = msg; *ptr; ++ptr) {
+ if (*ptr == '\n') {
+ lines.push_back(Common::String(msg, ptr - msg));
+ msg = ptr + 1;
+ }
+ }
+ lines.push_back(Common::String(msg, ptr - msg));
+
+ // Determine a rect which would contain the message string (clipped to the
+ // screen dimensions).
+ const int vOffset = 6;
+ const int lineSpacing = 1;
+ const int lineHeight = font->getFontHeight() + 2 * lineSpacing;
+ int width = 0;
+ int height = lineHeight * lines.size() + 2 * vOffset;
+ uint i;
+ for (i = 0; i < lines.size(); i++) {
+ width = MAX(width, font->getStringWidth(lines[i]) + 14);
+ }
+
+ // Clip the rect
+ if (width > getOverlayWidth())
+ width = getOverlayWidth();
+ if (height > getOverlayHeight())
+ height = getOverlayHeight();
+
+ _osdMessage.create(width, height, _pfGameTexture);
+ _osdMessage.fillRect(Common::Rect(width, height), _pfGameTexture.ARGBToColor(200, 0, 0, 0));
+
+ // Render the message, centered, and in white
+ for (i = 0; i < lines.size(); i++) {
+ font->drawString(&_osdMessage, lines[i],
+ 0, 0 + i * lineHeight + vOffset + lineSpacing, width,
+ _pfGameTexture.RGBToColor(255, 255, 255),
+ Graphics::kTextAlignCenter);
+ }
+
+ _osdMessageEndTime = getMillis(true) + kOSDMessageDuration;
+}
+
void OSystem_3DS::displayActivityIconOnOSD(const Graphics::Surface *icon) {
if (!icon) {
_activityIcon.free();