Log in to reply
 

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



  • Lightweight menu library

    Comparison
    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

    Features

    • :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.

    Releases

    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?



  • @MAFINS
    Thanks! Default aesthetics work probably. :p

    @ashishcw
    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?



  • @MAFINS
    Eats ~30 FPS when opened.


  • TRANSLATOR

    @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.

    Imgur

    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.


  • MODERATOR

    @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.

    Imgur

    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



  • @ikt this is amazing. great work



  • 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.


Log in to reply
 

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