summaryrefslogtreecommitdiffstats
path: root/ksmiletris
diff options
context:
space:
mode:
Diffstat (limited to 'ksmiletris')
-rw-r--r--ksmiletris/COPYRIGHT22
-rw-r--r--ksmiletris/Makefile.am21
-rw-r--r--ksmiletris/README1
-rw-r--r--ksmiletris/data/Makefile.am16
-rw-r--r--ksmiletris/data/bg1.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/bg10.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/bg11.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/bg12.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/bg13.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/bg14.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/bg15.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/bg16.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/bg2.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/bg3.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/bg4.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/bg5.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/bg6.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/bg7.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/bg8.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/bg9.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-a1.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-a2.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-a3.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-a4.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-a5.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-a6.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-a7.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-a8.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-b1.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-b2.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-b3.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-b4.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-b5.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-b6.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-b7.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-b8.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-c1.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-c2.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-c3.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-c4.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-c5.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-c6.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-c7.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/block-c8.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/broken-mask.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/broken.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/cleared-a.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/cleared-b.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/cleared-c.bmpbin0 -> 3126 bytes
-rw-r--r--ksmiletris/data/pause.bmpbin0 -> 41094 bytes
-rw-r--r--ksmiletris/gamewidget.cpp518
-rw-r--r--ksmiletris/gamewidget.h112
-rw-r--r--ksmiletris/gamewindow.cpp204
-rw-r--r--ksmiletris/gamewindow.h63
-rw-r--r--ksmiletris/hi128-app-ksmiletris.pngbin0 -> 13287 bytes
-rw-r--r--ksmiletris/hi16-app-ksmiletris.pngbin0 -> 877 bytes
-rw-r--r--ksmiletris/hi22-app-ksmiletris.pngbin0 -> 1605 bytes
-rw-r--r--ksmiletris/hi32-app-ksmiletris.pngbin0 -> 2224 bytes
-rw-r--r--ksmiletris/hi48-app-ksmiletris.pngbin0 -> 4225 bytes
-rw-r--r--ksmiletris/hi64-app-ksmiletris.pngbin0 -> 6172 bytes
-rw-r--r--ksmiletris/ksmiletris.desktop78
-rw-r--r--ksmiletris/ksmiletris.h86
-rw-r--r--ksmiletris/ksmiletrisui.rc12
-rw-r--r--ksmiletris/main.cpp53
-rw-r--r--ksmiletris/mirrorwidget.cpp58
-rw-r--r--ksmiletris/mirrorwidget.h49
-rw-r--r--ksmiletris/npiecewidget.cpp63
-rw-r--r--ksmiletris/npiecewidget.h49
-rw-r--r--ksmiletris/screenwidget.cpp68
-rw-r--r--ksmiletris/screenwidget.h49
-rw-r--r--ksmiletris/wav/Makefile.am7
-rw-r--r--ksmiletris/wav/break.wavbin0 -> 12250 bytes
-rw-r--r--ksmiletris/wav/clear.wavbin0 -> 18450 bytes
73 files changed, 1529 insertions, 0 deletions
diff --git a/ksmiletris/COPYRIGHT b/ksmiletris/COPYRIGHT
new file mode 100644
index 00000000..783a77c3
--- /dev/null
+++ b/ksmiletris/COPYRIGHT
@@ -0,0 +1,22 @@
+/****************************************************************
+Copyright (c) 1998 Sandro Sigala <[email protected]>.
+All rights reserved.
+
+Permission to use, copy, modify, and distribute this software
+and its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of the author not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+The author disclaim all warranties with regard to this
+software, including all implied warranties of merchantability
+and fitness. In no event shall the author be liable for any
+special, indirect or consequential damages or any damages
+whatsoever resulting from loss of use, data or profits, whether
+in an action of contract, negligence or other tortious action,
+arising out of or in connection with the use or performance of
+this software.
+****************************************************************/
diff --git a/ksmiletris/Makefile.am b/ksmiletris/Makefile.am
new file mode 100644
index 00000000..2b0c0b3e
--- /dev/null
+++ b/ksmiletris/Makefile.am
@@ -0,0 +1,21 @@
+SUBDIRS= data wav
+
+INCLUDES = -I$(top_srcdir)/libkdegames -I$(top_srcdir)/libkdegames/highscore $(all_includes)
+METASOURCES = AUTO
+
+bin_PROGRAMS = ksmiletris
+ksmiletris_SOURCES = main.cpp gamewindow.cpp gamewidget.cpp \
+ screenwidget.cpp mirrorwidget.cpp npiecewidget.cpp
+ksmiletris_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+ksmiletris_LDADD = $(LIB_KDEGAMES)
+ksmiletris_DEPENDENCIES = $(LIB_KDEGAMES_DEP)
+
+xdg_apps_DATA = ksmiletris.desktop
+
+KDE_ICON = ksmiletris
+
+rcdir = $(kde_datadir)/ksmiletris
+rc_DATA = ksmiletrisui.rc
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/ksmiletris.pot
diff --git a/ksmiletris/README b/ksmiletris/README
new file mode 100644
index 00000000..7b4179b2
--- /dev/null
+++ b/ksmiletris/README
@@ -0,0 +1 @@
+See the HTML documentation in the doc/ subdirectory.
diff --git a/ksmiletris/data/Makefile.am b/ksmiletris/data/Makefile.am
new file mode 100644
index 00000000..b9b59670
--- /dev/null
+++ b/ksmiletris/data/Makefile.am
@@ -0,0 +1,16 @@
+AUTOMAKE_OPTIONS = foreign
+
+ksmiletrisdir = $(kde_datadir)/ksmiletris/data
+
+ksmiletris_DATA = bg1.bmp bg10.bmp bg11.bmp bg12.bmp bg13.bmp bg14.bmp \
+ bg15.bmp bg16.bmp bg2.bmp bg3.bmp bg4.bmp bg5.bmp bg6.bmp \
+ bg7.bmp bg8.bmp bg9.bmp block-a1.bmp block-a2.bmp \
+ block-a3.bmp block-a4.bmp block-a5.bmp block-a6.bmp \
+ block-a7.bmp block-a8.bmp block-b1.bmp block-b2.bmp \
+ block-b3.bmp block-b4.bmp block-b5.bmp block-b6.bmp \
+ block-b7.bmp block-b8.bmp block-c1.bmp block-c2.bmp \
+ block-c3.bmp block-c4.bmp block-c5.bmp block-c6.bmp \
+ block-c7.bmp block-c8.bmp broken-mask.bmp broken.bmp \
+ pause.bmp cleared-a.bmp cleared-b.bmp cleared-c.bmp
+
+EXTRA_DIST = $(ksmiletris_DATA)
diff --git a/ksmiletris/data/bg1.bmp b/ksmiletris/data/bg1.bmp
new file mode 100644
index 00000000..c1a92f86
--- /dev/null
+++ b/ksmiletris/data/bg1.bmp
Binary files differ
diff --git a/ksmiletris/data/bg10.bmp b/ksmiletris/data/bg10.bmp
new file mode 100644
index 00000000..70f900bf
--- /dev/null
+++ b/ksmiletris/data/bg10.bmp
Binary files differ
diff --git a/ksmiletris/data/bg11.bmp b/ksmiletris/data/bg11.bmp
new file mode 100644
index 00000000..927b4796
--- /dev/null
+++ b/ksmiletris/data/bg11.bmp
Binary files differ
diff --git a/ksmiletris/data/bg12.bmp b/ksmiletris/data/bg12.bmp
new file mode 100644
index 00000000..05e40ef6
--- /dev/null
+++ b/ksmiletris/data/bg12.bmp
Binary files differ
diff --git a/ksmiletris/data/bg13.bmp b/ksmiletris/data/bg13.bmp
new file mode 100644
index 00000000..d887e9ee
--- /dev/null
+++ b/ksmiletris/data/bg13.bmp
Binary files differ
diff --git a/ksmiletris/data/bg14.bmp b/ksmiletris/data/bg14.bmp
new file mode 100644
index 00000000..98c70026
--- /dev/null
+++ b/ksmiletris/data/bg14.bmp
Binary files differ
diff --git a/ksmiletris/data/bg15.bmp b/ksmiletris/data/bg15.bmp
new file mode 100644
index 00000000..8757b0a0
--- /dev/null
+++ b/ksmiletris/data/bg15.bmp
Binary files differ
diff --git a/ksmiletris/data/bg16.bmp b/ksmiletris/data/bg16.bmp
new file mode 100644
index 00000000..2eb18c21
--- /dev/null
+++ b/ksmiletris/data/bg16.bmp
Binary files differ
diff --git a/ksmiletris/data/bg2.bmp b/ksmiletris/data/bg2.bmp
new file mode 100644
index 00000000..823723d5
--- /dev/null
+++ b/ksmiletris/data/bg2.bmp
Binary files differ
diff --git a/ksmiletris/data/bg3.bmp b/ksmiletris/data/bg3.bmp
new file mode 100644
index 00000000..c2ee8de1
--- /dev/null
+++ b/ksmiletris/data/bg3.bmp
Binary files differ
diff --git a/ksmiletris/data/bg4.bmp b/ksmiletris/data/bg4.bmp
new file mode 100644
index 00000000..6f39972a
--- /dev/null
+++ b/ksmiletris/data/bg4.bmp
Binary files differ
diff --git a/ksmiletris/data/bg5.bmp b/ksmiletris/data/bg5.bmp
new file mode 100644
index 00000000..0e484b81
--- /dev/null
+++ b/ksmiletris/data/bg5.bmp
Binary files differ
diff --git a/ksmiletris/data/bg6.bmp b/ksmiletris/data/bg6.bmp
new file mode 100644
index 00000000..07420680
--- /dev/null
+++ b/ksmiletris/data/bg6.bmp
Binary files differ
diff --git a/ksmiletris/data/bg7.bmp b/ksmiletris/data/bg7.bmp
new file mode 100644
index 00000000..86036a44
--- /dev/null
+++ b/ksmiletris/data/bg7.bmp
Binary files differ
diff --git a/ksmiletris/data/bg8.bmp b/ksmiletris/data/bg8.bmp
new file mode 100644
index 00000000..6ce24fe1
--- /dev/null
+++ b/ksmiletris/data/bg8.bmp
Binary files differ
diff --git a/ksmiletris/data/bg9.bmp b/ksmiletris/data/bg9.bmp
new file mode 100644
index 00000000..ca3c94fc
--- /dev/null
+++ b/ksmiletris/data/bg9.bmp
Binary files differ
diff --git a/ksmiletris/data/block-a1.bmp b/ksmiletris/data/block-a1.bmp
new file mode 100644
index 00000000..5841d5bd
--- /dev/null
+++ b/ksmiletris/data/block-a1.bmp
Binary files differ
diff --git a/ksmiletris/data/block-a2.bmp b/ksmiletris/data/block-a2.bmp
new file mode 100644
index 00000000..1e447d36
--- /dev/null
+++ b/ksmiletris/data/block-a2.bmp
Binary files differ
diff --git a/ksmiletris/data/block-a3.bmp b/ksmiletris/data/block-a3.bmp
new file mode 100644
index 00000000..21528d77
--- /dev/null
+++ b/ksmiletris/data/block-a3.bmp
Binary files differ
diff --git a/ksmiletris/data/block-a4.bmp b/ksmiletris/data/block-a4.bmp
new file mode 100644
index 00000000..5d57813a
--- /dev/null
+++ b/ksmiletris/data/block-a4.bmp
Binary files differ
diff --git a/ksmiletris/data/block-a5.bmp b/ksmiletris/data/block-a5.bmp
new file mode 100644
index 00000000..98d462c5
--- /dev/null
+++ b/ksmiletris/data/block-a5.bmp
Binary files differ
diff --git a/ksmiletris/data/block-a6.bmp b/ksmiletris/data/block-a6.bmp
new file mode 100644
index 00000000..f5850429
--- /dev/null
+++ b/ksmiletris/data/block-a6.bmp
Binary files differ
diff --git a/ksmiletris/data/block-a7.bmp b/ksmiletris/data/block-a7.bmp
new file mode 100644
index 00000000..f6684405
--- /dev/null
+++ b/ksmiletris/data/block-a7.bmp
Binary files differ
diff --git a/ksmiletris/data/block-a8.bmp b/ksmiletris/data/block-a8.bmp
new file mode 100644
index 00000000..b69d0dda
--- /dev/null
+++ b/ksmiletris/data/block-a8.bmp
Binary files differ
diff --git a/ksmiletris/data/block-b1.bmp b/ksmiletris/data/block-b1.bmp
new file mode 100644
index 00000000..4b602027
--- /dev/null
+++ b/ksmiletris/data/block-b1.bmp
Binary files differ
diff --git a/ksmiletris/data/block-b2.bmp b/ksmiletris/data/block-b2.bmp
new file mode 100644
index 00000000..8b5e8a74
--- /dev/null
+++ b/ksmiletris/data/block-b2.bmp
Binary files differ
diff --git a/ksmiletris/data/block-b3.bmp b/ksmiletris/data/block-b3.bmp
new file mode 100644
index 00000000..99d7caf3
--- /dev/null
+++ b/ksmiletris/data/block-b3.bmp
Binary files differ
diff --git a/ksmiletris/data/block-b4.bmp b/ksmiletris/data/block-b4.bmp
new file mode 100644
index 00000000..c25c9031
--- /dev/null
+++ b/ksmiletris/data/block-b4.bmp
Binary files differ
diff --git a/ksmiletris/data/block-b5.bmp b/ksmiletris/data/block-b5.bmp
new file mode 100644
index 00000000..032591c6
--- /dev/null
+++ b/ksmiletris/data/block-b5.bmp
Binary files differ
diff --git a/ksmiletris/data/block-b6.bmp b/ksmiletris/data/block-b6.bmp
new file mode 100644
index 00000000..d068c51a
--- /dev/null
+++ b/ksmiletris/data/block-b6.bmp
Binary files differ
diff --git a/ksmiletris/data/block-b7.bmp b/ksmiletris/data/block-b7.bmp
new file mode 100644
index 00000000..0154cf1b
--- /dev/null
+++ b/ksmiletris/data/block-b7.bmp
Binary files differ
diff --git a/ksmiletris/data/block-b8.bmp b/ksmiletris/data/block-b8.bmp
new file mode 100644
index 00000000..3f60e0ad
--- /dev/null
+++ b/ksmiletris/data/block-b8.bmp
Binary files differ
diff --git a/ksmiletris/data/block-c1.bmp b/ksmiletris/data/block-c1.bmp
new file mode 100644
index 00000000..f6d91227
--- /dev/null
+++ b/ksmiletris/data/block-c1.bmp
Binary files differ
diff --git a/ksmiletris/data/block-c2.bmp b/ksmiletris/data/block-c2.bmp
new file mode 100644
index 00000000..f83013bc
--- /dev/null
+++ b/ksmiletris/data/block-c2.bmp
Binary files differ
diff --git a/ksmiletris/data/block-c3.bmp b/ksmiletris/data/block-c3.bmp
new file mode 100644
index 00000000..bb07ba76
--- /dev/null
+++ b/ksmiletris/data/block-c3.bmp
Binary files differ
diff --git a/ksmiletris/data/block-c4.bmp b/ksmiletris/data/block-c4.bmp
new file mode 100644
index 00000000..8f9aa21c
--- /dev/null
+++ b/ksmiletris/data/block-c4.bmp
Binary files differ
diff --git a/ksmiletris/data/block-c5.bmp b/ksmiletris/data/block-c5.bmp
new file mode 100644
index 00000000..ca97d6d0
--- /dev/null
+++ b/ksmiletris/data/block-c5.bmp
Binary files differ
diff --git a/ksmiletris/data/block-c6.bmp b/ksmiletris/data/block-c6.bmp
new file mode 100644
index 00000000..2fa42edf
--- /dev/null
+++ b/ksmiletris/data/block-c6.bmp
Binary files differ
diff --git a/ksmiletris/data/block-c7.bmp b/ksmiletris/data/block-c7.bmp
new file mode 100644
index 00000000..8dd189fe
--- /dev/null
+++ b/ksmiletris/data/block-c7.bmp
Binary files differ
diff --git a/ksmiletris/data/block-c8.bmp b/ksmiletris/data/block-c8.bmp
new file mode 100644
index 00000000..79fbbaf0
--- /dev/null
+++ b/ksmiletris/data/block-c8.bmp
Binary files differ
diff --git a/ksmiletris/data/broken-mask.bmp b/ksmiletris/data/broken-mask.bmp
new file mode 100644
index 00000000..f84cc4c1
--- /dev/null
+++ b/ksmiletris/data/broken-mask.bmp
Binary files differ
diff --git a/ksmiletris/data/broken.bmp b/ksmiletris/data/broken.bmp
new file mode 100644
index 00000000..a575c899
--- /dev/null
+++ b/ksmiletris/data/broken.bmp
Binary files differ
diff --git a/ksmiletris/data/cleared-a.bmp b/ksmiletris/data/cleared-a.bmp
new file mode 100644
index 00000000..4d904604
--- /dev/null
+++ b/ksmiletris/data/cleared-a.bmp
Binary files differ
diff --git a/ksmiletris/data/cleared-b.bmp b/ksmiletris/data/cleared-b.bmp
new file mode 100644
index 00000000..0193c4ab
--- /dev/null
+++ b/ksmiletris/data/cleared-b.bmp
Binary files differ
diff --git a/ksmiletris/data/cleared-c.bmp b/ksmiletris/data/cleared-c.bmp
new file mode 100644
index 00000000..0193c4ab
--- /dev/null
+++ b/ksmiletris/data/cleared-c.bmp
Binary files differ
diff --git a/ksmiletris/data/pause.bmp b/ksmiletris/data/pause.bmp
new file mode 100644
index 00000000..75f8b8d0
--- /dev/null
+++ b/ksmiletris/data/pause.bmp
Binary files differ
diff --git a/ksmiletris/gamewidget.cpp b/ksmiletris/gamewidget.cpp
new file mode 100644
index 00000000..7bead2f7
--- /dev/null
+++ b/ksmiletris/gamewidget.cpp
@@ -0,0 +1,518 @@
+/****************************************************************
+Copyright (c) 1998 Sandro Sigala <[email protected]>.
+All rights reserved.
+
+Permission to use, copy, modify, and distribute this software
+and its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of the author not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+The author disclaim all warranties with regard to this
+software, including all implied warranties of merchantability
+and fitness. In no event shall the author be liable for any
+special, indirect or consequential damages or any damages
+whatsoever resulting from loss of use, data or profits, whether
+in an action of contract, negligence or other tortious action,
+arising out of or in connection with the use or performance of
+this software.
+****************************************************************/
+
+#include "config.h"
+
+#include <kaudioplayer.h>
+#include <kapplication.h>
+#include <kstandarddirs.h>
+#include <qbitmap.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qtimer.h>
+#ifdef HAVE_USLEEP
+#include <unistd.h>
+#endif
+
+#include "ksmiletris.h"
+#include "gamewidget.h"
+#include "screenwidget.h"
+#include "mirrorwidget.h"
+#include "npiecewidget.h"
+
+#include <kmessagebox.h>
+#include <klocale.h>
+
+GameWidget::GameWidget(QWidget *parent, const char *name)
+ : QWidget(parent, name)
+{
+ in_game = false;
+ in_pause = false;
+
+ random.setSeed(0);
+
+ loadSprites();
+ setPieces(Pieces_Smiles);
+
+ map = new Sprite[scr_width * scr_height];
+ mirror_sprites = new Sprite[scr_width];
+
+ screen = new ScreenWidget(sprites, &in_game, &in_pause, this);
+ screen->move(10, 10);
+ screen->setScreenSprites(map);
+
+ mirror = new MirrorWidget(sprites, &in_game, &in_pause, this);
+ mirror->move(10, 407);
+ mirror->setMirrorSprites(mirror_sprites);
+
+ next = new NextPieceWidget(sprites, &in_game, &in_pause, this);
+ next->move(278, 10);
+ next->setNextPieceSprites(next_piece);
+
+ timer = new QTimer(this);
+ connect(timer, SIGNAL(timeout()), this, SLOT(timeout()));
+}
+
+GameWidget::~GameWidget()
+{
+ delete [] sprites;
+ delete [] map;
+ delete [] mirror_sprites;
+}
+
+void GameWidget::playSound(Sound s)
+{
+ if (!do_sounds)
+ return;
+
+ QString name;
+ switch (s) {
+ case Sound_Break:
+ name = "break.wav";
+ break;
+ case Sound_Clear:
+ name = "clear.wav";
+ break;
+ }
+
+ KAudioPlayer::play(locate("data", QString("ksmiletris/sounds/") + name));
+}
+
+void GameWidget::setPieces(PiecesType type)
+{
+ QString prefix;
+
+ switch (type) {
+ case Pieces_Smiles:
+ prefix = "block-a";
+ loadSprite(Sprite_Cleared, "cleared-a.bmp");
+ break;
+ case Pieces_Symbols:
+ prefix = "block-b";
+ loadSprite(Sprite_Cleared, "cleared-b.bmp");
+ break;
+ case Pieces_Icons:
+ prefix = "block-c";
+ loadSprite(Sprite_Cleared, "cleared-c.bmp");
+ }
+
+ for (int i = 0; i < num_blocks; ++i) {
+ QString n;
+ n.setNum(i + 1);
+ loadSprite((Sprite)(Sprite_Block1 + i), prefix + n + ".bmp");
+ }
+ QPixmap pm(32, 32);
+ for (int i = 0; i < num_blocks; ++i) {
+ QPainter p;
+ p.begin(&pm);
+ p.drawPixmap(0, 0, sprites[Sprite_Block1 + i]);
+ p.drawPixmap(0, 0, sprites[Sprite_Broken]);
+ p.end();
+ sprites[Sprite_Broken1 + i] = pm;
+ }
+
+ if (in_game) repaintChilds();
+}
+
+void GameWidget::loadSprites()
+{
+ sprites = new QPixmap[num_sprites];
+ loadSprite(Sprite_Bg1, "bg1.bmp");
+ loadSprite(Sprite_Bg2, "bg2.bmp");
+ loadSprite(Sprite_Bg3, "bg3.bmp");
+ loadSprite(Sprite_Bg4, "bg4.bmp");
+ loadSprite(Sprite_Bg5, "bg5.bmp");
+ loadSprite(Sprite_Bg6, "bg6.bmp");
+ loadSprite(Sprite_Bg7, "bg7.bmp");
+ loadSprite(Sprite_Bg8, "bg8.bmp");
+ loadSprite(Sprite_Bg9, "bg9.bmp");
+ loadSprite(Sprite_Bg10, "bg10.bmp");
+ loadSprite(Sprite_Bg11, "bg11.bmp");
+ loadSprite(Sprite_Bg12, "bg12.bmp");
+ loadSprite(Sprite_Bg13, "bg13.bmp");
+ loadSprite(Sprite_Bg14, "bg14.bmp");
+ loadSprite(Sprite_Bg15, "bg15.bmp");
+ loadSprite(Sprite_Bg16, "bg16.bmp");
+ loadMaskedSprite(Sprite_Broken, "broken.bmp", "broken-mask.bmp");
+}
+
+void GameWidget::loadSprite(Sprite spr, const QString & path)
+{
+ if (!sprites[spr].load(locate("appdata", QString("data/") + path)))
+ qFatal("Cannot open data files.\nHave you correctly installed KSmiletris?");
+}
+
+void GameWidget::loadMaskedSprite(Sprite spr, const QString & path1, const QString & path2)
+{
+ QBitmap bmp;
+ if (!sprites[spr].load(locate("appdata", QString("data/") + path1)))
+ qFatal("Cannot open data files.\nHave you correctly installed KSmiletris?");
+ if (!bmp.load(locate("appdata", QString("data/") + path2)))
+ qFatal("Cannot open data files.\nHave you correctly installed KSmiletris?");
+ sprites[spr].setMask(bmp);
+}
+
+void GameWidget::newGame()
+{
+ in_pause = false;
+ fast_mode = false;
+
+ num_level = 1;
+ num_pieces_level = 2;
+ num_points = 0;
+
+ bg_sprite = (Sprite)(Sprite_Bg1 + random.getLong(num_bgs));
+ screen->setBackgroundSprite(bg_sprite);
+ mirror->setBackgroundSprite(bg_sprite);
+ next->setBackgroundSprite(bg_sprite);
+ for (int i = 0; i < scr_width; ++i)
+ mirror_sprites[i] = bg_sprite;
+ for (int i = 0; i < 4; ++i)
+ next_piece[i] = bg_sprite;
+ for (int y = 0; y < scr_height; ++y)
+ for (int x = 0; x < scr_width; ++x)
+ ref(x, y) = bg_sprite;
+
+ newPiece();
+ nextPiece();
+ updateMirror();
+
+ in_game = true;
+ repaintChilds();
+ emit changedStats(num_level, num_points);
+ timer_interval = 700;
+ timer->start(timer_interval);
+}
+
+void GameWidget::repaintChilds()
+{
+ screen->repaint(false);
+ mirror->repaint(false);
+ next->repaint(false);
+}
+
+void GameWidget::putPiece()
+{
+ if (piece[0] != bg_sprite) ref(xpos + 0, ypos + 0) = piece[0];
+ if (piece[1] != bg_sprite) ref(xpos + 1, ypos + 0) = piece[1];
+ if (piece[2] != bg_sprite) ref(xpos + 0, ypos + 1) = piece[2];
+ if (piece[3] != bg_sprite) ref(xpos + 1, ypos + 1) = piece[3];
+ updateMirror();
+ screen->repaint(false);
+}
+
+void GameWidget::getPiece()
+{
+ if (piece[0] != bg_sprite) ref(xpos + 0, ypos + 0) = bg_sprite;
+ if (piece[1] != bg_sprite) ref(xpos + 1, ypos + 0) = bg_sprite;
+ if (piece[2] != bg_sprite) ref(xpos + 0, ypos + 1) = bg_sprite;
+ if (piece[3] != bg_sprite) ref(xpos + 1, ypos + 1) = bg_sprite;
+}
+
+void GameWidget::newPiece()
+{
+ static int pieces[][4] = {{1, 0, 1, 1},
+ {1, 1, 1, 0},
+ {1, 1, 0, 1},
+ {0, 1, 1, 1}};
+ int p = random.getLong(4);
+ for (int i = 0; i < 4; ++i)
+ if (pieces[p][i])
+ next_piece[i] = (Sprite)(Sprite_Block1 + random.getLong(num_pieces_level));
+ else
+ next_piece[i] = bg_sprite;
+ next->repaint(false);
+}
+
+void GameWidget::nextPiece()
+{
+ piece[0] = next_piece[0];
+ piece[1] = next_piece[1];
+ piece[2] = next_piece[2];
+ piece[3] = next_piece[3];
+ newPiece();
+ xpos = (scr_width - 2) / 2;
+ ypos = 0;
+ if ((piece[0] != bg_sprite && ref(xpos + 0, ypos + 0) != bg_sprite)
+ || (piece[1] != bg_sprite && ref(xpos + 1, ypos + 0) != bg_sprite)
+ || (piece[2] != bg_sprite && ref(xpos + 0, ypos + 1) != bg_sprite)
+ || (piece[3] != bg_sprite && ref(xpos + 1, ypos + 1) != bg_sprite)) {
+ in_game = false;
+ repaintChilds();
+ KMessageBox::sorry(this, i18n("Game Over"));
+ emit gameOver();
+ }
+
+ putPiece();
+}
+
+void GameWidget::updateMirror()
+{
+ for (int x = 0; x < scr_width; ++x)
+ mirror_sprites[x] = bg_sprite;
+ mirror_sprites[xpos] = piece[2] == bg_sprite ? piece[0] : piece[2];
+ mirror_sprites[xpos+1] = piece[3] == bg_sprite ? piece[1] : piece[3];
+ mirror->repaint(false);
+}
+
+void GameWidget::keyUp()
+{
+ if (!in_game || in_pause) return;
+
+ getPiece();
+ if ((piece[0] == bg_sprite && ref(xpos + 0, ypos + 0) != bg_sprite)
+ || (piece[1] == bg_sprite && ref(xpos + 1, ypos + 0) != bg_sprite)
+ || (piece[2] == bg_sprite && ref(xpos + 0, ypos + 1) != bg_sprite)
+ || (piece[3] == bg_sprite && ref(xpos + 1, ypos + 1) != bg_sprite)) {
+ putPiece();
+ return;
+ }
+
+ Sprite npiece[4];
+ npiece[2] = piece[0];
+ npiece[0] = piece[1];
+ npiece[3] = piece[2];
+ npiece[1] = piece[3];
+ for (int i = 0; i < 4; ++i)
+ piece[i] = npiece[i];
+ putPiece();
+}
+
+void GameWidget::keyDown()
+{
+ if (!in_game || in_pause) return;
+
+ getPiece();
+ if ((piece[0] == bg_sprite && ref(xpos + 0, ypos + 0) != bg_sprite)
+ || (piece[1] == bg_sprite && ref(xpos + 1, ypos + 0) != bg_sprite)
+ || (piece[2] == bg_sprite && ref(xpos + 0, ypos + 1) != bg_sprite)
+ || (piece[3] == bg_sprite && ref(xpos + 1, ypos + 1) != bg_sprite)) {
+ putPiece();
+ return;
+ }
+
+ Sprite npiece[4];
+ npiece[0] = piece[2];
+ npiece[1] = piece[0];
+ npiece[2] = piece[3];
+ npiece[3] = piece[1];
+ for (int i = 0; i < 4; ++i)
+ piece[i] = npiece[i];
+ putPiece();
+}
+
+void GameWidget::keyLeft()
+{
+ if (!in_game || in_pause || xpos == 0) return;
+
+ getPiece();
+ if ((piece[0] != bg_sprite && ref(xpos - 1, ypos + 0) != bg_sprite)
+ || (piece[1] != bg_sprite && ref(xpos + 0, ypos + 0) != bg_sprite)
+ || (piece[2] != bg_sprite && ref(xpos - 1, ypos + 1) != bg_sprite)
+ || (piece[3] != bg_sprite && ref(xpos + 0, ypos + 1) != bg_sprite)) {
+ putPiece();
+ return;
+ }
+
+ --xpos;
+ putPiece();
+}
+
+void GameWidget::keyRight()
+{
+ if (!in_game || in_pause || xpos == scr_width - 2) return;
+
+ getPiece();
+ if ((piece[0] != bg_sprite && ref(xpos + 1, ypos + 0) != bg_sprite)
+ || (piece[1] != bg_sprite && ref(xpos + 2, ypos + 0) != bg_sprite)
+ || (piece[2] != bg_sprite && ref(xpos + 1, ypos + 1) != bg_sprite)
+ || (piece[3] != bg_sprite && ref(xpos + 2, ypos + 1) != bg_sprite)) {
+ putPiece();
+ return;
+ }
+
+ ++xpos;
+ putPiece();
+}
+
+void GameWidget::keySpace()
+{
+ if (!in_game || in_pause || fast_mode) return;
+ fast_mode = true;
+ timer->changeInterval(50);
+}
+
+void GameWidget::broke(int x, int y, bool *xmap)
+{
+ xmap[y*scr_width + x] = true;
+ if (ref(x, y) >= Sprite_Broken1) {
+ // Clear the piece
+ playSound(Sound_Clear);
+ ref(x, y) = Sprite_Cleared;
+ num_points += 20;
+ } else {
+ // Break the piece
+ playSound(Sound_Break);
+ ref(x, y) = (Sprite)(Sprite_Broken1 + ref(x, y) - Sprite_Block1);
+ num_points += 10;
+ }
+ int level = num_points / 1000 + 1;
+ if (level > num_level) {
+ num_level = level;
+ num_pieces_level = (num_level/2 + 2) > num_blocks ?
+ num_blocks : num_level/2 + 2;
+ timer_interval = timer_interval - 25;
+ if (timer_interval < 50)
+ timer_interval = 50;
+ timer->changeInterval(timer_interval);
+ }
+
+ emit changedStats(num_level, num_points);
+
+#ifdef HAVE_USLEEP
+ screen->repaint(false);
+ usleep(75 * 1000);
+#endif
+}
+
+void GameWidget::recBroke(int x, int y, bool *xmap)
+{
+ int t = type(ref(x, y));
+
+ broke(x, y, xmap);
+ // X-1, Y
+ if (x > 0 && !xmap[y*scr_width + x - 1] && type(ref(x-1, y)) == t)
+ recBroke(x-1, y, xmap);
+ // X+1, Y
+ if (x < scr_width-1 && !xmap[y*scr_width + x + 1] && type(ref(x+1, y)) == t)
+ recBroke(x+1, y, xmap);
+ // X, Y-1
+ if (y > 0 && !xmap[(y-1)*scr_width + x] && type(ref(x, y-1)) == t)
+ recBroke(x, y-1, xmap);
+ // X, Y+1
+ if (y < scr_height-1 && !xmap[(y+1)*scr_width + x] && type(ref(x, y+1)) == t)
+ recBroke(x, y+1, xmap);
+
+ // X-1, Y+1
+ if (x > 0 && y < scr_height-1 && !xmap[(y+1)*scr_width + x - 1] && type(ref(x-1, y+1)) == t)
+ recBroke(x-1, y+1, xmap);
+ // X+1, Y+1
+ if (x < scr_width-1 && y < scr_height-1 && !xmap[(y+1)*scr_width + x + 1] && type(ref(x+1, y+1)) == t)
+ recBroke(x+1, y+1, xmap);
+ // X-1, Y-1
+ if (x > 0 && y > 0 && !xmap[(y-1)*scr_width + x - 1] && type(ref(x-1, y-1)) == t)
+ recBroke(x-1, y-1, xmap);
+ // X+1, Y-1
+ if (x < scr_width-1 && y > 0 && !xmap[(y-1)*scr_width + x + 1] && type(ref(x+1, y-1)) == t)
+ recBroke(x+1, y-1, xmap);
+}
+
+void GameWidget::checkSolePiece(int x, int y, bool *xmap)
+{
+ if (y < scr_height-1 && type(ref(x, y+1)) == type(ref(x, y)))
+ recBroke(x, y, xmap);
+}
+
+void GameWidget::checkPiece(int x, int y)
+{
+ bool xmap[scr_width * scr_height];
+ for (int yy = 0; yy < scr_height; ++yy)
+ for (int x = 0; x < scr_width; ++x)
+ xmap[yy*scr_width + x] = false;
+ checkSolePiece(x, y, xmap);
+}
+
+void GameWidget::compact()
+{
+ recheck:
+ bool moved = true;
+ while (moved) {
+ moved = false;
+ for (int x = 0; x < scr_width; ++x)
+ for (int y = scr_height - 1; y > 0; --y)
+ if (ref(x, y) == bg_sprite
+ || ref(x, y) == Sprite_Cleared) {
+ int i;
+ for (i = y-1; i >= 0; --i)
+ if (ref(x, i) != bg_sprite
+ && ref(x, i) != Sprite_Cleared) {
+ ref(x, y) = ref(x, i);
+ ref(x, i) = bg_sprite;
+ moved = true;
+ checkPiece(x, y);
+ goto recheck;
+ break;
+ }
+ if (i < 0)
+ ref(x, y) = bg_sprite;
+ }
+ }
+}
+
+void GameWidget::blockPiece()
+{
+ if (fast_mode) {
+ timer->changeInterval(timer_interval);
+ fast_mode = false;
+ }
+ putPiece();
+ bool xmap[scr_width * scr_height];
+ for (int yy = 0; yy < scr_height; ++yy)
+ for (int x = 0; x < scr_width; ++x)
+ xmap[yy*scr_width + x] = false;
+ if (piece[2] != bg_sprite)
+ checkSolePiece(xpos, ypos+1, xmap);
+ if (piece[3] != bg_sprite)
+ checkSolePiece(xpos+1, ypos+1, xmap);
+ if (piece[2] == bg_sprite)
+ checkSolePiece(xpos, ypos, xmap);
+ if (piece[3] == bg_sprite)
+ checkSolePiece(xpos+1, ypos, xmap);
+ compact();
+ nextPiece();
+}
+
+void GameWidget::timeout()
+{
+ if (!in_game || in_pause)
+ return;
+
+ getPiece();
+ if (ypos == scr_height - 2) {
+ blockPiece();
+ return;
+ }
+
+ if ((piece[0] != bg_sprite && ref(xpos + 0, ypos + 1) != bg_sprite)
+ || (piece[1] != bg_sprite && ref(xpos + 1, ypos + 1) != bg_sprite)
+ || (piece[2] != bg_sprite && ref(xpos + 0, ypos + 2) != bg_sprite)
+ || (piece[3] != bg_sprite && ref(xpos + 1, ypos + 2) != bg_sprite))
+ blockPiece();
+ else {
+ ++ypos;
+ putPiece();
+ }
+
+}
+
+#include "gamewidget.moc"
diff --git a/ksmiletris/gamewidget.h b/ksmiletris/gamewidget.h
new file mode 100644
index 00000000..49901650
--- /dev/null
+++ b/ksmiletris/gamewidget.h
@@ -0,0 +1,112 @@
+/****************************************************************
+Copyright (c) 1998 Sandro Sigala <[email protected]>.
+All rights reserved.
+
+Permission to use, copy, modify, and distribute this software
+and its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of the author not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+The author disclaim all warranties with regard to this
+software, including all implied warranties of merchantability
+and fitness. In no event shall the author be liable for any
+special, indirect or consequential damages or any damages
+whatsoever resulting from loss of use, data or profits, whether
+in an action of contract, negligence or other tortious action,
+arising out of or in connection with the use or performance of
+this software.
+****************************************************************/
+
+#ifndef GAMEWIDGET_H
+#define GAMEWIDGET_H
+
+#include <qwidget.h>
+#include <krandomsequence.h>
+
+#include "ksmiletris.h"
+
+class ScreenWidget;
+class MirrorWidget;
+class NextPieceWidget;
+class QTimer;
+
+class GameWidget : public QWidget {
+ Q_OBJECT
+
+signals:
+ void changedStats(int, int);
+ void gameOver();
+
+public:
+ bool in_game, in_pause;
+ bool do_sounds;
+ int num_level;
+ int num_points;
+
+ GameWidget(QWidget *parent=0, const char *name=0);
+ ~GameWidget();
+
+ void setPieces(PiecesType type);
+
+ Sprite& ref(int x, int y) {
+ return map[y*scr_width + x];
+ }
+
+ Sprite type(Sprite s) {
+ if (s >= Sprite_Broken1 && s < Sprite_Broken1 + num_blocks)
+ return (Sprite)(Sprite_Block1 + s - Sprite_Broken1);
+ return s;
+ }
+
+ void repaintChilds();
+
+private:
+ QPixmap *sprites;
+ ScreenWidget *screen;
+ MirrorWidget *mirror;
+ NextPieceWidget *next;
+ int xpos, ypos;
+ Sprite piece[4];
+ Sprite *map;
+ Sprite *mirror_sprites;
+ Sprite next_piece[4];
+ Sprite bg_sprite;
+ int timer_interval;
+ bool fast_mode;
+ QTimer *timer;
+ KRandomSequence random;
+
+ int num_pieces_level;
+
+ void playSound(Sound s);
+ void loadSprites();
+ void loadSprite(Sprite spr, const QString & path);
+ void loadMaskedSprite(Sprite spr, const QString & path1, const QString & path2);
+ void newBlock();
+ void putPiece();
+ void getPiece();
+ void newPiece();
+ void nextPiece();
+ void compact();
+ void broke(int x, int y, bool *xmap);
+ void recBroke(int x, int y, bool *xmap);
+ void checkSolePiece(int x, int y, bool *xmap);
+ void checkPiece(int x, int y);
+ void blockPiece();
+ void updateMirror();
+
+public slots:
+ void newGame();
+ void keyUp();
+ void keyDown();
+ void keyLeft();
+ void keyRight();
+ void keySpace();
+ void timeout();
+};
+
+#endif // !GAMEWIDGET_H
diff --git a/ksmiletris/gamewindow.cpp b/ksmiletris/gamewindow.cpp
new file mode 100644
index 00000000..60973530
--- /dev/null
+++ b/ksmiletris/gamewindow.cpp
@@ -0,0 +1,204 @@
+/****************************************************************
+Copyright (c) 1998 Sandro Sigala <[email protected]>.
+All rights reserved.
+
+Permission to use, copy, modify, and distribute this software
+and its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of the author not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+The author disclaim all warranties with regard to this
+software, including all implied warranties of merchantability
+and fitness. In no event shall the author be liable for any
+special, indirect or consequential damages or any damages
+whatsoever resulting from loss of use, data or profits, whether
+in an action of contract, negligence or other tortious action,
+arising out of or in connection with the use or performance of
+this software.
+****************************************************************/
+
+#include "config.h"
+
+#include <kapplication.h>
+#include <klocale.h>
+#include <kconfig.h>
+#include <kmenubar.h>
+#include <kstatusbar.h>
+
+#include "ksmiletris.h"
+#include "gamewindow.h"
+#include "gamewidget.h"
+#include "kscoredialog.h"
+
+#include <kaction.h>
+#include <kstdgameaction.h>
+
+
+
+const int default_width = 362;
+const int default_height = 460;
+
+GameWindow::GameWindow(QWidget *, const char *name)
+ : KMainWindow(0, name)
+{
+ //New Games
+ (void)KStdGameAction::gameNew(this,
+ SLOT(menu_newGame()),
+ actionCollection());
+
+ //Pause Game
+ (void)KStdGameAction::pause(this,
+ SLOT(menu_pause()),
+ actionCollection());
+
+ //End Game
+ (void)KStdGameAction::end(this,
+ SLOT(menu_endGame()),
+ actionCollection());
+
+ //Highscores
+ (void)KStdGameAction::highscores(this,
+ SLOT(menu_highScores()),
+ actionCollection());
+
+ //Quit
+ (void)KStdGameAction::quit(this,
+ SLOT(close()),
+ actionCollection());
+
+ QStringList list;
+ KSelectAction* piecesAct =
+ new KSelectAction(i18n("&Pieces"), 0, this, SLOT(menu_pieces()),
+ actionCollection(), "settings_pieces");
+ list.append(i18n("&Smiles"));
+ list.append(i18n("S&ymbols"));
+ list.append(i18n("&Icons"));
+ piecesAct->setItems(list);
+
+ (void)new KToggleAction(i18n("&Sounds"), 0, this,
+ SLOT(menu_sounds()), actionCollection(), "settings_sounds");
+
+
+
+
+
+ //connect(menu, SIGNAL(moved(menuPosition)),
+ // this, SLOT(movedMenu(menuPosition))); ?
+
+ status = new KStatusBar(this);
+ status->insertItem(i18n("Level: 99"), 1);
+ status->insertItem(i18n("Score: 999999"), 2);
+ status->changeItem("", 1);
+ status->changeItem("", 2);
+
+ game = new GameWidget(this);
+ setCentralWidget(game);
+ connect(game, SIGNAL(changedStats(int, int)),
+ this, SLOT(updateStats(int, int)));
+ connect(game, SIGNAL(gameOver()), this, SLOT(gameOver()));
+
+ //keys
+ (void)new KAction(i18n("Move Left"), Key_Left, game, SLOT(keyLeft()), actionCollection(), "left");
+ (void)new KAction(i18n("Move Right"), Key_Right, game, SLOT(keyRight()), actionCollection(), "right");
+ (void)new KAction(i18n("Rotate Left"), Key_Up, game, SLOT(keyUp()), actionCollection(), "up");
+ (void)new KAction(i18n("Rotate Right"), Key_Down, game, SLOT(keyDown()), actionCollection(), "down");
+ (void)new KAction(i18n("Drop Down"), Key_Space, game, SLOT(keySpace()), actionCollection(), "space");
+
+ game->setFixedSize(default_width, default_height);
+ adjustSize();
+ setFixedSize(size());
+
+ // Read configuration
+ KConfig *config = kapp->config();
+ config->setGroup("Options");
+ PiecesType pieces_type = (PiecesType)config->readNumEntry("Pieces", static_cast<int>(Pieces_Smiles));
+ game->setPieces(pieces_type);
+ ((KSelectAction*)actionCollection()->action("settings_pieces"))->setCurrentItem((int)pieces_type);
+
+
+ game->do_sounds = config->readBoolEntry("Sounds", true);
+ ((KToggleAction*)actionCollection()->action("settings_sounds"))->setChecked(game->do_sounds);
+
+ setupGUI(KMainWindow::Save | Keys | StatusBar | Create);
+}
+
+void GameWindow::menu_newGame()
+{
+ ((KToggleAction*)actionCollection()->action(KStdGameAction::stdName(KStdGameAction::Pause)))->setChecked(false);
+ game->newGame();
+}
+
+void GameWindow::menu_pause()
+{
+ if (game->in_game) {
+ game->in_pause = !game->in_pause;
+ ((KToggleAction*)actionCollection()->action(KStdGameAction::stdName(KStdGameAction::Pause)))->setChecked(game->in_pause);
+ game->repaintChilds();
+ }
+}
+
+void GameWindow::menu_endGame()
+{
+ if (game->in_game) {
+ game->in_game = false;
+ game->repaintChilds();
+ ((KToggleAction*)actionCollection()->action(KStdGameAction::stdName(KStdGameAction::Pause)))->setChecked(false);
+ gameOver();
+ }
+}
+
+void GameWindow::menu_highScores()
+{
+ KScoreDialog d(KScoreDialog::Name | KScoreDialog::Level | KScoreDialog::Score, this);
+ d.exec();
+}
+
+void GameWindow::menu_pieces()
+{
+ int index = ((KSelectAction*)actionCollection()->action("settings_pieces"))->currentItem();
+ game->setPieces((PiecesType)index);
+
+ KConfig *config = kapp->config();
+ config->setGroup("Options");
+ config->writeEntry("Pieces", index);
+}
+
+void GameWindow::menu_sounds()
+{
+ game->do_sounds = !game->do_sounds;
+ ((KToggleAction*)actionCollection()->action("settings_sounds"))->setChecked(game->do_sounds);
+
+ KConfig *config = kapp->config();
+ config->setGroup("Options");
+ config->writeEntry("Sounds", game->do_sounds);
+}
+
+void GameWindow::updateStats(int level, int points)
+{
+ QString l, p;
+ l.setNum(level);
+ p.setNum(points);
+ status->changeItem(i18n("Level: %1").arg(l), 1);
+ status->changeItem(i18n("Score: %1").arg(p), 2);
+}
+
+void GameWindow::gameOver()
+{
+ KScoreDialog d(KScoreDialog::Name | KScoreDialog::Level | KScoreDialog::Score, this);
+
+ KScoreDialog::FieldInfo scoreInfo;
+
+ scoreInfo[KScoreDialog::Level].setNum(game->num_level);
+
+ if (!d.addScore(game->num_points, scoreInfo))
+ return;
+
+ // Show highscore & ask for name.
+ d.exec();
+}
+
+#include "gamewindow.moc"
diff --git a/ksmiletris/gamewindow.h b/ksmiletris/gamewindow.h
new file mode 100644
index 00000000..54e637a0
--- /dev/null
+++ b/ksmiletris/gamewindow.h
@@ -0,0 +1,63 @@
+/****************************************************************
+Copyright (c) 1998 Sandro Sigala <[email protected]>.
+All rights reserved.
+
+Permission to use, copy, modify, and distribute this software
+and its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of the author not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+The author disclaim all warranties with regard to this
+software, including all implied warranties of merchantability
+and fitness. In no event shall the author be liable for any
+special, indirect or consequential damages or any damages
+whatsoever resulting from loss of use, data or profits, whether
+in an action of contract, negligence or other tortious action,
+arising out of or in connection with the use or performance of
+this software.
+****************************************************************/
+
+#ifndef GAMEWINDOW_H
+#define GAMEWINDOW_H
+
+#include <kmainwindow.h>
+
+#include "ksmiletris.h"
+
+class KMenuBar;
+class QPopupMenu;
+class GameWidget;
+class KStatusBar;
+
+class GameWindow : public KMainWindow {
+ Q_OBJECT
+
+public:
+ GameWindow(QWidget *parent=0, const char *name=0);
+
+public slots:
+ void menu_newGame();
+ void menu_pause();
+ void menu_endGame();
+ void menu_highScores();
+ void menu_pieces();
+ void menu_sounds();
+
+ void updateStats(int level, int points);
+ void gameOver();
+ //void movedMenu(menuPosition);
+
+private:
+ //enum menuPosition { Top, Bottom, Floating }; // hack
+ //KMenuBar *menu;
+
+ KStatusBar *status;
+ GameWidget *game;
+ QString m_player;
+};
+
+#endif // !GAMEWINDOW_H
diff --git a/ksmiletris/hi128-app-ksmiletris.png b/ksmiletris/hi128-app-ksmiletris.png
new file mode 100644
index 00000000..a7789b74
--- /dev/null
+++ b/ksmiletris/hi128-app-ksmiletris.png
Binary files differ
diff --git a/ksmiletris/hi16-app-ksmiletris.png b/ksmiletris/hi16-app-ksmiletris.png
new file mode 100644
index 00000000..c0883958
--- /dev/null
+++ b/ksmiletris/hi16-app-ksmiletris.png
Binary files differ
diff --git a/ksmiletris/hi22-app-ksmiletris.png b/ksmiletris/hi22-app-ksmiletris.png
new file mode 100644
index 00000000..e4b46fea
--- /dev/null
+++ b/ksmiletris/hi22-app-ksmiletris.png
Binary files differ
diff --git a/ksmiletris/hi32-app-ksmiletris.png b/ksmiletris/hi32-app-ksmiletris.png
new file mode 100644
index 00000000..2c38e3ce
--- /dev/null
+++ b/ksmiletris/hi32-app-ksmiletris.png
Binary files differ
diff --git a/ksmiletris/hi48-app-ksmiletris.png b/ksmiletris/hi48-app-ksmiletris.png
new file mode 100644
index 00000000..17696b2c
--- /dev/null
+++ b/ksmiletris/hi48-app-ksmiletris.png
Binary files differ
diff --git a/ksmiletris/hi64-app-ksmiletris.png b/ksmiletris/hi64-app-ksmiletris.png
new file mode 100644
index 00000000..6c9b6263
--- /dev/null
+++ b/ksmiletris/hi64-app-ksmiletris.png
Binary files differ
diff --git a/ksmiletris/ksmiletris.desktop b/ksmiletris/ksmiletris.desktop
new file mode 100644
index 00000000..59d6034f
--- /dev/null
+++ b/ksmiletris/ksmiletris.desktop
@@ -0,0 +1,78 @@
+[Desktop Entry]
+MimeType=
+GenericName=Tetris-like Game
+GenericName[be]=Гульня ў тэтрыс
+GenericName[bg]=Тетрис
+GenericName[bn]=টেট্রিস-জাতীয় টালির খেলা
+GenericName[br]=Ur c'hoari a seurt gant Tetris
+GenericName[bs]=Igra nalik na Tetris
+GenericName[ca]=Joc a l'estil Tetris
+GenericName[cs]=Hra podobná Tetris
+GenericName[cy]=Gêm sy'n debyg i Tetris
+GenericName[da]=Tetris-lignende spil
+GenericName[de]=Tetris-ähnliches Spiel
+GenericName[el]=Παιχνίδι παρόμοιο με το Tetris
+GenericName[eo]="Tetris"-simila ludo
+GenericName[es]=Juego similar al Tetris
+GenericName[et]=Tetrise moodi mäng
+GenericName[eu]=Tetris-en antzeko jokoa
+GenericName[fa]=بازی شبیه Tetris
+GenericName[fi]=Tetris-tyylinen peli
+GenericName[fr]=Jeu dans le style de Tetris
+GenericName[ga]=Cluiche Mar Tetris
+GenericName[he]=חיקוי טטריס
+GenericName[hr]=Igra poput Tetrisa
+GenericName[hu]=Tetrisz-szerű
+GenericName[is]=Leikur líkur Tetris
+GenericName[it]=Gioco simile al Tetris
+GenericName[ja]=テトリスのようなゲーム
+GenericName[km]=ល្បែង​ដូច Tetris
+GenericName[ko]=지뢰찾기 게임
+GenericName[lt]=Tetrio tipo žaidimas
+GenericName[lv]=Tetrim līdzīga spēle
+GenericName[mk]=Игра слична на Тетрис
+GenericName[nb]=Tetrislignende spill
+GenericName[nds]=Tetris-liek Speel
+GenericName[ne]=टेट्रिस जस्तै खेल
+GenericName[nl]=Tetris-achtig spel
+GenericName[nn]=Tetrisliknande spel
+GenericName[pl]=Gra typu Tetris
+GenericName[pt]=Jogo tipo Tetris
+GenericName[pt_BR]=Jogo como Tetris
+GenericName[ru]=Игра в тетрис
+GenericName[se]=Tetrislágan speallu
+GenericName[sk]=Hra typu Tetris
+GenericName[sl]=Igra podobna Tetrisu
+GenericName[sr]=Игра налик на Tetris
+GenericName[sr@Latn]=Igra nalik na Tetris
+GenericName[sv]=Tetrisliknande spel
+GenericName[ta]=டெட்ரிஸ் போன்ற விளையாட்டு
+GenericName[uk]=Гра схожа на тетріс
+GenericName[zh_CN]=俄罗斯方块
+GenericName[zh_TW]=類似俄羅斯方塊遊戲
+Exec=ksmiletris -caption "%c" %i %m
+Icon=ksmiletris
+Path=
+Type=Application
+Terminal=false
+Name=KSmileTris
+Name[af]=K-glimlag-tetris
+Name[be]=Смайл-тэтрыс
+Name[bn]=কে-স্মাইলট্রিস
+Name[eo]=Ridultetriso
+Name[hi]=के-स्माईल ट्रिस
+Name[is]=Brostris
+Name[ne]=केडीई स्माइल ट्रिस
+Name[pt_BR]=KSorrisoTris
+Name[ru]=Смайлик-тетрис
+Name[sv]=Ksmiletris
+Name[ta]= Kஸ்மைல் ட்ரிஸ்
+Name[tg]=KТетриси ханда
+Name[tr]=KSmiletris
+Name[zh_CN]=KSmiletris
+Name[zh_TW]=KSmileTris 笑臉俄羅斯
+Name[zu]=I-KSmileTris
+X-KDE-StartupNotify=true
+X-DCOP-ServiceType=Multi
+Categories=Qt;KDE;Game;ArcadeGame;
+DocPath=ksmiletris/index.html
diff --git a/ksmiletris/ksmiletris.h b/ksmiletris/ksmiletris.h
new file mode 100644
index 00000000..c141d601
--- /dev/null
+++ b/ksmiletris/ksmiletris.h
@@ -0,0 +1,86 @@
+/****************************************************************
+Copyright (c) 1998 Sandro Sigala <[email protected]>.
+All rights reserved.
+
+Permission to use, copy, modify, and distribute this software
+and its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of the author not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+The author disclaim all warranties with regard to this
+software, including all implied warranties of merchantability
+and fitness. In no event shall the author be liable for any
+special, indirect or consequential damages or any damages
+whatsoever resulting from loss of use, data or profits, whether
+in an action of contract, negligence or other tortious action,
+arising out of or in connection with the use or performance of
+this software.
+****************************************************************/
+
+#ifndef KSMILETRIS_H
+#define KSMILETRIS_H
+
+const int sprite_width = 32;
+const int sprite_height = 32;
+
+enum Sprite {
+ Sprite_Bg1,
+ Sprite_Bg2,
+ Sprite_Bg3,
+ Sprite_Bg4,
+ Sprite_Bg5,
+ Sprite_Bg6,
+ Sprite_Bg7,
+ Sprite_Bg8,
+ Sprite_Bg9,
+ Sprite_Bg10,
+ Sprite_Bg11,
+ Sprite_Bg12,
+ Sprite_Bg13,
+ Sprite_Bg14,
+ Sprite_Bg15,
+ Sprite_Bg16,
+ Sprite_Block1,
+ Sprite_Block2,
+ Sprite_Block3,
+ Sprite_Block4,
+ Sprite_Block5,
+ Sprite_Block6,
+ Sprite_Block7,
+ Sprite_Block8,
+ Sprite_Broken,
+ Sprite_Broken1,
+ Sprite_Broken2,
+ Sprite_Broken3,
+ Sprite_Broken4,
+ Sprite_Broken5,
+ Sprite_Broken6,
+ Sprite_Broken7,
+ Sprite_Broken8,
+ Sprite_Cleared,
+ NUM_SPRITES
+};
+
+const int num_sprites = NUM_SPRITES;
+const int num_blocks = 8;
+const int num_bgs = 16;
+
+const int scr_width = 8;
+const int scr_height = 12;
+
+enum PiecesType {
+ Pieces_Smiles=0,
+ Pieces_Symbols=1,
+ Pieces_Icons=2
+};
+
+enum Sound {
+ Sound_Break,
+ Sound_Clear
+};
+
+#endif // !KSMILETRIS_H
diff --git a/ksmiletris/ksmiletrisui.rc b/ksmiletris/ksmiletrisui.rc
new file mode 100644
index 00000000..66c29179
--- /dev/null
+++ b/ksmiletris/ksmiletrisui.rc
@@ -0,0 +1,12 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="ksmiletris" version="2">
+<MenuBar>
+ <Menu name="game"><text>&amp;Game</text>
+ </Menu>
+ <Menu name="settings"><text>&amp;Settings</text>
+ <Action name="settings_pieces" append="save_merge"/>
+ <Action name="settings_sounds" append="save_merge"/>
+ </Menu>
+</MenuBar>
+
+</kpartgui>
diff --git a/ksmiletris/main.cpp b/ksmiletris/main.cpp
new file mode 100644
index 00000000..ebb51ee2
--- /dev/null
+++ b/ksmiletris/main.cpp
@@ -0,0 +1,53 @@
+/****************************************************************
+Copyright (c) 1998 Sandro Sigala <[email protected]>.
+All rights reserved.
+
+Permission to use, copy, modify, and distribute this software
+and its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of the author not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+The author disclaim all warranties with regard to this
+software, including all implied warranties of merchantability
+and fitness. In no event shall the author be liable for any
+special, indirect or consequential damages or any damages
+whatsoever resulting from loss of use, data or profits, whether
+in an action of contract, negligence or other tortious action,
+arising out of or in connection with the use or performance of
+this software.
+****************************************************************/
+
+#include "config.h"
+
+#include <kapplication.h>
+#include <klocale.h>
+#include <kcmdlineargs.h>
+#include <kaboutdata.h>
+
+#include "gamewindow.h"
+
+
+static const char description[] = I18N_NOOP("KDE SmileTris");
+
+
+int main(int argc, char **argv)
+{
+ KAboutData aboutData( "ksmiletris", I18N_NOOP("KSmileTris"),
+ VERSION, description, KAboutData::License_GPL,
+ "(c) 1998, Sandro Sigala");
+ aboutData.addAuthor("Sandro Sigala",0, "[email protected]");
+ KCmdLineArgs::init( argc, argv, &aboutData );
+
+
+ KApplication app;
+ KGlobal::locale()->insertCatalogue("libkdegames");
+
+ GameWindow *w = new GameWindow;
+ app.setMainWidget(w);
+ w->show();
+ return app.exec();
+}
diff --git a/ksmiletris/mirrorwidget.cpp b/ksmiletris/mirrorwidget.cpp
new file mode 100644
index 00000000..43ae0175
--- /dev/null
+++ b/ksmiletris/mirrorwidget.cpp
@@ -0,0 +1,58 @@
+/****************************************************************
+Copyright (c) 1998 Sandro Sigala <[email protected]>.
+All rights reserved.
+
+Permission to use, copy, modify, and distribute this software
+and its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of the author not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+The author disclaim all warranties with regard to this
+software, including all implied warranties of merchantability
+and fitness. In no event shall the author be liable for any
+special, indirect or consequential damages or any damages
+whatsoever resulting from loss of use, data or profits, whether
+in an action of contract, negligence or other tortious action,
+arising out of or in connection with the use or performance of
+this software.
+****************************************************************/
+
+#include "config.h"
+
+#include <qframe.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+
+#include "ksmiletris.h"
+#include "mirrorwidget.h"
+
+MirrorWidget::MirrorWidget(QPixmap *s, bool *game, bool *pause,
+ QWidget *parent, const char *name)
+ : QFrame(parent, name)
+{
+ in_game = game;
+ in_pause = pause;
+ sprites = s;
+ setFrameStyle(QFrame::Box | QFrame::Raised);
+ setLineWidth(2);
+ setMidLineWidth(1);
+ resize(scr_width * sprite_width + 10, sprite_height + 10);
+}
+
+void MirrorWidget::drawContents(QPainter *p)
+{
+ QRect r = contentsRect();
+
+ if (!*in_game) {
+ p->fillRect(r, black);
+ return;
+ }
+
+ for (int x = 0; x < scr_width; ++x)
+ p->drawPixmap(r.x() + x*sprite_width, r.y(),
+ sprites[mirror_sprites[x]]);
+}
diff --git a/ksmiletris/mirrorwidget.h b/ksmiletris/mirrorwidget.h
new file mode 100644
index 00000000..4b0c7fa0
--- /dev/null
+++ b/ksmiletris/mirrorwidget.h
@@ -0,0 +1,49 @@
+/****************************************************************
+Copyright (c) 1998 Sandro Sigala <[email protected]>.
+All rights reserved.
+
+Permission to use, copy, modify, and distribute this software
+and its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of the author not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+The author disclaim all warranties with regard to this
+software, including all implied warranties of merchantability
+and fitness. In no event shall the author be liable for any
+special, indirect or consequential damages or any damages
+whatsoever resulting from loss of use, data or profits, whether
+in an action of contract, negligence or other tortious action,
+arising out of or in connection with the use or performance of
+this software.
+****************************************************************/
+
+#ifndef MIRRORWIDGET_H
+#define MIRRORWIDGET_H
+
+#include <qframe.h>
+
+#include "ksmiletris.h"
+
+class MirrorWidget : public QFrame {
+public:
+ MirrorWidget(QPixmap *s, bool *game, bool *pause,
+ QWidget *parent=0, const char *name=0);
+
+ void setBackgroundSprite(Sprite s) { bg_sprite = s; }
+ void setMirrorSprites(Sprite *s) { mirror_sprites = s; }
+
+private:
+ QPixmap *sprites;
+ bool *in_game, *in_pause;
+ Sprite bg_sprite;
+ Sprite *mirror_sprites;
+
+protected:
+ void drawContents(QPainter *p);
+};
+
+#endif // !MIRRORWIDGET_H
diff --git a/ksmiletris/npiecewidget.cpp b/ksmiletris/npiecewidget.cpp
new file mode 100644
index 00000000..5df68f8e
--- /dev/null
+++ b/ksmiletris/npiecewidget.cpp
@@ -0,0 +1,63 @@
+/****************************************************************
+Copyright (c) 1998 Sandro Sigala <[email protected]>.
+All rights reserved.
+
+Permission to use, copy, modify, and distribute this software
+and its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of the author not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+The author disclaim all warranties with regard to this
+software, including all implied warranties of merchantability
+and fitness. In no event shall the author be liable for any
+special, indirect or consequential damages or any damages
+whatsoever resulting from loss of use, data or profits, whether
+in an action of contract, negligence or other tortious action,
+arising out of or in connection with the use or performance of
+this software.
+****************************************************************/
+
+#include "config.h"
+
+#include <qframe.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+
+#include "ksmiletris.h"
+#include "npiecewidget.h"
+
+NextPieceWidget::NextPieceWidget(QPixmap *s, bool *game, bool *pause,
+ QWidget *parent, const char *name)
+ : QFrame(parent, name)
+{
+ in_game = game;
+ in_pause = pause;
+ sprites = s;
+ setFrameStyle(QFrame::Box | QFrame::Raised);
+ setLineWidth(2);
+ setMidLineWidth(1);
+ resize(2 * sprite_width + 10, 2 * sprite_height + 10);
+}
+
+void NextPieceWidget::drawContents(QPainter *p)
+{
+ QRect r = contentsRect();
+
+ if (!*in_game) {
+ p->fillRect(r, black);
+ return;
+ }
+
+ p->drawPixmap(r.x(), r.y(),
+ sprites[next_piece_sprites[0]]);
+ p->drawPixmap(r.x()+sprite_width, r.y(),
+ sprites[next_piece_sprites[1]]);
+ p->drawPixmap(r.x(), r.y()+sprite_height,
+ sprites[next_piece_sprites[2]]);
+ p->drawPixmap(r.x()+sprite_width, r.y()+sprite_height,
+ sprites[next_piece_sprites[3]]);
+}
diff --git a/ksmiletris/npiecewidget.h b/ksmiletris/npiecewidget.h
new file mode 100644
index 00000000..66095e31
--- /dev/null
+++ b/ksmiletris/npiecewidget.h
@@ -0,0 +1,49 @@
+/****************************************************************
+Copyright (c) 1998 Sandro Sigala <[email protected]>.
+All rights reserved.
+
+Permission to use, copy, modify, and distribute this software
+and its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of the author not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+The author disclaim all warranties with regard to this
+software, including all implied warranties of merchantability
+and fitness. In no event shall the author be liable for any
+special, indirect or consequential damages or any damages
+whatsoever resulting from loss of use, data or profits, whether
+in an action of contract, negligence or other tortious action,
+arising out of or in connection with the use or performance of
+this software.
+****************************************************************/
+
+#ifndef NPIECEWIDGET_H
+#define NPIECEWIDGET_H
+
+#include <qframe.h>
+
+#include "ksmiletris.h"
+
+class NextPieceWidget : public QFrame {
+public:
+ NextPieceWidget(QPixmap *s, bool *game, bool *pause,
+ QWidget *parent=0, const char *name=0);
+
+ void setBackgroundSprite(Sprite s) { bg_sprite = s; }
+ void setNextPieceSprites(Sprite *s) { next_piece_sprites = s; }
+
+private:
+ QPixmap *sprites;
+ bool *in_game, *in_pause;
+ Sprite bg_sprite;
+ Sprite *next_piece_sprites;
+
+protected:
+ void drawContents(QPainter *p);
+};
+
+#endif // !NPIECEWIDGET_H
diff --git a/ksmiletris/screenwidget.cpp b/ksmiletris/screenwidget.cpp
new file mode 100644
index 00000000..0080aadd
--- /dev/null
+++ b/ksmiletris/screenwidget.cpp
@@ -0,0 +1,68 @@
+/****************************************************************
+Copyright (c) 1998 Sandro Sigala <[email protected]>.
+All rights reserved.
+
+Permission to use, copy, modify, and distribute this software
+and its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of the author not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+The author disclaim all warranties with regard to this
+software, including all implied warranties of merchantability
+and fitness. In no event shall the author be liable for any
+special, indirect or consequential damages or any damages
+whatsoever resulting from loss of use, data or profits, whether
+in an action of contract, negligence or other tortious action,
+arising out of or in connection with the use or performance of
+this software.
+****************************************************************/
+
+#include "config.h"
+
+#include <kapplication.h>
+#include <kstandarddirs.h>
+#include <qframe.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+
+#include "ksmiletris.h"
+#include "screenwidget.h"
+
+ScreenWidget::ScreenWidget(QPixmap *s, bool *game, bool *pause,
+ QWidget *parent, const char *name)
+ : QFrame(parent, name)
+{
+ in_game = game;
+ in_pause = pause;
+ sprites = s;
+ setFrameStyle(QFrame::Box | QFrame::Raised);
+ setLineWidth(2);
+ setMidLineWidth(1);
+ resize(scr_width * sprite_width + 10, scr_height * sprite_height + 10);
+}
+
+void ScreenWidget::drawContents(QPainter *p)
+{
+ QRect r = contentsRect();
+
+ if (!*in_game) {
+ p->fillRect(r, black);
+ return;
+ }
+
+ for (int y = 0; y < scr_height; ++y)
+ for (int x = 0; x < scr_width; ++x)
+ p->drawPixmap(r.x() + x*sprite_width,
+ r.y() + y*sprite_height,
+ sprites[screen_sprites[y*scr_width + x]]);
+
+ if (*in_pause) {
+ QPixmap pause(locate("appdata", "data/pause.bmp"));
+ p->drawPixmap((width()-pause.width())/2,
+ (height()-pause.height())/2, pause);
+ }
+}
diff --git a/ksmiletris/screenwidget.h b/ksmiletris/screenwidget.h
new file mode 100644
index 00000000..5643d7ed
--- /dev/null
+++ b/ksmiletris/screenwidget.h
@@ -0,0 +1,49 @@
+/****************************************************************
+Copyright (c) 1998 Sandro Sigala <[email protected]>.
+All rights reserved.
+
+Permission to use, copy, modify, and distribute this software
+and its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of the author not be used in
+advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+The author disclaim all warranties with regard to this
+software, including all implied warranties of merchantability
+and fitness. In no event shall the author be liable for any
+special, indirect or consequential damages or any damages
+whatsoever resulting from loss of use, data or profits, whether
+in an action of contract, negligence or other tortious action,
+arising out of or in connection with the use or performance of
+this software.
+****************************************************************/
+
+#ifndef SCREENWIDGET_H
+#define SCREENWIDGET_H
+
+#include <qframe.h>
+
+#include "ksmiletris.h"
+
+class ScreenWidget : public QFrame {
+public:
+ ScreenWidget(QPixmap *s, bool *game, bool *pause,
+ QWidget *parent=0, const char *name=0);
+
+ void setBackgroundSprite(Sprite s) { bg_sprite = s; }
+ void setScreenSprites(Sprite *s) { screen_sprites = s; }
+
+private:
+ QPixmap *sprites;
+ bool *in_game, *in_pause;
+ Sprite bg_sprite;
+ Sprite *screen_sprites;
+
+protected:
+ void drawContents(QPainter *p);
+};
+
+#endif // !SCREENWIDGET_H
diff --git a/ksmiletris/wav/Makefile.am b/ksmiletris/wav/Makefile.am
new file mode 100644
index 00000000..1eed07ad
--- /dev/null
+++ b/ksmiletris/wav/Makefile.am
@@ -0,0 +1,7 @@
+AUTOMAKE_OPTIONS = foreign
+
+sound_DATA = break.wav clear.wav
+
+sounddir = $(kde_datadir)/ksmiletris/sounds
+
+EXTRA_DIST = $(sound_DATA)
diff --git a/ksmiletris/wav/break.wav b/ksmiletris/wav/break.wav
new file mode 100644
index 00000000..a3596a20
--- /dev/null
+++ b/ksmiletris/wav/break.wav
Binary files differ
diff --git a/ksmiletris/wav/clear.wav b/ksmiletris/wav/clear.wav
new file mode 100644
index 00000000..dec7f26d
--- /dev/null
+++ b/ksmiletris/wav/clear.wav
Binary files differ