PDA

View Full Version : IN Game Menu -


RenEvo
01-02-2005, 23:37
Hey guys, was wondering exactly how forcing the client to show a menu could be done. I saw that Mani pulled it off quite smoothly, and love that ability.

I read up a bit on everything that has posted so far, and can pretty much follow anything you post up. If it helps to know, i have already implemented serverside posting of chat messages using IRecipientFilter etc... Just to show i can get the hang of stuff lol.

Anywho, i played around for about 4 hours last night before my head started hurting from the frustration.

Why couldn't valve had done there "menu" sample as that type of menu and not a freekin builtin VGUI2 menu stored on the clientside....

anywho, if anyone can help me out, that would be totally great.

Thanks in advance.

RenEvo
01-03-2005, 03:14
Well, after taking a long break today, and coming back to it.

I have it figured out, as well as all the other user messages.

I am going to make a helper class for them with documentation and post it up sometime this week.

Geesu
01-03-2005, 07:55
Sounds good, I've been trying to figure this out as well.

RenEvo
01-05-2005, 15:51
until i can get this sample & doc finished, here is a quick rundown.

First, you will need to be able to do the saytext example that is on this forum (usermessage 3 using bitbuff.h & bitbuff.cpp as well as having your own MRecipientFilter created).

now, from there, instead of sending message 3, you will send message 9.

From this point, you can find the correct ordering in the menu.cpp that is located in the cpp look for the ShowMenu function, from memory it is:

Short
Byte
*Char

short = bitfield of items the user can select (i.e. 1-9 + 0)
byte = true/false of whether this is the last send
*char = the text

for the bitfield, you will need to do the following format, then convert to short:

100 0000 0000

starting AFTER the 1, it starts in reverse order, and acts like a true false, 1 for true, 0 for false.

so

110 0000 0011 is will make it so that the user can enter 1, 2, and 0

110 0001 1111 will make it so the user can select 1,2,3,4,5 and 0

111 1111 1111 will make it so options 1-9 and 0 can be selected.

remember that you DONT have to do your text in order, as long as you know what option links.

i.e. Say you send the following menu:

775
false
Pick an Option\n1. Option 1\n2. Option 2\n3. Option 3\n \n0. Exit\n

775 = bitfield 110 000 0111 (use calculator with the scientific view if you aren't familiar with binary)

false = there are no more for this menu, so display it

the last line is the text for the menu, and will display like the following


Pick an Option
1. Option 1
2. Option 2
3. Option 3

0. Exit


options will be returned as user commands in the following format:

menuselect %d

where %d is the number they chose


hope that provides enough information for you, and i hope i remembered everything, if you have any troubles, please post your code, and im sure i can spot the issue.


I should have the full version up soon, with code samples.

RenEvo
01-05-2005, 15:54
*note, if you don't use the 0 for an entry, the actual function is as follows:

if (yournum & (1 << selectedNum -1))

thats what is ran, so for just 1, 2, and 3, your bitfield would be

1111, which = 15

Geesu
01-05-2005, 16:04
Sweet thats perfect, thanks!!!! :)

theqizmo
01-08-2005, 17:45
//-----------------------------------------------------------------------------
// Purpose: Message handler for ShowMenu message
// takes four values:
// short: a bitfield of keys that are valid input
// char : the duration, in seconds, the menu should stay up. -1 means is stays until something is chosen.
// byte : a boolean, TRUE if there is more string yet to be received before displaying the menu, false if it's the last string
// string: menu string to display
// if this message is never received, then scores will simply be the combined totals of the players.
//-----------------------------------------------------------------------------