diff --git a/src/link.cpp b/src/link.cpp index fcebd37..c5b352f 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -33,12 +33,14 @@ Link::Link(GMenu2X *gmenu2x) : Button(gmenu2x, true) { iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png"); iconX = 0; padding = 0; + + updateSurfaces(); } void Link::run() {} void Link::paint() { - gmenu2x->sc[getIconPath()]->blit(gmenu2x->s, iconX, rect.y+padding, 32,32); + iconSurface->blit(gmenu2x->s, iconX, rect.y+padding, 32,32); gmenu2x->s->write( gmenu2x->font, getTitle(), iconX+16, rect.y+gmenu2x->skinConfInt["linkHeight"]-padding, SFontHAlignCenter, SFontVAlignBottom ); } @@ -50,6 +52,11 @@ bool Link::paintHover() { return true; } +void Link::updateSurfaces() +{ + iconSurface = gmenu2x->sc[getIconPath()]; +} + string Link::getTitle() { return title; } @@ -89,6 +96,7 @@ void Link::setIcon(string icon) { this->icon = icon; edited = true; + updateSurfaces(); } string Link::searchIcon() { @@ -106,6 +114,7 @@ void Link::setIconPath(string icon) { iconPath = icon; else iconPath = gmenu2x->sc.getSkinFilePath("icons/generic.png"); + updateSurfaces(); } void Link::setSize(int w, int h) { diff --git a/src/link.h b/src/link.h index 5c0494f..0f5695d 100644 --- a/src/link.h +++ b/src/link.h @@ -24,6 +24,7 @@ #include #include "button.h" +#include "surface.h" using std::string; @@ -42,7 +43,11 @@ protected: bool edited; string title, description, icon, iconPath; + Surface *iconSurface; + Surface *icon_hover; + void recalcCoordinates(); + void updateSurfaces(); public: Link(GMenu2X *gmenu2x);