285 lines
11 KiB
Text
285 lines
11 KiB
Text
// stats stab
|
|
|
|
Class DemolitionistStatsTab : DemolitionistMenuTab
|
|
{
|
|
DemolitionistMenuList lists[4];
|
|
int section;
|
|
String sname[4];
|
|
int lwidth;
|
|
SWWMStats stats;
|
|
int ofs, maxofs;
|
|
double smofs;
|
|
bool drag;
|
|
|
|
override DemolitionistMenuTab Init( DemolitionistMenu master )
|
|
{
|
|
title = "$SWWM_STATTAB";
|
|
section = 0;
|
|
lwidth = 0;
|
|
for ( int i=0; i<4; i++ )
|
|
{
|
|
sname[i] = StringTable.Localize("$SWWM_STATTAB"..i);
|
|
lwidth = max(lwidth,master.LargeFont.StringWidth(sname[i]));
|
|
lists[i] = new("DemolitionistMenuList");
|
|
lists[i].selected = -1;
|
|
}
|
|
lwidth += 16; // account for padding of 8px on each side
|
|
return Super.Init(master);
|
|
}
|
|
override void OnSelect()
|
|
{
|
|
section = master.shnd.menustate.At("LastStatSection").ToInt();
|
|
}
|
|
override void OnDeselect()
|
|
{
|
|
master.shnd.menustate.Insert("LastStatSection",String.Format("%d",section));
|
|
}
|
|
override void Ticker()
|
|
{
|
|
// update list contents
|
|
switch ( section )
|
|
{
|
|
case 0:
|
|
if ( !stats ) stats = Demolitionist(players[consoleplayer].mo)?Demolitionist(players[consoleplayer].mo).mystats:null;
|
|
if ( lists[0].items.Size() == 0 ) // allocate first
|
|
{
|
|
for ( int i=0; i<31; i++ )
|
|
{
|
|
let li = new("DemolitionistMenuListItem").Init(master,"");
|
|
li.xpos = 0;
|
|
li.ypos = i*16;
|
|
lists[0].items.Push(li);
|
|
}
|
|
}
|
|
maxofs = int(16*lists[0].items.Size()-(master.ws.y-46));
|
|
if ( !stats ) break;
|
|
// oof
|
|
int thour = ((level.totaltime-stats.lastspawn)/(3600*GameTicRate));
|
|
int tmin = ((level.totaltime-stats.lastspawn)/(60*GameTicRate))%60;
|
|
int tsec = ((level.totaltime-stats.lastspawn)/GameTicRate)%60;
|
|
String str = String.Format("\cx%s\c-%02d\cu:\c-%02d\cu:\c-%02d",StringTable.Localize("$SWWM_STATUPTIME"),thour,tmin,tsec);
|
|
lists[0].items[0].label = str;
|
|
if ( stats.grounddist > 32000. ) str = String.Format("\cx%s\c-%g\cu%s\c-",StringTable.Localize("$SWWM_STATONFOOT"),stats.grounddist/32000.,StringTable.Localize("$SWWM_UNIT_KILOMETER"));
|
|
else str = String.Format("\cx%s\c-%g\cu%s\c-",StringTable.Localize("$SWWM_STATONFOOT"),stats.grounddist/32.,StringTable.Localize("$SWWM_UNIT_METER"));
|
|
lists[0].items[1].label = str;
|
|
if ( stats.airdist > 32000. ) str = String.Format("\cx%s\c-%g\cu%s\c-",StringTable.Localize("$SWWM_STATFLIGHT"),stats.airdist/32000.,StringTable.Localize("$SWWM_UNIT_KILOMETER"));
|
|
else str = String.Format("\cx%s\c-%g\cu%s\c-",StringTable.Localize("$SWWM_STATFLIGHT"),stats.airdist/32.,StringTable.Localize("$SWWM_UNIT_METER"));
|
|
lists[0].items[2].label = str;
|
|
if ( stats.swimdist > 32000. ) str = String.Format("\cx%s\c-%g\cu%s\c-",StringTable.Localize("$SWWM_STATSWIM"),stats.swimdist/32000.,StringTable.Localize("$SWWM_UNIT_KILOMETER"));
|
|
else str = String.Format("\cx%s\c-%g\cu%s\c-",StringTable.Localize("$SWWM_STATSWIM"),stats.swimdist/32.,StringTable.Localize("$SWWM_UNIT_METER"));
|
|
lists[0].items[3].label = str;
|
|
if ( stats.teledist > 32000. ) str = String.Format("\cx%s\c-%g\cu%s\c-",StringTable.Localize("$SWWM_STATTELE"),stats.teledist/32000.,StringTable.Localize("$SWWM_UNIT_KILOMETER"));
|
|
else str = String.Format("\cx%s\c-%g\cu%s\c-",StringTable.Localize("$SWWM_STATTELE"),stats.teledist/32.,StringTable.Localize("$SWWM_UNIT_METER"));
|
|
lists[0].items[4].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATBOOST"),stats.boostcount);
|
|
lists[0].items[5].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATDASH"),stats.dashcount);
|
|
lists[0].items[6].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATSTOMP"),stats.stompcount);
|
|
lists[0].items[7].label = str;
|
|
str = String.Format("\cx%s\c-%g\cu%s\c-",StringTable.Localize("$SWWM_STATFUEL"),stats.fuelusage,StringTable.Localize("$SWWM_UNIT_LITER"));
|
|
lists[0].items[8].label = str;
|
|
str = String.Format("\cx%s\c-%g\cu%s\c-",StringTable.Localize("$SWWM_STATSPEED"),(stats.topspeed*3600.*GameTicRate)/32000.,StringTable.Localize("$SWWM_UNIT_KPH"));
|
|
lists[0].items[9].label = str;
|
|
thour = (stats.airtime/(3600*GameTicRate));
|
|
tmin = (stats.airtime/(60*GameTicRate))%60;
|
|
tsec = (stats.airtime/GameTicRate)%60;
|
|
str = String.Format("\cx%s\c-%02d\cu:\c-%02d\cu:\c-%02d",StringTable.Localize("$SWWM_STATAIRTIME"),thour,tmin,tsec);
|
|
lists[0].items[10].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATPARRY"),stats.parries);
|
|
lists[0].items[11].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATPPARRY"),stats.pparries);
|
|
lists[0].items[12].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATWPONCH"),stats.wponch);
|
|
lists[0].items[13].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATBUSTS"),stats.busts);
|
|
lists[0].items[14].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATBUTTS"),stats.buttslams);
|
|
lists[0].items[15].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATPATS"),stats.pats);
|
|
lists[0].items[16].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATKISS"),stats.smooch);
|
|
lists[0].items[17].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATFRIENDS"),stats.befriend);
|
|
lists[0].items[18].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATITEMS"),stats.items);
|
|
lists[0].items[19].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATSECRETS"),stats.secrets);
|
|
lists[0].items[20].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATKILLS"),stats.kills);
|
|
lists[0].items[21].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATDEATHS"),stats.deaths);
|
|
lists[0].items[22].label = str;
|
|
if ( stats.hdamagedealt > 0 ) str = str = String.Format("\cx%s\c-%d%09d",StringTable.Localize("$SWWM_STATDDEALT"),stats.hdamagedealt,stats.damagedealt);
|
|
else str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATDDEALT"),stats.damagedealt);
|
|
lists[0].items[23].label = str;
|
|
if ( stats.hdamagetaken > 0 ) str = String.Format("\cx%s\c-%d%09d",StringTable.Localize("$SWWM_STATDTAKEN"),stats.hdamagetaken,stats.damagetaken);
|
|
else str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATDTAKEN"),stats.damagetaken);
|
|
lists[0].items[24].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATTDEALT"),stats.topdealt);
|
|
lists[0].items[25].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATTTAKEN"),stats.toptaken);
|
|
lists[0].items[26].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATMKILL"),stats.mkill);
|
|
lists[0].items[27].label = str;
|
|
str = String.Format("\cx%s\c-%d",StringTable.Localize("$SWWM_STATSKILL"),stats.skill);
|
|
lists[0].items[28].label = str;
|
|
str = String.Format("\cx%s\c-",StringTable.Localize("$SWWM_STATFAVWEAP"));
|
|
if ( stats.favweapon == -1 ) str = str.."N/A";
|
|
else if ( stats.wstats[stats.favweapon].w == 'SWWMWeapon' ) str = str..StringTable.Localize("$SWWM_YOURSELF");
|
|
else if ( stats.wstats[stats.favweapon].w == 'SWWMGesture' ) str = str..StringTable.Localize("$SWWM_DOKIDOKI");
|
|
else if ( stats.wstats[stats.favweapon].w == 'SWWMItemGesture' ) str = str..StringTable.Localize("$T_FROGGY");
|
|
else if ( stats.wstats[stats.favweapon].w == 'Weapon' ) str = str..StringTable.Localize("$SWWM_GRAVKILL");
|
|
else if ( stats.wstats[stats.favweapon].w == 'DoomWeapon' ) str = str..StringTable.Localize("$SWWM_PARRYKILL");
|
|
else
|
|
{
|
|
let def = GetDefaultByType(stats.wstats[stats.favweapon].w);
|
|
str = str..def.GetTag();
|
|
}
|
|
lists[0].items[29].label = str;
|
|
if ( stats.hhiscore > 0 ) str = String.Format("\cx%s\cu¥\c-%d%09d",StringTable.Localize("$SWWM_STATHISCORE"),stats.hhiscore,stats.hiscore);
|
|
else str = String.Format("\cx%s\cu¥\c-%09d",StringTable.Localize("$SWWM_STATHISCORE"),stats.hiscore);
|
|
lists[0].items[30].label = str;
|
|
break;
|
|
}
|
|
// update smooth scroll
|
|
smofs = (smofs*.6)+(ofs*.4);
|
|
if ( abs(smofs-ofs) < (1./master.hs) ) smofs = ofs;
|
|
// tick the current list
|
|
lists[section].Ticker();
|
|
}
|
|
// 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 )
|
|
{
|
|
if ( maxofs <= 0 ) return false;
|
|
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 )
|
|
{
|
|
if ( maxofs <= 0 ) return false;
|
|
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 )
|
|
{
|
|
switch ( key )
|
|
{
|
|
case MK_LEFT:
|
|
master.MenuSound("menu/demoscroll");
|
|
section--;
|
|
if ( section < 0 ) section = 3;
|
|
smofs = ofs = 0;
|
|
break;
|
|
case MK_RIGHT:
|
|
master.MenuSound("menu/demoscroll");
|
|
section++;
|
|
if ( section > 3 ) section = 0;
|
|
smofs = ofs = 0;
|
|
break;
|
|
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 )
|
|
{
|
|
// global events
|
|
switch ( btn )
|
|
{
|
|
case MB_DRAG:
|
|
if ( drag ) SetOffset(pos.y);
|
|
break;
|
|
case MB_RELEASE:
|
|
drag = false;
|
|
break;
|
|
}
|
|
// mouse on left side
|
|
if ( pos.x < lwidth )
|
|
{
|
|
switch ( btn )
|
|
{
|
|
case MB_LEFT:
|
|
for ( int i=0; i<4; i++ )
|
|
{
|
|
if ( pos.x < 9 ) continue;
|
|
if ( pos.x > 9+master.LargeFont.StringWidth(sname[i]) ) continue;
|
|
if ( pos.y < 23+16*i ) continue;
|
|
if ( pos.y > 36+16*i ) continue;
|
|
if ( section != i )
|
|
{
|
|
master.MenuSound("menu/demoscroll");
|
|
section = i;
|
|
smofs = ofs = 0;
|
|
}
|
|
break;
|
|
}
|
|
break;
|
|
case MB_WHEELUP:
|
|
MenuInput(MK_LEFT);
|
|
break;
|
|
case MB_WHEELDOWN:
|
|
MenuInput(MK_RIGHT);
|
|
break;
|
|
}
|
|
}
|
|
switch ( btn )
|
|
{
|
|
case MB_LEFT:
|
|
// see if we're clicking the scrollbar (if it exists)
|
|
if ( (maxofs > 0) && (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;
|
|
}
|
|
}
|
|
override void Drawer()
|
|
{
|
|
double xx = 9;
|
|
double yy = 23;
|
|
for ( int i=0; i<4; i++ )
|
|
{
|
|
Screen.DrawText(master.LargeFont,(i==section)?Font.CR_FIRE:Font.CR_WHITE,master.origin.x+xx,master.origin.y+yy,sname[i],DTA_VirtualWidthF,master.ss.x,DTA_VirtualHeightF,master.ss.y,DTA_KeepRatio,true);
|
|
yy += 16;
|
|
}
|
|
master.DrawVSeparator(lwidth,14,master.ws.y-28);
|
|
if ( section == 0 )
|
|
{
|
|
xx = lwidth+9;
|
|
yy = 23;
|
|
int cliptop = int((master.origin.y+23)*master.hs);
|
|
int clipbottom = int((master.origin.y+master.ws.y-23)*master.hs);
|
|
int clipleft = int((master.origin.x+lwidth+9)*master.hs);
|
|
int clipright = int((master.origin.x+master.ws.x-9)*master.hs);
|
|
lists[0].Drawer((xx,yy-smofs),cliptop,clipbottom,clipleft,clipright);
|
|
if ( maxofs > 0 )
|
|
{
|
|
xx = master.ws.x-8;
|
|
master.DrawVSeparator(xx,14,master.ws.y-28);
|
|
xx += 2;
|
|
yy = floor(smofs*((master.ws.y-39)/maxofs))+13;
|
|
Screen.DrawText(master.TewiFont,Font.CR_FIRE,master.origin.x+xx,master.origin.y+yy,"▮",DTA_VirtualWidthF,master.ss.x,DTA_VirtualHeightF,master.ss.y,DTA_KeepRatio,true);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|