aboutsummaryrefslogtreecommitdiff
path: root/backends/networking/curl
diff options
context:
space:
mode:
authorAlexander Tkachev2016-06-04 16:02:20 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit4874fafb153a21de5e6ab573c50de7fbf3c46729 (patch)
tree7727dcc271867d9edb3c48ab92af0d492bb5beaf /backends/networking/curl
parent1b9987ddc9ff7a69d0de5bbbbd4aee42fff08b42 (diff)
downloadscummvm-rg350-4874fafb153a21de5e6ab573c50de7fbf3c46729.tar.gz
scummvm-rg350-4874fafb153a21de5e6ab573c50de7fbf3c46729.tar.bz2
scummvm-rg350-4874fafb153a21de5e6ab573c50de7fbf3c46729.zip
CLOUD: Fix CloudIcon
Now it loads the surface once.
Diffstat (limited to 'backends/networking/curl')
-rw-r--r--backends/networking/curl/cloudicon.cpp49
-rw-r--r--backends/networking/curl/cloudicon.h7
2 files changed, 49 insertions, 7 deletions
diff --git a/backends/networking/curl/cloudicon.cpp b/backends/networking/curl/cloudicon.cpp
index e8c92592bf..ec89c12dc9 100644
--- a/backends/networking/curl/cloudicon.cpp
+++ b/backends/networking/curl/cloudicon.cpp
@@ -24,14 +24,48 @@
#include "backends/cloud/cloudmanager.h"
#include "gui/ThemeEngine.h"
#include "gui/gui-manager.h"
+#include "image/png.h"
+#include <common/file.h>
+#include <backends/graphics/surfacesdl/surfacesdl-graphics.h>
namespace Networking {
-CloudIcon::CloudIcon(): _frame(0), _wasVisible(false) {}
+CloudIcon::CloudIcon(): _frame(0), _wasVisible(false), _iconsInited(false) {
+ initIcons();
+}
CloudIcon::~CloudIcon() {}
-void CloudIcon::draw() {
+void CloudIcon::initIcons() {
+ if (_iconsInited) return;
+
+ Image::PNGDecoder decoder;
+ Common::ArchiveMemberList members;
+ Common::File file;
+ if (!file.open("cloudicon.png")) warning("failed");
+ Common::SeekableReadStream *stream = &file;
+ if (stream) {
+ if (!decoder.loadStream(*stream))
+ error("Error decoding PNG");
+
+ Graphics::TransparentSurface *s = new Graphics::TransparentSurface(*decoder.getSurface(), true);
+ if (s) {
+ Graphics::PixelFormat f = g_system->getOSDFormat();
+ //f.bytesPerPixel = 4;
+ debug("%d in osd vs %d in s", f.bytesPerPixel, s->format.bytesPerPixel);
+ Graphics::TransparentSurface *s2 = s->convertTo(f);
+ if (s2) _icon.copyFrom(*s2);
+ else warning("failed converting");
+ }
+ else warning("failed reading");
+ }
+ _iconsInited = true;
+}
+
+void CloudIcon::draw() {
+ initIcons();
+ _frame++;
+
Cloud::Storage *storage = CloudMan.getCurrentStorage();
if (storage && storage->isWorking()) {
if (g_system) {
@@ -39,16 +73,19 @@ void CloudIcon::draw() {
g_system->clearOSD();
_wasVisible = true;
}
-
- const Graphics::Surface *s = g_gui.theme()->getImageSurface(GUI::ThemeEngine::kImageLogoSmall);
- int x = g_system->getOverlayWidth() - s->w - 10, y = 10;
- g_system->copyRectToOSD(s->getPixels(), s->pitch, x, y, s->w, s->h);
} else {
_wasVisible = false;
}
} else {
_wasVisible = false;
}
+
+ if (g_system) {
+ if (_icon.getPixels()) {
+ int x = g_system->getOverlayWidth() - _icon.w - 10, y = 10;
+ g_system->copyRectToOSD(_icon.getPixels(), _icon.pitch, x, y, _icon.w, _icon.h);
+ }
+ }
}
} // End of namespace Networking
diff --git a/backends/networking/curl/cloudicon.h b/backends/networking/curl/cloudicon.h
index 24c1fd6f71..7cecf3acde 100644
--- a/backends/networking/curl/cloudicon.h
+++ b/backends/networking/curl/cloudicon.h
@@ -23,11 +23,16 @@
#ifndef BACKENDS_NETWORKING_CURL_CLOUDICON_H
#define BACKENDS_NETWORKING_CURL_CLOUDICON_H
+#include "graphics/transparent_surface.h"
+
namespace Networking {
class CloudIcon {
int _frame;
- bool _wasVisible;
+ bool _wasVisible, _iconsInited;
+ Graphics::TransparentSurface _icon;
+
+ void initIcons();
public:
CloudIcon();