This is intended as a simple menu for ScriptHookV scripts, which mimics the looks of the game's menus.
Requirements:
- ScriptHookV SDK by Alexander Blade
- Added such that
#include <inc/main.h>
can be found - Uses
natives.h
generated from Dot.'s Native DB (Compact vectors)
- Added such that
- simpleini 4.x
- Added such that
#include <simpleini/SimpleIni.h
can be found
- Added such that
Add this repository as submodule:
git submodule add https://github.com/E66666666/GTAVMenuBase
Example implementations
Full menu example:
Check GTAVMenuExample's implementation to see the source code.
update_menu()
is the main update loop. This should be called every tick.
Required methods inside update_menu()
:
CheckKeys
- accepts a
MenuControls
pointer and a voidstd::function
, so a function is called when the menu gets opened. The function can benullptr
if no functionality is desired.
- accepts a
EndMenu
- Draws all sprites that should be drawn, like backgrounds and check boxes, and draws any other additional information.
Required menus and items:
- Main menu
- Check the description how to do this
- Title
- You'll need to specify a menu title
For a more complete example (working build), check GTAVMenuExample.
MenuControls
does input checking, so it can distinguish between key press, key being pressed, key being released. This applies both to keyboard input (GetAsyncKeyState
) and native inputs (IS_DISABLED_CONTROL_PRESSED
). Conflicts/delays between these two shouldn't occur as that's handled in CheckKeys
: if a GetAsyncKeyState is detected, native controls are temporarily
blocked. This should prevent ghosting when a menu key is assigned to the same key the game
navigation controls are binded to.
There are two detail panes available:
- Info pane to the right
- Details pane below the menu
A menu option with the info pane on the right can be created with OptionPlus
. You can bind
functions to left/right press, and the original return-true-when-option-pressed
is also
still available. The pane can be filled with a string vector, where each item represents a new
line. As of now these aren't split automatically yet, so you'll need to manually manage the
line length. It's originally made to show short pieces of information.
Detail panes are available for all option types. It accepts a string vector. Each item in this vector is automatically split up so it fits nicely within the detail pane. A newline can be forced by adding more string items to the vector. For normal use a vector with a simple string should be enough.
- commit 173a499 moves the menu to the top left. This makes
(0.0f, 0.0f)
sit flush with the safe zone - commit 3b37182 restores the selected bool pointer requirement in OptionPlus
- commit ec9477b removes the automatic uppercase menu subtitle argument
- commit d7a1e72 updates to C++17 for
std::any
(changed tostd::variant
in commit a61461d) - commit d88ec66 requires the implementing project to include simpleini 4.x
- commit 3b165f0 uses compact vectors as generated by Dot.'s Native DB
Feel free to use the issues, or post in the thread on the GTA5-Mods forums.
If you're also not using ScriptHookVDotNet with NativeUI and just want something less painful than the mess that happens in the ScriptHookV Simple Trainer example, I hope this is of some use for you.
This thing started out as something I needed for VStancer where Unknown Modder on GTA5-Mods linked me the SudoMod menu sources.
Good luck modding!
- DireDan for the original implementation for sudomod
- Sudomod authors
- NativeUI authors
- alloc8or