Forum: GTA IV Mod Releases / W.I.P.s


The above video goes away if you are a member and logged in, so log in now!




 
Would you like to get all the new info from
PSX-Scene in your email each day?




Want to learn more about the team keeping you up to date with the latest scene news?

Read about them now!

Check out our Developer bios, too!

 


User Tag List

Like Tree59Likes

Thread: [CODE] Menu Library v1.3
  

Page 1 of 6 1 2 3 ... LastLast
Results 1 to 10 of 58
  1. #1 [CODE] Menu Library v1.3 
    Three-Socks's Avatar
    Three-Socks is offline Developer
    Join Date
    Feb 2011
    Posts
    362
    Downloads
    16
    Uploads
    0
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    83
    Likes Received
    310
    GTAIV Menu Library v1.3

    For Developers


    Introduction
    A code library for GTAIV Script developers to create advanced menus in-game.

    Projects that use it:
    Contents.

    1. Introduction
    2. How to Code Your First Menu
    3. Download Complete Sample
    4. Function API
    5. Changelog
    Features

    • Supports up to 50 menu items by default.
    • Menu scrolling.
    • 10 menu levels by default.
    • Simple coding structure.
    • Customisable options.
    • Default style mimics GTA's frontend UI.
    • Support for extra styles.

    Configuration Options

    Configuration options should be stored in "project_setup.c" in a function named "project_setup".

    Compiler Defines
    • PC - If to use the PC font ID.
    • MAX_MENU_ITEMS - Max menu items per menu.
    • MAX_MENU_LEVLS - Max menu levels.
    • STYLE - Custom style to load /menu/menu_style_#.c.

    Config Vars - Define in /menu/menu_style_#.c - style_setup()
    • menu_start_y - Menu starting position.
    • menu_spacing - Spacing between each item.
    • menu_max - Max number of items before scrolling.
    • menu_start_scrolling - Item number to start scrolling at.

    Custom Config Vars - Define anywhere in your script
    • startup_script - The start up script to launch after the menu is closed. (Recommended you declare this as early in your script as possible)
    • custom_float_dp - How many decimal places to show when using the 'float selector' (menu_addItemFloat).
    • custom_float_change - How much to add/subtract when pressing left/right in the 'float selector'.
    • custom_bool_on - Custom text to display in the 'toggle selector' in the 'true' position. (menu_addItemBool)
    • custom_bool_off - Custom text to display in the 'toggle selector' in the 'false' position.


    Code Repository

    https://bitbucket.org/ThreeSocks/gtaiv-menu-library/

    License

    Code:
     DON'T BE A DICK PUBLIC LICENSE
    
                        Version 1, December 2009
    
     Copyright (C) 2009 Philip Sturgeon <email@philsturgeon.co.uk>
     
     Everyone is permitted to copy and distribute verbatim or modified
     copies of this license document, and changing it is allowed as long
     as the name is changed.
    
                      DON'T BE A DICK PUBLIC LICENSE
        TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
    
      1. Do whatever you like with the original work, just don't be a dick.
    
         Being a dick includes - but is not limited to - the following instances:
    
     1a. Outright copyright infringement - Don't just copy this and change the name.
     1b. Selling the unmodified original with no work done what-so-ever, that's REALLY being a dick.
     1c. Modifying the original work to contain hidden harmful content. That would make you a PROPER dick.
    
      2. If you become rich through modifications, related works/services, or supporting the original work,
     share the love. Only a dick would make loads off this work and not buy the original works 
     creator(s) a pint.
     
      3. Code is provided with no warranty. Using somebody else's code and bitching when it goes wrong makes 
     you a DONKEY dick. Fix the problem yourself. A non-dick would submit the fix back.
    Last edited by Three-Socks; 02-02-2013 at 09:35 AM.
    jumper, tthousand, JDMAlex and 9 others like this.
    Reply With Quote  

  2. #2 How To Code Your First Menu 
    Three-Socks's Avatar
    Three-Socks is offline Developer
    Join Date
    Feb 2011
    Posts
    362
    Downloads
    16
    Uploads
    0
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    83
    Likes Received
    310
    How To Code Your First Menu


    Includes

    First start by linking to the menu library and any of your own includes in-between.

    Menu = Core menu code (Functions, Drawing, Catching button press.)
    Project = Your project menu configuration and startup/shutdown code.

    PHP Code:
    #include <natives.h>
    #include <common.h>
    #include <strings.h>
    #include <types.h>
    #include <consts.h>

    //#define PC
    #define MAX_MENU_ITEMS 52
    #define MAX_MENU_LEVLS 5
    #define STYLE 1

    // Menu
    #include "menu/menu.h"

    #include "sample_lang.h"
    #include "sample_locals.h"

    // Project
    #include "project_error.c"

    #include "sample_functions.c"

    // Project
    #include "project_set.c"
    #include "project_action.c"

    // Menu
    #include "menu/menu_core.c" 

    Main Code

    Call core menu/project functions.
    PHP Code:
    void main(void)
    {
        
    startup_script "sample_startup";

        
    menu_core_startup();
        
    draw_startup();

        while(
    true)
        {
            
    WAIT(0);

            if (
    inMenu)
            {
                
    menu_core();

                
    // Draw background/header/text.
                
    drawWindow();

                
    drawFrontend();
                
                
    drawHeader();
                
    menu_draw();
            }
        }


    Error code

    Handles the error function of your project (if needed). It should be specific to your project.

    It should be stored in "project_error.c" in a function named "project_error".
    PHP Code:
    void project_error(uint error_id)
    {
        if (
    menu_item[item_selected].action)
            
    actionError true;

        
    menu_clean();

        
    // Invalid Menu.
        
    menu_header sample_menu_error;

        if (
    error_id == SAMPLE_ERROR_ID_INVALID)
            
    menu_addItem(sample_menu_error_invalid);

        
    menu_addItem(sample_menu_error_goback);
        
    inError true;


    Set Code

    This "Sets" the menu for display.

    "Set" code should be stored in "project_set.c" in a function named "project_set".

    PHP Code:
    void project_set(void)
    {
        
    menu_items_set true;

        
    uint mainMenu last_selected[1];
        
    uint subMenu last_selected[2]; 

        
    // Main
        
    if (menu_level == 1)
        {
            
    // Main
            
    menu_header sample_menu_main;
            
    menu_addItem(sample_menu_1);
            
    menu_addItem(sample_menu_2);
            
    menu_addItem(sample_menu_exit);
            
    menu_addAction();
            return;
        }
        
    // Menu Item 1
        
    else if (mainMenu == 1)
        {
            if (
    menu_level == 2)
            {
                
    menu_header sample_menu_sub;
                
    menu_addItem(sample_menu_sub_1);
                
    menu_addAction();
                
    menu_addItem(sample_menu_sub_2);
                
    menu_addAction();
                
    menu_addItem(sample_menu_sub_3);
                
    menu_addAction();

                return;    
            }
        }
        
    // Menu Item 2
        
    else if (mainMenu == 2)
        {
            if (
    menu_level == 2)
            {
                
    menu_header sample_menu_sub;
                
    menu_addItem(sample_menu_sub_1);
                
    menu_addAction();
                
    menu_addItem(sample_menu_sub_2);
                
    menu_addAction();
                
    menu_addItem(sample_menu_sub_3);
                
    menu_addAction();

                return;
            }
        }

        
    project_error(SAMPLE_ERROR_ID_INVALID);
    }

    void project_catchFunctionButtonPress(void)
    {


    Action Code


    "Action" is code that is run when a menu item is set as an 'action'. Then pressed.

    "Action" code should be stored in "project_action.c" with the function name "project_doAction".

    PHP Code:
    void run_my_code(void)
    {
        
    // Your code/natives.
    }

    void project_doAction(void)
    {
        
    menu_items_set true;

        
    // Helpers
        
    uint num_val_selected menu_item[item_selected].num_val;
        
    uint mainMenu last_selected[1];
        
    uint subMenu last_selected[2]; 

        if (
    menu_level == 1)
        {
            if (
    item_selected == 3)
                
    // Exit
                
    project_shutdown();
        }
        else if (
    mainMenu == 1)
        {
            if (
    menu_level == 2)
            {
                if (
    subMenu == 1)
                    
    run_my_code();
                else if (
    subMenu == 2)
                    
    run_my_code();
                else if (
    subMenu == 3)
                    
    run_my_code();

                return;
            }
        }
        else if (
    mainMenu == 2)
        {
            if (
    menu_level == 2)
            {
                if (
    subMenu == 1)
                    
    run_my_code();
                else if (
    subMenu == 2)
                    
    run_my_code();
                else if (
    subMenu == 3)
                    
    run_my_code();

                return;
            }
        }

        
    project_error(SAMPLE_ERROR_ID_INVALID);

    Last edited by Three-Socks; 08-07-2012 at 07:02 PM.
    jumper, tthousand, JDMAlex and 3 others like this.
    Reply With Quote  

  3. #3 Download Complete Sample 
    Three-Socks's Avatar
    Three-Socks is offline Developer
    Join Date
    Feb 2011
    Posts
    362
    Downloads
    16
    Uploads
    0
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    83
    Likes Received
    310
    Download Complete Sample


    https://bitbucket.org/ThreeSocks/gta...c/default/menu

    Download the menu library from its repo and place the files inside the folder "menu".
    Last edited by Three-Socks; 07-31-2012 at 05:23 AM.
    jumper, tthousand, JDMAlex and 3 others like this.
    Reply With Quote  

  4. #4 Function API 
    Three-Socks's Avatar
    Three-Socks is offline Developer
    Join Date
    Feb 2011
    Posts
    362
    Downloads
    16
    Uploads
    0
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    83
    Likes Received
    310
    Function API


    menu_addItem
    Code:
    void menu_addItem(char* item_text)
    Description
    Sets a new menu item.
    Parameters
    (char) item_text: Text to display.




    menu_addItemNumber
    Code:
    void menu_addItemNumber(uint item_num, uint item_max)
    Description
    Adds a number selector to the last menu item set.
    Parameters
    (uint) item_num: Default number to start at.
    (uint) item_max: Maximum number it can reach before it gets set to 1.




    menu_addItemFloat
    Code:
    void menu_addItemFloat(float item_float, uint item_max)
    Description
    Adds a number selector to the last menu item set.
    Parameters
    (float) item_float: Default float to start at.
    (uint) item_max: Maximum float it can reach before it gets set to 1.




    menu_addItemBool
    Code:
    void menu_addItemBool(bool item_bool)
    Description
    Adds a On/Off toggle to the last menu item set.
    Parameters
    (bool) item_bool: Default value.




    menu_addItemHash
    Code:
    void menu_addItemHash(char* item_text, uint item_hash)
    Description
    Sets a new menu item with a hash.
    Parameters
    (char) item_text: Text to display.
    (uint) item_hash: Hash to store with the menu item.




    menu_addItemGXTHash
    Code:
    void menu_addItemGXTHash(uint item_gxt_hash)
    Description
    Sets a new menu item with a GXT.
    Parameters
    (uint) item_gxt_hash: GXT.




    menu_addAction
    Code:
    void menu_addAction(void)
    Description
    Adds the action flag to the last set item.
    Parameters
    None.




    menu_clean
    Code:
    void menu_clean(void)
    Description
    Wipes the menu struct.
    Parameters
    None.




    menu_draw
    Code:
    void menu_draw(void)
    Description
    Draws the menu on screen.
    Parameters
    None.




    menu_up_pressed
    Code:
    bool menu_up_pressed(bool counter)
    Description
    Returns true when the up button is pressed.
    Parameters
    (bool) counter: Choose if to count this press towards the hold counter.




    menu_down_pressed
    Code:
    bool menu_down_pressed(bool counter)
    Description
    Returns true when the down button is pressed.
    Parameters
    (bool) counter: Choose if to count this press towards the hold counter.




    menu_left_pressed
    Code:
    bool menu_left_pressed(bool counter)
    Description
    Returns true when the left button is pressed.
    Parameters
    (bool) counter: Choose if to count this press towards the hold counter.




    menu_right_pressed
    Code:
    bool menu_right_pressed(bool counter)
    Description
    Returns true when the right button is pressed.
    Parameters
    (bool) counter: Choose if to count this press towards the hold counter.




    menu_forward_pressed
    Code:
    bool menu_forward_pressed()
    Description
    Returns true when the forward button is pressed.
    Parameters
    None.




    menu_back_pressed
    Code:
    bool menu_back_pressed()
    Description
    Returns true when the back button is pressed.
    Parameters
    None.
    Last edited by Three-Socks; 07-31-2012 at 05:24 AM.
    jumper, HuN and keredor like this.
    Reply With Quote  

  5. #5 Changelog 
    Three-Socks's Avatar
    Three-Socks is offline Developer
    Join Date
    Feb 2011
    Posts
    362
    Downloads
    16
    Uploads
    0
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    83
    Likes Received
    310
    Changelog


    1.3

    Code Changeset

    - New default style (by jumper).
    - New default style notes:
    - all positioning is calculated from a base position allowing easy movement
    - menu text is more compact and allows underscores
    - right side items are set to right justify to slim down code a bit (added 2 vars to set_up_draw() to handle positioning)
    - correct spacing for floats up to 9999 and up to 8 decimal spaces, and for integers up to 99999999
    - changing text width, height, or spacing may still break some placements
    - I'm probably forgetting some things...

    1.2.2

    Code Changeset

    - Added disable menu feature. Allows you to hide the menu at any menu level and re-open it. (if configured).

    Code Changesets

    - Fixes #3.

    1.2

    Code Changesets

    - Fixed extra style support.
    - Renamed "menu_core_init" to "menu_core_startup".
    - Removed "project_setup.c" it is now handled in the defined custom style (/menu/menu_style_#.c style_setup())
    - Added project_error.c.
    - Fixed: If a project_error occurred while in the first menu_level. It would exit the script.
    - Added null_string - to be used instead of " ".
    - Added "ModManager" custom style (ID: 2).

    1.1

    Code Changeset

    - Added extra styles support.

    1.0.1

    Code Changeset

    - Added global modifying scripts to Menu Library. Instead of relying on the project to do it. (menu_globals, menu_gexit).
    - Added TLAD/TBOGT globals to global modifying scripts.
    - Moved generic project_startup & project_shutdown into menu_core.c.
    - Minor changes.

    1.0
    - Initial release.
    Last edited by Three-Socks; 02-02-2013 at 09:36 AM.
    jumper, HuN, keredor and 1 others like this.
    Reply With Quote  

  6. #6  
    Zaapata's Avatar
    Zaapata is offline Member
    Join Date
    Jun 2012
    Posts
    83
    Downloads
    1
    Uploads
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    2
    Likes Received
    7
    Oh My God! Thanks Finally im understanding this (Script). Thanks, Good Explaination
    Reply With Quote  

  7. #7  
    nativesith's Avatar
    nativesith is offline Moderator
    Join Date
    Jun 2011
    Location
    Los Santos
    Posts
    1,388
    Downloads
    12
    Uploads
    7
    Mentioned
    39 Post(s)
    Tagged
    2 Thread(s)
    Likes Given
    1001
    Likes Received
    672
    Thanks again Three, becoming more n more clear.
    Reply With Quote  

  8. #8  
    Anonreporter is offline Member
    Join Date
    Jun 2012
    Posts
    17
    Downloads
    0
    Uploads
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    0
    Likes Received
    6
    just saying but this setup for this library is confusing completely unlike ur the last manager could u post up an example with basic scripts added so i understand where to add the individual parts would be appreciated it helped last time how u had some scripts added in ur source because than i was able to understand how to set stuff up i mean you explained the natives fine in this thread but that didnt help me understand how to add my scripts to it

    once again nice release
    Reply With Quote  

  9. #9  
    keyFlamer is offline Member
    Join Date
    Mar 2012
    Posts
    24
    Downloads
    2
    Uploads
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    4
    Likes Received
    2
    Thanks for this tutorial three-sock's.
    Reply With Quote  

  10. #10  
    Three-Socks's Avatar
    Three-Socks is offline Developer
    Join Date
    Feb 2011
    Posts
    362
    Downloads
    16
    Uploads
    0
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Likes Given
    83
    Likes Received
    310
    Quote Originally Posted by Anonreporter View Post
    just saying but this setup for this library is confusing completely unlike ur the last manager could u post up an example with basic scripts added so i understand where to add the individual parts would be appreciated it helped last time how u had some scripts added in ur source because than i was able to understand how to set stuff up i mean you explained the natives fine in this thread but that didnt help me understand how to add my scripts to it

    once again nice release
    Have you checked out the Complete Sample menu at the bottom of the second post? That should get you started.

    But I think you might have this confused with something its not. It just designed to handle the basic core functions of a menu. Button presses, scrolling, drawing, and a lot more that you might need while coding a menu for your mod.

    This just gives you the base to do what the hell you like with it.

    Its not like modmanager, which its sole purpose was to load scripts.

    See how you get along with the sample. I'll be more than happy to help with anything
    Reply With Quote  

Page 1 of 6 1 2 3 ... LastLast
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •