| 1 | // version: $Id$cxx . . $ `<file>/src/board.cc`/ |
| 2 | /*************************************************************************** |
| 3 | * Copyright (C) 2004-2007 Artur Wiebe * |
| 4 | * [email protected] * |
| 5 | * * |
| 6 | * This program is free software; you can redistribute it and/or modify * |
| 7 | * it under the terms of the GNU General Public License as published by * |
| 8 | * the Free Software Foundation; either version 2 of the License, or * |
| 9 | * (at your option) any later version. * |
| 10 | * * |
| 11 | * This program is distributed in the hope that it will be useful, * |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | * GNU General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU General Public License * |
| 17 | * along with this program; if not, write to the * |
| 18 | * Free Software Foundation, Inc., * |
| 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 20 | ***************************************************************************/ |
| 21 | #include <QLayout> |
| 22 | #include <QtGui> |
| 23 | #include <QDebug> |
| 24 | |
| 25 | #include "board.h"cxx . . $ `<file>/src/board.h`/ |
| 26 | #include "common.h"cxx . . $ `<file>/src/common.h`/ |
| 27 | #include "pdn.h"cxx . . $ `<file>/src/pdn.h`/ |
| 28 | #include "echeckers.h"cxx . . $ `<file>/src/echeckers.h`/ |
| 29 | #include "rcheckers.h"cxx . . $ `<file>/src/rcheckers.h`/ |
| 30 | /* |
| 31 | #include "newgamedlg.h" |
| 32 | |
| 33 | #include "player.h" |
| 34 | #include "humanplayer.h" |
| 35 | #include "computerplayer.h" |
| 36 | */ |
| 37 | |
| 38 | QColorcxx . . $ QColor# myColorInterpolatorcxx . . $ myColorInterpolator(31dbfd0d9d72a182).(const QColorcxx . . $ QColor# &start, const QColorcxx . . $ QColor# &end, qrealcxx . . $ qreal# progress) { |
| 39 | qrealcxx . . $ qreal# r = (1 - progress) * start.redcxx . . $ QColor#red(ea6fe5115c70a13f).() + progress * end.redcxx . . $ QColor#red(ea6fe5115c70a13f).(); |
| 40 | qrealcxx . . $ qreal# g = (1 - progress) * start.greencxx . . $ QColor#green(ea6fe5115c70a13f).() + progress * end.greencxx . . $ QColor#green(ea6fe5115c70a13f).(); |
| 41 | qrealcxx . . $ qreal# b = (1 - progress) * start.bluecxx . . $ QColor#blue(ea6fe5115c70a13f).() + progress * end.bluecxx . . $ QColor#blue(ea6fe5115c70a13f).(); |
| 42 | //qDebug("from %s to %s, progress %f", qUtf8Printable(start.name()), qUtf8Printable(end.name()), progress); |
| 43 | return QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(r, g, b); |
| 44 | } |
| 45 | |
| 46 | myBoardcxx . . $ myBoard#::myBoardcxx . . $ myBoard#myBoard(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget#* parent) |
| 47 | : QFramecxx . . $ QFrame#(parent) |
| 48 | { |
| 49 | /* |
| 50 | * board & info |
| 51 | */ |
| 52 | setFrameStylecxx . . $ QFrame#setFrameStyle(d4f767463ce0a6b3).(QFramecxx . . $ QFrame#::Boxcxx . . $ QFrame#Box.|cxx . . $ `operator|`(44af6e16e9fc6bb).QFramecxx . . $ QFrame#::Plaincxx . . $ QFrame#Plain.); |
| 53 | for(int i=0; i<64; i++) { |
| 54 | m_fieldscxx . . $ myBoard#m_fields.[i] = new Fieldcxx . . $ Field#(this, i); |
| 55 | } |
| 56 | |
| 57 | pixmap_validcxx . . $ myBoard#pixmap_valid. = false; |
| 58 | m_src_fieldcxx . . $ myBoard#m_src_field. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 59 | m_dst_fieldcxx . . $ myBoard#m_dst_field. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 60 | animation_stepscxx . . $ myBoard#animation_steps. = 10; |
| 61 | current_stepcxx . . $ myBoard#current_step. = 0; |
| 62 | animation_timercxx . . $ myBoard#animation_timer. = startTimercxx . . $ QObject#startTimer(cf5d4a693bb15cf1).(100); |
| 63 | |
| 64 | // for(int i=0; i<32; i++) { |
| 65 | // connect(m_fields[i], SIGNAL(click(int)), |
| 66 | // this, SIGNAL(fieldClicked(int))); |
| 67 | // } |
| 68 | |
| 69 | |
| 70 | /* |
| 71 | * game init |
| 72 | */ |
| 73 | m_gamecxx . . $ myBoard#m_game. = 0; |
| 74 | |
| 75 | } |
| 76 | |
| 77 | |
| 78 | myBoardcxx . . $ myBoard#::~cxx . . $ myBoard#`~myBoard`(ced63f7c635d850d).myBoardcxx . . $ myBoard#() |
| 79 | { |
| 80 | for (int i = 0; i < 64; i++) { |
| 81 | delete m_fieldscxx . . $ myBoard#m_fields.[i]; |
| 82 | } |
| 83 | if(m_gamecxx . . $ myBoard#m_game.) { |
| 84 | delete m_gamecxx . . $ myBoard#m_game.; |
| 85 | } |
| 86 | if (pixmapcxx . . $ myBoard#pixmap.) { |
| 87 | delete pixmapcxx . . $ myBoard#pixmap.; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | void myBoardcxx . . $ myBoard#::beginSetupcxx . . $ myBoard#beginSetup(49f6e7a06ebc5aa8).() { |
| 92 | for (int i = 0; i < 64; i++) { |
| 93 | m_fieldscxx . . $ myBoard#m_fields.[i]->beginSetupcxx . . $ Field#beginSetup(49f6e7a06ebc5aa8).(); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | void myBoardcxx . . $ myBoard#::endSetupcxx . . $ myBoard#endSetup(49f6e7a06ebc5aa8).() { |
| 98 | for (int i = 0; i < 64; i++) { |
| 99 | m_fieldscxx . . $ myBoard#m_fields.[i]->endSetupcxx . . $ Field#endSetup(49f6e7a06ebc5aa8).(); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | void myBoardcxx . . $ myBoard#::paintEventcxx . . $ myBoard#paintEvent(f239c9e85d61a220).(QPaintEventcxx . . $ QPaintEvent#*) |
| 104 | { |
| 105 | QPaintercxx . . $ QPainter# pcxx . . $ QPainter#QPainter(dd2eedc069b0ab5f).(this); |
| 106 | |
| 107 | drawcxx . . $ myBoard#draw(49f6e7a06ebc5aa8).(); |
| 108 | Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:861:13`!(pixmap_valid); |
| 109 | p.drawPixmapcxx . . $ QPainter#drawPixmap(c906314a67120896).(0, 0, *pixmapcxx . . $ myBoard#pixmap.); |
| 110 | |
| 111 | p.endcxx . . $ QPainter#end(c9857a73d68e59ba).(); |
| 112 | } |
| 113 | |
| 114 | void myBoardcxx . . $ myBoard#::setThemecxx . . $ myBoard#setTheme(37c160c81b6367f7).(const QStringcxx . . $ QString#& path, bool set_white) |
| 115 | { |
| 116 | int fieldSize = getTargetFieldSizecxx . . $ myBoard#getTargetFieldSize(a2fa66c7aa097f19).(sizecxx . . $ QWidget#size(4b3b776e5ee2b367).()); |
| 117 | m_themecxx . . $ myBoard#m_theme. = new Themecxx . . $ Theme#(this, path, 0); |
| 118 | if (fieldSize > 3) { |
| 119 | if (m_themecxx . . $ myBoard#m_theme.->getIsResizeablecxx . . $ Theme#getIsResizeable(c9857a73d68e59ba).()) { |
| 120 | m_themecxx . . $ myBoard#m_theme.->setTargetSizecxx . . $ Theme#setTargetSize(d4f767463ce0a6b3).(fieldSize); |
| 121 | } |
| 122 | } |
| 123 | for (int i = 0; i < 64; i++) { |
| 124 | m_fieldscxx . . $ myBoard#m_fields.[i]->setThemecxx . . $ Field#setTheme(99b847e279ae44f4).(m_themecxx . . $ myBoard#m_theme.); |
| 125 | } |
| 126 | |
| 127 | beginSetupcxx . . $ myBoard#beginSetup(49f6e7a06ebc5aa8).(); |
| 128 | |
| 129 | setColorWhitecxx . . $ myBoard#setColorWhite(b45ddcbc8423892c).(set_white); |
| 130 | |
| 131 | for(int i=0; i<32; i++) { |
| 132 | m_fieldscxx . . $ myBoard#m_fields.[i]->setPatterncxx . . $ Field#setPattern(d4f767463ce0a6b3).(2); |
| 133 | } |
| 134 | for(int i=32; i<64; i++) { |
| 135 | m_fieldscxx . . $ myBoard#m_fields.[i]->setPatterncxx . . $ Field#setPattern(d4f767463ce0a6b3).(1); |
| 136 | } |
| 137 | |
| 138 | //setFixedSize(sizeHint()); |
| 139 | if (! m_themecxx . . $ myBoard#m_theme.->getIsResizeablecxx . . $ Theme#getIsResizeable(c9857a73d68e59ba).()) { |
| 140 | int width = m_themecxx . . $ myBoard#m_theme.->getFieldWidthcxx . . $ Theme#getFieldWidth(b126dc7c1de90089).()*8 + 2*frameWidthcxx . . $ QFrame#frameWidth(455f465bc33b4cdf).(); |
| 141 | int height = m_themecxx . . $ myBoard#m_theme.->getFieldHeightcxx . . $ Theme#getFieldHeight(b126dc7c1de90089).()*8 + 2*frameWidthcxx . . $ QFrame#frameWidth(455f465bc33b4cdf).(); |
| 142 | setFixedSizecxx . . $ QWidget#setFixedSize(3e454b8ccf442868).(width, height); |
| 143 | } else { |
| 144 | setFixedSizecxx . . $ QWidget#setFixedSize(3e454b8ccf442868).(QWIDGETSIZE_MAXcxx . . $ `<external>/17274239923536813539/qwidget.h:888:9`!, QWIDGETSIZE_MAXcxx . . $ `<external>/17274239923536813539/qwidget.h:888:9`!); |
| 145 | } |
| 146 | |
| 147 | if(m_gamecxx . . $ myBoard#m_game.) { |
| 148 | fieldsSetupcxx . . $ myBoard#fieldsSetup(49f6e7a06ebc5aa8).(); |
| 149 | } |
| 150 | |
| 151 | endSetupcxx . . $ myBoard#endSetup(49f6e7a06ebc5aa8).(); |
| 152 | repaintcxx . . $ QWidget#repaint(49f6e7a06ebc5aa8).(); |
| 153 | } |
| 154 | |
| 155 | QSizecxx . . $ QSize# myBoardcxx . . $ myBoard#::sizeHintcxx . . $ myBoard#sizeHint(4b3b776e5ee2b367).() const { |
| 156 | if (! m_themecxx . . $ myBoard#m_theme.) { |
| 157 | return QSizecxx . . $ QSize#QSize(ced63f7c635d850d).(); |
| 158 | } else { |
| 159 | int width = m_themecxx . . $ myBoard#m_theme.->getFieldWidthcxx . . $ Theme#getFieldWidth(b126dc7c1de90089).()*8 + 2*frameWidthcxx . . $ QFrame#frameWidth(455f465bc33b4cdf).(); |
| 160 | int height = m_themecxx . . $ myBoard#m_theme.->getFieldHeightcxx . . $ Theme#getFieldHeight(b126dc7c1de90089).()*8 + 2*frameWidthcxx . . $ QFrame#frameWidth(455f465bc33b4cdf).(); |
| 161 | return QSizecxx . . $ QSize#QSize(c0d38f4800714fae).(width, height); |
| 162 | //qInfo("Size is fixed: %d x %d", width, height); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | void myBoardcxx . . $ myBoard#::resetcxx . . $ myBoard#reset(49f6e7a06ebc5aa8).() |
| 167 | { |
| 168 | int new_board[32]; |
| 169 | |
| 170 | for(int i=0; i<12; i++) { |
| 171 | new_board[i]=MAN2cxx . . $ `src/checkers.h:37:9`!; |
| 172 | } |
| 173 | for(int i=12; i<20; i++) { |
| 174 | new_board[i]=FREEcxx . . $ `src/checkers.h:35:9`!; |
| 175 | } |
| 176 | for(int i=20; i<32; i++) { |
| 177 | new_board[i]=MAN1cxx . . $ `src/checkers.h:33:9`!; |
| 178 | } |
| 179 | |
| 180 | // reset frames. |
| 181 | for(int i=0; i<32; i++) { |
| 182 | m_fieldscxx . . $ myBoard#m_fields.[i]->showFramecxx . . $ Field#showFrame(b45ddcbc8423892c).(false); |
| 183 | } |
| 184 | |
| 185 | if(m_gamecxx . . $ myBoard#m_game.) { |
| 186 | m_gamecxx . . $ myBoard#m_game.->setupcxx . . $ Checkers#setup(18a3c31ed0aa5760).(new_board); |
| 187 | } |
| 188 | |
| 189 | fieldsSetupcxx . . $ myBoard#fieldsSetup(49f6e7a06ebc5aa8).(); |
| 190 | } |
| 191 | |
| 192 | |
| 193 | void myBoardcxx . . $ myBoard#::adjustNotationcxx . . $ myBoard#adjustNotation(b45ddcbc8423892c).(bool bottom_is_white) |
| 194 | { |
| 195 | if(!m_gamecxx . . $ myBoard#m_game.) { |
| 196 | return; |
| 197 | } |
| 198 | |
| 199 | for(int i=0; i<32; i++) { |
| 200 | m_fieldscxx . . $ myBoard#m_fields.[i]->setLabelcxx . . $ Field#setLabel(3520e46b33348bf6).(m_gamecxx . . $ myBoard#m_game.->getFieldNotationcxx . . $ Checkers#getFieldNotation(f256c639af9cb348).(i, bottom_is_white)); |
| 201 | } |
| 202 | invalidatecxx . . $ myBoard#invalidate(49f6e7a06ebc5aa8).(); |
| 203 | repaintcxx . . $ QWidget#repaint(49f6e7a06ebc5aa8).(); |
| 204 | } |
| 205 | |
| 206 | |
| 207 | void myBoardcxx . . $ myBoard#::fieldsSetupcxx . . $ myBoard#fieldsSetup(49f6e7a06ebc5aa8).() |
| 208 | { |
| 209 | for(int i=0; i<32; i++) { |
| 210 | m_fieldscxx . . $ myBoard#m_fields.[i]->setcxx . . $ Field#set(918ebd27a9ddbad3).(m_gamecxx . . $ myBoard#m_game.->itemcxx . . $ Checkers#item(7ccb52b1bfe01045).(i), bottom_is_whitecxx . . $ myBoard#bottom_is_white.); |
| 211 | } |
| 212 | invalidatecxx . . $ myBoard#invalidate(49f6e7a06ebc5aa8).(); |
| 213 | } |
| 214 | |
| 215 | void myBoardcxx . . $ myBoard#::invalidatecxx . . $ myBoard#invalidate(49f6e7a06ebc5aa8).() { |
| 216 | pixmap_validcxx . . $ myBoard#pixmap_valid. = false; |
| 217 | for (int i = 0; i < 64; i++) { |
| 218 | m_fieldscxx . . $ myBoard#m_fields.[i]->invalidatecxx . . $ Field#invalidate(49f6e7a06ebc5aa8).(); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | void myBoardcxx . . $ myBoard#::drawFieldcxx . . $ myBoard#drawField(1d81d6ab033f4409).(QPaintercxx . . $ QPainter#& painter, Fieldcxx . . $ Field#* field, int row, int column) { |
| 223 | int width = sizecxx . . $ QWidget#size(4b3b776e5ee2b367).().widthcxx . . $ QSize#width(ea6fe5115c70a13f).(); |
| 224 | int height = sizecxx . . $ QWidget#size(4b3b776e5ee2b367).().heightcxx . . $ QSize#height(ea6fe5115c70a13f).(); |
| 225 | |
| 226 | int rowHeight = height / 8; |
| 227 | int colWidth = width / 8; |
| 228 | int size = rowHeight < colWidth ? rowHeight : colWidth; |
| 229 | |
| 230 | QRectcxx . . $ QRect# rectcxx . . $ QRect#QRect(2261ffe5112eab06).(column * size, row * size, size, size); |
| 231 | field->drawcxx . . $ Field#draw(34758fb9d6aa1963).(painter, rect); |
| 232 | } |
| 233 | |
| 234 | void myBoardcxx . . $ myBoard#::drawcxx . . $ myBoard#draw(49f6e7a06ebc5aa8).() { |
| 235 | if (pixmap_validcxx . . $ myBoard#pixmap_valid.) { |
| 236 | return; |
| 237 | } |
| 238 | QPixmapcxx . . $ QPixmap#* prev = pixmapcxx . . $ myBoard#pixmap.; |
| 239 | pixmapcxx . . $ myBoard#pixmap. = new QPixmapcxx . . $ QPixmap#QPixmap(1c5f201b4c2f0aba).(sizecxx . . $ QWidget#size(4b3b776e5ee2b367).()); |
| 240 | pixmapcxx . . $ myBoard#pixmap.->fillcxx . . $ QPixmap#fill(129a55e114526ad3).(Qtcxx . . $ QColor#QColor(408ec4d5924bfb00).::whitecxx . . $ Qt/white.); |
| 241 | QPaintercxx . . $ QPainter# paintercxx . . $ QPainter#QPainter(dd2eedc069b0ab5f).(pixmapcxx . . $ myBoard#pixmap.); |
| 242 | for(int i=0; i<4; i++) { |
| 243 | for(int k=0; k<4; k++) { |
| 244 | drawFieldcxx . . $ myBoard#drawField(1d81d6ab033f4409).(painter, m_fieldscxx . . $ myBoard#m_fields.[i*8+k+32], i*2, k*2 ); |
| 245 | drawFieldcxx . . $ myBoard#drawField(1d81d6ab033f4409).(painter, m_fieldscxx . . $ myBoard#m_fields.[i*8+k ], i*2, k*2+1); |
| 246 | drawFieldcxx . . $ myBoard#drawField(1d81d6ab033f4409).(painter, m_fieldscxx . . $ myBoard#m_fields.[i*8+k+4 ], i*2+1,k*2 ); |
| 247 | drawFieldcxx . . $ myBoard#drawField(1d81d6ab033f4409).(painter, m_fieldscxx . . $ myBoard#m_fields.[i*8+k+36], i*2+1,k*2+1); |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | if (animation_in_progresscxx . . $ myBoard#animation_in_progress. && m_src_fieldcxx . . $ myBoard#m_src_field. && m_dst_fieldcxx . . $ myBoard#m_dst_field.) { |
| 252 | painter.setPencxx . . $ QPainter#setPen(af0a25dfda3214db).(QPencxx . . $ QPen#QPen(c1f9b1cc0228302b).(m_src_colorcxx . . $ QBrush#QBrush(b50947b0752ea6ac)., 5)); |
| 253 | painter.drawRectcxx . . $ QPainter#drawRect(22ba0428947158b).(m_src_fieldcxx . . $ myBoard#m_src_field.->rectcxx . . $ Field#rect(f4023511c62cad66).()); |
| 254 | painter.setPencxx . . $ QPainter#setPen(129a55e114526ad3).(Qtcxx . . $ QColor#QColor(408ec4d5924bfb00).::blackcxx . . $ Qt/black.); |
| 255 | |
| 256 | painter.setPencxx . . $ QPainter#setPen(af0a25dfda3214db).(QPencxx . . $ QPen#QPen(c1f9b1cc0228302b).(m_dst_colorcxx . . $ QBrush#QBrush(b50947b0752ea6ac)., 5)); |
| 257 | painter.drawRectcxx . . $ QPainter#drawRect(22ba0428947158b).(m_dst_fieldcxx . . $ myBoard#m_dst_field.->rectcxx . . $ Field#rect(f4023511c62cad66).()); |
| 258 | painter.setPencxx . . $ QPainter#setPen(129a55e114526ad3).(Qtcxx . . $ QColor#QColor(408ec4d5924bfb00).::blackcxx . . $ Qt/black.); |
| 259 | } |
| 260 | painter.endcxx . . $ QPainter#end(c9857a73d68e59ba).(); |
| 261 | updatecxx . . $ QWidget#update(49f6e7a06ebc5aa8).(); |
| 262 | pixmap_validcxx . . $ myBoard#pixmap_valid. = true; |
| 263 | delete prev; |
| 264 | } |
| 265 | |
| 266 | void myBoardcxx . . $ myBoard#::setColorWhitecxx . . $ myBoard#setColorWhite(b45ddcbc8423892c).(bool b) |
| 267 | { |
| 268 | bottom_is_whitecxx . . $ myBoard#bottom_is_white. = b; |
| 269 | } |
| 270 | |
| 271 | void myBoardcxx . . $ myBoard#::setNotationcxx . . $ myBoard#setNotation(b0b38cda41d4ede4).(bool s, bool above) |
| 272 | { |
| 273 | for(int i=0; i<32; i++) { |
| 274 | m_fieldscxx . . $ myBoard#m_fields.[i]->showLabelcxx . . $ Field#showLabel(b0b38cda41d4ede4).(s, above); |
| 275 | } |
| 276 | invalidatecxx . . $ myBoard#invalidate(49f6e7a06ebc5aa8).(); |
| 277 | repaintcxx . . $ QWidget#repaint(49f6e7a06ebc5aa8).(); |
| 278 | } |
| 279 | |
| 280 | /* |
| 281 | void myBoard::do_move(const QString& move) |
| 282 | { |
| 283 | qDebug() << __PRETTY_FUNCTION__; |
| 284 | if(!m_current->isHuman()) { |
| 285 | add_log(myBoard::Warning, tr("It's not your turn.")); |
| 286 | return; |
| 287 | } |
| 288 | |
| 289 | int from_num, to_num; |
| 290 | if(extract_move(move, &from_num, &to_num)) { |
| 291 | slot_click(from_num); |
| 292 | slot_click(to_num); |
| 293 | } else |
| 294 | add_log(myBoard::Warning, tr("Syntax error. Usage: /from-to")); |
| 295 | } |
| 296 | */ |
| 297 | |
| 298 | |
| 299 | |
| 300 | bool myBoardcxx . . $ myBoard#::convert_movecxx . . $ myBoard#convert_move(50f8f23f66042ab).(const QStringcxx . . $ QString#& move_orig, int* from_num, int* to_num) |
| 301 | { |
| 302 | QStringcxx . . $ QString# move = move_origcxx . . $ QString#QString(132dd6869045752b)..toUppercxx . . $ QString#toUpper(dca2c5857e9adf82).().replacecxx . . $ QString#replace(8514d9896be75a4a).('X'cxx . . $ QChar#QChar(f349c77f591a7878)., '-'cxx . . $ QChar#QChar(f349c77f591a7878).); |
| 303 | QStringcxx . . $ QString# fromcxx . . $ QString#QString(ced63f7c635d850d).; |
| 304 | QStringcxx . . $ QString# tocxx . . $ QString#QString(ced63f7c635d850d).; |
| 305 | int sect = move.countcxx . . $ QString#count(e9a51133502dffc0).('-'cxx . . $ QChar#QChar(f349c77f591a7878).); |
| 306 | |
| 307 | *from_num = *to_num = -1; |
| 308 | |
| 309 | from =cxx . . $ QString#`operator=`(4f35bf974e7f8568). move.sectioncxx . . $ QString#section(6e922cf609fb9683).('-'cxx . . $ QChar#QChar(f349c77f591a7878)., 0, 0); |
| 310 | to =cxx . . $ QString#`operator=`(4f35bf974e7f8568). move.sectioncxx . . $ QString#section(6e922cf609fb9683).('-'cxx . . $ QChar#QChar(f349c77f591a7878)., sect, sect); |
| 311 | |
| 312 | if(from!=cxx . . $ `operator!=`(aa68d9f0d6cffae2).QStringcxx . . $ QString#::nullcxx . . $ QString#null. && to!=cxx . . $ `operator!=`(aa68d9f0d6cffae2).QStringcxx . . $ QString#::nullcxx . . $ QString#null.) { |
| 313 | for(int i=0; i<32; i++) { |
| 314 | if(m_fieldscxx . . $ myBoard#m_fields.[i]->labelcxx . . $ Field#label(a2fb7a6ce195d51).()==cxx . . $ `operator==`(5bc2975d2d751687).from) { |
| 315 | *from_num = m_fieldscxx . . $ myBoard#m_fields.[i]->numbercxx . . $ Field#number(455f465bc33b4cdf).(); |
| 316 | } |
| 317 | if(m_fieldscxx . . $ myBoard#m_fields.[i]->labelcxx . . $ Field#label(a2fb7a6ce195d51).()==cxx . . $ `operator==`(5bc2975d2d751687).to) { |
| 318 | *to_num = m_fieldscxx . . $ myBoard#m_fields.[i]->numbercxx . . $ Field#number(455f465bc33b4cdf).(); |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | if(*from_num>=0 && *to_num>=0) { |
| 323 | return true; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | return false; |
| 328 | } |
| 329 | |
| 330 | |
| 331 | void myBoardcxx . . $ myBoard#::setNotationFontcxx . . $ myBoard#setNotationFont(d0a4bd0c8524b912).(const QFontcxx . . $ QFont#& f) |
| 332 | { |
| 333 | setFontcxx . . $ QWidget#setFont(d0a4bd0c8524b912).(f); |
| 334 | for(int i=0; i<32; i++) { |
| 335 | m_fieldscxx . . $ myBoard#m_fields.[i]->fontUpdatecxx . . $ Field#fontUpdate(49f6e7a06ebc5aa8).(); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | |
| 340 | void myBoardcxx . . $ myBoard#::setGamecxx . . $ myBoard#setGame(d4f767463ce0a6b3).(int rules) |
| 341 | { |
| 342 | if(m_gamecxx . . $ myBoard#m_game.) { |
| 343 | delete m_gamecxx . . $ myBoard#m_game.; |
| 344 | } |
| 345 | |
| 346 | if(rules==ENGLISHcxx . . $ `src/pdn.h:34:9`!) { |
| 347 | m_gamecxx . . $ myBoard#m_game. = new ECheckerscxx . . $ ECheckers#(); |
| 348 | } else { |
| 349 | m_gamecxx . . $ myBoard#m_game. = new RCheckerscxx . . $ RCheckers#(); |
| 350 | } |
| 351 | |
| 352 | resetcxx . . $ myBoard#reset(49f6e7a06ebc5aa8).(); |
| 353 | } |
| 354 | |
| 355 | |
| 356 | void myBoardcxx . . $ myBoard#::selectFieldcxx . . $ myBoard#selectField(918ebd27a9ddbad3).(int field_num, bool is_on) |
| 357 | { |
| 358 | for(int i=0; i<32; i++) { |
| 359 | if(i==field_num) { |
| 360 | m_fieldscxx . . $ myBoard#m_fields.[i]->showFramecxx . . $ Field#showFrame(b45ddcbc8423892c).(is_on); |
| 361 | } else { |
| 362 | m_fieldscxx . . $ myBoard#m_fields.[i]->showFramecxx . . $ Field#showFrame(b45ddcbc8423892c).(false); |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | |
| 368 | QStringcxx . . $ QString# myBoardcxx . . $ myBoard#::doMovecxx . . $ myBoard#doMove(12ab5028faa519cd).(int from_num, int to_num, bool white_player) |
| 369 | { |
| 370 | bool bottom_player = (white_player && bottom_is_whitecxx . . $ myBoard#bottom_is_white.) |
| 371 | || (!white_player && !bottom_is_whitecxx . . $ myBoard#bottom_is_white.); |
| 372 | |
| 373 | int from_pos = from_num; |
| 374 | int to_pos = to_num; |
| 375 | |
| 376 | if(!bottom_player) { |
| 377 | from_pos = 31-from_pos; |
| 378 | to_pos = 31-to_pos; |
| 379 | m_gamecxx . . $ myBoard#m_game.->fromStringcxx . . $ Checkers#fromString(e1defb592416720d).(m_gamecxx . . $ myBoard#m_game.->toStringcxx . . $ Checkers#toString(11ecdffe9192d1a2).(true)); |
| 380 | } |
| 381 | if(!m_gamecxx . . $ myBoard#m_game.->go1cxx . . $ Checkers#go1(cf9ef193275fa6d8).(from_pos, to_pos)) { |
| 382 | return QStringcxx . . $ QString#QString(ee6b7ef95d0103b6).::nullcxx . . $ QString#null.; |
| 383 | /* |
| 384 | qDebug() << __PRETTY_FUNCTION__ |
| 385 | << from_pos << "," << to_pos |
| 386 | << " could not move."; |
| 387 | */ |
| 388 | } |
| 389 | if(!bottom_player) { |
| 390 | m_gamecxx . . $ myBoard#m_game.->fromStringcxx . . $ Checkers#fromString(e1defb592416720d).(m_gamecxx . . $ myBoard#m_game.->toStringcxx . . $ Checkers#toString(11ecdffe9192d1a2).(true)); |
| 391 | } |
| 392 | |
| 393 | fieldsSetupcxx . . $ myBoard#fieldsSetup(49f6e7a06ebc5aa8).(); |
| 394 | highlightcxx . . $ myBoard#highlight(6908015b96d379c0).(from_num, to_num, bottom_player); |
| 395 | |
| 396 | return QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1?%3") |
| 397 | .argcxx . . $ QString#arg(bc823072288cbbb5).(m_fieldscxx . . $ myBoard#m_fields.[from_num]->labelcxx . . $ Field#label(a2fb7a6ce195d51).()) |
| 398 | .argcxx . . $ QString#arg(bc823072288cbbb5).(m_fieldscxx . . $ myBoard#m_fields.[to_num]->labelcxx . . $ Field#label(a2fb7a6ce195d51).()); |
| 399 | } |
| 400 | |
| 401 | |
| 402 | bool myBoardcxx . . $ myBoard#::doMovecxx . . $ myBoard#doMove(7bc58614ad8ebda3).(const QStringcxx . . $ QString#& move, bool white_player) |
| 403 | { |
| 404 | int from_pos, to_pos; |
| 405 | if(convert_movecxx . . $ myBoard#convert_move(50f8f23f66042ab).(move, &from_pos, &to_pos)) { |
| 406 | doMovecxx . . $ myBoard#doMove(12ab5028faa519cd).(from_pos, to_pos, white_player); |
| 407 | return true; |
| 408 | } |
| 409 | return false; |
| 410 | } |
| 411 | |
| 412 | |
| 413 | void myBoardcxx . . $ myBoard#::doFreeMovecxx . . $ myBoard#doFreeMove(3e454b8ccf442868).(int from, int to) |
| 414 | { |
| 415 | int old_to = m_gamecxx . . $ myBoard#m_game.->itemcxx . . $ Checkers#item(7ccb52b1bfe01045).(to); |
| 416 | int old_from = m_gamecxx . . $ myBoard#m_game.->itemcxx . . $ Checkers#item(7ccb52b1bfe01045).(from); |
| 417 | m_gamecxx . . $ myBoard#m_game.->setItemcxx . . $ Checkers#setItem(3e454b8ccf442868).(to, old_from); |
| 418 | m_gamecxx . . $ myBoard#m_game.->setItemcxx . . $ Checkers#setItem(3e454b8ccf442868).(from, old_to); |
| 419 | fieldsSetupcxx . . $ myBoard#fieldsSetup(49f6e7a06ebc5aa8).(); |
| 420 | } |
| 421 | |
| 422 | int myBoardcxx . . $ myBoard#::getTargetFieldSizecxx . . $ myBoard#getTargetFieldSize(a2fa66c7aa097f19).(QSizecxx . . $ QSize# size) { |
| 423 | int w_max = size.widthcxx . . $ QSize#width(ea6fe5115c70a13f).(); |
| 424 | int h_max = size.heightcxx . . $ QSize#height(ea6fe5115c70a13f).(); |
| 425 | int max_size = w_max < h_max ? w_max : h_max; |
| 426 | return (max_size - 2*frameWidthcxx . . $ QFrame#frameWidth(455f465bc33b4cdf).()) / 8; |
| 427 | } |
| 428 | |
| 429 | void myBoardcxx . . $ myBoard#::resizeEventcxx . . $ myBoard#resizeEvent(eeeec21cf8dc0387).(QResizeEventcxx . . $ QResizeEvent#* e) { |
| 430 | if (m_themecxx . . $ myBoard#m_theme.) { |
| 431 | int size = getTargetFieldSizecxx . . $ myBoard#getTargetFieldSize(a2fa66c7aa097f19).(e->sizecxx . . $ QResizeEvent#size(68bda57ac551785b).()); |
| 432 | m_themecxx . . $ myBoard#m_theme.->setTargetSizecxx . . $ Theme#setTargetSize(d4f767463ce0a6b3).(size); |
| 433 | fieldsSetupcxx . . $ myBoard#fieldsSetup(49f6e7a06ebc5aa8).(); |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | void myBoardcxx . . $ myBoard#::mousePressEventcxx . . $ myBoard#mousePressEvent(702858a82d06265c).(QMouseEventcxx . . $ QMouseEvent#* me) |
| 438 | { |
| 439 | if(me->buttoncxx . . $ QMouseEvent#button(4a2598559eeedfc9).() != Qtcxx . . $ Qt/::LeftButtoncxx . . $ Qt/LeftButton.) |
| 440 | return; |
| 441 | if (animation_in_progresscxx . . $ myBoard#animation_in_progress.) |
| 442 | return; |
| 443 | for (int i = 0; i < 32; i++) { |
| 444 | if (m_fieldscxx . . $ myBoard#m_fields.[i]->rectcxx . . $ Field#rect(f4023511c62cad66).().containscxx . . $ QRect#contains(eaee943b37977784).(me->poscxx . . $ QMouseEvent#pos(75d69cfbd3c4b2dd).())) { |
| 445 | invalidatecxx . . $ myBoard#invalidate(49f6e7a06ebc5aa8).(); |
| 446 | updatecxx . . $ QWidget#update(49f6e7a06ebc5aa8).(); |
| 447 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! fieldClickedcxx . . $ myBoard#fieldClicked(d4f767463ce0a6b3).(i); |
| 448 | return; |
| 449 | } |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | void myBoardcxx . . $ myBoard#::highlightcxx . . $ myBoard#highlight(6908015b96d379c0).(int from, int to, bool bottom_player) { |
| 454 | animation_in_progresscxx . . $ myBoard#animation_in_progress. = true; |
| 455 | m_src_fieldcxx . . $ myBoard#m_src_field. = m_fieldscxx . . $ myBoard#m_fields.[from]; |
| 456 | m_dst_fieldcxx . . $ myBoard#m_dst_field. = m_fieldscxx . . $ myBoard#m_fields.[to]; |
| 457 | animating_bottom_playercxx . . $ myBoard#animating_bottom_player. = bottom_player; |
| 458 | } |
| 459 | |
| 460 | void myBoardcxx . . $ myBoard#::timerEventcxx . . $ myBoard#timerEvent(b9e57d1150f23bf5).(QTimerEventcxx . . $ QTimerEvent#* e) { |
| 461 | if (e->timerIdcxx . . $ QTimerEvent#timerId(455f465bc33b4cdf).() != animation_timercxx . . $ myBoard#animation_timer.) { |
| 462 | return; |
| 463 | } |
| 464 | if (animation_in_progresscxx . . $ myBoard#animation_in_progress.) { |
| 465 | qrealcxx . . $ qreal# progress = ((qrealcxx . . $ qreal#)current_stepcxx . . $ myBoard#current_step.) / ((qrealcxx . . $ qreal#)animation_stepscxx . . $ myBoard#animation_steps.); |
| 466 | QColorcxx . . $ QColor# begincxx . . $ QColor#QColor(ced63f7c635d850d).; |
| 467 | QColorcxx . . $ QColor# endcxx . . $ QColor#QColor(ced63f7c635d850d).; |
| 468 | if (animating_bottom_playercxx . . $ myBoard#animating_bottom_player.) { |
| 469 | begin =cxx . . $ QColor#`operator=`(fd1b853fb77c9003). QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0, 0, 0); |
| 470 | end =cxx . . $ QColor#`operator=`(fd1b853fb77c9003). QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0, 255, 0); |
| 471 | } else { |
| 472 | begin =cxx . . $ QColor#`operator=`(fd1b853fb77c9003). QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(0, 0, 0); |
| 473 | end =cxx . . $ QColor#`operator=`(fd1b853fb77c9003). QColorcxx . . $ QColor#QColor(2261ffe5112eab06).(255, 0, 0); |
| 474 | } |
| 475 | m_src_colorcxx . . $ myBoard#m_src_color. =cxx . . $ QColor#`operator=`(fd1b853fb77c9003). myColorInterpolatorcxx . . $ myColorInterpolator(31dbfd0d9d72a182).(begin, end, progress); |
| 476 | m_dst_colorcxx . . $ myBoard#m_dst_color. =cxx . . $ QColor#`operator=`(fd1b853fb77c9003). myColorInterpolatorcxx . . $ myColorInterpolator(31dbfd0d9d72a182).(begin, end, 1-progress); |
| 477 | current_stepcxx . . $ myBoard#current_step. ++; |
| 478 | if (current_stepcxx . . $ myBoard#current_step. >= animation_stepscxx . . $ myBoard#animation_steps.) { |
| 479 | current_stepcxx . . $ myBoard#current_step. = 0; |
| 480 | animation_in_progresscxx . . $ myBoard#animation_in_progress. = false; |
| 481 | m_src_fieldcxx . . $ myBoard#m_src_field. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 482 | m_dst_fieldcxx . . $ myBoard#m_dst_field. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 483 | invalidatecxx . . $ myBoard#invalidate(49f6e7a06ebc5aa8).(); |
| 484 | repaintcxx . . $ QWidget#repaint(49f6e7a06ebc5aa8).(); |
| 485 | } else { |
| 486 | invalidatecxx . . $ myBoard#invalidate(49f6e7a06ebc5aa8).(); |
| 487 | repaintcxx . . $ QWidget#repaint(49f6e7a06ebc5aa8).(); |
| 488 | } |
| 489 | } |
| 490 | } |
| 491 |