00001 /* Yo Emacs, this is -*- C++ -*- */ 00002 /* 00003 * ksame 0.4 - simple Game 00004 * Copyright (C) 1997,1998 Marcus Kreutzberger 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 * 00020 */ 00021 00022 #ifndef _STONEWIDGET 00023 #define _STONEWIDGET 00024 00025 #include <qpixmap.h> 00026 #include <qwidget.h> 00027 00028 #include <qpe/config.h> 00029 00030 #include "StoneField.h" 00031 00032 struct StoneSlice; 00033 00034 class StoneWidget : public QWidget { 00035 Q_OBJECT 00036 00037 int modified; 00038 // int marked; // # of marked stones 00039 00040 int stones_x, stones_y; 00041 int sizex, sizey; 00042 int field_width, field_height; 00043 00044 QList<QPoint> history; 00045 StoneField stonefield; 00046 00047 // picture number of stonemovie 00048 int slice; 00049 00050 StoneSlice **map; 00051 00052 public: 00053 StoneWidget( QWidget *parent=0, int x=10,int y=10); 00054 ~StoneWidget(); 00055 00056 unsigned int board(); 00057 int score(); 00058 int marked(); 00059 QSize size(); 00060 int colors(); 00061 virtual QSize sizeHint() const; 00062 00063 bool undoPossible() const; 00064 00065 void newGame(unsigned int board, int colors); 00066 void reset(); 00067 void unmark(); 00068 int undo(int count=1); 00069 00070 // test for game end 00071 bool isGameover(); 00072 // if isGameover(): finished with bonus? 00073 bool hasBonus(); 00074 void clearBonus(); 00075 // test for unchanged start position 00076 bool isOriginalBoard(); 00077 00078 virtual void readProperties(Config *conf); 00079 virtual void saveProperties(Config *conf); 00080 00081 protected: 00082 00083 void timerEvent( QTimerEvent *e ); 00084 void paintEvent( QPaintEvent *e ); 00085 void mousePressEvent ( QMouseEvent *e); 00086 void myMoveEvent ( QMouseEvent *e); 00087 00088 // properties of the stone picture 00089 int stone_width,stone_height; // size of one stone 00090 int maxcolors; // number of different stones (Y direction) 00091 int maxslices; // number of pictures per movie (X direction) 00092 00093 signals: 00094 // A new game begins 00095 void s_newgame(); 00096 00097 void s_colors(int colors); 00098 void s_board(int board); 00099 void s_score(int score); 00100 void s_marked(int m); 00101 00102 void s_gameover(); 00103 00104 // The stone (x,y) was clicked(removed), 00105 // all neighbor stones disappear without further signals 00106 void s_remove(int x,int y); 00107 00108 void s_sizechanged(); 00109 }; 00110 00111 #endif 00112 00113 00114 00115 00116
1.4.2