当前位置: 首页>>代码示例>>C++>>正文


C++ CVar::GetValue方法代码示例

本文整理汇总了C++中CVar::GetValue方法的典型用法代码示例。如果您正苦于以下问题:C++ CVar::GetValue方法的具体用法?C++ CVar::GetValue怎么用?C++ CVar::GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CVar的用法示例。


在下文中一共展示了CVar::GetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetCVarValue

tstring CVar::GetCVarValue(tstring sName)
{
	CVar* pVar = FindCVar(sName);
	if (!pVar)
		return "";

	return pVar->GetValue();
}
开发者ID:BSVino,项目名称:CodenameInfinite,代码行数:8,代码来源:cvar.cpp

示例2: SetCVar

void SetCVar(CCommand* pCommand, tvector<tstring>& asTokens, const tstring& sCommand)
{
	CVar* pCVar = dynamic_cast<CVar*>(pCommand);
	TAssert(pCVar);
	if (!pCVar)
		return;

	if (asTokens.size() > 1)
		pCVar->SetValue(asTokens[1]);

	TMsg(sprintf(tstring("%s = %s\n"), pCVar->GetName().c_str(), pCVar->GetValue().c_str()));
}
开发者ID:BSVino,项目名称:CodenameInfinite,代码行数:12,代码来源:cvar.cpp

示例3: execute

/* Console::execute
 * Attempts to execute the command line given
 *******************************************************************/
void Console::execute(string command)
{
	::logMessage(1, "> %s", CHR(command));

	// Don't bother doing anything else with an empty command
	if (command.size() == 0)
		return;

	// Add the command to the log
	cmd_log.insert(cmd_log.begin(), command);

	// Tokenize the command string
	Tokenizer tz;
	tz.openString(command);

	// Get the command name
	string cmd_name = tz.getToken();

	// Get all args
	string arg = tz.getToken();
	vector<string> args;
	while (arg != "")
	{
		args.push_back(arg);
		arg = tz.getToken();
	}

	// Check that it is a valid command
	//for (size_t a = 0; a < commands.size(); a++)
	for (Command& command : commands)
	{
		// Found it, execute and return
		if (command.getName() == cmd_name)
		{
			command.execute(args);
			return;
		}
	}

	// Check if it is a cvar
	CVar* cvar = get_cvar(cmd_name);
	if (cvar)
	{
		// Arg(s) given, set cvar value
		if (args.size() > 0)
		{
			if ((cvar->flags & CVAR_LOCKED) > 0)
				logMessage(S_FMT("CVar \"%s\" can not be modified via the console", CHR(cmd_name)));
			else if (cvar->type == CVAR_BOOLEAN)
			{
				if (args[0] == "0" || args[0] == "false")
					*((CBoolCVar*)cvar) = false;
				else
					*((CBoolCVar*)cvar) = true;
			}
			else if (cvar->type == CVAR_INTEGER)
				*((CIntCVar*)cvar) = atoi(CHR(args[0]));
			else if (cvar->type == CVAR_FLOAT)
				*((CFloatCVar*)cvar) = (float)atof(CHR(args[0]));
			else if (cvar->type == CVAR_STRING)
				*((CStringCVar*)cvar) = args[0];
		}

		// Print cvar value
		string value = "";
		if (cvar->type == CVAR_BOOLEAN)
		{
			if (cvar->GetValue().Bool)
				value = "true";
			else
				value = "false";
		}
		else if (cvar->type == CVAR_INTEGER)
			value = S_FMT("%d", cvar->GetValue().Int);
		else if (cvar->type == CVAR_FLOAT)
			value = S_FMT("%1.4f", cvar->GetValue().Float);
		else
			value = ((CStringCVar*)cvar)->value;

		logMessage(S_FMT("\"%s\" = \"%s\"", CHR(cmd_name), CHR(value)));

		if (cmd_name == "log_verbosity")
			Global::log_verbosity = cvar->GetValue().Int;

		return;
	}

	// Toggle global debug mode
	if (cmd_name == "debug")
	{
		Global::debug = !Global::debug;
		if (Global::debug)
			logMessage("Debugging stuff enabled");
		else
			logMessage("Debugging stuff disabled");

		return;
//.........这里部分代码省略.........
开发者ID:sirjuddington,项目名称:Voxigine,代码行数:101,代码来源:Console.cpp


注:本文中的CVar::GetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。