manups4e / ScaleformUI

ScaleformUI is a GTA menu styled API made with custom Scaleforms to be lighter, faster and visually better
Other
141 stars 49 forks source link

[PauseMenu] Error when trying to add SubmenuTab #161

Closed nicxes closed 1 year ago

nicxes commented 1 year ago

I am developing two menus - one for account creation and one for career selection. The account creation menu works perfectly, but I encounter an error when trying to implement similar functionality in the career selection menu.

Here's the working code for the account creation menu:

private static void CreateMenu()
{
    TabView pauseMenu = new TabView("User Account", "Here you can manage, create or select an account to use on GTA Americas.", "", "", "");
    pauseMenu.CanPlayerCloseMenu = false;
    pauseMenu.FocusLevel = 1;

    SubmenuTab multiItemTab = new SubmenuTab("CREATE");
    pauseMenu.AddTab(multiItemTab);

    TabLeftItem second = new TabLeftItem("Information", LeftItemType.Info);
    TabLeftItem fourth = new TabLeftItem("Account Details", LeftItemType.Settings);

    second.UpdateBackground("scaleformui", "pauseinfobg", LeftItemBGType.Full);
    fourth.UpdateBackground("scaleformui", "pausesetsbg", LeftItemBGType.Resized);

    multiItemTab.AddLeftItem(second);
    multiItemTab.AddLeftItem(fourth);

    second.RightTitle = "Welcome";
    second.AddItem(new BasicTabItem("Content Text"));

    SettingsItem usernameItem = new SettingsItem("Username", "");
    SettingsItem passwordItem = new SettingsItem("Password", "~c~**********");
    SettingsItem confirmItem = new SettingsItem("Confirm Password", "~c~**********");
    SettingsItem emailItem = new SettingsItem("Email", "");
    SettingsItem createItem = new SettingsItem("Create Account", "")

    createItem.OnActivate += (item) =>
    {
        pauseMenu.Visible = false;
        CreateAccount();
    };

    fourth.AddItem(usernameItem);
    fourth.AddItem(passwordItem);
    fourth.AddItem(confirmItem);
    fourth.AddItem(emailItem);
    fourth.AddItem(createItem);

    pauseMenu.Visible = true;
}

For the career selection menu, I'm using similar code, but it results in an error. I've attached a screenshot of the error below.

image

Additionally, I noticed that removing the following lines from the account creation menu also results in an error. However, removing or adding these lines in the career selection menu does not change the error that I'm encountering.

infoItem.UpdateBackground("scaleformui", "pauseinfobg", LeftItemBGType.Full);
accountItem.UpdateBackground("scaleformui", "pausesetsbg", LeftItemBGType.Resized);

Here is the Careers Menu code:

private static void CreateCareersMenu()
{
    TabView pauseMenu = new TabView("Careers", "Start by selecting your first career path.", "", "", "");
    pauseMenu.CanPlayerCloseMenu = false;
    pauseMenu.FocusLevel = 1;

    /*
     * Welcome
     */
    TextTab welcomeTab = new TextTab("WELCOME", "Welcome");
    welcomeTab.AddItem(new BasicTabItem("Content.\n\n"));
    pauseMenu.AddTab(welcomeTab);

    /*
     * Create
     */
    SubmenuTab createTab = new SubmenuTab("CREATE");
    pauseMenu.AddTab(createTab);

    TabLeftItem infoItem = new TabLeftItem("Information", LeftItemType.Info);
    TabLeftItem accountItem = new TabLeftItem("Account Details", LeftItemType.Settings);

    infoItem.UpdateBackground("scaleformui", "pauseinfobg", LeftItemBGType.Full);
    accountItem.UpdateBackground("scaleformui", "pausesetsbg", LeftItemBGType.Resized);

    createTab.AddLeftItem(infoItem);
    createTab.AddLeftItem(accountItem);

    pauseMenu.Visible = true;
}

Any assistance in resolving this issue would be greatly appreciated. Thank you!

manups4e commented 1 year ago

you posted the error.. but did you check the line the error occurs? it's a NullReferenceException, it means something in your code is null, if i could see the line number in your error it would help me finding the bug.

manups4e commented 1 year ago

ok so after investigated about the error you're getting 🤔 it seems some checks were missing. i fixed it and i'm gonna release so you can update your library and fix the problem 😄 https://github.com/manups4e/ScaleformUI/commit/ce7af8dcedf82b6049422b7434c7df992436dea5