init commit

This commit is contained in:
Andrei Yankovich 2018-01-20 17:44:28 +03:00
commit b4ec551105
34 changed files with 1226 additions and 0 deletions

39
.gitignore vendored Normal file
View File

@ -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*

165
LICENSE Normal file
View File

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
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.

BIN
Screenshots/Screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
Screenshots/Screenshot2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
Screenshots/Screenshot3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
forAndroid (long).png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

BIN
forAndroid.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

9
setup/gui/HanoiTower.desktop Executable file
View File

@ -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;

37
snap/snapcraft.yaml Normal file
View File

@ -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]

84
source/Tower.qml Normal file
View File

@ -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
}
}

44
source/about.qml Normal file
View File

@ -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"
}
}
}

View File

@ -0,0 +1,77 @@
<?xml version="1.0"?>
<manifest package="df.mobily.hanoi_towers" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.2" android:versionCode="2" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:icon="@drawable/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="landscape" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Application arguments -->
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
<!-- Application arguments -->
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<!-- Messages maps -->
<!-- Splash screen -->
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
<!-- Splash screen -->
<!-- Background running -->
<!-- Warning: changing this value to true may cause unexpected crashes if the
application still try to draw after
"applicationStateChanged(Qt::ApplicationSuspended)"
signal is sent! -->
<meta-data android:name="android.app.background_running" android:value="false"/>
<!-- Background running -->
<!-- auto screen scale factor -->
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
<!-- auto screen scale factor -->
<!-- extract android style -->
<!-- available android:values :
* full - useful QWidget & Quick Controls 1 apps
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
* none - useful for apps that don't use any of the above Qt modules
-->
<meta-data android:name="android.app.extract_android_style" android:value="full"/>
<!-- extract android style -->
</activity>
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/>
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. -->
<!-- %%INSERT_PERMISSIONS -->
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
Remove the comment if you do not require these default features. -->
<!-- %%INSERT_FEATURES -->
</manifest>

View File

@ -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
}
}

Binary file not shown.

View File

@ -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

164
source/android/gradlew vendored Executable file
View File

@ -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 "$@"

90
source/android/gradlew.bat vendored Normal file
View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -0,0 +1,25 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<array name="qt_sources">
<item>https://download.qt.io/ministro/android/qt5/qt-5.8</item>
</array>
<!-- The following is handled automatically by the deployment tool. It should
not be edited manually. -->
<array name="bundled_libs">
<!-- %%INSERT_EXTRA_LIBS%% -->
</array>
<array name="qt_libs">
<!-- %%INSERT_QT_LIBS%% -->
</array>
<array name="bundled_in_lib">
<!-- %%INSERT_BUNDLED_IN_LIB%% -->
</array>
<array name="bundled_in_assets">
<!-- %%INSERT_BUNDLED_IN_ASSETS%% -->
</array>
</resources>

242
source/game.qml Normal file
View File

@ -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)
}
}
}

47
source/hanoi_towers.pro Normal file
View File

@ -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

BIN
source/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

15
source/main.cpp Normal file
View File

@ -0,0 +1,15 @@
#include <QApplication>
//#include <QScreen>
#include <QQmlApplicationEngine>
#include <QQmlComponent>
#include "saver.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// app.primaryScreen()->setOrientationUpdateMask(Qt::LandscapeOrientation);
QQmlApplicationEngine engine;
qmlRegisterType<Saver>("Saver",1,0,"Saver");
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}

18
source/main.qml Normal file
View File

@ -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)
}
}
}

46
source/plate.qml Normal file
View File

@ -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
}
}
}

14
source/qml.qrc Normal file
View File

@ -0,0 +1,14 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>plate.qml</file>
<file>game.qml</file>
<file>Tower.qml</file>
<file>about.qml</file>
<file>icon.png</file>
<file>qtquickcontrols2.conf</file>
</qresource>
<qresource prefix="/textures">
<file>res/wood.png</file>
</qresource>
</RCC>

View File

@ -0,0 +1,2 @@
[Controls]
Style=Imagine

5
source/res.qrc Normal file
View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/textures">
<file>res/wood.png</file>
</qresource>
</RCC>

BIN
source/res/wood.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

23
source/saver.cpp Normal file
View File

@ -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;
}

17
source/saver.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef SAVER_H
#define SAVER_H
#include <QObject>
#include <QFile>
#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