added namespace for the Core Level

This commit is contained in:
Andrei Yankovich 2021-07-05 17:39:26 +03:00
parent b678ca8366
commit 3a7c8f171f
57 changed files with 215 additions and 41 deletions

View File

@ -20,7 +20,7 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
ClientApp client;
CRAWL::ClientApp client;
client.registerLevel<TestLvl>();

View File

@ -8,6 +8,9 @@
#include "Extensions/claster.h"
#include "clasteritem.h"
namespace CRAWL {
ClasterItem::ClasterItem(const QString &name,
const QString &viewTempalte,
QObject *ptr):
@ -36,3 +39,5 @@ void ClasterItem::removeClaster(Claster *claster) {
const QSet<Claster *> &ClasterItem::parentClasters() const {
return _parentClasters;
}
}

View File

@ -13,6 +13,8 @@
#ifndef CLASTERITEM_H
#define CLASTERITEM_H
namespace CRAWL {
class Claster;
/**
@ -59,4 +61,5 @@ private:
friend class Claster;
};
}
#endif // CLASTERITEM_H

View File

@ -23,6 +23,8 @@
#include <viewsolutions.h>
#include "worldstatus.h"
namespace CRAWL {
QByteArray ClientApp::initTheme() {
int themeIndex = Settings::instance()->getValue(THEME, THEME_DEFAULT).toInt();
@ -149,3 +151,5 @@ void ClientApp::addLvl(IWorld *levelWordl) {
_availableLvls.insert(data.model->name(), data);
_menu->addWorldViewModel(data.viewModel);
}
}

View File

@ -14,15 +14,18 @@
#include "global.h"
#include "ilevel.h"
class QQmlApplicationEngine;
inline void initCrawlResources() { Q_INIT_RESOURCE(Crawl); }
namespace CRAWL {
class Engine;
class IWorld;
class WorldViewData;
class QQmlApplicationEngine;
class MainMenuModel;
class IControl;
inline void initCrawlResources() { Q_INIT_RESOURCE(Crawl); }
/**
* @brief The WordlData struct simple structure that contains information about world.
@ -32,7 +35,6 @@ struct WordlData {
IWorld * model = nullptr;
};
/**
* @brief The ClientApp class This is main class of the Game engine.
*/
@ -85,4 +87,6 @@ private:
Engine *_engine = nullptr;
};
}
#endif // CLIENTAPP_H

View File

@ -7,6 +7,8 @@
#include "defaultcontrol.h"
namespace CRAWL {
DefaultControl::DefaultControl() {
}
@ -14,3 +16,4 @@ DefaultControl::DefaultControl() {
QString DefaultControl::initQmlView() const {
return "qrc:/CrawlModule/DefaultMenu.qml";
}
}

View File

@ -11,6 +11,9 @@
#include "icontrol.h"
#include "global.h"
namespace CRAWL {
/**
* @brief The DefaultControl class This class contains default implementation of the game menu.
*/
@ -37,4 +40,6 @@ signals:
void userTap();
};
}
#endif // DEFAULTCONTROL_H

View File

@ -1,5 +1,7 @@
#include "diff.h"
namespace CRAWL {
QList<int> Diff::getAddedIds() const {
return addedIds;
}
@ -8,3 +10,4 @@ QList<int> Diff::getRemoveIds() const {
return removeIds;
}
}

View File

@ -11,6 +11,8 @@
#include <QList>
#include <QObject>
namespace CRAWL {
class GuiObject;
/**
@ -27,6 +29,7 @@ public:
QList<int> addedIds;
};
Q_DECLARE_METATYPE(Diff)
}
Q_DECLARE_METATYPE(CRAWL::Diff)
#endif // DIFF_H

View File

@ -8,6 +8,8 @@
#ifndef GAMERESULT_H
#define GAMERESULT_H
namespace CRAWL {
/**
* @brief The GameResult struct This is simple structure with game statistic.
*/
@ -24,4 +26,6 @@ struct GameResult
int distance = 0;
};
}
#endif // GAMERESULT_H

View File

@ -9,6 +9,9 @@
#include <QVector3D>
namespace CRAWL {
GuiObject::GuiObject(const QString &name, const QString &viewTempalte, QObject *ptr):
QObject (ptr) {
_viewTemplate = viewTempalte;
@ -180,3 +183,5 @@ void GuiObject::setMash(const QString &newMash) {
_mash = newMash;
emit mashChanged();
}
}

View File

@ -17,6 +17,9 @@
#define DEFAULT_VIEW_TEMPLATE "qrc:/CrawlModule/GraphicItem.qml"
namespace CRAWL {
/**
* @brief The GuiObject class This base model for gui objects.
*
@ -162,7 +165,6 @@ protected:
int _guiId = -1;
QString _color = "#ff1111";
private:
void generateId();
@ -179,4 +181,5 @@ private:
QString _className;
};
}
#endif // GUIOBJECT_H

View File

@ -7,6 +7,10 @@
#include "iai.h"
namespace CRAWL {
IAI::IAI() {
}
}

View File

@ -10,6 +10,8 @@
#include "global.h"
namespace CRAWL {
/**
* @brief The IAI class Is default interface for ai classes.
* @note example of use :
@ -36,4 +38,5 @@ public:
virtual void stopAI() = 0;
};
}
#endif // IAI_H

View File

@ -7,6 +7,9 @@
#include "icontrol.h"
namespace CRAWL {
IControl::IControl() {
}
@ -30,3 +33,5 @@ void IControl::setView(const QString &newView) {
_view = newView;
emit viewChanged();
}
}

View File

@ -11,6 +11,9 @@
#include <QObject>
#include "global.h"
namespace CRAWL {
/**
* @brief The IControl class This interface should be contains implementation of custom user interface
* How to use this class:
@ -62,4 +65,6 @@ private:
friend class Engine;
};
}
#endif // ICONTROL_H

View File

@ -8,6 +8,9 @@
#include "iground.h"
#include "iworld.h"
namespace CRAWL {
IGround::IGround(const QString &name,
const QString &viewTempalte,
QObject *ptr):
@ -24,3 +27,5 @@ void IGround::render(unsigned int ) {
setX(playerObject->position().x() + camera.z() * 4);
}
}
}

View File

@ -11,6 +11,8 @@
#include "iworlditem.h"
#include "global.h"
namespace CRAWL {
/**
* @brief The IGround class This is one tile of the world. Any objects of this type created automatically for filing ground plain.
*/
@ -25,4 +27,6 @@ public:
void render(unsigned int tbfMsec) override;
};
}
#endif // IGROUND_H

View File

@ -8,6 +8,9 @@
#ifndef LEVEL_H
#define LEVEL_H
namespace CRAWL {
class IWorld;
/**
@ -27,4 +30,6 @@ public:
virtual IWorld* world() = 0;
};
}
#endif // LEVEL_H

View File

@ -8,6 +8,9 @@
#include "defaultcontrol.h"
#include "iplayer.h"
namespace CRAWL {
IPlayer::IPlayer(const QString &name,
const QString &viewTempalte,
QObject *ptr):
@ -53,3 +56,5 @@ void IPlayer::setControl(const IControl *control) {
void IPlayer::kill() {
_fDead = true;
}
}

View File

@ -13,6 +13,9 @@
#include "iworlditem.h"
#include "Extensions/movableobject.h"
namespace CRAWL {
class IControl;
/**
@ -83,4 +86,6 @@ private:
};
}
#endif // IPLAYER_H

View File

@ -6,8 +6,10 @@
//#
#include "irender.h"
namespace CRAWL {
IRender::IRender()
{
}
}

View File

@ -11,6 +11,8 @@
#include "global.h"
#include "quasarapp.h"
namespace CRAWL {
/**
* @brief The IRender class This interface provide render functionality for all objects.
* @note Override the render method.
@ -57,4 +59,5 @@ public:
};
};
}
#endif // IRENDER_H

View File

@ -18,6 +18,10 @@
#include "clasteritem.h"
#include "thread"
#include "chrono"
#include "diff.h"
namespace CRAWL {
IWorld::IWorld() {
@ -419,3 +423,5 @@ void IWorld::runAsBackGround() {
setTargetFps(30);
}
}

View File

@ -17,9 +17,13 @@
#include <QQuaternion>
#include <QString>
#include "irender.h"
#include "diff.h"
#include "global.h"
#include <QMutex>
#include "Crawl/diff.h"
class ClastersTest;
namespace CRAWL {
class IWorldItem;
class IPlayer;
@ -239,7 +243,7 @@ signals:
* @brief sigOBjctsListChanged This signal emited when lvel status are changed.
* @brief diff This is list of removed and addeds items
*/
void sigOBjctsListChanged(Diff diff);
void sigOBjctsListChanged(CRAWL::Diff diff);
/**
* @brief cameraReleativePositionChanged This signal emot when releative position of camera cahged.
@ -472,7 +476,8 @@ private:
friend class Engine;
// testing
friend class ClastersTest;
friend ClastersTest;
};
}
#endif // IWORLD_H

View File

@ -9,6 +9,9 @@
#include "iworld.h"
#include "quasarapp.h"
namespace CRAWL {
IWorldItem::IWorldItem(const QString& name,
const QString& viewTempalte,
QObject *ptr):
@ -56,3 +59,5 @@ void IWorldItem::initOnWorld(const IWorld *world, const IWorldItem * player) {
const IWorld *IWorldItem::world() const {
return _world;
}
}

View File

@ -11,6 +11,9 @@
#include <Crawl/guiobject.h>
#include "global.h"
namespace CRAWL {
class IWorld;
/**
* @brief The IWorldItem class This is World item. This class contains functions for control event system.
@ -62,5 +65,5 @@ private:
const IWorldItem *_playerObject = nullptr;
friend class IWorld;
};
}
#endif // IWORLDITEM_H

View File

@ -10,6 +10,9 @@
#include "singleclasterworlditem.h"
#include "quasarapp.h"
namespace CRAWL {
SingleClasterWorldItem::SingleClasterWorldItem(const QString &name,
const QString &viewTempalte,
QObject *ptr):
@ -34,3 +37,5 @@ Claster *SingleClasterWorldItem::parentClaster() const {
return *ClasterItem::parentClasters().begin();
}
}

View File

@ -11,6 +11,8 @@
#include "clasteritem.h"
namespace CRAWL {
class Claster;
/**
@ -41,5 +43,6 @@ protected:
friend class Claster;
};
}
#endif // SINGLECLASTERWORLDITEM_H

View File

@ -12,6 +12,9 @@
#include <quasarapp.h>
#include <cmath>
namespace CRAWL {
Snake::Snake(const QString &name, const QString &viewTempalte, QObject *ptr):
IPlayer (name, viewTempalte, ptr) {
@ -159,3 +162,5 @@ float Snake::lengthBetwinItems() const{
void Snake::setLengthBetwinItems(float newLengthBetwinItems) {
_lengthBetwinItems = newLengthBetwinItems;
}
}

View File

@ -11,6 +11,8 @@
#include "iplayer.h"
#include "Extensions/claster.h"
namespace CRAWL {
class SnakeItem;
/**
@ -118,4 +120,6 @@ private:
};
}
#endif // SNAKE_H

View File

@ -8,6 +8,9 @@
#include "snake.h"
#include "snakeitem.h"
namespace CRAWL {
SnakeItem::SnakeItem(const QString itemName): SingleClasterWorldItem(itemName) {
setAngularVelocity(-1);
@ -41,3 +44,4 @@ void SnakeItem::render(unsigned int tbfMsec) {
const IWorldItem * SnakeItem::prev() const {
return _prevObject;
}
}

View File

@ -12,6 +12,9 @@
#include "singleclasterworlditem.h"
#include "Extensions/movableobject.h"
namespace CRAWL {
class CRAWL_EXPORT SnakeItem: public SingleClasterWorldItem, public MovableObject
{
Q_OBJECT
@ -35,4 +38,6 @@ private:
const IWorldItem *_prevObject = nullptr;
};
}
#endif // SNAKEITEM_H

View File

@ -98,7 +98,7 @@ View3D {
target: privateRoot.world;
function onSigOBjctsListChanged(diff) {
if (!diff) {
console.log("dif not found");
console.log("diff not found");
return;
}

View File

@ -69,7 +69,6 @@ Item {
themeWarning.visible = true;
}
}
}
Item {

View File

@ -8,6 +8,8 @@
#include "claster.h"
#include "Crawl/singleclasterworlditem.h"
namespace CRAWL {
Claster::Claster() {}
Claster::~Claster() {
@ -34,3 +36,5 @@ void Claster::remove(int id) {
const QHash<int, ClasterItem *> &Claster::objects() const {
return _objects;
}
}

View File

@ -10,6 +10,9 @@
#include "Crawl/iworlditem.h"
namespace CRAWL {
class ClasterItem;
/**
@ -54,4 +57,5 @@ private:
};
}
#endif // CLASTER_H

View File

@ -10,6 +10,9 @@
#include <math.h>
#include <Crawl/guiobject.h>
namespace CRAWL {
MovableObject::MovableObject() {
}
@ -87,3 +90,5 @@ void MovableObject::renderPosition(GuiObject *object, unsigned int tbfMsec) {
const QVector3D &MovableObject::currentMovableVector() const {
return _currentMovableVector;
}
}

View File

@ -12,6 +12,9 @@
#include "Crawl/irender.h"
#include <QVector3D>
namespace CRAWL {
class GuiObject;
/**
@ -106,4 +109,6 @@ private:
float _breakingForce = 0;
};
}
#endif // MOVABLEOBJECT_H

View File

@ -8,6 +8,8 @@
#include "defaultbackgroundai.h"
#include <QTimer>
namespace CRAWL {
DefaultBackgroundAI::DefaultBackgroundAI() {
_timer = new QTimer();
_timer->setInterval(1000);
@ -33,3 +35,5 @@ void DefaultBackgroundAI::handleTimerTriger() {
emit userTap();
}
}

View File

@ -10,9 +10,10 @@
#include "Crawl/defaultcontrol.h"
#include <Crawl/iai.h>
class QTimer;
namespace CRAWL {
class DefaultBackgroundAI: public DefaultControl, public IAI {
Q_OBJECT
public:
@ -31,4 +32,5 @@ private:
QTimer *_timer = nullptr;
};
}
#endif // DEFAULTBACKGROUNDAI_H

View File

@ -16,6 +16,8 @@
#include "QDateTime"
#include "QtConcurrent"
namespace CRAWL {
Engine::Engine(QObject *parent): QObject(parent) {
}
@ -170,3 +172,5 @@ void Engine::renderLoop() {
}
}

View File

@ -13,6 +13,8 @@
#include <QQmlEngine>
#include <Crawl/diff.h>
namespace CRAWL {
class IWorld;
/**
@ -148,4 +150,5 @@ private:
bool _renderLoop = false;
};
}
#endif // ENGINE_H

View File

@ -11,6 +11,8 @@
#include <quasarapp.h>
namespace CRAWL {
MainMenuModel::MainMenuModel(QObject *ptr): QObject (ptr) {
_conf = QuasarAppUtils::Settings::instance();
@ -39,3 +41,4 @@ void MainMenuModel::newGame(const QString &lvl) {
emit sigNewGame(lvl);
}
}

View File

@ -16,6 +16,8 @@ namespace ViewSolutions {
class ListViewModel;
}
namespace CRAWL {
class WorldInfo;
/**
@ -49,4 +51,5 @@ private:
};
}
#endif // NETWORKPROFILEMAINMODEL_H

View File

@ -7,6 +7,7 @@
#include "worldviewdata.h"
#include "Crawl/iworld.h"
namespace CRAWL {
WorldViewData::WorldViewData(const IWorld *data) {
setWorldObject(data);
@ -63,3 +64,4 @@ void WorldViewData::setWorldObject(const IWorld *newWorldObject) {
emit dataChanged();
}
}

View File

@ -10,6 +10,8 @@
#include <QObject>
namespace CRAWL {
class IWorld;
/**
@ -46,5 +48,5 @@ signals:
void dataChanged();
void unlockedChanged();
};
}
#endif // WORLDVIEWDATA_H

View File

@ -9,7 +9,7 @@
#define BOX_H
#include "Crawl/iworlditem.h"
class Box: public IWorldItem {
class Box: public CRAWL::IWorldItem {
public:
Box();

View File

@ -9,7 +9,7 @@
#define PLATE_H
#include "Crawl/iground.h"
class Plate: public IGround {
class Plate: public CRAWL::IGround {
public:
Plate();

View File

@ -5,7 +5,7 @@
/**
* @brief The TestControl class This controll support custom camera-ratation functions.
*/
class TestControl: public DefaultControl
class TestControl: public CRAWL::DefaultControl
{
Q_OBJECT
public:

View File

@ -10,7 +10,7 @@
#include "Crawl/snake.h"
class TestSnake : public Snake {
class TestSnake : public CRAWL::Snake {
Q_OBJECT

View File

@ -11,7 +11,7 @@
#include "Crawl/snakeitem.h"
class TestSnakeItem: public SnakeItem
class TestSnakeItem: public CRAWL::SnakeItem
{
Q_OBJECT
public:

View File

@ -17,8 +17,8 @@ World::World() {
setCameraRatation(QQuaternion::fromEulerAngles({0,0,-90}));
}
WorldRule *World::initWorldRules() {
return new WorldRule {
CRAWL::WorldRule *World::initWorldRules() {
return new CRAWL::WorldRule {
{0, {{registerObject<Box>(), 1000}}}
};
}
@ -43,11 +43,11 @@ int World::costToUnlock() const {
return 0;
}
IControl *World::initUserInterface() const {
CRAWL::IControl *World::initUserInterface() const {
return new TestControl();
}
void World::initPlayerControl(IControl *control) {
void World::initPlayerControl(CRAWL::IControl *control) {
if (auto test = dynamic_cast<TestControl*>(control)) {
connect(test, &TestControl::xChanged, this, &World::handleXViewChanged);
connect(test, &TestControl::yChanged, this, &World::handleYViewChanged);
@ -56,11 +56,11 @@ void World::initPlayerControl(IControl *control) {
return IWorld::initPlayerControl(control);
}
IPlayer *World::initPlayer() const {
CRAWL::IPlayer *World::initPlayer() const {
return new TestSnake();
}
IAI *World::initBackGroundAI() const {
CRAWL::IAI *World::initBackGroundAI() const {
return IWorld::initBackGroundAI();
}

View File

@ -10,23 +10,23 @@
#include "Crawl/iworld.h"
class World : public IWorld {
class World : public CRAWL::IWorld {
// IWorld interface
public:
World();
WorldRule *initWorldRules() override;
CRAWL::WorldRule *initWorldRules() override;
QString initHdrBackGround() const override;
QString description() const override;
QString imagePreview() const override;
QString name() const override;
int costToUnlock() const override;
IControl *initUserInterface() const override;
void initPlayerControl(IControl *control) override;
IPlayer *initPlayer() const override;
IAI *initBackGroundAI() const override;
CRAWL::IControl *initUserInterface() const override;
void initPlayerControl(CRAWL::IControl *control) override;
CRAWL::IPlayer *initPlayer() const override;
CRAWL::IAI *initBackGroundAI() const override;
private slots:
void handleXViewChanged(double dx);

View File

@ -12,7 +12,7 @@ TestLvl::TestLvl() {
}
IWorld *TestLvl::world() {
CRAWL::IWorld *TestLvl::world() {
initTestLvlResources();
return new World();
}

View File

@ -17,14 +17,14 @@ inline void initTestLvlResources() { Q_INIT_RESOURCE(Empty);
/**
* @brief The TestLvl class This is test lvlv wraper of the crawl
*/
class CRAWL_TEST_LEVEL_EXPORT TestLvl: public ILevel
class CRAWL_TEST_LEVEL_EXPORT TestLvl: public CRAWL::ILevel
{
public:
TestLvl();
// ILevel interface
public:
IWorld *world() override;
CRAWL::IWorld *world() override;
};
#endif // TESTLVL_H

View File

@ -13,7 +13,8 @@
#include <Crawl/iworld.h>
// Test claster object.
class TestClasterObject: public IWorldItem, public Claster {
class TestClasterObject: public CRAWL::IWorldItem,
public CRAWL::Claster {
public:
TestClasterObject(): IWorldItem("TestClaster"){};
@ -22,7 +23,7 @@ protected:
};
// Test single claster item
class TestClasterSingleItem: public SingleClasterWorldItem {
class TestClasterSingleItem: public CRAWL::SingleClasterWorldItem {
public:
TestClasterSingleItem(): SingleClasterWorldItem("TestClasterSingleItem"){};
protected:
@ -30,7 +31,7 @@ protected:
};
// Test claster item
class TestClasterItem: public ClasterItem {
class TestClasterItem: public CRAWL::ClasterItem {
public:
TestClasterItem(): ClasterItem("TestClasterItem"){};
protected:
@ -38,14 +39,14 @@ protected:
};
// Test world of clasters
class TestWorld: public IWorld {
class TestWorld: public CRAWL::IWorld {
public:
TestWorld(): IWorld(){};
// IWorld interface
public:
IPlayer *initPlayer() const {return nullptr;};
WorldRule *initWorldRules() {return nullptr;};
CRAWL::IPlayer *initPlayer() const {return nullptr;};
CRAWL::WorldRule *initWorldRules() {return nullptr;};
QString initHdrBackGround() const {return "";};
QString description() const {return "";};
QString imagePreview() const {return "";};