HUD.qml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. import QtQuick 2.15
  2. import QtQuick.Controls 2.15
  3. import QtQuick.Layouts 2.15
  4. Item {
  5. id: hud
  6. signal pauseToggled()
  7. signal speedChanged(real speed)
  8. signal unitCommand(string command)
  9. property bool gameIsPaused: false
  10. property real currentSpeed: 1.0
  11. // Top panel
  12. Rectangle {
  13. id: topPanel
  14. anchors.top: parent.top
  15. anchors.left: parent.left
  16. anchors.right: parent.right
  17. height: 60
  18. color: "#2c3e50"
  19. border.color: "#34495e"
  20. border.width: 1
  21. RowLayout {
  22. anchors.fill: parent
  23. anchors.margins: 8
  24. spacing: 10
  25. // Pause/Play button
  26. Button {
  27. text: gameIsPaused ? "▶" : "⏸"
  28. font.pointSize: 16
  29. onClicked: {
  30. gameIsPaused = !gameIsPaused
  31. pauseToggled()
  32. }
  33. }
  34. Rectangle {
  35. width: 1
  36. height: parent.height * 0.6
  37. color: "#34495e"
  38. }
  39. // Speed controls
  40. Text {
  41. text: "Speed:"
  42. color: "white"
  43. font.pointSize: 12
  44. }
  45. Button {
  46. text: "0.5x"
  47. enabled: !gameIsPaused
  48. onClicked: {
  49. currentSpeed = 0.5
  50. speedChanged(currentSpeed)
  51. }
  52. }
  53. Button {
  54. text: "1x"
  55. enabled: !gameIsPaused
  56. onClicked: {
  57. currentSpeed = 1.0
  58. speedChanged(currentSpeed)
  59. }
  60. }
  61. Button {
  62. text: "2x"
  63. enabled: !gameIsPaused
  64. onClicked: {
  65. currentSpeed = 2.0
  66. speedChanged(currentSpeed)
  67. }
  68. }
  69. Rectangle {
  70. width: 1
  71. height: parent.height * 0.6
  72. color: "#34495e"
  73. }
  74. // Resources display (placeholder)
  75. Text {
  76. text: "Resources: 1000 Gold, 500 Wood"
  77. color: "white"
  78. font.pointSize: 12
  79. }
  80. Item {
  81. Layout.fillWidth: true
  82. }
  83. // Minimap placeholder
  84. Rectangle {
  85. width: 120
  86. height: parent.height * 0.8
  87. color: "#1a252f"
  88. border.color: "#34495e"
  89. border.width: 1
  90. Text {
  91. anchors.centerIn: parent
  92. text: "Minimap"
  93. color: "#7f8c8d"
  94. font.pointSize: 10
  95. }
  96. }
  97. }
  98. }
  99. // Bottom panel - Selection and orders
  100. Rectangle {
  101. id: bottomPanel
  102. anchors.bottom: parent.bottom
  103. anchors.left: parent.left
  104. anchors.right: parent.right
  105. height: 120
  106. color: "#2c3e50"
  107. border.color: "#34495e"
  108. border.width: 1
  109. RowLayout {
  110. anchors.fill: parent
  111. anchors.margins: 8
  112. spacing: 10
  113. // Unit selection panel
  114. Rectangle {
  115. Layout.preferredWidth: 200
  116. Layout.fillHeight: true
  117. color: "#34495e"
  118. border.color: "#1a252f"
  119. border.width: 1
  120. Column {
  121. anchors.fill: parent
  122. anchors.margins: 4
  123. spacing: 4
  124. Text {
  125. text: "Selected Units"
  126. color: "white"
  127. font.pointSize: 10
  128. font.bold: true
  129. }
  130. ScrollView {
  131. width: parent.width
  132. height: parent.height - 20
  133. ListView {
  134. id: selectedUnitsList
  135. model: ListModel {
  136. ListElement { name: "Warrior"; health: 100; maxHealth: 100 }
  137. ListElement { name: "Archer"; health: 75; maxHealth: 80 }
  138. }
  139. delegate: Rectangle {
  140. width: selectedUnitsList.width
  141. height: 25
  142. color: "#1a252f"
  143. Row {
  144. anchors.left: parent.left
  145. anchors.verticalCenter: parent.verticalCenter
  146. anchors.margins: 4
  147. spacing: 4
  148. Text {
  149. text: model.name
  150. color: "white"
  151. font.pointSize: 9
  152. }
  153. Rectangle {
  154. width: 40
  155. height: 8
  156. color: "#e74c3c"
  157. Rectangle {
  158. width: parent.width * (model.health / model.maxHealth)
  159. height: parent.height
  160. color: "#27ae60"
  161. }
  162. }
  163. }
  164. }
  165. }
  166. }
  167. }
  168. }
  169. // Command buttons
  170. GridLayout {
  171. Layout.preferredWidth: 300
  172. Layout.fillHeight: true
  173. columns: 3
  174. rowSpacing: 4
  175. columnSpacing: 4
  176. Button {
  177. Layout.fillWidth: true
  178. Layout.fillHeight: true
  179. text: "Move"
  180. onClicked: unitCommand("move")
  181. }
  182. Button {
  183. Layout.fillWidth: true
  184. Layout.fillHeight: true
  185. text: "Attack"
  186. onClicked: unitCommand("attack")
  187. }
  188. Button {
  189. Layout.fillWidth: true
  190. Layout.fillHeight: true
  191. text: "Stop"
  192. onClicked: unitCommand("stop")
  193. }
  194. Button {
  195. Layout.fillWidth: true
  196. Layout.fillHeight: true
  197. text: "Hold"
  198. onClicked: unitCommand("hold")
  199. }
  200. Button {
  201. Layout.fillWidth: true
  202. Layout.fillHeight: true
  203. text: "Patrol"
  204. onClicked: unitCommand("patrol")
  205. }
  206. Button {
  207. Layout.fillWidth: true
  208. Layout.fillHeight: true
  209. text: "Guard"
  210. onClicked: unitCommand("guard")
  211. }
  212. }
  213. Item {
  214. Layout.fillWidth: true
  215. }
  216. // Production panel (placeholder)
  217. Rectangle {
  218. Layout.preferredWidth: 200
  219. Layout.fillHeight: true
  220. color: "#34495e"
  221. border.color: "#1a252f"
  222. border.width: 1
  223. Text {
  224. anchors.centerIn: parent
  225. text: "Building/Production"
  226. color: "#7f8c8d"
  227. font.pointSize: 10
  228. }
  229. }
  230. }
  231. }
  232. }