32 , m_lastFixedHandicap(
Preferences::fixedHandicapValue())
37 startButton->setIcon(KIcon(
QLatin1String(
"media-playback-start" )));
39 whiteStoneImageLabel->setPixmap(whiteStone);
41 blackStoneImageLabel->setPixmap(blackStone);
44 connect(whiteIsComputerCheckBox, SIGNAL(toggled(
bool)),
this, SLOT(whiteIsComputer(
bool)));
45 connect(blackIsComputerCheckBox, SIGNAL(toggled(
bool)),
this, SLOT(blackIsComputer(
bool)));
46 connect(sizeSmall, SIGNAL(clicked(
bool)),
this, SLOT(on_boardSize_changed()));
47 connect(sizeMedium, SIGNAL(clicked(
bool)),
this, SLOT(on_boardSize_changed()));
48 connect(sizeBig, SIGNAL(clicked(
bool)),
this, SLOT(on_boardSize_changed()));
49 connect(sizeOther, SIGNAL(clicked(
bool)),
this, SLOT(on_boardSize_changed()));
50 connect(sizeOtherSpinBox, SIGNAL(valueChanged(
int)),
this, SLOT(on_boardSize_changed()));
62 gameSetupStack->setCurrentIndex(0);
64 handicapSpinBox->setSuffix(ki18np(
" Stone",
" Stones"));
73 gameSetupStack->setCurrentIndex(1);
74 m_game->
init(fileName);
75 m_lastFileName = fileName;
78 if (!file.
open(QIODevice::ReadOnly | QIODevice::Text)) {
90 eventLabel->setText(re.
cap(1));
91 eventLabel->setVisible(
true);
92 eventStaticLabel->setVisible(
true);
94 eventLabel->setVisible(
false);
95 eventStaticLabel->setVisible(
false);
100 locationLabel->setText(re.
cap(1));
101 locationLabel->setVisible(
true);
102 locationStaticLabel->setVisible(
true);
104 locationLabel->setVisible(
false);
105 locationStaticLabel->setVisible(
false);
109 if (re.
indexIn(content) > -1) {
110 roundLabel->setText(re.
cap(1));
111 roundLabel->setVisible(
true);
112 roundStaticLabel->setVisible(
true);
114 roundLabel->setVisible(
false);
115 roundStaticLabel->setVisible(
false);
118 if (re.
indexIn(content) > -1) {
119 dateLabel->setText(re.
cap(1));
120 dateLabel->setVisible(
true);
121 dateStaticLabel->setVisible(
true);
123 dateLabel->setVisible(
false);
124 dateStaticLabel->setVisible(
false);
128 if (re.
indexIn(content) > -1) {
129 blackPlayerName->setText(re.
cap(1));
132 if (re.
indexIn(content) > -1) {
133 blackPlayerName->setText(blackPlayerName->text() +
" (" + re.
cap(1) +
')');
136 if (re.
indexIn(content) > -1) {
137 blackPlayerName->setText(blackPlayerName->text() +
" [" + re.
cap(1) +
']');
141 if (re.
indexIn(content) > -1) {
142 whitePlayerName->setText(re.
cap(1));
145 if (re.
indexIn(content) > -1) {
146 whitePlayerName->setText(whitePlayerName->text() +
" (" + re.
cap(1) +
')');
149 if (re.
indexIn(content) > -1) {
150 whitePlayerName->setText(whitePlayerName->text() +
" [" + re.
cap(1) +
']');
154 if (re.
indexIn(content) > -1) {
155 komiLabel->setText(re.
cap(1));
156 komiLabel->setVisible(
true);
157 komiStaticLabel->setVisible(
true);
159 komiLabel->setVisible(
false);
160 komiStaticLabel->setVisible(
false);
164 if (re.
indexIn(content) > -1) {
166 int hours = seconds/3600;
167 int minutes = (seconds/60)%60;
168 QString minuteString = i18ncp(
"Time limit of a game in minutes",
"%1 minute",
"%1 minutes", minutes);
170 timeLabel->setText(i18ncp(
"Time limit of a game, hours, minutes",
"%1 hour, %2",
"%1 hours, %2", hours, minuteString));
172 timeLabel->setText(minuteString);
174 timeLabel->setVisible(
true);
175 timeStaticLabel->setVisible(
true);
177 timeLabel->setVisible(
false);
178 timeStaticLabel->setVisible(
false);
182 if (re.
indexIn(content) > -1) {
183 scoreLabel->setText(re.
cap(1));
184 scoreLabel->setVisible(
true);
185 scoreStaticLabel->setVisible(
true);
187 scoreLabel->setVisible(
false);
188 scoreStaticLabel->setVisible(
false);
192 startMoveSpinBox->setSuffix(i18n(
" of %1", count));
193 startMoveSpinBox->setMaximum(count);
194 startMoveSpinBox->setValue(count);
195 startMoveSpinBox->setFocus(Qt::OtherFocusReason);
196 connect(startMoveSpinBox, SIGNAL(valueChanged(
int)),
this, SLOT(on_startMoveSpinBox_valueChanged(
int)));
220 if (gameSetupStack->currentIndex() == 0) {
228 void SetupWidget::on_startMoveSpinBox_valueChanged(
int value)
230 if (!m_lastFileName.
isEmpty()) {
231 m_game->
init(m_lastFileName, value);
235 playerLabel->setText(i18n(
"White to play"));
237 playerLabel->setText(i18n(
"Black to play"));
239 playerLabel->setText(
"");
243 void SetupWidget::on_boardSize_changed()
245 if (sizeOther->isChecked()) {
246 sizeOtherSpinBox->setEnabled(
true);
249 sizeOtherSpinBox->setEnabled(
false);
250 if (sizeSmall->isChecked()) {
252 }
else if (sizeMedium->isChecked()) {
254 }
else if (sizeBig->isChecked()) {
261 void SetupWidget::on_handicapSpinBox_valueChanged(
int value)
263 m_lastFixedHandicap = value;
268 void SetupWidget::updateHandicapBox()
271 handicapSpinBox->setEnabled(maxFixedHandicap > 0);
272 handicapSpinBox->setMaximum(maxFixedHandicap);
273 handicapSpinBox->setValue(m_lastFixedHandicap);
274 on_handicapSpinBox_valueChanged(handicapSpinBox->value());
277 void SetupWidget::loadSettings()
292 sizeSmall->setChecked(
true);
295 sizeMedium->setChecked(
true);
298 sizeBig->setChecked(
true);
301 sizeOther->setChecked(
true);
302 sizeOtherSpinBox->setEnabled(
true);
308 void SetupWidget::saveSettings()
310 if (gameSetupStack->currentIndex() == 0) {
326 if (sizeSmall->isChecked()) {
328 }
else if (sizeMedium->isChecked()) {
330 }
else if (sizeBig->isChecked()) {
332 }
else if (sizeOther->isChecked()) {
338 void SetupWidget::blackIsComputer(
bool computer)
340 blackPlayerStack->setCurrentIndex(computer ? 1 : 0);
343 void SetupWidget::whiteIsComputer(
bool computer)
345 whitePlayerStack->setCurrentIndex(computer ? 1 : 0);
350 #include "moc_setupwidget.cpp"
static void setWhitePlayerHuman(bool v)
Set Is white a human player?
static QString blackPlayerName()
Get The name of the black player.
QString cap(int nth) const
static void setBlackPlayerHuman(bool v)
Set Is black a human player?
bool setKomi(float komi)
Set the komi.
static void setFixedHandicapValue(int v)
Set Extra stones for the black player.
static int blackPlayerStrength()
Get The strength of the black player.
void setName(const QString &name)
static void setWhitePlayerStrength(int v)
Set The strength of the white player.
static void setKomi(double v)
Set Komi.
static void setBlackPlayerStrength(int v)
Set The strength of the black player.
void setPattern(const QString &pattern)
bool setStrength(int strength)
int indexIn(const QString &str, int offset, CaretMode caretMode) const
static void setBoardSize(int v)
Set Go board size.
int toInt(bool *ok, int base) const
static void setBlackPlayerName(const QString &v)
Set The name of the black player.
int moveCount()
Returns the number of moves in the game so far.
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
bool setBoardSize(int size)
Set the board size to NxN.
static bool blackPlayerHuman()
Get Is black a human player?
static double komi()
Get Komi.
int fixedHandicapUpperBound()
Returns the maximum amount fixed handicap stones placeable at the current Go board size...
static int fixedHandicapValue()
Get Extra stones for the black player.
bool init()
Initialize a new game.
static ThemeRenderer * self()
Only one ThemeRenderer is needed per application, this method returns the singleton self...
static int whitePlayerStrength()
Get The strength of the white player.
static Preferences * self()
bool setFixedHandicap(int handicap)
Set up fixed placement handicap stones.
static void setWhitePlayerName(const QString &v)
Set The name of the white player.
The Game class implements the Go game and acts as a wrapper around a remote Go Game game implementing...
void renderElement(Element element, QPainter *painter, const QRectF &rect) const
Renders a specific element of the current SVG theme.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
static bool whitePlayerHuman()
Get Is white a human player?
static int boardSize()
Get Go board size.
static QString whitePlayerName()
Get The name of the white player.