Re: How To: ZSCRIPT MENUS?

Funny, because you coded it that way that if the menu processes an event it won't get passed on to the event handler.
// this is magic and I have no idea where it runs from, just null it here
override bool MenuEvent(int mkey, bool fromcontroller)
{
if (e && e.MenuEvent(mkey, fromcontroller))
return true;
return Menu.MenuEvent(mkey, fromcontroller);
}
Struct ButtonState
{
int mRenderStyle;
Color mColor;
double mAlpha;
TextureID mTex;
String text;
int fontColor;
double textAlpha;
void Init()
{
mRenderStyle = STYLE_Normal;
mColor = (255, 255, 255, 255);
mAlpha = 1.0;
mTex = null;
text = "";
fontColor = Font.CR_RED;
textAlpha = 1.0;
}
bool SetProperties(TextureID tex, String tx = "", int style = -1, double ta = -1.0, int r = -1, int g = -1, int b = -1)
{
mTex = TexMan.CheckForTexture(tex, TexMan.Type_Any);
if (ta >= 0.0) mAlpha = ta;
if (r >= 0) mColor.r = Clamp(r, 0, 255);
if (g >= 0) mColor.g = Clamp(g, 0, 255);
if (b >= 0) mColor.b = Clamp(b, 0, 255);
if (style >= 0) mRenderStyle = style;
text = tx;
return mTex != null;
}
}
ButtonState mButtonUp;
ButtonState mButtonDown;
ButtonState mButtonHover;
ButtonState mButtonDisabled;
void DrawButton(ButtonState b, bool animated, double x, double y)
{
Screen.DrawTexture(b.mTex, animated, VirtualX+x, VirtualY+y,
DTA_VirtualWidthF, VirtualWidth,
DTA_VirtualHeightF, VirtualHeight,
DTA_KeepRatio, true,
DTA_ClipTop, int(ClipTop),
DTA_ClipLeft, int(ClipLeft),
DTA_ClipBottom, int(ClipBottom),
DTA_ClipRight, int(ClipRight)
//,
//DTA_Alpha, b.mAlpha,
);
if (b.mAlpha <= 0.0) return;
Screen.DrawTexture(b.mTex, animated, VirtualX+x, VirtualY+y,
DTA_VirtualWidthF, VirtualWidth,
DTA_VirtualHeightF, VirtualHeight,
DTA_KeepRatio, true,
DTA_ClipTop, int(ClipTop),
DTA_ClipLeft, int(ClipLeft),
DTA_ClipBottom, int(ClipBottom),
DTA_ClipRight, int(ClipRight),
DTA_Alpha, b.mAlpha,
DTA_RenderStyle, b.mRenderStyle,
DTA_ColorOverlay, b.mColor
);
}
Script error, "PlayerMenu.pk7:menudef.txt" line 6:
Tried to replace menu 'Playermenu' with a menu of different type
ListMenu "PlayerMenu"
{
StaticTextCentered 160, 6, "This is a redefined player menu"
Class "NewPlayerMenu"
}
class NewPlayerMenu : PlayerMenu
{
override void Drawer()
{
Super.Drawer();
console.printf("New menu is being used!");
}
}
Major Cooke wrote:You probably can't replace it. You just have to make your own and inject it into the menu since it potentially still relies on internal code that's not exported (or exportable)
Spoiler: For size...
// All write function for the player config are native to prevent abuse.
protected native void AutoaimChanged(float val);
protected native void TeamChanged(int val);
protected native void AlwaysRunChanged(int val);
protected native void GenderChanged(int val);
protected native void SwitchOnPickupChanged(int val);
protected native void ColorChanged(int red, int green, int blue);
protected native void ColorSetChanged(int red);
protected native void PlayerNameChanged(String name);
protected native void SkinChanged (int val);
protected native void ClassChanged(int sel, PlayerClass cls);
ListMenu "PlayerMenu"
{
StaticTextCentered 160, 6, "$MNU_PLAYERSETUP"
Font "SmallFont"
Linespacing 14
Position 48, 36
IfGame (Doom, Strife, Chex)
{
PlayerNameBox "$PLYRMNU_NAME", 0, "Playerbox"
Selector "-", -16, -1
}
IfGame(Heretic, Hexen)
{
PlayerNameBox "$PLYRMNU_NAME", 5, "Playerbox"
Selector "-", -16, 1
}
IfGame(Doom, Heretic, Strife, Chex)
{
MouseWindow 0, 220
PlayerDisplay 220, 80, "20 00 00", "80 00 40", 1, "PlayerDisplay"
}
IfGame(Hexen)
{
MouseWindow 0, 220
PlayerDisplay 220, 80, "00 07 00", "40 53 40", 1, "PlayerDisplay"
}
ValueText "$PLYRMNU_TEAM", "Team"
ValueText "$PLYRMNU_PLAYERCOLOR", "Color"
Linespacing 10
Slider "$PLYRMNU_RED", "Red", 0, 255, 16
Slider "$PLYRMNU_GREEN", "Green", 0, 255, 16
Linespacing 14
Slider "$PLYRMNU_BLUE", "Blue", 0, 255, 16
ValueText "$PLYRMNU_PLAYERCLASS", "Class"
ValueText "$PLYRMNU_PLAYERSKIN", "Skin"
ValueText "$PLYRMNU_PLAYERGENDER", "Gender", "Gender"
Slider "$PLYRMNU_AUTOAIM", "Autoaim", 0, 35, 1
ValueText "$PLYRMNU_SWITCHONPICKUP", "Switch", "OffOn"
ValueText "$PLYRMNU_ALWAYSRUN", "AlwaysRun", "OnOff"
Class "PlayerMenu"
}
Class "PlayerMenu"
ListMenu "SkillMenu"
{
IfGame(Doom, Chex)
{
StaticPatch 96, 14, "M_NEWG"
}
IfGame(Strife)
{
StaticPatch 96, 14, "M_NGAME"
}
IfGame(Doom, Strife, Chex)
{
StaticPatch 54, 38, "M_SKILL"
Position 48, 63
}
IfGame (Heretic)
{
Position 38, 30
}
IfGame (Hexen)
{
StaticText 74, 16, "$MNU_CHOOSESKILL"
Position 160, 44
centermenu
}
}
ListMenu "EpisodeMenu"
{
IfGame(Doom, Heretic, Hexen, Strife)
{
NetgameMessage "$NEWGAME"
}
IfGame(Chex)
{
NetgameMessage "$CNEWGAME"
}
IfGame(Doom, Chex)
{
Position 48, 63
StaticPatch 54, 38, "M_EPISOD"
}
IfGame(Strife)
{
Position 48, 63
StaticText 54, 38, "$MNU_EPISODE"
}
IfGame(Heretic, Hexen)
{
Position 80, 50
}
// items will be filled in by MAPINFO
}