From 02384c8e72e4762e091cb431d8bddeb0653cdcb4 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Fri, 15 Aug 2014 01:34:35 +0200 Subject: [PATCH] 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. --- src/gmenu2x.cpp | 12 +++++++----- src/selector.cpp | 2 +- src/surface.cpp | 11 ++--------- src/surface.h | 3 +-- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/gmenu2x.cpp b/src/gmenu2x.cpp index 2363f2e..cca0d09 100644 --- a/src/gmenu2x.cpp +++ b/src/gmenu2x.cpp @@ -316,7 +316,8 @@ void GMenu2X::initBG() { 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); } @@ -326,7 +327,8 @@ void GMenu2X::initBG() { cpuX = font->getTextWidth(df) + 32; #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); } cpuX += 19; @@ -339,19 +341,19 @@ void GMenu2X::initBG() { if (usbnet) { if (web) { auto webserver = OffscreenSurface::loadImage( - "imgs/webserver.png", confStr["skin"]); + sc.getSkinFilePath("imgs/webserver.png")); if (webserver) webserver->blit(*bgmain, serviceX, bottomBarIconY); serviceX -= 19; } if (samba) { auto sambaS = OffscreenSurface::loadImage( - "imgs/samba.png", confStr["skin"]); + sc.getSkinFilePath("imgs/samba.png")); if (sambaS) sambaS->blit(*bgmain, serviceX, bottomBarIconY); serviceX -= 19; } if (inet) { auto inetS = OffscreenSurface::loadImage( - "imgs/inet.png", confStr["skin"]); + sc.getSkinFilePath("imgs/inet.png")); if (inetS) inetS->blit(*bgmain, serviceX, bottomBarIconY); serviceX -= 19; } diff --git a/src/selector.cpp b/src/selector.cpp index f362079..359a8cf 100644 --- a/src/selector.cpp +++ b/src/selector.cpp @@ -105,7 +105,7 @@ int Selector::exec(int startSelection) { //Screenshot if (fl.isFile(selected)) { string path = screendir + trimExtension(fl[selected]) + ".png"; - auto screenshot = OffscreenSurface::loadImage(path, "", false); + auto screenshot = OffscreenSurface::loadImage(path, false); if (screenshot) { screenshot->blitRight(s, 320, 0, 320, 240, 128u); } diff --git a/src/surface.cpp b/src/surface.cpp index 16bed8d..73b2854 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -22,7 +22,6 @@ #include "debug.h" #include "imageio.h" -#include "surfacecollection.h" #include "utilities.h" #include @@ -292,15 +291,9 @@ unique_ptr OffscreenSurface::emptySurface( } unique_ptr OffscreenSurface::loadImage( - string const& img,string const& skin, bool loadAlpha) + string const& img, bool loadAlpha) { - string skinpath; - if (!skin.empty() && !img.empty() && img[0]!='/') - skinpath = SurfaceCollection::getSkinFilePath(skin, img); - else - skinpath = img; - - SDL_Surface *raw = loadPNG(skinpath, loadAlpha); + SDL_Surface *raw = loadPNG(img, loadAlpha); if (!raw) { ERROR("Couldn't load surface '%s'\n", img.c_str()); return unique_ptr(); diff --git a/src/surface.h b/src/surface.h index a4a9f74..10870f5 100644 --- a/src/surface.h +++ b/src/surface.h @@ -110,8 +110,7 @@ public: static std::unique_ptr emptySurface( int width, int height); static std::unique_ptr loadImage( - std::string const& img, std::string const& skin = "", - bool loadAlpha = true); + std::string const& img, bool loadAlpha = true); OffscreenSurface(Surface const& other) : Surface(other) {} OffscreenSurface(OffscreenSurface const& other) : Surface(other) {}