Log in to reply
 

[Tutorial] - LemonUI Vb.Net Example



  • Hi Guys,

    This is an example to use LemonUI V 1.1 in Vb.Net:

    Public Class HL_Menu_Krlos_Rokr
    Inherits Script
    Private LemonUIPool As LemonUI.ObjectPool
    Private MainMenu As LemonUI.Menus.NativeMenu
    Private SettingsMenu As LemonUI.Menus.NativeMenu

    Private Created As Boolean=False

    Sub New()
        Me.Interval = 5
    End Sub
    
    Sub CreateMenu()
    
        LemonUIPool = New LemonUI.ObjectPool
        MainMenu = New LemonUI.Menus.NativeMenu("Menu 1", "Dev: Krlos_Rokr", "This is a Test Menu")
        SettingsMenu = New LemonUI.Menus.NativeMenu("Settings", "Krlos_Rokr", "Change Script Options") 'SubMenu
        LemonUIPool.Add(MainMenu)
        LemonUIPool.Add(SettingsMenu)
        Dim TItem As New LemonUI.Menus.NativeItem("Item 1", "~b~Some ~w~Info ~r~/////")
        MainMenu.Add(TItem)
        AddHandler Me.Tick, AddressOf LemonUIPool.Process 'Add the process to the Tick
    
        AddHandler TItem.Activated, Sub()
                                        UI.Notify("Selected: " & TItem.Title.ToString) 'Add code to the event handler
                                    End Sub
        TItem = New LemonUI.Menus.NativeItem("Item 2 test", "Some info 2")
        MainMenu.Add(TItem)
        AddHandler TItem.Activated, Sub()
                                        UI.Notify("Selected: " & TItem.Title.ToString)
                                    End Sub
    
    'Add SubMenu
    
    Dim TitemSM = MainMenu.AddSubMenu(SettingsMenu) 'Works OK but can't display the title, instead it's displayed the subtitle
    

    'or can be use this way:
    ' Dim TitemSM2 = New LemonUI.Menus.NativeSubmenuItem(SettingsMenu, MainMenu) 'Works OK -> both cases can't display the title instead it's displayed the subtitle
    'MainMenu.Add(TitemSM2) 'Works OK

    TitemSM.Title = SettingsMenu.Title.Text 'Fix the problems With the incorrect name of the created NativeItem **
        Created = True
    End Sub
    
    
    Sub DestroyMenu()
        MainMenu.Close()
        SettingsMenu.Close() 
        RemoveHandler Me.Tick, AddressOf LemonUIPool.Process
        LemonUIPool = Nothing
        MainMenu.Clear()
        SettingsMenu.Clear()
        MainMenu = Nothing
        SettingsMenu = Nothing
        Created = False
    End Sub
    
    Private Sub HL_Menu_Krlos_Rokr_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.L Then
            If Created = False Then
                CreateMenu()
            End If
            If Created = True Then
                MainMenu.Visible = Not MainMenu.Visible
                If MainMenu.Visible = False Then
                    DestroyMenu()
                End If
            End If
        End If
    End Sub
    

    End Class


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.