示例#1
0
文件: maplist.c 项目: Bader14/Nexuiz
void NexuizMapList_g_maplistCacheToggle(entity me, float i)
{
	string a, b, c, s, bspname;
	float n;
	s = me.g_maplistCache;
	if not(s)
		return;
	b = substring(s, i, 1);
	if(b == "0")
		b = "1";
	else if(b == "1")
		b = "0";
	else
		return; // nothing happens
	a = substring(s, 0, i);
	c = substring(s, i+1, strlen(s) - (i+1));
	strunzone(s);
	me.g_maplistCache = strzone(strcat(a, b, c));
	// TODO also update the actual cvar
	if not((bspname = MapInfo_BSPName_ByID(i)))
		return;
	if(b == "1")
		cvar_set("g_maplist", strcat(bspname, " ", cvar_string("g_maplist")));
	else
	{
		s = "";
		n = tokenize_console(cvar_string("g_maplist"));
		for(i = 0; i < n; ++i)
			if(argv(i) != bspname)
				s = strcat(s, " ", argv(i));
		cvar_set("g_maplist", substring(s, 1, strlen(s) - 1));
	}
}
示例#2
0
void NexuizColorpickerString_configureNexuizColorpickerString(entity me, string theCvar, string theDefaultCvar)
{
	me.cvarName = theCvar;
	me.configureImage(me, me.image);
	if(cvar_string(theCvar) != "")
		me.prevcoords = color_hslimage(stov(cvar_string(theCvar)), me.imagemargin);
	else // use default
		me.prevcoords = color_hslimage(stov(cvar_string(theDefaultCvar)), me.imagemargin);
}
示例#3
0
void loadCvarsNexuizTextSlider(entity me)
{
	if not(me.cvarName)
		return;

	var float n = tokenize_console(me.cvarName);
	var string s = cvar_string(argv(0));
	float i;
	for(i = 1; i < n; ++i)
		s = strcat(s, " ", cvar_string(argv(i)));
	me.setValueFromIdentifier(me, s);
}
void ToggleFavorite(string srv)
{
	string s, s0, s1, s2, srv_resolved, p;
	float i, n, f;
	srv_resolved = netaddress_resolve(srv, 26000);
	p = crypto_getidfp(srv_resolved);
	s = cvar_string("net_slist_favorites");
	n = tokenize_console(s);
	f = 0;
	for(i = 0; i < n; ++i)
	{
		if(substring(argv(i), 0, 1) != "[" && strlen(argv(i)) == 44 && strstrofs(argv(i), ".", 0) < 0)
		{
			if(p)
				if(argv(i) != p)
					continue;
		}
		else
		{
			if(srv_resolved != netaddress_resolve(argv(i), 26000))
				continue;
		}
		s0 = s1 = s2 = "";
		if(i > 0)
			s0 = substring(s, 0, argv_end_index(i - 1));
		if(i < n-1)
			s2 = substring(s, argv_start_index(i + 1), -1);
		if(s0 != "" && s2 != "")
			s1 = " ";
		cvar_set("net_slist_favorites", strcat(s0, s1, s2));
		s = cvar_string("net_slist_favorites");
		n = tokenize_console(s);
		f = 1;
		--i;
	}
	
	if(!f)
	{
		s1 = "";
		if(s != "")
			s1 = " ";
		if(p)
			cvar_set("net_slist_favorites", strcat(s, s1, p));
		else
			cvar_set("net_slist_favorites", strcat(s, s1, srv));
	}

	resorthostcache();
}
示例#5
0
文件: maplist.c 项目: Bader14/Nexuiz
void NexuizMapList_refilter(entity me)
{
	float i, j, n;
	string s;
	float gt, f;
	gt = MapInfo_CurrentGametype();
	f = MapInfo_CurrentFeatures();
	MapInfo_FilterGametype(gt, f, MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
	me.nItems = MapInfo_count;
	for(i = 0; i < MapInfo_count; ++i)
		draw_PreloadPicture(strcat("/maps/", MapInfo_BSPName_ByID(i)));
	if(me.g_maplistCache)
		strunzone(me.g_maplistCache);
	s = "0";
	for(i = 1; i < MapInfo_count; i *= 2)
		s = strcat(s, s);
	n = tokenize_console(cvar_string("g_maplist"));
	for(i = 0; i < n; ++i)
	{
		j = MapInfo_FindName(argv(i));
		if(j >= 0)
			s = strcat(
				substring(s, 0, j),
				"1",
				substring(s, j+1, MapInfo_count - (j+1))
			);
	}
	me.g_maplistCache = strzone(s);
	if(gt != me.lastGametype || f != me.lastFeatures)
	{
		me.lastGametype = gt;
		me.lastFeatures = f;
		me.setSelected(me, 0);
	}
}
示例#6
0
// { votecoop
void vote_check_coop ()
{
	int veto;

	if ( ( deathmatch && match_in_progress ) || intermission_running || match_over )
		return;

	if ( !get_votes( OV_COOP ) )
		return;

	veto = is_admins_vote( OV_COOP );

	if( veto || !get_votes_req( OV_COOP, true ) )
	{
		vote_clear( OV_COOP );

		// toggle coop mode
		cvar_fset( "coop", coop = !cvar("coop") );
		// set appropriate deathmatch
		cvar_fset( "deathmatch", deathmatch = !coop );

		if ( veto )
			G_bprint( 2, "%s\n", redtext(va("Coop mode %s by admin veto", OnOff(cvar("coop")))) );
		else
			G_bprint( 2, "%s\n", redtext(va("Coop mode %s by majority vote", OnOff(cvar("coop")))) );

		// and reload map
		if ( cvar("k_bloodfest") )
			changelevel( coop ? g_globalvars.mapname : cvar_string( "k_defmap" ) );
		else
			changelevel( coop ? "start" : g_globalvars.mapname );
			
		return;
	}
}
示例#7
0
void ToggleFavorite(string srv)
{
	string s, s0, s1, s2, srv_resolved;
	float i, n;
	srv_resolved = netaddress_resolve(srv, 26000);
	s = cvar_string("net_slist_favorites");
	n = tokenize_console(s);
	for(i = 0; i < n; ++i)
		if(srv_resolved == netaddress_resolve(argv(i), 26000))
		{
			s0 = s1 = s2 = "";
			if(i > 0)
				s0 = substring(s, 0, argv_end_index(i - 1));
			if(i < n-1)
				s2 = substring(s, argv_start_index(i + 1), -1);
			if(s0 != "" && s2 != "")
				s1 = " ";
			print("s0 = >>", s0, "<<\ns1 = >>", s1, "<<\ns2 = >>", s2, "<<\n");
			cvar_set("net_slist_favorites", strcat(s0, s1, s2));
			return;
		}
	
	s1 = "";
	if(s != "")
		s1 = " ";
	cvar_set("net_slist_favorites", strcat(s, " ", srv));

	resorthostcache();
}
float IsFavorite(string srv)
{
	string p;
	float i, n;
	if(srv == "")
		return FALSE;
	srv = netaddress_resolve(srv, 26000);
	if(srv == "")
		return FALSE;
	p = crypto_getidfp(srv);
	n = tokenize_console(cvar_string("net_slist_favorites"));
	for(i = 0; i < n; ++i)
	{
		if(substring(argv(i), 0, 1) != "[" && strlen(argv(i)) == 44 && strstrofs(argv(i), ".", 0) < 0)
		{
			if(p)
				if(argv(i) == p)
					return TRUE;
		}
		else
		{
			if(srv == netaddress_resolve(argv(i), 26000))
				return TRUE;
		}
	}
	return FALSE;
}
示例#9
0
void drawListBoxItemNexuizCvarList(entity me, float i, vector absSize, float isSelected)
{
	string k, v, d;
	float t;

	vector theColor;
	float theAlpha;

	string s;

	if(isSelected)
		draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
	
	k = bufstr_get(me.handle, i);

	v = cvar_string(k);
	d = cvar_defstring(k);
	t = cvar_type(k);
	if(t & CVAR_TYPEFLAG_SAVED)
		theAlpha = SKINALPHA_CVARLIST_SAVED;
	else
		theAlpha = SKINALPHA_CVARLIST_TEMPORARY;
	if(v == d)
		theColor = SKINCOLOR_CVARLIST_UNCHANGED;
	else
		theColor = SKINCOLOR_CVARLIST_CHANGED;

	s = draw_TextShortenToWidth(k, me.columnNameSize, 0, me.realFontSize);
	draw_Text(me.realUpperMargin * eY + me.columnNameOrigin * eX, s, me.realFontSize, theColor, theAlpha, 0);
	s = draw_TextShortenToWidth(v, me.columnValueSize, 0, me.realFontSize);
	draw_Text(me.realUpperMargin * eY + me.columnValueOrigin * eX, s, me.realFontSize, theColor, theAlpha, 0);
}
示例#10
0
void loadCvarsNexuizTextSlider(entity me)
{
	if not(me.cvarName)
		return;

	me.setValueFromIdentifier(me, cvar_string(me.cvarName));
}
示例#11
0
文件: maplist.c 项目: Bader14/Nexuiz
void MapList_LoadMap(entity btn, entity me)
{
	string m;
	float i;

	i = me.selectedItem;

	if(btn.parent.instanceOfNexuizMapInfoDialog)
	{
		i = btn.parent.currentMapIndex;
		Dialog_Close(btn, btn.parent);
	}

	if(i >= me.nItems || i < 0)
		return;

	m = MapInfo_BSPName_ByID(i);
	if not(m)
	{
		print("Huh? Can't play this (m is NULL). Refiltering so this won't happen again.\n");
		return;
	}
	if(MapInfo_CheckMap(m))
	{
		localcmd("\nmenu_loadmap_prepare\n");
		if(cvar("menu_use_default_hostname"))
			localcmd("hostname \"", strdecolorize(cvar_string("_cl_name")), "'s Nexuiz server\"\n");
		MapInfo_LoadMap(m);
	}
	else
	{
		print("Huh? Can't play this (invalid game type). Refiltering so this won't happen again.\n");
		me.refilter(me);
	}
}
示例#12
0
void WeaponsList_MoveUp_Click(entity box, entity me)
{
	if(me.selectedItem > 0)
	{
		cvar_set("cl_weaponpriority", swapInPriorityList(cvar_string("cl_weaponpriority"), me.selectedItem - 1, me.selectedItem));
		me.selectedItem -= 1;
	}
}
void NexuizPlayerSettingsTab_draw(entity me)
{
	if(cvar_string("_cl_name") == "Player")
		me.playerNameLabel.alpha = ((mod(time * 2, 2) < 1) ? 1 : 0);
	else
		me.playerNameLabel.alpha = me.playerNameLabelAlpha;
	SUPER(NexuizPlayerSettingsTab).draw(me);
}
示例#14
0
void XonoticCheckBoxString_loadCvars(entity me)
{
	if not(me.cvarName)
		return;

	if(cvar_string(me.cvarName) == me.yesString)
		me.checked = 1;
}
void drawNexuizPlayerSettingsTab(entity me)
{
	if(cvar_string("_cl_name") == "Player")
		me.playerNameLabel.alpha = ((mod(time * 2, 2) < 1) ? 1 : 0);
	else
		me.playerNameLabel.alpha = me.playerNameLabelAlpha;
	drawContainer(me);
}
示例#16
0
void WeaponsList_MoveDown_Click(entity box, entity me)
{
	if(me.selectedItem < me.nItems - 1)
	{
		cvar_set("cl_weaponpriority", swapInPriorityList(cvar_string("cl_weaponpriority"), me.selectedItem, me.selectedItem + 1));
		me.selectedItem += 1;
	}
}
void XonoticCrosshairButton_draw(entity me)
{
	vector sz, rgb;
	float a;

	rgb = stov(cvar_string("crosshair_color"));
	a = cvar("crosshair_alpha");

	if(!me.checked && !me.focused && me.cvarValueFloat != -1)
	{
		a *= me.disabledAlpha;
		rgb = '1 1 1';
	}

	if(me.cvarValueFloat == -1) // update the preview if this is the preview button
	{
		if(me.src3)
			strunzone(me.src3);
		me.src3 = strzone(strcat("/gfx/crosshair", cvar_string("crosshair")));
		me.focused = 1;
		me.checked = 0;
	}

	SUPER(XonoticCrosshairButton).draw(me);

	sz = draw_PictureSize(me.src3);
	sz = globalToBoxSize(sz, draw_scale);
	if(me.cvarValueFloat == -1)
	{
		sz = (6 * '1 1 0' + sz * cvar("crosshair_size")) * 0.08; // (6 * '1 1 0' + ...) * 0.08 here to make visible size changes happen also at bigger sizes
		if(sz_x > 0.95)
			sz = sz * (0.95 / sz_x);
		if(sz_y > 0.95)
			sz = sz * (0.95 / sz_y);
	}
	else // show the crosshair picker at full size
		sz = '0.95 0.95 0';

	draw_Picture('0.5 0.5 0' - 0.5 * sz, me.src3, sz, rgb, a);
	if(cvar("crosshair_dot"))
    {
        if(cvar_string("crosshair_dot_color") != "0")
            rgb = stov(cvar_string("crosshair_dot_color"));
		draw_Picture('0.5 0.5 0' - 0.5 * sz * cvar("crosshair_dot_size"), me.src4, sz * cvar("crosshair_dot_size"), rgb, a * cvar("crosshair_dot_alpha"));
    }
}
示例#18
0
float mouseDragNexuizWeaponsList(entity me, vector pos)
{
	float f, i;
	i = me.selectedItem;
	f = mouseDragListBox(me, pos);
	if(me.selectedItem != i)
		cvar_set("cl_weaponpriority", swapInPriorityList(cvar_string("cl_weaponpriority"), me.selectedItem, i));
	return f;
}
示例#19
0
float XonoticWeaponsList_mouseDrag(entity me, vector pos)
{
	float f, i;
	i = me.selectedItem;
	f = SUPER(XonoticWeaponsList).mouseDrag(me, pos);
	if(me.selectedItem != i)
		cvar_set("cl_weaponpriority", swapInPriorityList(cvar_string("cl_weaponpriority"), me.selectedItem, i));
	return f;
}
示例#20
0
void XonoticPlayerModelSelector_loadCvars(entity me)
{
	string skin, modelname;
	float i;

	skin = cvar_string("_cl_playerskin");
	modelname = cvar_string("_cl_playermodel");

	for(i = 0; i < me.numModels; ++i)
	{
		if(bufstr_get(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_MODEL) == modelname)
		if(bufstr_get(me.bufModels, BUFMODELS_COUNT*i+BUFMODELS_SKIN) == skin)
			break;
	}
	if(i >= me.numModels) // fail
		i = 0;
	me.idxModels = i;
}
示例#21
0
float IsFavorite(string srv)
{
	float i, n;
	srv = netaddress_resolve(srv, 26000);
	n = tokenize_console(cvar_string("net_slist_favorites"));
	for(i = 0; i < n; ++i)
		if(srv == netaddress_resolve(argv(i), 26000))
			return TRUE;
	return FALSE;
}
示例#22
0
文件: logs.c 项目: JosephPecoraro/ktx
void StartLogs()
{
	char date[64] = {0}, date_c[64] = {0}, *ip, *port;
	int i = 0;

	if ( strnull( ip = cvar_string( "sv_local_addr" ) ) || strnull( port = strchr(ip, ':') ) || !(i = atoi(port + 1)) )
		return;

	port[0] = 0;
	port++;

	if ( !QVMstrftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S %Z", 0) )
		date[0] = 0; // bad date
	if ( !QVMstrftime(date_c, sizeof(date_c), "%Y%m%d-%H%M%S-%Z", 0) )
		date_c[0] = 0; // bad date

	log_open("%s", cvar_string("extralogname"));
	log_printf("%s", "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
	log_printf("<ktxlog xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n", cvar_string("k_extralog_xsd_uri"));

	log_printf(
		"\t<version>0.1</version>\n"
	);

	log_printf(
		"\t<match_info>\n"
		"\t\t<timestamp>%s</timestamp>\n"
		"\t\t<hostname>%s</hostname>\n"
		"\t\t<ip>%s</ip>\n"
		"\t\t<port>%d</port>\n"
		"\t\t<map>%s</map>\n"
		"\t\t<mode>%s</mode>\n"
		"\t</match_info>\n",
		date,
		cleantext(cvar_string("_k_host")),
		ip,
		i,
		g_globalvars.mapname,
		GetMode()
	);
	log_printf("\t<events>\n");	
}
示例#23
0
void configureNexuizModButtonNexuizModButton(entity me, string menu)
{
	me.configureNexuizButton(me, "", '0 0 0');
	me.onClick = NexuizModButton_Click;
	me.onClickEntity = me;
	me.destination = menu;

	if (cvar_string("menu_slist_modfilter") == "havoc")
		me.text = "Switch to Nexuiz mode";
	else
		me.text = "Switch to Havoc mode";
}
void XonoticCrosshairButton_configureXonoticCrosshairButton(entity me, float theGroup, float theCrosshair)
{
	me.cvarName = "crosshair";
	me.cvarValueFloat = theCrosshair;
	me.loadCvars(me);
	me.configureRadioButton(me, string_null, me.fontSize, me.image, theGroup, 0);
	me.srcMulti = 1;
	if(me.cvarValueFloat == -1)
		me.src3 = strzone(strcat("/gfx/crosshair", cvar_string("crosshair")));
	else
		me.src3 = strzone(strcat("/gfx/crosshair", ftos(me.cvarValueFloat)));
	me.src4 = "/gfx/crosshairdot";
}
示例#25
0
void NexuizTextSlider_loadCvars(entity me)
{
	if not(me.cvarName)
		return;

	var float n = tokenize_console(me.cvarName);
	var string s = cvar_string(argv(0));
	float i;
	for(i = 1; i < n; ++i)
		s = strcat(s, " ", cvar_string(argv(i)));
	me.setValueFromIdentifier(me, s);
	if(me.value < 0 && n > 1)
	{
		// if it failed: check if all cvars have the same value
		// if yes, try its value as 1-word identifier
		for(i = 1; i < n; ++i)
			if(cvar_string(argv(i)) != cvar_string(argv(i-1)))
				break;
		if(i >= n)
			me.setValueFromIdentifier(me, cvar_string(argv(0)));
	}
}
示例#26
0
void NexuizModButton_Click(entity me, entity other)
{
	string thecmd;
	thecmd = strcat("\nmenu_restart");

	if (me.destination != "")
		thecmd = strcat(thecmd, "\ntogglemenu\ndefer 0.1 \"menu_cmd directmenu ", me.destination,"\"\n");

	if (cvar_string("menu_slist_modfilter") == "havoc")
		thecmd = strcat("\ngamedir data", thecmd);
	else
		thecmd = strcat("\ngamedir havoc", thecmd);
	cmd(thecmd);
}
示例#27
0
void drawNexuizWeaponsList(entity me)
{
	// read in cvar?
	string s, t;
	s = W_NumberWeaponOrder(cvar_string("cl_weaponpriority"));
	t = W_FixWeaponOrder(s, 1);
	if(t != s)
	{
		print("AUTOFIXED\n");
		cvar_set("cl_weaponpriority", W_NameWeaponOrder(t));
	}
	me.nItems = tokenize_console(t);
	drawListBox(me);
}
示例#28
0
string toStringNexuizWeaponsList(entity me)
{
	float n, i;
	string s;
	entity e;
	n = tokenize_console(W_NumberWeaponOrder(cvar_string("cl_weaponpriority")));
	s = "";
	for(i = 0; i < n; ++i)
	{
		e = get_weaponinfo(stof(argv(i)));
		s = strcat(s, e.message, ", ");
	}
	return substring(s, 0, strlen(s) - 2);
}
示例#29
0
void XonoticWeaponsList_draw(entity me)
{
	// read in cvar?
	string s, t;
	s = W_NumberWeaponOrder(cvar_string("cl_weaponpriority"));
	t = W_FixWeaponOrder(s, 1);
	if(t != s)
	{
		print("AUTOFIXED\n");
		cvar_set("cl_weaponpriority", W_NameWeaponOrder(t));
	}
	me.nItems = tokenize_console(t);
	SUPER(XonoticWeaponsList).draw(me);
}
示例#30
0
void setSelectedNexuizCvarList(entity me, float i)
{
	string s;

	setSelectedListBox(me, i);
	if(me.nItems == 0)
		return;
	
	if(me.cvarName)
		strunzone(me.cvarName);
	if(me.cvarDescription)
		strunzone(me.cvarDescription);
	if(me.cvarType)
		strunzone(me.cvarType);
	if(me.cvarDefault)
		strunzone(me.cvarDefault);
	me.cvarName = strzone(bufstr_get(me.handle, me.selectedItem));
	me.cvarDescription = strzone(cvar_description(me.cvarName));
	me.cvarDefault = strzone(cvar_defstring(me.cvarName));

	float t;
	t = cvar_type(me.cvarName);
	me.cvarType = "";
	if(t & CVAR_TYPEFLAG_SAVED)
		me.cvarType = strcat(me.cvarType, ", will be saved to config.cfg");
	else
		me.cvarType = strcat(me.cvarType, ", will not be saved");
	if(t & CVAR_TYPEFLAG_PRIVATE)
		me.cvarType = strcat(me.cvarType, ", private");
	if(t & CVAR_TYPEFLAG_ENGINE)
		me.cvarType = strcat(me.cvarType, ", engine setting");
	if(t & CVAR_TYPEFLAG_READONLY)
		me.cvarType = strcat(me.cvarType, ", read only");
	me.cvarType = strzone(substring(me.cvarType, 2, strlen(me.cvarType) - 2));

	me.cvarNameBox.setText(me.cvarNameBox, me.cvarName);
	me.cvarDescriptionBox.setText(me.cvarDescriptionBox, me.cvarDescription);
	me.cvarTypeBox.setText(me.cvarTypeBox, me.cvarType);
	me.cvarDefaultBox.setText(me.cvarDefaultBox, me.cvarDefault);

	// this one can handle tempstrings
	s = cvar_string(me.cvarName);
	me.cvarValueBox.setText(me.cvarValueBox, s);
	me.cvarValueBox.cursorPos = strlen(s);
}