added fog and fixed game play of hanoitowers
@ -44,10 +44,10 @@ protected:
|
||||
|
||||
private:
|
||||
QList<QList<int>> save;
|
||||
int maxValueOfLoadedSave = 0;
|
||||
int maxValueOfLoadedSave = 1;
|
||||
int step = 0;
|
||||
|
||||
short _lvl = 0;
|
||||
short _lvl = 1;
|
||||
|
||||
};
|
||||
|
||||
|
88
HanoiTowers/client/Fog.qml
Normal file
@ -0,0 +1,88 @@
|
||||
import QtQuick 2.15
|
||||
|
||||
Item {
|
||||
id: root
|
||||
property string source: ""
|
||||
property alias run: tim.running
|
||||
property real spread: 0.1
|
||||
readonly property int duration: 10000
|
||||
|
||||
visible: backEnd.fog
|
||||
|
||||
onVisibleChanged: {
|
||||
|
||||
console.log("Fog visible = " + fog)
|
||||
}
|
||||
|
||||
Image {
|
||||
id: background
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
source: root.source
|
||||
sourceSize: Qt.size(parent.width, parent.height)
|
||||
visible: true
|
||||
opacity: 1
|
||||
height: parent.height
|
||||
width: parent.width * (1 + spread)
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
easing.type: Easing.InOutQuart
|
||||
duration: root.duration
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
id: background2
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
source: root.source
|
||||
sourceSize: Qt.size(parent.width, parent.height)
|
||||
opacity: 0
|
||||
visible: true
|
||||
anchors.fill: parent
|
||||
height: parent.height
|
||||
width: parent.width * (1 + spread)
|
||||
x: height * spread
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
easing.type: Easing.InOutQuart
|
||||
duration: root.duration
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
id: background3
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
source: root.source
|
||||
sourceSize: Qt.size(parent.width, parent.height)
|
||||
opacity: 0
|
||||
visible: true
|
||||
anchors.fill: parent
|
||||
height: parent.height
|
||||
width: parent.width * (1 + spread)
|
||||
x: - (height * spread)
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
easing.type: Easing.InOutQuart
|
||||
duration: root.duration
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Timer {
|
||||
id: tim
|
||||
|
||||
repeat: true;
|
||||
running: backEnd.fogAnimation
|
||||
interval: root.duration
|
||||
onTriggered: {
|
||||
|
||||
background.opacity = Math.random()
|
||||
background2.opacity = Math.random()
|
||||
background3.opacity = Math.random()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -6,27 +6,28 @@
|
||||
//#
|
||||
|
||||
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Dialogs 1.3
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import "./base" as Base
|
||||
|
||||
|
||||
Rectangle {
|
||||
Item {
|
||||
visible: true
|
||||
id: gameWindow
|
||||
width: 640
|
||||
height: 480
|
||||
color: "#ffffff"
|
||||
property int all: 1
|
||||
property var oldTower
|
||||
property var upPlate : null
|
||||
|
||||
function continue_game() {
|
||||
console.log("continue");
|
||||
property var stateWidget: null
|
||||
|
||||
signal returnToMenu();
|
||||
|
||||
function continue_game() {
|
||||
load("Player");
|
||||
}
|
||||
|
||||
@ -34,80 +35,7 @@ Rectangle {
|
||||
id: theme
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouse
|
||||
}
|
||||
|
||||
Base.BaseText {
|
||||
id: towerheight
|
||||
font.bold: true
|
||||
font.pointSize: height / text.length * 2
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
height: parent.height * 0.08
|
||||
|
||||
styleColor: "#973c3c"
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: qsTr("Tower height:")
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.leftMargin: width * 0.2
|
||||
|
||||
}
|
||||
|
||||
Base.BaseButton {
|
||||
id: frame
|
||||
|
||||
text: qsTr("lvl ") + (tumbler.spin.currentIndex + 1)
|
||||
width: parent.width * 0.13
|
||||
height: parent.height * 0.08
|
||||
|
||||
onClicked: {
|
||||
tumbler.visible = true;
|
||||
}
|
||||
anchors.left: towerheight.right
|
||||
anchors.top: parent.top
|
||||
anchors.leftMargin: frame.width * 0.2
|
||||
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: step
|
||||
property int ste: 0
|
||||
width: frame.width * 0.8
|
||||
height: frame.height
|
||||
Text {
|
||||
font.bold: true
|
||||
font.pointSize: 14
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
styleColor: "#973c3c"
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: qsTr("step ") + step.ste
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
anchors.left: frame.right
|
||||
anchors.leftMargin: frame.width * 0.2
|
||||
anchors.top: parent.top
|
||||
}
|
||||
|
||||
Base.BaseButton {
|
||||
id: b_exit
|
||||
text: qsTr("Return to main menu")
|
||||
height: frame.height
|
||||
width: frame.width * 2
|
||||
|
||||
onClicked: {
|
||||
gameWindow.parent.source = "menu/MainMenu.qml"
|
||||
}
|
||||
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: parent.width * 0.05;
|
||||
anchors.top: parent.top
|
||||
|
||||
}
|
||||
|
||||
function launch(){
|
||||
function launch() {
|
||||
if (backEnd.isFirst) {
|
||||
help.open();
|
||||
}
|
||||
@ -119,7 +47,7 @@ Rectangle {
|
||||
function load () {
|
||||
|
||||
backEnd.gameState.load();
|
||||
tumbler.spin.maximumValue = backEnd.gameState.getMaxValueOfLoadedSaves();
|
||||
stateWidget.tumbler.spin.maximumValue = backEnd.gameState.getMaxValueOfLoadedSaves();
|
||||
|
||||
tower1.clear()
|
||||
tower2.clear()
|
||||
@ -130,8 +58,8 @@ Rectangle {
|
||||
upPlate = null;
|
||||
}
|
||||
|
||||
step.ste = backEnd.gameState.getStep();
|
||||
tumbler.spin.value = all = backEnd.gameState.getMaxValueOfLoadedSaves();
|
||||
stateWidget.step = backEnd.gameState.getStep();
|
||||
stateWidget.tumbler.spin.value = all = backEnd.gameState.getMaxValueOfLoadedSaves();
|
||||
|
||||
const towers = [tower1, tower2, tower3]
|
||||
|
||||
@ -140,7 +68,7 @@ Rectangle {
|
||||
toewer.forEach((mass)=>{
|
||||
var temp = Qt.createComponent("plate.qml")
|
||||
if (temp.status === Component.Ready) {
|
||||
let obj = temp.createObject(parent)
|
||||
let obj = temp.createObject(this)
|
||||
obj.mass = mass
|
||||
obj.value = all
|
||||
towers[i].push(obj)
|
||||
@ -151,22 +79,22 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
function start(value) {
|
||||
function start(value = -1 ) {
|
||||
|
||||
tumbler.spin.maximumValue = backEnd.gameState.getMaxValueOfLoadedSaves();
|
||||
if (tumbler.spin.maximumValue <= value || value < 0)
|
||||
tumbler.spin.value = all = value = tumbler.spin.maximumValue
|
||||
stateWidget.tumbler.spin.maximumValue = backEnd.gameState.lvl;
|
||||
if (stateWidget.tumbler.spin.maximumValue <= value || value < 0)
|
||||
stateWidget.tumbler.spin.value = all = value = stateWidget.tumbler.spin.maximumValue
|
||||
else {
|
||||
tumbler.spin.value = all = value
|
||||
stateWidget.tumbler.spin.value = all = value
|
||||
}
|
||||
step.ste = 0
|
||||
stateWidget.step = 0
|
||||
tower1.clear()
|
||||
tower2.clear()
|
||||
tower3.clear()
|
||||
while (value--) {
|
||||
var temp = Qt.createComponent("plate.qml")
|
||||
if (temp.status === Component.Ready) {
|
||||
let obj = temp.createObject(parent)
|
||||
let obj = temp.createObject(this)
|
||||
obj.mass = value + 1
|
||||
obj.value = all
|
||||
tower1.push(obj)
|
||||
@ -178,11 +106,10 @@ Rectangle {
|
||||
saveState(tower1);
|
||||
saveState(tower2);
|
||||
saveState(tower3);
|
||||
|
||||
}
|
||||
|
||||
function saveState(obj) {
|
||||
backEnd.gameState.setStep(step.ste);
|
||||
backEnd.gameState.setStep(stateWidget.step);
|
||||
backEnd.gameState.setTower(obj.number, obj.itemsMassArray);
|
||||
}
|
||||
|
||||
@ -192,11 +119,12 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
function trigered(obj) {
|
||||
tumbler.visible = false;
|
||||
|
||||
stateWidget.tumbler.visible = false;
|
||||
let objectPlate = null;
|
||||
if (upPlate) {
|
||||
if (obj.push(upPlate)) {
|
||||
if(oldTower !== obj) step.ste++
|
||||
if(oldTower !== obj) stateWidget.step++
|
||||
objectPlate = upPlate;
|
||||
upPlate = null
|
||||
}
|
||||
@ -206,32 +134,42 @@ Rectangle {
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ( tower3.items.length === all) {
|
||||
let reward = backEnd.getMinSteps(all) - step.ste + backEnd.getMinSteps(all);
|
||||
let reward = backEnd.getMinSteps(all) - stateWidget.step + backEnd.getMinSteps(all);
|
||||
|
||||
if (reward < 1) {
|
||||
reward = 1;
|
||||
}
|
||||
if (all === tumbler.spin.maximumValue) {
|
||||
backEnd.gameState.unlockNextLvl();
|
||||
if (all === stateWidget.tumbler.spin.maximumValue) {
|
||||
|
||||
popUp.text = (qsTr("You have passed the level in %0 steps and unlocked level %1") +
|
||||
qsTr("\n Minimum steps for this lvl: %2") +
|
||||
qsTr("\n you reward = %3")).
|
||||
arg(step.ste).arg(all + 1).arg(backEnd.getMinSteps(all)).
|
||||
arg(stateWidget.step).arg(all + 1).arg(backEnd.getMinSteps(all)).
|
||||
arg(reward);
|
||||
|
||||
popUp.open()
|
||||
start(backEnd.gameState.getMaxValueOfLoadedSaves())
|
||||
|
||||
const action = function () {
|
||||
backEnd.gameState.unlockNextLvl();
|
||||
start(backEnd.gameState.lvl)
|
||||
}
|
||||
|
||||
popUp.action = action;
|
||||
|
||||
} else {
|
||||
popUp.text = (qsTr("You have passed the level in %0 steps.\n") +
|
||||
qsTr("Minimum steps for this lvl: %1") +
|
||||
qsTr("\n you reward = %3")).
|
||||
arg(step.ste).arg(backEnd.getMinSteps(all)).arg(reward);
|
||||
arg(stateWidget.step).arg(backEnd.getMinSteps(all)).arg(reward);
|
||||
|
||||
popUp.open()
|
||||
start(++tumbler.spin.value)
|
||||
|
||||
const action = function () {
|
||||
start(++stateWidget.tumbler.spin.value)
|
||||
}
|
||||
|
||||
popUp.action = action;
|
||||
}
|
||||
backEnd.setReward(reward);
|
||||
}
|
||||
@ -288,20 +226,7 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
SwitchLvl {
|
||||
id: tumbler
|
||||
|
||||
x: frame.x
|
||||
y: frame.y + frame.height
|
||||
width: frame.width
|
||||
height: parent.height * 0.7
|
||||
|
||||
onStart: {
|
||||
gameWindow.start(lvl);
|
||||
}
|
||||
}
|
||||
|
||||
Help{
|
||||
Help {
|
||||
id: help
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ Dialog {
|
||||
x: (parent.width - width) / 2
|
||||
y: (parent.height - height) / 2
|
||||
property alias text : textContainer.text
|
||||
property var action: function () {}
|
||||
|
||||
Base.BaseText {
|
||||
id: textContainer
|
||||
@ -24,4 +25,8 @@ Dialog {
|
||||
horizontalAlignment: Qt.AlignLeft
|
||||
verticalAlignment: Qt.AlignTop
|
||||
}
|
||||
|
||||
onAccepted: {
|
||||
action();
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,8 @@
|
||||
//#
|
||||
|
||||
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import "./base" as Base
|
||||
|
||||
Rectangle {
|
||||
@ -17,7 +17,7 @@ Rectangle {
|
||||
visible: false
|
||||
|
||||
signal start(var lvl);
|
||||
property var spin: spin
|
||||
property alias spin: spin
|
||||
|
||||
Tumbler {
|
||||
|
||||
@ -27,10 +27,6 @@ Rectangle {
|
||||
property int value: 4
|
||||
property int maximumValue: 99
|
||||
|
||||
function format(){
|
||||
|
||||
}
|
||||
|
||||
delegate: Text {
|
||||
|
||||
color: Qt.rgba(0.5,0.5,0.5,1 / (Math.abs(spin.currentIndex - modelData)))
|
||||
|
@ -18,45 +18,12 @@ Item {
|
||||
signal click(var obj)
|
||||
|
||||
Rectangle {
|
||||
|
||||
id: centerLine
|
||||
height: parent.height
|
||||
width: parent.width / 20
|
||||
x: parent.width / 2 - width / 2
|
||||
y: 0
|
||||
radius: 20
|
||||
|
||||
|
||||
LinearGradient {
|
||||
source: parent
|
||||
anchors.fill: parent
|
||||
start: Qt.point(0, centerLine.height / 2)
|
||||
end: Qt.point(centerLine.width, parent.height / 2)
|
||||
gradient: Gradient {
|
||||
GradientStop {
|
||||
position: 0.0
|
||||
color: "#f0cb98"
|
||||
}
|
||||
GradientStop {
|
||||
position: 1.0
|
||||
color: "#d9b077"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Image {
|
||||
|
||||
id: bottomLine
|
||||
width: parent.width
|
||||
height: 10
|
||||
x: 0
|
||||
fillMode: Image.TileVertically
|
||||
source: "/textures/res/wood.png"
|
||||
|
||||
color: "#d1cccc"
|
||||
anchors.bottomMargin: 0
|
||||
anchors.bottom: parent.bottom
|
||||
height: 10
|
||||
x: 0
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
function up() {
|
||||
|
@ -20,16 +20,20 @@
|
||||
#define DEFAULT_USER_NAME "User"
|
||||
|
||||
#define FIRST_RUN_KEY "isFirstStart"
|
||||
#define LVL_KEY "lvl"
|
||||
#define ANIMATION_KEY "animation"
|
||||
#define RANDOM_COLOR_KEY "randomColor"
|
||||
#define CURRENT_PROFILE_KEY "currentProfile"
|
||||
#define FOG "fog"
|
||||
#define FOG_ANIMATION "fogAnimation"
|
||||
|
||||
BackEnd::BackEnd(QQmlApplicationEngine *engine):
|
||||
QObject()
|
||||
{
|
||||
_settings = QuasarAppUtils::Settings::get();
|
||||
|
||||
_settingsData.animation = animation();
|
||||
_settingsData.randomColor = randomColor();
|
||||
|
||||
connect(this, &BackEnd::profileChanged, [this](){
|
||||
_settings->setValue(CURRENT_PROFILE_KEY, profile());
|
||||
});
|
||||
@ -88,9 +92,10 @@ ProfileData* BackEnd::initProfile(const QByteArray& userId, const QString &userN
|
||||
void BackEnd::reset(){
|
||||
|
||||
_settings->setValue(FIRST_RUN_KEY, true);
|
||||
_settings->setValue(LVL_KEY, 1);
|
||||
_settings->setValue(ANIMATION_KEY, true);
|
||||
_settings->setValue(RANDOM_COLOR_KEY, false);
|
||||
_settings->setValue(FOG, true);
|
||||
_settings->setValue(FOG_ANIMATION, true);
|
||||
|
||||
if (!initProfile(DEFAULT_USER_ID, DEFAULT_USER_NAME)) {
|
||||
throw std::runtime_error("Init default profile is failed!!! on the " + std::string(__func__) + " functions");
|
||||
@ -207,6 +212,14 @@ void BackEnd::setShowHelp(bool state) {
|
||||
_settings->setValue(FIRST_RUN_KEY, state);
|
||||
}
|
||||
|
||||
bool BackEnd::fog() const {
|
||||
return _settings->getValue(FOG, true).toBool();
|
||||
}
|
||||
|
||||
bool BackEnd::fogAnimation() const {
|
||||
return _settings->getValue(FOG_ANIMATION, true).toBool();
|
||||
}
|
||||
|
||||
BackEnd::~BackEnd() {
|
||||
_client.updateProfile(*_profile);
|
||||
}
|
||||
@ -268,3 +281,27 @@ void BackEnd::setReward(int revard) {
|
||||
_profile->setRecord(revard);
|
||||
}
|
||||
}
|
||||
|
||||
void BackEnd::setFog(bool fog) {
|
||||
if (_settingsData.fog == fog)
|
||||
return;
|
||||
|
||||
_settingsData.fog = fog;
|
||||
_settings->setValue(FOG, fog);
|
||||
|
||||
if (!_settingsData.fog)
|
||||
setFogAnimation(_settingsData.fog);
|
||||
|
||||
emit fogChanged(_settingsData.fog);
|
||||
}
|
||||
|
||||
void BackEnd::setFogAnimation(bool fogAnimation) {
|
||||
if (_settingsData.fogAnimation == fogAnimation ||
|
||||
!_settingsData.fog)
|
||||
return;
|
||||
|
||||
_settingsData.fogAnimation = fogAnimation;
|
||||
_settings->setValue(FOG_ANIMATION, fogAnimation);
|
||||
|
||||
emit fogAnimationChanged(_settingsData.fogAnimation);
|
||||
}
|
||||
|
@ -34,6 +34,9 @@ class BackEnd: public QObject
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool randomColor READ randomColor WRITE setRandomColor NOTIFY randomColorChanged)
|
||||
Q_PROPERTY(bool animation READ animation WRITE setAnimation NOTIFY animationChanged)
|
||||
Q_PROPERTY(bool fog READ fog WRITE setFog NOTIFY fogChanged)
|
||||
Q_PROPERTY(bool fogAnimation READ fogAnimation WRITE setFogAnimation NOTIFY fogAnimationChanged)
|
||||
|
||||
Q_PROPERTY(QObject* gameState READ gameState)
|
||||
Q_PROPERTY(QObject* client READ client)
|
||||
Q_PROPERTY(QObject* profileObject READ profileObject NOTIFY profileChanged)
|
||||
@ -64,6 +67,10 @@ public:
|
||||
*/
|
||||
Q_INVOKABLE void setShowHelp(bool state);
|
||||
|
||||
bool fog() const;
|
||||
|
||||
bool fogAnimation() const;
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
@ -123,10 +130,10 @@ public slots:
|
||||
QObject* profileObject() const;
|
||||
|
||||
void removeUser(const QByteArray &userId);
|
||||
|
||||
void setProfile(QString userId);
|
||||
|
||||
void setReward(int);
|
||||
void setFog(bool fog);
|
||||
void setFogAnimation(bool fogAnimation);
|
||||
|
||||
signals:
|
||||
void animationChanged();
|
||||
@ -138,6 +145,10 @@ signals:
|
||||
void showOnlinePage();
|
||||
|
||||
|
||||
void fogChanged(bool fog);
|
||||
|
||||
void fogAnimationChanged(bool fogAnimation);
|
||||
|
||||
private slots:
|
||||
void handleOnlineRequestfromProfile(const QString&);
|
||||
void handleOnlineRequest(const LoginView::UserData&);
|
||||
|
@ -8,7 +8,7 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
Text{
|
||||
Label{
|
||||
Theme{
|
||||
id: theme;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import QtQuick.Window 2.1
|
||||
import "utils.js" as Utils
|
||||
|
||||
Item {
|
||||
readonly property int gameStateFontSize: Utils.baseGameStateFontSize(Screen.pixelDensity)
|
||||
readonly property int fontSize: Utils.baseFontSize(Screen.pixelDensity)
|
||||
readonly property int headerSize: Utils.headerFontSize(Screen.pixelDensity);
|
||||
readonly property int buttonsWidth: Utils.dp(Screen.pixelDensity, 80)
|
||||
|
@ -38,6 +38,10 @@ function baseFontSize(pixelDensity){
|
||||
return Number(dp(pixelDensity, 14));
|
||||
}
|
||||
|
||||
function baseGameStateFontSize(pixelDensity){
|
||||
return Number(dp(pixelDensity, 16));
|
||||
}
|
||||
|
||||
function headerFontSize(pixelDensity){
|
||||
return Number(dp(pixelDensity, 28));
|
||||
}
|
||||
|
@ -34,21 +34,31 @@ ApplicationWindow {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
background: Fog {
|
||||
source: "qrc:/textures/res/fogBack.png"
|
||||
anchors.fill: parent
|
||||
opacity: 0.2
|
||||
}
|
||||
|
||||
contentData: SwipeView {
|
||||
id: stackview
|
||||
state: "MainMenu"
|
||||
anchors.fill: parent
|
||||
interactive: false
|
||||
|
||||
background: Item {}
|
||||
|
||||
Menu.MainMenu {
|
||||
id: mainmenu
|
||||
onStart: {
|
||||
gamePage.start();
|
||||
stackview.state = "Game"
|
||||
gamePage.launch();
|
||||
|
||||
}
|
||||
onLoad: {
|
||||
gamePage.load();
|
||||
stackview.state = "Game"
|
||||
gamePage.load();
|
||||
|
||||
|
||||
}
|
||||
@ -71,6 +81,7 @@ ApplicationWindow {
|
||||
|
||||
Game {
|
||||
id: gamePage
|
||||
stateWidget: gameWindow.header.gameState
|
||||
}
|
||||
|
||||
states: [
|
||||
|
@ -10,6 +10,7 @@ import QtQuick.Controls 2.2
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Extras 1.4
|
||||
import "./../base" as Base
|
||||
import ".."
|
||||
|
||||
Item {
|
||||
id:menuPage
|
||||
@ -55,12 +56,51 @@ Item {
|
||||
backEnd.animation = checked;
|
||||
}
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
id: fogConfig
|
||||
Component.onCompleted: {
|
||||
checked = backEnd.fog
|
||||
}
|
||||
text: qsTr("Fog")
|
||||
onCheckedChanged: {
|
||||
backEnd.fog = checked;
|
||||
}
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
Component.onCompleted: {
|
||||
checked = backEnd.fogAnimation
|
||||
}
|
||||
text: qsTr("Fog Animations")
|
||||
onCheckedChanged: {
|
||||
backEnd.fogAnimation = checked;
|
||||
}
|
||||
enabled: fogConfig.checked
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
id: colorsView
|
||||
fillMode: Image.PreserveAspectFit
|
||||
source: (backEnd && backEnd.randomColor)? "../img/random":"../img/standart"
|
||||
|
||||
Tower {
|
||||
id: exampleTower
|
||||
Component.onCompleted: {
|
||||
let all = 5
|
||||
let value = all
|
||||
while (value--) {
|
||||
var temp = Qt.createComponent("../plate.qml")
|
||||
if (temp.status === Component.Ready) {
|
||||
let obj = temp.createObject(this)
|
||||
obj.mass = value + 1
|
||||
obj.value = all
|
||||
exampleTower.push(obj)
|
||||
obj.updateCoordinates();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
|
||||
}
|
||||
|
||||
|
63
HanoiTowers/client/menu/GameStateWidget.qml
Normal file
@ -0,0 +1,63 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Dialogs 1.3
|
||||
import QtQuick.Layouts 1.15
|
||||
import QtQuick.Window 2.1
|
||||
|
||||
import "../base" as Base
|
||||
import ".."
|
||||
|
||||
RowLayout {
|
||||
id: root
|
||||
|
||||
property alias tumbler: tumblerWidget
|
||||
property alias step: stepWidget.ste
|
||||
|
||||
spacing: Screen.pixelDensity * 5
|
||||
|
||||
Label {
|
||||
id: towerheight
|
||||
font.bold: true
|
||||
font.pixelSize: theme.gameStateFontSize;
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
|
||||
styleColor: "#973c3c"
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: qsTr("Tower height: ")
|
||||
|
||||
}
|
||||
|
||||
Base.BaseButton {
|
||||
id: frame
|
||||
|
||||
text: tumblerWidget.spin.currentIndex + 1
|
||||
onClicked: {
|
||||
tumblerWidget.visible = true;
|
||||
}
|
||||
|
||||
SwitchLvl {
|
||||
id: tumblerWidget
|
||||
|
||||
onStart: {
|
||||
gameWindow.start(lvl);
|
||||
}
|
||||
height: parent.height * 4
|
||||
anchors.top: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
id: stepWidget
|
||||
property int ste: 0
|
||||
font.bold: true
|
||||
|
||||
font.pixelSize: theme.gameStateFontSize;
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
styleColor: "#973c3c"
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: qsTr("step ") + step
|
||||
}
|
||||
|
||||
}
|
@ -18,6 +18,8 @@ Page {
|
||||
id: theme;
|
||||
}
|
||||
|
||||
background: Item {}
|
||||
|
||||
signal load()
|
||||
signal start()
|
||||
signal newState(var state)
|
||||
|
@ -10,10 +10,14 @@ ToolBar {
|
||||
property var client: (backEnd)? backEnd.onlineStatus: null;
|
||||
property int onlineStatus: (client)? client.status : 0
|
||||
property bool returnButton: false
|
||||
property bool gameStateWidget: false
|
||||
|
||||
property string wecomMessage: ""
|
||||
|
||||
property string p_profile: (backEnd)? backEnd.profile: ""
|
||||
|
||||
property alias gameState: gameWidget
|
||||
|
||||
function getStatusColor(status) {
|
||||
switch(status) {
|
||||
|
||||
@ -31,7 +35,6 @@ ToolBar {
|
||||
|
||||
RowLayout {
|
||||
|
||||
|
||||
Base.BaseText {
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
Layout.preferredHeight: returnBut.height
|
||||
@ -42,6 +45,14 @@ ToolBar {
|
||||
font.pixelSize: theme.headerSize;
|
||||
}
|
||||
|
||||
GameStateWidget {
|
||||
id: gameWidget
|
||||
visible: gameStateWidget
|
||||
Layout.preferredHeight: returnBut.height
|
||||
Layout.fillWidth: true
|
||||
|
||||
}
|
||||
|
||||
ToolButton {
|
||||
id: returnBut
|
||||
text: qsTr("Return to main menu");
|
||||
@ -64,6 +75,7 @@ ToolBar {
|
||||
target: root
|
||||
returnButton: false
|
||||
visible: true
|
||||
gameStateWidget: false
|
||||
wecomMessage: qsTr("Welcom to Hanoi Towers ") + p_profile
|
||||
|
||||
}
|
||||
@ -74,6 +86,7 @@ ToolBar {
|
||||
target: root
|
||||
returnButton: true
|
||||
visible: true
|
||||
gameStateWidget: false
|
||||
wecomMessage: qsTr("Profiles") + " (" + p_profile + ")";
|
||||
|
||||
}
|
||||
@ -85,6 +98,7 @@ ToolBar {
|
||||
target: root
|
||||
returnButton: true
|
||||
visible: true
|
||||
gameStateWidget: false
|
||||
wecomMessage: qsTr("This are the main settings")
|
||||
|
||||
}
|
||||
@ -96,6 +110,7 @@ ToolBar {
|
||||
target: root
|
||||
returnButton: true
|
||||
visible: true
|
||||
gameStateWidget: false
|
||||
wecomMessage: qsTr("About Page")
|
||||
|
||||
}
|
||||
@ -106,7 +121,8 @@ ToolBar {
|
||||
PropertyChanges {
|
||||
target: root
|
||||
returnButton: true
|
||||
visible: false
|
||||
visible: true
|
||||
gameStateWidget: true
|
||||
wecomMessage: ""
|
||||
|
||||
}
|
||||
|
@ -6,60 +6,86 @@
|
||||
//#
|
||||
|
||||
|
||||
import QtQuick 2.9
|
||||
import QtGraphicalEffects 1.0
|
||||
import QtQuick 2.15
|
||||
import QtGraphicalEffects 1.15
|
||||
|
||||
Rectangle{
|
||||
Rectangle {
|
||||
property int mass: 0;
|
||||
property int value: 1;
|
||||
property int pushofnumber: 0
|
||||
property int maxHeight: parent.height * 0.1
|
||||
property int curentHeight: parent.height / value * 0.94
|
||||
height: (curentHeight < maxHeight )? curentHeight: maxHeight
|
||||
width:parent.width * (mass / value) * 0.90
|
||||
property int maxHeight: (parent)? parent.height * 0.1 : 0
|
||||
property int curentHeight: (parent)? parent.height / value * 0.94 : 0
|
||||
height: (parent)? ((curentHeight < maxHeight )? curentHeight: maxHeight): 0
|
||||
width: (parent)? parent.width * (mass / value) * 0.90 : 0
|
||||
|
||||
onWidthChanged: {
|
||||
updateCoordinates()
|
||||
}
|
||||
|
||||
onHeightChanged: {
|
||||
updateCoordinates()
|
||||
}
|
||||
|
||||
property int durationAnimation: 1000;
|
||||
|
||||
radius: 10;
|
||||
clip: false
|
||||
color: "#004bb870"
|
||||
|
||||
function updateCoordinates() {
|
||||
x = (parent.width - width) / 2 ;
|
||||
y = parent.height - (pushofnumber*height * 1.01) - 10.5;
|
||||
}
|
||||
|
||||
Image {
|
||||
id: texture;
|
||||
source: "/textures/res/Plate.png"
|
||||
Rectangle {
|
||||
id: texture
|
||||
anchors.fill: parent;
|
||||
color: "#4bb870"
|
||||
radius: 4;
|
||||
clip: true
|
||||
Image {
|
||||
id: mask;
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
source: "/textures/res/fog.png"
|
||||
sourceSize: Qt.size(parent.width, parent.height)
|
||||
visible: true
|
||||
opacity: 0.2
|
||||
anchors.fill: parent;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BrightnessContrast {
|
||||
anchors.fill: (backEnd.randomColor)? "": texture
|
||||
source: (backEnd.randomColor)? "": texture
|
||||
anchors.fill: texture
|
||||
source: texture
|
||||
brightness: (value - mass) / value
|
||||
contrast: (value - mass) / value
|
||||
visible: backEnd && !backEnd.randomColor;
|
||||
|
||||
}
|
||||
|
||||
Colorize {
|
||||
anchors.fill: (!backEnd.randomColor)? "": texture
|
||||
source: (!backEnd.randomColor)? "": texture
|
||||
anchors.fill: texture
|
||||
source: texture
|
||||
hue: (value - mass) / value
|
||||
|
||||
visible: backEnd && backEnd.randomColor;
|
||||
|
||||
saturation: 0.8
|
||||
lightness: 0.5
|
||||
}
|
||||
|
||||
Behavior on x{
|
||||
Behavior on x {
|
||||
NumberAnimation
|
||||
{
|
||||
easing.type: (backEnd.animation)? Easing.OutBounce : Easing.OutExpo
|
||||
easing.type: (backEnd && backEnd.animation)? Easing.OutBounce : Easing.OutExpo
|
||||
duration: durationAnimation
|
||||
}
|
||||
}
|
||||
Behavior on y{
|
||||
Behavior on y {
|
||||
NumberAnimation
|
||||
{
|
||||
easing.type: (backEnd.animation)? Easing.OutBounce : Easing.OutExpo
|
||||
easing.type: (backEnd && backEnd.animation)? Easing.OutBounce : Easing.OutExpo
|
||||
duration: durationAnimation
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@
|
||||
<file>base/utils.js</file>
|
||||
<file>PopUp.qml</file>
|
||||
<file>Help.qml</file>
|
||||
<file alias="ubuntu">res/ubuntu.ttf</file>
|
||||
<file>menu/MainMenu.qml</file>
|
||||
<file>menu/Config.qml</file>
|
||||
<file>SwitchLvl.qml</file>
|
||||
@ -23,15 +22,15 @@
|
||||
<file>menu/UserTableRow.qml</file>
|
||||
<file>menu/ToolBarPage.qml</file>
|
||||
<file>menu/UserTableDelegate.qml</file>
|
||||
<file>menu/GameStateWidget.qml</file>
|
||||
<file>Fog.qml</file>
|
||||
</qresource>
|
||||
<qresource prefix="/textures">
|
||||
<file>res/wood.png</file>
|
||||
<file>res/Plate.png</file>
|
||||
<file>res/fogBack.png</file>
|
||||
<file>res/fog.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/img">
|
||||
<file alias="Help">res/help.jpg</file>
|
||||
<file alias="random">res/randomColor.png</file>
|
||||
<file alias="standart">res/standartColor.png</file>
|
||||
<file alias="Help">res/help.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/languages">
|
||||
<file alias="ru">languages/ru.qm</file>
|
||||
|
BIN
HanoiTowers/client/res/HanoiTowers Banner Android.png
Normal file
After ![]() (image error) Size: 605 KiB |
BIN
HanoiTowers/client/res/HanoiTowers Banner Snap.png
Normal file
After ![]() (image error) Size: 278 KiB |
BIN
HanoiTowers/client/res/HanoiTowers Logo_Web.png
Normal file
After ![]() (image error) Size: 121 KiB |
BIN
HanoiTowers/client/res/HanoiTowers_Banner_Web.png
Normal file
After ![]() (image error) Size: 367 KiB |
Before ![]() (image error) Size: 11 KiB |
BIN
HanoiTowers/client/res/QuasarApp_Logo_web.png
Normal file
After ![]() (image error) Size: 372 KiB |
BIN
HanoiTowers/client/res/fog.png
Normal file
After ![]() (image error) Size: 128 KiB |
BIN
HanoiTowers/client/res/fogBack.png
Normal file
After ![]() (image error) Size: 79 KiB |
Before ![]() (image error) Size: 86 KiB |
Before ![]() (image error) Size: 64 KiB After ![]() (image error) Size: 107 KiB ![]() ![]() |
Before ![]() (image error) Size: 58 KiB |
Before ![]() (image error) Size: 175 KiB |
BIN
HanoiTowers/client/res/help.png
Normal file
After ![]() (image error) Size: 90 KiB |
Before (image error) Size: 22 KiB After (image error) Size: 33 KiB |
Before ![]() (image error) Size: 22 KiB After ![]() (image error) Size: 121 KiB ![]() ![]() |
Before ![]() (image error) Size: 5.7 KiB After ![]() (image error) Size: 18 KiB ![]() ![]() |
Before ![]() (image error) Size: 20 KiB |
Before ![]() (image error) Size: 28 KiB |
Before ![]() (image error) Size: 102 KiB |
@ -6,6 +6,9 @@ struct SettingsData
|
||||
{
|
||||
bool animation = false;
|
||||
bool randomColor = false;
|
||||
|
||||
bool fog = true;
|
||||
bool fogAnimation = true;
|
||||
};
|
||||
|
||||
#endif // SETTINGSDATA_H
|
||||
|