void Template::OnDraw(){ static int coldelta = 0; CMainCanvas* m_pMainCanvas = Master()->GetMainCanvas(); m_pMainCanvas->Lock(); //m_pMainCanvas->Blit( m_pMainCanvas->GetDimension(), *m_pBackground, // m_pBackground->GetDimension() ); m_pBackground->RenderCopy(); CRectangle frect(700, 500, 185, 185); SDL_Color* wavemap = ColorData::Instance()->Wavemap(); int index = (coldelta * 2 & 63); //m_pMainCanvas->FillRect( frect, mcol ); SDL_Color& fcol = wavemap[index]; CColor color = CColor(fcol.r, fcol.g, fcol.b); m_pMainCanvas->RenderFillRect( frect, &color ); //m_pMainCanvas->AddUpdateRect(frect); CRectangle dstDims( 0, 0, 200, 200); //m_pScrollText->RenderPut(m_pBackground.get(), dstDims, dstDims ); //m_pMainCanvas->AddUpdateRect(dstDims); m_pScroller->Render(); coldelta++; if (coldelta > 64) { coldelta = 0; } //controls::CControl::Redraw(); m_pOverlay->Draw(); m_pMainCanvas->Unlock(); } // OnDraw
/** TestScreen, OnDraw: * Detailed description. * @return TODO */ void TestScreen::OnDraw(){ static int coldelta = 0; CMainCanvas* m_pMainCanvas = Master()->GetMainCanvas(); m_pMainCanvas->Lock(); m_pMainCanvas->Blit( m_pMainCanvas->GetDimension(), *m_pBackground, m_pBackground->GetDimension() ); CRectangle frect(700, 500, 185, 185); SDL_Color* wavemap = ColorData::Instance()->Wavemap(); int index = (coldelta * 2 & 63); //m_pMainCanvas->FillRect( frect, mcol ); SDL_Color& fcol = wavemap[index]; m_pMainCanvas->FillRect( frect, CColor(fcol.r, fcol.g, fcol.b) ); m_pMainCanvas->AddUpdateRect(frect); CRectangle dstDims( 0, 0, 200, 200); m_pScrollText->Put(m_pBackground.get(), dstDims, dstDims ); m_pMainCanvas->AddUpdateRect(dstDims); coldelta++; if (coldelta > 64) { coldelta = 0; } m_pMainCanvas->Unlock(); } // OnDraw
static void gamescreen(void) { clrscr(); stars(); setbg(blue); setfg(white); moveto(1,24); printf(" [j] left [k] rotate [l] right [space] drop [p] pause [n] next [q] quit "); setbg(border); frect(40-WIDTH-2,1,40+WIDTH+1,HEIGHT+1); #define VIEWX 5 #define VIEWY 8 setbg(yellow); rect(VIEWX-3,VIEWY-2,VIEWX+8,VIEWY+5); rect(VIEWX-2,VIEWY-2,VIEWX+7,VIEWY+5); setbg(bg); frect(VIEWX-1, VIEWY-1, VIEWX+6, VIEWY+4); frect(40-WIDTH,1,40+WIDTH-1,HEIGHT); moveto(1,24); flush(); }
void RageTexture::CreateFrameRects() { GetFrameDimensionsFromFileName(GetID().filename, &m_iFramesWide, &m_iFramesHigh); m_TextureCoordRects.clear(); for (int j = 0; j < m_iFramesHigh; j++) { for (int i = 0; i < m_iFramesWide; i++) { RectF frect((i + 0) / (float)m_iFramesWide * m_iImageWidth / (float)m_iTextureWidth, (j + 0) / (float)m_iFramesHigh * m_iImageHeight / (float)m_iTextureHeight, (i + 1) / (float)m_iFramesWide * m_iImageWidth / (float)m_iTextureWidth, (j + 1) / (float)m_iFramesHigh * m_iImageHeight / (float)m_iTextureHeight); m_TextureCoordRects.push_back(frect); } } }
static void splash(void) { int r; clrscr(); setbg(blue); horizontal(1,79,1); horizontal(1,79,24); setfg(white); setbg(white); rect(20,7, 60,18); setbg(red); frect(21,8, 59,17); bold(); moveto(28,9); printf("tctetris - version 0.90"); normal(); setbg(red); setfg(white); moveto(23,10); printf("Copyright (c) 2006, Ivo van Poorten"); moveto(MENUX,12); printf("n - new game"); moveto(MENUX,14); printf("s - speed [%02d]", sspeed); moveto(MENUX,16); printf("q - quit"); moveto(1,23); flush(); }
void RageTexture::CreateFrameRects() { GetFrameDimensionsFromFileName( GetID().filename, &m_iFramesWide, &m_iFramesHigh ); /////////////////////////////////// // Fill in the m_FrameRects with the bounds of each frame in the animation. /////////////////////////////////// m_TextureCoordRects.clear(); for( int j=0; j<m_iFramesHigh; j++ ) // traverse along Y { for( int i=0; i<m_iFramesWide; i++ ) // traverse along X (important that this is the inner loop) { RectF frect( (i+0)/(float)m_iFramesWide*m_iImageWidth /(float)m_iTextureWidth, // these will all be between 0.0 and 1.0 (j+0)/(float)m_iFramesHigh*m_iImageHeight/(float)m_iTextureHeight, (i+1)/(float)m_iFramesWide*m_iImageWidth /(float)m_iTextureWidth, (j+1)/(float)m_iFramesHigh*m_iImageHeight/(float)m_iTextureHeight ); m_TextureCoordRects.push_back( frect ); // the index of this array element will be (i + j*m_iFramesWide) //LOG->Trace( "Adding frect%d %f %f %f %f", (i + j*m_iFramesWide), frect.left, frect.top, frect.right, frect.bottom ); } } }
static void game(void) { char c; int counter = sspeed, rs, a, blocks = 0, paused = 0; gamescreen(); clearboard(); nexts = rnd()%28; nextc = rnd()%7 + 1; newshape(); score = view = 0; if (view) drawview(nexts, nextc); level = 1; speed = sspeed; printscore(); printlevel(); for(;;) { if (paused) { gametick(); c = tgetchar(); switch(c) { case 'q': goto stopgame; case 'p': paused = 0; moveto(68,5); setbg(black); printf(" "); normal(); flush(); default: break; } continue; } if (counter <= 0) { counter = 14 - speed; if (shapefits(current.s, current.x, current.y+1)) { drawshape(current.s, 0, 40-WIDTH-8+current.x*2, current.y-3); current.y++; drawshape(current.s, current.color, 40-WIDTH-8+current.x*2, current.y-3); } else { markboard(current.s, current.color, current.x, current.y); checkboard(current.y); incrscore(1); newshape(); if (!shapefits(current.s, current.x, current.y)) goto stopgame; blocks++; if (blocks == blocksperlevel) { blocks = 0; incrlevel(1); } if (view) drawview(nexts, nextc); } } counter--; moveto(1,24); flush(); gametick(); c = tgetchar(); switch(c) { case 'q': goto stopgame; case 'j': if (shapefits(current.s, current.x-1, current.y)) { drawshape(current.s, 0, 40-WIDTH-8+current.x*2, current.y-3); current.x--; drawshape(current.s, current.color, 40-WIDTH-8+current.x*2, current.y-3); } break; case 'l': if (shapefits(current.s, current.x+1, current.y)) { drawshape(current.s, 0, 40-WIDTH-8+current.x*2, current.y-3); current.x++; drawshape(current.s, current.color, 40-WIDTH-8+current.x*2, current.y-3); } break; case 'k': rs = (current.s & ~0x03) | ((current.s + 1) & 0x03); if (shapefits(rs, current.x, current.y)) { drawshape(current.s, 0, 40-WIDTH-8+current.x*2, current.y-3); current.s = rs; drawshape(current.s, current.color, 40-WIDTH-8+current.x*2, current.y-3); } break; case ' ': for (a=1; ; a++) { if (!shapefits(current.s, current.x, current.y+a)) break; } if (shapefits(current.s, current.x, current.y+a-1)) { drawshape(current.s, 0, 40-WIDTH-8+current.x*2, current.y-3); current.y += a-1; drawshape(current.s, current.color, 40-WIDTH-8+current.x*2, current.y-3); } incrscore(view ? (a-1) * 3 / 4 : a-1); break; case 'n': view ^= 1; if (view) drawview(nexts, nextc); else clearview(); break; case 'p': paused = 1; moveto(68,5); setfg(white); setbg(blue); printf(" PAUSED!!! "); moveto(1,24); flush(); default: break; } } stopgame: setbg(white); rect(20,8,60,12); setbg(red); frect(21,9,59,11); setfg(white); bold(); moveto(30,10); printf(" G A M E O V E R "); moveto(1,24); flush(); for(;;) { c = tgetchar(); if (c > 0) return; } }
static void clearview(void) { normal(); setfg(black); frect(4,7,11,11); }
void qkeybutton::InitAllProperty(KeyBoardItem *pItem) { if (pItem)//打开一个已有的位按钮 { pCopyItem = pItem; pScene->clear(); pScene->addItem(pCopyItem); pBaseItem = new QGroupItem(pCopyItem); pBaseItem->SetHeigth(100); pBaseItem->SetWidth(100); pASCIIInputgen->Init(pItem);//初始化一般页面 pSecurityWight->init(pItem); oId = pItem->id(); ui->spinBox->setValue(oId); } else//新建 { pASCIIInputgen->Init(NULL);//初始化一般页面 KeyInfo key; pASCIIInputgen->onGetinfo(key); KeyBoardItem *pGroupItem = new KeyBoardItem; QRectItem *pBackRect; QRectItem *pFramRect; QSimpleTextItem *pTextRect; QRectF brect(QPointF(5,5), QSize(90,90)); pBackRect = new QRectItem(brect); //pQvalueColor->onGetValueBackColor(mColor); pBackRect->SetBackColor(key.nUpBackColor); pBackRect->SetLineType(0); pBackRect->setZValue(2); pBackRect->SetName(tr("mBackRect")); pBackRect->setFlag(QGraphicsItem::ItemIsSelectable, false); pBackRect->setFlag(QGraphicsItem::ItemIsMovable, false); QRectF frect(QPointF(0,0), QSize(100,100)); pFramRect = new QRectItem(frect); pFramRect->SetBackColor(key.nUpFrameColor); pFramRect->SetLineType(0); pFramRect->setZValue(1); pFramRect->SetName(tr("mFramRect")); pFramRect->setFlag(QGraphicsItem::ItemIsSelectable, false); pFramRect->setFlag(QGraphicsItem::ItemIsMovable, false); QRectF mrect(QPointF(5,5), QSize(90,90)); pTextRect = new QSimpleTextItem(mrect,key.sText); pTextRect->SetName("mText"); pTextRect->SetRectOutLine(false); pTextRect->setZValue(5); pTextRect->setFlag(QGraphicsItem::ItemIsSelectable, false); pTextRect->SetFontColor(pASCIIInputgen->sColor); pGroupItem->addToGroup(pFramRect); pGroupItem->addToGroup(pBackRect); pGroupItem->addToGroup(pTextRect); pCopyItem = pGroupItem; pCopyItem->textItem = pTextRect; pCopyItem->pBackRect = pBackRect; pCopyItem->frameRect = pFramRect; pScene->clear(); pScene->addItem(pCopyItem); pBaseItem = new QGroupItem(pCopyItem); pBaseItem->SetHeigth(100); pBaseItem->SetWidth(100); ui->spinBox->setValue(pwnd->getNewId()); } }
void QValueDlg::onDrawSence(QString sName) { QString sText = ""; QColor mColor(0,0,0); if(bInitFlag)//初始化完成后调用就是重画设置属性 { if("FontColor" == sName) { pQvalueColor->onGetValueColor(mColor); pCopyItem->SetFontColor(mColor); //pBaseItem->SetPropertyValue("mText.FontColor",QVariant(nColor)); } else if("BackColor" == sName) { pQvalueColor->onGetValueBackColor(mColor); pCopyItem->SetRectBackColor(mColor); //pBaseItem->SetPropertyValue("mBackRect.BackColor",QVariant(nColor)); } else if("Text" == sName) { if(DATAINPUTSHOW == eDataType) { sText.clear(); int nTotaldigit = pQvalueShow->onGetTotaldigit(); for(int i = 0; i < nTotaldigit;i++) { sText = sText + "8"; } int nPoint = pQvalueShow->onGetDecimaldigit(); if(nPoint > 0 && nPoint < nTotaldigit) { sText.insert(nTotaldigit - nPoint,'.'); } int nfontsize = pQvalueShow->onGetFontSize(); QString sFont = pQvalueShow->onGetFont(eDataType); pBaseItem->SetPropertyValue("mText.Font",QVariant(sFont)); pBaseItem->SetPropertyValue("mText.FontSize",QVariant(nfontsize)); } else if(ASCIIINPUTSHOW == eDataType) { for(int i = 0; i <pQvalueShow->onGetTotaldigit(); i++) { int nChar = i%26; sText.insert(i,'A'+nChar); } int nfontsize = pQvalueShow->onGetFontSize(); QString sFont = pQvalueShow->onGetFont(eDataType); pBaseItem->SetPropertyValue("mText.Font",QVariant(sFont)); pBaseItem->SetPropertyValue("mText.FontSize",QVariant(nfontsize)); } else if(DATETIMEINPUT == eDataType) { sText = pQvalueBace->onGetpreText(); pCopyItem->SetTextAlign(5); QString sFont = pQvalueBace->onGetFontType(); pBaseItem->SetPropertyValue("mText.Font",QVariant(sFont)); int nfontsize = pQvalueBace->onGetFontSize(); pBaseItem->SetPropertyValue("mText.FontSize",QVariant(nfontsize)); //pBaseItem->SetPropertyValue("mText.Alignment",QVariant(5)); //居中对齐 } pCopyItem->SetText(sText); //pBaseItem->SetPropertyValue("mText.Text",QVariant(sText)); } else if("4" == sName) { if(pCopyItem) { pCopyItem->SetTextAlign(4); } // pBaseItem->SetPropertyValue("mText.Alignment",QVariant(4)); //左对齐 // data_st.eShowStyle = LStart; // ascii_st.nShowStyle = LStart; // time_st.nShowStyle = LStart; } else if("5" == sName) { if(pCopyItem) { pCopyItem->SetTextAlign(5); } // pBaseItem->SetPropertyValue("mText.Alignment",QVariant(5)); //居中对齐 // data_st.eShowStyle = CStart; // ascii_st.nShowStyle = CStart; // time_st.nShowStyle = CStart; } else if("6" == sName) { if(pCopyItem) { pCopyItem->SetTextAlign(6); } // pBaseItem->SetPropertyValue("mText.Alignment",QVariant(6)); //右对齐 // data_st.eShowStyle = RStart; // ascii_st.nShowStyle = RStart; // time_st.nShowStyle = RStart; } else if("Font" == sName) { QString sFont = ""; if(DATAINPUTSHOW == eDataType || ASCIIINPUTSHOW == eDataType) { sFont = pQvalueShow->onGetFont(eDataType); } else { sFont = pQvalueBace->onGetFontType(); } pBaseItem->SetPropertyValue("mText.Font",QVariant(sFont)); } else if("FontSize" == sName) { int nfontsize = 10; if(DATAINPUTSHOW == eDataType || ASCIIINPUTSHOW == eDataType) { nfontsize = pQvalueShow->onGetFontSize(); } else { nfontsize = pQvalueBace->onGetFontSize(); } pBaseItem->SetPropertyValue("mText.FontSize",QVariant(nfontsize)); } else if("FontType" == sName) { onSetFontType(); } } else { if("" != sName) { return;//非初始化进入直接返回 } DataDisplayItem *pGroupItem = new DataDisplayItem; QRectItem *pBackRect; QRectItem *pFramRect; QSimpleTextItem *pTextRect; QRectF brect(QPointF(5,5), QSize(90,90)); pBackRect = new QRectItem(brect); pQvalueColor->onGetValueBackColor(mColor); pBackRect->SetBackColor(mColor); pBackRect->SetLineType(0); pBackRect->setZValue(2); pBackRect->SetName(tr("mBackRect")); pBackRect->setFlag(QGraphicsItem::ItemIsSelectable, false); pBackRect->setFlag(QGraphicsItem::ItemIsMovable, false); QRectF frect(QPointF(0,0), QSize(100,100)); pFramRect = new QRectItem(frect); pFramRect->SetBackColor(QColor(224,224,224)); pFramRect->SetLineType(0); pFramRect->setZValue(1); pFramRect->SetName(tr("mFramRect")); pFramRect->setFlag(QGraphicsItem::ItemIsSelectable, false); pFramRect->setFlag(QGraphicsItem::ItemIsMovable, false); pFramRect->SetPattern(0); QRectF mrect(QPointF(15,25), QSize(70,50)); pTextRect = new QSimpleTextItem(mrect,""); pTextRect->SetName("mText"); pTextRect->SetRectOutLine(false); pTextRect->setZValue(3); pTextRect->setFlag(QGraphicsItem::ItemIsSelectable, false); pTextRect->SetPattern(1); pTextRect->SetFontSize(pQvalueShow->onGetFontSize()); int nTotaldigit = pQvalueShow->onGetTotaldigit(); for(int i = 0; i < nTotaldigit;i++) { sText = sText + "8"; } int nPoint = pQvalueShow->onGetDecimaldigit(); if(nPoint > 0 && nPoint < nTotaldigit) { sText.insert(nTotaldigit - nPoint,'.'); } pTextRect->SetText(sText); pQvalueColor->onGetValueColor(mColor); pTextRect->SetFontColor(mColor); pQvalueColor->onGetValueBackColor(mColor); pTextRect->SetRectBackColor(mColor); QString sFont = pQvalueShow->onGetFont(eDataType); pTextRect->SetFontName(sFont); //pGroupItem->addToGroup(pFramRect); //pGroupItem->addToGroup(pBackRect); pGroupItem->addToGroup(pTextRect); pCopyItem = pGroupItem; pCopyItem->textItem = pTextRect; pScene->clear(); pScene->addItem(pCopyItem); pBaseItem = new QGroupItem(pCopyItem); //pBaseItem->SetHeigth(100); //pBaseItem->SetWidth(100); } setTransparent(); }