Use own fonts for achievements menu (still needs more work to fit in low resolutions).

This commit is contained in:
Mari the Deer 2022-08-30 12:49:40 +02:00
commit 4b20fc0b12
2 changed files with 35 additions and 32 deletions

View file

@ -13,6 +13,7 @@ Class SWWMAchievementMenu : GenericMenu
int mBaseY; // Y position achievement boxes are being drawn at
// needed to tune mouse selection
int completed, incomplete, total;
Font mSmallFont, mTinyFont;
override void Init( Menu parent )
{
@ -46,6 +47,8 @@ Class SWWMAchievementMenu : GenericMenu
AchievementUnknown = TexMan.CheckForTexture("graphics/Achievements/HiddenAchievement.png",TexMan.Type_Any);
SelectBox = TexMan.CheckForTexture("graphics/Achievements/SelectAchievement.png",TexMan.Type_Any);
BaseBox = TexMan.CheckForTexture("graphics/Achievements/NoAchievement.png",TexMan.Type_Any);
mSmallFont = Font.GetFont('TewiFontOutline');
mTinyFont = Font.GetFont('MiniwiFontOutline');
}
override void Ticker()
@ -77,18 +80,18 @@ Class SWWMAchievementMenu : GenericMenu
bool hasprogress = (a.maxval && a.val);
String str = StringTable.Localize("$SWWM_ACHIEVEMENT_"..a.basename.."_TAG");
if ( !completed && !hasprogress && ShouldObscure ) SWWMUtility.ObscureText(str,MenuTime()/3);
int xx = (Screen.GetWidth()-newsmallfont.StringWidth(str)*CleanXFac_1)/2;
int xx = (Screen.GetWidth()-mSmallFont.StringWidth(str)*CleanXFac_1)/2;
int yy = y;
if ( !a.maxval || (ShouldObscure && !hasprogress) ) yy += ((newsmallfont.GetHeight()+2)*CleanYFac_1)/2;
Screen.DrawText(newsmallfont,completed?Font.CR_GREEN:Font.CR_DARKGRAY,xx,yy,str,DTA_CleanNoMove_1,true);
yy += (newsmallfont.GetHeight()+2)*CleanYFac_1;
if ( !a.maxval || (ShouldObscure && !hasprogress) ) yy += ((mSmallFont.GetHeight()+2)*CleanYFac_1)/2;
Screen.DrawText(mSmallFont,completed?Font.CR_GREEN:Font.CR_DARKGRAY,xx,yy,str,DTA_CleanNoMove_1,true);
yy += (mSmallFont.GetHeight()+2)*CleanYFac_1;
str = a.hasformat?String.Format(StringTable.Localize("$SWWM_ACHIEVEMENT_"..a.basename.."_TXT"),a.maxval):StringTable.Localize("$SWWM_ACHIEVEMENT_"..a.basename.."_TXT");
if ( !completed && !hasprogress && ShouldObscure ) SWWMUtility.ObscureText(str,(MenuTime()/3)+1);
xx = (Screen.GetWidth()-newsmallfont.StringWidth(str)*CleanXFac_1)/2;
Screen.DrawText(newsmallfont,completed?Font.CR_WHITE:Font.CR_BLACK,xx,yy,str,DTA_CleanNoMove_1,true);
xx = (Screen.GetWidth()-mTinyFont.StringWidth(str)*CleanXFac_1)/2;
Screen.DrawText(mTinyFont,completed?Font.CR_WHITE:Font.CR_BLACK,xx,yy,str,DTA_CleanNoMove_1,true);
if ( a.maxval && (!ShouldObscure || hasprogress) )
{
yy += (newsmallfont.GetHeight()+2)*CleanYFac_1;
yy += (mTinyFont.GetHeight()+2)*CleanYFac_1;
int val = 0;
if ( a.bitfield )
{
@ -99,8 +102,8 @@ Class SWWMAchievementMenu : GenericMenu
val = clamp(val,0,a.maxval);
if ( completed ) str = String.Format("%s / %s",SWWMUtility.ThousandsNum(a.maxval),SWWMUtility.ThousandsNum(a.maxval));
else str = String.Format("%s / %s",SWWMUtility.ThousandsNum(val),SWWMUtility.ThousandsNum(a.maxval));
xx = (Screen.GetWidth()-newsmallfont.StringWidth(str)*CleanXFac_1)/2;
Screen.DrawText(newsmallfont,completed?Font.CR_GREEN:Font.CR_DARKGRAY,xx,yy,str,DTA_CleanNoMove_1,true);
xx = (Screen.GetWidth()-mTinyFont.StringWidth(str)*CleanXFac_1)/2;
Screen.DrawText(mTinyFont,completed?Font.CR_GREEN:Font.CR_DARKGRAY,xx,yy,str,DTA_CleanNoMove_1,true);
}
}
@ -112,38 +115,38 @@ Class SWWMAchievementMenu : GenericMenu
if ( completed == total )
{
str = StringTable.Localize("$SWWM_AC_COMPLETE1");
xx = (Screen.GetWidth()-newsmallfont.StringWidth(str)*CleanXFac_1)/2;
Screen.DrawText(newsmallfont,Font.CR_FIRE,xx,yy,str,DTA_CleanNoMove_1,true,DTA_ColorOverlay,Color(int(64+64*sin(MSTimeF()/3.6)),255,255,255));
yy += newsmallfont.GetHeight()*CleanYFac_1;
xx = (Screen.GetWidth()-mSmallFont.StringWidth(str)*CleanXFac_1)/2;
Screen.DrawText(mSmallFont,Font.CR_FIRE,xx,yy,str,DTA_CleanNoMove_1,true,DTA_ColorOverlay,Color(int(64+64*sin(MSTimeF()/3.6)),255,255,255));
yy += mSmallFont.GetHeight()*CleanYFac_1;
// spanish hotfix needed
int gnd = players[consoleplayer].GetGender();
str = String.Format(StringTable.Localize("$SWWM_AC_COMPLETE2"),(gnd==1)?"a":"");
xx = (Screen.GetWidth()-newsmallfont.StringWidth(str)*CleanXFac_1)/2;
Screen.DrawText(newsmallfont,Font.CR_FIRE,xx,yy,str,DTA_CleanNoMove_1,true,DTA_ColorOverlay,Color(int(64+64*sin(MSTimeF()/3.6)),255,255,255));
xx = (Screen.GetWidth()-mSmallFont.StringWidth(str)*CleanXFac_1)/2;
Screen.DrawText(mSmallFont,Font.CR_FIRE,xx,yy,str,DTA_CleanNoMove_1,true,DTA_ColorOverlay,Color(int(64+64*sin(MSTimeF()/3.6)),255,255,255));
return;
}
String str1 = StringTable.Localize("$SWWM_AC_UNLOCKED");
String str2 = StringTable.Localize("$SWWM_AC_INCOMPLETE");
String str3 = StringTable.Localize("$SWWM_AC_UNDISCOVERED");
int maxw = max(newsmallfont.StringWidth(str1),max(newsmallfont.StringWidth(str2),newsmallfont.StringWidth(str3)))+newsmallfont.StringWidth("000");
int maxw = max(mSmallFont.StringWidth(str1),max(mSmallFont.StringWidth(str2),mSmallFont.StringWidth(str3)))+mSmallFont.StringWidth("000");
xx = (Screen.GetWidth()-maxw*CleanXFac_1)/2;
Screen.DrawText(newsmallfont,Font.CR_GREEN,xx,yy,str1,DTA_CleanNoMove_1,true);
yy += newsmallfont.GetHeight()*CleanYFac_1;
Screen.DrawText(newsmallfont,Font.CR_DARKGRAY,xx,yy,str2,DTA_CleanNoMove_1,true);
yy += newsmallfont.GetHeight()*CleanYFac_1;
Screen.DrawText(newsmallfont,Font.CR_DARKGRAY,xx,yy,str3,DTA_CleanNoMove_1,true);
Screen.DrawText(mSmallFont,Font.CR_GREEN,xx,yy,str1,DTA_CleanNoMove_1,true);
yy += mSmallFont.GetHeight()*CleanYFac_1;
Screen.DrawText(mSmallFont,Font.CR_DARKGRAY,xx,yy,str2,DTA_CleanNoMove_1,true);
yy += mSmallFont.GetHeight()*CleanYFac_1;
Screen.DrawText(mSmallFont,Font.CR_DARKGRAY,xx,yy,str3,DTA_CleanNoMove_1,true);
yy = y;
str = String.Format("%d",completed);
xx = (Screen.GetWidth()+maxw*CleanXFac_1)/2-newsmallfont.StringWidth(str)*CleanXFac_1;
Screen.DrawText(newsmallfont,Font.CR_WHITE,xx,yy,str,DTA_CleanNoMove_1,true);
yy += newsmallfont.GetHeight()*CleanYFac_1;
xx = (Screen.GetWidth()+maxw*CleanXFac_1)/2-mSmallFont.StringWidth(str)*CleanXFac_1;
Screen.DrawText(mSmallFont,Font.CR_WHITE,xx,yy,str,DTA_CleanNoMove_1,true);
yy += mSmallFont.GetHeight()*CleanYFac_1;
str = String.Format("%d",incomplete);
xx = (Screen.GetWidth()+maxw*CleanXFac_1)/2-newsmallfont.StringWidth(str)*CleanXFac_1;
Screen.DrawText(newsmallfont,Font.CR_BLACK,xx,yy,str,DTA_CleanNoMove_1,true);
yy += newsmallfont.GetHeight()*CleanYFac_1;
xx = (Screen.GetWidth()+maxw*CleanXFac_1)/2-mSmallFont.StringWidth(str)*CleanXFac_1;
Screen.DrawText(mSmallFont,Font.CR_BLACK,xx,yy,str,DTA_CleanNoMove_1,true);
yy += mSmallFont.GetHeight()*CleanYFac_1;
str = String.Format("%d",total-(completed+incomplete));
xx = (Screen.GetWidth()+maxw*CleanXFac_1)/2-newsmallfont.StringWidth(str)*CleanXFac_1;
Screen.DrawText(newsmallfont,Font.CR_BLACK,xx,yy,str,DTA_CleanNoMove_1,true);
xx = (Screen.GetWidth()+maxw*CleanXFac_1)/2-mSmallFont.StringWidth(str)*CleanXFac_1;
Screen.DrawText(mSmallFont,Font.CR_BLACK,xx,yy,str,DTA_CleanNoMove_1,true);
}
override bool MenuEvent( int mkey, bool fromcontroller )
@ -200,10 +203,10 @@ Class SWWMAchievementMenu : GenericMenu
override void Drawer()
{
Super.Drawer();
int y = DrawCaption()+10*CleanYFac_1;
int y = DrawCaption()+16*CleanYFac_1;
DrawTooltip(y);
int xx = (Screen.GetWidth()-480*CleanXFac_1)/2;
int yy = y+60*CleanYFac_1;
int yy = y+48*CleanYFac_1;
mBaseY = yy;
int i;
for ( i=0; i<mItems.Size(); i++ )