by Major Cooke » Sun Oct 21, 2018 10:17 am
Spoiler: If we're talking status bars...
Personally I just do something like this.
Code: Select all
void DrawStringScaled(HUDFont font, String string, Vector2 pos, int flags = 0, int translation = Font.CR_UNTRANSLATED, double Alpha = 1., int wrapwidth = -1, int linespacing = 4, double scaling = 1.0)
{
if (scaling == 0.0)
return;
scaling = abs(scaling);
Vector2 OldScale = BaseSize, TempScale = BaseSize;
Vector2 ScaledPos = pos;
bool sized = (scaling != 1.0);
if (sized)
{
TempScale /= scaling;
ScaledPos /= scaling;
}
if (sized) SetSize(0, TempScale.X, TempScale.Y);
DrawString(font, string, ScaledPos, flags, translation, Alpha, wrapwidth, linespacing);
if (sized) SetSize(0, OldScale.X, OldScale.Y);
}
BaseSize is a constant (in D4D's case, (1024, 768)) you'll have to set up but other than that, it works out of the box. It's set up where scaling works as a multiplier so 2 is twice as big and so on.
[spoiler=If we're talking status bars...]Personally I just do something like this.
[code]void DrawStringScaled(HUDFont font, String string, Vector2 pos, int flags = 0, int translation = Font.CR_UNTRANSLATED, double Alpha = 1., int wrapwidth = -1, int linespacing = 4, double scaling = 1.0)
{
if (scaling == 0.0)
return;
scaling = abs(scaling);
Vector2 OldScale = BaseSize, TempScale = BaseSize;
Vector2 ScaledPos = pos;
bool sized = (scaling != 1.0);
if (sized)
{
TempScale /= scaling;
ScaledPos /= scaling;
}
if (sized) SetSize(0, TempScale.X, TempScale.Y);
DrawString(font, string, ScaledPos, flags, translation, Alpha, wrapwidth, linespacing);
if (sized) SetSize(0, OldScale.X, OldScale.Y);
}
[/code]
BaseSize is a constant (in D4D's case, (1024, 768)) you'll have to set up but other than that, it works out of the box. It's set up where scaling works as a multiplier so 2 is twice as big and so on.[/spoiler]