Raised This Month: $ Target: $400
 0% 

DisplayMenuAtItem / GetMenuSelectionPosition help?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Velak
Junior Member
Join Date: Jan 2009
Old 01-23-2009 , 10:10   DisplayMenuAtItem / GetMenuSelectionPosition help?
Reply With Quote #1

G'day Gang.

I've spent quite a bit of time reading through http://wiki.alliedmods.net, as well as studying other people's code here, so I could make my own admin menu additions.

Everything's going along fine, but I've run into a problem and I just can't seem to solve it. I was hoping one of you code guru's could help me out.
I'm sure this is an easy question for someone.

The problem is, when I have a menu which has multiple pages, if I were to select an item from a deeper page than the "top" one, when the menu is redrawn, it goes back to the "top" page. I'd like it to stay at the page it's on.

Now, I'm sure the solution to my problem is to use the functions DisplayMenuAtItem and GetMenuSelectionPosition but I can't for the life of me seem to get them to work how I want.

To demonstrate my problem/question - attached is just a quick sample of code - Most of this code is stripped from Fexxi's "Left 4 Dead Infected Spawner", but I'll use it just to show you what I mean:

This code compiles and runs fine, but if you select:
4. Left 4 Dead
1. Spawn Weapons
9. Next
then select any item there, it will take you back to the main "Spawn Weapons" menu.

(yes, I know that's exactly what I'm telling it to do)

Can someone please inform me exactly how I can make it so that it will stay on that second "weapons" panel, until I press "8. Back"?

Thank you!
Attached Files
File Type: sp Get Plugin or Get Source (menu_problem.sp - 575 views - 4.2 KB)
Velak is offline
BAILOPAN
Join Date: Jan 2004
Old 01-23-2009 , 21:49   Re: DisplayMenuAtItem / GetMenuSelectionPosition help?
Reply With Quote #2

You need, somewhere, to use DisplayMenuAtItem. You can use GetMenuSelectionPosition (passing in the item selected) to get an appropriate value for DisplayMenuAtItem.

My recommendation is not use DisplayWeaponsMenu to re-display. Just re-use the handle, and avoid closing it until MenuAction_Cancel comes through (it is guaranteed to fire if there is no item selected).

You can edit the menu after each selection to disable the item if you need to. There's no helper to do this trivially (feel free to request one if you want) - but you can do it via MenuAction_DrawItem hooks or RemoveMenuItem+InsertMenuItem.
__________________
egg
BAILOPAN is offline
Velak
Junior Member
Join Date: Jan 2009
Old 01-23-2009 , 23:12   Re: DisplayMenuAtItem / GetMenuSelectionPosition help?
Reply With Quote #3

Quote:
Originally Posted by BAILOPAN View Post
You need, somewhere, to use DisplayMenuAtItem. You can use GetMenuSelectionPosition (passing in the item selected) to get an appropriate value for DisplayMenuAtItem.
G'day!

I used an example of some working code to clearly illustrate my problem, so it would be easy for someone to see where I was having the issue.

However, in my actual code I was indeed using GetMenuSelectionPosition and DisplayMenuAtItem. I know GetMenuSelectionPosition was returning the correct values (I had added some print statements to help debug it), but when I used DisplayMenuAtItem, it aways redisplays the menu back at the main menu.


EDIT: OH. MY. GOD.

I figured it out. I'm so ashamed for wasting your time. I was right, it was a facepalm moment. I'm getting old and forgetful. I'm really sorry for wasting your time.

Last edited by Velak; 01-24-2009 at 11:04. Reason: Brainfart
Velak is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode