Skip to content

Latest commit

 

History

History
110 lines (74 loc) · 5.21 KB

README.md

File metadata and controls

110 lines (74 loc) · 5.21 KB

ScriptHookV Menu Base

This is intended as a simple menu for ScriptHookV scripts, which mimics the looks of the game's menus.

Comparison

Building

Requirements:

Add this repository as submodule:

git submodule add https://github.com/E66666666/GTAVMenuBase

Example implementations

Full menu example:

Usage

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 void std::function, so a function is called when the menu gets opened. The function can be nullptr if no functionality is desired.
  • 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.

Input handling

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.

Details

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.

Changes

Questions/Suggestions/Discussion

Feel free to use the issues, or post in the thread on the GTA5-Mods forums.

Remarks

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!

Credits