Diffstat (limited to 'noncore/games/backgammon/backgammon.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/backgammon/backgammon.cpp | 131 |
1 files changed, 31 insertions, 100 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); |