| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- import QtQuick 2.15
- import QtQuick.Controls 2.15
- import QtQuick.Layouts 1.3
- import QtQuick.Window 2.15
- import StandardOfIron.UI 1.0
- Item {
- id: root
- signal openSkirmish()
- signal openSettings()
- signal loadSave()
- signal saveGame()
- signal exitRequested()
- anchors.fill: parent
- z: 10
- focus: true
- Keys.onPressed: function(event) {
- if (event.key === Qt.Key_Down) {
- container.selectedIndex = Math.min(container.selectedIndex + 1, menuModel.count - 1);
- event.accepted = true;
- } else if (event.key === Qt.Key_Up) {
- container.selectedIndex = Math.max(container.selectedIndex - 1, 0);
- event.accepted = true;
- } else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
- var m = menuModel.get(container.selectedIndex);
- if (m.idStr === "skirmish")
- root.openSkirmish();
- else if (m.idStr === "save")
- root.saveGame();
- else if (m.idStr === "load")
- root.loadSave();
- else if (m.idStr === "settings")
- root.openSettings();
- else if (m.idStr === "exit")
- root.exitRequested();
- event.accepted = true;
- } else if (event.key === Qt.Key_Escape) {
- if (typeof mainWindow !== 'undefined' && mainWindow.menuVisible && mainWindow.gameStarted) {
- mainWindow.menuVisible = false;
- event.accepted = true;
- }
- }
- }
- Rectangle {
- anchors.fill: parent
- color: Theme.dim
- }
- Rectangle {
- id: container
- property int selectedIndex: 0
- width: Math.min(parent.width * 0.78, 1100)
- height: Math.min(parent.height * 0.78, 700)
- anchors.centerIn: parent
- radius: Theme.radiusPanel
- color: Theme.panelBase
- border.color: Theme.panelBr
- border.width: 1
- opacity: 0.98
- clip: true
- GridLayout {
- id: grid
- anchors.fill: parent
- anchors.margins: Theme.spacingXLarge
- rowSpacing: Theme.spacingMedium
- columnSpacing: 18
- columns: parent.width > 900 ? 2 : 1
- ColumnLayout {
- Layout.preferredWidth: parent.width > 900 ? parent.width * 0.45 : parent.width
- spacing: Theme.spacingLarge
- ColumnLayout {
- spacing: Theme.spacingSmall
- Label {
- text: "STANDARD OF IRON"
- color: Theme.textMain
- font.pointSize: Theme.fontSizeHero
- font.bold: true
- horizontalAlignment: Text.AlignLeft
- Layout.fillWidth: true
- elide: Label.ElideRight
- }
- Label {
- text: "A tiny but ambitious RTS"
- color: Theme.textSub
- font.pointSize: Theme.fontSizeMedium
- horizontalAlignment: Text.AlignLeft
- Layout.fillWidth: true
- elide: Label.ElideRight
- }
- }
- ListModel {
- id: menuModel
- ListElement {
- idStr: "skirmish"
- title: "Play — Skirmish"
- subtitle: "Select a map and start"
- }
- ListElement {
- idStr: "save"
- title: "Save Game"
- subtitle: "Save your current progress"
- }
- ListElement {
- idStr: "load"
- title: "Load Game"
- subtitle: "Resume a previous game"
- }
- ListElement {
- idStr: "settings"
- title: "Settings"
- subtitle: "Adjust graphics & controls"
- }
- ListElement {
- idStr: "exit"
- title: "Exit"
- subtitle: "Quit the game"
- }
- }
- Repeater {
- model: menuModel
- delegate: Item {
- id: menuItem
- property int idx: index
- Layout.fillWidth: true
- Layout.preferredHeight: container.width > 900 ? 64 : 56
- Rectangle {
- anchors.fill: parent
- radius: Theme.radiusLarge
- clip: true
- color: container.selectedIndex === idx ? Theme.selectedBg : menuItemMouse.containsPress ? Theme.hoverBg : Qt.rgba(0, 0, 0, 0)
- border.width: 1
- border.color: container.selectedIndex === idx ? Theme.selectedBr : Theme.cardBorder
- RowLayout {
- anchors.fill: parent
- anchors.margins: Theme.spacingSmall
- spacing: Theme.spacingMedium
- Item {
- Layout.fillWidth: true
- Layout.preferredWidth: 1
- }
- ColumnLayout {
- Layout.fillWidth: true
- spacing: Theme.spacingTiny
- Text {
- text: model.title
- Layout.fillWidth: true
- elide: Text.ElideRight
- color: container.selectedIndex === idx ? Theme.textMain : Theme.textBright
- font.pointSize: Theme.fontSizeLarge
- font.bold: container.selectedIndex === idx
- }
- Text {
- text: model.subtitle
- Layout.fillWidth: true
- elide: Text.ElideRight
- color: container.selectedIndex === idx ? Theme.accentBright : Theme.textSubLite
- font.pointSize: Theme.fontSizeSmall
- }
- }
- Text {
- text: "›"
- font.pointSize: Theme.fontSizeTitle
- color: container.selectedIndex === idx ? Theme.textMain : Theme.textHint
- }
- }
- Behavior on color {
- ColorAnimation {
- duration: Theme.animNormal
- }
- }
- Behavior on border.color {
- ColorAnimation {
- duration: Theme.animNormal
- }
- }
- }
- MouseArea {
- id: menuItemMouse
- anchors.fill: parent
- hoverEnabled: true
- acceptedButtons: Qt.LeftButton
- cursorShape: Qt.PointingHandCursor
- onEntered: container.selectedIndex = idx
- onClicked: {
- if (model.idStr === "skirmish")
- root.openSkirmish();
- else if (model.idStr === "save")
- root.saveGame();
- else if (model.idStr === "load")
- root.loadSave();
- else if (model.idStr === "settings")
- root.openSettings();
- else if (model.idStr === "exit")
- root.exitRequested();
- }
- }
- }
- }
- Item {
- Layout.fillHeight: true
- }
- RowLayout {
- spacing: Theme.spacingSmall
- Label {
- text: "v0.9 — prototype"
- color: Theme.textDim
- font.pointSize: Theme.fontSizeSmall
- }
- Item {
- Layout.fillWidth: true
- }
- Label {
- text: Qt.formatDateTime(new Date(), "yyyy-MM-dd")
- color: Theme.textHint
- font.pointSize: Theme.fontSizeSmall
- elide: Label.ElideRight
- }
- }
- }
- Rectangle {
- color: Qt.rgba(0, 0, 0, 0)
- radius: Theme.radiusMedium
- Layout.preferredWidth: parent.width > 900 ? parent.width * 0.45 : parent.width
- ColumnLayout {
- anchors.fill: parent
- anchors.margins: Theme.spacingSmall
- spacing: Theme.spacingMedium
- Rectangle {
- id: promo
- color: Theme.cardBase
- radius: Theme.radiusLarge
- border.color: Theme.border
- border.width: 1
- Layout.preferredHeight: 260
- clip: true
- ColumnLayout {
- anchors.fill: parent
- anchors.margins: Theme.spacingMedium
- spacing: Theme.spacingSmall
- Label {
- text: "Featured"
- color: Theme.accent
- font.pointSize: Theme.fontSizeMedium
- Layout.fillWidth: true
- elide: Label.ElideRight
- }
- Label {
- text: "Skirmish Mode"
- color: Theme.textMain
- font.pointSize: Theme.fontSizeTitle
- font.bold: true
- Layout.fillWidth: true
- elide: Label.ElideRight
- }
- Text {
- text: "Pick a map, adjust your forces and jump into battle. Modern controls and responsive UI."
- color: Theme.textSubLite
- wrapMode: Text.WordWrap
- maximumLineCount: 3
- elide: Text.ElideRight
- Layout.fillWidth: true
- }
- }
- }
- Rectangle {
- color: Theme.cardBase
- radius: Theme.radiusLarge
- border.color: Theme.border
- border.width: 1
- Layout.preferredHeight: 120
- clip: true
- ColumnLayout {
- anchors.fill: parent
- anchors.margins: Theme.spacingSmall
- spacing: Theme.spacingSmall
- Label {
- text: "Tips"
- color: Theme.accent
- font.pointSize: Theme.fontSizeMedium
- Layout.fillWidth: true
- elide: Label.ElideRight
- }
- Text {
- text: "Hover menu items or use Up/Down and Enter to navigate. Play opens map selection."
- color: Theme.textSubLite
- wrapMode: Text.WordWrap
- maximumLineCount: 3
- elide: Text.ElideRight
- Layout.fillWidth: true
- }
- }
- }
- }
- }
- }
- }
- }
|