Example #1
0
void Script_ExecWolfConfig(itemDef_t *item, qboolean *bAbort, char **args)
{
	int useprofile = 1;

	if (Int_Parse(args, &useprofile))
	{
		char cl_profileStr[256];

		DC->getCVarString("cl_profile", cl_profileStr, sizeof(cl_profileStr));

		if (useprofile && cl_profileStr[0])
		{
			if (!Script_CheckProfile(va("profiles/%s/profile.pid", cl_profileStr)))
			{
#ifndef LEGACY_DEBUG
				Com_Printf("^3WARNING: profile.pid found for profile '%s' - not executing %s\n", cl_profileStr, CONFIG_NAME);
#else
				DC->executeText(EXEC_NOW, va("exec profiles/%s/%s\n", cl_profileStr, CONFIG_NAME));
#endif
			}
			else
			{
				DC->executeText(EXEC_NOW, va("exec profiles/%s/%s\n", cl_profileStr, CONFIG_NAME));

				if (!Script_WriteProfile(va("profiles/%s/profile.pid", cl_profileStr)))
				{
					Com_Printf("^3WARNING: couldn't write profiles/%s/profile.pid\n", cl_profileStr);
				}
			}
		}
	}
}
Example #2
0
void PartyMngt_Script_DialogButton(char **args) {
	int button;
	if (!Int_Parse(args, &button)) {
		return;
	}
	if (button < PDLGRESP_OK || button > PDLGRESP_CANCEL) {
		// Invalid button
		return;
	}
	if (PDlgData.InUse) {
		if (PDlgData.type == PDLG_TEXT) {
			menuDef_t *menu;
			itemDef_t *item;
			menu = Menus_FindByName("jkg_partymanagement");
			if (menu) {
				item = Menu_FindItemByName(menu, "dlg_textentry");
				if (item) {
					(*PDlgData.callback)(button, item->typeData.edit->buffer);
					return;
				}
			}
			(*PDlgData.callback)(button, "");
		} else {
			(*PDlgData.callback)(button, NULL);
		}
	}
}
Example #3
0
void Script_Transition(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *name = NULL;

	if (String_Parse(args, &name))
	{
		rectDef_t rectFrom, rectTo;
		float     amt  = 0.0f;
		int       time = 0;

		if (Rect_Parse(args, &rectFrom) && Rect_Parse(args, &rectTo) && Int_Parse(args, &time) && Float_Parse(args, &amt))
		{
			Menu_TransitionItemByName(item->parent, name, rectFrom, rectTo, time, amt);
		}
	}
}
void JKG_Slice_Script_DialogButton(char **args) {
	int button;
	if (!Int_Parse(args, &button)) {
		return;
	}
	if (button < 0 || button > 1) {
		// Invalid button
		return;
	}
	if (sliceData.dlgActive) {
		if (sliceData.dlgid == DLGID_SERVER) {
			cgImports->SendClientCommand(va("~slc dlgresp %i", button));
		} else if (sliceData.dlgid == DLGID_STOPSLICING && button == 1) {
			cgImports->SendClientCommand("~slc stop");
		}
	}
	JKG_Slice_Dialog_Close();
}
Example #5
0
void Script_ConditionalOpen(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *cvar  = NULL;
	const char *name1 = NULL;
	const char *name2 = NULL;
	int        testtype;  // 0: check val not 0
	// 1: check cvar not empty

	if (String_Parse(args, &cvar) && Int_Parse(args, &testtype) && String_Parse(args, &name1) && String_Parse(args, &name2))
	{
		float val;

		switch (testtype)
		{
		default:
		case 0:
			val = DC->getCVarValue(cvar);
			if (val == 0.f)
			{
				Menus_OpenByName(name2);
			}
			else
			{
				Menus_OpenByName(name1);
			}
			break;
		case 1:
		{
			char buff[1024];

			DC->getCVarString(cvar, buff, sizeof(buff));
			if (!buff[0])
			{
				Menus_OpenByName(name2);
			}
			else
			{
				Menus_OpenByName(name1);
			}
		}
		break;
		}
	}
}
Example #6
0
void PartyMngt_Script_Button(char **args) {
	int button;
	uiClientState_t	cs;

	if (!Int_Parse(args, &button)) {
		return;
	}
	trap->GetClientState( &cs );
	switch (button) {
		case PBTN_STARTPARTY:
			if (PMngtData.inParty) {
				return;
			}
			PMngtData.dlgid = PDLGID_NEWPARTY;
			PartyMngt_Dialog_Show("Do you want to create a new party?", NULL, NULL, PDLG_YESNO, PartyMngt_Dlg_Response);
			break;
		case PBTN_ACCEPTINVITE:
			if (PMngtData.inParty) {
				return;
			}
			// Check if we got a valid slot selected
			if (PMngtData.partySelection < 0 || PMngtData.partySelection >= PMngtData.partyListEntries) {
				return;
			}
			PMngtData.dlgid = PDLGID_ACCEPTINVITE;
			PartyMngt_Dialog_Show(va("Do you want to join ^7%s^7's team?", PMngtData.Data.Invites[PMngtData.partySelection].leaderName), NULL, NULL, PDLG_YESNO, PartyMngt_Dlg_Response);
			break;
		case PBTN_REJECTINVITE:
			if (PMngtData.inParty) {
				return;
			}
			if (PMngtData.partySelection < 0 || PMngtData.partySelection >= PMngtData.partyListEntries) {
				return;
			}
			PMngtData.dlgid = PDLGID_REJECTINVITE;
			PartyMngt_Dialog_Show("Are you sure you want to reject this invitation?", NULL, NULL, PDLG_YESNO, PartyMngt_Dlg_Response);
			break;
		case PBTN_LEAVEPARTY:
			if (!PMngtData.inParty) {
				return;
			}
			PMngtData.dlgid = PDLGID_LEAVEPARTY;
			PartyMngt_Dialog_Show("You cannot return unless you get re-invited.", "Are you sure you want to leave the party?", NULL, PDLG_YESNO, PartyMngt_Dlg_Response);
			break;
		case PBTN_DISBANDPARTY:
			if (!PMngtData.inParty || !PMngtData.partyLead) {
				return;
			}
			PMngtData.dlgid = PDLGID_DISBANDPARTY;
			PartyMngt_Dialog_Show("Are you sure you want to disband your party?", NULL, NULL, PDLG_YESNO, PartyMngt_Dlg_Response);
			break;
		case PBTN_MAKELEADER:
			if (!PMngtData.inParty || !PMngtData.partyLead) {
				return;
			}
			// Check if we got a valid slot selected
			if (PMngtData.partySelection < 0 || PMngtData.partySelection >= PMngtData.partyListEntries) {
				return;
			}
			if (PMngtData.Data.PartyMembers[PMngtData.partySelection].id == cs.clientNum) {
				PMngtData.dlgid = PDLGID_ANY;
				PartyMngt_Dialog_Show("You are already this party's leader.", NULL, NULL, PDLG_OK, PartyMngt_Dlg_Response);
			} else {
				PMngtData.dlgid = PDLGID_MAKELEADER;
				PartyMngt_Dialog_Show("If you make someone else the party leader", "you will give up your own leader position.", "Are you sure you want to do this?", PDLG_YESNO, PartyMngt_Dlg_Response);
			}
			break;
		case PBTN_DISMISSMEMBER:
			if (!PMngtData.inParty || !PMngtData.partyLead) {
				return;
			}
			// Check if we got a valid slot selected
			if (PMngtData.partySelection < 0 || PMngtData.partySelection >= PMngtData.partyListEntries) {
				return;
			}
			if (PMngtData.Data.PartyMembers[PMngtData.partySelection].id == cs.clientNum) {
				PMngtData.dlgid = PDLGID_ANY;
				PartyMngt_Dialog_Show("You can't dismiss yourself.", NULL, NULL, PDLG_OK, PartyMngt_Dlg_Response);
			} else {
				PMngtData.dlgid = PDLGID_DISMISSMEMBER;
				PartyMngt_Dialog_Show(va("Are you sure you want to dismiss ^7%s^7?", PMngtData.Data.PartyMembers[PMngtData.partySelection].playerName), NULL, NULL, PDLG_YESNO, PartyMngt_Dlg_Response);
			}
			break;
		case PBTN_ADDTOLIST:
			if (PMngtData.inParty || PMngtData.amSeeker) {
				return;
			}
			PMngtData.dlgid = PDLGID_ADDTOLIST;
			PartyMngt_Dialog_Show("To get on the 'seeking a party' list, please", "type a message to show on the list.", NULL, PDLG_TEXT, PartyMngt_Dlg_Response);
			break;
		case PBTN_REMOVEFROMLIST:
			if (PMngtData.inParty || !PMngtData.amSeeker) {
				return;
			}
			PMngtData.dlgid = PDLGID_REMOVEFROMLIST;
			PartyMngt_Dialog_Show("Are you sure you want to remove yourself from the list?", NULL, NULL, PDLG_YESNO, PartyMngt_Dlg_Response);
			break;
		case PBTN_INVITE:
			if (!PMngtData.inParty || !PMngtData.partyLead) {
				return;
			}
			if (PMngtData.seekerSelection < 0 || PMngtData.seekerSelection >= PMngtData.partySeekers) {
				return;
			}
			PMngtData.dlgid = PDLGID_INVITE;
			PartyMngt_Dialog_Show(va("Do you want want to invite ^7%s^7?", PMngtData.partySeeker[PMngtData.seekerSelection].playerName), NULL, NULL, PDLG_YESNO, PartyMngt_Dlg_Response);
			break;
		default:
			break;
	}
}
Example #7
0
void Script_Orbit(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *name = NULL;

	if (String_Parse(args, &name))
	{
		float cx   = 0.0f, cy = 0.0f, x = 0.0f, y = 0.0f;
		int   time = 0;

		if (Float_Parse(args, &x) && Float_Parse(args, &y) && Float_Parse(args, &cx) && Float_Parse(args, &cy) && Int_Parse(args, &time))
		{
			Menu_OrbitItemByName(item->parent, name, x, y, cx, cy, time);
		}
	}
}
Example #8
0
void Script_ConditionalScript(itemDef_t *item, qboolean *bAbort, char **args)
{
	const char *cvar;
	const char *script1;
	const char *script2;
	const char *token;
	int        testtype;  // 0: check val not 0
	// 1: check cvar not empty
	int testval;

	if (String_Parse(args, &cvar) &&
	    Int_Parse(args, &testtype) &&
	    String_Parse(args, &token) && (token && *token == '(') &&
	    String_Parse(args, &script1) &&
	    String_Parse(args, &token) && (token && *token == ')') &&
	    String_Parse(args, &token) && (token && *token == '(') &&
	    String_Parse(args, &script2) &&
	    String_Parse(args, &token) && (token && *token == ')'))
	{
		float val;

		switch (testtype)
		{
		default:
		case 0:
			val = DC->getCVarValue(cvar);
			if (val == 0.f)
			{
				Item_RunScript(item, bAbort, script2);
			}
			else
			{
				Item_RunScript(item, bAbort, script1);
			}
			break;
		case 1:
		{
			char buff[1024];

			DC->getCVarString(cvar, buff, sizeof(buff));
			if (!buff[0])
			{
				Item_RunScript(item, bAbort, script2);
			}
			else
			{
				Item_RunScript(item, bAbort, script1);
			}
		}
		break;
		case 3:
			if (Int_Parse(args, &testval))
			{
				int testVal;

				val     = DC->getCVarValue(cvar);
				testVal = (int)val;
				if (testVal != testval)
				{
					Item_RunScript(item, bAbort, script2);
				}
				else
				{
					Item_RunScript(item, bAbort, script1);
				}
			}
			break;
		case 2:
			// special tests
			if (!Q_stricmp(cvar, "UIProfileIsActiveProfile"))
			{
				char ui_profileStr[256];
				char cl_profileStr[256];

				DC->getCVarString("ui_profile", ui_profileStr, sizeof(ui_profileStr));
				Q_CleanStr(ui_profileStr);
				Q_CleanDirName(ui_profileStr);

				DC->getCVarString("cl_profile", cl_profileStr, sizeof(cl_profileStr));

				if (!Q_stricmp(ui_profileStr, cl_profileStr))
				{
					Item_RunScript(item, bAbort, script1);
				}
				else
				{
					Item_RunScript(item, bAbort, script2);
				}
			}
			else if (!Q_stricmp(cvar, "UIProfileValidName"))
			{
				char ui_profileStr[256];
				char ui_profileCleanedStr[256];

				DC->getCVarString("ui_profile", ui_profileStr, sizeof(ui_profileStr));
				Q_strncpyz(ui_profileCleanedStr, ui_profileStr, sizeof(ui_profileCleanedStr));
				Q_CleanStr(ui_profileCleanedStr);
				Q_CleanDirName(ui_profileCleanedStr);

				if (*ui_profileStr && *ui_profileCleanedStr)
				{
					Item_RunScript(item, bAbort, script1);
				}
				else
				{
					Item_RunScript(item, bAbort, script2);
				}

			}
			else if (!Q_stricmp(cvar, "UIProfileAlreadyExists"))
			{
				char         ui_profileCleanedStr[256];
				qboolean     alreadyExists = qfalse;
				fileHandle_t f;

				DC->getCVarString("ui_profile", ui_profileCleanedStr, sizeof(ui_profileCleanedStr));
				Q_CleanStr(ui_profileCleanedStr);
				Q_CleanDirName(ui_profileCleanedStr);

				if (trap_FS_FOpenFile(va("profiles/%s/profile.dat", ui_profileCleanedStr), &f, FS_READ) >= 0)
				{
					alreadyExists = qtrue;
					trap_FS_FCloseFile(f);
				}

				if (alreadyExists)
				{
					Item_RunScript(item, bAbort, script1);
				}
				else
				{
					Item_RunScript(item, bAbort, script2);
				}
			}
			else if (!Q_stricmp(cvar, "UIProfileAlreadyExists_Rename"))
			{
				char         ui_profileCleanedStr[256];
				qboolean     alreadyExists = qfalse;
				fileHandle_t f;

				DC->getCVarString("ui_profile_renameto", ui_profileCleanedStr, sizeof(ui_profileCleanedStr));
				Q_CleanStr(ui_profileCleanedStr);
				Q_CleanDirName(ui_profileCleanedStr);

				if (trap_FS_FOpenFile(va("profiles/%s/profile.dat", ui_profileCleanedStr), &f, FS_READ) >= 0)
				{
					alreadyExists = qtrue;
					trap_FS_FCloseFile(f);
				}

				if (alreadyExists)
				{
					Item_RunScript(item, bAbort, script1);
				}
				else
				{
					Item_RunScript(item, bAbort, script2);
				}
			}
			else if (!Q_stricmp(cvar, "ReadyToCreateProfile"))
			{
				char         ui_profileStr[256], ui_profileCleanedStr[256];
				int          ui_rate;
				qboolean     alreadyExists = qfalse;
				fileHandle_t f;

				DC->getCVarString("ui_profile", ui_profileStr, sizeof(ui_profileStr));

				Q_strncpyz(ui_profileCleanedStr, ui_profileStr, sizeof(ui_profileCleanedStr));
				Q_CleanStr(ui_profileCleanedStr);
				Q_CleanDirName(ui_profileCleanedStr);

				if (trap_FS_FOpenFile(va("profiles/%s/profile.dat", ui_profileCleanedStr), &f, FS_READ) >= 0)
				{
					alreadyExists = qtrue;
					trap_FS_FCloseFile(f);
				}

				ui_rate = (int)DC->getCVarValue("ui_rate");

				if (!alreadyExists && *ui_profileStr && ui_rate > 0)
				{
					Item_RunScript(item, bAbort, script1);
				}
				else
				{
					Item_RunScript(item, bAbort, script2);
				}
			}
			else if (!Q_stricmp(cvar, "vidrestartIsRequired"))
			{
				int  ui_r_mode                           = DC->getCVarValue("ui_r_mode");
				int  ui_r_colorbits                      = DC->getCVarValue("ui_r_colorbits");
				int  ui_r_fullscreen                     = DC->getCVarValue("ui_r_fullscreen");
				int  ui_r_noborder                       = DC->getCVarValue("ui_r_noborder");
				int  ui_r_texturebits                    = DC->getCVarValue("ui_r_texturebits");
				int  ui_r_depthbits                      = DC->getCVarValue("ui_r_depthbits");
				int  ui_r_ext_compressed_textures        = DC->getCVarValue("ui_r_ext_compressed_textures");
				int  ui_r_allowextensions                = DC->getCVarValue("ui_r_allowextensions");
				int  ui_s_khz                            = DC->getCVarValue("ui_s_khz");
				int  ui_r_detailtextures                 = DC->getCVarValue("ui_r_detailtextures");
				int  ui_r_subdivisions                   = DC->getCVarValue("ui_r_subdivisions");
				int  ui_r_ext_texture_filter_anisotropic = DC->getCVarValue("ui_r_ext_texture_filter_anisotropic");
				int  ui_cg_shadows                       = DC->getCVarValue("ui_cg_shadows");
				char ui_r_texturemode[MAX_CVAR_VALUE_STRING];

				int  r_mode                           = DC->getCVarValue("r_mode");
				int  r_colorbits                      = DC->getCVarValue("r_colorbits");
				int  r_fullscreen                     = DC->getCVarValue("r_fullscreen");
				int  r_noborder                       = DC->getCVarValue("r_noborder");
				int  r_texturebits                    = DC->getCVarValue("r_texturebits");
				int  r_depthbits                      = DC->getCVarValue("r_depthbits");
				int  r_ext_compressed_textures        = DC->getCVarValue("r_ext_compressed_textures");
				int  r_allowextensions                = DC->getCVarValue("r_allowextensions");
				int  s_khz                            = DC->getCVarValue("s_khz");
				int  r_detailtextures                 = DC->getCVarValue("r_detailtextures");
				int  r_subdivisions                   = DC->getCVarValue("r_subdivisions");
				int  r_ext_texture_filter_anisotropic = DC->getCVarValue("r_ext_texture_filter_anisotropic");
				int  cg_shadows                       = DC->getCVarValue("cg_shadows");
				char r_texturemode[MAX_CVAR_VALUE_STRING];

				trap_Cvar_VariableStringBuffer("ui_r_texturemode", ui_r_texturemode, sizeof(ui_r_texturemode));
				trap_Cvar_VariableStringBuffer("r_texturemode", r_texturemode, sizeof(r_texturemode));

				if (ui_r_subdivisions != r_subdivisions ||
				    ui_r_mode != r_mode ||
				    ui_r_colorbits != r_colorbits ||
				    ui_r_fullscreen != r_fullscreen ||
				    ui_r_noborder != r_noborder ||
				    ui_r_texturebits != r_texturebits ||
				    ui_r_depthbits != r_depthbits ||
				    ui_r_ext_compressed_textures != r_ext_compressed_textures ||
				    ui_r_allowextensions != r_allowextensions ||
				    ui_s_khz != s_khz ||
				    ui_r_detailtextures != r_detailtextures ||
				    ui_r_ext_texture_filter_anisotropic != r_ext_texture_filter_anisotropic ||
				    ui_cg_shadows != cg_shadows ||
				    Q_stricmp(r_texturemode, ui_r_texturemode))
				{
					Item_RunScript(item, bAbort, script1);
				}
				else
				{
					Item_RunScript(item, bAbort, script2);
				}
				/*} else if( !Q_stricmpn( cvar, "voteflags", 9 ) ) {
				char info[MAX_INFO_STRING];
				int voteflags = atoi(cvar + 9);

				trap_Cvar_VariableStringBuffer( "cg_ui_voteFlags", info, sizeof(info) );

				if( (atoi(info) & item->voteFlag) != item->voteFlag ) {
				Item_RunScript( item, bAbort, script1 );
				} else {
				Item_RunScript( item, bAbort, script2 );
				}*/
#ifndef CGAMEDLL
			}
			else if (!Q_stricmpn(cvar, "serversort_", 11))
			{
				int sorttype = atoi(cvar + 11);

				if (sorttype != uiInfo.serverStatus.sortKey)
				{
					Item_RunScript(item, bAbort, script2);
				}
				else
				{
					Item_RunScript(item, bAbort, script1);
				}
			}
			else if (!Q_stricmp(cvar, "ValidReplaySelected"))
			{
				if (uiInfo.demoIndex >= 0 && uiInfo.demoIndex < uiInfo.demoCount)
				{
					Item_RunScript(item, bAbort, script1);
				}
				else
				{
					Item_RunScript(item, bAbort, script2);
				}
#endif // !CGAMEDLL
			}
			else if (!Q_stricmp(cvar, "ROldModeCheck"))
			{
				char r_oldModeStr[256];
				int  r_oldMode;
				int  r_mode = DC->getCVarValue("r_mode");

				DC->getCVarString("r_oldMode", r_oldModeStr, sizeof(r_oldModeStr));
				r_oldMode = atoi(r_oldModeStr);

				if (*r_oldModeStr && r_oldMode != r_mode)
				{
					Item_RunScript(item, bAbort, script1);
				}
				else
				{
					if (r_oldMode == r_mode)
					{
						trap_Cvar_Set("r_oldMode", "");   // clear it
					}

					Item_RunScript(item, bAbort, script2);
				}
			}

			break;
		}
	}
}