Esempio n. 1
0
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);
}
Esempio n. 2
0
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");
    }
}
/*
================
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 );
}
Esempio n. 4
0
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);
}
Esempio n. 5
0
/**
 * 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;
	}
}
Esempio n. 6
0
int Settings::getCVar(const std::string& name)
{
	CVar* cvar = cvarlist[name];
	if ( cvar )
		return cvar->getIntValue();
	return 0;
}
Esempio n. 7
0
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;
	}
}
Esempio n. 8
0
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);
}
Esempio n. 9
0
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());
}
Esempio n. 10
0
void SCR_SetUpToDrawConsole(void) {
	Con_CheckResize();

	if (scr_drawloading)
		return; // never a console with loading plaque

	// decide on the height of the console
	con_forcedup = !cl.worldmodel || cls.signon != SIGNONS;

	if (con_forcedup) {
		scr_conlines = vid.conheight; // full screen
		scr_con_current = scr_conlines;
	} else if (key_dest == key_console)
		scr_conlines = vid.conheight / 2; // half screen
	else
		scr_conlines = 0; // none visible

	if (scr_conlines < scr_con_current) {
		scr_con_current -= scr_conspeed.getFloat() * host_frametime;
		if (scr_conlines > scr_con_current)
			scr_con_current = scr_conlines;

	} else if (scr_conlines > scr_con_current) {
		scr_con_current += scr_conspeed.getFloat() * host_frametime;
		if (scr_conlines < scr_con_current)
			scr_con_current = scr_conlines;
	}

	if (!(clearconsole++ < vid.numpages || clearnotify++ < vid.numpages))
		con_notifylines = 0;
}
Esempio n. 11
0
void CCamera::Think()
{
	bool bFreeMode = cam_free.GetBool();
	if (bFreeMode != m_bFreeMode)
	{
		m_vecFreeCamera = GetCameraPosition();
		m_angFreeCamera = VectorAngles((GetCameraTarget() - GetCameraPosition()).Normalized());
		m_bFreeMode = bFreeMode;
		CApplication::Get()->SetMouseCursorEnabled(!m_bFreeMode);
	}

	if (m_bFreeMode)
	{
		Vector vecForward, vecRight;
		AngleVectors(m_angFreeCamera, &vecForward, &vecRight, NULL);

		m_vecFreeCamera += vecForward * m_vecFreeVelocity.x * GameServer()->GetFrameTime() * 20;
		m_vecFreeCamera -= vecRight * m_vecFreeVelocity.z * GameServer()->GetFrameTime() * 20;
	}
	else
	{
		if (shrink_frustum.GetBool())
			GameServer()->GetRenderer()->FrustumOverride(GetCameraPosition(), GetCameraTarget(), GetCameraFOV()-1, GetCameraNear()+1, GetCameraFar()-1);
	}
}
Esempio n. 12
0
void CVar::SetCVar(tstring sName, float flValue)
{
	CVar* pVar = FindCVar(sName);
	if (!pVar)
		return;

	pVar->SetValue(flValue);
}
Esempio n. 13
0
tstring CVar::GetCVarValue(tstring sName)
{
	CVar* pVar = FindCVar(sName);
	if (!pVar)
		return "";

	return pVar->GetValue();
}
Esempio n. 14
0
bool CVar::GetCVarBool(tstring sName)
{
	CVar* pVar = FindCVar(sName);
	if (!pVar)
		return false;

	return pVar->GetBool();
}
Esempio n. 15
0
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);
}
Esempio n. 16
0
int CVar::GetCVarInt(tstring sName)
{
	CVar* pVar = FindCVar(sName);
	if (!pVar)
		return 0;

	return pVar->GetInt();
}
Esempio n. 17
0
void CVar::SetCVar(tstring sName, int iValue)
{
	CVar* pVar = FindCVar(sName);
	if (!pVar)
		return;

	pVar->SetValue(iValue);
}
Esempio n. 18
0
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);
}
Esempio n. 19
0
gcString DesuraJSSettings::getValue(gcString name)
{
	CVar* cvar = GetCVarManager()->findCVar(name.c_str());
	if (!cvar)
		return "";

	return cvar->getExitString();
}
Esempio n. 20
0
float CVar::GetCVarFloat(tstring sName)
{
	CVar* pVar = FindCVar(sName);
	if (!pVar)
		return 0;

	return pVar->GetFloat();
}
Esempio n. 21
0
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;
}
Esempio n. 22
0
void MainApp::Init(int argc, wxCmdLineArgsArray &argv)
{
	gcTrace("");

	if (argc > 0)
	{
		for (int x=0; x<argc; x++)
		{
			wxString str = argv[x].MakeLower();

			if (str == "-dgl")
				m_bQuiteMode = true;

			if (str.StartsWith("desura://"))
				m_szDesuraCache = gcString(argv[x].ToStdString());
		}
	}

	//char *comAppPath = nullptr;
	//UTIL::OS::getAppDataPath(&comAppPath);
	//UTIL::FS::recMakeFolder(comAppPath);
	//safe_delete(comAppPath);

	InitLogging();
	cc_PrintVersion();
	cc_CheckCert();
	Msg("Logging Has started\n");
	Msg("\n\n");

	InitManagers();
	InitLocalManagers();

	std::string val = UTIL::OS::getConfigValue(REGRUN);
	gc_autostart.setValue( val.size() > 0 );

	//because logging gets init first we need to man reg it
	RegLogWithWindow();

	//because logging gets init before managers we need to reapply the color scheme.
	LoggingapplyTheme();
	loadFrame(wxDEFAULT_FRAME_STYLE);

#ifndef NIX
	if (!m_bQuiteMode)
		m_wxTBIcon = new TaskBarIcon(this);
#endif
	m_wxTBIcon = nullptr;

	std::string szAppid = UTIL::OS::getConfigValue(APPID);

	uint32 appid = -1;

	if (szAppid.size() > 0)
		appid = Safe::atoi(szAppid.c_str());

	if (appid == BUILDID_BETA || appid == BUILDID_INTERNAL)
		gc_uploaddumps.setValue(true);
}
Esempio n. 23
0
void CStructure::Think()
{
	BaseClass::Think();

	if (GameData().GetCommandMenu())
	{
		if (IsUnderConstruction() && IsWorkingConstructionTurn())
		{
			CCommandMenu* pMenu = GameData().GetCommandMenu();
			pMenu->SetProgressBar(GameServer()->GetGameTime() - m_flConstructionTurnTime, build_time_construct.GetFloat());
		}

		if (GameData().GetCommandMenu()->WantsToClose())
			GameData().CloseCommandMenu();
		else
			GameData().GetCommandMenu()->Think();
	}

	if (GameServer()->GetGameTime() > m_flConstructionTurnTime + build_time_construct.GetFloat())
		ConstructionTurn();

	if (IsUnderConstruction())
	{
		if (CanAutoOpenMenu())
		{
			// If the player is nearby, looking at me, and not already looking at another command menu, open a temp command menu showing construction info.
			CCommandMenu* pMenu = GameData().CreateCommandMenu(GetOwner()->GetPlayerCharacter());
			SetupMenuButtons();
		}
		else if (CanAutoCloseMenu())
		{
			// If the player goes away or stops looking, close it.
			GameData().CloseCommandMenu();
		}

		if (GameData().GetCommandMenu())
			GameData().GetCommandMenu()->Think();
	}
	else if (TakesPower() && GetOwner() && GetOwner()->GetPlayerCharacter() && GetOwner()->GetPlayerCharacter()->IsHoldingPowerCord())
	{
		if (CanAutoOpenMenu())
		{
			// If the player is nearby, looking at me, and not already looking at another command menu, open a temp command menu showing construction info.
			CCommandMenu* pMenu = GameData().CreateCommandMenu(GetOwner()->GetPlayerCharacter());
			SetupMenuButtons();
		}
		else if (CanAutoCloseMenu())
		{
			// If the player goes away or stops looking, close it.
			GameData().CloseCommandMenu();
		}

		if (GameData().GetCommandMenu())
			GameData().GetCommandMenu()->Think();
	}
}
Esempio n. 24
0
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();
}
Esempio n. 25
0
void SCR_SizeDown_f(void) {
	//JHL:HACK; changed to affect the HUD, not SCR size
	if (hud.getInt() > 0) {
		hud.set(hud.getFloat() - 1);
		vid.recalc_refdef = 1;
	}
	//qmb :hud
	//Cvar_SetValue ("viewsize",scr_viewsize.value-10);
	//vid.recalc_refdef = 1;
}
Esempio n. 26
0
void MainApp::onNeedCvar(UserCore::Misc::CVar_s& info)
{
	if (info.name)
	{
		CVar* c = GetCVarManager()->findCVar(info.name);

		if (c)
			info.value = c->getString();
	}
}
Esempio n. 27
0
void LoginForm::onMove(wxMoveEvent  &event)
{
	if (m_bSavePos)
	{
		gc_login_x.setValue(GetPosition().x);
		gc_login_y.setValue(GetPosition().y);
	}

	event.Skip();
}
Esempio n. 28
0
void CVarManager::saveToDb(sqlite3x::sqlite3_command &cmd, uint8 flags)
{
	for (uint32 x=0; x<getCount(); x++)
	{
		CVar* cvarNode = getItem(x);

		if (cvarNode->getFlags() & CFLAG_NOSAVE)
			continue;

		//dont save if user = true and usercvar = false || user = false and usercvar = true
		if ((flags & CFLAG_USER) ^ (cvarNode->getFlags() & CFLAG_USER))
			continue;

		if ((flags & CFLAG_WINUSER) ^ (cvarNode->getFlags() & CFLAG_WINUSER))
			continue;

		//dont save if setting hasnt changed
		if (!cvarNode->getExitString() || (strcmp(cvarNode->getExitString(), cvarNode->getDefault())) == 0)
			continue;

		cmd.bind(1, std::string(cvarNode->getName()));
		cmd.bind(2, std::string(cvarNode->getExitString()));
		cmd.executenonquery();
	}
}
Esempio n. 29
0
// this function does not free head.
void FreeArray(CVar* head)
{
	 CVar* var = head->GetTail();
	 CVar* prev_var;
	 while(!var->isHead())
	 {
		 prev_var = var->prev;
		 delete var;
		 var = prev_var;
	 }
}
Esempio n. 30
0
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()));
}