author | drw <drw> | 2005-05-20 21:23:29 (UTC) |
---|---|---|
committer | drw <drw> | 2005-05-20 21:23:29 (UTC) |
commit | dfdc651b989550e30f2b72f535ce0cd3431fc9f4 (patch) (unidiff) | |
tree | 1f5e64509fe2ef75a14c1909a8f981779b7b5acb | |
parent | 5e7bbe42671f565bef961b44862ddbf68beed774 (diff) | |
download | opie-dfdc651b989550e30f2b72f535ce0cd3431fc9f4.zip opie-dfdc651b989550e30f2b72f535ce0cd3431fc9f4.tar.gz opie-dfdc651b989550e30f2b72f535ce0cd3431fc9f4.tar.bz2 |
Resource -> OResource, remove some unnecessary includes
-rw-r--r-- | noncore/games/zsame/StoneWidget.cpp | 12 | ||||
-rw-r--r-- | noncore/games/zsame/ZSameWidget.cpp | 13 |
2 files changed, 8 insertions, 17 deletions
diff --git a/noncore/games/zsame/StoneWidget.cpp b/noncore/games/zsame/StoneWidget.cpp index 5dd0252..f370714 100644 --- a/noncore/games/zsame/StoneWidget.cpp +++ b/noncore/games/zsame/StoneWidget.cpp | |||
@@ -1,94 +1,88 @@ | |||
1 | /* | 1 | /* |
2 | * ksame 0.4 - simple Game | 2 | * ksame 0.4 - simple Game |
3 | * Copyright (C) 1997,1998 Marcus Kreutzberger | 3 | * Copyright (C) 1997,1998 Marcus Kreutzberger |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | * | 18 | * |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <stdio.h> | 21 | #include <opie2/oresource.h> |
22 | #include <stdlib.h> | ||
23 | 22 | ||
24 | 23 | #include <qbitmap.h> | |
25 | |||
26 | #include <qpe/resource.h> | ||
27 | 24 | ||
28 | #include <time.h> | 25 | #include <time.h> |
29 | #include <assert.h> | 26 | #include <assert.h> |
30 | 27 | ||
31 | #include "StoneWidget.h" | 28 | #include "StoneWidget.h" |
32 | 29 | ||
33 | 30 | ||
34 | 31 | ||
35 | struct StoneSlice { | 32 | struct StoneSlice { |
36 | QPixmap stone; | 33 | QPixmap stone; |
37 | }; | 34 | }; |
38 | 35 | ||
39 | 36 | ||
40 | StoneWidget::StoneWidget( QWidget *parent, int x, int y ) | 37 | StoneWidget::StoneWidget( QWidget *parent, int x, int y ) |
41 | : QWidget(parent,"StoneWidget"), stonefield(x,y) | 38 | : QWidget(parent,"StoneWidget"), stonefield(x,y) |
42 | { | 39 | { |
43 | // setBackgroundPixmap(QPixmap(locate("wallpaper", "Time-For-Lunch-2.jpg"))); | 40 | QPixmap stonemap = Opie::Core::OResource::loadPixmap( "zsame/stones" ); |
44 | // QPixmap stonemap(locate("appdata", "stones.png")); | ||
45 | |||
46 | QPixmap stonemap = Resource::loadPixmap("zsame/stones" ); | ||
47 | assert(!stonemap.isNull()); | 41 | assert(!stonemap.isNull()); |
48 | 42 | ||
49 | slice=0; | 43 | slice=0; |
50 | maxslices=30; | 44 | maxslices=30; |
51 | maxcolors=4; | 45 | maxcolors=4; |
52 | 46 | ||
53 | sizex=x; | 47 | sizex=x; |
54 | sizey=y; | 48 | sizey=y; |
55 | 49 | ||
56 | stone_width=stonemap.width()/(maxslices+1); | 50 | stone_width=stonemap.width()/(maxslices+1); |
57 | stone_height=stonemap.height()/maxcolors; | 51 | stone_height=stonemap.height()/maxcolors; |
58 | 52 | ||
59 | map = new StoneSlice*[maxcolors]; | 53 | map = new StoneSlice*[maxcolors]; |
60 | QBitmap mask; | 54 | QBitmap mask; |
61 | for (int c = 0; c < maxcolors; c++) { | 55 | for (int c = 0; c < maxcolors; c++) { |
62 | map[c] = new StoneSlice[maxslices]; | 56 | map[c] = new StoneSlice[maxslices]; |
63 | 57 | ||
64 | for (int s = 0; s < maxslices; s++) { | 58 | for (int s = 0; s < maxslices; s++) { |
65 | map[c][s].stone.resize(stone_width, stone_height); | 59 | map[c][s].stone.resize(stone_width, stone_height); |
66 | assert(!map[c][s].stone.isNull()); | 60 | assert(!map[c][s].stone.isNull()); |
67 | bitBlt(&map[c][s].stone, 0, 0, | 61 | bitBlt(&map[c][s].stone, 0, 0, |
68 | &stonemap, stone_width * s, | 62 | &stonemap, stone_width * s, |
69 | c*stone_height, | 63 | c*stone_height, |
70 | stone_width,stone_height,CopyROP,false); | 64 | stone_width,stone_height,CopyROP,false); |
71 | QImage im = map[c][s].stone.convertToImage(); | 65 | QImage im = map[c][s].stone.convertToImage(); |
72 | mask = im.createHeuristicMask(); | 66 | mask = im.createHeuristicMask(); |
73 | map[c][s].stone.setMask(mask); | 67 | map[c][s].stone.setMask(mask); |
74 | } | 68 | } |
75 | } | 69 | } |
76 | 70 | ||
77 | field_height=stone_height*sizey; | 71 | field_height=stone_height*sizey; |
78 | field_width=stone_width*sizex; | 72 | field_width=stone_width*sizex; |
79 | 73 | ||
80 | setMouseTracking(true); | 74 | setMouseTracking(true); |
81 | 75 | ||
82 | // QColor c(115,115,115); | 76 | // QColor c(115,115,115); |
83 | // setBackgroundColor(c); | 77 | // setBackgroundColor(c); |
84 | 78 | ||
85 | // emit s_sizechanged(); | 79 | // emit s_sizechanged(); |
86 | startTimer( 100 ); | 80 | startTimer( 100 ); |
87 | history.setAutoDelete(true); | 81 | history.setAutoDelete(true); |
88 | } | 82 | } |
89 | 83 | ||
90 | StoneWidget::~StoneWidget() { | 84 | StoneWidget::~StoneWidget() { |
91 | for (int c = 0; c < maxcolors; c++) { | 85 | for (int c = 0; c < maxcolors; c++) { |
92 | delete [] map[c]; | 86 | delete [] map[c]; |
93 | } | 87 | } |
94 | delete [] map; | 88 | delete [] map; |
diff --git a/noncore/games/zsame/ZSameWidget.cpp b/noncore/games/zsame/ZSameWidget.cpp index dee4a1c..7bcbee1 100644 --- a/noncore/games/zsame/ZSameWidget.cpp +++ b/noncore/games/zsame/ZSameWidget.cpp | |||
@@ -1,127 +1,124 @@ | |||
1 | /* Yo Emacs, this is -*- C++ -*- */ | 1 | /* Yo Emacs, this is -*- C++ -*- */ |
2 | /* | 2 | /* |
3 | * ksame 0.4 - simple Game | 3 | * ksame 0.4 - simple Game |
4 | * Copyright (C) 1997,1998 Marcus Kreutzberger | 4 | * Copyright (C) 1997,1998 Marcus Kreutzberger |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or | 8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. | 9 | * (at your option) any later version. |
10 | * | 10 | * |
11 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | * | 15 | * |
16 | * You should have received a copy of the GNU General Public License | 16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software | 17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <stdio.h> | ||
23 | |||
24 | #include <opie2/oapplicationfactory.h> | 22 | #include <opie2/oapplicationfactory.h> |
25 | 23 | #include <opie2/oresource.h> | |
26 | #include <qpe/resource.h> | ||
27 | 24 | ||
28 | #include <qtoolbar.h> | 25 | #include <qtoolbar.h> |
29 | #include <qmenubar.h> | 26 | #include <qmenubar.h> |
30 | #include <qapplication.h> | 27 | #include <qapplication.h> |
31 | #include <qaction.h> | 28 | #include <qaction.h> |
32 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
33 | 30 | ||
34 | #include <kapplication.h> | 31 | #include <kapplication.h> |
35 | 32 | ||
36 | #include "ZSameWidget.h" | 33 | #include "ZSameWidget.h" |
37 | 34 | ||
38 | static int default_colors=3; | 35 | static int default_colors=3; |
39 | 36 | ||
40 | #define i18n tr | 37 | #define i18n tr |
41 | 38 | ||
42 | 39 | ||
43 | using namespace Opie::Core; | 40 | using namespace Opie::Core; |
44 | OPIE_EXPORT_APP( OApplicationFactory<ZSameWidget> ) | 41 | OPIE_EXPORT_APP( OApplicationFactory<ZSameWidget> ) |
45 | 42 | ||
46 | 43 | ||
47 | 44 | ||
48 | ZSameWidget::ZSameWidget( QWidget* parent, const char* name, WFlags fl ) | 45 | ZSameWidget::ZSameWidget( QWidget* parent, const char* name, WFlags fl ) |
49 | : QMainWindow( parent, name, fl ) | 46 | : QMainWindow( parent, name, fl ) |
50 | { | 47 | { |
51 | setCaption(tr("ZSame")); | 48 | setCaption(tr("ZSame")); |
52 | 49 | ||
53 | setToolBarsMovable( false ); | 50 | setToolBarsMovable( false ); |
54 | QToolBar* con = new QToolBar( this ); | 51 | QToolBar* con = new QToolBar( this ); |
55 | con->setHorizontalStretchable( true ); | 52 | con->setHorizontalStretchable( true ); |
56 | QMenuBar* mb = new QMenuBar( con ); | 53 | QMenuBar* mb = new QMenuBar( con ); |
57 | QToolBar* tb = new QToolBar( this ); | 54 | QToolBar* tb = new QToolBar( this ); |
58 | 55 | ||
59 | QPopupMenu* fileMenu = new QPopupMenu( this ); | 56 | QPopupMenu* fileMenu = new QPopupMenu( this ); |
60 | 57 | ||
61 | QAction* a = new QAction(tr("New Game"), Resource::loadIconSet("new") , | 58 | QAction* a = new QAction(tr("New Game"), Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ), |
62 | QString::null, 0, this, "new_icon"); | 59 | QString::null, 0, this, "new_icon"); |
63 | a->addTo( fileMenu ); | 60 | a->addTo( fileMenu ); |
64 | a->addTo( tb ); | 61 | a->addTo( tb ); |
65 | connect(a, SIGNAL(activated()), this, SLOT(m_new())); | 62 | connect(a, SIGNAL(activated()), this, SLOT(m_new())); |
66 | 63 | ||
67 | a = new QAction(tr("Restart This Board"), Resource::loadIconSet("redo"), | 64 | a = new QAction(tr("Restart This Board"), Opie::Core::OResource::loadPixmap( "redo", Opie::Core::OResource::SmallIcon ), |
68 | QString::null, 0, this, "restart_board" ); | 65 | QString::null, 0, this, "restart_board" ); |
69 | a->addTo( fileMenu ); | 66 | a->addTo( fileMenu ); |
70 | connect( a, SIGNAL(activated()), this, SLOT(m_restart())); | 67 | connect( a, SIGNAL(activated()), this, SLOT(m_restart())); |
71 | restart = a; | 68 | restart = a; |
72 | 69 | ||
73 | a = new QAction( tr("Undo"), Resource::loadIconSet("undo"), | 70 | a = new QAction( tr("Undo"), Opie::Core::OResource::loadPixmap( "undo", Opie::Core::OResource::SmallIcon ), |
74 | QString::null, 0, this, "undo_action" ); | 71 | QString::null, 0, this, "undo_action" ); |
75 | a->addTo( fileMenu ); | 72 | a->addTo( fileMenu ); |
76 | a->addTo( tb ); | 73 | a->addTo( tb ); |
77 | connect( a, SIGNAL(activated()), this, SLOT(m_undo())); | 74 | connect( a, SIGNAL(activated()), this, SLOT(m_undo())); |
78 | 75 | ||
79 | a = new QAction(tr("Quit"), Resource::loadIconSet("quit_icon"), | 76 | a = new QAction(tr("Quit"), Opie::Core::OResource::loadPixmap( "quit_icon", Opie::Core::OResource::SmallIcon ), |
80 | QString::null, 0, this, "quit_action"); | 77 | QString::null, 0, this, "quit_action"); |
81 | a->addTo( fileMenu ); | 78 | a->addTo( fileMenu ); |
82 | a->addTo( tb ); | 79 | a->addTo( tb ); |
83 | connect(a, SIGNAL(activated()), this, SLOT(m_quit())); | 80 | connect(a, SIGNAL(activated()), this, SLOT(m_quit())); |
84 | 81 | ||
85 | mb->insertItem(tr("Game" ), fileMenu ); | 82 | mb->insertItem(tr("Game" ), fileMenu ); |
86 | 83 | ||
87 | int foo[2]; | 84 | int foo[2]; |
88 | desktop_widget(foo); | 85 | desktop_widget(foo); |
89 | stone = new StoneWidget(this,foo[0],foo[1]); | 86 | stone = new StoneWidget(this,foo[0],foo[1]); |
90 | 87 | ||
91 | connect( stone, SIGNAL(s_gameover()), this, SLOT(gameover())); | 88 | connect( stone, SIGNAL(s_gameover()), this, SLOT(gameover())); |
92 | 89 | ||
93 | connect( stone, SIGNAL(s_colors(int)), this, SLOT(setColors(int))); | 90 | connect( stone, SIGNAL(s_colors(int)), this, SLOT(setColors(int))); |
94 | connect( stone, SIGNAL(s_board(int)), this, SLOT(setBoard(int))); | 91 | connect( stone, SIGNAL(s_board(int)), this, SLOT(setBoard(int))); |
95 | connect( stone, SIGNAL(s_marked(int)), this, SLOT(setMarked(int))); | 92 | connect( stone, SIGNAL(s_marked(int)), this, SLOT(setMarked(int))); |
96 | connect( stone, SIGNAL(s_score(int)), this, SLOT(setScore(int))); | 93 | connect( stone, SIGNAL(s_score(int)), this, SLOT(setScore(int))); |
97 | connect( stone, SIGNAL(s_remove(int,int)), this, SLOT(stonesRemoved(int,int))); | 94 | connect( stone, SIGNAL(s_remove(int,int)), this, SLOT(stonesRemoved(int,int))); |
98 | 95 | ||
99 | connect(stone, SIGNAL(s_sizechanged()), this, SLOT(sizeChanged())); | 96 | connect(stone, SIGNAL(s_sizechanged()), this, SLOT(sizeChanged())); |
100 | 97 | ||
101 | sizeChanged(); | 98 | sizeChanged(); |
102 | setCentralWidget(stone); | 99 | setCentralWidget(stone); |
103 | 100 | ||
104 | 101 | ||
105 | setScore(0); | 102 | setScore(0); |
106 | } | 103 | } |
107 | 104 | ||
108 | ZSameWidget::~ZSameWidget() { | 105 | ZSameWidget::~ZSameWidget() { |
109 | 106 | ||
110 | } | 107 | } |
111 | 108 | ||
112 | void ZSameWidget::readProperties(Config *) { | 109 | void ZSameWidget::readProperties(Config *) { |
113 | /* | 110 | /* |
114 | Q_ASSERT(conf); | 111 | Q_ASSERT(conf); |
115 | stone->readProperties(conf); | 112 | stone->readProperties(conf); |
116 | */ | 113 | */ |
117 | } | 114 | } |
118 | 115 | ||
119 | void ZSameWidget::saveProperties(Config *) { | 116 | void ZSameWidget::saveProperties(Config *) { |
120 | /* | 117 | /* |
121 | Q_ASSERT(conf); | 118 | Q_ASSERT(conf); |
122 | stone->saveProperties(conf); | 119 | stone->saveProperties(conf); |
123 | conf->sync(); | 120 | conf->sync(); |
124 | */ | 121 | */ |
125 | } | 122 | } |
126 | 123 | ||
127 | void ZSameWidget::sizeChanged() { | 124 | void ZSameWidget::sizeChanged() { |