Example #1
0
//
// Called when Dialog first appears.
//
BOOL CWaitingForManagers::OnInitDialog()
{
	RECT rect;
	int width;

	CDialog::OnInitDialog();

	// Initialize the countdown.
	remaining_seconds = theApp.cmdline.GetTimeout();
	UpdateCountdown();

	// Tell Windows to call OnTimer every xxxx ms to check
	// for an empty list and to decrement the countdown.
	SetTimer(TIMER_COUNTDOWN, 1000 / polling_frequency, NULL);

	// Figure out the width of the waiting manager list control
	m_LManagers.GetWindowRect(&rect);
	width = rect.right - rect.left + 1;
	width -= 5;		// necessary to avoid seeing a scrollbar (for some reason?)

	// Initialize the manager waiting list CListCtrl
	m_LManagers.InsertColumn(0, "Name", LVCFMT_LEFT, width / 2);
	m_LManagers.InsertColumn(1, "Address", LVCFMT_LEFT, width / 2, 1);

	// Update the waiting list
	DisplayManagers();

	return TRUE;		// return TRUE unless you set the focus to a control
}
Example #2
0
//
// Timer handler -- decrements countdown every second.
//
void CWaitingForManagers::OnTimer(UINT_PTR nIDEvent)
{
	static int accumulator = 0;

	switch (nIDEvent) {
	case TIMER_COUNTDOWN:
		accumulator += 1000 / polling_frequency;

		// Has a second gone by?
		if (accumulator >= 1000) {
			accumulator -= 1000;
			remaining_seconds--;
			UpdateCountdown();
		}

		if (names.GetSize() == 0) {
			theApp.pView->OpenConfigFile(callback_infilename, callback_flags, callback_replace);
			(void)Close();

			// If we are in batch mode, start the test.
			// (In batch mode, this dialog will always appear.)
			if (theApp.IsBatchMode())
				theApp.pView->Go();
		} else if (remaining_seconds <= 0) {
			// theApp.OverrideBatchMode();

			if (theApp.IsBatchMode()) {
				exit(1);
			}

			(void)Close();

			ErrorMessage("Time expired.  Not all managers specified in the config file "
				     "were available in Iometer, so loading was aborted.");
		}
		break;
	default:
		CDialog::OnTimer(nIDEvent);
	}
}
Example #3
0
//*****************************************************************************
//
// Paint the main area of the display while the game is not running.
//
//*****************************************************************************
void
OnStopAreaPaint(tWidget *pWidget, tContext *pContext)
{
    short sX, sY;
    char pcHighScore[32];

    //
    // Determine the position for the top line of text.
    //
    sX = GAME_AREA_LEFT + (GAME_AREA_WIDTH / 2);
    sY = GAME_AREA_TOP + 20;

    //
    // What we display depends upon the current game state.
    //
    switch(g_eGameState)
    {
        //
        // We are waiting for someone to press the "Start" button so just show
        // some very basic instructions.
        //
        case BLOX_WAITING:
        {
            //
            // Clear the canvas.
            //
            GrContextForegroundSet(pContext, BACKGROUND_COLOR);
            GrRectFill(pContext, &(pWidget->sPosition));

            //
            // Display some instructions
            //
            GrContextForegroundSet(pContext, TEXT_COLOR);
            GrContextFontSet(pContext, g_pFontCmss16);
            GrStringDrawCentered(pContext,
                                 "Guide the falling blocks so that they fit",
                                 -1, sX, sY, false);
            GrStringDrawCentered(pContext,
                                 "without leaving gaps. Full rows will be",
                                 -1, sX, sY + 15, false);
            GrStringDrawCentered(pContext,
                                "removed. Earn higher scores by dropping",
                                -1, sX, sY + 30, false);
            GrStringDrawCentered(pContext,
                                 "blocks from a greater height.",
                                 -1, sX, sY + 45, false);
            break;
        }

        //
        // The "Start" button has been pressed.  Show a countdown.
        //
        case BLOX_STARTING:
        {
            //
            // Clear the canvas.
            //
            GrContextForegroundSet(pContext, BACKGROUND_COLOR);
            GrRectFill(pContext, &(pWidget->sPosition));

            //
            // Draw the heading text.
            //
            CenteredStringWithShadow(g_pFontCmss20, "GAME STARTING IN",
                                     sX, sY + 26, false);

            //
            // Draw the countdown time.
            //
            UpdateCountdown(g_ulCountdown);

            break;
        }

        //
        // The game has just ended.  Show the high score.
        //
        case BLOX_GAME_OVER:
        {
            //
            // Write "GAME OVER" with a white shadow.
            //
            CenteredStringWithShadow(g_pFontCmss20, " GAME_OVER ", sX, sY, true);

            //
            // Format the high score string and display it.
            //
            usnprintf(pcHighScore, 32, " %s %d ",
                      g_bNewHighScore ? " NEW HIGH SCORE! " : "High Score",
                      g_iHighScore);
            CenteredStringWithShadow(g_pFontCmss18, pcHighScore, sX, sY + 30,
                                     true);
            break;
        }

        default:
            break;
    }

}
void LogLineBox::countdownData()
{
  UpdateCountdown();
}