CQPaletteChooser:: CQPaletteChooser(QWidget *parent) : QWidget(parent) { QHBoxLayout *layout = new QHBoxLayout(this); layout->setMargin(2); layout->setSpacing(2); edit_ = new QLineEdit (this); button_ = new QPushButton(this); button_->setIcon(CQPixmapCacheInst->getIcon("PALETTE_DIALOG")); //button_->setFixedSize(QSize(24,24)); layout->addWidget(edit_ ); layout->addWidget(button_); edit_ ->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); button_->setSizePolicy(QSizePolicy::Fixed , QSizePolicy::Fixed); connect(edit_ , SIGNAL(editingFinished()), this, SLOT(editPalette())); connect(button_, SIGNAL(clicked ()), this, SLOT(choosePalette())); }
void updateTurret(turret_struct* t) { if(!t || !t->used)return; if(!t->OBB || !t->OBB->used){t->OBB=NULL;t->used=false;return;} t->counter+=2;t->counter%=63; //TEMP if(t->dead)t->counter=31; editPalette((u16*)t->OBB->modelInstance.palette,0,RGB15(abs(31-t->counter),0,0)); //TEMP int32* m=t->OBB->transformationMatrix; room_struct* r=getPlayer()->currentRoom; if(!r)return; int32 angle, d; bool b=pointInTurretSight(t, getPlayer()->object->position, &angle, &d); if(b) { vect3D u=vectDifference(getPlayer()->object->position,t->laserOrigin); int32 d=magnitude(u); u=divideVect(u,d); if(collideLineMap(&gameRoom, NULL, t->laserOrigin, u, d, NULL, NULL))b=false; } switch(t->state) { case TURRET_CLOSED: changeAnimation(&t->OBB->modelInstance, 0, false); t->drawShot[0]=t->drawShot[1]=0; if(b && !t->dead){t->state=TURRET_OPENING; playSFX(turretDeploySFX);} break; case TURRET_OPENING: if(t->OBB->modelInstance.currentAnim==2) { t->state=TURRET_OPEN; }else if(t->OBB->modelInstance.currentAnim!=1) { changeAnimation(&t->OBB->modelInstance, 2, false); changeAnimation(&t->OBB->modelInstance, 1, true); } t->drawShot[0]=t->drawShot[1]=0; break; case TURRET_OPEN: { if(angle>mulf32(sinLerp(TURRET_SIGHTANGLE/3),d))changeAnimation(&t->OBB->modelInstance, 4, false); else if(angle<-mulf32(sinLerp(TURRET_SIGHTANGLE/3),d))changeAnimation(&t->OBB->modelInstance, 5, false); else changeAnimation(&t->OBB->modelInstance, 2, false); int i; for(i=0;i<2;i++) { if(!t->drawShot[i] && !(rand()%3)) { t->drawShot[i]=rand()%8; t->shotAngle[i]=rand(); shootPlayer(NULL, normalize(vectDifference(t->laserDestination,t->laserOrigin)), 6); playSFX(turretFireSFX); } if(t->drawShot[i])t->drawShot[i]--; } if(!b || t->dead){t->state=TURRET_CLOSING; playSFX(turretRetractSFX);} } break; case TURRET_CLOSING: if(t->OBB->modelInstance.currentAnim==0) { t->state=TURRET_CLOSED; }else if(t->OBB->modelInstance.currentAnim!=3) { changeAnimation(&t->OBB->modelInstance, 0, false); changeAnimation(&t->OBB->modelInstance, 3, true); } t->drawShot[0]=t->drawShot[1]=0; break; } if(!t->dead) { t->laserOrigin=addVect(vectDivInt(t->OBB->position,4),evalVectMatrix33(m,laserOrigin)); t->laserDestination=addVect(t->laserOrigin,vect(m[2],m[5],m[8])); if(b)t->laserDestination=getPlayer()->object->position; vect3D dir=normalize(vectDifference(t->laserDestination,t->laserOrigin)); t->laserThroughPortal=false; laserProgression(r, &t->laserOrigin, &t->laserDestination, dir); int32 x, y, z; vect3D v; portal_struct* portal=NULL; if(isPointInPortal(&portal1, t->laserDestination, &v, &x, &y, &z))portal=&portal1; if(abs(z)>=32)portal=NULL; if(!portal) { if(isPointInPortal(&portal2, t->laserDestination, &v, &x, &y, &z))portal=&portal2; if(abs(z)>=32)portal=NULL; } if(portal) { t->laserDestination=addVect(t->laserDestination,vectMult(dir,TILESIZE)); t->laserThroughPortal=true; dir=warpVector(portal,dir); t->laserOrigin2=addVect(portal->targetPortal->position, warpVector(portal, vectDifference(t->laserDestination, portal->position))); t->laserDestination2=addVect(t->laserOrigin2,dir); laserProgression(r, &t->laserOrigin2, &t->laserDestination2, dir); t->laserOrigin2=addVect(t->laserOrigin2,vectMult(dir,-TILESIZE)); } if(m[4]<sinLerp(8192/2))t->dead=true; } updateAnimation(&t->OBB->modelInstance); }