Results 1 to 9 of 9

Thread: WINDOW_STYLE_DVAR_SHADER

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts

    WINDOW_STYLE_DVAR_SHADER

    I just discovered this. I didn't know of its existence until I saw it in COD1 (it's not used in COD2 at all, and there isn't any reference to it), so I thought I'd share:

    If you want to show a shader image in a menu file, but you only want to show it on certain conditions, what I have been doing all these years is to put in a dvartest to only show the shader when the condition is right. This lead to quite a few different itemDef assets in the same menu file. By using the WINDOW_STYLE_DVAR_SHADER as the style setting, you only have to have 1 ItemDef and then set the dvar, either in the menu action, or by GSC script. That way you can show an unlimited number of different shaders on different occasions and keep your asset count down.

    This is an example:

    Code:
    		itemDef
    		{
    			name			"soldier_image"
    			visible 		1
    			rect			0 0 270 270
    			origin			ORIGIN_TEAMIMAGE
    	 		style			WINDOW_STYLE_CVAR_SHADER
    			cvar			"ui_nation"
    			forecolor		1 1 1 1
    			backcolor		0 0 0 0.7975
    			decoration
    		}
    So, that is an ItemDef in my teams menu. I set the "ui_nation" dvar according to which team they are on:

    Code:
    	switch( game["allies"] )
    	{
    		case "american":
    			self setClientCvar( "ui_nation", "ui_mp/assets/hud@team_flags_americangerman.dds" );
    			break;
    		
    		case "british":
    			self setClientCvar( "ui_nation", "ui_mp/assets/hud@team_flags_britishgerman.dds" );
    			break;
    
    		case "russian":
    			self setClientCvar( "ui_nation", "ui_mp/assets/hud@team_flags_russiangerman.dds" );
    			break;
    	}
    NOTE - the dvar contains the full path to the file. The example above is from COD1, and so obviously as that game didn't use materials files, the path leads to the raw shader file.

    Special Note for COD2 - If you want to keep switching the shader shown, to make the ItemDef "blank", you have to set the dvar to nothing. In COD1, that's fine - if it doesn't find a shader, it wont kick off. With COD2 however, you get the checkerboard missing image shader. So, create a blank/empty IWI file and materials, and call that to "blank" it out:

    Code:
    self setClientCvar( "ui_nation", "empty" );
    Where "empty" is a 12 x 12 shader with a white alpha channel but nothing on its face (it is effectively "blank" or "empty").
    Last edited by Tally; 29th October 2014 at 10:29.

  2. The Following 2 Users Say Thank You to Tally For This Useful Post:

    filthy_freak_ (30th October 2014),kung foo man (29th October 2014)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •