Squaby Demo
import QtQuick 2.0
import Felgo 4.0
Item {
id: hud
property variant selectedEntity
property string selectedTowerId: ""
property alias levelEditingHud: levelEditingHUD
signal menuButtonClicked
state: "buildTowers"
TowerRangeCircle {
id: selectedTowerRange
visible: false
onVisibleChanged: {
if(visible)
tutorials.nextAction("towerRange", "visible")
else
tutorials.nextAction("towerRange", "invisible")
}
transform: [
Translate { x: -selectedTowerRange.width/2; y: -selectedTowerRange.height/2 - hud.y}
]
}
SingleSquabySprite {
id: menuBackground
source: Qt.resolvedUrl("../../../assets/img/menu_labels/menuBackground.png")
visible: opacity > 0
}
LevelEditingHUD {
id: levelEditingHUD
anchors.left: parent.left
anchors.right: parent.right
height: hud.height
visible: false
}
function changeToBuildMenu() {
menuBackground.opacity = 1
if(itemEditor.visible) {
itemEditor.slideOut()
}
}
function changeFromBuildMenu() {
menuBackground.opacity = 0
if(!itemEditor.visible) {
itemEditor.slideIn()
}
}
Item {
id: menuButtonItem
width: menuButton.width
height: menuButton.height
SingleSquabySprite {
id: menuButton
source: Qt.resolvedUrl("../../../assets/img/menu_labels/menuIconMenuButton.png")
}
MouseArea {
anchors.fill: menuButton
onClicked: {
menuButtonClicked();
}
}
}
SquabyPerformanceTestOptions {
id: perfmenuButtonItem
anchors.right: hud.right
visible: developerBuild && scene.state !== "levelEditing"
}
Item {
id: anchorItem
anchors.right: developerBuild ? perfmenuButtonItem.left : hud.right
}
MenuGoldWaveItems {
id: menuGoldWaveItems
anchors.left: menuButtonItem.right
}
BuyTowersHUD {
id: buyTowersHUD
height: parent.height
anchors.right: anchorItem.left
visible: false
}
UpgradeTowerHUD {
id: upgradeTowerHUD
anchors.right: anchorItem.left
visible: false
}
Loader {
id: modifyEntityHUD
source: Qt.resolvedUrl("ModifyEntityHUD.qml")
anchors.right: anchorItem.left
visible: false
}
function entitySelected(entity) {
if(selectedEntity) {
selectedEntity.entityState = "";
}
selectedEntity = entity;
hud.state = "modifyEntity";
}
function towerSelected(message) {
tutorials.nextAction(message.entityType,"clicked",message.towerPosition)
upgradeTowerHUD.towerSelected(message);
}
states: [
State {
name: "buildTowers"
PropertyChanges { target: buyTowersHUD; visible: true}
PropertyChanges { target: hud; selectedTowerId: ""}
StateChangeScript {
script: {
levelEditingHUD.state = ""
changeToBuildMenu()
}
}
},
State {
name: "upgrading"
PropertyChanges { target: selectedTowerRange; visible: true }
PropertyChanges { target: upgradeTowerHUD; visible: true }
},
State {
name: "levelEditing"
PropertyChanges { target: levelEditingHUD; visible: true}
PropertyChanges { target: menuButtonItem; visible: false}
StateChangeScript {
script: {
if(selectedEntity)
selectedEntity.entityState = "";
}
}
PropertyChanges { target: hud; selectedEntity: null; restoreEntryValues: false}
PropertyChanges { target: menuGoldWaveItems; visible: false}
},
State {
name: "modifyEntity"
PropertyChanges { target: modifyEntityHUD; visible: true}
PropertyChanges { target: menuGoldWaveItems; visible: false}
PropertyChanges { target: menuButtonItem; visible: false}
}
]