Commit 454ad0ad authored by Julian Helfferich's avatar Julian Helfferich 💬
Browse files

Create SceneInterface

Later on, I want to create a MockScene object in order to sense the
changes done to the scene by the KBlocksWin class.
parent fc3fd5cd
/***************************************************************************
* KBlocks, a falling blocks game by KDE *
* Copyright (C) 2010 Mauricio Piacentini <mauricio@tabuleiro.com> *
* Zhongjie Cai <squall.leonhart.cai@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
/******************************************************************************
* KBlocks, a falling blocks game by KDE *
* Copyright (C) 2010-2021 Mauricio Piacentini <mauricio@tabuleiro.com> *
* Zhongjie Cai <squall.leonhart.cai@gmail.com> *
* Julian Helfferich <julian.helfferich@mailbox.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
******************************************************************************/
#ifndef KBLOCKSSCENE_H
#define KBLOCKSSCENE_H
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QString>
......@@ -26,13 +26,15 @@
#include "KBlocksDefine.h"
class KBlocksScene : public QGraphicsScene
#include "SceneInterface.h"
class KBlocksScene : public SceneInterface
{
Q_OBJECT
public:
explicit KBlocksScene(GameLogicInterface *p, int capacity = 1);
~KBlocksScene();
virtual ~KBlocksScene();
KBlocksItemGroup *getItemGroup(int index);
KBlocksScore *getScoreHandler(int index);
......@@ -46,7 +48,7 @@ public:
void setUpdateInterval(int interval);
void setSoundsEnabled(bool enabled);
void readSettings(const QSize &viewSize);
void readSettings(const QSize &viewSize) override;
void viewScaled(const QSize &newsize);
void startGame();
......
/***************************************************************************
* KBlocks, a falling blocks game by KDE *
* Copyright (C) 2010 Mauricio Piacentini <mauricio@tabuleiro.com> *
* Zhongjie Cai <squall.leonhart.cai@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "KBlocksView.h"
/******************************************************************************
* KBlocks, a falling blocks game by KDE *
* Copyright (C) 2010-2021 Mauricio Piacentini <mauricio@tabuleiro.com> *
* Zhongjie Cai <squall.leonhart.cai@gmail.com> *
* Julian Helfferich <julian.helfferich@mailbox.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
******************************************************************************/
#include <QResizeEvent>
KBlocksView::KBlocksView(KBlocksScene *scene, QWidget *parent): QGraphicsView(scene, parent)
#include "KBlocksView.h"
#include "SceneInterface.h"
KBlocksView::KBlocksView(SceneInterface *scene, QWidget *parent): QGraphicsView(scene, parent)
{
mpGameScene = scene;
......
/***************************************************************************
* KBlocks, a falling blocks game by KDE *
* Copyright (C) 2010 Mauricio Piacentini <mauricio@tabuleiro.com> *
* Zhongjie Cai <squall.leonhart.cai@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
/******************************************************************************
* KBlocks, a falling blocks game by KDE *
* Copyright (C) 2010-2021 Mauricio Piacentini <mauricio@tabuleiro.com> *
* Zhongjie Cai <squall.leonhart.cai@gmail.com> *
* Julian Helfferich <julian.helfferich@mailbox.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
******************************************************************************/
#ifndef KBLOCKSVIEW_H
#define KBLOCKSVIEW_H
#include <QGraphicsView>
#include "KBlocksScene.h"
class SceneInterface;
class KBlocksView : public QGraphicsView
{
Q_OBJECT
public:
explicit KBlocksView(KBlocksScene *scene, QWidget *parent = nullptr);
explicit KBlocksView(SceneInterface *scene, QWidget *parent = nullptr);
~KBlocksView();
signals:
......@@ -35,7 +36,7 @@ protected:
void resizeEvent(QResizeEvent *event) override;
protected:
KBlocksScene *mpGameScene = nullptr;
SceneInterface *mpGameScene = nullptr;
};
#endif
......
/******************************************************************************
* KBlocks, a falling blocks game by KDE *
* Copyright (C) 2009-2021 Julian Helfferich <julian.helfferich@mailbox.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
******************************************************************************/
#ifndef SCENEINTERFACE_H
#define SCENEINTERFACE_H
#include <QGraphicsScene>
class SceneInterface : public QGraphicsScene
{
public:
SceneInterface() = default;
virtual ~SceneInterface() = default;
public:
virtual void readSettings(const QSize&) = 0;
};
#endif // SCENEINTERFACE_H
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