diff --git a/src/libs/tgfclient/guiimage.cpp b/src/libs/tgfclient/guiimage.cpp index 285d72713..af2fc8421 100644 --- a/src/libs/tgfclient/guiimage.cpp +++ b/src/libs/tgfclient/guiimage.cpp @@ -87,13 +87,13 @@ int GfuiStaticImageCreate(void *scr, int x, int y, int w, int h, const char *nam /** Replace an image by another one (source image doesn't need to be a square or of POT sizes). @ingroup gui - @param scr Screen where tthe image is displayed + @param scr Screen where the image is displayed @param id Image Id @param name Filename of the source image (PNG or JPEG) @param index Target index for the texture (defaults to 0) @return none */ -void GfuiStaticImageSet(void *scr, int id, const char *name, unsigned index, bool canDeform) +void GfuiStaticImageSet(void *scr, int id, const char *name, unsigned index) { int pow2Width, pow2Height; tGfuiObject *curObject; @@ -101,14 +101,13 @@ void GfuiStaticImageSet(void *scr, int id, const char *name, unsigned index, boo tGfuiImage *image; curObject = screen->objects; - if (curObject != NULL) { + if (curObject) { do { curObject = curObject->next; if (curObject->id == id) { if (curObject->widget == GFUI_IMAGE) { image = &(curObject->u.image); GfTexFreeTexture(image->texture[index]); - image->canDeform = canDeform; // We don't use returned POT width and height, but passing non NULL pointers // for them enforces POT sizes for the loaded texture. image->texture[index] = @@ -121,6 +120,13 @@ void GfuiStaticImageSet(void *scr, int id, const char *name, unsigned index, boo } } +/** Set active image by its index. + @ingroup gui + @param scr Screen where the image is displayed + @param id Image Id + @param index Target image index + @return none +*/ void GfuiStaticImageSetActive(void *scr, int id, int index) { tGfuiObject *curObject; @@ -128,7 +134,7 @@ void GfuiStaticImageSetActive(void *scr, int id, int index) tGfuiImage *image; curObject = screen->objects; - if (curObject != NULL) { + if (curObject) { do { curObject = curObject->next; if (curObject->id == id) { @@ -142,6 +148,34 @@ void GfuiStaticImageSetActive(void *scr, int id, int index) } } +/** Set "can deform" property. + @ingroup gui + @param scr Screen where the image is displayed + @param id Image Id + @param canDeform Target value + @return none +*/ +void GfuiStaticImageSetDeformable(void *scr, int id, bool canDeform) +{ + tGfuiObject *curObject; + tGfuiScreen *screen = (tGfuiScreen*)scr; + tGfuiImage *image; + + curObject = screen->objects; + if (curObject) { + do { + curObject = curObject->next; + if (curObject->id == id) { + if (curObject->widget == GFUI_IMAGE) { + image = &(curObject->u.image); + image->canDeform = canDeform; + } + return; + } + } while (curObject != screen->objects); + } +} + void gfuiReleaseImage(tGfuiObject *obj) { diff --git a/src/libs/tgfclient/guimenu.cpp b/src/libs/tgfclient/guimenu.cpp index e61ed87c8..2b3855279 100644 --- a/src/libs/tgfclient/guimenu.cpp +++ b/src/libs/tgfclient/guimenu.cpp @@ -249,7 +249,7 @@ createStaticImage(void* hscr, void* hparm, const char* pszName) sprintf(pszImageFieldName, GFMNU_ATTR_IMAGE" %d", i); const char* pszFileName = GfParmGetStr(hparm, pszName, pszImageFieldName, 0); if (pszFileName) - GfuiStaticImageSet(hscr, id, pszFileName, i, canDeform); + GfuiStaticImageSet(hscr, id, pszFileName, i); else break; // Assumes an indexed image list, with no hole inside. } diff --git a/src/libs/tgfclient/tgfclient.h b/src/libs/tgfclient/tgfclient.h index e86d0da3e..75a6027df 100644 --- a/src/libs/tgfclient/tgfclient.h +++ b/src/libs/tgfclient/tgfclient.h @@ -539,9 +539,9 @@ TGFCLIENT_API int GfuiScrollBarPosGet(void* scr, int id); /* Images */ TGFCLIENT_API int GfuiStaticImageCreate(void* scr, int x, int y, int w, int h, const char* name, bool canDeform = true); -TGFCLIENT_API void GfuiStaticImageSet(void* scr, int id, const char* name, - unsigned index = 0, bool canDeform = true); +TGFCLIENT_API void GfuiStaticImageSet(void* scr, int id, const char* name, unsigned index = 0); TGFCLIENT_API void GfuiStaticImageSetActive(void* scr, int id, int index); +TGFCLIENT_API void GfuiStaticImageSetDeformable(void *scr, int id, bool canDeform = true); /***************************** * Menu Management Interface * diff --git a/src/modules/userinterface/legacymenu/racescreens/driverselect.cpp b/src/modules/userinterface/legacymenu/racescreens/driverselect.cpp index 16703866c..c6e79988c 100644 --- a/src/modules/userinterface/legacymenu/racescreens/driverselect.cpp +++ b/src/modules/userinterface/legacymenu/racescreens/driverselect.cpp @@ -271,9 +271,7 @@ rmdsChangeSkin(void *vp) // Load associated preview image (or "no preview" panel if none available). if (GfFileExists(curSkin.getCarPreviewFileName().c_str())) - GfuiStaticImageSet(ScrHandle, CarImageId, - curSkin.getCarPreviewFileName().c_str(), - /* index= */ 0, /* canDeform= */false); + GfuiStaticImageSet(ScrHandle, CarImageId, curSkin.getCarPreviewFileName().c_str()); else GfuiStaticImageSet(ScrHandle, CarImageId, "data/img/nocarpreview.png"); diff --git a/src/modules/userinterface/legacymenu/racescreens/garagemenu.cpp b/src/modules/userinterface/legacymenu/racescreens/garagemenu.cpp index 38471e593..440ac0589 100644 --- a/src/modules/userinterface/legacymenu/racescreens/garagemenu.cpp +++ b/src/modules/userinterface/legacymenu/racescreens/garagemenu.cpp @@ -349,8 +349,7 @@ void RmGarageMenu::resetCarPreviewImage(const GfDriverSkin& selSkin) // Load the preview image. if (GfFileExists(selSkin.getCarPreviewFileName().c_str())) - GfuiStaticImageSet(getMenuHandle(), nCarImageId, selSkin.getCarPreviewFileName().c_str(), - /* index= */ 0, /* canDeform= */false); + GfuiStaticImageSet(getMenuHandle(), nCarImageId, selSkin.getCarPreviewFileName().c_str()); else GfuiStaticImageSet(getMenuHandle(), nCarImageId, "data/img/nocarpreview.png"); }