Пример #1
1
void COutlook2Ctrl::AnimateToFolder(int f)
{
	m_iSelectedFolder = f;
 	pLastHilink = NULL;
	m_csCaption = GetFolder(f)->csName;

	if (m_iSize > 4)
	{

		CRect rc;
		GetClientRect(rc);

		CDC dc;
		CClientDC cdc(this);
		dc.CreateCompatibleDC(&cdc);
		CBitmap bmp;
		bmp.CreateCompatibleBitmap(&cdc, rc.Width(), rc.Height());
		CBitmap * ob = (CBitmap *) dc.SelectObject(&bmp);

		DrawCaption(&dc, rc);
		CRect rcBdr(rc);
		rc.InflateRect(-1,-1);
		DrawButtons(&dc, rc);
		int iBottomInner = rc.bottom;
		dc.Draw3dRect(rcBdr, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
		rcInnerRect = rc;
		dc.FillSolidRect(rc, m_crBackground);
		if (m_iSelectedFolder >= 0 && m_iSelectedFolder < m_Folders.GetSize())
		{
			COL2Folder * o = (COL2Folder *) m_Folders.GetAt(m_iSelectedFolder);
			DrawItems(&dc, o, rc);
		}

		for (int t = iBottomInner - 10; t > 0; t -= (iBottomInner/8))
		{
			cdc.BitBlt(0,t,rc.Width(), iBottomInner - t, &dc, 0,0, SRCCOPY);
			Sleep(30);
		}
		dc.SelectObject(ob);
	}

	Invalidate();
}
Пример #2
0
GUI_Status GfxWidget::Select( short item ) {
  if ( item < 0 ) item = -1;
  else if ( item >= items ) item = items - 1;

  if ( item != current ) {
    short newtop = toprow;
    current = item;

    if ( current >= 0 ) {
      short selrow = (current/gfx_per_row) * ItemHeight();
      if ( selrow < toprow ) newtop = selrow;
      else if ( selrow + ItemHeight() >= newtop + visrows )
        newtop = selrow - visrows + ItemHeight();
    }

    if ( toprow != newtop ) {
      static_cast<SliderWidget *>( GetWidget(0) )->ScrollTo( newtop );
    } else {
      DrawItems();
      Show();
    }
  }
  if ( hook ) return hook->WidgetActivated( this, surface );
  return GUI_OK;
}
Пример #3
0
void CDlgConfirm2::OnPaint() 
{
	CPaintDC dc(this);
	CRect rc;
	GetClientRect(rc);
	CBitmap* pOldBmp = memDC.SelectObject(&bitmap);
	memDC.BitBlt(0,0, rc.Width(), rc.Height(), &bk_normal_dc, 0, 0, SRCCOPY);

	CString str;
	CRect Rect;
	enBtnState state;

	//绘制背景
	for(int i=0;i<3;i++)
	{
		Rect = m_Item[i].rect;
		state = m_Item[i].nState;
		DrawItems(&memDC,Rect,state);
	}

	DrawBtnText(&memDC,CRect(0,80,494,274),m_stTitle,CGDICommon::Instance()->bigbigfont(),
		RGB(255,255,255),DT_CENTER|DT_WORDBREAK);

	BOOL b = dc.BitBlt(0, 0, rc.Width(), rc.Height(),&memDC,0,0,SRCCOPY);
	ASSERT(b);

	memDC.SelectObject(pOldBmp);
}
Пример #4
0
void CDlgFailureDiagonostic::OnPaint() 
{
	CPaintDC dc(this);
	CRect rc;
	GetClientRect(rc);
	CBitmap* pOldBmp = memDC.SelectObject(&bitmap);
	memDC.BitBlt(0,0, rc.Width(), rc.Height(), &bk_normal_dc, 0, 0, SRCCOPY);
	
	CString str;
	CRect Rect;
	enBtnState state;
	
	for(int i=0;i<enCtrCount;i++)
	{
		//»æÖƱ³¾°
		str		= m_Item[i].chChar;
		Rect	= m_Item[i].rect;
		state	= m_Item[i].nState;
		DrawItems(&memDC,Rect,state);
		Rect.bottom += 35;
		DrawBtnText(&memDC,Rect,str,CGDICommon::Instance()->smallfont(),
			RGB(255,255,255),DT_CENTER|DT_BOTTOM);
	}

	DrawBtnText(&memDC,g_retTitile,m_csTitile,CGDICommon::Instance()->bigbigfont(),
		RGB(255,255,255),DT_VCENTER|DT_CENTER);
	
	BOOL b = dc.BitBlt(0, 0, rc.Width(), rc.Height(),&memDC,0,0,SRCCOPY);
	ASSERT(b);
	
	memDC.SelectObject(pOldBmp);
}
Пример #5
0
void VividTree::OnPaint()
{
	CPaintDC dc(this);	// Device context for painting
	CDC dc_ff;			// Memory base device context for flicker free painting
	CBitmap bm_ff;		// The bitmap we paint into
	CBitmap *bm_old;
	CFont *font, *old_font;
	CFont fontDC;
	int old_mode;

	GetClientRect(&m_rect);
	SCROLLINFO scroll_info;
	// Determine window portal to draw into taking into account
	// scrolling position
	if ( GetScrollInfo( SB_HORZ, &scroll_info, SIF_POS | SIF_RANGE ) )
	{
		m_h_offset = -scroll_info.nPos;
		m_h_size = max( scroll_info.nMax+1, m_rect.Width());
	}
	else
	{
		m_h_offset = m_rect.left;
		m_h_size = m_rect.Width();
	}
	if ( GetScrollInfo( SB_VERT, &scroll_info, SIF_POS | SIF_RANGE ) )
	{
		if ( scroll_info.nMin == 0 && scroll_info.nMax == 100) 
			scroll_info.nMax = 0;
		m_v_offset = -scroll_info.nPos * GetItemHeight();
		m_v_size = max( (scroll_info.nMax+2)*((int)GetItemHeight()+1), m_rect.Height() );
	}
	else
	{
		m_v_offset = m_rect.top;
		m_v_size = m_rect.Height();
	}

	// Create an offscreen dc to paint with (prevents flicker issues)
	dc_ff.CreateCompatibleDC( &dc );
    bm_ff.CreateCompatibleBitmap( &dc, m_rect.Width(), m_rect.Height() );
    // Select the bitmap into the off-screen DC.
    bm_old = (CBitmap *)dc_ff.SelectObject( &bm_ff );
	// Default font in the DC is not the font used by 
	// the tree control, so grab it and select it in.
	font = GetFont();
	old_font = dc_ff.SelectObject( font );
	// We're going to draw text transparently
	old_mode = dc_ff.SetBkMode( TRANSPARENT );

	DrawBackGround( &dc_ff );
	DrawItems( &dc_ff );
	DrawItemLines(&dc_ff);

    // Now Blt the changes to the real device context - this prevents flicker.
    dc.BitBlt( m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(), &dc_ff, 0, 0, SRCCOPY);

	dc_ff.SelectObject( old_font );
	dc_ff.SetBkMode( old_mode );
    dc_ff.SelectObject( bm_old );
}
Пример #6
0
//-------------------------------------------------------------------------------------------
//!
//-------------------------------------------------------------------------------------------
void tScrollerBar::paintEvent( QPaintEvent* pEvent )
{
    QWidget::paintEvent( pEvent );

    QPainter painter( this );
    painter.setRenderHint( QPainter::Antialiasing );
    painter.setPen( Qt::black );
    painter.setBrush( QBrush( Qt::black ) );
    painter.drawRect( rect() );

    DrawItems( &painter );

    switch( m_MinimisedPanel )
    {
    case tContextPanelController::eUIState_SmartTow:
    case tContextPanelController::eUIState_Cruise:
    case tContextPanelController::eUIState_Eco:
    case tContextPanelController::eUIState_Troll:
        DrawUnavailableOverlay( &painter );
        break;

    default:
        // Do nothing
        break;
    }
    
}
Пример #7
0
void CDlgAnswerList::OnPaint() 
{
	CPaintDC dc(this);
	CRect rc;
	GetClientRect(rc);
	CBitmap* pOldBmp = memDC.SelectObject(&bitmap);
	memDC.BitBlt(0,0, rc.Width(), rc.Height(), &bk_normal_dc, 0, 0, SRCCOPY);

	CString str;
	CRect Rect;
	enBtnState state;
	int i;

	for(i=0;i<BTN_COUNT;i++)
	{	//绘制背景
		str = m_Item[i].chChar;
		Rect = m_Item[i].rect;
		state = m_Item[i].nState;
		DrawItems(&memDC,Rect,state);
	}

	//绘制列表
	DrawList(&memDC);

	DrawBtnText(&memDC,g_retTitile,m_csTitile,CGDICommon::Instance()->bigbigfont(),
		RGB(255,255,255),DT_VCENTER|DT_CENTER);

	BOOL b = dc.BitBlt(0, 0, rc.Width(), rc.Height(),&memDC,0,0,SRCCOPY);
	ASSERT(b);

	memDC.SelectObject(pOldBmp);
}
Пример #8
0
void CDlgDriveEconomy::OnPaint() 
{
	CPaintDC dc(this);
	CRect rc;
	GetClientRect(rc);
	CBitmap* pOldBmp = memDC.SelectObject(&bitmap);
	memDC.BitBlt(0,0, rc.Width(), rc.Height(), &bk_normal_dc, 0, 0, SRCCOPY);
	
	CString str;
	CRect Rect;
	enBtnState state;
	
	for(int i=0;i<enCtrCount;i++)
	{
		//绘制背景
		str		= m_Item[i].chChar;
		Rect	= m_Item[i].rect;
		state	= m_Item[i].nState;
		DrawItems(&memDC,Rect,state);
		DrawBtnText(&memDC,Rect,str,smallfont,RGB(255,255,255),DT_CENTER|DT_BOTTOM);
	}
	
	DrawBtnText(&memDC,g_retTitile,m_csTitile,bigfont,RGB(255,255,255),DT_VCENTER|DT_LEFT);
	
	BOOL b = dc.BitBlt(0, 0, rc.Width(), rc.Height(),&memDC,0,0,SRCCOPY);
	ASSERT(b);
	
	memDC.SelectObject(pOldBmp);
}
Пример #9
0
void COutlook2Ctrl::OnPaint()
{
	ClearRects();
	CPaintDC pdc(this);

	CRect rc;
	GetClientRect(rc);
	if (m_iSize <= 4)
	{
		pdc.FillSolidRect(rc, GetSysColor(COLOR_3DFACE));
		return;
	}
	COMemDC dc(&pdc);
	DrawCaption(&dc, rc);
	CRect rcBdr(rc);
	rc.InflateRect(-1,-1);
	DrawButtons(&dc, rc);
	dc.Draw3dRect(rcBdr, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
	rcInnerRect = rc;
	dc.FillSolidRect(rc, m_crBackground);
	if (m_iSelectedFolder >= 0 && m_iSelectedFolder < m_Folders.GetSize())
	{
		COL2Folder * o = (COL2Folder *) m_Folders.GetAt(m_iSelectedFolder);
		DrawItems(&dc, o, rc);
	}
}
Пример #10
0
GUI_Status GfxWidget::WidgetActivated( Widget *widget, Window *win ) {
  if ( widget->ID() == 0 ) {
    toprow = static_cast<SliderWidget *>(widget)->Level();
    DrawItems();
    Show();
  }
  return GUI_OK;
}
Пример #11
0
void CDlg_Search::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

    DrawItems(&dc);	

    // Do not call CDialog::OnPaint() for painting messages
}
Пример #12
0
void
ListControl::OnPaint(Canvas &canvas)
{
  if (item_renderer != nullptr)
    DrawItems(canvas, origin, origin + items_visible + 2);

  DrawScrollBar(canvas);
}
Пример #13
0
void
ListControl::OnPaint(Canvas &canvas, const PixelRect &dirty)
{
  if (item_renderer != nullptr)
    DrawItems(canvas, origin + (dirty.top + pixel_pan) / item_height,
              origin + (dirty.bottom + pixel_pan + item_height - 1) / item_height);

  DrawScrollBar(canvas);
}
Пример #14
0
void CBrowser::OnDraw(const SRect &rUpdate)
{
	if( !IsVisible() )
		return;

	mpPrimitives->DrawRect(rUpdate, GetRect(), SRGB(192, 192, 192));

	SPos Pos(GetPos() + SPos(miMarginLeft, miMarginTop));
	DrawItems(rUpdate, mItemRoot.SubItems, Pos);
}
Пример #15
0
void CFeedIcoItemListCtrl::OnPaint()
{
	CRect rectClip;
	{	
		CPaintDC dcPaint(this); // device context for painting
		//dcPaint.GetClipBox(rectClip);
	}

	CRect rectClient; 
	GetClientRect(&rectClient); //获取客户区大小

	CClientDC dc(this); //背景图 获取客户区DC
	dc.GetClipBox(rectClip);

	CDC dcMem; //定义一个显示设备对象
	dcMem.CreateCompatibleDC(NULL);//随后建立与屏幕显示兼容的内存显示设备

	CBitmap MemBitmap;//定义一个位图对象(画布)
	MemBitmap.CreateCompatibleBitmap(&dc,rectClient.Width(),rectClient.Height());

	//将位图选入到内存显示设备中
	CBitmap *pOldBit = dcMem.SelectObject(&MemBitmap);//相当于将此位图设置为画布
	dcMem.SetBkMode(TRANSPARENT);

	CBrush *pBKBrush = new CBrush( RGB(0xf3,0xf3,0xf3/*246, 252, 251*/) );
	dcMem.FillRect( rectClient, pBKBrush );//填充客户区背景色
	delete pBKBrush;

	
	//CMemDC dcMem(&dc, rectClient);
	//dcMem.BitBlt(0, 0, rectClient.Width(), rectClient.Height(), &dc, 0, 0, SRCCOPY);

	//CFont * pListFont = GetFont();
	//CFont * pOrgMemFont = NULL;
	//if ( pListFont != NULL )
	//{
	//	pOrgMemFont = dcMem.SelectObject(pListFont);
	//}
	//dcMem.SetBkMode(TRANSPARENT);

	if ( GetItemCount() > 0 )
	{
		DrawGroupInfo(dcMem, rectClip, rectClient);
		DrawItems(dcMem, rectClip, rectClient);
	}

	//if ( pOrgMemFont != NULL )
	//{
	//	dcMem.SelectObject(pOrgMemFont);
	//}
	//dcMem->Flush();
	dc.BitBlt( rectClient.left, rectClient.top, rectClient.Width(),rectClient.Height(), &dcMem, 0,0, SRCCOPY );//最终贴图
}
Пример #16
0
void CBrightnessSetDlg::OnPaint() 
{
	CPaintDC dc(this);
	CRect rc;
	GetClientRect(rc);
	CBitmap* pOldBmp = memDC.SelectObject(&bitmap);
	memDC.BitBlt(0,0, rc.Width(), rc.Height(), &bk_normal_dc, 0, 0, SRCCOPY);

	CString str;
	CRect Rect;
	enBtnState state;

	for(int i=0;i<7;i++)
	{
		//绘制背景
		str = m_Item[i].chChar;
		Rect = m_Item[i].rect;
		state = m_Item[i].nState;
		DrawItems(&memDC,Rect,state);
//		Rect.top = Rect.top + 54;
//		DrawBtnText(&memDC,Rect,str,RGB(255,125,0));
	}
	
	str = m_Item[1].chChar;
	Rect = m_Item[1].rect;
	state = BTN_STATE_DISABLE;
	if( CSysConfig::Instance().GetLanguage() != ID_CHINESE &&  CSysConfig::Instance().GetLanguage() != ID_ENGLISH )
		DrawBtnText(&memDC,Rect,str,CGDICommon::Instance()->bigbigfont(),
		RGB(255,255,255), DT_CENTER | DT_VCENTER);
	else
		DrawBtnText(&memDC,Rect,str,CGDICommon::Instance()->bigbigfont(),
		RGB(255,255,255), DT_CENTER | DT_VCENTER);
	
	str = m_Item[4].chChar;
	Rect = m_Item[4].rect;
	state = BTN_STATE_DISABLE;
	if( CSysConfig::Instance().GetLanguage() != ID_CHINESE &&  CSysConfig::Instance().GetLanguage() != ID_ENGLISH )
		DrawBtnText(&memDC,Rect,str,CGDICommon::Instance()->bigbigfont(),
		RGB(255,255,255), DT_CENTER | DT_VCENTER);
	else
		DrawBtnText(&memDC,Rect,str,CGDICommon::Instance()->bigbigfont(),
		RGB(255,255,255), DT_CENTER | DT_VCENTER);


	DrawBtnText(&memDC,g_retTitile,m_csTitile,CGDICommon::Instance()->bigbigfont(),
		RGB(255,255,255),DT_VCENTER|DT_CENTER);

	BOOL b = dc.BitBlt(0, 0, rc.Width(), rc.Height(),&memDC,0,0,SRCCOPY);
	ASSERT(b);

	memDC.SelectObject(pOldBmp);	
}
Пример #17
0
void Container::DrawUI()
{
	//opening and closing the container onto the screen. SLIDES.
	Vector2f center = window->getView().getCenter();
	Vector2f size = window->getView().getSize();

	m_sprite.setPosition(center.x + size.x / 2 - offset.x, center.y - size.y / 2);
	window->draw(m_sprite);

	if (open) {
		DrawItems();
	}
}
Пример #18
0
void CBrowser::DrawItems(const SRect RectUpdate, const std::list<SItem*>& Items, SPos& Pos)
{
	SSize SizeBitmap;
	mpArrow->GetRealSize(SizeBitmap);

	tint32 iNrOfItems = Items.size();
	std::list<SItem*>::const_iterator it = Items.begin();
	tint32 iItem;
	for (iItem = 0; iItem < iNrOfItems; iItem++, it++) {
		SItem* pItem = *it;

		if (pItem->bFolder) {
			// Item is folder
			DrawBitmapFrame(mpArrow, RectUpdate, SRect(Pos, SizeBitmap),
				pItem->bFolderIsOpen ? 1 : 0,
				2);
		}

		SPos PosText = Pos + mTextPosition;
		SSize SizeText;
		SizeText.iCY = mpFont->GetTextHeight();
		SizeText.iCX = mpFont->GetTextWidth((tchar*)(pItem->sNameModified.c_str()));
		DrawFont(mpFont,
			RectUpdate,
			SRect(PosText, SizeText),
			(const tchar*)(pItem->sNameModified.c_str()));

		if (pItem == mpItemSelected) {
			// This is the selected item
			SRect RectInvert(GetPos(), SizeText);
			RectInvert.iY = PosText.iY - 1;
			RectInvert.iCY += 1;
			RectInvert.iCX = GetSize().iCX;
			mpPrimitives->InvertRect(RectUpdate, RectInvert);
		}

		Pos.iY += miSpaceBetweenItems;

		if (pItem->bFolder) {
			if (pItem->bFolderIsOpen) {
				tint iX = Pos.iX;
				Pos.iX += miSpaceBetweenFolders;
				DrawItems(RectUpdate, pItem->SubItems, Pos);
				Pos.iX = iX;
			}
		}
	}
}
Пример #19
0
void CDlgComSetting::OnPaint() 
{
	CPaintDC dc(this);
	CRect rc;
	GetClientRect(rc);
	CBitmap* pOldBmp = memDC.SelectObject(&bitmap);
	memDC.BitBlt(0,0, rc.Width(), rc.Height(), &bk_normal_dc, 0, 0, SRCCOPY);

	CString str;
	CRect Rect;
	enBtnState state;

	for(int i=0;i<BTN_COUNT;i++)
	{
		//绘制背景
		str = m_Item[i].chChar;
		Rect = m_Item[i].rect;
		state = m_Item[i].nState;
		DrawItems(&memDC,Rect,state);
		DrawBtnText(&memDC,Rect,str,CGDICommon::Instance()->bigfont(),
			RGB(255,255,255),DT_VCENTER|DT_CENTER);
	}

	str = _T("IC卡串口:");
	Rect = m_Item[0].rect;
	Rect.left = 40;
	DrawBtnText(&memDC,Rect,str,CGDICommon::Instance()->bigfont(),
		RGB(255,255,255),DT_VCENTER|DT_LEFT);
	str = _T("条形码扫描串口:");
	Rect = m_Item[3].rect;
	Rect.left = 40;
	DrawBtnText(&memDC,Rect,str,CGDICommon::Instance()->bigfont(),
		RGB(255,255,255),DT_VCENTER|DT_LEFT);
	str = _T("RFID串口:");
	Rect = m_Item[6].rect;
	Rect.left = 40;
	DrawBtnText(&memDC,Rect,str,CGDICommon::Instance()->bigfont(),
		RGB(255,255,255),DT_VCENTER|DT_LEFT);

	DrawBtnText(&memDC,g_retTitile,m_csTitile,CGDICommon::Instance()->bigbigfont(),
		RGB(255,255,255),DT_VCENTER|DT_CENTER);

	BOOL b = dc.BitBlt(0, 0, rc.Width(), rc.Height(),&memDC,0,0,SRCCOPY);
	ASSERT(b);

	memDC.SelectObject(pOldBmp);	
}
Пример #20
0
void CDlg_OpmlImport::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	
	// Do not call CCustomDlg::OnPaint() for painting messages

	DrawItems(&dc);

	CRect rect;
	m_editFileLocation.GetWindowRect(rect);
	ScreenToClient(rect);

	rect.InflateRect(1, 1 + EDIT_MARGIN, 1, 1);

	CPen*	pOldPen = dc.SelectObject(&m_penOutline);
	dc.Rectangle(rect);
	dc.SelectObject(pOldPen);
}
Пример #21
0
void CPhoneLog::OnPaint() 
{
	CPaintDC dc(this);
	CRect rc;
	GetClientRect(rc);
	CBitmap* pOldBmp = memDC.SelectObject(&bitmap);
	memDC.BitBlt(0,0, rc.Width(), rc.Height(), &bk_normal_dc, 0, 0, SRCCOPY);

	CString str;
	CRect Rect;
	enBtnState state;

	for(int i=0;i<12;i++)
	{
		//绘制背景
		str = m_Item[i].chChar;
		Rect = m_Item[i].rect;
		state = m_Item[i].nState;
		DrawItems(&memDC,Rect,state);
	}

	CRect temprect;
	for(int j=0; j<5; j++)
	{
		temprect		= m_Item[j].rect;
		temprect.left	+= 20;
		DrawBtnText(&memDC,temprect,ItemStr[j],CGDICommon::Instance()->smallfont(),
			RGB(255,255,255),DT_LEFT | DT_VCENTER);

		temprect.left	+= 265;
		DrawBtnText(&memDC,temprect,m_strTime[j],CGDICommon::Instance()->smallfont(),
			RGB(255,255,255),DT_LEFT | DT_VCENTER);
	}

	DrawBtnText(&memDC,g_retTitile,m_stTitle,CGDICommon::Instance()->bigbigfont(),
		RGB(255,255,255),DT_CENTER | DT_VCENTER);
	BOOL b = dc.BitBlt(0, 0, rc.Width(), rc.Height(),&memDC,0,0,SRCCOPY);
	ASSERT(b);

	memDC.SelectObject(pOldBmp);
}
Пример #22
0
void VendorEncounter::SellingItemsLoop()
{
    string Message = "How can I help you, " + player.GetName() + "?";
    unsigned i=0;
    for(int y=0; y<13; ++y)
    {
        for(int x=0; x<4; ++x)
        {
            if(i<player.GetItems().size())
            {
                ItemGrid[y][x] = i;
            }
            else
            {
                ItemGrid[y][x] = -1;
            }
            ++i;
        }
    }
    int IterX = 0, IterY = 0;
    ArrowX = 0; ArrowY = 70;
    ArrowSprite.setPosition(ArrowX, ArrowY);
    while(Window.isOpen()) 
    {
        while(Window.pollEvent(Event))
        {
            if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Up))
            {
                if(IterY != 0)
                {
                    --IterY;
                    ArrowY -= 32;
                    ArrowSprite.setPosition(ArrowX, ArrowY);
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Down))
            {
                if(IterY != 12)
                {
                    ++IterY;
                    ArrowY += 32;
                    ArrowSprite.setPosition(ArrowX, ArrowY);
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Right))
            {
                if(IterX != 3)
                {
                    ++IterX;
                    ArrowX += 81;
                    ArrowSprite.setPosition(ArrowX, ArrowY);
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Left))
            {
                if(IterX != 0)
                {
                    --IterX;
                    ArrowX -= 81;
                    ArrowSprite.setPosition(ArrowX, ArrowY);
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Return))
            {
                switch(player.GetItems()[ItemGrid[IterY][IterX]].Type)
                {
                case ITEM_QUEST:
                    Message = "I don't want that item.";
                    break;
                default:
                    player.SetWealth(player.GetWealth() + player.GetItems()[ItemGrid[IterY][IterX]].SellPrice);
                    player.RemoveItem(ItemGrid[IterY][IterX]);
                    MoneyText.setString(IntToString(player.GetWealth()));
                    break;
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Escape))
            {
                return;
            }
        }
        Window.clear();
        Window.draw(GUISprite);
        Window.draw(ArrowSprite);
        Window.draw(sf::Sprite(ScreenTexture));
        DrawItems();
        DrawMessage(Message);
        Window.draw(MoneySprite);
        Window.draw(MoneyText);
        if(ItemGrid[IterY][IterX] != -1)
        {
            ItemSprite.setTexture(player.GetItems()[ItemGrid[IterY][IterX]].ItemTexture);
            switch(player.GetItems()[ItemGrid[IterY][IterX]].Type) //PH
            {
            case ITEM_FOOD:
                ItemName.setString
                    (player.GetItems()[ItemGrid[IterY][IterX]].Name 
                    + '\n' + "Regenrates " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].Value)
                    + " health." + '\n' + "Cannot be used in combat" + '\n'
                    + "Buy Price: " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].BuyPrice) + '\n'
                    + "Sell Price: " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].SellPrice));
                break;
            case ITEM_POWER_POTION:
                ItemName.setString
                    (player.GetItems()[ItemGrid[IterY][IterX]].Name 
                    + '\n' + "Regenrates " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].Value)
                    + " power." + '\n' + "Can be used in combat" + '\n'
                    + "Buy Price: " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].BuyPrice) + '\n'
                    + "Sell Price: " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].SellPrice));
                break;
            case ITEM_HEALTH_POTION:
                ItemName.setString
                    (player.GetItems()[ItemGrid[IterY][IterX]].Name 
                    + '\n' + "Regenrates " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].Value)
                    + " health." + '\n' + "Can be used in combat" + '\n'
                    + "Buy Price: " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].BuyPrice) + '\n'
                    + "Sell Price: " + IntToString(player.GetItems()[ItemGrid[IterY][IterX]].SellPrice));
                break;
            }
            Window.draw(ItemName);
            Window.draw(ItemSprite);
        }
        Window.display();
    }
}
Пример #23
0
void VendorEncounter::MainLoop()
{
    Font.loadFromFile("Graphics/papyrus.ttf");
    BuyItem.setString("Buy Item");
    SellItem.setString("Sell Item");
    YourItems.setString("Your items: ");
    VendorItems.setString("Vendors items: ");
    Return.setString("Back to Game");
    DrawTexture();
    MoneyText.setString(IntToString(player.GetWealth()));
    MoneyText.setStyle(sf::Text::Bold);
    MoneyText.setColor(sf::Color::Black);
    MoneyText.setPosition(410.0f, 20.0f);
    sf::Texture ArrowTexture, GUITexture, MoneyTexture;
    MoneyTexture.loadFromFile("Items/Money.png");
    MoneyText.setFont(Font);
    MoneySprite.setTexture(MoneyTexture);
    MoneySprite.setPosition(380.0f, 20.0f);
    ArrowTexture.loadFromFile("Graphics/Arrow2.png");
    GUITexture.loadFromFile("Graphics/VendorScreen.png");
    ArrowSprite.setTexture(ArrowTexture);
    ArrowSprite.setPosition(ArrowX, ArrowY);
    GUISprite.setTexture(GUITexture);
    int Command = 0;

    while(Window.isOpen()) 
    {
        while(Window.pollEvent(Event))
        {
            if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Up))
            {
                if(Command != 0)
                {
                    --Command;
                    ArrowY -= 35;
                    ArrowSprite.setPosition(ArrowX, ArrowY);
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Down))
            {
                if(Command != 2)
                {
                    ++Command;
                    ArrowY += 35;
                    ArrowSprite.setPosition(ArrowX, ArrowY);
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Return))
            {
                switch(Command)
                {
                case 0:
                    BuyingItemsLoop();
                    break;
                case 1:
                    SellingItemsLoop();
                    break;
                case 2:
                    return;
                }
                Command = 0;
                ArrowX = 405.0f;
                ArrowY = 370.0f;
                ArrowSprite.setPosition(ArrowX, ArrowY);
            }
        }
        Window.clear();
        Window.draw(GUISprite);
        DrawItems();
        Window.draw(sf::Sprite(ScreenTexture));
        Window.draw(ArrowSprite);
        DrawMessage("How can I help you, " + player.GetName() + "?");
        Window.draw(MoneySprite);
        Window.draw(MoneyText);
        Window.display();
    }
}
Пример #24
0
void VendorEncounter::BuyingItemsLoop()
{
    string Message = "How can I help you, " + player.GetName() + "?";
    unsigned i=0;
    for(int y=0; y<13; ++y)
    {
        for(int x=0; x<4; ++x)
        {
            if(i < vendor.Items.size())
            {
                ItemGrid[y][x] = i;
            }
            else
            {
                ItemGrid[y][x] = -1;
            }
            ++i;
        }
    }
    int IterX = 0, IterY = 0;
    ArrowX = 636; ArrowY = 70;
    ArrowSprite.setPosition(ArrowX, ArrowY);
    while(Window.isOpen()) 
    {
        while(Window.pollEvent(Event))
        {
            if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Up))
            {
                if(IterY != 0)
                {
                    --IterY;
                    ArrowY -= 32;
                    ArrowSprite.setPosition(ArrowX, ArrowY);
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Down))
            {
                if(IterY != 12)
                {
                    ++IterY;
                    ArrowY += 32;
                    ArrowSprite.setPosition(ArrowX, ArrowY);
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Right))
            {
                if(IterX != 3)
                {
                    ++IterX;
                    ArrowX += 81;
                    ArrowSprite.setPosition(ArrowX, ArrowY);
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Left))
            {
                if(IterX != 0)
                {
                    --IterX;
                    ArrowX -= 81;
                    ArrowSprite.setPosition(ArrowX, ArrowY);
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Return))
            {
                if(player.GetWealth() < vendor.Items[ItemGrid[IterY][IterX]].BuyPrice)
                {
                    Message = "You cannot afford that item!";
                    continue;
                }
                if(player.GetItems().size() == MAX_ITEMS)
                {
                    Message = "You cannot carry any more items";
                    continue;
                }
                player.SetWealth(player.GetWealth() - vendor.Items[ItemGrid[IterY][IterX]].BuyPrice);
                player.AddItem(vendor.Items[ItemGrid[IterY][IterX]]);
                Message = "It's been pleasure trading with you, " + player.GetName();
                MoneyText.setString(IntToString(player.GetWealth()));
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Escape))
            {
                return;
            }
        }
        Window.clear();
        Window.draw(GUISprite);
        Window.draw(ArrowSprite);
        Window.draw(sf::Sprite(ScreenTexture));
        DrawMessage(Message);
        DrawItems();
        Window.draw(MoneySprite);
        Window.draw(MoneyText);
        if(ItemGrid[IterY][IterX] != -1)
        {
            ItemSprite.setTexture(vendor.Items[ItemGrid[IterY][IterX]].ItemTexture);
            switch(vendor.Items[ItemGrid[IterY][IterX]].Type) //PH
            {
            case ITEM_FOOD:
                ItemName.setString
                    (vendor.Items[ItemGrid[IterY][IterX]].Name 
                    + '\n' + "Regenrates " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].Value)
                    + " health." + '\n' + "Cannot be used in combat" + '\n'
                    + "Buy Price: " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].BuyPrice) + '\n'
                    + "Sell Price: " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].SellPrice));
                break;
            case ITEM_MANA_FOOD:
                ItemName.setString
                    (vendor.Items[ItemGrid[IterY][IterX]].Name 
                    + '\n' + "Regenrates " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].Value)
                    + " power." + '\n' + "Cannot be used in combat" + '\n'
                    + "Buy Price: " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].BuyPrice) + '\n'
                    + "Sell Price: " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].SellPrice));
                break;
            case ITEM_POWER_POTION:
                ItemName.setString
                    (vendor.Items[ItemGrid[IterY][IterX]].Name 
                    + '\n' + "Regenrates " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].Value)
                    + " power." + '\n' + "Can be used in combat" + '\n'
                    + "Buy Price: " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].BuyPrice) + '\n'
                    + "Sell Price: " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].SellPrice));
                break;
            case ITEM_HEALTH_POTION:
                ItemName.setString
                    (vendor.Items[ItemGrid[IterY][IterX]].Name 
                    + '\n' + "Regenrates " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].Value)
                    + " health." + '\n' + "Can be used in combat" + '\n'
                    + "Buy Price: " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].BuyPrice) + '\n'
                    + "Sell Price: " + IntToString(vendor.Items[ItemGrid[IterY][IterX]].SellPrice));
                break;
            }
            Window.draw(ItemSprite);
            Window.draw(ItemName);
        }
        Window.display();
    }
}
Пример #25
0
void GfxWidget::Draw( void ) {
  CompositeWidget::Draw();
  surface->DrawBox( Rect(x,y,bounds.w+8,h), BOX_RECESSED );
  if ( init ) DrawItems();
}
Пример #26
0
void RadialPlot::Draw(wxDC *dc)
{
	bool mustDeleteDc = false;
	if (!dc)
	{
		dc = new wxClientDC(this);
		mustDeleteDc = true;
	}

	wxSize s = dc->GetSize();

	if (!backBuffer || s.x != backBuffer->GetWidth() || s.y != backBuffer->GetHeight())
	{
		if (backBuffer)
			delete backBuffer;
		backBuffer = new wxBitmap(s.x, s.y);
	}

	wxMemoryDC bdc;
	bdc.SelectObject(*backBuffer);



	bdc.SetFont(*wxNORMAL_FONT);
	bdc.SetPen(*wxBLACK_PEN);

	bdc.Clear();

	CustomDrawPre(&bdc);

	DrawItems(&bdc);


	int h = 0;
	bdc.GetTextExtent(wxT("A"), NULL, &h);

	wxString t;
	t.Printf(wxT("Full circle = %d"), maxValue );

	bdc.DrawText(t, 1, bdc.GetSize().y - h - 1);

	if (selected != (unsigned int)(-1))
	{
		bdc.DrawText(wxString::FromAscii(GetName(items[selected].handle)), 1,1);

		wxString t;
		t.Printf(wxT("%d\n"), GetValue(items[selected].handle));

		bdc.DrawText(t, 1,20);

	}

	CustomDrawPost(&bdc);

	bdc.SelectObject(wxNullBitmap);

	dc->DrawBitmap(*backBuffer,0,0);

	if (mustDeleteDc)
	{
		delete dc;
	}
}