simple refactoring
1
.gitignore
vendored
@ -22,6 +22,7 @@ HanoiTowersTerminal/build
|
||||
/stage/*
|
||||
/Build-*
|
||||
/Release-*
|
||||
HanoiTowers/client/build/
|
||||
*.stash
|
||||
/source/android/*
|
||||
!/source/android/AndroidManifest.xml
|
||||
|
9
.gitmodules
vendored
@ -1,15 +1,6 @@
|
||||
[submodule "SimpleQmlNotify"]
|
||||
path = SimpleQmlNotify
|
||||
url = https://github.com/QuasarApp/SimpleQmlNotify.git
|
||||
[submodule "Patronum"]
|
||||
path = Patronum
|
||||
url = https://github.com/QuasarApp/Patronum.git
|
||||
[submodule "hanoi_towers/ViewSolutions"]
|
||||
path = hanoi_towers/ViewSolutions
|
||||
url = https://github.com/QuasarApp/ViewSolutions.git
|
||||
[submodule "hanoi_towers/QMLLoginView"]
|
||||
path = hanoi_towers/QMLLoginView
|
||||
url = https://github.com/QuasarApp/QMLLoginView.git
|
||||
[submodule "Heart"]
|
||||
path = Heart
|
||||
url = https://github.com/QuasarApp/Heart.git
|
||||
|
@ -46,7 +46,7 @@ addDeployAPK("Android" "${CMAKE_CURRENT_SOURCE_DIR}/hanoi_towers/android-libHano
|
||||
# Add sub directories
|
||||
add_subdirectory(SimpleQmlNotify)
|
||||
add_subdirectory(Heart)
|
||||
add_subdirectory(hanoi_towers)
|
||||
add_subdirectory(HanoiTowers)
|
||||
#add_subdirectory(hanoi_towers/ViewSolutions)
|
||||
|
||||
add_subdirectory(Patronum)
|
||||
|
14
HanoiTowers/CMakeLists.txt
Normal file
@ -0,0 +1,14 @@
|
||||
#
|
||||
# Copyright (C) 2018-2020 QuasarApp.
|
||||
# Distributed under the lgplv3 software license, see the accompanying
|
||||
# Everyone is permitted to copy and distribute verbatim copies
|
||||
# of this license document, but changing it is not allowed.
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
add_subdirectory(Protockol)
|
||||
add_subdirectory(client)
|
||||
add_subdirectory(Server)
|
||||
add_subdirectory(Terminal)
|
||||
|
33
HanoiTowers/Protockol/CMakeLists.txt
Normal file
@ -0,0 +1,33 @@
|
||||
#
|
||||
# Copyright (C) 2018-2020 QuasarApp.
|
||||
# Distributed under the lgplv3 software license, see the accompanying
|
||||
# Everyone is permitted to copy and distribute verbatim copies
|
||||
# of this license document, but changing it is not allowed.
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
|
||||
set(CURRENT_PROJECT ${PROJECT_NAME}Protockol)
|
||||
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
add_definitions(-DHANOITOWERSPROTOCOL)
|
||||
|
||||
file(GLOB SOURCE_CPP
|
||||
"src/*.cpp"
|
||||
"src/Private/*.cpp"
|
||||
"src/Private/*.qrc"
|
||||
)
|
||||
|
||||
add_library(${CURRENT_PROJECT} SHARED ${SOURCE_CPP})
|
||||
target_link_libraries(${CURRENT_PROJECT} PUBLIC Heart)
|
||||
target_include_directories(${CURRENT_PROJECT} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||
target_include_directories(${CURRENT_PROJECT} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/Private")
|
||||
|
||||
setVersion(0 1 0)
|
@ -29,7 +29,7 @@ file(GLOB SOURCE_CPP
|
||||
)
|
||||
|
||||
add_executable(${CURRENT_PROJECT} ${SOURCE_CPP})
|
||||
target_link_libraries(${CURRENT_PROJECT} PRIVATE QmlNotyfyService NetworkProtocol LoginView)
|
||||
target_link_libraries(${CURRENT_PROJECT} PRIVATE QmlNotyfyService Heart LoginView)
|
||||
target_include_directories(${CURRENT_PROJECT} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
setVersion(${PRODUCT_VER_Mj} ${PRODUCT_VER_Mn} ${PRODUCT_VER_Re})
|
Before ![]() (image error) Size: 22 KiB After ![]() (image error) Size: 22 KiB ![]() ![]() |
Before ![]() (image error) Size: 22 KiB After ![]() (image error) Size: 22 KiB ![]() ![]() |
Before ![]() (image error) Size: 22 KiB After ![]() (image error) Size: 22 KiB ![]() ![]() |
@ -14,23 +14,11 @@
|
||||
#include <QDataStream>
|
||||
#include <streambase.h>
|
||||
|
||||
class GameState : public QObject, public NP::StreamBase
|
||||
class GameState : public QObject, public QH::StreamBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(short lvl READ lvl WRITE saveLvl)
|
||||
|
||||
private:
|
||||
QList<QList<int>> save;
|
||||
int maxValueOfLoadedSave = 0;
|
||||
int step = 0;
|
||||
|
||||
short _lvl;
|
||||
|
||||
// StreamBase interface
|
||||
protected:
|
||||
QDataStream &fromStream(QDataStream &stream);
|
||||
QDataStream &toStream(QDataStream &stream) const;
|
||||
|
||||
public:
|
||||
explicit GameState();
|
||||
Q_INVOKABLE QList<int> getTower(int i);
|
||||
@ -44,8 +32,22 @@ public:
|
||||
|
||||
Q_INVOKABLE void unlockNextLvl();
|
||||
|
||||
|
||||
public slots:
|
||||
void saveLvl(short lvl);
|
||||
|
||||
// StreamBase interface
|
||||
protected:
|
||||
QDataStream &fromStream(QDataStream &stream);
|
||||
QDataStream &toStream(QDataStream &stream) const;
|
||||
|
||||
private:
|
||||
QList<QList<int>> save;
|
||||
int maxValueOfLoadedSave = 0;
|
||||
int step = 0;
|
||||
|
||||
short _lvl;
|
||||
|
||||
};
|
||||
|
||||
|
@ -16,25 +16,16 @@ void ProfileData::setOnline(bool onlineProfile) {
|
||||
}
|
||||
|
||||
void ProfileData::setRecord(int rec) {
|
||||
if (record() == rec)
|
||||
if (_record == rec)
|
||||
return;
|
||||
|
||||
_userData.extraData()["points"] = rec;
|
||||
_record = rec;
|
||||
emit recordChanged(rec);
|
||||
}
|
||||
|
||||
const NP::UserData *ProfileData::userData() const {
|
||||
return &_userData;
|
||||
}
|
||||
|
||||
void ProfileData::handleServerResponce(const NP::UserData &data) {
|
||||
_userData = data;
|
||||
emit onlineChanged(isOnline());
|
||||
}
|
||||
|
||||
ProfileData::ProfileData(const QString &name):
|
||||
QObject(nullptr) {
|
||||
_userData.setName(name);
|
||||
_name = name;
|
||||
}
|
||||
|
||||
ProfileData::~ProfileData() = default;
|
||||
@ -44,25 +35,26 @@ QObject *ProfileData::gameState() {
|
||||
}
|
||||
|
||||
QString ProfileData::name() const {
|
||||
return _userData.name();
|
||||
return _name;
|
||||
}
|
||||
|
||||
int ProfileData::record() const {
|
||||
return _userData.extraData()["points"].toInt();
|
||||
return _record;
|
||||
}
|
||||
|
||||
bool ProfileData::isOnline() const {
|
||||
return _userData.token().toBytes().size();
|
||||
}
|
||||
|
||||
void ProfileData::update(const NP::UserData *newData) {
|
||||
_userData.copyFrom(newData);
|
||||
return _online;
|
||||
}
|
||||
|
||||
QDataStream &ProfileData::fromStream(QDataStream &stream) {
|
||||
return stream >> _userData >> _state;
|
||||
return stream >> _name >> _record >> _online >> _state;
|
||||
}
|
||||
|
||||
QDataStream &ProfileData::toStream(QDataStream &stream) const {
|
||||
return stream << _userData << _state;
|
||||
return stream << _name << _record << _online << _state;
|
||||
}
|
||||
|
||||
ProfileData &ProfileData::operator =(const ProfileData &right) {
|
||||
this->fromBytes(right.toBytes());
|
||||
return *this;
|
||||
}
|
@ -8,9 +8,8 @@
|
||||
#ifndef PROFILEDATA_H
|
||||
#define PROFILEDATA_H
|
||||
#include "gamestate.h"
|
||||
#include "userdata.h"
|
||||
|
||||
class ProfileData : public QObject, public NP::StreamBase
|
||||
class ProfileData : public QObject, public QH::StreamBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -19,12 +18,6 @@ class ProfileData : public QObject, public NP::StreamBase
|
||||
Q_PROPERTY(int record READ record WRITE setRecord NOTIFY recordChanged)
|
||||
Q_PROPERTY(bool onlineUser READ isOnline WRITE setOnline NOTIFY onlineChanged)
|
||||
|
||||
private:
|
||||
NP::UserData _userData;
|
||||
GameState _state;
|
||||
|
||||
private slots:
|
||||
void handleServerResponce(const NP::UserData &data);
|
||||
|
||||
public:
|
||||
ProfileData(const QString& name);
|
||||
@ -36,13 +29,11 @@ public:
|
||||
Q_INVOKABLE int record() const;
|
||||
Q_INVOKABLE bool isOnline() const;
|
||||
|
||||
void update(const NP::UserData *newData);
|
||||
|
||||
// StreamBase interface
|
||||
QDataStream &fromStream(QDataStream &stream) override;
|
||||
QDataStream &toStream(QDataStream &stream) const override;
|
||||
|
||||
const NP::UserData *userData() const;
|
||||
ProfileData& operator = (const ProfileData& right);
|
||||
|
||||
public slots:
|
||||
void setOnline(bool onlineUser);
|
||||
@ -53,6 +44,12 @@ signals:
|
||||
void onlineChanged(bool onlineUser);
|
||||
void onlineRequest(const QString& name);
|
||||
void recordChanged(int record);
|
||||
|
||||
private:
|
||||
GameState _state;
|
||||
QString _name;
|
||||
int _record;
|
||||
bool _online;
|
||||
};
|
||||
|
||||
#endif // PROFILEDATA_H
|
Before ![]() (image error) Size: 11 KiB After ![]() (image error) Size: 11 KiB ![]() ![]() |
Before ![]() (image error) Size: 86 KiB After ![]() (image error) Size: 86 KiB ![]() ![]() |
Before ![]() (image error) Size: 64 KiB After ![]() (image error) Size: 64 KiB ![]() ![]() |
Before ![]() (image error) Size: 58 KiB After ![]() (image error) Size: 58 KiB ![]() ![]() |
Before ![]() (image error) Size: 175 KiB After ![]() (image error) Size: 175 KiB ![]() ![]() |
Before (image error) Size: 22 KiB After (image error) Size: 22 KiB |
Before ![]() (image error) Size: 22 KiB After ![]() (image error) Size: 22 KiB ![]() ![]() |
Before ![]() (image error) Size: 5.7 KiB After ![]() (image error) Size: 5.7 KiB ![]() ![]() |
Before ![]() (image error) Size: 20 KiB After ![]() (image error) Size: 20 KiB ![]() ![]() |
Before ![]() (image error) Size: 28 KiB After ![]() (image error) Size: 28 KiB ![]() ![]() |
Before ![]() (image error) Size: 102 KiB After ![]() (image error) Size: 102 KiB ![]() ![]() |
6
HanoiTowers/client/user.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "user.h"
|
||||
|
||||
User::User()
|
||||
{
|
||||
|
||||
}
|
11
HanoiTowers/client/user.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef USER_H
|
||||
#define USER_H
|
||||
|
||||
|
||||
class User
|
||||
{
|
||||
public:
|
||||
User();
|
||||
};
|
||||
|
||||
#endif // USER_H
|
52
HanoiTowers/client/userdata.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 QuasarApp.
|
||||
* Distributed under the lgplv3 software license, see the accompanying
|
||||
* Everyone is permitted to copy and distribute verbatim copies
|
||||
* of this license document, but changing it is not allowed.
|
||||
*/
|
||||
|
||||
#include "userdata.h"
|
||||
#include "profiledata.h"
|
||||
|
||||
UserData::UserData():
|
||||
QH::PKG::DBObject("UsersData"),
|
||||
_userData("") {
|
||||
|
||||
}
|
||||
|
||||
UserData::UserData(const QH::Package &from):
|
||||
UserData() {
|
||||
fromPakcage(from);
|
||||
}
|
||||
|
||||
UserData::UserData(const ProfileData &from): UserData() {
|
||||
_userData = from;
|
||||
}
|
||||
|
||||
bool UserData::copyFrom(const QH::PKG::AbstractData *other) {
|
||||
if (!AbstractData::copyFrom(other))
|
||||
return false;
|
||||
|
||||
auto otherObject = dynamic_cast<const UserData*>(other);
|
||||
if (!otherObject)
|
||||
return false;
|
||||
|
||||
_userData = otherObject->_userData;
|
||||
return true;
|
||||
}
|
||||
|
||||
QH::PKG::DBObject *UserData::createDBObject() const {
|
||||
QH::PKG::DBObject
|
||||
}
|
||||
|
||||
QDataStream &UserData::fromStream(QDataStream &stream) {
|
||||
AbstractData::fromStream(stream);
|
||||
stream >> _userData;
|
||||
return stream;
|
||||
}
|
||||
|
||||
QDataStream &UserData::toStream(QDataStream &stream) const {
|
||||
AbstractData::toStream(stream);
|
||||
stream << _userData;
|
||||
return stream;
|
||||
}
|
35
HanoiTowers/client/userdata.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2020 QuasarApp.
|
||||
* Distributed under the lgplv3 software license, see the accompanying
|
||||
* Everyone is permitted to copy and distribute verbatim copies
|
||||
* of this license document, but changing it is not allowed.
|
||||
*/
|
||||
|
||||
#ifndef USERDATA_H
|
||||
#define USERDATA_H
|
||||
|
||||
#include <dbobject.h>
|
||||
#include <profiledata.h>
|
||||
|
||||
class UserData: public QH::PKG::DBObject
|
||||
{
|
||||
public:
|
||||
UserData();
|
||||
UserData(const QH::Package& from);
|
||||
UserData(const ProfileData& from);
|
||||
|
||||
bool copyFrom(const AbstractData *other) override;
|
||||
QH::PKG::DBObject *createDBObject() const override;
|
||||
QH::PKG::PrepareResult prepareSaveQuery(QSqlQuery &q) const override;
|
||||
|
||||
protected:
|
||||
QDataStream &fromStream(QDataStream &stream) override;
|
||||
QDataStream &toStream(QDataStream &stream) const override;
|
||||
|
||||
QH::BaseId generateId() const override;
|
||||
|
||||
private:
|
||||
ProfileData _userData;
|
||||
};
|
||||
|
||||
#endif // USERDATA_H
|
@ -1 +0,0 @@
|
||||
Subproject commit 6a2856ca9883b34f3d072389007af0ea4a0a091f
|
@ -1 +0,0 @@
|
||||
Subproject commit 3d36acb3f287e0fc7e0889ca4c34a04742681db9
|
@ -1 +0,0 @@
|
||||
Subproject commit af10f80ea1f3256cac0a45b9660012ee996b8c30
|