Author Topic: Feature: New menu system that allows for variables in menu widgets  (Read 7241 times)

Eiii

  • Autococker
  • Posts: 4595
Zorch and Cobo could do awesome things with this. ;)

Edited subject to include only one feature
Re-edited to include the feature I want
« Last Edit: January 05, 2008, 06:21:00 PM by jitspoe »

Cobo

  • Autococker
  • Posts: 1362
Re: Feature: Allow for variables in menu widgets
« Reply #1 on: January 05, 2008, 06:24:40 PM »
My menu system ftw!

Code: [Select]
// This is our header. Version 2.
pb2menu 2

// This widgets will always draw.
// They are 'global'.

// Our 'back' button.
WIDGET back BEGIN valign bottom ybot -8 xabs 8 type text command "menu pop" text "Back" END

// Our title picture.
WIDGET title_pic BEGIN type pic pic "m_setup1s" xcent 0 halign center yabs 16 END

// This is the header. The Look, Weapon, Move, and Misc widgets.
// When clicked they refresh the menu passing an argument, the argument will override the default event.
WIDGET title_look    BEGIN xcent -128 yabs 64 halign center text "[Look]"   command "menu refresh LOOK"   END
WIDGET title_weapon  BEGIN xcent -43  yabs 64 halign center text "[Weapon]" command "menu refresh WEAPON" END
WIDGET title_move    BEGIN xcent 42   yabs 64 halign center text "[Move]"   command "menu refresh MOVE"   END
WIDGET title_misc    BEGIN xcent 127  yabs 64 halign center text "[Misc]"   command "menu refresh MISC"   END

// Everything after this is 'dynamic'
// Widgets will draw on events.

// This event will load on default.
ON LOAD
CALL LOOK // Calls the LOOK event.
OFF

// The Look widget got clicked.
ON LOOK
// Change the look of the title_look widget, so its highlighted.
// The title_look widget is defined above, in the 'global' widgets.
WIDGET title_look BEGIN xcent -128 yabs 64 text "ˆE[Look]" END

// Draw Look stuff.

WIDGET look_minput BEGIN type checkbox y 88 xcent -8 halign right cvar in_mouse text "Use Mouse Input" END
WIDGET look_mfree BEGIN yrel 10 halign right type checkbox cvar freelook text "Mouse Freelook" END
WIDGET look_invert BEGIN yrel 10 halign right type checkbox cvar m_invert text "Invert Mouse" END
WIDGET look_msmooth BEGIN yrel 10 halign right type checkbox cvar m_filter text "Mouse Smoothing" END
WIDGET look_sensitivity BEGIN yrel 10 type slider halign right cvar sensitivity text "Sensitivity" min .5 max 20 END
WIDGET look_binds BEGIN xcent 0 yrel 16 halign center nobackground type select width 38 height 10
begin binds
"+lookup" "           Look Up: "
"+lookdown" "         Look Down: "
"+left" "         Turn Left: "
"+right" "        Turn Right: "
"centerview" "       Center View: "
"+mlook" "        Mouse Look: "
"+klook" "     Keyboard Look: "
end
END
WIDGET look_joystick BEGIN y 88 xcent 8 type checkbox cvar in_joystick text "Use Joystick" END
WIDGET look_strafe BEGIN yrel 10 type checkbox cvar lookstrafe text "Look Strafe" END
WIDGET look_advjoy BEGIN yrel 16 text "  Advanced Joystick  " command "menu setup_joystick" END
OFF

// The Weapon widget got clicked.
ON WEAPON
// Change the look of the title_weapon widget, so its highlighted.
// The title_weapon widget is defined above, in the 'global' widgets.
WIDGET title_weapon BEGIN xcent -43  yabs 64 text "ˆE[Weapon]" END

// Draw Weapon stuff.

WIDGET weapon_binds BEGIN xcent 0 y 100 halign center nobackground type select width 38 height 10
begin binds
"+attack" "            Fire Gun: "
"+tossgren" " Prime/Throw Grenade: "
"tossgren timed" " Throw Timed Grenade: "
"tossgren impact" "Throw Impact Grenade: "
"tossgren" "       Throw Grenade: " "dropgren" "        Drop Grenade: "
"empty_co2" "          Reload CO2: "
"dropgun" "            Drop Gun: "
"dropammo large" "     Drop Large Ammo: "
"dropammo small" "     Drop Small Ammo: "
"drophopper" "         Drop Hopper: "
"dropbarrel" "         Drop Barrel: "
"dropco2" "            Drop CO2: "
"cvar_inc hand 1 0 2" "         Switch Hand: "
end
END
OFF

// The Move widget got clicked.
ON MOVE
// Change the look of the title_move widget, so its highlighted.
// The title_move widget is defined above, in the 'global' widgets.
WIDGET title_move BEGIN xcent 42   yabs 64 text "ˆE[Move]" END

// Draw Move stuff.

WIDGET move_run BEGIN xcent 0 y 88 halign right type checkbox text "Always Run" cvar cl_run END
WIDGET move_mfspeed BEGIN yrel 14 x 64 type field width 4 text "Mouse Forward Speed" cvar m_forward END
WIDGET move_msspeed BEGIN yrel 14 x 64 type field width 4 text "Mouse Side Speed" cvar m_side END
WIDGET move_binds BEGIN xcent 0 yrel 16 halign center nobackground type select width 38 height 10
begin binds
"+forward" "      Walk Forward: "
"+back" "     Walk Backward: "
"+moveleft" "         Step Left: "
"+moveright" "        Step Right: "
"+moveup" "         Up / Jump: "
"+movedown" "     Down / Crouch: "
"+speed" "        Walk / Run: "
"+strafe" "            Strafe: "
end
END
OFF

// The Misc widget got clicked.
ON MISC
// Change the look of the title_misc widget, so its highlighted.
// The title_misc widget is defined above, in the 'global' widgets.
WIDGET title_misc BEGIN xcent 127  yabs 64 text "ˆE[Misc]" END

// Draw Misc stuff.

WIDGET misc_noalt BEGIN yrel 32 xcent 0 halign right cvar win_noalttab type checkbox text "Disable Alt-Tab" END
WIDGET misc_binds BEGIN xcent 0 yrel 16 halign center nobackground type select width 38 height 10
begin binds
"messagemode" "              Chat: "
"messagemode2" "       Chat (Team): "
"+scores" "        Scoreboard: "
"dropflag" "         Drop Flag: "
"camera" "      Chase Camera: "
"invnext" "Next Camera Target: "
"invprev" "Prev Camera Target: "
"noclip" "   Noclip Observer: "
"screenshot" "   Take Screenshot: "
end
END
OFF


Also, variables in menus are pretty easy to add, although the way I did it was a quick hack.

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Tweak: Allow for variables in menus / New menu system
« Reply #2 on: January 05, 2008, 06:26:34 PM »
Please don't group things together, and take the time to properly describe what the feature will do rather than starting as many new topics as you can.  Mentioning Zorch and Cobo does nothing to tell people what the feature actually does. :P

http://dplogin.com/dplogin/featurevote/feature.php?id=10009

Eiii

  • Autococker
  • Posts: 4595
Re: Feature: New menu system that allows for variables in menu widgets
« Reply #3 on: January 05, 2008, 06:29:21 PM »
Sorry, I don't really have a fleshed-out specification for the new menu system on-hand- I just think there's a need for one. And other people do as well, apparently.
Also, if any threads need more explaining then I've provided, do feel free to ask for more info. Most of this stuff is fairly abstract from my position, anyway.

FlaMe

  • Autococker
  • Posts: 601


Garrett

  • Autococker
  • Posts: 1372
Re: Feature: New menu system that allows for variables in menu widgets
« Reply #6 on: January 06, 2008, 01:42:17 AM »
I have been waiting for this feature for a while now.  Please people, vote this in.

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Feature: New menu system that allows for variables in menu widgets
« Reply #7 on: January 10, 2008, 10:09:14 PM »
I'm pretty close on this.  I'm wondering if I should allow for variables in the cvar and command fields.  Is there any practical reason for that?  If I added them to the command field, all the existing menus would need to be modified since there are some variables in the commands that need to be left as variables.  Well, actually, they may still work.

Zorchenhimer

  • Autococker
  • Posts: 2614
Re: Feature: New menu system that allows for variables in menu widgets
« Reply #8 on: January 10, 2008, 11:06:30 PM »
I'm pretty close on this.  I'm wondering if I should allow for variables in the cvar and command fields.

YES!!  I think I could do some pretty cool stuff with this.

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Feature: New menu system that allows for variables in menu widgets
« Reply #9 on: January 11, 2008, 12:02:05 AM »
If you say so... I'll see what I can do.  Dynamic cvars could be a pain, though.  What did you have in mind for these?

Zorchenhimer

  • Autococker
  • Posts: 2614
Re: Feature: New menu system that allows for variables in menu widgets
« Reply #10 on: January 11, 2008, 01:06:58 AM »
Actually, nevermind.  Haha.  I can't think of anything.  :P

Edit:  I'll let you know if I think of anything though.

Cobo

  • Autococker
  • Posts: 1362
Re: Feature: New menu system that allows for variables in menu widgets
« Reply #11 on: January 11, 2008, 01:10:55 AM »
If you say so... I'll see what I can do.  Dynamic cvars could be a pain, though.  What did you have in mind for these?
Hm, cant you just do $$cvar$$ for dynamic cvars? Or maybe im not understanding what you mean by dynamic cvars.

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Feature: New menu system that allows for variables in menu widgets
« Reply #12 on: January 11, 2008, 01:19:21 AM »
Well, I went ahead and put it in for the commands, since that shouldn't break anything.  It doesn't matter if the variables are parsed an the menu level or the console level (unless you're trying to do something fancy that includes $'s, but I don't think anything currently does).  I can always add it for the cvars later, but for now, I don't think there's any good reason to waste processing power and programming time for something that won't be used.


Cobo: I mean something like this:

widget
type checkbox
cvar "$some_setting"
text "Check me!"

If you set "some_setting" to different values, the checkbox would set different settings cvars.

Zorchenhimer

  • Autococker
  • Posts: 2614
Re: Feature: New menu system that allows for variables in menu widgets
« Reply #13 on: January 11, 2008, 01:31:54 AM »
OH!! The Funname menu!  For the separate name and clan tag fields.  For instance, you click on a field and it changes what the buttons in the funname menu apply to.  Or would that already be handled by the mouse over field thing?

Cobo

  • Autococker
  • Posts: 1362
Re: Feature: New menu system that allows for variables in menu widgets
« Reply #14 on: January 11, 2008, 01:33:42 AM »
So wouldnt this work?

set setting_name "$$some_setting$$"

widget
type checkbox
cvar "$setting_name"
text "Check me!"

set setting_name "$$another_setting$$"

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Feature: New menu system that allows for variables in menu widgets
« Reply #15 on: January 11, 2008, 01:52:27 AM »
I'm not sure separating the clan tag and name is a good idea.  Then people won't know if they've gone over the name limit.  Also, the funname editor modifies the cvar value directly.  It doesn't put text into the edit box (though it would probably be good to change that some day).

XtremeBain

  • Developer
  • Autococker
  • Posts: 1470
Re: Feature: New menu system that allows for variables in menu widgets
« Reply #16 on: January 11, 2008, 09:09:13 AM »
OH!! The Funname menu!  For the separate name and clan tag fields.  For instance, you click on a field and it changes what the buttons in the funname menu apply to.  Or would that already be handled by the mouse over field thing?

Just make the apply button do something like 'set temptagname $temptag;cvar_cat temptagname $tempname;name $temptagname' to get that menu to work.

Zorchenhimer

  • Autococker
  • Posts: 2614
Re: Feature: New menu system that allows for variables in menu widgets
« Reply #17 on: January 11, 2008, 11:28:03 AM »
Yea, thats what I'm doing now for the tag box.