From 45304052cdee76e31d5c8f7b57b65c04fd4f15b7 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Fri, 15 Aug 2014 17:38:43 +0200 Subject: [PATCH] Changed icon lookup in GMenu2X::drawButton(Right) Look up the icon with the "skin:" prefix to be consistent with how other lookups of the same icons are performed. Also don't perform repeated lookups. --- src/gmenu2x.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/gmenu2x.cpp b/src/gmenu2x.cpp index ad3e415..da7ec0c 100644 --- a/src/gmenu2x.cpp +++ b/src/gmenu2x.cpp @@ -1031,11 +1031,13 @@ string GMenu2X::getDiskFree(const char *path) { } int GMenu2X::drawButton(Surface& s, const string &btn, const string &text, int x, int y) { - if (y<0) y = resY+y; int w = 0; - if (sc.skinRes("imgs/buttons/"+btn+".png") != NULL) { - sc["imgs/buttons/"+btn+".png"]->blit(s, x, y-7); - w = sc["imgs/buttons/"+btn+".png"]->width() + 3; + auto icon = sc["skin:imgs/buttons/" + btn + ".png"]; + if (icon) { + if (y < 0) y = resY + y; + w = icon->width(); + icon->blit(s, x, y - 7); + w += 3; w += font->write( s, text, x + w, y, Font::HAlignLeft, Font::VAlignMiddle); } @@ -1043,15 +1045,17 @@ int GMenu2X::drawButton(Surface& s, const string &btn, const string &text, int x } int GMenu2X::drawButtonRight(Surface& s, const string &btn, const string &text, int x, int y) { - if (y<0) y = resY+y; - if (sc.skinRes("imgs/buttons/"+btn+".png") != NULL) { - x -= 16; - sc["imgs/buttons/"+btn+".png"]->blit(s, x, y-7); - x -= 3; - return x-6 - font->write( - s, text, x, y, Font::HAlignRight, Font::VAlignMiddle); + int w = 0; + auto icon = sc["skin:imgs/buttons/" + btn + ".png"]; + if (icon) { + if (y < 0) y = resY + y; + w = icon->width(); + icon->blit(s, x - w, y - 7); + w += 3; + w += font->write( + s, text, x - w, y, Font::HAlignRight, Font::VAlignMiddle); } - return x-6; + return x - (w + 6); } void GMenu2X::drawScrollBar(uint pageSize, uint totalSize, uint pagePos) {