本文整理汇总了C++中CVar类的典型用法代码示例。如果您正苦于以下问题:C++ CVar类的具体用法?C++ CVar怎么用?C++ CVar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CVar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: safe_delete
void LoginForm::onLogin()
{
safe_delete(m_pLogThread);
bool remPass = m_cbRemPass->GetValue();
gc_savelogin.setValue(remPass);
if (gc_saveusername.getBool())
{
wxString dastr = m_tbUsername->GetValue();
gc_lastusername.setValue(dastr.ToUTF8());
}
SaveCVars();
if (m_comboProvider)
gc_login_stage_last.setValue(m_comboProvider->GetStringSelection().ToUTF8());
Show(false);
MainApp* temp = dynamic_cast<MainApp*>(GetParent());
if (temp)
temp->onLoginAccepted(remPass, m_bAutoLogin);
}
示例2: SCR_DrawFPS
void SCR_DrawFPS(void) {
extern CVar show_fps;
static double lastframetime;
double t;
extern int fps_count;
static int lastfps;
static int totalfps;
static int lastsecond;
int x, y;
char st[80];
if (!show_fps.getBool())
return;
t = Sys_FloatTime();
lastfps = 1 / (t - lastframetime);
if (((int) (t) % 100) > ((int) (lastframetime) % 100)) {
lastsecond = totalfps;
totalfps = 0;
}
lastframetime = t;
totalfps += 1;
sprintf(st, "%3d FPS", lastfps);
x = vid.conwidth - strlen(st) * 8 - 16;
y = 0;
Draw_String(x, y, st);
sprintf(st, "%3d Last second", lastsecond);
x = vid.conwidth - strlen(st) * 8 - 16;
y = 8;
Draw_String(x, y, st);
}
示例3: getCVar
int Settings::getCVar(const std::string& name)
{
CVar* cvar = cvarlist[name];
if ( cvar )
return cvar->getIntValue();
return 0;
}
示例4: KeyDown
void CCamera::KeyDown(int c)
{
if (CVar::GetCVarBool("cheats") && c == 'Z')
{
cam_free.SetValue(m_bFreeMode?_T("off"):_T("on"));
if (lock_freemode_frustum.GetBool())
{
if (m_bFreeMode)
GameServer()->GetRenderer()->FrustumOverride(GetCameraPosition(), GetCameraTarget(), GetCameraFOV(), GetCameraNear(), GetCameraFar());
else
GameServer()->GetRenderer()->CancelFrustumOverride();
}
}
if (m_bFreeMode)
{
if (c == 'W')
m_vecFreeVelocity.x = 10.0f;
if (c == 'S')
m_vecFreeVelocity.x = -10.0f;
if (c == 'D')
m_vecFreeVelocity.z = 10.0f;
if (c == 'A')
m_vecFreeVelocity.z = -10.0f;
}
}
示例5: GetCVarManager
void DesuraJSSettings::setValue(gcString name, gcString val)
{
CVar* cvar = GetCVarManager()->findCVar(name.c_str());
if (cvar && val != gcString(cvar->getString()))
cvar->setValue(val.c_str());
}
示例6: FindCVar
void CVar::SetCVar(tstring sName, float flValue)
{
CVar* pVar = FindCVar(sName);
if (!pVar)
return;
pVar->SetValue(flValue);
}
示例7: getCVarPtr
const int* Settings::getCVarPtr(const std::string& name)
{
CVar* cvar = cvarlist[name];
if ( cvar )
return cvar->getIntValuePointer();
else
BE_ERROR("::SETTINGS error unknown cvar: " << name);
}
示例8:
const std::string& Settings::getCVarS(const std::string& name)
{
CVar* cvar = cvarlist[name];
if ( cvar )
return cvar->getStringValue();
else
BE_ERROR("::SETTINGS error unknown cvar: " << name);
}
示例9: GetCVarManager
gcString DesuraJSSettings::getValue(gcString name)
{
CVar* cvar = GetCVarManager()->findCVar(name.c_str());
if (!cvar)
return "";
return cvar->getExitString();
}
示例10: sPlain
bool CFont::InitModel()
{
static CStrAny sPlain(ST_CONST, "Plain");
static CStrAny sg_mWorld(ST_CONST, "g_mWorld");
static CStrAny sg_mView(ST_CONST, "g_mView");
static CStrAny sg_mProj(ST_CONST, "g_mProj");
static CStrAny sg_mTexTransform(ST_CONST, "g_mTexTransform");
static CStrAny sg_cMaterialDiffuse(ST_CONST, "g_cMaterialDiffuse");
static CStrAny sg_txDiffuse(ST_CONST, "g_txDiffuse");
static CStrAny sg_sDiffuse(ST_CONST, "g_sDiffuse");
ASSERT(!m_pTextModel);
bool bRes;
CTechnique *pTech = CGraphics::Get()->GetTechnique(sPlain);
if (!pTech)
return false;
CSmartPtr<CGeometry> pGeom(new CGeometry());
bRes = pGeom->Init(pTech->m_pInputDesc, CGeometry::PT_TRIANGLELIST, INIT_BUFFER_CHARS * 4, INIT_BUFFER_CHARS * 6, 0, 0,
CResource::RF_DYNAMIC | CResource::RF_KEEPSYSTEMCOPY, CResource::RF_DYNAMIC | CResource::RF_KEEPSYSTEMCOPY);
if (!bRes)
return false;
CSmartPtr<CMaterial> pMaterial(new CMaterial());
bRes = pMaterial->Init(pTech, true, 0);
if (!bRes)
return false;
CSmartPtr<CModel> pModel(new CModel());
bRes = pModel->Init(pGeom, pMaterial, 0, false);
if (!bRes)
return false;
m_pTextModel = pModel;
CMatrix<4, 4> mIdentity;
mIdentity.SetDiagonal();
CMatrixVar vMat(4, 4, CMatrixVar::MVF_OWNVALUES, &mIdentity(0, 0));
m_pTextModel->SetVar(sg_mProj, vMat);
m_pTextModel->SetVar(sg_mView, vMat);
m_pTextModel->SetVar(sg_mWorld, vMat);
CMatrix<3, 2> mTexIdentity;
mTexIdentity.SetDiagonal();
CMatrixVar vTexMat(3, 2, CMatrixVar::MVF_OWNVALUES, &mTexIdentity(0, 0));
m_pTextModel->SetVar(sg_mTexTransform, vTexMat);
CVar<CVector<4> > vVec4;
vVec4.Val().Set(1, 1, 1, 1);
m_pTextModel->SetVar(sg_cMaterialDiffuse, vVec4);
CVar<CTexture *> vTexVar;
vTexVar.Val() = m_pTexture;
m_pTextModel->SetVar(sg_txDiffuse, vTexVar);
CVar<CSampler *> vSampVar;
vSampVar.Val() = CGraphics::Get()->GetSampler(CSampler::TDesc());
m_pTextModel->SetVar(sg_sDiffuse, vSampVar);
ResetModel();
return true;
}
示例11: GetUserCore
void MainApp::onLoginAcceptedCB(std::pair<bool,bool> &loginInfo)
{
bool saveLoginInfo = loginInfo.first;
bool autologin = loginInfo.second;
if (m_wxLoginForm)
{
m_wxLoginForm->Show(false);
m_wxLoginForm->Destroy();
m_wxLoginForm = nullptr;
}
if (saveLoginInfo)
GetUserCore()->saveLoginInfo();
GetUserCore()->getAppUpdateProgEvent() += guiDelegate(this, &MainApp::onAppUpdateProg);
GetUserCore()->getAppUpdateCompleteEvent() += guiDelegate(this, &MainApp::onAppUpdate);
GetWebCore()->getCookieUpdateEvent() += guiDelegate(this, &MainApp::onCookieUpdate);
GetWebCore()->getLoggedOutEvent() += delegate(&onLoggedOutEvent);
GetUserCore()->getPipeDisconnectEvent() += guiDelegate(this, &MainApp::onPipeDisconnect);
//trigger this so it sets cookies first time around
onCookieUpdate();
admin_developer.setValue(GetUserCore()->isAdmin());
GetCVarManager()->loadUser(GetUserCore()->getUserId());
gcWString userName(GetUserCore()->getUserName());
SetCrashDumpSettings(userName.c_str(), gc_uploaddumps.getBool());
m_bLoggedIn = true;
m_iMode = APP_MODE::MODE_ONLINE;
bool showMain = !(autologin && gc_silentlaunch.getBool());
showMainForm(false, showMain);
m_pInternalLink = new InternalLink(this);
if (!m_bQuiteMode)
GetUserCore()->getItemManager()->checkItems();
if (m_wxTBIcon)
m_wxTBIcon->regEvents();
if (showMain && !m_bQuiteMode)
showNews();
if (m_szDesuraCache != "")
{
m_pInternalLink->handleInternalLink(m_szDesuraCache.c_str());
m_szDesuraCache = "";
}
onLoginEvent();
}
示例12: Instructor_LessonLearned
void CPlayer::Instructor_LessonLearned(const tstring& sLesson)
{
if (!GameWindow()->GetInstructor()->IsInitialized())
GameWindow()->GetInstructor()->Initialize();
auto it = m_apLessonProgress.find(sLesson);
TAssert(it != m_apLessonProgress.end());
if (it == m_apLessonProgress.end())
return;
CLessonProgress* pLessonProgress = &it->second;
TAssert(pLessonProgress);
if (!pLessonProgress)
return;
// Can only learn a lesson once in a while, to ensure that it is truly learned.
// The idea is that the player spends a couple seconds toying around with the
// new feature, but won't spend all of the lessons in that time.
if (GameServer()->GetGameTime() < pLessonProgress->m_flLastTimeLearned + lesson_learntime.GetFloat())
return;
pLessonProgress->m_flLastTimeLearned = GameServer()->GetGameTime();
pLessonProgress->m_iTimesLearned++;
if (lesson_debug.GetBool())
{
CLesson* pLesson = GameWindow()->GetInstructor()->GetLesson(sLesson);
if (pLessonProgress->m_iTimesLearned < pLesson->m_iTimesToLearn)
TMsg(tsprintf("Instructor: Trained lesson " + sLesson + " - %d/%d\n", pLessonProgress->m_iTimesLearned, pLesson->m_iTimesToLearn));
else if (pLessonProgress->m_iTimesLearned == pLesson->m_iTimesToLearn)
TMsg("Instructor: Learned lesson " + sLesson + "\n");
}
}
示例13: ExecuteSingleCmd
/*
================
CmdSystemEx::ExecuteSingleCmd
================
*/
void CmdSystemEx::ExecuteSingleCmd( const char *cmd ) {
CmdArgs args(cmd);
if ( !args.Argc() )
return;
const char *arg0 = args.Argv(0);
int index = cmdList.Find( arg0 );
if ( index != -1 ) {
ConsoleCmd &cCmd = cmdList[index];
if( cCmd.flags & CMD_DEVELOPER && !com_developer.GetBool() ) {
User::Warning( "Developer mode is not active!" );
return;
}
if( cCmd.flags & CMD_CHEAT && !net_allowCheats.GetBool() ) {
User::Warning( Format( "$* is cheat protected" ) << cmdList.GetKey(index) );
return;
}
if ( cCmd.usage->minArguments > (args.Argc()-1) )
cCmd.usage->ShowUsage();
else
cCmd.func(args);
return;
}
if ( !cvarSystemEx->OnCommand(args) )
User::Warning( Format( "Unknown command '$*'.\n" ) << arg0 );
}
示例14: CL_SignonReply
/**
* An svc_signonnum has been received, perform a client side setup
*/
void CL_SignonReply(void) {
char str[8192];
Con_DPrintf("CL_SignonReply: %i\n", cls.signon);
switch (cls.signon) {
case 1:
MSG_WriteByte(&cls.message, clc_stringcmd);
MSG_WriteString(&cls.message, "prespawn");
break;
case 2:
MSG_WriteByte(&cls.message, clc_stringcmd);
MSG_WriteString(&cls.message, va("name \"%s\"\n", cl_name.getString()));
MSG_WriteByte(&cls.message, clc_stringcmd);
MSG_WriteString(&cls.message, va("color %i %i\n", cl_color.getInt() >> 4, cl_color.getInt()&15));
MSG_WriteByte(&cls.message, clc_stringcmd);
sprintf(str, "spawn %s", cls.spawnparms);
MSG_WriteString(&cls.message, str);
break;
case 3:
MSG_WriteByte(&cls.message, clc_stringcmd);
MSG_WriteString(&cls.message, "begin");
MemoryObj::Report(); // print remaining memory
break;
case 4:
SCR_EndLoadingPlaque(); // allow normal screen updates
break;
}
}
示例15: guiDelegate
MainApp::MainApp()
{
Bind(wxEVT_CLOSE_WINDOW, &MainApp::onClose, this);
m_wxLoginForm = NULL;
m_wxTBIcon = NULL;
m_wxMainForm = NULL;
m_bQuiteMode = false;
m_bLoggedIn = false;
m_iMode = MODE_LOGOUT;
//need to overide the value in corecount if not set
if (gc_corecount.getInt() == 0)
{
//need to change the value so it will trigger the cvar callback
gc_corecount.setValue(1);
gc_corecount.setValue(0);
}
m_pOfflineDialog = NULL;
m_pInternalLink = NULL;
onLoginAcceptedEvent += guiDelegate(this, &MainApp::onLoginAcceptedCB);
onInternalLinkEvent += guiDelegate(this, &MainApp::onInternalLink);
onInternalLinkStrEvent += guiDelegate(this, &MainApp::onInternalStrLink);
onNotifyGiftUpdateEvent += guiDelegate(this, &MainApp::onNotifyGiftUpdate);
}