Buttons

From VbGORE Visual Basic Online RPG Engine

[edit] Introduction

This short tutorial will show you how to add buttons to your vbGORE game. The following will focus on opening the stats window without using the hotkey.

[edit] Adding the code

Firsty, open your current skin.dat and add the following code:

Then open your skin.ini and add:

[QUICKMENU]
ScreenX=0
ScreenY=553
ScreenWidth=32
ScreenHeight=32
Grh=43

This is necessary to add the pic in the quickmenubar.

Change the Grh to suit your image.

Now, open GameClient.vbp.

Find:

Function Input_Mouse_LeftClick_Window(ByVal WindowIndex As Byte) As Byte

After:

Select Case WindowIndex

Add:

        Case QuickMenuWindow
                With GameWindow.QuickMenu
                    If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X, .Screen.Y, .Screen.Width, .Screen.Height) Then
                        Input_Mouse_LeftClick_Window = 1
                        LastClickedWindow = QuickMenuWindow
                        If ShowGameWindow(StatWindow) = 0 Then
                            ShowGameWindow(StatWindow) = 1
                        Else
                            ShowGameWindow(StatWindow) = 0
                        End If
                        LastClickedWindow = 0
                    End If
                End With

Find:

'Set scroll pixels per frame

Add:

ShowGameWindow(QuickMenuWindow) = 1

Replace:

'Important: Windows are ordered by priority, where 1 = highest!
Public Const AmountWindow As Byte = 1
Public Const MenuWindow As Byte = 2
Public Const NPCChatWindow As Byte = 3
Public Const TradeWindow As Byte = 4
Public Const WriteMessageWindow As Byte = 5
Public Const ViewMessageWindow As Byte = 6
Public Const MailboxWindow As Byte = 7
Public Const InventoryWindow As Byte = 8
Public Const ShopWindow As Byte = 9
Public Const BankWindow As Byte = 10
Public Const StatWindow As Byte = 11
Public Const ChatWindow As Byte = 12
Public Const QuickBarWindow As Byte = 13
Public Const NumGameWindows As Byte = 13

With:

'Important: Windows are ordered by priority, where 1 = highest!
Public Const AmountWindow As Byte = 1
Public Const MenuWindow As Byte = 2
Public Const NPCChatWindow As Byte = 3
Public Const TradeWindow As Byte = 4
Public Const WriteMessageWindow As Byte = 5
Public Const ViewMessageWindow As Byte = 6
Public Const MailboxWindow As Byte = 7
Public Const InventoryWindow As Byte = 8
Public Const ShopWindow As Byte = 9
Public Const BankWindow As Byte = 10
Public Const StatWindow As Byte = 11
Public Const ChatWindow As Byte = 12
Public Const QuickMenuWindow As Byte = 13
Public Const QuickBarWindow As Byte = 14
Public Const NumGameWindows As Byte = 14

Find:

Private Sub Engine_Render_GUI_Window(ByVal WindowIndex As Byte)

After:

Select Case WindowIndex

Add:

        Case QuickMenuWindow
        With GameWindow.QuickMenu
            Engine_Render_Grh .SkinGrh, .Screen.X, .Screen.Y, 0, 1, True, GUIColorValue, GUIColorValue, GUIColorValue, GUIColorValue
        End With

Find:

Public Sub Engine_Init_GUI(Optional ByVal LoadCustomPos As Byte = 1)

Add:

     'Load Quickmenu
    With GameWindow.QuickMenu
        .Screen.X = Val(Var_Get(t, "QUICKMENU", "ScreenX"))
        .Screen.Y = Val(Var_Get(t, "QUICKMENU", "ScreenY"))
        .Screen.Width = Val(Var_Get(s, "QUICKMENU", "ScreenWidth"))
        .Screen.Height = Val(Var_Get(s, "QUICKMENU", "ScreenHeight"))
        Engine_Init_Grh .SkinGrh, Val(Var_Get(s, "QUICKMENU", "Grh"))
    End With

Find:

Private Type KeyDefinitions

Add:

    QuickMenuWindow As Integer

Find:

Private Type WindowQuickBar     'Quick bar window
    Screen As Rectangle
    Image(1 To 12) As Rectangle
    SkinGrh As Grh
End Type

Below Add:

Private Type QuickMenuWindow     'Quick Menu window
    Screen As Rectangle
    SkinGrh As Grh
End Type

Find:

   Public Type GameWindow          'List of all the different game windows
       QuickBar As WindowQuickBar
       Inventory As WindowInventory
       Shop As WindowInventory
       Mailbox As WindowMailbox
       ViewMessage As WindowMessage
       WriteMessage As WindowMessage
       Amount As WindowAmount
       Menu As WindowMenu
       ChatWindow As ChatWindow
       StatWindow As StatWindow
       Bank As WindowInventory
       NPCChat As WindowNPCChat
       Trade As TradeWindow
       QuestLog As dQuestLogWindow 'A link to the quest window information

Below Add:

       QuickMenu As QuickMenuWindow


That's all! Now you know how to do add a window and a button at vbGore!

Personal tools