qmlFrontend/qml/qmlFrontend/GameConfig.qml
author unc0rr
Mon, 20 Oct 2014 22:55:12 +0400
branchqmlfrontend
changeset 10442 c58db813240b
parent 10436 084e046f6bd5
child 10444 47a6231f1fc1
permissions -rw-r--r--
Load and show local teams list

import QtQuick 2.0
import Hedgewars.Engine 1.0


Rectangle {
    HWButton {
        id: btnPreview
        x: 50
        y: 16
        width: 256
        height: 128

        onClicked: HWEngine.getPreview()

        Connections {
            target: HWEngine
            onPreviewImageChanged: previewImage.source = "image://preview/" + HWEngine.currentSeed()
        }

        Image {
            id: previewImage
            x: 0
            y: 0
            width: 256
            height: 128
            cache: false
        }
    }

    Rectangle {
        x: 320
        y: 16
        width: 100
        height: 256
        color: "#15193a"
        radius: 8
        border.width: 4
        border.color: "#eaea00"
        Image {
            id: themeImage
            x: 0
            y: 0
            width: 64
            height: 64
            fillMode: Image.Pad
        }

        ListView {
            id: themesList
            x: 0
            y: 64
            width: 100
            height: 192
            highlight: Rectangle { color: "#eaea00"; radius: 4 }
            focus: true

            model: themesModel
            delegate: Rectangle {
                height: 25
                width: 100
                color: "transparent"
                Text {id: themeName; text: modelData }
                MouseArea {
                     z: 1
                     anchors.fill: parent
                     onClicked: {
                         themeImage.source = "image://theme/" + themeName.text
                         themesList.currentIndex = index
                     }
                }
            }
        }
    }

    ListView {
        id: playingTeamsList
        x: 440
        y: 16
        width: 100
        height: 192
        highlight: Rectangle { color: "#eaea00"; radius: 4 }
        focus: true
        clip: true

        model: ListModel {
            id: localTeamsModel
        }

        delegate: Rectangle {
            id: teamDelegate
            height: 24
            width: parent.width
            radius: 8
            border.width: 2
            border.color: "#eaea00"

            Row {
                Text { text: name }
            }
        }

        Connections {
            target: HWEngine
            onLocalTeamAdded: localTeamsModel.append({"aiLevel": aiLevel, "name": teamName})
        }
    }

    Component.onCompleted: {
        HWEngine.getTeamsList()
        HWEngine.getPreview()
    }
}