00001 #include "playerdialog.h"
00002
00003 #include <qgroupbox.h>
00004
00005 #include <qpe/qpeapplication.h>
00006
00007 PlayerDialog::PlayerDialog(QWidget* parent,const char* name,bool modal,WFlags f)
00008 :QDialog(parent,name,modal,f)
00009 {
00010 auto2=false;
00011 auto2=true;
00012 setCaption("Player Settings");
00013
00014 QGroupBox* player1_box=new QGroupBox("Player 1",this);
00015 player1_box->setGeometry(10,30,220,60);
00016
00017 manual_button1=new QRadioButton("Human",player1_box);
00018 connect(manual_button1,SIGNAL(clicked()),this,SLOT(button_manual1()));
00019 manual_button1->setGeometry(10,20,100,20);
00020 auto_button1=new QRadioButton("Computer",player1_box);
00021 connect(auto_button1,SIGNAL(clicked()),this,SLOT(button_auto1()));
00022 auto_button1->setGeometry(110,20,100,20);
00023 button1_state(auto1);
00024
00025 QGroupBox* player2_box=new QGroupBox("Player 2",this);
00026 player2_box->setGeometry(10,150,220,60);
00027
00028 manual_button2=new QRadioButton("Human",player2_box);
00029 connect(manual_button2,SIGNAL(clicked()),this,SLOT(button_manual2()));
00030 manual_button2->setGeometry(10,20,100,20);
00031 auto_button2=new QRadioButton("Computer",player2_box);
00032 connect(auto_button2,SIGNAL(clicked()),this,SLOT(button_auto2()));
00033 auto_button2->setGeometry(110,20,100,20);
00034 button2_state(auto2);
00035
00036 QPEApplication::showDialog( this );
00037 }
00038
00039 PlayerDialog::~PlayerDialog()
00040 {}
00041
00042
00043 void PlayerDialog::button_manual1()
00044 {
00045 auto1=false;
00046 button1_state(auto1);
00047 }
00048
00049 void PlayerDialog::button_auto1()
00050 {
00051 auto1=true;
00052 button1_state(auto1);
00053 }
00054
00055 void PlayerDialog::button_manual2()
00056 {
00057 auto2=false;
00058 button2_state(auto2);
00059 }
00060
00061 void PlayerDialog::button_auto2()
00062 {
00063 auto2=true;
00064 button2_state(auto2);
00065 }
00066
00067 void PlayerDialog::button1_state(bool computer)
00068 {
00069 if(computer)
00070 {
00071 manual_button1->setChecked(false);
00072 auto_button1->setChecked(true);
00073 }
00074 else
00075 {
00076 manual_button1->setChecked(true);
00077 auto_button1->setChecked(false);
00078 }
00079 }
00080
00081 void PlayerDialog::button2_state(bool computer)
00082 {
00083 if(computer)
00084 {
00085 manual_button2->setChecked(false);
00086 auto_button2->setChecked(true);
00087 }
00088 else
00089 {
00090 manual_button2->setChecked(true);
00091 auto_button2->setChecked(false);
00092 }
00093 }
00094
00095
00096 void PlayerDialog::setAuto1(bool newstate)
00097 {
00098 auto1=newstate;
00099 button1_state(auto1);
00100 }
00101
00102 bool PlayerDialog::getAuto1()
00103 {
00104 return auto1;
00105 }
00106
00107 void PlayerDialog::setAuto2(bool newstate)
00108 {
00109 auto2=newstate;
00110 button2_state(auto2);
00111 }
00112
00113 bool PlayerDialog::getAuto2()
00114 {
00115 return auto2;
00116 }