METHOD(Image, draw, void(entity))
METHOD(Image, toString, string(entity))
METHOD(Image, resizeNotify, void(entity, vector, vector, vector, vector))
+ METHOD(Image, updateAspect, void(entity))
ATTRIB(Image, src, string, string_null)
ATTRIB(Image, color, vector, '1 1 1')
ATTRIB(Image, forcedAspect, float, 0)
{
draw_Picture(me.imgOrigin, me.src, me.imgSize, me.color, 1);
}
-void resizeNotifyImage(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
+void updateAspectImage(entity me)
{
- resizeNotifyItem(me, relOrigin, relSize, absOrigin, absSize);
+ float asp;
+ if(me.size_x <= 0 || me.size_y <= 0)
+ return;
if(me.forcedAspect == 0)
{
me.imgOrigin = '0 0 0';
}
else
{
- if(absSize_x > me.forcedAspect * absSize_y)
+ if(me.forcedAspect < 0)
+ {
+ vector sz;
+ sz = draw_PictureSize(me.src);
+ asp = sz_x / sz_y;
+ }
+ else
+ asp = me.forcedAspect;
+ if(me.size_x > asp * me.size_y)
{
// x too large, so center x-wise
- me.imgSize = eY + eX * (absSize_y * me.forcedAspect / absSize_x);
+ me.imgSize = eY + eX * (me.size_y * asp / me.size_x);
}
else
{
// y too large, so center y-wise
- me.imgSize = eX + eY * (absSize_x / (me.forcedAspect * absSize_y));
+ me.imgSize = eX + eY * (me.size_x / (asp * me.size_y));
}
me.imgOrigin = '0.5 0.5 0' - 0.5 * me.imgSize;
}
}
+void resizeNotifyImage(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
+{
+ resizeNotifyItem(me, relOrigin, relSize, absOrigin, absSize);
+ me.updateAspect(me);
+}
#endif
void configureXonoticImageXonoticImage(entity me, string theImage, float theAspect)
{
me.configureImage(me, theImage);
- if(theAspect < 0) // use image aspect
- {
- vector sz;
- sz = draw_PictureSize(theImage);
- me.forcedAspect = sz_x / sz_y;
- }
- else
- me.forcedAspect = theAspect;
+ me.forcedAspect = theAspect;
}
#endif
float sortbuf, glob, i;
string fn;
- me.configureXonoticImage(me, string_null, 263.0/360.0);
+ me.configureXonoticImage(me, string_null, -1);
sortbuf = buf_create();
glob = search_begin(get_model_datafilename(string_null, -1, "txt"), TRUE, TRUE);
me.currentSkin = stof(bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_SKIN));
me.currentModel = strzone(bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_MODEL));
me.currentModelDescription = strzone(bufstr_get(me.bufModels, BUFMODELS_COUNT*me.idxModels+BUFMODELS_DESC));
+
+ // fix the image
+ me.src = me.currentModelImage;
+ me.updateAspect(me);
}
void PlayerModelSelector_Next_Click(entity btn, entity me)
float i, n;
vector o;
- me.src = me.currentModelImage;
drawImage(me);
- me.src = string_null;
// draw text on the image, handle \n in the description
draw_CenterText('0.5 0 0', me.currentModelTitle, me.realFontSize * (me.titleFontSize / me.fontSize), SKINCOLOR_MODELTITLE, SKINALPHA_MODELTITLE, FALSE);