Exemple #1
0
void FGameConfigFile::SetRavenDefaults (bool isHexen)
{
	UCVarValue val;

	val.Bool = false;
	wi_percents.SetGenericRepDefault (val, CVAR_Bool);
	val.Bool = true;
	con_centernotify.SetGenericRepDefault (val, CVAR_Bool);
	snd_pitched.SetGenericRepDefault (val, CVAR_Bool);
	val.Int = 9;
	msg0color.SetGenericRepDefault (val, CVAR_Int);
	val.Int = CR_WHITE;
	msgmidcolor.SetGenericRepDefault (val, CVAR_Int);
	val.Int = CR_YELLOW;
	msgmidcolor2.SetGenericRepDefault (val, CVAR_Int);

	val.Int = 0x543b17;
	am_wallcolor.SetGenericRepDefault (val, CVAR_Int);
	val.Int = 0xd0b085;
	am_fdwallcolor.SetGenericRepDefault (val, CVAR_Int);
	val.Int = 0x734323;
	am_cdwallcolor.SetGenericRepDefault (val, CVAR_Int);

	// Fix the Heretic/Hexen automap colors so they are correct.
	// (They were wrong on older versions.)
	if (*am_wallcolor == 0x2c1808 && *am_fdwallcolor == 0x887058 && *am_cdwallcolor == 0x4c3820)
	{
		am_wallcolor.ResetToDefault ();
		am_fdwallcolor.ResetToDefault ();
		am_cdwallcolor.ResetToDefault ();
	}

	if (!isHexen)
	{
		val.Int = 0x3f6040;
		color.SetGenericRepDefault (val, CVAR_Int);
	}
}
Exemple #2
0
        void Choice::MoveChoice(const int I_Way, const unsigned int UI_Increment)
        {
            const int i_Increment = I_Way * (int) ((UI_Increment == 0) ? 1 : UI_Increment);
            const int i_Choice = GetChoice();

            if (i_Choice < 0)
            {
                // Undefined choice: restore default.
                GetShell().Beep();
                ResetToDefault();
            }
            else if (i_Choice + i_Increment < 0)
            {
                // Top of choice list.
                // Possibly beep.
                if (i_Choice <= 0)
                {
                    GetShell().Beep();
                }
                // Reprint.
                Line::SetLine(Choice2Str(0, m_tkChoices).GetString(m_eLang), false, true);
            }
            else if (i_Choice + i_Increment >= (int) m_tkChoices.GetCount())
            {
                // Bottom of choice list.
                // Possibly beep.
                if (i_Choice >= ((int) m_tkChoices.GetCount()) - 1)
                {
                    GetShell().Beep();
                }
                // Reprint.
                Line::SetLine(Choice2Str(m_tkChoices.GetCount() - 1, m_tkChoices).GetString(m_eLang), false, true);
            }
            else
            {
                // Move to next element.
                Line::SetLine(Choice2Str(GetChoice() + i_Increment, m_tkChoices).GetString(m_eLang), false, true);
            }
        }
void FFMODStudioStyle::Shutdown()
{
	ResetToDefault();
	ensure(StyleInstance.IsUnique());
	StyleInstance.Reset();
}
void PlayerAI::LoadBindings()
{
	TiXmlDocument doc("Controls.xml");
	bool xml_error = false;
	if(doc.LoadFile())
	{
		TiXmlElement* root = doc.FirstChildElement("Controls");
		if(root)
		{
			TiXmlElement* player = root->FirstChildElement("PlayerBindings");
			while(player)
			{
				int player_id = 0;
				if(player->QueryIntAttribute("id", &player_id) == TIXML_SUCCESS)
				{
					TiXmlElement* ic = player->FirstChildElement("InputConfig");
					while(ic)
					{
						std::string action_string;
						if(ic->QueryValueAttribute("Action", &action_string) != TIXML_SUCCESS)
						{
							Logger::ErrorOut() << "Error reading action attribute, continuing\n";
							continue;
						}
						std::string binding_type_string;
						if(ic->QueryValueAttribute("BindingType", &binding_type_string) != TIXML_SUCCESS)
						{
							Logger::ErrorOut() << "Error reading binding attribute, continuing\n";
							continue;
						}
						
						Action::Enum action = Action::FromStr(action_string);
						BindingType::Enum binding_type = BindingType::FromStr(binding_type_string);
						TiXmlElement* binding = ic->FirstChildElement("Binding");
						if(binding)
						{
							switch(binding_type)
							{
								case BindingType::KeyboardBinding:
									{
										int key = 0;
										if(binding->QueryValueAttribute("Key", &key) == TIXML_SUCCESS)
										{
											bindings[player_id].push_back(InputConfig(binding_type, Binding((SDLKey)key), action));
										} else
										{
											Logger::ErrorOut() << "Missing Key attribute, continuing\n";
											continue;
										}
									}
									break;
								case BindingType::JoystickButtonBinding:
									{
										int joystick_index = 0;
										int joystick_button_index = 0;
										if(binding->QueryValueAttribute("JoystickIndex", &joystick_index) == TIXML_SUCCESS && 
										   binding->QueryValueAttribute("JoystickButton", &joystick_button_index) == TIXML_SUCCESS)
										{
											bindings[player_id].push_back(InputConfig(binding_type, Binding(JoystickButton::Create(joystick_index, joystick_button_index)), action));
										} else
										{
											Logger::ErrorOut() << "Missing JoystickIndex or JoystickButton atttribute, continuing\n";
										}
									}
									break;
								case BindingType::JoystickAxisBinding:
									{
										int joystick_index = 0;
										int joystick_axis_index = 0;
										if(binding->QueryValueAttribute("JoystickIndex", &joystick_index) == TIXML_SUCCESS && 
										   binding->QueryValueAttribute("JoystickAxis", &joystick_axis_index) == TIXML_SUCCESS)
										{
											bindings[player_id].push_back(InputConfig(binding_type, Binding(JoystickAxis::Create(joystick_index, joystick_axis_index)), action));
										} else
										{
											Logger::ErrorOut() << "Missing JoystickIndex or JoystickAxis atttribute, continuing\n";
										}
									}
									break;
								case BindingType::MouseAxisBinding:
									{
										std::string axis;
										if(binding->QueryValueAttribute("MouseAxis", &axis) == TIXML_SUCCESS)
										{
											MouseAxis::Enum mouse_axis = MouseAxis::FromStr(axis);
											if(mouse_axis != MouseAxis::InvalidFirst && mouse_axis != MouseAxis::InvalidLast)
											{
												bindings[player_id].push_back(InputConfig(binding_type, Binding(mouse_axis), action));
											} else
											{
												Logger::ErrorOut() << "MouseAxis attribute incorrect: " << axis << "\n";
											}
										} else
										{
											Logger::ErrorOut() << "Missing MouseAxis attribute\n";
										}
									}
									break;
								case BindingType::MouseButtonBinding:
									{
										std::string button;
										if(binding->QueryValueAttribute("MouseButton", &button) == TIXML_SUCCESS)
										{
											MouseButton::Enum mouse_button = MouseButton::FromStr(button);
											if(mouse_button != MouseButton::InvalidFirst && mouse_button != MouseButton::InvalidLast)
											{
												bindings[player_id].push_back(InputConfig(binding_type, Binding(mouse_button), action));
											} else
											{
												Logger::ErrorOut() << "Missing MouseAxis attribute\n";
											}

										} else
										{
											Logger::ErrorOut() << "Missing MouseButton attribute\n";
										}
									}
									break;

							}
						} else 
						{
							xml_error = true;
							Logger::ErrorOut() << "Missing Binding element\n";
						}

						
						ic = ic->NextSiblingElement("InputConfig");
					}
					
				} else xml_error = true;
				player = player->NextSiblingElement("PlayerBindings");
			}
		} else xml_error = true;
	} else xml_error = true;
	if(xml_error)
	{
		ResetToDefault();
	}
}
Exemple #5
0
void FGameConfigFile::DoGlobalSetup ()
{
	if (SetSection ("GlobalSettings.Unknown"))
	{
		ReadCVars (CVAR_GLOBALCONFIG);
	}
	if (SetSection ("GlobalSettings"))
	{
		ReadCVars (CVAR_GLOBALCONFIG);
	}
	if (SetSection ("LastRun"))
	{
		const char *lastver = GetValueForKey ("Version");
		if (lastver != NULL)
		{
			double last = atof (lastver);
			if (last < 123.1)
			{
				FBaseCVar *noblitter = FindCVar ("vid_noblitter", NULL);
				if (noblitter != NULL)
				{
					noblitter->ResetToDefault ();
				}
			}
			if (last < 202)
			{
				// Make sure the Hexen hotkeys are accessible by default.
				if (SetSection ("Hexen.Bindings"))
				{
					SetValueForKey ("\\", "use ArtiHealth");
					SetValueForKey ("scroll", "+showscores");
					SetValueForKey ("0", "useflechette");
					SetValueForKey ("9", "use ArtiBlastRadius");
					SetValueForKey ("8", "use ArtiTeleport");
					SetValueForKey ("7", "use ArtiTeleportOther");
					SetValueForKey ("6", "use ArtiPork");
					SetValueForKey ("5", "use ArtiInvulnerability2");
				}
			}
			if (last < 204)
			{ // The old default for vsync was true, but with an unlimited framerate
			  // now, false is a better default.
				FBaseCVar *vsync = FindCVar ("vid_vsync", NULL);
				if (vsync != NULL)
				{
					vsync->ResetToDefault ();
				}
			}
			if (last < 206)
			{ // spc_amp is now a float, not an int.
				if (spc_amp > 16)
				{
					spc_amp = spc_amp / 16.f;
				}
			}
			if (last < 207)
			{ // Now that snd_midiprecache works again, you probably don't want it on.
				FBaseCVar *precache = FindCVar ("snd_midiprecache", NULL);
				if (precache != NULL)
				{
					precache->ResetToDefault();
				}
			}
			if (last < 208)
			{ // Weapon sections are no longer used, so tidy up the config by deleting them.
				const char *name;
				size_t namelen;
				bool more;

				more = SetFirstSection();
				while (more)
				{
					name = GetCurrentSection();
					if (name != NULL && 
						(namelen = strlen(name)) > 12 &&
						strcmp(name + namelen - 12, ".WeaponSlots") == 0)
					{
						more = DeleteCurrentSection();
					}
					else
					{
						more = SetNextSection();
					}
				}
			}
			if (last < 209)
			{
				// menu dimming is now a gameinfo option so switch user override off
				FBaseCVar *dim = FindCVar ("dimamount", NULL);
				if (dim != NULL)
				{
					dim->ResetToDefault ();
				}
			}
			if (last < 210)
			{
				if (SetSection ("Hexen.Bindings"))
				{
					// These 2 were misnamed in earlier versions
					SetValueForKey ("6", "use ArtiPork");
					SetValueForKey ("5", "use ArtiInvulnerability2");
				}
			}
			if (last < 213)
			{
				auto var = FindCVar("snd_channels", NULL);
				if (var != NULL)
				{
					// old settings were default 32, minimum 8, new settings are default 128, minimum 64.
					UCVarValue v = var->GetGenericRep(CVAR_Int);
					if (v.Int < 64) var->ResetToDefault();
				}
			}
			if (last < 214)
			{
				FBaseCVar *var = FindCVar("hud_scale", NULL);
				if (var != NULL) var->ResetToDefault();
				var = FindCVar("st_scale", NULL);
				if (var != NULL) var->ResetToDefault();
				var = FindCVar("hud_althudscale", NULL);
				if (var != NULL) var->ResetToDefault();
				var = FindCVar("con_scale", NULL);
				if (var != NULL) var->ResetToDefault();
				var = FindCVar("con_scaletext", NULL);
				if (var != NULL) var->ResetToDefault();
				var = FindCVar("uiscale", NULL);
				if (var != NULL) var->ResetToDefault();
			}
			if (last < 215)
			{
				// Previously a true/false boolean. Now an on/off/auto tri-state with auto as the default.
				FBaseCVar *var = FindCVar("snd_hrtf", NULL);
				if (var != NULL) var->ResetToDefault();
			}
			if (last < 216)
			{
				FBaseCVar *var = FindCVar("gl_texture_hqresize", NULL);
				if (var != NULL)
				{
					auto v = var->GetGenericRep(CVAR_Int);
					switch (v.Int)
					{
					case 1:
						gl_texture_hqresizemode = 1; gl_texture_hqresizemult = 2;
						break;
					case 2:
						gl_texture_hqresizemode = 1; gl_texture_hqresizemult = 3;
						break;
					case 3:
						gl_texture_hqresizemode = 1; gl_texture_hqresizemult = 4;
						break;
					case 4:
						gl_texture_hqresizemode = 2; gl_texture_hqresizemult = 2;
						break;
					case 5:
						gl_texture_hqresizemode = 2; gl_texture_hqresizemult = 3;
						break;
					case 6:
						gl_texture_hqresizemode = 2; gl_texture_hqresizemult = 4;
						break;
					case 7:
						gl_texture_hqresizemode = 3; gl_texture_hqresizemult = 2;
						break;
					case 8:
						gl_texture_hqresizemode = 3; gl_texture_hqresizemult = 3;
						break;
					case 9:
						gl_texture_hqresizemode = 3; gl_texture_hqresizemult = 4;
						break;
					case 10:
						gl_texture_hqresizemode = 4; gl_texture_hqresizemult = 2;
						break;
					case 11:
						gl_texture_hqresizemode = 4; gl_texture_hqresizemult = 3;
						break;
					case 12:
						gl_texture_hqresizemode = 4; gl_texture_hqresizemult = 4;
						break;
					case 18:
						gl_texture_hqresizemode = 4; gl_texture_hqresizemult = 5;
						break;
					case 19:
						gl_texture_hqresizemode = 4; gl_texture_hqresizemult = 6;
						break;
					case 13:
						gl_texture_hqresizemode = 5; gl_texture_hqresizemult = 2;
						break;
					case 14:
						gl_texture_hqresizemode = 5; gl_texture_hqresizemult = 3;
						break;
					case 15:
						gl_texture_hqresizemode = 5; gl_texture_hqresizemult = 4;
						break;
					case 16:
						gl_texture_hqresizemode = 5; gl_texture_hqresizemult = 5;
						break;
					case 17:
						gl_texture_hqresizemode = 5; gl_texture_hqresizemult = 6;
						break;
					case 20:
						gl_texture_hqresizemode = 6; gl_texture_hqresizemult = 2;
						break;
					case 21:
						gl_texture_hqresizemode = 6; gl_texture_hqresizemult = 3;
						break;
					case 22:
						gl_texture_hqresizemode = 6; gl_texture_hqresizemult = 4;
						break;
					case 23:
						gl_texture_hqresizemode = 6; gl_texture_hqresizemult = 5;
						break;
					case 24:
						gl_texture_hqresizemode = 6; gl_texture_hqresizemult = 6;
						break;
					case 0:
					default:
						gl_texture_hqresizemode = 0; gl_texture_hqresizemult = 1;
						break;
					}
				}
			}
			if (last < 217)
			{
				auto var = FindCVar("vid_scalemode", NULL);
				UCVarValue newvalue;
				newvalue.Int = 2;
				if (var != NULL)
				{
					UCVarValue v = var->GetGenericRep(CVAR_Int);
					if (v.Int == 3) var->SetGenericRep(newvalue, CVAR_Int);
				}
			}
		}
	}
}