Log in to reply

Why does Native UI cause Vertigo?

  • I haven't figured out how to run code with Native UI in VB.NET, i hope it's possible but have no clue how to do it and the VB.NET experts are likely long gone and retired or don't come here. So I'm back to C# but it's making me nauseous.

    Any one know what causes the spinning, seems to happen only the first time menu is called and can be stopped by the mouse. I'm using the Native UI Empty template as my base template. In passing, all the cars are just from hitting spawn peds inside car repeatedly.

  • @JohnFromGWN Converted several hundred lines of code from VB.Net to C#, really just a search and replace exercise. Sometimes the code is case sensitive. Hundreds of lines because I'm spawning peds with component variations, i.e. every ped is customized through the script.

    Still have that awful spinning, scared I'm going to puke all over my KB. JK.
    It is annoying as hell though.

    Menu progressing nicely otherwise. Will replace some of my fav Menyoo functions in the process.


    NativeUI has a cursor, which spins the camera in the direction you hit the screen border.

    This seems to be a non-configurable feature of NativeUI. I saw a commit last year that allows disabling NativeUI's cursor feature, but the released NativeUI version doesn't have that yet.

    Might I suggest switching to LemonUI? It's a replacement for NativeUI, and from what I've heard, switching over is pretty easy since they're similar. It's also actively maintained, which is always nice for feature requests and bug reports.

  • @ikt Thank you again for your help. Started the conversion to Lemon UI, mostly just doing search and replace, but I hit a frustrating snag. I'm unable to get the .AddSubMenu method right.
    I've tried many different syntax by trial and just error and nothing works. All the code above and below this was correctly converted.
    Documentation says NativeMenu.AddSubMenu but this gives VS errors.

    This is the current working code from NativeUI. Can you help?

    var MenuPeds = GTA_MenuPool.AddSubMenu(menu, "Peds"); //Level 1
    //First Option for Peds, it is a subMenu

    var SMenuGangs = GTA_MenuPool.AddSubMenu(MenuPeds, "Female Gangs");//Level 2, submenu

    My hit and miss trys, included
    ObjectPool.LemonUI.Menus.NativeMenu.AddSubMenu(Menu, "Peds");
    ObjectPool.NativeMenu.AddSubMenu(Menu, "Peds");

    i also tried explicit rather than variable as suggested by VS.


    I never used NativeUI nor LemonUI, maybe the author could help you?

    I think you need to remove the string argument - but then again, never used it.

  • @ikt Ok thanks. The documentation is of very little use, too superficial for someone new to UI functions.
    The author provides a guide on how to migrate from Native to Lemon, and thankfully I was not that deep in to Native.
    All the replacements in his guide worked as did adding items such as buttons.
    However it's very disappointing that the author, while givings examples for just about everything, explicitly neglects sub menus - probably the most common and useful item. Again, I'm not a programmer and C# is definitely foreign to me, so I'm obviously missing the obvious.
    I could use some Lemon Aid (bad joke), I'll keep trying to fix it myself.
    P.S. I haven't even checked, removing the sub menus, if the spin is there or not.
    And to add to the fun, once I have this sorted out I really want to make it work in VB.Net.

  • This post is deleted!

  • @ikt Was able to figure it out. Works fine. Just need to populate the menus now. Thanks again for pointing me in the right direction.

  • @JohnFromGWN If anyone is interested, new to modding like myself, I'll gladly share code or help.
    Here are the basics for using LemonUI to create your own menus.
    You have a container called Object Pool, then Menus, Submenus, and items.
    You can add checkboxes, listboxes, etc.

        private static readonly ObjectPool pool = new ObjectPool();
        private static readonly NativeMenu menu = new NativeMenu("GTA V Custom", " ", " ");
        private static readonly NativeMenu submenuPed = new NativeMenu("Peds", "Ped Gangs", "");
        private static readonly NativeItem Ballas = new NativeItem("Ballas and Family", "");

  • I know you've already converted to LemonUI, but for anybody wondering how to disable the mouse in NativeUI, use the UIMenu.MouseControlsEnabled and/or UIMenu.MouseEdgeEnabled properties.

    Example: https://gitlab.com/Jitnaught/ropecreator-gta5/-/blob/45bb7045b66e8a426d5e3a963c6ba4286ef3d22e/RopeCreator/Menu.cs#L387

  • @Jitnaught Good to know thank you. I had to convert code from Native to Lemon, and VB.Net to C#.
    This was no fun. I did get stuck on one important line, and being tired I left it as is.
    Wondering if you could help me?
    Author uses controlpress rather than keys, and I was unable to modify this - through intellisense or lack of documentation.
    This means a loss of flexibility because currently only z key will enable menu. I tried quite a few variations, but this led to ripple issues with the tick function.
    I think the way it is now, using EventArgs rather than KeyEventArgs is causing the grief, but can't change it to e.keys and can't find a way using ControlJustPressed.

    `private void Basics_Tick(object sender, EventArgs e)

             if (Game.IsControlJustPressed(0, Control.MultiplayerInfo) && !menu.Visible && !submenuPed.Visible)
                menu.Visible = true;

  • @JohnFromGWN
    Something like this?

    //i'm guessing this is what the constructor is named
    public Basics()
    	//the other code already in here
    	KeyDown += Basics_KeyDown;
    private void Basics_KeyDown(object sender, KeyEventArgs e)
    	if (e.KeyCode == Keys.Z)
    		menu.Visible = true;

    Make sure to add using System.Windows.Forms; to the top so you can use Keys. And remove the control pressed code from the Tick function.

    If this mod is going to be compiled, and you want to have the key customizable:

    Keys toggleKey;
    public Basics()
    	toggleKey = Settings.GetValue<Keys>("Settings", "ToggleKey", Keys.Z); //Z is default key if no INI file found
    	//the other code already in here
    	KeyDown += Basics_KeyDown;
    private void Basics_KeyDown(object sender, KeyEventArgs e)
    	if (e.KeyCode == toggleKey)
    		menu.Visible = true;

    and the INI file:

    ToggleKey = Z

    Apologies for any errors, wrote the code in notepad.

  • Also, I recently converted a mod of mine to LemonUI (pushed it to GitLab today), maybe the code could be of some use for you: https://gitlab.com/Jitnaught/ropecreator-gta5/-/blob/master/RopeCreator/Menu.cs

    Here is the diff of what was changed from NativeUI to LemonUI: https://gitlab.com/Jitnaught/ropecreator-gta5/-/compare/45bb7045b66e8a426d5e3a963c6ba4286ef3d22e...4e19e0d9b38214417b7f7879dfd043f3dbc8dc71?view=parallel#0b7a54ec0d77cb409dc12336ef0e3a6ed7602afd (scroll down to RopeCreator/Menu.cs)

  • @Jitnaught A picture is worth a thousand......well you know. Once again, you are amazing.

    alt text

  • @Jitnaught Code examples are a great way to learn. Thank you for sharing. When I joined 3 months ago I wouldn't have thought I'd be creating my own menus - and in C#. :)

Log in to reply

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.