-
Notifications
You must be signed in to change notification settings - Fork 0
/
qtbeerwanterwidget.h
88 lines (63 loc) · 2.22 KB
/
qtbeerwanterwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//---------------------------------------------------------------------------
/*
BeerWanter. A simple game.
Copyright (C) 2005-2016 Richel Bilderbeek
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/GameBeerWanter.htm
//---------------------------------------------------------------------------
#ifndef QTBEERWANTERWIDGET_H
#define QTBEERWANTERWIDGET_H
#include <tuple>
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <QWidget>
#include "beerwantermaindialog.h"
struct QMouseEvent;
struct QPixmap;
struct QTimer;
namespace ribi {
struct BeerWanterMainDialog;
class QtBeerWanterWidget : public QWidget
{
Q_OBJECT //!OCLINT
public:
explicit QtBeerWanterWidget(QWidget *parent = 0);
const BeerWanterMainDialog * GetBeerWanter() const;
private:
std::tuple<int,int,int> m_background_rgb;
std::string m_debug_text;
boost::scoped_ptr<BeerWanterMainDialog> m_dialog;
boost::shared_ptr<QPixmap> m_sprite;
boost::shared_ptr<QTimer> m_timer;
private slots:
void mouseMoveEvent(QMouseEvent * event);
void mousePressEvent(QMouseEvent * event);
void onTimer();
void paintEvent(QPaintEvent *);
signals:
void DoShake(const int x, const int y);
void LevelUp(const std::string&);
};
//From http://www.richelbilderbeek.nl/CppPaint.htm
void MyPaint(
QPixmap& pixmap,
const unsigned char r,
const unsigned char g,
const unsigned char b,
const unsigned char a = 255
); //Opaque
///Modify the color value by [-1,1], keep it in [0, 255] range
int Modify(const int color) noexcept;
} //~namespace ribi
#endif // QTBEERWANTERWIDGET_H