Ejemplo n.º 1
0
void COpenHoldemView::UpdateDisplay(const bool update_all) {
	bool		update_it = false;
	CDC			*pDC = GetDC();

	CString sym_handnumber = p_handreset_detector->GetHandNumber();
	double  sym_bblind = p_symbol_engine_tablelimits->bblind();
	double  sym_sblind = p_symbol_engine_tablelimits->sblind();
	double  sym_ante = p_symbol_engine_tablelimits->ante();
	int     sym_lim = p_symbol_engine_gametype->gametype();
	bool    sym_istournament = p_symbol_engine_istournament->istournament();
	double  sym_pot = p_symbol_engine_chip_amounts->pot();

	// Get size of current client window
	GetClientRect(&_client_rect);

	// Set background color (light gray)
	if (update_all) 
	{
		CBrush backBrush(COLOR_GRAY);
		CBrush* pOldBrush = pDC->SelectObject(&backBrush);
		pDC->PatBlt(_client_rect.left, _client_rect.top, _client_rect.right-_client_rect.left, _client_rect.bottom-_client_rect.top, PATCOPY);
		pDC->SelectObject(pOldBrush);
	}

	// Draw center info box
	update_it = false;
	if (_handnumber_last != sym_handnumber) 
	{
		_handnumber_last = sym_handnumber;
		update_it = true;
	}
	if (_sblind_last != sym_sblind) 
	{
		_sblind_last = sym_sblind;
		update_it = true;
	}
	if (_bblind_last != sym_bblind) 
	{
		_bblind_last = sym_bblind;
		update_it = true;
	}
	if (_lim_last != sym_lim) 
	{
		_lim_last = sym_lim;
		update_it = true;
	}
	if (_istournament_last != sym_istournament) 
	{
		_istournament_last = sym_istournament;
		update_it = true;
	}
	if (_ante_last != sym_ante != 0) 
	{
		_ante_last = sym_ante;
		update_it = true;
	}
	if (_pot_last != sym_pot) 
	{
		_pot_last = sym_pot;
		update_it = true;
	}

  if ((p_symbol_engine_autoplayer->ismyturn()) || update_it || update_all) 
	{
		assert(p_white_info_box != NULL);
    p_white_info_box->Draw(_client_rect, _logfont, pDC,
      &_black_pen, &_white_brush);
    ReleaseDC(pDC);
	}

	// Draw button state indicators
	DrawButtonIndicators();

	// Draw common cards
	for (int i=0; i<kNumberOfCommunityCards; i++) 
	{
    Card *p_card = &p_table_state->_common_cards[i];
    int card_value = p_table_state->_common_cards[i].GetValue();
		if (_card_common_last[i] != card_value || update_all) 
		{
			_card_common_last[i] = card_value;
			write_log(preferences.debug_gui(), "[GUI] COpenHoldemView::UpdateDisplay() Drawing common card %i: [%s]\n",
        i, p_card->ToString());
			DrawCard(p_card,
					  _client_rect.right/2 + cc[i][0], _client_rect.bottom/2 + cc[i][1],
					  _client_rect.right/2 + cc[i][0] + CARDSIZEX, _client_rect.bottom/2 + cc[i][1] + CARDSIZEY,
					  false);
		}
	}
  // Draw collection of player info
	for (int i=0; i<p_tablemap->nchairs(); i++) 	{
		write_log(preferences.debug_gui(), "[GUI] COpenHoldemView::UpdateDisplay() checking changes for chair %i\n", i);
		// Figure out if we need to redraw this seat
		update_it = false;
		if (_seated_last[i] != p_table_state->_players[i]._seated 
        || _active_last[i] != p_table_state->_players[i]._active) 	{
			_seated_last[i] = p_table_state->_players[i]._seated;
			_active_last[i] = p_table_state->_players[i]._active;
			update_it = true;
		}
    if (_card_player_last[i][0] != p_table_state->_players[i]._hole_cards[0].GetValue()
        || _card_player_last[i][1] != p_table_state->_players[i]._hole_cards[1].GetValue()) 		{
			_card_player_last[i][0] = p_table_state->_players[i]._hole_cards[0].GetValue();
			_card_player_last[i][1] = p_table_state->_players[i]._hole_cards[1].GetValue();
			update_it = true;
		}
		if (_dealer_last[i] != p_table_state->_players[i]._dealer) {
			_dealer_last[i] = p_table_state->_players[i]._dealer;
			update_it = true;
		}
		if (_playername_last[i] != p_table_state->_players[i]._name) {
			_playername_last[i] = p_table_state->_players[i]._name;
			update_it = true;
		}
		if (_playerbalance_last[i] != p_table_state->_players[i]._balance) {
			_playerbalance_last[i] = p_table_state->_players[i]._balance;
			update_it = true;
		}
		if (_playerbet_last[i] != p_table_state->_players[i]._bet) 
		{
			_playerbet_last[i] = p_table_state->_players[i]._bet;
			update_it = true;
		}

		if (update_it || update_all) {
			write_log(preferences.debug_gui(), "[GUI] COpenHoldemView::UpdateDisplay() updating chair %i\n", i);
			// Draw active circle
			if (p_table_state->_players[i]._seated) 	{
				DrawSeatedActiveCircle(i);
				// Draw cards first, because we want the name 
				// to occlude the cards and not the other way.
				DrawPlayerCards(i);
				DrawNameBox(i);
				DrawBalanceBox(i);
        DrawColourCodes(i);
			}
			// Drawing a bet, even if no player seated.
			// The player might have left the table, 
			// but depending on casinos potmethod a bet might still be there.
			DrawPlayerBet(i);
		}
		// Draw dealer button
		// At some casinos the dealer can be at an empty seat.
		// Therefore we draw the dealer-button anyway, inependent of "seated" and "active".
		// Draw it at the very last, as we want to have it at the top of the cards.
		if (p_table_state->_players[i]._dealer) {
			DrawDealerButton(i);
		}
	}
	write_log(preferences.debug_gui(), "[GUI] COpenHoldemView::UpdateDisplay() Update finished\n");
	ReleaseDC(pDC);
	write_log(preferences.debug_gui(), "[GUI] COpenHoldemView::UpdateDisplay() DC released\n");
}
Ejemplo n.º 2
0
void COpenHoldemView::UpdateDisplay(const bool update_all) 
{
	int			i = 0;

	bool		update_it = false;
	RECT		cr = {0};
	CDC			*pDC = GetDC();

	CString		sym_handnumber = p_handreset_detector->GetHandNumber();
	double		sym_bblind = p_tablelimits->bblind();
	double		sym_sblind = p_tablelimits->sblind();
	double		sym_ante = p_tablelimits->ante();
	int			sym_lim = p_tablelimits->gametype();
	bool		sym_istournament = p_tablelimits->istournament();
	double		sym_pot = p_symbol_engine_chip_amounts->pot();

	// Get size of current client window
	GetClientRect(&cr);

	// Set background color (light gray)
	if (update_all) 
	{
		CBrush backBrush(COLOR_GRAY);
		CBrush* pOldBrush = pDC->SelectObject(&backBrush);
		pDC->PatBlt(cr.left, cr.top, cr.right-cr.left, cr.bottom-cr.top, PATCOPY);
		pDC->SelectObject(pOldBrush);
	}

	// Draw center info box
	update_it = false;
	if (_handnumber_last != sym_handnumber) 
	{
		_handnumber_last = sym_handnumber;
		update_it = true;
	}
	if (_sblind_last != sym_sblind) 
	{
		_sblind_last = sym_sblind;
		update_it = true;
	}
	if (_bblind_last != sym_bblind) 
	{
		_bblind_last = sym_bblind;
		update_it = true;
	}
	if (_lim_last != sym_lim) 
	{
		_lim_last = sym_lim;
		update_it = true;
	}
	if (_istournament_last != sym_istournament) 
	{
		_istournament_last = sym_istournament;
		update_it = true;
	}
	if (_ante_last != sym_ante != 0) 
	{
		_ante_last = sym_ante;
		update_it = true;
	}
	if (_pot_last != sym_pot) 
	{
		_pot_last = sym_pot;
		update_it = true;
	}

	if (prefs.log_symbol_enabled() || update_it || update_all) 
	{
		DrawCenterInfoBox();
	}

	// Draw button state indicators
	DrawButtonIndicators();

	// Draw common cards
	for (i=0; i<5; i++) 
	{
		if (_card_common_last[i] != p_scraper->card_common(i) || update_all) 
		{
			_card_common_last[i] = p_scraper->card_common(i);

			DrawCard(p_scraper->card_common(i),
					  cr.right/2 + cc[i][0], cr.bottom/2 + cc[i][1],
					  cr.right/2 + cc[i][0] + CARDSIZEX, cr.bottom/2 + cc[i][1] + CARDSIZEY,
					  false);
		}
	}

	// Draw collection of player info
	for (i=0; i<p_tablemap->nchairs(); i++) 
	{

		// Figure out if we need to redraw this seat
		update_it = false;
		if (_seated_last[i] != p_scraper->seated(i) ||
			_active_last[i] != p_scraper->active(i)) 
		{
			_seated_last[i] = p_scraper->seated(i);
			_active_last[i] = p_scraper->active(i);
			update_it = true;
		}
		if (_card_player_last[i][0] != p_scraper->card_player(i, 0) ||
			_card_player_last[i][1] != p_scraper->card_player(i, 1)) 
		{
			_card_player_last[i][0] = p_scraper->card_player(i, 0);
			_card_player_last[i][1] = p_scraper->card_player(i, 1);
			update_it = true;
		}
		if (_dealer_last[i] != p_scraper->dealer(i)) 
		{
			_dealer_last[i] = p_scraper->dealer(i);
			update_it = true;
		}
		if (_playername_last[i] != p_scraper->player_name(i)) 
		{
			_playername_last[i] = p_scraper->player_name(i);
			update_it = true;
		}
		if (_playerbalance_last[i] != p_scraper->player_balance(i)) 
		{
			_playerbalance_last[i] = p_scraper->player_balance(i);
			update_it = true;
		}
		if (_playerbet_last[i] != p_scraper->player_bet(i)) 
		{
			_playerbet_last[i] = p_scraper->player_bet(i);
			update_it = true;
		}

		if (update_it || update_all) 
		{
			// Draw active circle
			if (p_string_match->IsStringSeated(p_scraper->seated(i))) 
				DrawSeatedActiveCircle(i);

			// Draw player cards
			DrawCard(p_scraper->card_player(i, 0),
					  cr.right * pc[p_tablemap->nchairs()][i][0] - CARDSIZEX - 2,
					  cr.bottom * pc[p_tablemap->nchairs()][i][1] - CARDSIZEY/2,
					  cr.right * pc[p_tablemap->nchairs()][i][0] - 2,
					  cr.bottom * pc[p_tablemap->nchairs()][i][1] + CARDSIZEY/2 - 1,
					  true);
			DrawCard(p_scraper->card_player(i, 1),
					  cr.right * pc[p_tablemap->nchairs()][i][0] + 1,
					  cr.bottom * pc[p_tablemap->nchairs()][i][1] - CARDSIZEY/2,
					  cr.right * pc[p_tablemap->nchairs()][i][0] + CARDSIZEX + 1,
					  cr.bottom * pc[p_tablemap->nchairs()][i][1] + CARDSIZEY/2 - 1,
					  true);

			// Draw dealer button
			if (p_scraper->dealer(i))
				DrawDealerButton(i);

			// Draw name and balance boxes
			DrawNameBox(i);
			DrawBalanceBox(i);

			// Draw player bet
			DrawPlayerBet(i);
		}
	}

	ReleaseDC(pDC);
}