Show play time in options menu.
Store unlock date for achievements.
This commit is contained in:
parent
bbb9f2e765
commit
d22f9609e0
9 changed files with 163 additions and 13 deletions
|
|
@ -27,6 +27,7 @@ extend Class SWWMStaticHandler
|
|||
if ( (val == 1) && (gametic > lastachievementnotify) )
|
||||
{
|
||||
a.state.SetInt(2);
|
||||
a.date.SetInt(SystemTime.Now());
|
||||
EventHandler.SendNetworkEvent("swwmachievement."..a.basename,consoleplayer);
|
||||
let notif = new("SWWMAchievementNotification").Init(a.basename,a.icon,a.hasformat?a.maxval:0);
|
||||
StatusBar.AttachMessage(notif,-3478);
|
||||
|
|
|
|||
|
|
@ -112,6 +112,66 @@ Class OptionMenuItemSWWMVoiceOption : OptionMenuItemOptionBase
|
|||
}
|
||||
}
|
||||
|
||||
Class OptionMenuItemSWWMPlayTime : OptionMenuItem
|
||||
{
|
||||
CVar mCVar;
|
||||
bool dformat; // switch between short form and long form time display
|
||||
|
||||
OptionMenuItemSWWMPlayTime Init( String label, Name command )
|
||||
{
|
||||
Super.Init(label,command);
|
||||
return self;
|
||||
}
|
||||
|
||||
override bool MenuEvent( int mkey, bool fromcontroller )
|
||||
{
|
||||
if ( (mkey == Menu.MKEY_Left) || (mkey == Menu.MKEY_Right) || (mkey == Menu.MKEY_Enter) )
|
||||
dformat = !dformat;
|
||||
else return Super.MenuEvent(mkey,fromcontroller);
|
||||
Menu.MenuSound("menu/change");
|
||||
return true;
|
||||
}
|
||||
|
||||
override int Draw( OptionMenuDescriptor desc, int y, int indent, bool selected )
|
||||
{
|
||||
drawLabel(indent,y,selected?OptionMenuSettings.mFontColorSelection:OptionMenuSettings.mFontColor);
|
||||
int val = swwm_playtime;
|
||||
int sec = (val%60);
|
||||
int min = ((val/60)%60);
|
||||
int hour = ((val/3600)%24);
|
||||
int day = val/86400;
|
||||
String str = "";
|
||||
if ( dformat )
|
||||
{
|
||||
if ( day ) str.AppendFormat("%d %s",day,StringTable.Localize("$SWWM_TIME_DAYS"));
|
||||
if ( hour )
|
||||
{
|
||||
if ( str != "" ) str = str..", ";
|
||||
str.AppendFormat("%d %s",hour,StringTable.Localize("$SWWM_TIME_HOURS"));
|
||||
}
|
||||
if ( min )
|
||||
{
|
||||
if ( str != "" ) str = str..", ";
|
||||
str.AppendFormat("%d %s",min,StringTable.Localize("$SWWM_TIME_MINUTES"));
|
||||
}
|
||||
if ( sec )
|
||||
{
|
||||
if ( str != "" ) str = str..", ";
|
||||
str.AppendFormat("%d %s",sec,StringTable.Localize("$SWWM_TIME_SECONDS"));
|
||||
}
|
||||
if ( str == "" ) str.AppendFormat("0 %s",StringTable.Localize("$SWWM_TIME_SECONDS"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( day ) str = String.Format("%d:%02d:%02d:%02d",day,hour,min,sec);
|
||||
else if ( hour ) str = String.Format("%d:%02d:%02d",hour,min,sec);
|
||||
else str = String.Format("%d:%02d",min,sec);
|
||||
}
|
||||
drawValue(indent,y,OptionMenuSettings.mFontColorValue,str);
|
||||
return indent;
|
||||
}
|
||||
}
|
||||
|
||||
// option menu /w tooltips
|
||||
Class SWWMOptionMenu : OptionMenu
|
||||
{
|
||||
|
|
|
|||
|
|
@ -205,11 +205,7 @@ Class SWWMStaticHandler : StaticEventHandler
|
|||
Console.Printf("swwm_progress_"..achievements[i].basename.."="..achievements[i].progress.GetString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override void NetworkProcess( ConsoleEvent e )
|
||||
{
|
||||
if ( e.Name ~== "swwmgetversion" )
|
||||
else if ( e.Name ~== "swwmgetversion" )
|
||||
{
|
||||
let ti = ThinkerIterator.Create("SWWMSaveVerData",Thinker.STAT_STATIC);
|
||||
let svd = SWWMSaveVerData(ti.Next());
|
||||
|
|
@ -217,8 +213,11 @@ Class SWWMStaticHandler : StaticEventHandler
|
|||
else Console.Printf("\cg(no version data)\c-");
|
||||
if ( tainted ) Console.Printf("\cgversion mismatched\c-");
|
||||
else Console.Printf("\cdversion not mismatched\c-");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
override void NetworkProcess( ConsoleEvent e )
|
||||
{
|
||||
if ( e.IsManual ) return;
|
||||
if ( e.Name.Left(12) ~== "swwmversion." )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ enum EDoExplosionFlags
|
|||
Class SWWMAchievement
|
||||
{
|
||||
String basename;
|
||||
transient CVar state, progress;
|
||||
transient CVar state, progress, date;
|
||||
TextureID icon;
|
||||
int maxval;
|
||||
bool hasformat;
|
||||
|
|
@ -57,7 +57,6 @@ Class SWWMUtility
|
|||
let ac = new("SWWMAchievement");
|
||||
ac.basename = ln[0];
|
||||
ac.maxval = ln[1].ToInt();
|
||||
ac.hasformat = (ln[2]~=="yes");
|
||||
ac.state = CVar.FindCVar("swwm_achievement_"..ac.basename);
|
||||
// if filtering, always hide the full completion achievement until it's unlocked
|
||||
if ( filter && (ac.basename == "everything") && (ac.state.GetInt() <= 0) )
|
||||
|
|
@ -87,15 +86,17 @@ Class SWWMUtility
|
|||
}
|
||||
}
|
||||
else ac.progress = null;
|
||||
ac.icon = TexMan.CheckForTexture("graphics/Achievements/Achievement"..ac.basename..".png",TexMan.Type_Any);
|
||||
// fallback icon if one is not found
|
||||
if ( !ac.icon.IsValid() ) ac.icon = TexMan.CheckForTexture("graphics/Achievements/DefaultAchievement.png",TexMan.Type_Any);
|
||||
// hide away achievements at 0%
|
||||
if ( hide && (ac.state.GetInt() <= 0) && (!ac.progress || (ac.progress.GetInt() <= 0)) )
|
||||
{
|
||||
ac.Destroy();
|
||||
continue;
|
||||
}
|
||||
ac.hasformat = (ln[2]~=="yes");
|
||||
ac.icon = TexMan.CheckForTexture("graphics/Achievements/Achievement"..ac.basename..".png",TexMan.Type_Any);
|
||||
// fallback icon if one is not found
|
||||
if ( !ac.icon.IsValid() ) ac.icon = TexMan.CheckForTexture("graphics/Achievements/DefaultAchievement.png",TexMan.Type_Any);
|
||||
ac.date = CVar.FindCVar("swwm_unlockdate_"..ac.basename);
|
||||
achievements.Push(ac);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue