Added option to toggle pausing on Demolitionist Menu. Properly handled fuzz bg toggling on all cases where it's used (now extends to titlemap and help screens).
242 lines
7.1 KiB
Text
242 lines
7.1 KiB
Text
// Hey Graf how about you let us replace the class used for the "Read This!"
|
|
// menu in mapinfo/gameinfo or something so I don't have to do this hack here?
|
|
Class SWWMReadThisHijacker : StaticEventHandler
|
|
{
|
|
override void UiTick()
|
|
{
|
|
Menu cur = Menu.GetCurrentMenu();
|
|
if ( cur is 'ReadThisMenu' )
|
|
{
|
|
cur.Close();
|
|
Menu.SetMenu('SWWMHelpMenu');
|
|
}
|
|
}
|
|
}
|
|
|
|
Class SWWMHelpMenu : GenericMenu
|
|
{
|
|
int curpage, prevpage;
|
|
int fadetic;
|
|
TextureID bgtex;
|
|
transient Font TewiFont, MPlusFont;
|
|
transient CVar lang, fuzz;
|
|
bool isrclick;
|
|
int pagedir;
|
|
|
|
enum EHelpPage
|
|
{
|
|
PAGE_STORY,
|
|
PAGE_DEMO,
|
|
PAGE_ARSENAL1,
|
|
PAGE_ARSENAL2,
|
|
PAGE_ARSENAL3,
|
|
PAGE_TECH,
|
|
PAGE_KBASE,
|
|
NUM_HELP_PAGES
|
|
};
|
|
|
|
// returns MPlus if we're playing in Japanese, otherwise returns the requested font
|
|
Font LangFont( Font req )
|
|
{
|
|
if ( !lang ) lang = CVar.GetCVar('language',players[consoleplayer]);
|
|
if ( lang.GetString() ~== "jp" ) return MPlusFont;
|
|
return req;
|
|
}
|
|
|
|
override void Init( Menu parent )
|
|
{
|
|
curpage = 0;
|
|
prevpage = -1;
|
|
fadetic = gametic;
|
|
pagedir = 0;
|
|
bgtex = TexMan.CheckForTexture("graphics/tempbg.png",TexMan.Type_Any);
|
|
}
|
|
|
|
override bool MenuEvent( int mkey, bool fromcontroller )
|
|
{
|
|
double alph = clamp((gametic-fadetic)*(5./Thinker.TICRATE),0.,1.);
|
|
switch ( mkey )
|
|
{
|
|
case MKEY_Enter:
|
|
case MKEY_Right:
|
|
case MKEY_Down:
|
|
case MKEY_PageDown:
|
|
if ( (curpage < NUM_HELP_PAGES-1) && ((prevpage == -1) || (alph >= 1.)) )
|
|
{
|
|
MenuSound("menu/choose");
|
|
prevpage = curpage;
|
|
curpage++;
|
|
pagedir = 1;
|
|
fadetic = gametic;
|
|
}
|
|
return true;
|
|
break;
|
|
case MKEY_Clear:
|
|
case MKEY_Left:
|
|
case MKEY_Up:
|
|
case MKEY_PageUp:
|
|
if ( (curpage > 0) && ((prevpage == -1) || (alph >= 1.)) )
|
|
{
|
|
MenuSound("menu/choose");
|
|
prevpage = curpage;
|
|
curpage--;
|
|
pagedir = -1;
|
|
fadetic = gametic;
|
|
}
|
|
return true;
|
|
break;
|
|
}
|
|
return Super.MenuEvent(mkey,fromcontroller);
|
|
}
|
|
|
|
override bool MouseEvent( int type, int x, int y )
|
|
{
|
|
if ( (type == MOUSE_Click) && (y != -1) )
|
|
return MenuEvent(isrclick?MKEY_Clear:MKEY_Enter,true);
|
|
return false;
|
|
}
|
|
|
|
override bool OnUiEvent( UIEvent ev )
|
|
{
|
|
int y;
|
|
bool res;
|
|
switch ( ev.type )
|
|
{
|
|
case UIEvent.Type_WheelDown:
|
|
return MenuEvent(MKEY_Enter,true);
|
|
break;
|
|
case UIEvent.Type_WheelUp:
|
|
return MenuEvent(MKEY_Clear,true);
|
|
break;
|
|
case UIEvent.Type_LButtonDown:
|
|
isrclick = false;
|
|
return Super.OnUIEvent(ev);
|
|
break;
|
|
case UIEvent.Type_RButtonDown:
|
|
isrclick = true;
|
|
// copy over what base menus do for L click
|
|
y = ev.MouseY;
|
|
res = MouseEventBack(MOUSE_Click,ev.MouseX,y);
|
|
if ( res ) y = -1;
|
|
res |= MouseEvent(MOUSE_Click,ev.MouseX,y);
|
|
if ( res ) SetCapture(true);
|
|
return false;
|
|
break;
|
|
case UIEvent.Type_RButtonUp:
|
|
// copy over what base menus do for L release
|
|
if ( mMouseCapture )
|
|
{
|
|
SetCapture(false);
|
|
y = ev.MouseY;
|
|
res = MouseEventBack(MOUSE_Release,ev.MouseX,y);
|
|
if ( res ) y = -1;
|
|
res |= MouseEvent(MOUSE_Release,ev.MouseX,y);
|
|
}
|
|
return false;
|
|
break;
|
|
}
|
|
return Super.OnUIEvent(ev);
|
|
}
|
|
|
|
// big bulk of code
|
|
private void DrawPage( int page, Vector2 ss, Vector2 origin, double alpha = 1. )
|
|
{
|
|
Font fnt = LangFont(TewiFont);
|
|
int h = fnt.GetHeight();
|
|
String hdr = "", txt = "";
|
|
BrokenLines l;
|
|
int maxlen = 0, lh;
|
|
double y = 0;
|
|
switch ( page )
|
|
{
|
|
case PAGE_STORY:
|
|
hdr = StringTable.Localize("$SWWM_HELP_STORY");
|
|
if ( gameinfo.gametype&GAME_Heretic ) txt = StringTable.Localize("$SWWM_HELP_STORYHERETIC");
|
|
else if ( gameinfo.gametype&GAME_Hexen ) txt = StringTable.Localize("$SWWM_HELP_STORYHEXEN");
|
|
else if ( gameinfo.gametype&GAME_Strife ) txt = StringTable.Localize("$SWWM_HELP_STORYSTRIFE");
|
|
else txt = StringTable.Localize("$SWWM_HELP_STORYDOOM");
|
|
break;
|
|
case PAGE_DEMO:
|
|
hdr = StringTable.Localize("$SWWM_HELP_DEMO");
|
|
txt = StringTable.Localize("$SWWM_HELP_DEMOTXT");
|
|
break;
|
|
case PAGE_ARSENAL1:
|
|
hdr = StringTable.Localize("$SWWM_HELP_ARSE1");
|
|
txt = StringTable.Localize("$SWWM_HELP_ARSE1TXT");
|
|
break;
|
|
case PAGE_ARSENAL2:
|
|
hdr = StringTable.Localize("$SWWM_HELP_ARSE2");
|
|
txt = StringTable.Localize("$SWWM_HELP_ARSE2TXT");
|
|
break;
|
|
case PAGE_ARSENAL3:
|
|
hdr = StringTable.Localize("$SWWM_HELP_ARSE3");
|
|
txt = StringTable.Localize("$SWWM_HELP_ARSE3TXT");
|
|
break;
|
|
case PAGE_KBASE:
|
|
hdr = StringTable.Localize("$SWWM_HELP_KBASE");
|
|
txt = StringTable.Localize("$SWWM_HELP_KBASETXT");
|
|
break;
|
|
case PAGE_TECH:
|
|
hdr = StringTable.Localize("$SWWM_HELP_TECH");
|
|
txt = StringTable.Localize("$SWWM_HELP_TECHTXT");
|
|
break;
|
|
}
|
|
if ( txt && hdr )
|
|
{
|
|
l = fnt.BreakLines(txt,480);
|
|
lh = l.Count()*h;
|
|
Screen.DrawText(fnt,Font.CR_FIRE,origin.x+320-fnt.StringWidth(hdr)/2,origin.y+200-(h*4+lh)/2,hdr,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alpha);
|
|
for ( int i=0; i<l.Count(); i++ )
|
|
{
|
|
int len = l.StringWidth(i);
|
|
if ( len > maxlen ) maxlen = len;
|
|
}
|
|
for ( int i=0; i<l.Count(); i++ )
|
|
{
|
|
Screen.DrawText(fnt,Font.CR_WHITE,origin.x+320-maxlen/2,origin.y+200-lh/2+y,l.StringAt(i),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alpha);
|
|
y += h;
|
|
}
|
|
return;
|
|
}
|
|
txt = String.Format("(Unknown help page #%d)",page);
|
|
Screen.DrawText(fnt,Font.CR_GOLD,origin.x+320-fnt.StringWidth(txt)/2,origin.y+200-h/2,txt,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alpha);
|
|
}
|
|
|
|
override void Drawer()
|
|
{
|
|
if ( !TewiFont ) TewiFont = Font.GetFont('TewiShaded');
|
|
if ( !MPlusFont ) MPlusFont = Font.GetFont('MPlusShaded');
|
|
if ( !fuzz ) fuzz = CVar.GetCvar('swwm_fuzz',players[consoleplayer]);
|
|
if ( fuzz.GetBool() )
|
|
{
|
|
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());
|
|
double hs;
|
|
if ( (Screen.GetWidth() < 640) || (Screen.GetHeight() < 400) ) hs = max(min(floor(Screen.GetWidth()/320.),floor(Screen.GetHeight()/200.)),1.)/2.;
|
|
else hs = max(min(floor(Screen.GetWidth()/640.),floor(Screen.GetHeight()/400.)),1.);
|
|
Vector2 ss = (Screen.GetWidth(),Screen.GetHeight())/hs;
|
|
Vector2 origin = (ss.x-640,ss.y-400)/2.;
|
|
double alph = clamp((gametic-fadetic)*(5./Thinker.TICRATE),0.,1.);
|
|
if ( (prevpage == -1) || (alph >= 1.) ) DrawPage(curpage,ss,origin);
|
|
else
|
|
{
|
|
DrawPage(prevpage,ss,origin-(pagedir*alph*32,0),(1.-alph)**3);
|
|
DrawPage(curpage,ss,origin+(pagedir*(1.-alph)*32,0),alph**3);
|
|
}
|
|
int h = TewiFont.GetHeight();
|
|
double y = ss.y/2-(h*2);
|
|
for ( int i=0; i<4; i++ )
|
|
{
|
|
if ( curpage > 0 )
|
|
Screen.DrawText(TewiFont,Font.CR_GOLD,12,y,"<",DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
|
|
if ( curpage < NUM_HELP_PAGES-1 )
|
|
Screen.DrawText(TewiFont,Font.CR_GOLD,ss.x-18,y,">",DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
|
|
y += h;
|
|
}
|
|
Super.Drawer();
|
|
}
|
|
}
|