Quantcast

Jump to content

» «
Photo

[.NET] NativeUI

V WIP
195 replies to this topic
qiangqiang101
  • qiangqiang101

    I'm Not MentaL

  • Members
  • Joined: 02 Feb 2010
  • Malaysia

#31

Posted 24 July 2015 - 09:05 AM

 

 

 

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

 
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

 

 

but the problem is Guad's menu also not show when i hit F5


Guad
  • Guad

    Punk-ass Bitch

  • Members
  • Joined: 08 May 2015
  • Spain

#32

Posted 24 July 2015 - 03:32 PM

Spoiler

but the problem is Guad's menu also not show when i hit F5

 

 

MenuPool has been changed since 0.9, it's no longer static. In your script constructor you will have to initialize it and then add every menu you create to it with myMenuPool.Add(myMenu). Then you can use myMenuPool.ProcessMenus().

The example in the OP is for 0.9 and will not work for the github version. 1.0 release is expected for this weekend or next monday/tuesday.


Guad
  • Guad

    Punk-ass Bitch

  • Members
  • Joined: 08 May 2015
  • Spain

#33

Posted 24 July 2015 - 03:39 PM

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"?

Yeah sure, you can perfectly do that with

item.Activated += (menu, item) =>
                 {
                       UI.Notify("Button activated");
                 }

qiangqiang101
  • qiangqiang101

    I'm Not MentaL

  • Members
  • Joined: 02 Feb 2010
  • Malaysia

#34

Posted 24 July 2015 - 05:08 PM Edited by qiangqiang101, 24 July 2015 - 05:10 PM.

 

Spoiler

but the problem is Guad's menu also not show when i hit F5

 

 

MenuPool has been changed since 0.9, it's no longer static. In your script constructor you will have to initialize it and then add every menu you create to it with myMenuPool.Add(myMenu). Then you can use myMenuPool.ProcessMenus().

The example in the OP is for 0.9 and will not work for the github version. 1.0 release is expected for this weekend or next monday/tuesday.

 

 

Can you fix my code?

Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Windows.Forms
Imports GTA
Imports GTA.Native
Imports NativeUI
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks

Public Class pdmcarshop
Inherits Script

Private player As Player
Private playerPed As Ped
Private simeon As Ped

Private mainMenu As UIMenu
Private motorMenu As UIMenu
Private compactMenu As UIMenu
Private coupeMenu As UIMenu
Private sedanMenu As UIMenu
Private sportMenu As UIMenu
Private classicMenu As UIMenu
Private exoticMenu As UIMenu
Private muscleMenu As UIMenu
Private offroadMenu As UIMenu
Private suvMenu As UIMenu
Private vanMenu As UIMenu
Private utilityMenu As UIMenu
Private armouredMenu As UIMenu

Dim itemMotor As New UIMenuItem("Motorcycles")
Dim itemCompact As New UIMenuItem("Compacts")
Dim itemCoupe As New UIMenuItem("Coupes")
Dim itemSedan As New UIMenuItem("Sedans")
Dim itemSport As New UIMenuItem("Sports")
Dim itemClassic As New UIMenuItem("Classics")
Dim itemExotic As New UIMenuItem("Exotics")
Dim itemMuscle As New UIMenuItem("Muscle")
Dim itemOffRoad As New UIMenuItem("Off-Road")
Dim itemSuv As New UIMenuItem("SUVs")
Dim itemVan As New UIMenuItem("Vans")
Dim itemUtility As New UIMenuItem("Utility")
Dim itemArmoured As New UIMenuItem("Armoured")

Private motorcycle As String = Application.StartupPath & "\scripts\PDMCarShop\motorcycle.ini"
Private compact As String = Application.StartupPath & "\scripts\PDMCarShop\compact.ini"
Private coupe As String = Application.StartupPath & "\scripts\PDMCarShop\coupe.ini"
Private sedan As String = Application.StartupPath & "\scripts\PDMCarShop\sedan.ini"
Private sport As String = Application.StartupPath & "\scripts\PDMCarShop\sport.ini"
Private classic As String = Application.StartupPath & "\scripts\PDMCarShop\classic.ini"
Private exotic As String = Application.StartupPath & "\scripts\PDMCarShop\exotic.ini"
Private muscle As String = Application.StartupPath & "\scripts\PDMCarShop\muscle.ini"
Private offroad As String = Application.StartupPath & "\scripts\PDMCarShop\offroad.ini"
Private suv As String = Application.StartupPath & "\scripts\PDMCarShop\suv.ini"
Private van As String = Application.StartupPath & "\scripts\PDMCarShop\van.ini"
Private utility As String = Application.StartupPath & "\scripts\PDMCarShop\utility.ini"
Private armoured As String = Application.StartupPath & "\scripts\PDMCarShop\armoured.ini"
Private parameters As String() = {"[name]", "[hash]", "[price]", "[price2]", "[model]"}

Private _menuPool As MenuPool

Public Sub ReadMotorcycle()
Dim format As New BTEFormatReader(motorcycle, parameters)
Dim qty As Integer = format.Count - 1

motorMenu = New UIMenu("PDM Car Shop", "~r~MOTORCYCLES")
_menuPool.Add(motorMenu)
For i As Integer = 0 To format.Count - 1
Dim item As New UIMenuItem(format(i)("name") & " $" & format(i)("price"))
motorMenu.AddItem(item)
With item
.Hash = format(i)("hash")
.Model = format(i)("model")
.Price = format(i)("price")
End With
Next
motorMenu.RefreshIndex()
mainMenu.BindMenuToItem(motorMenu, itemMotor)
End Sub

Public Sub ReadCompact()
Dim format As New BTEFormatReader(compact, parameters)
Dim qty As Integer = format.Count - 1

compactMenu = New UIMenu("PDM Car Shop", "~r~COMPACTS")
_menuPool.Add(compactMenu)
For i As Integer = 0 To format.Count - 1
Dim item As New UIMenuItem(format(i)("name") & " $" & format(i)("price"))
compactMenu.AddItem(item)
With item
.Hash = format(i)("hash")
.Model = format(i)("model")
.Price = format(i)("price")
End With
Next
compactMenu.RefreshIndex()
mainMenu.BindMenuToItem(compactMenu, itemCompact)
End Sub

Public Sub ReadCoupe()
Dim format As New BTEFormatReader(coupe, parameters)
Dim qty As Integer = format.Count - 1

coupeMenu = New UIMenu("PDM Car Shop", "~r~COUPES")
_menuPool.Add(coupeMenu)
For i As Integer = 0 To format.Count - 1
Dim item As New UIMenuItem(format(i)("name") & " $" & format(i)("price"))
coupeMenu.AddItem(item)
With item
.Hash = format(i)("hash")
.Model = format(i)("model")
.Price = format(i)("price")
End With
Next
coupeMenu.RefreshIndex()
mainMenu.BindMenuToItem(coupeMenu, itemCoupe)
End Sub

Public Sub ReadSedan()
Dim format As New BTEFormatReader(sedan, parameters)
Dim qty As Integer = format.Count - 1

sedanMenu = New UIMenu("PDM Car Shop", "~r~SEDANS")
_menuPool.Add(sedanMenu)
For i As Integer = 0 To format.Count - 1
Dim item As New UIMenuItem(format(i)("name") & " $" & format(i)("price"))
sedanMenu.AddItem(item)
With item
.Hash = format(i)("hash")
.Model = format(i)("model")
.Price = format(i)("price")
End With
Next
sedanMenu.RefreshIndex()
mainMenu.BindMenuToItem(sedanMenu, itemSedan)
End Sub

Public Sub ReadSport()
Dim format As New BTEFormatReader(sport, parameters)
Dim qty As Integer = format.Count - 1

sportMenu = New UIMenu("PDM Car Shop", "~r~SPORTS")
_menuPool.Add(sportMenu)
For i As Integer = 0 To format.Count - 1
Dim item As New UIMenuItem(format(i)("name") & " $" & format(i)("price"))
sportMenu.AddItem(item)
With item
.Hash = format(i)("hash")
.Model = format(i)("model")
.Price = format(i)("price")
End With
Next
sportMenu.RefreshIndex()
mainMenu.BindMenuToItem(sportMenu, itemSport)
End Sub

Public Sub ReadClassic()
Dim format As New BTEFormatReader(classic, parameters)
Dim qty As Integer = format.Count - 1

classicMenu = New UIMenu("PDM Car Shop", "~r~CLASSICS")
_menuPool.Add(classicMenu)
For i As Integer = 0 To format.Count - 1
Dim item As New UIMenuItem(format(i)("name") & " $" & format(i)("price"))
classicMenu.AddItem(item)
With item
.Hash = format(i)("hash")
.Model = format(i)("model")
.Price = format(i)("price")
End With
Next
classicMenu.RefreshIndex()
mainMenu.BindMenuToItem(classicMenu, itemClassic)
End Sub

Public Sub ReadExotic()
Dim format As New BTEFormatReader(exotic, parameters)
Dim qty As Integer = format.Count - 1

exoticMenu = New UIMenu("PDM Car Shop", "~r~EXOTICS")
_menuPool.Add(exoticMenu)
For i As Integer = 0 To format.Count - 1
Dim item As New UIMenuItem(format(i)("name") & " $" & format(i)("price"))
exoticMenu.AddItem(item)
With item
.Hash = format(i)("hash")
.Model = format(i)("model")
.Price = format(i)("price")
End With
Next
exoticMenu.RefreshIndex()
mainMenu.BindMenuToItem(exoticMenu, itemExotic)
End Sub

Public Sub ReadMuscle()
Dim format As New BTEFormatReader(muscle, parameters)
Dim qty As Integer = format.Count - 1

muscleMenu = New UIMenu("PDM Car Shop", "~r~MUSCLES")
_menuPool.Add(muscleMenu)
For i As Integer = 0 To format.Count - 1
Dim item As New UIMenuItem(format(i)("name") & " $" & format(i)("price"))
muscleMenu.AddItem(item)
With item
.Hash = format(i)("hash")
.Model = format(i)("model")
.Price = format(i)("price")
End With
Next
muscleMenu.RefreshIndex()
mainMenu.BindMenuToItem(muscleMenu, itemMuscle)
End Sub

Public Sub ReadOffroad()
Dim format As New BTEFormatReader(offroad, parameters)
Dim qty As Integer = format.Count - 1

offroadMenu = New UIMenu("PDM Car Shop", "~r~OFF-ROAD")
_menuPool.Add(offroadMenu)
For i As Integer = 0 To format.Count - 1
Dim item As New UIMenuItem(format(i)("name") & " $" & format(i)("price"))
offroadMenu.AddItem(item)
With item
.Hash = format(i)("hash")
.Model = format(i)("model")
.Price = format(i)("price")
End With
Next
offroadMenu.RefreshIndex()
mainMenu.BindMenuToItem(offroadMenu, itemOffRoad)
End Sub

Public Sub ReadSuv()
Dim format As New BTEFormatReader(suv, parameters)
Dim qty As Integer = format.Count - 1

suvMenu = New UIMenu("PDM Car Shop", "~r~SUVS")
_menuPool.Add(suvMenu)
For i As Integer = 0 To format.Count - 1
Dim item As New UIMenuItem(format(i)("name") & " $" & format(i)("price"))
suvMenu.AddItem(item)
With item
.Hash = format(i)("hash")
.Model = format(i)("model")
.Price = format(i)("price")
End With
Next
suvMenu.RefreshIndex()
mainMenu.BindMenuToItem(suvMenu, itemSuv)
End Sub

Public Sub ReadVan()
Dim format As New BTEFormatReader(van, parameters)
Dim qty As Integer = format.Count - 1

vanMenu = New UIMenu("PDM Car Shop", "~r~VANS")
_menuPool.Add(vanMenu)
For i As Integer = 0 To format.Count - 1
Dim item As New UIMenuItem(format(i)("name") & " $" & format(i)("price"))
vanMenu.AddItem(item)
With item
.Hash = format(i)("hash")
.Model = format(i)("model")
.Price = format(i)("price")
End With
Next
vanMenu.RefreshIndex()
mainMenu.BindMenuToItem(vanMenu, itemVan)
End Sub

Public Sub ReadUtility()
Dim format As New BTEFormatReader(utility, parameters)
Dim qty As Integer = format.Count - 1

utilityMenu = New UIMenu("PDM Car Shop", "~r~UTILITIES")
_menuPool.Add(utilityMenu)
For i As Integer = 0 To format.Count - 1
Dim item As New UIMenuItem(format(i)("name") & " $" & format(i)("price"))
utilityMenu.AddItem(item)
With item
.Hash = format(i)("hash")
.Model = format(i)("model")
.Price = format(i)("price")
End With
Next
utilityMenu.RefreshIndex()
mainMenu.BindMenuToItem(utilityMenu, itemUtility)
End Sub

Public Sub ReadArmoured()
Dim format As New BTEFormatReader(armoured, parameters)
_menuPool.Add(armouredMenu)
Dim qty As Integer = format.Count - 1

armouredMenu = New UIMenu("PDM Car Shop", "~r~ARMOURED")
For i As Integer = 0 To format.Count - 1
Dim item As New UIMenuItem(format(i)("name") & " $" & format(i)("price"))
armouredMenu.AddItem(item)
With item
.Hash = format(i)("hash")
.Model = format(i)("model")
.Price = format(i)("price")
End With
Next
armouredMenu.RefreshIndex()
mainMenu.BindMenuToItem(armouredMenu, itemArmoured)
End Sub

Public Sub New()
AddHandler Tick, AddressOf OnTick
AddHandler KeyDown, AddressOf OnKeyDown
_menuPool = New MenuPool()

mainMenu = New UIMenu("PDM Car Shop", "~b~CATEGORIES")
_menuPool.Add(mainMenu)
mainMenu.AddItem(itemMotor)
mainMenu.AddItem(itemCompact)
mainMenu.AddItem(itemCoupe)
mainMenu.AddItem(itemSedan)
mainMenu.AddItem(itemSport)
mainMenu.AddItem(itemClassic)
mainMenu.AddItem(itemExotic)
mainMenu.AddItem(itemMuscle)
mainMenu.AddItem(itemOffRoad)
mainMenu.AddItem(itemSuv)
mainMenu.AddItem(itemVan)
mainMenu.AddItem(itemUtility)
mainMenu.AddItem(itemArmoured)
mainMenu.RefreshIndex()

ReadMotorcycle()
ReadCompact()
ReadCoupe()
ReadSedan()
ReadSport()
ReadClassic()
ReadExotic()
ReadMuscle()
ReadOffroad()
ReadSuv()
ReadVan()
ReadUtility()
ReadArmoured()

AddHandler mainMenu.OnItemSelect, AddressOf ItemSelectHandler
AddHandler motorMenu.OnItemSelect, AddressOf CategoryItemSelectHandler
AddHandler compactMenu.OnItemSelect, AddressOf CategoryItemSelectHandler
AddHandler coupeMenu.OnItemSelect, AddressOf CategoryItemSelectHandler
AddHandler sedanMenu.OnItemSelect, AddressOf CategoryItemSelectHandler
AddHandler sportMenu.OnItemSelect, AddressOf CategoryItemSelectHandler
AddHandler classicMenu.OnItemSelect, AddressOf CategoryItemSelectHandler
AddHandler exoticMenu.OnItemSelect, AddressOf CategoryItemSelectHandler
AddHandler muscleMenu.OnItemSelect, AddressOf CategoryItemSelectHandler
AddHandler offroadMenu.OnItemSelect, AddressOf CategoryItemSelectHandler
AddHandler suvMenu.OnItemSelect, AddressOf CategoryItemSelectHandler
AddHandler vanMenu.OnItemSelect, AddressOf CategoryItemSelectHandler
AddHandler utilityMenu.OnItemSelect, AddressOf CategoryItemSelectHandler
AddHandler armouredMenu.OnItemSelect, AddressOf CategoryItemSelectHandler

AddHandler motorMenu.OnIndexChange, AddressOf CategoryItemChange
AddHandler compactMenu.OnIndexChange, AddressOf CategoryItemChange
AddHandler coupeMenu.OnIndexChange, AddressOf CategoryItemChange
AddHandler sedanMenu.OnIndexChange, AddressOf CategoryItemChange
AddHandler sportMenu.OnIndexChange, AddressOf CategoryItemChange
AddHandler classicMenu.OnIndexChange, AddressOf CategoryItemChange
AddHandler exoticMenu.OnIndexChange, AddressOf CategoryItemChange
AddHandler muscleMenu.OnIndexChange, AddressOf CategoryItemChange
AddHandler offroadMenu.OnIndexChange, AddressOf CategoryItemChange
AddHandler suvMenu.OnIndexChange, AddressOf CategoryItemChange
AddHandler vanMenu.OnIndexChange, AddressOf CategoryItemChange
AddHandler utilityMenu.OnIndexChange, AddressOf CategoryItemChange
AddHandler armouredMenu.OnIndexChange, AddressOf CategoryItemChange
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 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

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 Sub
End Class

Guad
  • Guad

    Punk-ass Bitch

  • Members
  • Joined: 08 May 2015
  • Spain

#35

Posted 24 July 2015 - 06:43 PM

 

 

Spoiler

but the problem is Guad's menu also not show when i hit F5

 

 

MenuPool has been changed since 0.9, it's no longer static. In your script constructor you will have to initialize it and then add every menu you create to it with myMenuPool.Add(myMenu). Then you can use myMenuPool.ProcessMenus().

The example in the OP is for 0.9 and will not work for the github version. 1.0 release is expected for this weekend or next monday/tuesday.

 

 

Can you fix my code?

Spoiler

 

I'm not a VB programmer, sorry. Also here's a tip, you can make a button open another menu by using firstMenu.BindMenuToItem(secondMenu, itemThatOpensIt)


qiangqiang101
  • qiangqiang101

    I'm Not MentaL

  • Members
  • Joined: 02 Feb 2010
  • Malaysia

#36

Posted 24 July 2015 - 07:21 PM

 

 

 

Spoiler

but the problem is Guad's menu also not show when i hit F5

 

 

MenuPool has been changed since 0.9, it's no longer static. In your script constructor you will have to initialize it and then add every menu you create to it with myMenuPool.Add(myMenu). Then you can use myMenuPool.ProcessMenus().

The example in the OP is for 0.9 and will not work for the github version. 1.0 release is expected for this weekend or next monday/tuesday.

 

 

Can you fix my code?

Spoiler

 

I'm not a VB programmer, sorry. Also here's a tip, you can make a button open another menu by using firstMenu.BindMenuToItem(secondMenu, itemThatOpensIt)

 

yes i did! see >>>mainMenu.BindMenuToItem(sedanMenu, itemSedan)


GeorgeZhang
  • GeorgeZhang

    I'm New

  • Members
  • Joined: 04 Jul 2015
  • None

#37

Posted 26 July 2015 - 05:51 AM

 

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"?

Yeah sure, you can perfectly do that with

item.Activated += (menu, item) =>
                 {
                       UI.Notify("Button activated");
                 }

but I cannot find myItem.Activated, it says: NativeUI.UIMenuItem does not contain a definition for "Activated", am i doing something wrong? can you show me a simple example please?


alex8b
  • alex8b

    Square Civilian

  • Members
  • Joined: 12 Jun 2015
  • Sweden

#38

Posted 26 July 2015 - 09:38 AM Edited by alex8b, 26 July 2015 - 09:45 AM.

It would be great if you merge it into ScriptHookDotNet. That would solve all the problems with distribution/incompatible versions.

Guad
  • Guad

    Punk-ass Bitch

  • Members
  • Joined: 08 May 2015
  • Spain

#39

Posted 26 July 2015 - 10:22 AM

 

 

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"?

Yeah sure, you can perfectly do that with

item.Activated += (menu, item) =>
                 {
                       UI.Notify("Button activated");
                 }

but I cannot find myItem.Activated, it says: NativeUI.UIMenuItem does not contain a definition for "Activated", am i doing something wrong? can you show me a simple example please?

 

 

That's because it was added in 1.0, which was just released. You can get the full changelog and download the release here:

https://github.com/G...eleases/tag/1.0


GeorgeZhang
  • GeorgeZhang

    I'm New

  • Members
  • Joined: 04 Jul 2015
  • None

#40

Posted 26 July 2015 - 03:03 PM Edited by GeorgeZhang, 26 July 2015 - 04:10 PM.

 

 

 

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"?

Yeah sure, you can perfectly do that with

item.Activated += (menu, item) =>
                 {
                       UI.Notify("Button activated");
                 }

but I cannot find myItem.Activated, it says: NativeUI.UIMenuItem does not contain a definition for "Activated", am i doing something wrong? can you show me a simple example please?

 

 

That's because it was added in 1.0, which was just released. You can get the full changelog and download the release here:

https://github.com/G...eleases/tag/1.0

 

nice, got it working! great update thanks:) so, every button needs to have a name? Though I can't understand, ScriptHookVDotNet's example shows that it add a button and change it and add it as another, that seems weird but it works:

        var button = new MenuButton( "Player", "Opens the menu with \nplayer commands" );
        button.Activated += ( sender, args ) => this.OpenPlayerMenu();
        menuItems.Add( button );

        button = new MenuButton( "Weapons", "Opens the menu with \nweapon commands" );
        button.Activated += ( sender, args ) => this.OpenWeaponMenu();
        menuItems.Add( button );

Guad
  • Guad

    Punk-ass Bitch

  • Members
  • Joined: 08 May 2015
  • Spain

#41

Posted 26 July 2015 - 04:47 PM

 

 

 

 

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"?

Yeah sure, you can perfectly do that with

item.Activated += (menu, item) =>
                 {
                       UI.Notify("Button activated");
                 }

but I cannot find myItem.Activated, it says: NativeUI.UIMenuItem does not contain a definition for "Activated", am i doing something wrong? can you show me a simple example please?

 

 

That's because it was added in 1.0, which was just released. You can get the full changelog and download the release here:

https://github.com/G...eleases/tag/1.0

 

nice, got it working! great update thanks:) so, every button needs to have a name? Though I can't understand, ScriptHookVDotNet's example shows that it add a button and change it and add it as another, that seems weird but it works:

        var button = new MenuButton( "Player", "Opens the menu with \nplayer commands" );
        button.Activated += ( sender, args ) => this.OpenPlayerMenu();
        menuItems.Add( button );

        button = new MenuButton( "Weapons", "Opens the menu with \nweapon commands" );
        button.Activated += ( sender, args ) => this.OpenWeaponMenu();
        menuItems.Add( button );

 

The example you provided would work with NativeUI.

Not all buttons have to be initialised into a variable, but it helps.


alex8b
  • alex8b

    Square Civilian

  • Members
  • Joined: 12 Jun 2015
  • Sweden

#42

Posted 26 July 2015 - 04:59 PM

Great mod!

 

I have few feature requests.

 

1. Slider control

2. Find element by value, not by index in the constructor.


jedijosh920
  • jedijosh920

    ⭐⭐⭐⭐⭐

  • Members
  • Joined: 01 Mar 2012
  • United-States

#43

Posted 26 July 2015 - 06:27 PM

Good update! I used NativeUI in my latest mod: https://www.gta5-mod...mal-ark-shelter

 

725a58-3.jpg


frodzet
  • frodzet

    Snitch

  • Members
  • Joined: 24 May 2015
  • Denmark

#44

Posted 26 July 2015 - 07:26 PM

Thanks man! This is sweet! We can finally get some good looking UI's without having to spend hours developing our own :-) 

 

I haven't tested it thoroughly out yet, but i was wondering if we can add complete arrays/lists as new menu items? Like we can in scripthookvdotnet:

List<IMenuItem> menuItems = new List<IMenuItem>();

var buttonX = new MenuButton("X");
menuItems.Add(buttonX);

var mainMenu = new Menu("X Menu", menuItems.ToArray());

(I personally really like this format)

 

Or would we have to do something like:

List<UIMenuItem> menuItems = new List<UIMenuItem>();

var buttonX = new UIMenuItem("X");
menuItems.Add(buttonX);

var mainMenu = new UIMenu("Main Menu", "WHATEVER");

foreach (UIMenuItem item in menuItems)
{
    mainMenu.AddItem(item);
}
  • jedijosh920 likes this

Guad
  • Guad

    Punk-ass Bitch

  • Members
  • Joined: 08 May 2015
  • Spain

#45

Posted 27 July 2015 - 12:40 AM

 

Thanks man! This is sweet! We can finally get some good looking UI's without having to spend hours developing our own :-) 

 

I haven't tested it thoroughly out yet, but i was wondering if we can add complete arrays/lists as new menu items? Like we can in scripthookvdotnet:

List<IMenuItem> menuItems = new List<IMenuItem>();

var buttonX = new MenuButton("X");
menuItems.Add(buttonX);

var mainMenu = new Menu("X Menu", menuItems.ToArray());

(I personally really like this format)

 

Or would we have to do something like:

List<UIMenuItem> menuItems = new List<UIMenuItem>();

var buttonX = new UIMenuItem("X");
menuItems.Add(buttonX);

var mainMenu = new UIMenu("Main Menu", "WHATEVER");

foreach (UIMenuItem item in menuItems)
{
    mainMenu.AddItem(item);
}

 

Yeah, you'd have to do the second option.


ayylmao420
  • ayylmao420

    Player Hater

  • New Members
  • Joined: 27 Jul 2015
  • Azerbaijan

#46

Posted 27 July 2015 - 12:01 PM

The menu is called automatically, but i want to have the menu spawned via a event and rather not a key. It doesn't matter if you instantiate the menu like ExampleMenu test = new ExampleMenu(); it still gets called automatically. The problem is i can't call the menu in a static void, because .visible doesn't seem to work outside of the examplemenu.


frodzet
  • frodzet

    Snitch

  • Members
  • Joined: 24 May 2015
  • Denmark

#47

Posted 27 July 2015 - 02:42 PM

 

 

Thanks man! This is sweet! We can finally get some good looking UI's without having to spend hours developing our own :-) 

 

I haven't tested it thoroughly out yet, but i was wondering if we can add complete arrays/lists as new menu items? Like we can in scripthookvdotnet:

List<IMenuItem> menuItems = new List<IMenuItem>();

var buttonX = new MenuButton("X");
menuItems.Add(buttonX);

var mainMenu = new Menu("X Menu", menuItems.ToArray());

(I personally really like this format)

 

Or would we have to do something like:

List<UIMenuItem> menuItems = new List<UIMenuItem>();

var buttonX = new UIMenuItem("X");
menuItems.Add(buttonX);

var mainMenu = new UIMenu("Main Menu", "WHATEVER");

foreach (UIMenuItem item in menuItems)
{
    mainMenu.AddItem(item);
}

 

Yeah, you'd have to do the second option.

 

 

It's not a deal breaker anyways :-) By the way, you should just fix the example code slighty, as you can see, hitting F5 while on another menu than the mainMenu will cause the mainMenu to interfere with the current menu, it should instead either handleback one step like the backspace does or it should completely close all menus :-)


GeorgeZhang
  • GeorgeZhang

    I'm New

  • Members
  • Joined: 04 Jul 2015
  • None

#48

Posted 27 July 2015 - 02:53 PM

ok, there's another thing happening: evey UIMenuListItems in my menu appear like this <   option > rather than < option > if you know what i mean. there's a unwanted blank at the left side, how can I fix it??


Guad
  • Guad

    Punk-ass Bitch

  • Members
  • Joined: 08 May 2015
  • Spain

#49

Posted 27 July 2015 - 02:59 PM

The menu is called automatically, but i want to have the menu spawned via a event and rather not a key. It doesn't matter if you instantiate the menu like ExampleMenu test = new ExampleMenu(); it still gets called automatically. The problem is i can't call the menu in a static void, because .visible doesn't seem to work outside of the examplemenu.

Just set your menu as a global variable.

 

 

Spoiler

 

It's not a deal breaker anyways :-) By the way, you should just fix the example code slighty, as you can see, hitting F5 while on another menu than the mainMenu will cause the mainMenu to interfere with the current menu, it should instead either handleback one step like the backspace does or it should completely close all menus :-)

 

 

Ah yes, you can use myMenuPool.IsAnyMenuOpen() or myMenuPool.CloseAllMenus(). I'll fix it.

ok, there's another thing happening: evey UIMenuListItems in my menu appear like this <   option > rather than < option > if you know what i mean. there's a unwanted blank at the left side, how can I fix it??

 

Well that's just how string measurement works at the moment, i'll fix try to fix it later, but for now you can insert spaces to "balance" it out.

  • frodzet likes this

ISOFX
  • ISOFX

    Trick

  • Members
  • Joined: 31 May 2015
  • United-Kingdom

#50

Posted 27 July 2015 - 03:44 PM Edited by ISOFX, 27 July 2015 - 04:45 PM.

Hi Guad, i have a question , can you turn a option on and off or is that the check box item.

Thanks :)

 

EDIT: ANOTHER QUESTION

 

can someone help me?

why doesnt my options link with the function? the functions dont work. why? The menu works but not the options.

http://pastebin.com/1k31HSGG

 

NOTE: im just playing around with this. :D


Guad
  • Guad

    Punk-ass Bitch

  • Members
  • Joined: 08 May 2015
  • Spain

#51

Posted 27 July 2015 - 08:11 PM

Hi Guad, i have a question , can you turn a option on and off or is that the check box item.

Thanks :)

 

EDIT: ANOTHER QUESTION

 

can someone help me?

why doesnt my options link with the function? the functions dont work. why? The menu works but not the options.

http://pastebin.com/1k31HSGG

 

NOTE: im just playing around with this. :D

 

You can use a checkbox to turn something on/off.

Your OnItemSelect handler is wrong, you should check whether an item is the item you want, not viceversa.


Guad
  • Guad

    Punk-ass Bitch

  • Members
  • Joined: 08 May 2015
  • Spain

#52

Posted 27 July 2015 - 09:00 PM

Version 1.1 is out, you can now mouse over a screen side and the camera will rotate. Also some minor fixed, changelog here.

  • jedijosh920 and frodzet like this

frodzet
  • frodzet

    Snitch

  • Members
  • Joined: 24 May 2015
  • Denmark

#53

Posted 27 July 2015 - 09:17 PM Edited by frodzet, 27 July 2015 - 09:49 PM.

Version 1.1 is out, you can now mouse over a screen side and the camera will rotate. Also some minor fixed, changelog here.

 

Great, thanks man :-) Really a sweet thing you got going here :-)

 

Oh remember to update the example in the Getting Started as well :-) 


ISOFX
  • ISOFX

    Trick

  • Members
  • Joined: 31 May 2015
  • United-Kingdom

#54

Posted 27 July 2015 - 10:26 PM

Hey Guad , do you know why i get 14 errors? i got the latest scripthookvdotnet and NativeUI in the reference but i get these errors - 

 

Error 1 - The type or namespace name 'UIMenuItem' could not be found (are you missing a using directive or an assembly reference?)
 
Error 2 - The type or namespace name 'UIMenu' could not be found (are you missing a using directive or an assembly reference?)
 
Error 3 - The type or namespace name 'MenuPool' could not be found (are you missing a using directive or an assembly reference?)
 
Can you help me resolve these errors? Thanks :D

Guad
  • Guad

    Punk-ass Bitch

  • Members
  • Joined: 08 May 2015
  • Spain

#55

Posted 27 July 2015 - 10:35 PM

 

Hey Guad , do you know why i get 14 errors? i got the latest scripthookvdotnet and NativeUI in the reference but i get these errors - 

 

Error 1 - The type or namespace name 'UIMenuItem' could not be found (are you missing a using directive or an assembly reference?)
 
Error 2 - The type or namespace name 'UIMenu' could not be found (are you missing a using directive or an assembly reference?)
 
Error 3 - The type or namespace name 'MenuPool' could not be found (are you missing a using directive or an assembly reference?)
 
Can you help me resolve these errors? Thanks :D

 

 

Make sure you didn't move the NativeUI.dll after you've added it to References and placed a using NativeUI; at the top of your script.


ayylmao420
  • ayylmao420

    Player Hater

  • New Members
  • Joined: 27 Jul 2015
  • Azerbaijan

#56

Posted 28 July 2015 - 04:29 AM Edited by ayylmao420, 28 July 2015 - 04:30 AM.

 

The menu is called automatically, but i want to have the menu spawned via a event and rather not a key. It doesn't matter if you instantiate the menu like ExampleMenu test = new ExampleMenu(); it still gets called automatically. The problem is i can't call the menu in a static void, because .visible doesn't seem to work outside of the examplemenu.

Just set your menu as a global variable.

 

 

 

i tried that, it doesn't register it because im calling it from a static void

 

    public UIMenu mainMenu;


frodzet
  • frodzet

    Snitch

  • Members
  • Joined: 24 May 2015
  • Denmark

#57

Posted 28 July 2015 - 08:15 AM Edited by frodzet, 28 July 2015 - 08:23 AM.

 

 

The menu is called automatically, but i want to have the menu spawned via a event and rather not a key. It doesn't matter if you instantiate the menu like ExampleMenu test = new ExampleMenu(); it still gets called automatically. The problem is i can't call the menu in a static void, because .visible doesn't seem to work outside of the examplemenu.

Just set your menu as a global variable.

 

 

 

i tried that, it doesn't register it because im calling it from a static void

 

    public UIMenu mainMenu;

 

 

The question is then, why are you calling it from a static void? For what particular reason are you using static? :-) You could just set the UIMenu mainMenu to be static aswell. 

 

Else you would just have to reference the class by instantiating a new instance of it.

 

MenuExample myExample = new MenuExample();

 

and then to work with stuff that says that an object reference is required you just say myExample.WhatEverFunction

 

IMO static is bad practice, it doesn't really involve true OOP, which is the beauty of C# :-)

  • ayylmao420 likes this

ISOFX
  • ISOFX

    Trick

  • Members
  • Joined: 31 May 2015
  • United-Kingdom

#58

Posted 28 July 2015 - 08:41 AM

Just figured it out before you replied lol anyway if you could help me one more time i will be very greatful, Thanks :D

Ok, i have some code but it doesnt work. Do you know why this doesnt work? 

http://pastebin.com/fTLFFqAa


frodzet
  • frodzet

    Snitch

  • Members
  • Joined: 24 May 2015
  • Denmark

#59

Posted 28 July 2015 - 12:57 PM Edited by frodzet, 29 July 2015 - 12:12 PM.

Meh..


ISOFX
  • ISOFX

    Trick

  • Members
  • Joined: 31 May 2015
  • United-Kingdom

#60

Posted 28 July 2015 - 10:01 PM

Hello Again, sorry for asking so many questions but can someone help me with this code, it doesnt seem to work.

Thanks :D

http://pastebin.com/D7D52tmb





9 user(s) are reading this topic

0 members, 9 guests, 0 anonymous users