swwmgz_m/zscript/swwm_options.zsc
Marisa Kirisame eb2ee7b29f Push to master all the current WIP stuff in 0.9.11b:
- Reduce number of collectibles (some might come back in the future).
 - Merge both DLC weaponsets into one, removing redundant weapons.
 - Readjust prices of some items.
 - Initial work on collectibles (currently Frispy Corn is done).
 - Added bigfont for main menu, based on Source Han Sans.
 - Reduced default HUD margin to 10.
 - Added blob shadows.
 - Added precise crosshair drawing.
 - Tweaked decals, imported more stuff from UT.
 - Swapped the Ynykron impact decal for something better.
 - Fixes to slope alignment code.
 - Implemented headpats for MBF Helper Dogs and Cacodemons.
 - Implemented partial HDoom support, with love and headpats.
 - Fix various string functions breaking on unicode.
 - Added cracktro-style text scroll to Titlemap.
 - Fixed handling of healthbars for friendly monsters.
 - Workaround for maps that use the old author name hack (" - by: " separator).
 - Fixed Silver Bullet not autoswitching on first pickup.
 - Fixed misalignment of Silver Bullet zoomed aim.
 - Silver Bullet is unchambered on first pickup, consistent with Candygun.
 - Adjusted collision sizes of all items across the board.
 - Implemented "Use To Pickup" to work around any issues introduced by the previous change.
 - Swapped CHANF_LOOPING for CHANF_LOOP in many cases, this was a typo.
 - Tweaked Biospark arc lengths, for balance and higher performance.
 - Fix misaligned fire offsets of some weapons (most noticeable on Wallbuster).
 - Prettified the loading disclaimers for BD and HDoom.
 - Add pickup flash to all items.
 - Add custom key models for Doom and Heretic.
 - Fix blown kisses giving you "need key" messages.
 - Fix worn armor and embiggeners not being removed on scripted inventory resets.
 - Remove all references to the no longer planned Radio.
 - Workaround for gzdoom devbuild quirk where MenuSound changed its argument type.
 - Added timezone to fake clock.
 - Fix some times and dates in said clock.
 - SWWM blood now also hits ceilings.
 - Added default properties to DLC ammo and weapon stubs.
 - Lore entries for collectibles and dlc weapons (incomplete).
 - Massive amount of typo fixes across the board.
2020-10-20 11:37:14 +02:00

472 lines
16 KiB
Text

// Menu stuff
// voice selector
Class OptionMenuItemSWWMVoiceOption : OptionMenuItemOptionBase
{
CVar mCVar;
Array<String> types;
OptionMenuItemSWWMVoiceOption Init( String label, Name command, CVar graycheck = null, int center = 0 )
{
Super.Init(label,command,'',graycheck,center);
mCVar = CVar.FindCVar(mAction);
int lmp;
for ( lmp = Wads.FindLump("swwmvoicepack.txt"); lmp > 0; lmp = Wads.FindLump("swwmvoicepack.txt",lmp+1) )
{
Array<String> lst;
lst.Clear();
String dat = Wads.ReadLump(lmp);
dat.Split(lst,"\n",0);
for ( int i=0; i<lst.Size(); i++ )
{
if ( (lst[i].Length() <= 0) || (lst[i].GetNextCodePoint(0) == 0) || (lst[i].Left(1) == "\n") || (lst[i].Left(1) == "#") ) continue;
types.Push(lst[i]);
}
}
return self;
}
override bool SetString( int i, String newtext )
{
if ( i == OP_VALUES )
{
int cnt = types.Size();
if ( cnt >= 0 )
{
mValues = newtext;
int s = GetSelection();
if ( (s >= cnt) || (s < 0) ) s = 0;
SetSelection(s);
return true;
}
}
return false;
}
override int GetSelection()
{
int Selection = -1;
int cnt = types.Size();
if ( (cnt > 0) && mCVar )
{
String cv = mCVar.GetString();
for( int i=0; i<cnt; i++ )
{
if ( cv ~== types[i] )
{
Selection = i;
break;
}
}
}
return Selection;
}
override void SetSelection( int Selection )
{
int cnt = types.Size();
if ( (cnt > 0) && mCVar )
mCVar.SetString(types[Selection]);
}
override int Draw( OptionMenuDescriptor desc, int y, int indent, bool selected )
{
if ( mCenter ) indent = (screen.GetWidth()/2);
drawLabel(indent,y,selected?OptionMenuSettings.mFontColorSelection:OptionMenuSettings.mFontColor,isGrayed());
int Selection = GetSelection();
String loc;
if ( Selection == -1 ) loc = "Unknown";
else
{
String uptxt = types[Selection];
uptxt.MakeUpper();
String str = String.Format("SWWM_VOICENAME_%s",uptxt);
loc = StringTable.Localize(str,false);
if ( str == loc ) loc = types[Selection];
}
drawValue(indent,y,OptionMenuSettings.mFontColorValue,loc,isGrayed());
return indent;
}
override bool MenuEvent( int mkey, bool fromcontroller )
{
int cnt = types.Size();
if ( cnt > 0 )
{
int Selection = GetSelection();
if ( mkey == Menu.MKEY_Left )
{
if ( Selection == -1 ) Selection = 0;
else if ( --Selection < 0 ) Selection = cnt-1;
}
else if ( (mkey == Menu.MKEY_Right) || (mkey == Menu.MKEY_Enter) )
{
if ( ++Selection >= cnt ) Selection = 0;
}
else return OptionMenuItem.MenuEvent(mkey,fromcontroller);
SetSelection(Selection);
Menu.MenuSound("menu/change");
}
else return OptionMenuItem.MenuEvent(mkey,fromcontroller);
return true;
}
}
// option menu /w tooltips
Class SWWMOptionMenu : OptionMenu
{
private String ttip;
transient CVar lang;
transient Font TewiFont, MPlusFont;
override void Ticker()
{
Super.Ticker();
// fetch the tooltip for whatever's selected (if any)
if ( mDesc.mSelectedItem == -1 ) return;
String mcvar = mDesc.mItems[mDesc.mSelectedItem].GetAction();
mcvar.Replace(" ","_"); // need to strip whitespace for command actions
String locstr = String.Format("TOOLTIP_%s",mcvar);
ttip = StringTable.Localize(locstr,false);
if ( ttip == locstr ) ttip = "";
}
override void Drawer()
{
Super.Drawer();
if ( ttip == "" ) return;
// re-evaluate y to check where the cursor is
int cy = 0;
int y = mDesc.mPosition;
if ( y <= 0 )
{
let font = generic_ui||!mDesc.mFont?NewSmallFont:mDesc.mFont;
if ( font && (mDesc.mTitle.Length() > 0) )
y = -y+font.GetHeight();
else y = -y;
}
int fontheight = OptionMenuSettings.mLinespacing*CleanYfac_1;
y *= CleanYfac_1;
int lastrow = Screen.GetHeight()-OptionHeight()*CleanYfac_1;
for ( int i=0; ((i < mDesc.mItems.Size()) && (y <= lastrow)); i++ )
{
// Don't scroll the uppermost items
if ( i == mDesc.mScrollTop )
{
i += mDesc.mScrollPos;
if ( i >= mDesc.mItems.Size() ) break; // skipped beyond end of menu
}
y += fontheight;
if ( mDesc.mSelectedItem == i )
{
cy = y;
break;
}
}
if ( !TewiFont ) TewiFont = Font.GetFont('Tewi');
if ( !MPlusFont ) MPlusFont = Font.GetFont('MPlus');
if ( !lang ) lang = CVar.GetCVar('language',players[consoleplayer]);
Font fnt = TewiFont;
if ( lang.GetString() ~== "jp" ) fnt = MPlusFont;
let lines = fnt.BreakLines(ttip,CleanWidth_1-8);
int height = (8+fnt.GetHeight()*lines.Count())*CleanYFac_1;
// draw at the bottom unless the selected option could is covered by the tooltip
int ypos = Screen.GetHeight()-height;
if ( cy >= ypos ) ypos = 0;
Screen.Dim("Black",.75,0,ypos,Screen.GetWidth(),height);
ypos += 4*CleanYFac_1;
for ( int i=0; i<lines.Count(); i++ )
{
Screen.DrawText(fnt,Font.CR_WHITE,4*CleanXFac_1,ypos,lines.StringAt(i),DTA_CleanNoMove_1,true);
ypos += fnt.GetHeight()*CleanYFac_1;
}
}
}
// main menu w/ version info
Class SWWMMainMenu : ListMenu
{
transient Font TewiFont;
override void Drawer()
{
Super.Drawer();
int xx, yy;
if ( !TewiFont ) TewiFont = Font.GetFont('TewiShaded');
String str = StringTable.Localize("$SWWM_MODVER");
int width = TewiFont.StringWidth(str)+8;
int height = TewiFont.GetHeight()+4;
xx = CleanWidth_1-width;
yy = CleanHeight_1-height;
Screen.Dim("Black",.75,int(xx*CleanXFac_1),int(yy*CleanYFac_1),int(width*CleanXFac_1),int(height*CleanYFac_1));
Screen.DrawText(TewiFont,Font.CR_GOLD,(xx+4)*CleanXFac_1,(yy+2)*CleanYFac_1,str,DTA_CleanNoMove_1,true);
}
}
// scaled SWWM GZ logo
class ListMenuItemSWWMLogo : ListMenuItem
{
TextureID mTexture;
void Init( ListMenuDescriptor desc, TextureID patch )
{
Super.Init(desc.mXpos,desc.mYpos);
mTexture = patch;
}
// the old way
override void Drawer( bool selected )
{
if ( !mTexture.Exists() )
return;
Vector2 vs = TexMan.GetScaledSize(mTexture);
double x = (320-vs.x)/2;
Screen.DrawTexture(mTexture,false,x,-48,DTA_Clean,true);
}
// FIXME The 4.5+ way - swap out for this once it's done
/*override void Draw( bool selected, ListMenuDescriptor desc )
{
if ( !mTexture.Exists() )
return;
int w = desc?desc.DisplayWidth():ListMenuDescriptor.CleanScale;
int h = desc?desc.DisplayHeight():-1;
Vector2 vs = TexMan.GetScaledSize(mTexture);
double x;
if ( w == ListMenuDescriptor.CleanScale )
{
x = (320-vs.x)/2;
Screen.DrawTexture(mTexture,false,x,-48,DTA_Clean,true);
}
else
{
x = (w-vs.x)/2;
Screen.DrawTexture(mTexture,false,x,-48,DTA_VirtualWidth,w,DTA_VirtualHeight,h,DTA_FullscreenScale,FSMode_ScaleToFit43);
}
}*/
}
// message box that enforces newsmallfont and changes text color to match menus
Class SWWMMessageBox : MessageBoxMenu
{
override void Init( Menu parent, String message, int messagemode, bool playsound, Name cmd, voidptr native_handler )
{
Super.Init(parent,message,messagemode,playsound,cmd,native_handler);
textFont = arrowFont = newsmallfont;
destWidth = CleanWidth;
destHeight = CleanHeight;
selector = "▶";
int mr1 = 170+textFont.StringWidth(Stringtable.Localize("$TXT_YES"));
int mr2 = 170+textFont.StringWidth(Stringtable.Localize("$TXT_NO"));
mMouseRight = max(mr1,mr2);
mMessage = textFont.BreakLines(Stringtable.Localize(message), 300);
}
override void Drawer()
{
int fontheight = textFont.GetHeight();
int y = 100;
int c = mMessage.Count();
y -= c*fontHeight/2;
for ( int i=0; i<c; i++ )
{
Screen.DrawText(textFont,OptionMenuSettings.mFontColorValue,160-mMessage.StringWidth(i)/2,y, mMessage.StringAt(i),DTA_Clean,true);
y += fontheight;
}
if ( mMessageMode != 0 ) return;
y += fontheight;
mMouseY = y;
Screen.DrawText(textFont,messageSelection==0?OptionMenuSettings.mFontColorSelection:OptionMenuSettings.mFontColor,160,y,Stringtable.Localize("$TXT_YES"),DTA_Clean,true);
Screen.DrawText(textFont,messageSelection==1?OptionMenuSettings.mFontColorSelection:OptionMenuSettings.mFontColor,160,y+fontheight+1,Stringtable.Localize("$TXT_NO"),DTA_Clean,true);
if ( messageSelection < 0 ) return;
if ( (MenuTime()%8) < 6 )
Screen.DrawText(arrowFont,OptionMenuSettings.mFontColorSelection,(150-160)*CleanXfac+Screen.GetWidth()/2,(y+(fontheight+1)*messageSelection-100+fontheight/2-5)*CleanYfac+Screen.GetHeight()/2,selector,DTA_CellX,8*CleanXfac,DTA_CellY,8*CleanYfac);
}
// FIXME the 4.5+ way - swap out for this once it's done
/*override void Init( Menu parent, String message, int messagemode, bool playsound, Name cmd, voidptr native_handler )
{
Super.Init(parent,message,messagemode,playsound,cmd,native_handler);
textFont = arrowFont = newsmallfont;
destWidth = CleanWidth;
destHeight = CleanHeight;
selector = "▸";
int mr1 = destWidth/2+10+textFont.StringWidth(Stringtable.Localize("$TXT_YES"));
int mr2 = destWidth/2+10+textFont.StringWidth(Stringtable.Localize("$TXT_NO"));
mMouseRight = max(mr1,mr2);
mMessage = textFont.BreakLines(Stringtable.Localize(message),int(300/NotifyFontScale));
}
override void Drawer()
{
let fontheight = textFont.GetHeight()*NotifyFontScale;
double y = destHeight/2;
int c = mMessage.Count();
y -= c*fontHeight/2;
for ( int i=0; i<c; i++ )
{
Screen.DrawText(textFont,OptionMenuSettings.mFontColorValue,destWidth/2-mMessage.StringWidth(i)*NotifyFontScale/2,y,mMessage.StringAt(i),DTA_VirtualWidth,destWidth, DTA_VirtualHeight,destHeight,DTA_KeepRatio,true,DTA_ScaleX,NotifyFontScale,DTA_ScaleY,NotifyFontScale);
y += fontheight;
}
if ( mMessageMode != 0 ) return;
y += fontheight;
mMouseY = int(y);
Screen.DrawText(textFont,messageSelection==0?OptionMenuSettings.mFontColorSelection:OptionMenuSettings.mFontColor,destWidth/2,y,Stringtable.Localize("$TXT_YES"), DTA_VirtualWidth,destWidth,DTA_VirtualHeight,destHeight,DTA_KeepRatio,true,DTA_ScaleX,NotifyFontScale,DTA_ScaleY,NotifyFontScale);
Screen.DrawText(textFont,messageSelection==1?OptionMenuSettings.mFontColorSelection:OptionMenuSettings.mFontColor,destWidth/2,y+fontheight, Stringtable.Localize("$TXT_NO"),DTA_VirtualWidth,destWidth,DTA_VirtualHeight,destHeight,DTA_KeepRatio,true,DTA_ScaleX,NotifyFontScale,DTA_ScaleY,NotifyFontScale);
if ( messageSelection < 0 ) return;
if ( (MenuTime()%8) < 6 )
Screen.DrawText(arrowFont,OptionMenuSettings.mFontColorSelection,destWidth/2-11,y+fontheight*messageSelection,selector,DTA_VirtualWidth,destWidth, DTA_VirtualHeight,destHeight,DTA_KeepRatio,true);
}*/
}
// main menu item with wiggly text when selected and Demo face selectors on both sides
class ListMenuItemSWWMTextItemM : ListMenuItemSelectable
{
String mText;
Font mFont;
void Init( ListMenuDescriptor desc, String text, String hotkey, Name child, int param = 0 )
{
Super.Init(desc.mXpos,desc.mYpos,desc.mLinespacing,child,param);
mText = text;
mFont = desc.mFont;
mHotkey = hotkey.GetNextCodePoint(0);
}
override int GetWidth()
{
return max(1,mFont.StringWidth(StringTable.Localize(mText)));
}
override void Drawer( bool selected )
{
String text = StringTable.Localize(mText);
// centered
double x = (320-mFont.StringWidth(text))/2;
double y = mYPos-12; // text needs to be offset up for some reason, otherwise doesn't match mouse selection bounds
if ( selected )
{
double xx = x;
int tlen = text.CodePointCount();
for ( int i=0, pos=0; i<tlen; i++ )
{
int ch;
[ch, pos] = text.GetNextCodePoint(pos);
double yy = y+4*sin(32*i+8*Menu.MenuTime());
Screen.DrawChar(mFont,Font.CR_SAPPHIRE,xx,yy,ch,DTA_Clean,true);
xx += mFont.GetCharWidth(ch)-2; // account for menu font kerning
}
}
else Screen.DrawText(mFont,Font.CR_WHITE,x,y,text,DTA_Clean,true);
}
override void DrawSelector( double xofs, double yofs, TextureID tex )
{
if ( tex.isNull() ) return;
double x = (320-GetWidth())/2;
Screen.DrawTexture(tex,true,x+xofs,mYpos+yofs,DTA_Clean,true,DTA_CenterOffset,true);
x = (320+GetWidth())/2;
Screen.DrawTexture(tex,true,x-xofs,mYpos+yofs,DTA_Clean,true,DTA_CenterOffset,true);
}
// FIXME The 4.5+ way - swap out for this once it's done
/*override void Draw( bool selected, ListMenuDescriptor desc )
{
int w = desc?desc.DisplayWidth():ListMenuDescriptor.CleanScale;
int h = desc?desc.DisplayHeight():-1;
String text = StringTable.Localize(mText);
double x;
// centered
if ( w == ListMenuDescriptor.CleanScale ) x = (320-mFont.StringWidth(text))/2;
else x = (w-mFont.StringWidth(text))/2;
double y = mYPos-12; // text needs to be offset up for some reason, otherwise doesn't match mouse selection bounds
if ( selected )
{
double xx = x;
int tlen = text.CodePointCount();
if ( w == ListMenuDescriptor.CleanScale )
{
for ( int i=0, pos=0; i<tlen; i++ )
{
int ch;
[ch, pos] = text.GetNextCodePoint(pos);
double yy = y+4*sin(32*i+8*Menu.MenuTime());
Screen.DrawChar(mFont,Font.CR_SAPPHIRE,xx,yy,ch,DTA_Clean,true);
xx += mFont.GetCharWidth(ch)-2; // account for menu font kerning
}
}
else
{
for ( int i=0, pos=0; i<tlen; i++ )
{
int ch;
[ch, pos] = text.GetNextCodePoint(pos);
double yy = y+4*sin(32*i+8*Menu.MenuTime());
Screen.DrawChar(mFont,Font.CR_SAPPHIRE,xx,yy,ch,DTA_VirtualWidth,w,DTA_VirtualHeight,h,DTA_FullscreenScale,FSMode_ScaleToFit43);
xx += mFont.GetCharWidth(ch)-2; // account for menu font kerning
}
}
}
else
{
if ( w == ListMenuDescriptor.CleanScale )
Screen.DrawText(mFont,Font.CR_WHITE,x,y,text,DTA_Clean,true);
else
Screen.DrawText(mFont,Font.CR_WHITE,x,y,text,DTA_VirtualWidth,w,DTA_VirtualHeight,h,DTA_FullscreenScale,FSMode_ScaleToFit43);
}
}
override void DrawSelector( double xofs, double yofs, TextureID tex, ListMenuDescriptor desc )
{
if ( tex.isNull() ) return;
int w = desc?desc.DisplayWidth():ListMenuDescriptor.CleanScale;
int h = desc?desc.DisplayHeight():-1;
if ( w == ListMenuDescriptor.CleanScale )
{
double x = (320-GetWidth())/2;
Screen.DrawTexture(tex,true,x+xofs,mYpos+yofs,DTA_Clean,true,DTA_CenterOffset,true,DTA_Rotate,15.*sin(8*Menu.MenuTime()));
x = (320+GetWidth())/2;
Screen.DrawTexture(tex,true,x-xofs,mYpos+yofs,DTA_Clean,true,DTA_CenterOffset,true,DTA_Rotate,-15.*sin(8*Menu.MenuTime()));
}
else
{
double x = (w-GetWidth())/2;
Screen.DrawTexture(tex,true,x+xofs,mYpos+yofs,DTA_VirtualWidth,w,DTA_VirtualHeight,h,DTA_FullscreenScale,FSMode_ScaleToFit43,DTA_CenterOffset,true,DTA_Rotate,15.*sin(8*Menu.MenuTime()));
x = (w+GetWidth())/2;
Screen.DrawTexture(tex,true,x-xofs,mYpos+yofs,DTA_VirtualWidth,w,DTA_VirtualHeight,h,DTA_FullscreenScale,FSMode_ScaleToFit43,DTA_CenterOffset,true,DTA_Rotate,-15.*sin(8*Menu.MenuTime()));
}
}*/
}
// FIXME uncomment this once it's supported
/*Class SWWMMenuDelegate : DoomMenuDelegate
{
transient CVar lang;
transient Font TewiFont, MPlusFont, SWWMBigFont;
override int DrawCaption( String title, Font fnt, int y, bool drawit )
{
// forcibly use our bigfont here
// somehow it doesn't get overriden when using PickFont()
// most likely because of pointer poopery
// could we get a function for fetching a font's name, graf?
if ( !SWWMBigFont ) SWWMBigFont = Font.GetFont('SWWMBigFont');
return Super.DrawCaption(title,SWWMBigFont,y,drawit);
}
// this doesn't seem to always work?
override Font PickFont( Font fnt )
{
if ( !lang ) lang = CVar.GetCVar('language',players[consoleplayer]);
if ( !TewiFont ) TewiFont = Font.GetFont('TewiShaded');
if ( !MPlusFont ) MPlusFont = Font.GetFont('MPlusShaded');
if ( !SWWMBigFont ) SWWMBigFont = Font.GetFont('SWWMBigFont');
if ( (fnt == SmallFont) || (fnt == SmallFont2) || (fnt == AlternativeSmallFont) || (fnt == NewSmallFont) || !fnt )
{
if ( lang.GetString() ~== "jp" ) return MPlusFont;
return TewiFont;
}
if ( (fnt == BigFont) || (fnt == AlternativeBigFont) || (fnt == OriginalBigFont) || (fnt == IntermissionFont) ) return SWWMBigFont;
return fnt;
}
}*/