author | waspe <waspe> | 2003-05-16 16:34:55 (UTC) |
---|---|---|
committer | waspe <waspe> | 2003-05-16 16:34:55 (UTC) |
commit | 11b6ce5ac500dce757ccdd0a5f5b5ecd7fb866c8 (patch) (side-by-side diff) | |
tree | 3013dbafcb4e1f919e104204d1288f0309da5641 /noncore/games/backgammon | |
parent | 75f1e9815410e75a6f9ae76d8db716c0c315ea45 (diff) | |
download | opie-11b6ce5ac500dce757ccdd0a5f5b5ecd7fb866c8.zip opie-11b6ce5ac500dce757ccdd0a5f5b5ecd7fb866c8.tar.gz opie-11b6ce5ac500dce757ccdd0a5f5b5ecd7fb866c8.tar.bz2 |
*** empty log message ***
-rw-r--r-- | noncore/games/backgammon/backgammon.cpp | 131 | ||||
-rw-r--r-- | noncore/games/backgammon/backgammon.h | 30 | ||||
-rw-r--r-- | noncore/games/backgammon/backgammonview.cpp | 8 | ||||
-rw-r--r-- | noncore/games/backgammon/backgammonview.h | 8 | ||||
-rw-r--r-- | noncore/games/backgammon/definition.cpp | 1 | ||||
-rw-r--r-- | noncore/games/backgammon/displaydialog.cpp | 89 | ||||
-rw-r--r-- | noncore/games/backgammon/displaydialog.h | 30 | ||||
-rw-r--r-- | noncore/games/backgammon/moveengine.cpp | 2 | ||||
-rw-r--r-- | noncore/games/backgammon/moveengine.h | 2 | ||||
-rw-r--r-- | noncore/games/backgammon/rulesdialog.h | 1 |
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 @@ -3,3 +3,2 @@ #include "aidialog.h" -#include "displaydialog.h" #include "filedialog.h" @@ -11,2 +10,3 @@ #include <qfile.h> +#include <qlayout.h> #include <qmessagebox.h> @@ -14,2 +14,3 @@ #include <qtimer.h> +#include <qmainwindow.h> #include <qpe/qpeapplication.h> @@ -21,26 +22,5 @@ -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) { @@ -98,17 +78,2 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) - //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; @@ -165,22 +130,17 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) 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); @@ -250,4 +210,4 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) 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); @@ -255,4 +215,4 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) 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); @@ -262,4 +222,4 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) 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); @@ -267,4 +227,4 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) 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); @@ -277,4 +237,4 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) 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); @@ -289,6 +249,2 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) 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); @@ -297,3 +253,3 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) board->setZ(0); - board->setSize(235-2*offset,200-2*offset); + board->setSize(235-2,200-2); board->show(); @@ -302,11 +258,7 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) 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(); @@ -601,15 +553,2 @@ void BackGammon::setrules() -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"); -} @@ -618,3 +557,3 @@ void BackGammon::draw() Pieces pieces; - move->position(pieces,non_qte); + move->position(pieces); for(int a=0;a<15;a++) @@ -671,6 +610,6 @@ void BackGammon::mouse(int x,int y) - 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); @@ -687,3 +626,3 @@ void BackGammon::mouse(int x,int y) { - 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]); @@ -987,6 +926,2 @@ 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); @@ -994,6 +929,2 @@ void BackGammon::applytheme() QImage tablebg(Resource::loadImage("backgammon/table/"+table_name)); - if(non_qte) - { - tablebg=tablebg.copy(offset,0,235-offset,200); - } table->setImage(tablebg); 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 @@ -3,4 +3,4 @@ +#include "backgammonview.h" #include "canvasimageitem.h" -#include "definition.h" //#include "rulesdialog.h" @@ -8,21 +8,11 @@ -#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 { @@ -31,7 +21,4 @@ private: //GUI - //is the style not qte ? - bool non_qte; - int offset; //the "status" bar - QLineEdit* inputfield; + QLabel* message; //the main drawing area @@ -55,3 +42,3 @@ private: QCanvasRectangle* marker_next[4]; - QLabel* message; + //ENGINE @@ -115,3 +102,2 @@ private slots: void setrules(); - void displaySettings(); void mouse(int x,int y); 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 @@ -5,8 +5,14 @@ BackGammonView::BackGammonView(QCanvas* canvas,QWidget* parent) { + //do nothing } + + BackGammonView::~BackGammonView() { + //do nothing } + + void BackGammonView::contentsMousePressEvent(QMouseEvent* e) @@ -15,3 +21,3 @@ void BackGammonView::contentsMousePressEvent(QMouseEvent* e) 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,3 +1,3 @@ -#ifndef BACKGAMMONVIEW_H -#define BACKGAMMONVIEW_H +#ifndef BACKGAMMON_VIEW_H +#define BACKGAMMON_VIEW_H @@ -12,3 +12,3 @@ public: signals: - //void mousepressed(int,int); + void mouse(int,int); private: @@ -17,2 +17,2 @@ private: -#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 @@ -2,2 +2 @@ -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 @@ -6,4 +6,2 @@ -#include <stdlib.h> - MoveEngine::MoveEngine() 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 @@ -3,4 +3,4 @@ -#include <qobject.h> #include "definition.h" +#include <qobject.h> 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 @@ -7,3 +7,2 @@ - class RulesDialog : public QDialog |