4
1
mirror of https://github.com/QuasarApp/Snake.git synced 2025-05-12 17:39:47 +00:00

added first android version

This commit is contained in:
Andrei Yankovich 2018-11-25 18:10:08 +03:00
parent 3dbb3776cc
commit 67865a9211
27 changed files with 783 additions and 27 deletions

@ -0,0 +1,83 @@
<?xml version='1.0' encoding='utf-8'?>
<manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation"
android:name="org.qtproject.qt5.android.bindings.QtActivity"
android:label="-- %%INSERT_APP_NAME%% --"
android:screenOrientation="unspecified"
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%% --"/>
<!-- Used to specify custom system library path to run with local system libs -->
<!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/> -->
<!-- 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>

57
android/build.gradle Normal file

@ -0,0 +1,57 @@
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
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.

@ -0,0 +1,6 @@
#Mon Feb 20 10:43:22 EST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4-bin.zip

172
android/gradlew vendored Executable file

@ -0,0 +1,172 @@
#!/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="-Xmx1024m -Dfile.encoding=UTF-8"
# 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" "$@"

84
android/gradlew.bat vendored Normal file

@ -0,0 +1,84 @@
@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=-Xmx1024m -Dfile.encoding=UTF-8
@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

@ -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.9</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>

@ -1,8 +1,11 @@
#include "baseclass.h"
void BaseClass::setName(const QString &value) {
name = value;
}
BaseClass::BaseClass() :
name("BaseClass") {
}
BaseClass::~BaseClass() {

@ -11,6 +11,7 @@ public:
virtual void render() = 0;
virtual ~BaseClass();
QString getName() const;
void setName(const QString &value);
};
#endif // BASECLASS_H

@ -24,7 +24,6 @@ bool Controller::nextLvl() {
void Controller::generateDiff(const QMap<int, GuiObject *>& objs) {
auto removeIds = objectsContainer.keys();
QList<int> addedIds;
@ -57,11 +56,13 @@ void Controller::update() {
stopTimer();
emit finished(true, lvl, world.getCurrentLong());
}
long_changed(static_cast<int>(world.getCurrentLong()));
}
void Controller::newGame() {
world.clear();
world.resetPosition();
WorldRules newGameRules = lvls.first();
lvl = 0;
@ -81,6 +82,10 @@ void Controller::stopTimer() {
timer->stop();
}
int Controller::long_() const {
return static_cast<int>(world.getCurrentLong());
}
void Controller::buttonPress() {
world.reversClick();
}

@ -12,6 +12,8 @@ class Controller : public QObject
{
Q_OBJECT
Q_PROPERTY(int long_ READ long_ NOTIFY long_changed)
private:
World world;
QTimer *timer;
@ -19,12 +21,13 @@ private:
QMap<int, GuiObject *> objectsContainer;
void generateDiff(const QMap<int, GuiObject *> &);
public:
Controller();
void startTimer();
void stopTimer();
int long_() const;
public slots:
void buttonPress();
void update();
@ -61,6 +64,7 @@ signals:
* @param dif
*/
void gameObjectsChanged(const Diff &dif);
void long_changed(int m_long);
};
#endif // CONTROLLER_H

@ -68,6 +68,11 @@ void GuiObject::setH(double h) {
emit hChanged(m_h);
}
void GuiObject::reset() {
setX(-1);
setY(-1);
}
void GuiObject::setW(double w) {
m_w = w;
emit wChanged(m_w);

@ -43,7 +43,7 @@ public:
double angle() const;
QString texture() const;
void render();
void render() override;
QRectF rect() const;
virtual void setAngle(double angle);
@ -63,6 +63,8 @@ public:
void setW(double w);
void setH(double h);
virtual void reset();
signals:
void angleChanged(double angle);
void textureChanged(QString texture);

@ -14,6 +14,9 @@ void Head::render() {
emit yChanged(m_y);
}
void Head::reset() {
}
Head::Head(double x, double y, double h, double w, double *spead):
GuiObject () {
setX(x);

@ -15,7 +15,7 @@ public:
Head(double x , double y, double h, double w, double *speed);
void setAngle(double angle) override;
void render() override;
void reset() override;
~Head() override;
};

@ -1,9 +1,9 @@
#include "lvls.h"
QList<WorldRules> lvls {
WorldRules{{"Lvl", 1}, {"Long", 500}, {"Box", 2}, {"Spead", 10}},
WorldRules{{"Lvl", 2}, {"Long", 1000}, {"Box", 4}, {"Spead", 12}},
WorldRules{{"Lvl", 3}, {"Long", 2000}, {"Box", 8}, {"Spead", 14}},
WorldRules{{"Lvl", 4}, {"Long", 4000}, {"Box", 16}, {"Spead", 18}},
WorldRules{{"Lvl", 5}, {"Long", 8000}, {"Box", 32}, {"Spead", 26}}
WorldRules{{"Long", 500}, {"Box", 2}, {"Spead", 10}},
WorldRules{{"Long", 1000}, {"Box", 4}, {"Spead", 12}},
WorldRules{{"Long", 2000}, {"Box", 8}, {"Spead", 14}},
WorldRules{{"Long", 4000}, {"Box", 16}, {"Spead", 18}},
WorldRules{{"Long", 8000}, {"Box", 32}, {"Spead", 26}}
};

@ -81,12 +81,11 @@ QMap<int, GuiObject*> Snake::init(int size, double *speed) {
this->speed = speed;
changeCountObjects(size -items.size());
changeCountObjects(size - items.size());
for (auto i : items) {
res[i->guiId()] = i;
}
return res;
}
@ -101,6 +100,16 @@ void Snake::clearItems() {
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]->setAngle(0);
}
}
Snake::~Snake() {
clearItems();
}

@ -22,10 +22,12 @@ private:
double checDistance(int i);
void clearItems();
public:
Snake();
~Snake() override;
void clear();
void resetPosotion();
void reverse();
void render() override;

@ -25,7 +25,10 @@ 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) {
@ -83,7 +86,8 @@ QMap<int, GuiObject *> World::init(const WorldRules &rules) {
oldRules = rules;
time = QDateTime::currentMSecsSinceEpoch();
defiat = false;
spead = 0;
return res;
}
@ -114,6 +118,13 @@ void World::render() {
currentLong += dx;
}
void World::resetPosition() {
for (auto i : items) {
i->reset();
}
snake.resetPosotion();
}
bool World::move() {
return isEnd();
}

@ -33,6 +33,7 @@ public:
QMap<int, GuiObject*> init(const WorldRules &rules);
~World() override;
void render() override;
void resetPosition();
bool move();
bool isEnd();
const QVector<ItemWorld*>& getItems() const;

@ -5,7 +5,11 @@ import QtQuick.Layouts 1.3
Item {
id: item1
property alias level: level
visible: true
z: 1
signal paly();
ColumnLayout {
@ -19,15 +23,16 @@ Item {
Button {
id: play
text: qsTr("Play game")
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
font.pixelSize: 20
spacing: 4
focusPolicy: Qt.StrongFocus
display: AbstractButton.TextBesideIcon
Layout.preferredHeight: 75
Layout.preferredWidth: 500
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
paly();
contr.newGame();
}
@ -36,21 +41,20 @@ Item {
Button {
id: level
text: qsTr("Select level")
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
font.pixelSize: 20
Layout.preferredWidth: 500
Layout.preferredHeight: 75
spacing: 2
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
Button {
id: exit
text: qsTr("Exit")
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
font.pixelSize: 20
Layout.preferredHeight: 75
Layout.preferredWidth: 500
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
Qt.quit();
@ -63,7 +67,8 @@ Item {
id: roundButton
x: 569
y: 20
height: 20
height: 48
clip: false
anchors.right: parent.right
anchors.rightMargin: 23
anchors.top: parent.top

@ -0,0 +1,136 @@
import QtQuick 2.11
import QtQuick.Controls 2.3
import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.3
Popup {
id : popup
width: 200
height: 100
x: 0
y: 0
transformOrigin: Item.Center
property bool autoClose: true
property int closeInterval: 15000;
property int margin : 0
NumberAnimation {
id: animation;
target: popup
property: "opacity"
easing.period: 0.33
easing.amplitude: 1
duration: 2000
easing.type: Easing.OutElastic
onStopped: {
if (to < 1)
close();
}
}
function show(title_, message_, img_) {
animation.from = 0;
animation.to = 1;
animation.start();
title.text = title_;
message.text = message_;
if (img_) {
image.source = img_;
} else {
image.source = "";
}
if (autoClose) {
timerAnimation.start();
}
open();
}
Timer {
id: timerAnimation;
running: false;
repeat: false;
onTriggered: {
animation.from = 1;
animation.to = 0;
animation.start();
}
}
onClosed: {
opacity = 0;
}
Page {
id: page
title: "Level Up!!!"
anchors.fill: parent
Label {
id: title
x: 0
width: 200
height: 31
text: qsTr("Title Message")
font.bold: true
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 0
font.pointSize: 14
fontSizeMode: Text.Fit
renderType: Text.QtRendering
textFormat: Text.AutoText
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
}
RowLayout {
id: rowLayout
spacing: 5
clip: true
anchors.top: title.bottom
anchors.topMargin: 1
anchors.left: parent.left
anchors.leftMargin: 0
anchors.right: parent.right
anchors.rightMargin: 0
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
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: ""
}
}
Label {
id: message
text: qsTr("Message")
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
Layout.fillHeight: true;
Layout.fillWidth: true;
clip: true
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
}
}
}

@ -1,10 +1,14 @@
import QtQuick 2.9
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
property var model: (contr)? contr: null;
property var arrayObjects: []
signal showMenu();
property bool showMenu: false
function add (cppObjId) {
if (!model) {
console.log("create object fail")
@ -41,6 +45,7 @@ Item {
model.newGame();
}
showMenu = (auto && model)
autoTimer.running = auto && model;
}
@ -79,15 +84,21 @@ Item {
onFinished: {
var isVictory = victory;
var gameLvl = lvl;
var gameLvl = lvl + 1;
var dist = distance;
if (isVictory ) {
if (!autoTimer.running)
notification.show(qsTr(" Next Lvl!!!"),
qsTr(" You anblock next lvl (" + gameLvl + ")" ),
"qrc:/texture/up");
model.nextLvl();
} else if (autoTimer.running) {
model.newGame();
} else {
showMenu();
showMenu = true;
}
}
}
@ -104,4 +115,71 @@ Item {
model.buttonPress();
}
}
NotificationForm {
z: -1
id: notification;
margin: mainWindow.point;
x: parent.width - width - margin;
y: margin;
width: 40 * mainWindow.point;
height: width * 0.5
}
Button {
id: returnToMenu;
text: "<<"
anchors.left: parent.left
anchors.leftMargin: point
anchors.top: parent.top
anchors.topMargin: point
visible: !showMenu
}
Button {
id: pause
text: "||"
anchors.left: returnToMenu.right
anchors.leftMargin: point
anchors.top: parent.top
anchors.topMargin: point
visible: !showMenu
}
Button {
Label {
anchors.fill: parent;
textFormat: Text.AutoText
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
text: qsTr("long: ") + (model)? model.long_: "0"
}
width: 15 * point;
height: pause.height;
anchors.left: pause.right
anchors.leftMargin: point
anchors.top: parent.top
anchors.topMargin: point
visible: !showMenu
}
}

@ -15,6 +15,7 @@ ApplicationWindow {
Component.onCompleted: {
scane.setAuto(true);
// contr.newGame();
}
Scene {
@ -22,8 +23,14 @@ ApplicationWindow {
anchors.fill: parent;
}
// MainMenu {
MainMenu {
// anchors.fill: parent;
// }
anchors.fill: parent;
visible: scane.showMenu;
onPaly: {
scane.setAuto(false);
}
}
}

45
img/up.svg Normal file

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="970.504px" height="970.503px" viewBox="0 0 970.504 970.503" style="enable-background:new 0 0 970.504 970.503;"
xml:space="preserve">
<g>
<path d="M120.027,962.802c26.6,0,53.5-8.801,75.7-27l288.1-234.7l290.899,237c22.301,18.1,49.101,27,75.7,27
c34.8,0,69.4-15.101,93.101-44.2c41.899-51.4,34.1-127-17.2-168.8l-366.7-298.8c-44.1-36-107.5-36-151.6,0l-363.8,296.5
c-51.4,41.8-59.1,117.399-17.3,168.8C50.727,947.702,85.227,962.802,120.027,962.802z"/>
<path d="M120.027,541.902c26.6,0,53.5-8.8,75.7-27l288.1-234.7l290.899,237c22.301,18.101,49.101,27,75.7,27
c34.8,0,69.4-15.1,93.101-44.2c41.899-51.399,34.1-127-17.2-168.8l-366.7-298.8c-44.1-36-107.5-36-151.6,0l-363.8,296.4
c-51.4,41.9-59.1,117.5-17.3,168.9C50.727,526.802,85.227,541.902,120.027,541.902z"/>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

(image error) Size: 1.3 KiB

@ -6,8 +6,11 @@
<file>qtquickcontrols2.conf</file>
<file>front-end/Scene.qml</file>
<file>front-end/Image.qml</file>
<file>front-end/NotificationForm.qml</file>
</qresource>
<qresource prefix="/texture">
<file alias="box-texture">img/box-texture.png</file>
<file alias="up">img/up.svg</file>
<file alias="settings">img/Settings-icon.png</file>
</qresource>
</RCC>

@ -55,4 +55,13 @@ HEADERS += \
back-end/diff.h
DISTFILES += \
doc/calassdiagramm.qmodel
doc/calassdiagramm.qmodel \
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