Beispiel #1
0
short FitToScreen(HWND hWnd, BRDATA lpBrData)
{
    HMENU hMenu;
    WORD wRes;

    hMenu = GetMenu(hWnd);
    wRes = GetMenuState(hMenu, IDM_FIT, MF_BYCOMMAND);

    /* If item currently checked, uncheck it. Otherwise check it */
    if (wRes & MF_CHECKED)
        UpdateFitMenu(hWnd, lpBrData, FALSE);
    else
        UpdateFitMenu(hWnd, lpBrData, TRUE);

    /* Fix up the scroll bars */
    if (lpBrData->bFitToScreen)
    {
        SetScrollPos(hWnd, SB_VERT, MINPOS, TRUE);
        SetScrollPos(hWnd, SB_HORZ, MINPOS, TRUE);
    }
    else
    {
        SetScrollPos(hWnd, SB_VERT, lpBrData->vThumb, TRUE);
        SetScrollPos(hWnd, SB_HORZ, lpBrData->hThumb, TRUE);
    }

    /* Cause a repaint */
    UPDATE_SCREEN(hWnd);

    return TRUE;
}
Beispiel #2
0
short ScaleBrowser(HWND hWnd, BRDATA lpBrData, FARPROC fOptions)
{
    if (DialogBox(hInstKappa, (LPSTR) MAKEINTRESOURCE(IDD_BrOptions),
                  hWnd, fOptions))
    {
        /* Setup scroll bars */
        SetScrollPos(hWnd, SB_VERT, lpBrData->vThumb, TRUE);
        SetScrollPos(hWnd, SB_HORZ, lpBrData->hThumb, TRUE);

        /* Cause a repaint */
        UPDATE_SCREEN(hWnd);
    }
    
    return TRUE;
}
Beispiel #3
0
WORD HScroll_Browser(HWND hWnd, BRDATA lpBrData, WORD wParam, long lParam)
{
    float fMaxHRange;
    float fDeltaY = 1.0f;
    short sPos;
    BOOL bScrolled = TRUE;

    switch (wParam) {
      case SB_PAGEUP:
          if (lpBrData->fRightColumn != lpBrData->fLeftColumn)
              fDeltaY = lpBrData->fRightColumn - lpBrData->fLeftColumn + 1;

      case SB_LINEUP:
          if (lpBrData->fLeftColumn == (float) lpBrData->lFocusedLevel)
              bScrolled = FALSE;
          else if (lpBrData->fLeftColumn - fDeltaY < 1.0f)
          {
              lpBrData->fRightColumn -=
                  (lpBrData->fLeftColumn - 1.0f);
              lpBrData->fLeftColumn = lpBrData->lFocusedLevel;
          }
          else
          {
              lpBrData->fLeftColumn -= fDeltaY;
              lpBrData->fRightColumn -= fDeltaY;
          }
          break;

      case SB_PAGEDOWN:
          if (lpBrData->fRightColumn != lpBrData->fLeftColumn)
              fDeltaY = lpBrData->fRightColumn - lpBrData->fLeftColumn + 1;

      case SB_LINEDOWN:
          if (lpBrData->fRightColumn == (float) lpBrData->lDepth)
              bScrolled = FALSE;

          else if (lpBrData->fRightColumn + fDeltaY > 
                   (float) lpBrData->lDepth)
          {
              lpBrData->fLeftColumn +=
                  ((float) lpBrData->lDepth - lpBrData->fRightColumn);
              lpBrData->fRightColumn = (float) lpBrData->lDepth;
          }
          else
          {
              lpBrData->fLeftColumn += fDeltaY;
              lpBrData->fRightColumn += fDeltaY;
          }
          break;

      case SB_THUMBPOSITION:
          sPos = LOWORD(lParam);
          lpBrData->hThumb = sPos;
          SetScrollPos(hWnd, SB_HORZ, lpBrData->hThumb, TRUE);
          if (HIWORD(lParam) != DONT_REDRAW)
              UPDATE_SCREEN(hWnd);
          bScrolled = FALSE;
          break;

      default:
          bScrolled = FALSE;
    }

    /* Update the window */
    if (bScrolled)
    {
        fMaxHRange = (float) lpBrData->lDepth -
            (lpBrData->fRightColumn -
             lpBrData->fLeftColumn + 1.0f);

        if (fMaxHRange != 0.0f)
            lpBrData->hThumb = (short)
                (((float) MAXPOS) *
                 ((lpBrData->fLeftColumn - 1.0f) / fMaxHRange));

        SetScrollPos(hWnd, SB_HORZ, lpBrData->hThumb, TRUE);
        if (HIWORD(lParam) != DONT_REDRAW)
            UPDATE_SCREEN(hWnd);
    }

    return TRUE;
}
Beispiel #4
0
// Main function for showing products and determining how many plinkos you get
static inline int PRODUCTS(void) {
	unsigned char STATUS = RUNNING, FLAG;
	unsigned char plinkos = 1;  // You automatically start out with 1 plinko
	char turn = 1;  // Start out on First turn
	unsigned char n1, n2, real;
	unsigned char x = 0;
	char PRESSED, name[30], option, sign1, sign2;
	typedef unsigned short BOOL;
	BOOL ANSWER;
	
	//const char question[42] = "Which digit is in the actual retail price?";
	
	unsigned char *LIGHT, *DARK;
	
	while(STATUS == RUNNING && turn < 5) {
		
		PRESSED = 0;
		GET_PRODUCT(&n1, &n2, name);  // Send the address of n1, n2, and name.  The reason why name doesn't have a 
		// star is because it is an array and an array automatically give a pointer to it's the first item.
		
		if (random(2)) {  // Discards one of the actual retail price digits and replaces it with a "fake" number
			real = n1;  // Remember the real number to show after a guess
			ANSWER = 1;
			do 
			{
				n1 = random(10);
			} while (real == n1 || n1 == n2);  // Make sure n1 and n2 are not equal and the fake random number is not
			// equal to the real number
		} else {
			real = n2;
			ANSWER = 0;
			do 
			{
				n2 = random(10);
			} while (real == n2 || n1 == n2);
		}
		
		option = random(3);
		
		FLAG = FALSE;
		while(STATUS == RUNNING) {
			
			if (FLAG == FALSE) {
				if (_keytest (RR_LEFT))  x = 0;
				if (_keytest (RR_RIGHT))  x = 1;
			}
			
			LIGHT = Hiddenl;
			DARK = Hiddend;
			
			UPDATE_SCREEN(option, LIGHT, DARK);
			
			sign1 = 1 - 2 * random(2);
			sign2 = 1 - 2 * random(2);
			
			GRAPHIC(56 + (!x)*(sign1 * random(3)), 40 + (!x)*(sign2 * random(3)), n1, TRUE);
			GRAPHIC(82 + (x)*(sign1 * random(3)), 40 + (x)*(sign2 * random(3)), n2, TRUE);
			
			SHOW_PLINKOS(turn, plinkos, Hiddenl, Hiddend);
			
			DrawString (0, name);
			
			if (FLAG != FALSE) {
				GRAPHIC(56 + 26 * (ANSWER == 0), FLAG, real, TRUE);
				if ((FLAG -= 3) <= 40)
					break;
			}
			
			GrayDBufToggleSync(); // switches two sets of planes
			if (FLAG == FALSE) {
				DELAY(5);
				
				if (_keytest (RR_2ND)) PRESSED = 1;
				else if (PRESSED == 1) FLAG = 85;
			}
			
			if (_keytest (RR_ESC))
				return QUIT;
		}
		
		//GRAPHIC(x2, 40, real, TRUE);
		DRAW_BOX(60, 65, 14, 32);
		
		if (ANSWER == x) {  // You guessed right
			plinkos++;
			GraySprite32_OR(64, 69, 14, WINl, WINd, Hiddenl, 
			Hiddend);  // Show WIN
		} else
			GraySprite32_OR(64, 69, 14, wrongl, wrongd, Hiddenl,
			Hiddend);  // Show Wrong
		
		GrayDBufToggleSync(); // switches two sets of planes
		Waitkey();
		
		turn++;
	}
	
	return plinkos;
}