Esempio n. 1
0
bool iDibReader::FromFile(iPaletteDib& dib, const iStringT& fname) const
{ 
	if (!iFile::Exists(fname)) return false;
	IMG_TYPE it;
	if (fname.Right(4).CompareIgnoreCase(_T(".bmp")) == 0) it = IT_BMP;
	else if (fname.Right(4).CompareIgnoreCase(_T(".gif")) == 0) it = IT_GIF;
	else return false;

	iFilePtr pFile = NULL;
	pFile = OpenWin32File(fname);
	if (!pFile) return false;
	bool bRes = FromStream(dib,pFile.get(),it);
	return bRes;
}
Esempio n. 2
0
void iHighScore::Load(const iStringT& fname)
{
	iFileStream file(OpenWin32File(fname));
	if (file.IsValid()) {
		uint32 cnt;
		file.Read(cnt);
		iEntry entry;
		while (cnt--) {
			file.Read(entry.land);
			file.Read(entry.date);
			file.Read(entry.days);
			file.Read(entry.score);
			m_entries.Add(entry);
		}
	}
}
Esempio n. 3
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrCmdLine, int nCmdShow)
#endif
{
	// Checks mem availability and closes background apps
	// NB: This is approximate amount of memory (in MB) required to start application
	if ( !EnsureMemAvail( 4 ) ) {
		MessageBox( GetForegroundWindow(), _T("Not enough mana found!"), _T("Startup error"), MB_OK );
		return 0;
	}

	// Root, Save and Maps folders
	iFileName::GetAppPath(gRootPath);
	gDataPath = gRootPath + _T("Data\\");
	gSavePath = gRootPath + _T("Save\\");
	gMapsPath = gRootPath + _T("Maps\\");

	// Init log manager
#ifdef DEBUG_LOG
	gLogMgr.Init(gRootPath+_T("game.log"));
#endif //DEBUG_LOG

	// Load settings
	if (!gSettings.Init(lpstrCmdLine)) {
		MessageBox(NULL, _T("Unable to init game settings!"), NULL, MB_OK);
	}

	// Init application
	uint32 flags = GXLF_LANDSCAPE;
	if (!gSettings.ForceNoSound() && gSettings.GetEntryValue(CET_SFXVOLUME) != 0) flags |= GXLF_ENABLESOUND;
#ifdef OS_WINCE
	if (gSettings.GetEntryValue(CET_LHANDMAODE)) flags |= GXLF_LHANDER;
#endif
#ifdef OS_WIN32
	flags |= GXLF_DOUBLESIZE;
#endif
	if (!gApp.Init(hInstance,L"Palm Heroes",&gGame,30,flags)){
		return -1;
	}

	// ShowLogo and intro image (disabled for this version)
	//iIntroDlg idlg(&gApp.ViewMgr());
	//idlg.DoModal();
	

	// Setup global sfx volume
	if (gApp.SndPlayer().Inited()) {
		gApp.SndPlayer().SetVolume(gSettings.GetEntryValue(CET_SFXVOLUME)*256/10);
	}

	// Setup initial gamma value
	gApp.Display().SetGamma(1.0f + 0.05f * gSettings.GetEntryValue(CET_DISPGAMMA));

	// Init secret dllLib
	pSecret = (iSecret*)malloc(sizeof(iSecret));
	memset(pSecret, 0, sizeof(iSecret));
	pSecret->state = (xxc::dll_init( *pCoreHandle ))?1:0;

	// Init text composer
	if (!gTextComposer.Init()) {
		MessageBox(NULL, _T("Unable to init text composer!"), NULL, MB_OK);
		return -1;
	}

	// Init text resources
	if (!gTextMgr.Init()) {
		MessageBox(NULL, _T("Unable to init text manager!"), NULL, MB_OK);
		return -1;
	}

	// Init gfx resources and fill secret dll
	gGfxMgr.SetGamma( gSettings.GetEntryValue(CET_DISPGAMMA) );
	if (!gGfxMgr.Load(0,(gDataPath+_T("game.gfx")).CStr(), gSettings.MapSpriteFile()?(iGfxManager::LM_MappedFile):(iGfxManager::LM_Memory))) {
		MessageBox(NULL, _T("Unable to open sprite file!"), NULL, MB_OK);
		return -1;
	}


	// Init sfx resources
	if (gSettings.GetEntryValue(CET_SFXVOLUME) != 0 && !gSfxMgr.Init(gDataPath+_T("game.sfx"))) {
		MessageBox(NULL, _T("Unable to open sound resources file!"), NULL, MB_OK);
		return -1;
	}

	// Registration
#if defined(NEED_REGISTRATION)
	// load bloom bits
	{
		iFilePtr pFile = OpenWin32File(gDataPath + L"dumpset.dat");
		// key file is missing!
		check( pFile );
		if ( !pFile ) return -1;
		uint32 bitsSize = pFile->GetSize();
		pBloomBits = (uint8*)malloc(bitsSize);
		pFile->Read(pBloomBits, bitsSize );
	}
	//gSettings.SetActivationKey( iStringT( L"ANWC94TN58FP1ZENT8A6U7GP" ));
	//gSettings.SetActivationKey( iStringT( L"70W88K22AY382PXVH14CWZME" ));Q6K9CQTRN1YZ5R0874FWU34E
	//gSettings.SetActivationKey( iStringT( L"Q6K9CQTRN1YZ5R0874FWU34E" ));
	if (!gSettings.HasActivationKey()) {
		iDlg_Register rdlg(&gApp.ViewMgr());
		rdlg.DoModal();
	}
#endif


	// Initialize and start new game
	if (!gGame.Init(lpstrCmdLine) ) {
		return -1;
	}

#ifdef OS_WINCE
	iLightHolder	lightHolder;
#endif //OS_WINCE

	// Core loop
	sint32 retCode =  gApp.Run();


	// Cleanup
	gApp.Destroy();

	return retCode;
}