Fix cheat input using the wrong font.

This commit is contained in:
Mari the Deer 2022-04-20 17:22:35 +02:00
commit 90d7737734
2 changed files with 12 additions and 11 deletions

View file

@ -1,3 +1,3 @@
[default]
SWWM_MODVER="\cyDEMOLITIONIST \cw1.2.11 r5 \cu(Wed 20 Apr 17:26:26 CEST 2022)\c-";
SWWM_SHORTVER="\cw1.2.11 r5 \cu(2022-04-20 17:26:26)\c-";
SWWM_MODVER="\cyDEMOLITIONIST \cw1.2.11 r6 \cu(Wed 20 Apr 17:26:39 CEST 2022)\c-";
SWWM_SHORTVER="\cw1.2.11 r6 \cu(2022-04-20 17:26:39)\c-";

View file

@ -7,6 +7,7 @@ extend Class SWWMHandler
transient ui bool kfail;
transient ui int rss;
ui bool nostalgic;
ui Font CheatFont;
transient int sewercnt;
private ui void CheatUITick()
@ -511,25 +512,25 @@ extend Class SWWMHandler
// cheat input
if ( (kcode <= 4) && ((klinger < gametic) || (klingerstr == "")) )
return;
double hs = max(floor(Screen.GetWidth()/480.),1.);
Vector2 ss = (Screen.GetWidth(),Screen.GetHeight())/hs;
double scl = CleanXFac_1*3.;
String chstr = (kcode>4)?kstr.Mid(4):klingerstr.Mid(4);
double alph = clamp((klinger-(gametic+e.fractic))/20.,0.,1.);
double shine = clamp((klinger-(gametic+e.fractic+40))/20.,0.,1.);
int col = (kcode>4)?0:(kfail)?2:1;
int tlen = chstr.CodePointCount();
int width = (bigfont.StringWidth(chstr)+6*(tlen-1));
int xx = int((ss.x-width)/2.);
int yy = int((ss.y-bigfont.GetHeight())/2.);
if ( !CheatFont ) CheatFont = Font.GetFont("TewiFontOutline");
int width = (CheatFont.StringWidth(chstr)+3*(tlen-1));
double xx = int(Screen.GetWidth()-width*scl)/2;
double yy = int(Screen.GetHeight()-CheatFont.GetHeight()*scl)/2;
rss = (kcode>4)?gametic:klinger;
for ( int i=0, pos=0; i<tlen; i++ )
{
int ch;
[ch, pos] = chstr.GetNextCodePoint(pos);
if ( col == 0 ) Screen.DrawChar(bigfont,Font.CR_DARKGRAY,xx+RandomShiver(),yy+RandomShiver(),ch,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
else if ( col == 1 ) Screen.DrawChar(bigfont,Font.CR_SAPPHIRE,xx,yy,ch,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph,DTA_ColorOverlay,Color(int(shine*255),255,255,255));
else if ( col == 2 ) Screen.DrawChar(bigfont,Font.CR_RED,xx,yy+RandomFall()*(1.-alph),ch,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph);
xx += bigfont.GetCharWidth(ch)+bigfont.GetDefaultKerning()+6;
if ( col == 0 ) Screen.DrawChar(CheatFont,Font.CR_DARKGRAY,xx+RandomShiver()*CleanXFac_1,yy+RandomShiver()*CleanXFac_1,ch,DTA_ScaleX,scl,DTA_ScaleY,scl);
else if ( col == 1 ) Screen.DrawChar(CheatFont,Font.CR_SAPPHIRE,xx,yy,ch,DTA_ScaleX,scl,DTA_ScaleY,scl,DTA_Alpha,alph,DTA_ColorOverlay,Color(int(shine*255),255,255,255));
else if ( col == 2 ) Screen.DrawChar(CheatFont,Font.CR_RED,xx,yy+RandomFall()*(1.-alph)*CleanXFac_1,ch,DTA_ScaleX,scl,DTA_ScaleY,scl,DTA_Alpha,alph);
xx += (CheatFont.GetCharWidth(ch)+CheatFont.GetDefaultKerning()+3)*scl;
}
}
}