Re: ZScript: Status Bar Questions
Posted: Sun Apr 23, 2017 7:58 am
AFADoomer, I might suggest doing it a bit differently. At any point, Graf could alter the function if he needs to fix a bug or something. If said changes doesn't affect parameter count, you won't have to change anything. (Yes I know you used DrawBar, and I used DrawString. Concept is the same because it affects both equally.)
This works for status bar sections, but I have yet to fully try it out on full screen huds which has a different coordinate system.
Code: Select all
// Uniform scaling.
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)
{
Vector2 OldScale = BaseSize, TempScale = BaseSize;
Vector2 ScaledPos = pos;
if (scaling == 0.0) //Why draw anything? Also to prevent division by 0.
return;
scaling = abs(scaling);
// Thankfully, scaling up is directly that -- smaller screen coordinates and
// larger texture size which is automatically handled by the engine.
bool sized = (scaling != 1.0);
if (sized)
{
TempScale /= scaling;
ScaledPos /= scaling;
}
// Change to the new scale, draw it, and then set it back.
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);
}