swwmgz_m/zscript/kbase/swwm_kbase.zsc

136 lines
3.5 KiB
Text

// internal "knowledge base" and more
Class MenuTransaction
{
enum ETransactionType
{
TT_ITEMUSE,
TT_ITEMDROP,
TT_ITEMSEND
};
int uid, type;
Class<Inventory> used;
bool result, usedup;
}
Class DemolitionistMenu : GenericMenu
{
transient Font TewiFont, MPlusFont, MiniwiFont, k6x8Font;
// temporary bottom messages, such as "not enough money"
String tmsg;
int tmsgtic;
// bottom clock
String clockstr;
// menu keybind
int ikey[2];
String mkey[2];
// for checks (duh)
Array<MenuTransaction> checklist;
int lasttuid;
SWWMHandler hnd;
// seeeeecret
int kcode;
// crimey clock stuff
int c_year, c_month, c_day, c_hour, c_minute;
String c_tz;
// somehow Drawer can be called while closing prematurely, which is big bollocks
bool isclosing;
// returns MPlus if we're playing in Japanese, otherwise returns the requested font
Font LangFont( Font req )
{
if ( language ~== "jp" ) return (req==MiniwiFont)?k6x8Font:MPlusFont;
return req;
}
int GenTUID()
{
return lasttuid++;
}
override void Init( Menu parent )
{
Super.Init(parent);
if ( (gamestate != GS_LEVEL) || (players[consoleplayer].Health <= 0) || !(players[consoleplayer].mo is 'Demolitionist') )
{
// can't open this menu outside of the game or if dead
// also can't if you're not the Demolitionist
EventHandler.SendNetworkEvent("swwmclearalltransactions",consoleplayer);
isclosing = true;
return;
}
// TODO initialize base graphics here
TewiFont = Font.GetFont('TewiShaded');
MPlusFont = Font.GetFont('MPlusShaded');
MiniwiFont = Font.GetFont('MiniwiShaded');
k6x8Font = Font.GetFont('k6x8Shaded');
MenuSound("menu/demoopen");
[ikey[0], ikey[1]] = Bindings.GetKeysForCommand("event swwmdemomenu");
mkey[0] = Bindings.NameKeys(ikey[0],0);
mkey[1] = Bindings.NameKeys(ikey[1],0);
tmsg = StringTable.Localize("$SWWM_MAINCONTROLS");
tmsgtic = gametic+70;
lasttuid = Random[TUID]();
hnd = SWWMHandler(EventHandler.Find("SWWMHandler"));
SetClock();
// TODO initialize tabs here
}
override bool MenuEvent( int mkey, bool fromcontroller )
{
switch ( mkey )
{
case MKEY_BACK:
MenuSound("menu/democlose");
EventHandler.SendNetworkEvent("swwmclearalltransactions",consoleplayer);
Close();
return true;
}
return Super.MenuEvent(mkey,fromcontroller);
}
override void Ticker()
{
Super.Ticker();
if ( (gamestate != GS_LEVEL) || (players[consoleplayer].Health <= 0) || isclosing )
{
// ded (or force close)
EventHandler.SendNetworkEvent("swwmclearalltransactions",consoleplayer);
Close();
return;
}
if ( swwm_menupause ) menuactive = Menu.On;
else menuactive = Menu.OnNoPause;
// forcibly tick hud (mainly so interpolators can still update in the background)
if ( !multiplayer && (menuactive == Menu.On) )
StatusBar.Tick();
CheckTransactions();
// update time string
clockstr = CrimeTime();
}
override bool OnUiEvent( UIEvent ev )
{
switch ( ev.type )
{
case UIEvent.Type_KeyDown:
if( (ikey[0] && (ev.keystring == mkey[0])) || (ikey[1] && (ev.keystring == mkey[1])) )
{
MenuSound("menu/democlose");
EventHandler.SendNetworkEvent("swwmclearalltransactions",consoleplayer);
Close();
return true;
}
break;
}
return Super.OnUiEvent(ev);
}
override void Drawer()
{
if ( isclosing ) return;
Font fnt = LangFont(TewiFont);
String str = "NEW DEMOLITIONIST MENU IS UNDER CONSTRUCTION";
Screen.DrawText(fnt,Font.CR_RED,(Screen.GetWidth()-fnt.StringWidth(str)*CleanXFac_1)/2,(Screen.GetHeight()-fnt.GetHeight()*CleanYFac_1)/2,str,DTA_CleanNoMove_1,true);
}
}