Silent Creating Custom Menu

From MyGamingTalk
Revision as of 19:07, 14 September 2015 by Gaoesa (talk | contribs) (→‎Example)

Customized Voice Chat Menus

Starting from silEnT 0.9.0, the following files have changed their name:

wm_quickmessage.menu => wm_quickmessage_silEnT.menu
wm_quickmessageAlt.menu => wm_quickmessageAlt_silEnT.menu
wm_ftquickmessageAlt.menu => wm_ftquickmessageAlt_silEnT.menu
wm_ftquickmessage.menu => wm_ftquickmessage_silEnT.menu

If you are using customized voice chats, please make sure the menu files are named as such. No other changes are required when converting between the versions.

Customized Server Menus

Starting from silEnT 0.9.0, server admins have the option to have a second, server customized menu. This is opposed to editing the official menus.

The second menu is always opened automatically if present when player opens the menus by pressing ESC. If the user clicks either menu, the official or the server custom menu, the other menu automatically closes. The server custom menus have the same commands as the official menus, with the exception that onOpen event can not be defined. If onOpen is defined, it is ignored.

Following is an example of a server custom menu:

Example

Customized server menu has one requirement, there must be a file called menus_server_custom.txt. This file is used exactly like the old menus.txt. It defines the .menu files that are loaded for the custom menu. An example:

// menu defs
// 
{
	loadMenu { "ui/custom_main.menu" }
	loadMenu { "ui/rules.menu" }
}

The custom_main.menu defined in the menus_server_custom.txt in this example, could look like this:

#include "ui/menudef.h"

// Defines //

#define WINDOW_X		16
#define WINDOW_Y		232
#define WINDOW_WIDTH	160
#define WINDOW_HEIGHT	60

#define GROUP_NAME		"grpCustomMain"

// Macros //

#include "ui/menumacros.h"

// Main Menu //

menuDef {
	name		"custom_main"
	visible		0
	fullscreen	0
	rect		WINDOW_X WINDOW_Y WINDOW_WIDTH WINDOW_HEIGHT
	style		0
	
	onEsc {
		close custom_main ;
	}

// Window //

	WINDOW( "^7Example", 232 )
	
// Buttons //

	BUTTON( 6, 32, WINDOW_WIDTH-12, 18, "^7Rules", .3, 14, close custom_main ; open rules )
}

And finally, the rules.menu could look something like this:

#include "ui/menudef.h"

// Defines //

#define WINDOW_X		100
#define WINDOW_Y		16
#define WINDOW_WIDTH	128
#define WINDOW_HEIGHT	152
#define GROUP_NAME		"grpRules"

// Macros //

#include "ui/menumacros.h"
		
// Options Menu //
	
menuDef {
	name		"rules"
	visible		0
	fullscreen	0
	rect		WINDOW_X WINDOW_Y WINDOW_WIDTH WINDOW_HEIGHT
	style		WINDOW_STYLE_FILLED
	
	onESC {
		close rules;
		open custom_main
	}

// Window //

	WINDOW( "RULES", 94 )
	
	... Stuff for players to read in menu controls ...
}

Note that the menu is not complete. You can delete the "... Stuff for players to read in menu controls ..." or insert some controls that work in its place.

The resulting files need to be packed into a zip file that is renamed to pk3 so that all the menu files and the "menus_server_custom.txt" are in and under ui directory.

Properties

  • When user opens the menus, both the official menu and the server customized menu are opened. The menus are opened in a way that the official menu is always on top in case the two menus overlap.
  • If user clicks a button in either menu, the other menu is automatically closed by the mod. This also includes the case when user presses ESC to close the menus.
  • The onOpen event is ignored in the custom menus.
  • Menu files in the etmain directory or the official menus can not be modified and the server refuses to start if it detects such modifications.
  • Old way of customizing the menus still work if the user already has the menus or he manually adds the menus. The restriction is that the server can not reference pk3 files that modify the menus.
  • Menus for the customized voice chats are excluded from the checks.