summaryrefslogtreecommitdiff
authorwaspe <waspe>2003-05-16 16:34:55 (UTC)
committer waspe <waspe>2003-05-16 16:34:55 (UTC)
commit11b6ce5ac500dce757ccdd0a5f5b5ecd7fb866c8 (patch) (side-by-side diff)
tree3013dbafcb4e1f919e104204d1288f0309da5641
parent75f1e9815410e75a6f9ae76d8db716c0c315ea45 (diff)
downloadopie-11b6ce5ac500dce757ccdd0a5f5b5ecd7fb866c8.zip
opie-11b6ce5ac500dce757ccdd0a5f5b5ecd7fb866c8.tar.gz
opie-11b6ce5ac500dce757ccdd0a5f5b5ecd7fb866c8.tar.bz2
*** empty log message ***
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/backgammon/backgammon.cpp131
-rw-r--r--noncore/games/backgammon/backgammon.h32
-rw-r--r--noncore/games/backgammon/backgammonview.cpp14
-rw-r--r--noncore/games/backgammon/backgammonview.h10
-rw-r--r--noncore/games/backgammon/definition.cpp1
-rw-r--r--noncore/games/backgammon/displaydialog.cpp89
-rw-r--r--noncore/games/backgammon/displaydialog.h30
-rw-r--r--noncore/games/backgammon/moveengine.cpp2
-rw-r--r--noncore/games/backgammon/moveengine.h2
-rw-r--r--noncore/games/backgammon/rulesdialog.h1
10 files changed, 56 insertions, 256 deletions
diff --git a/noncore/games/backgammon/backgammon.cpp b/noncore/games/backgammon/backgammon.cpp
index 38ccb49..c40f462 100644
--- a/noncore/games/backgammon/backgammon.cpp
+++ b/noncore/games/backgammon/backgammon.cpp
@@ -1,51 +1,31 @@
#include "backgammon.h"
#include "aidialog.h"
-#include "displaydialog.h"
#include "filedialog.h"
#include "playerdialog.h"
#include "rulesdialog.h"
#include "themedialog.h"
#include <qdatetime.h>
#include <qfile.h>
+#include <qlayout.h>
#include <qmessagebox.h>
#include <qstring.h>
#include <qtimer.h>
+#include <qmainwindow.h>
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <qpe/qpemenubar.h>
#include <qpe/resource.h>
#include <stdlib.h>
-BackGammonView::BackGammonView(QCanvas* canvas,QWidget* parent)
- :QCanvasView(canvas,parent)
-{
- //do nothing
-}
-
-
-
-BackGammonView::~BackGammonView()
-{
- //do nothing
-}
-
-
-
-void BackGammonView::contentsMousePressEvent(QMouseEvent* e)
-{
- int x=e->x();
- int y=e->y();
- emit mouse(x,y);
-}
BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl)
- : QWidget(parent, name, fl)
+ : QMainWindow(parent, name, fl)
{
if (!name) setName("BackGammon");
setCaption("Backgammon");
setIcon( Resource::loadPixmap( "backgammon" ) );
//general counter varaible
int a=0;
@@ -93,27 +73,12 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl)
ai.expose=conf.readNumEntry("expose",1);
ai.protect=conf.readNumEntry("protect",5);
ai.safe=conf.readNumEntry("safe",3);
ai.empty=conf.readNumEntry("empty",2);
move->setAISettings(ai);
- //non qte styles are smaller
- conf.setGroup("display");
- display.small=conf.readBoolEntry("small",false);
- display.warning=conf.readBoolEntry("warning",true);
- non_qte=display.small;
- if(display.warning)
- {
- Config test("qpe");
- test.setGroup("Appearance");
- if(test.readEntry("Style")!="QPE")
- {
- displaySettings();
- }
- }
- offset=(non_qte) ? 5 : 0;
//get the theme component names
Config theme(theme_file,Config::File);
if(!theme.isValid())
{
qDebug("theme file does not exist");
@@ -160,32 +125,27 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl)
QPopupMenu* optionmenu=new QPopupMenu(this);
optionmenu->insertItem("Player",this,SLOT(playerselect()));
optionmenu->insertSeparator();
optionmenu->insertItem("AI",this,SLOT(modify_AI()));
optionmenu->insertItem("Rules",this,SLOT(setrules()));
- optionmenu->insertItem("Display",this,SLOT(displaySettings()));
menuBar->insertItem("Options",optionmenu);
- //status bar
- message=new QLabel("<b>Backgammon</b>",this);
- message->setGeometry(0,260,237,20);
- message->setAlignment(AlignHCenter);
-
+ QWidget* mainarea=new QWidget(this);
+ setCentralWidget(mainarea);
//the main area
- area=new QCanvas(235-2*offset,235-2*offset);
- boardview=new BackGammonView(area,this);
+ QBoxLayout* layout=new QBoxLayout(mainarea,QBoxLayout::TopToBottom);
+ area=new QCanvas(235,235);
+ boardview=new BackGammonView(area,mainarea);
+ boardview->setMaximumHeight(240);
+ layout->addWidget(boardview);
connect(boardview,SIGNAL(mouse(int,int)),this,SLOT(mouse(int,int)));
- if(non_qte)
- {
- boardview->setGeometry(5,20,229,229);
- }
- else
- {
- boardview->setGeometry(1,20,237,237);
- }
+ //status bar
+ message=new QLabel("<b>Backgammon</b>",mainarea);
+ message->setAlignment(AlignHCenter);
+ layout->addWidget(message);
//the marker
marker_current=new QCanvasRectangle(area);
marker_current->setBrush(QColor(0,0,255));
marker_current->setSize(15,5);
marker_current->setZ(1);
@@ -245,73 +205,65 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl)
for(a=0;a<7;a++)
{
QImage dicebgA=dicebgA_all.copy(a*25,0,25,25);
diceA1[a]=new CanvasImageItem(dicebgA,area);
- diceA1[a]->setX(5-offset);
- diceA1[a]->setY(205-2*offset);
+ diceA1[a]->setX(5);
+ diceA1[a]->setY(205-2);
diceA1[a]->setZ(1);
diceA1[a]->setSize(25,25);
diceA2[a]=new CanvasImageItem(dicebgA,area);
- diceA2[a]->setX(35-offset);
- diceA2[a]->setY(205-2*offset);
+ diceA2[a]->setX(35);
+ diceA2[a]->setY(205-2);
diceA2[a]->setZ(1);
diceA2[a]->setSize(25,25);
QImage dicebgB=dicebgB_all.copy(a*25,0,25,25);
diceB1[a]=new CanvasImageItem(dicebgB,area);
- diceB1[a]->setX(175-offset);
- diceB1[a]->setY(205-2*offset);
+ diceB1[a]->setX(175);
+ diceB1[a]->setY(205-2);
diceB1[a]->setZ(1);
diceB1[a]->setSize(25,25);
diceB2[a]=new CanvasImageItem(dicebgB,area);
- diceB2[a]->setX(205-offset);
- diceB2[a]->setY(205-2*offset);
+ diceB2[a]->setX(205);
+ diceB2[a]->setY(205-2);
diceB2[a]->setZ(1);
diceB2[a]->setSize(25,25);
/*
if(a<6)
{
QImage oddsbg=oddsbg_all.copy(a*15,0,15,15);
oddsDice[a]=new CanvasImageItem(oddsbg,area);
- oddsDice[a]->setX(110-offset);
- oddsDice[a]->setY(210-2*offset);
+ oddsDice[a]->setX(110);
+ oddsDice[a]->setY(210-2);
oddsDice[a]->setZ(1);
oddsDice[a]->setSize(15,15);
oddsDice[a]->hide();
}
*/
}
//oddsDice[0]->show();
//set the board
QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name));
- if(non_qte)
- {
- boardbg=boardbg.copy(offset,offset,235-2*offset,200-2*offset);
- }
board=new CanvasImageItem(boardbg,area);
board->setX(0);
board->setY(0);
board->setZ(0);
- board->setSize(235-2*offset,200-2*offset);
+ board->setSize(235-2,200-2);
board->show();
//the table
QImage tablebg(Resource::loadImage("backgammon/table/"+table_name));
- if(non_qte)
- {
- tablebg=tablebg.copy(offset,0,235-offset,200);
- }
table=new CanvasImageItem(tablebg,area);
table->setX(0);
- table->setY(200-2*offset);
+ table->setY(200-2);
table->setZ(0);
- table->setSize(235-2*offset,20);
+ table->setSize(235-2,20);
table->show();
//the no move marker
QImage nomovebg(Resource::loadImage("backgammon/no_move"));
nomove_marker=new CanvasImageItem(nomovebg,area);
nomove_marker->setX(0);
@@ -596,30 +548,17 @@ void BackGammon::setrules()
conf.setGroup("rules");
conf.writeEntry("move_with_pieces_out",rules.move_with_pieces_out);
conf.writeEntry("nice_dice",rules.generous_dice);
move->setRules(rules);
}
-void BackGammon::displaySettings()
-{
- DisplayDialog* displaydialog=new DisplayDialog(this);
- displaydialog->setDisplaySettings(display);
- if(!displaydialog->exec())
- return;
- display=displaydialog->getDisplaySettings();
- Config conf("backgammon");
- conf.setGroup("display");
- conf.writeEntry("small",display.small);
- conf.writeEntry("warning",display.warning);
- QMessageBox::warning(this,"Backgammon","changed display settings will\nonly take place after game has\nbeen restarted","OK");
-}
void BackGammon::draw()
{
Pieces pieces;
- move->position(pieces,non_qte);
+ move->position(pieces);
for(int a=0;a<15;a++)
{
if(!pieces.player1[a].side)
{
p1[a]->setX(pieces.player1[a].x);
p1[a]->setY(pieces.player1[a].y);
@@ -666,29 +605,29 @@ void BackGammon::mouse(int x,int y)
{
if((player==1 && player1_auto) || (player==2 && player2_auto))
return;
Marker marker;
- move->boardpressed(x,y,marker,non_qte);
+ move->boardpressed(x,y,marker);
if(marker.visible_current)
{
- marker_current->setX(marker.x_current-offset);
+ marker_current->setX(marker.x_current);
marker_current->setY(marker.y_current);
marker_current->show();
}
else
{
marker_current->hide();
}
for(int a=0;a<4;a++)
{
if(marker.visible_next[a])
{
- marker_next[a]->setX(marker.x_next[a]-offset);
+ marker_next[a]->setX(marker.x_next[a]);
marker_next[a]->setY(marker.y_next[a]);
marker_next[a]->show();
}
else
{
marker_next[a]->hide();
@@ -982,23 +921,15 @@ void BackGammon::autoroll_dice2()
mouse(170,210);
}
void BackGammon::applytheme()
{
QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name));
- if(non_qte)
- {
- boardbg=boardbg.copy(offset,offset,235-2*offset,200-2*offset);
- }
board->setImage(boardbg);
QImage tablebg(Resource::loadImage("backgammon/table/"+table_name));
- if(non_qte)
- {
- tablebg=tablebg.copy(offset,0,235-offset,200);
- }
table->setImage(tablebg);
QImage piece_1_all(Resource::loadImage("backgammon/pieces/"+piecesA_name));
QImage piece_1_front=piece_1_all.copy(0,0,15,15);
QImage piece_1_side=piece_1_all.copy(0,15,15,5);
diff --git a/noncore/games/backgammon/backgammon.h b/noncore/games/backgammon/backgammon.h
index 40dbaba..e3276f1 100644
--- a/noncore/games/backgammon/backgammon.h
+++ b/noncore/games/backgammon/backgammon.h
@@ -1,42 +1,29 @@
#ifndef BACKGAMMON_H
#define BACKGAMMON_H
+#include "backgammonview.h"
#include "canvasimageitem.h"
-#include "definition.h"
//#include "rulesdialog.h"
#include "moveengine.h"
-#include <qcanvas.h>
+
#include <qlabel.h>
-#include <qlineedit.h>
-#include <qwidget.h>
+#include <qmainwindow.h>
+//#include <qwidget.h>
-class BackGammonView : public QCanvasView
-{
- Q_OBJECT
-public:
- BackGammonView(QCanvas* canvas,QWidget* parent);
- ~BackGammonView();
-signals:
- void mouse(int,int);
-private:
- void contentsMousePressEvent(QMouseEvent* e);
-};
-class BackGammon : public QWidget
+
+class BackGammon : public QMainWindow
{
Q_OBJECT
private:
//GUI
- //is the style not qte ?
- bool non_qte;
- int offset;
//the "status" bar
- QLineEdit* inputfield;
+ QLabel* message;
//the main drawing area
QCanvas* area;
BackGammonView* boardview;
CanvasImageItem* board;
CanvasImageItem* table;
CanvasImageItem** p1;
@@ -47,16 +34,16 @@ private:
CanvasImageItem** diceA1;
CanvasImageItem** diceA2;
CanvasImageItem** diceB1;
CanvasImageItem** diceB2;
//CanvasImageItem** oddsDice;
CanvasImageItem* nomove_marker;
-
+
QCanvasRectangle* marker_current;
QCanvasRectangle* marker_next[4];
- QLabel* message;
+
//ENGINE
MoveEngine* move;
//the dice values
int diceA1_value;
int diceA2_value;
int diceA3_value;
@@ -110,13 +97,12 @@ private slots:
void loadtheme();
void savetheme();
void themedefault();
void deletetheme();
void modify_AI();
void setrules();
- void displaySettings();
void mouse(int x,int y);
void done_dice1();
void done_dice2();
void done_dice3();
void done_dice4();
void nomove();
diff --git a/noncore/games/backgammon/backgammonview.cpp b/noncore/games/backgammon/backgammonview.cpp
index ecbc12b..6ee8f10 100644
--- a/noncore/games/backgammon/backgammonview.cpp
+++ b/noncore/games/backgammon/backgammonview.cpp
@@ -1,17 +1,23 @@
#include "backgammonview.h"
BackGammonView::BackGammonView(QCanvas* canvas,QWidget* parent)
- :QCanvasView(canvas,parent)
+ :QCanvasView(canvas,parent)
{
+ //do nothing
}
+
+
BackGammonView::~BackGammonView()
{
+ //do nothing
}
+
+
void BackGammonView::contentsMousePressEvent(QMouseEvent* e)
{
int x=e->x();
- int y=e->y();
- //emit mousepressed(x,y);
-} \ No newline at end of file
+ int y=e->y();
+ emit mouse(x,y);
+}
diff --git a/noncore/games/backgammon/backgammonview.h b/noncore/games/backgammon/backgammonview.h
index e50f2b0..52508e2 100644
--- a/noncore/games/backgammon/backgammonview.h
+++ b/noncore/games/backgammon/backgammonview.h
@@ -1,18 +1,18 @@
-#ifndef BACKGAMMONVIEW_H
-#define BACKGAMMONVIEW_H
+#ifndef BACKGAMMON_VIEW_H
+#define BACKGAMMON_VIEW_H
#include <qcanvas.h>
class BackGammonView : public QCanvasView
{
Q_OBJECT
public:
BackGammonView(QCanvas* canvas,QWidget* parent);
- ~BackGammonView();
+ ~BackGammonView();
signals:
- //void mousepressed(int,int);
+ void mouse(int,int);
private:
void contentsMousePressEvent(QMouseEvent* e);
};
-#endif //BACKGAMMONVIEW_H \ No newline at end of file
+#endif //BACKGAMMON_VIEW_H \ No newline at end of file
diff --git a/noncore/games/backgammon/definition.cpp b/noncore/games/backgammon/definition.cpp
index 9e0029d..c036319 100644
--- a/noncore/games/backgammon/definition.cpp
+++ b/noncore/games/backgammon/definition.cpp
@@ -1,3 +1,2 @@
#include "definition.h"
-static bool debug=false;
diff --git a/noncore/games/backgammon/displaydialog.cpp b/noncore/games/backgammon/displaydialog.cpp
deleted file mode 100644
index 8b97545..0000000
--- a/noncore/games/backgammon/displaydialog.cpp
+++ b/dev/null
@@ -1,89 +0,0 @@
-#include "displaydialog.h"
-
-#include <qgroupbox.h>
-#include <qlabel.h>
-
-DisplayDialog::DisplayDialog(QWidget* parent,const char* name,bool modal,WFlags f)
- : QDialog(parent,name,modal,f)
-{
- setCaption("Display Configuration");
- QLabel* header=new QLabel("<b>Change the display settings</b>",this);
- header->setGeometry(10,10,200,20);
-
- //
- QGroupBox* settings_frame=new QGroupBox("Settings",this);
- settings_frame->setGeometry(10,10,220,120);
-
- small_box=new QRadioButton("Big display, e.g. for QPE Style",settings_frame);
- small_box->setGeometry(10,20,200,20);
- connect(small_box,SIGNAL(clicked()),this,SLOT(small_clicked()));
-
- big_box=new QRadioButton("Small display, e.g. for Windows Style",settings_frame);
- big_box->setGeometry(10,50,200,20);
- connect(big_box,SIGNAL(clicked()),this,SLOT(big_clicked()));
-
- //
- QGroupBox* warning_frame=new QGroupBox("Warning",this);
- warning_frame->setGeometry(10,140,220,120);
-
- warning_box=new QCheckBox("show style warning",warning_frame);
- warning_box->setGeometry(10,20,200,20);
- connect(warning_box,SIGNAL(clicked()),this,SLOT(warning_clicked()));
-
- QLabel* warning_help=new QLabel("show style warning at statup if the system style is not QPE\nif not set to small you may have\nscrollbars on the palying area",warning_frame);
- warning_help->setGeometry(10,50,200,60);
-
- showMaximized();
-}
-
-
-DisplayDialog::~DisplayDialog()
-{
-}
-
-void DisplayDialog::big_clicked()
-{
- big_box->setChecked(true);
- small_box->setChecked(false);
-}
-
-void DisplayDialog::small_clicked()
-{
- big_box->setChecked(false);
- small_box->setChecked(true);
-}
-
-void DisplayDialog::warning_clicked()
-{
-}
-
-void DisplayDialog::setDisplaySettings(const Display& display)
-{
- if(!display.small)
- {
- big_box->setChecked(false);
- small_box->setChecked(true);
- }
- else
- {
- big_box->setChecked(true);
- small_box->setChecked(false);
- }
- if(display.warning)
- warning_box->setChecked(true);
- else
- warning_box->setChecked(false);
-
-}
-
-Display DisplayDialog::getDisplaySettings()
-{
- Display display;
- display.small=!small_box->isChecked();
- display.warning=warning_box->isChecked();
- return display;
-}
-
-
-
-
diff --git a/noncore/games/backgammon/displaydialog.h b/noncore/games/backgammon/displaydialog.h
deleted file mode 100644
index 26b77f0..0000000
--- a/noncore/games/backgammon/displaydialog.h
+++ b/dev/null
@@ -1,30 +0,0 @@
-#ifndef DISPLAYDLAOG_H
-#define DISPLAYDLAOG_H
-
-#include <qcheckbox.h>
-#include <qdialog.h>
-#include <qradiobutton.h>
-
-#include "definition.h"
-
-
-class DisplayDialog : public QDialog
-{
- Q_OBJECT
-private:
- QRadioButton* small_box;
- QRadioButton* big_box;
- QCheckBox* warning_box;
-public:
- DisplayDialog(QWidget* parent=0,const char* name=0,bool modal=TRUE,WFlags f=0);
- ~DisplayDialog();
-private slots:
- void big_clicked();
- void small_clicked();
- void warning_clicked();
-public:
- void setDisplaySettings(const Display& display);
- Display getDisplaySettings();
-};
-
-#endif //DISPLAYDLAOG_H
diff --git a/noncore/games/backgammon/moveengine.cpp b/noncore/games/backgammon/moveengine.cpp
index 8106b3f..009c449 100644
--- a/noncore/games/backgammon/moveengine.cpp
+++ b/noncore/games/backgammon/moveengine.cpp
@@ -1,14 +1,12 @@
#include "moveengine.h"
#include <qmessagebox.h>
#include <qtimer.h>
-#include <stdlib.h>
-
MoveEngine::MoveEngine()
: QObject()
{
int offset=7;
int a=0; //counter variable
int xfill[]={210,185,170,155,140,125,110,85,70,55,40,25,10,10,25,40,55,70,85,110,125,140,155,170,185,210};
diff --git a/noncore/games/backgammon/moveengine.h b/noncore/games/backgammon/moveengine.h
index a2d4a52..4c39a04 100644
--- a/noncore/games/backgammon/moveengine.h
+++ b/noncore/games/backgammon/moveengine.h
@@ -1,11 +1,11 @@
#ifndef MOVEENGINE_H
#define MOVEENGINE_H
-#include <qobject.h>
#include "definition.h"
+#include <qobject.h>
class MoveEngine : public QObject
{
Q_OBJECT
private:
//normal pieses
diff --git a/noncore/games/backgammon/rulesdialog.h b/noncore/games/backgammon/rulesdialog.h
index 9269a0e..f11a28c 100644
--- a/noncore/games/backgammon/rulesdialog.h
+++ b/noncore/games/backgammon/rulesdialog.h
@@ -2,13 +2,12 @@
#define RULESDIALOG_H_
#include <qcheckbox.h>
#include <qdialog.h>
#include "definition.h"
-
class RulesDialog : public QDialog
{
Q_OBJECT
private:
QCheckBox* pieces_out;
QCheckBox* nice_dice;