Log in to reply

[TOOL][WIP][C++/SHV] Lightweight Menu Library


    Lightweight menu library

    Left: Interaction menu, Right: Native Menu

    Speed comparison between interaction menu and this native menu.

    Native Menu is going to be a C++ library to get Rockstar-like menus in your ScriptHookV mods.

    SOURCE & Example


    • :ballot_box_with_check: Simple fast menu
    • :ballot_box_with_check: Simple nesting model
    • :ballot_box_with_check: Native controls
    • :ballot_box_with_check: Custom rebindable keyboard controls
    • :ballot_box_with_check: Incremental navigation speed
    • :ballot_box_with_check: Item descriptions with word wrap
    • :ballot_box_with_check: Safe zone adaption
    • :ballot_box_with_check: Aspect ratio adaption
    • :ballot_box_with_check: Custom banners
    • :ballot_box_with_check: Remember last location
    • :tools: Visually similar to GTA V's menus (WIP)
    • :ballot_box_with_check: Image support in OptionPlus()

    Missing / In progress:

    • :negative_squared_cross_mark: Badges
    • :negative_squared_cross_mark: Mouse/cursor support
    • :negative_squared_cross_mark: Radar remove for longer lists
    • :question: Library usage

    A few months ago, I wanted a menu for some of my mods, since none NativeUI-like menu was available. It looked and worked quite differently when I first got my hands on the original source code - since then I've added, removed, refactored a bunch of things, making it look and feel like it does now.

    Usage and release

    Right now, I'm not sure what release approach should be taken here. During the development I used it in my own mods by just building the source files along with the mod project, but now I'm getting to a phase where I actually want to distribute it, I'm wondering about the implementation preferences of possible users. There are basically two options:

    • Full source code. This means the project can be cloned/copied from Git, where you actually build the source along with your project. This gives control over what menu version you're using and might prevent incompatibilities from happening. It will also allow you to change some implementation details if desired. Every change in the menus you wish to incorporate, will need a recompilation of your project though.
    • As a library. This means you'll be linking against NativeMenu.lib, and the user has a NativeMenu.dll - just like ScriptHookV.lib/ScriptHookV.dll. This puts me in control of distributing menus, but for the off chance of me messing with the API, you'll need to update your mod, or me having to distribute it as another library name to prevent incompatibilities.

    Are there any preferences under SHV mod developers? Please let me know.


    No official releases yet, as it's still rather WIP. I'd like to add AR and safe zone adaption and make a final decision on the menu usage.

    The menu's still in development, so I'll still be adding/changing features. Beware of this if you choose to use it now already. The final goal would be to have a featureset similar to NativeUI.


    Menu usage poll

    So I have an indication of how/what the preference is. In case it'd be a library like NativeUI, I'll probably need to work longer on it.

  • Pretty cool.
    But why does everybody like the default menu style so much? xD

  • @ikt Amazing work, A substitute for NativeUI was indeed very much needed. Any FPS hit while accessing these mod menu in game screen?


    Thanks! Default aesthetics work probably. :p

    None, but beware that it's for SHV, not SHVDN sadly.

  • @ikt ah yeah, right, as the title reads, my bad, I missed it. Anyways, good work.
    I wonder if any one would be making new menu plugin available for C#, AFAIR, LeeC was working on some similar thing for C#, I am unsure though. Thanks anyways.

  • @ashishcw What's wrong with NativeUI?


    Eats ~30 FPS when opened.


    @ikt the 1 / 4 should place next to C++ MENU SHOWCASE

    and the blue bar between menu items and item description should only show when item is more than 10

  • @ikt Is good to see modders interested in enhance the menu experiences.
    Other guys like LecLee or Rarefacer are developing good menu styles with not performance issues:

    LeeC2202 Menu

    Rarefacer Menu


    Got some interesting updates!

    • :ballot_box_with_check: Safe zone adaption
    • :ballot_box_with_check: Aspect ratio adaption
    • :ballot_box_with_check: Custom banners

    First off - safe zone and aspect ration are fully implemented! This does change the coordinates again, this time they are relative to the safe zone from the upper-left. The width of the menu also stays constant for different aspect ratios, like the original interaction menu. Custom banners also are changed along with all of this.
    Sadly the custom banners (external textures) have a slight 1px offset depending on aspect ratio, safe zone and resolution. Any advice here would be welcome. It looks perfect for 16:9 resolutions though.

    Another feature I added is auto-fitted titles! Default-sized titles longer than the width will be resized to fit. If they are still too long after becoming half the size of the title, they'll be split.


    There are a few things to pay attention to:

    • Menu origin is changed to top-left instead of top-center. Putting it at (0,0) now puts it flush to the safe zone borders.
    • Custom background is always drawn on top of the game. Titles will not show here.
    • Custom background works on a handle. You should create the texture in your code first. This was chosen to prevent any path handling peculiarities.

    To finish up I'll need to see how the blue bottom bar can be changed when a non-standard background is chosen.

    Changes are live on GitHub, so there's not much of a release ^^'

    This will stay as a "statically" linked library for a while, as I found out I still have a few API-touchy things to change.

  • @ikt hmm, I will have to take a look at that auto-fitted titles code and safezone code :sunglasses:

  • Looking good.

    @ikt If it's a dynamic library it might become a DLL hell if there are multiple versions and multiple scripts using it.


    @Zerovv said in [TOOL][WIP][C++/SHV] Lightweight Menu Library:

    Looking good.

    @ikt If it's a dynamic library it might become a DLL hell if there are multiple versions and multiple scripts using it.

    Yeah, that's why I'll probably only do that when I'm very very very sure the API isn't changing any more. Right now I'm having SHVDN mods relying on different versions of NativeUI :(. Don't want that to happen with this. Static is fine for now. Heck, it's as source even, could be used like a git submodule to lock in specific versions if somebody wants.


    Image support! If you grab the resolution (or hard-code it...) images are displayed with their correct aspect ratios too. It again works with a handle, so read the files yourself. In the example I used a simple PNG header reader. Should be fine for you too since Alexander Blade recommends using PNGs anyway.

    The image support is embedded into OptionPlus and will show in the extra pane. Since OptionPlus supports a vector of strings as extra arguments to display, any of those strings can be !IMG:<file handle>W<height>H<width> and it will be parsed as an image. There's a small padding to the top and sides. As demonstrated, you can see that text appears normally above and below the image.

    Ignore the... uh... cringy test images. :^)

    I'll see how/if I can also implement this in my Addon Spawner, since I planned it to be user-interactionless as possible (in the setup steps).

    Update: That wasn't too bad. Somewhat concerned about performance since I do it in a dumb way, but oh well.


    Next update for this you should be able to make a AddonSpawner/img/<modelname>.png and it'll show up (if the model names match of course).

    I also saw LeeC2202 and ReNNie with Pick Your Ride! basically having the same. I wasn't aware of that existing, but seems like we kinda ended up in the same result, with different approaches :p


    I just changed the background of the footer (the thing with the up/down arrow and number of options) to solid black per default, and added an option to set a custom footer per (sub)menu. Would this be the right way to go about this? Not sure about the changed default, but it sure does look cleaner.
    No option for a texture since it would be drawn on top of the numbers anyway.

  • @ikt I have a problem. If I open the example/the base I am getting many errors. Do you know what I have to do. Maybe I am just too stupid to do it right. Hopefully can you help me. :)

    PS: I love the pics of this menu base ;)


    The folder structure of the base and the example should be as described in the base's readme.

    I might have changed a few things over time though, so I'll verify if I didn't mess up something.

    Edit: Example still builds, so make sure your folders and dependencies are set up properly.

  • @ikt Thanks for your help :D


    Some new updates:

    • Fix custom texture/image positions for >16:9 aspect ratios and multi-monitor resolutions. Haven't tested properly on real 21:9 monitors or triple screen setups, just used the commandline file for custom (borderless) testing.
    • Add instructional buttons scaleform (just Accept/Back right now).

    Due to me using std::any (basically borrowing SHVDN's Scaleform handling) you need to update your project to C++17, if you use this menu. SimpleIni's also gotten an update (for C++17), so remember to update the submodules too.
    If you used SimpleIni in your own project, remember to update that too.

    Further plans for instructional buttons: Basically find a way to bind them to menu options, but this entire thing has been getting messy. A full OO rewrite + restructure could help but that's gonna take time, effort and breaks compatibility.

  • @ikt This can work on C+ or only on c++?

  • @sp75

    Aside from the fact that this thread is 6 years old, assuming you're not a bot, did you just invent a new language called c+?

  • @JohnFromGWN ok like a bot i was wrong C# :laughing:

  • @sp75 don't underestimate the bots.

Log in to reply

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