ProductionPanel.qml 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898
  1. import QtQuick 2.15
  2. import QtQuick.Controls 2.15
  3. import QtQuick.Layouts 1.15
  4. import StandardOfIron 1.0
  5. Rectangle {
  6. id: productionPanel
  7. property int selectionTick: 0
  8. property var gameInstance: null
  9. signal recruitUnit(string unitType)
  10. signal rallyModeToggled()
  11. signal buildTower()
  12. signal builderConstruction(string itemType)
  13. function defaultProductionState() {
  14. return {
  15. "has_barracks": false,
  16. "produced_count": 0,
  17. "max_units": 0,
  18. "queue_size": 0,
  19. "in_progress": false,
  20. "production_queue": [],
  21. "product_type": "",
  22. "villager_cost": 1,
  23. "build_time": 0,
  24. "time_remaining": 0,
  25. "nation_id": ""
  26. };
  27. }
  28. function unitIconSource(unitType, nationKey) {
  29. if (typeof StyleGuide === "undefined" || !StyleGuide.unitIconSources || !unitType)
  30. return "";
  31. var sources = StyleGuide.unitIconSources[unitType];
  32. if (!sources)
  33. sources = StyleGuide.unitIconSources["default"];
  34. if (typeof sources === "object" && sources !== null) {
  35. if (nationKey && sources[nationKey])
  36. return sources[nationKey];
  37. if (sources["default"])
  38. return sources["default"];
  39. } else if (typeof sources === "string") {
  40. return sources;
  41. }
  42. return "";
  43. }
  44. function unitIconEmoji(unitType) {
  45. if (typeof StyleGuide !== "undefined" && StyleGuide.unitIcons)
  46. return StyleGuide.unitIcons[unitType] || StyleGuide.unitIcons["default"] || "👤";
  47. return "👤";
  48. }
  49. function getUnitProductionInfo(unitType, nationId) {
  50. if (productionPanel.gameInstance && productionPanel.gameInstance.get_unit_production_info)
  51. return productionPanel.gameInstance.get_unit_production_info(unitType, nationId || "");
  52. return {
  53. "cost": 50,
  54. "build_time": 5,
  55. "individuals_per_unit": 1,
  56. "display_name": unitType
  57. };
  58. }
  59. color: "#0f1419"
  60. border.color: "#3498db"
  61. border.width: 2
  62. radius: 6
  63. ScrollView {
  64. anchors.fill: parent
  65. anchors.margins: 10
  66. clip: true
  67. ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
  68. ScrollBar.vertical.policy: ScrollBar.AsNeeded
  69. Column {
  70. width: productionPanel.width - 20
  71. spacing: 8
  72. Rectangle {
  73. property bool has_barracks: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.has_selected_type && productionPanel.gameInstance.has_selected_type("barracks")))
  74. width: parent.width
  75. height: productionContent.height + 16
  76. color: "#1a252f"
  77. radius: 6
  78. border.color: "#34495e"
  79. border.width: 1
  80. visible: has_barracks
  81. Column {
  82. id: productionContent
  83. property var prod: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.get_selected_production_state) ? productionPanel.gameInstance.get_selected_production_state() : productionPanel.defaultProductionState())
  84. anchors.horizontalCenter: parent.horizontalCenter
  85. anchors.top: parent.top
  86. anchors.margins: 8
  87. spacing: 10
  88. width: parent.width - 16
  89. Text {
  90. anchors.horizontalCenter: parent.horizontalCenter
  91. text: qsTr("PRODUCTION QUEUE")
  92. color: "#3498db"
  93. font.pointSize: 8
  94. font.bold: true
  95. }
  96. Row {
  97. anchors.horizontalCenter: parent.horizontalCenter
  98. spacing: 6
  99. Repeater {
  100. model: 5
  101. Rectangle {
  102. property int queueTotal: (productionContent.prod.in_progress ? 1 : 0) + (productionContent.prod.queue_size || 0)
  103. property bool isOccupied: index < queueTotal
  104. property bool isProducing: index === 0 && productionContent.prod.in_progress
  105. property string queueUnitType: {
  106. if (!isOccupied)
  107. return "";
  108. if (index === 0 && productionContent.prod.in_progress)
  109. return productionContent.prod.product_type || "archer";
  110. var queueIndex = productionContent.prod.in_progress ? index - 1 : index;
  111. if (productionContent.prod.production_queue && productionContent.prod.production_queue[queueIndex])
  112. return productionContent.prod.production_queue[queueIndex];
  113. return "archer";
  114. }
  115. width: 36
  116. height: 36
  117. radius: 6
  118. color: isProducing ? "#27ae60" : (isOccupied ? "#2c3e50" : "#1a1a1a")
  119. border.color: isProducing ? "#229954" : (isOccupied ? "#4a6572" : "#2a2a2a")
  120. border.width: 2
  121. Image {
  122. id: queueIconImage
  123. anchors.centerIn: parent
  124. width: 28
  125. height: 28
  126. fillMode: Image.PreserveAspectFit
  127. smooth: true
  128. source: parent.isOccupied ? productionPanel.unitIconSource(parent.queueUnitType, productionContent.prod.nation_id) : ""
  129. visible: parent.isOccupied && source !== ""
  130. }
  131. Text {
  132. anchors.centerIn: parent
  133. text: parent.isOccupied ? productionPanel.unitIconEmoji(parent.queueUnitType) : "·"
  134. color: parent.isProducing ? "#ffffff" : (parent.isOccupied ? "#bdc3c7" : "#3a3a3a")
  135. font.pointSize: parent.isOccupied ? 16 : 20
  136. font.bold: parent.isProducing
  137. visible: !queueIconImage.visible
  138. }
  139. Text {
  140. anchors.right: parent.right
  141. anchors.bottom: parent.bottom
  142. anchors.margins: 2
  143. text: (index + 1).toString()
  144. color: parent.isOccupied ? "#7f8c8d" : "#2a2a2a"
  145. font.pointSize: 7
  146. font.bold: true
  147. }
  148. SequentialAnimation on opacity {
  149. running: isProducing
  150. loops: Animation.Infinite
  151. NumberAnimation {
  152. from: 0.7
  153. to: 1
  154. duration: 800
  155. }
  156. NumberAnimation {
  157. from: 1
  158. to: 0.7
  159. duration: 800
  160. }
  161. }
  162. }
  163. }
  164. }
  165. Text {
  166. property int queueTotal: (productionContent.prod.in_progress ? 1 : 0) + (productionContent.prod.queue_size || 0)
  167. anchors.horizontalCenter: parent.horizontalCenter
  168. text: queueTotal + " / 5"
  169. color: queueTotal >= 5 ? "#e74c3c" : "#bdc3c7"
  170. font.pointSize: 9
  171. font.bold: queueTotal >= 5
  172. }
  173. Rectangle {
  174. width: parent.width - 20
  175. height: 20
  176. anchors.horizontalCenter: parent.horizontalCenter
  177. radius: 10
  178. color: "#0a0f14"
  179. border.color: "#2c3e50"
  180. border.width: 2
  181. visible: productionContent.prod.in_progress
  182. Rectangle {
  183. anchors.left: parent.left
  184. anchors.verticalCenter: parent.verticalCenter
  185. anchors.margins: 2
  186. height: parent.height - 4
  187. width: {
  188. if (!productionContent.prod.in_progress || productionContent.prod.build_time <= 0)
  189. return 0;
  190. var progress = 1 - (Math.max(0, productionContent.prod.time_remaining) / productionContent.prod.build_time);
  191. return Math.max(0, (parent.width - 4) * progress);
  192. }
  193. color: "#27ae60"
  194. radius: 8
  195. SequentialAnimation on opacity {
  196. running: parent.width > 0
  197. loops: Animation.Infinite
  198. NumberAnimation {
  199. from: 0.8
  200. to: 1
  201. duration: 600
  202. }
  203. NumberAnimation {
  204. from: 1
  205. to: 0.8
  206. duration: 600
  207. }
  208. }
  209. }
  210. Text {
  211. anchors.centerIn: parent
  212. text: productionContent.prod.in_progress ? Math.max(0, productionContent.prod.time_remaining).toFixed(1) + "s" : "Idle"
  213. color: "#ecf0f1"
  214. font.pointSize: 9
  215. font.bold: true
  216. style: Text.Outline
  217. styleColor: "#000000"
  218. }
  219. }
  220. Text {
  221. anchors.horizontalCenter: parent.horizontalCenter
  222. text: qsTr("Units Produced: %1 / %2").arg(productionContent.prod.produced_count || 0).arg(productionContent.prod.max_units || 0)
  223. color: (productionContent.prod.produced_count >= productionContent.prod.max_units) ? "#e74c3c" : "#bdc3c7"
  224. font.pointSize: 8
  225. }
  226. }
  227. }
  228. Rectangle {
  229. property bool has_barracks: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.has_selected_type && productionPanel.gameInstance.has_selected_type("barracks")))
  230. width: parent.width
  231. height: unitGridContent.height + 16
  232. color: "#1a252f"
  233. radius: 6
  234. border.color: "#34495e"
  235. border.width: 1
  236. visible: has_barracks
  237. Column {
  238. id: unitGridContent
  239. property var prod: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.get_selected_production_state) ? productionPanel.gameInstance.get_selected_production_state() : productionPanel.defaultProductionState())
  240. anchors.horizontalCenter: parent.horizontalCenter
  241. anchors.top: parent.top
  242. anchors.margins: 8
  243. spacing: 8
  244. Text {
  245. anchors.horizontalCenter: parent.horizontalCenter
  246. text: qsTr("RECRUIT UNITS")
  247. color: "#3498db"
  248. font.pointSize: 8
  249. font.bold: true
  250. }
  251. Grid {
  252. anchors.horizontalCenter: parent.horizontalCenter
  253. columns: 3
  254. columnSpacing: 8
  255. rowSpacing: 8
  256. Rectangle {
  257. property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
  258. property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
  259. property var unitInfo: productionPanel.getUnitProductionInfo("archer", unitGridContent.prod.nation_id)
  260. property bool isHovered: archerMouseArea.containsMouse
  261. width: 110
  262. height: 80
  263. radius: 6
  264. color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
  265. border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
  266. border.width: isHovered && isEnabled ? 4 : 2
  267. opacity: isEnabled ? 1 : 0.5
  268. scale: isHovered && isEnabled ? 1.1 : 1
  269. Image {
  270. id: archerRecruitIcon
  271. anchors.fill: parent
  272. fillMode: Image.PreserveAspectCrop
  273. smooth: true
  274. source: productionPanel.unitIconSource("archer", unitGridContent.prod.nation_id)
  275. visible: source !== ""
  276. opacity: parent.isEnabled ? 1 : 0.35
  277. }
  278. Text {
  279. anchors.centerIn: parent
  280. visible: !archerRecruitIcon.visible
  281. text: productionPanel.unitIconEmoji("archer")
  282. color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
  283. font.pointSize: 42
  284. opacity: parent.isEnabled ? 0.9 : 0.4
  285. }
  286. Rectangle {
  287. id: archerCostBadge
  288. width: archerCostText.implicitWidth + 12
  289. height: archerCostText.implicitHeight + 6
  290. anchors.horizontalCenter: parent.horizontalCenter
  291. anchors.bottom: parent.bottom
  292. anchors.bottomMargin: 6
  293. radius: 8
  294. color: parent.isEnabled ? "#000000b3" : "#00000066"
  295. border.color: parent.isEnabled ? "#f39c12" : "#555555"
  296. border.width: 1
  297. Text {
  298. id: archerCostText
  299. anchors.centerIn: parent
  300. text: parent.parent.unitInfo.cost || 50
  301. color: archerCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
  302. font.pointSize: 16
  303. font.bold: true
  304. }
  305. }
  306. MouseArea {
  307. id: archerMouseArea
  308. anchors.fill: parent
  309. hoverEnabled: true
  310. onClicked: {
  311. if (parent.isEnabled)
  312. productionPanel.recruitUnit("archer");
  313. }
  314. cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
  315. ToolTip.visible: containsMouse
  316. ToolTip.text: parent.isEnabled ? qsTr("Recruit %1\nCost: %2 villagers\nBuild time: %3s").arg(parent.unitInfo.display_name || "Archer").arg(parent.unitInfo.cost || 50).arg((parent.unitInfo.build_time || 5).toFixed(0)) : (parent.queueTotal >= 5 ? qsTr("Queue is full (5/5)") : (unitGridContent.prod.produced_count >= unitGridContent.prod.max_units ? qsTr("Unit cap reached") : qsTr("Cannot recruit")))
  317. ToolTip.delay: 300
  318. }
  319. Rectangle {
  320. anchors.fill: parent
  321. color: "#ffffff"
  322. opacity: archerMouseArea.pressed ? 0.2 : 0
  323. radius: parent.radius
  324. }
  325. Behavior on color {
  326. ColorAnimation {
  327. duration: 150
  328. }
  329. }
  330. Behavior on border.color {
  331. ColorAnimation {
  332. duration: 150
  333. }
  334. }
  335. Behavior on scale {
  336. NumberAnimation {
  337. duration: 100
  338. }
  339. }
  340. }
  341. Rectangle {
  342. property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
  343. property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
  344. property var unitInfo: productionPanel.getUnitProductionInfo("swordsman", unitGridContent.prod.nation_id)
  345. property bool isHovered: swordsmanMouseArea.containsMouse
  346. width: 110
  347. height: 80
  348. radius: 6
  349. color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
  350. border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
  351. border.width: isHovered && isEnabled ? 4 : 2
  352. opacity: isEnabled ? 1 : 0.5
  353. scale: isHovered && isEnabled ? 1.1 : 1
  354. Image {
  355. id: swordsmanRecruitIcon
  356. anchors.fill: parent
  357. fillMode: Image.PreserveAspectCrop
  358. smooth: true
  359. source: productionPanel.unitIconSource("swordsman", unitGridContent.prod.nation_id)
  360. visible: source !== ""
  361. opacity: parent.isEnabled ? 1 : 0.35
  362. }
  363. Text {
  364. anchors.centerIn: parent
  365. visible: !swordsmanRecruitIcon.visible
  366. text: productionPanel.unitIconEmoji("swordsman")
  367. color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
  368. font.pointSize: 42
  369. opacity: parent.isEnabled ? 0.9 : 0.4
  370. }
  371. Rectangle {
  372. id: swordsmanCostBadge
  373. width: swordsmanCostText.implicitWidth + 12
  374. height: swordsmanCostText.implicitHeight + 6
  375. anchors.horizontalCenter: parent.horizontalCenter
  376. anchors.bottom: parent.bottom
  377. anchors.bottomMargin: 6
  378. radius: 8
  379. color: parent.isEnabled ? "#000000b3" : "#00000066"
  380. border.color: parent.isEnabled ? "#f39c12" : "#555555"
  381. border.width: 1
  382. Text {
  383. id: swordsmanCostText
  384. anchors.centerIn: parent
  385. text: parent.parent.unitInfo.cost || 90
  386. color: swordsmanCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
  387. font.pointSize: 16
  388. font.bold: true
  389. }
  390. }
  391. MouseArea {
  392. id: swordsmanMouseArea
  393. anchors.fill: parent
  394. hoverEnabled: true
  395. onClicked: {
  396. if (parent.isEnabled)
  397. productionPanel.recruitUnit("swordsman");
  398. }
  399. cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
  400. ToolTip.visible: containsMouse
  401. ToolTip.text: parent.isEnabled ? qsTr("Recruit %1\nCost: %2 villagers\nBuild time: %3s").arg(parent.unitInfo.display_name || "Swordsman").arg(parent.unitInfo.cost || 90).arg((parent.unitInfo.build_time || 7).toFixed(0)) : (parent.queueTotal >= 5 ? qsTr("Queue is full (5/5)") : (unitGridContent.prod.produced_count >= unitGridContent.prod.max_units ? qsTr("Unit cap reached") : qsTr("Cannot recruit")))
  402. ToolTip.delay: 300
  403. }
  404. Rectangle {
  405. anchors.fill: parent
  406. color: "#ffffff"
  407. opacity: swordsmanMouseArea.pressed ? 0.2 : 0
  408. radius: parent.radius
  409. }
  410. Behavior on color {
  411. ColorAnimation {
  412. duration: 150
  413. }
  414. }
  415. Behavior on border.color {
  416. ColorAnimation {
  417. duration: 150
  418. }
  419. }
  420. Behavior on scale {
  421. NumberAnimation {
  422. duration: 100
  423. }
  424. }
  425. }
  426. Rectangle {
  427. property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
  428. property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
  429. property var unitInfo: productionPanel.getUnitProductionInfo("spearman", unitGridContent.prod.nation_id)
  430. property bool isHovered: spearmanMouseArea.containsMouse
  431. width: 110
  432. height: 80
  433. radius: 6
  434. color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
  435. border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
  436. border.width: isHovered && isEnabled ? 4 : 2
  437. opacity: isEnabled ? 1 : 0.5
  438. scale: isHovered && isEnabled ? 1.1 : 1
  439. Image {
  440. id: spearmanRecruitIcon
  441. anchors.fill: parent
  442. fillMode: Image.PreserveAspectCrop
  443. smooth: true
  444. source: productionPanel.unitIconSource("spearman", unitGridContent.prod.nation_id)
  445. visible: source !== ""
  446. opacity: parent.isEnabled ? 1 : 0.35
  447. }
  448. Text {
  449. anchors.centerIn: parent
  450. visible: !spearmanRecruitIcon.visible
  451. text: productionPanel.unitIconEmoji("spearman")
  452. color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
  453. font.pointSize: 42
  454. opacity: parent.isEnabled ? 0.9 : 0.4
  455. }
  456. Rectangle {
  457. id: spearmanCostBadge
  458. width: spearmanCostText.implicitWidth + 12
  459. height: spearmanCostText.implicitHeight + 6
  460. anchors.horizontalCenter: parent.horizontalCenter
  461. anchors.bottom: parent.bottom
  462. anchors.bottomMargin: 6
  463. radius: 8
  464. color: parent.isEnabled ? "#000000b3" : "#00000066"
  465. border.color: parent.isEnabled ? "#f39c12" : "#555555"
  466. border.width: 1
  467. Text {
  468. id: spearmanCostText
  469. anchors.centerIn: parent
  470. text: parent.parent.unitInfo.cost || 75
  471. color: spearmanCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
  472. font.pointSize: 16
  473. font.bold: true
  474. }
  475. }
  476. MouseArea {
  477. id: spearmanMouseArea
  478. anchors.fill: parent
  479. hoverEnabled: true
  480. onClicked: {
  481. if (parent.isEnabled)
  482. productionPanel.recruitUnit("spearman");
  483. }
  484. cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
  485. ToolTip.visible: containsMouse
  486. ToolTip.text: parent.isEnabled ? qsTr("Recruit %1\nCost: %2 villagers\nBuild time: %3s").arg(parent.unitInfo.display_name || "Spearman").arg(parent.unitInfo.cost || 75).arg((parent.unitInfo.build_time || 6).toFixed(0)) : (parent.queueTotal >= 5 ? qsTr("Queue is full (5/5)") : (unitGridContent.prod.produced_count >= unitGridContent.prod.max_units ? qsTr("Unit cap reached") : qsTr("Cannot recruit")))
  487. ToolTip.delay: 300
  488. }
  489. Rectangle {
  490. anchors.fill: parent
  491. color: "#ffffff"
  492. opacity: spearmanMouseArea.pressed ? 0.2 : 0
  493. radius: parent.radius
  494. }
  495. Behavior on color {
  496. ColorAnimation {
  497. duration: 150
  498. }
  499. }
  500. Behavior on border.color {
  501. ColorAnimation {
  502. duration: 150
  503. }
  504. }
  505. Behavior on scale {
  506. NumberAnimation {
  507. duration: 100
  508. }
  509. }
  510. }
  511. Rectangle {
  512. property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
  513. property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
  514. property var unitInfo: productionPanel.getUnitProductionInfo("horse_swordsman", unitGridContent.prod.nation_id)
  515. property bool isHovered: horseKnightMouseArea.containsMouse
  516. width: 110
  517. height: 80
  518. radius: 6
  519. color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
  520. border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
  521. border.width: isHovered && isEnabled ? 4 : 2
  522. opacity: isEnabled ? 1 : 0.5
  523. scale: isHovered && isEnabled ? 1.1 : 1
  524. Image {
  525. id: horseKnightIcon
  526. anchors.fill: parent
  527. fillMode: Image.PreserveAspectCrop
  528. smooth: true
  529. source: productionPanel.unitIconSource("horse_swordsman", unitGridContent.prod.nation_id)
  530. visible: source !== ""
  531. opacity: parent.isEnabled ? 1 : 0.35
  532. }
  533. Text {
  534. anchors.centerIn: parent
  535. visible: !horseKnightIcon.visible
  536. text: productionPanel.unitIconEmoji("horse_swordsman")
  537. color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
  538. font.pointSize: 42
  539. opacity: parent.isEnabled ? 0.9 : 0.4
  540. }
  541. Rectangle {
  542. id: horseKnightCostBadge
  543. width: horseKnightCostText.implicitWidth + 12
  544. height: horseKnightCostText.implicitHeight + 6
  545. anchors.horizontalCenter: parent.horizontalCenter
  546. anchors.bottom: parent.bottom
  547. anchors.bottomMargin: 6
  548. radius: 8
  549. color: parent.isEnabled ? "#000000b3" : "#00000066"
  550. border.color: parent.isEnabled ? "#f39c12" : "#555555"
  551. border.width: 1
  552. Text {
  553. id: horseKnightCostText
  554. anchors.centerIn: parent
  555. text: parent.parent.unitInfo.cost || 150
  556. color: horseKnightCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
  557. font.pointSize: 16
  558. font.bold: true
  559. }
  560. }
  561. MouseArea {
  562. id: horseKnightMouseArea
  563. anchors.fill: parent
  564. hoverEnabled: true
  565. onClicked: {
  566. if (parent.isEnabled)
  567. productionPanel.recruitUnit("horse_swordsman");
  568. }
  569. cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
  570. ToolTip.visible: containsMouse
  571. ToolTip.text: parent.isEnabled ? qsTr("Recruit %1\nCost: %2 villagers\nBuild time: %3s").arg(parent.unitInfo.display_name || "Mounted Knight").arg(parent.unitInfo.cost || 150).arg((parent.unitInfo.build_time || 10).toFixed(0)) : (parent.queueTotal >= 5 ? qsTr("Queue is full (5/5)") : (unitGridContent.prod.produced_count >= unitGridContent.prod.max_units ? qsTr("Unit cap reached") : qsTr("Cannot recruit")))
  572. ToolTip.delay: 300
  573. }
  574. Rectangle {
  575. anchors.fill: parent
  576. color: "#ffffff"
  577. opacity: horseKnightMouseArea.pressed ? 0.2 : 0
  578. radius: parent.radius
  579. }
  580. Behavior on color {
  581. ColorAnimation {
  582. duration: 150
  583. }
  584. }
  585. Behavior on border.color {
  586. ColorAnimation {
  587. duration: 150
  588. }
  589. }
  590. Behavior on scale {
  591. NumberAnimation {
  592. duration: 100
  593. }
  594. }
  595. }
  596. Rectangle {
  597. property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
  598. property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
  599. property var unitInfo: productionPanel.getUnitProductionInfo("horse_archer", unitGridContent.prod.nation_id)
  600. property bool isHovered: horseArcherMouseArea.containsMouse
  601. width: 110
  602. height: 80
  603. radius: 6
  604. color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
  605. border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
  606. border.width: isHovered && isEnabled ? 4 : 2
  607. opacity: isEnabled ? 1 : 0.5
  608. scale: isHovered && isEnabled ? 1.1 : 1
  609. Image {
  610. id: horseArcherIcon
  611. anchors.fill: parent
  612. fillMode: Image.PreserveAspectCrop
  613. smooth: true
  614. source: productionPanel.unitIconSource("horse_archer", unitGridContent.prod.nation_id)
  615. visible: source !== ""
  616. opacity: parent.isEnabled ? 1 : 0.35
  617. }
  618. Text {
  619. anchors.centerIn: parent
  620. visible: !horseArcherIcon.visible
  621. text: productionPanel.unitIconEmoji("horse_archer")
  622. color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
  623. font.pointSize: 42
  624. opacity: parent.isEnabled ? 0.9 : 0.4
  625. }
  626. Rectangle {
  627. id: horseArcherCostBadge
  628. width: horseArcherCostText.implicitWidth + 12
  629. height: horseArcherCostText.implicitHeight + 6
  630. anchors.horizontalCenter: parent.horizontalCenter
  631. anchors.bottom: parent.bottom
  632. anchors.bottomMargin: 6
  633. radius: 8
  634. color: parent.isEnabled ? "#000000b3" : "#00000066"
  635. border.color: parent.isEnabled ? "#f39c12" : "#555555"
  636. border.width: 1
  637. Text {
  638. id: horseArcherCostText
  639. anchors.centerIn: parent
  640. text: parent.parent.unitInfo.cost || 120
  641. color: horseArcherCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
  642. font.pointSize: 16
  643. font.bold: true
  644. }
  645. }
  646. MouseArea {
  647. id: horseArcherMouseArea
  648. anchors.fill: parent
  649. hoverEnabled: true
  650. onClicked: {
  651. if (parent.isEnabled)
  652. productionPanel.recruitUnit("horse_archer");
  653. }
  654. cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
  655. ToolTip.visible: containsMouse
  656. ToolTip.text: parent.isEnabled ? qsTr("Recruit %1\nCost: %2 villagers\nBuild time: %3s").arg(parent.unitInfo.display_name || "Horse Archer").arg(parent.unitInfo.cost || 120).arg((parent.unitInfo.build_time || 9).toFixed(0)) : (parent.queueTotal >= 5 ? qsTr("Queue is full (5/5)") : (unitGridContent.prod.produced_count >= unitGridContent.prod.max_units ? qsTr("Unit cap reached") : qsTr("Cannot recruit")))
  657. ToolTip.delay: 300
  658. }
  659. Rectangle {
  660. anchors.fill: parent
  661. color: "#ffffff"
  662. opacity: horseArcherMouseArea.pressed ? 0.2 : 0
  663. radius: parent.radius
  664. }
  665. Behavior on color {
  666. ColorAnimation {
  667. duration: 150
  668. }
  669. }
  670. Behavior on border.color {
  671. ColorAnimation {
  672. duration: 150
  673. }
  674. }
  675. Behavior on scale {
  676. NumberAnimation {
  677. duration: 100
  678. }
  679. }
  680. }
  681. Rectangle {
  682. property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
  683. property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
  684. property var unitInfo: productionPanel.getUnitProductionInfo("horse_spearman", unitGridContent.prod.nation_id)
  685. property bool isHovered: horseSpearmanMouseArea.containsMouse
  686. width: 110
  687. height: 80
  688. radius: 6
  689. color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
  690. border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
  691. border.width: isHovered && isEnabled ? 4 : 2
  692. opacity: isEnabled ? 1 : 0.5
  693. scale: isHovered && isEnabled ? 1.1 : 1
  694. Image {
  695. id: horseSpearmanIcon
  696. anchors.fill: parent
  697. fillMode: Image.PreserveAspectCrop
  698. smooth: true
  699. source: productionPanel.unitIconSource("horse_spearman", unitGridContent.prod.nation_id)
  700. visible: source !== ""
  701. opacity: parent.isEnabled ? 1 : 0.35
  702. }
  703. Text {
  704. anchors.centerIn: parent
  705. visible: !horseSpearmanIcon.visible
  706. text: productionPanel.unitIconEmoji("horse_spearman")
  707. color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
  708. font.pointSize: 42
  709. opacity: parent.isEnabled ? 0.9 : 0.4
  710. }
  711. Rectangle {
  712. id: horseSpearmanCostBadge
  713. width: horseSpearmanCostText.implicitWidth + 12
  714. height: horseSpearmanCostText.implicitHeight + 6
  715. anchors.horizontalCenter: parent.horizontalCenter
  716. anchors.bottom: parent.bottom
  717. anchors.bottomMargin: 6
  718. radius: 8
  719. color: parent.isEnabled ? "#000000b3" : "#00000066"
  720. border.color: parent.isEnabled ? "#f39c12" : "#555555"
  721. border.width: 1
  722. Text {
  723. id: horseSpearmanCostText
  724. anchors.centerIn: parent
  725. text: parent.parent.unitInfo.cost || 130
  726. color: horseSpearmanCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
  727. font.pointSize: 16
  728. font.bold: true
  729. }
  730. }
  731. MouseArea {
  732. id: horseSpearmanMouseArea
  733. anchors.fill: parent
  734. hoverEnabled: true
  735. onClicked: {
  736. if (parent.isEnabled)
  737. productionPanel.recruitUnit("horse_spearman");
  738. }
  739. cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
  740. ToolTip.visible: containsMouse
  741. ToolTip.text: parent.isEnabled ? qsTr("Recruit %1\nCost: %2 villagers\nBuild time: %3s").arg(parent.unitInfo.display_name || "Horse Spearman").arg(parent.unitInfo.cost || 130).arg((parent.unitInfo.build_time || 9).toFixed(0)) : (parent.queueTotal >= 5 ? qsTr("Queue is full (5/5)") : (unitGridContent.prod.produced_count >= unitGridContent.prod.max_units ? qsTr("Unit cap reached") : qsTr("Cannot recruit")))
  742. ToolTip.delay: 300
  743. }
  744. Rectangle {
  745. anchors.fill: parent
  746. color: "#ffffff"
  747. opacity: horseSpearmanMouseArea.pressed ? 0.2 : 0
  748. radius: parent.radius
  749. }
  750. Behavior on color {
  751. ColorAnimation {
  752. duration: 150
  753. }
  754. }
  755. Behavior on border.color {
  756. ColorAnimation {
  757. duration: 150
  758. }
  759. }
  760. Behavior on scale {
  761. NumberAnimation {
  762. duration: 100
  763. }
  764. }
  765. }
  766. Rectangle {
  767. property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
  768. property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
  769. property var unitInfo: productionPanel.getUnitProductionInfo("healer", unitGridContent.prod.nation_id)
  770. property bool isHovered: healerMouseArea.containsMouse
  771. width: 110
  772. height: 80
  773. radius: 6
  774. color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
  775. border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
  776. border.width: isHovered && isEnabled ? 4 : 2
  777. opacity: isEnabled ? 1 : 0.5
  778. scale: isHovered && isEnabled ? 1.1 : 1
  779. Image {
  780. id: healerRecruitIcon
  781. anchors.fill: parent
  782. fillMode: Image.PreserveAspectCrop
  783. smooth: true
  784. source: productionPanel.unitIconSource("healer", unitGridContent.prod.nation_id)
  785. visible: source !== ""
  786. opacity: parent.isEnabled ? 1 : 0.35
  787. }
  788. Text {
  789. anchors.centerIn: parent
  790. visible: !healerRecruitIcon.visible
  791. text: productionPanel.unitIconEmoji("healer")
  792. color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
  793. font.pointSize: 42
  794. opacity: parent.isEnabled ? 0.9 : 0.4
  795. }
  796. Rectangle {
  797. id: healerCostBadge
  798. width: healerCostText.implicitWidth + 12
  799. height: healerCostText.implicitHeight + 6
  800. anchors.horizontalCenter: parent.horizontalCenter
  801. anchors.bottom: parent.bottom
  802. anchors.bottomMargin: 6
  803. radius: 8
  804. color: parent.isEnabled ? "#000000b3" : "#00000066"
  805. border.color: parent.isEnabled ? "#f39c12" : "#555555"
  806. border.width: 1
  807. Text {
  808. id: healerCostText
  809. anchors.centerIn: parent
  810. text: parent.parent.unitInfo.cost || 100
  811. color: healerCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
  812. font.pointSize: 16
  813. font.bold: true
  814. }
  815. }
  816. MouseArea {
  817. id: healerMouseArea
  818. anchors.fill: parent
  819. hoverEnabled: true
  820. onClicked: {
  821. if (parent.isEnabled)
  822. productionPanel.recruitUnit("healer");
  823. }
  824. cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
  825. ToolTip.visible: containsMouse
  826. ToolTip.text: parent.isEnabled ? qsTr("Recruit %1\nCost: %2 villagers\nBuild time: %3s").arg(parent.unitInfo.display_name || "Healer").arg(parent.unitInfo.cost || 100).arg((parent.unitInfo.build_time || 8).toFixed(0)) : (parent.queueTotal >= 5 ? qsTr("Queue is full (5/5)") : (unitGridContent.prod.produced_count >= unitGridContent.prod.max_units ? qsTr("Unit cap reached") : qsTr("Cannot recruit")))
  827. ToolTip.delay: 300
  828. }
  829. Rectangle {
  830. anchors.fill: parent
  831. color: "#ffffff"
  832. opacity: healerMouseArea.pressed ? 0.2 : 0
  833. radius: parent.radius
  834. }
  835. Behavior on color {
  836. ColorAnimation {
  837. duration: 150
  838. }
  839. }
  840. Behavior on border.color {
  841. ColorAnimation {
  842. duration: 150
  843. }
  844. }
  845. Behavior on scale {
  846. NumberAnimation {
  847. duration: 100
  848. }
  849. }
  850. }
  851. Rectangle {
  852. property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
  853. property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
  854. property var unitInfo: productionPanel.getUnitProductionInfo("builder", unitGridContent.prod.nation_id)
  855. property bool isHovered: builderMouseArea.containsMouse
  856. width: 110
  857. height: 80
  858. radius: 6
  859. color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
  860. border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
  861. border.width: isHovered && isEnabled ? 4 : 2
  862. opacity: isEnabled ? 1 : 0.5
  863. scale: isHovered && isEnabled ? 1.1 : 1
  864. Image {
  865. id: builderRecruitIcon
  866. anchors.fill: parent
  867. fillMode: Image.PreserveAspectCrop
  868. smooth: true
  869. source: productionPanel.unitIconSource("builder", unitGridContent.prod.nation_id)
  870. visible: source !== ""
  871. opacity: parent.isEnabled ? 1 : 0.35
  872. }
  873. Text {
  874. anchors.centerIn: parent
  875. visible: !builderRecruitIcon.visible
  876. text: productionPanel.unitIconEmoji("builder")
  877. color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
  878. font.pointSize: 42
  879. opacity: parent.isEnabled ? 0.9 : 0.4
  880. }
  881. Rectangle {
  882. id: builderCostBadge
  883. width: builderCostText.implicitWidth + 12
  884. height: builderCostText.implicitHeight + 6
  885. anchors.horizontalCenter: parent.horizontalCenter
  886. anchors.bottom: parent.bottom
  887. anchors.bottomMargin: 6
  888. radius: 8
  889. color: parent.isEnabled ? "#000000b3" : "#00000066"
  890. border.color: parent.isEnabled ? "#f39c12" : "#555555"
  891. border.width: 1
  892. Text {
  893. id: builderCostText
  894. anchors.centerIn: parent
  895. text: parent.parent.unitInfo.cost || 60
  896. color: builderCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
  897. font.pointSize: 16
  898. font.bold: true
  899. }
  900. }
  901. MouseArea {
  902. id: builderMouseArea
  903. anchors.fill: parent
  904. hoverEnabled: true
  905. onClicked: {
  906. if (parent.isEnabled)
  907. productionPanel.recruitUnit("builder");
  908. }
  909. cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
  910. ToolTip.visible: containsMouse
  911. ToolTip.text: parent.isEnabled ? qsTr("Recruit %1\nCost: %2 villagers\nBuild time: %3s").arg(parent.unitInfo.display_name || "Builder").arg(parent.unitInfo.cost || 60).arg((parent.unitInfo.build_time || 6).toFixed(0)) : (parent.queueTotal >= 5 ? qsTr("Queue is full (5/5)") : (unitGridContent.prod.produced_count >= unitGridContent.prod.max_units ? qsTr("Unit cap reached") : qsTr("Cannot recruit")))
  912. ToolTip.delay: 300
  913. }
  914. Rectangle {
  915. anchors.fill: parent
  916. color: "#ffffff"
  917. opacity: builderMouseArea.pressed ? 0.2 : 0
  918. radius: parent.radius
  919. }
  920. Behavior on color {
  921. ColorAnimation {
  922. duration: 150
  923. }
  924. }
  925. Behavior on border.color {
  926. ColorAnimation {
  927. duration: 150
  928. }
  929. }
  930. Behavior on scale {
  931. NumberAnimation {
  932. duration: 100
  933. }
  934. }
  935. }
  936. Rectangle {
  937. property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
  938. property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
  939. property var unitInfo: productionPanel.getUnitProductionInfo("elephant", unitGridContent.prod.nation_id)
  940. property bool isHovered: elephantMouseArea.containsMouse
  941. width: 110
  942. height: 80
  943. radius: 6
  944. color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
  945. border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
  946. border.width: isHovered && isEnabled ? 4 : 2
  947. opacity: isEnabled ? 1 : 0.5
  948. scale: isHovered && isEnabled ? 1.1 : 1
  949. visible: unitGridContent.prod.nation_id === "carthage"
  950. Image {
  951. id: elephantRecruitIcon
  952. anchors.fill: parent
  953. fillMode: Image.PreserveAspectCrop
  954. smooth: true
  955. source: productionPanel.unitIconSource("elephant", unitGridContent.prod.nation_id)
  956. visible: source !== ""
  957. opacity: parent.isEnabled ? 1 : 0.35
  958. }
  959. Text {
  960. anchors.centerIn: parent
  961. visible: !elephantRecruitIcon.visible
  962. text: productionPanel.unitIconEmoji("elephant")
  963. color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
  964. font.pointSize: 42
  965. opacity: parent.isEnabled ? 0.9 : 0.4
  966. }
  967. Rectangle {
  968. id: elephantCostBadge
  969. width: elephantCostText.implicitWidth + 12
  970. height: elephantCostText.implicitHeight + 6
  971. anchors.horizontalCenter: parent.horizontalCenter
  972. anchors.bottom: parent.bottom
  973. anchors.bottomMargin: 6
  974. radius: 8
  975. color: parent.isEnabled ? "#000000b3" : "#00000066"
  976. border.color: parent.isEnabled ? "#f39c12" : "#555555"
  977. border.width: 1
  978. Text {
  979. id: elephantCostText
  980. anchors.centerIn: parent
  981. text: parent.parent.unitInfo.cost || 250
  982. color: elephantCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
  983. font.pointSize: 16
  984. font.bold: true
  985. }
  986. }
  987. MouseArea {
  988. id: elephantMouseArea
  989. anchors.fill: parent
  990. hoverEnabled: true
  991. onClicked: {
  992. if (parent.isEnabled)
  993. productionPanel.recruitUnit("elephant");
  994. }
  995. cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
  996. ToolTip.visible: containsMouse
  997. ToolTip.text: parent.isEnabled ? qsTr("Recruit %1\nCost: %2 villagers\nBuild time: %3s\nCarthage exclusive").arg(parent.unitInfo.display_name || "War Elephant").arg(parent.unitInfo.cost || 250).arg((parent.unitInfo.build_time || 20).toFixed(0)) : (parent.queueTotal >= 5 ? qsTr("Queue is full (5/5)") : (unitGridContent.prod.produced_count >= unitGridContent.prod.max_units ? qsTr("Unit cap reached") : qsTr("Cannot recruit")))
  998. ToolTip.delay: 300
  999. }
  1000. Rectangle {
  1001. anchors.fill: parent
  1002. color: "#ffffff"
  1003. opacity: elephantMouseArea.pressed ? 0.2 : 0
  1004. radius: parent.radius
  1005. }
  1006. Behavior on color {
  1007. ColorAnimation {
  1008. duration: 150
  1009. }
  1010. }
  1011. Behavior on border.color {
  1012. ColorAnimation {
  1013. duration: 150
  1014. }
  1015. }
  1016. Behavior on scale {
  1017. NumberAnimation {
  1018. duration: 100
  1019. }
  1020. }
  1021. }
  1022. }
  1023. }
  1024. }
  1025. Rectangle {
  1026. property bool has_barracks: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.has_selected_type && productionPanel.gameInstance.has_selected_type("barracks")))
  1027. width: parent.width
  1028. height: 1
  1029. color: "#34495e"
  1030. visible: has_barracks
  1031. }
  1032. Rectangle {
  1033. property bool has_barracks: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.has_selected_type && productionPanel.gameInstance.has_selected_type("barracks")))
  1034. width: parent.width
  1035. height: rallyContent.height + 12
  1036. color: "#1a252f"
  1037. radius: 6
  1038. border.color: "#34495e"
  1039. border.width: 1
  1040. visible: has_barracks
  1041. Column {
  1042. id: rallyContent
  1043. property var prod: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.get_selected_production_state) ? productionPanel.gameInstance.get_selected_production_state() : productionPanel.defaultProductionState())
  1044. anchors.horizontalCenter: parent.horizontalCenter
  1045. anchors.top: parent.top
  1046. anchors.margins: 6
  1047. spacing: 6
  1048. Button {
  1049. anchors.horizontalCenter: parent.horizontalCenter
  1050. width: parent.parent.width - 20
  1051. height: 32
  1052. text: (typeof gameView !== 'undefined' && gameView.setRallyMode) ? qsTr("📍 Click Map to Set Rally") : qsTr("📍 Set Rally Point")
  1053. focusPolicy: Qt.NoFocus
  1054. enabled: rallyContent.prod.has_barracks
  1055. onClicked: productionPanel.rallyModeToggled()
  1056. ToolTip.visible: hovered
  1057. ToolTip.text: qsTr("Set where newly recruited units will gather.\nRight-click to cancel.")
  1058. ToolTip.delay: 500
  1059. background: Rectangle {
  1060. color: parent.enabled ? (parent.down ? "#16a085" : (parent.hovered ? "#1abc9c" : "#2c3e50")) : "#1a1a1a"
  1061. radius: 6
  1062. border.color: (typeof gameView !== 'undefined' && gameView.setRallyMode) ? "#1abc9c" : "#34495e"
  1063. border.width: 2
  1064. }
  1065. contentItem: Text {
  1066. text: parent.text
  1067. font.pointSize: 9
  1068. font.bold: true
  1069. color: parent.enabled ? "#ecf0f1" : "#5a5a5a"
  1070. horizontalAlignment: Text.AlignHCenter
  1071. verticalAlignment: Text.AlignVCenter
  1072. }
  1073. }
  1074. Text {
  1075. anchors.horizontalCenter: parent.horizontalCenter
  1076. text: (typeof gameView !== 'undefined' && gameView.setRallyMode) ? qsTr("Right-click to cancel") : ""
  1077. color: "#7f8c8d"
  1078. font.pointSize: 8
  1079. font.italic: true
  1080. }
  1081. }
  1082. }
  1083. Item {
  1084. property bool has_barracksSelected: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.has_selected_type && productionPanel.gameInstance.has_selected_type("barracks")))
  1085. height: 20
  1086. visible: !has_barracksSelected
  1087. }
  1088. Rectangle {
  1089. property bool has_builder: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.has_selected_type && productionPanel.gameInstance.has_selected_type("builder")))
  1090. width: parent.width
  1091. height: builderProductionContent.height + 16
  1092. color: "#1a252f"
  1093. radius: 6
  1094. border.color: "#34495e"
  1095. border.width: 1
  1096. visible: has_builder
  1097. Column {
  1098. id: builderProductionContent
  1099. property var builderProd: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.get_selected_builder_production_state) ? productionPanel.gameInstance.get_selected_builder_production_state() : {
  1100. "in_progress": false,
  1101. "build_time": 10,
  1102. "time_remaining": 0,
  1103. "product_type": ""
  1104. })
  1105. anchors.horizontalCenter: parent.horizontalCenter
  1106. anchors.top: parent.top
  1107. anchors.margins: 8
  1108. spacing: 8
  1109. width: parent.width - 16
  1110. Row {
  1111. anchors.horizontalCenter: parent.horizontalCenter
  1112. spacing: 6
  1113. Image {
  1114. id: builderHeaderIcon
  1115. width: 18
  1116. height: 18
  1117. source: productionPanel.unitIconSource("builder")
  1118. fillMode: Image.PreserveAspectFit
  1119. smooth: true
  1120. visible: source !== ""
  1121. }
  1122. Text {
  1123. anchors.verticalCenter: parent.verticalCenter
  1124. text: builderHeaderIcon.visible ? qsTr("BUILDER CONSTRUCTION") : qsTr("🔨 BUILDER CONSTRUCTION")
  1125. color: "#3498db"
  1126. font.pointSize: 9
  1127. font.bold: true
  1128. }
  1129. }
  1130. Text {
  1131. anchors.horizontalCenter: parent.horizontalCenter
  1132. text: qsTr("Build siege weapons and structures")
  1133. color: "#7f8c8d"
  1134. font.pointSize: 7
  1135. }
  1136. Rectangle {
  1137. width: parent.width - 20
  1138. height: 20
  1139. anchors.horizontalCenter: parent.horizontalCenter
  1140. radius: 10
  1141. color: "#0a0f14"
  1142. border.color: "#2c3e50"
  1143. border.width: 2
  1144. visible: builderProductionContent.builderProd.in_progress
  1145. Rectangle {
  1146. anchors.left: parent.left
  1147. anchors.verticalCenter: parent.verticalCenter
  1148. anchors.margins: 2
  1149. height: parent.height - 4
  1150. width: {
  1151. if (!builderProductionContent.builderProd.in_progress || builderProductionContent.builderProd.build_time <= 0)
  1152. return 0;
  1153. var progress = 1 - (Math.max(0, builderProductionContent.builderProd.time_remaining) / builderProductionContent.builderProd.build_time);
  1154. return Math.max(0, (parent.width - 4) * progress);
  1155. }
  1156. color: "#27ae60"
  1157. radius: 8
  1158. SequentialAnimation on opacity {
  1159. running: parent.width > 0
  1160. loops: Animation.Infinite
  1161. NumberAnimation {
  1162. from: 0.8
  1163. to: 1
  1164. duration: 600
  1165. }
  1166. NumberAnimation {
  1167. from: 1
  1168. to: 0.8
  1169. duration: 600
  1170. }
  1171. }
  1172. }
  1173. Text {
  1174. anchors.centerIn: parent
  1175. text: builderProductionContent.builderProd.in_progress ? Math.max(0, builderProductionContent.builderProd.time_remaining).toFixed(1) + "s" : "Idle"
  1176. color: "#ecf0f1"
  1177. font.pointSize: 9
  1178. font.bold: true
  1179. style: Text.Outline
  1180. styleColor: "#000000"
  1181. }
  1182. }
  1183. Text {
  1184. anchors.horizontalCenter: parent.horizontalCenter
  1185. text: builderProductionContent.builderProd.in_progress ? qsTr("Building: %1").arg(builderProductionContent.builderProd.product_type) : qsTr("Select an item to build")
  1186. color: builderProductionContent.builderProd.in_progress ? "#27ae60" : "#7f8c8d"
  1187. font.pointSize: 8
  1188. font.bold: builderProductionContent.builderProd.in_progress
  1189. visible: true
  1190. }
  1191. Grid {
  1192. anchors.horizontalCenter: parent.horizontalCenter
  1193. columns: 3
  1194. columnSpacing: 8
  1195. rowSpacing: 8
  1196. Rectangle {
  1197. property bool isEnabled: !builderProductionContent.builderProd.in_progress
  1198. property bool isHovered: builderCatapultMouseArea.containsMouse
  1199. width: 110
  1200. height: 80
  1201. radius: 6
  1202. color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
  1203. border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
  1204. border.width: isHovered && isEnabled ? 4 : 2
  1205. opacity: isEnabled ? 1 : 0.5
  1206. scale: isHovered && isEnabled ? 1.1 : 1
  1207. Image {
  1208. id: builderCatapultIcon
  1209. anchors.fill: parent
  1210. anchors.margins: 6
  1211. fillMode: Image.PreserveAspectCrop
  1212. smooth: true
  1213. source: productionPanel.unitIconSource("catapult")
  1214. visible: source !== ""
  1215. opacity: parent.isEnabled ? 1 : 0.35
  1216. }
  1217. Text {
  1218. anchors.centerIn: parent
  1219. visible: !builderCatapultIcon.visible
  1220. text: productionPanel.unitIconEmoji("catapult")
  1221. color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
  1222. font.pointSize: 36
  1223. opacity: parent.isEnabled ? 0.9 : 0.4
  1224. }
  1225. Text {
  1226. anchors.horizontalCenter: parent.horizontalCenter
  1227. anchors.bottom: parent.bottom
  1228. anchors.bottomMargin: 6
  1229. text: qsTr("Catapult")
  1230. color: parent.isEnabled ? "#bdc3c7" : "#5a5a5a"
  1231. font.pointSize: 8
  1232. font.bold: true
  1233. }
  1234. MouseArea {
  1235. id: builderCatapultMouseArea
  1236. anchors.fill: parent
  1237. hoverEnabled: true
  1238. onClicked: {
  1239. if (parent.isEnabled)
  1240. productionPanel.builderConstruction("catapult");
  1241. }
  1242. cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
  1243. ToolTip.visible: containsMouse
  1244. ToolTip.text: parent.isEnabled ? qsTr("Build Catapult\nLong-range siege weapon\nEffective against structures\nBuild time: 15s") : qsTr("Already building...")
  1245. ToolTip.delay: 300
  1246. }
  1247. Rectangle {
  1248. anchors.fill: parent
  1249. color: "#ffffff"
  1250. opacity: builderCatapultMouseArea.pressed ? 0.2 : 0
  1251. radius: parent.radius
  1252. }
  1253. Behavior on color {
  1254. ColorAnimation {
  1255. duration: 150
  1256. }
  1257. }
  1258. Behavior on border.color {
  1259. ColorAnimation {
  1260. duration: 150
  1261. }
  1262. }
  1263. Behavior on scale {
  1264. NumberAnimation {
  1265. duration: 100
  1266. }
  1267. }
  1268. }
  1269. Rectangle {
  1270. property bool isEnabled: !builderProductionContent.builderProd.in_progress
  1271. property bool isHovered: builderBallistaMouseArea.containsMouse
  1272. width: 110
  1273. height: 80
  1274. radius: 6
  1275. color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
  1276. border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
  1277. border.width: isHovered && isEnabled ? 4 : 2
  1278. opacity: isEnabled ? 1 : 0.5
  1279. scale: isHovered && isEnabled ? 1.1 : 1
  1280. Image {
  1281. id: builderBallistaIcon
  1282. anchors.fill: parent
  1283. anchors.margins: 6
  1284. fillMode: Image.PreserveAspectCrop
  1285. smooth: true
  1286. source: productionPanel.unitIconSource("ballista")
  1287. visible: source !== ""
  1288. opacity: parent.isEnabled ? 1 : 0.35
  1289. }
  1290. Text {
  1291. anchors.centerIn: parent
  1292. visible: !builderBallistaIcon.visible
  1293. text: productionPanel.unitIconEmoji("ballista")
  1294. color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
  1295. font.pointSize: 36
  1296. opacity: parent.isEnabled ? 0.9 : 0.4
  1297. }
  1298. Text {
  1299. anchors.horizontalCenter: parent.horizontalCenter
  1300. anchors.bottom: parent.bottom
  1301. anchors.bottomMargin: 6
  1302. text: qsTr("Ballista")
  1303. color: parent.isEnabled ? "#bdc3c7" : "#5a5a5a"
  1304. font.pointSize: 8
  1305. font.bold: true
  1306. }
  1307. MouseArea {
  1308. id: builderBallistaMouseArea
  1309. anchors.fill: parent
  1310. hoverEnabled: true
  1311. onClicked: {
  1312. if (parent.isEnabled)
  1313. productionPanel.builderConstruction("ballista");
  1314. }
  1315. cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
  1316. ToolTip.visible: containsMouse
  1317. ToolTip.text: parent.isEnabled ? qsTr("Build Ballista\nPrecision siege weapon\nEffective against units\nBuild time: 12s") : qsTr("Already building...")
  1318. ToolTip.delay: 300
  1319. }
  1320. Rectangle {
  1321. anchors.fill: parent
  1322. color: "#ffffff"
  1323. opacity: builderBallistaMouseArea.pressed ? 0.2 : 0
  1324. radius: parent.radius
  1325. }
  1326. Behavior on color {
  1327. ColorAnimation {
  1328. duration: 150
  1329. }
  1330. }
  1331. Behavior on border.color {
  1332. ColorAnimation {
  1333. duration: 150
  1334. }
  1335. }
  1336. Behavior on scale {
  1337. NumberAnimation {
  1338. duration: 100
  1339. }
  1340. }
  1341. }
  1342. Rectangle {
  1343. property bool isEnabled: !builderProductionContent.builderProd.in_progress
  1344. property bool isHovered: builderDefenseTowerMouseArea.containsMouse
  1345. width: 110
  1346. height: 80
  1347. radius: 6
  1348. color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
  1349. border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
  1350. border.width: isHovered && isEnabled ? 4 : 2
  1351. opacity: isEnabled ? 1 : 0.5
  1352. scale: isHovered && isEnabled ? 1.1 : 1
  1353. Image {
  1354. id: builderDefenseTowerIcon
  1355. anchors.fill: parent
  1356. anchors.margins: 6
  1357. fillMode: Image.PreserveAspectCrop
  1358. smooth: true
  1359. source: productionPanel.unitIconSource("defense_tower")
  1360. visible: source !== ""
  1361. opacity: parent.isEnabled ? 1 : 0.35
  1362. }
  1363. Text {
  1364. anchors.centerIn: parent
  1365. visible: !builderDefenseTowerIcon.visible
  1366. text: "🏰"
  1367. color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
  1368. font.pointSize: 36
  1369. opacity: parent.isEnabled ? 0.9 : 0.4
  1370. }
  1371. Text {
  1372. anchors.horizontalCenter: parent.horizontalCenter
  1373. anchors.bottom: parent.bottom
  1374. anchors.bottomMargin: 6
  1375. text: qsTr("Defense Tower")
  1376. color: parent.isEnabled ? "#bdc3c7" : "#5a5a5a"
  1377. font.pointSize: 8
  1378. font.bold: true
  1379. }
  1380. MouseArea {
  1381. id: builderDefenseTowerMouseArea
  1382. anchors.fill: parent
  1383. hoverEnabled: true
  1384. onClicked: {
  1385. if (parent.isEnabled)
  1386. productionPanel.builderConstruction("defense_tower");
  1387. }
  1388. cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
  1389. ToolTip.visible: containsMouse
  1390. ToolTip.text: parent.isEnabled ? qsTr("Build Defense Tower\nStationary defense structure\nShoots arrows at enemies\nBuild time: 20s") : qsTr("Already building...")
  1391. ToolTip.delay: 300
  1392. }
  1393. Rectangle {
  1394. anchors.fill: parent
  1395. color: "#ffffff"
  1396. opacity: builderDefenseTowerMouseArea.pressed ? 0.2 : 0
  1397. radius: parent.radius
  1398. }
  1399. Behavior on color {
  1400. ColorAnimation {
  1401. duration: 150
  1402. }
  1403. }
  1404. Behavior on border.color {
  1405. ColorAnimation {
  1406. duration: 150
  1407. }
  1408. }
  1409. Behavior on scale {
  1410. NumberAnimation {
  1411. duration: 100
  1412. }
  1413. }
  1414. }
  1415. Rectangle {
  1416. property bool isEnabled: !builderProductionContent.builderProd.in_progress
  1417. property bool isHovered: builderHomeMouseArea.containsMouse
  1418. width: 110
  1419. height: 80
  1420. radius: 6
  1421. color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
  1422. border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
  1423. border.width: isHovered && isEnabled ? 4 : 2
  1424. opacity: isEnabled ? 1 : 0.5
  1425. scale: isHovered && isEnabled ? 1.1 : 1
  1426. Image {
  1427. id: builderHomeIcon
  1428. anchors.fill: parent
  1429. anchors.margins: 6
  1430. fillMode: Image.PreserveAspectCrop
  1431. smooth: true
  1432. source: productionPanel.unitIconSource("home")
  1433. visible: source !== ""
  1434. opacity: parent.isEnabled ? 1 : 0.35
  1435. }
  1436. Text {
  1437. anchors.centerIn: parent
  1438. visible: !builderHomeIcon.visible
  1439. text: "🏠"
  1440. color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
  1441. font.pointSize: 36
  1442. opacity: parent.isEnabled ? 0.9 : 0.4
  1443. }
  1444. Text {
  1445. anchors.horizontalCenter: parent.horizontalCenter
  1446. anchors.bottom: parent.bottom
  1447. anchors.bottomMargin: 6
  1448. text: qsTr("Home")
  1449. color: parent.isEnabled ? "#bdc3c7" : "#5a5a5a"
  1450. font.pointSize: 8
  1451. font.bold: true
  1452. }
  1453. MouseArea {
  1454. id: builderHomeMouseArea
  1455. anchors.fill: parent
  1456. hoverEnabled: true
  1457. onClicked: {
  1458. if (parent.isEnabled)
  1459. productionPanel.builderConstruction("home");
  1460. }
  1461. cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
  1462. ToolTip.visible: containsMouse
  1463. ToolTip.text: parent.isEnabled ? qsTr("Build Home\nResidential building\nAdds +50 population to nearest barracks\nBuild time: 10s") : qsTr("Already building...")
  1464. ToolTip.delay: 300
  1465. }
  1466. Rectangle {
  1467. anchors.fill: parent
  1468. color: "#ffffff"
  1469. opacity: builderHomeMouseArea.pressed ? 0.2 : 0
  1470. radius: parent.radius
  1471. }
  1472. Behavior on color {
  1473. ColorAnimation {
  1474. duration: 150
  1475. }
  1476. }
  1477. Behavior on border.color {
  1478. ColorAnimation {
  1479. duration: 150
  1480. }
  1481. }
  1482. Behavior on scale {
  1483. NumberAnimation {
  1484. duration: 100
  1485. }
  1486. }
  1487. }
  1488. }
  1489. }
  1490. }
  1491. Item {
  1492. property bool has_barracks: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.has_selected_type && productionPanel.gameInstance.has_selected_type("barracks")))
  1493. property bool has_builder: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.has_selected_type && productionPanel.gameInstance.has_selected_type("builder")))
  1494. visible: !has_barracks && !has_builder
  1495. width: parent.width
  1496. height: 200
  1497. Column {
  1498. anchors.centerIn: parent
  1499. spacing: 8
  1500. Text {
  1501. anchors.horizontalCenter: parent.horizontalCenter
  1502. text: "🏰"
  1503. color: "#34495e"
  1504. font.pointSize: 32
  1505. }
  1506. Text {
  1507. anchors.horizontalCenter: parent.horizontalCenter
  1508. text: qsTr("No Barracks Selected")
  1509. color: "#7f8c8d"
  1510. font.pointSize: 11
  1511. font.bold: true
  1512. }
  1513. Text {
  1514. anchors.horizontalCenter: parent.horizontalCenter
  1515. text: qsTr("Select a barracks to recruit units")
  1516. color: "#5a6c7d"
  1517. font.pointSize: 9
  1518. }
  1519. }
  1520. }
  1521. }
  1522. }
  1523. }