Jump to content

Recommended Posts

NativeUI Library

Download 1.9.1

ScriptHookVDotNet based library for easy and fast Rockstar-like menus.

nqD2Ty1.png

 

Features:

  • Support for simple buttons, checkboxes and lists.
  • Support for custom banners from game sprites and your own textures.
  • Easy nested menus for fast and painless nested menu system.
  • Controller support.
  • Mouse controls.
  • Custom instructional buttons.
  • Support for all screen resolutions.
  • Item descriptions.
  • Rebindable keys and controls.
  • Badges to decorate your items.
  • Event-based callbacks.

 

Installation

After installing ScriptHookVDotNet, copy NativeUI.dll to your scripts/ folder.

 

Usage

Add NativeUI.dll your references in Visual Studio just like you did with ScriptHookDotNet.dll and add "using NativeUI;" to the top of your script.

You can read the documentation at the wiki.

 

Changelog

- 1.9.1

-- Updated binary

- 1.9

-- See full changelog at https://github.com/Guad/NativeUI/releases

- 1.8

-- Published package to NuGet: https://www.nuget.org/packages/NativeUI

-- Added UIMenuDynamicListItem

-- Performance improvements

-- Proper multilang support

- 1.7

-- Fixed issue when UIMenuListItem had more than 100k items
-- Added mouse controls to TabView
-- Added TabInteractiveListItem
-- Added UIMenu.ScaleWithSafezone
-- Removed useless BarTimerBar.Text

- 1.6.1

-- Fixed Wasted & Busted messages not going away.

- 1.6

-- Added Timer bars.

-- Added pause menu style menus.

-- Added BigMessage class. See wiki for a tutorial.

- 1.5

-- Fixed crash related to instructional buttons. Thanks zorg93 for the find.

- 1.4

-- Compatibilities with ScriptHookVDotNet 2.0

-- Mouse controls are disabled when controller is used.

-- Bugfixes.

- 1.3

-- See github release for more information.

- 1.2

-- Cursor resets when menu is open. You can disable this setting ResetCursorOnOpen to false.

- 1.1

-- You can read the changelog here.

- 1.0

-- You can read the full changelog here.

- 0.9

-- Removed debug stuff from last release.

-- Lied a base for controller detection.

- 0.8

-- Menu mantains aspect ratio in all screen resolutions.

- 0.7

-- Added menu nesting methods: BindMenuToItem and ReleaseMenuFromItem

-- Added back/exit buttons.

-- Added a helper class, MenuPool, to easily call your process methods of all of your menus with just one method, ProcessMenus.

- 0.6

-- Added mouse controls. Place ProcessMouse() in your OnTick event.

-- Restyled the menu to look a lot more like an official Rockstar menu.

- 0.5

-- Added controller support.

- 0.4

-- Support for both keys and controls
-- Disabled phone when menu is open
-- Added Select support for list items

- 0.3

-- Fixed graphical errors when there were more than 12 items on screen.

- 0.2

-- Added badges.

- 0.1

-- Initial Release.

 

Distribution

Please, do not distribute the .dll with your mod. This causes many old versions floating around on the internet. Instead, point your users to this post.

 

Media

 

 

 

Screenshots were taken in 1.4

b8AP4PL.png

DrJDczM.png

 

 

 

 

Extra Credits

Thanks to jedijosh920 for helping out on natives and making it look a lot more like Rockstar, thanks man.

 

Sourcecode

You can find the source at https://github.com/Guad/NativeUI

Edited by Guad
Link to comment
https://gtaforums.com/topic/809284-net-nativeui/
Share on other sites

 

NativeUI Library

Download 0.3

ScriptHookVDotNet based library for easy and fast Rockstar-like menus.

ui.PNG

Features:

  • Support for simple buttons, checkboxes and lists.
  • Support for custom banners from game sprites.
  • Item descriptions.
  • Rebindable keys.
  • Badges to decorate your items.
  • Event-based callbacks.

Installation

After installing ScriptHookVDotNet, copy NativeUI.dll to your scripts/ folder.

 

Usage

Add NativeUI.dll your references in Visual Studio just like you did with ScriptHookDotNet.dll and add "using NativeUI;" to the top of your script.

 

 

You can create a menu by using the UIMenu class. This class provides 4 events: OnIndexChange, OnListChange, OnCheckboxChange and OnItemSelect.

UIMenu has two base parameters: the banner title and the subtitle. It also has an overload with a third Point parameter which determines the offset, and an overload for a custom sprites.

var myMenu = new UIMenu("Banner Title", "~b~SUBTITLE");

You may change the default Numpad navigation keys by changing the KeyUp-KeySelect properties.

myMenu.KeyUp = Keys.W;myMenu.KeyDown = Keys.S;myMenu.KeyLeft = Keys.A;myMenu.KeyRight = Keys.D;myMenu.KeySelect = Keys.Space;

Now you can start adding elements to your menu by using the AddItem(UIMenuItem item) method.

myMenu.AddItem(new UIMenuItem("Simple Button"));myMenu.AddItem(new UIMenuCheckboxItem("Simple Checkbox", false));myMenu.AddItem(new UIMenuListItem("Simple List", new List<dynamic> {"Item 1", "Item 2", "Item 3"}, 0));myMenu.AddItem(new UIMenuItem("Another Button", "Items can have descriptions too!"));myMenu.RefreshIndex();

After you have done adding items, you will have to set the index at 0 by using the RefreshIndex() method.

By using events, you can easily check when something has been changed.

myMenu.OnItemSelect += ItemSelectHandler; public void ItemSelectHandler(UIMenu sender, UIMenuItem selectedItem, int index){    UI.Notify("You have selected: ~b~" + selectedItem.Text);}

Finally, you will have to implement an open/close trigger for your menu by using the Visible property, and some other final touches like the Draw method in your Tick event handler, and ProcessKey method in your KeyDown handler.

public void OnTick(object o, EventArgs e){    myMenu.Draw();}public void OnKeyDown(object o, KeyEventArgs e){    myMenu.ProcessKey(e.KeyCode);    if (e.KeyCode == Keys.F5) // Our menu on/off switch    {        myMenu.Visible = !myMenu.Visible;    }}

 

 

 

Example Script

 

Simple script to showcase some of NativeUI's features.

using System;using System.Collections.Generic;using System.Drawing;using System.Windows.Forms;using GTA;using NativeUI;public class MenuExample : Script{    private UIMenu mainMenu;    private UIMenuCheckboxItem ketchupCheckbox;    private UIMenuListItem dishesListItem;    private UIMenuItem cookItem;    public MenuExample()    {        Tick += OnTick;        KeyDown += OnKeyDown;        mainMenu = new UIMenu("Native UI", "~b~NATIVEUI SHOWCASE", new Point(20, 10));        mainMenu.AddItem(ketchupCheckbox = new UIMenuCheckboxItem("Add ketchup?", false, "Do you wish to add ketchup?"));        var foods = new List<dynamic>        {            "Banana",            "Apple",            "Pizza",            "Quartilicious",            0xF00D, // Dynamic!        };        mainMenu.AddItem(dishesListItem = new UIMenuListItem("Food", foods, 0));        mainMenu.AddItem(cookItem = new UIMenuItem("Cook!", "Cook the dish with the appropiate ingredients and ketchup."));        cookItem.LeftBadge = UIMenuItem.BadgeStyle.Star;        cookItem.RightBadge = UIMenuItem.BadgeStyle.Tick;        mainMenu.RefreshIndex();        mainMenu.OnItemSelect += OnItemSelect;        mainMenu.OnListChange += OnListChange;        mainMenu.OnCheckboxChange += OnCheckboxChange;        mainMenu.OnIndexChange += OnItemChange;    }    public void OnItemChange(UIMenu sender, int index)    {        sender.MenuItems[index].LeftBadge = UIMenuItem.BadgeStyle.None;    }    public void OnCheckboxChange(UIMenu sender, UIMenuCheckboxItem checkbox, bool Checked)    {        if (sender != mainMenu || checkbox != ketchupCheckbox) return; // We only want to detect changes from our menu.        UI.Notify("~r~Ketchup status: ~b~" + Checked);    }    public void OnListChange(UIMenu sender, UIMenuListItem list, int index)    {        if (sender != mainMenu || list != dishesListItem) return; // We only want to detect changes from our menu.        string dish = list.IndexToItem(index).ToString();        UI.Notify("Preparing ~b~" + dish +"~w~...");    }    public void OnItemSelect(UIMenu sender, UIMenuItem selectedItem, int index)    {        if (sender != mainMenu || selectedItem != cookItem) return; // We only want to detect changes from our menu and our button.        // You can also detect the button by using index        string dish = dishesListItem.IndexToItem(dishesListItem.Index).ToString();        bool ketchup = ketchupCheckbox.Checked;        string output = ketchup            ? "You have ordered ~b~{0}~w~ ~r~with~w~ ketchup."            : "You have ordered ~b~{0}~w~ ~r~without~w~ ketchup.";        UI.ShowSubtitle(String.Format(output, dish));    }    public void OnTick(object o, EventArgs e)    {        mainMenu.Draw();    }    public void OnKeyDown(object o, KeyEventArgs e)    {        mainMenu.ProcessKey(e.KeyCode);        if (e.KeyCode == Keys.F5) // Our menu on/off switch        {            mainMenu.Visible = !mainMenu.Visible;        }    }}

 

 

 

Changelog

  • 0.3

Fixed graphical errors when there were more than 12 items on screen.

  • 0.2

Added badges.

  • 0.1

Initial Release.

 

Distribution

Please, do not distribute the .dll with your mod. This causes many old versions floating around on the internet. Instead, point your users to this post.

 

Sourcecode

You can find the source at https://github.com/Guad/NativeUI

 

I approve of this UI

Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067771047
Share on other sites

unknown modder

it says this : the primary reference "NativeUI" could not be resolved because it was built against the ".NETFramework,Version=v4.5.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5".

what does it mean?

go to your project settings and change the net framework to 4.5.2
Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067780539
Share on other sites

qiangqiang101
why isn't my code working?



Inherits Script

Private player As Player
Private playerPed As Ped
Private simeon As Ped
Private mainMenu As UIMenu

Public Sub menuExample()
AddHandler mainMenu.OnItemSelect, AddressOf ItemSelectHandler
AddHandler Tick, AddressOf OnTick
AddHandler KeyDown, AddressOf OnKeyDown

mainMenu = New UIMenu("NativeUI", "~b~NATIVEUI SHOWCASE")
mainMenu.SetKey(UIMenu.MenuControls.Up, GTA.Control.FrontendDown)
mainMenu.SetKey(UIMenu.MenuControls.Down, GTA.Control.FrontendUp)
mainMenu.SetKey(UIMenu.MenuControls.Select, GTA.Control.FrontendSelect)
mainMenu.SetKey(UIMenu.MenuControls.Back, GTA.Control.FrontendCancel)

mainMenu.AddItem(New UIMenuItem("Simple Button"))
mainMenu.AddItem(New UIMenuCheckboxItem("Simple Checkbox", False))
mainMenu.AddItem(New UIMenuListItem("Simple List", New List(Of Object)() From {
"Item 1",
"Item 2",
"Item 3"
}, 0))
mainMenu.AddItem(New UIMenuItem("Another Button", "Items Can have descriptions too!"))
mainMenu.RefreshIndex()
End Sub

Public Sub ItemSelectHandler(sender As UIMenu, selectedItem As UIMenuItem, index As Integer)
UI.Notify("You have selected: ~b~" + selectedItem.Text)
End Sub

Public Sub OnTick(o As Object, e As EventArgs)
'mainMenu.ProcessControl()
'mainMenu.ProcessMouse()
'mainMenu.Draw()
MenuPool.ProcessMenus()
End Sub

Public Sub OnKeyDown(o As Object, e As KeyEventArgs)
'mainMenu.ProcessKey(e.KeyCode)
If e.KeyCode = Keys.F9 Then
mainMenu.Visible = Not mainMenu.Visible
Else
mainMenu.Visible = mainMenu.Visible
End If
End Sub

Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067780604
Share on other sites

 

why isn't my code working?

 

Inherits Script     Private player As Player    Private playerPed As Ped    Private simeon As Ped    Private mainMenu As UIMenu     Public Sub menuExample()        AddHandler mainMenu.OnItemSelect, AddressOf ItemSelectHandler        AddHandler Tick, AddressOf OnTick        AddHandler KeyDown, AddressOf OnKeyDown         mainMenu = New UIMenu("NativeUI", "~b~NATIVEUI SHOWCASE")        mainMenu.SetKey(UIMenu.MenuControls.Up, GTA.Control.FrontendDown)        mainMenu.SetKey(UIMenu.MenuControls.Down, GTA.Control.FrontendUp)        mainMenu.SetKey(UIMenu.MenuControls.Select, GTA.Control.FrontendSelect)        mainMenu.SetKey(UIMenu.MenuControls.Back, GTA.Control.FrontendCancel)         mainMenu.AddItem(New UIMenuItem("Simple Button"))        mainMenu.AddItem(New UIMenuCheckboxItem("Simple Checkbox", False))        mainMenu.AddItem(New UIMenuListItem("Simple List", New List(Of Object)() From {                                            "Item 1",                                            "Item 2",                                            "Item 3"                                            }, 0))        mainMenu.AddItem(New UIMenuItem("Another Button", "Items Can have descriptions too!"))        mainMenu.RefreshIndex()    End Sub     Public Sub ItemSelectHandler(sender As UIMenu, selectedItem As UIMenuItem, index As Integer)        UI.Notify("You have selected: ~b~" + selectedItem.Text)    End Sub     Public Sub OnTick(o As Object, e As EventArgs)        'mainMenu.ProcessControl()        'mainMenu.ProcessMouse()        'mainMenu.Draw()        MenuPool.ProcessMenus()    End Sub     Public Sub OnKeyDown(o As Object, e As KeyEventArgs)        'mainMenu.ProcessKey(e.KeyCode)        If e.KeyCode = Keys.F9 Then            mainMenu.Visible = Not mainMenu.Visible        Else            mainMenu.Visible = mainMenu.Visible        End If    End Sub

 

 

 

What error does it show you?

You should change

If e.KeyCode = Keys.F9 Then            mainMenu.Visible = Not mainMenu.Visible        Else            mainMenu.Visible = mainMenu.Visible        End If

to

If e.KeyCode = Keys.F9 Then            mainMenu.Visible = Not mainMenu.Visible        End If
Edited by Guad
Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067781776
Share on other sites

qiangqiang101

 

 

why isn't my code working?

 

Inherits Script     Private player As Player    Private playerPed As Ped    Private simeon As Ped    Private mainMenu As UIMenu     Public Sub menuExample()        AddHandler mainMenu.OnItemSelect, AddressOf ItemSelectHandler        AddHandler Tick, AddressOf OnTick        AddHandler KeyDown, AddressOf OnKeyDown         mainMenu = New UIMenu("NativeUI", "~b~NATIVEUI SHOWCASE")        mainMenu.SetKey(UIMenu.MenuControls.Up, GTA.Control.FrontendDown)        mainMenu.SetKey(UIMenu.MenuControls.Down, GTA.Control.FrontendUp)        mainMenu.SetKey(UIMenu.MenuControls.Select, GTA.Control.FrontendSelect)        mainMenu.SetKey(UIMenu.MenuControls.Back, GTA.Control.FrontendCancel)         mainMenu.AddItem(New UIMenuItem("Simple Button"))        mainMenu.AddItem(New UIMenuCheckboxItem("Simple Checkbox", False))        mainMenu.AddItem(New UIMenuListItem("Simple List", New List(Of Object)() From {                                            "Item 1",                                            "Item 2",                                            "Item 3"                                            }, 0))        mainMenu.AddItem(New UIMenuItem("Another Button", "Items Can have descriptions too!"))        mainMenu.RefreshIndex()    End Sub     Public Sub ItemSelectHandler(sender As UIMenu, selectedItem As UIMenuItem, index As Integer)        UI.Notify("You have selected: ~b~" + selectedItem.Text)    End Sub     Public Sub OnTick(o As Object, e As EventArgs)        'mainMenu.ProcessControl()        'mainMenu.ProcessMouse()        'mainMenu.Draw()        MenuPool.ProcessMenus()    End Sub     Public Sub OnKeyDown(o As Object, e As KeyEventArgs)        'mainMenu.ProcessKey(e.KeyCode)        If e.KeyCode = Keys.F9 Then            mainMenu.Visible = Not mainMenu.Visible        Else            mainMenu.Visible = mainMenu.Visible        End If    End Sub

 

 

 

What error does it show you?

You should change

If e.KeyCode = Keys.F9 Then            mainMenu.Visible = Not mainMenu.Visible        Else            mainMenu.Visible = mainMenu.Visible        End If

to

If e.KeyCode = Keys.F9 Then            mainMenu.Visible = Not mainMenu.Visible        End If

No Error sir, just the menu is not showing

below is my full code

 

 

Imports SystemImports System.Collections.GenericImports System.DrawingImports System.Windows.FormsImports GTAImports GTA.NativeImports NativeUIImports System.LinqImports System.TextImports System.Threading.Tasks Public Class pdmcarshop    Inherits Script     Private player As Player    Private playerPed As Ped    Private simeon As Ped    Private mainMenu As UIMenu     Public Sub menuExample()        AddHandler mainMenu.OnItemSelect, AddressOf ItemSelectHandler        AddHandler Tick, AddressOf OnTick        AddHandler KeyDown, AddressOf OnKeyDown         mainMenu = New UIMenu("NativeUI", "~b~NATIVEUI SHOWCASE")        mainMenu.SetKey(UIMenu.MenuControls.Up, GTA.Control.FrontendDown)        mainMenu.SetKey(UIMenu.MenuControls.Down, GTA.Control.FrontendUp)        mainMenu.SetKey(UIMenu.MenuControls.Select, GTA.Control.FrontendSelect)        mainMenu.SetKey(UIMenu.MenuControls.Back, GTA.Control.FrontendCancel)         mainMenu.AddItem(New UIMenuItem("Simple Button"))        mainMenu.AddItem(New UIMenuCheckboxItem("Simple Checkbox", False))        mainMenu.AddItem(New UIMenuListItem("Simple List", New List(Of Object)() From {                                            "Item 1",                                            "Item 2",                                            "Item 3"                                            }, 0))        mainMenu.AddItem(New UIMenuItem("Another Button", "Items Can have descriptions too!"))        mainMenu.RefreshIndex()    End Sub     Public Sub ItemSelectHandler(sender As UIMenu, selectedItem As UIMenuItem, index As Integer)        UI.Notify("You have selected: ~b~" + selectedItem.Text)    End Sub     Public Sub OnTick(o As Object, e As EventArgs)        MenuPool.ProcessMenus()    End Sub     Public Sub OnKeyDown(o As Object, e As KeyEventArgs)        If e.KeyCode = Keys.F9 Then            mainMenu.Visible = Not mainMenu.Visible        End If    End SubEnd Class
  • Like 1
Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067781906
Share on other sites

 

 

 

why isn't my code working?

 

Inherits Script     Private player As Player    Private playerPed As Ped    Private simeon As Ped    Private mainMenu As UIMenu     Public Sub menuExample()        AddHandler mainMenu.OnItemSelect, AddressOf ItemSelectHandler        AddHandler Tick, AddressOf OnTick        AddHandler KeyDown, AddressOf OnKeyDown         mainMenu = New UIMenu("NativeUI", "~b~NATIVEUI SHOWCASE")        mainMenu.SetKey(UIMenu.MenuControls.Up, GTA.Control.FrontendDown)        mainMenu.SetKey(UIMenu.MenuControls.Down, GTA.Control.FrontendUp)        mainMenu.SetKey(UIMenu.MenuControls.Select, GTA.Control.FrontendSelect)        mainMenu.SetKey(UIMenu.MenuControls.Back, GTA.Control.FrontendCancel)         mainMenu.AddItem(New UIMenuItem("Simple Button"))        mainMenu.AddItem(New UIMenuCheckboxItem("Simple Checkbox", False))        mainMenu.AddItem(New UIMenuListItem("Simple List", New List(Of Object)() From {                                            "Item 1",                                            "Item 2",                                            "Item 3"                                            }, 0))        mainMenu.AddItem(New UIMenuItem("Another Button", "Items Can have descriptions too!"))        mainMenu.RefreshIndex()    End Sub     Public Sub ItemSelectHandler(sender As UIMenu, selectedItem As UIMenuItem, index As Integer)        UI.Notify("You have selected: ~b~" + selectedItem.Text)    End Sub     Public Sub OnTick(o As Object, e As EventArgs)        'mainMenu.ProcessControl()        'mainMenu.ProcessMouse()        'mainMenu.Draw()        MenuPool.ProcessMenus()    End Sub     Public Sub OnKeyDown(o As Object, e As KeyEventArgs)        'mainMenu.ProcessKey(e.KeyCode)        If e.KeyCode = Keys.F9 Then            mainMenu.Visible = Not mainMenu.Visible        Else            mainMenu.Visible = mainMenu.Visible        End If    End Sub

 

 

 

What error does it show you?

You should change

If e.KeyCode = Keys.F9 Then            mainMenu.Visible = Not mainMenu.Visible        Else            mainMenu.Visible = mainMenu.Visible        End If

to

If e.KeyCode = Keys.F9 Then            mainMenu.Visible = Not mainMenu.Visible        End If

No Error sir, just the menu is not showing

below is my full code

 

 

 

Imports SystemImports System.Collections.GenericImports System.DrawingImports System.Windows.FormsImports GTAImports GTA.NativeImports NativeUIImports System.LinqImports System.TextImports System.Threading.Tasks Public Class pdmcarshop    Inherits Script     Private player As Player    Private playerPed As Ped    Private simeon As Ped    Private mainMenu As UIMenu     Public Sub menuExample()        AddHandler mainMenu.OnItemSelect, AddressOf ItemSelectHandler        AddHandler Tick, AddressOf OnTick        AddHandler KeyDown, AddressOf OnKeyDown         mainMenu = New UIMenu("NativeUI", "~b~NATIVEUI SHOWCASE")        mainMenu.SetKey(UIMenu.MenuControls.Up, GTA.Control.FrontendDown)        mainMenu.SetKey(UIMenu.MenuControls.Down, GTA.Control.FrontendUp)        mainMenu.SetKey(UIMenu.MenuControls.Select, GTA.Control.FrontendSelect)        mainMenu.SetKey(UIMenu.MenuControls.Back, GTA.Control.FrontendCancel)         mainMenu.AddItem(New UIMenuItem("Simple Button"))        mainMenu.AddItem(New UIMenuCheckboxItem("Simple Checkbox", False))        mainMenu.AddItem(New UIMenuListItem("Simple List", New List(Of Object)() From {                                            "Item 1",                                            "Item 2",                                            "Item 3"                                            }, 0))        mainMenu.AddItem(New UIMenuItem("Another Button", "Items Can have descriptions too!"))        mainMenu.RefreshIndex()    End Sub     Public Sub ItemSelectHandler(sender As UIMenu, selectedItem As UIMenuItem, index As Integer)        UI.Notify("You have selected: ~b~" + selectedItem.Text)    End Sub     Public Sub OnTick(o As Object, e As EventArgs)        MenuPool.ProcessMenus()    End Sub     Public Sub OnKeyDown(o As Object, e As KeyEventArgs)        If e.KeyCode = Keys.F9 Then            mainMenu.Visible = Not mainMenu.Visible        End If    End SubEnd Class

 

 

 

First of all your code is not in a constructor. Second is that you called your menu before it was created. Third, the buttons you listed are already added by default.

So this is how your code should look

 

 

 

Imports SystemImports System.Collections.GenericImports System.DrawingImports System.Windows.FormsImports GTAImports GTA.NativeImports NativeUIImports System.LinqImports System.TextImports System.Threading.TasksPublic Class pdmcarshop    Inherits Script    Private player As player    Private playerPed As Ped    Private simeon As Ped    Private mainMenu As UIMenu    Public Sub New()        AddHandler Tick, AddressOf OnTick        AddHandler KeyDown, AddressOf OnKeyDown        mainMenu = New UIMenu("NativeUI", "~b~NATIVEUI SHOWCASE")        mainMenu.AddItem(New UIMenuItem("Simple Button"))        mainMenu.AddItem(New UIMenuCheckboxItem("Simple Checkbox", False))        mainMenu.AddItem(New UIMenuListItem("Simple List", New List(Of Object)() From {                                            "Item 1",                                            "Item 2",                                            "Item 3"                                            }, 0))        mainMenu.AddItem(New UIMenuItem("Another Button", "Items Can have descriptions too!"))        mainMenu.RefreshIndex()        AddHandler mainMenu.OnItemSelect, AddressOf ItemSelectHandler    End Sub    Public Sub ItemSelectHandler(sender As UIMenu, selectedItem As UIMenuItem, index As Integer)        UI.Notify("You have selected: ~b~" + selectedItem.Text)    End Sub    Public Sub OnTick(o As Object, e As EventArgs)        MenuPool.ProcessMenus()    End Sub    Public Sub OnKeyDown(o As Object, e As KeyEventArgs)        If e.KeyCode = Keys.F5 Then            mainMenu.Visible = True        End If    End SubEnd Class

 

 

Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067782153
Share on other sites

 

NativeUI Library

Download 0.9

ScriptHookVDotNet based library for easy and fast Rockstar-like menus.

ui.PNG

Features:

  • Support for simple buttons, checkboxes and lists.
  • Support for custom banners from game sprites.
  • Easy nested menus for fast and painless nested menu system.
  • Controller support.
  • Mouse controls.
  • Support for all screen resolutions.
  • Item descriptions.
  • Rebindable keys and controls.
  • Badges to decorate your items.
  • Event-based callbacks.

Installation

After installing ScriptHookVDotNet, copy NativeUI.dll to your scripts/ folder.

 

Usage

Add NativeUI.dll your references in Visual Studio just like you did with ScriptHookDotNet.dll and add "using NativeUI;" to the top of your script.

 

 

You can create a menu by using the UIMenu class. This class provides 4 events: OnIndexChange, OnListChange, OnCheckboxChange and OnItemSelect.

UIMenu has two base parameters: the banner title and the subtitle. It also has an overload with a third Point parameter which determines the offset, and an overload for a custom sprites.

var myMenu = new UIMenu("Banner Title", "~b~SUBTITLE");

You may add to the default arrow navigation keys by using the SetKey method.

myMenu.SetKey(UIMenu.MenuControls.Up, Keys.W); // KeysmyMenu.SetKey(UI.Menu.MenuControls.Down, GTA.Controls.FrontendDown); //Or Controls

Now you can start adding elements to your menu by using the AddItem(UIMenuItem item) method.

myMenu.AddItem(new UIMenuItem("Simple Button"));myMenu.AddItem(new UIMenuCheckboxItem("Simple Checkbox", false));myMenu.AddItem(new UIMenuListItem("Simple List", new List<dynamic> {"Item 1", "Item 2", "Item 3"}, 0));myMenu.AddItem(new UIMenuItem("Another Button", "Items can have descriptions too!"));myMenu.RefreshIndex();

After you have done adding items, you will have to set the index at 0 by using the RefreshIndex() method.

By using events, you can easily check when something has been changed.

myMenu.OnItemSelect += ItemSelectHandler; public void ItemSelectHandler(UIMenu sender, UIMenuItem selectedItem, int index){    UI.Notify("You have selected: ~b~" + selectedItem.Text);}

Finally, you will have to implement an open/close trigger for your menu by using the Visible property, and some other final touches like the Draw method in your Tick event handler, and ProcessKey method in your KeyDown handler.

You can also use the MenuPool helper class and call it's ProcessMenus method. It takes care of the rest.

public void OnTick(object o, EventArgs e){    //myMenu.ProcessControl();    //myMenu.ProcessMouse();    //myMenu.Draw();    MenuPool.ProcessMenus();}public void OnKeyDown(object o, KeyEventArgs e){    //myMenu.ProcessKey(e.KeyCode); // We are using controls instead of keys, so we comment it out.    if (e.KeyCode == Keys.F5) // Our menu on/off switch    {        myMenu.Visible = !myMenu.Visible;    }}

 

 

 

Example Script

 

Simple script to showcase some of NativeUI's features.

using System;using System.Collections.Generic;using System.Drawing;using System.Windows.Forms;using GTA;using GTA.Native;using NativeUI;public class MenuExample : Script{    private UIMenu mainMenu;    private UIMenu newMenu;    private UIMenuCheckboxItem ketchupCheckbox;    private UIMenuListItem dishesListItem;    private UIMenuItem cookItem;    public MenuExample()    {        Tick += OnTick;        KeyDown += OnKeyDown;        mainMenu = new UIMenu("Native UI", "~b~NATIVEUI SHOWCASE");        mainMenu.AddItem(ketchupCheckbox = new UIMenuCheckboxItem("Add ketchup?", false, "Do you wish to add ketchup?"));        var foods = new List<dynamic>        {            "Banana",            "Apple",            "Pizza",            "Quartilicious",            0xF00D, // Dynamic!        };        mainMenu.AddItem(dishesListItem = new UIMenuListItem("Food", foods, 0));        mainMenu.AddItem(cookItem = new UIMenuItem("Cook!", "Cook the dish with the appropiate ingredients and ketchup."));        var menuItem = new UIMenuItem("Go to another menu.");        mainMenu.AddItem(menuItem);        cookItem.LeftBadge = UIMenuItem.BadgeStyle.Star;        cookItem.RightBadge = UIMenuItem.BadgeStyle.Tick;        mainMenu.RefreshIndex();        mainMenu.OnItemSelect += OnItemSelect;        mainMenu.OnListChange += OnListChange;        mainMenu.OnCheckboxChange += OnCheckboxChange;        mainMenu.OnIndexChange += OnItemChange;        newMenu = new UIMenu("Native UI", "~r~NATIVEUI SHOWCASE");        for (int i = 0; i < 20; i++)        {            newMenu.AddItem(new UIMenuItem("PageFiller", "Sample description that takes more than one line. Moreso, it takes way more than two lines since it's so long. Wow, check out this length!"));        }        newMenu.RefreshIndex();        mainMenu.BindMenuToItem(newMenu, menuItem);    }    public void OnItemChange(UIMenu sender, int index)    {        sender.MenuItems[index].LeftBadge = UIMenuItem.BadgeStyle.None;    }    public void OnCheckboxChange(UIMenu sender, UIMenuCheckboxItem checkbox, bool Checked)    {        if (sender != mainMenu || checkbox != ketchupCheckbox) return; // We only want to detect changes from our menu.        UI.Notify("~r~Ketchup status: ~b~" + Checked);    }    public void OnListChange(UIMenu sender, UIMenuListItem list, int index)    {        if (sender != mainMenu || list != dishesListItem) return; // We only want to detect changes from our menu.        string dish = list.IndexToItem(index).ToString();        UI.Notify("Preparing ~b~" + dish +"~w~...");    }       public void OnItemSelect(UIMenu sender, UIMenuItem selectedItem, int index)    {        if (sender != mainMenu || selectedItem != cookItem) return; // We only want to detect changes from our menu and our button.        // You can also detect the button by using index        string dish = dishesListItem.IndexToItem(dishesListItem.Index).ToString();        bool ketchup = ketchupCheckbox.Checked;        string output = ketchup            ? "You have ordered ~b~{0}~w~ ~r~with~w~ ketchup."            : "You have ordered ~b~{0}~w~ ~r~without~w~ ketchup.";        UI.ShowSubtitle(String.Format(output, dish));    }    public void OnTick(object o, EventArgs e)    {        MenuPool.ProcessMenus();    }    public void OnKeyDown(object o, KeyEventArgs e)    {        if (e.KeyCode == Keys.F5) // Our menu on/off switch        {            mainMenu.Visible = !mainMenu.Visible;        }    }}

 

 

 

Changelog

- 0.9

-- Removed debug stuff from last release.

-- Lied a base for controller detection.

- 0.8

-- Menu mantains aspect ratio in all screen resolutions.

- 0.7

-- Added menu nesting methods: BindMenuToItem and ReleaseMenuFromItem

-- Added back/exit buttons.

-- Added a helper class, MenuPool, to easily call your process methods of all of your menus with just one method, ProcessMenus.

- 0.6

-- Added mouse controls. Place ProcessMouse() in your OnTick event.

-- Restyled the menu to look a lot more like an official Rockstar menu.

- 0.5

-- Added controller support.

- 0.4

-- Support for both keys and controls

-- Disabled phone when menu is open

-- Added Select support for list items

- 0.3

-- Fixed graphical errors when there were more than 12 items on screen.

- 0.2

-- Added badges.

- 0.1

-- Initial Release.

 

Distribution

Please, do not distribute the .dll with your mod. This causes many old versions floating around on the internet. Instead, point your users to this post.

 

Media

 

Screenshots were taken in 0.7

3jvnop.PNG

ua35o6.PNG

r3c22j.PNG

frywy3.PNG

 

 

Extra Credits

Thanks to jedijosh920 for helping out on natives and making it look a lot more like Rockstar, thanks man.

 

Sourcecode

You can find the source at https://github.com/Guad/NativeUI

 

 

This is so awesome. I'm using it re-create the menus in some of my scripts. Looks so much better. May I suggest the addition of an ItemActivated event for the UIMenuItem? Thanks, this has saved me a ton of time!!

  • Like 2
Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067782360
Share on other sites

 

 

 

NativeUI Library

Download 0.9

ScriptHookVDotNet based library for easy and fast Rockstar-like menus.

ui.PNG

Features:

  • Support for simple buttons, checkboxes and lists.
  • Support for custom banners from game sprites.
  • Easy nested menus for fast and painless nested menu system.
  • Controller support.
  • Mouse controls.
  • Support for all screen resolutions.
  • Item descriptions.
  • Rebindable keys and controls.
  • Badges to decorate your items.
  • Event-based callbacks.

Installation

After installing ScriptHookVDotNet, copy NativeUI.dll to your scripts/ folder.

 

Usage

Add NativeUI.dll your references in Visual Studio just like you did with ScriptHookDotNet.dll and add "using NativeUI;" to the top of your script.

 

 

You can create a menu by using the UIMenu class. This class provides 4 events: OnIndexChange, OnListChange, OnCheckboxChange and OnItemSelect.

UIMenu has two base parameters: the banner title and the subtitle. It also has an overload with a third Point parameter which determines the offset, and an overload for a custom sprites.

var myMenu = new UIMenu("Banner Title", "~b~SUBTITLE");

You may add to the default arrow navigation keys by using the SetKey method.

myMenu.SetKey(UIMenu.MenuControls.Up, Keys.W); // KeysmyMenu.SetKey(UI.Menu.MenuControls.Down, GTA.Controls.FrontendDown); //Or Controls

Now you can start adding elements to your menu by using the AddItem(UIMenuItem item) method.

myMenu.AddItem(new UIMenuItem("Simple Button"));myMenu.AddItem(new UIMenuCheckboxItem("Simple Checkbox", false));myMenu.AddItem(new UIMenuListItem("Simple List", new List<dynamic> {"Item 1", "Item 2", "Item 3"}, 0));myMenu.AddItem(new UIMenuItem("Another Button", "Items can have descriptions too!"));myMenu.RefreshIndex();

After you have done adding items, you will have to set the index at 0 by using the RefreshIndex() method.

By using events, you can easily check when something has been changed.

myMenu.OnItemSelect += ItemSelectHandler; public void ItemSelectHandler(UIMenu sender, UIMenuItem selectedItem, int index){    UI.Notify("You have selected: ~b~" + selectedItem.Text);}

Finally, you will have to implement an open/close trigger for your menu by using the Visible property, and some other final touches like the Draw method in your Tick event handler, and ProcessKey method in your KeyDown handler.

You can also use the MenuPool helper class and call it's ProcessMenus method. It takes care of the rest.

public void OnTick(object o, EventArgs e){    //myMenu.ProcessControl();    //myMenu.ProcessMouse();    //myMenu.Draw();    MenuPool.ProcessMenus();}public void OnKeyDown(object o, KeyEventArgs e){    //myMenu.ProcessKey(e.KeyCode); // We are using controls instead of keys, so we comment it out.    if (e.KeyCode == Keys.F5) // Our menu on/off switch    {        myMenu.Visible = !myMenu.Visible;    }}

 

 

 

Example Script

 

Simple script to showcase some of NativeUI's features.

using System;using System.Collections.Generic;using System.Drawing;using System.Windows.Forms;using GTA;using GTA.Native;using NativeUI;public class MenuExample : Script{    private UIMenu mainMenu;    private UIMenu newMenu;    private UIMenuCheckboxItem ketchupCheckbox;    private UIMenuListItem dishesListItem;    private UIMenuItem cookItem;    public MenuExample()    {        Tick += OnTick;        KeyDown += OnKeyDown;        mainMenu = new UIMenu("Native UI", "~b~NATIVEUI SHOWCASE");        mainMenu.AddItem(ketchupCheckbox = new UIMenuCheckboxItem("Add ketchup?", false, "Do you wish to add ketchup?"));        var foods = new List<dynamic>        {            "Banana",            "Apple",            "Pizza",            "Quartilicious",            0xF00D, // Dynamic!        };        mainMenu.AddItem(dishesListItem = new UIMenuListItem("Food", foods, 0));        mainMenu.AddItem(cookItem = new UIMenuItem("Cook!", "Cook the dish with the appropiate ingredients and ketchup."));        var menuItem = new UIMenuItem("Go to another menu.");        mainMenu.AddItem(menuItem);        cookItem.LeftBadge = UIMenuItem.BadgeStyle.Star;        cookItem.RightBadge = UIMenuItem.BadgeStyle.Tick;        mainMenu.RefreshIndex();        mainMenu.OnItemSelect += OnItemSelect;        mainMenu.OnListChange += OnListChange;        mainMenu.OnCheckboxChange += OnCheckboxChange;        mainMenu.OnIndexChange += OnItemChange;        newMenu = new UIMenu("Native UI", "~r~NATIVEUI SHOWCASE");        for (int i = 0; i < 20; i++)        {            newMenu.AddItem(new UIMenuItem("PageFiller", "Sample description that takes more than one line. Moreso, it takes way more than two lines since it's so long. Wow, check out this length!"));        }        newMenu.RefreshIndex();        mainMenu.BindMenuToItem(newMenu, menuItem);    }    public void OnItemChange(UIMenu sender, int index)    {        sender.MenuItems[index].LeftBadge = UIMenuItem.BadgeStyle.None;    }    public void OnCheckboxChange(UIMenu sender, UIMenuCheckboxItem checkbox, bool Checked)    {        if (sender != mainMenu || checkbox != ketchupCheckbox) return; // We only want to detect changes from our menu.        UI.Notify("~r~Ketchup status: ~b~" + Checked);    }    public void OnListChange(UIMenu sender, UIMenuListItem list, int index)    {        if (sender != mainMenu || list != dishesListItem) return; // We only want to detect changes from our menu.        string dish = list.IndexToItem(index).ToString();        UI.Notify("Preparing ~b~" + dish +"~w~...");    }       public void OnItemSelect(UIMenu sender, UIMenuItem selectedItem, int index)    {        if (sender != mainMenu || selectedItem != cookItem) return; // We only want to detect changes from our menu and our button.        // You can also detect the button by using index        string dish = dishesListItem.IndexToItem(dishesListItem.Index).ToString();        bool ketchup = ketchupCheckbox.Checked;        string output = ketchup            ? "You have ordered ~b~{0}~w~ ~r~with~w~ ketchup."            : "You have ordered ~b~{0}~w~ ~r~without~w~ ketchup.";        UI.ShowSubtitle(String.Format(output, dish));    }    public void OnTick(object o, EventArgs e)    {        MenuPool.ProcessMenus();    }    public void OnKeyDown(object o, KeyEventArgs e)    {        if (e.KeyCode == Keys.F5) // Our menu on/off switch        {            mainMenu.Visible = !mainMenu.Visible;        }    }}

 

 

 

Changelog

- 0.9

-- Removed debug stuff from last release.

-- Lied a base for controller detection.

- 0.8

-- Menu mantains aspect ratio in all screen resolutions.

- 0.7

-- Added menu nesting methods: BindMenuToItem and ReleaseMenuFromItem

-- Added back/exit buttons.

-- Added a helper class, MenuPool, to easily call your process methods of all of your menus with just one method, ProcessMenus.

- 0.6

-- Added mouse controls. Place ProcessMouse() in your OnTick event.

-- Restyled the menu to look a lot more like an official Rockstar menu.

- 0.5

-- Added controller support.

- 0.4

-- Support for both keys and controls

-- Disabled phone when menu is open

-- Added Select support for list items

- 0.3

-- Fixed graphical errors when there were more than 12 items on screen.

- 0.2

-- Added badges.

- 0.1

-- Initial Release.

 

Distribution

Please, do not distribute the .dll with your mod. This causes many old versions floating around on the internet. Instead, point your users to this post.

 

Media

 

Screenshots were taken in 0.7

3jvnop.PNG

ua35o6.PNG

r3c22j.PNG

frywy3.PNG

 

 

Extra Credits

Thanks to jedijosh920 for helping out on natives and making it look a lot more like Rockstar, thanks man.

 

Sourcecode

You can find the source at https://github.com/Guad/NativeUI

 

 

 

This is so awesome. I'm using it re-create the menus in some of my scripts. Looks so much better. May I suggest the addition of an ItemActivated event for the UIMenuItem? Thanks, this has saved me a ton of time!!

 

What do you mean ItemActived event? You can use OnIndexChange, which is called when the player selects an item with a mouse/moves up or down

Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067782522
Share on other sites

 

 

 

 

NativeUI Library

Download 0.9

ScriptHookVDotNet based library for easy and fast Rockstar-like menus.

ui.PNG

Features:

  • Support for simple buttons, checkboxes and lists.
  • Support for custom banners from game sprites.
  • Easy nested menus for fast and painless nested menu system.
  • Controller support.
  • Mouse controls.
  • Support for all screen resolutions.
  • Item descriptions.
  • Rebindable keys and controls.
  • Badges to decorate your items.
  • Event-based callbacks.

Installation

After installing ScriptHookVDotNet, copy NativeUI.dll to your scripts/ folder.

 

Usage

Add NativeUI.dll your references in Visual Studio just like you did with ScriptHookDotNet.dll and add "using NativeUI;" to the top of your script.

 

 

You can create a menu by using the UIMenu class. This class provides 4 events: OnIndexChange, OnListChange, OnCheckboxChange and OnItemSelect.

UIMenu has two base parameters: the banner title and the subtitle. It also has an overload with a third Point parameter which determines the offset, and an overload for a custom sprites.

var myMenu = new UIMenu("Banner Title", "~b~SUBTITLE");

You may add to the default arrow navigation keys by using the SetKey method.

myMenu.SetKey(UIMenu.MenuControls.Up, Keys.W); // KeysmyMenu.SetKey(UI.Menu.MenuControls.Down, GTA.Controls.FrontendDown); //Or Controls

Now you can start adding elements to your menu by using the AddItem(UIMenuItem item) method.

myMenu.AddItem(new UIMenuItem("Simple Button"));myMenu.AddItem(new UIMenuCheckboxItem("Simple Checkbox", false));myMenu.AddItem(new UIMenuListItem("Simple List", new List<dynamic> {"Item 1", "Item 2", "Item 3"}, 0));myMenu.AddItem(new UIMenuItem("Another Button", "Items can have descriptions too!"));myMenu.RefreshIndex();

After you have done adding items, you will have to set the index at 0 by using the RefreshIndex() method.

By using events, you can easily check when something has been changed.

myMenu.OnItemSelect += ItemSelectHandler; public void ItemSelectHandler(UIMenu sender, UIMenuItem selectedItem, int index){    UI.Notify("You have selected: ~b~" + selectedItem.Text);}

Finally, you will have to implement an open/close trigger for your menu by using the Visible property, and some other final touches like the Draw method in your Tick event handler, and ProcessKey method in your KeyDown handler.

You can also use the MenuPool helper class and call it's ProcessMenus method. It takes care of the rest.

public void OnTick(object o, EventArgs e){    //myMenu.ProcessControl();    //myMenu.ProcessMouse();    //myMenu.Draw();    MenuPool.ProcessMenus();}public void OnKeyDown(object o, KeyEventArgs e){    //myMenu.ProcessKey(e.KeyCode); // We are using controls instead of keys, so we comment it out.    if (e.KeyCode == Keys.F5) // Our menu on/off switch    {        myMenu.Visible = !myMenu.Visible;    }}

 

 

 

Example Script

 

Simple script to showcase some of NativeUI's features.

using System;using System.Collections.Generic;using System.Drawing;using System.Windows.Forms;using GTA;using GTA.Native;using NativeUI;public class MenuExample : Script{    private UIMenu mainMenu;    private UIMenu newMenu;    private UIMenuCheckboxItem ketchupCheckbox;    private UIMenuListItem dishesListItem;    private UIMenuItem cookItem;    public MenuExample()    {        Tick += OnTick;        KeyDown += OnKeyDown;        mainMenu = new UIMenu("Native UI", "~b~NATIVEUI SHOWCASE");        mainMenu.AddItem(ketchupCheckbox = new UIMenuCheckboxItem("Add ketchup?", false, "Do you wish to add ketchup?"));        var foods = new List<dynamic>        {            "Banana",            "Apple",            "Pizza",            "Quartilicious",            0xF00D, // Dynamic!        };        mainMenu.AddItem(dishesListItem = new UIMenuListItem("Food", foods, 0));        mainMenu.AddItem(cookItem = new UIMenuItem("Cook!", "Cook the dish with the appropiate ingredients and ketchup."));        var menuItem = new UIMenuItem("Go to another menu.");        mainMenu.AddItem(menuItem);        cookItem.LeftBadge = UIMenuItem.BadgeStyle.Star;        cookItem.RightBadge = UIMenuItem.BadgeStyle.Tick;        mainMenu.RefreshIndex();        mainMenu.OnItemSelect += OnItemSelect;        mainMenu.OnListChange += OnListChange;        mainMenu.OnCheckboxChange += OnCheckboxChange;        mainMenu.OnIndexChange += OnItemChange;        newMenu = new UIMenu("Native UI", "~r~NATIVEUI SHOWCASE");        for (int i = 0; i < 20; i++)        {            newMenu.AddItem(new UIMenuItem("PageFiller", "Sample description that takes more than one line. Moreso, it takes way more than two lines since it's so long. Wow, check out this length!"));        }        newMenu.RefreshIndex();        mainMenu.BindMenuToItem(newMenu, menuItem);    }    public void OnItemChange(UIMenu sender, int index)    {        sender.MenuItems[index].LeftBadge = UIMenuItem.BadgeStyle.None;    }    public void OnCheckboxChange(UIMenu sender, UIMenuCheckboxItem checkbox, bool Checked)    {        if (sender != mainMenu || checkbox != ketchupCheckbox) return; // We only want to detect changes from our menu.        UI.Notify("~r~Ketchup status: ~b~" + Checked);    }    public void OnListChange(UIMenu sender, UIMenuListItem list, int index)    {        if (sender != mainMenu || list != dishesListItem) return; // We only want to detect changes from our menu.        string dish = list.IndexToItem(index).ToString();        UI.Notify("Preparing ~b~" + dish +"~w~...");    }       public void OnItemSelect(UIMenu sender, UIMenuItem selectedItem, int index)    {        if (sender != mainMenu || selectedItem != cookItem) return; // We only want to detect changes from our menu and our button.        // You can also detect the button by using index        string dish = dishesListItem.IndexToItem(dishesListItem.Index).ToString();        bool ketchup = ketchupCheckbox.Checked;        string output = ketchup            ? "You have ordered ~b~{0}~w~ ~r~with~w~ ketchup."            : "You have ordered ~b~{0}~w~ ~r~without~w~ ketchup.";        UI.ShowSubtitle(String.Format(output, dish));    }    public void OnTick(object o, EventArgs e)    {        MenuPool.ProcessMenus();    }    public void OnKeyDown(object o, KeyEventArgs e)    {        if (e.KeyCode == Keys.F5) // Our menu on/off switch        {            mainMenu.Visible = !mainMenu.Visible;        }    }}

 

 

 

Changelog

- 0.9

-- Removed debug stuff from last release.

-- Lied a base for controller detection.

- 0.8

-- Menu mantains aspect ratio in all screen resolutions.

- 0.7

-- Added menu nesting methods: BindMenuToItem and ReleaseMenuFromItem

-- Added back/exit buttons.

-- Added a helper class, MenuPool, to easily call your process methods of all of your menus with just one method, ProcessMenus.

- 0.6

-- Added mouse controls. Place ProcessMouse() in your OnTick event.

-- Restyled the menu to look a lot more like an official Rockstar menu.

- 0.5

-- Added controller support.

- 0.4

-- Support for both keys and controls

-- Disabled phone when menu is open

-- Added Select support for list items

- 0.3

-- Fixed graphical errors when there were more than 12 items on screen.

- 0.2

-- Added badges.

- 0.1

-- Initial Release.

 

Distribution

Please, do not distribute the .dll with your mod. This causes many old versions floating around on the internet. Instead, point your users to this post.

 

Media

 

Screenshots were taken in 0.7

3jvnop.PNG

ua35o6.PNG

r3c22j.PNG

frywy3.PNG

 

 

Extra Credits

Thanks to jedijosh920 for helping out on natives and making it look a lot more like Rockstar, thanks man.

 

Sourcecode

You can find the source at https://github.com/Guad/NativeUI

 

 

 

This is so awesome. I'm using it re-create the menus in some of my scripts. Looks so much better. May I suggest the addition of an ItemActivated event for the UIMenuItem? Thanks, this has saved me a ton of time!!

 

What do you mean ItemActived event? You can use OnIndexChange, which is called when the player selects an item with a mouse/moves up or down

 

 

I just find it messy handling all button events in one method. Only personal opinion. It would be nice to be able to use lambda to perform the button action. I know you provided the source and I added it myself. But i'm just making the suggestion.

Edited by CamxxCore
Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067782926
Share on other sites

 

 

 

 

 

NativeUI Library

Download 0.9

ScriptHookVDotNet based library for easy and fast Rockstar-like menus.

ui.PNG

Features:

  • Support for simple buttons, checkboxes and lists.
  • Support for custom banners from game sprites.
  • Easy nested menus for fast and painless nested menu system.
  • Controller support.
  • Mouse controls.
  • Support for all screen resolutions.
  • Item descriptions.
  • Rebindable keys and controls.
  • Badges to decorate your items.
  • Event-based callbacks.

Installation

After installing ScriptHookVDotNet, copy NativeUI.dll to your scripts/ folder.

 

Usage

Add NativeUI.dll your references in Visual Studio just like you did with ScriptHookDotNet.dll and add "using NativeUI;" to the top of your script.

 

 

You can create a menu by using the UIMenu class. This class provides 4 events: OnIndexChange, OnListChange, OnCheckboxChange and OnItemSelect.

UIMenu has two base parameters: the banner title and the subtitle. It also has an overload with a third Point parameter which determines the offset, and an overload for a custom sprites.

var myMenu = new UIMenu("Banner Title", "~b~SUBTITLE");

You may add to the default arrow navigation keys by using the SetKey method.

myMenu.SetKey(UIMenu.MenuControls.Up, Keys.W); // KeysmyMenu.SetKey(UI.Menu.MenuControls.Down, GTA.Controls.FrontendDown); //Or Controls

Now you can start adding elements to your menu by using the AddItem(UIMenuItem item) method.

myMenu.AddItem(new UIMenuItem("Simple Button"));myMenu.AddItem(new UIMenuCheckboxItem("Simple Checkbox", false));myMenu.AddItem(new UIMenuListItem("Simple List", new List<dynamic> {"Item 1", "Item 2", "Item 3"}, 0));myMenu.AddItem(new UIMenuItem("Another Button", "Items can have descriptions too!"));myMenu.RefreshIndex();

After you have done adding items, you will have to set the index at 0 by using the RefreshIndex() method.

By using events, you can easily check when something has been changed.

myMenu.OnItemSelect += ItemSelectHandler; public void ItemSelectHandler(UIMenu sender, UIMenuItem selectedItem, int index){    UI.Notify("You have selected: ~b~" + selectedItem.Text);}

Finally, you will have to implement an open/close trigger for your menu by using the Visible property, and some other final touches like the Draw method in your Tick event handler, and ProcessKey method in your KeyDown handler.

You can also use the MenuPool helper class and call it's ProcessMenus method. It takes care of the rest.

public void OnTick(object o, EventArgs e){    //myMenu.ProcessControl();    //myMenu.ProcessMouse();    //myMenu.Draw();    MenuPool.ProcessMenus();}public void OnKeyDown(object o, KeyEventArgs e){    //myMenu.ProcessKey(e.KeyCode); // We are using controls instead of keys, so we comment it out.    if (e.KeyCode == Keys.F5) // Our menu on/off switch    {        myMenu.Visible = !myMenu.Visible;    }}

 

 

 

Example Script

 

Simple script to showcase some of NativeUI's features.

using System;using System.Collections.Generic;using System.Drawing;using System.Windows.Forms;using GTA;using GTA.Native;using NativeUI;public class MenuExample : Script{    private UIMenu mainMenu;    private UIMenu newMenu;    private UIMenuCheckboxItem ketchupCheckbox;    private UIMenuListItem dishesListItem;    private UIMenuItem cookItem;    public MenuExample()    {        Tick += OnTick;        KeyDown += OnKeyDown;        mainMenu = new UIMenu("Native UI", "~b~NATIVEUI SHOWCASE");        mainMenu.AddItem(ketchupCheckbox = new UIMenuCheckboxItem("Add ketchup?", false, "Do you wish to add ketchup?"));        var foods = new List<dynamic>        {            "Banana",            "Apple",            "Pizza",            "Quartilicious",            0xF00D, // Dynamic!        };        mainMenu.AddItem(dishesListItem = new UIMenuListItem("Food", foods, 0));        mainMenu.AddItem(cookItem = new UIMenuItem("Cook!", "Cook the dish with the appropiate ingredients and ketchup."));        var menuItem = new UIMenuItem("Go to another menu.");        mainMenu.AddItem(menuItem);        cookItem.LeftBadge = UIMenuItem.BadgeStyle.Star;        cookItem.RightBadge = UIMenuItem.BadgeStyle.Tick;        mainMenu.RefreshIndex();        mainMenu.OnItemSelect += OnItemSelect;        mainMenu.OnListChange += OnListChange;        mainMenu.OnCheckboxChange += OnCheckboxChange;        mainMenu.OnIndexChange += OnItemChange;        newMenu = new UIMenu("Native UI", "~r~NATIVEUI SHOWCASE");        for (int i = 0; i < 20; i++)        {            newMenu.AddItem(new UIMenuItem("PageFiller", "Sample description that takes more than one line. Moreso, it takes way more than two lines since it's so long. Wow, check out this length!"));        }        newMenu.RefreshIndex();        mainMenu.BindMenuToItem(newMenu, menuItem);    }    public void OnItemChange(UIMenu sender, int index)    {        sender.MenuItems[index].LeftBadge = UIMenuItem.BadgeStyle.None;    }    public void OnCheckboxChange(UIMenu sender, UIMenuCheckboxItem checkbox, bool Checked)    {        if (sender != mainMenu || checkbox != ketchupCheckbox) return; // We only want to detect changes from our menu.        UI.Notify("~r~Ketchup status: ~b~" + Checked);    }    public void OnListChange(UIMenu sender, UIMenuListItem list, int index)    {        if (sender != mainMenu || list != dishesListItem) return; // We only want to detect changes from our menu.        string dish = list.IndexToItem(index).ToString();        UI.Notify("Preparing ~b~" + dish +"~w~...");    }       public void OnItemSelect(UIMenu sender, UIMenuItem selectedItem, int index)    {        if (sender != mainMenu || selectedItem != cookItem) return; // We only want to detect changes from our menu and our button.        // You can also detect the button by using index        string dish = dishesListItem.IndexToItem(dishesListItem.Index).ToString();        bool ketchup = ketchupCheckbox.Checked;        string output = ketchup            ? "You have ordered ~b~{0}~w~ ~r~with~w~ ketchup."            : "You have ordered ~b~{0}~w~ ~r~without~w~ ketchup.";        UI.ShowSubtitle(String.Format(output, dish));    }    public void OnTick(object o, EventArgs e)    {        MenuPool.ProcessMenus();    }    public void OnKeyDown(object o, KeyEventArgs e)    {        if (e.KeyCode == Keys.F5) // Our menu on/off switch        {            mainMenu.Visible = !mainMenu.Visible;        }    }}

 

 

 

Changelog

- 0.9

-- Removed debug stuff from last release.

-- Lied a base for controller detection.

- 0.8

-- Menu mantains aspect ratio in all screen resolutions.

- 0.7

-- Added menu nesting methods: BindMenuToItem and ReleaseMenuFromItem

-- Added back/exit buttons.

-- Added a helper class, MenuPool, to easily call your process methods of all of your menus with just one method, ProcessMenus.

- 0.6

-- Added mouse controls. Place ProcessMouse() in your OnTick event.

-- Restyled the menu to look a lot more like an official Rockstar menu.

- 0.5

-- Added controller support.

- 0.4

-- Support for both keys and controls

-- Disabled phone when menu is open

-- Added Select support for list items

- 0.3

-- Fixed graphical errors when there were more than 12 items on screen.

- 0.2

-- Added badges.

- 0.1

-- Initial Release.

 

Distribution

Please, do not distribute the .dll with your mod. This causes many old versions floating around on the internet. Instead, point your users to this post.

 

Media

 

Screenshots were taken in 0.7

3jvnop.PNG

ua35o6.PNG

r3c22j.PNG

frywy3.PNG

 

 

Extra Credits

Thanks to jedijosh920 for helping out on natives and making it look a lot more like Rockstar, thanks man.

 

Sourcecode

You can find the source at https://github.com/Guad/NativeUI

 

 

 

This is so awesome. I'm using it re-create the menus in some of my scripts. Looks so much better. May I suggest the addition of an ItemActivated event for the UIMenuItem? Thanks, this has saved me a ton of time!!

 

What do you mean ItemActived event? You can use OnIndexChange, which is called when the player selects an item with a mouse/moves up or down

 

 

I just find it messy handling all button events in one method. Only personal opinion. It would be nice to be able to use lambda to perform the button action. I know you provided the source and I added it myself. But i'm just making the suggestion.

 

 

You can have each menu have it's button handler. Also you can make a pull request to the repo and I'll have it merged.

Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067782982
Share on other sites

great,got it working. two questions:how to customize the banner? does it affect performance if i have alot of menus?(does it process all menus at the same time?)

1. You can set a customize the banner by:

- Set a game sprite to the banner

- Set a solid color rectangle as the banner

- Set an external texture as the banner -- this is currently broken because UI.DrawTexture uses a different coordinate system

You can do all of this using the SetBannerType method.

You can also change the title color/size/position/font by accessing the myMenu.Title property.

2. Only visible menus get processed, so no.

Edited by Guad
Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067785907
Share on other sites

unknown modder

 

great,got it working. two questions:how to customize the banner? does it affect performance if i have alot of menus?(does it process all menus at the same time?)

1. You can set a customize the banner by:

- Set a game sprite to the banner

- Set a solid color rectangle as the banner

- Set an external texture as the banner -- this is currently broken because UI.DrawTexture uses a different coordinate system

You can do all of this using the SetBannerType method.

You can also change the title color/size/position/font by accessing the myMenu.Title property.

2. Only visible menus get processed, so no.

 

whats up with UI.Textures coordinate system, That one works on x-y integer coordinate system from 1080x720

Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067786909
Share on other sites

qiangqiang101

There's a bug: if you press enter on the previous menu, and it will goto new menu. But it also select the item in new menu.

How to fix it??

 

https://www.youtube.com/watch?v=fCKgfpTtU-w&feature=youtu.be

 

In the Video my codes...

 

 

Public Sub CategoryItemSelectHandler(sender As UIMenu, selectedItem As UIMenuItem, index As Integer)        Dim nl = Environment.NewLine        UI.Notify("Name: ~b~" & selectedItem.Text & nl & "~s~Model: ~r~" & selectedItem.Model & nl & "~s~Hash: ~y~" & selectedItem.Hash & nl & "~s~Price: ~g~" & selectedItem.Price)    End Sub     Public Sub CategoryItemChange(sender As UIMenu, index As Integer)        Dim nl = Environment.NewLine        UI.ShowSubtitle("Name: ~b~" & sender.MenuItems(index).Text & nl & "~s~Model: ~r~" & sender.MenuItems(index).Model & nl & "~s~Hash: ~y~" & sender.MenuItems(index).Hash & nl & "~s~Price: ~g~" & sender.MenuItems(index).Price)    End Sub
Edited by qiangqiang101
Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067787622
Share on other sites

Hello Guadmaz,

Error:

'NativeUI.UIMenu.Title.get' must declare a body because it is not marked abstract or extern. Automatically implemented properties must define both get and set accessors.


and this was what the error was for

public UIResText Title { get; }


I am new to C# so i dont know much but can you help me? :D

Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067787704
Share on other sites

 

There's a bug: if you press enter on the previous menu, and it will goto new menu. But it also select the item in new menu.

How to fix it??

 

https://www.youtube.com/watch?v=fCKgfpTtU-w&feature=youtu.be

 

In the Video my codes...

Public Sub CategoryItemSelectHandler(sender As UIMenu, selectedItem As UIMenuItem, index As Integer)        Dim nl = Environment.NewLine        UI.Notify("Name: ~b~" & selectedItem.Text & nl & "~s~Model: ~r~" & selectedItem.Model & nl & "~s~Hash: ~y~" & selectedItem.Hash & nl & "~s~Price: ~g~" & selectedItem.Price)    End Sub     Public Sub CategoryItemChange(sender As UIMenu, index As Integer)        Dim nl = Environment.NewLine        UI.ShowSubtitle("Name: ~b~" & sender.MenuItems(index).Text & nl & "~s~Model: ~r~" & sender.MenuItems(index).Model & nl & "~s~Hash: ~y~" & sender.MenuItems(index).Hash & nl & "~s~Price: ~g~" & sender.MenuItems(index).Price)    End Sub

 

That has been fixed already, you can grab it off girhub.

 

 

great,got it working. two questions:how to customize the banner? does it affect performance if i have alot of menus?(does it process all menus at the same time?)

1. You can set a customize the banner by:

- Set a game sprite to the banner

- Set a solid color rectangle as the banner

- Set an external texture as the banner -- this is currently broken because UI.DrawTexture uses a different coordinate system

You can do all of this using the SetBannerType method.

You can also change the title color/size/position/font by accessing the myMenu.Title property.

2. Only visible menus get processed, so no.

 

whats up with UI.Textures coordinate system, That one works on x-y integer coordinate system from 1080x720

 

It uses 1080 as base height then calculates the width based on the user's aspect ratio, then converts it to ScriptHookVDotNet's UI coordinate system for drawing.

  • Like 1
Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067788109
Share on other sites

GeorgeZhang

I have another question:when using ScriptHookVDotNet UI, we have this to trigger a function:

button.Activated += (sender, args) =>        {            UI.Notify("You cannot afford it");        };

my question is, can I do something similar with the NativeUI, so that i don't have to make every button's function in the "OnItemSelect"?

Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067789521
Share on other sites

qiangqiang101

 

 

There's a bug: if you press enter on the previous menu, and it will goto new menu. But it also select the item in new menu.

How to fix it??

 

https://www.youtube.com/watch?v=fCKgfpTtU-w&feature=youtu.be

 

In the Video my codes...

Public Sub CategoryItemSelectHandler(sender As UIMenu, selectedItem As UIMenuItem, index As Integer)        Dim nl = Environment.NewLine        UI.Notify("Name: ~b~" & selectedItem.Text & nl & "~s~Model: ~r~" & selectedItem.Model & nl & "~s~Hash: ~y~" & selectedItem.Hash & nl & "~s~Price: ~g~" & selectedItem.Price)    End Sub     Public Sub CategoryItemChange(sender As UIMenu, index As Integer)        Dim nl = Environment.NewLine        UI.ShowSubtitle("Name: ~b~" & sender.MenuItems(index).Text & nl & "~s~Model: ~r~" & sender.MenuItems(index).Model & nl & "~s~Hash: ~y~" & sender.MenuItems(index).Hash & nl & "~s~Price: ~g~" & sender.MenuItems(index).Price)    End Sub

 

That has been fixed already, you can grab it off girhub.

Sir, another error after update to your latest source code on github

 

Both your example menu and my menu wasn't show while i press the hotkey

 

 

[17:02:00] [DEBUG] Instantiating script 'PremiumDeluxeMotorsport.NET.pdmcarshop' in script domain 'ScriptDomain_E9FE744' ...[17:02:00] [DEBUG] Started script 'PremiumDeluxeMotorsport.NET.pdmcarshop'.[17:02:00] [ERROR] Caught fatal unhandled exception:System.NullReferenceException: Object reference not set to an instance of an object.   at NativeUI.MenuPool.<>c.<ProcessControl>b__8_0(UIMenu menu)   at System.Linq.Enumerable.WhereListIterator`1.MoveNext()   at NativeUI.MenuPool.ProcessControl()   at NativeUI.MenuPool.ProcessMenus()   at PremiumDeluxeMotorsport.NET.pdmcarshop.OnTick(Object o, EventArgs e)   at GTA.Script.raise_Tick(Object value0, EventArgs value1)   at GTA.Script.MainLoop()
Edited by qiangqiang101
Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067790036
Share on other sites

unknown modder

 

 

 

There's a bug: if you press enter on the previous menu, and it will goto new menu. But it also select the item in new menu.

How to fix it??

 

https://www.youtube.com/watch?v=fCKgfpTtU-w&feature=youtu.be

 

In the Video my codes...

Public Sub CategoryItemSelectHandler(sender As UIMenu, selectedItem As UIMenuItem, index As Integer)        Dim nl = Environment.NewLine        UI.Notify("Name: ~b~" & selectedItem.Text & nl & "~s~Model: ~r~" & selectedItem.Model & nl & "~s~Hash: ~y~" & selectedItem.Hash & nl & "~s~Price: ~g~" & selectedItem.Price)    End Sub     Public Sub CategoryItemChange(sender As UIMenu, index As Integer)        Dim nl = Environment.NewLine        UI.ShowSubtitle("Name: ~b~" & sender.MenuItems(index).Text & nl & "~s~Model: ~r~" & sender.MenuItems(index).Model & nl & "~s~Hash: ~y~" & sender.MenuItems(index).Hash & nl & "~s~Price: ~g~" & sender.MenuItems(index).Price)    End Sub

That has been fixed already, you can grab it off girhub.

Sir, another error after update to your latest source code on github

 

System.NullReferenceException: Object reference not set to an instance of an object.   at NativeUI.MenuPool.<>c.<ProcessControl>b__8_0(UIMenu menu)   at System.Linq.Enumerable.WhereListIterator`1.MoveNext()   at NativeUI.MenuPool.ProcessControl()   at NativeUI.MenuPool.ProcessMenus()   at PremiumDeluxeMotorsport.NET.pdmcarshop.OnTick(Object o, EventArgs e)   at GTA.Script.raise_Tick(Object value0, EventArgs value1)   at GTA.Script.MainLoop()
the code causing the error is just as helpful as the error code if not more
Link to comment
https://gtaforums.com/topic/809284-net-nativeui/#findComment-1067790053
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 6 Users Currently Viewing
    0 members, 0 Anonymous, 6 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.