| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511 |
- import QtQuick 2.15
- import QtQuick.Controls 2.15
- import QtQuick.Layouts 2.15
- Item {
- id: topRoot
- property bool gameIsPaused: false
- property real currentSpeed: 1
- readonly property int barmin_height: 72
- readonly property bool compact: width < 800
- readonly property bool ultraCompact: width < 560
- signal pauseToggled()
- signal speedChanged(real speed)
- Rectangle {
- id: topPanel
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: parent.top
- height: barmin_height
- color: "#1a1a1a"
- opacity: 0.98
- clip: true
- Rectangle {
- anchors.fill: parent
- opacity: 0.9
- gradient: Gradient {
- GradientStop {
- position: 0
- color: "#22303a"
- }
- GradientStop {
- position: 1
- color: "#0f1a22"
- }
- }
- }
- Rectangle {
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- height: 2
- gradient: Gradient {
- GradientStop {
- position: 0
- color: "transparent"
- }
- GradientStop {
- position: 0.5
- color: "#3498db"
- }
- GradientStop {
- position: 1
- color: "transparent"
- }
- }
- }
- RowLayout {
- id: barRow
- anchors.fill: parent
- anchors.margins: 8
- spacing: 12
- RowLayout {
- id: leftGroup
- spacing: 10
- Layout.alignment: Qt.AlignVCenter
- Button {
- id: pauseBtn
- Layout.preferredWidth: topRoot.compact ? 48 : 56
- Layout.preferredHeight: Math.min(40, topPanel.height - 12)
- text: topRoot.gameIsPaused ? "\u25B6" : "\u23F8"
- font.pixelSize: 26
- font.bold: true
- focusPolicy: Qt.NoFocus
- onClicked: topRoot.pauseToggled()
- background: Rectangle {
- color: parent.pressed ? "#e74c3c" : parent.hovered ? "#c0392b" : "#34495e"
- radius: 6
- border.color: "#2c3e50"
- border.width: 1
- }
- contentItem: Text {
- text: parent.text
- font: parent.font
- color: "#ecf0f1"
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
- }
- Rectangle {
- width: 2
- Layout.fillHeight: true
- radius: 1
- visible: !topRoot.compact
- gradient: Gradient {
- GradientStop {
- position: 0
- color: "transparent"
- }
- GradientStop {
- position: 0.5
- color: "#34495e"
- }
- GradientStop {
- position: 1
- color: "transparent"
- }
- }
- }
- RowLayout {
- spacing: 8
- Layout.alignment: Qt.AlignVCenter
- Label {
- text: qsTr("Speed:")
- visible: !topRoot.compact
- color: "#ecf0f1"
- font.pixelSize: 14
- font.bold: true
- verticalAlignment: Text.AlignVCenter
- }
- Row {
- id: speedRow
- property var options: [0.5, 1, 2]
- spacing: 8
- visible: !topRoot.compact
- ButtonGroup {
- id: speedGroup
- }
- Repeater {
- model: speedRow.options
- delegate: Button {
- Layout.minimumWidth: 48
- width: 56
- height: Math.min(34, topPanel.height - 16)
- checkable: true
- enabled: !topRoot.gameIsPaused
- checked: (topRoot.currentSpeed === modelData) && !topRoot.gameIsPaused
- focusPolicy: Qt.NoFocus
- text: modelData + "x"
- ButtonGroup.group: speedGroup
- onClicked: topRoot.speedChanged(modelData)
- background: Rectangle {
- color: parent.checked ? "#27ae60" : parent.hovered ? "#34495e" : "#2c3e50"
- radius: 6
- border.color: parent.checked ? "#229954" : "#1a252f"
- border.width: 1
- }
- contentItem: Text {
- text: parent.text
- font.pixelSize: 13
- font.bold: true
- color: parent.enabled ? "#ecf0f1" : "#7f8c8d"
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
- }
- }
- }
- ComboBox {
- id: speedCombo
- visible: topRoot.compact
- Layout.preferredWidth: 120
- model: ["0.5x", "1x", "2x"]
- currentIndex: topRoot.currentSpeed === 0.5 ? 0 : topRoot.currentSpeed === 1 ? 1 : 2
- enabled: !topRoot.gameIsPaused
- font.pixelSize: 13
- onActivated: function(i) {
- var v = i === 0 ? 0.5 : (i === 1 ? 1 : 2);
- topRoot.speedChanged(v);
- }
- }
- }
- Rectangle {
- width: 2
- Layout.fillHeight: true
- radius: 1
- visible: !topRoot.compact
- gradient: Gradient {
- GradientStop {
- position: 0
- color: "transparent"
- }
- GradientStop {
- position: 0.5
- color: "#34495e"
- }
- GradientStop {
- position: 1
- color: "transparent"
- }
- }
- }
- RowLayout {
- spacing: 8
- Layout.alignment: Qt.AlignVCenter
- Label {
- text: qsTr("Camera:")
- visible: !topRoot.compact
- color: "#ecf0f1"
- font.pixelSize: 14
- font.bold: true
- verticalAlignment: Text.AlignVCenter
- }
- Button {
- id: followBtn
- Layout.preferredWidth: topRoot.compact ? 44 : 80
- Layout.preferredHeight: Math.min(34, topPanel.height - 16)
- checkable: true
- text: topRoot.compact ? "\u2609" : qsTr("Follow")
- font.pixelSize: 13
- focusPolicy: Qt.NoFocus
- onToggled: {
- if (typeof game !== 'undefined' && game.camera_follow_selection)
- game.camera_follow_selection(checked);
- }
- background: Rectangle {
- color: parent.checked ? "#3498db" : parent.hovered ? "#34495e" : "#2c3e50"
- radius: 6
- border.color: parent.checked ? "#2980b9" : "#1a252f"
- border.width: 1
- }
- contentItem: Text {
- text: parent.text
- font: parent.font
- color: "#ecf0f1"
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
- }
- Button {
- id: resetBtn
- Layout.preferredWidth: topRoot.compact ? 44 : 80
- Layout.preferredHeight: Math.min(34, topPanel.height - 16)
- text: topRoot.compact ? "\u21BA" : qsTr("Reset")
- font.pixelSize: 13
- focusPolicy: Qt.NoFocus
- onClicked: {
- if (typeof game !== 'undefined' && game.reset_camera)
- game.reset_camera();
- }
- background: Rectangle {
- color: parent.hovered ? "#34495e" : "#2c3e50"
- radius: 6
- border.color: "#1a252f"
- border.width: 1
- }
- contentItem: Text {
- text: parent.text
- font: parent.font
- color: "#ecf0f1"
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
- }
- }
- }
- Item {
- Layout.fillWidth: true
- }
- RowLayout {
- id: rightGroup
- spacing: 12
- Layout.alignment: Qt.AlignVCenter
- Layout.rightMargin: 260
- Row {
- id: statsRow
- spacing: 10
- Layout.alignment: Qt.AlignVCenter
- Label {
- id: playerLbl
- text: "🗡️ " + (typeof game !== 'undefined' ? game.player_troop_count : 0) + " / " + (typeof game !== 'undefined' ? game.max_troops_per_player : 0)
- color: {
- if (typeof game === 'undefined')
- return "#95a5a6";
- var count = game.player_troop_count;
- var max = game.max_troops_per_player;
- if (count >= max)
- return "#e74c3c";
- if (count >= max * 0.8)
- return "#f39c12";
- return "#2ecc71";
- }
- font.pixelSize: 14
- font.bold: true
- elide: Text.ElideRight
- verticalAlignment: Text.AlignVCenter
- }
- Rectangle {
- width: 2
- height: 24
- color: "#34495e"
- opacity: 0.5
- visible: !topRoot.compact
- }
- Label {
- id: ownersLbl
- text: {
- if (typeof game === 'undefined')
- return "Players: 0";
- var owners = game.owner_info;
- var playerCount = 0;
- var aiCount = 0;
- for (var i = 0; i < owners.length; i++) {
- if (owners[i].type === "Player")
- playerCount++;
- else if (owners[i].type === "AI")
- aiCount++;
- }
- return "👥 " + playerCount + " | 🤖 " + aiCount;
- }
- color: "#ecf0f1"
- font.pixelSize: 13
- font.bold: false
- visible: !topRoot.compact
- verticalAlignment: Text.AlignVCenter
- ToolTip.visible: ma.containsMouse
- ToolTip.delay: 500
- ToolTip.text: {
- if (typeof game === 'undefined')
- return "";
- var owners = game.owner_info;
- var tip = "Owner IDs:\n";
- for (var i = 0; i < owners.length; i++) {
- tip += owners[i].id + ": " + owners[i].name + " (" + owners[i].type + ")";
- if (owners[i].isLocal)
- tip += " [You]";
- tip += "\n";
- }
- return tip;
- }
- MouseArea {
- id: ma
- anchors.fill: parent
- hoverEnabled: true
- }
- }
- Label {
- id: enemyLbl
- text: "💀 " + (typeof game !== 'undefined' ? game.enemy_troops_defeated : 0)
- color: "#ecf0f1"
- font.pixelSize: 14
- elide: Text.ElideRight
- verticalAlignment: Text.AlignVCenter
- }
- }
- Item {
- id: miniWrap
- visible: !topRoot.ultraCompact
- Layout.preferredWidth: Math.round(topPanel.height * 2.2)
- Layout.minimumWidth: Math.round(topPanel.height * 1.6)
- Layout.preferredHeight: topPanel.height - 8
- }
- }
- }
- }
- Rectangle {
- id: minimapContainer
- visible: !topRoot.ultraCompact
- width: 240
- height: 240
- anchors.right: parent.right
- anchors.top: parent.top
- anchors.rightMargin: 8
- anchors.topMargin: 8
- z: 100
- color: "#0f1a22"
- radius: 8
- border.width: 2
- border.color: "#3498db"
- Rectangle {
- anchors.fill: parent
- anchors.margins: 3
- radius: 6
- color: "#0a0f14"
- Image {
- id: minimapImage
- property int imageVersion: 0
- anchors.fill: parent
- anchors.margins: 2
- source: imageVersion > 0 ? "image://minimap/v" + imageVersion : ""
- fillMode: Image.PreserveAspectFit
- smooth: true
- cache: false
- asynchronous: false
- Connections {
- function onMinimap_image_changed() {
- Qt.callLater(function() {
- minimapImage.imageVersion++;
- });
- }
- target: game
- }
- Label {
- anchors.centerIn: parent
- text: qsTr("MINIMAP")
- color: "#3f5362"
- font.pixelSize: 12
- font.bold: true
- visible: parent.status !== Image.Ready
- }
- }
- }
- }
- }
|