QTfrontend/bgwidget.h
author unc0rr
Sun, 04 Sep 2011 20:51:54 +0400
changeset 5768 852ba8f5685c
parent 4976 088d40d8aba2
permissions -rw-r--r--
Only prepend hedgewars.org if the url is relative
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2012
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
     1
/*
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
     3
 * Copyright (c) 2009 Kristian Lehmann <email@thexception.net>
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 2948
diff changeset
     4
 * Copyright (c) 2009-2011 Andrey Korotaev <unC0Rr@gmail.com>
2012
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
     5
 *
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
     7
 * it under the terms of the GNU General Public License as published by
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
     8
 * the Free Software Foundation; version 2 of the License
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
     9
 *
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    13
 * GNU General Public License for more details.
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    14
 *
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    16
 * along with this program; if not, write to the Free Software
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    18
 */
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    19
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    20
#ifndef BGWIDGET_H
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    21
#define BGWIDGET_H
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    22
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    23
#include <QWidget>
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    24
//#include <QGLWidget>
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    25
#include <QPainter>
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    26
#include <QTimer>
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    27
#include <QPaintEvent>
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    28
#include <QTime>
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    29
#include <QPoint>
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    30
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    31
#define SPRITE_MAX 12
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    32
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    33
#define ANIMATION_INTERVAL 40
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    34
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    35
class SpritePosition
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    36
{
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    37
public:
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    38
    SpritePosition(QWidget * parent, int sh);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    39
    ~SpritePosition();
2012
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    40
private:
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    41
    float fX;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    42
    float fY;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    43
    float fXMov;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    44
    float fYMov;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    45
    int iAngle;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    46
    QWidget * wParent;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    47
    int iSpriteHeight;
2012
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    48
public:
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    49
    void move();
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    50
    void reset();
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    51
    QPoint pos();
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    52
    int getAngle();
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    53
    void init();
2012
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    54
};
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    55
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    56
class BGWidget : public QWidget
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    57
{
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    58
    Q_OBJECT
2012
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    59
public:
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    60
    BGWidget(QWidget * parent);
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    61
    ~BGWidget();
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    62
    void startAnimation();
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    63
    void stopAnimation();
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    64
    void init();
2012
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    65
private:
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    66
    QImage sprite;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    67
    QTimer * timerAnimation;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    68
    SpritePosition * spritePositions[SPRITE_MAX];
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    69
    QImage * rotatedSprites[360];
2012
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    70
protected:
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    71
    void paintEvent(QPaintEvent * event);
2012
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    72
private slots:
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2377
diff changeset
    73
    void animate();
2012
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    74
};
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    75
76fff564246b TheXception's patch:
unc0rr
parents:
diff changeset
    76
#endif // BGWIDGET_H