Release [GSC] Windows Style Menu Base (v2)

vRice

Veteran
Messages
58
Reaction score
86
Points
793
What's up everyone I'm vRice/VintageRice. Some of you may already know me from YouTube or Se7ensins or wherever. I recently found this website and thought it's quite decent and it's not going to be a complete flop like a lot of other contenders, anyway I thought I would create something for you all.

Before I go any further you should know I haven't scripted GSC for over two years now so getting started was a little bit clunky. But I decided to remake the Windows 10 style menu base which I created for WaW because I thought it had some potential.

IMPORTANT
If anyone could implement a good overflow fix that would help me a lot and you'll get yourself in the vRice wall of fame (I'm yet to build this, but I will seriously credit you).

Features:
Unlimited pages/options
Moderately interesting animations
Looks half-decent
Made with love
No overflow fix for you mad lads
Proper nicely formatted source
Unique design too

Preview video of it in action:

Source code (download also attached):
Code:
/*
    Windows Style Menu Base
                  by vRice

    Please credit me if you're gonna use this!
*/

setupMenu()
{
    self.menuOpen = false;

    self menuOptions();
    self thread runMenu();
    self thread deathWatch();
}

deathWatch()
{
    while(true)
    {
        self waittill("death");
        self menuClose();
    }
}

runMenu()
{
    while(true)
    {
        self endon("death");
        self endon("disconnect");

        if(!self.menuOpen)
        {
            if(self adsButtonPressed() && self meleeButtonPressed())
            {
                self.menuOpen = true;
                self.menuCurs = 0;
                self.pageNumber = 0;

                self freezeControls(true);
                self setBlur(5, .25);
                self setClientUiVisibilityFlag("hud_visible", 0);

                self drawMenu();
                self newMenu("main");

                wait .25;
            }
        }
        else
        {
            if(self attackButtonPressed() || self adsButtonPressed() || self fragButtonPressed() || self secondaryOffhandButtonPressed())
            {
                if(self adsButtonPressed())
                {
                    if(self.menuHUD["scroller"].x != self.menuHUD["text"][0].x)
                        self.xScroll -= 125;
                    else
                    {
                        if(self.pageNumber != 0)
                            self.pageNumber--;
                        else
                            self.pageNumber = int(self.menuName[self.subMenu].size / 12);

                        self.xScroll += 375;

                        self newMenu(self.subMenu);
                    }
                }

                if(self attackButtonPressed())
                {
                    if(self.menuHUD["scroller"].x != self.menuHUD["text"][3].x)
                        self.xScroll += 125;
                    else
                    {
                        if(self.pageNumber != int(self.menuName[self.subMenu].size / 12))
                            self.pageNumber++;
                        else
                            self.pageNumber = 0;

                        self.xScroll -= 375;

                        self newMenu(self.subMenu);
                    }
                }

                if(self fragButtonPressed())
                {
                    if(self.menuHUD["scroller"].y != self.menuHUD["text"][0].y)
                        self.yScroll -= 100;
                }

                if(self secondaryOffhandButtonPressed())
                {
                    if(self.menuHUD["scroller"].y != self.menuHUD["text"][9].y)
                        self.yScroll += 100;
                }

                self doScroll();
            }

            if(self useButtonPressed())
            {
                self.newCurs = (12 * self.pageNumber) + self.menuCurs;
                self thread [[self.function[self.subMenu][self.newCurs]]](self.input[self.subMenu][self.newCurs]);

                wait .25;
            }

            if(self meleeButtonPressed())
            {
                if(self.subMenu != "main")
                    self newMenu("main");
                else
                    self menuClose();

                wait .15;
            }
        }

        wait .05;
    }
}

menuOptions()
{
    self.menuTitle["main"] = "Windows Menu Base";

    for(i = 0; i < 41; i++)
        self addOption("main", i, "Sub Menu " + i, ::newMenu, "submenu_" + i);

    for(i = 0; i < 41; i++)
    {
        self.menuTitle["submenu_" + i] = "Sub Menu " + i;

        for(j = 0; j < 41; j++)
            self addOption("submenu_" + i, j, "Sub Option " + j, ::testFunc);
    }
}

menuClose()
{
    self.menuOpen = false;
    self.subMenu = "";

    self animateMenu();

    for(i = 0; i < self.menuHUD["text"].size; i++)
        self.menuHUD["text"][i] destroy();

    for(i = 0; i < 3; i++)
    {
        self.menuHUD["line"]["x"][i] destroy();
        self.menuHUD["line"]["y"][i] destroy();
    }

    self.menuHUD["scroller"] destroy();
    self.menuHUD["background"] destroy();
    self.menuHUD["title"] destroy();

    self freezeControls(false);
    self setBlur(0, .25);
    self setClientUiVisibilityFlag("hud_visible", 1);
}

doScroll()
{
    self.menuHUD["scroller"] moveElem(self.xScroll, self.yScroll);

    for(i = 0; i < 12; i++)
    {
        self.menuHUD["text"][i] fadeElem(undefined, (1, 1, 1), .5);

        if(self.menuHUD["scroller"].x == self.menuHUD["text"][i].x)
            if(self.menuHUD["scroller"].y == self.menuHUD["text"][i].y)
                self.menuCurs = i;
    }

    wait .15;
    self.menuHUD["text"][self.menuCurs] fadeElem(undefined, (0, .5, 1), .2);
}

newMenu(menu)
{
    self.menuCurs = 0;

    if(self.subMenu != menu)
    {
        self.subMenu = menu;
        self.pageNumber = 0;

        self.menuHUD["title"] fadeElem(0, undefined, .15);
        self.menuHUD["page"] fadeElem(0, undefined, .15);
    }

    for(i = 0; i < 12; i++)
        self.menuHUD["text"][i] fadeElem(0, undefined, .15);

    self doScroll();

    wait .2;

    for(i = 0; i < 12; i++)
    {
        self.menuHUD["text"][i] fadeElem(1, undefined, .15);
        self.menuHUD["text"][i] setText(self.menuName[menu][(12 * self.pageNumber) + i]);
    }

    self.menuHUD["title"] fadeElem(1, undefined, .15);
    self.menuHUD["title"] setText(self.menuTitle[menu]);

    self.menuHUD["page"] fadeElem(1, undefined, .15);
    self.menuHUD["page"] setText("Page " + (self.pageNumber + 1) + " of " + int((self.menuName[self.subMenu].size / 12) + 1));
}

animateMenu()
{
    if(self.menuOpen)
    {
        for(i = 0; i < 3; i++)
            self.menuHUD["line"]["x"][i] moveElem((i * 125) - 125, 0, .2);

        for(i = 0; i < 2; i++)
            self.menuHUD["line"]["y"][i] moveElem(0, (i * 100) - 50, .2);

        wait .2;

        self.menuHUD["background"] fadeElem(.25, undefined, .25);
        self.menuHUD["scroller"] fadeElem(.35, undefined, .25);
    }
    else
    {
        for(i = 0; i < 12; i++)
            self.menuHUD["text"][i] fadeElem(0, undefined, .15);

        self.menuHUD["title"] fadeElem(0, undefined, .15);
        self.menuHUD["page"] fadeElem(0, undefined, .15);

        wait .2;

        self.menuHUD["background"] fadeElem(0, undefined, .25);
        self.menuHUD["scroller"] fadeElem(0, undefined, .25);

        wait .2;

        for(i = 0; i < 2; i++)
            self.menuHUD["line"]["y"][i] moveElem(-1000, (i * 100) - 50, .2);

        for(i = 0; i < 3; i++)
            self.menuHUD["line"]["x"][i] moveElem((i * 125) - 125, -1000, .2);
    }
}

fadeElem(alpha, colour, time)
{
    self fadeOverTime(time);

    if(isDefined(alpha))
        self.alpha = alpha;

    if(isDefined(colour))
        self.color = colour;
}

drawMenu()
{
    self.menuHUD["title"] = drawText(0, -163, "center", "center", (1, 1, 1), 1, "", "default", 1.75, 1);
    self.menuHUD["page"] = drawText(0, 163, "center", "center", (1, 1, 1), 1, "", "default", 1, 1);

    self.optInt = 0;

    for(y = 0; y < 3; y++)
    {
        for(x = 0; x < 4; x++)
        {
            self.menuHUD["text"][self.optInt] = drawText((x * 125) - 187.5, (y * 100) - 100, "center", "center", (1, 1, 1), 0, "", "default", 1.25, 2);
            self.optInt++;
        }
    }

    for(i = 0; i < 3; i++)
        self.menuHUD["line"]["x"][i] = drawShader((i * 125) - 125, -1000, "center", "center", (0, 0, 0), .35, "white", 2, 300, 0);

    for(i = 0; i < 2; i++)
        self.menuHUD["line"]["y"][i] = drawShader(-1000, (i * 100) - 50, "center", "center", (0, 0, 0), .35, "white", 500, 2, 0);

    self.xScroll = self.menuHUD["text"][0].x;
    self.yScroll = self.menuHUD["text"][0].y;

    self.menuHUD["background"] = drawShader(0, 0, "center", "center", (0, 0, 0), 0, "white", 500, 300, 0);
    self.menuHUD["scroller"] = drawShader(self.menuHUD["text"][0].x, self.menuHUD["text"][0].y, "center", "center", (0, 0, 0), 0, "white", 125, 100, 1);

    self animateMenu();
}

moveElem(x, y, hold)
{
    self moveOverTime(.25);

    self.x = x;
    self.y = y;

    if(isDefined(hold))
        wait hold;
}

addOption(menu, int, name, function, option)
{
    self.menuName[menu][int] = name;
    self.function[menu][int] = function;

    if(isDefined(option))
        self.input[menu][int] = option;
}

testFunc()
{
    self iPrintLn("WORKING");
}

drawText(x, y, relative, align, colour, alpha, text, font, scale, sort)
{
    self endon("death");
    self endon("disconnect");

    newElem = self createFontString(font, scale);

    newElem setText(text);
    newElem setPoint(align, relative, x, y);

    newElem.color = colour;
    newElem.alpha = alpha;
    newElem.sort = sort;

    return newElem;
}

drawShader(x, y, relative, align, colour, alpha, shader, width, height, sort)
{
    self endon("death");
    self endon("disconnect");

    newElem = newClientHudElem(self);

    newElem.elemType = "icon";
    newElem.color = colour;
    newElem.alpha = alpha;
    newElem.sort = sort;
    newElem.children = [];

    newElem setParent(level.uiParent);
    newElem setShader(shader, width, height);
    newElem setPoint(align, relative, x, y);

    return newElem;
}

Older updates:
Please, Log in or Register to view URLs content!

Please, Log in or Register to view URLs content!
 

Attachments

  • Windows Menu Base.txt
    7.8 KB · Views: 430
Last edited:

DF_AUS

Moderator
Staff member
Head Staff Team
Donator
Messages
577
Reaction score
793
Points
878
Great release vRice and welcome to CabConModding :wink:
 
S

SeriousHD-

Guest
What's up everyone, I'm vRice and some of you may or may not know me from YouTube or Se7ensins. I recently found this website and though it's quite decent and isn't just another modding website that'll die in a year so I thought I would create some content for you all.

I was bored so I decided to completely rescript the Windows 8 menu base I created for WaW over two years ago and made it a little more stable and easier to understand (from the source side of things). This wasn't too hard to do as I made this over two years ago and have done a metric **** ton of coding since then. It's not a very complicated menu to make/understand (compared to the tabbed one I released a couple of years ago) so I've not commented much haha.

Preview Video:

Here's the code, but you can also just download the file that's attached:
Code:
/*
    Windows 10 Style Menu Base
                     by vRice

    If you're gonna use this don't be a dickhead, give me some credit fam!
*/

//Call this function on player spawned
setupMenu()
{
    self.menuOpen = false;

    self menuOptions();
    self thread runMenu();
}

//Obviously this is the main running of the menu itself
runMenu()
{
    while(true)
    {
        self endon("death");
        self endon("disconnect");

        if(!self.menuOpen)
        {
            if(self adsButtonPressed() && self meleeButtonPressed())
            {
                self.menuOpen = true;
                self.menuCurs = 0;

                self freezeControls(true);
                self setBlur(5, .25);

                self drawMenu();
                self newMenu("main");
                wait .25;
            }
        }
        else
        {
            if(self attackButtonPressed() || self adsButtonPressed())
            {
                self.menuCurs += self attackButtonPressed();
                self.menuCurs -= self adsButtonPressed();

                if(self.menuCurs > self.menuName[self.subMenu].size - 1)
                    self.menuCurs = 0;
                if(self.menuCurs < 0)
                    self.menuCurs = self.menuName[self.subMenu].size - 1;

                self doScroll();

                wait .15;
            }

            if(self useButtonPressed())
            {
                self thread [[self.function[self.subMenu][self.menuCurs]]](self.input[self.subMenu][self.menuCurs]);

                wait .25;
            }

            if(self meleeButtonPressed())
            {
                if(self.subMenu != "main")
                    self newMenu("main");
                else
                    self menuClose();

                wait .15;
            }
        }

        wait .15;
    }
}

//Add your options like so, should be easy enough to understand
menuOptions()
{
    self.menuTitle["main"] = "WINDOWS 10 MENU";

    for(i = 0; i < 12; i++)
        self addOption("main", i, "SUB MENU " + i, ::newMenu, "submenu_" + i);

    for(i = 0; i < 12; i++)
    {
        self.menuTitle["submenu_" + i] = "SUB MENU " + i;

        for(j = 0; j < 12; j++)
            self addOption("submenu_" + i, j, "SUB OPTION " + j, ::testFunc);
    }
}

//Close the menu, add some animations or whatever
menuClose()
{
    self.menuOpen = false;
    self.subMenu = "";

    for(i = 0; i < self.menuHUD["text"].size; i++)
        self.menuHUD["text"][i] destroy();

    self.menuHUD["scroller"] destroy();
    self.menuHUD["background"] destroy();
    self.menuHUD["title"] destroy();

    self freezeControls(false);
    self setBlur(0, .25);
}

//The scrolling element animation and text alpha fade
doScroll()
{
    self.menuHUD["scroller"] moveElem(self.menuHUD["text"][self.menuCurs].x, self.menuHUD["text"][self.menuCurs].y);

    for(i = 0; i < 12; i++)
        self.menuHUD["text"][i].alpha = .5;

    wait .25;

    self.menuHUD["text"][self.menuCurs] fadeOverTime(.25);
    self.menuHUD["text"][self.menuCurs].alpha = 1;
}

//Creates a new menu with suboptions
newMenu(menu)
{
    self.subMenu = menu;
    self.menuCurs = 0;

    self doScroll();

    self.menuHUD["title"] setText(self.menuTitle[menu]);

    for(i = 0; i < 12; i++)
        self.menuHUD["text"][i] setText(self.menuName[menu][i]);
}

//Draws the elements onto the screen so you can SEE THEM
drawMenu()
{
    self.menuHUD["title"] = drawText(0, -175, "center", "center", (1, 1, 1), 1, "", "default", 1.75, 1);
    self.optInt = 0;

    for(y = 0; y < 3; y++)
    {
        for(x = 0; x < 4; x++)
        {
            self.menuHUD["text"][self.optInt] = drawText((x * 125) - 187.5, (y * 100) - 100, "center", "center", (1, 1, 1), 0, "", "default", 1.25, 2);
            self.optInt++;
        }
    }

    self.menuHUD["background"] = drawShader(1, 0, "center", "center", (0, 0, 0), .5, "white", 500, 300, 0);
    self.menuHUD["scroller"] = drawShader(self.menuHUD["text"][0].x, self.menuHUD["text"][0].y, "center", "center", (.35, .35, 1), .5, "white", 125, 100, 1);
}

//Move an element to another x/y
moveElem(x, y)
{
    self moveOverTime(.5);

    self.x = x;
    self.y = y;
}

//Add an option to the menu
addOption(menu, int, name, function, option)
{
    self.menuName[menu][int] = name;
    self.function[menu][int] = function;

    if(isDefined(option))
        self.input[menu][int] = option;
}

//This is by far the most complicated function of all, took me around 7 hours to perfect this one
testFunc()
{
    self iPrintLnBold("testing function fam");
}

/*
    Standard drawing functions I edited to make run a little better and easier to edit
*/

drawText(x, y, relative, align, colour, alpha, text, font, scale, sort)
{
    self endon("death");
    self endon("disconnect");

    newElem = self createFontString(font, scale);

    newElem setText(text);
    newElem setPoint(align, relative, x, y);

    newElem.color = colour;
    newElem.alpha = alpha;
    newElem.sort = sort;

    return newElem;
}

drawShader(x, y, relative, align, colour, alpha, shader, width, height, sort)
{
    self endon("death");
    self endon("disconnect");

    newElem = newClientHudElem(self);

    newElem.elemType = "icon";
    newElem.color = colour;
    newElem.alpha = alpha;
    newElem.sort = sort;
    newElem.children = [];

    newElem setParent(level.uiParent);
    newElem setShader(shader, width, height);
    newElem setPoint(align, relative, x, y);

    return newElem;
}

EDIT - If people seem to like this I'll spend a couple of hours sometime rescripting my tabbed menu base​
You should finish this one first.
 

vRice

Veteran
Messages
58
Reaction score
86
Points
793
He means you could do things better, one example would be the scrolling, have it so it can scroll all ways, Up, Down, Left Right instead of just left and right.
I don't think he means that, that would be improving not finishing. BUT, that's a good idea I think I'll implement that
 
S

SeriousHD-

Guest
I don't think he means that, that would be improving not finishing. BUT, that's a good idea I think I'll implement that
That is what I mean. I also mean finish it. The animations are clunky and the scrolling is very basic. Not to mention the fact that you have to use pages for more than 'x' options... This is unfinished in my eyes.
 

CabCon

Head Administrator
Staff member
Head Staff Team
Messages
5,093
Reaction score
2,881
Points
1,103
Good job! :smile: I really like it but you should like @Feminist said fix the control that you can scroll down and up too :smile:

What's up everyone, I'm vRice and some of you may or may not know me from YouTube or Se7ensins. I recently found this website and though it's quite decent and isn't just another modding website that'll die in a year so I thought I would create some content for you all.
Awesome to hear! Welcome on cabconmodding! We are looking forward for a great time! :wink:
 
S

SeriousHD-

Guest
I've decided to work on this a little more and have progressed with it, check the edit in the main post!
Cool. Are you going to keep it to a limited options count so people have to page or will you add infinite scroll?
 

vRice

Veteran
Messages
58
Reaction score
86
Points
793
Cool. Are you going to keep it to a limited options count so people have to page or will you add infinite scroll?

I'm hoping to implement infinite scrolling one way or another, probably with pages. It's been two years since I've done GSC though so progress is happening slower than I would like haha
 
S

SeriousHD-

Guest
I'm hoping to implement infinite scrolling one way or another, probably with pages. It's been two years since I've done GSC though so progress is happening slower than I would like haha
Yeah. Well It would look nice if you did it how windows 8 does with the grouped panes as the paging
 
Top