Jump to content

Some help with MP UI coding?


Go to solution Solved by eezstreet,

Recommended Posts

So I'm kinda gonna copy and paste this from somewhere else I asked.

 

////

So, I notice some of the functions and workings of things in the UI system are a bit different in MP as compared to SP, where most of my UI code experience comes from. 


My Questions:

1.) In MP, cvarStrList seems not to serve its main function that I use it for. Looking through mb2 and base, I notice hardly any of the MP menus use it, always using cvarFloatList instead. 

The main thing I use cvarStrList for is loading sets of commands into a custom cvar I make. Like say I have:

(rough sketch here of UI code, this isn't actual proper code)

type ITEM_TYPE_MULTI
cvar ui_weaponchoice
cvarStrList
{
"E-11 Blaster Rifle" "set ui_weapondescription @HELP_E11"
"DL-44 Blaster Pistol" "set ui_weapondescription @HELP_PISTOL"
}
action
{
exec "vstr ui_weaponchoice"
}
 

 



This all works in SP. But in MP the menu item/button with this code won't respond correctly. The problem with cvarFloatList is it can only input numbers/floats into a cvar, it can't put in a string of commands like above. CvarStrList works fine if I use it the same way I could a FloatList, but that defeats the purpose.



2.) Autowrapping text in ITEM_TYPE_EDITFIELD.

Is this possible? Can I have an EDITFIELD item type scroll to the next line when the user inputs enough text? All my experiments with this are buggy. Hard to tell anything.



3.) Autowrapping text and using a cvar to determine text in an ITEM_TYPE_TEXTSCROLL.

Does the autowrapped feature work in MP for textscrolls? When I used it the way I did in SP it doesn't seem to do anything. The only tools I have are maxlinechars or whatever it's called.

Also, in SP, I can have a TEXTSCROLL decide which text to show based on a cvar. For example:

 

itemDef
{
name gametiptext
group none
style WINDOW_STYLE_EMPTY
type ITEM_TYPE_TEXTSCROLL
rect 35 365 520 200
cvar gameplaytip
font 4
forecolor 1 1 1 1
textscale 1
textalign ITEM_ALIGN_LEFT
textalignx 0
textaligny 6
lineHeight 20
visible 1
autowrapped
}

 

 

 


^Using that setup crashes the game though. Is there any other way to use a cvar on a single menu item to determine what text it displays in MP?

 

 

////

EDIT: Just cause I think they might be able to help me, @@eezstreet and @@therfiles

Link to comment

1. You really shouldn't do it like that, a number field is much better to use because less overhead and also you don't have to worry about different languages screwing the string up.

 

2. Editfields weren't meant to be scrolled. The only elements that are natively scrollable are feeders. Use some ownerdraw code for scrollable stuff like that. "autowrapped" keyword will work though, but scrolling will be buggy without further code.

 

3. Autowrapped/textscroll are compatible with each other, see Siege class selection menu for a really good example (weapon descriptions). Though I think the actual text inside them are ownerdraw (unsure)

Link to comment

1. You really shouldn't do it like that, a number field is much better to use because less overhead and also you don't have to worry about different languages screwing the string up.

 

Well I'm not worried about languages right now but I don't see how that would be affected. The thing is though that's one of my techniques, using cvarStrList to load sets of commands into cvars. I can work around it, but it's beat if I can never use that ever in MP...

 

I mean MP recognizes cvarStrList as a valid command. The problem is I don't know how or even if I can use it for sets of commands. The problem is I think MP can't read values in quotes like SP.

 

 

 

It can read this correctly:

cvarStrList

{

"text1"   1

}

 

But not this:

cvarStrList

{

"text1"   "command1; command2; command3"

}

 

 

 

2. Editfields weren't meant to be scrolled. The only elements that are natively scrollable are feeders. Use some ownerdraw code for scrollable stuff like that. "autowrapped" keyword will work though, but scrolling will be buggy without further code.

 

Fair enough.

 

3. Autowrapped/textscroll are compatible with each other, see Siege class selection menu for a really good example (weapon descriptions). Though I think the actual text inside them are ownerdraw (unsure) 

 

Alright, will do, thanks for the tip! I just want to make this clear though, with the exception of the EDITFIELD stuff, everything I've mentioned is possible in SP as I've done it, I'm not just blowing smoke  ;).

 

So, in SP I can have a textscroll item determine it's displayed text via a cvar, but in MP it crashes out right (the game won't even load with that in a menu somewhere). Basically, you take out the "text" field in the menu item and just put in a single "cvar mycvar" field. And then if the value of mycvar is say @SOMETHING the text it shows will be @SOMETHING.

 

MP won't work with that method at least, but is there any provision in the code for getting it to read from a cvar somehow, that's maybe set up differently from SP? If I have to maybe I'll have to do some ownerdraw coding stuff but that's out of my area of expertise.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...