swwmgz_m/zscript/menu/swwm_credits.zsc
2022-06-17 23:04:05 +02:00

450 lines
15 KiB
Text

// credits menu
Class SWWMCreditsEntry ui
{
String title;
TextureID Sprite;
int sheight;
int tics, cur;
BrokenLines btext;
int width, height;
int titlecol, btextcol;
Font mSmallFont;
SWWMCreditsEntry Init( String t, String b = "", int c1 = Font.CR_SAPPHIRE, int c2 = Font.CR_WHITE, String s = "" )
{
mSmallFont = Font.GetFont('TewiFont');
if ( s != "" )
{
Sprite = TexMan.CheckForTexture(s,TexMan.Type_Any);
Vector2 ofs = TexMan.GetScaledOffset(Sprite);
sheight = int(ofs.y);
}
titlecol = c1;
btextcol = c2;
title = StringTable.Localize(t);
if ( b == "" )
{
width = CalcWidth();
height = CalcHeight();
return self;
}
String b2 = StringTable.Localize(b);
btext = mSmallFont.BreakLines(b2,320);
width = CalcWidth();
height = CalcHeight();
return self;
}
override void OnDestroy()
{
Super.OnDestroy();
if ( btext ) btext.Destroy();
}
private int CalcWidth()
{
int len = mSmallFont.StringWidth(title);
if ( !btext ) return len;
for ( int i=0; i<btext.Count(); i++ )
{
int len2 = btext.StringWidth(i);
if ( len2 > len ) len = len2;
}
return len;
}
private int CalcHeight()
{
int h = 0;
if ( Sprite.IsValid() ) h = sheight;
h += mSmallFont.GetHeight();
if ( !btext ) return h;
h += 6;
h += mSmallFont.GetHeight()*btext.Count();
return h;
}
double Draw( Vector2 ss, double x, double y )
{
// don't draw if we're offscreen, saves time
if ( (y+height < 0) || (y > ss.y) ) return height;
double yy = y;
if ( Sprite.IsValid() )
{
yy += sheight;
Screen.DrawTexture(Sprite,true,x+1,yy+1,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_ColorOverlay,Color(255,0,0,0));
Screen.DrawTexture(Sprite,true,x,yy,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
}
int w = mSmallFont.StringWidth(title);
double xx = x-w/2;
Screen.DrawText(mSmallFont,titlecol,xx,yy,title,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
if ( !btext ) return height;
// underline
int cw = int(ceil((w+8)/6.))*6;
xx = x-cw/2;
for ( int i=0; i<cw; i+=6 )
Screen.DrawChar(mSmallFont,titlecol,xx+i,yy+6,0x5F,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
yy += mSmallFont.GetHeight()+6;
for ( int i=0; i<btext.Count(); i++ )
{
xx = x-(btext.StringWidth(i))/2;
Screen.DrawText(mSmallFont,btextcol,xx,yy,btext.StringAt(i),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
yy += mSmallFont.GetHeight();
}
return height;
}
}
Class SWWMCreditsMenu : GenericMenu
{
TextureID bgtex;
TextureID logo;
String stitle, stitle2;
String sdev, sassets, smusic, svoice, sfanart, slocal, spatrons, sthanks;
Array<SWWMCreditsEntry> cdev, cassets, cmusic, cvoice, cfanart, clocal, cpatrons, cthanks;
String oldlang;
Vector2 ss;
double hs;
Vector2 logosz;
double logow, logoh;
Font mSmallFont, mBigFont;
String oldmus;
int oldorder;
bool oldloop;
const ENTRY_PAD = 8;
const SECTION_PAD = 20;
const SECTION_SHIFT = -4;
double spos, speed;
int theight;
void UpdateSize()
{
hs = max(min(floor(Screen.GetWidth()/640.),floor(Screen.GetHeight()/360.)),1.);
ss = (Screen.GetWidth(),Screen.GetHeight())/hs;
}
override void Init( Menu parent )
{
Super.Init(parent);
mSmallFont = Font.GetFont('TewiFont');
mBigFont = Font.GetFont('TewiFontOutline');
bgtex = TexMan.CheckForTexture("graphics/tempbg.png",TexMan.Type_Any);
UpdateSize();
logo = TexMan.CheckForTexture(swwm_oldlogo?"graphics/M_SWWM.png":"graphics/M_DEMOLITIONIST.png",TexMan.Type_Any);
logosz = TexMan.GetScaledSize(logo);
if ( !swwm_oldlogo )
{
logosz *= (2./3.);
logosz.y += 36.;
}
stitle = StringTable.Localize("$SWWM_CSTITLE");
stitle2 = StringTable.Localize("$SWWM_CSTITLE2");
sdev = StringTable.Localize("$SWWM_CLEAD");
sassets = StringTable.Localize("$SWWM_CASSETS");
smusic = StringTable.Localize("$SWWM_CMUSIC");
svoice = StringTable.Localize("$SWWM_CVOICE");
sfanart = StringTable.Localize("$SWWM_CFANART");
slocal = StringTable.Localize("$SWWM_CLOCAL");
spatrons = StringTable.Localize("$SWWM_CPATRON");
sthanks = StringTable.Localize("$SWWM_CTHANK");
cdev.Push(new("SWWMCreditsEntry").Init("Marisa the Magician","$SWWM_CDEV2",s:"graphics/Credits/MariSprite.png"));
cassets.Push(new("SWWMCreditsEntry").Init("Bethesda Game Studios","Fallout: New Vegas\nFallout 4"));
cassets.Push(new("SWWMCreditsEntry").Init("Epic Games","Unreal\nUnreal Tournament\nUnreal Tournament 2004\nUnreal Tournament 3"));
cassets.Push(new("SWWMCreditsEntry").Init("Ion Storm","Deus Ex"));
cassets.Push(new("SWWMCreditsEntry").Init("Looking Glass Studios","Thief\nSystem Shock 2"));
cassets.Push(new("SWWMCreditsEntry").Init("People Can Fly","Painkiller"));
cassets.Push(new("SWWMCreditsEntry").Init("Tripwire Interactive","Killing Floor"));
cassets.Push(new("SWWMCreditsEntry").Init("From Software","Dark Souls\nDark Souls II\nDark Souls III"));
cassets.Push(new("SWWMCreditsEntry").Init("Amuscaria","$SWWM_ASSBARONS"));
cassets.Push(new("SWWMCreditsEntry").Init("Ryan Cordell","$SWWM_ASSOTHERS"));
cassets.Push(new("SWWMCreditsEntry").Init("Blox","$SWWM_ASSEXTRA"));
cassets.Push(new("SWWMCreditsEntry").Init("SiFi270","$SWWM_ASSKEEN"));
cassets.Push(new("SWWMCreditsEntry").Init("Nash","WidePix"));
cmusic.Push(new("SWWMCreditsEntry").Init("Teque","Traumatic State\nDragony\nHidden Tune #242\nHypercardish 1.1"));
cmusic.Push(new("SWWMCreditsEntry").Init("BouncyTEM","Solitary Apprehension"));
cvoice.Push(new("SWWMCreditsEntry").Init("Vyolette","$T_DEMOLITIONIST"));
cfanart.Push(new("SWWMCreditsEntry").Init("Substance20 (@S20TBL)"));
cfanart.Push(new("SWWMCreditsEntry").Init("Captain J (@Jho7835)"));
cfanart.Push(new("SWWMCreditsEntry").Init("Redead-ITA"));
cfanart.Push(new("SWWMCreditsEntry").Init("Sgt. Shivers (@Sgt_Shivers_)"));
cfanart.Push(new("SWWMCreditsEntry").Init("Moa Dixøn / Endie (@MoaDixon)"));
cfanart.Push(new("SWWMCreditsEntry").Init("Monsoon-Soft (@MonsoonSoft)"));
clocal.Push(new("SWWMCreditsEntry").Init("Marisa the Magician","$SWWM_LOCES"));
cpatrons.Push(new("SWWMCreditsEntry").Init("Snacks"));
cpatrons.Push(new("SWWMCreditsEntry").Init("john"));
cpatrons.Push(new("SWWMCreditsEntry").Init("FireFly"));
cpatrons.Push(new("SWWMCreditsEntry").Init("Corey Hectus"));
cpatrons.Push(new("SWWMCreditsEntry").Init("Dac"));
cpatrons.Push(new("SWWMCreditsEntry").Init("kevansevans"));
cpatrons.Push(new("SWWMCreditsEntry").Init("Log!"));
cpatrons.Push(new("SWWMCreditsEntry").Init("Pietro Gagliardi"));
cpatrons.Push(new("SWWMCreditsEntry").Init("Ryan Weatherman"));
cpatrons.Push(new("SWWMCreditsEntry").Init("Xada Xephron"));
cpatrons.Push(new("SWWMCreditsEntry").Init("Zard1084"));
cpatrons.Push(new("SWWMCreditsEntry").Init("John"));
cpatrons.Push(new("SWWMCreditsEntry").Init("NekoMithos"));
cpatrons.Push(new("SWWMCreditsEntry").Init("Ultralight"));
cpatrons.Push(new("SWWMCreditsEntry").Init("Antlason Widowz"));
cpatrons.Push(new("SWWMCreditsEntry").Init("bouncytem"));
cpatrons.Push(new("SWWMCreditsEntry").Init("Brett Saltzer"));
cpatrons.Push(new("SWWMCreditsEntry").Init("Clint Walker"));
cpatrons.Push(new("SWWMCreditsEntry").Init("Figo"));
cpatrons.Push(new("SWWMCreditsEntry").Init("melancholygeek"));
cpatrons.Push(new("SWWMCreditsEntry").Init("Namsan"));
cpatrons.Push(new("SWWMCreditsEntry").Init("YaGirlJuniper"));
cthanks.Push(new("SWWMCreditsEntry").Init("Marrub","$SWWM_CMAB2",Font.FindFontColor('Heliotrope'),Font.FindFontColor('BlushPink')));
cthanks.Push(new("SWWMCreditsEntry").Init("KynikossDragonn","$SWWM_CDRAGON2"));
cthanks.Push(new("SWWMCreditsEntry").Init("Lucy","$SWWM_CLUCY2"));
cthanks.Push(new("SWWMCreditsEntry").Init("Gutawer","$SWWM_CGUTA2"));
cthanks.Push(new("SWWMCreditsEntry").Init("Mikolah","$SWWM_CMIKO2"));
cthanks.Push(new("SWWMCreditsEntry").Init("KeksDose","$SWWM_CKEKS2"));
cthanks.Push(new("SWWMCreditsEntry").Init("ZZYZX & Nash","$SWWM_CZN2"));
cthanks.Push(new("SWWMCreditsEntry").Init("Val Pal","$SWWM_CVAL2"));
cthanks.Push(new("SWWMCreditsEntry").Init("Kaffy Kathy","$SWWM_CKATHY2"));
cthanks.Push(new("SWWMCreditsEntry").Init("BouncyTEM","$SWWM_CBOUNCY2"));
cthanks.Push(new("SWWMCreditsEntry").Init("\ctCptSledge\c- & \cdBunray\c-","$SWWM_CSLEDGE2"));
cthanks.Push(new("SWWMCreditsEntry").Init("a1337spy","$SWWM_CSPY2"));
cthanks.Push(new("SWWMCreditsEntry").Init("$SWWM_CINSP1","$SWWM_CINSP2"));
cthanks.Push(new("SWWMCreditsEntry").Init("$SWWM_CCOMMUNITY1","$SWWM_CCOMMUNITY2"));
cthanks.Push(new("SWWMCreditsEntry").Init("$SWWM_CDEVS1","$SWWM_CDEVS2"));
cthanks.Push(new("SWWMCreditsEntry").Init("$SWWM_CYOU1","$SWWM_CYOU2"));
speed = 16.;
spos = ss.y-logosz.y;
// calc total height
theight = int(logosz.y);
theight += 8*(SECTION_PAD+mBigFont.GetHeight()*2);
for ( int i=0; i<cdev.Size(); i++ )
{
theight += ENTRY_PAD;
theight += cdev[i].height;
}
for ( int i=0; i<cassets.Size(); i++ )
{
theight += ENTRY_PAD;
theight += cassets[i].height;
}
for ( int i=0; i<cmusic.Size(); i++ )
{
theight += ENTRY_PAD;
theight += cmusic[i].height;
}
for ( int i=0; i<cvoice.Size(); i++ )
{
theight += ENTRY_PAD;
theight += cvoice[i].height;
}
for ( int i=0; i<cfanart.Size(); i++ )
{
theight += ENTRY_PAD;
theight += cfanart[i].height;
}
for ( int i=0; i<clocal.Size(); i++ )
{
theight += ENTRY_PAD;
theight += clocal[i].height;
}
for ( int i=0; i<cpatrons.Size(); i++ )
{
theight += ENTRY_PAD;
theight += cpatrons[i].height;
}
for ( int i=0; i<cthanks.Size(); i++ )
{
theight += ENTRY_PAD;
theight += cthanks[i].height;
}
// music swap
oldmus = musplaying.name;
oldorder = musplaying.baseorder;
oldloop = musplaying.loop;
S_ChangeMusic("music/H2I4D2E.XM");
}
double DrawLogo( double x, double y )
{
// don't draw if we're offscreen, saves time
if ( (y+logosz.y < 0) || (y > ss.y) ) return logosz.y;
if ( swwm_oldlogo ) Screen.DrawTexture(logo,true,x-logosz.x/2,y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
else Screen.DrawTexture(logo,true,x-logosz.x/2,y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_ScaleX,(2./3.),DTA_ScaleY,(2./3.));
Screen.DrawText(mSmallFont,Font.CR_SAPPHIRE,x-mSmallFont.StringWidth(stitle)/2,y+(logosz.y-28),stitle,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
// underline
int w = max(mSmallFont.StringWidth(stitle),mSmallFont.StringWidth(stitle2));
int cw = int(ceil((w+8)/6.))*6;
double xx = x-cw/2;
for ( int i=0; i<cw; i+=6 )
Screen.DrawChar(mSmallFont,Font.CR_SAPPHIRE,xx+i,y+(logosz.y-22),0x5F,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
Screen.DrawText(mSmallFont,Font.CR_WHITE,x-mSmallFont.StringWidth(stitle2)/2,y+(logosz.y-9),stitle2,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
return logosz.y;
}
double DrawSection( double x, double y, String txt )
{
// don't draw if we're offscreen, saves time
y += SECTION_SHIFT;
if ( (y+mBigFont.GetHeight()*2 < 0) || (y > ss.y) ) return mBigFont.GetHeight()*2;
Screen.DrawText(mBigFont,Font.CR_BLUE,x-mBigFont.StringWidth(txt),y,txt,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_ScaleX,2,DTA_ScaleY,2);
return mBigFont.GetHeight()*2;
}
override void Drawer()
{
if ( swwm_fuzz )
{
Vector2 tsize = TexMan.GetScaledSize(bgtex);
double zoom = max(ceil(Screen.GetWidth()/tsize.x),ceil(Screen.GetHeight()/tsize.y));
Vector2 vsize = (Screen.GetWidth(),Screen.GetHeight())/zoom;
Screen.DrawTexture(bgtex,false,(vsize.x-tsize.x)/2,(vsize.y-tsize.y)/2,DTA_VirtualWidthF,vsize.x,DTA_VirtualHeightF,vsize.y,DTA_KeepRatio,true,DTA_ColorOverlay,Color(192,0,0,0),DTA_Alpha,.8);
}
else Screen.Dim("Black",.8,0,0,Screen.GetWidth(),Screen.GetHeight());
Super.Drawer();
UpdateSize();
// logo
double yy = spos;
double xx = ss.x/2.;
yy += DrawLogo(xx,yy);
// developer
yy += SECTION_PAD;
yy += DrawSection(xx,yy,sdev);
for ( int i=0; i<cdev.Size(); i++ )
{
yy += ENTRY_PAD;
yy += cdev[i].Draw(ss,xx,yy);
}
// assets
yy += SECTION_PAD;
yy += DrawSection(xx,yy,sassets);
for ( int i=0; i<cassets.Size(); i++ )
{
yy += ENTRY_PAD;
yy += cassets[i].Draw(ss,xx,yy);
}
// music
yy += SECTION_PAD;
yy += DrawSection(xx,yy,smusic);
for ( int i=0; i<cmusic.Size(); i++ )
{
yy += ENTRY_PAD;
yy += cmusic[i].Draw(ss,xx,yy);
}
// voices
yy += SECTION_PAD;
yy += DrawSection(xx,yy,svoice);
for ( int i=0; i<cvoice.Size(); i++ )
{
yy += ENTRY_PAD;
yy += cvoice[i].Draw(ss,xx,yy);
}
// fanart
yy += SECTION_PAD;
yy += DrawSection(xx,yy,sfanart);
for ( int i=0; i<cfanart.Size(); i++ )
{
yy += ENTRY_PAD;
yy += cfanart[i].Draw(ss,xx,yy);
}
// localization
yy += SECTION_PAD;
yy += DrawSection(xx,yy,slocal);
for ( int i=0; i<clocal.Size(); i++ )
{
yy += ENTRY_PAD;
yy += clocal[i].Draw(ss,xx,yy);
}
// patrons
yy += SECTION_PAD;
yy += DrawSection(xx,yy,spatrons);
for ( int i=0; i<cpatrons.Size(); i++ )
{
yy += ENTRY_PAD;
yy += cpatrons[i].Draw(ss,xx,yy);
}
// thanks
yy += SECTION_PAD;
yy += DrawSection(xx,yy,sthanks);
for ( int i=0; i<cthanks.Size(); i++ )
{
yy += ENTRY_PAD;
yy += cthanks[i].Draw(ss,xx,yy);
}
}
override void Ticker()
{
spos -= speed/GameTicRate;
if ( spos < -theight ) spos = ss.y;
if ( spos > ss.y ) spos = -theight;
}
override bool TranslateKeyboardEvents()
{
return false;
}
override bool OnUIEvent( UIEvent ev )
{
switch ( ev.type )
{
case UIEvent.Type_KeyDown:
if ( ev.KeyChar == UIEvent.Key_Escape )
{
// gotta manually send this one
MenuEvent(MKEY_Back,false);
return true;
}
if ( ev.KeyChar == UIEvent.Key_Backspace )
{
spos = (ss.y-logoh)/2;
speed = 16.;
return true;
}
if ( ev.KeyChar == UIEvent.Key_Down )
{
speed = 48.;
return true;
}
if ( ev.KeyChar == UIEvent.Key_PgDn )
{
speed = 96.;
return true;
}
if ( ev.KeyChar == UIEvent.Key_Up )
{
speed = -48.;
return true;
}
if ( ev.KeyChar == UIEvent.Key_PgUp )
{
speed = -96.;
return true;
}
if ( ev.KeyChar == UIEvent.Key_Return )
{
speed = 0.;
return true;
}
break;
case UIEvent.Type_KeyUp:
if ( (ev.KeyChar == UIEvent.Key_Down) || (ev.KeyChar == UIEvent.Key_Up)
|| (ev.KeyChar == UIEvent.Key_PgDn) || (ev.KeyChar == UIEvent.Key_PgUp)
|| (ev.KeyChar == UIEvent.Key_Return) )
{
speed = 16.;
return true;
}
break;
}
return Super.OnUIEvent(ev);
}
override bool MenuEvent( int mkey, bool fromcontroller )
{
switch ( mkey )
{
case MKEY_Back:
// reset music
S_ChangeMusic(oldmus,oldorder,oldloop);
Close();
let m = GetCurrentMenu();
MenuSound(m?"menu/backup":"menu/clear");
if ( !m ) menuDelegate.MenuDismissed();
return true;
}
return false;
}
}