1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-22 12:57:31 +02:00

Removed skin lookup feature from OffscreenSurface::loadImage

Instead, make the caller perform the lookup. This simplifies the
interface of loadImage and it removes the dependency from
OffscreenSurface on SurfaceCollection.
This commit is contained in:
Maarten ter Huurne 2014-08-15 01:34:35 +02:00
parent 2c47515321
commit 02384c8e72
4 changed files with 11 additions and 17 deletions

View File

@ -316,7 +316,8 @@ void GMenu2X::initBG() {
OffscreenSurface *bgmain = sc.add(*bg, "bgmain"); OffscreenSurface *bgmain = sc.add(*bg, "bgmain");
{ {
auto sd = OffscreenSurface::loadImage("imgs/sd.png", confStr["skin"]); auto sd = OffscreenSurface::loadImage(
sc.getSkinFilePath("imgs/sd.png"));
if (sd) sd->blit(*bgmain, 3, bottomBarIconY); if (sd) sd->blit(*bgmain, 3, bottomBarIconY);
} }
@ -326,7 +327,8 @@ void GMenu2X::initBG() {
cpuX = font->getTextWidth(df) + 32; cpuX = font->getTextWidth(df) + 32;
#ifdef ENABLE_CPUFREQ #ifdef ENABLE_CPUFREQ
{ {
auto cpu = OffscreenSurface::loadImage("imgs/cpu.png", confStr["skin"]); auto cpu = OffscreenSurface::loadImage(
sc.getSkinFilePath("imgs/cpu.png"));
if (cpu) cpu->blit(bgmain, cpuX, bottomBarIconY); if (cpu) cpu->blit(bgmain, cpuX, bottomBarIconY);
} }
cpuX += 19; cpuX += 19;
@ -339,19 +341,19 @@ void GMenu2X::initBG() {
if (usbnet) { if (usbnet) {
if (web) { if (web) {
auto webserver = OffscreenSurface::loadImage( auto webserver = OffscreenSurface::loadImage(
"imgs/webserver.png", confStr["skin"]); sc.getSkinFilePath("imgs/webserver.png"));
if (webserver) webserver->blit(*bgmain, serviceX, bottomBarIconY); if (webserver) webserver->blit(*bgmain, serviceX, bottomBarIconY);
serviceX -= 19; serviceX -= 19;
} }
if (samba) { if (samba) {
auto sambaS = OffscreenSurface::loadImage( auto sambaS = OffscreenSurface::loadImage(
"imgs/samba.png", confStr["skin"]); sc.getSkinFilePath("imgs/samba.png"));
if (sambaS) sambaS->blit(*bgmain, serviceX, bottomBarIconY); if (sambaS) sambaS->blit(*bgmain, serviceX, bottomBarIconY);
serviceX -= 19; serviceX -= 19;
} }
if (inet) { if (inet) {
auto inetS = OffscreenSurface::loadImage( auto inetS = OffscreenSurface::loadImage(
"imgs/inet.png", confStr["skin"]); sc.getSkinFilePath("imgs/inet.png"));
if (inetS) inetS->blit(*bgmain, serviceX, bottomBarIconY); if (inetS) inetS->blit(*bgmain, serviceX, bottomBarIconY);
serviceX -= 19; serviceX -= 19;
} }

View File

@ -105,7 +105,7 @@ int Selector::exec(int startSelection) {
//Screenshot //Screenshot
if (fl.isFile(selected)) { if (fl.isFile(selected)) {
string path = screendir + trimExtension(fl[selected]) + ".png"; string path = screendir + trimExtension(fl[selected]) + ".png";
auto screenshot = OffscreenSurface::loadImage(path, "", false); auto screenshot = OffscreenSurface::loadImage(path, false);
if (screenshot) { if (screenshot) {
screenshot->blitRight(s, 320, 0, 320, 240, 128u); screenshot->blitRight(s, 320, 0, 320, 240, 128u);
} }

View File

@ -22,7 +22,6 @@
#include "debug.h" #include "debug.h"
#include "imageio.h" #include "imageio.h"
#include "surfacecollection.h"
#include "utilities.h" #include "utilities.h"
#include <algorithm> #include <algorithm>
@ -292,15 +291,9 @@ unique_ptr<OffscreenSurface> OffscreenSurface::emptySurface(
} }
unique_ptr<OffscreenSurface> OffscreenSurface::loadImage( unique_ptr<OffscreenSurface> OffscreenSurface::loadImage(
string const& img,string const& skin, bool loadAlpha) string const& img, bool loadAlpha)
{ {
string skinpath; SDL_Surface *raw = loadPNG(img, loadAlpha);
if (!skin.empty() && !img.empty() && img[0]!='/')
skinpath = SurfaceCollection::getSkinFilePath(skin, img);
else
skinpath = img;
SDL_Surface *raw = loadPNG(skinpath, loadAlpha);
if (!raw) { if (!raw) {
ERROR("Couldn't load surface '%s'\n", img.c_str()); ERROR("Couldn't load surface '%s'\n", img.c_str());
return unique_ptr<OffscreenSurface>(); return unique_ptr<OffscreenSurface>();

View File

@ -110,8 +110,7 @@ public:
static std::unique_ptr<OffscreenSurface> emptySurface( static std::unique_ptr<OffscreenSurface> emptySurface(
int width, int height); int width, int height);
static std::unique_ptr<OffscreenSurface> loadImage( static std::unique_ptr<OffscreenSurface> loadImage(
std::string const& img, std::string const& skin = "", std::string const& img, bool loadAlpha = true);
bool loadAlpha = true);
OffscreenSurface(Surface const& other) : Surface(other) {} OffscreenSurface(Surface const& other) : Surface(other) {}
OffscreenSurface(OffscreenSurface const& other) : Surface(other) {} OffscreenSurface(OffscreenSurface const& other) : Surface(other) {}