qml.qml 4.19 KB
Newer Older
1 2 3
import QtQuick
// import QtQuick.VirtualKeyboard

4 5
// Import all components from folder
import "scenes"
6
import "constants/scene.js" as SceneConstants
7

8
Window {
9 10
    property string scene: SceneConstants.homeScene

11 12 13 14 15 16 17
    Loader {
        id: ld
        anchors.fill: parent;
    }
    FontLoader {
        id: globalFont;
        source: "./fonts/OpenSans-VariableFont_wdth.ttf"
18
    }
Exc404's avatar
Exc404 committed
19

20

21 22 23
    Connections {
        target: core_app
        function onGameStarted(done) {
24
            // console.log("core_app: gameStarted");
25 26 27
            window.scene = SceneConstants.runningScene;
        }
        function onGameEnded(done) {
28
            // console.log("core_app: gameEnded");
29 30
            window.scene = SceneConstants.gameInfoScene;
        }
ADav's avatar
ADav committed
31 32 33 34
        function onGotGameData(result) {
            // console.log(JSON.stringify(result))
            gameInfoScene.setGameData(result)
        }
35
        function onGamepadClickedLB(done){
36
            window._trigger("onGamepadClickedLB", done);
37 38
        }
        function onGamepadClickedRB(done){
39
            window._trigger("onGamepadClickedRB", done);
40
        }
41
        function onGamepadAxisLeft(done){
42
            window._trigger("onGamepadAxisLeft", done);
43 44
        }
        function onGamepadAxisRight(done){
45
            window._trigger("onGamepadAxisRight", done);
46 47
        }
        function onGamepadClickedApply(done){
48 49 50 51
            window._trigger("onGamepadClickedApply", done);
        }
        function onGamepadClickedBack(done){
            window._trigger("onGamepadClickedBack", done);
52
        }
53 54
    }

55 56 57 58 59 60 61 62 63 64 65 66
    function _trigger(_method, ...args){
        let scenes = {};
        scenes[SceneConstants.homeScene] = homeScene;
        scenes[SceneConstants.gameInfoScene] = gameInfoScene;
        scenes[SceneConstants.runningScene] = runningScene;

        let d = scenes[scene];

        if(d !== null && d[_method] !== undefined && d[_method] !== null)
            d[_method](args);
    }

67
    Component.onDestruction: {
68
        // console.log("Desctructing window");
69 70
    }

71 72 73 74
    id: window
    width: 640
    height: 480
    visible: true
75 76
    title: qsTr("Launcher")

Exc404's avatar
Exc404 committed
77 78 79 80 81 82
    Image {
        id: bg
        anchors.fill: parent
        fillMode: Image.PreserveAspectCrop
        source: './images/bg3.svg'
    }
83 84

    // Решение бага с изменением положений кнопок вкладок через opacity и enabled - ЭТО КОСТЫЛЬ!!!
85
    HomeScene {
86
        // visible: scene == SceneConstants.homeScene
87 88 89
        opacity: scene == SceneConstants.homeScene
        enabled: scene == SceneConstants.homeScene

90
        id: homeScene
91
        anchors.fill: parent
Exc404's avatar
Exc404 committed
92 93 94 95 96 97 98 99

        Behavior on opacity {
            NumberAnimation {
                target: homeScene;
                property: "opacity";
                duration: 300;
            }
        }
100
    }
101

102
    GameInfoScene {
103
        // visible: scene == SceneConstants.gameInfoScene
104 105 106
        opacity: scene == SceneConstants.gameInfoScene
        enabled: scene == SceneConstants.gameInfoScene

107 108
        id: gameInfoScene
        anchors.fill: parent
Exc404's avatar
Exc404 committed
109 110 111 112 113 114 115 116

        Behavior on opacity {
            NumberAnimation {
                target: gameInfoScene;
                property: "opacity";
                duration: 300;
            }
        }
117 118 119
    }

    RunningScene {
120
        // visible: scene == SceneConstants.runningScene
121 122 123
        opacity: scene == SceneConstants.runningScene
        enabled: scene == SceneConstants.runningScene

124 125 126 127 128 129
        id: runningScene
        anchors.fill: parent
    }



130
    /* InputPanelHomeScene {
131 132 133 134 135 136
        id: inputPanel
        z: 99
        x: 0
        y: window.height
        width: window.width

137
        states: StateHomeScene {
138 139
            name: "visible"
            when: inputPanel.active
140
            PropertyChangesHomeScene {
141 142 143 144
                target: inputPanel
                y: window.height - inputPanel.height
            }
        }
145
        transitions: TransitionHomeScene {
146 147 148
            from: ""
            to: "visible"
            reversible: true
149 150
            ParallelAnimationHomeScene {
                NumberAnimationHomeScene {
151 152 153 154 155 156 157 158
                    properties: "y"
                    duration: 250
                    easing.type: Easing.InOutQuad
                }
            }
        }
    } */
}