コード例 #1
0
void CmdSystemEx::Cmd_ListCmds_f( const CmdArgs &args ) {
	DictEx<ConsoleCmd> & cmdList = CmdSystemObject.cmdList;
	bool match = false;
	const char *matchstr = 0;

	if( args.Argc() > 1 ) {
		match = true;
		matchstr = args.Argv(1);
	}

	int num = cmdList.Num();
	int i = 0;
	int disp = 0;
	Format out("  $+18* - $*\n");
	for( i=0; i<num; i++ ) {
		if ( match && String::Find(cmdList.GetKey(i).c_str(), matchstr, false) == String::INVALID_POSITION )
			continue;
		out << cmdList.GetKey(i) << cmdList[i].usage->strDescription;
		Console::Print( out );
		out.Reset();
		disp++;
	}

	if( match )
		Console::Print( Format( "\n  $* command$* matching \"$*\"\n" ) << disp << (disp == 1 ? "" : "s") << matchstr );
	else
		Console::Print( Format( "\n  $* command$*\n" ) << disp << (disp == 1 ? "" : "s") );
}
コード例 #2
0
void CmdSystemEx::Cmd_Wait_f( const CmdArgs &args ) {
	int ms = CmdSystemObject.minWaitTime;
	if ( args.Argc() > 1 ) {
		ms = String::ToInt(args.Argv(1));
		if ( ms < CmdSystemObject.minWaitTime )
			ms = CmdSystemObject.minWaitTime;
	}
	CmdSystemObject.waitTime = SysInfo::GetTime() + ms;
}
コード例 #3
0
void CmdSystemEx::Cmd_Help_f( const CmdArgs &args ) {
	if ( args.Argc() > 2 ) {
		Cmd_Help_Usage.ShowUsage();
		return;
	}

	const char *cmd = args.Argv(1);
	// Try Command List
	int i = CmdSystemObject.cmdList.Find(cmd);
	if ( i != -1 ) {
		Console::Print( Format( "$*: $*\n" ) << CmdSystemObject.cmdList.GetKey(i) << CmdSystemObject.cmdList[i].usage->strDescription );
		CmdSystemObject.cmdList[i].usage->ShowUsage();
		return;
	}
	// Not a Command, is it a CVar?
	CVar *cv = cvarSystem->Find(cmd);
	if ( cv ) {
		Console::Print( Format( "$*: $*\n" ) << cv->data->strName << cv->data->strDescription );
		return;
	}
	Console::Print( Format( "Command/Cvar not found: '$*'.\n" ) << cmd );
}