Custom Sound Pack Question


(RaneR) #1

Hi All, I have a custom sound pack I made that works fine. The problem is that the sound pack is to big. So what I want to do is make a sound pak bound to the keyboard key “M”.
All I need help with is the UI menu script . How should it read to so the “M” key will activate the menu for the sound pack. Below is the begining of the sound pack ui script that is working :

#include "ui/menudef.h"

#define DEFAULT_TEXT_SCALE 0.25

#define ORIGIN_QUICKMESSAGE		10 10

#define QM_MENU_GRADIENT_START_OFFSET

#define QM_MENU_START( WINDOWNAME )																			\
																											\

menuDef {
name WINDOWNAME
visible 0
fullscreen 0
rect 0 100 640 380
onOpen { setCvar cl_bypassMouseInput “1” }
onClose { setCvar cl_bypassMouseInput “0” }
onEsc { closeAll }

itemDef {
name “window”
rect 0 19 204 136
origin ORIGIN_QUICKMESSAGE
style WINDOW_STYLE_FILLED
backcolor 0 0 0 .75
border WINDOW_BORDER_FULL
bordercolor .5 .5 .5 .5
visible 1
decoration
}

itemDef {
name “windowtitle”
rect $evalfloat((0)+2) $evalfloat((19)+2) $evalfloat((204)-4) 12
origin ORIGIN_QUICKMESSAGE
text “MESSAGE”
textfont UI_FONT_ARIBLK_16
textscale .19
textalignx 3
textaligny 10
style WINDOW_STYLE_FILLED
backcolor .16 .2 .17 .8
forecolor .6 .6 .6 1
visible 1
decoration
}

#define QM_MENU_END }

#define QM_MENU_ITEM( WINDOWTEXT, ACTION, KEY, POS )				\
itemDef {															\
	name			"menuitem"##WINDOWTEXT							\
	rect			6 $evalfloat( 35 + ( 12 * POS )) 128 10			\
	origin			ORIGIN_QUICKMESSAGE								\
	type			ITEM_TYPE_TEXT									\
	text			WINDOWTEXT										\
	textfont		UI_FONT_COURBD_21								\
	textstyle		ITEM_TEXTSTYLE_SHADOWED							\
	textscale		.2												\
	textaligny		8												\
	forecolor		.6 .6 .6 1										\
	visible			1												\
	decoration														\
}																	\
execKey KEY { ACTION }

#define QM_MENU_ITEM_TEAM( WINDOWTEXT, ACTION, KEY, POS )			\
itemDef {															\
	name			"menuitem"##WINDOWTEXT							\
	rect			6 $evalfloat( 35 + ( 12 * POS )) 128 10			\
	origin			ORIGIN_QUICKMESSAGE								\
	type			ITEM_TYPE_TEXT									\
	text			WINDOWTEXT										\
	textfont		UI_FONT_COURBD_21								\
	textstyle		ITEM_TEXTSTYLE_SHADOWED							\
	textscale		.2												\
	textaligny		8												\
	forecolor		.6 .6 .6 1										\
	visible			1												\
	decoration														\
}																	\

Where should the edit be on the above script for “M” to execute the sound pack menu. Thanks


(Indloon) #2
onEsc	 { closeAll }

?

onM { open menu } 

?


(Indloon) #3
onM { open menu } 

?

 execKey M 

?
Well I personally think that you arent able to make these kind script(s).
You must click somewhere:P
Maybe use the watermark for opening the sound menu?


(RaneR) #4

Thanks Genert, is that it,everything else stays the way it is?
onEsc { closeAll } that does not need changing, Reads the same as above.
onM { open menu } were do I insert this.
thanks again for the comeback.


(phisherman) #5

[QUOTE=RaneR;373325]onM { open menu } were do I insert this.[/QUOTE]This will not work. There’s only two hooks of this type and that’s onEsc and onEnter. I.e. there’s no way you can define a button to open a menu. Do as everybody does: Add your custom soundpack menu as submenu of wm_quickmessage(Alt).menu.


(Indloon) #6

Actually,you can do so,but with touching SDK.
In ui_shared.c.You should add


on 6500 somewhere
      	{ "onM",				ItemParse_onM,			NULL },
somewhere 3580~
        case THECODEOFMBUTTON:
somewhere 7000
        {"onM", MenuParse_onM, NULL},
somewhere 6700
        qboolean MenuParse_onM( itemDef_t *item, int handle ) {
	menuDef_t *menu = (menuDef_t*)item;
	if (!PC_Script_Parse(handle, &menu->onM)) {
		return qfalse;
	}
	return qtrue;
}
6000
      qboolean ItemParse_onM( itemDef_t *item, int handle ) {
	if( !PC_Script_Parse( handle, &item->onM ) ) {
		return qfalse;
	}
	return qtrue;
}
3100...
	if( realKey ==  THECODEOFMBUTTON && item->onM ) {
		Item_RunScript( item, NULL, item->onM );
		return qtrue;
	}
ui_shared.h
const char *onM;				

And


onM { open menu }

Basiclly it should work:d
But this gave me idea how the developer can manipulate with keys then.
Should make function.
So the developer can use.


ONKEY==K_MOUSE1 { open menu }


(RaneR) #7

Hello Indloon thanks for the help…you posted this
In ui_shared.c.You should add
on 6500 somewhere
{ “onM”, ItemParse_onM, NULL },
somewhere 3580~
case THECODEOFMBUTTON:
somewhere 7000
{“onM”, MenuParse_onM, NULL},
somewhere 6700
qboolean MenuParse_onM( itemDef_t *item, int handle ) {
menuDef_t menu = (menuDef_t)item;
if (!PC_Script_Parse(handle, &menu->onM)) {
return qfalse;
}
return qtrue;
}
6000
qboolean ItemParse_onM( itemDef_t *item, int handle ) {
if( !PC_Script_Parse( handle, &item->onM ) ) {
return qfalse;
}
return qtrue;
}
3100…
if( realKey == THECODEOFMBUTTON && item->onM ) {
Item_RunScript( item, NULL, item->onM );
return qtrue;
}
ui_shared.h
const char *onM;

Then to add this…
onM { open menu }

Where do I add …onM { open menu }
Sorry for not posting sooner but I got the sound pack in server and forgot to come back to this post
but I want to save this information for future use…Thanks again for the help Guys…