コード例 #1
0
ファイル: Input.cpp プロジェクト: mpreisler/ember
void Input::runCommand(const std::string &command, const std::string &args)
{
	if (command == BINDCOMMAND) {
		Tokeniser tokeniser;
		tokeniser.initTokens(args);
		std::string state("general");
		std::string key = tokeniser.nextToken();
		if (key != "") {
			std::string command(tokeniser.nextToken());
			if (command != "") {
				if (tokeniser.nextToken() != "") {
					state = tokeniser.nextToken();
				}
				InputCommandMapperStore::iterator I = mInputCommandMappers.find(state);
				if (I != mInputCommandMappers.end()) {
					I->second->bindCommand(key, command);
				}
			}
		}
	} else if (command == UNBINDCOMMAND) {
		Tokeniser tokeniser;
		tokeniser.initTokens(args);
		std::string state("general");
		std::string key(tokeniser.nextToken());
		if (key != "") {
			if (tokeniser.nextToken() != "") {
				state = tokeniser.nextToken();
			}
			InputCommandMapperStore::iterator I = mInputCommandMappers.find(state);
			if (I != mInputCommandMappers.end()) {
				I->second->unbindCommand(key);
			}
		}
	}
}
コード例 #2
0
  void
  AccountAvailableState::runCommand(const std::string &command,
      const std::string &args)
  {
    if (CreateAcc == command)
      {

        Tokeniser tokeniser = Tokeniser();
        tokeniser.initTokens(args);
        std::string uname = tokeniser.nextToken();
        std::string password = tokeniser.nextToken();
        std::string realname = tokeniser.remainingTokens();

        std::string msg;
        msg = "Creating account: Name: [" + uname + "], Password: [" + password
            + "], Real Name: [" + realname + "]";

        try
          {
            mAccount.createAccount(uname, realname, password);
          }
        catch (const std::exception& except)
          {
            S_LOG_WARNING("Got error on account creation." << except);
            return;
          }
        catch (...)
          {
            S_LOG_WARNING("Got unknown error on account creation.");
            return;
          }

      }
    else if (Login == command)
      {

        // Split string into userid / password pair
        Tokeniser tokeniser = Tokeniser();
        tokeniser.initTokens(args);
        std::string userid = tokeniser.nextToken();
        std::string password = tokeniser.remainingTokens();

        mAccount.login(userid, password);

        std::string msg;
        msg = "Login: [" + userid + "," + password + "]";
        ConsoleBackend::getSingleton().pushMessage(msg, "info");
      }
  }
コード例 #3
0
ファイル: LoggedInState.cpp プロジェクト: Chimangoo/ember
void LoggedInState::runCommand(const std::string &command, const std::string &args)
{
	if (Logout == command) {
		ConsoleBackend::getSingleton().pushMessage("Logging out...", "important");
		mAccount.logout();

		// Create Character command
	} else if (CreateChar == command) {
		// Split string into name/type/sex/description
		Tokeniser tokeniser = Tokeniser();
		tokeniser.initTokens(args);
		std::string name = tokeniser.nextToken();
		std::string sex = tokeniser.nextToken();
		std::string type = tokeniser.nextToken();
		std::string spawnPoint = tokeniser.nextToken();
		std::string description = tokeniser.remainingTokens();

		createCharacter(name, sex, type, description, spawnPoint, Atlas::Message::MapType());

		// Take Character Command
	} else if (TakeChar == command) {

		takeCharacter(args);

		// List Characters Command
	} else if (ListChars == command) {

		mAccount.refreshCharacterInfo();

		// Say (In-Game chat) Command
	}
}
コード例 #4
0
ファイル: ConfigService.cpp プロジェクト: LawrenceWeng/ember
	void ConfigService::runCommand ( const std::string &command, const std::string &args )
	{
		if ( command == SETVALUE )
		{
			Tokeniser tokeniser;
			tokeniser.initTokens ( args );
			std::string section ( tokeniser.nextToken() );
			std::string key ( tokeniser.nextToken() );
			std::string value ( tokeniser.remainingTokens() );

			if ( section == "" || key == "" || value == "" )
			{
				ConsoleBackend::getSingleton().pushMessage ( "Usage: set_value <section> <key> <value>", "help" );
			}
			else
			{
				setValue ( section, key, value );
				ConsoleBackend::getSingleton().pushMessage ( "New value set, section: " +  section + " key: " + key + " value: " + value, "info" );
			}

		}
		else if ( command == GETVALUE )
		{
			Tokeniser tokeniser;
			tokeniser.initTokens ( args );
			std::string section ( tokeniser.nextToken() );
			std::string key ( tokeniser.nextToken() );

			if ( section == "" || key == "" )
			{
				ConsoleBackend::getSingleton().pushMessage ( "Usage: get_value <section> <key>", "help" );
			}
			else
			{
				if ( !hasItem ( section, key ) )
				{
					ConsoleBackend::getSingleton().pushMessage ( "No such value.", "error" );
				}
				else
				{
					varconf::Variable value = getValue ( section, key );
					ConsoleBackend::getSingleton().pushMessage ( std::string ( "Value: " ) + static_cast<std::string> ( value ), "info" );
				}
			}
		}
	}
コード例 #5
0
void ShaderManager::runCommand(const std::string &command, const std::string &args)
{
  if (SetLevel == command) {
    Tokeniser tokeniser;
    tokeniser.initTokens(args);
    std::string levelString = tokeniser.nextToken();
    EmberServices::getSingleton().getConfigService().setValue("graphics", "level", levelString);
  }
}
コード例 #6
0
void ThirdPersonCameraMount::runCommand(const std::string& command, const std::string& args) {
	if (SetCameraDistance == command) {
		Tokeniser tokeniser;
		tokeniser.initTokens(args);
		std::string distance = tokeniser.nextToken();
		if (!distance.empty()) {
			float fDistance = Ogre::StringConverter::parseReal(distance);
			setCameraDistance(fDistance);
		}
	}
}
コード例 #7
0
ファイル: EmberEntityFactory.cpp プロジェクト: Arsakes/ember
void EmberEntityFactory::runCommand(const std::string &command, const std::string &args)
{
	if (command == ShowModels.getCommand()) {
		Tokeniser tokeniser;
		tokeniser.initTokens(args);
		std::string value = tokeniser.nextToken();
		if (value == "true") {
			S_LOG_INFO("Showing models.");
			Model::ModelDefinitionManager::getSingleton().setShowModels(true);
		} else if (value == "false") {
			S_LOG_INFO("Hiding models.");
			Model::ModelDefinitionManager::getSingleton().setShowModels(false);
		}
	} else if (DumpAttributes == command) {
		Tokeniser tokeniser;
		tokeniser.initTokens(args);
		std::string value = tokeniser.nextToken();
		if (value == "") {
			dumpAttributesOfEntity(value);
		}
	}
}
コード例 #8
0
void CaelumEnvironment::runCommand(const std::string &command, const std::string &args)
{
	if (SetCaelumTime == command) {
		Tokeniser tokeniser;
		tokeniser.initTokens(args);
		std::string hourString = tokeniser.nextToken();
		std::string minuteString = tokeniser.nextToken();

		int hour = ::Ogre::StringConverter::parseInt(hourString);
		int minute = ::Ogre::StringConverter::parseInt(minuteString);
		setTime(hour, minute);
	}
}
コード例 #9
0
ファイル: EntityMoveManager.cpp プロジェクト: Chimangoo/ember
void EntityMoveManager::runCommand(const std::string &command, const std::string &args)
{
	if (Move == command) {
		//the first argument must be a valid entity id
		Tokeniser tokeniser;
		tokeniser.initTokens(args);
		std::string entityId = tokeniser.nextToken();
		if (entityId != "") {
			EmberEntity* entity = mWorld.getEmberEntity(entityId);
			if (entity != 0) {
				startMove(*entity);
			}
		} else {
			ConsoleBackend::getSingletonPtr()->pushMessage("You must specify a valid entity id to move.", "error");
		}

	}
}
コード例 #10
0
void NonConnectedState::runCommand(const std::string &command, const std::string &args)
{
	// Connect command
	if (Connect == command) {
		// Split string into server / port pair
		Tokeniser tokeniser = Tokeniser();
		tokeniser.initTokens(args);
		std::string server = tokeniser.nextToken();
		std::string port = tokeniser.remainingTokens();
		std::string msg;
		msg = "Connecting to: [" + server + "]";
		ConsoleBackend::getSingleton().pushMessage(msg, "info");
		if (port == "")
			connect(server);
		else
			connect(server, (short)atoi(port.c_str()));

		// Disonnect command
	}
}
コード例 #11
0
void InspectWidget::runCommand(const std::string &command, const std::string &args)
{
	if(Inspect == command && EmberOgre::getSingleton().getWorld())
	{
		//the first argument must be a valid entity id
		Tokeniser tokeniser;
		tokeniser.initTokens(args);
		std::string entityId = tokeniser.nextToken();
		if (entityId != "") {
			EmberEntity* entity = EmberOgre::getSingleton().getWorld()->getEmberEntity(entityId);
			if (entity != 0) {
				startInspecting(entity);
			}
		} else {
			ConsoleBackend::getSingletonPtr()->pushMessage("You must specifify a valid entity id to inspect.", "error");
		}

	} else {
		Widget::runCommand(command, args);
	}

}
      void
      MaterialEditor::runCommand(const std::string &command,
          const std::string &args)
      {

        if (AlterMaterial == command)
          {
            try
              {
                Tokeniser tokeniser;
                tokeniser.initTokens(args);

                std::vector<std::string> tokens;
                std::string token;
                while ((token = tokeniser.nextToken()) != "")
                  {
                    tokens.push_back(token);
                  }

                std::string materialName = tokens[0];

                Ogre::MaterialPtr materialPtr =
                    static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName(
                        materialName));
                if (!materialPtr.isNull())
                  {
                    std::string techniqueIndexString = tokens[1];
                    if (techniqueIndexString != "")
                      {
                        int techniqueIndex = Ogre::StringConverter::parseInt(
                            techniqueIndexString);
                        Ogre::Technique* technique = materialPtr->getTechnique(
                            techniqueIndex);
                        if (technique)
                          {
                            std::string passIndexString = tokens[2];
                            if (passIndexString != "")
                              {
                                int passIndex = Ogre::StringConverter::parseInt(
                                    passIndexString);
                                Ogre::Pass* pass = technique->getPass(
                                    passIndex);
                                //is texture unit specified
                                if (tokens.size() == 6)
                                  {
                                    std::string textureUnitIndexString =
                                        tokens[3];
                                    std::string property = tokens[4];
                                    std::string value = tokens[5];

                                    int textureUnitIndex =
                                        Ogre::StringConverter::parseInt(
                                            textureUnitIndexString);

                                    Ogre::TextureUnitState* textureUnit =
                                        pass->getTextureUnitState(
                                            textureUnitIndex);
                                    if (textureUnit)
                                      {

                                      }
                                  }
                                else
                                  {
                                    std::string property = tokens[3];
                                    std::string value = tokens[4];
                                    if (property == "alpha_rejection")
                                      {
                                        pass->setAlphaRejectValue(
                                            Ogre::StringConverter::parseInt(
                                                value));
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
            catch (const std::exception& ex)
              {
                S_LOG_WARNING("Error when altering material." << ex);
              }
            catch (...)
              {
                S_LOG_WARNING("Error when altering material.");
              }
          }
      }