| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- import QtQuick 2.15
- import QtQuick.Controls 2.15
- import QtQuick.Layouts 1.15
- import StandardOfIron 1.0
- Item {
- id: root
- property var mission_objectives: null
- signal closeRequested()
- function refreshObjectives() {
- if (typeof game !== 'undefined' && game.get_current_mission_objectives)
- mission_objectives = game.get_current_mission_objectives();
- else
- mission_objectives = null;
- }
- anchors.fill: parent
- z: 10
- focus: true
- Keys.onPressed: function(event) {
- if (event.key === Qt.Key_Escape) {
- root.closeRequested();
- event.accepted = true;
- }
- }
- Component.onCompleted: {
- refreshObjectives();
- }
- onVisibleChanged: {
- if (visible)
- refreshObjectives();
- }
- Rectangle {
- anchors.fill: parent
- color: Theme.dim
- }
- Rectangle {
- id: container
- width: Math.min(parent.width * 0.7, 800)
- height: Math.min(parent.height * 0.8, 600)
- anchors.centerIn: parent
- radius: Theme.radiusPanel
- color: Theme.panelBase
- border.color: Theme.panelBr
- border.width: 1
- opacity: 0.98
- ColumnLayout {
- anchors.fill: parent
- anchors.margins: Theme.spacingXLarge
- spacing: Theme.spacingLarge
- RowLayout {
- Layout.fillWidth: true
- spacing: Theme.spacingMedium
- Label {
- text: qsTr("Mission Objectives")
- color: Theme.textMain
- font.pointSize: Theme.fontSizeHero
- font.bold: true
- Layout.fillWidth: true
- }
- StyledButton {
- text: "×"
- Layout.preferredWidth: 40
- Layout.preferredHeight: 40
- onClicked: root.closeRequested()
- }
- }
- Rectangle {
- Layout.fillWidth: true
- Layout.preferredHeight: 1
- color: Theme.border
- }
- ScrollView {
- id: objectivesScroll
- Layout.fillWidth: true
- Layout.fillHeight: true
- clip: true
- contentWidth: objectivesScroll.availableWidth
- ColumnLayout {
- width: objectivesScroll.availableWidth
- spacing: Theme.spacingLarge
- ColumnLayout {
- Layout.fillWidth: true
- spacing: Theme.spacingSmall
- visible: !!(mission_objectives && mission_objectives.title)
- Label {
- text: mission_objectives && mission_objectives.title ? mission_objectives.title : ""
- color: Theme.textMain
- font.pointSize: Theme.fontSizeTitle
- font.bold: true
- wrapMode: Text.WordWrap
- Layout.fillWidth: true
- }
- Label {
- text: mission_objectives && mission_objectives.summary ? mission_objectives.summary : ""
- color: Theme.textSubLite
- font.pointSize: Theme.fontSizeMedium
- wrapMode: Text.WordWrap
- Layout.fillWidth: true
- }
- }
- ColumnLayout {
- Layout.fillWidth: true
- spacing: Theme.spacingMedium
- visible: !!(mission_objectives && mission_objectives.victory_conditions && mission_objectives.victory_conditions.length > 0)
- Label {
- text: qsTr("Victory Conditions")
- color: Theme.successText
- font.pointSize: Theme.fontSizeLarge
- font.bold: true
- Layout.fillWidth: true
- }
- Repeater {
- model: mission_objectives && mission_objectives.victory_conditions ? mission_objectives.victory_conditions : []
- delegate: Rectangle {
- Layout.fillWidth: true
- Layout.preferredHeight: victory_content.implicitHeight + Theme.spacingMedium * 2
- radius: Theme.radiusMedium
- color: Theme.successBg
- border.color: Theme.successBr
- border.width: 1
- RowLayout {
- id: victory_content
- anchors.fill: parent
- anchors.margins: Theme.spacingMedium
- spacing: Theme.spacingMedium
- Label {
- text: "✓"
- color: Theme.successText
- font.pointSize: Theme.fontSizeLarge
- font.bold: true
- Layout.alignment: Qt.AlignTop
- }
- Label {
- text: modelData.description || qsTr("Complete the objective")
- color: Theme.textMain
- font.pointSize: Theme.fontSizeMedium
- wrapMode: Text.WordWrap
- Layout.fillWidth: true
- }
- }
- }
- }
- }
- ColumnLayout {
- Layout.fillWidth: true
- spacing: Theme.spacingMedium
- visible: !!(mission_objectives && mission_objectives.defeat_conditions && mission_objectives.defeat_conditions.length > 0)
- Label {
- text: qsTr("Defeat Conditions")
- color: Theme.removeColor
- font.pointSize: Theme.fontSizeLarge
- font.bold: true
- Layout.fillWidth: true
- }
- Repeater {
- model: mission_objectives && mission_objectives.defeat_conditions ? mission_objectives.defeat_conditions : []
- delegate: Rectangle {
- Layout.fillWidth: true
- Layout.preferredHeight: defeat_content.implicitHeight + Theme.spacingMedium * 2
- radius: Theme.radiusMedium
- color: Theme.dangerBg
- border.color: Theme.dangerBr
- border.width: 1
- RowLayout {
- id: defeat_content
- anchors.fill: parent
- anchors.margins: Theme.spacingMedium
- spacing: Theme.spacingMedium
- Label {
- text: "✗"
- color: Theme.removeColor
- font.pointSize: Theme.fontSizeLarge
- font.bold: true
- Layout.alignment: Qt.AlignTop
- }
- Label {
- text: modelData.description || qsTr("Avoid this condition")
- color: Theme.removeColor
- font.pointSize: Theme.fontSizeMedium
- wrapMode: Text.WordWrap
- Layout.fillWidth: true
- }
- }
- }
- }
- }
- ColumnLayout {
- Layout.fillWidth: true
- spacing: Theme.spacingMedium
- visible: !!(mission_objectives && mission_objectives.optional_objectives && mission_objectives.optional_objectives.length > 0)
- Label {
- text: qsTr("Optional Objectives")
- color: Theme.accent
- font.pointSize: Theme.fontSizeLarge
- font.bold: true
- Layout.fillWidth: true
- }
- Repeater {
- model: mission_objectives && mission_objectives.optional_objectives ? mission_objectives.optional_objectives : []
- delegate: Rectangle {
- Layout.fillWidth: true
- Layout.preferredHeight: optional_content.implicitHeight + Theme.spacingMedium * 2
- radius: Theme.radiusMedium
- color: Theme.infoBg
- border.color: Theme.infoBr
- border.width: 1
- RowLayout {
- id: optional_content
- anchors.fill: parent
- anchors.margins: Theme.spacingMedium
- spacing: Theme.spacingMedium
- Label {
- text: "★"
- color: Theme.accent
- font.pointSize: Theme.fontSizeLarge
- font.bold: true
- Layout.alignment: Qt.AlignTop
- }
- Label {
- text: modelData.description || qsTr("Optional objective")
- color: Theme.textMain
- font.pointSize: Theme.fontSizeMedium
- wrapMode: Text.WordWrap
- Layout.fillWidth: true
- }
- }
- }
- }
- }
- Label {
- visible: !mission_objectives || (!mission_objectives.victory_conditions && !mission_objectives.defeat_conditions && !mission_objectives.optional_objectives)
- text: qsTr("No mission objectives available.\nThis may be a skirmish game or objectives have not been configured.")
- color: Theme.textDim
- font.pointSize: Theme.fontSizeMedium
- horizontalAlignment: Text.AlignHCenter
- wrapMode: Text.WordWrap
- Layout.fillWidth: true
- Layout.topMargin: Theme.spacingXLarge
- }
- }
- }
- RowLayout {
- Layout.fillWidth: true
- spacing: Theme.spacingMedium
- Item {
- Layout.fillWidth: true
- }
- StyledButton {
- text: qsTr("Close")
- onClicked: root.closeRequested()
- }
- }
- }
- }
- }
|