Diffstat (limited to 'noncore/games/backgammon/playerdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/backgammon/playerdialog.cpp | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/noncore/games/backgammon/playerdialog.cpp b/noncore/games/backgammon/playerdialog.cpp new file mode 100644 index 0000000..c16f202 --- a/dev/null +++ b/noncore/games/backgammon/playerdialog.cpp | |||
@@ -0,0 +1,114 @@ | |||
1 | #include "playerdialog.h" | ||
2 | |||
3 | #include <qgroupbox.h> | ||
4 | |||
5 | PlayerDialog::PlayerDialog(QWidget* parent,const char* name,bool modal,WFlags f) | ||
6 | :QDialog(parent,name,modal,f) | ||
7 | { | ||
8 | auto2=false; | ||
9 | auto2=true; | ||
10 | setCaption("Player Settings"); | ||
11 | |||
12 | QGroupBox* player1_box=new QGroupBox("Player 1",this); | ||
13 | player1_box->setGeometry(10,30,220,60); | ||
14 | |||
15 | manual_button1=new QRadioButton("Human",player1_box); | ||
16 | connect(manual_button1,SIGNAL(clicked()),this,SLOT(button_manual1())); | ||
17 | manual_button1->setGeometry(10,20,100,20); | ||
18 | auto_button1=new QRadioButton("Computer",player1_box); | ||
19 | connect(auto_button1,SIGNAL(clicked()),this,SLOT(button_auto1())); | ||
20 | auto_button1->setGeometry(110,20,100,20); | ||
21 | button1_state(auto1); | ||
22 | |||
23 | QGroupBox* player2_box=new QGroupBox("Player 2",this); | ||
24 | player2_box->setGeometry(10,150,220,60); | ||
25 | |||
26 | manual_button2=new QRadioButton("Human",player2_box); | ||
27 | connect(manual_button2,SIGNAL(clicked()),this,SLOT(button_manual2())); | ||
28 | manual_button2->setGeometry(10,20,100,20); | ||
29 | auto_button2=new QRadioButton("Computer",player2_box); | ||
30 | connect(auto_button2,SIGNAL(clicked()),this,SLOT(button_auto2())); | ||
31 | auto_button2->setGeometry(110,20,100,20); | ||
32 | button2_state(auto2); | ||
33 | |||
34 | showMaximized(); | ||
35 | } | ||
36 | |||
37 | PlayerDialog::~PlayerDialog() | ||
38 | {} | ||
39 | |||
40 | |||
41 | void PlayerDialog::button_manual1() | ||
42 | { | ||
43 | auto1=false; | ||
44 | button1_state(auto1); | ||
45 | } | ||
46 | |||
47 | void PlayerDialog::button_auto1() | ||
48 | { | ||
49 | auto1=true; | ||
50 | button1_state(auto1); | ||
51 | } | ||
52 | |||
53 | void PlayerDialog::button_manual2() | ||
54 | { | ||
55 | auto2=false; | ||
56 | button2_state(auto2); | ||
57 | } | ||
58 | |||
59 | void PlayerDialog::button_auto2() | ||
60 | { | ||
61 | auto2=true; | ||
62 | button2_state(auto2); | ||
63 | } | ||
64 | |||
65 | void PlayerDialog::button1_state(bool computer) | ||
66 | { | ||
67 | if(computer) | ||
68 | { | ||
69 | manual_button1->setChecked(false); | ||
70 | auto_button1->setChecked(true); | ||
71 | } | ||
72 | else | ||
73 | { | ||
74 | manual_button1->setChecked(true); | ||
75 | auto_button1->setChecked(false); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | void PlayerDialog::button2_state(bool computer) | ||
80 | { | ||
81 | if(computer) | ||
82 | { | ||
83 | manual_button2->setChecked(false); | ||
84 | auto_button2->setChecked(true); | ||
85 | } | ||
86 | else | ||
87 | { | ||
88 | manual_button2->setChecked(true); | ||
89 | auto_button2->setChecked(false); | ||
90 | } | ||
91 | } | ||
92 | |||
93 | |||
94 | void PlayerDialog::setAuto1(bool newstate) | ||
95 | { | ||
96 | auto1=newstate; | ||
97 | button1_state(auto1); | ||
98 | } | ||
99 | |||
100 | bool PlayerDialog::getAuto1() | ||
101 | { | ||
102 | return auto1; | ||
103 | } | ||
104 | |||
105 | void PlayerDialog::setAuto2(bool newstate) | ||
106 | { | ||
107 | auto2=newstate; | ||
108 | button2_state(auto2); | ||
109 | } | ||
110 | |||
111 | bool PlayerDialog::getAuto2() | ||
112 | { | ||
113 | return auto2; | ||
114 | } | ||