Skip to content
This repository has been archived by the owner on Sep 13, 2018. It is now read-only.

Commit

Permalink
Added button for buying items
Browse files Browse the repository at this point in the history
Tabbing an item once reveals a button. Tabbing that one will buy one
unit of that item.
  • Loading branch information
Erik Schilling committed Mar 16, 2015
1 parent 039ef49 commit 12b1a42
Showing 1 changed file with 50 additions and 23 deletions.
73 changes: 50 additions & 23 deletions example/qml/main/ShopPage.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import QtQuick 2.0
import QtQuick.Layouts 1.1

import Mana 1.0

Item {
Expand All @@ -9,39 +11,64 @@ Item {

model: itemDB.isLoaded ? gameClient.shopListModel : null
delegate: MouseArea {
id: item
property variant info: itemDB.getInfo(model.itemId)
property bool extended: false

anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 10

height: 36
//height: extended ? 100 : 36
height: layout.height

Image {
id: itemGraphic
x: 2; y: 2
// TODO: use imageprovider for this + handling dye
source: resourceManager.dataUrl + resourceManager.itemIconsPrefix + info.image
smooth: false
}
ColumnLayout {
id: layout
anchors.left: parent.left
anchors.right: parent.right

Text {
text: info.name
RowLayout {
anchors.left: parent.left
anchors.right: parent.right
Image {
id: itemGraphic
x: 2; y: 2
// TODO: use imageprovider for this + handling dye
source: resourceManager.dataUrl + resourceManager.itemIconsPrefix + info.image
smooth: false
}

anchors.left: parent.left
anchors.leftMargin: 2 + 32 + 5
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 12
}
Text {
text: info.name

Text {
text: amount
visible: amount > 0
Layout.fillWidth: true
font.pixelSize: 12
}

anchors.right: parent.right
anchors.rightMargin: 4
anchors.verticalCenter: parent.verticalCenter
font.bold: true
font.pixelSize: 12
Text {
text: amount
visible: amount > 0

font.bold: true
font.pixelSize: 12
}
}

BrownButton {
text: "Buy"
visible: item.extended

Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: 100

onClicked: {
onClicked: gameClient.buySell(model.itemId, 1);
}
}
}

onClicked: {
extended = !extended;
}
}
}
Expand Down

0 comments on commit 12b1a42

Please sign in to comment.