mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 07:57:52 +00:00
- initial work on DrawString method.
This commit is contained in:
parent
617934e1c2
commit
b5720ee1e7
3 changed files with 100 additions and 19 deletions
|
@ -337,6 +337,32 @@ public:
|
||||||
ST_DEADFACE = ST_GODFACE + 1
|
ST_DEADFACE = ST_GODFACE + 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum EAlign
|
||||||
|
{
|
||||||
|
TOP = 0,
|
||||||
|
VCENTER = 1,
|
||||||
|
BOTTOM = 2,
|
||||||
|
VOFFSET = 3,
|
||||||
|
VMASK = 3,
|
||||||
|
|
||||||
|
LEFT = 0,
|
||||||
|
HCENTER = 4,
|
||||||
|
RIGHT = 8,
|
||||||
|
HOFFSET = 12,
|
||||||
|
HMASK = 12,
|
||||||
|
|
||||||
|
CENTER = VCENTER | HCENTER,
|
||||||
|
CENTER_BOTTOM = BOTTOM | HCENTER
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ETextAlign
|
||||||
|
{
|
||||||
|
ALIGN_LEFT = 0,
|
||||||
|
ALIGN_CENTER = 1,
|
||||||
|
ALIGN_RIGHT = 2
|
||||||
|
};
|
||||||
|
|
||||||
DBaseStatusBar ();
|
DBaseStatusBar ();
|
||||||
void SetSize(int reltop = 32, int hres = 320, int vres = 200);
|
void SetSize(int reltop = 32, int hres = 320, int vres = 200);
|
||||||
void OnDestroy() override;
|
void OnDestroy() override;
|
||||||
|
@ -375,27 +401,11 @@ public:
|
||||||
void DrawLog();
|
void DrawLog();
|
||||||
uint32_t GetTranslation() const;
|
uint32_t GetTranslation() const;
|
||||||
|
|
||||||
enum EAlign
|
void DrawGraphic(FTextureID texture, bool animate, double x, double y, double Alpha = 1., bool translatable = false, bool dim = false,
|
||||||
{
|
|
||||||
TOP = 0,
|
|
||||||
VCENTER = 1,
|
|
||||||
BOTTOM = 2,
|
|
||||||
VOFFSET = 3,
|
|
||||||
VMASK = 3,
|
|
||||||
|
|
||||||
LEFT = 0,
|
|
||||||
HCENTER = 4,
|
|
||||||
RIGHT = 8,
|
|
||||||
HOFFSET = 12,
|
|
||||||
HMASK = 12,
|
|
||||||
|
|
||||||
CENTER = VCENTER | HCENTER,
|
|
||||||
CENTER_BOTTOM = BOTTOM | HCENTER
|
|
||||||
};
|
|
||||||
|
|
||||||
void DBaseStatusBar::DrawGraphic(FTextureID texture, bool animate, double x, double y, double Alpha = 1., bool translatable = false, bool dim = false,
|
|
||||||
int imgAlign = TOP | LEFT, int screenalign = TOP | LEFT, bool alphamap = false, double width = -1, double height = -1);
|
int imgAlign = TOP | LEFT, int screenalign = TOP | LEFT, bool alphamap = false, double width = -1, double height = -1);
|
||||||
|
|
||||||
|
void DrawString(FFont *font, const FString &cstring, double x, double y, double Alpha, int translation, int align, int screenalign, int spacing = 0, bool monospaced = false, int shadowX = 0, int shadowY = 0);
|
||||||
|
|
||||||
void GetCoords(int &x, int &y)
|
void GetCoords(int &x, int &y)
|
||||||
{
|
{
|
||||||
x = ST_X;
|
x = ST_X;
|
||||||
|
|
|
@ -1492,6 +1492,69 @@ DEFINE_ACTION_FUNCTION(DBaseStatusBar, DrawGraphic)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
//
|
||||||
|
// draw stuff
|
||||||
|
//
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, double y, double Alpha, int translation, int align, int screenalign, int spacing, bool monospaced, int shadowX, int shadowY)
|
||||||
|
{
|
||||||
|
switch (align)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
case ALIGN_RIGHT:
|
||||||
|
if (!monospaced)
|
||||||
|
x -= static_cast<int> (font->StringWidth(cstring) + (spacing * cstring.Len()));
|
||||||
|
else //monospaced, so just multiply the character size
|
||||||
|
x -= static_cast<int> ((spacing) * cstring.Len());
|
||||||
|
break;
|
||||||
|
case ALIGN_CENTER:
|
||||||
|
if (!monospaced)
|
||||||
|
x -= static_cast<int> (font->StringWidth(cstring) + (spacing * cstring.Len())) / 2;
|
||||||
|
else //monospaced, so just multiply the character size
|
||||||
|
x -= static_cast<int> ((spacing)* cstring.Len()) / 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(DBaseStatusBar, DrawString)
|
||||||
|
{
|
||||||
|
PARAM_SELF_PROLOGUE(DBaseStatusBar);
|
||||||
|
PARAM_POINTER(font, FFont);
|
||||||
|
PARAM_STRING(string);
|
||||||
|
PARAM_FLOAT(x);
|
||||||
|
PARAM_FLOAT(y);
|
||||||
|
PARAM_FLOAT(alpha);
|
||||||
|
PARAM_BOOL(trans);
|
||||||
|
PARAM_INT(ialign);
|
||||||
|
PARAM_INT(salign);
|
||||||
|
PARAM_INT_DEF(spacing);
|
||||||
|
PARAM_BOOL_DEF(monospaced);
|
||||||
|
PARAM_INT_DEF(shadowX);
|
||||||
|
PARAM_INT_DEF(shadowY);
|
||||||
|
PARAM_INT_DEF(wrapwidth);
|
||||||
|
PARAM_INT_DEF(linespacing);
|
||||||
|
|
||||||
|
if (wrapwidth > 0)
|
||||||
|
{
|
||||||
|
FBrokenLines *brk = V_BreakLines(font, wrapwidth, string, true);
|
||||||
|
for (int i = 0; brk[i].Width >= 0; i++)
|
||||||
|
{
|
||||||
|
self->DrawString(font, brk[i].Text, x, y, alpha, trans, ialign, salign, spacing, monospaced, shadowX, shadowY);
|
||||||
|
y += font->GetHeight() + linespacing;
|
||||||
|
}
|
||||||
|
V_FreeBrokenLines(brk);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self->DrawString(font, string, x, y, alpha, trans, ialign, salign, spacing, monospaced, shadowX, shadowY);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
//
|
//
|
||||||
// CCMD showpop
|
// CCMD showpop
|
||||||
|
|
|
@ -83,6 +83,13 @@ class BaseStatusBar native ui
|
||||||
CENTER_BOTTOM = BOTTOM|HCENTER
|
CENTER_BOTTOM = BOTTOM|HCENTER
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ETextAlign
|
||||||
|
{
|
||||||
|
ALIGN_LEFT = 0,
|
||||||
|
ALIGN_CENTER = 1,
|
||||||
|
ALIGN_RIGHT = 2
|
||||||
|
};
|
||||||
|
|
||||||
enum SBGameModes
|
enum SBGameModes
|
||||||
{
|
{
|
||||||
SINGLEPLAYER = 0x1,
|
SINGLEPLAYER = 0x1,
|
||||||
|
@ -151,6 +158,7 @@ class BaseStatusBar native ui
|
||||||
native static TextureID, bool GetInventoryIcon(Inventory item, int flags);
|
native static TextureID, bool GetInventoryIcon(Inventory item, int flags);
|
||||||
|
|
||||||
native void DrawGraphic(TextureID texture, bool animate, Vector2 pos, double Alpha, bool translatable, bool dim, int imgAlign, int screenalign, bool alphamap, Vector2 box);
|
native void DrawGraphic(TextureID texture, bool animate, Vector2 pos, double Alpha, bool translatable, bool dim, int imgAlign, int screenalign, bool alphamap, Vector2 box);
|
||||||
|
native void DrawString(Font font, String string, Vector2 pos , double Alpha, int translation, int align, int screenalign, int spacing=0, bool monospaced = false, int shadowX=0, int shadowY=0, int wrapwidth = -1, int linespacing = 4);
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
Loading…
Reference in a new issue