Exemple #1
0
void ZVision::initialize() {
	const Common::FSNode gameDataDir(ConfMan.get("path"));

	_searchManager = new SearchManager(ConfMan.get("path"), 6);

	_searchManager->addDir("FONTS");
	_searchManager->addDir("addon");

	if (getGameId() == GID_GRANDINQUISITOR) {
		if (!_searchManager->loadZix("INQUIS.ZIX"))
			error("Unable to load file INQUIS.ZIX");
	} else if (getGameId() == GID_NEMESIS) {
		if (!_searchManager->loadZix("NEMESIS.ZIX")) {
			// The game might not be installed, try MEDIUM.ZIX instead
			if (!_searchManager->loadZix("ZNEMSCR/MEDIUM.ZIX"))
				error("Unable to load the file ZNEMSCR/MEDIUM.ZIX");
		}
	}

	initScreen();

	// Register random source
	_rnd = new Common::RandomSource("zvision");

	// Create managers
	_scriptManager = new ScriptManager(this);
	_renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _resourcePixelFormat, _doubleFPS);
	_saveManager = new SaveManager(this);
	_stringManager = new StringManager(this);
	_cursorManager = new CursorManager(this, _resourcePixelFormat);
	_textRenderer = new TextRenderer(this);
	_midiManager = new MidiManager();

	if (getGameId() == GID_GRANDINQUISITOR)
		_menu = new MenuZGI(this);
	else
		_menu = new MenuNemesis(this);

	// Initialize the managers
	_cursorManager->initialize();
	_scriptManager->initialize();
	_stringManager->initialize(getGameId());

	registerDefaultSettings();

	loadSettings();

#ifndef USE_MPEG2
	// libmpeg2 not loaded, disable the MPEG2 movies option
	_scriptManager->setStateValue(StateKey_MPEGMovies, 2);
#endif

	// Create debugger console. It requires GFX to be initialized
	_console = new Console(this);
	_doubleFPS = ConfMan.getBool("doublefps");

	// Initialize FPS timer callback
	getTimerManager()->installTimerProc(&fpsTimerCallback, 1000000, this, "zvisionFPS");
}
bool
GHOST_SystemSDL::processEvents(bool waitForEvent)
{
	// Get all the current events -- translate them into
	// ghost events and call base class pushEvent() method.

	bool anyProcessed = false;

	do {
		GHOST_TimerManager *timerMgr = getTimerManager();

		if (waitForEvent && m_dirty_windows.empty() && !SDL_HasEvents(SDL_FIRSTEVENT, SDL_LASTEVENT)) {
			GHOST_TUns64 next = timerMgr->nextFireTime();

			if (next == GHOST_kFireTimeNever) {
				SDL_WaitEventTimeout(NULL, -1);
				//SleepTillEvent(m_display, -1);
			}
			else {
				GHOST_TInt64 maxSleep = next - getMilliSeconds();

				if (maxSleep >= 0) {
					SDL_WaitEventTimeout(NULL, next - getMilliSeconds());
					// SleepTillEvent(m_display, next - getMilliSeconds()); // X11
				}
			}
		}

		if (timerMgr->fireTimers(getMilliSeconds())) {
			anyProcessed = true;
		}

		SDL_Event sdl_event;
		while (SDL_PollEvent(&sdl_event)) {
			processEvent(&sdl_event);
			anyProcessed = true;
		}

		if (generateWindowExposeEvents()) {
			anyProcessed = true;
		}
	} while (waitForEvent && !anyProcessed);

	return anyProcessed;
}
Exemple #3
0
bool GHOST_SystemWin32::processEvents(bool waitForEvent)
{
	MSG msg;
	bool anyProcessed = false;

	do {
		GHOST_TimerManager *timerMgr = getTimerManager();

		if (waitForEvent && !::PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) {
#if 1
			::Sleep(1);
#else
			GHOST_TUns64 next = timerMgr->nextFireTime();
			GHOST_TInt64 maxSleep = next - getMilliSeconds();
			
			if (next == GHOST_kFireTimeNever) {
				::WaitMessage();
			}
			else if (maxSleep >= 0.0) {
				::SetTimer(NULL, 0, maxSleep, NULL);
				::WaitMessage();
				::KillTimer(NULL, 0);
			}
#endif
		}

		if (timerMgr->fireTimers(getMilliSeconds())) {
			anyProcessed = true;
		}

		// Process all the events waiting for us
		while (::PeekMessageW(&msg, 0, 0, 0, PM_REMOVE) != 0) {
			// TranslateMessage doesn't alter the message, and doesn't change our raw keyboard data.
			// Needed for MapVirtualKey or if we ever need to get chars from wm_ime_char or similar.
			::TranslateMessage(&msg);
			::DispatchMessageW(&msg);
			anyProcessed = true;
		}
	} while (waitForEvent && !anyProcessed);

	return anyProcessed;
}
Exemple #4
0
void OSystem::initBackend() {
	// Verify all managers has been set
	if (!_audiocdManager)
		error("Backend failed to instantiate audio CD manager");
	if (!_eventManager)
		error("Backend failed to instantiate event manager");
	if (!getTimerManager())
		error("Backend failed to instantiate timer manager");

	// TODO: We currently don't check _savefileManager, because at least
	// on the Nintendo DS, it is possible that none is set. That should
	// probably be treated as "saving is not possible". Or else the NDS
	// port needs to be changed to always set a _savefileManager
// 	if (!_savefileManager)
// 		error("Backend failed to instantiate savefile manager");

	// TODO: We currently don't check _fsFactory because not all ports
	// set it.
// 	if (!_fsFactory)
// 		error("Backend failed to instantiate fs factory");
}
Exemple #5
0
bool GHOST_SystemWin32::processEvents(bool waitForEvent)
{
	MSG msg;
	bool anyProcessed = false;

	do {
		GHOST_TimerManager* timerMgr = getTimerManager();

		if (waitForEvent && !::PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) {
#if 1
			::Sleep(1);
#else
			GHOST_TUns64 next = timerMgr->nextFireTime();
			GHOST_TInt64 maxSleep = next - getMilliSeconds();
			
			if (next == GHOST_kFireTimeNever) {
				::WaitMessage();
			} else if(maxSleep >= 0.0) {
				::SetTimer(NULL, 0, maxSleep, NULL);
				::WaitMessage();
				::KillTimer(NULL, 0);
			}
#endif
		}

		if (timerMgr->fireTimers(getMilliSeconds())) {
			anyProcessed = true;
		}

		// Process all the events waiting for us
		while (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE) != 0) {
			::TranslateMessage(&msg);
			::DispatchMessage(&msg);
			anyProcessed = true;
		}
	} while (waitForEvent && !anyProcessed);

	return anyProcessed;
}
/* this is an old style low level event queue.
 * As we want to handle our own timers, this is ok.
 * the full screen hack should be removed */
bool GHOST_SystemCarbon::processEvents(bool waitForEvent)
{
	bool anyProcessed = false;
	EventRef event;
	
//	SetMouseCoalescingEnabled(false, NULL);

	do {
		GHOST_TimerManager *timerMgr = getTimerManager();
		
		if (waitForEvent) {
			GHOST_TUns64 next = timerMgr->nextFireTime();
			double timeOut;
			
			if (next == GHOST_kFireTimeNever) {
				timeOut = kEventDurationForever;
			}
			else {
				timeOut = (double)(next - getMilliSeconds()) / 1000.0;
				if (timeOut < 0.0)
					timeOut = 0.0;
			}
			
			::ReceiveNextEvent(0, NULL, timeOut, false, &event);
		}
		
		if (timerMgr->fireTimers(getMilliSeconds())) {
			anyProcessed = true;
		}

		if (getFullScreen()) {
			// Check if the full-screen window is dirty
			GHOST_IWindow *window = m_windowManager->getFullScreenWindow();
			if (((GHOST_WindowCarbon *)window)->getFullScreenDirty()) {
				pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) );
				anyProcessed = true;
			}
		}

		/* end loop when no more events available */
		while (::ReceiveNextEvent(0, NULL, 0, true, &event) == noErr) {
			OSStatus status = ::SendEventToEventTarget(event, ::GetEventDispatcherTarget());
			if (status == noErr) {
				anyProcessed = true;
			}
			else {
				UInt32 i = ::GetEventClass(event);
				
				/* Ignore 'cgs ' class, no documentation on what they
				 * are, but we get a lot of them
				 */
				if (i != 'cgs ') {
					if (i != 'tblt') {  // tablet event. we use the one packaged in the mouse event
						; //printf("Missed - Class: '%.4s', Kind: %d\n", &i, ::GetEventKind(event));
					}
				}
			}
			::ReleaseEvent(event);
		}
	} while (waitForEvent && !anyProcessed);
	
	return anyProcessed;
}