Advertisement
Guest User

levelEditorScene

a guest
Jan 20th, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
q/kdb+ 4.74 KB | None | 0 0
  1. import VPlay 1.0
  2. import QtQuick 1.1
  3. import "entities"
  4.  
  5. SceneBase{
  6.     id: levelEditorScene
  7.  
  8.     property bool playerOnScreen: false
  9.  
  10.     EntityManager{
  11.         id: entityManager
  12.         entityContainer: levelEditorScene
  13.        //dynamicCreationEntityList: [Qt.resolvedUrl("entities/Star.qml"), Qt.resolvedUrl("entities/Planet.qml"),Qt.resolvedUrl("entities/Obstacle.qml") ]
  14.     }
  15.  
  16.     BackButton{
  17.         width: levelEditorScene.width / 20
  18.         height: levelEditorScene.width / 20
  19.         anchors.right: parent.right
  20.         onClicked: backPressed()
  21.     }
  22.  
  23.     LevelEditor{
  24.         id: levelEditor
  25.         toRemoveEntityTypes: ["star", "planet", "planet2", "obstacle", "object", "blackHole"]
  26.         toStoreEntityTypes: ["star", "planet","planet2", "obstacle", "object", "blackHole"]
  27.     }
  28.  
  29.     Rectangle{
  30.         id: rectangle
  31.  
  32.         color: "grey"
  33.         opacity: 0.8
  34.         width: levelEditorScene.width
  35.         height: 35
  36.         anchors.bottom: parent.bottom
  37.     }
  38.  
  39.  
  40.     Row{
  41.         anchors.centerIn: rectangle
  42.         spacing: 20
  43.  
  44.         BuildEntityButton{
  45.             toCreateEntityType: "entities/Planet.qml"
  46.  
  47.  
  48.             width: levelEditorScene.width / 20
  49.             height: levelEditorScene.width / 20
  50.             anchors.bottom: parent.left
  51.  
  52.  
  53.            //costumize button
  54.             Image {
  55.                 source: "img/planet1.png"
  56.                 anchors.fill: parent
  57.             }
  58.  
  59.         }
  60.  
  61.         BuildEntityButton{
  62.             toCreateEntityType: "entities/UndestroyablePlanet.qml"
  63.  
  64.             width: levelEditorScene.width / 20
  65.             height: levelEditorScene.width / 20
  66.             anchors.bottom: parent.left
  67.  
  68.            //costumize button
  69.             Image {
  70.                 source: "img/planet2.png"
  71.                 anchors.fill: parent
  72.             }
  73.  
  74.         }
  75.  
  76.         BuildEntityButton{
  77.             toCreateEntityType: "entities/BlackHole.qml"
  78.  
  79.             width: levelEditorScene.width / 20
  80.             height: levelEditorScene.width / 20
  81.             anchors.bottom: parent.left
  82.  
  83.            //costumize button
  84.             Image {
  85.                 source: "img/_planet2.png"
  86.                 anchors.fill: parent
  87.             }
  88.  
  89.         }
  90.  
  91.         BuildEntityButton{
  92.             toCreateEntityType: "entities/Star.qml"
  93.  
  94.             width: levelEditorScene.width / 20
  95.             height: levelEditorScene.width / 20
  96.             anchors.bottom: parent.left
  97.  
  98.            //costumize button
  99.             Image {
  100.                 source: "img/star.png"
  101.                 anchors.fill: parent
  102.             }
  103.  
  104.         }
  105.         BuildEntityButton{
  106.             toCreateEntityType: "entities/Obstacle.qml"
  107.  
  108.             width: levelEditorScene.width / 20
  109.             height: levelEditorScene.width / 20
  110.             anchors.bottom: parent.left
  111.  
  112.            //costumize button
  113.             Image{
  114.                 source: "img/obstacle.png"
  115.                 anchors.fill: parent
  116.             }
  117.  
  118.         }
  119.  
  120.         BuildEntityButton{
  121.             id: createPlayer
  122.             toCreateEntityType: "entities/Object.qml"
  123.  
  124.             width: levelEditorScene.width / 20
  125.             height: levelEditorScene.width / 20
  126.             anchors.bottom: parent.left
  127.  
  128.             onEntityWasBuilt: {
  129.                 playerOnScreen = true
  130.                 opacity = 0.5
  131.                 enabled = false
  132.             }
  133.  
  134.            //costumize button
  135.             Image{
  136.                 source: "img/raumschiff.png"
  137.                 anchors.fill: parent
  138.             }
  139.  
  140.         }
  141.  
  142.         MenuButton{
  143.             text: "New Level"
  144.             onClicked: {
  145.                 playerOnScreen = false
  146.                 createPlayer.opacity = 1
  147.                 createPlayer.enabled = true
  148.                 levelEditor.createNewLevel()
  149.             }
  150.             visible: scene.state === "levelEditing"
  151.  
  152.             width: levelEditorScene.width / 10
  153.             height: width / 3
  154.  
  155.             anchors.bottom: parent.left
  156.  
  157.             textSize: 10
  158.         }
  159.  
  160.         MenuButton{
  161.             text: "Save Level"
  162.             width: levelEditorScene.width / 10
  163.             height: width / 3
  164.             textSize: 10
  165.  
  166.             onClicked: nativeUtils.displayTextInput("Enter level name", "", levelEditor.currentLevelName)
  167.             visible: scene.state === "levelEditing"
  168.  
  169.             anchors.bottom: parent.left
  170.  
  171.             Connections{
  172.                 target: nativeUtils
  173.                 onTextInputFinished:{
  174.                     if(accepted){
  175.                         levelEditor.saveCurrentLevel({levelMetaData: {levelName: enteredText}})
  176.                         levelEditor.exportLevelAsFile(enteredText)
  177.                     }
  178.                 }
  179.             }
  180.         }
  181.  
  182.     }
  183. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement