forked from speed-dreams/speed-dreams-code
Re #333 Fixed GfuiStaticImageSet overwriting the 'can deform' XML property + added GfuiStaticImageSetDeformable
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@4621 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: bbaee260fe6d63af3a09446d2f1736d8cd268267 Former-commit-id: c112765303a7b9090162d2a2e3bc80133927e8fd
This commit is contained in:
parent
7c020518e8
commit
d0df79cb30
5 changed files with 44 additions and 13 deletions
|
@ -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).
|
/** Replace an image by another one (source image doesn't need to be a square or of POT sizes).
|
||||||
@ingroup gui
|
@ingroup gui
|
||||||
@param scr Screen where tthe image is displayed
|
@param scr Screen where the image is displayed
|
||||||
@param id Image Id
|
@param id Image Id
|
||||||
@param name Filename of the source image (PNG or JPEG)
|
@param name Filename of the source image (PNG or JPEG)
|
||||||
@param index Target index for the texture (defaults to 0)
|
@param index Target index for the texture (defaults to 0)
|
||||||
@return none
|
@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;
|
int pow2Width, pow2Height;
|
||||||
tGfuiObject *curObject;
|
tGfuiObject *curObject;
|
||||||
|
@ -101,14 +101,13 @@ void GfuiStaticImageSet(void *scr, int id, const char *name, unsigned index, boo
|
||||||
tGfuiImage *image;
|
tGfuiImage *image;
|
||||||
|
|
||||||
curObject = screen->objects;
|
curObject = screen->objects;
|
||||||
if (curObject != NULL) {
|
if (curObject) {
|
||||||
do {
|
do {
|
||||||
curObject = curObject->next;
|
curObject = curObject->next;
|
||||||
if (curObject->id == id) {
|
if (curObject->id == id) {
|
||||||
if (curObject->widget == GFUI_IMAGE) {
|
if (curObject->widget == GFUI_IMAGE) {
|
||||||
image = &(curObject->u.image);
|
image = &(curObject->u.image);
|
||||||
GfTexFreeTexture(image->texture[index]);
|
GfTexFreeTexture(image->texture[index]);
|
||||||
image->canDeform = canDeform;
|
|
||||||
// We don't use returned POT width and height, but passing non NULL pointers
|
// We don't use returned POT width and height, but passing non NULL pointers
|
||||||
// for them enforces POT sizes for the loaded texture.
|
// for them enforces POT sizes for the loaded texture.
|
||||||
image->texture[index] =
|
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)
|
void GfuiStaticImageSetActive(void *scr, int id, int index)
|
||||||
{
|
{
|
||||||
tGfuiObject *curObject;
|
tGfuiObject *curObject;
|
||||||
|
@ -128,7 +134,7 @@ void GfuiStaticImageSetActive(void *scr, int id, int index)
|
||||||
tGfuiImage *image;
|
tGfuiImage *image;
|
||||||
|
|
||||||
curObject = screen->objects;
|
curObject = screen->objects;
|
||||||
if (curObject != NULL) {
|
if (curObject) {
|
||||||
do {
|
do {
|
||||||
curObject = curObject->next;
|
curObject = curObject->next;
|
||||||
if (curObject->id == id) {
|
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
|
void
|
||||||
gfuiReleaseImage(tGfuiObject *obj)
|
gfuiReleaseImage(tGfuiObject *obj)
|
||||||
{
|
{
|
||||||
|
|
|
@ -249,7 +249,7 @@ createStaticImage(void* hscr, void* hparm, const char* pszName)
|
||||||
sprintf(pszImageFieldName, GFMNU_ATTR_IMAGE" %d", i);
|
sprintf(pszImageFieldName, GFMNU_ATTR_IMAGE" %d", i);
|
||||||
const char* pszFileName = GfParmGetStr(hparm, pszName, pszImageFieldName, 0);
|
const char* pszFileName = GfParmGetStr(hparm, pszName, pszImageFieldName, 0);
|
||||||
if (pszFileName)
|
if (pszFileName)
|
||||||
GfuiStaticImageSet(hscr, id, pszFileName, i, canDeform);
|
GfuiStaticImageSet(hscr, id, pszFileName, i);
|
||||||
else
|
else
|
||||||
break; // Assumes an indexed image list, with no hole inside.
|
break; // Assumes an indexed image list, with no hole inside.
|
||||||
}
|
}
|
||||||
|
|
|
@ -539,9 +539,9 @@ TGFCLIENT_API int GfuiScrollBarPosGet(void* scr, int id);
|
||||||
/* Images */
|
/* Images */
|
||||||
TGFCLIENT_API int GfuiStaticImageCreate(void* scr, int x, int y, int w, int h, const char* name,
|
TGFCLIENT_API int GfuiStaticImageCreate(void* scr, int x, int y, int w, int h, const char* name,
|
||||||
bool canDeform = true);
|
bool canDeform = true);
|
||||||
TGFCLIENT_API void GfuiStaticImageSet(void* scr, int id, const char* name,
|
TGFCLIENT_API void GfuiStaticImageSet(void* scr, int id, const char* name, unsigned index = 0);
|
||||||
unsigned index = 0, bool canDeform = true);
|
|
||||||
TGFCLIENT_API void GfuiStaticImageSetActive(void* scr, int id, int index);
|
TGFCLIENT_API void GfuiStaticImageSetActive(void* scr, int id, int index);
|
||||||
|
TGFCLIENT_API void GfuiStaticImageSetDeformable(void *scr, int id, bool canDeform = true);
|
||||||
|
|
||||||
/*****************************
|
/*****************************
|
||||||
* Menu Management Interface *
|
* Menu Management Interface *
|
||||||
|
|
|
@ -271,9 +271,7 @@ rmdsChangeSkin(void *vp)
|
||||||
|
|
||||||
// Load associated preview image (or "no preview" panel if none available).
|
// Load associated preview image (or "no preview" panel if none available).
|
||||||
if (GfFileExists(curSkin.getCarPreviewFileName().c_str()))
|
if (GfFileExists(curSkin.getCarPreviewFileName().c_str()))
|
||||||
GfuiStaticImageSet(ScrHandle, CarImageId,
|
GfuiStaticImageSet(ScrHandle, CarImageId, curSkin.getCarPreviewFileName().c_str());
|
||||||
curSkin.getCarPreviewFileName().c_str(),
|
|
||||||
/* index= */ 0, /* canDeform= */false);
|
|
||||||
else
|
else
|
||||||
GfuiStaticImageSet(ScrHandle, CarImageId, "data/img/nocarpreview.png");
|
GfuiStaticImageSet(ScrHandle, CarImageId, "data/img/nocarpreview.png");
|
||||||
|
|
||||||
|
|
|
@ -349,8 +349,7 @@ void RmGarageMenu::resetCarPreviewImage(const GfDriverSkin& selSkin)
|
||||||
|
|
||||||
// Load the preview image.
|
// Load the preview image.
|
||||||
if (GfFileExists(selSkin.getCarPreviewFileName().c_str()))
|
if (GfFileExists(selSkin.getCarPreviewFileName().c_str()))
|
||||||
GfuiStaticImageSet(getMenuHandle(), nCarImageId, selSkin.getCarPreviewFileName().c_str(),
|
GfuiStaticImageSet(getMenuHandle(), nCarImageId, selSkin.getCarPreviewFileName().c_str());
|
||||||
/* index= */ 0, /* canDeform= */false);
|
|
||||||
else
|
else
|
||||||
GfuiStaticImageSet(getMenuHandle(), nCarImageId, "data/img/nocarpreview.png");
|
GfuiStaticImageSet(getMenuHandle(), nCarImageId, "data/img/nocarpreview.png");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue