bool BecherConfig::Conf() { if (!m_continue) return false; Load(v_config.GetString()); return m_continue; }
bool BecherConfig::Conf(HINSTANCE hInstance) { if (!m_continue) return false; if (Load(v_config.GetString())!=0 || m_showdlg) { if (!ShowConfig(hInstance)) return false; } return m_continue; }
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(); }
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) { } return 1; }
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; }*/ }