diff --git a/.gitignore b/.gitignore
index f84e2b3..c3e225f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,33 +1,19 @@
# C++ objects and libs
-
*.slo
*.lo
*.o
*.a
*.la
*.lai
-*.so*
+*.so
+*.so.*
*.dll
*.dylib
-*.exe
# Qt-es
-/Build*
-/build*
-SnakeClient/Client/build/
-SnakeClient/SnakeApp/build/
-SnakeServer/Server/build/
-SnakeServer/serverProtocolTests/build/
-SnakeServer/Terminal/build
-*.stash
-/Release*
-/parts/*
-/prime/*
-/snap/.snapcraft/*
-/stage/*
-/Build-*
-/Release-*
-*.stash
+object_script.*.Release
+object_script.*.Debug
+*_plugin_import.cpp
/.qmake.cache
/.qmake.stash
*.pro.user
@@ -39,46 +25,43 @@ moc_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
+*.qmlc
+*.jsc
Makefile*
*build-*
-*_qml.cpp
-*.snap
+tests/build/
+src/build/
*.qm
-qml_qmlcache.qrc
-qmlcache_loader.cpp
-snake
-SnakeServer/Terminal/build/debug/Terminal
+*.prl
+
+# Qt unit tests
+target_wrapper.*
# QtCreator
-installer/HanoiTowersInstaller
*.autosave
-installer/installer
-# QtCtreator Qml
+# QtCreator Qml
*.qmlproject.user
*.qmlproject.user.*
-# QtCtreator CMake
+# QtCreator CMake
CMakeLists.txt.user*
-installer/packages/Snake/data
-\.buildconfig
-SnakeServer/Daemon/build/*
+# QtCreator 4.8< compilation database
+compile_commands.json
-SnakeServer/Client/build/*/Client
+# QtCreator local machine specific files for imported projects
+*creator.user*
-SnakeServer/Daemon/build/*/Daemon
-
-SnakeServer/serverProtocolTests/target_wrapper\.sh
-
-SnakeServer/serverProtocolTests/serverProtocolTests
-
-deployTests/
-
-installer/SnakeInstaller
-
-Distro/
-
-android-build/
-
-*.db
+CMakeLists.txt.user
+CMakeCache.txt
+CMakeFiles
+CMakeScripts
+Testing
+Makefile
+cmake_install.cmake
+install_manifest.txt
+compile_commands.json
+CTestTestfile.cmake
+_deps
+*_autogen*
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 6072d35..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,10 +0,0 @@
-[submodule "QuasarAppLib"]
- path = QuasarAppLib
- url = https://github.com/QuasarApp/QuasarAppLib.git
-
-[submodule "SnakeServer/Qt-Secret"]
- path = SnakeServer/Qt-Secret
- url = git@github.com:QuasarApp/Qt-Secret.git
-[submodule "installer"]
- path = installer
- url = git@github.com:QuasarApp/DesktopInstaller.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..384b03a
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,60 @@
+#
+# Copyright (C) 2020-2021 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.14)
+project(SnakeProject)
+if(TARGET ${PROJECT_NAME})
+ message("The ${PROJECT_NAME} arledy included in main Project")
+ return()
+endif()
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+set(CMAKE_AUTOUIC ON)
+
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Test QUIET)
+find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Test QUIET)
+
+include(submodules/CMake/ccache.cmake)
+include(submodules/CMake/QuasarAppCITargets.cmake)
+
+# Add sub directories
+add_subdirectory(src)
+
+if (NOT DEFINED SnakeProject_TESTS)
+ set(SnakeProject_TESTS ON)
+
+ if (DEFINED TARGET_PLATFORM_TOOLCHAIN)
+ if (${TARGET_PLATFORM_TOOLCHAIN} STREQUAL "wasm32")
+ set(SnakeProject_TESTS OFF)
+ endif()
+ endif()
+
+ if (ANDROID)
+ set(SnakeProject_TESTS OFF)
+ endif()
+
+ if (NOT QT_VERSION_MAJOR)
+ set(SnakeProject_TESTS OFF)
+ endif()
+endif()
+
+
+if (SnakeProject_TESTS)
+ add_subdirectory(tests)
+else()
+ message("The ${PROJECT_NAME} tests is disabled.")
+endif()
+
+initAll()
+
+addDoc(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/doxygen.conf)
+addDeployFromCustomFile("SnakeProject" "${CMAKE_CURRENT_SOURCE_DIR}/Deploy/SnakeProject.json")
diff --git a/Deploy/SnakeProject.json b/Deploy/SnakeProject.json
new file mode 100644
index 0000000..b79b689
--- /dev/null
+++ b/Deploy/SnakeProject.json
@@ -0,0 +1,19 @@
+{
+ "binDir": "./../src/build/Debug/SnakeProjectEaxample",
+ "clear": true,
+ "libDir": "./../",
+ "recursiveDepth": "10",
+ "deploySystem": false,
+ "qmlDir": "../",
+ "ignoreEnv": [
+ "./../installer",
+ "./../Distro",
+ "./../parts",
+ "./../snap",
+ "./../prime",
+ "./../stage"
+ ],
+ "extraLib": "crypto",
+ "targetDir": "./../DisttibutionKit"
+}
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..65c5ca8
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/QuasarAppLib b/QuasarAppLib
deleted file mode 160000
index 553e337..0000000
--- a/QuasarAppLib
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 553e337e6a956534d34dbbfcec42359117aa35d4
diff --git a/README.md b/README.md
index 98e10aa..08b0533 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,15 @@
-# Snake
+# CMakeProject
+Template repository for cmake project
+Fork me and replase SnakeProject to Name of your new project.
+
+1. Clone this repository
+2. Run ./init.sh NewProjectName
+
+# This template supports next build targets:
+
+| Command or make target | Description |
+|------|------|
+| **make test** | The run tests for a project (dependet of Qt Tests, so you need to add Qt in Cmake using CMAKE_PREFIX_PATH) |
+| **make doc** | The generate a documentation for a project (dependet of doxygen) |
+| **make deploy** | The generate distribution for a project (dependet of CQtDeployer) |
+| **make release** | The prepare Qt Installer framework repository for a project, generate a snap package and APK file for android (dependet of CQtDeployer, snapcraft, AndroidDeployer). |
diff --git a/SnakeClient/SnakeApp/SnakeApp.pro b/SnakeClient/SnakeApp/SnakeApp.pro
deleted file mode 100644
index 4225c5d..0000000
--- a/SnakeClient/SnakeApp/SnakeApp.pro
+++ /dev/null
@@ -1,116 +0,0 @@
-QT += quick concurrent
-CONFIG += c++17
-
-# The following define makes your compiler emit warnings if you use
-# any feature of Qt which as been marked deprecated (the exact warnings
-# depend on your compiler). Please consult the documentation of the
-# deprecated API in order to know how to port your code away from it.
-DEFINES += QT_DEPRECATED_WARNINGS
-
-# You can also make your code fail to compile if you use deprecated APIs.
-# In order to do so, uncomment the following line.
-# You can also select to disable deprecated APIs only up to a certain version of Qt.
-#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
-
-SOURCES += \
- back-end/ProfileViewItems/mainclient.cpp \
- back-end/ProfileViewItems/mainmenumodel.cpp \
- back-end/ProfileViewItems/networkclient.cpp \
- back-end/ProfileViewItems/notificationdata.cpp \
- back-end/ProfileViewItems/notificationservice.cpp \
- back-end/ProfileViewItems/playerclientdata.cpp \
- back-end/ProfileViewItems/settingsviewmodel.cpp \
- back-end/ProfileViewItems/userview.cpp \
- back-end/asyncimageresponse.cpp \
- back-end/background.cpp \
- back-end/backgrounditem.cpp \
- back-end/baseclass.cpp \
- back-end/box.cpp \
- back-end/clientapp.cpp \
- back-end/controller.cpp \
- back-end/diff.cpp \
- back-end/guiobject.cpp \
- back-end/guiobjectfactory.cpp \
- back-end/head.cpp \
- back-end/imageprovider.cpp \
- back-end/itemworld.cpp \
- back-end/settings.cpp \
- back-end/snake.cpp \
- back-end/world.cpp \
- back-end/main.cpp
-
-
-TARGET = Snake
-
-
-CONFIG(release, debug|release): {
- DESTDIR = $$PWD/build/release
-
-} else {
- DESTDIR = $$PWD/build/debug
-}
-
-# Additional import path used to resolve QML modules in Qt Creator's code model
-QML_IMPORT_PATH =
-
-# Additional import path used to resolve QML modules just for Qt Quick Designer
-QML_DESIGNER_IMPORT_PATH =
-
-include($$PWD/../../QuasarAppLib/QuasarLib.pri)
-include($$PWD/../../SnakeUtils/SnakeUtils.pri)
-include($$PWD/../../SnakeServer/ClientProtocol/ClientProtocol.pri)
-
-DISTFILES += \
- android/AndroidManifest.xml \
- android/AndroidManifest.xml \
- android/AndroidManifest.xml \
- android/build.gradle \
- android/build.gradle \
- android/gradle/wrapper/gradle-wrapper.jar \
- android/gradle/wrapper/gradle-wrapper.jar \
- android/gradle/wrapper/gradle-wrapper.jar \
- android/gradle/wrapper/gradle-wrapper.properties \
- android/gradle/wrapper/gradle-wrapper.properties \
- android/gradlew \
- android/gradlew \
- android/gradlew \
- android/gradlew.bat \
- android/gradlew.bat \
- android/res/values/libs.xml \
- android/res/values/libs.xml \
- android/res/values/libs.xml \
- android/build.gradle \
- android/gradle/wrapper/gradle-wrapper.properties \
- android/gradlew.bat \
- front-end/PagePopUp.qml
-
-ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
-
-RESOURCES += \
- qml.qrc
-
-HEADERS += \
- back-end/ProfileViewItems/mainclient.h \
- back-end/ProfileViewItems/mainmenumodel.h \
- back-end/ProfileViewItems/networkclient.h \
- back-end/ProfileViewItems/notificationdata.h \
- back-end/ProfileViewItems/notificationservice.h \
- back-end/ProfileViewItems/playerclientdata.h \
- back-end/ProfileViewItems/settingsviewmodel.h \
- back-end/ProfileViewItems/userview.h \
- back-end/asyncimageresponse.h \
- back-end/background.h \
- back-end/backgrounditem.h \
- back-end/baseclass.h \
- back-end/box.h \
- back-end/clientapp.h \
- back-end/controller.h \
- back-end/diff.h \
- back-end/guiobject.h \
- back-end/guiobjectfactory.h \
- back-end/head.h \
- back-end/imageprovider.h \
- back-end/itemworld.h \
- back-end/settings.h \
- back-end/snake.h \
- back-end/world.h
diff --git a/SnakeClient/SnakeApp/android/AndroidManifest.xml b/SnakeClient/SnakeApp/android/AndroidManifest.xml
deleted file mode 100644
index 586d919..0000000
--- a/SnakeClient/SnakeApp/android/AndroidManifest.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/SnakeClient/SnakeApp/android/build.gradle b/SnakeClient/SnakeApp/android/build.gradle
deleted file mode 100644
index 989d079..0000000
--- a/SnakeClient/SnakeApp/android/build.gradle
+++ /dev/null
@@ -1,57 +0,0 @@
-buildscript {
- repositories {
- google()
- jcenter()
- }
-
- dependencies {
- classpath 'com.android.tools.build:gradle:3.2.0'
- }
-}
-
-repositories {
- google()
- jcenter()
-}
-
-apply plugin: 'com.android.application'
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
-}
-
-android {
- /*******************************************************
- * The following variables:
- * - androidBuildToolsVersion,
- * - androidCompileSdkVersion
- * - qt5AndroidDir - holds the path to qt android files
- * needed to build any Qt application
- * on Android.
- *
- * are defined in gradle.properties file. This file is
- * updated by QtCreator and androiddeployqt tools.
- * Changing them manually might break the compilation!
- *******************************************************/
-
- compileSdkVersion androidCompileSdkVersion.toInteger()
-
- buildToolsVersion androidBuildToolsVersion
-
- sourceSets {
- main {
- manifest.srcFile 'AndroidManifest.xml'
- java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
- aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
- res.srcDirs = [qt5AndroidDir + '/res', 'res']
- resources.srcDirs = ['src']
- renderscript.srcDirs = ['src']
- assets.srcDirs = ['assets']
- jniLibs.srcDirs = ['libs']
- }
- }
-
- lintOptions {
- abortOnError false
- }
-}
diff --git a/SnakeClient/SnakeApp/android/gradle/wrapper/gradle-wrapper.jar b/SnakeClient/SnakeApp/android/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index f6b961f..0000000
Binary files a/SnakeClient/SnakeApp/android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/SnakeClient/SnakeApp/android/gradle/wrapper/gradle-wrapper.properties b/SnakeClient/SnakeApp/android/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index bf3de21..0000000
--- a/SnakeClient/SnakeApp/android/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
diff --git a/SnakeClient/SnakeApp/android/gradlew b/SnakeClient/SnakeApp/android/gradlew
deleted file mode 100755
index cccdd3d..0000000
--- a/SnakeClient/SnakeApp/android/gradlew
+++ /dev/null
@@ -1,172 +0,0 @@
-#!/usr/bin/env sh
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=$(save "$@")
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
-exec "$JAVACMD" "$@"
diff --git a/SnakeClient/SnakeApp/android/gradlew.bat b/SnakeClient/SnakeApp/android/gradlew.bat
deleted file mode 100644
index f955316..0000000
--- a/SnakeClient/SnakeApp/android/gradlew.bat
+++ /dev/null
@@ -1,84 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/SnakeClient/SnakeApp/android/res/drawable-hdpi/icon.png b/SnakeClient/SnakeApp/android/res/drawable-hdpi/icon.png
deleted file mode 100644
index f7120fc..0000000
Binary files a/SnakeClient/SnakeApp/android/res/drawable-hdpi/icon.png and /dev/null differ
diff --git a/SnakeClient/SnakeApp/android/res/drawable-ldpi/icon.png b/SnakeClient/SnakeApp/android/res/drawable-ldpi/icon.png
deleted file mode 100644
index f7120fc..0000000
Binary files a/SnakeClient/SnakeApp/android/res/drawable-ldpi/icon.png and /dev/null differ
diff --git a/SnakeClient/SnakeApp/android/res/drawable-mdpi/icon.png b/SnakeClient/SnakeApp/android/res/drawable-mdpi/icon.png
deleted file mode 100644
index f7120fc..0000000
Binary files a/SnakeClient/SnakeApp/android/res/drawable-mdpi/icon.png and /dev/null differ
diff --git a/SnakeClient/SnakeApp/android/res/values/libs.xml b/SnakeClient/SnakeApp/android/res/values/libs.xml
deleted file mode 100644
index 4009a77..0000000
--- a/SnakeClient/SnakeApp/android/res/values/libs.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
- - https://download.qt.io/ministro/android/qt5/qt-5.9
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/SnakeClient/SnakeApp/back-end/ProfileViewItems/mainclient.cpp b/SnakeClient/SnakeApp/back-end/ProfileViewItems/mainclient.cpp
deleted file mode 100644
index 7420fdd..0000000
--- a/SnakeClient/SnakeApp/back-end/ProfileViewItems/mainclient.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-#include "mainclient.h"
-#include "notificationservice.h"
-#include "playerclientdata.h"
-
-#include
-
-OnlineStatus MainClient::onlineStatus() const {
- return _onlineStatus;
-}
-
-void MainClient::setOnlineStatus(OnlineStatus onlineStatus) {
- if (_onlineStatus == onlineStatus)
- return;
-
- emit sigOnlineStatusChanged(_onlineStatus = onlineStatus);
- pushNotify(onlineStatus);
-
-}
-
-void MainClient::clientStatusChanged() {
- auto status = OnlineStatus::ClientIsOffline;
-
- if (isOnline()) {
- status = OnlineStatus::AuthorizationRequired;
- }
-
- if (isLogin()) {
- status = OnlineStatus::Success;
- }
-
- setOnlineStatus(status);
-}
-
-void MainClient::pushNotify(OnlineStatus onlineStatus) {
-
-
- switch (onlineStatus) {
-
- case OnlineStatus::Success: {
-
- NotificationService::getService()->setNotify(
- NotificationData(tr("Login status"), tr("Success")));
-
- break;
- }
-
- case OnlineStatus::AuthorizationRequired: {
-
- NotificationService::getService()->setNotify(
- NotificationData(tr("Login status"), tr("Authorization Required")));
-
- break;
- }
-
- case OnlineStatus::WaitForAnswer: {
-
- NotificationService::getService()->setNotify(
- NotificationData(tr("Login status"), tr("Wait for answer")));
-
- break;
- }
-
- case OnlineStatus::AuthorizationFail: {
-
- NotificationService::getService()->setNotify(
- NotificationData(tr("Login result"), tr("Authorization fail") , "", NotificationData::Error));
-
- break;
- }
-
- case OnlineStatus::ClientIsOffline: {
-
- NotificationService::getService()->setNotify(
- NotificationData(tr("Login result"), tr("Client is offline"), "", NotificationData::Warning));
-
- break;
- }
-
- case OnlineStatus::OfflineMode: {
-
- NotificationService::getService()->setNotify(
- NotificationData(tr("Login result"), tr("Offline Mode")));
-
- break;
- }
-
- default: break;
-
- }
-}
-
-void MainClient::handleReceivePackage(ClientProtocol::Command cmd, const QByteArray &obj) {
- switch (cmd) {
-
- case ClientProtocol::Command::Player: {
- auto playerData = QSharedPointer::create();
- playerData->fromBytes(obj);
-
- _users [playerData->id()] = playerData;
-
- if (playerData->id() == _currentUserId) {
- emit currentUserDataChanged(_users [playerData->id()]);
- }
-
- break;
- }
-
- case ClientProtocol::Command::BadRequest: {
-
- NotificationService::getService()->setNotify(
- NotificationData(tr("Request"), tr("Bad Request"), "",
- NotificationData::Error));
-
-
- break;
- }
- default: return;
- }
-}
-
-void MainClient::handleLoginChanged(bool logined) {
- this->setSubscribe(ClientProtocol::Command::Player, logined, _currentUserId);
- clientStatusChanged();
-
-}
-
-void MainClient::handleOnlineChanged(bool) {
- clientStatusChanged();
-}
-
-MainClient::MainClient(const QString &addrress, unsigned short port, QObject *ptr):
- ClientProtocol::Client (addrress, port, ptr) {
-
- connect(this, &MainClient::sigIncommingData,
- this, &MainClient::handleReceivePackage);
-
- connect(this, &MainClient::onlineChanged,
- this, &MainClient::handleOnlineChanged);
-
- connect(this, &MainClient::loginChanged,
- this, &MainClient::handleLoginChanged);
-}
-
-bool MainClient::login(const QString &gmail, const QByteArray &pass, bool) {
- if (!ClientProtocol::Client::login(gmail, pass)) {
- setOnlineStatus(OnlineStatus::AuthorizationFail);
- return false;
- }
-
- return true;
-}
-
-bool MainClient::registration(const QString &gmail,
- const QByteArray &pass) {
-
- if (!ClientProtocol::Client::registration(gmail, pass)) {
- setOnlineStatus(OnlineStatus::AuthorizationFail);
- return false;
- }
-
- return true;
-}
-
-void MainClient::playOffline() {
- if (_onlineStatus == OnlineStatus::ClientIsOffline) {
- setOnlineStatus(OfflineMode);
- }
-}
-
-void MainClient::tryConnect(const QString &addrress, unsigned short port) {
- setOnlineStatus(ClientIsOffline);
- connectToHost(addrress, port);
-}
-
-MainClient::~MainClient() {
- for (auto &i: _users) {
- i.clear();
- }
- _users.clear();
-}
diff --git a/SnakeClient/SnakeApp/back-end/ProfileViewItems/mainclient.h b/SnakeClient/SnakeApp/back-end/ProfileViewItems/mainclient.h
deleted file mode 100644
index ec1b842..0000000
--- a/SnakeClient/SnakeApp/back-end/ProfileViewItems/mainclient.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef MAINCLIENT_H
-#define MAINCLIENT_H
-#include
-
-class PlayerClientData;
-
-enum OnlineStatus: int {
- Success = 0x0,
- AuthorizationRequired,
- WaitForAnswer,
- AuthorizationFail,
- ClientIsOffline,
- OfflineMode
-};
-
-class MainClient: public ClientProtocol::Client
-{
- Q_OBJECT
-private:
- QHash> _users;
- OnlineStatus _onlineStatus = ClientIsOffline;
-
- void setOnlineStatus(OnlineStatus onlineStatus);
- void clientStatusChanged();
- void pushNotify(OnlineStatus onlineStatus);
-
-private slots:
- void handleReceivePackage(ClientProtocol::Command cmd, const QByteArray& obj);
- void handleLoginChanged(bool);
- void handleOnlineChanged(bool);
-
-public:
- MainClient(const QString& addrress = LOCAL_SNAKE_SERVER,
- unsigned short port = DEFAULT_SNAKE_PORT,
- QObject * ptr = nullptr);
- bool login(const QString& gmail, const QByteArray &pass, bool registerNewUser = false) override;
- bool registration(const QString& gmail,
- const QByteArray &pass) override;
- void playOffline();
- void tryConnect(const QString &addrress, unsigned short port);
-
- ~MainClient() override;
-
- OnlineStatus onlineStatus() const;
-
-signals:
- void sigOnlineStatusChanged(OnlineStatus);
- void currentUserDataChanged(QSharedPointer);
-};
-
-#endif // MAINCLIENT_H
diff --git a/SnakeClient/SnakeApp/back-end/ProfileViewItems/mainmenumodel.cpp b/SnakeClient/SnakeApp/back-end/ProfileViewItems/mainmenumodel.cpp
deleted file mode 100644
index d7edc60..0000000
--- a/SnakeClient/SnakeApp/back-end/ProfileViewItems/mainmenumodel.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#include "mainmenumodel.h"
-#include "settingsviewmodel.h"
-#include "userview.h"
-
-#include
-#include
-#include "mainclient.h"
-
-MainMenuModel::MainMenuModel(QObject *ptr): QObject (ptr) {
-
- if(!ClientProtocol::initClientProtockol()) {
- QuasarAppUtils::Params::verboseLog("client protockol not inited", QuasarAppUtils::Error);
- }
-
- _userViewModel = new UserView (this);
- _conf = Settings::get();
- _userSettingsModel = new SettingsViewModel(this);
- auto adderss = _conf->getValue(SERVER_ADDRESS, SERVER_ADDRESS_DEFAULT).toString();
- auto port = _conf->getValue(SERVER_ADDRESS_PORT, SERVER_ADDRESS_DEFAULT_PORT).toInt();
- _client = new MainClient(adderss, static_cast(port), this);
-
- connect(_client, &MainClient::sigOnlineStatusChanged,
- this , &MainMenuModel::onlineStatusChanged);
-
- connect(_client, &MainClient::currentUserDataChanged,
- _userViewModel , &UserView::setSource);
-}
-
-QObject *MainMenuModel::userViewModel() const {
- return _userViewModel;
-}
-
-int MainMenuModel::onlineStatus() const {
- return _client->onlineStatus();
-}
-
-void MainMenuModel::playOffline() {
- _client->playOffline();
- _userViewModel->setOffline(true);
-}
-
-void MainMenuModel::tryConnect() {
- auto adderss = _conf->getValue(SERVER_ADDRESS, SERVER_ADDRESS_DEFAULT).toString();
- auto port = _conf->getValue(SERVER_ADDRESS_PORT, SERVER_ADDRESS_DEFAULT_PORT).toInt();
- _client->tryConnect(adderss, static_cast(port));
-}
-
-QObject *MainMenuModel::userSettingsModel() const {
- return _userSettingsModel;
-}
-
-void MainMenuModel::login(const QString &email, const QString &pass) {
- _client->login(email, pass.toUtf8());
-}
-
-void MainMenuModel::registerNewUser(const QString &email,
- const QString &pass) {
- _client->registration(email, pass.toUtf8());
-}
diff --git a/SnakeClient/SnakeApp/back-end/ProfileViewItems/mainmenumodel.h b/SnakeClient/SnakeApp/back-end/ProfileViewItems/mainmenumodel.h
deleted file mode 100644
index 85f997b..0000000
--- a/SnakeClient/SnakeApp/back-end/ProfileViewItems/mainmenumodel.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef NETWORKPROFILEMAINMODEL_H
-#define NETWORKPROFILEMAINMODEL_H
-
-#include "mainclient.h"
-
-#include
-#include "./../settings.h"
-
-class UserView;
-
-class MainClient;
-class SettingsViewModel;
-
-class MainMenuModel : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QObject* userViewModel READ userViewModel NOTIFY userViewModelChanged)
- Q_PROPERTY(QObject* userSettingsModel READ userSettingsModel NOTIFY userSettingsModelChanged)
- Q_PROPERTY(int onlineStatus READ onlineStatus NOTIFY onlineStatusChanged)
-
-private:
- UserView* _userViewModel = nullptr;
- SettingsViewModel* _userSettingsModel = nullptr;
- MainClient *_client = nullptr;
- Settings *_conf = nullptr;
-
-public:
- MainMenuModel(QObject *ptr = nullptr);
-
- QObject* userViewModel() const;
- QObject* userSettingsModel() const;
-
- int onlineStatus() const;
- Q_INVOKABLE void playOffline();
- Q_INVOKABLE void tryConnect();
-
-public slots:
- void login(const QString& email, const QString& pass);
- void registerNewUser(const QString& email, const QString& pass);
-
-signals:
- void userViewModelChanged(QObject* userViewModel);
- void newGame();
- void onlinelChanged(bool online);
- void loginChanged(bool login);
- void onlineStatusChanged();
- void userSettingsModelChanged(QObject* userSettingsModel);
-};
-
-#endif // NETWORKPROFILEMAINMODEL_H
diff --git a/SnakeClient/SnakeApp/back-end/ProfileViewItems/networkclient.cpp b/SnakeClient/SnakeApp/back-end/ProfileViewItems/networkclient.cpp
deleted file mode 100644
index 10b646c..0000000
--- a/SnakeClient/SnakeApp/back-end/ProfileViewItems/networkclient.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "networkclient.h"
-#include "playerclientdata.h"
-
-#include
-
-int NetworkClient::loginedPlayer() const {
- return _loginedPlayer;
-}
-
-void NetworkClient::handleReceiveData(ClientProtocol::Command cmd,
- const QByteArray &obj) {
-
- if (cmd == ClientProtocol::Command::Player) {
- PlayerClientData data;
- data.fromBytes(obj);
- _playersDats[data.id()] = data;
- }
-
-}
-
-NetworkClient::NetworkClient() {
-
-}
diff --git a/SnakeClient/SnakeApp/back-end/ProfileViewItems/networkclient.h b/SnakeClient/SnakeApp/back-end/ProfileViewItems/networkclient.h
deleted file mode 100644
index 840902b..0000000
--- a/SnakeClient/SnakeApp/back-end/ProfileViewItems/networkclient.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef CLIENT_H
-#define CLIENT_H
-
-#include "playerclientdata.h"
-
-#include
-
-class NetworkClient : public ClientProtocol::Client
-{
- Q_OBJECT
-private:
- QHash _playersDats;
- int _loginedPlayer;
-private slots:
- void handleReceiveData(ClientProtocol::Command cmd, const QByteArray& obj);
-public:
- NetworkClient();
- int loginedPlayer() const;
-};
-
-#endif // CLIENT_H
diff --git a/SnakeClient/SnakeApp/back-end/ProfileViewItems/notificationdata.cpp b/SnakeClient/SnakeApp/back-end/ProfileViewItems/notificationdata.cpp
deleted file mode 100644
index 94bbce1..0000000
--- a/SnakeClient/SnakeApp/back-end/ProfileViewItems/notificationdata.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#include "notificationdata.h"
-
-NotificationData::NotificationData(const QString &title,
- const QString &text,
- const QString &img, Type type) {
-
- _text = text;
- _title = title;
- _img = img;
- _type = type;
-}
-
-QString NotificationData::text() const {
- return _text;
-}
-
-QString NotificationData::img() const {
- return _img;
-}
-
-QString NotificationData::title() const {
- return _title;
-}
-
-bool NotificationData::operator ==(const NotificationData &righ) {
- return _title == righ._title &&
- _text == righ._text &&
- _img == righ._img &&
- _type == righ._type;
-}
-
-bool NotificationData::operator !=(const NotificationData &righ) {
- return !operator==(righ);
-}
-
-int NotificationData::type() const {
- return _type;
-}
diff --git a/SnakeClient/SnakeApp/back-end/ProfileViewItems/notificationdata.h b/SnakeClient/SnakeApp/back-end/ProfileViewItems/notificationdata.h
deleted file mode 100644
index dc9ad1d..0000000
--- a/SnakeClient/SnakeApp/back-end/ProfileViewItems/notificationdata.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef NOTIFICATIONDATA_H
-#define NOTIFICATIONDATA_H
-#include
-
-class NotificationData
-{
- Q_GADGET
- Q_PROPERTY(QString text READ text)
- Q_PROPERTY(QString img READ img)
- Q_PROPERTY(QString title READ title)
- Q_PROPERTY(int type READ type)
-
- QString _text;
- QString _img;
- QString _title;
- int _type;
-
-public:
-
- enum Type {
- Normal,
- Warning = 1,
- Error = 2,
- };
-
- explicit NotificationData(const QString& title = "",
- const QString& text = "",
- const QString& img = "",
- Type type = Type::Normal);
-
- Q_INVOKABLE QString text() const;
- Q_INVOKABLE QString img() const;
- Q_INVOKABLE QString title() const;
- Q_INVOKABLE int type() const;
-
- bool operator ==(const NotificationData &righ);
- bool operator !=(const NotificationData &righ);
-
-};
-
-#endif // NOTIFICATIONDATA_H
diff --git a/SnakeClient/SnakeApp/back-end/ProfileViewItems/notificationservice.cpp b/SnakeClient/SnakeApp/back-end/ProfileViewItems/notificationservice.cpp
deleted file mode 100644
index 39caa5f..0000000
--- a/SnakeClient/SnakeApp/back-end/ProfileViewItems/notificationservice.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#include "notificationservice.h"
-
-NotificationService::NotificationService(QObject * ptr): QObject (ptr) {
- qRegisterMetaType("NotificationData");
- qRegisterMetaType> ("QList");
-
-}
-
-NotificationData NotificationService::notify() const {
- return _notify;
-}
-
-void NotificationService::setNotify(const NotificationData& notify) {
- if (_notify != notify)
- _history.push_back(_notify);
-
- _notify = notify;
-
- emit notifyChanged();
-}
-
-void NotificationService::setNotify(const QString &title,
- const QString &text,
- const QString &img,
- int type) {
-
- setNotify(NotificationData(title, text, img,
- static_cast(type)));
-}
-
-NotificationService *NotificationService::getService() {
- static auto service = new NotificationService;
- return service;
-}
-
-const QList &NotificationService::history() const {
- return _history;
-}
diff --git a/SnakeClient/SnakeApp/back-end/ProfileViewItems/notificationservice.h b/SnakeClient/SnakeApp/back-end/ProfileViewItems/notificationservice.h
deleted file mode 100644
index 75dcef9..0000000
--- a/SnakeClient/SnakeApp/back-end/ProfileViewItems/notificationservice.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef NOTIFICATIONSERVICE_H
-#define NOTIFICATIONSERVICE_H
-
-#include "notificationdata.h"
-
-#include
-
-class NotificationService: public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(NotificationData notify READ notify NOTIFY notifyChanged)
- Q_PROPERTY(QList history READ history NOTIFY notifyChanged)
-
-private:
- explicit NotificationService(QObject *ptr = nullptr);
-
- NotificationData _notify;
- QList _history;
-
-public:
- NotificationData notify() const;
- void setNotify(const NotificationData ¬ify);
- Q_INVOKABLE void setNotify(const QString& title = "",
- const QString& text = "",
- const QString& img = "",
- int type = NotificationData::Normal);
-
- static NotificationService* getService();
-
- const QList & history() const;
-
-signals:
- void notifyChanged();
-};
-
-
-
-#endif // NOTIFICATIONSERVICE_H
diff --git a/SnakeClient/SnakeApp/back-end/ProfileViewItems/playerclientdata.cpp b/SnakeClient/SnakeApp/back-end/ProfileViewItems/playerclientdata.cpp
deleted file mode 100644
index 509ed40..0000000
--- a/SnakeClient/SnakeApp/back-end/ProfileViewItems/playerclientdata.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "playerclientdata.h"
-
-PlayerClientData::PlayerClientData()
-{
-
-}
diff --git a/SnakeClient/SnakeApp/back-end/ProfileViewItems/playerclientdata.h b/SnakeClient/SnakeApp/back-end/ProfileViewItems/playerclientdata.h
deleted file mode 100644
index fc5a4c5..0000000
--- a/SnakeClient/SnakeApp/back-end/ProfileViewItems/playerclientdata.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef PLAYERCLIENTDATA_H
-#define PLAYERCLIENTDATA_H
-#include
-
-class PlayerClientData: public ClientProtocol::Player
-{
-public:
- PlayerClientData();
-};
-
-#endif // PLAYERCLIENTDATA_H
diff --git a/SnakeClient/SnakeApp/back-end/ProfileViewItems/settingsviewmodel.cpp b/SnakeClient/SnakeApp/back-end/ProfileViewItems/settingsviewmodel.cpp
deleted file mode 100644
index 2279777..0000000
--- a/SnakeClient/SnakeApp/back-end/ProfileViewItems/settingsviewmodel.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "settingsviewmodel.h"
-#include
-#include "settings.h"
-
-void SettingsViewModel::handleValueChanged(QString key, QVariant value) {
- if (key == SERVER_ADDRESS) {
- emit hostChanged(value.toString());
- } else if (key == SERVER_ADDRESS_PORT) {
- emit portChanged(value.toInt());
- } else if (key == THEME) {
- emit themeChanged(value.toInt());
- }
-}
-
-SettingsViewModel::SettingsViewModel(QObject *ptr):
- QObject (ptr) {
- _cfg = Settings::get();
-
- connect(_cfg, &Settings::valueChanged, this , &SettingsViewModel::handleValueChanged);
-}
-
-int SettingsViewModel::port() const {
- return _cfg->getValue(SERVER_ADDRESS_PORT, SERVER_ADDRESS_DEFAULT_PORT).toInt();
-}
-
-QString SettingsViewModel::host() const {
- return _cfg->getValue(SERVER_ADDRESS, SERVER_ADDRESS_DEFAULT).toString();
-}
-
-int SettingsViewModel::theme() const {
- return _cfg->getValue(THEME, THEME_DEFAULT).toInt();
-}
-
-void SettingsViewModel::forceUpdate() {
- emit hostChanged("");
- emit portChanged(0);
- emit themeChanged(0);
-
-}
-
-void SettingsViewModel::toDefault() {
- setPort(SERVER_ADDRESS_DEFAULT_PORT);
- setHost(SERVER_ADDRESS_DEFAULT);
- setTheme(THEME_DEFAULT);
-}
-
-void SettingsViewModel::setPort(int port) {
- _cfg->setValue(SERVER_ADDRESS_PORT, port);
-}
-
-void SettingsViewModel::setHost(const QString& host) {
- _cfg->setValue(SERVER_ADDRESS, host);
-}
-
-void SettingsViewModel::setTheme(int theme) {
- _cfg->setValue(THEME, theme);
-}
diff --git a/SnakeClient/SnakeApp/back-end/ProfileViewItems/settingsviewmodel.h b/SnakeClient/SnakeApp/back-end/ProfileViewItems/settingsviewmodel.h
deleted file mode 100644
index 9727844..0000000
--- a/SnakeClient/SnakeApp/back-end/ProfileViewItems/settingsviewmodel.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef SETTINGSVIEWMODEL_H
-#define SETTINGSVIEWMODEL_H
-
-#include
-#include "./../settings.h"
-
-
-class SettingsViewModel: public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int port READ port WRITE setPort NOTIFY portChanged)
- Q_PROPERTY(QString host READ host WRITE setHost NOTIFY hostChanged)
- Q_PROPERTY(int theme READ theme WRITE setTheme NOTIFY themeChanged)
-
-private:
- Settings *_cfg = nullptr;
-
-private slots:
- void handleValueChanged(QString key, QVariant value);
-
-public:
- SettingsViewModel(QObject* ptr = nullptr);
- int port() const;
- QString host() const;
- int theme() const;
-
- Q_INVOKABLE void forceUpdate();
- Q_INVOKABLE void toDefault();
-
-
-public slots:
- void setPort(int port);
- void setHost(const QString &host);
- void setTheme(int theme);
-
-signals:
- void portChanged(int port);
- void hostChanged(const QString &host);
- void themeChanged(int theme);
-};
-
-#endif // SETTINGSVIEWMODEL_H
diff --git a/SnakeClient/SnakeApp/back-end/ProfileViewItems/userview.cpp b/SnakeClient/SnakeApp/back-end/ProfileViewItems/userview.cpp
deleted file mode 100644
index 66867a9..0000000
--- a/SnakeClient/SnakeApp/back-end/ProfileViewItems/userview.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-#include "userview.h"
-
-const PlayerClientData *UserView::getSource() const {
- return _source.data();
-}
-
-void UserView::setSource(QSharedPointer data) {
-
- _offline = data == nullptr;
-
- if (data->id() != _source->id()) {
- _source = data;
- emit sourceChanged();
- }
-}
-
-bool UserView::offline() const {
- return _offline;
-}
-
-void UserView::setOffline(bool offline) {
- if (_offline != offline) {
- emit offlineChanged(_offline = offline);
- }
-}
-
-UserView::UserView(QObject *parent) : QObject(parent) {
-
-}
-
-QString UserView::name() const {
- if (!_source) {
- return tr("Undefined name");
- }
- return _source->getName();
-}
-
-QString UserView::gmail() const {
- if (!_source) {
- return tr("Undefined gmail");
- }
- return _source->getGmail();
-}
-
-int UserView::money() const {
- if (!_source) {
- return -1;
- }
- return static_cast(_source->getMany());
-}
-
-int UserView::record() const {
- if (!_source) {
- return -1;
- }
- return static_cast(_source->getRecord());
-}
-
-int UserView::avgRecord() const {
- if (!_source) {
- return -1;
- }
- return static_cast(_source->getAvgRecord());
-}
-
-int UserView::cureentSnake() const {
- if (!_source) {
- return -1;
- }
- return _source->getCureentSnake();
-}
-
-int UserView::id() const {
- if (!_source) {
- return -1;
- }
- return _source->id();
-}
diff --git a/SnakeClient/SnakeApp/back-end/ProfileViewItems/userview.h b/SnakeClient/SnakeApp/back-end/ProfileViewItems/userview.h
deleted file mode 100644
index 455f294..0000000
--- a/SnakeClient/SnakeApp/back-end/ProfileViewItems/userview.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef USERVIEW_H
-#define USERVIEW_H
-
-#include "playerclientdata.h"
-
-#include
-
-class UserView : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QString name READ name NOTIFY sourceChanged)
- Q_PROPERTY(QString gmail READ gmail NOTIFY sourceChanged)
- Q_PROPERTY(int money READ money NOTIFY sourceChanged)
- Q_PROPERTY(int record READ record NOTIFY sourceChanged)
- Q_PROPERTY(int avgRecord READ avgRecord NOTIFY sourceChanged)
- Q_PROPERTY(int cureentSnake READ cureentSnake NOTIFY sourceChanged)
- Q_PROPERTY(int id READ id NOTIFY sourceChanged)
- Q_PROPERTY(bool offline READ offline NOTIFY offlineChanged)
-
-private:
- QSharedPointer _source = nullptr;
-
- bool _offline = false;
-
-public:
- explicit UserView(QObject *parent = nullptr);
-
- QString name() const;
- QString gmail() const;
- int money() const;
- int record() const;
- int avgRecord() const;
- int cureentSnake() const;
- int id() const;
-
- const PlayerClientData *getSource() const;
- bool offline() const;
- void setOffline(bool offline);
-
-signals:
-
- void sourceChanged();
-
- void offlineChanged(bool offline);
-
-public slots:
- void setSource(QSharedPointer data);
-
-};
-
-#endif // USERVIEW_H
diff --git a/SnakeClient/SnakeApp/back-end/asyncimageresponse.cpp b/SnakeClient/SnakeApp/back-end/asyncimageresponse.cpp
deleted file mode 100644
index b6d7113..0000000
--- a/SnakeClient/SnakeApp/back-end/asyncimageresponse.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "asyncimageresponse.h"
-
-AsyncImageResponse::AsyncImageResponse() = default;
-AsyncImageResponse::~AsyncImageResponse() = default;
-
-QQuickTextureFactory *AsyncImageResponse::textureFactory() const {
- return _texture;
-}
-
-// memory leak ?
-void AsyncImageResponse::setResult(const QImage& image) {
- _texture = QQuickTextureFactory::textureFactoryForImage(image);
- emit finished();
-// deleteLater();
-}
-
-void AsyncImageResponse::error(const QString &err) {
- _errorString = " " + err;
-}
-
-QString AsyncImageResponse::errorString() const {
- return QQuickImageResponse::errorString() + _errorString;
-}
diff --git a/SnakeClient/SnakeApp/back-end/asyncimageresponse.h b/SnakeClient/SnakeApp/back-end/asyncimageresponse.h
deleted file mode 100644
index ca04a34..0000000
--- a/SnakeClient/SnakeApp/back-end/asyncimageresponse.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef ASYNCIMAGERESPONSE_H
-#define ASYNCIMAGERESPONSE_H
-
-#include
-
-
-class AsyncImageResponse : public QQuickImageResponse {
-
-private:
- QQuickTextureFactory *_texture = nullptr;
- QString _errorString;
-public:
-
- AsyncImageResponse ();
- ~AsyncImageResponse () override;
-
- QQuickTextureFactory *textureFactory() const override;
-
- void setResult(const QImage &image);
- void error(const QString &err);
-
- QString errorString() const override;
-};
-#endif // ASYNCIMAGERESPONSE_H
diff --git a/SnakeClient/SnakeApp/back-end/background.cpp b/SnakeClient/SnakeApp/back-end/background.cpp
deleted file mode 100644
index 50cd2f2..0000000
--- a/SnakeClient/SnakeApp/back-end/background.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "background.h"
-
-BackGround::BackGround(double x, double y): ItemWorld (x, y) {
- this->setSize(200, 400);
- this->setTexture("qrc:/texture/asphalt");
- setBeckGroundObject(true);
-}
-
-void BackGround::render() {
- auto wPart = w() / 2;
-
- if (m_x + wPart < 200) {
- setX(wPart);
- }
-}
-
-void BackGround::reset() {
- setX(0 - w());
- render();
-}
diff --git a/SnakeClient/SnakeApp/back-end/background.h b/SnakeClient/SnakeApp/back-end/background.h
deleted file mode 100644
index 26e4619..0000000
--- a/SnakeClient/SnakeApp/back-end/background.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef BACKGROUND_H
-#define BACKGROUND_H
-
-#include "itemworld.h"
-
-
-class BackGround : public ItemWorld
-{
-public:
- BackGround(double x, double y);
-
- void render() override;
- void reset() override;
-};
-
-#endif // BACKGROUND_H
diff --git a/SnakeClient/SnakeApp/back-end/backgrounditem.cpp b/SnakeClient/SnakeApp/back-end/backgrounditem.cpp
deleted file mode 100644
index dcdfbea..0000000
--- a/SnakeClient/SnakeApp/back-end/backgrounditem.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "backgrounditem.h"
-
-#include
-
-BackGroundItem::BackGroundItem(double x, double y):
- ItemWorld (x, y) {
- setBeckGroundObject(true);
- reset();
-}
-
-void BackGroundItem::reset() {
- auto tempColor = QColor(rand() % 255, rand() % 255, rand() % 255, 10);
- setColor(tempColor.name(QColor::HexArgb));
- auto radius = rand() % 200;
- setSize(radius , radius);
-
- setRadius(radius / 2);
-
-}
diff --git a/SnakeClient/SnakeApp/back-end/backgrounditem.h b/SnakeClient/SnakeApp/back-end/backgrounditem.h
deleted file mode 100644
index 6999772..0000000
--- a/SnakeClient/SnakeApp/back-end/backgrounditem.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef BACKGROUNDITEM_H
-#define BACKGROUNDITEM_H
-
-#include "itemworld.h"
-
-
-class BackGroundItem : public ItemWorld
-{
-public:
- BackGroundItem(double x, double y);
- void reset() override;
-
-};
-
-#endif // BACKGROUNDITEM_H
diff --git a/SnakeClient/SnakeApp/back-end/baseclass.cpp b/SnakeClient/SnakeApp/back-end/baseclass.cpp
deleted file mode 100644
index f635b82..0000000
--- a/SnakeClient/SnakeApp/back-end/baseclass.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#include "baseclass.h"
-
-void BaseClass::setName(const QString &value) {
- name = value;
-}
-
-BaseClass::BaseClass() :
- name("BaseClass") {
-}
-
-BaseClass::~BaseClass() {
-
-}
-
-QString BaseClass::getName() const {
- return name;
-}
diff --git a/SnakeClient/SnakeApp/back-end/baseclass.h b/SnakeClient/SnakeApp/back-end/baseclass.h
deleted file mode 100644
index a25ed02..0000000
--- a/SnakeClient/SnakeApp/back-end/baseclass.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef BASECLASS_H
-#define BASECLASS_H
-#include
-
-class BaseClass
-{
-private:
- QString name;
-public:
- BaseClass();
- virtual void render() = 0;
- virtual ~BaseClass();
- QString getName() const;
- void setName(const QString &value);
-};
-
-#endif // BASECLASS_H
diff --git a/SnakeClient/SnakeApp/back-end/box.cpp b/SnakeClient/SnakeApp/back-end/box.cpp
deleted file mode 100644
index 182bf46..0000000
--- a/SnakeClient/SnakeApp/back-end/box.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "box.h"
-
-#include
-
-Box::Box(double x, double y):
- ItemWorld (x, y) {
-
- this->setSize(10, 10);
-
- setColor(QColor(100, 100, 100).name());
-}
-
diff --git a/SnakeClient/SnakeApp/back-end/box.h b/SnakeClient/SnakeApp/back-end/box.h
deleted file mode 100644
index 7fd71a4..0000000
--- a/SnakeClient/SnakeApp/back-end/box.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef BOX_H
-#define BOX_H
-
-#include "itemworld.h"
-
-class Box: public ItemWorld
-{
-public:
- Box(double x, double y);
-
-};
-
-#endif // BOX_H
diff --git a/SnakeClient/SnakeApp/back-end/clientapp.cpp b/SnakeClient/SnakeApp/back-end/clientapp.cpp
deleted file mode 100644
index 2d9e109..0000000
--- a/SnakeClient/SnakeApp/back-end/clientapp.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "clientapp.h"
-#include "imageprovider.h"
-#include "ProfileViewItems/userview.h"
-#include
-#include
-
-#include
-#include
-
-QByteArray ClientApp::initTheme() {
- int themeIndex = Settings::get()->getValue(THEME, THEME_DEFAULT).toInt();
-
- switch (themeIndex) {
- case 1: return "Dark";
- default: return "Light";
- }
-
-}
-
-ClientApp::ClientApp() {
-}
-
-ClientApp::~ClientApp() {
-}
-
-bool ClientApp::init(QQmlApplicationEngine *engine) {
-
- qputenv("QT_QUICK_CONTROLS_MATERIAL_THEME", initTheme());
-
- qmlRegisterType ();
- qmlRegisterType ();
- qmlRegisterType ();
- qmlRegisterType ();
-
- auto root = engine->rootContext();
- if (!root)
- return false;
-
-
- engine->addImageProvider(QLatin1String("userItems"), new ImageProvider());
-
- root->setContextProperty("contr", &contr);
- root->setContextProperty("notificationService", NotificationService::getService());
-
- engine->load(QUrl(QStringLiteral("qrc:/front-end/main.qml")));
- if (engine->rootObjects().isEmpty())
- return false;
-
- return true;
-}
diff --git a/SnakeClient/SnakeApp/back-end/clientapp.h b/SnakeClient/SnakeApp/back-end/clientapp.h
deleted file mode 100644
index 8045ff2..0000000
--- a/SnakeClient/SnakeApp/back-end/clientapp.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef CLIENTAPP_H
-#define CLIENTAPP_H
-
-#include "controller.h"
-#include "diff.h"
-
-class QQmlApplicationEngine;
-
-class ClientApp
-{
-private:
- Controller contr;
-
- QByteArray initTheme();
-
-public:
- ClientApp();
- ~ClientApp();
- bool init(QQmlApplicationEngine* engine);
-};
-
-#endif // CLIENTAPP_H
diff --git a/SnakeClient/SnakeApp/back-end/controller.cpp b/SnakeClient/SnakeApp/back-end/controller.cpp
deleted file mode 100644
index 84473de..0000000
--- a/SnakeClient/SnakeApp/back-end/controller.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-#include "controller.h"
-#include
-#include
-#include "diff.h"
-#include
-#include "ProfileViewItems/mainmenumodel.h"
-#include
-
-Controller::Controller() {
- srand(static_cast(time(nullptr)));
- timer = new QTimer();
- timer->setInterval(1);
-
- _networkModel = new MainMenuModel(this);
-
- connect(timer, SIGNAL(timeout()), this, SLOT(update()));
- connect(_networkModel, &MainMenuModel::newGame, this, &Controller::handleNewGame);
-
-}
-
-Controller::~Controller() {
-
-}
-
-bool Controller::nextLvl() {
- if (lvl + 1 >= lvls.size()) {
- return true;
- }
- m_generalLong += static_cast(world.getCurrentLong());
-
- generateDiff(world.init(lvls.value(++lvl)));
- startTimer();
-
-
- return false;
-}
-
-void Controller::generateDiff(const QMap& objs) {
-
- auto removeIds = objectsContainer.keys();
- QList addedIds;
-
- for (auto i = objs.begin(); i != objs.end(); ++i) {
- if (objectsContainer.contains(i.key())) {
- removeIds.removeOne(i.key());
- } else {
- objectsContainer.insert(i.key(), i.value());
- addedIds.push_back(i.key());
- }
- }
-
- if (removeIds.size() || addedIds.size()) {
- Diff diff;
-
- diff.setRemoveIds(removeIds);
- diff.setAddedIds(addedIds);
- emit gameObjectsChanged(diff);
- }
-}
-
-void Controller::update() {
- if (pause) {
- return;
- }
-
- world.render();
-
- if(world.isDefiat()) {
- stopTimer();
- if (!_showMenu) {
- setShowMenu(true);
- }
- handleNewGame();
- }
-
- if (world.isEnd()) {
- stopTimer();
-
- if (!_showMenu) {
-
- NotificationData notify(tr(" Next Lvl!!!"),
- tr(" You anblock next lvl (%0)" ).arg(lvl),
- "qrc:/texture/up");
-
- NotificationService::getService()->setNotify(notify);
- }
-
- nextLvl();
-
- }
-
- long_changed(static_cast(world.getCurrentLong()));
- generalLongchanged(generalLong());
-
-}
-
-void Controller::handleNewGame() {
-
- world.resetPosition();
-
- WorldRules newGameRules = lvls.first();
- lvl = 0;
- m_generalLong = 0;
- generateDiff(world.init(newGameRules));
- startTimer();
-}
-
-QObject *Controller::getGameObject(int id) {
- return objectsContainer.value(id, nullptr);
-}
-
-void Controller::startTimer() {
- timer->start();
-}
-
-void Controller::stopTimer() {
- timer->stop();
-}
-
-int Controller::long_() const {
- return static_cast(world.getCurrentLong());
-}
-
-int Controller::generalLong() const {
- return m_generalLong + long_();
-}
-
-QObject *Controller::mainMenuModel() const {
- return _networkModel;
-}
-
-void Controller::buttonPress() {
- world.reversClick();
-}
-
-void Controller::setPause(bool p){
- pause = p;
- if (!pause) {
- world.unPause();
- }
-}
-
-bool Controller::showMenu() const {
- return _showMenu;
-}
-
-void Controller::setShowMenu(bool showMenu) {
- if (_showMenu == showMenu)
- return;
-
- _showMenu = showMenu;
- emit showMenuChanged(_showMenu);
-}
-
diff --git a/SnakeClient/SnakeApp/back-end/controller.h b/SnakeClient/SnakeApp/back-end/controller.h
deleted file mode 100644
index 93c0795..0000000
--- a/SnakeClient/SnakeApp/back-end/controller.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef CONTROLLER_H
-#define CONTROLLER_H
-
-#include
-#include
-#include
-#include "diff.h"
-#include "snake.h"
-#include "world.h"
-
-class MainMenuModel;
-
-class Controller : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(int long_ READ long_ NOTIFY long_changed)
- Q_PROPERTY(int generalLong READ generalLong NOTIFY generalLongchanged)
- Q_PROPERTY(QObject* mainMenuModel READ mainMenuModel NOTIFY mainMenuModelchanged)
- Q_PROPERTY(bool showMenu READ showMenu WRITE setShowMenu NOTIFY showMenuChanged)
-
-private:
-
- World world;
- QMap objectsContainer;
- QTimer *timer = nullptr;
-
- int lvl = 0;
- int m_generalLong = 0;
- bool pause = false;
- bool _showMenu = true;
-
- void generateDiff(const QMap &);
-
- MainMenuModel* _networkModel = nullptr;
-
-public:
- Controller();
- ~Controller();
-
- void startTimer();
- void stopTimer();
-
- int long_() const;
- int generalLong() const;
- bool showMenu() const;
-
- QObject* mainMenuModel() const;
-
-public slots:
- void buttonPress();
- void setPause(bool);
- void update();
-
- /**
- * @brief nextLvl - switch to next lvl from array lvels
- * @return true if all levels are passed
- */
- bool nextLvl();
-
- /**
- * @brief newGame - start game from first lvl
- */
- void handleNewGame();
-
- /**
- * @brief getGameObject
- * @param id - id of guiObject;
- * @return guiObject if (id is not valid return nullptr)
- */
- QObject* getGameObject(int id);
-
- void setShowMenu(bool showMenu);
-
-signals:
-
- /**
- * @brief gameObjectsChanged
- * @param dif
- */
- void gameObjectsChanged(const Diff &dif);
- void long_changed(int m_long);
- void generalLongchanged(int generalLong);
- void mainMenuModelchanged(QObject* mainMenuModel);
- void showMenuChanged(bool showMenu);
-};
-
-#endif // CONTROLLER_H
diff --git a/SnakeClient/SnakeApp/back-end/diff.cpp b/SnakeClient/SnakeApp/back-end/diff.cpp
deleted file mode 100644
index 489a756..0000000
--- a/SnakeClient/SnakeApp/back-end/diff.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "diff.h"
-
-QList Diff::getRemoveIds() const {
- return removeIds;
-}
-
-void Diff::setRemoveIds(const QList &value) {
- removeIds = value;
-}
-
-QList Diff::getAddedIds() const {
- return addedIds;
-}
-
-void Diff::setAddedIds(const QList &value) {
- addedIds = value;
-}
-
-Diff::Diff(){
-
-}
diff --git a/SnakeClient/SnakeApp/back-end/diff.h b/SnakeClient/SnakeApp/back-end/diff.h
deleted file mode 100644
index 7733e7b..0000000
--- a/SnakeClient/SnakeApp/back-end/diff.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef DIFF_H
-#define DIFF_H
-
-#include
-
-class Diff
-{
- Q_GADGET
-private:
- QList removeIds;
- QList addedIds;
-public:
- explicit Diff();
-
- Q_INVOKABLE QList getRemoveIds() const;
- void setRemoveIds(const QList &value);
- Q_INVOKABLE QList getAddedIds() const;
- void setAddedIds(const QList &value);
-};
-
-Q_DECLARE_METATYPE(Diff)
-
-#endif // DIFF_H
diff --git a/SnakeClient/SnakeApp/back-end/guiobject.cpp b/SnakeClient/SnakeApp/back-end/guiobject.cpp
deleted file mode 100644
index 419c576..0000000
--- a/SnakeClient/SnakeApp/back-end/guiobject.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-#include "guiobject.h"
-
-GuiObject::GuiObject(const QString &viewTempalte, QObject *ptr):
- QObject (ptr) {
- m_viewTemplate = viewTempalte;
- generateId();
-
-}
-
-double GuiObject::angle() const {
- return m_angle;
-}
-
-QString GuiObject::texture() const {
- return m_texture;
-}
-
-void GuiObject::render() {
-}
-
-QRectF GuiObject::rect() const {
- return QRectF(m_x - m_w / 2, m_y - m_h / 2, m_w, m_h);
-}
-
-void GuiObject::setAngle(double angle) {
- m_angle = angle;
- emit angleChanged(m_angle);
-}
-
-int GuiObject::guiId() const {
- return m_guiId;
-}
-
-QString GuiObject::color() const {
- return m_color;
-}
-
-void GuiObject::setColor(QString color) {
- if (m_color == color)
- return;
-
- m_color = color;
- emit colorChanged(m_color);
-}
-
-double GuiObject::x() const {
- return m_x;
-}
-
-double GuiObject::y() const {
- return m_y;
-}
-
-double GuiObject::w() const {
- return m_w;
-}
-
-double GuiObject::h() const {
- return m_h;
-}
-
-void GuiObject::generateId() {
- static int id = 0;
- m_guiId = id++;
-}
-
-void GuiObject::setH(double h) {
- m_h = h;
- emit hChanged(m_h);
-}
-
-void GuiObject::reset() {
- setX(-1);
- setY(-1);
-}
-
-int GuiObject::radius() const {
- return m_radius;
-}
-
-QString GuiObject::viewTemplate() const {
- return m_viewTemplate;
-}
-
-void GuiObject::setRadius(int radius) {
- if (m_radius == radius)
- return;
-
- m_radius = radius;
- emit radiusChanged(m_radius);
-}
-
-void GuiObject::setW(double w) {
- m_w = w;
- emit wChanged(m_w);
-
-}
-
-void GuiObject::setY(double y) {
- m_y = y;
- emit yChanged(m_y);
-
-}
-
-void GuiObject::setX(double x) {
- m_x = x;
- emit xChanged(m_x);
-
-}
-
-void GuiObject::setTexture(const QString &texture) {
- m_texture = texture;
- emit textureChanged(m_texture);
-}
-
-
diff --git a/SnakeClient/SnakeApp/back-end/guiobject.h b/SnakeClient/SnakeApp/back-end/guiobject.h
deleted file mode 100644
index dc903ef..0000000
--- a/SnakeClient/SnakeApp/back-end/guiobject.h
+++ /dev/null
@@ -1,91 +0,0 @@
-#ifndef GUIOBJECT_H
-#define GUIOBJECT_H
-
-#include "baseclass.h"
-#include "QObject"
-
-#include
-
-class GuiObject:public QObject, public BaseClass
-{
- Q_OBJECT
-// @todo: add color
- Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
- Q_PROPERTY(double angle READ angle NOTIFY angleChanged)
- Q_PROPERTY(QString texture READ texture NOTIFY textureChanged)
- Q_PROPERTY(int guiId READ guiId NOTIFY guiIdChanged)
- Q_PROPERTY(QString viewTemplate READ viewTemplate NOTIFY viewTemplateChanged)
- Q_PROPERTY(int radius READ radius WRITE setRadius NOTIFY radiusChanged)
-
- Q_PROPERTY(double x READ x NOTIFY xChanged)
- Q_PROPERTY(double y READ y NOTIFY yChanged)
- Q_PROPERTY(double w READ w NOTIFY wChanged)
- Q_PROPERTY(double h READ h NOTIFY hChanged)
-
-private:
- void generateId();
- QString m_viewTemplate;
-
-protected:
- int m_guiId = -1;
- double m_angle = 0;
- QString m_texture = "";
- QString m_color = "";
- int m_radius = 0;
-
- double m_x = 0;
- double m_y = 0;
- double m_w = 0;
- double m_h = 0;
-
- void setTexture(const QString &texture);
-
-
-public:
- GuiObject(const QString& viewTempalte = "GraphicItem", QObject *ptr = nullptr);
-
- double angle() const;
- QString texture() const;
-
- void render() override;
-
- QRectF rect() const;
- virtual void setAngle(double angle);
- int guiId() const;
-
- QString color() const;
-
- void setColor(QString color);
-
- double x() const;
- double y() const;
- double w() const;
- double h() const;
-
- void setX(double x);
- void setY(double y);
- void setW(double w);
- void setH(double h);
-
- virtual void reset();
- int radius() const;
- QString viewTemplate() const;
-
-public slots:
-
- void setRadius(int radius);
-
-signals:
- void angleChanged(double angle);
- void textureChanged(QString texture);
- void guiIdChanged(int guiId);
- void colorChanged(QString color);
- void xChanged(double x);
- void yChanged(double y);
- void wChanged(double w);
- void hChanged(double h);
- void radiusChanged(int radius);
- void viewTemplateChanged(QString viewTemplate);
-};
-
-#endif // GUIOBJECT_H
diff --git a/SnakeClient/SnakeApp/back-end/guiobjectfactory.cpp b/SnakeClient/SnakeApp/back-end/guiobjectfactory.cpp
deleted file mode 100644
index 4313c60..0000000
--- a/SnakeClient/SnakeApp/back-end/guiobjectfactory.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "guiobjectfactory.h"
-#include "box.h"
-#include
-#include "head.h"
-#include "background.h"
-#include "backgrounditem.h"
-
-GuiObjectFactory::GuiObjectFactory() {}
-
-ItemWorld *GuiObjectFactory::generate(const QString &name) {
- ItemWorld *obj = nullptr;
- if (name == "Box") {
- obj = new Box(rand() % 400, 0);
- }
- else if (name == "BackGround") {
- obj = new BackGround(0, 0);
- }
- else if (name == "BackGroundItem") {
- obj = new BackGroundItem(0, 0);
- }
-
- return obj;
-}
diff --git a/SnakeClient/SnakeApp/back-end/guiobjectfactory.h b/SnakeClient/SnakeApp/back-end/guiobjectfactory.h
deleted file mode 100644
index 1d60fe3..0000000
--- a/SnakeClient/SnakeApp/back-end/guiobjectfactory.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef GUIOBJECTFACTORY_H
-#define GUIOBJECTFACTORY_H
-
-#include
-
-class ItemWorld;
-
-/**
- * @brief The GuiObjectFactory class
- * factory of gui ojects;
- */
-class GuiObjectFactory
-{
-public:
- GuiObjectFactory();
-
- /**
- * @brief generate - generate the child of GuiObject
- * by object name.
- * @param name - name of class of genereta object
- * @return pointer of generated object.
- * If method called with not valid name then return nullptr.
- */
- static ItemWorld* generate(const QString& name);
-};
-
-#endif // GUIOBJECTFACTORY_H
diff --git a/SnakeClient/SnakeApp/back-end/head.cpp b/SnakeClient/SnakeApp/back-end/head.cpp
deleted file mode 100644
index 3701d32..0000000
--- a/SnakeClient/SnakeApp/back-end/head.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-#include "head.h"
-#include
-#include
-
-void Head::render() {
-
-
- qint64 tempTime = QDateTime::currentMSecsSinceEpoch() - time;
- time = QDateTime::currentMSecsSinceEpoch();
-
- double my = (m_y + (*speed * 0.55) * sin(m_angle * TO_RADIAN));
- m_y += (my - m_y) / 1000 * tempTime;
-
- if (*speed < 1) {
- setColor(generalSpeadColor);
- setRadius(static_cast(m_w * 0.4));
-
- } else if (*speed < normSpead) {
- setColor(normSpeadColor);
- setRadius(static_cast(m_w * 0.5));
-
- } else if (*speed < fastSpead) {
- setColor(fastSpeadColor);
- setRadius(static_cast(m_w * 0.5));
-
- } else if (*speed < megaFastSpead) {
- setColor(megaFastSpeadColor);
- setRadius(static_cast(m_w * 0.4));
-
- }
-
- emit yChanged(m_y);
-}
-
-void Head::reset() {
-}
-
-void Head::unPause() {
- time = QDateTime::currentMSecsSinceEpoch();
-}
-
-Head::Head(double x, double y, double h, double w, double *spead):
- GuiObject ("SnakeItem") {
- setX(x);
- setY(y);
- setW(w);
- setH(h);
- this->speed = spead;
-}
-
-void Head::setAngle(double angle) {
- m_angle = angle;
- emit angleChanged(m_angle);
-}
-
-Head::~Head() {
-
-}
diff --git a/SnakeClient/SnakeApp/back-end/head.h b/SnakeClient/SnakeApp/back-end/head.h
deleted file mode 100644
index 47fb207..0000000
--- a/SnakeClient/SnakeApp/back-end/head.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef HEAD_H
-#define HEAD_H
-#define TO_RADIAN 0.017453293
-
-
-#include "guiobject.h"
-#include
-
-class Head : public GuiObject
-{
-private:
- qint64 time;
- double *speed;
- const int megaFastSpead = 200;
- const int fastSpead = 100;
- const int normSpead = 50;
-
- const QString generalSpeadColor = "#616a6b";
- const QString normSpeadColor = "#5d6d7e";
- const QString fastSpeadColor = "#eb984e";
- const QString megaFastSpeadColor = "#ec7063";
-
-public:
- Head(double x , double y, double h, double w, double *speed);
- void setAngle(double angle) override;
- void render() override;
- void reset() override;
- void unPause();
- ~Head() override;
-};
-
-#endif // HEAD_H
diff --git a/SnakeClient/SnakeApp/back-end/imageprovider.cpp b/SnakeClient/SnakeApp/back-end/imageprovider.cpp
deleted file mode 100644
index 6300532..0000000
--- a/SnakeClient/SnakeApp/back-end/imageprovider.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "asyncimageresponse.h"
-#include "imageprovider.h"
-#include
-#include
-
-ImageProvider::ImageProvider() = default;
-ImageProvider::~ImageProvider() = default;
-
-QQuickImageResponse *ImageProvider::requestImageResponse(const QString &id,
- const QSize &requestedSize) {
-
- AsyncImageResponse* response = new AsyncImageResponse();
- auto readImage = [id, requestedSize, response]() mutable {
- Q_UNUSED(requestedSize);
-
- auto params = id.split("/");
-
- if (params.contains("player")) {
- response->setResult(QImage(":/img/defaultuser").
- scaled(requestedSize, Qt::KeepAspectRatioByExpanding));
-
- } else if (params.contains("item")) {
- response->setResult(QImage(":/img/defaultsnake").
- scaled(requestedSize, Qt::KeepAspectRatioByExpanding));
- } else {
- response->error("Wrong first parametr example 'first/last'");
- }
-
- };
-
- QtConcurrent::run(readImage);
-
- return response;
-}
-
-
-
diff --git a/SnakeClient/SnakeApp/back-end/imageprovider.h b/SnakeClient/SnakeApp/back-end/imageprovider.h
deleted file mode 100644
index 188380e..0000000
--- a/SnakeClient/SnakeApp/back-end/imageprovider.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef IMAGEPROVIDER_H
-#define IMAGEPROVIDER_H
-
-#include
-#include
-
-class ImageProvider: public QQuickAsyncImageProvider
-{
-private:
-public:
- explicit ImageProvider();
- ~ImageProvider() override;
-
- QQuickImageResponse *requestImageResponse(const QString &id,
- const QSize &requestedSize) override;
-};
-
-
-#endif // IMAGEPROVIDER_H
diff --git a/SnakeClient/SnakeApp/back-end/itemworld.cpp b/SnakeClient/SnakeApp/back-end/itemworld.cpp
deleted file mode 100644
index 5a1e24d..0000000
--- a/SnakeClient/SnakeApp/back-end/itemworld.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "itemworld.h"
-#include "snakeutils.h"
-#include
-#include
-#include
-
-#define POINT 100
-
-ItemWorld::ItemWorld(double x, double y, const QString& guiTemplate):
- GuiObject (guiTemplate) {
- setLoc(x, y);
-}
-
-void ItemWorld::setBeckGroundObject(bool value) {
- beckGroundObject = value;
-}
-
-void ItemWorld::setSize(double h, double w) {
- setH(h);
- setW(w);
-}
-
-void ItemWorld::setLoc(double x, double y) {
- setX(x);
- setY(y);
-}
-
-void ItemWorld::render() {
- if (m_x + w() < 0) {
- m_x = (rand() % 400) + 200;
- m_y = rand() % 100;
- emit xChanged(m_x);
- emit yChanged(m_y);
- }
-}
-
-bool ItemWorld::move(const GuiObject *snakeRiger, double dx) {
- m_x -= dx;
- emit xChanged(m_x);
-
- return snakeRiger->rect().intersects(rect()) && !beckGroundObject;
-}
-
-bool ItemWorld::isBeckGroundObject() {
- return beckGroundObject;
-}
-
-ItemWorld::~ItemWorld() {}
diff --git a/SnakeClient/SnakeApp/back-end/itemworld.h b/SnakeClient/SnakeApp/back-end/itemworld.h
deleted file mode 100644
index 6159eaf..0000000
--- a/SnakeClient/SnakeApp/back-end/itemworld.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef ITEMWORLD_H
-#define ITEMWORLD_H
-
-#include "guiobject.h"
-#include
-
-class ItemWorld : public GuiObject
-{
-private:
- bool beckGroundObject = false;
-protected:
- virtual void setSize(double h, double w);
- virtual void setLoc(double x, double y);
- void setBeckGroundObject(bool value);
-
-public:
- ItemWorld(double x, double y, const QString& GuiTemplate = "GraphicItem");
-
- void render();
- virtual bool move(const GuiObject* snakeRiger, double dx);
- bool isBeckGroundObject();
-
- ~ItemWorld();
-};
-
-#endif // ITEMWORLD_H
diff --git a/SnakeClient/SnakeApp/back-end/main.cpp b/SnakeClient/SnakeApp/back-end/main.cpp
deleted file mode 100644
index b2301a9..0000000
--- a/SnakeClient/SnakeApp/back-end/main.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#include
-#include
-#include
-#include "clientapp.h"
-
-
-int main(int argc, char *argv[])
-{
- QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
-
- QGuiApplication app(argc, argv);
- QQmlApplicationEngine engine;
- ClientApp client;
-
- if (!client.init(&engine)) {
- return 1;
- }
-
- return app.exec();
-}
diff --git a/SnakeClient/SnakeApp/back-end/settings.cpp b/SnakeClient/SnakeApp/back-end/settings.cpp
deleted file mode 100644
index d90bd07..0000000
--- a/SnakeClient/SnakeApp/back-end/settings.cpp
+++ /dev/null
@@ -1 +0,0 @@
-#include "settings.h"
diff --git a/SnakeClient/SnakeApp/back-end/settings.h b/SnakeClient/SnakeApp/back-end/settings.h
deleted file mode 100644
index f9245d0..0000000
--- a/SnakeClient/SnakeApp/back-end/settings.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef SNAKESETTINGS_H
-#define SNAKESETTINGS_H
-#include
-#include
-
-#define SERVER_ADDRESS "SERVER_ADDRESS"
-#define SERVER_ADDRESS_PORT "SERVER_ADDRESS_PORT"
-#define THEME "THEME_GUI"
-
-#define SERVER_ADDRESS_DEFAULT "quasarapp.ddns.net"
-//#define SERVER_ADDRESS_DEFAULT "127.0.0.1"
-#define SERVER_ADDRESS_DEFAULT_PORT DEFAULT_SNAKE_PORT
-#define THEME_DEFAULT 0
-
-using Settings = QuasarAppUtils::Settings;
-
-#endif // SNAKESETTINGS_H
diff --git a/SnakeClient/SnakeApp/back-end/snake.cpp b/SnakeClient/SnakeApp/back-end/snake.cpp
deleted file mode 100644
index 7b1416e..0000000
--- a/SnakeClient/SnakeApp/back-end/snake.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-#include "snake.h"
-#include "guiobject.h"
-
-#include
-#include
-#include
-#include
-
-Snake::Snake() {
-}
-
-const QVector &Snake::getItems() const {
- return items;
-}
-
-void Snake::render() {
-
- auto centerX = [](const Head* head) {
- return head->x()/* + (head->w() / 2)*/;
- };
-
- auto centerY = [](const Head* head) {
- return head->y() /*+ (head->h() / 2)*/;
- };
-
- for (int i = items.length() - 1; i >= 0; --i) {
-
- if (dead) {
- items[i]->render();
- continue;
- }
-
- if (i == 0) {
- if (isClick) {
- if (countClick & 1){
- items[i]->setAngle(45);
- } else {
- items[i]->setAngle(315);
- }
- isClick = false;
- }
- } else {
-
- double _atan2 = atan2(centerY(items[i - 1]) - centerY(items[i]),
- centerX(items[i - 1]) - centerX(items[i])) * 90;
-
- items[i]->setAngle(_atan2);
- }
-
- items[i]->render();
- }
-}
-
-double Snake::checDistance(int i) {
-
- auto result = (items[i]->rect().y() -
- items[i - 1]->rect().y()) / rataticonDistance;
-
- return result;
-
-}
-
-double Snake::getRataticonDistance() const {
- return rataticonDistance;
-}
-
-void Snake::setRataticonDistance(double value) {
- rataticonDistance = value;
-}
-
-void Snake::unPause() {
- for ( int i = 0; i < items.size(); ++i ) {
- items[i]->unPause();
- }
-}
-
-double Snake::sizeByLvl(double lvl , int count) const {
- double maxSize = 9;
- double minSize = 5;
-
- double pos = (1 - (lvl / count));
-
- QList> snakeGradientSize {
- {1, 4},
- {0.99, 7},
- {0.8, 5},
- {0.6, 6},
- {0.0, 3}
- };
-
- double local = 0;
- int index = 0;
-
- while (index + 1 < snakeGradientSize.size()
- && pos <= snakeGradientSize[index].first) {
-
- maxSize = snakeGradientSize[index].second;
- minSize = snakeGradientSize[index + 1].second;
-
- auto range = snakeGradientSize[index].first -
- snakeGradientSize[index + 1].first;
-
- local = ( range - (snakeGradientSize[index].first - pos)) /
- range;
-
- index++;
- }
-
- return local * (maxSize - minSize) + minSize;
-}
-
-void Snake::changeCountObjects(int count) {
- if (count > 0) {
- double margin = 60.0 / count;
- for ( int i = 0; i < count; ++i ) {
-
- auto size = sizeByLvl(i, count);
- auto obj = new Head(margin * (count - i),
- 50, size , size,
- this->speed);
-
- obj->setY(50 + obj->h() / 2);
-
- items.push_back(obj);
- }
-
- } else {
- for ( int i = count; i < 0; ++i ) {
- auto obj = items.first();
- items.removeFirst();
- delete obj;
- }
- }
-}
-
-QMap Snake::init(int size, double *speed) {
-
- QMap res;
-
- if (size <= 0) {
- return res;
- }
-
- this->speed = speed;
-
- changeCountObjects(size - items.size());
-
- for (auto i : items) {
- res[i->guiId()] = i;
- }
-
- dead = false;
-
- return res;
-}
-
-bool Snake::isInited() const {
- return items.size();
-}
-
-void Snake::clearItems() {
- for (auto i : items) {
- delete i;
- }
- items.clear();
-}
-
-void Snake::resetPosotion() {
- double margin = 60.0 / items.size();
-
- for ( int i = 0; i < items.size(); ++i ) {
- items[i]->setX(margin * (items.size() - i));
- items[i]->setY(50 + items[i]->h() / 2);
- items[i]->setAngle(0);
- }
-}
-
-void Snake::kill() {
- dead = true;
-}
-
-bool Snake::isDead() const {
- return dead;
-}
-
-Snake::~Snake() {
- clearItems();
-}
-
-void Snake::clear() {
- clearItems();
-}
-
-void Snake::reverse() {
- if (isClick) {
- return;
- }
- isClick = true;
- countClick++;
-}
diff --git a/SnakeClient/SnakeApp/back-end/snake.h b/SnakeClient/SnakeApp/back-end/snake.h
deleted file mode 100644
index b919028..0000000
--- a/SnakeClient/SnakeApp/back-end/snake.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef SNAKE_H
-#define SNAKE_H
-
-#define SPEEDSNAKE 10
-
-#include
-#include "head.h"
-#include "baseclass.h"
-
-class GuiObject;
-
-
-
-class Snake : public BaseClass
-{
-private:
- double rataticonDistance = 1;
- QVector items;
- double *speed = nullptr;
- bool isClick = false;
- int countClick = 0;
- bool dead = false;
- double sizeByLvl(double lvl, int count) const;
- void changeCountObjects(int count);
-
- double checDistance(int i);
- void clearItems();
-
-
-public:
- Snake();
- ~Snake() override;
- void clear();
- void resetPosotion();
-
- void kill();
- bool isDead() const;
-
- void reverse();
- void render() override;
- QMap init(int size, double *speed);
- bool isInited() const;
- const QVector& getItems() const;
- double getMovedLong() const;
- double getRataticonDistance() const;
- void setRataticonDistance(double value);
- int getDeadTimer() const;
- void setDeadTimer(int value);
- void unPause();
-};
-
-#endif // SNAKE_H
diff --git a/SnakeClient/SnakeApp/back-end/world.cpp b/SnakeClient/SnakeApp/back-end/world.cpp
deleted file mode 100644
index 62f799c..0000000
--- a/SnakeClient/SnakeApp/back-end/world.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-#include "background.h"
-#include "world.h"
-
-#include
-#include "guiobject.h"
-#include "guiobjectfactory.h"
-#include
-#include
-
-World::World() {
- currentLong = 0;
- endLong = 0;
- background = "";
-}
-
-void World::clear() {
- clearItems();
- snake.clear();
-}
-
-double World::getCurrentLong() const {
- return currentLong;
-}
-
-QMultiMap World::getItems() const
-{
- return items;
-}
-
-void World::unPause() {
- time = QDateTime::currentMSecsSinceEpoch();
- snake.unPause();
-}
-
-void World::clearItems() {
- for (auto i : items) {
- delete i;
- }
- oldRules.clear();
- items.clear();
- spead = 0;
- d_spead = 0;
-}
-
-void World::changeCountObjects(const QString &name, int count) {
-
- if (count > 0) {
-
- for ( int i = 0; i < count; ++i ) {
- auto obj = GuiObjectFactory::generate(name);
-
- if (!obj) {
- qWarning() <<"object not created line:" << Q_FUNC_INFO;
- break;
- }
-
- items.insertMulti(name, obj);
- }
-
- } else {
- for ( int i = count; i < 0; ++i ) {
- auto obj = items.value(name);
- if (1 != items.remove(name, obj)) {
- qWarning() << "World::changeCountObjects error delete object!";
- }
- delete obj;
- }
- }
-}
-
-QMap World::init(WorldRules rules) {
-
- QMap res;
-
-// rules["BackGround"] = 1;
-
- currentLong = -1;
- for (auto i = rules.begin(); i != rules.end(); ++i) {
- if (i.key() == "Long") {
- endLong = rules["Long"];
- currentLong = 0;
- }
- else if (i.key() == "Spead") {
- d_spead = rules["Spead"];
- }
- else {
- changeCountObjects(i.key(), i.value() - oldRules.value(i.key()));
- }
- }
-
- auto snakeItems = snake.init(20, &spead);
-
- for (auto i = snakeItems.begin(); i != snakeItems.end(); ++i) {
- res.insert(i.key(), i.value());
- }
-
- for (auto i : items) {
- res[i->guiId()] = i;
- }
-
-
- oldRules = rules;
- time = QDateTime::currentMSecsSinceEpoch();
- defiat = false;
- return res;
-}
-
-World::~World() {
- clearItems();
-}
-
-void World::render() {
-
- qint64 tempTime = QDateTime::currentMSecsSinceEpoch() - time;
- time = QDateTime::currentMSecsSinceEpoch();
- double dx = spead / 1000 * tempTime;
-
- spead -= 0.0310 * tempTime;
-
- if (spead < 0)
- spead = 0;
-
- snake.render();
- auto rig = snake.getItems().first();
-
- for (auto i = items.begin(); i != items.end(); ++i) {
- defiat |= (*i)->move(rig, dx);
- (*i)->render();
- }
-
- defiat |= (rig->y()< 0 || rig->y() > 100);
-
- if (!snake.isDead() && defiat) {
- snake.kill();
- }
-
- currentLong += dx;
-}
-
-void World::resetPosition() {
- for (auto i : items) {
- i->reset();
- }
- spead = 0;
-
- snake.resetPosotion();
-}
-
-bool World::move() {
- return isEnd();
-}
-
-bool World::isEnd() {
- return currentLong >= endLong;
-}
-
-bool World::isDefiat() const {
- return defiat && !static_cast(spead);
-}
-
-WorldRules World::currentRules() const {
- return oldRules;
-}
-
-void World::reversClick() {
- if (snake.isDead()) {
- spead = 0;
- return;
- }
-
- snake.reverse();
- spead += d_spead;
-}
diff --git a/SnakeClient/SnakeApp/back-end/world.h b/SnakeClient/SnakeApp/back-end/world.h
deleted file mode 100644
index d786634..0000000
--- a/SnakeClient/SnakeApp/back-end/world.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef WORLD_H
-#define WORLD_H
-
-#define SPEEDWORLD 10
-
-#include
-#include "itemworld.h"
-#include "baseclass.h"
-#include "snakeutils.h"
-#include "snake.h"
-
-class World : public BaseClass
-{
-private:
-
- Snake snake;
- QMultiMap items;
- double currentLong = 0;
- int endLong;
- double spead = 0, d_spead = 0;
- QString background;
- qint64 time;
- bool defiat = false;
- WorldRules oldRules;
-
- void clearItems();
-
- void changeCountObjects(const QString &name, int count);
-
-public:
- World();
- void clear();
- QMap init(WorldRules rules);
- ~World() override;
- void render() override;
- void resetPosition();
- bool move();
- bool isEnd();
- bool isDefiat() const;
- WorldRules currentRules() const;
- void reversClick();
- double getCurrentLong() const;
- QMultiMap getItems() const;
- void unPause();
-};
-
-#endif // WORLD_H
diff --git a/SnakeClient/SnakeApp/front-end/About.qml b/SnakeClient/SnakeApp/front-end/About.qml
deleted file mode 100644
index 8bcbc05..0000000
--- a/SnakeClient/SnakeApp/front-end/About.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import QtQuick 2.9
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls 2.3
-import QtQuick.Layouts 1.3
-
-Page {
-
- signal close();
-
- title: "Page"
- header: Rectangle {
- height: parent.height * 0.1
- color: "#cccccc"
- Label {
- id: title
- text: qsTr("About")
- font.pointSize: 13
- wrapMode: Text.WordWrap
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignHCenter
- anchors.fill: parent;
- anchors.margins: 5
- }
- }
-
- contentItem: AboutPage{
- }
-
-}
diff --git a/SnakeClient/SnakeApp/front-end/AboutPage.qml b/SnakeClient/SnakeApp/front-end/AboutPage.qml
deleted file mode 100644
index ef34917..0000000
--- a/SnakeClient/SnakeApp/front-end/AboutPage.qml
+++ /dev/null
@@ -1,72 +0,0 @@
-import QtQuick 2.9
-import QtQuick.Controls 2.3
-import QtQuick.Controls.Material 2.0
-import QtQuick.Layouts 1.3
-
-Item {
- clip: true
- ColumnLayout {
- id: columnLayout
- anchors.fill: parent
- spacing: 10
-
- Rectangle {
- Layout.preferredHeight: parent.width / 4
- Layout.preferredWidth: parent.width / 4
- Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
- color: "#00000000"
- Image {
- id: aboutLogo
- fillMode: Image.PreserveAspectFit
-
- source: "qrc:/logo/logo"
- anchors.margins: 10
- anchors.fill: parent
-
- }
- }
-
-
-
- Flickable {
- id: flickable
- clip: true
- flickableDirection: Flickable.VerticalFlick
-
- Layout.preferredHeight: parent.height - parent.height / 2.8
-
-
- TextArea.flickable: TextArea {
- id: textArea
- textFormat: Qt.RichText
- wrapMode: TextArea.Wrap
- readOnly: true
- persistentSelection: true
-
- leftPadding: 6
- rightPadding: 6
- topPadding: 0
- bottomPadding: 0
- background: null
-
- text: qsTr("Product of QuasarrApp");
- font.family: "Verdana"
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignTop
-
- onLinkActivated: Qt.openUrlExternally(link)
- }
-
- ScrollBar.vertical: ScrollBar { }
- Layout.fillWidth: true
-
- }
-
- }
-
-}
-
-/*##^## Designer {
- D{i:0;autoSize:true;height:480;width:640}
-}
- ##^##*/
diff --git a/SnakeClient/SnakeApp/front-end/BasePopUp.qml b/SnakeClient/SnakeApp/front-end/BasePopUp.qml
deleted file mode 100644
index 62af5a8..0000000
--- a/SnakeClient/SnakeApp/front-end/BasePopUp.qml
+++ /dev/null
@@ -1,71 +0,0 @@
-import QtQuick 2.11
-import QtQuick.Controls 2.3
-import QtQuick.Controls.Material 2.0
-import QtQuick.Layouts 1.3
-import QtGraphicalEffects 1.12
-
-Dialog {
- id : basePopup
- width: 200
- height: 100
- x: 0
- y: 0
-
- transformOrigin: Item.Center
-
- property bool autoClose: true
- property bool clickClose: true
-
- property int closeInterval: 15000;
- property int margin : 0
- property color backgroundColor: Material.background
-
- background: Item {
- id: bacground
-
- Rectangle{
- anchors.fill: parent
- id: backCorner
- color: backgroundColor
- radius: metrix.mm
- }
-
- DropShadow {
- anchors.fill: parent
- source: backCorner
- color: "#80000000"
- verticalOffset: 10
- samples: 30
- }
- }
-
- function _show() {
-
- if (autoClose) {
- timerAutoClose.start();
- }
-
- open();
- }
-
- Timer {
- id: timerAutoClose;
- running: false;
- repeat: false;
- interval: closeInterval;
-
- onTriggered: {
- close();
- }
- }
-
- onClosed: {
- if (autoClose)
- opacity = 0;
- }
-
- closePolicy: (!clickClose || autoClose)? Popup.NoAutoClose: Popup.CloseOnReleaseOutside
-
- onRejected: close()
-
-}
diff --git a/SnakeClient/SnakeApp/front-end/FrameView.qml b/SnakeClient/SnakeApp/front-end/FrameView.qml
deleted file mode 100644
index 33cc8e6..0000000
--- a/SnakeClient/SnakeApp/front-end/FrameView.qml
+++ /dev/null
@@ -1,32 +0,0 @@
-import QtQuick 2.12
-import QtQuick.Controls.Material 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Layouts 1.3
-import QtGraphicalEffects 1.12
-
-Frame {
- id: frameVew
- property bool translucent: true
- property bool showBorder: true
-
- function _backGroundColor() {
- if (translucent) {
- if (Material.theme == Material.Dark) {
- return "#50000000";
- }
-
- return "#50ffffff";
- }
-
- return Material.background;
- }
-
- background: Rectangle {
- color: _backGroundColor()
- border.color: (Material.theme == Material.Dark)? "#000000": "#cfcfcf"
- border.width: (showBorder)? 1 : 0
- radius: metrix.mm
- }
-
- padding: 3 * metrix.mm
-}
diff --git a/SnakeClient/SnakeApp/front-end/GraphicItem.qml b/SnakeClient/SnakeApp/front-end/GraphicItem.qml
deleted file mode 100644
index 3534c99..0000000
--- a/SnakeClient/SnakeApp/front-end/GraphicItem.qml
+++ /dev/null
@@ -1,38 +0,0 @@
-import QtQuick 2.9
-
-Rectangle {
- id: graphicItem
- property var model: null
- property real angle: (model) ? model.angle : 0;
- property string texture: (model) ? model.texture : "";
- property int guiId: (model) ? model.guiId : -1;
-
- z:-1
- property double devX: width / 2
- property double devY: height / 2
-
- Image {
- id: name
- visible: texture.length
- source: texture
-
- anchors.fill: parent;
- }
-
- color: (model) ? model.color : "#11ff32";
-
- width: (model) ? model.w * metrix.gamePt: 0;
- height: (model) ? model.h * metrix.gamePt: 0;
-
- x: (model) ? model.x * metrix.gamePt - devX: 0;
- y: (model) ? model.y * metrix.gamePt - devY: 0;
-
- radius: (model) ? model.radius * metrix.gamePt : 0;
-
- transform: Rotation {
- origin.x: devX;
- origin.y: devY;
- angle: graphicItem.angle;
- }
-
-}
diff --git a/SnakeClient/SnakeApp/front-end/ImageView.qml b/SnakeClient/SnakeApp/front-end/ImageView.qml
deleted file mode 100644
index 8e492b4..0000000
--- a/SnakeClient/SnakeApp/front-end/ImageView.qml
+++ /dev/null
@@ -1,83 +0,0 @@
-import QtQuick 2.12
-import QtQuick.Controls.Material 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Layouts 1.3
-import QtGraphicalEffects 1.12
-
-Item {
- id: imageView
- property int size: 50
- property double ratio: 1
- property string drawItem: ""
- property bool hovered: false
- property bool hold: false
-
- signal clicked();
-
- width: size * ratio
- height: size
-
- Image {
- id: img
- fillMode: Image.PreserveAspectFit
- source: drawItem
- sourceSize: Qt.size(width, height)
- smooth: true
- visible: false
- anchors.fill: parent
- }
-
- DropShadow {
- anchors.fill: img
- horizontalOffset: (hold)? 20: (hovered)? 10: 5
- verticalOffset: (hold)? 20: (hovered)? 10: 5
- radius: 8.0
- samples: 17
- Behavior on horizontalOffset {
-
- ColorAnimation {
- duration: 200
- }
- }
-
- Behavior on verticalOffset {
-
- ColorAnimation {
- duration: 200
- }
- }
-
-
- Behavior on color {
-
- ColorAnimation {
- duration: 200
- }
- }
- color: (hold)? "#80000000": (hovered)? "#60000000": "#40000000"
- source: img
- }
-
- MouseArea {
- anchors.fill: parent
- hoverEnabled: true
-
- onEntered: {
- parent.hovered = true;
- }
-
- onExited: {
- parent.hovered = false;
- }
-
- onReleased: {
- parent.hold = false;
- imageView.clicked();
- }
-
- onPressed: {
- parent.hold = true;
- }
- }
-
-}
diff --git a/SnakeClient/SnakeApp/front-end/LeftBoxSideBar.qml b/SnakeClient/SnakeApp/front-end/LeftBoxSideBar.qml
deleted file mode 100644
index 05e1daa..0000000
--- a/SnakeClient/SnakeApp/front-end/LeftBoxSideBar.qml
+++ /dev/null
@@ -1,13 +0,0 @@
-import QtQuick 2.0
-
-LeftSideBar {
- resizeHeight: true;
- closedHeight: closedWidth;
- openHeight: 10 * metrix.pt;
- openWidth: 10 * metrix.pt;
- anchors.left: parent.left;
- anchors.top: undefined;
- anchors.bottom: undefined;
-
-}
-
diff --git a/SnakeClient/SnakeApp/front-end/LeftSideBar.qml b/SnakeClient/SnakeApp/front-end/LeftSideBar.qml
deleted file mode 100644
index e566da8..0000000
--- a/SnakeClient/SnakeApp/front-end/LeftSideBar.qml
+++ /dev/null
@@ -1,35 +0,0 @@
-import QtQuick 2.12
-import QtQuick.Controls.Material 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Layouts 1.3
-
-SideBar {
- id: leftSideBar
- anchors.left: parent.left;
- anchors.top: parent.top;
- anchors.bottom: parent.bottom;
- closedWidth: closeButton.width + padding * 2;
- openWidth: 10 * metrix.pt;
- resizeHeight: false;
-
- header:
- RowLayout {
-
- Button {
- id: closeButton
- text: leftSideBar.isOpened? "<" : ">"
-
- Layout.preferredHeight: metrix.controlPtMaterial;
- Layout.preferredWidth: metrix.controlPtMaterial;
-
- Layout.alignment: Qt.AlignRight | Qt.AlignTop
- onClicked: {
- if (leftSideBar.isOpened)
- leftSideBar.hide();
- else
- leftSideBar.show();
- }
-
- }
- }
-}
diff --git a/SnakeClient/SnakeApp/front-end/LoginView.qml b/SnakeClient/SnakeApp/front-end/LoginView.qml
deleted file mode 100644
index e7c1ab8..0000000
--- a/SnakeClient/SnakeApp/front-end/LoginView.qml
+++ /dev/null
@@ -1,301 +0,0 @@
-import QtQuick 2.12
-import QtQuick.Controls.Material 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Layouts 1.3
-import QtGraphicalEffects 1.12
-
-Item {
- id: element
-
- property int loginStatus : 0
-
- readonly property int currentView: tabBar.currentIndex
- readonly property var resultEnum: [
- qsTr("Success"), // 0
- qsTr("Password must be at least 8 characters"), // 1
- qsTr("Name must be at least 1 characters"), // 2
- qsTr("Passwords must match"), // 3
-
- qsTr("The letter must match the pattern 'X@xxxx.xxx'") // 4
-
- ]
-
- signal sigNewUser(var gmail, var password);
- signal sigLogin(var gmail, var password);
- signal toOffline();
-
-
- function _checkLogin() {
- const pass = loginPass.text;
- const email = loginEmail.text;
-
- if (pass.length < 8) {
- return 1;
- }
-
- if (email.search(/[a-z\-A-Z0-9_]+@[a-z\-A-Z0-9_]+\.[a-z\-A-Z0-9_]+/) < 0) {
- return 4;
- }
-
- return 0;
-
- }
-
- function _checkRegister () {
- const pass = registerPassword.text;
- const pass2 = registerPassword2.text;
-
- const email = registerEmail.text;
-
- if (pass.length < 8) {
- return 1;
- }
-
- if (pass !== pass2) {
- return 3;
- }
-
- if (email.search(/[a-z\-A-Z0-9_]+@[a-z\-A-Z0-9_]+\.[a-z\-A-Z0-9_]+/) < 0) {
- return 4;
- }
-
- return 0;
- }
-
- function checkData(isregisterForm) {
- if (isregisterForm) {
- return _checkRegister();
- }
-
- return _checkLogin();
- }
-
- SwipeView {
- id: swipeView
- anchors.bottom: bottons.top
- anchors.top: tabBar.bottom
- anchors.left: parent.left
- anchors.right: parent.right
-
- clip: true
-
- currentIndex: tabBar.currentIndex
-
- Item {
- id: loginPage
-
- GridLayout {
- id: columnLayout
- anchors.fill: parent
- columns: 2
- rows: 2
- Label {
- text: qsTr("Email")
- }
-
- TextField {
- id: loginEmail
- placeholderText: "Enter Your Email"
- Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
- Layout.fillWidth: true
- }
-
-
- Label {
- text: qsTr("Passsword")
- }
- TextField {
- id: loginPass
- placeholderText: qsTr("Enter Your passsword")
-
- Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
-
- echoMode: TextInput.Password
- cursorVisible: true
- Layout.fillWidth: true
-
- }
-
- }
- }
-
- Item {
- id: rigisterPage
- GridLayout {
-
- anchors.fill: parent
-
- columns: 2
- rows: 3
-
- Label {
- text: qsTr("Email")
- }
- TextField {
- id: registerEmail;
- placeholderText: qsTr("Enter Your Email")
- Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
- Layout.fillWidth: true
-
- }
-
- Label {
- text: qsTr("Password")
- }
- TextField {
- id: registerPassword;
-
- placeholderText: qsTr("Enter Your passsword")
-
- Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
- Layout.fillWidth: true
- echoMode: TextInput.Password
- cursorVisible: true
- }
-
- Label {
- text: qsTr("Repeat password")
- }
- TextField {
- id: registerPassword2;
-
- placeholderText: qsTr("Enter Your passsword again")
-
- Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
- Layout.fillWidth: true
- echoMode: TextInput.Password
- cursorVisible: true
- }
- }
- }
- }
-
- TabBar {
- id: tabBar
- anchors.top: parent.top
- anchors.topMargin: 0
- anchors.left: parent.left
- anchors.leftMargin: 0
- anchors.right: parent.right
- anchors.rightMargin: 0
-
- TabButton {
- id: login
- text: qsTr("Sign in")
- checkable: false
- }
-
- TabButton {
- id: register
- text: qsTr("Sign Up")
- }
- }
-
- RowLayout {
- id : bottons
- Button {
- text: qsTr("Cancel")
-
- onClicked: {
- Qt.quit()
- }
-
- }
-
- Item {
- Layout.fillWidth: true
- }
-
- Button {
- text: tabBar.currentItem.text
-
- onClicked: {
-
- const messageIndex = checkData(tabBar.currentIndex);
- if (messageIndex === 0) {
-
- if (tabBar.currentIndex) {
- // register request
- sigNewUser(registerEmail.text, registerPassword);
- } else {
- //login request
- sigLogin(loginEmail.text, loginPass.text);
- }
- } else {
-
- notificationService.setNotify(qsTr("Error"),
- resultEnum[messageIndex],
- "",
- 2);
- }
- }
-
- }
-
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.right: parent.right
- }
-
- onLoginStatusChanged: {
- if (loginStatus === 2)
- busy._show();
- else {
- busy.close();
- }
- }
-
- PagePopUp {
- id: busy
- modal: true
- autoClose: false;
- clickClose: false;
- BusyIndicator {
- running: true
- anchors.fill: parent
- }
- height: 2 * metrix.controlPtMaterial
- width: height
-
- }
-
-
- FrameView {
- visible: loginStatus === 4
- anchors.fill: parent
- translucent: false
- showBorder: false
- ColumnLayout {
- anchors.fill: parent
-
- Label {
- text: qsTr("You need connect to server");
- font.pixelSize: metrix.controlPtMaterial;
- wrapMode: Text.WordWrap
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
-
- Layout.fillHeight: true
- Layout.fillWidth: true
-
- }
-
- Button {
- text: qsTr("Use OfflineMode");
- Layout.alignment: Qt.AlignHCenter
-
- onClicked: {
- toOffline();
- }
-
- }
- }
-
- }
-}
-
-/*##^## Designer {
- D{i:0;autoSize:true;height:480;width:640}D{i:3;anchors_height:100;anchors_width:100;anchors_x:228;anchors_y:63}
-D{i:1;anchors_height:200;anchors_width:200;anchors_x:205;anchors_y:53}D{i:11;anchors_width:240;anchors_x:226;anchors_y:21}
-}
- ##^##*/
diff --git a/SnakeClient/SnakeApp/front-end/MainMenu.qml b/SnakeClient/SnakeApp/front-end/MainMenu.qml
deleted file mode 100644
index 74147e0..0000000
--- a/SnakeClient/SnakeApp/front-end/MainMenu.qml
+++ /dev/null
@@ -1,196 +0,0 @@
-import QtQuick 2.9
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls 2.3
-import QtQuick.Layouts 1.3
-
-Item {
- id: item1
- property var model: null
- readonly property int onlineStatus: (model)? model.onlineStatus: false
-
- visible: true
- z: 1
-
- signal playGame();
-
- onOnlineStatusChanged: {
- if (onlineStatus && onlineStatus !== 5) {
- loginPopUp._show();
- } else {
- loginPopUp.close();
- }
- }
-
- LeftSideBar {
- id: userViewSideBar
- openWidth: 7 * metrix.pt;
-
- openHeight: columnLayout.height
- source: UserView {
-
- anchors.fill: parent;
- model: (item1.model)? item1.model.userViewModel: null
- visible: userViewSideBar.openFinished
- onTryConnect: {
- if (item1.model)
- item1.model.tryConnect();
- }
- }
-
- }
-
-
- GridLayout {
- id: columnLayout
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- anchors.left: userViewSideBar.right
- anchors.right: parent.right
-
- anchors.leftMargin: 0
- anchors.rightMargin: 0
- anchors.bottomMargin: 0
- anchors.topMargin: 0
-
- columns: 3
- rows: 2
-
-
- transformOrigin: Item.Center
-
-
- MainMenuButton {
- id: play
- text: qsTr("Play game")
-
- onClicked: {
- playGame();
- if (model)
- model.newGame();
- }
-
- }
-
- MainMenuButton {
- id: store
- text: qsTr("Store")
-
- }
-
- MainMenuButton {
- id: invitar
- text: qsTr("My Items")
- }
-
- MainMenuButton {
- id: freands
- text: qsTr("My friends")
-
- }
-
- MainMenuButton {
- id: settings
- text: qsTr("My Settings")
-
- onClicked: {
- settingsPopUp._show();
-
- }
-
- }
-
- MainMenuButton {
- id: exit
- text: qsTr("Exit")
-
- onClicked: {
- Qt.quit();
- }
- }
-
- }
-
- PagePopUp {
- id: about;
- width: parent.width / 2
- height: parent.height / 2;
-
- source: About {}
- }
-
- PagePopUp {
- id: settingsPopUp
- source: SettingsView {
- id: settingsView
- model: item1.model ? item1.model.userSettingsModel: null
- }
-
- standardButtons: Dialog.Save | Dialog.Cancel | Dialog.RestoreDefaults
- modal: false;
- autoClose: false
- clickClose: true
- width: 12 * metrix.controlPtMaterial
- height: 8 * metrix.controlPtMaterial;
-
- onAccepted: {
- settingsView.save();
- }
-
- onReset: {
- settingsView.reset();
- }
-
- onOpened: {
- settingsView.update();
- }
-
- }
-
-
- PagePopUp {
- id: loginPopUp
- source: LoginView {
- id: loginView
- loginStatus: onlineStatus
-
- onSigLogin: {
- if (!model) {
- return;
- }
-
- model.login(gmail, password);
- }
- onSigNewUser: {
- if (!model) {
- return;
- }
-
- model.registerNewUser(gmail, password);
-
- }
-
- onToOffline: {
- if (!model) {
- return;
- }
-
- model.playOffline();
- }
- }
-
- visible: true;
- modal: true;
- autoClose: false
- clickClose: false
- width: 12 * metrix.controlPtMaterial
- height: ((loginView.currentView)? 9 : 7) * metrix.controlPtMaterial;
- }
-
-
-}
-
-
-/*##^## Designer {
- D{i:0;autoSize:true;height:480;width:640}
-}
- ##^##*/
diff --git a/SnakeClient/SnakeApp/front-end/MainMenuButton.qml b/SnakeClient/SnakeApp/front-end/MainMenuButton.qml
deleted file mode 100644
index 12f6eb0..0000000
--- a/SnakeClient/SnakeApp/front-end/MainMenuButton.qml
+++ /dev/null
@@ -1,17 +0,0 @@
-import QtQuick 2.12
-import QtQuick.Controls.Material 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Layouts 1.3
-
-Button {
- id: exit
- Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
- font.pixelSize: height * 0.1
- display: AbstractButton.TextBesideIcon
- spacing: 4
- focusPolicy: Qt.StrongFocus
-
- Layout.preferredHeight: parent.height / (parent.rows + 1)
- Layout.preferredWidth: parent.width / (parent.columns + 1)
-
-}
diff --git a/SnakeClient/SnakeApp/front-end/Metrix.qml b/SnakeClient/SnakeApp/front-end/Metrix.qml
deleted file mode 100644
index f0bacc8..0000000
--- a/SnakeClient/SnakeApp/front-end/Metrix.qml
+++ /dev/null
@@ -1,27 +0,0 @@
-import QtQuick 2.0
-import QtQuick.Window 2.12
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls 2.3
-
-Item {
- readonly property int pointCount: 100;
- readonly property real mm: Screen.pixelDensity
- readonly property real sm: 10 * mm
- readonly property real dsm: Math.sqrt(Math.pow(Screen.desktopAvailableWidth, 2) + Math.pow(Screen.desktopAvailableHeight, 2)) / sm
- readonly property real pt: getfactor(dsm) * sm
- readonly property real controlPtMaterial: Material.buttonHeight
- readonly property real gamePt: (width < height) ? width / pointCount : height / pointCount;
-
- function getfactor(dsm) {
- if (dsm < 30) {
- return 0.5
- } else if ( dsm < 70) {
- return 1
- } else if (dsm < 140) {
- return 2;
- } else
- return 4;
- }
-
- anchors.fill: parent;
-}
diff --git a/SnakeClient/SnakeApp/front-end/NotificationForm.qml b/SnakeClient/SnakeApp/front-end/NotificationForm.qml
deleted file mode 100644
index 72445bc..0000000
--- a/SnakeClient/SnakeApp/front-end/NotificationForm.qml
+++ /dev/null
@@ -1,84 +0,0 @@
-import QtQuick 2.11
-import QtQuick.Controls 2.3
-import QtQuick.Controls.Material 2.0
-import QtQuick.Layouts 1.3
-
-BasePopUp {
- id : popup
-
- property string text: qsTr("Message")
- property string img: ""
- property string titleText: qsTr("Message")
- property int type: 0
-
- function _getBackGraundColor(type) {
- switch(type) {
-
- case 1: return "#FFC107"
- case 2: return "#FF5722"
-
- }
-
- return Material.background
- }
-
- autoClose: true;
- closeInterval: 5000
-
- margins: 0
- margin: 0
- spacing: 0
-
-
- backgroundColor: _getBackGraundColor(type);
-
- Page {
- id: page
- anchors.fill: parent
- spacing: 0
-
- background: Rectangle {
- color: "#00000000"
- }
-
- header: Label {
- text: titleText
- horizontalAlignment: Text.AlignHCenter
- }
-
- contentItem:
- RowLayout {
- id: rowLayout
- spacing: 5
- clip: true
-
- Rectangle {
- color: "#00000000"
- Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
- Layout.preferredWidth: rowLayout.height;
- Layout.preferredHeight: rowLayout.height;
-
- Image {
- id: image
- fillMode: Image.PreserveAspectCrop
- clip: true
- anchors.fill: parent;
- source: img
- }
- }
-
-
- Label {
- id: message
- text: popup.text
- Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
- Layout.fillHeight: true;
- Layout.fillWidth: true;
- clip: true
- wrapMode: Text.WordWrap
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignHCenter
- }
- }
- }
-}
diff --git a/SnakeClient/SnakeApp/front-end/NotificationServiceView.qml b/SnakeClient/SnakeApp/front-end/NotificationServiceView.qml
deleted file mode 100644
index fb6d18e..0000000
--- a/SnakeClient/SnakeApp/front-end/NotificationServiceView.qml
+++ /dev/null
@@ -1,30 +0,0 @@
-import QtQuick 2.12
-import QtQuick.Controls.Material 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Layouts 1.3
-import QtGraphicalEffects 1.12
-
-Item {
- readonly property var model: notificationService;
- readonly property var msg: model.notify
- readonly property var history: model.history
-
-
- NotificationForm {
- id: notyfyView
- titleText : msg.title;
- text: (msg)? msg.text: "";
- img: (msg)? msg.img: "";
- type: (msg)? msg.type: 0;
-
- x: parent.width - width - margin;
- y: margin;
-
- width: 6 * metrix.controlPtMaterial;
- height: width * 0.5
- }
-
- onMsgChanged: {
- notyfyView._show();
- }
-}
diff --git a/SnakeClient/SnakeApp/front-end/PagePopUp.qml b/SnakeClient/SnakeApp/front-end/PagePopUp.qml
deleted file mode 100644
index 7c35bb4..0000000
--- a/SnakeClient/SnakeApp/front-end/PagePopUp.qml
+++ /dev/null
@@ -1,26 +0,0 @@
-import QtQuick 2.11
-import QtQuick.Controls 2.3
-import QtQuick.Controls.Material 2.0
-import QtQuick.Layouts 1.3
-
-BasePopUp {
- id: pagePopUp
- property var source: null
- autoClose: false
-
- Item {
- id: sourceVal
- anchors.fill: parent
- }
-
- onSourceChanged: {
- if (!source)
- return;
-
- source.parent = sourceVal;
- source.anchors.fill = sourceVal;
- }
-
- x: parent.width / 2 - width / 2
- y: parent.height / 2 - height / 2
-}
diff --git a/SnakeClient/SnakeApp/front-end/PropertyView.qml b/SnakeClient/SnakeApp/front-end/PropertyView.qml
deleted file mode 100644
index 6870da8..0000000
--- a/SnakeClient/SnakeApp/front-end/PropertyView.qml
+++ /dev/null
@@ -1,124 +0,0 @@
-import QtQuick 2.12
-import QtQuick.Controls.Material 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Layouts 1.3
-import QtGraphicalEffects 1.12
-
-Item {
- id: properyView
-
- height: 1 * metrix.pt
-
- property string keyImage: "";
- property string keyText: "";
-
- property string valueImage: "";
- property string valueText: "";
-
- property int lineWidth : 0.5 * metrix.mm
-
- property bool hovered: false
- property bool hold: false
-
- Rectangle {
- id:background
- anchors.fill: parent
- color: "#00000000"
-
- Rectangle {
- height: lineWidth
- color: (hold)? Material.accent: (hovered)? Material.foreground:"#aaa"
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.right: parent.right
-
- Behavior on color {
-
- ColorAnimation {
- duration: 100
- }
- }
- }
- }
-
- DropShadow {
- anchors.fill: background
- horizontalOffset: 2
- verticalOffset: 2
- radius: 8.0
- samples: 17
-
- color: "#80000000";
- source: background
- }
-
- MouseArea {
- anchors.fill: parent
- hoverEnabled: true
-
- onEntered: {
- parent.hovered = true;
- }
-
- onExited: {
- parent.hovered = false;
- }
-
- onReleased: {
- parent.hold = false;
- }
-
- onPressed: {
- parent.hold = true;
- }
- }
-
- RowLayout {
-
- Label {
- text: keyText
- visible: keyText
- Layout.alignment: Qt.AlignLeft
- horizontalAlignment: Text.AlignLeft
-
- }
-
- ImageView {
- visible: keyImage
- drawItem: keyImage
- size: parent.height * 0.75
-
- Layout.alignment: Qt.AlignLeft
- }
-
-
- Label {
- text: valueText
- visible: valueText
- horizontalAlignment: Text.AlignRight
-
- Layout.fillWidth: true
-
- Layout.alignment: Qt.AlignRight
-
- }
-
- ImageView {
- drawItem: valueImage
- size: parent.height * 0.75
- visible: valueImage
-
- Layout.alignment: Qt.AlignRight
-
-
- }
- anchors.fill: parent
- }
-
-
-}
-
-/*##^## Designer {
- D{i:0;autoSize:true;height:480;width:640}
-}
- ##^##*/
diff --git a/SnakeClient/SnakeApp/front-end/Scene.qml b/SnakeClient/SnakeApp/front-end/Scene.qml
deleted file mode 100644
index 524d48f..0000000
--- a/SnakeClient/SnakeApp/front-end/Scene.qml
+++ /dev/null
@@ -1,228 +0,0 @@
-import QtQuick 2.11
-import QtQuick.Controls.Material 2.0
-import QtQuick.Controls 2.3
-import QtQuick.Layouts 1.3
-
-Item {
- id: scene;
- z: -2
-
- Rectangle {
- id: background;
- color: "#ffffff"
- anchors.fill: parent;
-
- Behavior on color {
-
- ColorAnimation {
- duration: 5000
- }
- }
-
- z: -3
-
- }
-
- property var model: null;
- property var arrayObjects: []
- readonly property bool showMenu: (model)? model.showMenu: false
- property bool isPause: false
-
- function add (cppObjId) {
- if (!model) {
- console.log("create object fail")
- return;
- }
- var objModel = model.getGameObject(cppObjId);
-
- if (!objModel) {
- console.log("object model not found");
- return;
- }
-
- var viewTemplate = objModel.viewTemplate;
-
- var temp = Qt.createComponent( viewTemplate + ".qml")
- if (temp.status === Component.Ready) {
- var obj = temp.createObject(parent) // parent - это обьект на который будет помещен соззданный элемент
- obj.model = model.getGameObject(cppObjId);
- obj.z = -2;
- arrayObjects.push(obj)
- } else {
- console.log("wrong viewTemplate in model");
- }
- }
-
- function remove(id) {
- if (typeof id !== "number" || id < 0) {
- console.log("id not found");
- return;
- }
-
- for (var i = 0; i < arrayObjects.length; ++i) {
- if (id === arrayObjects[i].guiId) {
- arrayObjects.splice(i,1);
- }
- }
- }
-
- function updateBackgroundColor(lvl) {
- switch(lvl % 7) {
- case 0: background.color = "#d6eaf8"; break;
- case 1: background.color = "#d0ece7"; break;
- case 2: background.color = "#d4efdf"; break;
- case 3: background.color = "#fcf3cf"; break;
- case 4: background.color = "#f6ddcc"; break;
- case 5: background.color = "#f2d7d5"; break;
- case 6: background.color = "#ebdef0"; break;
- case 7: background.color = "#fbfcfc"; break;
-
- }
- }
-
- Timer {
- id: autoTimer;
- repeat: true;
- running: showMenu;
- interval: 1000
- onTriggered: {
- interval = Math.random() * 600
- scene.model.buttonPress();
- }
- }
-
- Connections {
- target: model;
- onGameObjectsChanged: {
- if (!dif) {
- console.log("dif not found");
- return;
- }
-
- var tempDifRem = [];
- tempDifRem = dif.getRemoveIds();
- var tempDifAdd = [];
- tempDifAdd = dif.getAddedIds();
-
- for (var i = 0; i < tempDifAdd.length; ++i) {
- add(tempDifAdd[i]);
- }
-
- for (i = 0; i < tempDifRem.length; ++i) {
- remove(tempDifRem[i]);
- }
- }
- }
-
- Component.onCompleted: {
- updateBackgroundColor(0);
- model.handleNewGame();
-
- }
-
- MouseArea {
- anchors.fill: parent;
-
- onClicked: {
- if (!model || showMenu) {
- return;
- }
-
- model.buttonPress();
- }
- }
-
- Button {
- id: returnToMenu;
-
- text: "<<"
-
- anchors.left: parent.left
- anchors.leftMargin: metrix.gamePt
-
- anchors.top: parent.top
- anchors.topMargin: metrix.gamePt
- z: 1
-
- onClicked: {
- if (model)
- model.showMenu = true;
- }
-
- visible: !showMenu
- }
-
- Button {
- id: pause
-
- text: (isPause)? "▶" :"||"
-
- anchors.left: returnToMenu.right
- anchors.leftMargin: metrix.gamePt
-
- anchors.top: parent.top
- anchors.topMargin: metrix.gamePt
- z: returnToMenu.z
-
- onClicked: {
- isPause = !isPause;
- if (model) model.setPause(isPause);
- }
-
- visible: !showMenu
-
- }
-
- Button {
- id: long_
- Label {
- anchors.fill: parent;
-
- textFormat: Text.AutoText
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignHCenter
- wrapMode: Text.WordWrap
-
- text: qsTr("lvl long: ") + ((model)? model.long_: "0")
- }
-
- width: 35 * metrix.gamePt;
- height: pause.height;
-
- anchors.left: pause.right
- anchors.leftMargin: metrix.gamePt
-
- anchors.top: parent.top
- anchors.topMargin: metrix.gamePt
- z: returnToMenu.z
-
- visible: !showMenu
-
- }
-
- Button {
- Label {
- anchors.fill: parent;
-
- textFormat: Text.AutoText
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignHCenter
- wrapMode: Text.WordWrap
-
- text: qsTr("general long: ") + ((model)? model.generalLong: "0")
- }
-
- width: 35 * metrix.gamePt;
- height: long_.height;
-
- anchors.left: long_.right
- anchors.leftMargin: metrix.gamePt
-
- anchors.top: parent.top
- anchors.topMargin: metrix.gamePt
- z: returnToMenu.z
-
- visible: !showMenu
-
- }
-}
diff --git a/SnakeClient/SnakeApp/front-end/SelectLevelScene.qml b/SnakeClient/SnakeApp/front-end/SelectLevelScene.qml
deleted file mode 100644
index 674424e..0000000
--- a/SnakeClient/SnakeApp/front-end/SelectLevelScene.qml
+++ /dev/null
@@ -1,217 +0,0 @@
-import QtQuick 2.9
-import QtQuick.Controls 2.3
-import QtQuick.Controls.Material 2.0
-import QtQuick.Layouts 1.3
-
-Item {
- id: item1
-
- GridLayout {
- id: gridLayout
- rows: 8
- columnSpacing: 5
- rowSpacing: 5
- anchors.rightMargin: 200
- anchors.leftMargin: 200
- anchors.bottomMargin: 100
- anchors.topMargin: 50
- anchors.fill: parent
- columns: 8
-
- RoundButton {
- id: roundButton
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "1"
- }
-
- RoundButton {
- id: roundButton1
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "2"
- }
-
- RoundButton {
- id: roundButton2
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "3"
- }
-
- RoundButton {
- id: roundButton3
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "4"
- }
-
- RoundButton {
- id: roundButton4
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "5"
- }
-
- RoundButton {
- id: roundButton5
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "6"
- }
-
- RoundButton {
- id: roundButton6
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "7"
- }
-
- RoundButton {
- id: roundButton7
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "8"
- }
-
- RoundButton {
- id: roundButton8
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "9"
- }
-
- RoundButton {
- id: roundButton9
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "10"
- }
-
- RoundButton {
- id: roundButton10
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "11"
- }
-
- RoundButton {
- id: roundButton11
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "12"
- }
-
- RoundButton {
- id: roundButton12
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "13"
- }
-
- RoundButton {
- id: roundButton13
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "14"
- }
-
- RoundButton {
- id: roundButton14
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "15"
- }
-
- RoundButton {
- id: roundButton15
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "16"
- }
-
- RoundButton {
- id: roundButton16
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "17"
- }
-
- RoundButton {
- id: roundButton17
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "18"
- }
-
- RoundButton {
- id: roundButton18
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "19"
- }
-
- RoundButton {
- id: roundButton19
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "20"
- }
-
- RoundButton {
- id: roundButton20
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "21"
- }
-
- RoundButton {
- id: roundButton21
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "22"
- }
-
- RoundButton {
- id: roundButton22
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "23"
- }
-
- RoundButton {
- id: roundButton23
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "24"
- }
-
- RoundButton {
- id: roundButton24
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "25"
- }
-
- RoundButton {
- id: roundButton25
- width: 10*mainWindow.point
- height: 10*mainWindow.point
- text: "26"
- }
- }
-
- Label {
- id: label
- x: 187
- color: "#795548"
- text: qsTr("Select Level")
- font.bold: true
- font.pixelSize: 30
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.top: parent.top
- anchors.topMargin: 30
- }
-
-}
-
diff --git a/SnakeClient/SnakeApp/front-end/SettingsView.qml b/SnakeClient/SnakeApp/front-end/SettingsView.qml
deleted file mode 100644
index 337b0c9..0000000
--- a/SnakeClient/SnakeApp/front-end/SettingsView.qml
+++ /dev/null
@@ -1,122 +0,0 @@
-import QtQuick 2.12
-import QtQuick.Controls.Material 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Layouts 1.3
-
-Item {
- id: settingsView
-
- property var model: null
-
- function save() {
- if (!model) {
- return;
- }
-
- model.setPort(port.value);
- model.setHost(host.text);
- model.setTheme(themeBox.currentIndex);
-
- }
-
- function reset() {
- if (!model) {
- return;
- }
-
- model.toDefault();
- }
-
- function update() {
- if (!model) {
- return;
- }
- model.forceUpdate();
- }
-
- GridLayout {
-
- id: columnLayout
- rows: 4
- columns: 2
- anchors.fill: parent
-
-
- Label {
- text: qsTr("Game Host")
- Layout.fillWidth: true
- }
-
- TextField {
- id: host;
- text: (model)? model.host: "localhost"
- Layout.fillHeight: false
- Layout.fillWidth: true
- horizontalAlignment: Text.AlignLeft
- Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
-
- }
-
- Label {
- text: qsTr("Game Port")
- Layout.fillWidth: true
- }
-
- SpinBox {
- id: port;
- Layout.fillWidth: true
- to: 10000
- from: 7000
- antialiasing: false
- scale: 1
- Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
-
- value: (model)? model.port: 7777
-
- }
-
- Label {
- text: qsTr("Use Them")
- Layout.fillWidth: true
- }
-
- ComboBox {
- id: themeBox;
- Layout.fillWidth: true
- focusPolicy: Qt.NoFocus
-
- model: [qsTr("Light"), qsTr("Dark")];
- Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
-
- currentIndex: (settingsView.model)? settingsView.model.theme: 0
-
- onCurrentIndexChanged: {
- if (((settingsView.model)? settingsView.model.theme: 0)
- !== currentIndex) {
- themeWarning.visible = true;
- }
- }
-
- }
-
- Item {
- Layout.fillHeight: true
- Layout.fillWidth: true
-
- }
-
- Label {
- id: themeWarning
- text: qsTr("In order for the new theme to take effect, you need to reload the game.");
-
- color: "#FF0000"
-
- wrapMode: Label.WordWrap
-
- Layout.maximumWidth: themeBox.width
-
- visible: false;
- }
- }
-
-}
diff --git a/SnakeClient/SnakeApp/front-end/SideBar.qml b/SnakeClient/SnakeApp/front-end/SideBar.qml
deleted file mode 100644
index 1698007..0000000
--- a/SnakeClient/SnakeApp/front-end/SideBar.qml
+++ /dev/null
@@ -1,103 +0,0 @@
-import QtQuick 2.12
-import QtQuick.Controls.Material 2.12
-import QtQuick.Controls 2.12
-
-FrameView {
- id: sideBar
- property int openHeight: 10 * metrix.pt
- property int closedHeight: 1 * metrix.pt
- property int openWidth: 10 * metrix.pt
- property int closedWidth: 1 * metrix.pt
- property int headerHeight : 1 * metrix.controlPtMaterial
-
- clip: true;
-
- property bool resizeWidth: true
- property bool resizeHeight: true
-
- property bool isOpened: true
- property bool chainAnimation: true
- property var source: null
- property var header: null
-
- readonly property bool openFinished: openHeight === height && openWidth == width;
- readonly property bool closeFinished: closedHeight === height && closedWidth == width;
-
- function show() {
- if (resizeWidth && !(chainAnimation && resizeHeight))
- width = openWidth;
- if (resizeHeight )
- height = openHeight;
-
- isOpened = true;
-
- }
-
- function hide() {
- if (resizeWidth && !(chainAnimation && resizeHeight))
- width = closedWidth;
- if (resizeHeight )
- height = closedHeight;
-
- isOpened = false;
- }
-
- Component.onCompleted: {
- show();
- }
-
- onHeightChanged: {
- if (isOpened) {
- if (height === openHeight) {
- sideBar.width = openWidth
- }
- }
- else {
- if (height === closedHeight) {
- sideBar.width = closedWidth
- }
- }
- }
-
- Behavior on width {
- PropertyAnimation {
- duration: 1000
- easing.type: Easing.OutBounce
- }
- }
-
- Behavior on height {
- PropertyAnimation {
- duration: 1000
- easing.type: Easing.OutBounce
- }
- }
-
- Item {
- id: headerVal
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: parent.top
- height: headerHeight
- }
-
- Item {
- id: sourceVal
-
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: headerVal.bottom
- anchors.bottom: parent.bottom
-
- }
-
- onSourceChanged: {
- source.parent = sourceVal;
- source.anchors.fill = sourceVal;
- }
-
- onHeaderChanged: {
- header.parent = headerVal;
- header.anchors.fill = headerVal;
- }
-}
diff --git a/SnakeClient/SnakeApp/front-end/SnakeItem.qml b/SnakeClient/SnakeApp/front-end/SnakeItem.qml
deleted file mode 100644
index 6614e09..0000000
--- a/SnakeClient/SnakeApp/front-end/SnakeItem.qml
+++ /dev/null
@@ -1,17 +0,0 @@
-import QtQuick 2.9
-
-GraphicItem {
-
- Behavior on color {
- ColorAnimation {
- duration: 2000
- }
- }
-
- Behavior on radius {
- NumberAnimation {
- duration: 2000
- }
- }
-
-}
diff --git a/SnakeClient/SnakeApp/front-end/TextInput.qml b/SnakeClient/SnakeApp/front-end/TextInput.qml
deleted file mode 100644
index 17ac7c5..0000000
--- a/SnakeClient/SnakeApp/front-end/TextInput.qml
+++ /dev/null
@@ -1,47 +0,0 @@
-import QtQuick 2.11
-import QtQuick.Controls 2.3
-import QtQuick.Controls.Material 2.0
-import QtQuick.Layouts 1.3
-
-
-Item {
-
- signal close();
-
- RowLayout {
- anchors.fill: parent
- Layout.fillWidth: true
- Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
-
- Label {
- text: qsTr("Write you name ");
-
- }
-
- TextField {
-
- id: input;
-
- Layout.fillWidth: true
- horizontalAlignment: Text.AlignHCenter
-
- }
-
- Button {
-
- id: ok
- text: qsTr("Ok")
- Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
-
- onClicked: {
- if (contr) {
- var rec = contr.getRecords()
- rec.append(input.text, contr.generalLong);
- }
-
- close();
-
- }
- }
- }
-}
diff --git a/SnakeClient/SnakeApp/front-end/UserView.qml b/SnakeClient/SnakeApp/front-end/UserView.qml
deleted file mode 100644
index 848d3d6..0000000
--- a/SnakeClient/SnakeApp/front-end/UserView.qml
+++ /dev/null
@@ -1,112 +0,0 @@
-import QtQuick 2.12
-import QtQuick.Controls.Material 2.12
-import QtQuick.Controls 2.12
-import QtQuick.Layouts 1.3
-import QtGraphicalEffects 1.12
-
-
-Flickable {
- id: userVewFlic
-
- contentWidth: userVew.width
- contentHeight: userVew.height
- flickableDirection: Flickable.VerticalFlick;
- property var model: null
- signal tryConnect();
-
- ScrollBar.vertical: ScrollBar {
- width: metrix.pt
- }
-
- Item {
- id: userVew
-
- width: userVewFlic.width
-
- ColumnLayout {
- id: columnLayout
- anchors.fill: parent
-
- visible: (model)? !model.offline: false;
-
- ImageView {
- drawItem: "image://userItems/player/" + ((model)? model.id: -1).toString()
- Layout.fillWidth: true
- Layout.fillHeight: true
-
- }
-
- PropertyView {
- Layout.fillWidth: true
- keyText: qsTr("You ");
- valueText : (model)? model.name: -1
-
- }
-
- PropertyView {
- valueText : ((model)? model.gmail: -1).toString()
- Layout.fillWidth: true
- keyText: qsTr("You gmail");
- }
-
- PropertyView {
- keyText: qsTr("Money ");
-
- valueText : ((model)? model.money: -1).toString()
- Layout.fillWidth: true
- }
-
- PropertyView {
- keyText: qsTr("Record ");
-
- valueText : ((model)? model.record: -1).toString()
- Layout.fillWidth: true
- }
-
- PropertyView {
- keyText: qsTr("AvgRecord ");
-
- valueText : ((model)? model.avgRecord: -1).toString()
- Layout.fillWidth: true
-
- }
-
- PropertyView {
- keyText: qsTr("Snake ");
-
- valueImage : "image://userItems/item/" + ((model)? model.cureentSnake: -1).toString()
- Layout.fillWidth: true
-
- }
- }
-
- ColumnLayout {
- visible: (model)? model.offline: false;
- anchors.fill: parent
-
- Label {
- wrapMode: Text.WordWrap
- Layout.fillWidth: true
-
- text: qsTr("Offline mode. Your statistics will be frozen until you login your profile.");
- }
-
- Button {
- text: qsTr("try conect to server ");
-
- Layout.alignment: Qt.AlignHCenter
-
- onClicked: {
- tryConnect();
- }
- }
-
- Item {
- Layout.fillHeight: true
-
- }
- }
-
- }
-}
-
diff --git a/SnakeClient/SnakeApp/front-end/main.qml b/SnakeClient/SnakeApp/front-end/main.qml
deleted file mode 100644
index bd8e027..0000000
--- a/SnakeClient/SnakeApp/front-end/main.qml
+++ /dev/null
@@ -1,40 +0,0 @@
-import QtQuick 2.12
-import QtQuick.Window 2.12
-import QtQuick.Controls 2.12
-
-ApplicationWindow {
- id: mainWindow;
- visible: true;
- width: 640;
- height: 480;
- title: qsTr("SnakeOnTheRoad");
-
-// Component.onCompleted: {
-// mainWindow.showFullScreen();
-// }
-
-
- Metrix {id: metrix}
-
- Scene {
- id: scane;
- model: contr;
- anchors.fill: parent;
- }
-
- MainMenu {
-
- model: (contr)? contr.mainMenuModel: null;
- anchors.fill: parent;
- visible: scane.showMenu;
-
- onPlayGame: {
- contr.showMenu = false;
- }
-
- }
-
- NotificationServiceView {
- anchors.fill: parent;
- }
-}
diff --git a/SnakeClient/SnakeApp/img/Settings-icon.png b/SnakeClient/SnakeApp/img/Settings-icon.png
deleted file mode 100644
index 4c13597..0000000
Binary files a/SnakeClient/SnakeApp/img/Settings-icon.png and /dev/null differ
diff --git a/SnakeClient/SnakeApp/img/asphalt.jpg b/SnakeClient/SnakeApp/img/asphalt.jpg
deleted file mode 100644
index cf566c2..0000000
Binary files a/SnakeClient/SnakeApp/img/asphalt.jpg and /dev/null differ
diff --git a/SnakeClient/SnakeApp/img/box-texture.png b/SnakeClient/SnakeApp/img/box-texture.png
deleted file mode 100644
index 9592e5f..0000000
Binary files a/SnakeClient/SnakeApp/img/box-texture.png and /dev/null differ
diff --git a/SnakeClient/SnakeApp/img/cogs-solid.svg b/SnakeClient/SnakeApp/img/cogs-solid.svg
deleted file mode 100644
index 9cc62a7..0000000
--- a/SnakeClient/SnakeApp/img/cogs-solid.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/SnakeClient/SnakeApp/img/defaultSnake.png b/SnakeClient/SnakeApp/img/defaultSnake.png
deleted file mode 100644
index 93a3a3f..0000000
Binary files a/SnakeClient/SnakeApp/img/defaultSnake.png and /dev/null differ
diff --git a/SnakeClient/SnakeApp/img/defaultUser.png b/SnakeClient/SnakeApp/img/defaultUser.png
deleted file mode 100644
index 178aeec..0000000
Binary files a/SnakeClient/SnakeApp/img/defaultUser.png and /dev/null differ
diff --git a/SnakeClient/SnakeApp/img/icon.ico b/SnakeClient/SnakeApp/img/icon.ico
deleted file mode 100644
index 53635b1..0000000
Binary files a/SnakeClient/SnakeApp/img/icon.ico and /dev/null differ
diff --git a/SnakeClient/SnakeApp/img/logo.png b/SnakeClient/SnakeApp/img/logo.png
deleted file mode 100644
index f7120fc..0000000
Binary files a/SnakeClient/SnakeApp/img/logo.png and /dev/null differ
diff --git a/SnakeClient/SnakeApp/img/up.svg b/SnakeClient/SnakeApp/img/up.svg
deleted file mode 100644
index 25413c8..0000000
--- a/SnakeClient/SnakeApp/img/up.svg
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
diff --git a/SnakeClient/SnakeApp/qml.qrc b/SnakeClient/SnakeApp/qml.qrc
deleted file mode 100644
index ce92df9..0000000
--- a/SnakeClient/SnakeApp/qml.qrc
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
- front-end/main.qml
- front-end/GraphicItem.qml
- front-end/MainMenu.qml
- qtquickcontrols2.conf
- front-end/Scene.qml
- front-end/NotificationForm.qml
- front-end/SnakeItem.qml
- front-end/About.qml
- front-end/AboutPage.qml
- front-end/BasePopUp.qml
- front-end/TextInput.qml
- front-end/PagePopUp.qml
- front-end/UserView.qml
- front-end/ImageView.qml
- front-end/PropertyView.qml
- front-end/Metrix.qml
- front-end/LoginView.qml
- front-end/FrameView.qml
- front-end/MainMenuButton.qml
- front-end/SideBar.qml
- front-end/LeftSideBar.qml
- front-end/LeftBoxSideBar.qml
- front-end/SettingsView.qml
- front-end/NotificationServiceView.qml
-
-
- img/up.svg
-
-
- img/logo.png
- img/icon.ico
-
-
- img/defaultUser.png
- img/defaultSnake.png
-
-
diff --git a/SnakeClient/SnakeApp/qtquickcontrols2.conf b/SnakeClient/SnakeApp/qtquickcontrols2.conf
deleted file mode 100644
index 49b52e5..0000000
--- a/SnakeClient/SnakeApp/qtquickcontrols2.conf
+++ /dev/null
@@ -1,7 +0,0 @@
-[Controls]
-Style=Material
-
-[Material]
-Accent=Teal
-Primary=BlueGrey
-;Theme=Light
diff --git a/SnakeClient/SnakeClient.pro b/SnakeClient/SnakeClient.pro
deleted file mode 100644
index fb9ca15..0000000
--- a/SnakeClient/SnakeClient.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-TEMPLATE = subdirs
-CONFIG += ordered
-
-SUBDIRS += \
- SnakeApp
diff --git a/SnakeMain.pro b/SnakeMain.pro
deleted file mode 100644
index 97ff5a1..0000000
--- a/SnakeMain.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-
-TEMPLATE = subdirs
-CONFIG += ordered
-
-SUBDIRS += \
- QuasarAppLib \
- SnakeUtils \
- SnakeServer \
- SnakeClient \
-
-
-QuasarAppLib.file = QuasarAppLib/QuasarApp.pro
-Snake.file = Snake/snake.pro
-
-include($$PWD/installer/installerSnake.pri)
-include($$PWD/test.pri)
-
-DISTFILES += \
- doc/librarymodel.qmodel \
- doc/calassdiagramm.qmodel
diff --git a/SnakeServer/ClientProtocol/ClientProtocol.pri b/SnakeServer/ClientProtocol/ClientProtocol.pri
deleted file mode 100644
index dead322..0000000
--- a/SnakeServer/ClientProtocol/ClientProtocol.pri
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright (C) 2018 - 2019 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.
-#
-
-!isEmpty(CLIENTPROTOCOL_LIB):error("ClientProtocol.pri already included")
-CLIENTPROTOCOL_LIB = 1
-
-#DEPENDS
-CONFIG(release, debug|release): {
- CLIENTPROTOCOL_LIB_OUTPUT_DIR="$$PWD/build/release"
-} else {
- CLIENTPROTOCOL_LIB_OUTPUT_DIR="$$PWD/build/debug"
-}
-
-LIBS += -L$$CLIENTPROTOCOL_LIB_OUTPUT_DIR -lClientProtocol
-
-include($$PWD/ClientProtocolIncludes.pri)
-include($$PWD/../Qt-Secret/src/Qt-Secret.pri)
-
-
-
diff --git a/SnakeServer/ClientProtocol/ClientProtocol.pro b/SnakeServer/ClientProtocol/ClientProtocol.pro
deleted file mode 100644
index f7b8129..0000000
--- a/SnakeServer/ClientProtocol/ClientProtocol.pro
+++ /dev/null
@@ -1,91 +0,0 @@
-#
-# Copyright (C) 2018 - 2019 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.
-#
-
-#-------------------------------------------------
-#
-# Project created by QtCreator 2019-02-12T11:08:54
-#
-#-------------------------------------------------
-
-QT -= gui
-QT += network
-
-CONFIG += c++14
-TARGET = ClientProtocol
-TEMPLATE = lib
-
-DEFINES += CLIENTPROTOCOL_LIBRARY
-
-# The following define makes your compiler emit warnings if you use
-# any feature of Qt which has been marked as deprecated (the exact warnings
-# depend on your compiler). Please consult the documentation of the
-# deprecated API in order to know how to port your code away from it.
-DEFINES += QT_DEPRECATED_WARNINGS
-
-# You can also make your code fail to compile if you use deprecated APIs.
-# In order to do so, uncomment the following line.
-# You can also select to disable deprecated APIs only up to a certain version of Qt.
-#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
-
-CONFIG(release, debug|release): {
- DESTDIR = $$PWD/build/release
-
-} else {
- DESTDIR = $$PWD/build/debug
-}
-
-include($$PWD/../../QuasarAppLib/QuasarLib.pri)
-include($$PWD/../../SnakeUtils/SnakeUtils.pri)
-include($$PWD/../Qt-Secret/src/Qt-Secret.pri)
-
-
-SOURCES += \
- Objects/basenetworkobject.cpp \
- Objects/map.cpp \
- Objects/objdata.cpp \
- Objects/pubkey.cpp \
- Objects/snake.cpp \
- Objects/websocket.cpp \
- clientprotocol.cpp \
- client.cpp \
- Objects/gamedata.cpp \
- Objects/getitem.cpp \
- Objects/login.cpp \
- networkclasssize.cpp \
- Objects/player.cpp \
- rsakeyspool.cpp \
- server.cpp \
- factorynetobjects.cpp \
- connectioninfo.cpp \
- Objects/updateplayerdata.cpp
-
-
-HEADERS += \
- Objects/basenetworkobject.h \
- Objects/map.h \
- Objects/objdata.h \
- Objects/pubkey.h \
- Objects/snake.h \
- Objects/websocket.h \
- clientprotocol.h \
- clientprotocol_global.h \
- Objects/gamedata.h \
- Objects/getitem.h \
- Objects/login.h \
- networkclasssize.h \
- client.h \
- Objects/player.h \
- rsakeyspool.h \
- server.h \
- cp.h \
- config.h \
- factorynetobjects.h \
- connectioninfo.h \
- cpserver.h \
- Objects/updateplayerdata.h
-
-include($$PWD/ClientProtocolIncludes.pri)
diff --git a/SnakeServer/ClientProtocol/ClientProtocolIncludes.pri b/SnakeServer/ClientProtocol/ClientProtocolIncludes.pri
deleted file mode 100644
index 0617e71..0000000
--- a/SnakeServer/ClientProtocol/ClientProtocolIncludes.pri
+++ /dev/null
@@ -1,4 +0,0 @@
-INCLUDEPATH += "$$PWD/"
-INCLUDEPATH += "$$PWD/Objects"
-
-
diff --git a/SnakeServer/ClientProtocol/Objects/basenetworkobject.cpp b/SnakeServer/ClientProtocol/Objects/basenetworkobject.cpp
deleted file mode 100644
index 8587d54..0000000
--- a/SnakeServer/ClientProtocol/Objects/basenetworkobject.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-#include "basenetworkobject.h"
-
-namespace ClientProtocol {
-
-
-
-int BaseNetworkObject::id() const {
- return _id;
-}
-
-void BaseNetworkObject::setId(int id) {
- _id = id;
-}
-
-quint8 BaseNetworkObject::getClass() const {
- return _class;
-}
-
-BaseNetworkObject::BaseNetworkObject() {
-}
-
-BaseNetworkObject *BaseNetworkObject::create() const {
- return new BaseNetworkObject();
-}
-
-BaseNetworkObject::~BaseNetworkObject() {
-
-}
-
-NetworkClassSize BaseNetworkObject::classSize() const {
- return getTypeSize(_id) + getTypeSize(_class);
-}
-
-QDataStream &BaseNetworkObject::writeToStream(QDataStream &stream) const {
- stream << _class;
- stream << _id;
- return stream;
-}
-
-QDataStream &BaseNetworkObject::readFromStream(QDataStream &stream) {
- stream >> _class;
- stream >> _id;
- return stream;
-}
-
-bool BaseNetworkObject::isValid() const {
- return _id >= 0 && _class > 0;
-}
-
-void BaseNetworkObject::toBytes(QByteArray &array) const {
- QDataStream stream(&array, QIODevice::WriteOnly);
-
- writeToStream(stream);
-
-}
-
-void BaseNetworkObject::fromBytes(const QByteArray &array) {
- QDataStream stream(array);
-
- readFromStream(stream);
-}
-
-NetworkClassSize getTypeSize(const EncryptionParams ¶ms) {
- bool isKey = params.alg & Key;
-
- switch (params.alg & ~Key) {
- case RSA: {
-
- if (isKey) {
-
- return {
- static_cast(sizeof (int) +
- QRSAEncryption::getKeyBytesSize(static_cast(params.baseBits)))
- };
- }
-
- auto baseSize =
- static_cast(sizeof (int) +
- QRSAEncryption::getKeyBytesSize(static_cast(params.encryptBits))) / 2;
-
- return {baseSize, baseSize * params.baseBytes()};
- }
-
- case SHA: {
- return {static_cast(sizeof (int) + params.baseBytes())};
- }
- default:
- return sizeof (int) + 10;
- }
-
-
-}
-
-unsigned int EncryptionParams::baseBytes() const {
- return baseBits / 8;
-}
-
-}
diff --git a/SnakeServer/ClientProtocol/Objects/basenetworkobject.h b/SnakeServer/ClientProtocol/Objects/basenetworkobject.h
deleted file mode 100644
index 2584496..0000000
--- a/SnakeServer/ClientProtocol/Objects/basenetworkobject.h
+++ /dev/null
@@ -1,89 +0,0 @@
-#ifndef BASENETWORKOBJECT_H
-#define BASENETWORKOBJECT_H
-
-#include "networkclasssize.h"
-
-#include
-#include
-#include
-#include
-#include "config.h"
-#include
-#include "clientprotocol_global.h"
-#include
-
-namespace ClientProtocol {
-
-enum cryptoAlghoritms: unsigned int {
- RSA = 0x0,
- SHA = 0x2,
-
- Key = 0x100
-};
-
-struct EncryptionParams {
- unsigned int alg = SHA;
- unsigned int baseBits = QRSAEncryption::RSA_256;
- unsigned int encryptBits = QRSAEncryption::RSA_256;
-
- unsigned int baseBytes() const;
-};
-NetworkClassSize getTypeSize(const EncryptionParams ¶ms);
-
-template
-NetworkClassSize getTypeSize(const T& type = {}) {
-
- auto hash = typeid(type).hash_code();
-
- if (hash == typeid(QString).hash_code()) {
-
- return { sizeof (int), sizeof (QChar) * MAX_SIZE};
-
- } else if (hash == typeid(QList).hash_code()) {
-
- return { sizeof (int), sizeof (int) * MAX_SIZE};
-
- } else if (hash == typeid(QList).hash_code()) {
-
- return { sizeof (float), sizeof (float) * MAX_SIZE};
-
- } else if (hash == typeid(QStringList).hash_code()) {
-
- auto size = getTypeSize();
- return {sizeof (int) , size.max + static_cast(sizeof (int) * MAX_SIZE)};
-
- }
- return sizeof (type);
-}
-
-class CLIENTPROTOCOLSHARED_EXPORT BaseNetworkObject
-{
-private:
- int _id = -1;
-protected:
- quint8 _class = 0;
-
-public:
- BaseNetworkObject();
- virtual BaseNetworkObject* create() const;
- virtual ~BaseNetworkObject();
-
- virtual NetworkClassSize classSize() const;
- virtual QDataStream& writeToStream(QDataStream& stream) const;
- virtual QDataStream& readFromStream(QDataStream& stream);
- virtual bool isValid() const;
- void toBytes(QByteArray& array) const;
- void fromBytes(const QByteArray& array);
- int id() const;
- void setId(int id);
- quint8 getClass() const;
-};
-
-template
-auto cast(const BaseNetworkObject* obj) {
- static_assert (!std::is_pointer(), "Cast working only with pointers!");
- return static_cast(obj);
-}
-
-}
-#endif // BASENETWORKOBJECT_H
diff --git a/SnakeServer/ClientProtocol/Objects/gamedata.cpp b/SnakeServer/ClientProtocol/Objects/gamedata.cpp
deleted file mode 100644
index 2bd4f19..0000000
--- a/SnakeServer/ClientProtocol/Objects/gamedata.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "gamedata.h"
-#include "config.h"
-#include "clientprotocol.h"
-
-
-namespace ClientProtocol {
-
-GameData::GameData()
-{
- _class = static_cast(Command::GameData);
-}
-
-QList GameData::getTimeClick() const {
- return timeClick;
-}
-
-void GameData::setTimeClick(const QList &value) {
- timeClick = value;
-}
-
-int& GameData::operator[](int index) {
- return timeClick[index];
-}
-
-BaseNetworkObject *GameData::create() const {
- return new GameData();
-}
-
-NetworkClassSize GameData::classSize() const {
- return UpdatePlayerData::classSize() +
- getTypeSize(timeClick);
-}
-
-QDataStream &GameData::writeToStream(QDataStream &stream) const {
- UpdatePlayerData::writeToStream(stream);
- stream << timeClick;
- return stream;
-}
-
-QDataStream &GameData::readFromStream(QDataStream &stream) {
- UpdatePlayerData::readFromStream(stream);
- stream >> timeClick;
- return stream;
-}
-
-bool GameData::isValid() const {
- return timeClick.size() > 0 && UpdatePlayerData::isValid();
-}
-
-}
diff --git a/SnakeServer/ClientProtocol/Objects/gamedata.h b/SnakeServer/ClientProtocol/Objects/gamedata.h
deleted file mode 100644
index e3cf80a..0000000
--- a/SnakeServer/ClientProtocol/Objects/gamedata.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef GAMEDATA_H
-#define GAMEDATA_H
-
-#include
-
-namespace ClientProtocol {
-
-
-class CLIENTPROTOCOLSHARED_EXPORT GameData: public UpdatePlayerData
-{
-private:
- QList timeClick;
-public:
- GameData();
- QList getTimeClick() const;
- void setTimeClick(const QList &value);
- int& operator[](int index);
-
- BaseNetworkObject *create() const override;
- NetworkClassSize classSize() const override;
- QDataStream &writeToStream(QDataStream &stream) const override;
- QDataStream &readFromStream(QDataStream &stream) override;
- bool isValid() const override;
-
-};
-
-}
-#endif // GAMEDATA_H
diff --git a/SnakeServer/ClientProtocol/Objects/getitem.cpp b/SnakeServer/ClientProtocol/Objects/getitem.cpp
deleted file mode 100644
index 352a9cf..0000000
--- a/SnakeServer/ClientProtocol/Objects/getitem.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "getitem.h"
-#include "clientprotocol.h"
-
-namespace ClientProtocol {
-
-GetItem::GetItem()
-{
- _class = static_cast(Command::GetItem);
-}
-}
diff --git a/SnakeServer/ClientProtocol/Objects/getitem.h b/SnakeServer/ClientProtocol/Objects/getitem.h
deleted file mode 100644
index 06978ae..0000000
--- a/SnakeServer/ClientProtocol/Objects/getitem.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef GETITEM_H
-#define GETITEM_H
-
-#include
-
-namespace ClientProtocol {
-
-
-class CLIENTPROTOCOLSHARED_EXPORT GetItem : public UpdatePlayerData
-
-{
-public:
- GetItem();
-};
-
-}
-#endif // GETITEM_H
diff --git a/SnakeServer/ClientProtocol/Objects/login.cpp b/SnakeServer/ClientProtocol/Objects/login.cpp
deleted file mode 100644
index 078bd8f..0000000
--- a/SnakeServer/ClientProtocol/Objects/login.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#include "login.h"
-#include "config.h"
-#include "clientprotocol.h"
-
-namespace ClientProtocol {
-
-bool Login::getRegisterNewUser() const {
- return registerNewUser;
-}
-
-void Login::setRegisterNewUser(bool value) {
- registerNewUser = value;
-}
-
-Login::Login() {
- _class = static_cast(Command::Login);
-}
-
-BaseNetworkObject *Login::create() const {
- return new Login();
-}
-
-NetworkClassSize Login::classSize() const {
- auto size = BaseNetworkObject::classSize();
- EncryptionParams param = {
- cryptoAlghoritms::RSA | cryptoAlghoritms::Key,
- BASE_HASH_BITS,
- BASE_ENCRYPTION_BITS
- };
- return size + getTypeSize(param) + getTypeSize(gmail) + getTypeSize(registerNewUser);
-}
-
-QDataStream &Login::writeToStream(QDataStream &stream) const {
- BaseNetworkObject::writeToStream(stream);
- stream << gmail;
- stream << hashRsaPass;
- stream << registerNewUser;
- return stream;
-}
-
-QDataStream &Login::readFromStream(QDataStream &stream) {
- BaseNetworkObject::readFromStream(stream);
- stream >> gmail;
- stream >> hashRsaPass;
- stream >> registerNewUser;
- return stream;
-}
-
-bool Login::isValid() const {
- return gmail.size() > 5 &&
- hashRsaPass.size() >= 32 &&
- hashRsaPass.size() <= 64 &&
- BaseNetworkObject::isValid();
-}
-
-QString Login::getGmail() const {
- return gmail;
-}
-
-void Login::setGmail(const QString &value) {
- gmail = value;
-}
-
-QByteArray Login::getHashPass() const {
- return hashRsaPass;
-}
-
-void Login::setHashPass(const QByteArray &value) {
- hashRsaPass = value;
-}
-}
diff --git a/SnakeServer/ClientProtocol/Objects/login.h b/SnakeServer/ClientProtocol/Objects/login.h
deleted file mode 100644
index 9061765..0000000
--- a/SnakeServer/ClientProtocol/Objects/login.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef LOGIN_H
-#define LOGIN_H
-
-#include "basenetworkobject.h"
-namespace ClientProtocol {
-
-class CLIENTPROTOCOLSHARED_EXPORT Login : public BaseNetworkObject
-{
-
-private:
- QByteArray hashRsaPass;
- QString gmail;
- bool registerNewUser = false;
-
-public:
- Login();
-
- BaseNetworkObject *create() const override;
- NetworkClassSize classSize() const override;
- QDataStream &writeToStream(QDataStream &stream) const override;
- QDataStream &readFromStream(QDataStream &stream) override;
- bool isValid() const override;
- QString getGmail() const;
- void setGmail(const QString &value);
- QByteArray getHashPass() const;
- void setHashPass(const QByteArray &value);
- bool getRegisterNewUser() const;
- void setRegisterNewUser(bool value);
-};
-}
-#endif // LOGIN_H
diff --git a/SnakeServer/ClientProtocol/Objects/map.cpp b/SnakeServer/ClientProtocol/Objects/map.cpp
deleted file mode 100644
index 9902551..0000000
--- a/SnakeServer/ClientProtocol/Objects/map.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "map.h"
-#include
-
-namespace ClientProtocol {
-
-Map::Map()
-{
- _class = static_cast(Command::Map);
-}
-
-BaseNetworkObject *Map::create() const {
- return new Map();
-}
-
-NetworkClassSize Map::classSize() const {
-
- return BaseNetworkObject::classSize()
- + getTypeSize(lvl)
- + getTypeSize(lenght)
- + getTypeSize(objects);
-}
-
-QDataStream &Map::writeToStream(QDataStream &stream) const {
- BaseNetworkObject::writeToStream(stream);
- stream << lvl;
- stream << lenght;
- stream << objects;
-
- return stream;
-}
-
-QDataStream &Map::readFromStream(QDataStream &stream) {
- BaseNetworkObject::readFromStream(stream);
- stream >> lvl;
- stream >> lenght;
- stream >> objects;
- return stream;
-}
-
-bool Map::isValid() const {
- return lenght > 1 && objects.size() > 1 &&
- BaseNetworkObject::isValid();
-}
-
-}
diff --git a/SnakeServer/ClientProtocol/Objects/map.h b/SnakeServer/ClientProtocol/Objects/map.h
deleted file mode 100644
index f8caa60..0000000
--- a/SnakeServer/ClientProtocol/Objects/map.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef MAP_H
-#define MAP_H
-#include "basenetworkobject.h"
-#include "objdata.h"
-
-namespace ClientProtocol {
-
-class CLIENTPROTOCOLSHARED_EXPORT Map : public BaseNetworkObject
-{
-private:
- quint8 lvl;
- quint16 lenght;
- QList objects;
-
-public:
- Map();
-
- BaseNetworkObject *create() const override;
- NetworkClassSize classSize() const override;
- QDataStream &writeToStream(QDataStream &stream) const override;
- QDataStream &readFromStream(QDataStream &stream) override;
- bool isValid() const override;
-};
-}
-#endif // MAP_H
diff --git a/SnakeServer/ClientProtocol/Objects/objdata.cpp b/SnakeServer/ClientProtocol/Objects/objdata.cpp
deleted file mode 100644
index 9af67e7..0000000
--- a/SnakeServer/ClientProtocol/Objects/objdata.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "objdata.h"
-#include
-
-namespace ClientProtocol {
-
-QDataStream& operator <<(QDataStream &stream, const ObjData &obj) {
- stream << obj.id;
- stream << obj.x;
- stream << obj.y;
- stream << obj.rat;
-
- return stream;
-}
-
-QDataStream& operator >>(QDataStream &stream, ObjData &obj) {
- stream >> obj.id;
- stream >> obj.x;
- stream >> obj.y;
- stream >> obj.rat;
-
- return stream;
-
-}
-}
diff --git a/SnakeServer/ClientProtocol/Objects/objdata.h b/SnakeServer/ClientProtocol/Objects/objdata.h
deleted file mode 100644
index 530b832..0000000
--- a/SnakeServer/ClientProtocol/Objects/objdata.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef OBJDATA_H
-#define OBJDATA_H
-#include "clientprotocol_global.h"
-namespace ClientProtocol {
-
-struct CLIENTPROTOCOLSHARED_EXPORT ObjData {
- int id;
- unsigned short x;
- unsigned short y;
- unsigned short rat;
-
- friend QDataStream& operator << (QDataStream& stream, const ObjData& obj);
- friend QDataStream& operator >> (QDataStream& stream, ObjData& obj);
-
-};
-}
-#endif // OBJDATA_H
diff --git a/SnakeServer/ClientProtocol/Objects/player.cpp b/SnakeServer/ClientProtocol/Objects/player.cpp
deleted file mode 100644
index ff991de..0000000
--- a/SnakeServer/ClientProtocol/Objects/player.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-#include "player.h"
-#include "config.h"
-#include
-
-namespace ClientProtocol {
-
-
-QString Player::getName() const {
- return name;
-}
-
-void Player::setName(const QString &value) {
- name = value;
-}
-
-QString Player::getGmail() const {
- return gmail;
-}
-
-void Player::setGmail(const QString &value) {
- gmail = value;
-}
-
-unsigned int Player::getMany() const
-{
- return money;
-}
-
-void Player::setMany(unsigned int value) {
- money = value;
-}
-
-unsigned int Player::getRecord() const {
- return record;
-}
-
-void Player::setRecord(unsigned int value) {
- record = value;
-}
-
-QList Player::getItems() const {
- return items;
-}
-
-void Player::setItems(const QList &value) {
- items = value;
-}
-
-int Player::getCureentSnake() const {
- return cureentSnake;
-}
-
-void Player::setCureentSnake(int value) {
- cureentSnake = value;
-}
-
-
-unsigned int Player::getAvgRecord() const {
- return avgRecord;
-}
-
-void Player::setAvgRecord(unsigned int value) {
- avgRecord = value;
-}
-
-Player::Player() {
- _class = static_cast(Command::Player);
-
-}
-
-BaseNetworkObject *Player::create() const {
- return new Player();
-}
-
-NetworkClassSize Player::classSize() const {
-
- return UpdatePlayerData::classSize()
- + getTypeSize(name)
- + getTypeSize(gmail)
- + getTypeSize(money)
- + getTypeSize(record)
- + getTypeSize(avgRecord)
- + getTypeSize(items)
- + getTypeSize(cureentSnake);
-}
-
-QDataStream &Player::writeToStream(QDataStream &stream) const {
- UpdatePlayerData::writeToStream(stream);
- stream << name;
- stream << gmail;
- stream << money;
- stream << record;
- stream << avgRecord;
- stream << items;
- stream << cureentSnake;
-
- return stream;
-}
-
-QDataStream &Player::readFromStream(QDataStream &stream) {
- UpdatePlayerData::readFromStream(stream);
- stream >> name;
- stream >> gmail;
- stream >> money;
- stream >> record;
- stream >> avgRecord;
- stream >> items;
- stream >> cureentSnake;
- return stream;
-}
-
-bool Player::isValid() const {
- return !name.isNull() && gmail.size() > 5 &&
- BaseNetworkObject::isValid();
-}
-}
diff --git a/SnakeServer/ClientProtocol/Objects/player.h b/SnakeServer/ClientProtocol/Objects/player.h
deleted file mode 100644
index 88ed364..0000000
--- a/SnakeServer/ClientProtocol/Objects/player.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef PLAYER_H
-#define PLAYER_H
-
-#include "updateplayerdata.h"
-
-
-namespace ClientProtocol {
-
-
-class CLIENTPROTOCOLSHARED_EXPORT Player: public UpdatePlayerData
-{
-private:
- QString name = "user";
- QString gmail = "";
-
- unsigned int money = 0;
- unsigned int record = 0;
- unsigned int avgRecord = 0;
- QList items;
- int cureentSnake = -1;
-
-public:
- Player();
-
- BaseNetworkObject *create() const override;
- NetworkClassSize classSize() const override;
- QDataStream &writeToStream(QDataStream &stream) const override;
- QDataStream &readFromStream(QDataStream &stream) override;
- bool isValid() const override;
- QString getName() const;
- void setName(const QString &value);
- QString getGmail() const;
- void setGmail(const QString &value);
- unsigned int getMany() const;
- void setMany(unsigned int value);
- unsigned int getRecord() const;
- void setRecord(unsigned int value);
- QList getItems() const;
- void setItems(const QList &value);
- int getCureentSnake() const;
- void setCureentSnake(int value);
- unsigned int getAvgRecord() const;
- void setAvgRecord(unsigned int value);
-// QString getHexPass() const;
-// void fromHexPass(const QString& passHex);
-
-};
-
-}
-#endif // PLAYER_H
diff --git a/SnakeServer/ClientProtocol/Objects/pubkey.cpp b/SnakeServer/ClientProtocol/Objects/pubkey.cpp
deleted file mode 100644
index 80cf3e1..0000000
--- a/SnakeServer/ClientProtocol/Objects/pubkey.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "pubkey.h"
-#include "clientprotocol.h"
-
-namespace ClientProtocol {
-
-PubKey::PubKey():
- BaseNetworkObject() {
- _class = static_cast(Command::PubKey);
-}
-
-QRSAEncryption::Rsa PubKey::getTypeKey() const {
- return typeKey;
-}
-
-void PubKey::setTypeKey(const QRSAEncryption::Rsa &value) {
- typeKey = value;
-}
-
-QByteArray PubKey::getKey() const {
- return key;
-}
-
-void PubKey::setKey(const QByteArray &value) {
- key = value;
-}
-
-BaseNetworkObject *PubKey::create() const {
- return new PubKey();
-}
-
-NetworkClassSize PubKey::classSize() const {
- EncryptionParams param = {
- cryptoAlghoritms::RSA | cryptoAlghoritms::Key,
- BASE_ENCRYPTION_BITS
- };
- return BaseNetworkObject::classSize() +
- getTypeSize(param) +
- getTypeSize(int(typeKey));
-}
-
-QDataStream &PubKey::writeToStream(QDataStream &stream) const {
- BaseNetworkObject::writeToStream(stream);
- stream << int(typeKey);
- stream << key;
- return stream;
-}
-
-QDataStream &PubKey::readFromStream(QDataStream &stream) {
- BaseNetworkObject::readFromStream(stream);
- int _typeKey;
- stream >> _typeKey;
- typeKey = static_cast(_typeKey);
- stream >> key;
- return stream;
-}
-
-bool PubKey::isValid() const {
- return static_cast(key.size()) == QRSAEncryption::getKeyBytesSize(typeKey)
- && BaseNetworkObject::isValid();
-}
-
-}
diff --git a/SnakeServer/ClientProtocol/Objects/pubkey.h b/SnakeServer/ClientProtocol/Objects/pubkey.h
deleted file mode 100644
index 913db5c..0000000
--- a/SnakeServer/ClientProtocol/Objects/pubkey.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef PUBKEY_H
-#define PUBKEY_H
-#include
-
-#include "basenetworkobject.h"
-
-namespace ClientProtocol {
-
-class CLIENTPROTOCOLSHARED_EXPORT PubKey: public BaseNetworkObject
-{
-private:
- QRSAEncryption::Rsa typeKey;
- QByteArray key;
-
-public:
- PubKey();
-
- BaseNetworkObject *create() const override;
- NetworkClassSize classSize() const override;
- QDataStream &writeToStream(QDataStream &stream) const override;
- QDataStream &readFromStream(QDataStream &stream) override;
- bool isValid() const override;
-
- QRSAEncryption::Rsa getTypeKey() const;
- void setTypeKey(const QRSAEncryption::Rsa &value);
- QByteArray getKey() const;
- void setKey(const QByteArray &value);
-};
-}
-#endif // PUBKEY_H
diff --git a/SnakeServer/ClientProtocol/Objects/snake.cpp b/SnakeServer/ClientProtocol/Objects/snake.cpp
deleted file mode 100644
index f804a53..0000000
--- a/SnakeServer/ClientProtocol/Objects/snake.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-#include "snake.h"
-#include "clientprotocol.h"
-
-
-namespace ClientProtocol {
-
-quint8 Snake::getSpeed() const {
- return speed;
-}
-
-void Snake::setSpeed(const quint8 &value) {
- speed = value;
-}
-
-quint8 Snake::getSnakeClass() const {
- return snakeClass;
-}
-
-void Snake::setSnakeClass(const quint8 &value) {
- snakeClass = value;
-}
-
-QList Snake::getSkillet() const {
- return skillet;
-}
-
-void Snake::setSkillet(const QList &value) {
- skillet = value;
-}
-
-BaseNetworkObject *Snake::create() const {
- return new Snake();
-}
-
-NetworkClassSize Snake::classSize() const {
- return BaseNetworkObject::classSize() +
- getTypeSize(speed) +
- getTypeSize(snakeClass) +
- getTypeSize(skillet);
-}
-
-QDataStream &Snake::writeToStream(QDataStream &stream) const {
- BaseNetworkObject::writeToStream(stream);
- stream << speed;
- stream << snakeClass;
- stream << skillet;
-
- return stream;
-}
-
-QDataStream &Snake::readFromStream(QDataStream &stream) {
- BaseNetworkObject::readFromStream(stream);
- stream >> speed;
- stream >> snakeClass;
- stream >> skillet;
- return stream;
-}
-
-bool Snake::isValid() const {
- return (speed > 0) && skillet.size() && BaseNetworkObject::isValid();
-}
-
-Snake::Snake() {
- _class = static_cast(Command::Snake);
-
-}
-
-}
diff --git a/SnakeServer/ClientProtocol/Objects/snake.h b/SnakeServer/ClientProtocol/Objects/snake.h
deleted file mode 100644
index 685068e..0000000
--- a/SnakeServer/ClientProtocol/Objects/snake.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef SNAKE_H
-#define SNAKE_H
-
-#include "basenetworkobject.h"
-
-
-namespace ClientProtocol {
-
-class CLIENTPROTOCOLSHARED_EXPORT Snake: public BaseNetworkObject
-{
-private:
- quint8 speed;
- quint8 snakeClass;
- QList skillet;
-
-public:
- Snake();
- quint8 getSpeed() const;
- void setSpeed(const quint8 &value);
- quint8 getSnakeClass() const;
- void setSnakeClass(const quint8 &value);
- QList getSkillet() const;
- void setSkillet(const QList &value);
-
- BaseNetworkObject *create() const override;
- NetworkClassSize classSize() const override;
- QDataStream &writeToStream(QDataStream &stream) const override;
- QDataStream &readFromStream(QDataStream &stream) override;
- bool isValid() const override;
-};
-}
-#endif // SNAKE_H
diff --git a/SnakeServer/ClientProtocol/Objects/updateplayerdata.cpp b/SnakeServer/ClientProtocol/Objects/updateplayerdata.cpp
deleted file mode 100644
index 08df4e0..0000000
--- a/SnakeServer/ClientProtocol/Objects/updateplayerdata.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-#include "updateplayerdata.h"
-#include "config.h"
-#include "clientprotocol.h"
-
-namespace ClientProtocol {
-
-UpdatePlayerData::UpdatePlayerData() {
- _class = static_cast(Command::UpdatePlayerData);
-
-}
-
-QByteArray UpdatePlayerData::getToken() const {
- return token;
-}
-
-void UpdatePlayerData::setToken(const QByteArray &value) {
- token = value;
-}
-
-BaseNetworkObject *UpdatePlayerData::create() const {
- return new UpdatePlayerData();
-}
-
-NetworkClassSize UpdatePlayerData::classSize() const {
- EncryptionParams param = {
- cryptoAlghoritms::SHA,
- BASE_HASH_BITS
- };
-
- return BaseNetworkObject::classSize() + getTypeSize(param);
-}
-
-QDataStream &UpdatePlayerData::writeToStream(QDataStream &stream) const {
- BaseNetworkObject::writeToStream(stream);
- stream << token;
- return stream;
-}
-
-QDataStream &UpdatePlayerData::readFromStream(QDataStream &stream) {
- BaseNetworkObject::readFromStream(stream);
- stream >> token;
- return stream;
-}
-
-bool UpdatePlayerData::isValid() const {
- return token.size() == 32 && BaseNetworkObject::isValid();
-}
-
-}
diff --git a/SnakeServer/ClientProtocol/Objects/updateplayerdata.h b/SnakeServer/ClientProtocol/Objects/updateplayerdata.h
deleted file mode 100644
index 4833c3b..0000000
--- a/SnakeServer/ClientProtocol/Objects/updateplayerdata.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef UPDATEPLAYERDATA_H
-#define UPDATEPLAYERDATA_H
-
-#include "basenetworkobject.h"
-namespace ClientProtocol {
-
-
-class CLIENTPROTOCOLSHARED_EXPORT UpdatePlayerData : public BaseNetworkObject
-{
-private:
- QByteArray token;
-
-public:
- UpdatePlayerData();
- QByteArray getToken() const;
- void setToken(const QByteArray &value);
-
- BaseNetworkObject *create() const override;
- NetworkClassSize classSize() const override;
- QDataStream &writeToStream(QDataStream &stream) const override;
- QDataStream &readFromStream(QDataStream &stream) override;
- bool isValid() const override;
-};
-
-}
-#endif // UPDATEPLAYERDATA_H
diff --git a/SnakeServer/ClientProtocol/Objects/websocket.cpp b/SnakeServer/ClientProtocol/Objects/websocket.cpp
deleted file mode 100644
index 10ae941..0000000
--- a/SnakeServer/ClientProtocol/Objects/websocket.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#include "websocket.h"
-
-namespace ClientProtocol {
-
-WebSocket::WebSocket() {
- _class = static_cast(Command::WebSocket);
-}
-
-BaseNetworkObject *ClientProtocol::WebSocket::create() const {
- return new WebSocket();
-}
-
-NetworkClassSize WebSocket::classSize() const {
- return UpdatePlayerData::classSize() + getTypeSize(_data);
-
-}
-
-QDataStream &WebSocket::writeToStream(QDataStream &stream) const {
- UpdatePlayerData::writeToStream(stream);
- stream << _data;
- return stream;
-}
-
-QDataStream &WebSocket::readFromStream(QDataStream &stream) {
- UpdatePlayerData::readFromStream(stream);
- stream >> _data;
- return stream;
-}
-
-bool WebSocket::isValid() const {
- return static_cast(_data.cmd) != Command::Undefined &&
- UpdatePlayerData::isValid();
-
-}
-
-bool WebSocket::isSubscribe() const {
- return _data.subscribe;
-}
-
-Command WebSocket::getCommand() const {
- return static_cast(_data.cmd);
-}
-
-int WebSocket::getObjectId() const {
- return _data.objectId;
-}
-
-void WebSocket::setSubscribe(bool subscribe){
- _data.subscribe = subscribe;
-}
-
-void WebSocket::setCommand(Command cmd) {
- _data.cmd = static_cast(cmd);
-}
-
-void WebSocket::setObjectId(int value) {
- _data.objectId = value;
-}
-
-QDataStream &operator<<(QDataStream &stream, WebSocketData data) {
- stream.writeRawData(reinterpret_cast(&data), sizeof (data));
- return stream;
-}
-
-QDataStream &operator>>(QDataStream &stream, WebSocketData &data) {
- stream.readRawData(reinterpret_cast(&data), sizeof (data));
- return stream;
-
-}
-
-}
diff --git a/SnakeServer/ClientProtocol/Objects/websocket.h b/SnakeServer/ClientProtocol/Objects/websocket.h
deleted file mode 100644
index 4b2d238..0000000
--- a/SnakeServer/ClientProtocol/Objects/websocket.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef WEBSOCKET_H
-#define WEBSOCKET_H
-#include "updateplayerdata.h"
-#include "clientprotocol.h"
-
-namespace ClientProtocol {
-
-#pragma pack(push, 1)
-struct WebSocketData {
- unsigned char cmd : 5;
- unsigned subscribe : 1;
- int objectId : 26; // -1 is all ovjects, or other bumber is number of object
-
- friend QDataStream& operator<< (QDataStream& stream, WebSocketData data);
- friend QDataStream& operator>> (QDataStream& stream, WebSocketData& data);
-};
-#pragma pack(pop)
-
-class CLIENTPROTOCOLSHARED_EXPORT WebSocket : public UpdatePlayerData
-{
- WebSocketData _data;
-public:
- WebSocket();
-
- BaseNetworkObject *create() const override;
- NetworkClassSize classSize() const override;
- QDataStream &writeToStream(QDataStream &stream) const override;
- QDataStream &readFromStream(QDataStream &stream) override;
- bool isValid() const override;
-
- bool isSubscribe() const;
- Command getCommand() const;
- int getObjectId() const;
-
- void setSubscribe(bool subscribe);
- void setCommand(Command cmd) ;
- void setObjectId(int value);
-
-};
-}
-#endif // WEBSOCKET_H
diff --git a/SnakeServer/ClientProtocol/client.cpp b/SnakeServer/ClientProtocol/client.cpp
deleted file mode 100644
index 1e5c1a4..0000000
--- a/SnakeServer/ClientProtocol/client.cpp
+++ /dev/null
@@ -1,438 +0,0 @@
-#include "client.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "factorynetobjects.h"
-#include "gamedata.h"
-#include "getitem.h"
-#include "login.h"
-#include "updateplayerdata.h"
-#include
-#include
-
-#define SOLT "SNAKE"
-namespace ClientProtocol {
-
-Command Client::checkCommand(int sig, Command reqCmd, Type type) {
-
-#define idx static_cast(sig)
-
- auto expCmd = static_cast(
- _requestsMap[idx].value("expected",
- static_cast(Command::Undefined)).toInt());
-
- if (expCmd == Command::Undefined ||
- expCmd != reqCmd ||
- type != Type::Responke) {
-
- return Command::Undefined;
- }
-
- _requestsMap[idx]["time"] = QDateTime::currentMSecsSinceEpoch();
- return expCmd;
-}
-
-void Client::updateStatuses(Command extCmd, Command cmd, Type type, const QByteArray& obj)
-{
- setOnlineStatus(extCmd != Command::Undefined && type == Type::Responke);
-
- if (extCmd == Command::Login
- && type == Type::Responke) {
-
- UpdatePlayerData data;
- data.fromBytes(obj);
- bool validData = data.isValid();
- if (validData) {
- _token = data.getToken();
-
- }
-
- _currentUserId = data.id();
-
- setLoginStatus(cmd == Command::UpdatePlayerData && validData);
- }
-}
-
-bool Client::receiveData(const QByteArray &obj, Header hdr) {
-
- auto command = static_cast(hdr.command);
- auto requesCommand = static_cast(hdr.requestCommand);
-
- auto type = static_cast(hdr.type);
-
- if (command == Command::PubKey && !_rsaKey.size()) {
- PubKey data;
- data.fromBytes(obj);
- return setRSAKey(data.getKey());;
- }
-
- if (type != Type::Stream) {
- auto expectedCommand = checkCommand(hdr.sig, requesCommand, type);
-
- if (expectedCommand == Command::Undefined) {
- QuasarAppUtils::Params::verboseLog("wrong sig of package");
- return false;
- }
-
- updateStatuses(expectedCommand, command, type, obj);
- } else if (_subscribe.contains(hdr.command)) {
- _subscribe[hdr.command] = true;
- } else {
- return false;
- }
-
- emit sigIncommingData(static_cast(hdr.command), obj);
-
- return true;
-}
-
-bool Client::setRSAKey(const QByteArray& key) {
- bool newStatus = QRSAEncryption::isValidRsaKey(key);
- setOnlineStatus(newStatus);
-
- if (newStatus) {
- _rsaKey = key;
- }
-
- return newStatus;
-}
-
-void Client::setLoginStatus(bool newStatus) {
- if (newStatus != _logined) {
- _logined = newStatus;
- emit loginChanged(_logined);
- }
-}
-
-void Client::setOnlineStatus(bool newOnline) {
- if (newOnline != _online) {
- _online = newOnline;
- emit onlineChanged(_online);
- if (!_online) {
- _rsaKey = "";
- setLoginStatus(false);
- }
- }
-}
-
-void Client::incommingData() {
- auto array = _destination->readAll();
-
- if (_downloadPackage.hdr.isValid()) {
- _downloadPackage.data.append(array);
-
- } else {
- memcpy(&_downloadPackage.hdr,
- array.data(), sizeof(Header));
- _downloadPackage.data.append(array.mid(sizeof(Header)));
- }
-
- if (_downloadPackage.isValid()) {
- if (!receiveData(_downloadPackage.data, _downloadPackage.hdr)) {
- // ban
- }
-
- _downloadPackage.reset();
- return;
- }
-}
-
-void Client::handleDisconnected() {
- setOnlineStatus(false);
-}
-
-Client::Client(const QString &addrress, unsigned short port, QObject *ptr):
- QObject (ptr) {
-
- _destination = new QTcpSocket(this);
- connectToHost(addrress, port);
-
- connect(_destination, &QTcpSocket::readyRead,
- this, &Client::incommingData);
-
- connect(_destination, &QTcpSocket::disconnected,
- this, &Client::handleDisconnected);
-}
-
-bool Client::sendPackage(Package &pkg) {
- if (!pkg.isValid()) {
- return false;
- }
-
- if (!_destination->isValid()) {
- qCritical() << "destination server not valid!";
- return false;
- }
-
- if (!_destination->waitForConnected()) {
- qCritical() << "no connected to server! " << _destination->errorString();
- return false;
- }
-
- auto index = nextIndex();
- _requestsMap[index] = {{"expected", static_cast(pkg.hdr.command)}};
- pkg.hdr.sig = index;
-
- QByteArray bytes = pkg.toBytes();
- bool sendet = bytes.size() == _destination->write(bytes);
-
- return sendet;
-}
-
-unsigned char Client::nextIndex() {
- return static_cast((currentIndex++) % 256);
-}
-
-bool Client::ping() {
-
- Package pcg;
-
- if (!pcg.create(Command::Ping, Type::Request)) {
- return false;
- };
-
- if (!sendPackage(pcg)) {
- return false;
-
- }
-
- return true;
-}
-
-/// Do not change the order of this function,
-/// as this may lead to the loss of user accounts.
-QByteArray Client::generateHash(const QByteArray& pass) const {
- auto passHash = QCryptographicHash::hash(pass, QCryptographicHash::Sha256);
- return QCryptographicHash::hash(SOLT + passHash, QCryptographicHash::Sha256);
-}
-
-bool Client::login(const QString &gmail, const QByteArray &pass, bool newUser) {
- if (!pass.size()) {
- return false;
- }
-
- if (!gmail.size()) {
- return false;
- }
-
- if (!isOnline()) {
- return false;
- }
-
- Package pcg;
-
- Login login;
-
- login.setHashPass(QRSAEncryption::encode(generateHash(pass), _rsaKey, QRSAEncryption::RSA_256));
- login.setGmail(gmail);
- login.setId(0);
- login.setRegisterNewUser(newUser);
-
- if (!login.isValid()) {
- return false;
- }
-
- if (!pcg.create(&login, Type::Request)) {
- return false;
- };
-
- if (!sendPackage(pcg)) {
- return false;
-
- }
-
- return true;
-}
-
-bool Client::registration(const QString &gmail,
- const QByteArray &pass) {
- return login(gmail, pass, true);
-}
-
-void Client::loginOut() {
- _token = "";
- setLoginStatus(false);
-}
-
-void Client::dissconnectFromHost() {
- loginOut();
- _destination->disconnectFromHost();
-}
-
-void Client::connectToHost(const QString &address, unsigned short port) {
- _destination->connectToHost(_address = address, _port = port);
-}
-
-void Client::reconnectToHost() {
- _destination->connectToHost(_address, _port);
-}
-
-bool Client::updateData() {
-
- if (!isLogin()) {
- return false;
- }
-
- Package pcg;
-
- UpdatePlayerData rec;
- rec.setToken(_token);
- rec.setId(0);
-
- if (!rec.isValid()) {
- return false;
- }
-
- if (!pcg.create(&rec, Type::Request)) {
- return false;
- };
-
- if (!sendPackage(pcg)) {
- return false;
- }
-
- return true;
-}
-
-bool Client::savaData(const QList& gameData) {
- if (!isLogin()) {
- return false;
- }
-
- Package pcg;
-
- GameData rec;
- rec.setToken(_token);
- rec.setTimeClick(gameData);
- rec.setId(0);
-
- if (!rec.isValid()) {
- return false;
- }
-
- if (!pcg.create(&rec, Type::Request)) {
- return false;
- };
-
- if (!sendPackage(pcg)) {
- return false;
- }
-
- return true;
-}
-
-bool Client::getItem(int id) {
-
- if (!isLogin()) {
- return false;
- }
-
- if (id <= 0) {
- return false;
- }
-
- Package pcg;
-
- GetItem rec;
- rec.setToken(_token);
- rec.setId(id);
-
- if (!rec.isValid()) {
- return false;
- }
-
- if (!pcg.create(&rec, Type::Request)) {
- return false;
- };
-
- if (!sendPackage(pcg)) {
- return false;
- }
-
- return true;
-}
-
-bool Client::getPlayer(int id){
- if (!isLogin()) {
- return false;
- }
-
- if (id <= 0) {
- return false;
- }
-
- Package pcg;
-
- UpdatePlayerData rec;
- rec.setToken(_token);
- rec.setId(id);
-
- if (!rec.isValid()) {
- return false;
- }
-
- if (!pcg.create(&rec, Type::Request)) {
- return false;
- };
-
- if (!sendPackage(pcg)) {
- return false;
- }
-
- return true;
-}
-
-const bool& Client::isOnline() const {
- return _online;
-}
-
-const bool& Client::isLogin() const {
- return _logined;
-}
-
-bool Client::setSubscribe(Command cmd, bool subscribe, int id) {
- if (!isLogin()) {
- return false;
- }
-
- Package pcg;
-
- WebSocket rec;
- rec.setId(0);
- rec.setToken(_token);
- rec.setCommand(cmd);
- rec.setObjectId(id);
- rec.setSubscribe(subscribe);
-
- if (!rec.isValid()) {
- return false;
- }
-
- if (!pcg.create(&rec, Type::Stream)) {
- return false;
- };
-
- if (!sendPackage(pcg)) {
- return false;
- }
-
- if (subscribe)
- _subscribe[static_cast(cmd)] = false;
- else {
- _subscribe.remove(static_cast(cmd));
- }
-
- return true;
-}
-
-QHash Client::getSubscribe() const {
- return _subscribe;
-}
-
-
-}
diff --git a/SnakeServer/ClientProtocol/client.h b/SnakeServer/ClientProtocol/client.h
deleted file mode 100644
index cff1fd8..0000000
--- a/SnakeServer/ClientProtocol/client.h
+++ /dev/null
@@ -1,156 +0,0 @@
-#ifndef CLIENT_CP_H
-#define CLIENT_CP_H
-
-#include "clientprotocol_global.h"
-#include "clientprotocol.h"
-#include
-#include
-
-class QTcpSocket;
-class Player;
-class BaseItem;
-class testSankeServer;
-
-namespace ClientProtocol {
-
-
-class CLIENTPROTOCOLSHARED_EXPORT Client: public QObject
-{
- Q_OBJECT
-private:
- QTcpSocket *_destination;
- Package _downloadPackage;
- bool _online = false;
- bool _logined = false;
- QByteArray _token;
- QByteArray _rsaKey;
- int currentIndex = 0;
- QHash _requestsMap;
- QHash _subscribe; // command and data confirmation
- QString _address = LOCAL_SNAKE_SERVER;
- unsigned short _port = DEFAULT_SNAKE_PORT;
-
- /**
- * @brief checkCommand - return old sendet command if commnad not valid return undefined command
- * @param sig - sig package
- * @param reqCmd - reqCmd of package
- * @param type - type of package
- * @return if commnad not valid return undefined command
- */
- Command checkCommand(int sig, Command reqCmd, Type type);
- bool receiveData(const QByteArray &obj, Header hdr);
- bool setRSAKey(const QByteArray &key);
- void setLoginStatus(bool newStatus);
- void setOnlineStatus(bool newStatus);
- bool sendPackage(Package &pkg);
- inline unsigned char nextIndex();
-
-
- QByteArray generateHash(const QByteArray &pass) const;
-
- void updateStatuses(Command extCmd, Command cmd, Type type, const QByteArray &obj);
-
-private slots:
- void incommingData();
- void handleDisconnected();
-
-protected:
- int _currentUserId = -1;
-
-
-public:
- explicit Client(const QString& addrress = LOCAL_SNAKE_SERVER,
- unsigned short port = DEFAULT_SNAKE_PORT,
- QObject * ptr = nullptr);
-
-
- /**
- * @brief login - register or login a user
- * @param gmail - gmail of user
- * @param pass - hash of pass of user
- * @param error - error ( if all good this variable is empty)
- * @return true if message sendet
- */
- bool virtual login(const QString& gmail, const QByteArray &pass, bool newUser = false);
-
- /**
- * @brief registration - it is wraper of login method
- * @return true if message sendet
- */
- bool virtual registration(const QString& gmail, const QByteArray &pass);
-
-
- bool ping();
-
- void loginOut();
- void dissconnectFromHost();
- void connectToHost(const QString &addrress, unsigned short port);
- void reconnectToHost();
-
- /**
- * @brief updateData
- * @return true if refresh seсcessfully completed
- */
- bool updateData();
-
- /**
- * @brief savedata
- * @param gameData - data of lvl
- * @return true if all good
- */
- bool savaData(const QList &gameData);
-
- /**
- * @brief getItem
- * @param id of item
- * @return item data
- */
- bool getItem(int id);
-
- /**
- * @brief getPlayer
- * @param id of player
- * @return player data
- */
- bool getPlayer(int id);
-
- /**
- * @brief isOnline
- * @return true if client is connected to server and get rsapub key
- */
- const bool &isOnline() const;
-
- /**
- * @brief isLogin
- * @return true if player is online
- */
- const bool &isLogin() const;
-
- /**
- * @brief setSubscribe change subscribe of command "cmd"
- * @param cmd - command of subscribe
- * @param subscribe - boolean barametr. true is subscribe, false is unsubscribe
- * @param id - id of object for commands (Player and Item).
- * If this parameter is -1 then subscribe on all changes of objects.
- * @return true if all good
- */
- bool setSubscribe(Command cmd, bool subscribe, int id = -1);
-
- /**
- * @brief getSubscribe
- * @return set of current subscribe commands
- */
- QHash getSubscribe() const;
-
- friend class ::testSankeServer;
-
-
-signals:
- void sigIncommingData(Command cmd, const QByteArray& obj);
- void onlineChanged(bool);
- void loginChanged(bool);
-
-};
-
-}
-#endif // CLIENT_CP_H
diff --git a/SnakeServer/ClientProtocol/clientprotocol.cpp b/SnakeServer/ClientProtocol/clientprotocol.cpp
deleted file mode 100644
index f12ece6..0000000
--- a/SnakeServer/ClientProtocol/clientprotocol.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-#include "clientprotocol.h"
-#include "gamedata.h"
-#include "getitem.h"
-#include "login.h"
-#include "player.h"
-#include "updateplayerdata.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#define DEFAULT_GAME_PORT 7777
-
-namespace ClientProtocol {
-
-
-Header::Header() {
- reset();
-}
-
-bool Header::isValid() const {
-
- if (sizeof (*this) != 4) {
- return false;
- }
-
- if (static_cast(command) == Command::Undefined) {
- return false;
- }
-
- if (static_cast(type) == Type::Undefined) {
- return false;
- }
-
- if (static_cast(type) == Type::Responke) {
- return static_cast(command) != Command::Undefined;
- }
-
- return isValidSize(command, size);
-}
-
-void Header::reset() {
- size = 0;
- command = static_cast(Command::Undefined);
- type = static_cast(Type::Responke);
-}
-
-Package::Package() {
- reset();
-}
-
-bool Package::isValid() const {
- if (!hdr.isValid()) {
- return false;
- }
-
- if (data.size() && hdr.command != data.at(0)) {
- return false;
- }
-
- return hdr.size == static_cast (data.size());
-}
-
-BaseNetworkObject* Package::parse() const {
- if (!isValid())
- return nullptr;
-
- auto obj = FactoryNetObjects::build(hdr.command);
-
- if (!obj) {
- return nullptr;
- }
-
- QDataStream stream(data);
- obj->readFromStream(stream);
-
- return obj;
-}
-
-
-bool Package::create(const BaseNetworkObject *obj, Type type, const Header *old) {
-
- if (!obj) {
- return false;
- }
-
- auto command = static_cast(obj->getClass());
-
- if (command == Command::Undefined) {
- return false;
- }
-
- QDataStream stream(&data, QIODevice::ReadWrite);
- obj->writeToStream(stream);
-
- return create(command, type, old);
-}
-
-bool Package::create(Command cmd, Type type, const QByteArray &data, const Header* old) {
- this->data = data;
- return create(cmd, type, old);
-}
-
-bool Package::create(Command cmd, Type type, const Header *old) {
-
-
- if (cmd == Command::Undefined) {
- return false;
- }
-
- hdr.command = static_cast(cmd);
- hdr.type = static_cast(type);
- hdr.size = static_cast(data.size());
-
- if (type == Type::Responke) {
- signPackage(old);
- }
-
- return isValid();
-}
-
-QByteArray Package::toBytes() const {
- QByteArray res;
- res.append(reinterpret_cast(const_cast(&hdr)),
- sizeof (hdr));
-
- res.append(data);
- return res;
-}
-
-void Package::reset() {
- hdr.reset();
- data.clear();
-}
-
-bool Package::signPackage(const Header *oldHeader) {
-
- if (!oldHeader || !oldHeader->isValid()) {
- return false;
- }
-
- hdr.sig = oldHeader->sig;
- hdr.requestCommand = oldHeader->command;
-
- return true;
-}
-
-bool isValidSize(quint8 type, unsigned int size) {
-
- if (!FactoryNetObjects::isInited()) {
- return false;
- }
-
- if (!FactoryNetObjects::isRegisteredType(type)) {
- return size == 0;
- }
-
- return FactoryNetObjects::getSize(type).isValid(size);
-}
-
-bool initClientProtockol() {
- if (!FactoryNetObjects::regType(
- static_cast(Command::Login))) {
- return false;
- }
-
- if (!FactoryNetObjects::regType(
- static_cast(Command::UpdatePlayerData))) {
- return false;
- }
-
- if (!FactoryNetObjects::regType(
- static_cast(Command::GameData))) {
- return false;
- }
-
- if (!FactoryNetObjects::regType(
- static_cast(Command::GetItem))) {
- return false;
- }
-
- if (!FactoryNetObjects::regType(
- static_cast(Command::Player))) {
- return false;
- }
-
- if (!FactoryNetObjects::regType(
- static_cast(Command::Snake))) {
- return false;
- }
-
- if (!FactoryNetObjects::regType