- added adaptive layout for RR's summary screen as well.

To better handle the spacing for accented characters the text scale was slightly reduced.
This commit is contained in:
Christoph Oelckers 2023-01-14 10:37:07 +01:00
parent d067b23917
commit 5e7f90562c
2 changed files with 88 additions and 19 deletions

View file

@ -198,8 +198,8 @@ struct Duke native
}
else
{
if (align != -1) x -= myfont.StringWidth(text) * (align == 0 ? 0.2 : 0.4);
Screen.DrawText(myfont, Font.CR_UNTRANSLATED, x, y - 12, text, DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, 0.4, DTA_ScaleY, 0.4, DTA_Alpha, alpha);
if (align != -1) x -= myfont.StringWidth(text) * (align == 0 ? 0.175 : 0.35);
Screen.DrawText(myfont, Font.CR_UNTRANSLATED, x, y - 12, text, DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, 0.35, DTA_ScaleY, 0.35, DTA_Alpha, alpha);
}
}

View file

@ -577,7 +577,7 @@ class DukeLevelSummaryScreen : SummaryScreenBase
{
val_x += twidth - 140;
}
else
else if (twidth >= 156)
{
val_x = 166;
text_x -= twidth - 156;
@ -774,6 +774,13 @@ class RRLevelSummaryScreen : SummaryScreenBase
int exitSoundStart;
TextureID texBg;
double text_x;
double val_x;
double val_x2;
double press_x;
double map_x;
enum EFlags
{
printTimeText = 1,
@ -828,6 +835,67 @@ class RRLevelSummaryScreen : SummaryScreenBase
return false;
}
private void CalcLayout()
{
static const String texts[] = { "$TXT_YerTime", "$TXT_ParTime", "$TXT_XTRTIME"};
static const String texts2[] = { "$TXT_VarmintsKilled", "$TXT_VarmintsLeft", "$TXT_SECFND", "$TXT_SECMISS" };
let myfont = Raze.PickBigFont();
let fact = screen.GetAspectRatio();
let vwidth = 320 * 0.75 * fact;
let left = 5 + (320 - vwidth) / 2;
let twidth = 0.0;
let twidth1 = 0.0;
text_x = 30;
val_x = 191;
val_x2 = 231;
for(int i = 0; i < texts.size(); i++)
{
twidth1 = max(twidth1, 0.35 * myfont.StringWidth(texts[i]));
}
for(int i = 0; i < texts2.size(); i++)
{
twidth = max(twidth, 0.35 * myfont.StringWidth(texts2[i]));
}
if (twidth1 > 155 && twidth1 < 190 && twidth < 230)
{
Console.printf("small case: %f, %f", twidth, val_x);
val_x = val_x2;
return;
}
twidth = max(twidth, twidth1 + 40);
if (twidth >= 195 && twidth < 230)
{
val_x2 += twidth - 195;
val_x = val_x2;
}
else if (twidth >= 230)
{
val_x2 = 266;
text_x -= twidth - 230;
if (text_x < left)
{
val_x2 += left - text_x;
text_x = left;
}
val_x = val_x2;
}
map_x = 80;
let w = myfont.StringWidth(lastmapname) * 0.35;
if (w > 320) map_x = -(w - 320) / 2;
else if (w > 240) map_x = (320 - w) / 2;
press_x = 15;
w = myfont.StringWidth("$PRESSKEY") * 0.35;
if (w > 320) press_x = -(w - 320) / 2;
else if (w > 300) press_x = (320 - w) / 2;
}
override void OnTick()
{
if ((displaystate & printStatsAll) != printStatsAll)
@ -877,33 +945,33 @@ class RRLevelSummaryScreen : SummaryScreenBase
void PrintTime()
{
String tempbuf;
Duke.BigText(30, 48, "$TXT_YerTime", -1);
Duke.BigText(30, 64, "$TXT_ParTime", -1);
Duke.BigText(30, 80, "$TXT_XTRTIME", -1);
Duke.BigText(text_x, 48, "$TXT_YerTime", -1);
Duke.BigText(text_x, 64, "$TXT_ParTime", -1);
Duke.BigText(text_x, 80, "$TXT_XTRTIME", -1);
if (displaystate & printTimeVal)
{
tempbuf = FormatTime(stats.time);
Duke.BigText(191, 48, tempbuf, -1);
Duke.BigText(val_x, 48, tempbuf, -1);
tempbuf = FormatTime(level.parTime);
Duke.BigText(191, 64, tempbuf, -1);
Duke.BigText(val_x, 64, tempbuf, -1);
tempbuf = FormatTime(level.designerTime);
Duke.BigText(191, 80, tempbuf, -1);
Duke.BigText(val_x, 80, tempbuf, -1);
}
}
void PrintKills()
{
String tempbuf;
Duke.BigText(30, 112, "$TXT_VarmintsKilled", -1);
Duke.BigText(30, 128, "$TXT_VarmintsLeft", -1);
Duke.BigText(text_x, 112, "$TXT_VarmintsKilled", -1);
Duke.BigText(text_x, 128, "$TXT_VarmintsLeft", -1);
if (displaystate & printKillsVal)
{
tempbuf = String.Format("%-3d", stats.kills);
Duke.BigText(231, 112, tempbuf, -1);
Duke.BigText(val_x2, 112, tempbuf, -1);
if (stats.maxkills < 0)
{
tempbuf = "$TXT_N_A";
@ -912,31 +980,32 @@ class RRLevelSummaryScreen : SummaryScreenBase
{
tempbuf = String.Format("%-3d", max(0, stats.maxkills - stats.kills));
}
Duke.BigText(231, 128, tempbuf, -1);
Duke.BigText(val_x2, 128, tempbuf, -1);
}
}
void PrintSecrets()
{
String tempbuf;
Duke.BigText(30, 144, "$TXT_SECFND", -1);
Duke.BigText(30, 160, "$TXT_SECMISS", -1);
Duke.BigText(text_x, 144, "$TXT_SECFND", -1);
Duke.BigText(text_x, 160, "$TXT_SECMISS", -1);
if (displaystate & printSecretsVal)
{
tempbuf = String.Format("%-3d", stats.secrets);
Duke.BigText(231, 144, tempbuf, -1);
Duke.BigText(val_x2, 144, tempbuf, -1);
tempbuf = String.Format("%-3d", max(0, stats.maxsecrets - stats.secrets));
Duke.BigText(231, 160, tempbuf, -1);
Duke.BigText(val_x2, 160, tempbuf, -1);
}
}
override void Draw(double sr)
{
CalcLayout();
Screen.DrawTexture(texBg, true, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal);
Duke.BigText(80, 16, lastmapname, -1);
Duke.BigText(15, 192, "$PRESSKEY", -1);
Duke.BigText(map_x, 16, lastmapname, -1);
Duke.BigText(press_x, 192, "$PRESSKEY", -1);
if (displaystate & printTimeText)
{