Particle Editor Demo
import Felgo 3.0
import QtQuick 2.2
Scene {
id: scene
width: 480
height: 320
focus: true
property alias mainMenu: mainMenu.menuEditor
property alias entityMenu: itemEditor
property alias itemEditor: itemEditor.itemEditor
property alias loadMessage: loadMessage
property alias innerSpace: scene.innerSpaceWidth
property alias aboutPanel: aboutPanel
property int innerSpaceWidth: mainMenu.menuEditor.width-4*5
property color backgroundColor: Qt.rgba(0,0,0,1.0)
property bool entityBaseVisible: false
onEntityBaseVisibleChanged: {
var entities = entityManager.getEntityArrayByType("particleEntity")
for(var i=0; i<entities.length; ++i) {
entities[i].entityBaseVisible = scene.entityBaseVisible
}
}
property variant selectedEntity: null
property int usageAreaWidth: scene.gameWindowAnchorItem.x+scene.gameWindowAnchorItem.width
property int usageAreaHeight: scene.gameWindowAnchorItem.y+scene.gameWindowAnchorItem.height
property int pickableAreaSize: 50
Rectangle {
id: background
x: scene.gameWindowAnchorItem.x
y: scene.gameWindowAnchorItem.y
width: scene.gameWindowAnchorItem.width
height: scene.gameWindowAnchorItem.height
color: scene.backgroundColor
}
EditableComponent {
id: mainMenuComponent
targetEditor: mainMenu.menuEditor
editableType: "Menu"
defaultGroup: editableType
properties: {
"Background": {
"entityBaseVisible": {"label": "Entity Base Visible"},
"backgroundColor": {"min": 0, "max": 255,"stepsize": 1, "label": "Background Color"}
}
}
}
MouseArea {
id: mouseArea
objectName: "MouseArea"
width: usageAreaWidth
height: usageAreaHeight
onPressed: {
var entities = entityManager.getEntityArrayByType("particleEntity")
for(var i=0; i<entities.length; ++i) {
if(entities[i].x > mouse.x-pickableAreaSize && entities[i].x < mouse.x+pickableAreaSize && entities[i].y > mouse.y-pickableAreaSize && entities[i].y < mouse.y+pickableAreaSize) {
selectedEntity = entities[i]
scene.itemEditor.currentEditableType = utils.cropPath(entities[i].particleType, true)
break
}
}
}
onPositionChanged: {
if(selectedEntity && mouse.x < usageAreaWidth && mouse.x > 0) {
selectedEntity.x = mouse.x
}
if(selectedEntity && mouse.y < usageAreaHeight && mouse.y > 0) {
selectedEntity.y = mouse.y
}
}
onReleased: {
selectedEntity = 0
}
onClicked: {
var entities = entityManager.getEntityArrayByType("particleEntity")
for(var i=0; i<entities.length; ++i) {
if(entities[i].x > mouse.x-pickableAreaSize && entities[i].x < mouse.x+pickableAreaSize && entities[i].y > mouse.y-pickableAreaSize && entities[i].y < mouse.y+pickableAreaSize) {
entities[i].printParticle()
break
}
}
}
}
AboutPanel {
id: aboutPanel
x: gameWindowAnchorItem.x
y: gameWindowAnchorItem.y
}
onWidthChanged: {
mainMenu.slide()
itemEditor.slide()
}
onHeightChanged: {
mainMenu.slide()
itemEditor.slide()
}
MainMenu {
id: mainMenu
z:10
}
EntityPropertiesMenu {
id: itemEditor
z:10
}
Connections {
target: nativeUtils
onMessageBoxFinished: {
console.debug("the user confirmed the Ok/Cancel dialog with:", accepted)
if(accepted)
Qt.quit()
}
}
onBackButtonPressed: {
nativeUtils.displayMessageBox(qsTr("Really quit the application?"), "", 2);
}
Keys.onPressed: {
if(event.key === Qt.Key_D && system.desktopPlatform) {
mainMenu.menuEditor.contentDelegateObj.headerNext()
} else if(event.key === Qt.Key_A && system.desktopPlatform) {
mainMenu.menuEditor.contentDelegateObj.headerPrev()
}
if(event.key === Qt.Key_Right && system.desktopPlatform) {
itemEditor.itemEditor.contentDelegateObj.headerNext()
} else if(event.key === Qt.Key_Left && system.desktopPlatform) {
itemEditor.itemEditor.contentDelegateObj.headerPrev()
}
}
Rectangle {
id: loadMessage
z:1001
x: scene.gameWindowAnchorItem.x
y: scene.gameWindowAnchorItem.y
width: scene.gameWindowAnchorItem.width
height: scene.gameWindowAnchorItem.height
color: "black"
opacity: 0.5
visible: itemEditor.state === "loading" || mainMenu.state === "loading"
Text {
anchors.centerIn: parent
text: "loading..."
color: "white"
}
}
Text {
color: "white"
anchors.left: scene.gameWindowAnchorItem.left
anchors.margins: 5
anchors.bottom: scene.gameWindowAnchorItem.bottom
z: 11