Post: Surge "Rise" Menu Base - NO OVERFLOW [UPDATED 11/11/14]
10-10-2014, 03:25 AM #1
TheFallen
Former Dark Night
(adsbygoogle = window.adsbygoogle || []).push({});
Surge "Rise" Menu Base




Surge is finally out of beta and with that comes better features and better updates! So keep your eyes out for those!
All updates will be posted here.

Update 1.3.1
(Only supported by GSC Studio)




  • Bug fixes


Features


  • Overflow fix - no more string overflows! NEW (see "Setting Text and Preventing Overflow")
  • Works with other menu base's menu formats
  • Cursor Remembrance
  • Menu Paging
  • Ultimate Control System
  • Verification
  • Live Player Menu
  • Built-in API
  • Stable
  • Multi-input functions


Controls


  • Open - Dpad Down
  • Exit - R3
  • Select - X
  • Close - O
  • Scroll Up/Down - L1/R1


API Information (Advanced)

API
accessability.gsc


Function Parameters Return CallOn Description
checkAccess none none client Checks if the player has access and welcome them
changePlayerAccess client player
int accessLevel
none client Changes the access level of a player with a message
setAccessLevel int accessLevel none client Sets the access level of a player
getAccessLevel none int client Gets the access level of a player
getAccessLevelStatus [string acLevel] string client Gets the access level status of a player


hud_utilities.gsc


Function Parameters Return CallOn Description
setColor string type
string elem
string color
none level Sets an elements color in settings (does not actually change the visible color)
color string name rgb level Gets the rgb values for the specificed color (color must be defined using setColor())
addTheme string name
string label
(r,g,b) primaryColor
(r,g,b) secondaryColor
none client Adds a theme for the menu
setSafeText client player
string str
none text element Sets an element



menu.gsc


Function Parameters Return CallOn Description
addMenu string parent
string name
string title
none client Adds a menu
addOption string parent
string label
function function
var input
string type
entity entity
none client Adds an option to a menu
exitMenu none none client Exits the menu



toggle.gsc


Function Parameters Return CallOn Description
toggle var var
boolean state
none entity Toggles functions on and off with message



utilities.gsc


Function Parameters Return CallOn Description
getName none string client Gets the player's name without a clantag
isEmpty var var boolean entity Tells if the var is defined or is empty
enableDebugMode boolean toggle none level Toggles debug mode for Surge
addSetting string name
val value
none level Adds a setting for Surge
getSetting string name val level Gets the value of a setting for Surge
addVar string name
val value
none client Adds a var for a player (used in toggles)
getVar string name val client Gets the value of a var for a player (used in toggles)




Setting Text and Preventing Overflow


See "Creating Text", "Setting Text", and "Destroying Text" You must login or register to view this content.


Adding to the Menu
Adding Menus
Surge allows you to have multiple menus/submenus to help you organize your mods. You can do this by going to menu.gsc, updateMenu(), and calling addMenu(parent, name, title). Parent is the menu to add the menu to, name is the ID of the menu (must be unique), and title is the text to display for the title (if dynamic titles are enabled).

Ex:
    
updateMenu()
{
self addMenu("main", "accountSettings", "Account");
}


Adding Options
Surge allows you to have multiple menus/submenus to help you organize your mods. You can do this by going to menu.gsc, updateMenu(), and calling addOption(parent, label, function, [input], [type], [entity]). Parent is the menu to add the option to, label is the text to display, function is the function to be called when selected, input (optional) is the arguments to pass to the function when called, type (optional) is the type of function it is (see below), and entity (optional) is the entity to call the function on.

Simple

Adding a simple option is easy. All you need is the menu name, the option text, the function, and the input of you need one. Everything else is taken care of.

Ex:
    
updateMenu()
{
self addOption("main", "God Mode", ::enableGod);
self addOption("main", "God Mode", ::toggle, "god"); // Optional input
}



Advanced
Do not attempt the following unless you understand programming and what everything below means.


Surge allows you to have complete control over your mods. You can customize every aspect of the call to have it do what ever you need it to.

Input is optional but you can pass up to 5 arguments at once if you choose to. To do this simply create an array and add your desired inputs to the array and pass that in.

Type is optional and defaults to "thread" which runs the function async (along side) the rest. The other value for this is "immediate" which will pause execution, branch off, run the function, and then return to the parent thread.

Entity is optional and defaults to self. This allows you to call functions on any entity accessible in the scope.

Ex:
    
updateMenu()
{
player = level.players[0];

inputArray = [];
inputArray[0] = "arg1";
inputArray[1] = 2;
...
inputArray[4] = myObj; // last;
self addOption("main", "Multi Arg Func", ::multiFunc, input, "immediate", player); // This is equivalent to player multiFunc("arg1", 2, ..., myObj);
self addOption("main", "Multi Arg Func 2", ::multiFunc, input, "thread", player); // This is equivalent to player thread multiFunc("arg1", 2, ..., myObj);
}



Adding Options to the Player Menu
To add an option to the player menu add an option like you normally would except this time the type and entity arguments are required. Type should be "thread" for more info on this) and entitiy must be the client you want to call the function on (read Adding Options - Advanced for more information on these).

Ex:
    
updatePlayerMenu()
{
player = level.players[0];
self addOption(player + "Options", "Give God Mode", ::toggle, "god", "thread" player); // This will toggle god mode for this player.
}



Converting Menu Bases

Shark's Menu Base
To use Shark's menu base's option and menu format with Surge, simply copy and paste your old menu options and functions into updateMenu() or updatePlayerMenu() respectively. They will work right along with Surge's regular format with no problems.

Ex:
    
updateMenu()
{
self addMenu("", "main", "Surge");
self add_menu("test", "main", "Test Menu");
// Options in Shark's menu base format
self add_option("test", "Item", ::test);
self add_option("test", "Item 1", ::testOne, "arg1");
self add_option("test", "Item 2", ::testTwo, "arg1", "arg2");
self add_menu_alt("subMenu", "test");
self add_option("subMenu", "Sub Item", ::test);
self add_option("subMenu", "Sub Item 1", ::testOne, "arg1");
self add_option("subMenu", "Sub Item 2", ::testTwo, "arg1", "arg2");
//
self addMenu("main", "self", "Me");
self addOption("self", "God Mode", ::toggle, "god");
self addOption("self", "Unlimited Ammo", ::toggle, "ammo");
self addOption("self", "No Clip", ::toggle, "noclip");
}

updatePlayersMenu()
{
self.surge["menu"]["players"]["options"] = [];

foreach(player in level.players)
{
name = player getName();
menu = "player_" + name;
accessLevelsMenu = name + "_access_levels";

self addMenu("players", menu, "[" + player getAccessLevelStatus() + "] " + name);
if(player isHost() == false)
{
self addMenu(menu, accessLevelsMenu, "Change Access Level");
input = [];
input[0] = player; // This never changes because our first input is always the player
input[1] = 0; // This changed because it represents different access levels
self addOption(accessLevelsMenu, "Level 0 (" + level.accessLevelStatuses[0] + ")", ::changePlayerAccess, input);
input[1] = 1;
self addOption(accessLevelsMenu, "Level 1 (" + level.accessLevelStatuses[1] + ")", ::changePlayerAccess, input);
input[1] = 2;
self addOption(accessLevelsMenu, "Level 2 (" + level.accessLevelStatuses[2] + ")", ::changePlayerAccess, input);
// Shark's Menu Option Format
self add_option(accessLevelsMenu, "Option", ::function, input1, input2);
self add_option(accessLevelsMenu, "Option 1", ::function, input1, input2);
self add_option(accessLevelsMenu, "Option 2", ::function, input1, input2);
//
}
}

if(isEmpty(self.surge["menu"]["players"]["options"][self.surge["menu"]["players"]["position"]]))
self.surge["menu"]["players"]["position"] = 0;
}


Themes and Styling
Adding Colors
Go to main.gsc and find the function init(). Here is where you will define your colors.

Ex:
    
init()
{
//addColor(colorName, rgb)
addColor("red", (1, 0, 0));
}


Setting Colors
Go to main.gsc and find the function initSurge(). Here is where you will set your colors. You set them with setColor(type, elem, color). The type must exist in the first level of self.surge and the elem must exist in any level of self.surge[type]["hud"]. Color can be any (r, g, b) object. You can use predefined colors (view above) by calling color("color name").

Ex:
    
initSurge()
{
setColor("menu", "background", color("red"));
// or
setColor("menu", "background", (1, 0, 0));
}


Adding Themes
Go to main.gsc and find the function initSurge(). Here is where you will add your themes. You add them by calling addTheme(name, label, primaryColor, secondaryColor) with the name being the ID of the theme (must be unique), label being the text to display in the theme menu, and primaryColor and secondaryColor being any (r, g, b) object.

Ex:
    
initSurge()
{
addTheme("cherry", "Cherry", level.red, (1, 1, 1));
}


Turning On/Off Dynamic Menu Titles
Surge allows you to have dynamic menu titles. By default this is disabled to maximize stability but it can be turned on by going to main.gsc, initSurge(), and setting self.surge["settings"]["updateTitle"] = true;

Ex:
    
initSurge()
{
self.surge["settings"]["updateTitle"] = true; // On
self.surge["settings"]["updateTitle"] = false; // Off
}



Using the Toggle System
Surge comes with a easy-to-use toggle system that helps you create toggles. To start in main.gsc under initSurge() add an index to the vars array with the ID of your toggle. From there simply add an if statement with the ID of your toggle and inside of that is where the actual toggling goes on. To call it simply call toggle(var, [state]); You can either specify on/off or have it default to the opposite of what it currently is. Take a look at the example to see how to do this.

Ex:
    
initSurge()
{
self.surge["vars"]["god"] = false; // Defaults to false because we don't have god mode on when we spawn.
}

toggle(var, state)
{
if(isEmpty(state))
self.surge["vars"][var] = !self.surge["vars"][var];
else
self.surge["vars"][var] = state;

if(self.surge["vars"][var] == true)
status = "^2Enabled";
else
status = "^1Disabled";

// God mode
if(var == "god")
{
self iprintln("God Mode: " + status);

if(self.surge["vars"][var] == true)
self EnableInvulnerability();
else
{
// Only disable if not in menu; else will be disabled upon menu exit
if(self.surge["menu"]["active"] == false)
self DisableInvulnerability();
}
}
// generic example
else if(var == "varName")
{
self iprintln("Var Name: " + status); // prints out our status

if(self.surge["vars"][var] == true) // toggled on
self thread turnOnVar();
else // toggled off
self thread turnOffVar();
}
}

    
updateMenu()
{
self addOption("main", "God Mode", ::toggle, "god");
}


You must login or register to view this content.


Change Log

You must login or register to view this content.


  • Bug fixes



Past Updates

You must login or register to view this content.


  • Bug fixes
  • GUI change



You must login or register to view this content.


  • Shark Menu Base Converter



You must login or register to view this content.


  • Fixed Verifiaction Bug
  • Improved API
  • Added Overflow Fix (No string overflows)
  • GUI Changes



You must login or register to view this content.


Credits


  • ItsLollo1000 for his thread and anyone whose codes I used
  • Exelo for line_horizontal material
  • Taylor for reminding me how weird GSC when I tried doing something from a C language and for helping me test
  • iMCSx for his GSC Studio
  • Aiden729 for ideas and the release video
  • SyGnUs for testing
  • Adidas for testing
  • dtx12 for usage of clearAllTextAfterHudElem()
  • Shark for his menu base's option format
  • Natsu for menu base converter idea and references
Last edited by TheFallen ; 11-12-2014 at 03:52 AM. Reason: updated to 1.3.1

The following 41 users say thank you to TheFallen for this useful post:

/SneakerStreet/, A Friend, AlexNGU, anxify, BoatyMcBoatFace, BossamBemass, Bucko, canadiancaper, Chris, CustomSilent-, EncepT, ErasedDev, EternalHabit, Geo, iifire, iknownothing, Im Not Boobdidas, Im_YouViolateMe, ImPiffHD, ItsLollo1000, Jaredm09, John Leepe, M0T1VAT10N, MilkShakeModz, Obris, OrbitModding, Script Kiddie, seb5594, Shark, Source Code, StonedYoda, Taylor, SyGnUs, Synergy, Terrorize 420, The_Urban_Ninja, Vanz, zshred
08-04-2015, 07:46 PM #173
okay so ive come to a conclusion about this menu... i think it only works on ps3 cause on xbox it always froze but on the ps3 it runs like a charm
08-04-2015, 07:54 PM #174
itsSorrow
In my man cave
Originally posted by kewizzle View Post
okay so ive come to a conclusion about this menu... i think it only works on ps3 cause on xbox it always froze but on the ps3 it runs like a charm


Nope. Any GSC menu works for Xbox or PS3
08-05-2015, 02:35 AM #175
Originally posted by GentleSlugger View Post
Nope. Any GSC menu works for Xbox or PS3


nigga ik that but this menu freezes for xbox but not ps3 i am a owner of both and i make my own menus. All im saying is the coding for this is only stable for use on ps3 version.
08-05-2015, 02:37 AM #176
itsSorrow
In my man cave
Originally posted by kewizzle View Post
nigga ik that but this menu freezes for xbox but not ps3 i am a owner of both and i make my own menus. All im saying is the coding for this is only stable for use on ps3 version.


I am pretty sure we all make menus... Also it works for both
08-05-2015, 03:22 AM #177
Originally posted by GentleSlugger View Post
I am pretty sure we all make menus... Also it works for both


nah crashes on xbox ik ive tried millions everyone has issues.
08-05-2015, 03:23 AM #178
itsSorrow
In my man cave
Originally posted by kewizzle View Post
nah crashes on xbox ik ive tried millions everyone has issues.


nope,
08-05-2015, 03:41 AM #179
Originally posted by GentleSlugger View Post
nope,


um yeah lol
08-05-2015, 03:45 AM #180
itsSorrow
In my man cave
Originally posted by kewizzle View Post
um yeah lol


Nope.
08-05-2015, 05:14 AM #181
Originally posted by GentleSlugger View Post
Nope.


Lol okay argue. doesnt change the truth bro.

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo