Permalink
Browse files

Убрал выбор уровня сложности(опять), переделал экран статистики

  • Loading branch information...
1 parent e0ba643 commit b9d7d9460631c0966033bde111c11f986644d778 @WeirdCarrotMonster committed Nov 16, 2011
Showing with 48 additions and 61 deletions.
  1. +43 −34 scorescreen.cpp
  2. +3 −4 scorescreen.h
  3. +2 −23 window.cpp
View
@@ -1,42 +1,18 @@
-#include <QVBoxLayout>
-#include <QHBoxLayout>
+#include <QPainter>
#include "scorescreen.h"
scoreScreen::scoreScreen(QWidget *parent) :
QWidget(parent)
{
- QVBoxLayout *layout = new QVBoxLayout;
- QHBoxLayout *layout2 = new QHBoxLayout;
- QHBoxLayout *layout3 = new QHBoxLayout;
- QHBoxLayout *layout4 = new QHBoxLayout;
- QLabel *s = new QLabel(trUtf8("Score:"));
- QLabel *m = new QLabel(trUtf8("Multiplier:"));
- QLabel *t = new QLabel(trUtf8("Multiplier time left:"));
this->setFixedSize(200, 600);
- scoreLabel = new QLabel("0");
- multiplyLabel = new QLabel("1");
- multiplyTimeLabel = new QLabel("0");
score = 0;
multiply = 1;
multiplyTime = 0;
- list = new QListWidget();
- layout2->addWidget(s);
- layout2->addWidget(scoreLabel);
- layout3->addWidget(m);
- layout3->addWidget(multiplyLabel);
- layout4->addWidget(t);
- layout4->addWidget(multiplyTimeLabel);
- layout->addLayout(layout2);
- layout->addLayout(layout3);
- layout->addLayout(layout4);
- layout->addWidget(list);
- this->setLayout(layout);
}
void scoreScreen::increaseScore(int s)
{
score += s*multiply;
- scoreLabel->setText(QString::number(score));
}
void scoreScreen::addAchievement(QString s)
@@ -95,34 +71,26 @@ void scoreScreen::clear()
score = 0;
multiply = 1;
multiplyTime = 0;
- scoreLabel->setText(QString::number(0));
- multiplyLabel->setText(QString::number(1));
- multiplyTimeLabel->setText(QString::number(multiplyTime/10));
bonusList.clear();
- list->clear();
}
void scoreScreen::addMultiplier()
{
multiplyTime = 10000;
multiply++;
- multiplyLabel->setText(QString::number(multiply));
}
void scoreScreen::pass(int elapsed)
{
- list->clear();
if (multiplyTime > 0)
{
multiplyTime -= elapsed;
if (multiplyTime <= 0)
{
multiply = 1;
- multiplyLabel->setText(QString::number(1));
multiplyTime = 0;
}
}
- multiplyTimeLabel->setText(QString::number(multiplyTime/100));
if (!bonusList.empty())
{
@@ -142,7 +110,6 @@ void scoreScreen::pass(int elapsed)
s += a.name;
s += " ";
s += QString::number(a.bonusTime/100);
- list->addItem(s);
bonusList.insert(i, a);
i++;
}
@@ -160,3 +127,45 @@ int scoreScreen::currentScore()
{
return score;
}
+
+void scoreScreen::paintEvent(QPaintEvent *event)
+{
+ QPainter painter;
+ painter.begin(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ //Вот тут начинаем все рисовать
+ painter.setBrush(QBrush(QColor(125, 125, 125)));
+ painter.drawRect(0,0,200,600);
+ //Отрисовка экрана очков и множителя
+ painter.setBrush(QBrush(QColor(0, 100, 0)));
+ painter.drawRect(10,10,180,50);
+ painter.setPen(QColor(255, 255, 255));
+ painter.drawText(QRect(15, 15, 50, 20), QString("Score:"));
+ painter.drawText(QRect(60, 15, 120, 20), QString::number(score));
+ painter.drawText(QRect(15, 30, 60, 40), QString("Multiplier:"));
+ painter.setPen(QColor(255, 255, 255));
+ painter.drawText(QRect(80, 30, 120, 40), QString::number(multiply));
+ painter.setBrush(QBrush(QColor(0, 0, 100)));
+ painter.setPen(Qt::NoPen);
+ if (multiplyTime > 0)
+ painter.drawRect(15,45,170*multiplyTime/10000,10);
+
+ int startx, starty;
+ startx = 10;
+ starty = 70;
+
+ foreach (const bonus2 &value, bonusList)
+ {
+ //TODO:заменить на отрисовку изображения с прогрессбаром
+ painter.setBrush(QBrush(QColor(0, 100, 0)));
+ painter.setPen(QColor(255, 255, 255));
+ painter.drawRect(startx,starty,180,50);
+ painter.drawText(QRect(startx + 5, starty +5, 170, 30), value.name);
+ painter.setBrush(QBrush(QColor(0, 0, 100)));
+ painter.setPen(Qt::NoPen);
+ painter.drawRect(startx + 5,starty + 35,170*value.bonusTime/10000,10);
+ starty += 60;
+ }
+
+ painter.end();
+}
View
@@ -27,12 +27,11 @@ class scoreScreen : public QWidget
int currentMultiplier();
int currentScore();
+protected:
+ void paintEvent(QPaintEvent *event);
+
private:
- QLabel *scoreLabel;
- QLabel *multiplyLabel;
- QLabel *multiplyTimeLabel;
QList<bonus2> bonusList;
- QListWidget *list;
int score, multiply;
int multiplyTime;
};
View
@@ -4,8 +4,6 @@
#include "QCursor"
#include <QDebug>
#include <QMouseEvent>
-#include <QInputDialog>
-#include <QStringList>
Window::Window()
: QWidget()
@@ -24,28 +22,9 @@ Window::Window()
this->setMouseTracking(true);
QTimer *timer = new QTimer(this);
this->setFixedSize(820, 620);
-
- QStringList level;
- level << "easy" << "normal" << "hard" << "IMPOSSIBRU";
-
- QString title("Select level");
- QString query("levels:");
- QString pick = QInputDialog::getItem(0, title, query, level);
-
- int delay;
- if (pick == "easy")
- delay = 30;
- else if (pick == "normal")
- delay = 25;
- else if (pick == "hard")
- delay = 20;
- else if (pick == "IMPOSSIBRU")
- delay = 0;
- else
- delay = 25;
-
connect(timer, SIGNAL(timeout()), native, SLOT(repaint()));
- timer->start(delay);
+ connect(timer, SIGNAL(timeout()), screen, SLOT(repaint()));
+ timer->start(25);
}
void Window::mouseMoveEvent(QMouseEvent *event)

0 comments on commit b9d7d94

Please sign in to comment.