Verified Commit a795ee40 authored by Artem Sidyakin's avatar Artem Sidyakin
Browse files

Done

- customizing chosen coffee type
- complete navigation
- setting coffee parameters globally
- more crutches for the foam level
- skip foaming if foam is set to 0
- broken state just in case
- fuck level marks, they were broken from the beginning
- feng-shui
parent ada16d42
......@@ -29,9 +29,17 @@ Item {
}
}
function calculateFoamLevel(milkAmount, coffeeAmount, foamAmount) {
var level = 10 - milkAmount - coffeeAmount - foamAmount;
//console.log(level);
if (level < 1) { return 1 / 10; }
else { return level / 10; }
}
Image {
id: emptySpace
anchors.fill: background
sourceSize.width: background.width
sourceSize.height: background.height
fillMode: Image.PreserveAspectFit
source: "qrc:/images/coffee_cup_back.png"
......@@ -40,12 +48,16 @@ Item {
Item {
id: foam
anchors.fill: emptySpace
anchors.topMargin: foamAmount === 0 ? emptySpace.height : emptySpace.height * ((10 - milkAmount - coffeeAmount - foamAmount) / 10)
//anchors.topMargin: foamAmount === 0 ? emptySpace.height : milk.anchors.topMargin - emptySpace.height * 0.2
anchors.topMargin: foamAmount === 0 ? emptySpace.height : emptySpace.height * calculateFoamLevel(milkAmount, coffeeAmount, foamAmount)
clip: true
visible: milk.visible
visible: milk.visible ? (foamAmount > 0 ? true : false) : false
Image {
anchors.bottom: foam.bottom
anchors.horizontalCenter: foam.horizontalCenter
width: emptySpace.width
height: emptySpace.height
sourceSize.width: width
sourceSize.height: height
fillMode: Image.PreserveAspectFit
source: "qrc:/images/liquid_foam.png"
......@@ -60,7 +72,10 @@ Item {
visible: milkAmount > 0
Image {
anchors.bottom: milk.bottom
anchors.horizontalCenter: milk.horizontalCenter
width: emptySpace.width
height: emptySpace.height
sourceSize.width: width
sourceSize.height: height
fillMode: Image.PreserveAspectFit
source: "qrc:/images/liquid_milk.png"
......@@ -74,7 +89,10 @@ Item {
clip: true
Image {
anchors.bottom: coffee.bottom
anchors.horizontalCenter: coffee.horizontalCenter
width: emptySpace.width
height: emptySpace.height
sourceSize.width: width
sourceSize.height: height
fillMode: Image.PreserveAspectFit
source: "qrc:/images/liquid_coffee.png"
......@@ -83,32 +101,29 @@ Item {
LevelMark {
anchors.verticalCenter: foam.top
anchors.left: foam.right
anchors.leftMargin: background.width / 40
anchors.left: emptySpace.horizontalCenter
anchors.leftMargin: emptySpace.height / 2
text: qsTr("MILK FOAM")
pixelSize: emptySpace.height / 15
// showIt: root.showLabels
visible: root.showLabels ? (foamAmount > 0 ? true : false) : false
visible: root.showLabels ? (foam.visible ? true : false) : false
}
LevelMark {
anchors.verticalCenter: milk.top
anchors.left: milk.right
anchors.leftMargin: background.width / 40
anchors.left: emptySpace.horizontalCenter
anchors.leftMargin: emptySpace.height / 2
text: qsTr("HOT MILK")
pixelSize: emptySpace.height / 15
// showIt: root.showLabels
visible: root.showLabels ? (milkAmount > 0 ? true : false) : false
visible: root.showLabels ? (milk.visible ? true : false) : false
}
LevelMark {
anchors.verticalCenter: coffee.top
anchors.left: coffee.right
anchors.leftMargin: background.width / 40
text: qsTr("ESPRESSO COFFEE")
anchors.left: emptySpace.horizontalCenter
anchors.leftMargin: emptySpace.height / 2
text: qsTr("COFFEE")
pixelSize: emptySpace.height / 15
// showIt: root.showLabels
visible: root.showLabels ? (coffeeAmount > 0 ? true : false) : false
visible: root.showLabels ? (coffee.visible ? true : false) : false
}
Rectangle {
......@@ -126,12 +141,10 @@ Item {
id: sugarItem
anchors.horizontalCenter: emptySpace.horizontalCenter
anchors.bottom: emptySpace.bottom
anchors.bottomMargin: emptySpace.width * 0.2
//anchors.leftMargin: emptySpace.width * 0.2
width: emptySpace.width / 2
anchors.bottomMargin: parent.width > parent.height ? emptySpace.height * 0.2 : emptySpace.height * 0.3
width: emptySpace.height / 2
height: width
// anchors.left: emptySpace.left
// anchors.right: emptySpace.right
rotation: -45
Rectangle {
......@@ -174,8 +187,10 @@ Item {
Image {
id: background
anchors.centerIn: root
height: parent.height * 0.8
sourceSize.height: height
width: parent.width// * 0.8
height: parent.height// * 0.8
// sourceSize.width: parent.width
// sourceSize.height: parent.height
fillMode: Image.PreserveAspectFit
source: "qrc:/images/coffee_cup_front.png"
}
......@@ -183,8 +198,10 @@ Item {
Image {
id: question
anchors.centerIn: root
height: parent.height * 0.8
sourceSize.height: height
width: parent.width// * 0.8
height: parent.height// * 0.8
// sourceSize.width: width
// sourceSize.height: height
fillMode: Image.PreserveAspectFit
source: "qrc:/images/coffee_cup_large.png"
}
......
......@@ -3,7 +3,6 @@ import QtQuick 2.11
Item {
property alias text: mark.text
property alias pixelSize: mark.font.pixelSize
// property bool showIt: false
Text {
id: mark
......@@ -12,13 +11,11 @@ Item {
anchors.verticalCenter: line.verticalCenter
text: qsTr("ESPRESSO COFFEE")
color: Styles.labelColor
// visible: showIt
}
Rectangle {
id: line
width: 50
height: 1
color: Styles.labelColor
// visible: mark.visible
}
}
......@@ -13,16 +13,22 @@ Row {
spacing: 10
//height: image.height * 1.2
Text {
id: label
// anchors.left: row.forward ? parent.left : image.right
// anchors.leftMargin: row.forward ? 0 : 10
anchors.verticalCenter: parent.verticalCenter
color: Styles.labelColor
}
Image {
id: image
height: label.height
// anchors.left: row.forward ? label.right : parent.left
// anchors.leftMargin: row.forward ? 10 : 0
anchors.verticalCenter: label.verticalCenter
height: label.height
source: row.forward ? "qrc:/images/forward.png" : "qrc:/images/back.png"
fillMode: Image.PreserveAspectFit
scale: mouseArea.containsMouse ? 1.1 : 1
......
......@@ -4,10 +4,10 @@ import QtQuick.Layouts 1.11
Item {
id: root
property real sugar: 0
property real coffee: 0
property real milk: 0
property real foam: 0
property real sugar: 0
signal brewingReady
......@@ -19,7 +19,7 @@ Item {
ColumnLayout {
anchors.fill: parent
spacing: 0
spacing: 20
Item {
Layout.fillWidth: true
......@@ -37,10 +37,9 @@ Item {
id: cup
Layout.fillWidth: true
Layout.fillHeight: true
Layout.bottomMargin: 30
Layout.bottomMargin: cup.height / 8
questionVisible: false
showLabels: false
sugarAmount: 3
Component.onCompleted: {
makeAnimationsSlower(true)
}
......@@ -116,7 +115,8 @@ Item {
onTriggered: {
statusLabel.text = "ADDING MILK..."
state = "has-milk"
timerFoam.start()
if (root.foam > 0) { timerFoam.start() }
else { timerSugar.start() }
}
}
Timer {
......@@ -130,7 +130,7 @@ Item {
}
Timer {
id: timerSugar
interval: 1000
interval: 2000
onTriggered: {
statusLabel.text = "ADDING SUGAR..."
state = "has-sugar"
......@@ -154,7 +154,14 @@ Item {
}
Component.onCompleted: {
statusLabel.text = "MAKING COFFEE..."
timerCoffee.start()
if (root.coffee > 0)
{
statusLabel.text = "MAKING COFFEE..."
timerCoffee.start()
}
else
{
statusLabel.text = "YOU BROKE THE MACHINE"
}
}
}
import QtQuick 2.11
import QtQuick.Layouts 1.11
import QtQuick.Controls 2.4
Item {
id: root
state: "choosing"
signal choiceReady
signal choiceReady(real ca, real ma, real fa, real sa)
function setCoffee(chosenType, coffee, milk, foam)
{
labelCoffeeType.text = chosenType;
cup.questionVisible = false;
//cup.showLabels = true; // fuck this shit, I give up
cup.coffeeAmount = coffee;
milkSlider.value = milk;
cup.foamAmount = foam;
}
RowLayout {
anchors.fill: parent
......@@ -44,12 +55,7 @@ Item {
text: "Cappuccino"
source: "qrc:/images/cappucino.png"
onCoffeeChosen: {
labelCoffeeType.text = cappuccinoButton.text
cup.questionVisible = false
cup.showLabels = true
cup.coffeeAmount = 2
cup.milkAmount = 3
cup.foamAmount = 3
setCoffee(cappuccinoButton.text, 2, 3, 3)
}
}
......@@ -58,12 +64,7 @@ Item {
text: "Espresso"
source: "qrc:/images/espresso.png"
onCoffeeChosen: {
labelCoffeeType.text = espressoButton.text
cup.questionVisible = false
cup.showLabels = true
cup.coffeeAmount = 3
cup.milkAmount = 0
cup.foamAmount = 0
setCoffee(espressoButton.text, 3, 0, 0)
}
}
......@@ -72,12 +73,7 @@ Item {
text: "Latte"
source: "qrc:/images/latte.png"
onCoffeeChosen: {
labelCoffeeType.text = latteButton.text
cup.questionVisible = false
cup.showLabels = true
cup.coffeeAmount = 2
cup.milkAmount = 4.5
cup.foamAmount = 1.5
setCoffee(latteButton.text, 2, 4, 2)
}
}
......@@ -86,12 +82,7 @@ Item {
text: "Macchiato"
source: "qrc:/images/macchiato.png"
onCoffeeChosen: {
labelCoffeeType.text = macchiatoButton.text
cup.questionVisible = false
cup.showLabels = true
cup.coffeeAmount = 3
cup.milkAmount = 1
cup.foamAmount = 5
setCoffee(macchiatoButton.text, 3, 1, 4)
}
}
}
......@@ -108,6 +99,7 @@ Item {
spacing: 0
Item {
Layout.fillWidth: true
Layout.preferredHeight: parent.height * 0.2
Layout.leftMargin: 20
Text {
......@@ -115,7 +107,7 @@ Item {
anchors.fill: parent
text: qsTr("coffee type")
color: Styles.labelColor
font.pixelSize: cup.height / 8
font.pixelSize: btnNav.textSize//cup.height / 8
font.capitalization: Font.AllUppercase
visible: !cup.questionVisible
}
......@@ -127,23 +119,28 @@ Item {
Layout.fillHeight: true
questionVisible: true
showLabels: false
sugarAmount: 0
milkAmount: milkSlider.value
sugarAmount: sugarSlider.value
Component.onCompleted: {
makeAnimationsSlower(false)
}
}
Item {
Layout.fillWidth: true
Layout.preferredHeight: parent.height * 0.2
Layout.leftMargin: 20
Layout.bottomMargin: -10
Layout.bottomMargin: 20
NavigationButton {
anchors.fill: parent
text: qsTr("CONTINUE")
textSize: cup.height / 8
id: btnNav
anchors.left: parent.left
anchors.bottom: parent.bottom
textSize: rightSideBar.visible ? btnBrew.textSize : cup.height / 8
visible: !cup.questionVisible
onClicked: {
root.state = "customising"
root.state === "customising"
? root.state = "choosing"
: root.state = "customising"
}
}
}
......@@ -153,14 +150,73 @@ Item {
Rectangle {
id: rightSideBar
Layout.preferredWidth: parent.width * 0.3
Layout.maximumWidth: 300
Layout.maximumWidth: 350
Layout.fillHeight: true
color: Styles.sideBarColor
// debug
MouseArea {
ColumnLayout {
anchors.fill: parent
onClicked: {
root.choiceReady()
spacing: 0
Item {
Layout.fillHeight: true
}
ColumnLayout {
Layout.fillWidth: true
Layout.preferredHeight: parent.height * 0.1
Layout.leftMargin: 15
Layout.rightMargin: 15
spacing: 10
RowLayout {
spacing: 10
Image {
source: "qrc:/images/milk.png"
}
Slider {
id: milkSlider
Layout.fillWidth: true
value: 3
to: 4//8 - cup.coffeeAmount - cup.foamAmount
stepSize: 1
}
}
RowLayout {
spacing: 10
Image {
source: "qrc:/images/sugar.png"
}
Slider {
id: sugarSlider
Layout.fillWidth: true
value: 6
to: 10
}
}
}
Item {
Layout.fillWidth: true
Layout.preferredHeight: parent.height * 0.2
Layout.rightMargin: 20
Layout.bottomMargin: 20
NavigationButton {
id: btnBrew
anchors.right: parent.right
anchors.bottom: parent.bottom
text: "BREW"
textSize: parent.width / 5
onClicked: {
root.choiceReady(
cup.coffeeAmount,
cup.milkAmount,
cup.foamAmount,
cup.sugarAmount
)
}
}
}
}
}
......@@ -171,11 +227,13 @@ Item {
name: "choosing"
PropertyChanges { target: leftSideBar; visible: true }
PropertyChanges { target: rightSideBar; visible: false }
PropertyChanges { target: btnNav; text: "CONTINUE"; forward: true }
},
State {
name: "customising"
PropertyChanges { target: leftSideBar; visible: false }
PropertyChanges { target: rightSideBar; visible: true }
PropertyChanges { target: btnNav; text: "BACK"; forward: false }
}
]
}
......@@ -14,20 +14,21 @@ Item {
anchors.fill: parent
spacing: 0
Text {
Layout.alignment: Qt.AlignHCenter
Item {
Layout.fillWidth: true
Layout.preferredHeight: parent.height * 0.2
Layout.topMargin: 20
text: qsTr("PLEASE, INSERT CUP INTO TRAY")
color: Styles.labelColor
font.pixelSize: image.height / 10
Text {
anchors.centerIn: parent
text: qsTr("PLEASE, INSERT CUP INTO TRAY")
color: Styles.labelColor
font.pixelSize: image.height / 10
}
}
Image {
id: image
Layout.fillWidth: true
Layout.fillHeight: true
height: parent.height
fillMode: Image.PreserveAspectFit
source: "qrc:/images/coffee_cup_outline.png"
}
......
......@@ -2,28 +2,40 @@ import QtQuick 2.11
import QtQuick.Window 2.11
Window {
id: root
visible: true
width: 900
minimumWidth: 600
minimumWidth: 800
height: 600
minimumHeight: 400
minimumHeight: 500
title: qsTr("Coffee Machine")
property real coffeeAmount: 0
property real milkAmount: 0
property real foamAmount: 0
property real sugarAmount: 0
Loader {
id: loader
anchors.fill: parent
source: "choice.qml"
source: "qrc:/choice.qml"
Connections {
target: loader.item
onChoiceReady: loader.source = "qrc:/emptycup.qml"
onChoiceReady: {
root.coffeeAmount = ca
root.milkAmount = ma
root.foamAmount = fa
root.sugarAmount = sa
loader.source = "qrc:/emptycup.qml"
}
onCupReady: loader.setSource(
"qrc:/brewing.qml",
{
coffee: 3,
milk: 0,
foam: 2,
sugar: 8
coffee: root.coffeeAmount,
milk: root.milkAmount,
foam: root.foamAmount,
sugar: root.sugarAmount
})
onBrewingReady: loader.source = "qrc:/choice.qml"
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment