From 54fff5ee8492b0e1a6cd14e1799e436f7cfea918 Mon Sep 17 00:00:00 2001 From: dorian Date: Sun, 17 Feb 2019 13:57:57 +0100 Subject: [PATCH] - added example delegate in shop - added animated darkness when the popup is open --- QcookieClicker.pro.user | 15 ++- qml/ShopPopup.qml | 201 +++++++++++++++++++++++++++++++++- qml/components/GameButton.qml | 1 + qml/main.qml | 15 +++ 4 files changed, 225 insertions(+), 7 deletions(-) diff --git a/QcookieClicker.pro.user b/QcookieClicker.pro.user index 4238654..3dab907 100644 --- a/QcookieClicker.pro.user +++ b/QcookieClicker.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -8,7 +8,7 @@ ProjectExplorer.Project.ActiveTarget - 0 + 1 ProjectExplorer.Project.EditorSettings @@ -557,7 +557,10 @@ Qt4ProjectManager.AndroidDeployConfiguration2 1 - + + MWS0216A15001488 + 24 + false false @@ -603,9 +606,9 @@ 0 - - - Qt4ProjectManager.AndroidRunConfiguration:/home/dorian/QcookieClicker/QcookieClicker.pro + QcookieClicker + QcookieClicker + Qt4ProjectManager.AndroidRunConfiguration:/home/dorian/Documents/git/qcookieclicker/QcookieClicker.pro 3768 false diff --git a/qml/ShopPopup.qml b/qml/ShopPopup.qml index 9fde9f1..c3669b7 100644 --- a/qml/ShopPopup.qml +++ b/qml/ShopPopup.qml @@ -1,10 +1,14 @@ import QtQuick 2.9 import QtQuick.Controls 2.4 +import QtGraphicalEffects 1.0 Popup { id: control modal: true + dim: false + + scale: 0 height: 300 @@ -18,7 +22,194 @@ Popup { color: "white" + Item { + id: contentItm + anchors { + fill: parent + topMargin: -topImg.anchors.bottomMargin + } + + Column { + anchors.fill: parent + + ItemDelegate { + id: itemDelegate + width: parent.width + height: 40 + + Item { + id: leftSectionItm + + anchors { + top: parent.top + bottom: parent.bottom + left: parent.left + right: parent.right + rightMargin: parent.width * 0.8 + margins: 5 + } + + Rectangle { + id: iconRect + + anchors { + fill: parent + } + + width: height + + color: "red" + } + + } + + Item { + id: middleSectionItm + + anchors { + top: parent.top + bottom: parent.bottom + left: parent.left + leftMargin: parent.width * 0.2 + right: parent.right + rightMargin: parent.width * 0.3 + margins: 5 + } + + Label { + id: titleLab + + anchors { + top: parent.top + left: iconRect.right + } + + font.bold: true + + text: "title" + + } + + Item { + id: costItm + + anchors { + top: titleLab.bottom + bottom: parent.bottom + left: iconRect.right + } + + Image { + id: costCookieImg + source: "qrc:/icons/cookie.png" + mipmap: true + height: parent.height + width: height + } + + Label { + id: costLa + + anchors { + left: costCookieImg.right + verticalCenter: costCookieImg.verticalCenter + } + + text: "10" + } + + } + + } + + Item { + id: rightsectionItm + + anchors { + top: parent.top + bottom: parent.bottom + left: parent.left + leftMargin: parent.width * 0.75 + right: parent.right + margins: 5 + } + + Label { + id: levelLableLa + + anchors { + top: parent.top + left: parent.left + } + + font.pixelSize: parent.height * 0.45 + + text: "Level:" + } + + Label { + id: levelTextLa + + anchors { + verticalCenter: parent.verticalCenter + verticalCenterOffset: -parent.height * 0.24 + left: levelLableLa.right + right: parent.right + } + + font.pixelSize: parent.height * 0.45 * 1/text.length * 5 > parent.height * 0.45 ? parent.height * 0.45:parent.height * 0.45 * 1/text.length * 5 + + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + + text: "10" + + } + + Label { + id: useLableLa + + anchors { + bottom: parent.bottom + left: parent.left + } + + font.pixelSize: parent.height * 0.45 + + text: "Click:" + } + + Label { + id: useTextLa + + anchors { + verticalCenter: parent.verticalCenter + verticalCenterOffset: parent.height * 0.24 + left: useLableLa.right + right: parent.right + } + + font.pixelSize: parent.height * 0.45 * 1/text.length * 5 > parent.height * 0.45 ? parent.height * 0.45:parent.height * 0.45 * 1/text.length * 5 + + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + + text: "10" + + } + + } + + background: Rectangle { + color: parent.pressed ? "lightgrey":"white" + border.color: "grey" + border.width: 2 + } + + } + } + } } Image { @@ -28,8 +219,10 @@ Popup { bottom: contentRect.top bottomMargin: -height * 0.22 } + source: "qrc:/graphics/shopTop.png" fillMode: Image.PreserveAspectFit + mipmap: true width: parent.width } @@ -43,13 +236,19 @@ Popup { source: "qrc:/graphics/shopBottom.png" fillMode: Image.PreserveAspectFit + mipmap: true width: parent.width } - background: Rectangle { color: "transparent" } + enter: Transition { + NumberAnimation { properties: "scale"; to: 1; duration: 300; easing.type: Easing.Linear } + } + exit: Transition { + NumberAnimation { properties: "scale"; to: 0; duration: 300; easing.type: Easing.Linear } + } } diff --git a/qml/components/GameButton.qml b/qml/components/GameButton.qml index 4817fd7..9b189b5 100644 --- a/qml/components/GameButton.qml +++ b/qml/components/GameButton.qml @@ -12,6 +12,7 @@ Button { background: Image { source: control.imageSrc + mipmap: true } Behavior on scale { diff --git a/qml/main.qml b/qml/main.qml index 050a91c..1341edb 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -1,6 +1,7 @@ import QtQuick 2.9 import QtQuick.Window 2.2 import QtQuick.Controls 2.4 +import QtGraphicalEffects 1.0 import com.itsblue.qcookieclicker 1.0 @@ -76,6 +77,20 @@ Window { } } + Rectangle + { + id: popupModal + anchors.fill: parent + opacity: shopPu.opened ? 0.5:0 + color: "black" + + Behavior on opacity { + NumberAnimation { + duration: 200 + } + } + } + ShopPopup { id: shopPu