commit b4ec551105dd3a9dc17042e52285e68817eb6d10 Author: Andrei Date: Sat Jan 20 17:44:28 2018 +0300 init commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6732e72 --- /dev/null +++ b/.gitignore @@ -0,0 +1,39 @@ +# C++ objects and libs + +*.slo +*.lo +*.o +*.a +*.la +*.lai +*.so +*.dll +*.dylib + +# Qt-es + +/.qmake.cache +/.qmake.stash +*.pro.user +*.pro.user.* +*.qbs.user +*.qbs.user.* +*.moc +moc_*.cpp +moc_*.h +qrc_*.cpp +ui_*.h +Makefile* +*build-* + +# QtCreator + +*.autosave + +# QtCtreator Qml +*.qmlproject.user +*.qmlproject.user.* + +# QtCtreator CMake +CMakeLists.txt.user* + 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/Screenshots/Screenshot.png b/Screenshots/Screenshot.png new file mode 100644 index 0000000..ad2f924 Binary files /dev/null and b/Screenshots/Screenshot.png differ diff --git a/Screenshots/Screenshot2.jpg b/Screenshots/Screenshot2.jpg new file mode 100644 index 0000000..16c265b Binary files /dev/null and b/Screenshots/Screenshot2.jpg differ diff --git a/Screenshots/Screenshot3.jpg b/Screenshots/Screenshot3.jpg new file mode 100644 index 0000000..b40c5d3 Binary files /dev/null and b/Screenshots/Screenshot3.jpg differ diff --git a/forAndroid (long).png b/forAndroid (long).png new file mode 100644 index 0000000..b119e6c Binary files /dev/null and b/forAndroid (long).png differ diff --git a/forAndroid.png b/forAndroid.png new file mode 100644 index 0000000..5d3b42b Binary files /dev/null and b/forAndroid.png differ diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..a6666fe Binary files /dev/null and b/icon.png differ diff --git a/setup/gui/HanoiTower.desktop b/setup/gui/HanoiTower.desktop new file mode 100755 index 0000000..e11284e --- /dev/null +++ b/setup/gui/HanoiTower.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Version=1.0 +Name=Hanoi Towers +Comment=Hanoi Towers Game. +Exec=hanoi-towers +Icon=/snap/hanoi-towers/current/meta/gui/icon.png +Terminal=false +Type=Application +Categories=Games;Application; diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000..260d9a8 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,37 @@ +name: hanoi-towers +version: '1.2' +summary: Hanoi Towers Game +description: | + The Hanoi Tower is one of the most popular puzzles of the 19th century. Three bars are given, on one of which eight rings are strung, the rings differ in size and lie smaller on larger ones. The problem is to transfer the pyramid from eight rings for the least number of moves to another rod. At a time, only one ring is allowed to carry, and you can not put a larger ring on less. + +grade: stable # must be 'stable' to release into candidate/stable channels +confinement: strict # use 'strict' once you have the right plugs and slots + +icon: icon.png + +apps: + hanoi-towers: + command: desktop-launch $SNAP/opt/myapp/hanoi_towers +# desktop: usr/share/applications/desc.desktop + plugs: [home, unity7, x11] + + +parts: + hanoi-towers: + plugin: qmake + qt-version: qt5 + project-files: [hanoi_towers.pro] + source: source + install: | + install -d $SNAPCRAFT_PART_INSTALL/opt/myapp + install hanoi_towers $SNAPCRAFT_PART_INSTALL/opt/myapp/hanoi_towers + build-packages: + - qtdeclarative5-dev + stage-packages: + - libqt5qml5 + - libqt5quick5 + - qml-module-qtquick2 + - qml-module-qtquick-dialogs + - qml-module-qtquick-controls + after: [desktop-qt5] + diff --git a/source/Tower.qml b/source/Tower.qml new file mode 100644 index 0000000..4281c9c --- /dev/null +++ b/source/Tower.qml @@ -0,0 +1,84 @@ +import QtQuick 2.0 +import QtGraphicalEffects 1.0 + +Rectangle { + id: tover + property var items: [] + signal click(var obj) + color: "transparent" + + Rectangle { + + id: centerLine + width: parent.width / 20 + x: parent.width / 2 - width / 2 + radius: 20 + + LinearGradient { + source: parent + anchors.fill: parent + start: Qt.point(0, parent.height / 2) + end: Qt.point(parent.width, parent.height / 2) + gradient: Gradient { + GradientStop { + position: 0.0 + color: "#f0cb98" + } + GradientStop { + position: 1.0 + color: "#d9b077" + } + } + } + + anchors.top: parent.top + anchors.topMargin: 10 + anchors.bottomMargin: 0 + anchors.bottom: parent.bottom + } + + Image { + + id: bottomLine + width: parent.width + height: 10 + x: 0 + fillMode: Image.TileVertically + source: "/textures/res/wood.png" + + anchors.bottomMargin: 0 + anchors.bottom: parent.bottom + } + + radius: 20 + function push(obj) { + if (items.length > 0 && (!obj + || obj.mass > items[items.length - 1].mass)) + return false + items.push(obj) + obj.pushofnumber = items.length + obj.parent = this + return true + } + + function top() { + return items[items.length - 1] + } + + function clear() { + while (items.length) { + items[items.length - 1].destroy() + items.pop() + } + } + function pop() { + items.pop() + } + + MouseArea { + onClicked: { + click(parent) + } + anchors.fill: parent + } +} diff --git a/source/about.qml b/source/about.qml new file mode 100644 index 0000000..75c4b03 --- /dev/null +++ b/source/about.qml @@ -0,0 +1,44 @@ +import QtQuick 2.10 +import QtQuick.Controls 2.3 + +Item { + + id: ab + signal exit + property string type: "about" + Rectangle { + color: Qt.rgba(0.25, 0.25, 0.25, 1) + anchors.fill: parent + } + Image { + x: 0 + y: 0 + width: parent.width + height: parent.height * 0.2 + fillMode: Image.PreserveAspectFit + source: "/icon.png" + } + Label { + id: txt + x: 0 + y: parent.height * 0.2 + width: parent.width + height: parent.height * 0.7 + color: "white" + font.pixelSize: (ab.width < ab.height) ? ab.width / 15 : ab.height / 15 + font.italic: true + wrapMode: Text.Wrap + text: "Product of DigitalFace +* Developers: +* Programmer: Yankovich N. Andrei. +* This game is distributed under the LGPLv3 license. +* Contact: https://github.com/EndrII +* Copyright (C) 2017 Yankovich N. Andrei." + } + MouseArea { + anchors.fill: parent + onClicked: { + ab.parent.source = "game.qml" + } + } +} diff --git a/source/android/AndroidManifest.xml b/source/android/AndroidManifest.xml new file mode 100644 index 0000000..975b07c --- /dev/null +++ b/source/android/AndroidManifest.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/android/build.gradle b/source/android/build.gradle new file mode 100644 index 0000000..ef416b0 --- /dev/null +++ b/source/android/build.gradle @@ -0,0 +1,57 @@ +buildscript { + repositories { + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:1.1.0' + } +} + +allprojects { + repositories { + jcenter() + } +} + +apply plugin: 'com.android.application' + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) +} + +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/source/android/gradle/wrapper/gradle-wrapper.jar b/source/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..8c0fb64 Binary files /dev/null and b/source/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/source/android/gradle/wrapper/gradle-wrapper.properties b/source/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..1e61d1f --- /dev/null +++ b/source/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Apr 10 15:27:10 PDT 2013 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip diff --git a/source/android/gradlew b/source/android/gradlew new file mode 100755 index 0000000..91a7e26 --- /dev/null +++ b/source/android/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# 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 +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# 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\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +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" ] ; 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"` + + # 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 + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/source/android/gradlew.bat b/source/android/gradlew.bat new file mode 100644 index 0000000..aec9973 --- /dev/null +++ b/source/android/gradlew.bat @@ -0,0 +1,90 @@ +@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 + +@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= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@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 Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_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=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +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/source/android/res/drawable-hdpi/icon.png b/source/android/res/drawable-hdpi/icon.png new file mode 100644 index 0000000..a6666fe Binary files /dev/null and b/source/android/res/drawable-hdpi/icon.png differ diff --git a/source/android/res/drawable-ldpi/icon.png b/source/android/res/drawable-ldpi/icon.png new file mode 100644 index 0000000..a6666fe Binary files /dev/null and b/source/android/res/drawable-ldpi/icon.png differ diff --git a/source/android/res/drawable-mdpi/icon.png b/source/android/res/drawable-mdpi/icon.png new file mode 100644 index 0000000..a6666fe Binary files /dev/null and b/source/android/res/drawable-mdpi/icon.png differ diff --git a/source/android/res/values/libs.xml b/source/android/res/values/libs.xml new file mode 100644 index 0000000..77f422c --- /dev/null +++ b/source/android/res/values/libs.xml @@ -0,0 +1,25 @@ + + + + https://download.qt.io/ministro/android/qt5/qt-5.8 + + + + + + + + + + + + + + + + + + + + diff --git a/source/game.qml b/source/game.qml new file mode 100644 index 0000000..dbbf000 --- /dev/null +++ b/source/game.qml @@ -0,0 +1,242 @@ +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Dialogs 1.2 +import Saver 1.0 + +Rectangle { + visible: true + id: gameWindow + width: 640 + height: 480 + color: "#ffffff" + property int all: 1 + MouseArea { + id: mouse + } + Button { + id: b_start + text: "Start" + onClicked: { + gameWindow.start(spin.value) + } + anchors.right: about.left + width: mouseContener.width + height: mouseContener.height + } + Button { + id: b_exit + text: "Exit" + anchors.right: gameWindow.right + width: mouseContener.width + height: mouseContener.height + onClicked: { + Qt.quit() + } + } + Button { + id: about + text: "About" + anchors.right: b_exit.left + width: mouseContener.width + height: mouseContener.height + onClicked: { + gameWindow.parent.source = "about.qml" + } + } + Rectangle { + id: s_start + Rectangle { + Text { + font.bold: true + font.pointSize: height / text.length * 2 + horizontalAlignment: Text.AlignHCenter + styleColor: "#973c3c" + verticalAlignment: Text.AlignVCenter + text: "Tower height:" + anchors.fill: parent + } + anchors.left: parent.left + width: parent.width / 2 + height: parent.height + } + + Frame { + id: frame + padding: 0 + Tumbler { + id: spin + model: 99 + property int value: 4 + property int maximumValue: 99 + + function format(){ + + } + + delegate: Text { + color: "#959595" + text: "" + (modelData + 1) + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + font.pointSize: 16 / (Math.abs(spin.currentIndex - modelData) + 1 ) + + } + + onValueChanged: { + currentIndex = value - 1 + } + + onCurrentIndexChanged: { + value = currentIndex + 1; + } + + onMaximumValueChanged: { + model = maximumValue + } + anchors.fill: parent + } + width: parent.width / 2 + height: parent.height + anchors.right: parent.right + + } + + + anchors.right: b_start.left + width: mouseContener.width * 2 + height: mouseContener.height + } + + Rectangle { + id: step + property int ste: 0 + width: mouseContener.width + height: mouseContener.height + Text { + font.bold: true + font.pointSize: 14 + horizontalAlignment: Text.AlignHCenter + styleColor: "#973c3c" + verticalAlignment: Text.AlignVCenter + text: "" + step.ste + anchors.fill: parent + } + anchors.left: mouseContener.right + } + Item { + id: mouseContener + property var mouseObj: null + width: parent.width * 0.14 + height: parent.height * 0.1 + x: mouse.mouseX + y: mouse.mouseY + function clear() { + if (mouseObj) { + mouseObj.destroy() + } + } + function push(obj) { + mouseObj = obj + obj.parent = this + return true + } + function top() { + return mouseObj + } + function pop() { + mouseObj = null + } + } + function start(value) { + spin.maximumValue = saver.reed + if (saver.reed <= value || value < 0) + spin.value = all = value = saver.reed + else { + spin.value = all = value + } + step.ste = 0 + tower1.clear() + tower2.clear() + tower3.clear() + mouseContener.clear() + while (value--) { + var temp = Qt.createComponent("plate.qml") + if (temp.status === Component.Ready) { + var obj = temp.createObject(parent) + obj.mass = value + 1 + obj.value = all + tower1.push(obj) + } + } + } + function move(from, into) { + if (from[from.lenght - 1] < into[into.lenght - 1]) { + tower1.push() + } + } + function trigered(obj) { + if (mouseContener.mouseObj) { + if (obj.push(mouseContener.top())) { + step.ste++ + mouseContener.pop() + } + } else { + if (mouseContener.push((obj.top()))) + obj.pop() + } + if (tower2.items.length === all || tower3.items.length === all) { + if (all == spin.maximumValue) { + saver.save(spin.value = spin.maximumValue = all + 1) + messageDialog.show("You have passed the level in " + step.ste + + " steps\n and unlocked level " + all + ".") + start(spin.value) + } else { + messageDialog.show( + "You have passed the level in " + step.ste + " steps\n.") + start(++spin.value) + } + } + } + Saver { + id: saver + } + MessageDialog { + id: messageDialog + title: qsTr("You win!!") + + function show(caption) { + messageDialog.text = caption + messageDialog.open() + } + } + Tower { + id: tower1 + width: gameWindow.width * 0.33 + height: gameWindow.height * 0.9 + anchors.left: gameWindow.left + anchors.bottom: gameWindow.bottom + onClick: { + trigered(obj) + } + } + Tower { + id: tower2 + width: tower1.width + height: tower1.height + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: tower1.bottom + onClick: { + trigered(obj) + } + } + Tower { + id: tower3 + width: tower2.width + height: tower2.height + anchors.right: gameWindow.right + anchors.bottom: tower2.bottom + onClick: { + trigered(obj) + } + } +} diff --git a/source/hanoi_towers.pro b/source/hanoi_towers.pro new file mode 100644 index 0000000..0b805a3 --- /dev/null +++ b/source/hanoi_towers.pro @@ -0,0 +1,47 @@ +TEMPLATE = app + +QT += qml quick widgets + +CONFIG += c++11 + +SOURCES += main.cpp \ + saver.cpp + +RESOURCES += qml.qrc +TARGET=hanoi_towers + +# 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 = + +# 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 + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target + +DISTFILES += \ + android/AndroidManifest.xml \ + android/gradle/wrapper/gradle-wrapper.jar \ + android/gradlew \ + android/res/values/libs.xml \ + android/build.gradle \ + android/gradle/wrapper/gradle-wrapper.properties \ + android/gradlew.bat + +ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android + +HEADERS += \ + saver.h diff --git a/source/icon.png b/source/icon.png new file mode 100644 index 0000000..fea5c7d Binary files /dev/null and b/source/icon.png differ diff --git a/source/main.cpp b/source/main.cpp new file mode 100644 index 0000000..fe62917 --- /dev/null +++ b/source/main.cpp @@ -0,0 +1,15 @@ +#include +//#include +#include +#include +#include "saver.h" +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + // app.primaryScreen()->setOrientationUpdateMask(Qt::LandscapeOrientation); + QQmlApplicationEngine engine; + qmlRegisterType("Saver",1,0,"Saver"); + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} diff --git a/source/main.qml b/source/main.qml new file mode 100644 index 0000000..670f0a9 --- /dev/null +++ b/source/main.qml @@ -0,0 +1,18 @@ +import QtQuick 2.5 +import QtQuick.Controls 1.4 + +ApplicationWindow { + visible: true + id: gameWindow + width: 640 + height: 480 + title: qsTr("Hanoi Towers") + Loader { + id: core + source: "game.qml" + anchors.fill: parent + onLoaded: { + item.start(-1) + } + } +} diff --git a/source/plate.qml b/source/plate.qml new file mode 100644 index 0000000..bf8bb06 --- /dev/null +++ b/source/plate.qml @@ -0,0 +1,46 @@ +import QtQuick 2.0 +import QtGraphicalEffects 1.0 + +Rectangle{ + property int mass: 0; + property int value: 1; + property int pushofnumber: 0 + height: parent.height / value * 0.94 + color: "#c0f7de" + width:parent.width * (mass / value) * 0.90 + x:(parent.width - width) / 2 ; + y:parent.height - (pushofnumber*height * 1.01) - 10.5; + radius: 10; + + LinearGradient { + anchors.fill: parent + source: parent + start: Qt.point(0, parent.height / 2) + end: Qt.point(parent.width, parent.height / 2) + gradient: Gradient { + GradientStop { + position: 0.6 + color: Qt.rgba(0.160625, 0.576862745, 0.361176471, 1 - ((value - mass) / value)) + } + GradientStop { + position: 0.4 + color: Qt.rgba(0.23, 0.751568627, 0.480980392, 1 - ((value - mass) / value)) + } + } + } + + Behavior on x{ + NumberAnimation + { + easing.type: Easing.OutElastic + duration: 1000 + } + } + Behavior on y{ + NumberAnimation + { + easing.type: Easing.OutElastic + duration: 1000 + } + } +} diff --git a/source/qml.qrc b/source/qml.qrc new file mode 100644 index 0000000..cf564e8 --- /dev/null +++ b/source/qml.qrc @@ -0,0 +1,14 @@ + + + main.qml + plate.qml + game.qml + Tower.qml + about.qml + icon.png + qtquickcontrols2.conf + + + res/wood.png + + diff --git a/source/qtquickcontrols2.conf b/source/qtquickcontrols2.conf new file mode 100644 index 0000000..add378d --- /dev/null +++ b/source/qtquickcontrols2.conf @@ -0,0 +1,2 @@ +[Controls] +Style=Imagine diff --git a/source/res.qrc b/source/res.qrc new file mode 100644 index 0000000..96d857d --- /dev/null +++ b/source/res.qrc @@ -0,0 +1,5 @@ + + + res/wood.png + + diff --git a/source/res/wood.png b/source/res/wood.png new file mode 100644 index 0000000..99a05b3 Binary files /dev/null and b/source/res/wood.png differ diff --git a/source/saver.cpp b/source/saver.cpp new file mode 100644 index 0000000..df6f4ca --- /dev/null +++ b/source/saver.cpp @@ -0,0 +1,23 @@ +#include "saver.h" + +Saver::Saver(): + QObject() +{ + +} +void Saver::save(const short &lvl) const{ + QFile f(SAVE); + if(f.open(QIODevice::WriteOnly|QIODevice::Truncate)){ + f.write((char*)(&lvl),sizeof(lvl)); + f.close(); + } +} +short Saver::read()const{ + short temp=1; + QFile f(SAVE); + if(f.open(QIODevice::ReadOnly)){ + f.read((char*)&temp,sizeof(temp)); + f.close(); + } + return temp; +} diff --git a/source/saver.h b/source/saver.h new file mode 100644 index 0000000..e540143 --- /dev/null +++ b/source/saver.h @@ -0,0 +1,17 @@ +#ifndef SAVER_H +#define SAVER_H +#include +#include +#define SAVE "save" +class Saver: public QObject +{ + Q_OBJECT + Q_PROPERTY(short reed READ read WRITE save) +public: + Saver(); +public slots: + void save(const short &lvl)const; + short read()const; +}; + +#endif // SAVER_H