vbGore Free Online RPG Engine

Revolutionizing Visual Basic ORPG Development
It is currently Sat May 25, 2013 2:15 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Right Click Menu
PostPosted: Sun Feb 08, 2009 12:38 pm 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
Name: Arie Miller
Credit: Would be nice but not required.
Feature: Right Click Menu
Difficulty: Average
Edits: Server, Client
Details: This basically adds a window that shows up when you right click on a player then disappears when you click anywhere else.
Screenshots:
Attachment:
RightClickMenu.PNG

Server:
Find:
Code:
Public Type DataCode

Below Add:
Code:
User_ClickMenu As Byte


Find:
Code:
'Packet IDs

Scroll to the bottom of the list and add:
Code:
.User_ClickMenu = ###

Where ### is the number after the previous lines number.

Find:
Code:
'React to character

Replace:
Code:
            If Len(UserList(TempIndex).Desc) > 1 Then
                ConBuf.PreAllocate 4 + Len(UserList(TempIndex).Name) + Len(UserList(TempIndex).Desc)
                ConBuf.Put_Byte DataCode.Server_Message
                ConBuf.Put_Byte 30
                ConBuf.Put_String UserList(TempIndex).Name
                ConBuf.Put_String UserList(TempIndex).Desc
                Data_Send ToIndex, UserIndex, ConBuf.Get_Buffer
            Else
                ConBuf.PreAllocate 3 + Len(UserList(TempIndex).Name)
                ConBuf.Put_Byte DataCode.Server_Message
                ConBuf.Put_Byte 31
                ConBuf.Put_String UserList(TempIndex).Name
                Data_Send ToIndex, UserIndex, ConBuf.Get_Buffer
            End If

With:
Code:
            ConBuf.PreAllocate 5 + Len(UserList(TempIndex).Name)
            ConBuf.Put_Byte DataCode.User_ClickMenu
            ConBuf.Put_Integer X
            ConBuf.Put_Integer Y
            ConBuf.Put_String UserList(TempIndex).Name
            Data_Send ToIndex, UserIndex, ConBuf.Get_Buffer


Find:
Code:
Case .User_Use: Data_User_Use rbuf, Index

Below Add:
Code:
Case .User_ClickMenu: Data_User_ClickMenu rbuf, Index


In TCP.bas add:
Code:
Sub Data_User_ClickMenu(ByRef rbuf As DataBuffer, ByVal UserIndex As Integer)

End Sub


Client:
First Create a new window following the adding windows tutorial. From here on wherever you see WINDOW that will be the name of the window you made in that tutorial. Make sure your window has the following type data.
Code:
Public Type WINDOW
    Screen As Rectangle
    SkinGrh As Grh
    TargetName As String
End Type


Find:
Code:
Public Type DataCode

Below Add:
Code:
User_ClickMenu As Byte


Find:
Code:
'Packet IDs

Scroll to the bottom of the list and add:
Code:
.User_ClickMenu = ###

Where ### is the number after the previous lines number.

Find:
Code:
Case .User_Trade_UpdateTrade: Data_User_Trade_UpdateTrade rBuf

Below Add:
Code:
Case .User_ClickMenu: Data_User_ClickMenu rBuf


In TCP.bas add:
Code:
Sub Data_User_ClickMenu(ByRef rBuf As DataBuffer)
Dim X As Integer
Dim Y As Integer
X = rBuf.Get_Integer
Y = rBuf.Get_Integer
With GameWindow.WINDOW
.TargetName = rBuf.Get_String
.Screen.X = Engine_TPtoSPX(X) + 16
.Screen.Y = Engine_TPtoSPY(Y) + 16
End With
ShowGameWindow(RightClick) = 1
End Sub


In:
Code:
Private Sub Engine_Render_GUI_Window

Under:
Code:
Select Case WindowIndex

Add:
Code:
        Case WINDOW
            With GameWindow.WINDOW
                Engine_Render_Grh .SkinGrh, .Screen.X, .Screen.Y, 0, 0, False, GUIColorValue, GUIColorValue, GUIColorValue, GUIColorValue
                Engine_Render_Text Font_Default, .TargetName, .Screen.X + 5, .Screen.Y + 5, D3DColorARGB(255, 100, 10, 10)
            End With


NOTE: You may have already added something here while making the window make sure you use that one if you did.

Find:
Code:
'No windows clicked, so a tile click will take

Above add:
Code:
'*** Check for clickmenu
    If ShowGameWindow(WINDOW) = 1 Then ShowGameWindow(WINDOW) = 0


NOTE: You will have to do this twice you will find the No windows clicked comment in the right click even and the left click even.



The following codes are optional they will make it so that if the user clicks on a window it hides the right click menu. If you go to add click events later on you will have to do a bit of work in these sections. To make the window still disappear but your window click events work.

Under:
Code:
Function Input_Mouse_RightClick_Window

Add:
Code:
    '***Check for ClickMenu open
    If ShowGameWindow(WINDOW) = 1 Then ShowGameWindow(WINDOW) = 0


Under:
Code:
Function Input_Mouse_LeftClick_Window

Add:
Code:
    '***Check for ClickMenu open
    If ShowGameWindow(WINDOW) = 1 Then ShowGameWindow(WINDOW) = 0


Last edited by notexistant on Mon Sep 28, 2009 10:20 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Right Click Menu
PostPosted: Sun Feb 08, 2009 12:40 pm 
Hungry Zombie

Joined: Sat Jun 05, 1976 10:06 pm
Posts: 3179
Location: Auckland, New Zealand
Isn't there already a right click menu already done?


Top
 Profile  
 
 Post subject: Re: Right Click Menu
PostPosted: Sun Feb 08, 2009 12:42 pm 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
:? go look at the code I think mine is way cleaner


Top
 Profile  
 
 Post subject: Re: Right Click Menu
PostPosted: Sun Feb 08, 2009 12:47 pm 
Hungry Zombie

Joined: Sat Jun 05, 1976 10:06 pm
Posts: 3179
Location: Auckland, New Zealand
Fair enough :P

Looks good from what I've looked at, good job.


Top
 Profile  
 
 Post subject: Re: Right Click Menu
PostPosted: Sun Feb 08, 2009 12:48 pm 
Bit Baby

Joined: Sun Jul 20, 2008 5:48 pm
Posts: 387
Location: Mercer Island , Washington
Prbly, I wrote the "original "one. But his uses server more than mine IMO


Top
 Profile  
 
 Post subject: Re: Right Click Menu
PostPosted: Sun Feb 08, 2009 12:49 pm 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
The server only really checks if you right clicked a player, otherwise it does nothing.


Top
 Profile  
 
 Post subject: Re: Right Click Menu
PostPosted: Sun Feb 08, 2009 12:50 pm 
Bit Baby

Joined: Sun Jul 20, 2008 5:48 pm
Posts: 387
Location: Mercer Island , Washington
Oh ok. Ill keep mine for now, but may use your in future. :spin:


Top
 Profile  
 
 Post subject: Re: Right Click Menu
PostPosted: Sun Feb 08, 2009 12:53 pm 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
^^ OK, basically what happens is user right clicks client sends right click packet to server like it always does. If the user clicked a player it sends back a packet to show the menu. If not it does one of the other right click things or nothing at all. Then the client checks if you clicked anywhere and if the player clicked somewhere in the client it closes the window.


Top
 Profile  
 
 Post subject: Re: Right Click Menu
PostPosted: Sun Feb 08, 2009 1:00 pm 
Bit Baby

Joined: Sun Jul 20, 2008 5:48 pm
Posts: 387
Location: Mercer Island , Washington
[SNIP]


Last edited by nex666 on Sun Feb 08, 2009 1:03 pm, edited 1 time in total.
Please, this isn't a competition, keep on topic.


Top
 Profile  
 
 Post subject: Re: Right Click Menu
PostPosted: Sun Feb 08, 2009 2:38 pm 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
nex666 wrote:
Fair enough :P

Looks good from what I've looked at, good job.

ty :)


Top
 Profile  
 
 Post subject: Re: Right Click Menu
PostPosted: Mon Feb 09, 2009 5:49 am 
Bit Baby

Joined: Tue Sep 02, 2008 12:33 pm
Posts: 382
Location: United Kingdom
Damn you notexistant, I've already done this feature and i was going to add a tutorial for it. People keep stealing my good intentions :P

Well wasn't exactly this, was a character information screen when you right click a player, ahwell.

But yea, nice tut anyways :)


Top
 Profile  
 
 Post subject: Re: Right Click Menu
PostPosted: Mon Feb 09, 2009 6:00 am 
Slave to the BB

Joined: Sat Feb 24, 2007 11:17 pm
Posts: 2704
Location: The Aussie Land
Noice.

Make it so it does all the checks client side. Only send the packet if you need server side information.

So if you right click on a player, do the check client side. It doesn't matter if the player is really there or not, its not critical. Actually server check could be really annoying if theres lag.

Let's say you wanted that players information. Right-Click player is client side, when the client clicks on "view user information", the client can send that players index to the server requesting for that players information.


Top
 Profile  
 
 Post subject: Re: Right Click Menu
PostPosted: Mon Feb 09, 2009 5:20 pm 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
You see though, that right click packet gets sent by default so even if I were to do that it could end up making some of the default right click features not work. (mailbox) I would have to check for them client side too and... I really don't feel like making this a huge rewrite of features already in vbGore.

DarkSummon wrote:
Damn you notexistant, I've already done this feature and i was going to add a tutorial for it. People keep stealing my good intentions :P

Well wasn't exactly this, was a character information screen when you right click a player, ahwell.

But yea, nice tut anyways :)


:P It would be interesting to see how you did it.


Top
 Profile  
 
 Post subject: Re: Right Click Menu
PostPosted: Thu Feb 12, 2009 10:46 pm 
Bit Baby

Joined: Sun Jul 20, 2008 5:48 pm
Posts: 387
Location: Mercer Island , Washington
Its official, I am using a modified notexistants right-click menu. Found a serious problem with mine (causes lag under certain coditions) and when trading, if a person is in a guild/group it gets their FULL name with description. Instead of fixing my crap, I will start fresh and use this packet based one. If I have issues I can always go back to mine XD


Top
 Profile  
 
 Post subject: Re: Right Click Menu
PostPosted: Fri Feb 13, 2009 3:48 am 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
:rofl:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 8 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group