Log in to reply
 

Adding a menu at runtime? (NativeUI)



  • Is it possible? Because whenever I add a sub-menu, I get a "Collection was modified; enumeration operation may not execute" exception. This is kind of crucial for the feature I'm trying to make, any help would be much appreciated. I know there is probably some kind of loop going on when I call "ProcessMenus" (that is where the log file is pointing to) so do I have to make a hack-ish way of drawing menus myself, by making a custom MenuPool? I hope not :(



  • Alright, I solved my own problem... I did have to draw the menus myself. It does feel very hackish, but what can you do :(

                foreach(UIMenu menu in _menuPool.ToList().ToList())
                {
                    menu.Draw();
                    menu.ProcessMouse();
                    menu.ProcessControl();
                }
    

    The double ToList() is neccessary for some reason, probably because there's some kind of NativeUI's own enumeration going on behind-the-scenes. It does work btw.

    If anyone finds a better way, please let me know!



  • Is there any documentation for NativeUI? There is obviously, right? Glad you figured it out.



  • @JZersche said in Adding a menu at runtime? (NativeUI):

    Is there any documentation for NativeUI? There is obviously, right?

    Have a look at this Getting Started page for NativeUI, this is probably the most verbose page of them all. https://github.com/Guad/NativeUI/wiki/Getting-Started

    The documentation on the Pause Menu page says:

    "Base class is TabView, then keep adding items that inherit TabItemBase. No mouse control yet."

    That's it... that's the whole Pause Menu documentation.

    Typically, documentation for GTAV libraries varies from non-existent, to barely useful.



  • @LeeC2202 I haven't actually started using the TabView but I suppose its just as simple as adding items to a menu.



  • @AHK1221 The problem that I and other people had, was that TabView and TabItemBase are never mentioned anywhere else. There's no sample code or documentation for those items. Someone requested a sample, and Guad gave them a link to that documentation page. :\

    As for the question (sorry for the digression) I get this a lot when I am trying to modify collections I am iterating through... I am always using Dictionary<> for things and I always forget about changing the contents during a foreach loop. I had seen the ToList() solution but I hadn't seen one that requires a double ToList().

    That's an interesting one... but at least you sorted it, which is the main thing. :slight_smile: I don't use NativeUI now so I couldn't offer much help I am afraid.



  • What other alternatives are there to NativeUI? How would a GTA V Menu be created without it, or how could one? You could just create your own menu in C#, right? Why not do that? The advantages and disadvantages of NativeUI, are?



  • This is purely an answer from my own perspective...

    1. What other alternatives are there to NativeUI?

    None, it is the only publicly available library of its kind for GTAV... as far as I know.

    1. How would a GTA V Menu be created without it?

    By doing the same thing as NativeUI does, place on-screen text-elements, rectangles etc...

    1. You could just create your own menu in C#, right? Why not do that?

    I don't use NativeUI because that's exactly what I did... I wrote a menu library. I had intended on making it available to everyone but the further it went, the more I believed it was not up to the standard required for everyone to use. That was something I stated when I started the project and I was right to voice my concerns. I made some bad design choices that I could work around but that's not an acceptable way to have a library other people might use.

    1. The advantages and disadvantages of NativeUI, are?

    The advantage is that it is convenient because the hard part is already done. The menu drawing, the event handlers etc... it's all done for you. The disadvantage is that it is a massive drain on performance for many people. I managed to demonstrate a performance hit of around 50fps with a single menu on screen.

    It is far from perfect but there are no alternatives. The FPS hit has been known about for a long time, yet nothing has been done about it. Libraries require ongoing maintenance and extensive support but the libraries for GTAV, seem to be written by people who don't seem motivated by the end users.

    I wish I was better at what I did to be able to provide a solution for everyone... but the reality is, I'm simply not. I know my limitations but I still make the mistake of planning things beyond what I am capable of. I ended up with an alternative, yet limited menu system that serves my purpose but annoyingly, everyone else is still stuck with the same problem. :(


Log in to reply
 

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