Commit 52026133 authored by Laurent Montel's avatar Laurent Montel 😁

Port to QCDebug

parent 07331a53
......@@ -2,6 +2,7 @@
########### next target ###############
set(kgoldrunner_SRCS
kgoldrunner_debug.cpp
kgrview.cpp
kgrscene.cpp
kgrsprite.cpp
......
......@@ -34,8 +34,8 @@
#include <kconfig.h>
#include <kconfiggroup.h>
#include <QDebug>
#include <QDebug>
#include "kgoldrunner_debug.h"
#include "kgoldrunner_debug.h"
#include <ktoolbar.h>
#include <kmenubar.h>
......@@ -166,20 +166,20 @@ KGoldrunner::KGoldrunner()
// Do NOT paint main widget yet (title bar, menu, blank playfield).
// Instead, queue a call to the "KGoldrunner_2" constructor extension.
QMetaObject::invokeMethod (this, "KGoldrunner_2", Qt::QueuedConnection);
//qDebug() << "QMetaObject::invokeMethod (this, \"KGoldrunner_2\") done ... ";
//qDebug() << "1st scan of event-queue ...";
//qCDebug(KGOLDRUNNER_LOG) << "QMetaObject::invokeMethod (this, \"KGoldrunner_2\") done ... ";
//qCDebug(KGOLDRUNNER_LOG) << "1st scan of event-queue ...";
}
void KGoldrunner::KGoldrunner_2()
{
//qDebug() << "Entered constructor extension ...";
//qCDebug(KGOLDRUNNER_LOG) << "Entered constructor extension ...";
// Queue a call to the "initGame" method. This renders and paints the
// initial graphics, but only AFTER the initial main-window resize events
// have been seen and the final SVG scale is known.
QMetaObject::invokeMethod (game, "initGame", Qt::QueuedConnection);
//qDebug() << "QMetaObject::invokeMethod (game, \"initGame\") done ... ";
//qDebug() << "2nd scan of event-queue ...";
//qCDebug(KGOLDRUNNER_LOG) << "QMetaObject::invokeMethod (game, \"initGame\") done ... ";
//qCDebug(KGOLDRUNNER_LOG) << "2nd scan of event-queue ...";
}
KGoldrunner::~KGoldrunner()
......@@ -778,7 +778,7 @@ void KGoldrunner::setEditMenu (bool on_off)
if (on_off){
// Set the editToolbar icons to the current tile-size.
//qDebug() << "ToolBar icon size:" << scene->tileSize ();
//qCDebug(KGOLDRUNNER_LOG) << "ToolBar icon size:" << scene->tileSize ();
toolBar ("editToolbar")->setIconSize (scene->tileSize ());
// Set the editToolbar icons up with pixmaps of the current theme.
......@@ -830,7 +830,7 @@ void KGoldrunner::saveProperties (KConfigGroup & /* config - unused */)
// config file. Anything you write here will be available
// later when this app is restored.
//qDebug() << "I am in KGoldrunner::saveProperties.";
//qCDebug(KGOLDRUNNER_LOG) << "I am in KGoldrunner::saveProperties.";
}
void KGoldrunner::readProperties (const KConfigGroup & /* config - unused */)
......@@ -840,7 +840,7 @@ void KGoldrunner::readProperties (const KConfigGroup & /* config - unused */)
// the app is being restored. Read in here whatever you wrote
// in 'saveProperties'
//qDebug() << "I am in KGoldrunner::readProperties.";
//qCDebug(KGOLDRUNNER_LOG) << "I am in KGoldrunner::readProperties.";
}
void KGoldrunner::optionsConfigureKeys()
......
/* This file is part of the KDE project
Copyright (C) 2014 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "kgoldrunner_debug.h"
Q_LOGGING_CATEGORY(KGOLDRUNNER_LOG, "log_kgoldrunner")
/* This file is part of the KDE project
Copyright (C) 2014 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KGOLDRUNNER_DEBUG_H
#define KGOLDRUNNER_DEBUG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(KGOLDRUNNER_LOG)
#endif
......@@ -19,11 +19,11 @@
#define KGRDEBUG_H
static int dbgLevel = 0; // Local to file where kgrdebug.h is included.
#include <KDebug>
#define dbk kDebug()
#define dbk1 if(dbgLevel>=1)kDebug()
#define dbk2 if(dbgLevel>=2)kDebug()
#define dbk3 if(dbgLevel>=3)kDebug()
#include "kgoldrunner_debug.h"
#define dbk qCDebug(KGOLDRUNNER_LOG)
#define dbk1 if(dbgLevel>=1)qCDebug(KGOLDRUNNER_LOG)
#define dbk2 if(dbgLevel>=2)qCDebug(KGOLDRUNNER_LOG)
#define dbk3 if(dbgLevel>=3)qCDebug(KGOLDRUNNER_LOG)
#define dbo printf(
#define dbo1 if(dbgLevel>=1)printf(
......
......@@ -27,7 +27,7 @@
#include <ctype.h>
#include <QTimer>
#include <KDebug>
#include "kgoldrunner_debug.h"
KGrEditor::KGrEditor (KGrView * theView,
const QString & theSystemDir,
......@@ -138,7 +138,7 @@ bool KGrEditor::updateLevel (int pGameIndex, int level)
if (level < 0)
level = 0;
int selectedLevel = selectLevel (SL_UPDATE, level, gameIndex);
kDebug() << "Selected" << gameList.at(gameIndex)->name
qCDebug(KGOLDRUNNER_LOG) << "Selected" << gameList.at(gameIndex)->name
<< "level" << selectedLevel;
if (selectedLevel == 0) {
mouseDisabled = false;
......@@ -162,7 +162,7 @@ void KGrEditor::loadEditLevel (int lev)
{
KGrLevelData d;
kDebug() << "gameIndex" << gameIndex;
qCDebug(KGOLDRUNNER_LOG) << "gameIndex" << gameIndex;
// If system game or ENDE screen, choose system dir, else choose user dir.
const QString dir = ((gameList.at(gameIndex)->owner == SYSTEM) ||
(lev == 0)) ? systemDataDir : userDataDir;
......@@ -888,7 +888,7 @@ void KGrEditor::doEdit (int button)
// Mouse button down: start making changes.
int i, j;
emit getMousePos (i, j);
kDebug() << "Button" << button << "at" << i << j;
qCDebug(KGOLDRUNNER_LOG) << "Button" << button << "at" << i << j;
switch (button) {
case Qt::LeftButton:
......
This diff is collapsed.
......@@ -22,7 +22,7 @@
#include <QDir>
#include <KLocalizedString>
#include <QDebug>
#include "kgoldrunner_debug.h"
KGrGameIO::KGrGameIO (QWidget * pView)
:
......@@ -55,7 +55,7 @@ IOStatus KGrGameIO::fetchGameListData
filePath = dir + filename;
KGrGameData * g = initGameData (o);
gameList.append (g);
// //qDebug()<< "GAME PATH:" << filePath;
// //qCDebug(KGOLDRUNNER_LOG)<< "GAME PATH:" << filePath;
openFile.setFileName (filePath);
......@@ -95,7 +95,7 @@ IOStatus KGrGameIO::fetchGameListData
g->nLevels = fields.at (0).toInt();
g->rules = fields.at (1).at (0);
g->prefix = fields.at (2);
// //qDebug() << "Levels:" << g->nLevels << "Rules:" << g->rules <<
// //qCDebug(KGOLDRUNNER_LOG) << "Levels:" << g->nLevels << "Rules:" << g->rules <<
// "Prefix:" << g->prefix;
if (kgr3Format) {
......@@ -117,7 +117,7 @@ IOStatus KGrGameIO::fetchGameListData
gameName = removeNewline (textLine.right (textLine.size() - n));
g->name = i18n (gameName.constData());
}
// //qDebug() << "Skill:" << g->skill << "Name:" << g->name;
// //qCDebug(KGOLDRUNNER_LOG) << "Skill:" << g->skill << "Name:" << g->name;
// Loop to accumulate lines of about-data. If kgr3Format, exit on
// EOF or 'L' line. If not kgr3Format, exit on EOF or numeric line.
......@@ -132,7 +132,7 @@ IOStatus KGrGameIO::fetchGameListData
g->about.append (textLine);
}
g->about = removeNewline (g->about); // Remove final '\n'.
// //qDebug() << "Info about: [" + g->about + "]";
// //qCDebug(KGOLDRUNNER_LOG) << "Info about: [" + g->about + "]";
if ((! kgr3Format) && (c != '\0')) {
filePath = dir + filename;
......@@ -152,7 +152,7 @@ bool KGrGameIO::readLevelData (const QString & dir,
const QString & prefix,
const int levelNo, KGrLevelData & d)
{
//qDebug() << "dir" << dir << "Level" << prefix << levelNo;
//qCDebug(KGOLDRUNNER_LOG) << "dir" << dir << "Level" << prefix << levelNo;
QString filePath;
IOStatus stat = fetchLevelData
(dir, prefix, levelNo, d, filePath);
......@@ -190,7 +190,7 @@ IOStatus KGrGameIO::fetchLevelData
d.name = ""; // Level name (optional).
d.hint = ""; // Level hint (optional).
// //qDebug()<< "LEVEL PATH:" << filePath;
// //qCDebug(KGOLDRUNNER_LOG)<< "LEVEL PATH:" << filePath;
openFile.setFileName (filePath);
// Check that the level-file exists.
......@@ -240,9 +240,9 @@ IOStatus KGrGameIO::fetchLevelData
}
}
// //qDebug() << "Level:" << level << "Layout length:" << d.layout.size();
// //qDebug() << "Name:" << "[" + d.name + "]";
// //qDebug() << "Hint:" << "[" + d.hint + "]";
// //qCDebug(KGOLDRUNNER_LOG) << "Level:" << level << "Layout length:" << d.layout.size();
// //qCDebug(KGOLDRUNNER_LOG) << "Name:" << "[" + d.name + "]";
// //qCDebug(KGOLDRUNNER_LOG) << "Hint:" << "[" + d.hint + "]";
openFile.close();
return (result);
......@@ -284,7 +284,7 @@ char KGrGameIO::getALine (const bool kgr3, QByteArray & line)
}
}
// //qDebug() << "Raw line:" << line;
// //qCDebug(KGOLDRUNNER_LOG) << "Raw line:" << line;
if (line.size() <= 0) {
// Return a '\0' byte if end-of-file.
return ('\0');
......@@ -293,7 +293,7 @@ char KGrGameIO::getALine (const bool kgr3, QByteArray & line)
// In KGr 3 format, strip off leading and trailing syntax.
if (line.startsWith ("// ")) {
line = line.right (line.size() - 3);
// //qDebug() << "Stripped comment is:" << line;
// //qCDebug(KGOLDRUNNER_LOG) << "Stripped comment is:" << line;
}
else {
if (line.startsWith (" i18n(\"")) {
......@@ -314,7 +314,7 @@ char KGrGameIO::getALine (const bool kgr3, QByteArray & line)
else if (line.endsWith ("\"\n")) {
line = line.left (line.size() - 2);
}
// //qDebug() << "Stripped syntax is:" << line;
// //qCDebug(KGOLDRUNNER_LOG) << "Stripped syntax is:" << line;
}
// In Kgr 3 format, return the first byte if not end-of-file.
c = line.at (0);
......
......@@ -31,7 +31,7 @@
#include "kgrlevelgrid.h"
#include "kgrrunner.h"
#include <QDebug>
#include "kgoldrunner_debug.h"
#include <KMessageBox> // TODO - Remove.
#include <KRandomSequence>
......@@ -71,7 +71,7 @@ KGrLevelPlayer::~KGrLevelPlayer()
{
qDeleteAll(dugBricks);
dugBricks.clear(); //TODO: necessary?
//qDebug() << "LEVEL PLAYER BEING DELETED.";
//qCDebug(KGOLDRUNNER_LOG) << "LEVEL PLAYER BEING DELETED.";
playerCount--;
// TODO - Remove this debugging code.
......@@ -806,7 +806,7 @@ void KGrLevelPlayer::tick (bool missed, int scaledTime)
// Queued connection ensures KGrGame slot runs AFTER return from here.
emit endLevel (status);
//qDebug() << "END OF LEVEL";
//qCDebug(KGOLDRUNNER_LOG) << "END OF LEVEL";
return;
}
......@@ -1158,7 +1158,7 @@ void KGrLevelPlayer::killHero()
record (1, ACTION_CODE + KILL_HERO);
emit endLevel (DEAD);
//qDebug() << "END OF LEVEL";
//qCDebug(KGOLDRUNNER_LOG) << "END OF LEVEL";
}
}
......
......@@ -300,7 +300,7 @@ public:
* is paused and the KConfig file contains group Debugging with setting
* DebuggingShortcuts=true. The main actions are to do timer steps one at
* a time, activate/deactivate a bug-fix or new-feature patch dynamically,
* activate/deactivate logging output from fprintf or kDebug() dynamically,
* activate/deactivate logging output from fprintf or qCDebug(KGOLDRUNNER_LOG) dynamically,
* print the status of a cell pointed to by the mouse and print the status
* of the hero or an enemy. See the code in file kgoldrunner.cpp, at the
* end of KGoldrunner::setupActions() for details of codes and keystrokes.
......
......@@ -24,7 +24,7 @@
#include <KgThemeSelector>
#include <KLocalizedString>
#include <QDebug>
#include "kgoldrunner_debug.h"
#include <QString>
#include "kgrglobals.h"
......@@ -98,7 +98,7 @@ void KGrRenderer::matchThemes (const KgTheme * currentSetTheme)
void KGrRenderer::currentThemeChanged (const KgTheme* currentSetTheme)
{
qDebug() << "KGrRenderer::currentThemeChanged()" << currentSetTheme->name();
qCDebug(KGOLDRUNNER_LOG) << "KGrRenderer::currentThemeChanged()" << currentSetTheme->name();
matchThemes (currentSetTheme);
m_scene->changeTheme();
......@@ -274,7 +274,7 @@ QString KGrRenderer::getBackgroundKey (const int level)
}
}
qDebug() << "BACKGROUND pixmap key" << pixmapKey;
qCDebug(KGOLDRUNNER_LOG) << "BACKGROUND pixmap key" << pixmapKey;
return pixmapKey;
}
......
......@@ -23,7 +23,7 @@
#include <QObject>
#include <QList>
#include <KDebug>
#include "kgoldrunner_debug.h"
class KGrLevelGrid;
......
......@@ -22,7 +22,7 @@
#include "kgrrulebook.h"
#include "kgrlevelplayer.h"
#include <KDebug>
#include "kgoldrunner_debug.h"
KGrRunner::KGrRunner (KGrLevelPlayer * pLevelPlayer, KGrLevelGrid * pGrid,
int i, int j, const int pSpriteId,
......@@ -74,7 +74,7 @@ void KGrRunner::getRules()
pointsPerCell = rules->pointsPerCell();
turnAnywhere = rules->turnAnywhere();
if (spriteId < 1) {
kDebug() << "pointsPerCell" << pointsPerCell
qCDebug(KGOLDRUNNER_LOG) << "pointsPerCell" << pointsPerCell
<< "turnAnywhere" << turnAnywhere;
}
}
......@@ -201,9 +201,9 @@ KGrHero::KGrHero (KGrLevelPlayer * pLevelPlayer, KGrLevelGrid * pGrid,
KGrRunner (pLevelPlayer, pGrid, i, j, pSpriteId, pRules, 0),
nuggets (0) // KGrLevelPlayer object will call hero->setNuggets().
{
kDebug() << "THE HERO IS BORN at" << i << j << "sprite ID" << pSpriteId;
qCDebug(KGOLDRUNNER_LOG) << "THE HERO IS BORN at" << i << j << "sprite ID" << pSpriteId;
rules->getHeroTimes (runTime, fallTime, enemyFallTime, trapTime);
kDebug() << "Hero run time" << runTime << "fall time" << fallTime;
qCDebug(KGOLDRUNNER_LOG) << "Hero run time" << runTime << "fall time" << fallTime;
interval = runTime;
}
......@@ -305,7 +305,7 @@ HeroStatus KGrHero::run (const int scaledTime)
bool KGrHero::dig (const Direction diggingDirection, int & i, int & j)
{
QString text = (diggingDirection == DIG_LEFT) ? "LEFT" : "RIGHT";
// kDebug() << "Start digging" << text;
// qCDebug(KGOLDRUNNER_LOG) << "Start digging" << text;
Flags moves = grid->heroMoves (gridI, gridJ);
bool result = false;
......@@ -324,7 +324,7 @@ bool KGrHero::dig (const Direction diggingDirection, int & i, int & j)
// The place to dig must be clear and there must be a brick under it.
char aboveBrick = grid->cellType (gridI + relativeI, gridJ);
// kDebug() << "aboveBrick =" << aboveBrick;
// qCDebug(KGOLDRUNNER_LOG) << "aboveBrick =" << aboveBrick;
if ((grid->cellType (gridI + relativeI, gridJ + 1) == BRICK) &&
((aboveBrick == FREE) || (aboveBrick == HOLE))) {
......@@ -363,10 +363,10 @@ KGrEnemy::KGrEnemy (KGrLevelPlayer * pLevelPlayer, KGrLevelGrid * pGrid,
rulesType = rules->getEnemyTimes (runTime, fallTime, trapTime);
enemyFallTime = fallTime;
interval = runTime;
kDebug() << "ENEMY" << pSpriteId << "IS BORN at" << i << j;
qCDebug(KGOLDRUNNER_LOG) << "ENEMY" << pSpriteId << "IS BORN at" << i << j;
if (pSpriteId < 2) {
kDebug() << "Enemy run time " << runTime << "fall time" << fallTime;
kDebug() << "Enemy trap time" << trapTime << "Rules type" << rulesType;
qCDebug(KGOLDRUNNER_LOG) << "Enemy run time " << runTime << "fall time" << fallTime;
qCDebug(KGOLDRUNNER_LOG) << "Enemy trap time" << trapTime << "Rules type" << rulesType;
}
t.start(); // IDW
}
......
......@@ -15,8 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************/
#include <QDebug>
#include <QDebug>
#include "kgoldrunner_debug.h"
#include "kgoldrunner_debug.h"
#include <KLocalizedString>
......@@ -106,7 +106,7 @@ KGrScene::~KGrScene()
void KGrScene::redrawScene ()
{
qDebug() << "REDRAW: m_sizeChanged" << m_sizeChanged << "m_themeChanged" << m_themeChanged;
qCDebug(KGOLDRUNNER_LOG) << "REDRAW: m_sizeChanged" << m_sizeChanged << "m_themeChanged" << m_themeChanged;
bool redrawToolbar = false;
if (m_sizeChanged) {
// Calculate what size of tile will fit in the view.
......@@ -116,7 +116,7 @@ void KGrScene::redrawScene ()
m_topLeftX = (size.width() - m_tilesWide * tileSize)/2.0;
m_topLeftY = (size.height() - m_tilesHigh * tileSize)/2.0;
setSceneRect (0, 0, size.width(), size.height());
qDebug() << "SIZE" << size << "TL" << m_topLeftX << m_topLeftY << "TILE" << tileSize << "was" << m_tileSize << m_toolbarTileSize;
qCDebug(KGOLDRUNNER_LOG) << "SIZE" << size << "TL" << m_topLeftX << m_topLeftY << "TILE" << tileSize << "was" << m_tileSize << m_toolbarTileSize;
// Make the fade-out/fade-in rectangle cover the playing area.
m_spotlight->setRect (m_topLeftX + 2 * tileSize - 1,
......@@ -418,7 +418,7 @@ void KGrScene::drawFrame()
m_topLeftY + (2 * m_tileSize) - (3 * w),
FIELDWIDTH * m_tileSize + 6 * w,
FIELDHEIGHT * m_tileSize + 6 * w);
//qDebug() << "FRAME WIDTH" << w << "tile size" << m_tileSize << "rectangle" << m_frame->rect();
//qCDebug(KGOLDRUNNER_LOG) << "FRAME WIDTH" << w << "tile size" << m_tileSize << "rectangle" << m_frame->rect();
QPen pen = QPen (m_renderer->textColor());
pen.setWidth (w);
m_frame->setPen (pen);
......
......@@ -18,7 +18,7 @@
#include "kgrsounds.h"
#include <QDebug>
#include "kgoldrunner_debug.h"
KGrSounds::KGrSounds() :
QObject(),
......@@ -33,7 +33,7 @@ KGrSounds::~KGrSounds()
int KGrSounds::loadSound (const QString &fileName)
{
//qDebug() << "Loading sound" << fileName;
//qCDebug(KGOLDRUNNER_LOG) << "Loading sound" << fileName;
sounds << (new KgSound (fileName));
startTime << 0;
return sounds.count() - 1;
......
......@@ -19,7 +19,7 @@
#include "kgrsprite.h"
#include "kgrrenderer.h"
#include <QDebug>
#include "kgoldrunner_debug.h"
KGrSprite::KGrSprite (KGameRenderer * renderer, QString & key,
const char type, const int tickTime)
......@@ -85,7 +85,7 @@ void KGrSprite::setAnimation (bool repeating, int x, int y, int startFrame,
m_dy = (double) dy / m_ticks;
m_frameTicks = (double) m_ticks / nFrameChanges;
m_frameChange = 0.0;
// //qDebug() << "m_ticks" << m_ticks << "dx,dy,dt" << dx << dy << dt << "m_dx,m_dy" << m_dx << m_dy << "m_frameTicks" << m_frameTicks << "nFrames" << nFrames << "nFrameChanges" << nFrameChanges;
// //qCDebug(KGOLDRUNNER_LOG) << "m_ticks" << m_ticks << "dx,dy,dt" << dx << dy << dt << "m_dx,m_dy" << m_dx << m_dy << "m_frameTicks" << m_frameTicks << "nFrames" << nFrames << "nFrameChanges" << nFrameChanges;
}
void KGrSprite::animate (bool missed)
......@@ -100,7 +100,7 @@ void KGrSprite::animate (bool missed)
return;
}
}
// //qDebug() << missed << m_frameCtr << "=" << m_x << m_y << "frame" << m_startFrame + m_frameCtr << m_frameChange;
// //qCDebug(KGOLDRUNNER_LOG) << missed << m_frameCtr << "=" << m_x << m_y << "frame" << m_startFrame + m_frameCtr << m_frameChange;
// If the clock is running slow, skip an animation step.
if (! missed) {
......
......@@ -17,7 +17,7 @@
#include "kgrtimer.h"
#include <QDebug>
#include "kgoldrunner_debug.h"
KGrTimer::KGrTimer (QObject * parent, int pTickTime, float pScale)
:
......
......@@ -20,7 +20,7 @@
#include "kgrglobals.h"
#include "kgrrenderer.h"
#include <QDebug>
#include "kgoldrunner_debug.h"
KGrView::KGrView (QWidget * parent)
:
......
......@@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************/
#include <QDebug>
#include "kgoldrunner_debug.h"
#include <KAboutData>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment