2022-06-03 11:26:02 +00:00
|
|
|
// Copyright (C) 2017 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2018-06-26 13:53:07 +00:00
|
|
|
|
2020-12-01 12:57:32 +00:00
|
|
|
import QtQuick
|
2018-06-26 13:53:07 +00:00
|
|
|
import "logic.js" as Logic
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: container
|
|
|
|
width: 64
|
|
|
|
height: 64
|
|
|
|
property alias source: img.source
|
|
|
|
property int index
|
|
|
|
property int row: 0
|
|
|
|
property int col: 0
|
|
|
|
property int towerType
|
|
|
|
property bool canBuild: true
|
|
|
|
property Item gameCanvas: parent.parent.parent
|
|
|
|
signal clicked()
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: img
|
2024-07-05 17:41:58 +00:00
|
|
|
opacity: (container.canBuild && (container.gameCanvas as GameCanvas).coins >= Logic.towerData[container.towerType-1].cost) ? 1.0 : 0.4
|
2018-06-26 13:53:07 +00:00
|
|
|
}
|
|
|
|
Text {
|
|
|
|
anchors.right: parent.right
|
|
|
|
font.pointSize: 14
|
|
|
|
font.bold: true
|
|
|
|
color: "#ffffff"
|
2024-07-05 17:41:58 +00:00
|
|
|
text: Logic.towerData[container.towerType - 1].cost
|
2018-06-26 13:53:07 +00:00
|
|
|
}
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
2024-07-05 17:41:58 +00:00
|
|
|
Logic.buildTower(container.towerType, container.col, container.row)
|
2018-06-26 13:53:07 +00:00
|
|
|
container.clicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Image {
|
2024-07-05 17:41:58 +00:00
|
|
|
visible: container.col == container.index && container.row != 0
|
2018-06-26 13:53:07 +00:00
|
|
|
source: "gfx/dialog-pointer.png"
|
|
|
|
anchors.top: parent.bottom
|
|
|
|
anchors.topMargin: 4
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
Image {
|
2024-07-05 17:41:58 +00:00
|
|
|
visible: container.col == container.index && container.row == 0
|
2018-06-26 13:53:07 +00:00
|
|
|
source: "gfx/dialog-pointer.png"
|
|
|
|
rotation: 180
|
|
|
|
anchors.bottom: parent.top
|
|
|
|
anchors.bottomMargin: 6
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
}
|