/* * GraphicsReleaseCapture: Release mouse capture, if main window has it. * Return True iff main window had mouse capture. */ Bool GraphicsReleaseCapture(void) { if (!capture) return False; ReleaseCapture(); capture = False; GameWindowSetCursor(); return True; }
/* * InventoryReleaseCapture: Release mouse capture, if inventory has it. * Return True iff inventory had mouse capture. */ Bool InventoryReleaseCapture(void) { if (!capture) return False; ReleaseCapture(); capture = False; GameWindowSetCursor(); return True; }
/* * Functions should call RedrawAll if they need the room to be redrawn. * This sets a flag, and the next time an opportunity arises, the room * is redrawn via a call to RedrawForce. */ void RedrawForce(void) { HDC hdc; static DWORD lastEndFrame = 0; DWORD endFrame, startFrame; int totalFrameTime, oldMode; char buffer[32]; if (GameGetState() == GAME_INVALID || /*!need_redraw ||*/ IsIconic(hMain) || view.cx == 0 || view.cy == 0 || current_room.rows == 0 || current_room.cols == 0) { need_redraw = False; return; } timeBeginPeriod(1); startFrame = timeGetTime(); /* REVIEW: Clearing flag before draw phase allows draw phase to set flag. * This is useful in rare circumstances when an effect should * last only one frame, even if animation is off. */ need_redraw = False; hdc = GetDC(hMain); DrawRoom(hdc, view.x, view.y, ¤t_room, map); endFrame = timeGetTime(); msDrawFrame = (int)(endFrame - startFrame); totalFrameTime = (int)(endFrame - lastEndFrame); // if totalFrameTime is less than one, clamp to 1 so we don't divide by 0 or get negative fps if (1 > totalFrameTime) totalFrameTime = 1; fps = 1000 / (int)totalFrameTime; if (config.maxFPS) { if (fps > config.maxFPS) { int msSleep = (1000 / config.maxFPS) - totalFrameTime; Sleep(msSleep); } } lastEndFrame = endFrame; timeEndPeriod(1); if (config.showFPS) { RECT rc,lagBox; wsprintf(buffer, "FPS=%d (%dms) ", fps, msDrawFrame); ZeroMemory(&rc,sizeof(rc)); rc.bottom = DrawText(hdc,buffer,-1,&rc,DT_SINGLELINE|DT_CALCRECT); Lagbox_GetRect(&lagBox); OffsetRect(&rc,lagBox.right + TOOLBAR_SEPARATOR_WIDTH,lagBox.top); DrawWindowBackground(hdc, &rc, rc.left, rc.top); oldMode = SetBkMode(hdc,TRANSPARENT); DrawText(hdc,buffer,-1,&rc,DT_SINGLELINE); SetBkMode(hdc,oldMode); GdiFlush(); } ReleaseDC(hMain, hdc); GameWindowSetCursor(); // We may have moved; reset cursor }