EffectHandler::SPostProcessingPair EffectHandler::obtainScreenQuadMaterialFromFile(const irr::core::stringc& filename,
        irr::video::E_MATERIAL_TYPE baseMaterial)
{
    CShaderPreprocessor sPP(driver);

    sPP.addShaderDefine("SCREENX", core::stringc(ScreenRTTSize.Width));
    sPP.addShaderDefine("SCREENY", core::stringc(ScreenRTTSize.Height));

    video::E_VERTEX_SHADER_TYPE VertexLevel = driver->queryFeature(video::EVDF_VERTEX_SHADER_3_0) ? EVST_VS_3_0 : EVST_VS_2_0;
    video::E_PIXEL_SHADER_TYPE PixelLevel = driver->queryFeature(video::EVDF_PIXEL_SHADER_3_0) ? EPST_PS_3_0 : EPST_PS_2_0;

    E_SHADER_EXTENSION shaderExt = (driver->getDriverType() == EDT_DIRECT3D9) ? ESE_HLSL : ESE_GLSL;

    video::IGPUProgrammingServices* gpu = driver->getGPUProgrammingServices();

    const stringc shaderString = sPP.ppShaderFF(filename.c_str());

    ScreenQuadCB* SQCB = new ScreenQuadCB(this, true);

    s32 PostMat = gpu->addHighLevelShaderMaterial(
                      sPP.ppShader(SCREEN_QUAD_V[shaderExt]).c_str(), "vertexMain", VertexLevel,
                      shaderString.c_str(), "pixelMain", PixelLevel,
                      SQCB, baseMaterial);

    SPostProcessingPair pPair(PostMat, SQCB);

    SQCB->drop();

    return pPair;
}
Exemple #2
0
// ----------------------------------------------------------------------------
void Editor::writeStrc(FILE* fp, stringc str)
{
    u8 size;
    size = str.size() + 1;
    fwrite(&size, sizeof(u8), 1, fp);
    fwrite(str.c_str(), sizeof(c8), size, fp);
} // writeStrc
Exemple #3
0
CXSpritePtr XSpriteManager::createRes(const stringc& name, int flag)
{		
	CXSpritePtr sprite = new CXSprite();
	if(sprite->LoadFromFile(name.c_str()))
	{
		sprite->setName(name);
		DBG("engineDbg_Res","create sprite name: %s", name.c_str());
	}
	else
	{
		sprite = 0;
		DBG("engineDbg_Res","can not create sprite, name: %s", name.c_str());
	}	

	if(sprite.isValid())
	{
		stringc baseName, exten, path;

		StringUtil::splitFullFilename(name, baseName, exten, path);
		baseName = path+baseName+".tga";

		renderer::TextureManager& texMgr = renderer::TextureManager::getInstance();				
		sprite->SetTexture(texMgr.getRes(baseName));
	}

	return sprite;
}
Exemple #4
0
// ----------------------------------------------------------------------------
stringc Editor::getLib(stringc s)
{
    u32 ix;
    ix = s.findLast('/');
    s = s.subString(0, ix);
    ix = s.findLast('/');
    s = s.subString(ix + 1, s.size() - ix - 1);
    return s;
} // getLib
Exemple #5
0
	s32 getSettingAsInteger(const stringw& key) const
	{
		//we implicitly cast to string instead of stringw because strtol10 does not accept wide strings
		const stringc s = getSetting(key);
		if (s.empty())
			return 0;

		return strtol10(s.c_str());
	}
Exemple #6
0
__MY_CORE_LIB_API__ const c8* getSingletonsTableAsPrintableString()
{
	_PrintableString.sprintf(
		"&Device                = %p, Device                = %p\n"
		"&PluginManager         = %p, PluginManager         = %p\n"
		"&Profiler              = %p, Profiler              = %p\n"
		"&Logger                = %p, Logger                = %p\n"
		"&FileSystem            = %p, FileSystem            = %p\n"
		"&InputDispatcher       = %p, InputDispatcher       = %p\n"
		"&CursorControl         = %p, CursorControl         = %p\n"
		"&TimerMain             = %p, TimerMain             = %p\n"
		"&TimerSecond           = %p, TimerSecond           = %p\n"
		"&MemStatus             = %p, MemStatus             = %p\n"
		"&SoundDriver           = %p, SoundDriver           = %p\n"
		"&CoreScriptManager     = %p, CoreScriptManager     = %p\n"
		"&ScriptManager         = %p, ScriptManager         = %p\n"
		"&DynamicManager        = %p, DynamicManager        = %p\n"
		"&SceneManager          = %p, SceneManager          = %p\n"
		"&PathFinderManager     = %p, PathFinderManager     = %p\n"
		"&LightGridManager      = %p, LightGridManager      = %p\n"
		"&MaterialsManager      = %p, MaterialsManager      = %p\n"
		"&CullingSystem         = %p, CullingSystem         = %p\n"
		"&ImageLibrary          = %p, ImageLibrary          = %p\n"
		"&VideoDriver           = %p, VideoDriver           = %p\n"
		"&GameManager           = %p, GameManager           = %p\n"
		"&GameAIModule          = %p, GameAIModule          = %p\n"
		"&GameEventsDispatcher  = %p, GameEventsDispatcher  = %p\n"
		"&GameTasksManager      = %p, GameTasksManager      = %p\n"
		"&ResourceManager       = %p, ResourceManager       = %p",
		&g_SingletonsTable.Ptrs.Device,					g_SingletonsTable.Ptrs.Device,
		&g_SingletonsTable.Ptrs.PluginManager,			g_SingletonsTable.Ptrs.PluginManager,
		&g_SingletonsTable.Ptrs.Profiler,				g_SingletonsTable.Ptrs.Profiler,
		&g_SingletonsTable.Ptrs.Logger,					g_SingletonsTable.Ptrs.Logger,
		&g_SingletonsTable.Ptrs.FileSystem,				g_SingletonsTable.Ptrs.FileSystem,
		&g_SingletonsTable.Ptrs.InputDispatcher,		g_SingletonsTable.Ptrs.InputDispatcher,
		&g_SingletonsTable.Ptrs.CursorControl,			g_SingletonsTable.Ptrs.CursorControl,
		&g_SingletonsTable.Ptrs.TimerMain,				g_SingletonsTable.Ptrs.TimerMain,
		&g_SingletonsTable.Ptrs.TimerSecond,			g_SingletonsTable.Ptrs.TimerSecond,
		&g_SingletonsTable.Ptrs.MemStatus,				g_SingletonsTable.Ptrs.MemStatus,
		&g_SingletonsTable.Ptrs.SoundDriver,			g_SingletonsTable.Ptrs.SoundDriver,
		&g_SingletonsTable.Ptrs.CoreScriptManager,		g_SingletonsTable.Ptrs.CoreScriptManager,
		&g_SingletonsTable.Ptrs.ScriptManager,			g_SingletonsTable.Ptrs.ScriptManager,
		&g_SingletonsTable.Ptrs.DynamicManager,			g_SingletonsTable.Ptrs.DynamicManager,
		&g_SingletonsTable.Ptrs.SceneManager,			g_SingletonsTable.Ptrs.SceneManager,
		&g_SingletonsTable.Ptrs.PathFinderManager,		g_SingletonsTable.Ptrs.PathFinderManager,
		&g_SingletonsTable.Ptrs.LightGridManager,		g_SingletonsTable.Ptrs.LightGridManager,
		&g_SingletonsTable.Ptrs.MaterialsManager,		g_SingletonsTable.Ptrs.MaterialsManager,
		&g_SingletonsTable.Ptrs.CullingSystem,			g_SingletonsTable.Ptrs.CullingSystem,
		&g_SingletonsTable.Ptrs.ImageLibrary,			g_SingletonsTable.Ptrs.ImageLibrary,
		&g_SingletonsTable.Ptrs.VideoDriver,			g_SingletonsTable.Ptrs.VideoDriver,
		&g_SingletonsTable.Ptrs.GameManager,			g_SingletonsTable.Ptrs.GameManager,
		&g_SingletonsTable.Ptrs.GameAIModule,			g_SingletonsTable.Ptrs.GameAIModule,
		&g_SingletonsTable.Ptrs.GameEventsDispatcher,	g_SingletonsTable.Ptrs.GameEventsDispatcher,
		&g_SingletonsTable.Ptrs.GameTasksManager,		g_SingletonsTable.Ptrs.GameTasksManager,
		&g_SingletonsTable.Ptrs.ResourceManager,		g_SingletonsTable.Ptrs.ResourceManager);
	return _PrintableString.c_str();
}
Exemple #7
0
 //-------------------------------------------------------------------------
 //                              l o g M e s s a g e 
 //-------------------------------------------------------------------------
 void CApplication::logMessage(stringc msg)
 {
     msg += "\n";
     fputs(msg.c_str(), stdout);
     if(m_logFile)
     {
         m_logFile->write(msg.c_str(),msg.size());
         m_logFile->write("\n",1);
     }
 }
Exemple #8
0
Scenario::Scenario(IrrlichtDevice* dev, stringc file, stringc mapName)
{
    device = dev;

    device->getFileSystem()->addZipFileArchive(file.c_str());

    IAnimatedMesh* mesh = device->getSceneManager()->getMesh(mapName.c_str());

    ISceneNode* node = device->getSceneManager()->addOctreeSceneNode(mesh->getMesh(0), 0, -1, 1024);

}
Exemple #9
0
    //-------------------------------------------------------------------------
    //                         _ e x t r a c t D i r 
    //-------------------------------------------------------------------------
    stringc _extractDir(stringc filename)
    {
        stringc result="";
        // find last forward or backslash
        s32 lastSlash = filename.findLast('/');
        const s32 lastBackSlash = filename.findLast('\\');
        lastSlash = lastSlash > lastBackSlash ? lastSlash : lastBackSlash;

        if ((u32)lastSlash < filename.size())
            return filename.subString(0, lastSlash+1);
        else
            return ".";
    }
/// @brief SystemCall to stringc
stringc SingleSysCall( const stringc& command, const u32 LENGTH )
{
    /// open pipe to shell command result
	FILE *f = popen( command.c_str(), "r");
	if (!f) { printf ( "Could not open temporary file as bash script.\n" );	return stringc(""); }

	/// create linebuffer
	c8* buffer = new c8[LENGTH];
	if (!buffer) { printf ( "Sorry, but you are out of memory.\n" ); return stringc(""); }

	u32 lineCount = 0;

	stringc s = "";

	while (fgets(buffer, LENGTH, f))
	{
		/* ... */
		lineCount++;
		s += stringc(buffer);
	}

	delete buffer;

	pclose(f);

	return s;
}
void NBEFileParser::parseLine(stringc line){
	stringc l = line.trim(" \t\n\r");

	if (l == "")
		return;

	#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8
		stringc lw = irr::core::stringc(l);
		lw.make_lower();		
	#else
		stringc lw = l.make_lower();
	#endif
	

	if (stage == ERS_ROOT){
		if (lw.find("name ") == 0){
			stringc name = l.subString(4, l.size());
			proj->name = name.trim();
		}else if (lw.find("node ") == 0){
			stage = ERS_NODE;
			node = new Node(state->GetDevice(),state,proj->GetNodeCount());
			stringc name = l.subString(4,l.size());
			node->name = name.trim();
		}
	}else if (stage == ERS_NODE){
		if (lw.find("position ") == 0){
			printf("-- position parser not complete!\n");
		}else if (lw.find("nodebox ") == 0){
			stringc n = l.subString(7,l.size());
			n = n.trim();
			stringc ls[7];
			int i = 0;
			while (n!=""){
				int nid = n.find(" ");

				if (nid==-1){
					nid = n.size();
				}
				if (i>=7){
					printf("-- too many arguments to nodebox tag!\n%s\n",n.c_str());
					break;
				}
				ls[i] = n.subString(0,nid).trim();
				n = n.subString(nid,n.size()).trim();
				printf(">> %i ",i);
				printf(" is '%s'\n",ls[i].c_str());
				i++;				
			}
			node->addNodeBox();
			node->GetCurrentNodeBox()->name = ls[0];
			node->GetCurrentNodeBox()->one = vector3df(atof(ls[1].c_str()),atof(ls[2].c_str()),atof(ls[3].c_str()));
			node->GetCurrentNodeBox()->two = vector3df(atof(ls[4].c_str()),atof(ls[5].c_str()),atof(ls[6].c_str()));
			node->remesh();
		}else if (lw.find("end node") == 0){
			proj->AddNode(node);
			node = NULL;
			stage = ERS_ROOT;
		}		
	}
}
bool LoadLines( Container& container, const stringc& filename, const u32 LENGTH )
{
    /// open file
	FILE *f = fopen( filename.c_str(), "r");
	if (!f)	{ printf ( "Could not open file.\n" ); return false; }

	/// create buffer
	c8* b = new c8[LENGTH];
	if (!b) { printf ( "Sorry, but you are out of memory.\n" ); return false; }

	/// read line-count
	u32 lineCount = 0;
	while (fgets(b, LENGTH, f)) { lineCount++; }

	/// process line-count
	printf ( "Loaded file has %d container.\n", lineCount );
	if (lineCount == 0) { fclose(f); return false; }

	/// reallocate container
	container.reallocate( lineCount );
	container.set_used( 0 );

	/// rewind
	fseek( f, 0L, SEEK_SET );

	/// fill container
	while (fgets(b, LENGTH, f)) { container.push_back( stringc(b) ); }

	/// end
	fclose(f);
	if (b) delete b;
	return true;
}
bool StoreLines( const Container& container, const stringc& filename )
{
    /// open file
	FILE *f = fopen( filename.c_str(), "w");
	if (!f)
	{
		printf ( "Could not open temporary write-file.\n" );
		return false;
	}

	u32 i = 0;
	while (f && i<container.size())
	{
		fputs( container[i].c_str(), f );
		// if ( container[i].size() > fputs( container[i].c_str(), f ) )
		// {
		//		printf ( "Maybe some error while reading [%d].\n", i );
		// }
		fputs( "\n", f );
		i++;
	}

	fclose( f );
	f = 0;

	return true;
}
Exemple #14
0
bool CLanguages::setLanguage(stringc lang)
{
	m_Language->value = lang;
	bool found = false;

	for (u32 i=0; i< m_ListOfAvailableLanguages.size(); i++)
	{
		if(m_ListOfAvailableLanguages[i]->value.equals_ignore_case(lang))
		{
			m_Language->name = m_ListOfAvailableLanguages[i]->name;
			m_Language->index = m_ListOfAvailableLanguages[i]->index;
			found = true;
		}
	}

	if(!found)
	{
		printf("Language '%s' not found! Setting english as default language.\n", lang.c_str());
		m_Language->value = "en";
		m_Language->name = "english";
		m_Language->index = 0;
	}

	LoadStringTable();

	return found;
}
bool StoreCall( const stringc& command, const stringc& filename, const u32 LENGTH )
{
    /// open shell-pipe
	FILE *_shell = popen( command.c_str(), "r");
	if (!_shell) { printf ( "%s > %s\n", command.c_str(), filename.c_str() ); return false; }

	/// open write-file
	FILE *_file = fopen( filename.c_str(), "w");
	if (!_file)	{ printf ( "Could not open write-file %s.\n", filename.c_str() ); return false; }

	printf ( "%s > %s OK\n", command.c_str(), filename.c_str() );

	/// create linebuffer
	c8* _buffer = new c8[LENGTH];
	if (!_buffer) { printf ( "Sorry, but you are out of memory.\n" ); return false; }

	u32 lineCount = 0;

	while (fgets(_buffer, LENGTH, _shell))
	{
		fputs(_buffer, _file);
		lineCount++;
	}

	delete _buffer;

	pclose(_shell);
	fclose(_file);

	return true;
}
bool trimLine( stringc& line, u32 loop_count, const c8* char_list, const u32 char_count )
{
	u32 k_max = 3;
	bool result = false;

	/// find from start
	u32 k = 0;
	s32 pos = line.findFirstChar(char_list, char_count);
	if ( pos != -1 )
	{
		result = true;
		while ( (pos != -1) && (k<k_max) )
		{
			line.erase( k ); // more hackisch
			pos = line.findFirstChar(char_list, char_count);
			k++;
		}
	}

	/// find from back
	k = 0;
	pos = line.findLastChar(char_list, char_count);
	if ( pos != -1 )
	{
		result = true;
		while ( (pos != -1) && (k<k_max) )
		{
			line.erase( line.size()-1 ); // more hackisch
			pos = line.findLastChar(char_list, char_count);
			k++;
		}
	}
	return result;
}
	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;
	}
/// @brief List all files of given extension-list
u32 FindFiles( Container& out, const stringc& rootDir, const Container& fileTypes )
{
	if (rootDir.size()==0)
		return 0;

	if (fileTypes.size()==0)
		return 0;

	const u32 old_size = out.size();

	for (u32 i=0; i<fileTypes.size(); i++)
	{
		core::stringc command;
		command = "find ";
		command += rootDir;
		command += " -iname '*.";
		command += fileTypes[i];
		command += "' | sort";
		AddLines( out, command );
	}
	return out.size() - old_size; // return Number of added lines(stringc) to container 'out'.
}
	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;
	}
void NativeIrrlicht::setPath(std::string path) {
    gSdCardPath = path.c_str();
    __android_log_print(ANDROID_LOG_INFO, "Irrlicht", "not handled %s", gSdCardPath.c_str());
}
	// 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;
	}
	// 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;
	}
Exemple #23
0
namespace core {
//----------------------------------------------------------------------------

//! global table of the singleton objects pointers
SSingletonsTable g_SingletonsTable;

static stringc _PrintableString;

//----------------------------------------------------------------------------

__MY_CORE_LIB_API__ const SSingletonsTable& getSingletonsTable()
{ return g_SingletonsTable; }

//----------------------------------------------------------------------------

__MY_CORE_LIB_API__ const c8* getSingletonsTableAsPrintableString()
{
	_PrintableString.sprintf(
		"&Device                = %p, Device                = %p\n"
		"&PluginManager         = %p, PluginManager         = %p\n"
		"&Profiler              = %p, Profiler              = %p\n"
		"&Logger                = %p, Logger                = %p\n"
		"&FileSystem            = %p, FileSystem            = %p\n"
		"&InputDispatcher       = %p, InputDispatcher       = %p\n"
		"&CursorControl         = %p, CursorControl         = %p\n"
		"&TimerMain             = %p, TimerMain             = %p\n"
		"&TimerSecond           = %p, TimerSecond           = %p\n"
		"&MemStatus             = %p, MemStatus             = %p\n"
		"&SoundDriver           = %p, SoundDriver           = %p\n"
		"&CoreScriptManager     = %p, CoreScriptManager     = %p\n"
		"&ScriptManager         = %p, ScriptManager         = %p\n"
		"&DynamicManager        = %p, DynamicManager        = %p\n"
		"&SceneManager          = %p, SceneManager          = %p\n"
		"&PathFinderManager     = %p, PathFinderManager     = %p\n"
		"&LightGridManager      = %p, LightGridManager      = %p\n"
		"&MaterialsManager      = %p, MaterialsManager      = %p\n"
		"&CullingSystem         = %p, CullingSystem         = %p\n"
		"&ImageLibrary          = %p, ImageLibrary          = %p\n"
		"&VideoDriver           = %p, VideoDriver           = %p\n"
		"&GameManager           = %p, GameManager           = %p\n"
		"&GameAIModule          = %p, GameAIModule          = %p\n"
		"&GameEventsDispatcher  = %p, GameEventsDispatcher  = %p\n"
		"&GameTasksManager      = %p, GameTasksManager      = %p\n"
		"&ResourceManager       = %p, ResourceManager       = %p",
		&g_SingletonsTable.Ptrs.Device,					g_SingletonsTable.Ptrs.Device,
		&g_SingletonsTable.Ptrs.PluginManager,			g_SingletonsTable.Ptrs.PluginManager,
		&g_SingletonsTable.Ptrs.Profiler,				g_SingletonsTable.Ptrs.Profiler,
		&g_SingletonsTable.Ptrs.Logger,					g_SingletonsTable.Ptrs.Logger,
		&g_SingletonsTable.Ptrs.FileSystem,				g_SingletonsTable.Ptrs.FileSystem,
		&g_SingletonsTable.Ptrs.InputDispatcher,		g_SingletonsTable.Ptrs.InputDispatcher,
		&g_SingletonsTable.Ptrs.CursorControl,			g_SingletonsTable.Ptrs.CursorControl,
		&g_SingletonsTable.Ptrs.TimerMain,				g_SingletonsTable.Ptrs.TimerMain,
		&g_SingletonsTable.Ptrs.TimerSecond,			g_SingletonsTable.Ptrs.TimerSecond,
		&g_SingletonsTable.Ptrs.MemStatus,				g_SingletonsTable.Ptrs.MemStatus,
		&g_SingletonsTable.Ptrs.SoundDriver,			g_SingletonsTable.Ptrs.SoundDriver,
		&g_SingletonsTable.Ptrs.CoreScriptManager,		g_SingletonsTable.Ptrs.CoreScriptManager,
		&g_SingletonsTable.Ptrs.ScriptManager,			g_SingletonsTable.Ptrs.ScriptManager,
		&g_SingletonsTable.Ptrs.DynamicManager,			g_SingletonsTable.Ptrs.DynamicManager,
		&g_SingletonsTable.Ptrs.SceneManager,			g_SingletonsTable.Ptrs.SceneManager,
		&g_SingletonsTable.Ptrs.PathFinderManager,		g_SingletonsTable.Ptrs.PathFinderManager,
		&g_SingletonsTable.Ptrs.LightGridManager,		g_SingletonsTable.Ptrs.LightGridManager,
		&g_SingletonsTable.Ptrs.MaterialsManager,		g_SingletonsTable.Ptrs.MaterialsManager,
		&g_SingletonsTable.Ptrs.CullingSystem,			g_SingletonsTable.Ptrs.CullingSystem,
		&g_SingletonsTable.Ptrs.ImageLibrary,			g_SingletonsTable.Ptrs.ImageLibrary,
		&g_SingletonsTable.Ptrs.VideoDriver,			g_SingletonsTable.Ptrs.VideoDriver,
		&g_SingletonsTable.Ptrs.GameManager,			g_SingletonsTable.Ptrs.GameManager,
		&g_SingletonsTable.Ptrs.GameAIModule,			g_SingletonsTable.Ptrs.GameAIModule,
		&g_SingletonsTable.Ptrs.GameEventsDispatcher,	g_SingletonsTable.Ptrs.GameEventsDispatcher,
		&g_SingletonsTable.Ptrs.GameTasksManager,		g_SingletonsTable.Ptrs.GameTasksManager,
		&g_SingletonsTable.Ptrs.ResourceManager,		g_SingletonsTable.Ptrs.ResourceManager);
	return _PrintableString.c_str();
}

//----------------------------------------------------------------------------

__MY_CORE_LIB_API__ void initSingletonsTable(
	dev::IDevice				***Device_ms_Singleton,
	dev::IPluginManager			***PluginManager_ms_Singleton,
	dev::IProfiler				***Profiler_ms_Singleton,
	io::ILogger					***Logger_ms_Singleton,
	io::IFileSystem				***FileSystem_ms_Singleton,
	io::IInputDispatcher		***InputDispatcher_ms_Singleton,
	io::ICursorControl			***CursorControl_ms_Singleton,
	os::ITimerMain				***TimerMain_ms_Singleton,
	os::ITimerSecond			***TimerSecond_ms_Singleton,
	os::IMemStatus				***MemStatus_ms_Singleton,
	mm::ISoundDriver			***SoundDriver_ms_Singleton,
	scr::ICoreScriptManager		***CoreScriptManager_ms_Singleton,
	scr::IScriptManager			***ScriptManager_ms_Singleton,
	dyn::IDynamicManager		***DynamicManager_ms_Singleton,
	scn::ISceneManager			***SceneManager_ms_Singleton,
	scn::IPathFinderManager		***PathFinderManager_ms_Singleton,
	scn::ILightGridManager		***LightGridManager_ms_Singleton,
	scn::IMaterialsManager		***MaterialsManager_ms_Singleton,
	scn::ICullingSystem			***CullingSystem_ms_Singleton,
	img::IImageLibrary			***ImageLibrary_ms_Singleton,
	vid::IVideoDriver			***VideoDriver_ms_Singleton,
	game::IGameManager			***GameManager_ms_Singleton,
	game::IGameAIModule			***GameAIModule_ms_Singleton,
	game::IGameEventsDispatcher	***GameEventsDispatcher_ms_Singleton,
	game::IGameTasksManager		***GameTasksManager_ms_Singleton,
	res::IResourceManager		***ResourceManager_ms_Singleton)
{
	*Device_ms_Singleton				= &g_SingletonsTable.Ptrs.Device;	
	*PluginManager_ms_Singleton			= &g_SingletonsTable.Ptrs.PluginManager;
	*Profiler_ms_Singleton				= &g_SingletonsTable.Ptrs.Profiler;
	*Logger_ms_Singleton				= &g_SingletonsTable.Ptrs.Logger;
	*FileSystem_ms_Singleton			= &g_SingletonsTable.Ptrs.FileSystem;
	*InputDispatcher_ms_Singleton		= &g_SingletonsTable.Ptrs.InputDispatcher;
	*CursorControl_ms_Singleton			= &g_SingletonsTable.Ptrs.CursorControl;
	*TimerMain_ms_Singleton				= &g_SingletonsTable.Ptrs.TimerMain;
	*TimerSecond_ms_Singleton			= &g_SingletonsTable.Ptrs.TimerSecond;
	*MemStatus_ms_Singleton				= &g_SingletonsTable.Ptrs.MemStatus;
	*SoundDriver_ms_Singleton			= &g_SingletonsTable.Ptrs.SoundDriver;
	*CoreScriptManager_ms_Singleton		= &g_SingletonsTable.Ptrs.CoreScriptManager;
	*ScriptManager_ms_Singleton			= &g_SingletonsTable.Ptrs.ScriptManager;
	*DynamicManager_ms_Singleton		= &g_SingletonsTable.Ptrs.DynamicManager;
	*SceneManager_ms_Singleton			= &g_SingletonsTable.Ptrs.SceneManager;
	*PathFinderManager_ms_Singleton		= &g_SingletonsTable.Ptrs.PathFinderManager;	
	*LightGridManager_ms_Singleton		= &g_SingletonsTable.Ptrs.LightGridManager;	
	*MaterialsManager_ms_Singleton		= &g_SingletonsTable.Ptrs.MaterialsManager;	
	*CullingSystem_ms_Singleton			= &g_SingletonsTable.Ptrs.CullingSystem;	
	*ImageLibrary_ms_Singleton			= &g_SingletonsTable.Ptrs.ImageLibrary;
	*VideoDriver_ms_Singleton			= &g_SingletonsTable.Ptrs.VideoDriver;
	*GameManager_ms_Singleton			= &g_SingletonsTable.Ptrs.GameManager;
	*GameAIModule_ms_Singleton			= &g_SingletonsTable.Ptrs.GameAIModule;
	*GameEventsDispatcher_ms_Singleton	= &g_SingletonsTable.Ptrs.GameEventsDispatcher;
	*GameTasksManager_ms_Singleton		= &g_SingletonsTable.Ptrs.GameTasksManager;
	*ResourceManager_ms_Singleton		= &g_SingletonsTable.Ptrs.ResourceManager;
}

//-----------------------------------------------------------------------------

//! used nodes identificators in the ID-Factory
static core::array<s32> UsedNodesIDs[EUID_UNIQUE_ID_TYPE_COUNT];  

//-----------------------------------------------------------------------------

//! making sure that new Unique ID is unique in the ID-Factory
bool testUniqueID(E_UNIQUE_ID_TYPE uid_type, s32 id)
{
	u32 i;

	// making sure that new id is unique
	for (i=0; i<UsedNodesIDs[uid_type].size(); i++)
	{
		if (UsedNodesIDs[uid_type][i] == id)
			return false;
	}

	return true;
}

//-----------------------------------------------------------------------------

//! add new Unique ID to the ID-Factory
__MY_CORE_LIB_API__ bool addUniqueID(E_UNIQUE_ID_TYPE uid_type, s32 id)
{		
	if (id == -1)
		return true;

	if (testUniqueID( uid_type, id ))
	{
		// storing new identificator
		UsedNodesIDs[uid_type].push_back(id);

		return true;
	}

	return false;
}

//-----------------------------------------------------------------------------

//! remove Unique ID from the ID-Factory
__MY_CORE_LIB_API__ bool removeUniqueID(E_UNIQUE_ID_TYPE uid_type, s32 id)
{
	if (id== -1)
		return false;

	for (u32 i=0; i<UsedNodesIDs[uid_type].size(); i++)
	{
		if (UsedNodesIDs[uid_type][i] == id)
		{
			UsedNodesIDs[uid_type].erase(i);

			return true;
		}
	}

	return false;
}

//----------------------------------------------------------------------------
} // end namespace core
Exemple #24
0
void puzzle_select(s4 &game_state, stringc &selected_file, s4 &puzzle_type)
{
    //ICameraSceneNode* camera = irrlicht->smgr->addCameraSceneNode();
    // matrix4 ortho;
    // ortho.buildProjectionMatrixOrthoLH(
    //     irrlicht->driver->getScreenSize().Width/ortho_scale,
    //     irrlicht->driver->getScreenSize().Height/ortho_scale,-1.0,1000.0);
    // camera->setProjectionMatrix(ortho);
    // camera->setPosition({0,0,-100});
    // camera->setTarget({0,0,0}); 

    IGUIEnvironment* env = irrlicht->device->getGUIEnvironment(); 
    IGUIFont* font = irrlicht->font;//device->getGUIEnvironment()->getFont(_DIRECTORY_ + "fontlucida.png");

    p("---- Menu loop start ----");

    d32         dt = 0;
    const d32   maxDelta = 1.0f/60.0f * 5; 
    const d32   tick_ms = 0.01666; // TODO: change this back to 30ms?
    d32         render_dt = 0;
    const d32   render_ms = 0.064; // TODO: change this back to 30ms?
    uint32      time_physics_prev = btclock->getTimeMicroseconds();

    IFileSystem* file_system = env->getFileSystem();
    irr::io::path prev_dir = file_system->getWorkingDirectory();
    file_system->changeWorkingDirectoryTo(_DIRECTORY_ + "levels/");
    IFileList* file_list = file_system->createFileList();
    s4 file_count = file_list->getFileCount();

    s4 selected_level = 2;

    stringc* found_levels = new stringc[file_count];
    for (s4 i = 0; i < file_count; i++)
    { 
        found_levels[i] = file_list->getFileName(i).c_str();
    }

    while(irrlicht->device->run() && game_state == GAME_STATE_MENU)
    {
        const uint32 time_physics_curr = btclock->getTimeMicroseconds();
        const d32 frameTime = ((d32)(time_physics_curr - time_physics_prev)) / 1000000.0; // todo: is this truncated correctly?
        time_physics_prev = time_physics_curr;
        d32 capped_dt = frameTime;
        if (capped_dt > maxDelta) { capped_dt = maxDelta; }

        render_dt += capped_dt;
        if ( render_dt >= render_ms )
        {
            render_dt = 0.0f;  
            
            irrlicht->driver->beginScene(true, true, SColor(255,100,100,140));            
            irrlicht->smgr->drawAll();

            irrlicht->driver->clearZBuffer();
            for (s4 i = 0; i < file_count; i++)
            {
                SColor color = SColor(255,150,150,230);
                if (i == selected_level)
                {
                    color = SColor(255,255,255,255);
                }
                font->draw(found_levels[i], rect<s32>(10,20 + 20 * i,300,50), color);
            }            

            stringc text = "How To Throw A Baseball Through Solid Wall";
            font->draw(text, rect<s32>(300,90,300,50), SColor(255,255,255,255));

            text = "Arrow keys to move.";
            font->draw(text, rect<s32>(300,120,300,50), SColor(255,255,255,255));
            text = "A and D rotate camera. W zooms in, S zooms out.";
            font->draw(text, rect<s32>(300,140,300,50), SColor(255,255,255,255));
            text = "R to reset back to menu.";
            font->draw(text, rect<s32>(300,160,300,50), SColor(255,255,255,255));
            text = "Esc to quit.";
            font->draw(text, rect<s32>(300,180,300,50), SColor(255,255,255,255));
            text = "00_levels.fixed.txt: spacebar, backspace adjusts layers. ";
            font->draw(text, rect<s32>(300,200,300,50), SColor(255,255,255,255));

            text = "Baseball Gates is the only puzzle with a solution.";
            font->draw(text, rect<s32>(300,240,300,50), SColor(255,255,255,255));
            text = "Black cubes are placeholders for watermills.";
            font->draw(text, rect<s32>(300,260,300,50), SColor(255,255,255,255));
            text = "Put water in front of them to turn them on.";
            font->draw(text, rect<s32>(300,280,300,50), SColor(255,255,255,255)); 

            text = "antithesis.ctr is an experiment. Use mouse to grab things.";
            font->draw(text, rect<s32>(300,320,300,50), SColor(255,255,255,255));

            irrlicht->driver->endScene();
        }

        dt += capped_dt;
        while( dt >= tick_ms ) // run 30 times per second
        {
            dt -= tick_ms;
            receiver->input();
            
            s4 prev_selected_level = selected_level;

            if (receiver->up.state)     selected_level--;
            if (receiver->down.state)   selected_level++;

            if (selected_level < 2)     selected_level = file_count - 1;
            if (selected_level >= file_count)    selected_level = 2; 

            if (receiver->enter.state)  game_state = GAME_STATE_PLAY;
            
            if (receiver->QUIT)         game_state = GAME_STATE_QUIT;
        }
    }

    selected_file = found_levels[selected_level];

    s4 string_size = selected_file.size() - 1;
    char file_type[3];
    file_type[2] = selected_file[string_size];
    file_type[1] = selected_file[string_size-1];
    file_type[0] = selected_file[string_size-2];

    //std::cout << file_type[0] << file_type[1] << file_type[2] << std::endl;

    if (file_type[0] == 't') {
        puzzle_type = 0;
    } else if (file_type[0] == 'c') {
        puzzle_type = 1;
    }

    delete [] found_levels;

    file_system->changeWorkingDirectoryTo(prev_dir);

    // irrlicht->smgr->setActiveCamera(0);   
    // camera->remove();
    //irrlicht->smgr->clear();
}