mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
- Added Pink Silver's DrawString/Number alignment patch (with one minor change).
SVN r2460 (trunk)
This commit is contained in:
parent
a373c3858e
commit
006fb343b0
1 changed files with 63 additions and 5 deletions
|
@ -516,7 +516,7 @@ class CommandDrawString : public SBarInfoCommand
|
||||||
CommandDrawString(SBarInfo *script) : SBarInfoCommand(script),
|
CommandDrawString(SBarInfo *script) : SBarInfoCommand(script),
|
||||||
shadow(false), shadowX(2), shadowY(2), spacing(0), font(NULL),
|
shadow(false), shadowX(2), shadowY(2), spacing(0), font(NULL),
|
||||||
translation(CR_UNTRANSLATED), cache(-1), strValue(CONSTANT),
|
translation(CR_UNTRANSLATED), cache(-1), strValue(CONSTANT),
|
||||||
valueArgument(0)
|
valueArgument(0), alignment (ALIGN_RIGHT)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,6 +587,29 @@ class CommandDrawString : public SBarInfoCommand
|
||||||
{
|
{
|
||||||
sc.MustGetToken(TK_IntConst);
|
sc.MustGetToken(TK_IntConst);
|
||||||
spacing = sc.Number;
|
spacing = sc.Number;
|
||||||
|
if(sc.CheckToken(',')) //[KS] flags? flags! SIX FLAGS!
|
||||||
|
{
|
||||||
|
while(sc.CheckToken(TK_Identifier))
|
||||||
|
{
|
||||||
|
if(sc.Compare("alignment"))
|
||||||
|
{
|
||||||
|
sc.MustGetToken('(');
|
||||||
|
sc.MustGetToken(TK_Identifier);
|
||||||
|
if(sc.Compare("right"))
|
||||||
|
alignment = ALIGN_RIGHT;
|
||||||
|
else if(sc.Compare("left"))
|
||||||
|
alignment = ALIGN_LEFT;
|
||||||
|
else if(sc.Compare("center"))
|
||||||
|
alignment = ALIGN_CENTER;
|
||||||
|
else
|
||||||
|
sc.ScriptError("Unknown alignment '%s'.", sc.String);
|
||||||
|
sc.MustGetToken(')');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sc.ScriptError("Unknown flag '%s'.", sc.String);
|
||||||
|
if(!sc.CheckToken('|') && !sc.CheckToken(',')) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sc.MustGetToken(';');
|
sc.MustGetToken(';');
|
||||||
|
|
||||||
|
@ -682,13 +705,33 @@ class CommandDrawString : public SBarInfoCommand
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
|
enum StringAlignment
|
||||||
|
{
|
||||||
|
ALIGN_RIGHT,
|
||||||
|
ALIGN_LEFT,
|
||||||
|
ALIGN_CENTER,
|
||||||
|
};
|
||||||
|
|
||||||
void RealignString()
|
void RealignString()
|
||||||
{
|
{
|
||||||
x = startX;
|
x = startX;
|
||||||
if(script->spacingCharacter == '\0')
|
switch (alignment)
|
||||||
x -= static_cast<int> (font->StringWidth(str)+(spacing * str.Len()));
|
{
|
||||||
else //monospaced, so just multiplay the character size
|
case ALIGN_LEFT:
|
||||||
x -= static_cast<int> ((font->GetCharWidth((int) script->spacingCharacter) + spacing) * str.Len());
|
break;
|
||||||
|
case ALIGN_RIGHT:
|
||||||
|
if(script->spacingCharacter == '\0')
|
||||||
|
x -= static_cast<int> (font->StringWidth(str)+(spacing * str.Len()));
|
||||||
|
else //monospaced, so just multiplay the character size
|
||||||
|
x -= static_cast<int> ((font->GetCharWidth((int) script->spacingCharacter) + spacing) * str.Len());
|
||||||
|
break;
|
||||||
|
case ALIGN_CENTER:
|
||||||
|
if(script->spacingCharacter == '\0')
|
||||||
|
x -= static_cast<int> (font->StringWidth(str)+(spacing * str.Len()) / 2);
|
||||||
|
else
|
||||||
|
x -= static_cast<int> ((font->GetCharWidth((int) script->spacingCharacter) + spacing) * str.Len() / 2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum StringValueType
|
enum StringValueType
|
||||||
|
@ -721,6 +764,7 @@ class CommandDrawString : public SBarInfoCommand
|
||||||
StringValueType strValue;
|
StringValueType strValue;
|
||||||
int valueArgument;
|
int valueArgument;
|
||||||
FString str;
|
FString str;
|
||||||
|
StringAlignment alignment;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetStringToTag(AActor *actor)
|
void SetStringToTag(AActor *actor)
|
||||||
|
@ -887,6 +931,20 @@ class CommandDrawNumber : public CommandDrawString
|
||||||
interpolationSpeed = sc.Number;
|
interpolationSpeed = sc.Number;
|
||||||
sc.MustGetToken(')');
|
sc.MustGetToken(')');
|
||||||
}
|
}
|
||||||
|
else if(sc.Compare("alignment"))
|
||||||
|
{
|
||||||
|
sc.MustGetToken('(');
|
||||||
|
sc.MustGetToken(TK_Identifier);
|
||||||
|
if(sc.Compare("right"))
|
||||||
|
alignment = ALIGN_RIGHT;
|
||||||
|
else if(sc.Compare("left"))
|
||||||
|
alignment = ALIGN_LEFT;
|
||||||
|
else if(sc.Compare("center"))
|
||||||
|
alignment = ALIGN_CENTER;
|
||||||
|
else
|
||||||
|
sc.ScriptError("Unknown alignment '%s'.", sc.String);
|
||||||
|
sc.MustGetToken(')');
|
||||||
|
}
|
||||||
else
|
else
|
||||||
sc.ScriptError("Unknown flag '%s'.", sc.String);
|
sc.ScriptError("Unknown flag '%s'.", sc.String);
|
||||||
if(!sc.CheckToken('|'))
|
if(!sc.CheckToken('|'))
|
||||||
|
|
Loading…
Reference in a new issue