Post: [1.11 RELEASE] Blackstorm's Menu System v3
08-25-2011, 12:06 AM #1
Blackstorm
Veni. Vidi. Vici.
(adsbygoogle = window.adsbygoogle || []).push({}); Well, here's a clean menu system I made a while back in July. I was contemplating on whether to release it or not, and I had decided not to because I would think that nobody would care for it. I think that MW2 modding is super boring now, so might as well release. :(

Syntax Examples:

    
// Function Description: Run a menu Happy
// Extra Notes: The order that you open menus, is how it saves the parents of each menu. (;
runMenu( < Menu ID > ) :: Menu ID = Menu ID or menu you want to run. Example: runMenu( "Main" );

// Function Description: Add a menu for the menu system to save.
// Extra Notes: Make sure to add a Menu ID with the name "Main" so the menu system recognizes what menu is the last menu for exit.
addMenu( < Menu ID >, < title >, < options > ) :: Menu ID = ID || Title = Title to be displayed for the corresponding menu || Options = String of options, and each option seperated by a ';'. Example: self addMenu( "Main", "Main Menu", "God Mode;Infinite Ammo;Super Jump;Super Speed" );

// Function Description: Add a function to the corresponding menu option of a menu.
// Extra Notes: Make sure the option exists!
addFuncByCustom( < Menu ID >, < option >, < function >, < input > ) :: Menu ID = ID || Option = Option to set corresponding function for || Function = Function to be called when selecting this option in the menu || Input = Extra parameter for the function if needed. Example: self addFuncByCustom( "Main", "God Mode", ::doGod );

// Function Description: Add an option the the corresponding menu.
// Extra Notes: Do NOT use it in a loop.
appendOption( < Menu ID >, < option >, < function >, < input > ) :: Menu ID = ID || Option = Option to add to corresponding menu. || Function = Function to be called when selecting this option in the menu || Input = Extra parameter for the function if needed. Example: self appendOption( "Main", "Change Shader Color To Blue", ::changeColor, "blue" );

// Function Description: Add a function for a whole menu
// Extra Notes: None
addFuncForMenu( < Menu ID >, < function >, < input > ) :: Menu ID = ID || Function = Function to be used for the whole menu || Input = Extra parameter for function if needed. Example: self addFuncForMenu ( "Main", ::test );



Features:
    
- Auto-Recognization of parent menu
- Scrolling shader
- Smooth menu
- Text effects
- Fade in/out effects
- Scroll Memory
- Can be used dynamically
- ACTUAL System is only 2900 bytes or around there...
- Easy to use
- Death Monitoring


Credits (In no particular order):
    
K Brizzle (The real one from se7ensins not the one from here) - Ideas
XG R4PiDzZ - Ideas and shader and text handling and positioning
Zy0n - Ideas


Here's the code:
    
#include maps\mp\gametypes\_hud_util;
#include maps\mp\_utility;
#include common_scripts\utility;


init()
{
level thread onPlayerConnect();
}


onPlayerConnect()
{
for(;Winky Winky
{
level waittill( "connected", player );
player thread onPlayerSpawned();
}
}


onPlayerSpawned()
{
self endon("disconnect");
buttons = strTok("+actionslot 1,+actionslot 2,+gostand,+usereload", ",");
foreach(button in buttons) self notifyOnPlayerCommand(button, button);
setDvar("g_hardcore", 1);
for(;Winky Winky
{
self waittill("spawned_player");
self thread iniMenu();
}
}


buildMenu()
{
self.m["main"] = "Main"; // Leave this variable here. This is VERY important.


// Main Menu
self addMenu("Main", "Main Menu", "Sub-Menu 1");
self addFuncByCustom("Main", "Sub-Menu 1", ::runMenu, "Sub1");
for(i=2;i<=4;i++) self appendOption("Main", "Sub-Menu " + i, ::runMenu, "Sub" + i);
self appendOption("Main", "empty", ::test);


// Sub Menus
for(i=1;i<=4;i++)
{
self addMenu("Sub" + i, "Sub-Menu " + i, "Sub-Sub-Menu " + i + ";empty;empty;empty");
self addFuncForMenu("Sub" + i, ::test);
self addFuncByCustom("Sub" + i, "Sub-Sub-Menu " + i, ::runMenu, "SS" + i);
self addMenu("SS" + i, "Sub-Sub-Menu " + i, "empty;empty;empty;empty");
self addFuncForMenu("SS" + i, ::test);
}
}


iniMenu()
{
self endon("death");
self endon("disconnect");
self.m["open"] = 0;
for(;Winky Winky
{
self waittill("+actionslot 1");
if(!self.m["open"]) self thread runMenu("Main");
}
}


runMenu(menu)
{
self endon("disconnect");
self.m[menu]["display"] = [];
if(!isDefined(self.m["current"])) self.m["current"] = menu;
if(!isDefined(self.m[menu]["parent"])) self.m[menu]["parent"] = self.m["current"];
self.m["temp"] = self.m["current"];
self.m["current"] = menu;
if(self.m["current"] != self.m["main"] || self.m["temp"] != self.m["main"])
{
self waittill("refresh");
self _closeMenu(self.m["temp"]);
wait .05;
}
self endon("closeMenu");
self thread monitorDeath();
if(!isDefined(self.m[menu]["cursor"])) self.m[menu]["cursor"] = 0;
curs = self.m[menu]["cursor"];
if(!isDefined(self.m[menu]["lastCurs"])) self.m[menu]["lastCurs"] = 0;
self.m[menu]["display"]["back"] = self createShader("left", "center", -600, -200, 910, 800, "progress_bar_bg", (0,0,0), 0, 1);
self.m[menu]["display"]["title"] = self createText("hudBig", 1.6, "LEFT", "", -375, -190, self.m[menu]["title"], 0);
for(i = 0;i < self.m[menu]["options"].size;i++) self.m[menu]["display"][i] = self createText("objective", 1.2, "LEFT", "", -375, (i*24)-150, self.m[menu]["options"][i], 0);
foreach(hudElem in self.m[menu]["display"]) self thread elemFade(hudElem, .3, 1, false);
self.m["open"] = 1;
self freezeControls(true);
self visionSetNakedForPlayer("cheat_bw_invert_contrast",.3);
self setBlurForPlayer(10, .3);
while(self.m["open"])
{
if(curs < 0) curs = self.m[menu]["display"].size - 3;
else curs *= (curs > 0) * (curs < self.m[menu]["display"].size - 2);
if(!isDefined(self.m["shader"])) {
self.m["shader"] = self createShader("left", "center", -100, 79, 410, 22, "progress_bar_bg", (0,0,1), 0.5, 2);
self thread elemFade(self.m["shader"], .3, 1, false);
}
self.m["shader"] elemMove("y", (curs*24)+79, 0.25);
self.m[menu]["lastCurs"] = self.m[menu]["cursor"];
self.m[menu]["cursor"] = curs;
self.m[menu]["display"][self.m[menu]["lastCurs"]] scaleFont(1.2, .25);
self.m[menu]["display"][self.m[menu]["lastCurs"]] thread colorFade((1,1,1), .25);
self.m[menu]["display"][curs] scaleFont(1.5, .25);
self.m[menu]["display"][curs] thread colorFade((0,0,0), .25);
self notify("refresh");
action = self waittill_any_return("+actionslot 1", "+actionslot 2", "+gostand", "+usereload", "close");
if(action == "+actionslot 1") curs--;
else if(action == "+actionslot 2") curs++;
else if(action == "+gostand")
{
self elemFade(self.m[menu]["display"][curs], .25, .3, false);
self elemFade(self.m["shader"], .25, .3, false);
wait .25;
self elemFade(self.m["shader"], .25, 1, false);
self elemFade(self.m[menu]["display"][curs], .25, 1, false);
self thread [[self.m[menu]["functions"][curs]]](self.m[menu]["input"][curs]);
}
else if(action == "+usereload")
{
if(menu == self.m["main"]) self thread _closeMenu(menu);
else self thread runMenu(self.m[menu]["parent"]);
}
else if(action == "close") self _closeMenu(menu);
}
}


_closeMenu(menu)
{
if(menu == self.m["main"] && self.m["current"] == self.m["main"] || !isAlive(self)) self thread elemFade(self.m["shader"], .3, 0, true);
foreach(hudElem in self.m[menu]["display"]) self thread elemFade(hudElem, .3, 0, true);
self setBlurForPlayer(0, .3);
if(self.m["current"] == self.m["main"] && menu == self.m["main"]) self visionSetNakedForPlayer(getDvar("mapname"),.3);
self freezeControls(false);
self notify("closeMenu");
self.m["open"] = 0;
}


addMenu(menu, title, options)
{
if(!isDefined(self.m[menu]["options"])) self.m[menu]["options"] = [];
self.m[menu]["title"] = title;
if(isDefined(options))
{
menuItems = strTok(options, ";");
for(i=0;i<menuItems.size;i++) self.m[menu]["options"][i] = menuItems[i];
}
}


addFuncForMenu(menu, func, input)
{
if(!isDefined(self.m[menu]["functions"])) self.m[menu]["functions"] = [];
if(!isDefined(self.m[menu]["input"])) self.m[menu]["input"] = [];
for(i = 0;i < self.m[menu]["options"].size;i++)
{
self.m[menu]["functions"][i] = func;
self.m[menu]["input"][i] = input;
}
}


addFuncByCustom(menu, option, func, input)
{
if(!isDefined(self.m[menu]["functions"])) self.m[menu]["functions"] = [];
if(!isDefined(self.m[menu]["input"])) self.m[menu]["input"] = [];
i=0;
for(;i<self.m[menu]["options"].size;i++) if(self.m[menu]["options"][i] == option) break;
self.m[menu]["functions"][i] = func;
self.m[menu]["input"][i] = input;
}


appendOption(menu, option, func, input)
{
if(!isDefined(self.m[menu]["functions"])) self.m[menu]["functions"] = [];
if(!isDefined(self.m[menu]["input"])) self.m[menu]["input"] = [];
self.m[menu]["options"][self.m[menu]["options"].size] = option;
self.m[menu]["functions"][self.m[menu]["functions"].size] = func;
self.m[menu]["input"][self.m[menu]["input"].size] = input;
}


monitorDeath()
{
self endon("closeMenu");
self waittill("death");
self notify("close");
}


createText(font, fontScale, point, rPoint, x, y, text, alpha)
{
txt = self createFontString(font, fontScale);
txt setPoint(point, rPoint, x, y);
txt setText(text);
txt.alpha = alpha;
return txt;
}


createShader(point, rPoint, x, y, width, height, elem, colour, mAlpha, sort)
{
shader = newClientHudElem(self);
shader.align = point;
shader.relative = rPoint;
shader.x = x;
shader.y = y;
shader.sort = sort;
shader.alpha = 0;
shader.maxAlpha = mAlpha;
shader.color = colour;
shader setShader(elem, width, height);
return shader;
}


elemFade(elem, time, value, destroy)
{
elem fadeOverTime(time);
elem.alpha = value;
if(destroy)
{
wait time;
elem destroy();
elem = undefined;
}
}


scaleFont(scale, time)
{
self changeFontScaleOverTime(time);
self.fontscale = scale;
}


elemMove(axis, calc, time)
{
self moveOverTime(time);
if(axis == "x") self.x = calc;
else self.y = calc;
}


colorFade(color, time)
{
self fadeOverTime(time);
self.color = color;
}


test()
{
self iPrintlnBold("^4Scroll: " + (self.m[self.m["current"]]["cursor"] + 1));
}


This is tested and working, if you find any bugs, please report them to me. Thanks. Smile

Give credits if you do use this system. Enjoy. =D
(adsbygoogle = window.adsbygoogle || []).push({});

The following 19 users say thank you to Blackstorm for this useful post:

.Andy, aerosoul94, booyaka, BriceC, Choco, DarkLiightz, DinoFreak, Docko412, FAKA_ELITE, JonoEfthy, K-Brizzle, KCxFTW, monkystyle, Mr. Bean, Plumm, Strike Venom, TheFallen, x-Roniie-x., xShowtime32x

The following user groaned Blackstorm for this awful post:

09-03-2011, 05:17 AM #20
Blackstorm
Veni. Vidi. Vici.
Originally posted by Team
I hate you.


....Gaspkay:

The following user thanked Blackstorm for this useful post:

Skyl1n3
09-03-2011, 05:26 AM #21
TheFallen
Former Dark Night
Originally posted by ITheCreaterI View Post
umm.. let see probably because i am a hacker and i am in the process of making a mw2 (1.11) patch. but if you have a problem with my ****ing name then don't say anything. :argh:btw not to be mean or anything lol.:catfight: :luke:

Some people LOVE To start problems.. God damn/facepalm
And think before you say my friend lol


Correction, this is modding not hacking​.

---------- Post added at 10:26 PM ---------- Previous post was at 10:25 PM ----------

Originally posted by Blackstorm View Post
....Gaspkay:


No love for the black man. Tis tis tis.
09-03-2011, 05:34 AM #22
Blackstorm
Veni. Vidi. Vici.
Originally posted by ITheFallenI View Post
MADE YOU LOOK. NOOB. AHAHAHA.


Did I tell you I'm making a MW2 gametype? =D
09-03-2011, 05:51 AM #23
TheFallen
Former Dark Night
Originally posted by Blackstorm View Post
Did I tell you I'm making a MW2 gametype? =D

No, no one tells me anything anymore Gaspkay:
09-03-2011, 06:20 AM #24
Blackstorm
Veni. Vidi. Vici.
Originally posted by ITheFallenI View Post
No, no one tells me anything anymore Gaspkay:


It's a dragon ball z gametype Awesome face
09-03-2011, 03:08 PM #25
Default Avatar
Cade
Guest
Originally posted by Blackstorm View Post
....Gaspkay:


Anyways, I think I might be the only person that is actually going to use this menu.
09-03-2011, 03:49 PM #26
Blackstorm
Veni. Vidi. Vici.
Originally posted by Team
Anyways, I think I might be the only person that is actually going to use this menu.


At least someone is.
09-04-2011, 01:31 AM #27
finally ima test it asap
09-04-2011, 02:28 AM #28
how do i get this on my ps3

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo