Esempio n. 1
0
File: Gui.cpp Progetto: macBdog/game
bool Gui::LoadMenus(const char * a_guiPath, const DataPack * a_dataPack)
{
	bool loadSuccess = true;
	if (a_dataPack != NULL && a_dataPack->IsLoaded())
	{
		DataPack::EntryList menuEntries;
		a_dataPack->GetAllEntries(".mnu", menuEntries);
		DataPack::EntryNode * curNode = menuEntries.GetHead();

		// Load each menu in the list
		bool loadSuccess = true;
		while (curNode != NULL)
		{
			GameFile menuFile(curNode->GetData());
			loadSuccess &= LoadMenu(menuFile, a_dataPack);
			curNode = curNode->GetNext();
		}

		// Clean up the list of menu data pack entries
		a_dataPack->CleanupEntryList(menuEntries);
	}
	else
	{
		// Get a list of menu files in the gui directory
		FileManager & fileMan = FileManager::Get();
		FileManager::FileList menuFiles;
		fileMan.FillFileList(a_guiPath, menuFiles, ".mnu");

		// Load each menu in the directory
		FileManager::FileListNode * curNode = menuFiles.GetHead();
		while (curNode != NULL)
		{
			char fullPath[StringUtils::s_maxCharsPerLine];
			sprintf(fullPath, "%s%s", a_guiPath, curNode->GetData()->m_name);
			GameFile menuFile(fullPath);
			loadSuccess &= LoadMenu(menuFile, a_dataPack);
			curNode = curNode->GetNext();
		}

		// Clean up the list of fonts
		fileMan.CleanupFileList(menuFiles);
	}

	return loadSuccess;
}
Esempio n. 2
0
bool SoundManager::Startup(const char * a_soundPath, const DataPack * a_dataPack)
{
	// start the sound engine with default parameters
	if (m_engine = irrklang::createIrrKlangDevice(irrklang::ESOD_AUTO_DETECT))
    {
		// Cache off path and look for sounds to load
		strncpy(m_soundPath, a_soundPath, sizeof(char) * strlen(a_soundPath) + 1);

		if (a_dataPack != NULL && a_dataPack->IsLoaded())
		{
			// Populate a list of sounds
			DataPack::EntryList soundEntries;
			a_dataPack->GetAllEntries(".ogg,.wav", soundEntries);
			DataPack::EntryNode * curNode = soundEntries.GetHead();

			// Load each font in the pack
			bool loadSuccess = true;
			while (curNode != NULL)
			{
				DataPackEntry * curData = curNode->GetData();
				m_engine->addSoundSourceFromMemory(curData->m_data, curData->m_size, curData->m_path, false);
				curNode = curNode->GetNext();
			}

			// Clean up the list of sounds
			a_dataPack->CleanupEntryList(soundEntries);
		}
		return true;
	}
	else
	{
		Log::Get().WriteEngineErrorNoParams("Could not start up sound system.");
	}

	return false;
}