本文整理汇总了C++中CVar::GetString方法的典型用法代码示例。如果您正苦于以下问题:C++ CVar::GetString方法的具体用法?C++ CVar::GetString怎么用?C++ CVar::GetString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVar
的用法示例。
在下文中一共展示了CVar::GetString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Conf
bool BecherConfig::Conf()
{
if (!m_continue)
return false;
Load(v_config.GetString());
return m_continue;
}
示例2: WriteVariables
void CConsole::WriteVariables( void )
{
CVar* cv;
std::ofstream file( "config//config.cfg" ,ios::out );
file.clear();
for (int i=0;i<m_CommandList.Size();i++)
{
if ( !m_CommandList[i]->IsFlagSet( FCVAR_ARCHIVE ) )
continue;
cv = (CVar*)m_CommandList[i];
file << cv->GetName();
file << " ";
file << cv->GetString() << "\n";
}
file.close();
}
示例3: OnKeyPress
int Console::OnKeyPress(int key)
{
if(key >= ' ' && key < 127)
{
if(lshift || rshift)
cmd[cmdPos++] = (char)shiftTable[key-32];
else
cmd[cmdPos++] = (char)key;
}
else if(key == K_BACKSPACE)
{
cmdPos--;
if(cmdPos < 2)
cmdPos = 2;
cmd[cmdPos] = 0;
}
else if(key == K_ENTER)
{
if(cmd[2] == 0)
return true;
//exec
char lcmd[256];
cmd[cmdPos] = '\0';
strcpy(lcmd, &cmd[2]);
char* name = strtok(lcmd, " ");
char* args;
if ( (&cmd[2])[strlen(name)] == 0 )
args = NULL;
else
args = lcmd + strlen(name) + 1;
if(!g_commandSystem->Execute(name, args))
{
CVar* cvar = g_cvarSystem->Find(name);
// cvar
if(args)
{
if(cvar)
cvar->Set(args);
}
if(cvar)
g_common->Print("%s = %s", name, cvar->GetString());
}
else
{
}
memset(cmd, 0, 256);
cmd[0] = '>';
cmd[1] = ' ';
cmdPos = 2;
}
else if(key == K_LSHIFT)
{
lshift = 1;
}
else if(key == K_RSHIFT)
{
rshift = 1;
}
else if(key == K_TAB)
{
const char* txt = 0;
const char* cCmd = g_commandSystem->Complete(&cmd[2]);
const char* cCvar = g_cvarSystem->Complete(&cmd[2]);
if(cCmd)
txt = cCmd;
else if(cCvar)
txt = cCvar;
if(txt)
{
memset(cmd, 0, 256);
cmd[0] = '>';
cmd[1] = ' ';
strcpy(&cmd[2], txt);
cmd[strlen(txt)+2] = ' ';
cmdPos = (int)(strlen(txt)+3);
}
}
// command cycling
else if(key == K_UP)
{
cmdIdx--;
if(cmdIdx < 0)
cmdIdx = 0;
memset(cmd, 0, 256);
cmd[0] = '>';
cmd[1] = ' ';
}
else if(key == K_DOWN)
{
}
//.........这里部分代码省略.........
示例4: ExecuteString
void CConsole::ExecuteString(char *sCommand)
{
// przekaz aktualne zrodlo wywolania
//g_CmdSource = src;
// podziel linijke na slowa. od teraz mamy do nich dostep przez funkcje dostepowe
TokenizeString (sCommand);
// jesli nie ma zadnych slow, koniec
if (!m_iCmdArgc)
return;
// jesli to komentarz, pomin
if ( strlen(sCommand)>1 && sCommand[0]=='/' && sCommand[1]=='/' )
return;
// Sprawdzamy czy istnieje dana komenda lub zmienna
CCommandBase *pCommand = GetCommand( GetArgument(0) );
if ( !pCommand )
{
Output( "Unknown command: %s", GetArgument(0) );
return;
}
// Jesli to komenda, wykonujemy ja i konczymy
if ( pCommand->IsCommand() )
{
(( CCommand * )pCommand )->Dispatch();
return;
}
// Jesli to zmienna:
// Jesli jeden wyraz, pokaz zmienna
if ( m_iCmdArgc == 1 )
{
Output(" %s = %s", (( CVar * )pCommand)->GetName(), (( CVar * )pCommand)->GetString() );
return;
}
// Jesli dwa wyrazy, sprobuj przypisac wartosc
if ( m_iCmdArgc == 2 )
{
CVar *cv = ( CVar * )pCommand;
cv->SetValue( GetArgument(1) );
Output("CVar changed: %s = %s", GetArgument(0), cv->GetString());
return;
}
// --- sprawdzamy komendy! ---
// sprobuj znalezc komende o nazwie jak w pierwszym parametrze
/* CCommandBase *pCommand = CCommandBase::FindCommand( m_szCmdArgv[0] );
// jesli to komenda, uruchom jej funkcje
if ( pCommand && pCommand->IsCommand() )
{
(( CCommand * )pCommand )->Dispatch();
return;
}
// TEMP: jesli to cvar
// TODO: forwardowanie do servera i tylko gdy w grze
if ( pCommand && !pCommand->IsCommand() )
{
// jesli jeden wyraz, pokaz zmienna
if ( m_iCmdArgc == 1 )
{
// cvars()->PrintCvar( (CVar*)pCommand );
}
// TEMP: jesli dwa, sprobuj przypisac wartosc
if ( m_iCmdArgc == 2 )
{
CVar *cv = (CVar*)pCommand;
if ( cv->IsFlagSet(FCVAR_ENGINE) && m_CmdSource == SRC_CLIENT )
{
Output("You cannot change the engine CVar!");
return;
}
/*if ( cv->IsFlagSet(FCVAR_SERVER) && !sv.active )
{
CONCOLOR( rgb(255, 178, 22), "%s is a server variable, cannot change it locally", Cmd_Argv(0) );
} else*/
/*{
cv->SetValue( GetArgument(1) );
Output( "CVar changed: %s = %s", GetArgument(0), cv->GetString() );
}
}
return;
}*/
}