00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <math.h>
00023
00024
00025 #include <QFont>
00026 #include <QColor>
00027 #include <QPixmap>
00028 #include <QPoint>
00029
00030
00031 #include <klocale.h>
00032 #include <kdebug.h>
00033
00034
00035 #include "displayintro.h"
00036 #include "introsprite.h"
00037
00038
00039
00040
00041 DisplayIntro::DisplayIntro(int advancePeriod, QGraphicsScene* scene, ThemeManager* theme, QObject* parent)
00042 : Themable("introdisplay",theme), QObject(parent)
00043 {
00044
00045 scene->setBackgroundBrush(QColor(0,0,128));
00046
00047
00048 mTheme = theme;
00049 mScene = scene;
00050 mAdvancePeriod = advancePeriod;
00051
00052
00053 mSprites.clear();
00054
00055
00056 for (int i=0; i<42; i++)
00057 {
00058 IntroSprite* sprite = new IntroSprite("intro_piece", mTheme, mAdvancePeriod, i, mScene);
00059 if (!sprite) kFatal() << "Cannot load sprite " << "intro_piece" << endl;
00060 mSprites.append(sprite);
00061 if ((i/2)%2==0) sprite->setFrame(0);
00062 else sprite->setFrame(1);
00063 sprite->setZValue(i);
00064 sprite->hide();
00065 }
00066
00067
00068
00069 mTimer = new QTimer(this);
00070 connect(mTimer, SIGNAL(timeout()), this, SLOT(advance()));
00071
00072
00073 theme->updateTheme(this);
00074 }
00075
00076
00077
00078 DisplayIntro::~DisplayIntro()
00079 {
00080 delete mTimer;
00081 while (!mSprites.isEmpty())
00082 {
00083 delete mSprites.takeFirst();
00084 }
00085 }
00086
00087
00088
00089 void DisplayIntro::changeTheme()
00090 {
00091
00092 }
00093
00094
00095
00096 void DisplayIntro::start()
00097 {
00098
00099 mIntroState = IntroMoveIn;
00100
00101
00102 mTimer->setSingleShot(true);
00103 mTimer->start(0);
00104 }
00105
00106
00107
00108
00109 void DisplayIntro::advance()
00110 {
00111
00112 double dura, delay, rad;
00113 QPointF start, end;
00114
00115
00116 if (mIntroState == IntroMoveIn)
00117 {
00118
00119 for (int i = 0; i < mSprites.size(); ++i)
00120 {
00121
00122 if (mSprites.at(i)->type() != QGraphicsItem::UserType+1) continue;
00123
00124 IntroSprite* sprite = (IntroSprite*)mSprites.at(i);
00125 int no = sprite->number();
00126 {
00127 if (no%2==0)
00128 {
00129 start = QPointF(1.05, 0.5);
00130 end = QPointF(0.35 + no/300.0, 105.0/800.0+no/125.0);
00131 dura = 3000.0;
00132 delay = 80.0*no;
00133 rad = 0.1;
00134 }
00135 else
00136 {
00137 start = QPointF(-0.05, 0.5);
00138 end = QPointF(0.65-(no-1)/300.0, 105.0/800.0+(no-1)/125.0);
00139 dura = 3000.0;
00140 delay = 80.0*(no-1);
00141 rad = 0.1;
00142 }
00143 sprite->setZValue(no);
00144 sprite->startIntro(start, end, rad, dura, delay);
00145 }
00146 }
00147
00148
00149 mIntroState = IntroCollapse;
00150 mTimer->start(9000);
00151 return;
00152 }
00153
00154
00155 if (mIntroState == IntroCollapse)
00156 {
00157
00158 for (int i = 0; i < mSprites.size(); ++i)
00159 {
00160
00161 if (mSprites.at(i)->type() != QGraphicsItem::UserType+1) continue;
00162
00163 IntroSprite* sprite = (IntroSprite*)mSprites.at(i);
00164 sprite->startLinear(QPointF(0.5, 0.3), 200);
00165 }
00166
00167
00168 mIntroState = IntroExplode;
00169 mTimer->start(500);
00170 return;
00171 }
00172
00173
00174 if (mIntroState == IntroExplode)
00175 {
00176
00177 for (int i = 0; i < mSprites.size(); ++i)
00178 {
00179
00180 if (mSprites.at(i)->type() != QGraphicsItem::UserType+1) continue;
00181
00182 IntroSprite* sprite = (IntroSprite*)mSprites.at(i);
00183 int no = sprite->number();
00184 double x = 0.5 + 1.50*cos(no/42.0*2.0*M_PI);
00185 double y = 0.3 + 1.50*sin(no/42.0*2.0*M_PI);
00186 sprite->startLinear(QPointF(x,y), 800);
00187 }
00188
00189
00190 mIntroState = IntroMoveIn;
00191 mTimer->start(1900);
00192 return;
00193 }
00194 }
00195
00196
00197 #include "displayintro.moc"