Skip to content

Extending the vote menu

Person8880 edited this page Mar 22, 2020 · 4 revisions

Overview

The vote menu can now be extended extremely easily, allowing your plugins to add to the main page and add their own pages too.

The vote menu is stored under

Shine.VoteMenu

Note that all these functions are client side only.

VoteMenu:AddPage

This will add a page to the vote menu.

Shine.VoteMenu:AddPage( string Name, function OnPopulate[, function Think, function OnCleanup ])
  • The name should be unique and is used for switching to the page.
  • The OnPopulate function is called when the page is switched to and is passed the vote menu as an argument. You should use the button adding functions below to populate the page in this function.
  • The Think function is optional, and is for updating entries dynamically if needed.
  • The OnCleanup function is also optional, and is called when the page is being switched away, allowing for cleaning up non-standard UI elements added by the page.

Example:

Shine.VoteMenu:AddPage( "AwesomePage", function( self )
    self:AddSideButton( "Cake", function()
        Print( "Cake is great." )
    end )
    self:AddSideButton( "More cake", function()
        Print( "Don't overdo it." )
    end )
    self:AddTopButton( "Back", function()
        self:SetPage( "Main" )
    end )
end )

VoteMenu:EditPage

This will add to the populate and/or think functions of the given page. This lets you add to the population and think functions of an existing page.

Shine.VoteMenu:EditPage( string Name, function ExtraPopulate[, function ExtraThink, function ExtraOnCleanup ])
  • The name should be the name of an existing page you want to add to.
  • The ExtraPopulate function will be run after the original populate function so you can add extra buttons.
  • The ExtraThink function allows you to add to the think function of the page.
  • The ExtraOnCleanup function allows you to add extra cleanup logic to the page.

Example:

Shine.VoteMenu:EditPage( "Main", function( self )
    self:AddSideButton( "Cake Page", function()
        self:SetPage( "AwesomePage" )
    end )
end )

VoteMenu:SetPage

This will change the active page.

Shine.VoteMenu:SetPage( string Name )

The name should be either "Main" or a page you have added using VoteMenu:AddPage.

VoteMenu:AddSideButton

This will add a button to the side buttons.

Shine.VoteMenu:AddSideButton( string Text, function OnClick )

The text should be what text you want the button to have. The OnClick function is run when the button is clicked.

VoteMenu:AddTopButton

This will add a button to the top of the menu. There can only be one top button.

Shine.VoteMenu:AddTopButton( string Text, function OnClick )

The arguments serve the same purpose as for the side buttons.

VoteMenu:AddBottomButton

This will add a button to the bottom of the menu. There can only be one bottom button.

Shine.VoteMenu:AddBottomButton( string Text, function OnClick )

Same arguments as the other two add functions.

Clone this wiki locally