Exemplo n.º 1
0
void CLanguages::LoadStringTable()
{
	//parse language xml and load strings to table

	//clear old table
	m_LanguageStringTable.clear();
	m_ObjectStringTable.clear();

	stringc file = m_Language->value + stringc("_strings.xml"); 
	IXMLReader* xml = m_FS->createXMLReader(file);

	if (xml)
	{
		//get language name and value from file
		while(xml->read())
		{
			switch(xml->getNodeType())
			{
			case io::EXN_ELEMENT:
				{
					if (stringw("string").equals_ignore_case(xml->getNodeName()))
					{
						TLanguageString lang;
						lang.id = xml->getAttributeValueAsInt(L"id");
						lang.value = xml->getAttributeValue(L"value");
						m_LanguageStringTable.push_back(lang);
					}
				}
			}
		}

		xml->drop(); // don't forget to delete the xml reader
	}

	file = m_Language->value + stringc("_go_strings.xml"); 
	xml = m_FS->createXMLReader(file);

	if (xml)
	{
		//get language name and value from file
		while(xml->read())
		{
			switch(xml->getNodeType())
			{
			case io::EXN_ELEMENT:
				{
					if (stringw("string").equals_ignore_case(xml->getNodeName()))
					{
						TLanguageString lang;
						lang.id = xml->getAttributeValueAsInt(L"id");
						lang.value = xml->getAttributeValue(L"value");
						m_ObjectStringTable.push_back(lang);
					}
				}
			}
		}

		xml->drop(); // don't forget to delete the xml reader
	}
}
Exemplo n.º 2
0
void CGameObject::LoadTrajectoryPaths(IXMLReader* xml, ISceneManager* smgr, list <CGameObject*> *listOfGameObjects)
{
	bool startStoringPathNodes = false;
	TPath t_path;

	while(xml->read())
	{
		switch(xml->getNodeType())
		{
		case io::EXN_ELEMENT:
			{
				if (stringw("Path").equals_ignore_case(xml->getNodeName()))
				{
					startStoringPathNodes = true;
					t_path.name = xml->getAttributeValue(L"name");
					stringw loopStrValue = xml->getAttributeValue(L"loop");
					if(loopStrValue.equals_ignore_case("true")) t_path.loop = true;
					else t_path.loop = false;
					t_path.nodes.clear();
				}
				if(startStoringPathNodes)
				{
					if(stringw("Coord").equals_ignore_case(xml->getNodeName()))
					{
						f32 n_pause = xml->getAttributeValueAsFloat(L"pause");
						f32 n_speed = xml->getAttributeValueAsFloat(L"speed");
						vector3df n_rotation = Util_getVectorFromString(xml->getAttributeValue(L"rotation"));
						vector3df n_position = Util_getVectorFromString(xml->getAttributeValue(L"position"));
						vector3df n_scale = Util_getVectorFromString(xml->getAttributeValue(L"scale"));
						s32 n_id = xml->getAttributeValueAsInt(L"id");
						
						CGameObject* pathNodeGO = CreateTrajectoryNodeGO(&t_path, n_position, n_rotation, n_scale, n_id, n_pause, n_speed, smgr);
						listOfGameObjects->push_back(pathNodeGO);

					}
				}
			}
			break;

			case io::EXN_ELEMENT_END:
			{
				if (stringw("Path").equals_ignore_case(xml->getNodeName()))
				{
					//Path loaded.
					m_ListOfTrajectoryPaths.push_back(t_path);
					startStoringPathNodes = false;
				}
			}
		}
	}
}
void CTournamentBase::fillTournamentList() {
  if (!m_bNetClient) {
    m_pTournaments->clear();
    IFileSystem *pFs=m_pDevice->getFileSystem();
    c8 sDir[0xFFF];
    strcpy(sDir,pFs->getWorkingDirectory().c_str());
    c8 sTournamentDir[0xFF];

    sprintf(sTournamentDir,"%s/data/tournaments",sDir);
    pFs->changeWorkingDirectoryTo(sTournamentDir);

    IFileList *pTournaments=pFs->createFileList();

    for (u32 i=0; i<pTournaments->getFileCount(); i++) {
      if (!pTournaments->isDirectory(i) && strstr(pTournaments->getFileName(i).c_str(),".trn")!=NULL) {
        c8 sName[0xFFF];
        strcpy(sName,pTournaments->getFileName(i).c_str());
        if (strstr(sName,".trn")) *strstr(sName,".trn")='\0';
        m_pTournaments->addItem(stringw(sName).c_str());
      }
    }

    pTournaments->drop();
    pFs->changeWorkingDirectoryTo(sDir);
  }
}
Exemplo n.º 4
0
/* 
 * If trajectory path has been edited, it should be saved to path file.
 * 
 */
void CGameObject::SaveTrajectoryPaths(IXMLWriter* writer)
{
	//IXMLWriter* writer = m_EditorManager->getDevice()->getFileSystem()->createXMLWriter(m_MapName.c_str());
	writer->writeXMLHeader(); writer->writeLineBreak();
	writer->writeLineBreak();

	for(u32 i=0; i < m_ListOfTrajectoryPaths.size(); i++)
	{
		//usualy there is only one path
		writer->writeElement(L"Path",false,L"name", m_ListOfTrajectoryPaths[i].name.c_str(), L"loop", m_ListOfTrajectoryPaths[i].loop?L"true":L"false"); writer->writeLineBreak();

		for (u32 j=0; j< m_ListOfTrajectoryPaths[i].nodes.size(); j++)
		{
			array<stringw> names;
			array<stringw> values;
			names.push_back(L"id");
			names.push_back(L"position");
			names.push_back(L"rotation");
			names.push_back(L"scale");
			names.push_back(L"speed");
			names.push_back(L"pause");
			values.push_back(stringw(m_ListOfTrajectoryPaths[i].nodes[j].sceneNode->getID()));
			values.push_back(Util_getStringFromVector(m_ListOfTrajectoryPaths[i].nodes[j].sceneNode->getPosition()));
			values.push_back(Util_getStringFromVector(m_ListOfTrajectoryPaths[i].nodes[j].sceneNode->getRotation()));
			values.push_back(Util_getStringFromVector(m_ListOfTrajectoryPaths[i].nodes[j].sceneNode->getScale()));
			values.push_back(stringw(m_ListOfTrajectoryPaths[i].nodes[j].speed));
			values.push_back(stringw(m_ListOfTrajectoryPaths[i].nodes[j].pause));

			//<Coord id="1030" speed="100" position="1 1 1" rotation="0 0 0" scale="1 1 1" pause="0"/>
			writer->writeElement(L"Coord", true, names, values); writer->writeLineBreak();
			
			/*writer->writeElement(L"Coord", true, L"id", stringw(m_ListOfTrajectoryPaths[i].nodes[j].id).c_str(), L"speed", stringw(m_ListOfTrajectoryPaths[i].nodes[j].speed).c_str(),
								 L"position", Util_getStringFromVector(m_ListOfTrajectoryPaths[i].nodes[j].position).c_str(), L"rotation", Util_getStringFromVector(m_ListOfTrajectoryPaths[i].nodes[j].rotation).c_str(),
								 L"scale", Util_getStringFromVector(m_ListOfTrajectoryPaths[i].nodes[j].scale).c_str(), L"pause", stringw(m_ListOfTrajectoryPaths[i].nodes[j].pause).c_str()); writer->writeLineBreak();*/
		}

		writer->writeClosingTag(L"Path"); writer->writeLineBreak();
		writer->writeLineBreak();
	}
	writer->drop();
}
Exemplo n.º 5
0
void fillTB(IGUIElement* sidebar,int parentId,int id,float value){
	IGUIElement* e = sidebar->getElementFromId(parentId)->getElementFromId(id);

	if (e){
		IGUIEditBox* b = static_cast<IGUIEditBox*>(e);

		if (!b)
			return;

		b->setText(stringw(value).c_str());
	}
}
Exemplo n.º 6
0
//----------------------------------------------------------------------------
void RoadPanel::updateRoadList()
{
    Track* t = Viewport::get()->getTrack();
    if (t)
    {
        IRoad* r;
        array<IRoad*>* road_list = t->getRoadList();
        m_cb->clear();

        for (u32 i = 0; i < road_list->size(); i++)
        {
            r = (*road_list)[i];
            stringw name = r->getName();
            m_cb->addItem(name.c_str(), i);
        }

        stringw s = stringw(road_list->size());
        m_text_field->setText((stringw("RoadMesh_") + s).c_str());
        m_cb->setSelected(road_list->size()-1);
    }
} // updateRoadList
void CTournamentBase::readConfig(IXMLReaderUTF8 *pXml) {
  if (!strcmp(pXml->getNodeName(),"data")) {
    if (m_pTournament!=NULL) delete m_pTournament;
    m_pTournament=new CTournamentInfo(stringw(pXml->getAttributeValue("name")).c_str());
  }

  if (!strcmp(pXml->getNodeName(),"players")) {
    m_iPlayerNo=atoi(pXml->getAttributeValue("number"));
  }

  if (!strcmp(pXml->getNodeName(),"replay")) {
    m_bRecordReplay=atoi(pXml->getAttributeValue("record"));
  }

  if (m_pTournament) {
    if (!strcmp(pXml->getNodeName(),"race")) {
      u32 iLaps=atoi(pXml->getAttributeValue("laps"));
      CTournamentRaceInfo *pRace=new CTournamentRaceInfo(stringw(pXml->getAttributeValue("track")).c_str(),iLaps);
      m_pTournament->addRace(pRace);
    }
  }
}
Exemplo n.º 8
0
void TestLevel::afterRender() {
	static int lastFPS = -1;
	int fps = driver->getFPS();

	if (lastFPS != fps) {
		//		core::stringw tmp(L"ShootSpacer [");
		//		tmp += driver->getName();
		//		tmp += L"] fps: ";
		//		tmp += fps;

		device->setWindowCaption(
				(windowTitle + L"FPS: " + stringw(fps)).c_str());
		lastFPS = fps;
	}
}
Exemplo n.º 9
0
	int  CSLevel::loadPrefab(stringc filename)
	{
		CS_LOG(CSLOGTYPE::CSL_DEBUG, "Loading prefab %s", filename.c_str());

		int id = 0;

		stringc dir(getApplication()->getDirectory("PrefabDirectory"));
		dir += filename;

		IXMLReader* reader = getDevice()->getFileSystem()->createXMLReader(filename);
		if (!reader) { CS_LOG(CSLOGTYPE::CSL_WARNING, "Warning! unable to open prefab file %s", filename.c_str()); return -1; }

		// read file
		while (reader->read())
		{
			switch (reader->getNodeType())
			{
			case io::EXN_ELEMENT:
				stringw name = reader->getNodeName();

				if (stringw("CSOBJECT") == name)
				{
					stringw type = reader->getAttributeValueSafe(L"TYPE");

					CSObject* obj = getObjectFactory()->createObjectByType(stringc(type));
					if (obj)
					{
						id = obj->getId();
						IAttributes* attr = getDevice()->getFileSystem()->createEmptyAttributes(getDriver());
						attr->read(reader, false);
						obj->deserializeAttributes(attr);
						obj->setId(id);
						obj->reCreate();
						attr->drop();
					}
				}
			}
		}

		reader->drop();

		return id;
	}
Exemplo n.º 10
0
/**
 * The constructor
 * @param Irrlicht device for the XML reader and writer
 */
CHiScoreList::CHiScoreList(IrrlichtDevice *pDevice, const c8 *sFileName) {
  m_pDevice=pDevice;
  IXMLReaderUTF8 *pXml=m_pDevice->getFileSystem()->createXMLReaderUTF8(sFileName);
  strcpy(m_sFileName,sFileName);
  u32 iCnt=0;

  //If the XML was opened successfully we read the information from the file
  if (pXml) {
    while (pXml->read() && iCnt<10) {
      if (!strcmp(pXml->getNodeName(),"score")) {
        CHiScoreEntry *theEntry=new CHiScoreEntry();
        theEntry->iTime=atoi(pXml->getAttributeValue("time"));
        wcscpy(theEntry->sName,stringw(pXml->getAttributeValue("name")).c_str());
        m_lList.push_back(theEntry);
        iCnt++;
      }
    }
    pXml->drop();
  }
}
Exemplo n.º 11
0
/**
 * \brief Init loads list of available languages and sets default language from preferences.
 * \author Petar Bajic 
 * \date January, 21 2012.
 */
bool CLanguages::Init()
{
	u32 index = 0;

	IFileList* fileList = m_FS->createFileList();
	u32 count = fileList->getFileCount();
	for (u32 i=0; i<count; i++)
	{
		stringc file = fileList->getFileName(i);
		IXMLReader* xml = m_FS->createXMLReader(file);

		if (xml)
		{
			//get language name and value from file
			while(xml->read())
			{
				switch(xml->getNodeType())
				{
				case io::EXN_ELEMENT:
					{
						if (stringw("Language").equals_ignore_case(xml->getNodeName()))
						{
							TLanguage* lang = new TLanguage();
							lang->name = xml->getAttributeValue(L"name");
							lang->value = xml->getAttributeValue(L"value");
							lang->index = index;
							m_ListOfAvailableLanguages.push_back(lang);
							index++;
						}
					}
				}
			}

			xml->drop(); // don't forget to delete the xml reader
		}

	}


	return true;
}
Exemplo n.º 12
0
// Black screen fadeout in gameplay
void GUIGame::showBlackScreen(stringc text)
{
	IGUIInOutFader* fader=(IGUIInOutFader*)GUIManager::getInstance()->getGUIElement(GUIManager::ID_FADER);
    fader->setVisible(true);
    fader->fadeOut(1000);

    while(!fader->isReady() && App::getInstance()->getDevice()->run())
    {
        App::getInstance()->getDevice()->getVideoDriver()->beginScene(true, true, SColor(0,200,200,200));
        App::getInstance()->getDevice()->getSceneManager()->drawAll();

        guienv->drawAll();

		GUIManager::getInstance()->guiFontLarge28->draw(stringw(text),GUIManager::getInstance()->myRect(0,0,
                                             App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Width,
                                             App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Height ),
                     SColor(255,255,255,255),true,true);


        App::getInstance()->getDevice()->getVideoDriver()->endScene();
    }
}
Exemplo n.º 13
0
stringw Boton::getInput()
{
    if(usando_joystick)
    {
        if(joystick>=0)
            return stringw(joystick);
        if(joystick==-8)
            return stringw("up");
        if(joystick==-2)
            return stringw("down");
        if(joystick==-4)
            return stringw("left");
        if(joystick==-6)
            return stringw("right");
        return stringw("d");
    }else
    {
        return stringw(keyToString());
    }
}
Exemplo n.º 14
0
bool CTournamentRace::startRace() {
  printf("start next race\n");
  CIrrOdeKlangManager::getSharedInstance()->removeAllNodes();
  if (m_pSndEngine) m_pSndEngine->play2D("data/sounds/menuselect.ogg");

  CLevelList *pList=new CLevelList(m_pDevice);
  CRaceInfo *pInfo=NULL;

  CTournamentRaceInfo *pRace=m_pTrnInfo->getRace(m_iNextRace);
  stringw sRaceTrack=stringw(pRace->getTrack());

  for (u32 i=0; i<pList->m_aLevels.size(); i++) {
    if (sRaceTrack==pList->m_aLevels[i]->m_sName) {
      IFileSystem *pFs=m_pDevice->getFileSystem();
      bool bNetBookLevel=m_pOptions!=NULL && m_pOptions->netbook() && pFs->existFile(path(pList->m_aLevels[i]->m_sNetbookFile));

      pInfo=new CRaceInfo();
      pInfo->setLevel(bNetBookLevel?pList->m_aLevels[i]->m_sNetbookFile:pList->m_aLevels[i]->m_sFile);
      pInfo->setSplitHorizontal(m_pTrnInfo->getSplitHorizontal());
      pInfo->setLaps(pRace->getLaps());
      pInfo->setRecordReplay(m_pTrnInfo->getRecordReplay());
      for (u32 j=0; j<m_pTrnInfo->getPlayerNo(); j++) pInfo->addPlayerName(m_pTrnInfo->getPlayerName(j));
      pInfo->setHiScoreFile(pList->m_aLevels[i]->m_sHiScoreFile.c_str());
      m_pTrnInfo->addRaceInfo(pInfo);
      break;
    }
  }

  delete pList;

  if (pInfo) {
    m_iNextRace++;
    m_iSelect=6;
    m_pLogic->setRaceInfo(pInfo);
    return true;
  }
  return false;
}
Exemplo n.º 15
0
	int CSObject::loadFromPreFab(stringc filename)
	{
		int id = 0;

		stringc dir(getLevel()->getApplication()->getDirectory("PrefabDirectory"));
		dir += filename;

		CS_LOG(CSLOGTYPE::CSL_DEBUG, "Loading from prefab directory %s", dir.c_str());

		IXMLReader* reader = getDevice()->getFileSystem()->createXMLReader(dir);
		CS_CHECK_BOOL(reader, CSLOGTYPE::CSL_DEBUG, "Warning! unable to open prefab file");

		// read file
		while (reader->read())
		{
			switch (reader->getNodeType())
			{
				case io::EXN_ELEMENT:
				{
					stringw name = reader->getNodeName();
					if (stringw("CSOBJECT") == name)
					{
						stringw type = reader->getAttributeValueSafe(L"TYPE");

						IAttributes* attr = getDevice()->getFileSystem()->createEmptyAttributes(getDriver());
						attr->read(reader, false);
						deserializeAttributes(attr);
						setId(getLevel()->getObjectFactory()->getObjectManager()->getUniqueId());
						attr->drop();
					}
				}
			}
		}

		reader->drop();

		return id;
	}
Exemplo n.º 16
0
//Update the items list in gameplay
void GUIGame::updateItemsList()
{
	IGUIImage* guiPlayerLootImage = (IGUIImage*)GUIManager::getInstance()->getGUIElement(GUIManager::IMG_LOOT);
	IGUIListBox* guiPlayerItems =(IGUIListBox*)GUIManager::getInstance()->getGUIElement(GUIManager::LB_ID_PLAYER_ITEMS);
    guiPlayerItems->clear();
   
	vector<DynamicObject*> lootitems = DynamicObjectsManager::getInstance()->getPlayer()->getLootItems();
	std::sort(lootitems.begin(), lootitems.end());

    
	for(int i = 0; i<(int)lootitems.size(); i++)
	{
		//internalname is the Alias name of the object. If undefined it use the internal name
		guiPlayerItems->addItem(stringw(lootitems[i]->internalname).c_str());
	}

	if (guiPlayerItems->getSelected()<0)
	{
		ITexture* info_none = driver->getTexture("../media/editor/info_none.jpg");
		guiPlayerLootImage->setImage(info_none);
		((IGUIStaticText*)guienv->getRootGUIElement()->getElementFromId(GUIManager::TXT_ID_LOOT_DESCRIPTION,true))->setText(L"");
	}
}
Exemplo n.º 17
0
int DLL_EXPORT handleCamera() {
  printf("Handle Camera!");
  g_pCtrl = new CIrrCC(g_pDevice);

  g_iCtrls[eCameraLeft    ] = g_pCtrl->addItem(3, stringw("Camera Left"    ), KEY_KEY_Y, CIrrCC::eCtrlAxis);
  g_iCtrls[eCameraRight   ] = g_pCtrl->addItem(3, stringw("Camera Right"   ), KEY_KEY_C, CIrrCC::eCtrlAxis);
  g_iCtrls[eCameraUp      ] = g_pCtrl->addItem(3, stringw("Camera Up"      ), KEY_KEY_F, CIrrCC::eCtrlAxis);
  g_iCtrls[eCameraDown    ] = g_pCtrl->addItem(3, stringw("Camera Down"    ), KEY_KEY_V, CIrrCC::eCtrlAxis);
  g_iCtrls[eCameraCenter  ] = g_pCtrl->addItem(3, stringw("Center Camera"  ), KEY_KEY_X, CIrrCC::eCtrlButton);
  g_iCtrls[eCameraInternal] = g_pCtrl->addItem(3, stringw("Toggle Internal"), KEY_KEY_I, CIrrCC::eCtrlToggleButton);

  g_pCtrl->createAxis(g_iCtrls[eCameraLeft], g_iCtrls[eCameraRight]);
  g_pCtrl->createAxis(g_iCtrls[eCameraUp  ], g_iCtrls[eCameraDown ]);

  g_pCamera = new CCameraController(g_pDevice, g_pSnd, g_pCtrl, g_pOdeMngr, 1.0f);
  g_pCamera->setCtrl(g_iCtrls);
  return 0;
}
Exemplo n.º 18
0
	bool CSLevel::savePrefab(CSObject* obj, stringc filename)
	{
		CS_LOG(CSLOGTYPE::CSL_DEBUG, "Saving prefab to file %s", filename.c_str());

		CS_CHECK_BOOL(obj, CSLOGTYPE::CSL_WARNING, "Warning unable to save prefab. obj is not valid");

		_chdir(getApplication()->getDirectory("PrefabDirectory").c_str());

		IXMLWriter* writer = getDevice()->getFileSystem()->createXMLWriter(filename);
		if (!writer) { CS_LOG(CSLOGTYPE::CSL_WARNING, "Warning! unable to create prefab file %s", filename.c_str()); return false; }

		writer->writeXMLHeader();

		stringw name("CSOBJECT");
		writer->writeElement(name.c_str(), false, L"TYPE", stringw(obj->getInfo()->getName()).c_str());
		writer->writeLineBreak();

		IAttributes* attr = getDevice()->getFileSystem()->createEmptyAttributes(getDriver());
		SAttributeReadWriteOptions options;
		obj->serializeAttributes(attr, &options);

		if (attr->getAttributeCount() != 0)
		{
			attr->write(writer);
			writer->writeLineBreak();
		}

		attr->drop();

		writer->writeClosingTag(name.c_str());
		writer->writeLineBreak();
		writer->writeLineBreak();

		writer->drop();
		return true;
	}
Exemplo n.º 19
0
	// save the level objects to disk file
	bool CSLevel::saveToDisk(stringc filename)
	{
		// log this event
		CS_LOG(CSLOGTYPE::CSL_DEBUG, "Saving game data - %s", filename.c_str());

		// creat ethe xml writer
		IXMLWriter* writer = getDevice()->getFileSystem()->createXMLWriter(filename);
		if (!writer) { CS_LOG(CSLOGTYPE::CSL_WARNING, "Warning! unable to create save file %s", filename.c_str()); return false; }

		// write the xml header
		writer->writeXMLHeader();

		vector3df pos(0, 0, 0);
		vector3df tar(0, 0, 0);
		if (getCamera())
		{
			pos = getCamera()->getPosition();
			tar = getCamera()->getTarget();
		}

		// write the camera position and target
		writer->writeLineBreak();
		writer->writeElement(L"CAMERA", false,
			L"POSITION", stringw(vector3dfToStringc(pos)).c_str(),
			L"TARGET", stringw(vector3dfToStringc(tar)).c_str()
			);
		writer->writeLineBreak();
		writer->writeLineBreak();

		// run through thte list of objects
		CSObject* obj = getObjectFactory()->getObjectManager()->getNextObject(true);
		while (obj)
		{
			// if this is not a debug object, then save it to disk
			if (!obj->getDebugObject())
			{
				// write the node type
				stringw name("CSOBJECT");
				writer->writeElement(name.c_str(), false, L"TYPE", stringw(obj->getInfo()->getName()).c_str());
				writer->writeLineBreak();

				// let the object serialize itself into our attributes structure
				IAttributes* attr = getDevice()->getFileSystem()->createEmptyAttributes(getDriver());
				SAttributeReadWriteOptions options;
				obj->serializeAttributes(attr, &options);

				// if there are attributes
				if (attr->getAttributeCount() != 0)
				{
					// write the attributes to the xml file
					attr->write(writer);

					// make the file pretty
					writer->writeLineBreak();
				}

				// drop the pointer
				attr->drop();

				// finish writing the xml header / footer
				writer->writeClosingTag(name.c_str());
				writer->writeLineBreak();
				writer->writeLineBreak();
			}
			// get the next object
			obj = getObjectFactory()->getObjectManager()->getNextObject(false);
		}

		// drop the pointer
		writer->drop();

		// everything went fine
		return true;
	}
Exemplo n.º 20
0
//Need to be reworked: BAD. Render loop is done here!
stringc GUIGame::showInputQuestion(stringw text)
{
    std::string newtxt = "";

    bool mouseExit = false;

	
    while(!App::getInstance()->isKeyPressed(KEY_RETURN) && mouseExit==false && App::getInstance()->getDevice()->run())
    {
		u32 timercheck = App::getInstance()->getDevice()->getTimer()->getRealTime();
        App::getInstance()->getDevice()->getVideoDriver()->beginScene(true, true, SColor(0,200,200,200));
        App::getInstance()->getDevice()->getSceneManager()->drawAll();
        //guienv->drawAll();

        App::getInstance()->getDevice()->getVideoDriver()->draw2DRectangle(SColor(150,0,0,0), rect<s32>(10,
                                                                                                        App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Height - 200,
                                                                                                        App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Width - 10,
                                                                                                        App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Height - 10));

        rect<s32> textRect = rect<s32>(10,  App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Height - 180,
                                            App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Width - 10,
                                            App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Height - 10);

        stringw realTxt = stringw(text.c_str());
        realTxt += stringw(newtxt.c_str());
		// Flashing cursor, flash at 1/4 second interval (based on realtime)
	    if((timercheck-timer2>250))
		{
			realTxt += L'_';
			if (timercheck-timer2>500)
				timer2=timercheck;
		}

		GUIManager::getInstance()->guiFontDialog->draw(realTxt.c_str(),textRect,SColor(255,255,255,255),false,false,&textRect);


        //draw YES GREEN button
        position2di buttonYesPosition = position2di(App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Width - 58,
                    App::getInstance()->getDevice()->getVideoDriver()->getScreenSize().Height - 58);

        App::getInstance()->getDevice()->getVideoDriver()->draw2DImage(guiDialogImgYes,buttonYesPosition,
                                                                   rect<s32>(0,0,48,48),0,SColor(255,255,255,255),true);

        //check mouse click on OK button
        position2di mousePos = App::getInstance()->getDevice()->getCursorControl()->getPosition();
		if(mousePos.getDistanceFrom(buttonYesPosition+position2di(16,16)) < 16 && App::getInstance()->isMousePressed(0)) mouseExit = true;


        //verify pressed chars and add it to the string

        if(timercheck-timer > 160)
        {
            //process all keycodes [0-9] and [A-Z]
            for(int i=0x30;i<0x5B;i++)
            {
				if(App::getInstance()->isKeyPressed(i))
                {
                    newtxt += i;
                    timer = timercheck;
                }
            }

            //process delete and backspace (same behavior for both of them -> remove the last char)
            if(App::getInstance()->isKeyPressed(KEY_BACK) || App::getInstance()->isKeyPressed(KEY_DELETE))
            {
                newtxt = newtxt.substr(0,newtxt.size()-1);
				timer = timercheck;
            }
        }
        App::getInstance()->getDevice()->getVideoDriver()->endScene();
    }

    //EventReceiver::getInstance()->flushKeys();
    //EventReceiver::getInstance()->flushMouse();
	GUIManager::getInstance()->flush();

    return stringc(newtxt.c_str());
}
Exemplo n.º 21
0
void xmldata::loadLangFile(core::stringc  filename )
{
		core::stringc file="../media/";
		file+=filename;
		if (!device)
		{ 
			printf("Problems!\n");
			return;
		}

		const u32 starttime = device->getTimer()->getRealTime();
		io::IXMLReaderUTF8* xml = device->getFileSystem()->createXMLReaderUTF8(file.c_str());

		Lang CurrentLang;

		bool inside = false;
		bool found = false;

		// Language counter (using the XML hierachy)
		u32 count = 0;
		u32 linecount = 0;
		u32 linecount2 = 0;

		wchar_t out[255];

        while(xml && xml->read())
        {
                switch(xml->getNodeType())
                {
                case io::EXN_TEXT:		
                        break;

                case io::EXN_ELEMENT:
                {
					
						if ((core::stringw("text") == xml->getNodeName()))
						{

								// utf8toWchar was introducted in Irrlicht 1.9
								// This will allow IRB to save/load strings encoded in UTF8 to it's platform native WCHAR format.
								
								utf8ToWchar(xml->getAttributeValue("id"), out, 255);
								CurrentLang.name = stringw(out);
								
								utf8ToWchar(xml->getAttributeValue("str"), out, 255);
								CurrentLang.text = stringw(out);
	
								LANGManager::getInstance()->language.push_back(CurrentLang);
								linecount++;
						}
						if (core::stringw("about") == xml->getNodeName())
						{

								CurrentLang.name=L"txt_about";
								utf8ToWchar(xml->getAttributeValue("str"), out, 255);
								CurrentLang.text=stringw(out);
								LANGManager::getInstance()->aboutext.push_back(CurrentLang);
								
						}
				}
                break;

				case io::EXN_ELEMENT_END:
					if (!inside)
					{
						linecount=0;
						linecount2=0;
					}

					if (inside)
						count++;

					inside = false;
					break;
                default:
                        break;
                }
        }


        if (xml)
                xml->drop(); // don't forget to delete the xml reader

}
Exemplo n.º 22
0
// Set up the gameplay interface GUI
void GUIGame::setupGameplayGUI()
{

	driver=App::getInstance()->getDevice()->getVideoDriver();
	guienv=App::getInstance()->getDevice()->getGUIEnvironment();

	GUIManager::getInstance()->createConsole();

	IGUIInOutFader* fader=guienv->addInOutFader();
	fader->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT);
    fader->setVisible(false);
	fader->setID(GUIManager::ID_FADER);

	// NEW Create display size since IRRlicht return wrong values
	// Check the current screen size
	displayheight=screensize.Height;
	displaywidth=screensize.Width;

	// Create a cutscene text
	IGUIStaticText* guiCutsceneText = guienv->addStaticText(L"This is a standard cutscene text",core::rect<s32>(100,displayheight/2+(displayheight/4),displaywidth-10,displayheight-100),false,true,0,-1,false);
	guiCutsceneText->setOverrideFont(GUIManager::getInstance()->guiFontLarge28);
	guiCutsceneText->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);
	guiCutsceneText->setVisible(false);
	guiCutsceneText->setID(GUIManager::ST_ID_CUTSCENE_TEXT);

	// This is called only in the PLAYER application
	#ifndef EDITOR
	// ----------------------------------------
	guienv->getSkin()->setFont(GUIManager::getInstance()->guiFontC12);
	//guienv->getSkin()->setFont(guiFontCourier12);
	// Load textures
	ITexture* imgLogo = driver->getTexture(App::getInstance()->logoimage.c_str());
	printf("Here is the logo: %s\n",App::getInstance()->logoimage.c_str());

	//LOADER WINDOW
	IGUIWindow* guiLoaderWindow = guienv->addWindow(GUIManager::getInstance()->myRect(driver->getScreenSize().Width/2-300, driver->getScreenSize().Height/2-200,600,400),false,L"Loading...",0,GUIManager::WIN_LOADER);
	guiLoaderWindow->setDrawTitlebar(false);
	guiLoaderWindow->getCloseButton()->setVisible(false);

	guienv->addImage(imgLogo,vector2d<s32>(5,5),true,guiLoaderWindow);
    IGUIStaticText* guiLoaderDescription = guienv->addStaticText(L"Loading fonts...",
		GUIManager::getInstance()->myRect(10,350,580,40),
		true,true,guiLoaderWindow,
		GUIManager::TXT_ID_LOADER,false);

	//Define 2 buttons to place in the loader windows (player only)
	IGUIButton* guiBtGamePlay = guienv->addButton(core::rect<s32>(400,360,580,380),guiLoaderWindow, GUIManager::BT_PLAYER_START, L"PLAY GAME NOW!");
	guiBtGamePlay->setVisible(false);

	IGUIButton* guiBtGameConfig = guienv->addButton(core::rect<s32>(20,360,200,380),guiLoaderWindow, GUIManager::BT_PLAYER_CONFIG, L"EDIT CONFIGURATION");
	guiBtGameConfig->setVisible(false);

	App::getInstance()->quickUpdate();

	GUIManager::getInstance()->loadFonts();
	guiLoaderDescription->setText(L"Loading interface graphics...");
	//printf("The GUI should display from here...\n");
	// quick update
	App::getInstance()->quickUpdate();

	// Buttons
	ITexture* imgCloseProgram = driver->getTexture("../media/art/bt_close_program.png");
	ITexture* imgAbout = driver->getTexture("../media/art/bt_about.png");
	ITexture* imgAbout1 = driver->getTexture("../media/art/bt_about_ghost.png");
	ITexture* imgHelp = driver->getTexture("../media/art/bt_help.png");
	ITexture* imgHelp1 = driver->getTexture("../media/art/bt_help_ghost.png");
	ITexture* imgConfig = driver->getTexture("../media/art/bt_config.png");
	ITexture* imgConfig1 = driver->getTexture("../media/art/bt_config_ghost.png");

	IGUIWindow* guiMainToolWindow = guienv->addWindow(GUIManager::getInstance()->myRect(driver->getScreenSize().Width-170,0,170,46),false,0,0,GUIManager::WIN_GAMEPLAY);
	guiMainToolWindow->setDraggable(false);
	guiMainToolWindow->setDrawTitlebar(false);
	guiMainToolWindow->getCloseButton()->setVisible(false);
	guiMainToolWindow->setVisible(false);


	//Play Game
	int x = 0;
	mainToolbarPos.Y=5;
	IGUIButton* guiPlayGame= guienv->addButton(GUIManager::getInstance()->myRect(10+x,mainToolbarPos.Y,32,32),
                                     guiMainToolWindow,
									 GUIManager::BT_ID_PLAY_GAME,L"",
                                     stringw(LANGManager::getInstance()->getText("bt_play_game")).c_str());

    guiPlayGame->setImage(driver->getTexture("../media/art/bt_play_game.png"));


    //Stop Game
    IGUIButton* guiStopGame= guienv->addButton(GUIManager::getInstance()->myRect(10+x,mainToolbarPos.Y,32,32),
                                     guiMainToolWindow,
									 GUIManager::BT_ID_STOP_GAME,L"",
                                     stringw(LANGManager::getInstance()->getText("bt_stop_game")).c_str());

    guiStopGame->setImage(driver->getTexture("../media/art/bt_stop_game.png"));
    guiStopGame->setVisible(false);



    //ABOUT BUTTON
	x += 42;
    IGUIButton* guiAbout = guienv->addButton(GUIManager::getInstance()->myRect(10+x,mainToolbarPos.Y,32,32),
                                     guiMainToolWindow,
									 GUIManager::BT_ID_ABOUT,L"",
                                     stringw(LANGManager::getInstance()->getText("bt_about")).c_str() );

    guiAbout->setImage(imgAbout);
	guiAbout->setPressedImage(imgAbout1);

	// Help Button
	x += 42;
    IGUIButton* guiHelpButton = guienv->addButton(GUIManager::getInstance()->myRect(10+x,mainToolbarPos.Y,32,32),
                                     guiMainToolWindow,
									 GUIManager::BT_ID_HELP,L"",
                                     stringw(LANGManager::getInstance()->getText("bt_help")).c_str() );

    guiHelpButton->setImage(imgHelp);
    guiHelpButton->setPressedImage(imgHelp1);

	// Close program
	x += 42;
	IGUIButton* guiCloseProgram = guienv->addButton(GUIManager::getInstance()->myRect(10+x,mainToolbarPos.Y,32,32),
                                     guiMainToolWindow,
									 GUIManager::BT_ID_CLOSE_PROGRAM,L"",
                                     stringw(LANGManager::getInstance()->getText("bt_close_program")).c_str() );

    guiCloseProgram->setImage(imgCloseProgram);

	//ABOUT WINDOW
	IGUIWindow* guiAboutWindow = guienv->addWindow(GUIManager::getInstance()->myRect(driver->getScreenSize().Width/2 - 300,driver->getScreenSize().Height/2 - 200,600,400),false);
    guiAboutWindow->setDraggable(false);
    guiAboutWindow->setDrawTitlebar(false);
    guiAboutWindow->getCloseButton()->setVisible(false);
    guiAboutWindow->setVisible(false);

    guienv->addImage(driver->getTexture("../media/art/logo1.png"),position2di(guiAboutWindow->getAbsoluteClippingRect().getWidth()/2-100,10),true,guiAboutWindow);

	IGUIButton* guiAboutClose = guienv->addButton(GUIManager::getInstance()->myRect(guiAboutWindow->getAbsoluteClippingRect().getWidth() - 37,guiAboutWindow->getAbsoluteClippingRect().getHeight() - 37,32,32),guiAboutWindow,GUIManager::BT_ID_ABOUT_WINDOW_CLOSE);

    guiAboutClose->setImage(driver->getTexture("../media/art/bt_yes_32.png"));

	IGUIListBox* guiAboutText = guienv ->addListBox(GUIManager::getInstance()->myRect(guiAboutWindow->getAbsoluteClippingRect().getWidth()/2-250,160,500,200),guiAboutWindow);

	// Ask the LANGManager to fill the box with the proper Language of the about text.
	LANGManager::getInstance()->setAboutText(guiAboutText);

	// Create the Configuration window (Need to be updated)
#ifndef EDITOR
	configWindow = new GUIConfigWindow(App::getInstance()->getDevice());
	configWindow->setID(GUIManager::GCW_CONFIG_WINDOW);
	// Give back to the GUI Manager since it's needed for both applications
	GUIManager::getInstance()->setConfigWindow(configWindow);
#endif

	// ---------------------------------------
	#endif

	// --- Active game menu during play

	ITexture* gameplay_bar = driver->getTexture("../media/art/gameplay_bar.png");
	ITexture* circle = driver->getTexture("../media/art/circle.png");
	ITexture* circleMana = driver->getTexture("../media/art/circlemana.png");
	ITexture* topCircle = driver->getTexture("../media/art/circle_top.png");
	IGUIImage* gameplay_bar_image = NULL;
	
	if (gameplay_bar)
	{
		gameplay_bar_image = guienv->addImage(gameplay_bar,vector2d<s32>((displaywidth/2)-(gameplay_bar->getSize().Width/2),displayheight-gameplay_bar->getSize().Height),true);
		gameplay_bar_image->setAlignment(EGUIA_CENTER,EGUIA_CENTER,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);
		gameplay_bar_image->setID(GUIManager::IMG_BAR);

		// The life gauge
		CGUIGfxStatus* lifegauge = new gui::CGUIGfxStatus(guienv, gameplay_bar_image,GUIManager::getInstance()->myRect((gameplay_bar->getSize().Width/2)-60,gameplay_bar->getSize().Height-128,128,128),-1);
		lifegauge->setImage(circle);
		lifegauge->ViewHalfLeft();
		lifegauge->setID(GUIManager::IMG_LIFEGAUGE);

		// The mana gauge
		CGUIGfxStatus* managauge = new gui::CGUIGfxStatus(guienv, gameplay_bar_image,GUIManager::getInstance()->myRect((gameplay_bar->getSize().Width/2)-60,gameplay_bar->getSize().Height-128,128,128),-1);
		managauge->setImage(circleMana);
		managauge->ViewHalfRight();
		managauge->setID(GUIManager::IMG_MANAGAUGE);

		// The image over the circle
		IGUIImage* circle_overlay =	guienv->addImage(topCircle,vector2d<s32>((gameplay_bar->getSize().Width/2)-64,gameplay_bar->getSize().Height-128),true,gameplay_bar_image);
	}	

	gameplay_bar_image->setVisible(false);

    ///DIALOG
	guiDialogImgYes = driver->getTexture("../media/art/img_yes.png");
    guiDialogImgYes_s = driver->getTexture("../media/art/img_yes_s.png");
    guiDialogImgNo = driver->getTexture("../media/art/img_no.png");
    guiDialogImgNo_s = driver->getTexture("../media/art/img_no_s.png");


    //view items
	if (gameplay_bar_image)
	{
		core::stringw text=LANGManager::getInstance()->getText("bt_view_items");
		IGUIButton* guiBtViewItems = guienv->addButton(GUIManager::getInstance()->myRect(465,85,48,48),
		//displaywidth/2 + 80,displayheight - 57,48,48),
                                     gameplay_bar_image,
									 GUIManager::BT_ID_VIEW_ITEMS,L"",
									 text.c_str());

		guiBtViewItems->setImage(driver->getTexture("../media/art/bt_view_items.png"));
		guiBtViewItems->setVisible(true);
		
	}

	

    //Items window

	IGUIWindow* guiWindowItems = guienv->addWindow(GUIManager::getInstance()->myRect(100,100,displaywidth-200,displayheight-150),false,L"",0,GUIManager::GCW_GAMEPLAY_ITEMS);
    guiWindowItems->getCloseButton()->setVisible(false);
    guiWindowItems->setDrawTitlebar(false);
    guiWindowItems->setDraggable(false);
	guiWindowItems->setAlignment(EGUIA_CENTER,EGUIA_CENTER,EGUIA_CENTER,EGUIA_CENTER);
    IGUITabControl * gameTabCtrl = guienv->addTabControl(core::rect<s32>(10,30,displaywidth-240,displayheight-200),guiWindowItems,false,true,-1);
	IGUITab * tab1 = gameTabCtrl->addTab(LANGManager::getInstance()->getText("game_stats_title").c_str());
	IGUITab * tab2 = gameTabCtrl->addTab(LANGManager::getInstance()->getText("game_inventory_title").c_str());
	IGUITab * tab3 = gameTabCtrl->addTab(LANGManager::getInstance()->getText("game_skills_title").c_str());
	IGUITab * tab4 = gameTabCtrl->addTab(LANGManager::getInstance()->getText("game_quests_title").c_str());


	nodepreview = new NodePreview(guienv,tab1,rect<s32>(440,40,740,370),-1);
	nodepreview->drawBackground(false);

	//DynamicObjectsManager::getInstance()->setActiveObject("player_template");

	//guiPlayerNodePreview->setNode(DynamicObjectsManager::getInstance()->getActiveObject()->getNode());
	//guiPlayerNodePreview->setNode(Player::getInstance()->getNodeRef());
	//DynamicObjectsManager::getInstance()->setActiveObject("Archer");
	//printf("This is the node name: %s\n",DynamicObjectsManager::getInstance()->getActiveObject()->getName());
	nodepreview->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_UPPERLEFT,EGUIA_UPPERLEFT);

	IGUIListBox* guiPlayerItems = guienv->addListBox(GUIManager::getInstance()->myRect(10,30,200,displayheight-340),tab2,GUIManager::LB_ID_PLAYER_ITEMS,true);

	ITexture* info_none = driver->getTexture("../media/editor/info_none.jpg");

	IGUIImage* guiPlayerLootImage = NULL;

	if (info_none)
		guiPlayerLootImage = guienv->addImage(info_none,vector2d<s32>(220,30),true,tab2,GUIManager::IMG_LOOT);

	guienv->addStaticText(L"",core::rect<s32>(220,250,520,410),true,true,tab2,GUIManager::TXT_ID_LOOT_DESCRIPTION,true);

	//guienv->addImage(info_none,vector2d<s32>(5,5),true,tab2);
	core::stringc filename = "../media/dynamic_objects/";

	IGUIButton* guiBtUseItem = guienv->addButton(GUIManager::getInstance()->myRect(10,displayheight-300,32,32),
                                         tab2,
										 GUIManager::BT_ID_USE_ITEM,
                                         L"",
                                         stringw(LANGManager::getInstance()->getText("bt_use_item")).c_str());
    guiBtUseItem->setImage(driver->getTexture("../media/art/bt_yes_32.png"));

    IGUIButton* guiBtDropItem = guienv->addButton(GUIManager::getInstance()->myRect(52,displayheight-300,32,32),
                                         tab2,
										 GUIManager::BT_ID_DROP_ITEM,
                                         L"",
                                         stringw(LANGManager::getInstance()->getText("bt_drop_item")).c_str());
    guiBtDropItem->setImage(driver->getTexture("../media/art/bt_no_32.png"));


    IGUIButton* guiBtCloseItemsWindow = guienv->addButton(GUIManager::getInstance()->myRect(displaywidth-210-32,displayheight-160 - 32,32,32),
                                         guiWindowItems,
										 GUIManager::BT_ID_CLOSE_ITEMS_WINDOW,
                                         L"",
                                         stringw(LANGManager::getInstance()->getText("bt_close_items_window")).c_str());
    guiBtCloseItemsWindow->setImage(driver->getTexture("../media/art/bt_arrow_32.png"));
	guiWindowItems->setVisible(false);



	// TExt GUI for player stats

	IGUIStaticText* guiPlayerMoney = guienv->addStaticText(L"GOLD:129",GUIManager::getInstance()->myRect(15,displayheight-300,300,32),false,false,tab1, GUIManager::ST_ID_PLAYER_MONEY);
	guiPlayerMoney->setOverrideFont(GUIManager::getInstance()->guiFontLarge28);
    guiPlayerMoney->setOverrideColor(SColor(255,255,255,255));

	stringc playerLifeText = LANGManager::getInstance()->getText("txt_player_life");


	IGUIStaticText* guiPlayerLife=guienv->addStaticText(stringw(playerLifeText).c_str(),GUIManager::getInstance()->myRect(15,6,600,30),false,false,tab1,-1,false);
    guiPlayerLife->setOverrideColor(SColor(255,255,255,100));
    guiPlayerLife->setOverrideFont(GUIManager::getInstance()->guiFontLarge28);
	guiPlayerLife->setID(GUIManager::ST_ID_PLAYER_LIFE);

	//Have to rework this. Currently hidden.
	IGUIStaticText* guiPlayerLife_Shadow=guienv->addStaticText(stringw(playerLifeText).c_str(),GUIManager::getInstance()->myRect(14,5,600,30),false,false,tab1,-1,false);
    guiPlayerLife_Shadow->setOverrideColor(SColor(255,30,30,30));
	guiPlayerLife_Shadow->setOverrideFont(GUIManager::getInstance()->guiFontLarge28);
	guiPlayerLife_Shadow->setVisible(false);
	
	GUIManager::getInstance()->setElementVisible(GUIManager::ST_ID_PLAYER_LIFE, false);


	////// --------------------------------
	///    Define the Dialogs used in the game
	//////

	IGUIWindow* guidialog = guienv->addWindow(GUIManager::getInstance()->myRect(10,displayheight-200,displaywidth-20,190),true,L"",0,GUIManager::GCW_DIALOG);
	guidialog->getCloseButton()->setVisible(false);
	guidialog->setDrawTitlebar(false);
	guidialog->setDraggable(false);
	guidialog->setDrawBackground(false);
	guidialog->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);

	// Panel background is done with pictures
	IGUIImage* img1 = guienv->addImage(driver->getTexture("../media/art/panel_left.png"),vector2d<s32>(0,0),true,guidialog);
	IGUIImage* img2 = guienv->addImage(driver->getTexture("../media/art/panel_middle.png"),vector2d<s32>(51,0),true,guidialog);
	IGUIImage* img3 = guienv->addImage(driver->getTexture("../media/art/panel_right.png"),vector2d<s32>(581,0),true,guidialog);
	img2->setScaleImage(true);
	img2->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);
	img3->setAlignment(EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);

	// Text display of the panel
	rect<s32> textRect = rect<s32>(30,25,600,170);
	IGUIStaticText* txt_dialog = guienv->addStaticText(L"Hello! This is a simple test to see how the text is flowing inside the box. There is a test, test, and test of text we need to make to be sure the flowing is ok",textRect,false,false,guidialog,GUIManager::TXT_ID_DIALOG,false);
	txt_dialog->setOverrideFont(GUIManager::getInstance()->guiFontDialog);
	txt_dialog->setOverrideColor(SColor(255,255,255,255));
	txt_dialog->setWordWrap(true);
	txt_dialog->setAlignment(EGUIA_UPPERLEFT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);

	IGUIButton* guiBtDialogYes = guienv->addButton(GUIManager::getInstance()->myRect(640,30,52,52),
                                         guidialog,
										 GUIManager::BT_ID_DIALOG_YES,
                                         L"",
                                         stringw(LANGManager::getInstance()->getText("bt_dialog_yes")).c_str());
    guiBtDialogYes->setImage(guiDialogImgYes);
	guiBtDialogYes->setAlignment(EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);
	IGUIButton* guiBtDialogCancel = guienv->addButton(GUIManager::getInstance()->myRect(640,110,52,52),
                                         guidialog,
										 GUIManager::BT_ID_DIALOG_CANCEL,
                                         L"",
                                         stringw(LANGManager::getInstance()->getText("bt_dialog_no")).c_str());
    guiBtDialogCancel->setImage(guiDialogImgNo);
	guiBtDialogCancel->setAlignment(EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT,EGUIA_LOWERRIGHT);
	guidialog->setVisible(false);

}
		void dialog_createavatar::InitElements()
		{
			stringw title = stringw(lang_[L"CreateAvatar_WindowTitle"].c_str());

			window_ = new CGUIDecentralisedDialog(env_,
				env_->getRootGUIElement(),
				e_gui_elements::WindowCreateAvatar,
				rect<s32>(80, 40, 400, 250),
				true);
			window_->setDialogSkin(elems_.TxDialogBack, elems_.TxDialogFore);
			window_->setVisible(true);
			window_->setText(title.c_str());
			env_->setFocus(window_);
			window_->drop();

			s32 posy = 40;

			elems_.CreateAvPublicKeyLabel = env_->addStaticText(lang_[L"CreateAvatar_PublicKeyLabel"].c_str(),
				rect<s32>(20, posy, 260, posy + 22),
				false, true,
				window_,
				0);

			posy += 22;

			elems_.CreateAvPublicKeyBox = new CGUIDecentralisedTextbox(L"", true, env_, window_, e_gui_elements::CreateAvPasswordBox, rect<s32>(20, posy, 295, posy + 22));
			elems_.CreateAvPublicKeyBox->setEnabled(false);
			elems_.CreateAvPublicKeyBox->setOverrideColor(SColor(255, 0, 0, 0));

			posy += 32;

			elems_.CreateAvFirstNameLabel = env_->addStaticText(lang_[L"CreateAvatar_FirstnameLabel"].c_str(),
				rect<s32>(20, posy, 140, posy + 22),
				false, true,
				window_,
				0);

			elems_.CreateAvLastNameLabel = env_->addStaticText(lang_[L"CreateAvatar_LastnameLabel"].c_str(),
				rect<s32>(160, posy, 310, posy + 22),
				false, true,
				window_,
				0);

			posy += 22;

			elems_.CreateAvFirstNameTextBox = new CGUIDecentralisedTextbox(L"", true, env_, window_, e_gui_elements::CreateAvFirstnameBox, rect<s32>(20, posy, 155, posy + 22));
			elems_.CreateAvFirstNameTextBox->setEnabled(true);
			elems_.CreateAvFirstNameTextBox->setOverrideColor(SColor(255, 0, 0, 0));
			elems_.CreateAvFirstNameTextBox->drop();

			elems_.CreateAvLastNameTextBox = new CGUIDecentralisedTextbox(L"", true, env_, window_, e_gui_elements::CreateAvLastnameBox, rect<s32>(160, posy, 295, posy + 22));
			elems_.CreateAvLastNameTextBox->setEnabled(true);
			elems_.CreateAvLastNameTextBox->setOverrideColor(SColor(255, 0, 0, 0));
			elems_.CreateAvLastNameTextBox->drop();

			posy += 40;

			elems_.CreateAvCreateButton = new CGUIDecentralisedButton(env_, window_, e_gui_elements::CreateAvCreateButton, rect<s32>(20, posy, 180, posy + 25));
			elems_.CreateAvCreateButton->setImages(elems_.TxButtonLeft, elems_.TxButtonMiddle, elems_.TxButtonRight, elems_.TxButtonPressedLeft, elems_.TxButtonPressedMiddle, elems_.TxButtonPressedRight);
			elems_.CreateAvCreateButton->setText(lang_[L"CreateAvatar_CreateButtonText"].c_str());
			elems_.CreateAvCreateButton->drop();

			if (elems_.LoginButton)
				elems_.LoginButton->setEnabled(true);

			data_chunk publicKeyChunk = keyPair_.public_key();
			payment_address address;
			set_public_key(address, keyPair_.public_key());

			std::string encoded = address.encoded();
			std::wstring publicKey(encoded.begin(), encoded.end());
			elems_.CreateAvPublicKeyBox->setText(publicKey.c_str());
		}
Exemplo n.º 24
0
    //-------------------------------------------------------------------------
    //                                   i n i t
    //-------------------------------------------------------------------------
    int CApplication::init()
    {
        SIrrlichtCreationParameters cp;
        static SKeyMap keyMap[5];
        keyMap[0].Action = EKA_MOVE_FORWARD;
        keyMap[0].KeyCode = KEY_KEY_W;
        keyMap[1].Action = EKA_STRAFE_LEFT;
        keyMap[1].KeyCode = KEY_KEY_A;
        keyMap[2].Action = EKA_MOVE_BACKWARD;
        keyMap[2].KeyCode = KEY_KEY_S;
        keyMap[3].Action = EKA_STRAFE_RIGHT;
        keyMap[3].KeyCode = KEY_KEY_D;
        keyMap[4].Action = EKA_JUMP_UP;
        keyMap[4].KeyCode = KEY_SPACE;

        int result=0;
        stringc msg;


        // use null device for early file system access
        IrrlichtDevice* m_nullDevice = createDevice(EDT_NULL);
        IFileSystem* fileSystem = m_nullDevice->getFileSystem();

        m_currentDirectory = fileSystem->getWorkingDirectory();
        m_currentDirectory = fileSystem->flattenFilename(m_currentDirectory);
        if(m_argv)
        {
            m_appExecutable = m_argv[0];
        }
        else
        {
            m_appExecutable = "irrlicht.exe";
        }


        stringc appBaseName;
        appBaseName = fileSystem->getAbsolutePath(m_appExecutable);
        appBaseName = fileSystem->getFileBasename(appBaseName, false);

        //
        // create log writer
        //
        m_logName = appBaseName;
        m_logName += ".log";

        m_logFile = fileSystem->createAndWriteFile(m_logName);

        msg = "Created log file: ";
        msg += m_logName;
        logMessage(msg);

        //
        // configuration system
        //
        // locate the data directory - underneath our executable or outside of it.
        stringc temp("data/");
        if(!fileSystem->existFile(temp))
        {
            temp = "../data/";
            // todo - look for "data.zip"...
        }
        m_dataRoot = fileSystem->getAbsolutePath(temp);
        m_configName = m_dataRoot;
        m_configName += "/cfg/";
        m_configName += appBaseName;
        m_configName += ".xml";


        if(!fileSystem->existFile(m_configName))
        {
            // not in data/cfg or ../data/cfg so look in the working directory.
            m_configName = appBaseName;
            m_configName += ".xml";
            if(!fileSystem->existFile(m_configName))
            {
                return -1;
            }
        }

        // load the config file
        m_config = new CXMLConfig();
        if(!m_config->load(m_configName))
        {
            return -1;
        }

        // setup the device based on config settings
        stringc sdriver = m_config->getString("driver","video","EDT_OPENGL");
        cp.DriverType = EDT_OPENGL;
        if(sdriver == "EDT_DIRECT3D9")
            cp.DriverType = EDT_DIRECT3D9;        
        cp.WindowSize = m_config->getDimension("resolution","video",dimension2di(800, 600));
        cp.Bits = m_config->getInt("colordepth","video",32);
        cp.Fullscreen = m_config->getBool("fullscreen","video",false);
        cp.Vsync = m_config->getBool("vsync","video",true);
        cp.Stencilbuffer = m_config->getBool("stencilbuffer","video",false);
        cp.AntiAlias = m_config->getInt("antialias","video",0);
        cp.EventReceiver = this;
        cp.WindowId = 0;

        m_device =  createDeviceEx(cp);
        if(!m_device)
            return -1;

        m_fileSystem = m_device->getFileSystem();
        m_videoDriver = m_device->getVideoDriver();
        m_sceneManager = m_device->getSceneManager();
        m_gui = m_device->getGUIEnvironment();

        m_device->getCursorControl()->setVisible(m_config->getBool("HWCursorVisible","video",true));
        m_device->setWindowCaption(stringw(m_title).c_str());


        //
        // add configured file systems
        //
        if(_initFileSystems())
            return -1;

        //
        // set up the default font
        //        
        stringc fontFolder = "fnt/";
        stringc defFonts = fontFolder + "defaults.zip";
        if(m_fileSystem->existFile(defFonts.c_str()))
        {
            m_fileSystem->addZipFileArchive(defFonts.c_str());
            m_defaultFont = m_gui->getFont("tdeffont.xml");
            if(m_defaultFont)
            {
                m_defaultFont->grab();
                m_gui->getSkin()->setFont(m_defaultFont);
            }
            m_monoFont = m_gui->getFont("monospace.xml");
            if(m_monoFont)
            {
                m_monoFont->grab();
            }
        }

        m_world = m_sceneManager->createMetaTriangleSelector();

        // camera setup
        f32 rotateSpeed = m_config->getFloat("rotateSpeed","options",100.f);
        m_orgMoveSpeed = m_config->getFloat("moveSpeed","options",0.001f);
        f32 jumpSpeed = m_config->getFloat("jumpSpeed","options",0.05f);
        m_camera = m_sceneManager->addCameraSceneNodeFPS(0, rotateSpeed, m_orgMoveSpeed, -1,keyMap,5,true, jumpSpeed);

        vector3df v = m_config->getVector3("campos","options");
        m_camera->setPosition(v);

        v = m_config->getVector3("camtarget","options");
        m_camera->setTarget(v);

        bool collisionEnabled = m_config->getBool("collision","options");
        if(collisionEnabled)
        {
            vector3df gravity,ellipsoid;
            gravity = m_config->getVector3("gravity","options",vector3df(0,-0.1f,0));
            ellipsoid = m_config->getVector3("ellipsoid","options",vector3df(2,5,2));
            m_collisionResponse = m_sceneManager->createCollisionResponseAnimator(m_world,m_camera,
                ellipsoid, gravity);
            m_camera->addAnimator(m_collisionResponse);
        }
        
        // debug & help panels setup
        m_debugPanel = new gui::CGUITextPanel(m_gui, "debugPanel", rectf(0.25f,0.005f,0.75f,0.05f));
        m_debugPanel->addItem("Node: Pos(x,y,z) Hpr(x,y,z) Dir(x,y,z)", EGUIA_CENTER);
        m_debugPanel->addItem("Frame: Avg(0.0) Min(0.0) Max(0.0)", EGUIA_CENTER);
        m_debugPanel->setVisible(true);

        m_helpPanel = new gui::CGUITextPanel(m_gui, "helpPanel", rectf(0.005f,0.005f,0.245f,0.05f));
        m_helpPanel->addItem(" wasd - Movement");
        m_helpPanel->addItem("   F1 - Toggle Help");
        m_helpPanel->addItem("   F2 - Toggle Debug");

        createScene();

        return result;
    }
Exemplo n.º 25
0
PlayerFrame::PlayerFrame(FrameInfo info, bool load_volumic)
{
	// increase total number of loaded frames
	PlayerFrame::totalLoadedFrames++;
	device->getLogger()->log((stringw("Loading frame number ")+stringw(info.id)+L". Total of frames loaded : "+stringw(PlayerFrame::totalLoadedFrames)).c_str());

	core::array<stringc> _lastEleFileNames;
	core::array<stringc> _lastFaceFileNames;
	core::array<scene::SMeshBuffer*> _lastBuffers;

	// initialize some variables
	this->id = info.id;

	for (u32 o=0; o < info.nodefiles.size(); o++)
	{
		SMeshBuffer* buffer = new SMeshBuffer();
		IMeshSceneNode* node = NULL;
		stringc nodeFileName = info.nodefiles[o];
		stringc faceFileName = info.facefiles[o];
		stringc eleFileName = info.elefiles[o];

		// LOADING
		ifstream innode;
		ifstream inele;
		ifstream inface;

		int nb_of_points, nb_of_tetrahedra, nb_of_faces;
		int p1, p2, p3, p4;
		yohan::base::DATA x, y, z;

		// used to know if an error occured in the while loop
		bool error = false;


		// -----------------------------------------------------------------------
		// - POINTS --------------------------------------------------------------
		// -----------------------------------------------------------------------
		innode.open(nodeFileName.c_str(), ios::in | ios::binary); // opens the nodes file
		if (!innode || !innode.good())
		{
			device->getLogger()->log(( stringc("ERROR: This node file could not be opened : ") + nodeFileName ).c_str());
			buffer->drop();
			continue;
		}

		// first line data : innode >> nb_of_points >> dim >> nb_of_attr >> boundary_marker;
		innode.read(reinterpret_cast < char * > (&nb_of_points), sizeof(int));

		// we should have at least one tetrahedra (4 points) and each point should have 3 coordinates
		if (nb_of_points > 65535 || nb_of_points < 4)
		{
			device->getLogger()->log("ERROR: a node file should not contain more than 65535 points and less than 4 points.");
			buffer->drop();
			continue;
		}
		device->getLogger()->log((stringw("Loading ")+stringw(nb_of_points)+L" points from "+stringw(nodeFileName.c_str())+L"...").c_str());

		// default color
		video::SColor clr(255,100,100,200);

		// lets add the vertices to the buffer
		buffer->Vertices.reallocate( nb_of_points );

		// this is one line : innode >> index >> x >> y >> z;
		innode.read(reinterpret_cast < char * > (&x), sizeof(yohan::base::DATA));
		innode.read(reinterpret_cast < char * > (&y), sizeof(yohan::base::DATA));
		innode.read(reinterpret_cast < char * > (&z), sizeof(yohan::base::DATA));
		while (!innode.eof() && innode.good())// && (int)buffer->Vertices.size() < nb_of_points)
		{
			buffer->Vertices.push_back(video::S3DVertex((f32)x, (f32)y, (f32)z, 1,0,0, clr, 0,0));
			// this is one line : innode >> index >> x >> y >> z;
			innode.read(reinterpret_cast < char * > (&x), sizeof(yohan::base::DATA));
			innode.read(reinterpret_cast < char * > (&y), sizeof(yohan::base::DATA));
			innode.read(reinterpret_cast < char * > (&z), sizeof(yohan::base::DATA));
		}

		innode.close();
		innode.clear();
		// -----------------------------------------------------------------------

		// lets check if verticies have been added well
		if (buffer->Vertices.size() != nb_of_points)
		{
			device->getLogger()->log("ERROR: the node file does not seem to be valid.");
			buffer->drop();
			continue;
		}





		if (load_volumic)
		{
			// -----------------------------------------------------------------------
			// - TETRAHEDRAS ---------------------------------------------------------
			// -----------------------------------------------------------------------
			// at first we check if the ele file has not been already opened
			s32 eleLoadedIndex = -1;
			for (u32 e=0; e < PlayerFrame::lastEleFileNames.size(); e++)
			{
				if (PlayerFrame::lastEleFileNames[e] == eleFileName)
				{
					eleLoadedIndex = e;
					device->getLogger()->log("The ele file is already in memory. We do not need to reload it.");
					break;
				}
			}

			// if is not in memory, load it from file
			if (!PlayerFrame::last_was_volumic || eleLoadedIndex == -1 || PlayerFrame::lastBuffers[eleLoadedIndex]->Vertices.size() != buffer->Vertices.size())
			{
				if (eleLoadedIndex != -1)
					device->getLogger()->log((stringc(PlayerFrame::lastBuffers[eleLoadedIndex]->Vertices.size())+
					" This is weird: the ele file which is already in memory don't have the same number of vertices than this one.").c_str());

				inele.open(eleFileName.c_str(), ios::in | ios::binary); // opens the ele file
				if (!inele || !inele.good())
				{
					device->getLogger()->log(( stringc("ERROR: This ele file could not be opened : ") + eleFileName ).c_str());
					buffer->drop();
					continue;
				}

				// first line data : inele >> nb_of_tetrahedra >> dim >> nb_of_attr;
				inele.read(reinterpret_cast < char * > (&nb_of_tetrahedra), sizeof(int));
				device->getLogger()->log((stringw("Loading ")+stringw(nb_of_tetrahedra)+L" tetrahedras from "+stringw(eleFileName.c_str())+L"...").c_str());

				// we should have at least one tetrahedra and each tetrahedra should have 4 points
				if (nb_of_tetrahedra < 1)
				{
					buffer->drop();
					continue;
				}

				// lets add the indices to the buffer
				buffer->Indices.set_used( (u32)(3 * 4 * nb_of_tetrahedra) );
				u32 i = 0;

				// this is one line : inele >> index >> p1 >> p2 >> p3 >> p4;
				inele.read(reinterpret_cast < char * > (&p1), sizeof(int));
				inele.read(reinterpret_cast < char * > (&p2), sizeof(int));
				inele.read(reinterpret_cast < char * > (&p3), sizeof(int));
				inele.read(reinterpret_cast < char * > (&p4), sizeof(int));
				while (!inele.eof() && inele.good())// && i < 3 * 4 * nb_of_tetrahedra - 12)
				{
					// check if we are not out of bounds
					if (i > (u32)(3 * 4 * nb_of_tetrahedra - 12) || p1 > nb_of_points || p2 > nb_of_points || p3 > nb_of_points || p4 > nb_of_points)
					{
						device->getLogger()->log("ERROR: the ele file does not seem to be valid. ");
						buffer->drop();
						error = true;
						break;
					}

					// add 4 polygons per tetrahedra. Not optimized !
					s32 ajust_index = 0;
					buffer->Indices[(u32)(i+0)] = (u32)(p1 + ajust_index);
					buffer->Indices[(u32)(i+1)] = (u32)(p3 + ajust_index);
					buffer->Indices[(u32)(i+2)] = (u32)(p2 + ajust_index);
					core::triangle3df t4(
						buffer->Vertices[(u32)(p1 + ajust_index)].Pos,
						buffer->Vertices[(u32)(p3 + ajust_index)].Pos,
						buffer->Vertices[(u32)(p2 + ajust_index)].Pos);
					i += 3;

					buffer->Indices[(u32)(i+0)] = (u32)(p1 + ajust_index);
					buffer->Indices[(u32)(i+1)] = (u32)(p2 + ajust_index);
					buffer->Indices[(u32)(i+2)] = (u32)(p4 + ajust_index);
					core::triangle3df t3(
						buffer->Vertices[(u32)(p1 + ajust_index)].Pos,
						buffer->Vertices[(u32)(p2 + ajust_index)].Pos,
						buffer->Vertices[(u32)(p4 + ajust_index)].Pos);
					i += 3;

					buffer->Indices[(u32)(i+0)] = (u32)(p3 + ajust_index);
					buffer->Indices[(u32)(i+1)] = (u32)(p4 + ajust_index);
					buffer->Indices[(u32)(i+2)] = (u32)(p2 + ajust_index);
					core::triangle3df t1(
						buffer->Vertices[(u32)(p3 + ajust_index)].Pos,
						buffer->Vertices[(u32)(p4 + ajust_index)].Pos,
						buffer->Vertices[(u32)(p2 + ajust_index)].Pos);
					i += 3;

					buffer->Indices[(u32)(i+0)] = (u32)(p1 + ajust_index);
					buffer->Indices[(u32)(i+1)] = (u32)(p4 + ajust_index);
					buffer->Indices[(u32)(i+2)] = (u32)(p3 + ajust_index);
					core::triangle3df t2(
						buffer->Vertices[(u32)(p1 + ajust_index)].Pos,
						buffer->Vertices[(u32)(p4 + ajust_index)].Pos,
						buffer->Vertices[(u32)(p3 + ajust_index)].Pos);
					i += 3;

					buffer->Vertices[(u32)(p1 + ajust_index)].Normal = t1.getNormal();
					buffer->Vertices[(u32)(p2 + ajust_index)].Normal = t2.getNormal();
					buffer->Vertices[(u32)(p3 + ajust_index)].Normal = t3.getNormal();
					buffer->Vertices[(u32)(p4 + ajust_index)].Normal = t4.getNormal();

					// this is one line : inele >> index >> p1 >> p2 >> p3 >> p4;
					inele.read(reinterpret_cast < char * > (&p1), sizeof(int));
					inele.read(reinterpret_cast < char * > (&p2), sizeof(int));
					inele.read(reinterpret_cast < char * > (&p3), sizeof(int));
					inele.read(reinterpret_cast < char * > (&p4), sizeof(int));
				}

				inele.close();
				inele.clear();
			}
			else // we do not need to reload from the file !
			{
				buffer->Indices.reallocate(PlayerFrame::lastBuffers[eleLoadedIndex]->Indices.size());
				buffer->Indices = PlayerFrame::lastBuffers[eleLoadedIndex]->Indices;
				for (u32 j=0; j < buffer->Vertices.size(); j++)
					buffer->Vertices[j].Normal = PlayerFrame::lastBuffers[eleLoadedIndex]->Vertices[j].Normal;
			}
			// -----------------------------------------------------------------------
		}
		else // load_volumic == false
		{
			// -----------------------------------------------------------------------
			// - FACES ---------------------------------------------------------------
			// -----------------------------------------------------------------------
			// at first we check if the ele file has not been already opened
			s32 faceLoadedIndex = -1;
			for (u32 e=0; e < PlayerFrame::lastFaceFileNames.size(); e++)
			{
				if (PlayerFrame::lastFaceFileNames[e] == faceFileName)
				{
					faceLoadedIndex = e;
					device->getLogger()->log("The face file is already in memory. We do not need to reload it.");
					break;
				}
			}
			// if is not in memory, load it from file
			if (PlayerFrame::last_was_volumic || faceLoadedIndex == -1 || PlayerFrame::lastBuffers[faceLoadedIndex]->Vertices.size() != buffer->Vertices.size())
			{
				inface.open(faceFileName.c_str(), ios::in | ios::binary); // opens the face file
				if (!inface || !inface.good())
				{
					device->getLogger()->log(( stringc("ERROR: This face file could not be opened : ") + faceFileName ).c_str());
					buffer->drop();
					continue;
				}

				// first line data : inface >> nb_of_tetrahedra >> dim >> nb_of_attr;
				inface.read(reinterpret_cast < char * > (&nb_of_faces), sizeof(int));
				device->getLogger()->log((stringw("Loading ")+stringw(nb_of_faces)+L" faces from "+stringw(faceFileName.c_str())+L"...").c_str());

				// we should have at least one face
				if (nb_of_faces < 1)
				{
					buffer->drop();
					continue;
				}

				// lets add the indices to the buffer
				buffer->Indices.set_used( (u32)(3 * nb_of_faces) );
				u32 i = 0;

				// this is one line : inface >> index >> p1 >> p2 >> p3;
				inface.read(reinterpret_cast < char * > (&p1), sizeof(int));
				inface.read(reinterpret_cast < char * > (&p2), sizeof(int));
				inface.read(reinterpret_cast < char * > (&p3), sizeof(int));
				while (!inface.eof() && inface.good())
				{
					// check if we are not out of bounds
					if (i > (u32)(3 * nb_of_faces - 3) || p1 > nb_of_points || p2 > nb_of_points || p3 > nb_of_points)
					{
						device->getLogger()->log("ERROR: the face file does not seem to be valid. ");
						buffer->drop();
						error = true;
						break;
					}

					// add 1 polygon per face.
					s32 ajust_index = -1;
					buffer->Indices[(u32)(i+0)] = (u32)(p1 + ajust_index);
					buffer->Indices[(u32)(i+1)] = (u32)(p3 + ajust_index);
					buffer->Indices[(u32)(i+2)] = (u32)(p2 + ajust_index);
					core::triangle3df t(
						buffer->Vertices[(u32)(p1 + ajust_index)].Pos,
						buffer->Vertices[(u32)(p3 + ajust_index)].Pos,
						buffer->Vertices[(u32)(p2 + ajust_index)].Pos);
					i += 3;

					buffer->Vertices[(u32)(p1 + ajust_index)].Normal = t.getNormal();
					buffer->Vertices[(u32)(p2 + ajust_index)].Normal = t.getNormal();
					buffer->Vertices[(u32)(p3 + ajust_index)].Normal = t.getNormal();

					// this is one line : inface >> index >> p1 >> p2 >> p3;
					inface.read(reinterpret_cast < char * > (&p1), sizeof(int));
					inface.read(reinterpret_cast < char * > (&p2), sizeof(int));
					inface.read(reinterpret_cast < char * > (&p3), sizeof(int));
				}

				inface.close();
				inface.clear();
			}
			else // we do not need to reload from the file !
			{
				buffer->Indices.reallocate(PlayerFrame::lastBuffers[faceLoadedIndex]->Indices.size());
				buffer->Indices = PlayerFrame::lastBuffers[faceLoadedIndex]->Indices;
				for (u32 j=0; j < buffer->Vertices.size(); j++)
					buffer->Vertices[j].Normal = PlayerFrame::lastBuffers[faceLoadedIndex]->Vertices[j].Normal;
			}
			// -----------------------------------------------------------------------
		}

		if (error)
			continue;

		// lets recalculate the bounding box and create the mesh
		for (u32 j=0; j < buffer->Vertices.size(); ++j)
			buffer->BoundingBox.addInternalPoint(buffer->Vertices[j].Pos);

		SMesh* mesh = new SMesh;
		mesh->addMeshBuffer(buffer);
		mesh->recalculateBoundingBox();

		// here we go, lets create the node that will owns the mesh data
		node = smgr->addMeshSceneNode( mesh );
		mesh->drop();
		if (!node)
		{
			node = NULL;
			continue;
		}
		node->setVisible(false);
		//node->setMaterialFlag(video::EMF_WIREFRAME, true);

		this->nodes.push_back( node );

		// updating last
		_lastEleFileNames.push_back( eleFileName );
		_lastFaceFileNames.push_back( faceFileName );
		_lastBuffers.push_back( buffer );
	}

	// clean history and update it
	PlayerFrame::lastEleFileNames = _lastEleFileNames;
	PlayerFrame::lastFaceFileNames = _lastFaceFileNames;
	for (u32 e=0; e < lastBuffers.size(); e++)
	{
		if (_lastBuffers.binary_search(PlayerFrame::lastBuffers[e]) == -1)
		{
			PlayerFrame::lastBuffers[e]->drop();
		}
	}
	PlayerFrame::lastBuffers = _lastBuffers;
	PlayerFrame::last_was_volumic = load_volumic;


	// that's it !
	device->getLogger()->log("Loaded.");
}
Exemplo n.º 26
0
bool EditorEventReceiver::OnEvent(const SEvent &event)
{
	if (!device || !env)
		return false;

	gui::IGUIElement* root = env->getRootGUIElement();
	core::stringc s = "";

	// Mouse
	if (event.EventType == EET_MOUSE_INPUT_EVENT)
	{
		scene::ICameraSceneNode * activeCam = smgr->getActiveCamera();

		/*if (event.MouseInput.Control || event.MouseInput.Shift)
			activeCam->setInputReceiverEnabled( false );
		else
			activeCam->setInputReceiverEnabled( true );*/


		if (event.MouseInput.isLeftPressed() && event.MouseInput.Control)
		{
			editor->selectNode();
		}
		else if (event.MouseInput.Shift && event.MouseInput.Event == EMIE_MOUSE_MOVED)
		{
			position2di mousePos;
			mousePos.X = event.MouseInput.X;
            mousePos.Y = event.MouseInput.Y; 
			if ((oldMousePos - mousePos).getLength() > 10)
				oldMousePos = mousePos;
			editor->moveSelectedNode(vector3df(
				(mousePos.X - oldMousePos.X) * cos(activeCam->getRotation().Y) + (mousePos.Y - oldMousePos.Y) * sin(activeCam->getRotation().Y),
				0,
				(mousePos.X - oldMousePos.X) * sin(activeCam->getRotation().Y) + (mousePos.Y - oldMousePos.Y) * cos(activeCam->getRotation().Y)));
			oldMousePos = mousePos;
		}
	}


	// Key pressed once
	if (event.EventType == EET_KEY_INPUT_EVENT &&
		event.KeyInput.PressedDown == false)
	{
		switch(event.KeyInput.Key)
		{
		// press escape to go back to maya view
		case KEY_ESCAPE:
			{
				setActiveCamera(camera[0]);
				if (root->getElementFromId(GUI_ID_STATIC_TEXT_CAMERA_FPS, true))
					root->getElementFromId(GUI_ID_STATIC_TEXT_CAMERA_FPS, true)->remove();
				break;
			}
		}
	}

	// Key pressed
	if (event.EventType == EET_KEY_INPUT_EVENT &&
		event.KeyInput.PressedDown == true)
	{
		switch(event.KeyInput.Key)
		{
		case KEY_UP:
			break;
		}
	}

	// GUI
	if (event.EventType == EET_GUI_EVENT)
	{
		s32 id = event.GUIEvent.Caller->getID();

		switch(event.GUIEvent.EventType)
		{
		case EGET_MENU_ITEM_SELECTED:
			{
				// a menu item was clicked

				IGUIContextMenu* menu = (IGUIContextMenu*)event.GUIEvent.Caller;
				s32 id = menu->getItemCommandId(menu->getSelectedItem());

				switch(id)
				{
				case GUI_ID_NEW_SCENE: // File -> New
					editor->stop();
					editor->start();
					break;
				case GUI_ID_OPEN_SCENE: // File -> Open scene
					opening = OPENING_SCENE;
					env->addFileOpenDialog(L"Please select a scene file to open");
					break;
				case GUI_ID_SAVE_SCENE: // File -> Save scene
					editor->askForFileName();
					break;
				case GUI_ID_TETRAHEDRALIZE_AND_SIMULATE_SCENE: // File -> Tetrahedralize scene
					askForParameters();
					break;
				case GUI_ID_OPEN_MODEL: // File -> Open Model
					opening = OPENING_MODEL;
					env->addFileOpenDialog(L"Please select a model file to open");
					break;
				case GUI_ID_SWITCH_TO_PLAYER: // File -> Switch to player
					editor->switchToPlayer();
					break;
				case GUI_ID_QUIT: // File -> Quit
					device->closeDevice();
					break;
				case GUI_ID_DEBUG_OFF: // View -> Debug Information
					menu->setItemChecked(menu->getSelectedItem()+1, false);
					menu->setItemChecked(menu->getSelectedItem()+2, false);
					menu->setItemChecked(menu->getSelectedItem()+3, false);
					menu->setItemChecked(menu->getSelectedItem()+4, false);
					menu->setItemChecked(menu->getSelectedItem()+5, false);
					menu->setItemChecked(menu->getSelectedItem()+6, false);
					editor->setDebugDataVisible(scene::EDS_OFF);
					break;
				case GUI_ID_DEBUG_BOUNDING_BOX: // View -> Debug Information
					menu->setItemChecked(menu->getSelectedItem(), !menu->isItemChecked(menu->getSelectedItem()));
					editor->setDebugDataVisible((scene::E_DEBUG_SCENE_TYPE)(editor->isDebugDataVisible()^scene::EDS_BBOX));
					break;
				case GUI_ID_DEBUG_NORMALS: // View -> Debug Information
					menu->setItemChecked(menu->getSelectedItem(), !menu->isItemChecked(menu->getSelectedItem()));
					editor->setDebugDataVisible((scene::E_DEBUG_SCENE_TYPE)(editor->isDebugDataVisible()^scene::EDS_NORMALS));
					break;
				case GUI_ID_DEBUG_WIRE_OVERLAY: // View -> Debug Information
					menu->setItemChecked(menu->getSelectedItem(), !menu->isItemChecked(menu->getSelectedItem()));
					editor->setDebugDataVisible((scene::E_DEBUG_SCENE_TYPE)(editor->isDebugDataVisible()^scene::EDS_MESH_WIRE_OVERLAY));
					break;
				case GUI_ID_DEBUG_HALF_TRANSPARENT: // View -> Debug Information
					menu->setItemChecked(menu->getSelectedItem(), !menu->isItemChecked(menu->getSelectedItem()));
					editor->setDebugDataVisible((scene::E_DEBUG_SCENE_TYPE)(editor->isDebugDataVisible()^scene::EDS_HALF_TRANSPARENCY));
					break;
				case GUI_ID_DEBUG_BUFFERS_BOUNDING_BOXES: // View -> Debug Information
					menu->setItemChecked(menu->getSelectedItem(), !menu->isItemChecked(menu->getSelectedItem()));
					editor->setDebugDataVisible((scene::E_DEBUG_SCENE_TYPE)(editor->isDebugDataVisible()^scene::EDS_BBOX_BUFFERS));
					break;
				case GUI_ID_DEBUG_ALL: // View -> Debug Information
					menu->setItemChecked(menu->getSelectedItem()-1, true);
					menu->setItemChecked(menu->getSelectedItem()-2, true);
					menu->setItemChecked(menu->getSelectedItem()-3, true);
					menu->setItemChecked(menu->getSelectedItem()-4, true);
					menu->setItemChecked(menu->getSelectedItem()-5, true);
					menu->setItemChecked(menu->getSelectedItem()-6, true);
					editor->setDebugDataVisible(scene::EDS_FULL);
					break;
				case GUI_ID_ABOUT: // Help->About
					showHelp();
					break;

				case GUI_ID_CAMERA_MAYA:
					setActiveCamera(camera[0]);
					if (root->getElementFromId(GUI_ID_STATIC_TEXT_CAMERA_FPS, true))
						root->getElementFromId(GUI_ID_STATIC_TEXT_CAMERA_FPS, true)->remove();
					break;
				case GUI_ID_CAMERA_FIRST_PERSON:
					setActiveCamera(camera[1]);
					env->addStaticText(L"Press Escape to go back to maya-style camera mode.", core::rect<s32>(20,60,220,75), true, true, 0, GUI_ID_STATIC_TEXT_CAMERA_FPS);
					break;

				}
			break;
			}

		case EGET_FILE_SELECTED:
			{
				// load the model file, selected in the file open dialog
				IGUIFileOpenDialog* dialog =
					(IGUIFileOpenDialog*)event.GUIEvent.Caller;
				if (opening == OPENING_MODEL)
					editor->add3DModel(core::stringc(dialog->getFileName()).c_str());
				else if (opening == OPENING_SCENE)
					editor->load(core::stringc(dialog->getFileName()).c_str());
			}
			break;

		case EGET_SCROLL_BAR_CHANGED:
			break;

		case EGET_COMBO_BOX_CHANGED:
			break;

		case EGET_BUTTON_CLICKED:
			switch(id)
			{
			case GUI_ID_TOOL_BOX_SET_BUTTON:
				editor->setPositionRotationScaleOfSelectedNode();
				break;
			case GUI_ID_TOOL_BOX_DELETE_BUTTON:
				showConfirmDeleteNode();
				break;
			case GUI_ID_FORCE_FIELD_TOOL_BOX_SET_BUTTON:
				editor->setForceField();
				break;
			case GUI_ID_ASK_FILENAME_OK_BUTTON:
				s = root->getElementFromId(GUI_ID_ASK_FILENAME_NAME, true)->getText();
				if (s.size() == 0)
					s = "untitled.xml";
				editor->save(s.c_str());
				if (root->getElementFromId(GUI_ID_ASK_FILENAME_WINDOW, true))
					root->getElementFromId(GUI_ID_ASK_FILENAME_WINDOW, true)->remove();
				break;
			case GUI_ID_CONFIRM_DELETE_BUTTON:
				editor->remove3DModel();
				if (root->getElementFromId(GUI_ID_CONFIRM_DELETE_WINDOW, true))
					root->getElementFromId(GUI_ID_CONFIRM_DELETE_WINDOW, true)->remove();
				break;
			case GUI_ID_ASK_FILENAME_CANCEL_BUTTON:
				if (root->getElementFromId(GUI_ID_ASK_FILENAME_WINDOW, true))
					root->getElementFromId(GUI_ID_ASK_FILENAME_WINDOW, true)->remove();
				break;
			case GUI_ID_CANCEL_DELETE_BUTTON:
				if (root->getElementFromId(GUI_ID_CONFIRM_DELETE_WINDOW, true))
					root->getElementFromId(GUI_ID_CONFIRM_DELETE_WINDOW, true)->remove();
				break;
			case GUI_ID_ASK_PARAMETERS_GO_BUTTON:
				editor->quickTetAndSimulate();
				break;
			case GUI_ID_ASK_PARAMETERS_CANCEL_BUTTON:
				if (root->getElementFromId(GUI_ID_ASK_PARAMETERS_WINDOW, true))
					root->getElementFromId(GUI_ID_ASK_PARAMETERS_WINDOW, true)->remove();
				break;
			case GUI_ID_ASK_SWITCH_YES_BUTTON:
				if (root->getElementFromId(GUI_ID_ASK_SWITCH_WINDOW, true))
					root->getElementFromId(GUI_ID_ASK_SWITCH_WINDOW, true)->remove();
				editor->switchToPlayer(editor->getLastSimulatedSceneOutDir());;
				break;
			case GUI_ID_ASK_SWITCH_NO_BUTTON:
				if (root->getElementFromId(GUI_ID_ASK_SWITCH_WINDOW, true))
					root->getElementFromId(GUI_ID_ASK_SWITCH_WINDOW, true)->remove();
				break;
			case GUI_ID_OPEN_DIALOG_BUTTON:
				opening = OPENING_MODEL;
				env->addFileOpenDialog(L"Please select a model file to open");
				break;
			case GUI_ID_FORCE_FIELD_BUTTON:
				editor->createForceFieldToolBox();
				break;
			case GUI_ID_HELP_BUTTON:
				showHelp();
				break;
			case GUI_ID_TOOL_BOX_INCREASE_POSITION_X:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_X_POSITION, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_X_POSITION, true)->setText(stringw( 1.0f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;
			case GUI_ID_TOOL_BOX_DECREASE_POSITION_X:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_X_POSITION, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_X_POSITION, true)->setText(stringw( -1.0f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;
			case GUI_ID_TOOL_BOX_INCREASE_POSITION_Y:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_Y_POSITION, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_Y_POSITION, true)->setText(stringw( 1.0f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;
			case GUI_ID_TOOL_BOX_DECREASE_POSITION_Y:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_Y_POSITION, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_Y_POSITION, true)->setText(stringw( -1.0f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;
			case GUI_ID_TOOL_BOX_INCREASE_POSITION_Z:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_Z_POSITION, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_Z_POSITION, true)->setText(stringw( 1.0f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;
			case GUI_ID_TOOL_BOX_DECREASE_POSITION_Z:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_Z_POSITION, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_Z_POSITION, true)->setText(stringw( -1.0f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;

			case GUI_ID_TOOL_BOX_INCREASE_ROTATION_X:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_X_ROTATION, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_X_ROTATION, true)->setText(stringw( 1.0f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;
			case GUI_ID_TOOL_BOX_DECREASE_ROTATION_X:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_X_ROTATION, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_X_ROTATION, true)->setText(stringw( -1.0f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;
			case GUI_ID_TOOL_BOX_INCREASE_ROTATION_Y:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_Y_ROTATION, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_Y_ROTATION, true)->setText(stringw( 1.0f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;
			case GUI_ID_TOOL_BOX_DECREASE_ROTATION_Y:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_Y_ROTATION, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_Y_ROTATION, true)->setText(stringw( -1.0f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;
			case GUI_ID_TOOL_BOX_INCREASE_ROTATION_Z:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_Z_ROTATION, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_Z_ROTATION, true)->setText(stringw( 1.0f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;
			case GUI_ID_TOOL_BOX_DECREASE_ROTATION_Z:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_Z_ROTATION, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_Z_ROTATION, true)->setText(stringw( -1.0f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;

			case GUI_ID_TOOL_BOX_INCREASE_SCALE_X:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_X_SCALE, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_X_SCALE, true)->setText(stringw( 0.01f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;
			case GUI_ID_TOOL_BOX_DECREASE_SCALE_X:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_X_SCALE, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_X_SCALE, true)->setText(stringw( -0.01f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;
			case GUI_ID_TOOL_BOX_INCREASE_SCALE_Y:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_Y_SCALE, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_Y_SCALE, true)->setText(stringw( 0.01f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;
			case GUI_ID_TOOL_BOX_DECREASE_SCALE_Y:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_Y_SCALE, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_Y_SCALE, true)->setText(stringw( -0.01f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;
			case GUI_ID_TOOL_BOX_INCREASE_SCALE_Z:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_Z_SCALE, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_Z_SCALE, true)->setText(stringw( 0.01f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;
			case GUI_ID_TOOL_BOX_DECREASE_SCALE_Z:
				s = root->getElementFromId(GUI_ID_TOOL_BOX_Z_SCALE, true)->getText();
				root->getElementFromId(GUI_ID_TOOL_BOX_Z_SCALE, true)->setText(stringw( -0.01f + (f32)atof(s.c_str()) ).c_str());
				editor->setPositionRotationScaleOfSelectedNode();
				break;

			}

			break;
		default:
			break;
		}
	}

	return false;
}
Exemplo n.º 27
0
void Input::cargarDesdeXML(int jugador,Receiver* receiver)
{
    this->jugador=jugador;
    this->receiver=receiver;
    this->inteligencia_artificial=false;
    TiXmlDocument doc_t((char*)"misc/inputs.xml");
    doc_t.LoadFile();
    TiXmlDocument *doc;
    doc=&doc_t;

    vector<Boton> botones;
    for(TiXmlNode* input=doc->FirstChild("Input");
            input!=NULL;
            input=input->NextSibling("Input"))
    {
        if(jugador==atoi(input->ToElement()->Attribute("player")))
        {
            //Key
            if(strcmp("keyboard",input->ToElement()->Attribute("type"))==0)
            {
                for(TiXmlNode* boton=input->FirstChild("button");
                        boton!=NULL;
                        boton=boton->NextSibling("button"))
                {
                    botones.push_back(Boton(receiver,(irr::EKEY_CODE)boton->ToElement()->Attribute("input")[0],stringw(boton->ToElement()->Attribute("map"))));
                }
            }
            //Joy
            if(strcmp("joystick",input->ToElement()->Attribute("type"))==0)
            {
                for(TiXmlNode* boton=input->FirstChild("button");
                        boton!=NULL;
                        boton=boton->NextSibling("button"))
                {
                    int int_boton;
                    if(strcmp(boton->ToElement()->Attribute("input"),"up")==0)
                        int_boton=-8;
                    else if(strcmp(boton->ToElement()->Attribute("input"),"down")==0)
                        int_boton=-2;
                    else if(strcmp(boton->ToElement()->Attribute("input"),"left")==0)
                        int_boton=-4;
                    else if(strcmp(boton->ToElement()->Attribute("input"),"right")==0)
                        int_boton=-6;
                    else
                        int_boton=boton->ToElement()->Attribute("input")[0]-48;
                    botones.push_back(Boton(receiver,int_boton,input->ToElement()->Attribute("joystick_number")[0]-48,boton->ToElement()->Attribute("map")));
                }
            }
        }
    }

    tecla_arriba=true;
    for(int i=0;i<20;i++)
        buffer_inputs.push_back("5");
    for(int i=0;i<(int)botones.size();i++)
    {
        if(botones[i].getMapeo()=="2" || botones[i].getMapeo()=="4" || botones[i].getMapeo()=="6" || botones[i].getMapeo()=="8")
        {
            this->cruz.push_back(botones[i]);
        }
        else
        {
            this->botones.push_back(botones[i]);
        }
    }
}
Exemplo n.º 28
0
		void dialog_about::initElements()
		{
			stringw title = stringw(lang_[L"About_WindowTitle"].c_str()).replace("{0}", APP_TITLE);

			window_ = new CGUIDecentralisedDialog(env_,
				env_->getRootGUIElement(),
				e_gui_elements::WindowAbout,
				rect<s32>(80, 40, 420, 250),
				true);
			window_->setDialogSkin(elems_.TxDialogBack, elems_.TxDialogFore);
			window_->setText(title.c_str());
			env_->setFocus(window_);
			window_->drop();

			s32 posy = 40;

			env_->addStaticText(APP_TITLE,
				rect<s32>(20, posy, 320, posy + 22),
				false, true,
				window_);

			posy += 22;

			CGUIDecentralisedButton* linkBtn = new CGUIDecentralisedButton(env_, window_, e_gui_elements::AboutLink, rect<s32>(20, posy, 198, posy + 22));
			linkBtn->setText(L"http://decentralised-project.org");
			linkBtn->setButtonTextAlign(e_button_text_align::Left);
			linkBtn->setOverrideTextColor(SColor(255, 101, 174, 235));
			linkBtn->drop();

			posy += 34;

			stringw lead = stringw(lang_[L"About_LeadIntro"].c_str()).replace("{0}", APP_TITLE);
			env_->addStaticText(lead.c_str(),
				rect<s32>(20, posy, 320, posy + 44),
				false, true,
				window_);

			posy += 44;

			env_->addStaticText(lang_[L"About_Credit1"].c_str(),
				rect<s32>(20, posy, 320, posy + 22),
				false, true,
				window_);

			posy += 22;

			env_->addStaticText(lang_[L"About_Credit2"].c_str(),
				rect<s32>(20, posy, 320, posy + 22),
				false, true,
				window_);

			posy += 22;

			env_->addStaticText(lang_[L"About_Credit3"].c_str(),
				rect<s32>(20, posy, 320, posy + 22),
				false, true,
				window_);

			posy += 22;

		}
Exemplo n.º 29
0
void Input::actualizarBuffer(irr::core::map<stringw,stringw>*strings,
                             irr::core::map<stringw,stringw>*strings_contrario,
                             irr::core::map<stringw,int>*enteros,
                             irr::core::map<stringw,int>*enteros_contrario
                             )
{
    stringw resultado="";
    if(!inteligencia_artificial)
    {
        for(int i=0;i<(int)cruz.size();i++)
            if(cruz[i].estaPresionado())
                resultado+=cruz[i].getMapeo();
        if(resultado=="24" || resultado=="42")
            resultado="1";
        if(resultado=="26" || resultado=="62")
            resultado="3";
        if(resultado=="84" || resultado=="48")
            resultado="7";
        if(resultado=="68" || resultado=="86")
            resultado="9";
        if(tecla_arriba)
        {
            tecla_arriba=false;
            for(int i=0;i<(int)botones.size();i++)
                if(botones[i].estaPresionado())
                    resultado+=botones[i].getMapeo();
        }
        bool flag=false;
        for(int i=0;i<(int)botones.size();i++)
            if(botones[i].estaPresionado())
                flag=true;
        if(!flag)
            tecla_arriba=true;
    }
    else
    {
        resultado=ia->getInput(strings,strings_contrario,enteros,enteros_contrario);
    }
    if(resultado=="")
        resultado="5";

//inicio
resultado="5";
if(receiver->IsKeyDownn(irr::KEY_DOWN))
  resultado="2";
if(receiver->IsKeyDownn(irr::KEY_UP))
  resultado="8";
if(receiver->IsKeyDownn(irr::KEY_RIGHT))
  resultado="6";
if(receiver->IsKeyDownn(irr::KEY_LEFT))
  resultado="4";
if(receiver->IsKeyDownn(irr::KEY_KEY_U))
  resultado="a";
if(receiver->IsKeyDownn(irr::KEY_KEY_I))
  resultado="b";
//fin

    if(stringw(strings->operator[]("orientation"))==stringw("i"))
    {
        for(int i=0;i<(int)resultado.size();i++)
        {
            if(resultado[i]=='4')resultado[i]='6';
            else if(resultado[i]=='6')resultado[i]='4';
            else if(resultado[i]=='3')resultado[i]='1';
            else if(resultado[i]=='1')resultado[i]='3';
            else if(resultado[i]=='7')resultado[i]='9';
            else if(resultado[i]=='9')resultado[i]='7';
        }
    }
    buffer_inputs.insert(buffer_inputs.begin(),resultado);
    buffer_inputs.pop_back();
}
Exemplo n.º 30
0
	// load the level objects from disk file
	bool CSLevel::loadFromDisk(stringc filename, bool destroyOld)
	{
		CS_LOG(CSLOGTYPE::CSL_DEBUG, "*************************** Loading level from file %s ***************************", filename.c_str());
		if (destroyOld) clear();

		// attempt to open the file
		IXMLReader* reader = getDevice()->getFileSystem()->createXMLReader(filename);
		if (!reader) 
		{ 
			CS_LOG(CSLOGTYPE::CSL_WARNING, "Warning! unable to open file %s", filename.c_str());
			return false; 
		}

		// read file
		while (reader->read())
		{
			// based on the node type
			switch (reader->getNodeType())
			{
			case io::EXN_ELEMENT:
			{
				// get the node name
				stringw name = reader->getNodeName();
				// if this is an object definition
				if (stringw("CAMERA") == name)
				{
					stringw pos = reader->getAttributeValueSafe(L"POSITION");
					stringw tar = reader->getAttributeValueSafe(L"TARGET");
					if (getCamera())
					{
						getCamera()->setPosition(stringcToVector3df(stringc(pos)));
						getCamera()->setTarget(stringcToVector3df(stringc(tar)));
					}
					else CS_LOG(CSLOGTYPE::CSL_WARNING, "no camera in game save file");
				}
					
				// if this is an object definition
				if (stringw("CSOBJECT") == name)
				{
					// get the object type
					stringw type = reader->getAttributeValueSafe(L"TYPE");

					// attempt to create the object
					CSObject* obj = getObjectFactory()->createObjectByType(stringc(type));
					if (obj)
					{
						// load the attributes from the file
						IAttributes* attr = getDevice()->getFileSystem()->createEmptyAttributes(getDriver());
						attr->read(reader, false);

						// let the object deserialize from the attributes
						obj->deserializeAttributes(attr);

						// recreate the object using the new attribtues
						obj->reCreate();

						// drop the pointer
						attr->drop();
					}
				}
			}
			}
		}

		// drop the reader
		reader->drop();

		CS_LOG(CSLOGTYPE::CSL_DEBUG, "*************************** finished Loading level from file %s ***************************", filename.c_str());

		// everything went fine
		return true;
	}