Ticket #1571: redIcons.patch
File redIcons.patch, 7.1 KB (added by , 12 years ago) |
---|
-
binaries/data/mods/public/simulation/components/GuiInterface.js
567 567 return ret; 568 568 } 569 569 570 // Used to show a red square over GUI elements you can't yet afford. 571 GuiInterface.prototype.GetNeededResources = function(player, amounts){ 572 var cmpPlayer = QueryPlayerIDInterface(player, IID_Player); 573 return cmpPlayer.GetNeededResources(amounts); 574 }; 575 576 570 577 GuiInterface.prototype.PushNotification = function(notification) 571 578 { 572 579 this.notifications.push(notification); … … 1611 1618 "IsTechnologyResearched": 1, 1612 1619 "CheckTechnologyRequirements": 1, 1613 1620 "GetStartedResearch": 1, 1621 "GetNeededResources": 1, 1614 1622 "GetNextNotification": 1, 1615 1623 1616 1624 "GetAvailableFormations": 1, -
binaries/data/mods/public/simulation/components/Player.js
157 157 this.resourceCount[type] += (+amounts[type]); 158 158 } 159 159 }; 160 161 Player.prototype.TrySubtractResources = function(amounts) 160 Player.prototype.GetNeededResources = function(amounts) 162 161 { 163 162 // Check if we can afford it all 164 163 var amountsNeeded = {}; … … 169 168 var formattedAmountsNeeded = []; 170 169 for (var type in amountsNeeded) 171 170 formattedAmountsNeeded.push(type + ": " + amountsNeeded[type]); 171 return formattedAmountsNeeded; 172 }; 173 174 Player.prototype.TrySubtractResources = function(amounts) 175 { 176 var formattedAmountsNeeded = this.GetNeededResources(amounts); 172 177 173 178 // If we don't have enough resources, send a notification to the player 174 179 if (formattedAmountsNeeded.length) -
binaries/data/mods/public/gui/session/session.xml
802 802 <repeat count="24"> 803 803 <object name="unitConstructionButton[n]" hidden="true" style="iconButton" type="button" size="0 0 46 46" tooltip_style="sessionToolTipBottom"> 804 804 <object name="unitConstructionIcon[n]" type="image" ghost="true" size="3 3 43 43"/> 805 <object name="unitConstructionUnaffordable[n]" hidden="true" type="image" ghost="true" size="3 3 43 43" sprite="colour: 255 0 0 127"/> 805 806 </object> 806 807 </repeat> 807 808 </object> … … 815 816 <object name="unitResearchButton[n]" hidden="true" style="iconButton" type="button" size="0 0 46 46" tooltip_style="sessionToolTipBottom"> 816 817 <object name="unitResearchIcon[n]" type="image" ghost="true" size="3 3 43 43"/> 817 818 <object name="unitResearchSelection[n]" hidden="true" type="image" ghost="true" size="3 3 43 43" sprite="colour: 255 0 0 127"/> 819 <object name="unitResearchUnaffordable[n]" hidden="true" type="image" ghost="true" size="3 3 43 43" sprite="colour: 255 0 0 60"/> 818 820 </object> 819 821 </repeat> 820 822 <repeat count="8"> … … 832 834 <repeat count="24"> 833 835 <object name="unitTrainingButton[n]" hidden="true" style="iconButton" type="button" size="0 0 46 46" tooltip_style="sessionToolTipBottom"> 834 836 <object name="unitTrainingIcon[n]" type="image" ghost="true" size="3 3 43 43"/> 837 <object name="unitTrainingUnaffordable[n]" hidden="true" type="image" ghost="true" size="3 3 43 43" sprite="colour: 255 0 0 127"/> 835 838 </object> 836 839 </repeat> 837 840 </object> -
binaries/data/mods/public/gui/session/unit_commands.js
419 419 var icon = getGUIObjectByName("unit"+guiName+"Icon["+i+"]"); 420 420 var selection = getGUIObjectByName("unit"+guiName+"Selection["+i+"]"); 421 421 var pair = getGUIObjectByName("unit"+guiName+"Pair["+i+"]"); 422 var affordableMask = getGUIObjectByName("unit"+guiName+"Unaffordable["+i+"]"); 423 var affordableMask1 = getGUIObjectByName("unit"+guiName+"Unaffordable["+(i+rowLength)+"]"); 424 422 425 button.hidden = false; 423 426 button.tooltip = tooltip; 424 427 … … 569 572 { 570 573 pair.hidden = true; 571 574 button1.hidden = true; 575 affordableMask1.hidden = true; 572 576 } 573 577 } 578 if (guiName == RESEARCH) 579 { 580 affordableMask.hidden = true; 581 var totalCosts = {}; 582 583 for each (var r in ["food", "wood", "stone", "metal"]) 584 totalCosts[r] = Math.floor(template.cost[r]); 585 586 var neededResources = Engine.GuiInterfaceCall("GetNeededResources", totalCosts); 587 if(neededResources.length) 588 { 589 if(button.enabled != false) 590 { 591 button.enabled = false; 592 affordableMask.hidden = false; 593 } 594 button.tooltip += "\n\n[font=\"serif-bold-13\"]Insufficient resources:[/font]\n"+neededResources.join(", "); 595 } 596 if (item.pair) 597 { 598 affordableMask1.hidden = true; 599 totalCosts = {}; 600 601 for each (var r in ["food", "wood", "stone", "metal"]) 602 totalCosts[r] = Math.floor(template1.cost[r]); 603 604 neededResources = Engine.GuiInterfaceCall("GetNeededResources", totalCosts); 605 if(neededResources.length) 606 { 607 if(button1.enabled != false) 608 { 609 button1.enabled = false; 610 affordableMask1.hidden = false; 611 } 612 button1.tooltip += "\n\n[font=\"serif-bold-13\"]Insufficient resources:[/font]\n"+neededResources.join(", "); 613 } 614 } 615 } 616 617 if(guiName == CONSTRUCTION || guiName == TRAINING) 618 { 619 affordableMask.hidden = true; 620 var totalCosts = {}; 621 var totalCost = 0; 622 var trainNum = 1; 623 if (Engine.HotkeyIsPressed("session.batchtrain") && guiName == TRAINING) 624 { 625 var [batchSize, batchIncrement] = getTrainingBatchStatus(unitEntState.id, entType); 626 trainNum = batchSize + batchIncrement; 627 } 628 for each (var r in ["food", "wood", "stone", "metal"]) 629 { 630 // looks like walls can be this case. 631 if (template.cost !== undefined) 632 { 633 totalCosts[r] = Math.floor(template.cost[r]*trainNum); 634 totalCost += totalCosts[r]; 635 } 636 } 637 var neededResources = Engine.GuiInterfaceCall("GetNeededResources", totalCosts); 638 if(neededResources.length) 639 { 640 if(button.enabled != false) 641 { 642 button.enabled = false; 643 affordableMask.hidden = false; 644 var alpha = 100 + totalCost/6; 645 if (alpha > 175) 646 alpha = 175; 647 affordableMask.sprite = "colour: 255 0 0 " + (alpha); 648 } 649 button.tooltip += "\n\n[font=\"serif-bold-13\"]Insufficient resources:[/font]\n"+neededResources.join(", "); 650 } 651 } 652 574 653 } 575 654 else 576 655 { … … 647 726 getGUIObjectByName("unit"+guiName+"Pair["+i+"]").hidden = true; 648 727 } 649 728 } 650 651 729 g_unitPanelButtons[guiName] = numButtons; 652 730 } 653 731