File indexing completed on 2024-09-08 03:44:37
0001 /* 0002 This file is part of the KDE games kwin4 program 0003 SPDX-FileCopyrightText: 2006 Martin Heni <kde@heni-online.de> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #include "score.h" 0009 0010 // own 0011 #include "kfourinline_debug.h" 0012 #include "scoresprite.h" 0013 // KDEGames 0014 #define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API 0015 #include <libkdegamesprivate/kgame/kgameio.h> 0016 0017 // Construct a score object 0018 Score::Score(QObject *parent) 0019 : QObject(parent) 0020 { 0021 mDisplay = nullptr; 0022 } 0023 0024 // Activate the score display sprite 0025 void Score::setDisplay(ScoreSprite *s) 0026 { 0027 mDisplay = s; 0028 update(); 0029 } 0030 0031 // Update the values in the sprite 0032 void Score::update() 0033 { 0034 if (!mDisplay) 0035 return; 0036 0037 mDisplay->setTurn(mTurn); 0038 0039 for (int i = 0; i < 2; i++) { 0040 mDisplay->setPlayerName(mName[i], i); 0041 // Call this only after set name 0042 if (mInputDevice[i] == (int)KGameIO::ProcessIO) 0043 mDisplay->setLevel(mLevel[i], i); 0044 else 0045 mDisplay->setLevel(-1, i); 0046 mDisplay->setWon(QStringLiteral("%1").arg(mWin[i]), i); 0047 mDisplay->setDraw(QStringLiteral("%1").arg(mRemis[i]), i); 0048 mDisplay->setLoss(QStringLiteral("%1").arg(mLoss[i]), i); 0049 mDisplay->setBreak(QStringLiteral("%1").arg(mBrk[i]), i); 0050 mDisplay->setInput(mInputDevice[i], i); 0051 } 0052 } 0053 0054 #include "moc_score.cpp"