Ok finally got TPT to compile!

  • Videogamer555
    17th Jan 2012 Member 0 Permalink
    Great, now the FIRST thing to do is to add some more menus to stick any new elements I might want to make. Which of the .h and/or .c files will I need to edit to accomplish the task of adding menus to TPT's menu bar?
  • jacksonmj
    17th Jan 2012 Developer 0 Permalink
    interface.h

    Each menu has a name/number defined here, these are used in elementdata.c to determine which menu each element is shown in. Don't put any elements in SC_TOTAL, SC_TOTAL is the total number of menus. Only menus with a number from 0 to SC_TOTAL-1 will be displayed.
    #define SC_WALL 0
    #define SC_ELEC 1
    ...
    #define SC_LIFE 10
    #define SC_TOOL 11
    #define SC_CRACKER 13
    #define SC_CRACKER2 14
    #define SC_TOTAL 12


    A little further down, there is an array with information about the menus.
    static menu_section msections[] = //doshow does not do anything currently.
    {
    {"\xC1", "Walls", 0, 1},
    {"\xC2", "Electronics", 0, 1},
    {"\xD6", "Powered Materials", 0, 1},
    ...
    };

    There must be one row for each menu less than SC_TOTAL, and they must be in the same order as the menu numbers defined with "#define SC_WHATEVER"

    Now look at the structure used for this array:
    struct menu_section
    {
    char *icon;
    const char *name;
    int itemcount;
    int doshow;
    };
    typedef struct menu_section menu_section;

    The first column is a character used as an icon for the menu (TPT uses a custom font, and some icons are stored in it). \x means that the number following it is hexadecimal, and refers to a character.
    So \xC1 is ASCII character 193, which in TPT's custom font is the icon for the walls menu.

    The second column is the name for the menu, which will be displayed when you move your mouse over it. The third column (itemcount) is the number of elements in the menu - set this to 0, TPT calculates this automatically on startup. doshow is whether the menu should be shown, but it doesn't do anything at the moment. Set it to 1.


    So to add a menu:
    Define a new SC_WHATEVER, using the current value of SC_TOTAL.
    #define SC_WHATEVER 12
    Increase the value of SC_TOTAL by 1
    #define SC_TOTAL 13
    Add a line to the msections array in the right place (if SC_TOTAL was originally 12, then add it just after the "Tools" line).
    {"\xD2", "New things", 0, 1},