Exemple #1
0
		bool OgitorWorld::LoadGlobalObject(const String_t &type, const Register::Table &dict)
		{
			if((type.compare("Caelum Object") == 0) ||
			   (type.compare("Viewport Object") == 0))
			{
				return true;
			}
			else if(type.compare("OctreeSceneManager") == 0)
			{
				auto &render = OgreEngine::Render::GetInstance();
				render.SetAmbientColor(Register::GetColour(dict, "ambient"));

				return true;
			}
			else if(type.compare("Terrain Group Object") == 0)
			{
				m_pclTerrainGroupTable = &dict;

				return true;
			}
			else if(type.compare("Terrain Page Object") == 0)
			{
				m_pclTerrainPageTable = &dict;

				return true;
			}

			return false;
		}
Exemple #2
0
		bool OgitorWorld::LoadStaticObject(StaticObject_s &object, const String_t &name, const String_t &type, const Register::Table &dict)
		{
			TempStaticObject_s temp;

			temp.m_fParent = dict.TryGetString(PH_ENTITY_KEY_PARENT_NODE, object.strParent) && (object.strParent.compare(PH_WORLD_SCENE_MANAGER_NAME) != 0);
			temp.m_strName = name;

			if(type.compare("Node Object") == 0)
			{
				this->LoadNodeObject(temp, dict);
			}
			else if(type.compare("Light Object") == 0)
			{
				this->LoadLightObject(temp, dict);
			}
			else if(type.compare("Entity Object") == 0)
			{
				this->LoadEntityObject(temp, dict);
			}
			else
			{
				LogMakeStream() << "[OgitorWorld::LoadStaticObject] Error, unknown static object type: " << type << "\n";
				return false;
			}

			temp.Commit(object);

			//Check if we have a directional light after commit, to avoid dangling pointers
			if((object.m_pclLight != NULL) && (object.m_pclLight->getType() == Ogre::Light::LT_DIRECTIONAL))
				m_pclTerrainLight = object.m_pclLight;

			return true;
		}
bool Phobos::System::KeyboardInputDevice::TryGetActionId(const String_t &name, UInt_t &out) const
{	
	if(name.length() == 1)
	{
		Char_t ch = name[0];

		if(IS_ASCII_CHAR(ch))
		{
			out = static_cast<UInt_t>(ch);
			return true;
		}
		else
			return false;
	}
	else
	{
		UInt_t i = 0;
		for(;stInputKeyNames_g[i].pstrzName != NULL; ++i)
		{				
			if(name.compare(stInputKeyNames_g[i].pstrzName) == 0)
			{
				out = stInputKeyNames_g[i].uKey;
				return true;
			}
		}

		return false;
	}
}
Exemple #4
0
void Phobos::Register::Table::SetString(const String_t &key, const String_t &value)
{	
	CheckForKeyword(key);

	m_mapValues[key] = Value_s(value);

	if(key.compare(INHERIT_KEY) == 0)
	{			
		m_strInherit = value;
		m_pclInherit = NULL;
	}
	if(key.compare(BASE_HIVE_KEY) == 0)
	{			
		m_strBaseHive = value;
		m_pclInherit = NULL;
	}
}
Exemple #5
0
void Phobos::Register::Table::CheckInvalidKey(const String_t &key, const char *keys[], const char *message) const
{
	for(int i = 0;keys[i]; ++i)
	{
		if(key.compare(keys[i]) == 0)
		{
			std::stringstream stream;
			stream << "Value " << key << " " << message;
			PH_RAISE(INVALID_PARAMETER_EXCEPTION, "Phobos::Register::Table::CheckInvalidKey", stream.str());
		}
	}
}
Exemple #6
0
void Phobos::Register::Table::Load(Parser &parser)
{
	String_t idName;
	String_t value;

	ParserTokens_e token = parser.GetToken(&value);

	if(token != TOKEN_OPEN_BRACE)
		RaiseParseException(parser, TOKEN_OPEN_BRACE, token, value, "Phobos::Register::Table::Load");

	for(;;)
	{
		token = parser.GetToken(&value);
		if(token == TOKEN_CLOSE_BRACE)
			break;

		idName.clear();
		//Accepts name in the format:
		//model=
		//RenderCompoenent.model=
		for(;;)
		{
			if(token != TOKEN_ID)
				RaiseParseException(parser, TOKEN_ID, token, value, "Phobos::Register::Table::Load");

			idName.append(value);
			token = parser.GetToken(&value);
			if(token == TOKEN_DOT)
			{
				idName.append(value);
				token = parser.GetToken(&value);
				continue;
			}

			if(token == TOKEN_EQUAL)
				break;

			RaiseParseException(parser, TOKEN_EQUAL, token, value, "Phobos::Register::Table::Load");
		}

		token = parser.GetToken(&value);
		switch(token)
		{
			case TOKEN_ID:
				if(value.compare("new") == 0)
				{
					this->ParseSpecialValue(idName, parser);
					break;
				}
				//not special, just store it
				//fall thought

			case TOKEN_NUMBER:
			case TOKEN_STRING:
				this->SetString(idName, value);
				break;

			default:
				RaiseParseException(parser, TOKEN_STRING, token, idName, "Phobos::Register::Table::Load");
				break;
		}

		token = parser.GetToken(&value);
		if(token != TOKEN_SEMI_COLON)
			RaiseParseException(parser, TOKEN_SEMI_COLON, token, value, "Phobos::Register::Table::Load");
	}
}
Exemple #7
0
void Phobos::Register::Table::ParseSpecialValue(const String_t &idName, Parser &parser)
{
	String_t type;

	ParserTokens_e token;
	if((token = parser.GetToken(&type)) != TOKEN_ID)
	{
		RaiseParseException(parser, TOKEN_ID, token, type, "Phobos::Register::Table::ParseSpecialValue");
	}

	if(type.compare("CharMatrix") == 0)
	{
		if((token = parser.GetToken(NULL)) != TOKEN_OPEN_PAREN)
		{
			RaiseParseException(parser, TOKEN_OPEN_PAREN, token, type, "Phobos::Register::Table::ParseSpecialValue");
		}

		String_t matrix;
		String_t row;

		UInt16_t numColumns = 0;
		UInt16_t numRows = 0;

		bool first = true;
		for(;;)
		{
			token = parser.GetToken(&row);
			if(token == TOKEN_CLOSE_PAREN)
			{
				if(first)
				{
					//do not allow empty matrix
					RaiseParseException(parser, "matrix data", "closing parenthesis", "Phobos::Register::Table::ParseSpecialValue");
				}
					
				this->SetCharMatrix(idName, matrix, numRows, numColumns);
				break;
			}
			else if(token == TOKEN_STRING)
			{
				if(first)
				{
					numColumns = row.length();

					if(numColumns == 0)
						PH_RAISE(PARSER_EXCEPTION, "Phobos::Register::Table::ParseSpecialValue", "Matrix cannot be empty");

					first = false;
				}
				else if(numColumns != row.length())
				{
					PH_RAISE(PARSER_EXCEPTION, "Phobos::Register::Table::ParseSpecialValue", "Matrix rows should always have the same length");
				}

				matrix.append(row);
				++numRows;
			}
			else
			{
				RaiseParseException(parser, TOKEN_STRING, token, row, "Phobos::Register::Table::ParseSpecialValue");
			}
		}
	}	
	else
	{
		RaiseParseException(parser, " valid especial type, ie CharMatrix", type.c_str(), "Phobos::Register::Table::ParseSpecialValue");
	}
}