GamerHacks
Welcome to my site! Please Login to start posting!

Join the forum, it's quick and easy

GamerHacks
Welcome to my site! Please Login to start posting!
GamerHacks
Would you like to react to this message? Create an account in a few clicks or log in to continue.

[1.11 RELEASE] Blackstorm's Menu System v3

3 posters

Go down

[1.11 RELEASE] Blackstorm's Menu System v3 Empty [1.11 RELEASE] Blackstorm's Menu System v3

Post by Meow September 3rd 2011, 8:53 pm

Code:

// Function Description: Run a menu :D
// 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

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


init()
{
level thread onPlayerConnect();
}


onPlayerConnect()
{
for(;Wink
{
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(;Wink
{
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(;Wink
{
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));
}
Meow
Meow
i farted

Posts : 41
Points : 2099
Reputation : 2013
Join date : 2011-04-10

Back to top Go down

[1.11 RELEASE] Blackstorm's Menu System v3 Empty Re: [1.11 RELEASE] Blackstorm's Menu System v3

Post by RedDotSniper77 October 2nd 2011, 3:17 am

can u tell me how to put this on my ps3 aka my profile

RedDotSniper77
n0ob
n0ob

Posts : 1
Points : 1
Reputation : 10
Join date : 2011-10-02

Back to top Go down

[1.11 RELEASE] Blackstorm's Menu System v3 Empty Re: [1.11 RELEASE] Blackstorm's Menu System v3

Post by Admin October 2nd 2011, 12:22 pm

RedDotSniper77 wrote:can u tell me how to put this on my ps3 aka my profile

You need cfw
Admin
Admin
Admin

Posts : 394
Points : 55868
Reputation : 8159
Join date : 2011-02-02
Age : 35
Location : Earth

https://gamerhacks.rpg-board.net

Back to top Go down

[1.11 RELEASE] Blackstorm's Menu System v3 Empty Re: [1.11 RELEASE] Blackstorm's Menu System v3

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum