qmlFrontend/qml/qmlFrontend/GameConfig.qml
author unc0rr
Sat, 28 Nov 2015 00:18:04 +0300
branchqmlfrontend
changeset 11433 bca9afcc3a72
parent 11432 97e3e62ea5f9
child 11434 23912c93935a
permissions -rw-r--r--
Handle some CFG parameters
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 {
11426
ab6a6d9ebfc0 Small ui rework
unc0rr
parents: 10888
diff changeset
     6
    Column {
ab6a6d9ebfc0 Small ui rework
unc0rr
parents: 10888
diff changeset
     7
        spacing: 8
ab6a6d9ebfc0 Small ui rework
unc0rr
parents: 10888
diff changeset
     8
10422
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
     9
    HWButton {
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
    10
        id: btnPreview
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    11
        width: 256
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    12
        height: 128
10422
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
    13
10432
b0abef0ee78c Quick Game PoC
unc0rr
parents: 10428
diff changeset
    14
        onClicked: HWEngine.getPreview()
10422
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
    15
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
    16
        Connections {
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
    17
            target: HWEngine
10424
4be6cd55f1cf - Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents: 10422
diff changeset
    18
            onPreviewImageChanged: previewImage.source = "image://preview/" + HWEngine.currentSeed()
10422
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
    19
        }
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    20
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    21
        Image {
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    22
            id: previewImage
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    23
            x: 0
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    24
            y: 0
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    25
            width: 256
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    26
            height: 128
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    27
            cache: false
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    28
        }
10422
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
    29
    }
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
    30
10519
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    31
    HWComboBox {
10608
b85759f2ba18 Some more progress at custom combobox
unc0rr
parents: 10519
diff changeset
    32
        id: cbTheme
10610
eadf2cea55e0 Finish combobox implementation (except for visual part)
unc0rr
parents: 10608
diff changeset
    33
        width: 256
eadf2cea55e0 Finish combobox implementation (except for visual part)
unc0rr
parents: 10608
diff changeset
    34
        height: 64
10519
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    35
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    36
        model: themesModel
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    37
        delegate: Rectangle {
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    38
            height: 25
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    39
            width: 100
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    40
            color: "transparent"
10610
eadf2cea55e0 Finish combobox implementation (except for visual part)
unc0rr
parents: 10608
diff changeset
    41
eadf2cea55e0 Finish combobox implementation (except for visual part)
unc0rr
parents: 10608
diff changeset
    42
            property alias itemIconSource: themeIcon.source
eadf2cea55e0 Finish combobox implementation (except for visual part)
unc0rr
parents: 10608
diff changeset
    43
            property alias itemText: themeName.text
eadf2cea55e0 Finish combobox implementation (except for visual part)
unc0rr
parents: 10608
diff changeset
    44
10608
b85759f2ba18 Some more progress at custom combobox
unc0rr
parents: 10519
diff changeset
    45
            Row {
10610
eadf2cea55e0 Finish combobox implementation (except for visual part)
unc0rr
parents: 10608
diff changeset
    46
                Image {id: themeIcon; width: height; height: parent.height; source: "image://theme/" + modelData}
10608
b85759f2ba18 Some more progress at custom combobox
unc0rr
parents: 10519
diff changeset
    47
                Text {id: themeName; text: modelData }
b85759f2ba18 Some more progress at custom combobox
unc0rr
parents: 10519
diff changeset
    48
            }
10610
eadf2cea55e0 Finish combobox implementation (except for visual part)
unc0rr
parents: 10608
diff changeset
    49
10519
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    50
            MouseArea {
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    51
                 z: 1
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    52
                 anchors.fill: parent
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    53
                 onClicked: {
10608
b85759f2ba18 Some more progress at custom combobox
unc0rr
parents: 10519
diff changeset
    54
                     cbTheme.currentIndex = index
10519
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    55
                     HWEngine.setTheme(themeName.text)
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    56
                 }
af019fa70080 Attempt on a custom combobox
unc0rr
parents: 10456
diff changeset
    57
            }
11432
97e3e62ea5f9 Update seed, theme and script from net in UI
unc0rr
parents: 11426
diff changeset
    58
97e3e62ea5f9 Update seed, theme and script from net in UI
unc0rr
parents: 11426
diff changeset
    59
            Connections {
97e3e62ea5f9 Update seed, theme and script from net in UI
unc0rr
parents: 11426
diff changeset
    60
                target: HWEngine
97e3e62ea5f9 Update seed, theme and script from net in UI
unc0rr
parents: 11426
diff changeset
    61
                onThemeChanged: cbTheme.showItem({"iconSource" : "image://theme/" + theme, "text" : theme});
97e3e62ea5f9 Update seed, theme and script from net in UI
unc0rr
parents: 11426
diff changeset
    62
            }
10519
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
10612
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    66
    HWComboBox {
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    67
        id: cbScript
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    68
        width: 256
11426
ab6a6d9ebfc0 Small ui rework
unc0rr
parents: 10888
diff changeset
    69
        height: 32
10612
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    70
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    71
        model: scriptsModel
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    72
        delegate: Rectangle {
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    73
            height: 25
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    74
            width: 100
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    75
            color: "transparent"
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    76
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    77
            property string itemIconSource: ""
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    78
            property alias itemText: scriptName.text
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    79
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    80
            Row {
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    81
                //Image {id: themeIcon; width: height; height: parent.height; source: "image://theme/" + modelData}
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    82
                Text {id: scriptName; text: modelData }
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    83
            }
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    84
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    85
            MouseArea {
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    86
                 z: 1
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    87
                 anchors.fill: parent
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    88
                 onClicked: {
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    89
                     cbScript.currentIndex = index
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    90
                     HWEngine.setScript(scriptName.text)
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    91
                 }
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    92
            }
11432
97e3e62ea5f9 Update seed, theme and script from net in UI
unc0rr
parents: 11426
diff changeset
    93
            Connections {
97e3e62ea5f9 Update seed, theme and script from net in UI
unc0rr
parents: 11426
diff changeset
    94
                target: HWEngine
11433
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11432
diff changeset
    95
                onScriptChanged: cbScript.showItem({"iconSource" : "", "text" : script});
11432
97e3e62ea5f9 Update seed, theme and script from net in UI
unc0rr
parents: 11426
diff changeset
    96
            }
10436
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    97
        }
10612
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    98
    }
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10610
diff changeset
    99
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   100
    HWComboBox {
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   101
        id: cbScheme
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   102
        width: 256
11426
ab6a6d9ebfc0 Small ui rework
unc0rr
parents: 10888
diff changeset
   103
        height: 32
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   104
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   105
        model: schemesModel
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   106
        delegate: Rectangle {
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   107
            height: 25
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   108
            width: 100
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   109
            color: "transparent"
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   110
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   111
            property string itemIconSource: ""
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   112
            property alias itemText: schemeName.text
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   113
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   114
            Row {
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   115
                //Image {id: themeIcon; width: height; height: parent.height; source: "image://theme/" + modelData}
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   116
                Text {id: schemeName; text: modelData }
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   117
            }
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   118
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   119
            MouseArea {
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   120
                 z: 1
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   121
                 anchors.fill: parent
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   122
                 onClicked: {
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   123
                     cbScheme.currentIndex = index
10819
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10616
diff changeset
   124
                     HWEngine.setScheme(schemeName.text)
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   125
                 }
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   126
            }
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   127
        }
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   128
    }
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents: 10612
diff changeset
   129
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   130
10823
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   131
    HWComboBox {
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   132
        id: cbAmmo
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   133
        width: 256
11426
ab6a6d9ebfc0 Small ui rework
unc0rr
parents: 10888
diff changeset
   134
        height: 32
10823
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   135
10888
a04e04aaf599 Ammo schemes list, almost works
unc0rr
parents: 10823
diff changeset
   136
        model: ammosModel
10823
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   137
        delegate: Rectangle {
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   138
            height: 25
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   139
            width: 100
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   140
            color: "transparent"
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   141
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   142
            property string itemIconSource: ""
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   143
            property alias itemText: ammoName.text
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   144
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   145
            Row {
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   146
                //Image {id: themeIcon; width: height; height: parent.height; source: "image://theme/" + modelData}
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   147
                Text {id: ammoName; text: modelData }
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   148
            }
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   149
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   150
            MouseArea {
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   151
                 z: 1
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   152
                 anchors.fill: parent
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   153
                 onClicked: {
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   154
                     cbAmmo.currentIndex = index
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   155
                     HWEngine.setAmmo(ammoName.text)
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   156
                 }
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   157
            }
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   158
        }
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   159
    }
11426
ab6a6d9ebfc0 Small ui rework
unc0rr
parents: 10888
diff changeset
   160
    }
10823
1ff3dd3705b1 Introducing cbAmmo
unc0rr
parents: 10819
diff changeset
   161
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   162
    ListView {
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   163
        id: playingTeamsList
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   164
        x: 440
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   165
        y: 16
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   166
        width: 100
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   167
        height: 192
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   168
        highlight: Rectangle { color: "#eaea00"; radius: 4 }
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   169
        focus: true
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   170
        clip: true
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   171
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   172
        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
   173
            id: playingTeamsModel
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   174
        }
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   175
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   176
        delegate: Rectangle {
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   177
            id: teamDelegate
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   178
            height: 24
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   179
            width: parent.width
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   180
            radius: 8
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   181
            border.width: 2
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   182
            border.color: "#eaea00"
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   183
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   184
            Row {
10452
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   185
                Rectangle {
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   186
                    height: 20
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   187
                    width: height
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   188
                    color: teamColor
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   189
                    border.width: 2
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   190
                    border.color: "#eaea00"                    
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   191
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   192
                    MouseArea {
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   193
                        z: 1
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   194
                        anchors.fill: parent
10454
2b590e7972b1 Allow using right button or wheel to change team color
unc0rr
parents: 10452
diff changeset
   195
                        acceptedButtons: Qt.LeftButton | Qt.RightButton
2b590e7972b1 Allow using right button or wheel to change team color
unc0rr
parents: 10452
diff changeset
   196
                        onClicked: {
2b590e7972b1 Allow using right button or wheel to change team color
unc0rr
parents: 10452
diff changeset
   197
                            if (mouse.button === Qt.LeftButton)
2b590e7972b1 Allow using right button or wheel to change team color
unc0rr
parents: 10452
diff changeset
   198
                                HWEngine.changeTeamColor(name, 1)
2b590e7972b1 Allow using right button or wheel to change team color
unc0rr
parents: 10452
diff changeset
   199
                            else if (mouse.button === Qt.RightButton)
2b590e7972b1 Allow using right button or wheel to change team color
unc0rr
parents: 10452
diff changeset
   200
                                HWEngine.changeTeamColor(name, -1)
2b590e7972b1 Allow using right button or wheel to change team color
unc0rr
parents: 10452
diff changeset
   201
                        }
2b590e7972b1 Allow using right button or wheel to change team color
unc0rr
parents: 10452
diff changeset
   202
                        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
   203
                   }
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   204
                }
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   205
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   206
                Text { text: name
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   207
                    MouseArea {
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   208
                        z: 1
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   209
                        anchors.fill: parent
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   210
                        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
   211
                   }
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   212
                }
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   213
            }
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
   214
10452
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   215
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
   216
        }
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   217
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   218
        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
   219
            target: HWEngine
10452
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   220
            onPlayingTeamAdded: playingTeamsModel.append({
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   221
                                                             "aiLevel": aiLevel
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   222
                                                             , "name": teamName
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   223
                                                             , "local": isLocal
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   224
                                                             , "teamColor": "#000000"
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   225
                                                         })
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
   226
            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
   227
                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
   228
                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
   229
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   230
                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
   231
            }
10452
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   232
            onTeamColorChanged: {
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   233
                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
   234
                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
   235
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
   236
                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
   237
            }
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
   238
        }
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   239
    }
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   240
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   241
    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
   242
        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
   243
        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
   244
        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
   245
        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
   246
        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
   247
        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
   248
        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
   249
        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
   250
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   251
        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
   252
            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
   253
        }
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   254
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   255
        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
   256
            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
   257
            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
   258
            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
   259
            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
   260
            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
   261
            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
   262
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   263
            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
   264
                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
   265
            }
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   266
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   267
            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
   268
                 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
   269
                 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
   270
                 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
   271
            }
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   272
        }
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   273
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   274
        Connections {
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   275
            target: HWEngine
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   276
            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
   277
            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
   278
                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
   279
                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
   280
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   281
                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
   282
            }
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   283
        }
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   284
    }
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   285
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   286
    Component.onCompleted: {
10450
bf9e30b4ef9b - Store index of color instead of its value
unc0rr
parents: 10448
diff changeset
   287
        HWEngine.resetGameConfig()
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   288
        HWEngine.getTeamsList()
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   289
        HWEngine.getPreview()
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   290
    }
10422
4cf23d4c7624 - Pages
unc0rr
parents:
diff changeset
   291
}