summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/backgammon/backgammon.cpp131
-rw-r--r--noncore/games/backgammon/backgammon.h30
-rw-r--r--noncore/games/backgammon/backgammonview.cpp8
-rw-r--r--noncore/games/backgammon/backgammonview.h8
-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, 51 insertions, 251 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,7 +1,6 @@
#include "backgammon.h"
#include "aidialog.h"
-#include "displaydialog.h"
#include "filedialog.h"
#include "playerdialog.h"
#include "rulesdialog.h"
@@ -9,9 +8,11 @@
#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>
@@ -19,30 +20,9 @@
#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");
@@ -96,21 +76,6 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl)
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);
@@ -163,26 +128,21 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl)
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);
@@ -248,25 +208,25 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl)
{
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);
@@ -275,8 +235,8 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl)
{
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();
@@ -287,28 +247,20 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl)
//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
@@ -599,24 +551,11 @@ void BackGammon::setrules()
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)
@@ -669,10 +608,10 @@ void BackGammon::mouse(int x,int y)
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();
}
@@ -685,7 +624,7 @@ void BackGammon::mouse(int x,int y)
{
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();
}
@@ -985,17 +924,9 @@ void BackGammon::autoroll_dice2()
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));
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,39 +1,26 @@
#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;
@@ -53,7 +40,7 @@ private:
QCanvasRectangle* marker_current;
QCanvasRectangle* marker_next[4];
- QLabel* message;
+
//ENGINE
MoveEngine* move;
//the dice values
@@ -113,7 +100,6 @@ private slots:
void deletetheme();
void modify_AI();
void setrules();
- void displaySettings();
void mouse(int x,int y);
void done_dice1();
void done_dice2();
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
@@ -3,15 +3,21 @@
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 mousepressed(x,y);
+ emit mouse(x,y);
} \ No newline at end of file
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,5 +1,5 @@
-#ifndef BACKGAMMONVIEW_H
-#define BACKGAMMONVIEW_H
+#ifndef BACKGAMMON_VIEW_H
+#define BACKGAMMON_VIEW_H
#include <qcanvas.h>
@@ -10,9 +10,9 @@ public:
BackGammonView(QCanvas* canvas,QWidget* parent);
~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
@@ -4,8 +4,6 @@
#include <qtimer.h>
-#include <stdlib.h>
-
MoveEngine::MoveEngine()
: QObject()
{
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,8 +1,8 @@
#ifndef MOVEENGINE_H
#define MOVEENGINE_H
-#include <qobject.h>
#include "definition.h"
+#include <qobject.h>
class MoveEngine : public QObject
{
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
@@ -5,7 +5,6 @@
#include <qdialog.h>
#include "definition.h"
-
class RulesDialog : public QDialog
{
Q_OBJECT