Game Menu window

From VbGORE Visual Basic Online RPG Engine

I altered the "MenuWindow" (which appears when you press escape) to include a list of buttons that show/hide the Status (custom window which shows XP, HP, and MP. You can get it in the Custom Features area of the wiki), Stats, Chat, Quick Bar, Inventory, and Mini Map. So, for those of you who would like such a feature in your game, here's what I did.

Adding the Grh

ok, next thing to do. Download the skin file which you can find below. It is meant for the bluewave skin set. Of course, you can change it as you wish to fit your theme. and for those curious, the star at the upper right corner of the skin is my "X" button. Wanted something original!

Skin File: http://www.vbgore.com/Image:117.png

Next, open "bluewave.ini" (or the appropriate skin.ini file) and locate the "[Menu]" section. Add the following to what is already there.

<ini>StatusX=34 StatusY=22 StatusWidth=54 StatusHeight=24

StatsX=34 StatsY=39 StatsWidth=54 StatsHeight=24

ChatX=33 ChatY=56 ChatWidth=54 ChatHeight=24

QuickBarX=21 QuickBarY=73 QuickBarWidth=80 QuickBarHeight=24

InventoryX=21 InventoryY=90 InventoryWidth=80 InventoryHeight=24

MapX=41 MapY=107 MapWidth=42 MapHeight=24</ini>

Client

first off I made a function to handle opening and closing windows. I put it in the "Input.Bas" module.

<vb>Function HideShowWindow(ByVal WindowIndex As Byte) As Byte

   If ShowGameWindow(WindowIndex) Then
       ShowGameWindow(WindowIndex) = 0
       If LastClickedWindow = WindowIndex Then LastClickedWindow = 0
   Else
       ShowGameWindow(WindowIndex) = 1
       LastClickedWindow = WindowIndex
   End If

End Function</vb>

Just a tad bit of info, in the "Input_Keys_Down" function, I replaced the code under "'Hide/Show" functions with this:

<vb>'Hide/show windows

   If Input_Keys_IsPressed(KeyDefinitions.InventoryWindow, KeyCode) Then
       HideShowWindow (InventoryWindow)
   End If
   If Input_Keys_IsPressed(KeyDefinitions.QuickBarWindow, KeyCode) Then
       HideShowWindow (QuickBarWindow)
   End If
   If Input_Keys_IsPressed(KeyDefinitions.ChatWindow, KeyCode) Then
       HideShowWindow (ChatWindow)
   End If
   If Input_Keys_IsPressed(KeyDefinitions.StatWindow, KeyCode) Then
       HideShowWindow (StatWindow)
   End If
   If Input_Keys_IsPressed(KeyDefinitions.StatusWindow, KeyCode) Then
       HideShowWindow (StatusWindow)
   End If
   If Input_Keys_IsPressed(KeyDefinitions.MenuWindow, KeyCode) Then
       HideShowWindow (MenuWindow)
   End If</vb>

That just cleans the code up a bit. Not necessary at all.

Next, go to the "Input.Bas" module. Go to the "Input_Mouse_LeftClick_Window". Go to the "Case MenuWindow" section. replace the code for the 'Quit Button with this:

<vb>'Status button

                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .StatusLbl.X, .Screen.Y + .StatusLbl.Y, .StatusLbl.Width, .StatusLbl.Height) Then
                           HideShowWindow (StatusWindow)
                           Exit Function
                       End If
                       'Stats button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .StatsLbl.X, .Screen.Y + .StatsLbl.Y, .StatsLbl.Width, .StatsLbl.Height) Then
                           HideShowWindow (StatWindow)
                           Exit Function
                       End If
                       'Chat button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .ChatLbl.X, .Screen.Y + .ChatLbl.Y, .ChatLbl.Width, .ChatLbl.Height) Then
                           HideShowWindow (ChatWindow)
                           Exit Function
                       End If
                       'QuickBar button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .QuickBarLbl.X, .Screen.Y + .QuickBarLbl.Y, .QuickBarLbl.Width, .QuickBarLbl.Height) Then
                           HideShowWindow (QuickBarWindow)
                           Exit Function
                       End If
                       'Inventory button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .InventoryLbl.X, .Screen.Y + .InventoryLbl.Y, .InventoryLbl.Width, .InventoryLbl.Height) Then
                           HideShowWindow (InventoryWindow)
                           Exit Function
                       End If
                       'Map button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .MapLbl.X, .Screen.Y + .MapLbl.Y, .MapLbl.Width, .MapLbl.Height) Then
                           If ShowMiniMap = 0 Then ShowMiniMap = 1 Else ShowMiniMap = 0
                           Exit Function
                       End If
                       'Quit button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .QuitLbl.X, .Screen.Y + .QuitLbl.Y, .QuitLbl.Width, .QuitLbl.Height) Then
                           IsUnloading = 1
                           Exit Function
                       End If</vb>

Now go to the "TileEngine.bas" file. Locate the section of code under "Private Type WindowMenu" and add this:

<vb>StatusLbl As Rectangle

   StatsLbl As Rectangle
   ChatLbl As Rectangle
   QuickBarLbl As Rectangle
   InventoryLbl As Rectangle
   MapLbl As Rectangle

</vb>

Now go to "Engine_Init_GUI" and find the section of code under "'Load Menu Window". Then find the section of code "With GameWindow.Menu.QuitLbl". Above that add this:

<vb>With GameWindow.Menu.StatusLbl

       .X = Val(Var_Get(s, "MENU", "StatusX"))
       .Y = Val(Var_Get(s, "MENU", "StatusY"))
       .Width = Val(Var_Get(s, "MENU", "StatusWidth"))
       .Height = Val(Var_Get(s, "MENU", "StatusHeight"))
   End With
   With GameWindow.Menu.StatsLbl
       .X = Val(Var_Get(s, "MENU", "StatsX"))
       .Y = Val(Var_Get(s, "MENU", "StatsY"))
       .Width = Val(Var_Get(s, "MENU", "StatsWidth"))
       .Height = Val(Var_Get(s, "MENU", "StatsHeight"))
   End With
   With GameWindow.Menu.ChatLbl
       .X = Val(Var_Get(s, "MENU", "ChatX"))
       .Y = Val(Var_Get(s, "MENU", "ChatY"))
       .Width = Val(Var_Get(s, "MENU", "ChatWidth"))
       .Height = Val(Var_Get(s, "MENU", "ChatHeight"))
   End With
   With GameWindow.Menu.QuickBarLbl
       .X = Val(Var_Get(s, "MENU", "QuickBarX"))
       .Y = Val(Var_Get(s, "MENU", "QuickBarY"))
       .Width = Val(Var_Get(s, "MENU", "QuickBarWidth"))
       .Height = Val(Var_Get(s, "MENU", "QuickBarHeight"))
   End With
   With GameWindow.Menu.InventoryLbl
       .X = Val(Var_Get(s, "MENU", "InventoryX"))
       .Y = Val(Var_Get(s, "MENU", "InventoryY"))
       .Width = Val(Var_Get(s, "MENU", "InventoryWidth"))
       .Height = Val(Var_Get(s, "MENU", "InventoryHeight"))
   End With
   With GameWindow.Menu.MapLbl
       .X = Val(Var_Get(s, "MENU", "MapX"))
       .Y = Val(Var_Get(s, "MENU", "MapY"))
       .Width = Val(Var_Get(s, "MENU", "MapWidth"))
       .Height = Val(Var_Get(s, "MENU", "MapHeight"))
   End With</vb>

Unless I missed something, that should be it!. You got yourself a fancy Game menu!

Upgrade: Icons

I recently updated the menu system to be more "pretty." Here is a preview of what I mean:

Mnu.JPG

from left to right, top to bottom, those buttons are are 1) Appearance Editor (see my in game character editor) 2) mini - map 3) inventory 4) chat 5) status window (a custom feature [not mine]. you can get it in the custom features area. It's the XP percent bar) 6) stats 7) Quests (Opens a quest window [not mine]. Again, can be found in custom features area] 8) Who - see who's online 9) Guilds - See my guilds tutorial 10) Houses - A feature I'll be adding in the near future 11) Help 12) Quit

If you like it, here's what to do:

Bluewave.ini

Go to the bluewave.ini (or appropriate skin file) and locate [Menu]. Change the related code in that section to this:

<ini>[MENU] ScreenX=340 ScreenY=217 ScreenWidth=121 ScreenHeight=166

AppearanceX=11 AppearanceY=18 AppearanceWidth=24 AppearanceHeight=28

MapX=49 MapY=17 MapWidth=24 MapHeight=28

InventoryX=87 InventoryY=17 InventoryWidth=21 InventoryHeight=26

ChatX=12 ChatY=53 ChatWidth=26 ChatHeight=25

StatusX=50 StatusY=55 StatusWidth=26 StatusHeight=23

StatsX=87 StatsY=52 StatsWidth=21 StatsHeight=26

QuestX=10 QuestY=86 QuestWidth=30 QuestHeight=30

WhoX=47 WhoY=87 WhoWidth=30 WhoHeight=27

GuildX=25 GuildY=34 GuildWidth=86 GuildHeight=84

HouseX=12 HouseY=124 HouseWidth=30 HouseHeight=30

HelpX=49 HelpY=123 HelpWidth=30 HelpHeight=30

QuitX=86 QuitY=124 QuitWidth=28 QuitHeight=30

Grh=1401</ini>

Client

Go to your client code. Open Input.bas and go to Input_Mouse_LeftClick_Window. In there find "Case MenuWindow". Change that section of code to this:

<vb> Case MenuWindow

           If ShowGameWindow(MenuWindow) Then
               With GameWindow.Menu
                   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 = MenuWindow
                      
                       'Appearance button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .AppearanceLbl.X, .Screen.Y + .AppearanceLbl.Y, .AppearanceLbl.Width, .AppearanceLbl.Height) Then
                           HideShowWindow (CosmeticWindow)
                           HideShowWindow (MenuWindow)
                           Exit Function
                       End If
                       'Map button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .MapLbl.X, .Screen.Y + .MapLbl.Y, .MapLbl.Width, .MapLbl.Height) Then
                           If ShowMiniMap = 0 Then ShowMiniMap = 1 Else ShowMiniMap = 0
                          
                           HideShowWindow (MenuWindow)
                           Exit Function
                       End If
                       'Inventory button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .InventoryLbl.X, .Screen.Y + .InventoryLbl.Y, .InventoryLbl.Width, .InventoryLbl.Height) Then
                           HideShowWindow (InventoryWindow)
                           HideShowWindow (MenuWindow)
                           Exit Function
                       End If
                       'Chat button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .ChatLbl.X, .Screen.Y + .ChatLbl.Y, .ChatLbl.Width, .ChatLbl.Height) Then
                           HideShowWindow (ChatWindow)
                           HideShowWindow (MenuWindow)
                           Exit Function
                       End If
                       'Status button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .StatusLbl.X, .Screen.Y + .StatusLbl.Y, .StatusLbl.Width, .StatusLbl.Height) Then
                           HideShowWindow (StatusWindow)
                           HideShowWindow (MenuWindow)
                           Exit Function
                       End If
                       'Stats button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .StatsLbl.X, .Screen.Y + .StatsLbl.Y, .StatsLbl.Width, .StatsLbl.Height) Then
                           HideShowWindow (StatWindow)
                           HideShowWindow (MenuWindow)
                           Exit Function
                       End If
                       'quest button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .QuestLbl.X, .Screen.Y + .QuestLbl.Y, .QuestLbl.Width, .QuestLbl.Height) Then
                           If QuestInfoUBound = 0 Then
                               'No quests in place
                               Engine_AddToChatTextBuffer Message(103), FontColor_Quest
                           Else
                               ShowGameWindow(QuestLogWindow) = IIf(ShowGameWindow(QuestLogWindow) = True, False, True)
                           End If
                           HideShowWindow (MenuWindow)
                           Exit Function
                       End If
                       'Who button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .WhoLbl.X, .Screen.Y + .WhoLbl.Y, .WhoLbl.Width, .WhoLbl.Height) Then
                           sndBuf.Put_Byte DataCode.Server_Who
                           HideShowWindow (MenuWindow)
                           Exit Function
                       End If
                       'Guild button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .GuildLbl.X, .Screen.Y + .GuildLbl.Y, .GuildLbl.Width, .GuildLbl.Height) Then
                           sndBuf.Put_Byte DataCode.User_Group_Info
                           HideShowWindow (MenuWindow)
                           Exit Function
                       End If
                       'House button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .HouseLbl.X, .Screen.Y + .HouseLbl.Y, .HouseLbl.Width, .HouseLbl.Height) Then
                           'HideShowWindow (HouseWindow)
                           HideShowWindow (MenuWindow)
                           Exit Function
                       End If
                       'Help button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .HelpLbl.X, .Screen.Y + .HelpLbl.Y, .HelpLbl.Width, .HelpLbl.Height) Then
                           sndBuf.Put_Byte DataCode.Server_Help
                           HideShowWindow (MenuWindow)
                           Exit Function
                       End If
                       'Quit button
                       If Engine_Collision_Rect(MousePos.X, MousePos.Y, 1, 1, .Screen.X + .QuitLbl.X, .Screen.Y + .QuitLbl.Y, .QuitLbl.Width, .QuitLbl.Height) Then
                           IsUnloading = 1
                           HideShowWindow (MenuWindow)
                           Exit Function
                       End If
                      
                       SelGameWindow = MenuWindow
                   End If
               End With
           End If</vb>

Now go to "Private Type WindowMenu" and change that section of code to this:

<vb>Private Type WindowMenu

   Screen As Rectangle
   AppearanceLbl As Rectangle
   MapLbl As Rectangle
   InventoryLbl As Rectangle
   ChatLbl As Rectangle
   StatusLbl As Rectangle
   StatsLbl As Rectangle
   QuestLbl As Rectangle
   WhoLbl As Rectangle
   GuildLbl As Rectangle
   HouseLbl As Rectangle
   HelpLbl As Rectangle
   QuitLbl As Rectangle
   SkinGrh As Grh
   Locked As Boolean

End Type</vb>

Then locate Engine_Init_GUI and in there find "'Load Menu Window". Change that section of code below it to this:

<vb>'Load Menu Window

   With GameWindow.Menu.Screen
       If LoadCustomPos Then
           .X = Val(Var_Get(t, "MENU", "ScreenX"))
           .Y = Val(Var_Get(t, "MENU", "ScreenY"))
       Else
           .X = Val(Var_Get(s, "MENU", "ScreenX"))
           .Y = Val(Var_Get(s, "MENU", "ScreenY"))
       End If
       .Width = Val(Var_Get(s, "MENU", "ScreenWidth"))
       .Height = Val(Var_Get(s, "MENU", "ScreenHeight"))
   End With
   Engine_Init_Grh GameWindow.Menu.SkinGrh, Val(Var_Get(s, "MENU", "Grh"))
   With GameWindow.Menu.AppearanceLbl
       .X = Val(Var_Get(s, "MENU", "AppearanceX"))
       .Y = Val(Var_Get(s, "MENU", "AppearanceY"))
       .Width = Val(Var_Get(s, "MENU", "AppearanceWidth"))
       .Height = Val(Var_Get(s, "MENU", "AppearanceHeight"))
   End With
   With GameWindow.Menu.MapLbl
       .X = Val(Var_Get(s, "MENU", "MapX"))
       .Y = Val(Var_Get(s, "MENU", "MapY"))
       .Width = Val(Var_Get(s, "MENU", "MapWidth"))
       .Height = Val(Var_Get(s, "MENU", "MapHeight"))
   End With
   With GameWindow.Menu.InventoryLbl
       .X = Val(Var_Get(s, "MENU", "InventoryX"))
       .Y = Val(Var_Get(s, "MENU", "InventoryY"))
       .Width = Val(Var_Get(s, "MENU", "InventoryWidth"))
       .Height = Val(Var_Get(s, "MENU", "InventoryHeight"))
   End With
   With GameWindow.Menu.ChatLbl
       .X = Val(Var_Get(s, "MENU", "ChatX"))
       .Y = Val(Var_Get(s, "MENU", "ChatY"))
       .Width = Val(Var_Get(s, "MENU", "ChatWidth"))
       .Height = Val(Var_Get(s, "MENU", "ChatHeight"))
   End With
   With GameWindow.Menu.StatusLbl
       .X = Val(Var_Get(s, "MENU", "StatusX"))
       .Y = Val(Var_Get(s, "MENU", "StatusY"))
       .Width = Val(Var_Get(s, "MENU", "StatusWidth"))
       .Height = Val(Var_Get(s, "MENU", "StatusHeight"))
   End With
   With GameWindow.Menu.StatsLbl
       .X = Val(Var_Get(s, "MENU", "StatsX"))
       .Y = Val(Var_Get(s, "MENU", "StatsY"))
       .Width = Val(Var_Get(s, "MENU", "StatsWidth"))
       .Height = Val(Var_Get(s, "MENU", "StatsHeight"))
   End With
   With GameWindow.Menu.QuestLbl
       .X = Val(Var_Get(s, "MENU", "QuestX"))
       .Y = Val(Var_Get(s, "MENU", "QuestY"))
       .Width = Val(Var_Get(s, "MENU", "QuestWidth"))
       .Height = Val(Var_Get(s, "MENU", "QuestHeight"))
   End With
   With GameWindow.Menu.WhoLbl
       .X = Val(Var_Get(s, "MENU", "WhoX"))
       .Y = Val(Var_Get(s, "MENU", "WhoY"))
       .Width = Val(Var_Get(s, "MENU", "WhoWidth"))
       .Height = Val(Var_Get(s, "MENU", "WhoHeight"))
   End With
   With GameWindow.Menu.GuildLbl
       .X = Val(Var_Get(s, "MENU", "GuildX"))
       .Y = Val(Var_Get(s, "MENU", "GuildY"))
       .Width = Val(Var_Get(s, "MENU", "GuildWidth"))
       .Height = Val(Var_Get(s, "MENU", "GuildHeight"))
   End With
   With GameWindow.Menu.HouseLbl
       .X = Val(Var_Get(s, "MENU", "HouseX"))
       .Y = Val(Var_Get(s, "MENU", "HouseY"))
       .Width = Val(Var_Get(s, "MENU", "HouseWidth"))
       .Height = Val(Var_Get(s, "MENU", "HouseHeight"))
   End With
   With GameWindow.Menu.HelpLbl
       .X = Val(Var_Get(s, "MENU", "HelpX"))
       .Y = Val(Var_Get(s, "MENU", "HelpY"))
       .Width = Val(Var_Get(s, "MENU", "HelpWidth"))
       .Height = Val(Var_Get(s, "MENU", "HelpHeight"))
   End With
   With GameWindow.Menu.QuitLbl
       .X = Val(Var_Get(s, "MENU", "QuitX"))
       .Y = Val(Var_Get(s, "MENU", "QuitY"))
       .Width = Val(Var_Get(s, "MENU", "QuitWidth"))
       .Height = Val(Var_Get(s, "MENU", "QuitHeight"))
   End With</vb>

Some of the stuff on the new menu (i.e. guilds and housing) depend on my other tutorials I made. You can easily remove them from the menu if you don't want them.

This tutorial is made by: GoreMania

Personal tools