Pachinko code tab implemented.

This commit is contained in:
Mari the Deer 2022-03-24 16:28:44 +01:00
commit c78041fa6e
2 changed files with 131 additions and 3 deletions

View file

@ -1,3 +1,3 @@
[default]
SWWM_MODVER="\cyDEMOLITIONIST \cw1.2pre r193 \cu(Wed 23 Mar 10:50:12 CET 2022)\c-";
SWWM_SHORTVER="\cw1.2pre r193 \cu(2022-03-23 10:50:12)\c-";
SWWM_MODVER="\cyDEMOLITIONIST \cw1.2pre r195 \cu(Thu 24 Mar 16:28:58 CET 2022)\c-";
SWWM_SHORTVER="\cw1.2pre r195 \cu(2022-03-24 16:28:58)\c-";

View file

@ -2,20 +2,148 @@
Class DemolitionistSecretTab : DemolitionistMenuTab
{
TextureID img;
String sub;
BrokenLines l;
double smofs;
int ofs, maxofs;
bool drag;
override DemolitionistMenuTab Init( DemolitionistMenu master )
{
title = StringTable.Localize("$SWWM_SECRETTAB");
bHidden = true;
if ( gameinfo.gametype&GAME_Hexen )
{
img = TexMan.CheckForTexture("graphics/KBase/Drawing_Kirin.png",TexMan.Type_Any);
sub = StringTable.Localize("$SWWM_FROMKIRIN");
String str = StringTable.Localize("$SWWM_KIRINPOEM");
l = smallfont.BreakLines(str,600);
}
else if ( (gameinfo.gametype&GAME_Heretic) || SWWMUtility.IsEviternity() )
{
img = TexMan.CheckForTexture("graphics/KBase/Drawing_Ibuki.png",TexMan.Type_Any);
sub = StringTable.Localize("$SWWM_CUTIECLUB");
}
else
{
img = TexMan.CheckForTexture("graphics/KBase/Drawing_Saya.png",TexMan.Type_Any);
sub = StringTable.Localize("$SWWM_TODEMO");
}
maxofs = max(0,320-int(master.ws.y-40));
return Super.Init(master);
}
override void OnDestroy()
{
Super.OnDestroy();
if ( l ) l.Destroy();
}
override void OnSelect()
{
bHidden = false;
smofs = ofs;
}
override void OnDeselect()
{
bHidden = true;
smofs = ofs;
}
// called when sending a scroll input
// returns true if the position actually changed
// speed: how many pixels to move (either back or forward)
bool Scroll( int speed )
{
int oldofs = ofs;
ofs = clamp(ofs+speed,0,maxofs);
return (ofs != oldofs);
}
// called when clicking on our scrollbar
// returns true if the position actually changed
// y: relative click position
bool SetOffset( double y )
{
int oldofs = ofs;
ofs = clamp(int(round((y-20.5)/((master.ws.y-41.)/maxofs))),0,maxofs);
return (ofs != oldofs);
}
override void MenuInput( int key )
{
if ( maxofs <= 0 ) return;
switch ( key )
{
case MK_DOWN:
if ( Scroll(16) ) master.MenuSound("menu/demoscroll");
break;
case MK_UP:
if ( Scroll(-16) ) master.MenuSound("menu/demoscroll");
break;
}
}
override void MouseInput( Vector2 pos, int btn )
{
if ( maxofs <= 0 ) return;
switch ( btn )
{
case MB_LEFT:
// see if we're clicking the scrollbar (if it exists)
if ( pos.x > (master.ws.x-8) )
{
SetOffset(pos.y);
master.MenuSound("menu/demoscroll");
drag = true;
}
break;
case MB_WHEELUP:
if ( Scroll(-8) ) master.MenuSound("menu/demoscroll");
break;
case MB_WHEELDOWN:
if ( Scroll(8) ) master.MenuSound("menu/demoscroll");
break;
case MB_DRAG:
if ( drag ) SetOffset(pos.y);
break;
case MB_RELEASE:
drag = false;
break;
}
}
override void Ticker()
{
// update smooth scroll
smofs = (smofs*.6)+(ofs*.4);
if ( abs(smofs-ofs) < (1./master.hs) ) smofs = ofs;
}
override void Drawer()
{
double xx = 20;
double yy;
if ( maxofs <= 0 ) yy = master.ws.y/2-160;
else yy = 20-smofs;
int miny = int((master.origin.y+20)*master.hs);
int maxy = int((master.origin.y+(master.ws.y-20))*master.hs);
Screen.DrawTexture(img,false,master.origin.x+xx,master.origin.y+yy,DTA_VirtualWidthF,master.ss.x,DTA_VirtualHeightF,master.ss.y,DTA_KeepRatio,true,DTA_ClipTop,miny,DTA_ClipBottom,maxy);
int mxlen = 0;
if ( l ) for ( int i=0; i<l.Count(); i++ )
{
if ( l.StringWidth(i) > mxlen ) mxlen = l.StringWidth(i);
xx = (i<l.Count()-1)?350:(350+mxlen-l.StringWidth(i));
Screen.DrawText(smallfont,Font.CR_GOLD,master.origin.x+xx,master.origin.y+yy+4+i*14,l.StringAt(i),DTA_VirtualWidthF,master.ss.x,DTA_VirtualHeightF,master.ss.y,DTA_KeepRatio,true,DTA_ClipTop,miny,DTA_ClipBottom,maxy);
}
yy += 306;
xx = int(master.ws.x-smallfont.StringWidth(sub))/2;
Screen.DrawText(smallfont,Font.CR_WHITE,master.origin.x+xx,master.origin.y+yy,sub,DTA_VirtualWidthF,master.ss.x,DTA_VirtualHeightF,master.ss.y,DTA_KeepRatio,true,DTA_ClipTop,miny,DTA_ClipBottom,maxy);
if ( maxofs <= 0 ) return;
xx = master.ws.x-8;
master.DrawVSeparator(xx,14,master.ws.y-28);
xx += 2;
yy = floor(smofs*((master.ws.y-39)/maxofs))+14;
Screen.DrawText(smallfont,Font.CR_FIRE,master.origin.x+xx,master.origin.y+yy,"▮",DTA_VirtualWidthF,master.ss.x,DTA_VirtualHeightF,master.ss.y,DTA_KeepRatio,true);
}
}