void KisColorSelector::paintEvent(QPaintEvent* /*event*/) { // 0 red -> (1,0,0) // 1 yellow -> (1,1,0) // 2 green -> (0,1,0) // 3 cyan -> (0,1,1) // 4 blue -> (0,0,1) // 5 maenta -> (1,0,1) // 6 red -> (1,0,0) m_renderBuffer.fill(0); QPainter imgPainter(&m_renderBuffer); QPainter wdgPainter(this); QRect fgRect(0, 0 , QWidget::width(), QWidget::height()/2); QRect bgRect(0, QWidget::height()/2, QWidget::width(), QWidget::height()/2); wdgPainter.fillRect(fgRect, m_fgColor.getQColor()); wdgPainter.fillRect(bgRect, m_bgColor.getQColor()); for(int i=0; i<m_colorRings.size(); ++i) drawRing(imgPainter, m_colorRings[i], m_renderArea); wdgPainter.drawImage(m_renderArea, m_renderBuffer); drawOutline (wdgPainter, m_renderArea); drawLightStrip(wdgPainter, m_lightStripArea); }
LevelSelectState::LevelSelectState(StateStack &stack, Context context) : State(stack, context), mGUIContainer(context, context.window->getDefaultView()), mLevelContainer(std::make_shared<GUI::Container>(context, context.window->getDefaultView())), numLevels(0){ sf::Vector2u windowSize = context.window->getSize(); //Background sf::Texture &bgTexture = getContext().textureManager->get(TextureID::Background); sf::IntRect bgRect( 0, 0, static_cast<int>(windowSize.x), static_cast<int>(windowSize.y)); bgTexture.setRepeated(true); mBackground = sf::Sprite(bgTexture, bgRect); //Backdrop sf::Texture &backdropTexture = getContext().textureManager->get(TextureID::GrasslandsBackground); sf::IntRect backdropRect( 0, 0, static_cast<int>(windowSize.x), backdropTexture.getSize().y); backdropTexture.setRepeated(true); mBackdrop = sf::Sprite(backdropTexture, backdropRect); mBackdrop.setPosition( 0, windowSize.y - static_cast<float>(backdropTexture.getSize().y)); //Panel to display levels buildLevelPanel(); //Gem tracking sf::Texture &HUDTexture = context.textureManager->get(TextureID::HUDSpriteSheet); GUI::Image::Ptr cross = std::make_shared<GUI::Image>( HUDTexture, sf::IntRect(0, 239, 30, 28)); GUI::Number::Ptr numGems = std::make_shared<GUI::Number>( *context.textureManager, static_cast<unsigned int>(getCollectedGems())); GUI::Image::Ptr gem = std::make_shared<GUI::Image>( HUDTexture, sf::IntRect(98, 185, 46, 36)); sf::Vector2f panelTopRight( windowSize.x * 0.5f + mLevelPanel.getGlobalBounds().width / 2.f, windowSize.y * 0.5f - mLevelPanel.getGlobalBounds().height / 2.f); mGUIContainer.add(cross); mGUIContainer.add(numGems); mGUIContainer.add(gem); cross->setPosition(panelTopRight); numGems->setPosition(panelTopRight); gem->setPosition(panelTopRight); cross->move(-135.f, 20); numGems->move(-90.f, 20); gem->move(-30.f, 20); //Play main theme if we didn't get here from the menu state if (!context.musicPlayer->isPlaying()) context.musicPlayer->play(MusicID::MainTheme); }
void CCtrlEdit::doKeyboardShowAction() { if (!isVisible()) { return; } DLG_HANDLE hHandleDlg = GetTopParent(); CCMyWndObject* pWndObject = g_objUIMgr.GetWndObj(hHandleDlg); if (NULL == pWndObject) { return; } CCNode *pHandleNode = dynamic_cast<CCNode*>(pWndObject); if (NULL == pHandleNode) { return; } CCPoint destPos = getPosition(); CCRect bgRect(destPos.x, destPos.y, m_nWidth, m_nHeight); if (bgRect.origin.y - m_nHeight < m_infoIMEKeyboardNotification.end.origin.y + m_infoIMEKeyboardNotification.end.size.height) { m_RecordPos.y = pHandleNode->getPositionY(); m_RecordPos.x = 0; CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); destPos.x = 0; destPos.y = m_infoIMEKeyboardNotification.end.size.height+ visibleSize.height; CCMoveTo* moveTo = CCMoveTo::create(m_infoIMEKeyboardNotification.duration, destPos); pHandleNode->runAction(moveTo); } }
void RunKey( void ) { Sprite *s; int nac; int sel_type=0; unsigned long otype; switch( actcode ) { #ifdef KEY_TOPLEFT case KEY_TOPLEFT: case KEY_TOPRIGHT: case KEY_BOTTOMLEFT: case KEY_BOTTOMRIGHT: #endif case RC_LEFT : case RC_RIGHT : case RC_UP : case RC_DOWN : HandleDirection ( actcode ); break; case RC_RED : // kill all lemmings if ( pause || (action!=2) || !in_level ) break; SoundPlay( SND_OHNO ); FBGetImage( 11*32+32, 384, 32, 48, svdimage[11] ); FBDrawRect( 11*32+32, 384, 31, 47, RED ); FBDrawRect( 11*32+33, 385, 29, 45, RED ); killall=1; break; case RC_BLUE : // PAUSE - GO if ( action!=2 ) return; if ( pause == 1 ) FBCopyImage( 10*32+32, 384, 32, 48, svdimage[10] ); pause = pause ? 0 : 1; if ( pause ) { FBGetImage( 10*32+32, 384, 32, 48, svdimage[10] ); FBDrawRect( 10*32+32, 384, 31, 47, BLUE ); FBDrawRect( 10*32+33, 385, 29, 45, BLUE ); } break; case RC_1 : case RC_2 : case RC_3 : case RC_4 : case RC_5 : case RC_6 : case RC_7 : case RC_8 : // select lemm-action if ( pause || !action || (action>2)) break; nac=actcode-1; if ( afunc == actcode-1 ) break; if ( !portfolio[ actcode-1 ] ) break; FBGetImage( (nac+2)*32+32, 384, 32, 48, svdimage[nac+2] ); // save if ( afunc != -1 ) { FBCopyImage( (afunc+2)*32+32, 384, 32, 48, svdimage[afunc+2] ); DrawNumber( 106+afunc*32, 389, portfolio[afunc] ); } FBDrawRect( (nac+2)*32+32, 384, 31, 47, YELLOW ); FBDrawRect( (nac+2)*32+33, 385, 29, 45, YELLOW ); afunc=nac; break; case RC_PLUS : if ( pause || (action!=2) ) break; newspeed--; if ( newspeed < 1 ) newspeed=1; else { DrawNumber( 74, 389, 100-newspeed ); } break; case RC_MINUS : if ( pause || (action!=2) ) break; newspeed++; if ( newspeed > minspeed ) newspeed=minspeed; else { DrawNumber( 74, 389, 100-newspeed ); } break; case RC_OK : if( !action ) { action=1; s=deko[1]; // tor; s->anilocked=0; SoundPlay( SND_DOOR ); break; } if (( action != 2 ) || pause || ( sel_sprite == -1 ) || !portfolio[afunc]) break; s=lemm[ sel_sprite ]; if ( !s ) break; if ( afunc == 2 ) // EXPLODE { if ( !( s->type & TYP_EXPLODE ) ) { s->type |= TYP_EXPLODE; s->counter1=0; portfolio[ afunc ]--; DrawNumber( 106+afunc*32, 389, portfolio[afunc] ); } } else if ( afunc == 0 ) // CLIMB { if ( !( s->type & TYP_CLIMB ) ) { s->type |= TYP_CLIMB; portfolio[ afunc ]--; DrawNumber( 106+afunc*32, 389, portfolio[afunc] ); } } else { switch( afunc ) { case 3 : sel_type = TYP_STOPPER; break; case 4 : sel_type = TYP_BUILDER; break; case 6 : sel_type = TYP_DIGDIAG; break; case 7 : sel_type = TYP_DIGDOWN; break; } otype=s->type & TYP_WORK; while( 1 ) { if ( otype == sel_type ) { if (( otype == TYP_BUILDER ) && ( s->counter2 > 11 )) break; sel_type = 0; break; } if ( !( otype & TYP_STOPPER ) && !( s->type & TYP_FALLEN )) break; sel_type = 0; break; } if ( sel_type ) { otype = s->type; s->type = sel_type; portfolio[ afunc ]--; DrawNumber( 106+afunc*32, 389, portfolio[afunc] ); // erstmal die sprite-koordinaten wieder auf 0 if (( otype & TYP_BUILDER ) && ( s->counter2 < 12 )) { s->y+=3; } else if (( otype & TYP_BUILDER ) && ( s->counter2 == 12 )) { s->y-=2; } else if ( otype & TYP_DIGDIAG ) { s->y+=5; if ( !s->dir ) s->x+=7; } else if ( otype & TYP_DIGDOWN ) { s->y+=2; } // sprite-koordinaten eventl. verschieben if ( sel_type == TYP_DIGDOWN ) { s->y-=2; SpriteChangePic( s, 5 ); // lemming3 } if ( sel_type == TYP_STOPPER ) { s->counter1=0; SpriteChangePic( s, 4 ); // lemming2 bgRect( s->x+(s->width/2), s->y, 1, s->height-2, 150 ); } if ( sel_type == TYP_BUILDER ) { s->counter1=0; s->counter2=0; s->y -= 3; // 2 SpriteChangePic( s, 31 ); // builder if ( s->dir ) { s->x++; MirrorSprite( s ); } else s->x--; } if ( sel_type == TYP_DIGDIAG ) { s->counter1=0; s->counter2=0; s->y -= 5; SpriteChangePic( s, 33 ); // hacke if ( s->dir ) { MirrorSprite( s ); } else s->x-=7; } } } break; } }
void RunLemm( void ) { static int counter1=0; static int blinkc=0; int i; int f; int b; Sprite *s; int cursor_get=0; int kab=0; int hbk=0; // hat boden kontakt //int hhy=0; blinkc++; if ( action==3 ) { counter1=0; action=4; DrawSprite( deko[0] ); return; } if ( action==4 ) { counter1++; if ( counter1 < 24 ) return; if ( to_rescue > lem_in ) { FBDrawString( 252, 142, 64, "You lost !", WHITE, 0 ); FBDrawString( 250, 140, 64, "You lost !", RED, 0 ); } else { level++; if ( level>LASTLEVEL ) { FBDrawString( 252, 142, 64, "all level solved", WHITE, 0 ); FBDrawString( 250, 140, 64, "all level solved", GREEN, 0 ); FBDrawString( 240, 250, 36, "thanx to emuman for his javacode,", WHITE, 0 ); FBDrawString( 240, 286, 36, "Psygnosis and DMA for artwork...", WHITE, 0 ); level=1; doexit=2; return; } else { FBDrawString( 252, 142, 64, "Level solved", WHITE, 0 ); FBDrawString( 250, 140, 64, "Level solved", GREEN, 0 ); } } if ( afunc != -1 ) FBCopyImage( (afunc+2)*32+32, 384, 32, 48, svdimage[afunc+2] ); action=5; doexit=1; } if ( action != 2 ) { DrawSprite( deko[0] ); return; } if ( pause ) { UndrawSprite( deko[0] ); for( i=0; i<lem_run; i++ ) { if ( !lemm[i] ) continue; UndrawSprite( lemm[i] ); } DrawSprite( deko[1] ); // ziel DrawSprite( deko[2] ); // ziel for( i=0; i<lem_run; i++ ) { if ( !lemm[i] ) continue; s=lemm[i]; if (( s->type & TYP_EXPLODE ) && ( s->countdown > 0 )) { DrawSimpleNumber( s->x-main_x, s->y-6, s->countdown, 1 ); } SpriteGetBackground( s ); DrawSprite( s ); } SpriteSelPic( deko[0], 0 ); SpriteGetBackground( deko[0] ); DrawSprite( deko[0] ); if ( blinkc%5 ) return; if ( pause == 1 ) { FBCopyImage( 10*32+32, 384, 32, 48, svdimage[10] ); pause=2; } else { FBDrawRect( 10*32+32, 384, 31, 47, BLUE ); FBDrawRect( 10*32+33, 385, 29, 45, BLUE ); pause=1; } return; } sel_sprite=-1; if (( lem_run < lem_cnt ) && !( counter1%((newspeed/2)+3) ) && !killall ) { lemm[ lem_run ] = CreateSprite(3,0,deko[1]->x+19,deko[1]->y); lemm[ lem_run ]->dir=0; // rechts lemm[ lem_run ]->type = TYP_WALKER; in_level++; lem_run++; DrawInfo(1); } if ( in_level ) UndrawSprite( deko[0] ); for( i=0; i<lem_run; i++ ) { if ( !lemm[i] ) continue; s=lemm[i]; if ( s->type & TYP_EXPLODE ) restorecd( i ); else if (( s->type & TYP_FALLEN ) && s->partikel ) restorecd( i ); UndrawSprite( s ); s->counter1++; if ( !( s->counter1 % 10 ) && ( s->type & TYP_EXPLODE ) ) { s->countdown--; if ( s->countdown == -1 ) { s->counter1=0; bg2CopyImage( s->x-7, s->y-4, 21, 21, pbomb ); CopyBg2Screen( s->x-7,s->y-4, 21, 21); } } if (( s->counter1 == 2 ) && ( s->type & TYP_STOPPER ) && !( s->type & TYP_EXPLODE )) bgRect( s->x+1, s->y, s->width-1, s->height-2, 150 ); } // DrawSprite( deko[2] ); // ziel UnanimatedDeko(); for( i=0; i<lem_run; i++ ) { if ( !lemm[i] ) continue; s=lemm[i]; if ( killall && !kab ) { if ( !(s->type & TYP_EXPLODE ) ) { s->type |= TYP_EXPLODE; s->counter1=1; kab++; } } if ( (s->countdown==-1) && ( s->type & TYP_EXPLODE ) ) { s->partikel=1; partikel(i,1); } if ( !( s->counter1 % 10 ) && ( s->type & TYP_EXPLODE ) ) { if ( s->countdown == -1 ) { s->y-=4; s->x-=4; SpriteChangePic( s, 8 ); // explosion SpriteGetBackground( s ); DrawSprite(s); SoundPlay( SND_EXPLODE ); } if ( s->countdown == -2 ) { partikel(i,0); killlem( i ); s=0; DrawInfo(1); } } if ( s && ( s->countdown < 0 )) s=0; if ( s && ( s->type & TYP_FALLEN ) ) { if ( s->counter1 < 10 ) { s->partikel=1; partikel(i,1); } else { killlem( i ); DrawInfo(1); } s=0; } if ( s&&(s->countdown>0) ) { SpriteNextPic( s ); if ( s->type&TYP_ATHOME ) { s->y-=1; if(s->ani==4) { lem_in++; killlem(i); SoundPlay( SND_OING ); DrawInfo(3); } } else { /* lemming im ziel ? */ if((s->x==haus_x)&&(s->y>haus_y1)&& (s->y<haus_y2)) { s->type=TYP_ATHOME; s->counter2=0; SpriteChangePic( s, 6 ); // lemming4 } else { /* kein bodenkontakt ? */ switch( s->type & TYP_WORK ) { case TYP_WALKER : case TYP_DIGDOWN : hbk=isBrick(s->x+1,s->y+s->height,0)|| isBrick(s->x-2+s->width,s->y+s->height,0); break; case TYP_STOPPER : hbk=isBrick(s->x+1,s->y+s->height+1,0)|| isBrick(s->x-2+s->width,s->y+s->height+1,0); break; case TYP_DIGDIAG : hbk=isBrick(s->x+10,s->y+s->height-2,0)|| isBrick(s->x+11,s->y+s->height-2,0); break; case TYP_BUILDER : hbk=1; break; } if ( !hbk ) { #if 0 if ( s->type & TYP_DIGDIAG ) { hhy=s->y+s->height-2; printf("kein boden on %d, %d\n",s->x,s->y+s->height); } #endif if( !( s->type&TYP_WALKER ) ) { switch( s->type & TYP_WORK ) { case TYP_STOPPER : bgRect(s->x+1,s->y,s->width-1,s->height-2,14); break; case TYP_DIGDIAG : s->y+=5; if ( !s->dir ) s->x+=7; break; case TYP_DIGDOWN : s->y+=2; break; } s->type=TYP_WALKER|(s->type&TYP_UTILS); SpriteChangePic( s, 3 ); // lemming1-faller if ( s->dir ) MirrorSprite( s ); } // freier fall s->y += 2; s->counter2++; // aus bild gefallen if(s->y>=160) { SoundPlay( SND_DIE ); killlem(i); DrawInfo(1); } } else { if(s->type&TYP_WALKER) { /* aufgeschlagen */ if(s->counter2>=40) { s->counter1=0; s->type=TYP_FALLEN; SoundPlay( SND_DIE ); s->partikel=1; partikel(i,1); s=0; } else { /* wieder auf boden */ s->counter2=0; /* laeufer - getestet wird oben */ if((isBrick(s->x,s->y+1,1)&& (s->dir==1))|| (isBrick(s->x+s->width,s->y+1,1)&& (s->dir==0))) { MirrorSprite( s ); s->dir^=1; } else { s->x += (s->dir?-1:1); if ( s->dir ) { for(b=8;b>0;b--) { if(isBrick(s->x, s->y+s->height-b,0)) { s->y-=1; b=0; } } } else { for(b=8;b>0;b--) { if(isBrick(s->x+s->width, s->y+s->height-b,0)) { s->y-=1; b=0; } } } } } /* else, kein matsch */ } /** walker **/ else if(s&&(s->type&TYP_BUILDER)) { unsigned char c=118; // stair if ( !s->ani ) { s->counter2++; s->y--; if ( s->counter2 != 13 ) { if ( s->dir ) { s->x-=2; bghLine(s->x+2,s->y+s->height,6,&c,1); CopyBg2Screen( s->x+2,s->y+s->height,6,1); if ( isBrick(s->x+1,s->y+2,1) ) { s->y+=2; s->dir=0; s->counter2=13; } } else { s->x+=2; bghLine(s->x+1,s->y+s->height,6,&c,1); CopyBg2Screen( s->x+1,s->y+s->height,6,1); if ( isBrick(s->x+s->width,s->y+2,1) ) { s->y+=2; s->dir=1; s->counter2=13; } } } if ( s->counter2 == 12 ) { s->y+=2; SpriteChangePic( s, 32 );//keinesteine if ( s->dir ) MirrorSprite( s ); } if ( s->counter2 == 13 ) { s->type&=TYP_UTILS; s->type|=TYP_WALKER; SpriteChangePic( s, 3 );// lemming1 if ( s->dir ) MirrorSprite( s ); } } } else if(s&&(s->type&TYP_DIGDOWN)) { if(!(s->counter1%8)) { if(s->y<160) { bgRect( s->x+1, s->y+4, 10, 8-max(0,s->y-152), STEELBLUE ); s->y+=1; cursor_get=1; } } } /* digger */ else if(s&&(s->type&TYP_DIGDIAG)) { if ( s->ani == 8 ) { if ( s->dir ) { unsigned char *data = GetMirrorPic(34); bg2CopyImage(s->x+1,s->y+2,6,14,data); } else { inBg(34,0,s->x+11,s->y+2); } } if ( !s->ani ) { s->y+=1; if ( s->dir ) s->x-=2; else s->x+=2; } } } /* freier fall */ } /* nicht am ziel */ } /* countdown */ if ( s&&(level==5) ) { /* ab ins feuer ? */ for( f=5; f<11; f++ ) { if ( SpriteCollide( deko[f], s->x+s->width, s->y ) ) { SoundPlay( SND_DIE ); killlem(i); s=0; break; } } } } /* typ-fallen */ if ( !lemm[i] || !s ) continue; if (( s->type & TYP_EXPLODE ) && ( s->countdown > 0 )) { DrawSimpleNumber( s->x-main_x, s->y-6, s->countdown, 1 ); } SpriteGetBackground( s ); DrawSprite( s ); if ( SpriteCollide( s, deko[0]->x+7, deko[0]->y+7 ) ) { sel_sprite=i; } } if ( cursor_get ) SpriteGetBackground( deko[0] ); if ( sel_sprite != -1 ) { SpriteSelPic( deko[0], 1 ); } else { SpriteSelPic( deko[0], 0 ); } DrawSprite( deko[0] ); #if 0 if ( hhy ) FBDrawLine(32,hhy+hhy+32,656,hhy+hhy+32,RED); #endif counter1++; }
// Create a background bitmap simulating partial transparency void CSimplePanelBase::MakeBGBitMap() { wxRect r; wxBitmap rawBmp; wxBitmap whiteBmp; wxImage bgImage; wxImage whiteImage; register unsigned char *bgImagePixels; register unsigned char *whitePixels; register int i, j, k; CSimpleGUIPanel* backgroundPanel = (CSimpleGUIPanel*)GetParent(); wxPen bgPen(*wxWHITE, 1, wxTRANSPARENT); wxBrush bgBrush(*wxWHITE); CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple(); wxASSERT(pSkinSimple); wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple)); int white_weight = pSkinSimple->GetPanelOpacity(); int image_weight = MAX_OPACITY - white_weight; // Workaround for CSimpleGUIPanel not reliably getting // Paint or EraseBackground events under Linux #if (!(defined(__WXMSW_) || defined(__WXMAC__))) backgroundPanel->SetBackgroundBitmap(); #endif GetPosition(&r.x, &r.y); GetSize(&r.width, &r.height); wxBitmap *bgBmp(backgroundPanel->GetBackgroundBitMap()); wxRect bgRect(0, 0, bgBmp->GetWidth(), bgBmp->GetHeight()); if (bgRect.Contains(r)) { rawBmp = bgBmp->GetSubBitmap(r); } else { fprintf(stderr, "SimpleGUI background image is too small\n"); rawBmp = wxBitmap(r.width, r.height); wxMemoryDC dc(rawBmp); wxPen rawPen(*wxBLACK, 1, wxTRANSPARENT); wxBrush rawBrush(*wxBLACK); dc.SetBackgroundMode(wxSOLID); dc.SetPen(rawPen); dc.SetBrush(rawBrush); dc.DrawRectangle(0, 0, r.width, r.height); } whiteBmp = wxBitmap(r.width, r.height); wxMemoryDC dc(whiteBmp); dc.SetBackgroundMode(wxSOLID); dc.SetPen(bgPen); dc.SetBrush(bgBrush); dc.DrawRoundedRectangle(0, 0, r.width, r.height, RECTANGLERADIUS); bgImage = rawBmp.ConvertToImage(); bgImagePixels = bgImage.GetData(); // RGBRGBRGB... whiteImage = whiteBmp.ConvertToImage(); whitePixels = whiteImage.GetData(); // RGBRGBRGB... for (i=0; i<r.width; ++i) { for (j=0; j<r.height; ++j) { if (*whitePixels) { k = (((unsigned int)*bgImagePixels * image_weight) + ((unsigned int)*whitePixels++ * white_weight)); *bgImagePixels++ = k / MAX_OPACITY; k = (((unsigned int)*bgImagePixels * image_weight) + ((unsigned int)*whitePixels++ * white_weight)); *bgImagePixels++ = k / MAX_OPACITY; k = (((unsigned int)*bgImagePixels * image_weight) + ((unsigned int)*whitePixels++ * white_weight)); *bgImagePixels++ = k / MAX_OPACITY; } else { bgImagePixels += 3; whitePixels += 3; } } } m_TaskPanelBGBitMap = wxBitmap(bgImage); m_GotBGBitMap = true; }