qmlFrontend/qml/qmlFrontend/GameConfig.qml
author unc0rr
Wed, 03 Dec 2014 00:20:21 +0300
branchqmlfrontend
changeset 10608 b85759f2ba18
parent 10519 af019fa70080
child 10610 eadf2cea55e0
permissions -rw-r--r--
Some more progress at custom combobox
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10422
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
     1
import QtQuick 2.0
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
     2
import Hedgewars.Engine 1.0
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
     3
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
     4
10422
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
     5
Rectangle {
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
     6
    HWButton {
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
     7
        id: btnPreview
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
     8
        x: 50
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
     9
        y: 16
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    10
        width: 256
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    11
        height: 128
10422
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
    12
10432
b0abef0ee78c Quick Game PoC
unc0rr
parents: 10428
diff changeset
    13
        onClicked: HWEngine.getPreview()
10422
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
    14
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
    15
        Connections {
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
    16
            target: HWEngine
10424
4be6cd55f1cf - Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents: 10422
diff changeset
    17
            onPreviewImageChanged: previewImage.source = "image://preview/" + HWEngine.currentSeed()
10422
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
    18
        }
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    19
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    20
        Image {
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    21
            id: previewImage
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    22
            x: 0
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    23
            y: 0
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    24
            width: 256
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    25
            height: 128
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    26
            cache: false
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    27
        }
10422
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
    28
    }
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
    29
10448
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    30
    HWButton {
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    31
        id: btnRunGame
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    32
        x: 600
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    33
        y: 440
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    34
        width: 32
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    35
        height: 32
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    36
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    37
        onClicked: HWEngine.runLocalGame()
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    38
    }
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    39
10519
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    40
    HWComboBox {
10608
b85759f2ba18 Some more progress at custom combobox
unc0rr
parents: 10519
diff changeset
    41
        id: cbTheme
10519
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    42
        x: 320
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    43
        y: 16
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    44
        width: 100
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    45
        height: 256
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    46
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    47
        model: themesModel
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    48
        delegate: Rectangle {
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    49
            height: 25
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    50
            width: 100
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    51
            color: "transparent"
10608
b85759f2ba18 Some more progress at custom combobox
unc0rr
parents: 10519
diff changeset
    52
            Row {
b85759f2ba18 Some more progress at custom combobox
unc0rr
parents: 10519
diff changeset
    53
                Image {width: height; height: parent.height; source: "image://theme/" + modelData}
b85759f2ba18 Some more progress at custom combobox
unc0rr
parents: 10519
diff changeset
    54
                Text {id: themeName; text: modelData }
b85759f2ba18 Some more progress at custom combobox
unc0rr
parents: 10519
diff changeset
    55
            }
10519
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    56
            MouseArea {
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    57
                 z: 1
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    58
                 anchors.fill: parent
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    59
                 onClicked: {
10608
b85759f2ba18 Some more progress at custom combobox
unc0rr
parents: 10519
diff changeset
    60
                     cbTheme.currentIndex = index
10519
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    61
                     HWEngine.setTheme(themeName.text)
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    62
                 }
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    63
            }
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    64
        }
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    65
    }
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    66
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    67
/*    Rectangle {
10436
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    68
        x: 320
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    69
        y: 16
10436
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    70
        width: 100
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    71
        height: 256
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    72
        color: "#15193a"
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    73
        radius: 8
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    74
        border.width: 4
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    75
        border.color: "#eaea00"
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    76
        Image {
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    77
            id: themeImage
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    78
            x: 0
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    79
            y: 0
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    80
            width: 64
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    81
            height: 64
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    82
            fillMode: Image.Pad
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    83
        }
10519
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    84
*/
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    85
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    86
    ListView {
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    87
        id: playingTeamsList
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    88
        x: 440
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    89
        y: 16
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    90
        width: 100
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    91
        height: 192
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    92
        highlight: Rectangle { color: "#eaea00"; radius: 4 }
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    93
        focus: true
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    94
        clip: true
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    95
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    96
        model: ListModel {
10444
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
    97
            id: playingTeamsModel
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    98
        }
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    99
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   100
        delegate: Rectangle {
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   101
            id: teamDelegate
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   102
            height: 24
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   103
            width: parent.width
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   104
            radius: 8
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   105
            border.width: 2
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   106
            border.color: "#eaea00"
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   107
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   108
            Row {
10452
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   109
                Rectangle {
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   110
                    height: 20
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   111
                    width: height
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   112
                    color: teamColor
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   113
                    border.width: 2
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   114
                    border.color: "#eaea00"                    
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   115
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   116
                    MouseArea {
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   117
                        z: 1
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   118
                        anchors.fill: parent
10454
2b590e7972b1 Allow using right button or wheel to change team color
unc0rr
parents: 10452
diff changeset
   119
                        acceptedButtons: Qt.LeftButton | Qt.RightButton
2b590e7972b1 Allow using right button or wheel to change team color
unc0rr
parents: 10452
diff changeset
   120
                        onClicked: {
2b590e7972b1 Allow using right button or wheel to change team color
unc0rr
parents: 10452
diff changeset
   121
                            if (mouse.button === Qt.LeftButton)
2b590e7972b1 Allow using right button or wheel to change team color
unc0rr
parents: 10452
diff changeset
   122
                                HWEngine.changeTeamColor(name, 1)
2b590e7972b1 Allow using right button or wheel to change team color
unc0rr
parents: 10452
diff changeset
   123
                            else if (mouse.button === Qt.RightButton)
2b590e7972b1 Allow using right button or wheel to change team color
unc0rr
parents: 10452
diff changeset
   124
                                HWEngine.changeTeamColor(name, -1)
2b590e7972b1 Allow using right button or wheel to change team color
unc0rr
parents: 10452
diff changeset
   125
                        }
2b590e7972b1 Allow using right button or wheel to change team color
unc0rr
parents: 10452
diff changeset
   126
                        onWheel: HWEngine.changeTeamColor(name, -wheel.angleDelta.y)
10452
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   127
                   }
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   128
                }
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   129
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   130
                Text { text: name
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   131
                    MouseArea {
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   132
                        z: 1
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   133
                        anchors.fill: parent
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   134
                        onClicked: HWEngine.tryRemoveTeam(name)
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   135
                   }
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   136
                }
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   137
            }
10444
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   138
10452
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   139
10444
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   140
        }
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   141
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   142
        Connections {
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   143
            target: HWEngine
10452
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   144
            onPlayingTeamAdded: playingTeamsModel.append({
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   145
                                                             "aiLevel": aiLevel
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   146
                                                             , "name": teamName
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   147
                                                             , "local": isLocal
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   148
                                                             , "teamColor": "#000000"
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   149
                                                         })
10444
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   150
            onPlayingTeamRemoved: {
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   151
                var i = playingTeamsModel.count - 1;
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   152
                while ((i >= 0) && (playingTeamsModel.get(i).name !== teamName)) --i
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   153
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   154
                if(i >= 0) playingTeamsModel.remove(i, 1)
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   155
            }
10452
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   156
            onTeamColorChanged: {
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   157
                var i = playingTeamsModel.count - 1;
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   158
                while ((i >= 0) && (playingTeamsModel.get(i).name !== teamName)) --i
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   159
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   160
                if(i >= 0) playingTeamsModel.setProperty(i, "teamColor", colorValue)
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   161
            }
10444
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   162
        }
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   163
    }
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   164
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   165
    ListView {
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   166
        id: localTeamsList
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   167
        x: 440
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   168
        y: 224
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   169
        width: 100
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   170
        height: 192
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   171
        highlight: Rectangle { color: "#eaea00"; radius: 4 }
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   172
        focus: true
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   173
        clip: true
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   174
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   175
        model: ListModel {
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   176
            id: localTeamsModel
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   177
        }
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   178
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   179
        delegate: Rectangle {
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   180
            id: localTeamDelegate
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   181
            height: 24
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   182
            width: parent.width
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   183
            radius: 8
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   184
            border.width: 2
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   185
            border.color: "#eaea00"
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   186
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   187
            Row {
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   188
                Text { text: name }
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   189
            }
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   190
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   191
            MouseArea {
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   192
                 z: 1
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   193
                 anchors.fill: parent
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   194
                 onClicked: HWEngine.tryAddTeam(name)
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   195
            }
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   196
        }
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   197
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   198
        Connections {
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   199
            target: HWEngine
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   200
            onLocalTeamAdded: localTeamsModel.append({"aiLevel": aiLevel, "name": teamName})
10444
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   201
            onLocalTeamRemoved: {
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   202
                var i = localTeamsModel.count - 1;
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   203
                while ((i >= 0) && (localTeamsModel.get(i).name !== teamName)) --i
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   204
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   205
                if(i >= 0) localTeamsModel.remove(i, 1)
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   206
            }
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   207
        }
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   208
    }
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   209
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   210
    Component.onCompleted: {
10450
bf9e30b4ef9b - Store index of color instead of its value
unc0rr
parents: 10448
diff changeset
   211
        HWEngine.resetGameConfig()
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   212
        HWEngine.getTeamsList()
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   213
        HWEngine.getPreview()
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   214
    }
10422
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
   215
}