Пример #1
0
HRESULT InputHandler::InitInputHandler(Window* argWindow)
{
	dInput = NULL; //Nullify the DirectInput pointer
	if (FAILED(InitDInput()))
	{
		//Can't initialize DirectInput so we're going to log the error, notify the user and stop the program with a negative exit code
		loggerIH->WriteToFile(FatalError, "Could not create DirectInput interface in InputHandler!");
		argWindow->ShowMessagebox("Could not create DirectInput interface in InputHandler!", "Error", MB_ICONERROR | MB_OK);
		return -1;
	}
	//Create the Listeners now that we have DirectInput
	mousewhisperer = new MouseListener(argWindow, dInput);
	mousewhisperer->setMouseAcceleration(5);
	keyboardwhisperer = new KeyboardListener(argWindow, dInput);
	return 0;
}
Пример #2
0
int main(int argc,char *argv[])
{
  char *t;

  if(timeBeginPeriod(1)!=TIMERR_NOERROR)
  {
   AddLogText("Error setting timer granularity to 1ms.",1);
  }

  if(!FCEUI_Initialize())
   goto doexito;

  srand(GetTickCount());        // rand() is used for some GUI sillyness.

  fceu_hInstance=GetModuleHandle(0);

  GetBaseDirectory();

  sprintf(TempArray,"%s\\fceu98.cfg",BaseDirectory);
  LoadConfig(TempArray);

  t=ParseArgies(argc,argv);
  /* Bleh, need to find a better place for this. */
  {
        palyo&=1;
        FCEUI_SetVidSystem(palyo);
        genie&=1;
        FCEUI_SetGameGenie(genie);
        fullscreen&=1;
        soundo&=1;
        FCEUI_SetSoundVolume(soundvolume);
        FCEUI_SetSoundQuality(soundquality);

  }
  ParseGIInput(NULL);      /* Since a game doesn't have to be
                     loaded before the GUI can be used, make
                     sure the temporary input type variables
                     are set.
                  */

  CreateDirs();
  SetDirs();

  DoVideoConfigFix();
  DoTimingConfigFix();

  if(eoptions&EO_CPALETTE)
   FCEUI_SetPaletteArray(cpalette);

  if(!t) fullscreen=0;

  CreateMainWindow();

  if(!InitDInput())
   goto doexito;

  if(!DriverInitialize())
   goto doexito;

  InitSpeedThrottle();
  UpdateMenu();

  if(t)
   ALoad(t);
  else if(eoptions&EO_FOAFTERSTART)
   LoadNewGamey(hAppWnd, 0);

  doloopy:
  UpdateFCEUWindow();
  if(GI)
  {
   while(GI)
   {
         uint8 *gfx;
         int32 *sound;
         int32 ssize;

         FCEUI_Emulate(&gfx, &sound, &ssize, 0);
         xbsave = gfx;
         FCEUD_Update(gfx, sound, ssize);
   }
   xbsave = NULL;
   RedrawWindow(hAppWnd,0,0,RDW_ERASE|RDW_INVALIDATE);
   StopSound();
  }
  Sleep(50);
  if(!exiting)
   goto doloopy;

  doexito:
  DriverKill();
  timeEndPeriod(1);
  FCEUI_Kill();
  return(0);
}
Пример #3
0
LRESULT CGameApp::InitGame()
{
	if(S_OK!=InitDInput())	return E_FAIL;
	if(S_OK!=InitD3D())		return E_FAIL;

	HFONT hOldFont, hNewFont;
	// 创建逻辑字体hLeftFont,用于显示加载界面
	hNewFont = CreateFont(32, 0, 0, 0, FW_BOLD, 0, 0, 0, ANSI_CHARSET, 0, 0, 0, 0, "Comic Sans MS");;
	HDC hwndDC=GetDC(m_hwnd);
	hOldFont=(HFONT)SelectObject(hwndDC,hNewFont);
	SetTextColor(hwndDC, RGB(255, 255, 0));
	RECT rectRange;
	GetClientRect(m_hwnd,&rectRange); 
	HDC dcMem=CreateCompatibleDC(hwndDC);
	HBITMAP bmpMem=(HBITMAP)LoadImage(NULL,"logo.bmp",IMAGE_BITMAP,
									  rectRange.right-rectRange.left ,
									  rectRange.bottom-rectRange.top,
									  LR_LOADFROMFILE);
	SelectObject(dcMem,bmpMem);
	BitBlt(hwndDC,rectRange.left,rectRange.top,rectRange.right,rectRange.bottom,dcMem,0,0,SRCCOPY);  
	SetBkMode(hwndDC,TRANSPARENT); 
	int x = (rectRange.left + rectRange.right)/2 - 150;
	int y = 5;
	TextOut(hwndDC,x,y,"正在加载文件,请稍候...\n",23);

	TCHAR szDriver[5];
	TCHAR szDir[_MAX_PATH];
	::GetModuleFileName(NULL, m_szWorkDir, sizeof(m_szWorkDir)/sizeof(TCHAR));
	_tsplitpath(m_szWorkDir, szDriver, szDir, NULL, NULL);
	_tcscpy(m_szWorkDir, szDriver);
	_tcscat(m_szWorkDir, szDir);

	m_Reader.SetWorkDir(m_szWorkDir);
	m_Reader.SetMapFile("config\\map.cfg");
	m_Reader.SetPosFile("config\\position.cfg");
	m_Reader.SetTourFile("config\\tour.cfg");
	m_Reader.SetRoadFile("config\\road.cfg");
	m_Reader.LoadAll();

	if(S_OK!=InitScene())	return E_FAIL; 

	//释放临时的GDI对象
	SelectObject(hwndDC,hOldFont);
	DeleteObject(hNewFont);
	DeleteObject(bmpMem);
	DeleteObject(dcMem);
	DeleteObject(hwndDC);
	
	RECT rt;
	::GetClientRect(m_hwnd, &rt);
	rt.left += 40;
	rt.right = rt.left + 140;
	rt.top += 10;
	rt.bottom = rt.top + 40;
	m_pStopWatch = new CStopWatch(m_pD3DDevice, FALSE);
	m_pStopWatch->SetPosition(rt);
	_tcscpy(szDir, m_szWorkDir);
	_tcscat(szDir, m_Reader.m_szStopWatch);
	m_pStopWatch->SetTexture(szDir);
	m_pStopWatch->Start(game_time);

	::SendMessage(m_hwnd, MSG_GAME_NEW, 0, 0);
	return D3D_OK;
}