Clever .menu hacks needed D= -1 reply

Please wait...

Raz0r

Worse than most terrible

50 XP

27th September 2006

0 Uploads

6,737 Posts

0 Threads

#1 7 years ago

I'll keep it simple.

I have a bunch of elements (in a group) that need to be hidden based on the values of two cvars.

Ideally, I would do this: cvarTest ui_saber2_color hideCvar { "red"; "orange"; "yellow"; "green"; "blue"; "purple" }

cvarTest ui_saber_type hideCvar { "single"; "staff" }

Logically akin to: "If the second saber color is regular or if there is no second saber, hide this element" The issue there is, there can only be one cvar test per element (The previous test will be overwritten)

Does anyone know of a clever workaround? Perhaps sneaking a test in onOpen somehow?

The only workaround I can think of (And I want to avoid) is rewriting the UI code to save a list of tests instead of overwriting.




jk3editor

Retard Hungarian Modder

50 XP

21st August 2008

0 Uploads

1,520 Posts

0 Threads

#2 7 years ago

Maybe you can put another element onto it, which would hide it. And if a cvar's value is corrent, then hide this thing. (It's just an idea)




eezstreet

Lord of the .DCC files

50 XP

16th June 2008

0 Uploads

2,662 Posts

0 Threads

#3 7 years ago

Raz0r;5571281I'll keep it simple.

I have a bunch of elements (in a group) that need to be hidden based on the values of two cvars.

Ideally, I would do this: cvarTest ui_saber2_color hideCvar { "red"; "orange"; "yellow"; "green"; "blue"; "purple" }

cvarTest ui_saber_type hideCvar { "single"; "staff" }Logically akin to: "If the second saber color is regular or if there is no second saber, hide this element" The issue there is, there can only be one cvar test per element (The previous test will be overwritten)

Does anyone know of a clever workaround? Perhaps sneaking a test in onOpen somehow?

The only workaround I can think of (And I want to avoid) is rewriting the UI code to save a list of tests instead of overwriting.

Maybe if it's possible, work the other way. Instead of testing for conditions that hide, test conditions for which it would be shown, and set visible to off by default.




Raz0r

Worse than most terrible

50 XP

27th September 2006

0 Uploads

6,737 Posts

0 Threads

#4 7 years ago

I would still only being able to test either the color or the type (single/dual/staff)

I can't rely on 'visible 0' and show it when they press the 'Dual' button - what if they entered the menu *with* dual sabers?

As a temporary work-around so I can release my work, I've reworked a bit of the code to use cvarTest2/cvarHide2 for my second test. I feel bad now =[

WIP screen:

Spoiler: Show
0cdde157.jpg



Xycaleth

Resident programmer guy

50 XP

3rd May 2016

1 Uploads

86 Posts

0 Threads

#5 7 years ago

Maybe use a bit of code to detect to test both cvars? And then if the condition is met, set another single cvar (lets call is ui_blah) to 0 or 1. Then you can use that ui_blah in the ui menu :D




jk3editor

Retard Hungarian Modder

50 XP

21st August 2008

0 Uploads

1,520 Posts

0 Threads

#6 7 years ago

Or open another menu file :D




Raz0r

Worse than most terrible

50 XP

27th September 2006

0 Uploads

6,737 Posts

0 Threads

#7 7 years ago

That wouldn't solve my problem, I don't think. At any rate, it would be ridiculously complex and hard to manage.




Guest

I didn't make it!

0 XP

 
#8 7 years ago

Did you try to store the values in temp variables ? If I know you can create your own variables.

But it is some time ago, I was coding my last menu ;)

I will look into it.

Regards, Arth




Raz0r

Worse than most terrible

50 XP

27th September 2006

0 Uploads

6,737 Posts

0 Threads

#9 7 years ago
Spoiler: Show

keywordHash_t itemParseKeywords[] = { {"action", ItemParse_action, NULL }, {"addColorRange", ItemParse_addColorRange, NULL }, {"align", ItemParse_align, NULL }, {"autowrapped", ItemParse_autowrapped, NULL }, {"appearance_slot", ItemParse_Appearance_slot, NULL }, {"asset_model", ItemParse_asset_model, NULL }, {"asset_shader", ItemParse_asset_shader, NULL }, {"backcolor", ItemParse_backcolor, NULL }, {"background", ItemParse_background, NULL }, {"border", ItemParse_border, NULL }, {"bordercolor", ItemParse_bordercolor, NULL }, {"bordersize", ItemParse_bordersize, NULL }, {"cinematic", ItemParse_cinematic, NULL }, {"columns", ItemParse_columns, NULL }, {"cvar", ItemParse_cvar, NULL }, {"cvarFloat", ItemParse_cvarFloat, NULL }, {"cvarFloatList", ItemParse_cvarFloatList, NULL }, {"cvarStrList", ItemParse_cvarStrList, NULL }, {"cvarTest", ItemParse_cvarTest, NULL }, {"desctext", ItemParse_descText, NULL }, {"decoration", ItemParse_decoration, NULL }, {"disableCvar", ItemParse_disableCvar, NULL }, {"doubleclick", ItemParse_doubleClick, NULL }, {"elementheight", ItemParse_elementheight, NULL }, {"elementtype", ItemParse_elementtype, NULL }, {"elementwidth", ItemParse_elementwidth, NULL }, {"enableCvar", ItemParse_enableCvar, NULL }, {"feeder", ItemParse_feeder, NULL }, {"flag", ItemParse_flag, NULL }, {"focusSound", ItemParse_focusSound, NULL }, {"font", ItemParse_font, NULL }, {"forecolor", ItemParse_forecolor, NULL }, {"group", ItemParse_group, NULL }, {"hideCvar", ItemParse_hideCvar, NULL }, {"horizontalscroll", ItemParse_horizontalscroll, NULL }, {"isCharacter", ItemParse_isCharacter, NULL }, {"isSaber", ItemParse_isSaber, NULL }, {"isSaber2", ItemParse_isSaber2, NULL }, {"leaveFocus", ItemParse_leaveFocus, NULL }, {"maxChars", ItemParse_maxChars, NULL }, {"maxPaintChars", ItemParse_maxPaintChars, NULL }, {"model_angle", ItemParse_model_angle, NULL }, {"model_fovx", ItemParse_model_fovx, NULL }, {"model_fovy", ItemParse_model_fovy, NULL }, {"model_origin", ItemParse_model_origin, NULL }, {"model_rotation", ItemParse_model_rotation, NULL }, {"model_g2mins", ItemParse_model_g2mins, NULL }, {"model_g2maxs", ItemParse_model_g2maxs, NULL }, {"model_g2scale", ItemParse_model_g2scale, NULL }, {"model_g2skin", ItemParse_model_g2skin, NULL }, {"model_g2anim", ItemParse_model_g2anim, NULL }, {"mouseEnter", ItemParse_mouseEnter, NULL }, {"mouseEnterText", ItemParse_mouseEnterText, NULL }, {"mouseExit", ItemParse_mouseExit, NULL }, {"mouseExitText", ItemParse_mouseExitText, NULL }, {"name", ItemParse_name, NULL }, {"notselectable", ItemParse_notselectable, NULL }, {"onFocus", ItemParse_onFocus, NULL }, {"outlinecolor", ItemParse_outlinecolor, NULL }, {"ownerdraw", ItemParse_ownerdraw, NULL }, {"ownerdrawFlag", ItemParse_ownerdrawFlag, NULL }, {"rect", ItemParse_rect, NULL }, {"rectcvar", ItemParse_rectcvar, NULL }, {"showCvar", ItemParse_showCvar, NULL }, {"special", ItemParse_special, NULL }, {"style", ItemParse_style, NULL }, {"text", ItemParse_text, NULL }, {"textalign", ItemParse_textalign, NULL }, {"textalignx", ItemParse_textalignx, NULL }, {"textaligny", ItemParse_textaligny, NULL }, {"textscale", ItemParse_textscale, NULL }, {"textstyle", ItemParse_textstyle, NULL }, {"text2", ItemParse_text2, NULL }, {"text2alignx", ItemParse_text2alignx, NULL }, {"text2aligny", ItemParse_text2aligny, NULL }, {"type", ItemParse_type, NULL }, {"visible", ItemParse_visible, NULL }, {"wrapped", ItemParse_wrapped, NULL }, {"maxLineChars", ItemParse_maxLineChars, NULL }, {"lineHeight", ItemParse_lineHeight, NULL }, {"invertyesno", ItemParse_invertyesno, NULL }, {"scrollhidden", ItemParse_scrollhidden, NULL }, {"xoffset", ItemParse_xoffset, NULL }, //JLF end

{0, 0, 0 } };

I can't see any obvious way to save a variable, or how that would help me performing two cvar tests to show/hide an element :x




Guest

I didn't make it!

0 XP

 
#10 7 years ago

You can use all console commands in menu if I know. It means you can exec a cfg script.

I would try to make a workaround creatig a cfg-file, which checks all the variables for me and save the result to one custom variable.

In the menu item definitions, you check this variable, so you need only one cvarTest.

I will play with it, when I'm at home.

Cheers,

Arth

=========================

EDIT: I have tested few ideas, unfortunately not one solves your problem :( It seems, it's not possible without changing source code.

If JKJA would support "exec vstr " command , there would be a solution, but this does not work, sorry.