1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-25 18:05:20 +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");
{
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;
}

View File

@ -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);
}

View File

@ -22,7 +22,6 @@
#include "debug.h"
#include "imageio.h"
#include "surfacecollection.h"
#include "utilities.h"
#include <algorithm>
@ -292,15 +291,9 @@ unique_ptr<OffscreenSurface> OffscreenSurface::emptySurface(
}
unique_ptr<OffscreenSurface> 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<OffscreenSurface>();

View File

@ -110,8 +110,7 @@ public:
static std::unique_ptr<OffscreenSurface> emptySurface(
int width, int height);
static std::unique_ptr<OffscreenSurface> 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) {}