summaryrefslogtreecommitdiff
path: root/noncore/games/zsame/StoneWidget.h
blob: 89a8afc605691f87136dbfe4ea7f504b3acba3a7 (plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* Yo Emacs, this is -*- C++ -*- */
/*
 *   ksame 0.4 - simple Game
 *   Copyright (C) 1997,1998  Marcus Kreutzberger
 *
 *   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 2 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, write to the Free Software
 *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */

#ifndef _STONEWIDGET
#define _STONEWIDGET

#include <qpixmap.h>
#include <qwidget.h>

#include <qpe/config.h>

#include "StoneField.h"

struct StoneSlice;

class StoneWidget : public QWidget {
    Q_OBJECT

    int modified;
    //     int marked;            // # of marked stones

    int stones_x, stones_y;
    int sizex, sizey;
    int field_width, field_height;

    QList<QPoint> history;
    StoneField stonefield;

    // picture number of stonemovie
    int slice;

    StoneSlice **map;

public:
    StoneWidget( QWidget *parent=0, int x=10,int y=10);
    ~StoneWidget();

    unsigned int board();
    int score();
	int marked();
    QSize size();
    int colors();
    virtual QSize sizeHint() const;

    bool undoPossible() const;

    void newGame(unsigned int board, int colors);
    void reset();
    void unmark();
    int undo(int count=1);

    // test for game end
    bool isGameover();
	// if isGameover(): finished with bonus?
	bool hasBonus();
    void clearBonus();
	// test for unchanged start position
	bool isOriginalBoard();

    virtual void readProperties(Config *conf);
    virtual void saveProperties(Config *conf);

protected:

    void timerEvent( QTimerEvent *e );
    void paintEvent( QPaintEvent *e );
    void mousePressEvent ( QMouseEvent *e);
    void myMoveEvent ( QMouseEvent *e);

    // properties of the stone picture
    int stone_width,stone_height; // size of one stone
    int maxcolors;         // number of different stones (Y direction)
    int maxslices;         // number of pictures per movie (X direction)

signals:
    // A new game begins
    void s_newgame();

    void s_colors(int colors);
    void s_board(int board);
    void s_score(int score);
    void s_marked(int m);

    void s_gameover();

    // The stone (x,y) was clicked(removed),
    // all neighbor stones disappear without further signals
    void s_remove(int x,int y);

    void s_sizechanged();
};

#endif