-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
Visual Studio (NativeUI IV was compiled with 2019 version)
Grand Theft Auto IV: The Complete Edition (1.2.0.59)
ScriptHookDotNet by Priler
NativeUI IV
You need to add references before you can make your own menu. In Visual Studio, at the panel on the right, right click References -> Add Reference... -> Browse... and select 2 .dll files - ScriptHookDotNet.dll inside of ScriptHookDotNet\scripts\for Developers\bin and NativeUI.net.dll.
It is necessary to look at NativeUIExampleMenu to learn how to make your menu mod work, it contains many examples of what and how can be done.
You can create a menu by using the Menu class.
The constructor of the Menu class needs 3 parameters: your script instance (this), title of the menu and the description of the menu. It has 3 overloads, 2 of them are accepting title image of the menu. You can change the title image of the menu by creating new Texture/Image with a image of the size 432x98 using built in into NativeUI IV function Resource.LoadTexture()/Resource.LoadImage(). Then you can pass your newly created Texture/Image as the fourth parameter of the Menu constructor. Texture is used for .png images, Image is used for .gif images.
1. No image
Menu menuMain = new Menu(this, "NativeUI IV", "NATIVE IV SHOWCASE");
2. With Texture
Texture menuMainTitleImage = Resource.LoadTexture(basePath, "MenuTitleImageMain.png");
Menu menuMain = new Menu(this, "NativeUI IV", "NATIVE IV SHOWCASE", menuMainTitleImage);
3. With Image
Image menuMainTitleImage = Resource.LoadImage(basePath, "MenuTitleImageMain.gif");
Menu menuMain = new Menu(this, "NativeUI IV", "NATIVE IV SHOWCASE", menuMainTitleImage);
Menu accepts many properties that you can get, set and get/set:
UpKey - Key for navigating up in the menu
DownKey - Key for navigating down in the menu
LeftKey - Key for navigating left in the menu
RightKey - Key for navigating right in the menu
AcceptKey - Key to confirm the selection in the menu
BackKey - Key to go back to previous menu
CanControlCharacter - This will disable the movement of the player when the menu is opened and re-enables it when the menu closes
EnableControllerSupport - This enables the support for navigating through the menu with a controller
EnableMenuSounds - This will enable or disable menu sounds
InfiniteScroll - This will enable or disable infinite scrolling in menu
TitleImageFrameRate - Gets or sets the frame rate of title image
MaxItemsVisibleAtOnce - Gets or sets how much items the menu can display at once
Offset - Gets or sets menu offset
TitleTextOffset - Gets or sets title text offset
ShowTitle - Gets or sets title visibility
ShowDescription - Gets or sets description visibility
ShowArrows - Gets or sets arrows up-down visibility
ShowGaps - Gets or sets gaps visibility
TitleBackColor - Gets or sets title back color
TitleImage - Sets title image
TitleText - Gets or sets title text
TitleTextColor - Gets or sets title text color
TitleTextFont - Gets or sets title text font
TitleLineColor - Gets or sets title line color
DescriptionBackColor - Gets or sets description background color
DescriptionText - Gets or sets description text
DescriptionTextColor - Gets or sets description text color
DescriptionTextFont - Gets or sets description text font
SelectedIndexTextColor - Gets or sets selected index text color
SelectedIndexTextFont - Gets or sets selected index text font
Items - A collection of all items currently available in this menu
NoItemsBackColor - Gets or sets no items back color
NoItemsText - Gets or sets no items text
NoItemsTextColor - Gets or sets no items text color
NoItemsTextFont - Gets or sets no items text font
ArrowsUpDownBackColor - Gets or sets up-down arrows background color
IconsArrowUp - Sets up arrow icons
IconsArrowDown - Sets down arrow icons
IsMenuOpened - Gets the visibility state of this menu
SelectedIndex - Gets the currently selected item index of this menu
Instance functions:
Add(Item) - Add an item to the menu
AddRange(Item[]) - Adds an array of items to the menu
Remove(Item) - This removes the specific item from the list
RemoveAt(int) - This removes the specific item from the list through it's index
RemoveAll() - This removes all items from the menu
Restore() - Restores menu
Non instance functions:
Show(Menu) - Starts drawing the menu on screen
Hide() - Hides all menus
IsAnyMenuOpen(Script) - Checks if any menu of specified script is opened right now
GetCurrentMenu(Script) - Gets currently opened menu of specified script
GetAllMenus(Script) - Gets all menus of specified script
Current version of NativeUI IV features 4 items: button, checkbox, list and slider.
It is advised to create items with nested menus\events right away, they can always be added later.
Shared properties:
ShowDescriptionLine - Gets or sets description line visibility
ShowDescription - Gets or sets description visibility
TitleBackColors - Title back colors
TitleText - The title text of the element
TitleTextColors - Title text colors
TitleTextFonts - Title text fonts
DescriptionLineColors - Description line colors
DescriptionBackColors - Description back colors
DescriptionText - The description text of the element
DescriptionTextColors - Description text colors
DescriptionTextFonts - Description text fonts
IsEnabled - Gets or sets if the element is enabled or not
IsSelected - Gets if the current item is selected or not
Type - The type of the item
Shared methods:
Instance functions:
Restore() - Restores item
The constructor of the Item.Button class needs 4 parameters:
- Menu menu
- string titleText
- string descriptionText
- bool isEnabled
Item.Button features 4 overloads.
Examples:
1. No nested menu, no events
Item.Button itemMainButtonsButton1 = new Item.Button(menuMainButtons, "Button", "Clickable", true);
2. Nested menu, no events
Item.Button itemMainButtonsButton1 = new Item.Button(menuMainButtons, "Button", "Clickable", true, menuMainButtonsButton1);
3. No nested menu, events
Item.Button itemMainButtonsButton1 = new Item.Button(menuMainButtons, "Button", "Clickable", true, itemMainButtonsButton1_OnClick);
4. Nested menu, events
Item.Button itemMainButtonsButton1 = new Item.Button(menuMainButtons, "Buttons", "Clickable", true, menuMainButtonsButton1, itemMainButtonsButton1_OnClick);
menuMainButtonsButton1 is Menu. It can be added later with itemMainButtons.NestedMenu = menuMainButtonsButton1.
itemMainButtonsButton1_OnClick is OnClick event. It can be added later with itemMainButtonsButton1.OnClick += itemMainButtonsButton1_OnClick.
Button properties:
Icon - Gets or sets if button icon should be displayed
Icons - The icons for this item
IconLocation - The location of the icon
NestedMenu - Gets or sets the nested menu for this item
The constructor of the Item.CheckBox class needs 5 parameters:
- Menu menu
- string titleText
- string descriptionText
- bool isChecked
- bool isEnabled
Item.CheckBox features 2 overloads.
Examples:
1. No events
Item.CheckBox itemMainCheckBoxesCheckBox1 = new Item.CheckBox(menuMainCheckBoxes, "Checkbox (checked)", "Clickable, can be unchecked/checked", isChecked: true, isEnabled: true);
2. Events
Item.CheckBox itemMainCheckBoxesCheckBox1 = new Item.CheckBox(menuMainCheckBoxes, "Checkbox (checked)", "Clickable, can be unchecked/checked", isChecked: true, isEnabled: true, itemMainCheckBoxesCheckBox1_OnCheckedChanged);
itemMainCheckBoxesCheckBox1_OnCheckedChanged is OnCheckedChanged event. It can be added later with itemMainCheckBoxesCheckBox1.OnCheckedChanged += itemMainCheckBoxesCheckBox1_OnCheckedChanged.
CheckBox properties:
Mode - Gets or sets item mode (icon or text)
IsChecked - Gets or sets if the item is checked
Icons - The icons for this item
ToggleTexts - The toggle texts for this item
ToggleTextColors - The toggle text colors for this item
ToggleTextFonts - The toggle text fonts for this item
The constructor of the Item.List class needs 4 parameters:
- Menu menu
- string titleText
- string descriptionText
- bool isEnabled
Item.List features 4 overloads.
Examples:
1. No item list, no events
Item.List itemMainListsList1 = new Item.List(menuMainLists, "List", "Press Left or Right to navigate through the list.\nClickable", true);
2. Item list, no events
Item.List itemMainListsList1 = new Item.List(menuMainLists, "List", "Press Left or Right to navigate through the list.\nClickable", new List<string> { "Item 1", "Item 2", "Item 3" }, true);
3. No item list, events
Item.List itemMainListsList1 = new Item.List(menuMainLists, "List", "Press Left or Right to navigate through the list.\nClickable", true, itemMainListsList1_OnClick, itemMainListsList1_OnSelectedIndexChanged);
4. Item list, events
Item.List itemMainListsList1 = new Item.List(menuMainLists, "List", "Press Left or Right to navigate through the list.\nClickable", new List<string> { "Item 1", "Item 2", "Item 3" }, true, itemMainListsList1_OnClick, itemMainListsList1_OnSelectedIndexChanged);
itemMainListsList1_OnClick is OnClick event. It can be added later with itemMainListsList1.OnClick += itemMainListsList1_OnClick.
itemMainListsList1_OnSelectedIndexChanged is OnSelectedIndexChanged event. It can be added later with itemMainListsList1.OnSelectedIndexChanged += itemMainListsList1_OnSelectedIndexChanged.
List properties:
MaximumListWidth - Gets or sets the maximum width of the list
ShowArrows - This gets or sets arrows visibility
InfiniteScroll - This will enable or disable infinite scrolling in list
ItemList - Gets the item list
IconsArrowLeft - The left arrow icons for this item
IconsArrowRight - The right arrow icons for this item
SelectedTextColors - Selected text colors of the element
SelectedTextFonts - Selected text fonts of the element
List methods:
Instance functions:
Add(string) - Adds an items to the list of items
AddRange(string[]) - Adds an array of items to the list of items
Remove(string) - This removes the specific item from the list of items through it's name
RemoveAt(int) - This removes the specific item from the list of items through it's index
RemoveAll() - This removes all items from the list of items
The constructor of the Item.Slider class needs 7 parameters:
- Menu menu
- string titleText
- string descriptionText
- int minimumValue
- int maximumValue
- int currentValue
- bool isEnabled
Item.Slider features 2 overloads.
Examples:
1. No events
Item.Slider itemMainSlidersSlider1 = new Item.Slider(menuMainSliders, "Slider", "Press Left or Right to move slider, clickable", 0, 100, 0, true);
2. Events
Item.Slider itemMainSlidersSlider1 = new Item.Slider(menuMainSliders, "Slider", "Press Left or Right to move slider, clickable", 0, 100, 0, true, itemMainSlidersSlider1_OnClick, itemMainSlidersSlider1_OnCurrentValueChanged);
itemMainSlidersSlider1_OnClick is OnClick event. It can be added later with itemMainSlidersSlider1.OnClick += itemMainSlidersSlider1_OnClick.
itemMainSlidersSlider1_OnCurrentValueChanged is OnCurrentValueChanged event. It can be added later with itemMainSlidersSlider1.OnCurrentValueChanged += itemMainSlidersSlider1_OnCurrentValueChanged.
Slider properties:
SliderPositionOffset - Gets or sets the position offsets of the slider
SliderSizeOffset - Gets or sets the size offsets of the slider
SliderBorderSize - Gets or sets the size of the slider border
InfiniteScroll - This will enable or disable infinite scrolling in slider
MinimumValue - Gets or sets the minimum value of the slider
MaximumValue - Gets or sets the maximum value of the slider
CurrentValue - Gets or sets the current value of the slider
SliderBorderColors - The border colors of slider item
SliderBackColors - The back colors of slider item
SliderForeColors - The fore colors of slider item
If you are going to publish your mod on NexusMods, make sure to set NativeUI IV as a requirement for your mod.