Ticket #619: gate-multiselect.patch
File gate-multiselect.patch, 5.5 KB (added by , 12 years ago) |
---|
-
binaries/data/mods/public/gui/session/unit_commands.js
209 209 break; 210 210 211 211 case GATE: 212 if(numberOfItems > 2)213 numberOfItems = 2;212 if(numberOfItems > 8) 213 numberOfItems = 8; 214 214 break; 215 215 216 216 default: … … 513 513 // If already a gate, show locking actions 514 514 if (unitEntState.gate) 515 515 { 516 gateIcon = " lock_" + GATE_ACTIONS[i].toLowerCase() + "ed.png";516 gateIcon = "icons/lock_" + GATE_ACTIONS[i].toLowerCase() + "ed.png"; 517 517 selection.hidden = unitEntState.gate.locked != item.locked; 518 518 } 519 519 // otherwise show gate upgrade icon 520 520 else 521 521 { 522 gateIcon = "gate_closed.png"; 522 template = GetTemplateData(item.template); 523 gateIcon = template.icon ? "portraits/" + template.icon : "icons/gate_closed.png"; 523 524 selection.hidden = true; 524 525 } 525 526 526 icon.sprite = "stretched:session/ icons/" + gateIcon;527 icon.sprite = "stretched:session/" + gateIcon; 527 528 } 528 529 else if (template.icon) 529 530 { … … 806 807 removeDupes(buildableEnts); 807 808 removeDupes(trainableEnts); 808 809 810 // Whether the GUI's right panel has been filled. 811 var rightUsed = true; 812 809 813 // The first selected entity's type has priority. 810 814 if (entState.buildEntities) 811 815 setupUnitPanel(CONSTRUCTION, usedPanels, entState, buildableEnts, startBuildingPlacement); … … 814 818 function (trainEntType) { addTrainingToQueue(selection, trainEntType); } ); 815 819 else if (entState.trader) 816 820 setupUnitTradingPanel(usedPanels, entState, selection); 821 else if (entState.gate) 822 { 823 var items = []; 824 for (var i = 0; i < GATE_ACTIONS.length; ++i) 825 items.push({ 826 "tooltip": GATE_ACTIONS[i] + " gate", 827 "locked": i == 0 828 }); 829 setupUnitPanel(GATE, usedPanels, entState, items, 830 function (item) { lockGate(item.locked); } ); 831 } 832 else if (!entState.foundation && (hasClass(entState, "LongWall"))) 833 { 834 // Allow long wall pieces to be converted to gates 835 var longWallTypes = {}; 836 var items = []; 837 for (var i in selection) 838 { 839 if ((state = GetEntityState(selection[i])) && hasClass(state, "LongWall") && 840 !state.gate && !state.foundation && !longWallTypes[state.template]) 841 { 842 var gateTemplate = getWallGateTemplate(state.id); 843 if (gateTemplate) 844 { 845 var wallName = GetTemplateData(state.template).name.generic; 846 var gateName = GetTemplateData(gateTemplate).name.generic; 847 848 items.push({ 849 "tooltip": "Convert " + wallName + " to " + gateName, 850 "template": gateTemplate 851 }); 852 } 853 854 // We only need one entity per type. 855 longWallTypes[state.template] = true; 856 } 857 } 858 859 if (items.length) 860 setupUnitPanel(GATE, usedPanels, entState, items, 861 function (item) { transformWallToGate(item.template); } ); 862 else 863 rightUsed = false; 864 } 817 865 else 866 rightUsed = false; 867 868 if (!rightUsed) 818 869 { 819 870 // The right pane is empty. Fill the pane with a sane type. 820 871 // Prefer buildables for units and trainables for structures. … … 838 889 setupUnitPanel(QUEUE, usedPanels, entState, entState.production.queue, 839 890 function (item) { removeFromProductionQueue(entState.id, item.id); } ); 840 891 841 if(!entState.foundation && (entState.gate || hasClass(entState, "LongWall")))842 {843 if (entState.gate)844 {845 var items = [];846 for (var i = 0; i < GATE_ACTIONS.length; ++i)847 items.push({848 "tooltip": GATE_ACTIONS[i] + " gate",849 "locked": i == 0850 });851 setupUnitPanel(GATE, usedPanels, entState, items,852 function (item) { lockGate(item.locked); } );853 }854 else855 {856 // Allow long wall pieces to be converted to gates857 // TODO: find the gate template name in a better way858 // TODO: selections of multiple different types of walls (breaks currently)859 var longPos = entState.template.indexOf("long");860 if (longPos != -1)861 {862 var action = {863 "tooltip": "Convert to gate",864 "template": entState.template.substr(0, longPos) + "gate"865 };866 setupUnitPanel(GATE, usedPanels, entState, [action],867 function (item) { transformWallToGate(action.template); } );868 }869 }870 }871 872 892 supplementalDetailsPanel.hidden = false; 873 893 commandsPanel.hidden = false; 874 894 } -
binaries/data/mods/public/gui/session/input.js
1643 1643 var selection = g_Selection.toList(); 1644 1644 Engine.PostNetworkCommand({ 1645 1645 "type": "wall-to-gate", 1646 "entities": selection ,1646 "entities": selection.filter( function(e) { return getWallGateTemplate(e) == template } ), 1647 1647 "template": template, 1648 1648 }); 1649 1649 } 1650 1650 1651 // Gets the gate form (if any) of a given entity. 1652 function getWallGateTemplate(entity) 1653 { 1654 // TODO: find the gate template name in a better way 1655 var entState = GetEntityState(entity); 1656 var index; 1657 1658 if (entState && !entState.foundation && hasClass(entState, "LongWall") && (index = entState.template.indexOf("long")) >= 0) 1659 return entState.template.substr(0, index) + "gate"; 1660 return undefined; 1661 } 1662 1651 1663 // Set the camera to follow the given unit 1652 1664 function setCameraFollow(entity) 1653 1665 {