| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898 |
- import QtQuick 2.15
- import QtQuick.Controls 2.15
- import QtQuick.Layouts 1.15
- import StandardOfIron 1.0
- Rectangle {
- id: productionPanel
- property int selectionTick: 0
- property var gameInstance: null
- signal recruitUnit(string unitType)
- signal rallyModeToggled()
- signal buildTower()
- signal builderConstruction(string itemType)
- function defaultProductionState() {
- return {
- "has_barracks": false,
- "produced_count": 0,
- "max_units": 0,
- "queue_size": 0,
- "in_progress": false,
- "production_queue": [],
- "product_type": "",
- "villager_cost": 1,
- "build_time": 0,
- "time_remaining": 0,
- "nation_id": ""
- };
- }
- function unitIconSource(unitType, nationKey) {
- if (typeof StyleGuide === "undefined" || !StyleGuide.unitIconSources || !unitType)
- return "";
- var sources = StyleGuide.unitIconSources[unitType];
- if (!sources)
- sources = StyleGuide.unitIconSources["default"];
- if (typeof sources === "object" && sources !== null) {
- if (nationKey && sources[nationKey])
- return sources[nationKey];
- if (sources["default"])
- return sources["default"];
- } else if (typeof sources === "string") {
- return sources;
- }
- return "";
- }
- function unitIconEmoji(unitType) {
- if (typeof StyleGuide !== "undefined" && StyleGuide.unitIcons)
- return StyleGuide.unitIcons[unitType] || StyleGuide.unitIcons["default"] || "👤";
- return "👤";
- }
- function getUnitProductionInfo(unitType, nationId) {
- if (productionPanel.gameInstance && productionPanel.gameInstance.get_unit_production_info)
- return productionPanel.gameInstance.get_unit_production_info(unitType, nationId || "");
- return {
- "cost": 50,
- "build_time": 5,
- "individuals_per_unit": 1,
- "display_name": unitType
- };
- }
- color: "#0f1419"
- border.color: "#3498db"
- border.width: 2
- radius: 6
- ScrollView {
- anchors.fill: parent
- anchors.margins: 10
- clip: true
- ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
- ScrollBar.vertical.policy: ScrollBar.AsNeeded
- Column {
- width: productionPanel.width - 20
- spacing: 8
- Rectangle {
- property bool has_barracks: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.has_selected_type && productionPanel.gameInstance.has_selected_type("barracks")))
- width: parent.width
- height: productionContent.height + 16
- color: "#1a252f"
- radius: 6
- border.color: "#34495e"
- border.width: 1
- visible: has_barracks
- Column {
- id: productionContent
- property var prod: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.get_selected_production_state) ? productionPanel.gameInstance.get_selected_production_state() : productionPanel.defaultProductionState())
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.top: parent.top
- anchors.margins: 8
- spacing: 10
- width: parent.width - 16
- Text {
- anchors.horizontalCenter: parent.horizontalCenter
- text: qsTr("PRODUCTION QUEUE")
- color: "#3498db"
- font.pointSize: 8
- font.bold: true
- }
- Row {
- anchors.horizontalCenter: parent.horizontalCenter
- spacing: 6
- Repeater {
- model: 5
- Rectangle {
- property int queueTotal: (productionContent.prod.in_progress ? 1 : 0) + (productionContent.prod.queue_size || 0)
- property bool isOccupied: index < queueTotal
- property bool isProducing: index === 0 && productionContent.prod.in_progress
- property string queueUnitType: {
- if (!isOccupied)
- return "";
- if (index === 0 && productionContent.prod.in_progress)
- return productionContent.prod.product_type || "archer";
- var queueIndex = productionContent.prod.in_progress ? index - 1 : index;
- if (productionContent.prod.production_queue && productionContent.prod.production_queue[queueIndex])
- return productionContent.prod.production_queue[queueIndex];
- return "archer";
- }
- width: 36
- height: 36
- radius: 6
- color: isProducing ? "#27ae60" : (isOccupied ? "#2c3e50" : "#1a1a1a")
- border.color: isProducing ? "#229954" : (isOccupied ? "#4a6572" : "#2a2a2a")
- border.width: 2
- Image {
- id: queueIconImage
- anchors.centerIn: parent
- width: 28
- height: 28
- fillMode: Image.PreserveAspectFit
- smooth: true
- source: parent.isOccupied ? productionPanel.unitIconSource(parent.queueUnitType, productionContent.prod.nation_id) : ""
- visible: parent.isOccupied && source !== ""
- }
- Text {
- anchors.centerIn: parent
- text: parent.isOccupied ? productionPanel.unitIconEmoji(parent.queueUnitType) : "·"
- color: parent.isProducing ? "#ffffff" : (parent.isOccupied ? "#bdc3c7" : "#3a3a3a")
- font.pointSize: parent.isOccupied ? 16 : 20
- font.bold: parent.isProducing
- visible: !queueIconImage.visible
- }
- Text {
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- anchors.margins: 2
- text: (index + 1).toString()
- color: parent.isOccupied ? "#7f8c8d" : "#2a2a2a"
- font.pointSize: 7
- font.bold: true
- }
- SequentialAnimation on opacity {
- running: isProducing
- loops: Animation.Infinite
- NumberAnimation {
- from: 0.7
- to: 1
- duration: 800
- }
- NumberAnimation {
- from: 1
- to: 0.7
- duration: 800
- }
- }
- }
- }
- }
- Text {
- property int queueTotal: (productionContent.prod.in_progress ? 1 : 0) + (productionContent.prod.queue_size || 0)
- anchors.horizontalCenter: parent.horizontalCenter
- text: queueTotal + " / 5"
- color: queueTotal >= 5 ? "#e74c3c" : "#bdc3c7"
- font.pointSize: 9
- font.bold: queueTotal >= 5
- }
- Rectangle {
- width: parent.width - 20
- height: 20
- anchors.horizontalCenter: parent.horizontalCenter
- radius: 10
- color: "#0a0f14"
- border.color: "#2c3e50"
- border.width: 2
- visible: productionContent.prod.in_progress
- Rectangle {
- anchors.left: parent.left
- anchors.verticalCenter: parent.verticalCenter
- anchors.margins: 2
- height: parent.height - 4
- width: {
- if (!productionContent.prod.in_progress || productionContent.prod.build_time <= 0)
- return 0;
- var progress = 1 - (Math.max(0, productionContent.prod.time_remaining) / productionContent.prod.build_time);
- return Math.max(0, (parent.width - 4) * progress);
- }
- color: "#27ae60"
- radius: 8
- SequentialAnimation on opacity {
- running: parent.width > 0
- loops: Animation.Infinite
- NumberAnimation {
- from: 0.8
- to: 1
- duration: 600
- }
- NumberAnimation {
- from: 1
- to: 0.8
- duration: 600
- }
- }
- }
- Text {
- anchors.centerIn: parent
- text: productionContent.prod.in_progress ? Math.max(0, productionContent.prod.time_remaining).toFixed(1) + "s" : "Idle"
- color: "#ecf0f1"
- font.pointSize: 9
- font.bold: true
- style: Text.Outline
- styleColor: "#000000"
- }
- }
- Text {
- anchors.horizontalCenter: parent.horizontalCenter
- text: qsTr("Units Produced: %1 / %2").arg(productionContent.prod.produced_count || 0).arg(productionContent.prod.max_units || 0)
- color: (productionContent.prod.produced_count >= productionContent.prod.max_units) ? "#e74c3c" : "#bdc3c7"
- font.pointSize: 8
- }
- }
- }
- Rectangle {
- property bool has_barracks: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.has_selected_type && productionPanel.gameInstance.has_selected_type("barracks")))
- width: parent.width
- height: unitGridContent.height + 16
- color: "#1a252f"
- radius: 6
- border.color: "#34495e"
- border.width: 1
- visible: has_barracks
- Column {
- id: unitGridContent
- property var prod: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.get_selected_production_state) ? productionPanel.gameInstance.get_selected_production_state() : productionPanel.defaultProductionState())
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.top: parent.top
- anchors.margins: 8
- spacing: 8
- Text {
- anchors.horizontalCenter: parent.horizontalCenter
- text: qsTr("RECRUIT UNITS")
- color: "#3498db"
- font.pointSize: 8
- font.bold: true
- }
- Grid {
- anchors.horizontalCenter: parent.horizontalCenter
- columns: 3
- columnSpacing: 8
- rowSpacing: 8
- Rectangle {
- property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
- property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
- property var unitInfo: productionPanel.getUnitProductionInfo("archer", unitGridContent.prod.nation_id)
- property bool isHovered: archerMouseArea.containsMouse
- width: 110
- height: 80
- radius: 6
- color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
- border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
- border.width: isHovered && isEnabled ? 4 : 2
- opacity: isEnabled ? 1 : 0.5
- scale: isHovered && isEnabled ? 1.1 : 1
- Image {
- id: archerRecruitIcon
- anchors.fill: parent
- fillMode: Image.PreserveAspectCrop
- smooth: true
- source: productionPanel.unitIconSource("archer", unitGridContent.prod.nation_id)
- visible: source !== ""
- opacity: parent.isEnabled ? 1 : 0.35
- }
- Text {
- anchors.centerIn: parent
- visible: !archerRecruitIcon.visible
- text: productionPanel.unitIconEmoji("archer")
- color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
- font.pointSize: 42
- opacity: parent.isEnabled ? 0.9 : 0.4
- }
- Rectangle {
- id: archerCostBadge
- width: archerCostText.implicitWidth + 12
- height: archerCostText.implicitHeight + 6
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 6
- radius: 8
- color: parent.isEnabled ? "#000000b3" : "#00000066"
- border.color: parent.isEnabled ? "#f39c12" : "#555555"
- border.width: 1
- Text {
- id: archerCostText
- anchors.centerIn: parent
- text: parent.parent.unitInfo.cost || 50
- color: archerCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
- font.pointSize: 16
- font.bold: true
- }
- }
- MouseArea {
- id: archerMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked: {
- if (parent.isEnabled)
- productionPanel.recruitUnit("archer");
- }
- cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
- ToolTip.visible: containsMouse
- 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")))
- ToolTip.delay: 300
- }
- Rectangle {
- anchors.fill: parent
- color: "#ffffff"
- opacity: archerMouseArea.pressed ? 0.2 : 0
- radius: parent.radius
- }
- Behavior on color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on border.color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on scale {
- NumberAnimation {
- duration: 100
- }
- }
- }
- Rectangle {
- property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
- property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
- property var unitInfo: productionPanel.getUnitProductionInfo("swordsman", unitGridContent.prod.nation_id)
- property bool isHovered: swordsmanMouseArea.containsMouse
- width: 110
- height: 80
- radius: 6
- color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
- border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
- border.width: isHovered && isEnabled ? 4 : 2
- opacity: isEnabled ? 1 : 0.5
- scale: isHovered && isEnabled ? 1.1 : 1
- Image {
- id: swordsmanRecruitIcon
- anchors.fill: parent
- fillMode: Image.PreserveAspectCrop
- smooth: true
- source: productionPanel.unitIconSource("swordsman", unitGridContent.prod.nation_id)
- visible: source !== ""
- opacity: parent.isEnabled ? 1 : 0.35
- }
- Text {
- anchors.centerIn: parent
- visible: !swordsmanRecruitIcon.visible
- text: productionPanel.unitIconEmoji("swordsman")
- color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
- font.pointSize: 42
- opacity: parent.isEnabled ? 0.9 : 0.4
- }
- Rectangle {
- id: swordsmanCostBadge
- width: swordsmanCostText.implicitWidth + 12
- height: swordsmanCostText.implicitHeight + 6
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 6
- radius: 8
- color: parent.isEnabled ? "#000000b3" : "#00000066"
- border.color: parent.isEnabled ? "#f39c12" : "#555555"
- border.width: 1
- Text {
- id: swordsmanCostText
- anchors.centerIn: parent
- text: parent.parent.unitInfo.cost || 90
- color: swordsmanCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
- font.pointSize: 16
- font.bold: true
- }
- }
- MouseArea {
- id: swordsmanMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked: {
- if (parent.isEnabled)
- productionPanel.recruitUnit("swordsman");
- }
- cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
- ToolTip.visible: containsMouse
- 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")))
- ToolTip.delay: 300
- }
- Rectangle {
- anchors.fill: parent
- color: "#ffffff"
- opacity: swordsmanMouseArea.pressed ? 0.2 : 0
- radius: parent.radius
- }
- Behavior on color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on border.color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on scale {
- NumberAnimation {
- duration: 100
- }
- }
- }
- Rectangle {
- property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
- property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
- property var unitInfo: productionPanel.getUnitProductionInfo("spearman", unitGridContent.prod.nation_id)
- property bool isHovered: spearmanMouseArea.containsMouse
- width: 110
- height: 80
- radius: 6
- color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
- border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
- border.width: isHovered && isEnabled ? 4 : 2
- opacity: isEnabled ? 1 : 0.5
- scale: isHovered && isEnabled ? 1.1 : 1
- Image {
- id: spearmanRecruitIcon
- anchors.fill: parent
- fillMode: Image.PreserveAspectCrop
- smooth: true
- source: productionPanel.unitIconSource("spearman", unitGridContent.prod.nation_id)
- visible: source !== ""
- opacity: parent.isEnabled ? 1 : 0.35
- }
- Text {
- anchors.centerIn: parent
- visible: !spearmanRecruitIcon.visible
- text: productionPanel.unitIconEmoji("spearman")
- color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
- font.pointSize: 42
- opacity: parent.isEnabled ? 0.9 : 0.4
- }
- Rectangle {
- id: spearmanCostBadge
- width: spearmanCostText.implicitWidth + 12
- height: spearmanCostText.implicitHeight + 6
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 6
- radius: 8
- color: parent.isEnabled ? "#000000b3" : "#00000066"
- border.color: parent.isEnabled ? "#f39c12" : "#555555"
- border.width: 1
- Text {
- id: spearmanCostText
- anchors.centerIn: parent
- text: parent.parent.unitInfo.cost || 75
- color: spearmanCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
- font.pointSize: 16
- font.bold: true
- }
- }
- MouseArea {
- id: spearmanMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked: {
- if (parent.isEnabled)
- productionPanel.recruitUnit("spearman");
- }
- cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
- ToolTip.visible: containsMouse
- 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")))
- ToolTip.delay: 300
- }
- Rectangle {
- anchors.fill: parent
- color: "#ffffff"
- opacity: spearmanMouseArea.pressed ? 0.2 : 0
- radius: parent.radius
- }
- Behavior on color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on border.color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on scale {
- NumberAnimation {
- duration: 100
- }
- }
- }
- Rectangle {
- property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
- property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
- property var unitInfo: productionPanel.getUnitProductionInfo("horse_swordsman", unitGridContent.prod.nation_id)
- property bool isHovered: horseKnightMouseArea.containsMouse
- width: 110
- height: 80
- radius: 6
- color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
- border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
- border.width: isHovered && isEnabled ? 4 : 2
- opacity: isEnabled ? 1 : 0.5
- scale: isHovered && isEnabled ? 1.1 : 1
- Image {
- id: horseKnightIcon
- anchors.fill: parent
- fillMode: Image.PreserveAspectCrop
- smooth: true
- source: productionPanel.unitIconSource("horse_swordsman", unitGridContent.prod.nation_id)
- visible: source !== ""
- opacity: parent.isEnabled ? 1 : 0.35
- }
- Text {
- anchors.centerIn: parent
- visible: !horseKnightIcon.visible
- text: productionPanel.unitIconEmoji("horse_swordsman")
- color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
- font.pointSize: 42
- opacity: parent.isEnabled ? 0.9 : 0.4
- }
- Rectangle {
- id: horseKnightCostBadge
- width: horseKnightCostText.implicitWidth + 12
- height: horseKnightCostText.implicitHeight + 6
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 6
- radius: 8
- color: parent.isEnabled ? "#000000b3" : "#00000066"
- border.color: parent.isEnabled ? "#f39c12" : "#555555"
- border.width: 1
- Text {
- id: horseKnightCostText
- anchors.centerIn: parent
- text: parent.parent.unitInfo.cost || 150
- color: horseKnightCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
- font.pointSize: 16
- font.bold: true
- }
- }
- MouseArea {
- id: horseKnightMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked: {
- if (parent.isEnabled)
- productionPanel.recruitUnit("horse_swordsman");
- }
- cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
- ToolTip.visible: containsMouse
- 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")))
- ToolTip.delay: 300
- }
- Rectangle {
- anchors.fill: parent
- color: "#ffffff"
- opacity: horseKnightMouseArea.pressed ? 0.2 : 0
- radius: parent.radius
- }
- Behavior on color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on border.color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on scale {
- NumberAnimation {
- duration: 100
- }
- }
- }
- Rectangle {
- property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
- property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
- property var unitInfo: productionPanel.getUnitProductionInfo("horse_archer", unitGridContent.prod.nation_id)
- property bool isHovered: horseArcherMouseArea.containsMouse
- width: 110
- height: 80
- radius: 6
- color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
- border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
- border.width: isHovered && isEnabled ? 4 : 2
- opacity: isEnabled ? 1 : 0.5
- scale: isHovered && isEnabled ? 1.1 : 1
- Image {
- id: horseArcherIcon
- anchors.fill: parent
- fillMode: Image.PreserveAspectCrop
- smooth: true
- source: productionPanel.unitIconSource("horse_archer", unitGridContent.prod.nation_id)
- visible: source !== ""
- opacity: parent.isEnabled ? 1 : 0.35
- }
- Text {
- anchors.centerIn: parent
- visible: !horseArcherIcon.visible
- text: productionPanel.unitIconEmoji("horse_archer")
- color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
- font.pointSize: 42
- opacity: parent.isEnabled ? 0.9 : 0.4
- }
- Rectangle {
- id: horseArcherCostBadge
- width: horseArcherCostText.implicitWidth + 12
- height: horseArcherCostText.implicitHeight + 6
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 6
- radius: 8
- color: parent.isEnabled ? "#000000b3" : "#00000066"
- border.color: parent.isEnabled ? "#f39c12" : "#555555"
- border.width: 1
- Text {
- id: horseArcherCostText
- anchors.centerIn: parent
- text: parent.parent.unitInfo.cost || 120
- color: horseArcherCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
- font.pointSize: 16
- font.bold: true
- }
- }
- MouseArea {
- id: horseArcherMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked: {
- if (parent.isEnabled)
- productionPanel.recruitUnit("horse_archer");
- }
- cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
- ToolTip.visible: containsMouse
- 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")))
- ToolTip.delay: 300
- }
- Rectangle {
- anchors.fill: parent
- color: "#ffffff"
- opacity: horseArcherMouseArea.pressed ? 0.2 : 0
- radius: parent.radius
- }
- Behavior on color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on border.color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on scale {
- NumberAnimation {
- duration: 100
- }
- }
- }
- Rectangle {
- property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
- property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
- property var unitInfo: productionPanel.getUnitProductionInfo("horse_spearman", unitGridContent.prod.nation_id)
- property bool isHovered: horseSpearmanMouseArea.containsMouse
- width: 110
- height: 80
- radius: 6
- color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
- border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
- border.width: isHovered && isEnabled ? 4 : 2
- opacity: isEnabled ? 1 : 0.5
- scale: isHovered && isEnabled ? 1.1 : 1
- Image {
- id: horseSpearmanIcon
- anchors.fill: parent
- fillMode: Image.PreserveAspectCrop
- smooth: true
- source: productionPanel.unitIconSource("horse_spearman", unitGridContent.prod.nation_id)
- visible: source !== ""
- opacity: parent.isEnabled ? 1 : 0.35
- }
- Text {
- anchors.centerIn: parent
- visible: !horseSpearmanIcon.visible
- text: productionPanel.unitIconEmoji("horse_spearman")
- color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
- font.pointSize: 42
- opacity: parent.isEnabled ? 0.9 : 0.4
- }
- Rectangle {
- id: horseSpearmanCostBadge
- width: horseSpearmanCostText.implicitWidth + 12
- height: horseSpearmanCostText.implicitHeight + 6
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 6
- radius: 8
- color: parent.isEnabled ? "#000000b3" : "#00000066"
- border.color: parent.isEnabled ? "#f39c12" : "#555555"
- border.width: 1
- Text {
- id: horseSpearmanCostText
- anchors.centerIn: parent
- text: parent.parent.unitInfo.cost || 130
- color: horseSpearmanCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
- font.pointSize: 16
- font.bold: true
- }
- }
- MouseArea {
- id: horseSpearmanMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked: {
- if (parent.isEnabled)
- productionPanel.recruitUnit("horse_spearman");
- }
- cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
- ToolTip.visible: containsMouse
- 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")))
- ToolTip.delay: 300
- }
- Rectangle {
- anchors.fill: parent
- color: "#ffffff"
- opacity: horseSpearmanMouseArea.pressed ? 0.2 : 0
- radius: parent.radius
- }
- Behavior on color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on border.color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on scale {
- NumberAnimation {
- duration: 100
- }
- }
- }
- Rectangle {
- property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
- property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
- property var unitInfo: productionPanel.getUnitProductionInfo("healer", unitGridContent.prod.nation_id)
- property bool isHovered: healerMouseArea.containsMouse
- width: 110
- height: 80
- radius: 6
- color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
- border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
- border.width: isHovered && isEnabled ? 4 : 2
- opacity: isEnabled ? 1 : 0.5
- scale: isHovered && isEnabled ? 1.1 : 1
- Image {
- id: healerRecruitIcon
- anchors.fill: parent
- fillMode: Image.PreserveAspectCrop
- smooth: true
- source: productionPanel.unitIconSource("healer", unitGridContent.prod.nation_id)
- visible: source !== ""
- opacity: parent.isEnabled ? 1 : 0.35
- }
- Text {
- anchors.centerIn: parent
- visible: !healerRecruitIcon.visible
- text: productionPanel.unitIconEmoji("healer")
- color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
- font.pointSize: 42
- opacity: parent.isEnabled ? 0.9 : 0.4
- }
- Rectangle {
- id: healerCostBadge
- width: healerCostText.implicitWidth + 12
- height: healerCostText.implicitHeight + 6
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 6
- radius: 8
- color: parent.isEnabled ? "#000000b3" : "#00000066"
- border.color: parent.isEnabled ? "#f39c12" : "#555555"
- border.width: 1
- Text {
- id: healerCostText
- anchors.centerIn: parent
- text: parent.parent.unitInfo.cost || 100
- color: healerCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
- font.pointSize: 16
- font.bold: true
- }
- }
- MouseArea {
- id: healerMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked: {
- if (parent.isEnabled)
- productionPanel.recruitUnit("healer");
- }
- cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
- ToolTip.visible: containsMouse
- 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")))
- ToolTip.delay: 300
- }
- Rectangle {
- anchors.fill: parent
- color: "#ffffff"
- opacity: healerMouseArea.pressed ? 0.2 : 0
- radius: parent.radius
- }
- Behavior on color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on border.color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on scale {
- NumberAnimation {
- duration: 100
- }
- }
- }
- Rectangle {
- property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
- property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
- property var unitInfo: productionPanel.getUnitProductionInfo("builder", unitGridContent.prod.nation_id)
- property bool isHovered: builderMouseArea.containsMouse
- width: 110
- height: 80
- radius: 6
- color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
- border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
- border.width: isHovered && isEnabled ? 4 : 2
- opacity: isEnabled ? 1 : 0.5
- scale: isHovered && isEnabled ? 1.1 : 1
- Image {
- id: builderRecruitIcon
- anchors.fill: parent
- fillMode: Image.PreserveAspectCrop
- smooth: true
- source: productionPanel.unitIconSource("builder", unitGridContent.prod.nation_id)
- visible: source !== ""
- opacity: parent.isEnabled ? 1 : 0.35
- }
- Text {
- anchors.centerIn: parent
- visible: !builderRecruitIcon.visible
- text: productionPanel.unitIconEmoji("builder")
- color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
- font.pointSize: 42
- opacity: parent.isEnabled ? 0.9 : 0.4
- }
- Rectangle {
- id: builderCostBadge
- width: builderCostText.implicitWidth + 12
- height: builderCostText.implicitHeight + 6
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 6
- radius: 8
- color: parent.isEnabled ? "#000000b3" : "#00000066"
- border.color: parent.isEnabled ? "#f39c12" : "#555555"
- border.width: 1
- Text {
- id: builderCostText
- anchors.centerIn: parent
- text: parent.parent.unitInfo.cost || 60
- color: builderCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
- font.pointSize: 16
- font.bold: true
- }
- }
- MouseArea {
- id: builderMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked: {
- if (parent.isEnabled)
- productionPanel.recruitUnit("builder");
- }
- cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
- ToolTip.visible: containsMouse
- 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")))
- ToolTip.delay: 300
- }
- Rectangle {
- anchors.fill: parent
- color: "#ffffff"
- opacity: builderMouseArea.pressed ? 0.2 : 0
- radius: parent.radius
- }
- Behavior on color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on border.color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on scale {
- NumberAnimation {
- duration: 100
- }
- }
- }
- Rectangle {
- property int queueTotal: (unitGridContent.prod.in_progress ? 1 : 0) + (unitGridContent.prod.queue_size || 0)
- property bool isEnabled: unitGridContent.prod.has_barracks && unitGridContent.prod.produced_count < unitGridContent.prod.max_units && queueTotal < 5
- property var unitInfo: productionPanel.getUnitProductionInfo("elephant", unitGridContent.prod.nation_id)
- property bool isHovered: elephantMouseArea.containsMouse
- width: 110
- height: 80
- radius: 6
- color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
- border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
- border.width: isHovered && isEnabled ? 4 : 2
- opacity: isEnabled ? 1 : 0.5
- scale: isHovered && isEnabled ? 1.1 : 1
- visible: unitGridContent.prod.nation_id === "carthage"
- Image {
- id: elephantRecruitIcon
- anchors.fill: parent
- fillMode: Image.PreserveAspectCrop
- smooth: true
- source: productionPanel.unitIconSource("elephant", unitGridContent.prod.nation_id)
- visible: source !== ""
- opacity: parent.isEnabled ? 1 : 0.35
- }
- Text {
- anchors.centerIn: parent
- visible: !elephantRecruitIcon.visible
- text: productionPanel.unitIconEmoji("elephant")
- color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
- font.pointSize: 42
- opacity: parent.isEnabled ? 0.9 : 0.4
- }
- Rectangle {
- id: elephantCostBadge
- width: elephantCostText.implicitWidth + 12
- height: elephantCostText.implicitHeight + 6
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 6
- radius: 8
- color: parent.isEnabled ? "#000000b3" : "#00000066"
- border.color: parent.isEnabled ? "#f39c12" : "#555555"
- border.width: 1
- Text {
- id: elephantCostText
- anchors.centerIn: parent
- text: parent.parent.unitInfo.cost || 250
- color: elephantCostBadge.parent.isEnabled ? "#fdf7e3" : "#8a8a8a"
- font.pointSize: 16
- font.bold: true
- }
- }
- MouseArea {
- id: elephantMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked: {
- if (parent.isEnabled)
- productionPanel.recruitUnit("elephant");
- }
- cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
- ToolTip.visible: containsMouse
- 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")))
- ToolTip.delay: 300
- }
- Rectangle {
- anchors.fill: parent
- color: "#ffffff"
- opacity: elephantMouseArea.pressed ? 0.2 : 0
- radius: parent.radius
- }
- Behavior on color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on border.color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on scale {
- NumberAnimation {
- duration: 100
- }
- }
- }
- }
- }
- }
- Rectangle {
- property bool has_barracks: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.has_selected_type && productionPanel.gameInstance.has_selected_type("barracks")))
- width: parent.width
- height: 1
- color: "#34495e"
- visible: has_barracks
- }
- Rectangle {
- property bool has_barracks: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.has_selected_type && productionPanel.gameInstance.has_selected_type("barracks")))
- width: parent.width
- height: rallyContent.height + 12
- color: "#1a252f"
- radius: 6
- border.color: "#34495e"
- border.width: 1
- visible: has_barracks
- Column {
- id: rallyContent
- property var prod: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.get_selected_production_state) ? productionPanel.gameInstance.get_selected_production_state() : productionPanel.defaultProductionState())
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.top: parent.top
- anchors.margins: 6
- spacing: 6
- Button {
- anchors.horizontalCenter: parent.horizontalCenter
- width: parent.parent.width - 20
- height: 32
- text: (typeof gameView !== 'undefined' && gameView.setRallyMode) ? qsTr("📍 Click Map to Set Rally") : qsTr("📍 Set Rally Point")
- focusPolicy: Qt.NoFocus
- enabled: rallyContent.prod.has_barracks
- onClicked: productionPanel.rallyModeToggled()
- ToolTip.visible: hovered
- ToolTip.text: qsTr("Set where newly recruited units will gather.\nRight-click to cancel.")
- ToolTip.delay: 500
- background: Rectangle {
- color: parent.enabled ? (parent.down ? "#16a085" : (parent.hovered ? "#1abc9c" : "#2c3e50")) : "#1a1a1a"
- radius: 6
- border.color: (typeof gameView !== 'undefined' && gameView.setRallyMode) ? "#1abc9c" : "#34495e"
- border.width: 2
- }
- contentItem: Text {
- text: parent.text
- font.pointSize: 9
- font.bold: true
- color: parent.enabled ? "#ecf0f1" : "#5a5a5a"
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
- }
- Text {
- anchors.horizontalCenter: parent.horizontalCenter
- text: (typeof gameView !== 'undefined' && gameView.setRallyMode) ? qsTr("Right-click to cancel") : ""
- color: "#7f8c8d"
- font.pointSize: 8
- font.italic: true
- }
- }
- }
- Item {
- property bool has_barracksSelected: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.has_selected_type && productionPanel.gameInstance.has_selected_type("barracks")))
- height: 20
- visible: !has_barracksSelected
- }
- Rectangle {
- property bool has_builder: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.has_selected_type && productionPanel.gameInstance.has_selected_type("builder")))
- width: parent.width
- height: builderProductionContent.height + 16
- color: "#1a252f"
- radius: 6
- border.color: "#34495e"
- border.width: 1
- visible: has_builder
- Column {
- id: builderProductionContent
- property var builderProd: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.get_selected_builder_production_state) ? productionPanel.gameInstance.get_selected_builder_production_state() : {
- "in_progress": false,
- "build_time": 10,
- "time_remaining": 0,
- "product_type": ""
- })
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.top: parent.top
- anchors.margins: 8
- spacing: 8
- width: parent.width - 16
- Row {
- anchors.horizontalCenter: parent.horizontalCenter
- spacing: 6
- Image {
- id: builderHeaderIcon
- width: 18
- height: 18
- source: productionPanel.unitIconSource("builder")
- fillMode: Image.PreserveAspectFit
- smooth: true
- visible: source !== ""
- }
- Text {
- anchors.verticalCenter: parent.verticalCenter
- text: builderHeaderIcon.visible ? qsTr("BUILDER CONSTRUCTION") : qsTr("🔨 BUILDER CONSTRUCTION")
- color: "#3498db"
- font.pointSize: 9
- font.bold: true
- }
- }
- Text {
- anchors.horizontalCenter: parent.horizontalCenter
- text: qsTr("Build siege weapons and structures")
- color: "#7f8c8d"
- font.pointSize: 7
- }
- Rectangle {
- width: parent.width - 20
- height: 20
- anchors.horizontalCenter: parent.horizontalCenter
- radius: 10
- color: "#0a0f14"
- border.color: "#2c3e50"
- border.width: 2
- visible: builderProductionContent.builderProd.in_progress
- Rectangle {
- anchors.left: parent.left
- anchors.verticalCenter: parent.verticalCenter
- anchors.margins: 2
- height: parent.height - 4
- width: {
- if (!builderProductionContent.builderProd.in_progress || builderProductionContent.builderProd.build_time <= 0)
- return 0;
- var progress = 1 - (Math.max(0, builderProductionContent.builderProd.time_remaining) / builderProductionContent.builderProd.build_time);
- return Math.max(0, (parent.width - 4) * progress);
- }
- color: "#27ae60"
- radius: 8
- SequentialAnimation on opacity {
- running: parent.width > 0
- loops: Animation.Infinite
- NumberAnimation {
- from: 0.8
- to: 1
- duration: 600
- }
- NumberAnimation {
- from: 1
- to: 0.8
- duration: 600
- }
- }
- }
- Text {
- anchors.centerIn: parent
- text: builderProductionContent.builderProd.in_progress ? Math.max(0, builderProductionContent.builderProd.time_remaining).toFixed(1) + "s" : "Idle"
- color: "#ecf0f1"
- font.pointSize: 9
- font.bold: true
- style: Text.Outline
- styleColor: "#000000"
- }
- }
- Text {
- anchors.horizontalCenter: parent.horizontalCenter
- text: builderProductionContent.builderProd.in_progress ? qsTr("Building: %1").arg(builderProductionContent.builderProd.product_type) : qsTr("Select an item to build")
- color: builderProductionContent.builderProd.in_progress ? "#27ae60" : "#7f8c8d"
- font.pointSize: 8
- font.bold: builderProductionContent.builderProd.in_progress
- visible: true
- }
- Grid {
- anchors.horizontalCenter: parent.horizontalCenter
- columns: 3
- columnSpacing: 8
- rowSpacing: 8
- Rectangle {
- property bool isEnabled: !builderProductionContent.builderProd.in_progress
- property bool isHovered: builderCatapultMouseArea.containsMouse
- width: 110
- height: 80
- radius: 6
- color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
- border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
- border.width: isHovered && isEnabled ? 4 : 2
- opacity: isEnabled ? 1 : 0.5
- scale: isHovered && isEnabled ? 1.1 : 1
- Image {
- id: builderCatapultIcon
- anchors.fill: parent
- anchors.margins: 6
- fillMode: Image.PreserveAspectCrop
- smooth: true
- source: productionPanel.unitIconSource("catapult")
- visible: source !== ""
- opacity: parent.isEnabled ? 1 : 0.35
- }
- Text {
- anchors.centerIn: parent
- visible: !builderCatapultIcon.visible
- text: productionPanel.unitIconEmoji("catapult")
- color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
- font.pointSize: 36
- opacity: parent.isEnabled ? 0.9 : 0.4
- }
- Text {
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 6
- text: qsTr("Catapult")
- color: parent.isEnabled ? "#bdc3c7" : "#5a5a5a"
- font.pointSize: 8
- font.bold: true
- }
- MouseArea {
- id: builderCatapultMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked: {
- if (parent.isEnabled)
- productionPanel.builderConstruction("catapult");
- }
- cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
- ToolTip.visible: containsMouse
- ToolTip.text: parent.isEnabled ? qsTr("Build Catapult\nLong-range siege weapon\nEffective against structures\nBuild time: 15s") : qsTr("Already building...")
- ToolTip.delay: 300
- }
- Rectangle {
- anchors.fill: parent
- color: "#ffffff"
- opacity: builderCatapultMouseArea.pressed ? 0.2 : 0
- radius: parent.radius
- }
- Behavior on color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on border.color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on scale {
- NumberAnimation {
- duration: 100
- }
- }
- }
- Rectangle {
- property bool isEnabled: !builderProductionContent.builderProd.in_progress
- property bool isHovered: builderBallistaMouseArea.containsMouse
- width: 110
- height: 80
- radius: 6
- color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
- border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
- border.width: isHovered && isEnabled ? 4 : 2
- opacity: isEnabled ? 1 : 0.5
- scale: isHovered && isEnabled ? 1.1 : 1
- Image {
- id: builderBallistaIcon
- anchors.fill: parent
- anchors.margins: 6
- fillMode: Image.PreserveAspectCrop
- smooth: true
- source: productionPanel.unitIconSource("ballista")
- visible: source !== ""
- opacity: parent.isEnabled ? 1 : 0.35
- }
- Text {
- anchors.centerIn: parent
- visible: !builderBallistaIcon.visible
- text: productionPanel.unitIconEmoji("ballista")
- color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
- font.pointSize: 36
- opacity: parent.isEnabled ? 0.9 : 0.4
- }
- Text {
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 6
- text: qsTr("Ballista")
- color: parent.isEnabled ? "#bdc3c7" : "#5a5a5a"
- font.pointSize: 8
- font.bold: true
- }
- MouseArea {
- id: builderBallistaMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked: {
- if (parent.isEnabled)
- productionPanel.builderConstruction("ballista");
- }
- cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
- ToolTip.visible: containsMouse
- ToolTip.text: parent.isEnabled ? qsTr("Build Ballista\nPrecision siege weapon\nEffective against units\nBuild time: 12s") : qsTr("Already building...")
- ToolTip.delay: 300
- }
- Rectangle {
- anchors.fill: parent
- color: "#ffffff"
- opacity: builderBallistaMouseArea.pressed ? 0.2 : 0
- radius: parent.radius
- }
- Behavior on color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on border.color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on scale {
- NumberAnimation {
- duration: 100
- }
- }
- }
- Rectangle {
- property bool isEnabled: !builderProductionContent.builderProd.in_progress
- property bool isHovered: builderDefenseTowerMouseArea.containsMouse
- width: 110
- height: 80
- radius: 6
- color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
- border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
- border.width: isHovered && isEnabled ? 4 : 2
- opacity: isEnabled ? 1 : 0.5
- scale: isHovered && isEnabled ? 1.1 : 1
- Image {
- id: builderDefenseTowerIcon
- anchors.fill: parent
- anchors.margins: 6
- fillMode: Image.PreserveAspectCrop
- smooth: true
- source: productionPanel.unitIconSource("defense_tower")
- visible: source !== ""
- opacity: parent.isEnabled ? 1 : 0.35
- }
- Text {
- anchors.centerIn: parent
- visible: !builderDefenseTowerIcon.visible
- text: "🏰"
- color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
- font.pointSize: 36
- opacity: parent.isEnabled ? 0.9 : 0.4
- }
- Text {
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 6
- text: qsTr("Defense Tower")
- color: parent.isEnabled ? "#bdc3c7" : "#5a5a5a"
- font.pointSize: 8
- font.bold: true
- }
- MouseArea {
- id: builderDefenseTowerMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked: {
- if (parent.isEnabled)
- productionPanel.builderConstruction("defense_tower");
- }
- cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
- ToolTip.visible: containsMouse
- ToolTip.text: parent.isEnabled ? qsTr("Build Defense Tower\nStationary defense structure\nShoots arrows at enemies\nBuild time: 20s") : qsTr("Already building...")
- ToolTip.delay: 300
- }
- Rectangle {
- anchors.fill: parent
- color: "#ffffff"
- opacity: builderDefenseTowerMouseArea.pressed ? 0.2 : 0
- radius: parent.radius
- }
- Behavior on color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on border.color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on scale {
- NumberAnimation {
- duration: 100
- }
- }
- }
- Rectangle {
- property bool isEnabled: !builderProductionContent.builderProd.in_progress
- property bool isHovered: builderHomeMouseArea.containsMouse
- width: 110
- height: 80
- radius: 6
- color: isEnabled ? (isHovered ? "#1f8dd9" : "#2c3e50") : "#1a1a1a"
- border.color: isEnabled ? (isHovered ? "#00d4ff" : "#4a6572") : "#2a2a2a"
- border.width: isHovered && isEnabled ? 4 : 2
- opacity: isEnabled ? 1 : 0.5
- scale: isHovered && isEnabled ? 1.1 : 1
- Image {
- id: builderHomeIcon
- anchors.fill: parent
- anchors.margins: 6
- fillMode: Image.PreserveAspectCrop
- smooth: true
- source: productionPanel.unitIconSource("home")
- visible: source !== ""
- opacity: parent.isEnabled ? 1 : 0.35
- }
- Text {
- anchors.centerIn: parent
- visible: !builderHomeIcon.visible
- text: "🏠"
- color: parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
- font.pointSize: 36
- opacity: parent.isEnabled ? 0.9 : 0.4
- }
- Text {
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 6
- text: qsTr("Home")
- color: parent.isEnabled ? "#bdc3c7" : "#5a5a5a"
- font.pointSize: 8
- font.bold: true
- }
- MouseArea {
- id: builderHomeMouseArea
- anchors.fill: parent
- hoverEnabled: true
- onClicked: {
- if (parent.isEnabled)
- productionPanel.builderConstruction("home");
- }
- cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
- ToolTip.visible: containsMouse
- ToolTip.text: parent.isEnabled ? qsTr("Build Home\nResidential building\nAdds +50 population to nearest barracks\nBuild time: 10s") : qsTr("Already building...")
- ToolTip.delay: 300
- }
- Rectangle {
- anchors.fill: parent
- color: "#ffffff"
- opacity: builderHomeMouseArea.pressed ? 0.2 : 0
- radius: parent.radius
- }
- Behavior on color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on border.color {
- ColorAnimation {
- duration: 150
- }
- }
- Behavior on scale {
- NumberAnimation {
- duration: 100
- }
- }
- }
- }
- }
- }
- Item {
- property bool has_barracks: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.has_selected_type && productionPanel.gameInstance.has_selected_type("barracks")))
- property bool has_builder: (productionPanel.selectionTick, (productionPanel.gameInstance && productionPanel.gameInstance.has_selected_type && productionPanel.gameInstance.has_selected_type("builder")))
- visible: !has_barracks && !has_builder
- width: parent.width
- height: 200
- Column {
- anchors.centerIn: parent
- spacing: 8
- Text {
- anchors.horizontalCenter: parent.horizontalCenter
- text: "🏰"
- color: "#34495e"
- font.pointSize: 32
- }
- Text {
- anchors.horizontalCenter: parent.horizontalCenter
- text: qsTr("No Barracks Selected")
- color: "#7f8c8d"
- font.pointSize: 11
- font.bold: true
- }
- Text {
- anchors.horizontalCenter: parent.horizontalCenter
- text: qsTr("Select a barracks to recruit units")
- color: "#5a6c7d"
- font.pointSize: 9
- }
- }
- }
- }
- }
- }
|