Example #1
0
bool GsTilemap::loadHiresTile( const std::string& filename, const std::string& path )
{  
	std::string fullfilename;  
	// Cycle through possible filename extensions, when more formats are supported
	for( auto &ext : exts )
	{
	    fullfilename = filename + "." + ext;
	    fullfilename = getResourceFilename(fullfilename, path, false);  
	    if(!fullfilename.empty())
	      break;
	}	
	  
	if(!IsFileAvailable(fullfilename))
		return false;

    if(!mTileSurface.empty())
	{	  	  
        SDL_Surface *temp_surface = IMG_Load(GetFullFileName(fullfilename).c_str());
		if(temp_surface)
		{
            GsWeakSurface tempWeak(temp_surface);

            mTileSurface.createCopy(tempWeak);
            SDL_FreeSurface(temp_surface);
			return true;
		}
		else
		{
		  gLogging.textOut(FONTCOLORS::RED, "IMG_Load: %s\n", IMG_GetError());
		  gLogging.textOut(FONTCOLORS::RED, "IMG_Load: CG will ignore those images\n");
		}
	}

	return false;
}
Example #2
0
byte *getActionBasePtr()
{
    auto &exeFile = gKeenFiles.exeFile;

    if(exeFile.isPythonScript())
    {
        if(actionFormatData.empty())
        {
            int episode = exeFile.getEpisode();

            const std::string fname = "keen" + itoa(episode) + ".act";

            const auto actFilePath = JoinPaths(gKeenFiles.gameDir,fname);
            const auto actFullFilePath = GetFullFileName(actFilePath);

            gLogging << "Loading Action file " << actFullFilePath;

            if(actFullFilePath == "")
            {
                gLogging << "Error Loading Action file " << actFullFilePath;
                return nullptr;
            }

            loadActionFile(actFullFilePath);
        }

        return actionFormatData.data();
    }
    else
    {
        return exeFile.getDSegPtr();
    }
}
bool CSaveGameController::load()
{
    Uint32 size;
    std::ifstream StateFile;
    std::string fullpath = GetFullFileName(m_statefilename);
    OpenGameFileR( StateFile, m_statefilename, std::ofstream::binary );

    if (!StateFile.is_open())
    {
        g_pLogFile->textOut("Error loading \"" + fullpath + "\". Please check the status of that file.\n" );
        return false;
    }

    // Skip the header as we already chose the game
    StateFile.get(); // Skip the version info
    size = StateFile.get(); // get the size of the slotname and...
    for(Uint32 i=0 ; i<size ; i++)	// skip that name string
        StateFile.get();

    while(!StateFile.eof()) // read it everything in
        m_datablock.push_back(StateFile.get());

    // TODO: Decompression has still to be done!

    // Now write all the data to the file
    StateFile.close();

    // Done!
    g_pLogFile->textOut("File \""+ fullpath +"\" was sucessfully loaded. Size: "+itoa(m_datablock.size())+"\n");
    m_offset = 0;
    m_statefilename.clear();
    m_statename.clear();

    return true;
}
bool CTilemap::loadHiresTile( const std::string& filename, const std::string& path )
{  
	std::string fullfilename;  
	// Cycle through possible filename extensions, when more formats are supported
	for( auto &ext : exts )
	{
	    fullfilename = filename + "." + ext;
	    fullfilename = getResourceFilename(fullfilename, path, false);  
	    if(!fullfilename.empty())
	      break;
	}	
	  
	if(!IsFileAvailable(fullfilename))
		return false;

	if(m_Tilesurface)
	{	  	  
		SDL_Surface *temp_surface = IMG_Load(GetFullFileName(fullfilename).c_str());
		if(temp_surface)
		{
			SDL_FreeSurface(m_Tilesurface);
			m_Tilesurface = temp_surface;
			return true;
		}
		else
		{
		  g_pLogFile->textOut(RED, "IMG_Load: %s\n", IMG_GetError());
		  g_pLogFile->textOut(RED, "IMG_Load: CG will ignore those images\n");
		}
	}
	
	return false;
}
// This function writes all the data from the CPlayGame and CMenu Instances to a file,
// closes it and flushes the data block.
bool CSaveGameController::save()
{
    std::ofstream StateFile;
    std::string fullpath = GetFullFileName(m_statefilename);
    bool open = OpenGameFileW( StateFile, m_statefilename, std::ofstream::binary );

    if (!open)
    {
        g_pLogFile->textOut("Error saving \"" + fullpath + "\". Please check the status of that path.\n" );
        return false;
    }

    // Convert everything to a primitive data structure
    // First pass the header, which is only version,
    // sizeofname and name of slot itself
    Uint32 offset = 0;
    Uint32 size = sizeof(SAVEGAMEVERSION)
                  + sizeof(char)
                  + m_statename.size()*sizeof(char);

    size += m_datablock.size();
    // Headersize + Datablock size
    std::vector<char> primitive_buffer(size);

    // Write the header
    primitive_buffer[offset++] = SAVEGAMEVERSION;
    primitive_buffer[offset++] = m_statename.size();

    for( Uint32 i=0; i<m_statename.size() ; i++ )
    {
        primitive_buffer[offset++] = m_statename[i];
    }

    // Write the collected data block
    std::vector<byte>::iterator pos = m_datablock.begin();
    for( size_t i=0; i<m_datablock.size() ; i++ )
    {
        primitive_buffer[offset++] = *pos;
        pos++;
    }

    // TODO: Compression has still to be done!

    // Now write all the data to the file
    StateFile.write( &primitive_buffer[0], size );
    StateFile.close();

    m_datablock.clear();

    // Done!
    g_pLogFile->textOut("File \""+ fullpath +"\" was sucessfully saved. Size: "+itoa(size)+"\n");
    m_statefilename.clear();
    m_statename.clear();

    return true;
}
// This function checks if the file we want to read or save already exists
bool CSaveGameController::alreadyExits()
{
    std::ifstream StateFile;
    std::string fullpath = GetFullFileName(m_statefilename);
    OpenGameFileR( StateFile, m_statefilename, std::ofstream::binary );

    if (!StateFile.is_open())
        return false;
    else
    {
        StateFile.close();
        return true;
    }
}
Example #7
0
OJString GetFileName(const OJString &path)
{
    OJString res(GetFullFileName(path));

    if (!res.empty())
    {
        OJString ext(GetFileExt(path));

        if (!ext.empty())
            res = res.substr(0, res.size() - ext.size());
    }

    return res;
}
bool COGGPlayer::open()
{
	// If Ogg detected, decode it into the stream psound->sound_buffer.
	// It must fit into the Audio_cvt structure, so that it can be converted
    mHasCommonFreqBase = true;

    if(ov_fopen((char*)GetFullFileName(m_filename).c_str(), &m_oggStream) != 0)
        return false;

    mVorbisInfo = ov_info(&m_oggStream, -1);
    ov_comment(&m_oggStream, -1);

    m_AudioFileSpec.format = AUDIO_S16LSB; // Ogg Audio seems to always use this format

    m_AudioFileSpec.channels = mVorbisInfo->channels;
    m_AudioFileSpec.freq = mVorbisInfo->rate;

    // Since I cannot convert with a proper quality from 44100 to 48000 Ogg wave output
    // we set m_AudioFileSpec frequency to the same as the one of the SDL initialized AudioSpec
    // scale just the buffer using readOGGStreamAndResample.
    // This is base problem, but we have workarounds for that...
    if( (m_AudioFileSpec.freq%m_AudioSpec.freq != 0) &&
        (m_AudioSpec.freq%m_AudioFileSpec.freq != 0) )
    {
        m_AudioFileSpec.freq = m_AudioSpec.freq;
        mHasCommonFreqBase = false;
    }

    m_pcm_size = ov_pcm_total(&m_oggStream,-1);
    m_pcm_size *= (mVorbisInfo->channels*sizeof(Sint16));
    m_music_pos = 0;

	g_pLogFile->ftextOut("OGG-Player: File \"%s\" was opened successfully!<br>", m_filename.c_str());
	int ret = SDL_BuildAudioCVT(&m_Audio_cvt,
			m_AudioFileSpec.format, m_AudioFileSpec.channels, m_AudioFileSpec.freq,
			m_AudioSpec.format, m_AudioSpec.channels, m_AudioSpec.freq);
	if(ret == -1)
		return false;

	const size_t length = m_AudioSpec.size;
    //m_Audio_cvt.len = (length*m_Audio_cvt.len_mult)/m_Audio_cvt.len_ratio;

    m_Audio_cvt.len = (length)/m_Audio_cvt.len_ratio;

    m_Audio_cvt.len = (m_Audio_cvt.len>>2)<<2;

    m_Audio_cvt.buf = new Uint8[m_Audio_cvt.len*m_Audio_cvt.len_mult];

    return true;
}
Example #9
0
bool CFont::loadHiColourFont( const std::string& filename )
{
	if(!IsFileAvailable(filename))
		return false;

	if(m_FontSurface)
	{
		SDL_Surface *temp_surface = SDL_LoadBMP(GetFullFileName(filename).c_str());
		if(temp_surface)
		{
			SDL_Surface *displaysurface = SDL_ConvertSurface(temp_surface, m_FontSurface->format, m_FontSurface->flags);
			SDL_BlitSurface(displaysurface, NULL, m_FontSurface, NULL);
			SDL_FreeSurface(displaysurface);
			SDL_FreeSurface(temp_surface);
			return true;
		}
	}
	return false;
}
Example #10
0
SmartPointer<SDL_Surface> load_bitmap__allegroformat(const std::string& filename) {
	std::string fullfilename = GetFullFileName(filename);	
	SDL_Surface* img = IMG_Load(Utf8ToSystemNative(fullfilename).c_str());
	if(!img) return NULL;
	
	if( img->format->BitsPerPixel == 8 )
		return img;
	
	SmartPointer<SDL_Surface> converted = create_32bpp_sdlsurface__allegroformat(img->w, img->h);
	CopySurface(converted.get(), img, 0, 0, 0, 0, img->w, img->h);
	
	//SDL_Surface* converted = SDL_DisplayFormat(img);
	SDL_FreeSurface(img);
	
	if(!converted.get()) {
		errors << "Failed: Converting of bitmap " << filename << /*" to " << bpp <<*/ " bit" << endl;
		return NULL;
	}

	return converted;
}
Example #11
0
bool GsBitmap::loadHQBitmap( const std::string& filename )
{
	if(!IsFileAvailable(filename))
		return false;

	if( mpBitmapSurface )
	{
		SDL_Surface *tempSurface = SDL_LoadBMP(GetFullFileName(filename).c_str());
		if(tempSurface)
		{
            SDL_Surface *displaysurface = SDL_ConvertSurface(tempSurface,
                                                             mpBitmapSurface->format,
                                                             mpBitmapSurface->flags);
			SDL_BlitSurface(displaysurface, NULL, mpBitmapSurface.get(), NULL);
			SDL_FreeSurface(displaysurface);
			SDL_FreeSurface(tempSurface);
			return true;
		}
	}
	return false;
}
Example #12
0
bool CSprite::loadHQSprite( const std::string& filename )
{
	if(!IsFileAvailable(filename))
		return false;

	if(!mpSurface.empty())
	{
		const std::string fullpath = GetFullFileName(filename);

		SmartPointer<SDL_Surface> temp_surface = SDL_LoadBMP( fullpath.c_str() );
		if(!temp_surface.empty())
		{
			SmartPointer<SDL_Surface> displaysurface = SDL_ConvertSurface(temp_surface.get(), mpSurface->format, mpSurface->flags);
			readMask(displaysurface.get());
			readBBox(displaysurface.get());
			SDL_BlitSurface(displaysurface.get(), NULL, mpSurface.get(), NULL);
			return true;
		}
	}
	return false;
}
Example #13
0
bool CSprite::loadHQSprite( const std::string& filename )
{
	if(!IsFileAvailable(filename))
		return false;

	if(mpSurface)
	{
		const std::string fullpath = GetFullFileName(filename);

		std::unique_ptr<SDL_Surface, SDL_Surface_Deleter> temp_surface(SDL_LoadBMP( fullpath.c_str() ));
		if(temp_surface)
		{
			std::unique_ptr<SDL_Surface, SDL_Surface_Deleter> 
			      displaysurface( SDL_ConvertSurface(temp_surface.get(), mpSurface->format, mpSurface->flags));
			readMask(displaysurface.get());
			readBBox(displaysurface.get());
			SDL_BlitSurface(displaysurface.get(), NULL, mpSurface.get(), NULL);
			return true;
		}
	}
	return false;
}
Example #14
0
void CSoundSlot::openOGGSound(const std::string& filename, SDL_AudioSpec *pspec, Uint8 *&SoundBuffer, Uint32 &SoundLen)
{

#if defined(OGG) || defined(TREMOR)

    OggVorbis_File  oggStream;     				// stream handle
    const unsigned int BUFFER_SIZE = 32768;     // 32 KB buffers
    SoundBuffer = NULL;

    const SDL_AudioSpec &audioSpec = g_pSound->getAudioSpec();

    if(ov_fopen( (char *)GetFullFileName(filename).c_str(), &oggStream ) == 0)
    {
    	long bytes;
    	char array[BUFFER_SIZE];
    	std::vector<char> buffer;

    	int bitStream;
        vorbis_info*  vorbisInfo = ov_info(&oggStream, -1);
        ov_comment(&oggStream, -1);
        pspec->format = AUDIO_S16LSB; // Ogg Audio seems to always use this format
        pspec->channels = vorbisInfo->channels;

        mOggFreq = vorbisInfo->rate;

        pspec->freq = mOggFreq;


        mHasCommonFreqBase = true;

        // Since I cannot convert with a proper quality from 44100 to 48000 Ogg wave output
        // we set m_AudioFileSpec frequency to the same as the one of the SDL initialized AudioSpec
        // scale just the buffer using readOGGStreamAndResample.
        // This is base problem, but we have workarounds for that...
        if( (pspec->freq%audioSpec.freq != 0) &&
            (audioSpec.freq%pspec->freq != 0) )
        {
            pspec->freq = audioSpec.freq;
            mHasCommonFreqBase = false;
        }


        SoundLen = 0;

        do {
			// Read up to a buffer's worth of decoded sound data
#if defined(OGG)
        	bytes = ov_read(&oggStream, array, BUFFER_SIZE, 0, 2, 1, &bitStream);
#elif defined(TREMOR)
        	bytes = ov_read(&oggStream, array, BUFFER_SIZE, &bitStream);
#endif
			// Append to end of buffer
			buffer.insert(buffer.end(), array, array + bytes);
        } while (bytes > 0);

        ov_clear(&oggStream);

        SoundLen = buffer.size();
        SoundBuffer = (Uint8*) malloc(SoundLen*sizeof(Uint8));
        memcpy(SoundBuffer, &(buffer[0]), SoundLen);
    }
    #endif
}
/*
 * Process Response files on the command line
 * Returns true if it allocated a new argv array that must be freed later
 */
void ConsoleArgs::ProcessResponseArgs()
{
    HRESULT hr;
    b_tree *response_files = NULL;

    WCHAR   szFilename[MAX_PATH];
    WCAllocBuffer textBuffer;

    for (WStrList * listCurArg = m_listArgs;
        listCurArg != NULL && !m_output->HadFatalError();
        listCurArg = listCurArg->next)
    {
        WCHAR  * szArg = listCurArg->arg;

        // Skip everything except Response files
        if (szArg == NULL || szArg[0] != '@')
            continue;

        if (wcslen(szArg) == 1) {
            m_output->ShowErrorIdString( ERR_NoFileSpec, ERROR_ERROR, szArg);
            goto CONTINUE;
        }

        // Check for duplicates
        if (!GetFullFileName( RemoveQuotes(WCBuffer::CreateFrom(&szArg[1])), szFilename, false))
            continue;

        hr = TreeAdd(&response_files, szFilename);
        if (hr == E_OUTOFMEMORY) {
            m_output->ShowErrorId(FTL_NoMemory, ERROR_FATAL);
            goto CONTINUE;
        } else if (hr == S_FALSE) {
            m_output->ShowErrorIdString(ERR_DuplicateResponseFile, ERROR_ERROR, szFilename);
            goto CONTINUE;
        }

        FileType fileType;
        textBuffer.Clear();
        if (FAILED(hr = ReadTextFile(szFilename, NULL, textBuffer, &fileType)) || hr == S_FALSE)
        {
            if (hr == E_OUTOFMEMORY) {
                m_output->ShowErrorId(FTL_NoMemory, ERROR_FATAL);
            } else if (FAILED(hr)) {
                if (fileType == ftBinary)
                    m_output->ShowErrorIdString(ERR_BinaryFile, ERROR_ERROR, szFilename);
                else
                    m_output->ShowErrorIdString(ERR_OpenResponseFile, ERROR_ERROR, szFilename, m_output->ErrorHR(hr));
            }
            goto CONTINUE;
        }


        TextToArgs( textBuffer, &listCurArg->next);

CONTINUE: // remove the response file argument, and continue to the next.
        listCurArg->arg = NULL;
        VSFree(szArg);
    }

    CleanupTree(response_files);
}
Example #16
0
/**
 * \brief	The CSettings class handles the saving and loading of all the settings that are saved in
 * 			the game. Those are, video, audio, options and input.
 *
 * \param	p_option	pointer to an array that stores the options settings of the game
 */
CSettings::CSettings()
{
	notes << "Reading game options from " << GetFullFileName(CONFIGFILENAME) << endl;
	notes << "Will write game options to " << GetWriteFullFileName(CONFIGFILENAME, true) << endl;
}
TVerdict CTestCalInterimApiRichAlarmFormatStep::doTestStepL()
	{
	CActiveScheduler* scheduler = new(ELeave)CActiveScheduler;
	CleanupStack::PushL(scheduler);  
	CActiveScheduler::Install(scheduler);

	iSession  = CCalSession::NewL();
	
	CTestCalInterimApiCallbackForRichAlarms* alarmCallback = CTestCalInterimApiCallbackForRichAlarms::NewL(this);
	CleanupStack::PushL(alarmCallback); 

	OpenSessionFileL();
	iEntryView = CCalEntryView::NewL(*iSession,*alarmCallback);
	
	CActiveScheduler::Add(alarmCallback);
	CActiveScheduler::Start();
	
	//build the CCalDataExchange object and import
	CCalDataExchange* dataExchange = CCalDataExchange::NewL(*iSession);
	CleanupStack::PushL(dataExchange); 

	//IMPORT the calendar info from a known file
	RFs fs;
	fs.Connect();
	CleanupClosePushL(fs);
	RFile inFile;
	CleanupClosePushL(inFile);
	TInt errR = inFile.Open(fs, GetFullFileName(KEntryImportFile), EFileRead);
	RFileReadStream readStream(inFile);
	CleanupClosePushL(readStream);
	
	RPointerArray<CCalEntry> secondEntryArray;
	CleanupStack::PushL(TCleanupItem(CloseAndDeleteRPtrArrayEntries, &secondEntryArray));
	secondEntryArray.Reset();
	
	INFO_PRINTF1(KImporting);
	TInt index = 0;
	for (index = 0; index < KNumEntriesInFile; index++)
		{
		dataExchange->ImportL(KUidVCalendar, readStream, secondEntryArray);
		}
	
	CleanupStack::Pop(&secondEntryArray);
	CleanupStack::PopAndDestroy(&readStream);
	CleanupStack::PopAndDestroy(&inFile);
	CleanupStack::PushL(TCleanupItem(CloseAndDeleteRPtrArrayEntries, &secondEntryArray));

	SetTestStepResult(CompareAlarmDataL(&secondEntryArray));
	
	//Test for importing from a badly formatted file
	RFile badInFile;
	CleanupClosePushL(badInFile);
	TInt baddErr = badInFile.Open(fs, GetFullFileName(KEntryBadImportFile), EFileRead);
	RFileReadStream badStream(badInFile);
	CleanupClosePushL(badStream);
	
	RPointerArray<CCalEntry> badEntryArray;
	CleanupStack::PushL(TCleanupItem(CloseAndDeleteRPtrArrayEntries, &badEntryArray));
	badEntryArray.Reset();
	
	INFO_PRINTF1(KImporting);
	TInt i = 0;
	for (i = 0; i < 1; i++)
		{
		dataExchange->ImportL(KUidVCalendar, badStream, badEntryArray);
		}
	CCalEntry* pEntry = badEntryArray[0];
	CCalAlarm* pAlarm = pEntry->AlarmL();
	if (pAlarm)
		{
		CleanupStack::PushL(pAlarm);
		CCalContent* pContent = pAlarm->AlarmAction();
		if (pContent != NULL)
			{
			ERR_PRINTF1(KUnexpectedAlarmAction);
			SetTestStepResult(EFail);
			}
		delete pContent;
		CleanupStack::PopAndDestroy(pAlarm);
		}
	CleanupStack::PopAndDestroy(&badEntryArray);
	CleanupStack::PopAndDestroy(&badStream);
	CleanupStack::PopAndDestroy(&badInFile);

	
	CleanupStack::PopAndDestroy(5 , scheduler);

	return TestStepResult();
	}
Example #18
0
bool CSoundSlot::HQSndLoad(const std::string& gamepath, const std::string& soundname)
{
	SDL_AudioSpec AudioFileSpec;

    const SDL_AudioSpec &audioSpec = g_pSound->getAudioSpec();

	SDL_AudioCVT  Audio_cvt;

	std::string buf;

	Uint32 length = 0;
    Uint8 *oggdata = nullptr;
    Uint8 *wavdata = nullptr;

#if defined(OGG) || defined(TREMOR)
	buf = getResourceFilename("snd/" + soundname + ".OGG", gamepath, false, true); // Start with OGG

	if(buf != "")
	{
        openOGGSound(buf, &AudioFileSpec, oggdata, length);

        if(oggdata == nullptr)
        {
            gLogging.textOut(PURPLE,"Something is wrong with \"%s\"<br>", buf);
			return false;
        }
#else
		gLogging.textOut(PURPLE,"NOTE: OGG-Support is disabled! Get another version or compile it yourself!<br>");
#endif

#if defined(OGG) || defined(TREMOR)
	}
	else
	{
#endif

		buf = getResourceFilename("snd/" + soundname + ".WAV", gamepath, false); // Start with OGG

		if(buf == "")
			return false;

		// Check, if it is a wav file or go back to classic sounds
        if (SDL_LoadWAV (Utf8ToSystemNative(GetFullFileName(buf)).c_str(), &AudioFileSpec, &wavdata, &length) == NULL)
			return false;

#if defined(OGG) || defined(TREMOR)
	}
#endif
	// Build AudioCVT (This is needed for the conversion from one format to the one used in the game)
	const int ret = SDL_BuildAudioCVT(&Audio_cvt,
							AudioFileSpec.format, AudioFileSpec.channels, AudioFileSpec.freq,
                            audioSpec.format, audioSpec.channels, audioSpec.freq);

	// Check that the convert was built
	if(ret == -1)
	{
		gLogging.textOut(PURPLE,"Couldn't convert the sound correctly!<br>");
        SDL_FreeWAV(wavdata);
		return false;
	}

	// Setup for conversion, copy original data to new buffer
	Audio_cvt.buf = (Uint8*) malloc(length * Audio_cvt.len_mult);
	Audio_cvt.len = length;

    if(oggdata)
        memcpy(Audio_cvt.buf, oggdata, length);
    else
        memcpy(Audio_cvt.buf, wavdata, length);

	// We can delete to original WAV data now
    if(oggdata)
    {
        free(oggdata);
    }
    else
    {
        SDL_FreeWAV(wavdata);
    }


	// And now we're ready to convert
	SDL_ConvertAudio(&Audio_cvt);

	// copy the converted stuff to the original soundbuffer
    Uint8 *buffer;
    if( !mHasCommonFreqBase )
	{
        const float factor = float(audioSpec.freq)/mOggFreq;
		length = Audio_cvt.len_cvt;
		const unsigned long out_len = (float)length*factor;        
        buffer = (Uint8*) malloc(out_len);

        resample(buffer, Audio_cvt.buf,
                out_len, length, audioSpec.format, audioSpec.channels);
		length = out_len;
	}
	else
	{
		length = Audio_cvt.len_cvt;
        buffer = (Uint8*) malloc(length);
        memcpy(buffer, Audio_cvt.buf, length);
	}

    setupWaveForm(buffer, length);

    free(buffer);

	// Structure Audio_cvt must be freed!
	free(Audio_cvt.buf);

	return true;
}
Example #19
0
void CAbout::init()
{
    CInfoScene::init();
	CExeFile &ExeFile = g_pBehaviorEngine->m_ExeFile;
	mpMap.reset(new CMap);
	CVorticonMapLoaderBase Maploader(mpMap);
	
	Maploader.load(ExeFile.getEpisode(), 90, ExeFile.getDataDirectory());
	mpMap->gotoPos( 1008, 28 );
	
	// Load the SDL_Bitmap
	if(m_type == "ID")
	{
		mp_bmp = g_pGfxEngine->getBitmap("IDLOGO");
		
		// Get the offset where in the data the info is...
		size_t offset = 0;
		//m_numberoflines = 11;
		switch(ExeFile.getEpisode())
		{
			case 1:
				if(ExeFile.getEXEVersion() == 131)
					offset = 0x16180-512;
				break;
			case 2:
				if(ExeFile.getEXEVersion() == 131)
					offset = 0x1A954-512;
				break;
			case 3:
				if(ExeFile.getEXEVersion() == 131)
					offset = 0x1CA70-512;
				break;
		}
		mpMap->drawAll();
		
		// Read the strings and save them the string array of the class
		if(offset)
		{
			char *startdata;
			startdata = (char*)ExeFile.getRawData() + offset;
			std::string buf;
			for(int i=0 ; i<m_numberoflines ; i++)
			{
				char *data = startdata;

				for(short offset = 0 ; offset<0x28 ; offset++)
				{
					if(data[offset] == 0x0A && data[offset+1] == 0x00)
						break;

					buf.push_back(data[offset]);
				}
				startdata += 0x28;

				// now check how many new lines we have in buf
				size_t num_newlines = 0;
				bool endoftext = false;

				size_t  pos;
				if((pos = buf.find(0xFE)) != std::string::npos)
				{
					buf.erase(pos), endoftext = true;
				}

				while((pos = buf.find(0x0A)) != std::string::npos)
					buf.erase(pos,1), num_newlines++;

				while((pos = buf.find('\0')) != std::string::npos)
					buf.erase(pos,1);

				m_lines.push_back(buf);
				
				if(endoftext) break;

				while(num_newlines > 0)
					m_lines.push_back(""), num_newlines--;

				buf.clear();
			}
		}
	}
	else if(m_type == "CG")
	{
		std::string path = getResourceFilename("gfx/CGLogo.bmp", ExeFile.getDataDirectory(), true, true);
		mpLogoBMP.reset( SDL_LoadBMP(GetFullFileName(path).c_str()), &SDL_FreeSurface );
		
		m_lines.push_back("Commander Genius is an interpreter");
		m_lines.push_back("made with the goal of recreating");
		m_lines.push_back("the engine that was used to power");
		m_lines.push_back("the Commander Keen series.");
		m_lines.push_back("");
		m_lines.push_back("However, we are also trying to add");
		m_lines.push_back("better support for modern systems");
		m_lines.push_back("to the games, so they can run more");
		m_lines.push_back("smoothly than they did under DOS.");
		m_lines.push_back("");
		m_lines.push_back("Thank you for supporting us by");
		m_lines.push_back("downloading Commander Genius and");
		m_lines.push_back("we hope you will report any bugs.");
	}
	
	switch(ExeFile.getEpisode())
	{
		case 1:
			// Change the ugly lower Tiles which are seen, when using 320x240 base resolution
			for(int i=0; i<30 ; i++)
			{
				mpMap->changeTile(22+i, 15, 14*13);
				mpMap->changeTile(22+i, 16, 14*13+3);
			}
			break;
	}
	
	m_logo_rect.x = m_logo_rect.y = 0;
	m_logo_rect.h = m_logo_rect.w = 0;
	
	if(mpLogoBMP)
	{
		m_logo_rect.w = mpLogoBMP->w;
		m_logo_rect.h = mpLogoBMP->h;
		m_logo_rect.x = 160-m_logo_rect.w/2;
		m_logo_rect.y = 22;
	}

	SDL_Surface *temp = CG_CreateRGBSurface( g_pVideoDriver->getGameResolution().SDLRect() );
#if SDL_VERSION_ATLEAST(2, 0, 0)
    
#else
    mpDrawSfc.reset(SDL_DisplayFormatAlpha(temp), &SDL_FreeSurface);
#endif
	SDL_FreeSurface(temp);
}
////
// Initialization Routine
////
bool CGameLauncher::setupMenu()
{
    m_mustquit      = false;
    mDonePatchSelection = false;
    m_chosenGame    = -1;
    m_ep1slot       = -1;
    mLauncherDialog.initEmptyBackground();
    mSelection      = -1;

    bool gamesDetected = false;

    // TODO: Put that scanning into a separate so we can show a loading menu
    // Scan for games...
    m_DirList.clear();
    m_Entries.clear();

    gLogging.ftextOut("Game Autodetection Started<br>" );

    // Process any custom labels
    getLabels();

    // Scan VFS DIR_ROOT for exe's
    gamesDetected |= scanExecutables(DIR_ROOT);
    mGameScanner.setPermilage(100);

    // Recursivly scan into DIR_GAMES subdir's for exe's
    gamesDetected |= scanSubDirectories(DIR_GAMES, DEPTH_MAX_GAMES, 200, 900);

    mpSelList = new CGUITextSelectionList();

    // Save any custom labels
    putLabels();

    // Create an empty Bitmap control
    mLauncherDialog.addControl( new CGUIBitmap(),
                                GsRect<float>(0.51f, 0.07f, 0.48f, 0.48f) );

    mCurrentBmp = std::dynamic_pointer_cast< CGUIBitmap >
                  ( mLauncherDialog.getControlList().back() );

    mpPrevievBmpVec.resize(m_Entries.size());

	std::vector<GameEntry>::iterator it = m_Entries.begin();
    unsigned int i=0;
    for( ; it != m_Entries.end() ; it++	)
    {
    	mpSelList->addText(it->name);

        // And try to add a preview bitmap
        std::string fullfilename = "preview.bmp";
        fullfilename = getResourceFilename(fullfilename, it->path, false);
        fullfilename = GetFullFileName(fullfilename);

        if(IsFileAvailable(fullfilename))
        {
            SDL_Surface *pPrimBmp = SDL_LoadBMP(GetFullFileName(fullfilename).c_str());
            std::shared_ptr<SDL_Surface> bmpSfcPtr( pPrimBmp );
            std::shared_ptr<GsBitmap> pBmp(new GsBitmap(bmpSfcPtr));
            mpPrevievBmpVec[i] = pBmp;
        }
        i++;
    }

    mpSelList->setConfirmButtonEvent(new GMStart());
    mpSelList->setBackButtonEvent(new GMQuit());

    mLauncherDialog.addControl(new CGUIText("Pick a Game"), GsRect<float>(0.0f, 0.0f, 1.0f, 0.05f));
    mLauncherDialog.addControl(new GsButton( "x", new GMQuit() ), GsRect<float>(0.0f, 0.0f, 0.07f, 0.07f) );
    mLauncherDialog.addControl(mpSelList, GsRect<float>(0.01f, 0.07f, 0.49f, 0.79f));


    mLauncherDialog.addControl(new GsButton( "Start >", new GMStart() ), GsRect<float>(0.65f, 0.865f, 0.3f, 0.07f) );

#ifdef DBFUSION

    GsButton *fusionShellBtn = new GsButton( "DosFusion Shell >", new GMDBFusionStart() );
    GsButton *fusionBtn = new GsButton( "DosFusion! >", new GMDosGameFusionStart() );

    if(disallowDBFusion)
    {
        fusionShellBtn->enable(false);
        fusionBtn->enable(false);
    }

    mLauncherDialog.addControl( fusionShellBtn, GsRect<float>(0.01f, 0.865f, 0.3f, 0.07f) );
    mLauncherDialog.addControl( fusionBtn, GsRect<float>(0.35f, 0.865f, 0.3f, 0.07f) );
#endif



#ifdef DOWNLOADER
    GsButton *downloadBtn = new GsButton( "New Stuff", new GMDownloadDlgOpen() );
    mLauncherDialog.addControl( downloadBtn, GsRect<float>(0.35f, 0.865f, 0.3f, 0.07f) );
#endif

    mpEpisodeText = new CGUIText("Game");
    mpVersionText = new CGUIText("Version");
    mLauncherDialog.addControl(mpEpisodeText, GsRect<float>(0.5f, 0.75f, 0.5f, 0.05f));
    mLauncherDialog.addControl(mpVersionText, GsRect<float>(0.5f, 0.80f, 0.5f, 0.05f));

    // This way it goes right to the selection list.
    mLauncherDialog.setSelection(2);

    mGameScanner.setPermilage(1000);

    gLogging.ftextOut("Game Autodetection Finished<br>" );
    // Banner. TODO: Create a class for that...
    CGUIBanner *banner = new CGUIBanner("Commander Genius " CGVERSION "\n"
                    "By Gerstrong,\n"
                    "Hagel,\n"
                    "Tulip,\n"
                    "NY00123,\n"
                    "Pelya,\n"
					"and the CG Contributors\n");
    mLauncherDialog.addControl( banner, GsRect<float>(0.0f, 0.95f, 1.0f, 0.05f) );

    if(!gamesDetected)
        return false;

    const std::string gameDir = gArgs.getValue("dir");
    if(!gameDir.empty())
    {
        int chosenGame = 0;
        bool found=false;

        // Check if the given parameter makes one game start.
        for( GameEntry &entry : m_Entries)
        {
            if(entry.path == gameDir)
            {
                // found!
                m_chosenGame = chosenGame;
                gLogging.textOut("Launching game from directory: \"" + gameDir + "\"\n");
                gArgs.removeTag("dir");

                setupModsDialog();
                // Nothing else to do, break the loop
                found = true;
                break;
            }
            chosenGame++;
        }

        if(!found)
        {
            const std::string err = "The game from directory: \"" + gameDir + "\" cannot the launched." +
                    "Maybe it's missing or not compatible. Please check if you can run that through the game launcher.\n";

            gLogging.textOut(err);

            showMessageBox("Given path :\"" + gameDir + "\" unknown.\nPlease check the CGLog File!");
        }
    }

    return true;
}
TBool CTestCalInterimApiRichAlarmFormatStep::CheckAlarm3L(CCalAlarm* aAlarm)
	{
	TInt alarmNum = 3;
	if (NULL == aAlarm)
		{
		INFO_PRINTF2(KEntryAlarmNotFound, alarmNum);
		return EFalse;
		}
		
	// This should be an extended alarm, just using the AALARM for timing.
	// Make sure there is no sound name set
		if (aAlarm->AlarmSoundNameL() != _L(""))
		{
		INFO_PRINTF2(KEntryAlarmWrongSound, alarmNum);
		return EFalse;
		}
		
	// Now check the alarm action. The content of the alarm action in
	// this alarm is a jpeg, so we'll read the original jpeg file and compare
	// the buffers
	const CCalContent* alarmAction = aAlarm->AlarmAction();
	if (NULL == alarmAction)
		{
		INFO_PRINTF2(KEntryAlarmActionNotFound, alarmNum);
		return EFalse;
		}
				
	if (alarmAction->MimeType() != _L8("image/jpeg"))
		{
		INFO_PRINTF2(KEntryAlarmActionMimeTypeWrong, alarmNum);
		return EFalse;
		}

	if (alarmAction->Disposition() != CCalContent::EDispositionInline)
		{
		INFO_PRINTF2(KEntryAlarmActionDispositionWrong, alarmNum);
		return EFalse;
		}
		
	// Now we get the original jpeg data from KJPEGDataFile
	RFs   fs;
	fs.Connect();
	CleanupClosePushL(fs);
	RFile dataFile;
	CleanupClosePushL(dataFile);
	
	TInt errData = dataFile.Open(fs, GetFullFileName(KJPEGDataFile), EFileRead);
	if(errData != KErrNone)
		{
		_LIT(KReadJpgOpenErr, "Error Opening the jpg file, %d");
		INFO_PRINTF2(KReadJpgOpenErr, errData);
		CleanupStack::PopAndDestroy(2);
		SetTestStepResult(ETestSuiteError);
		return (TestStepResult());
		}
	TInt dataSize;
	errData = dataFile.Size(dataSize);
	if(errData != KErrNone)
		{
		_LIT(KReadJpgSizeErr, "Error Reading the size from the jpg file, %d");
		INFO_PRINTF2(KReadJpgSizeErr, errData);
		CleanupStack::PopAndDestroy(2);
		SetTestStepResult(ETestSuiteError);
		return (TestStepResult());
		}
		
	HBufC8* dataBuf = HBufC8::NewL(dataSize);
	CleanupStack::PushL(dataBuf);
	TPtr8 dataPtr(dataBuf->Des());
	errData = dataFile.Read(dataPtr);
	if(errData != KErrNone)
		{
		_LIT(KReadJpgReadErr, "Error Reading the jpg from file, %d");
		INFO_PRINTF2(KReadJpgReadErr, errData);
		CleanupStack::PopAndDestroy(3);
		SetTestStepResult(ETestSuiteError);
		return (TestStepResult());
		}
	CleanupStack::Pop(dataBuf);
	CleanupStack::PopAndDestroy(&dataFile);
	CleanupStack::PushL(dataBuf);
	
	
	if (dataPtr != alarmAction->Content())
		{
		INFO_PRINTF2(KEntryAlarmActionContentWrong, alarmNum);
		CleanupStack::PopAndDestroy(2, &fs);
		return EFalse;
		}

	CleanupStack::PopAndDestroy(2, &fs);
	return ETrue;
	}