Ticket #1492: hotkeys6.patch
File hotkeys6.patch, 40.0 KB (added by , 12 years ago) |
---|
-
binaries/data/config/default.cfg
commit 8667be2fa976064e67569141734d319c8401d385 Author: Roel Kluin <roel.kluin@gmail.com> Date: Thu Jun 14 00:54:35 2012 +0200 This implements the V, B, N and M hotkeys for Stance, Formation, garrison, ungarrison respectively Signed-off-by: Roel Kluin <roel.kluin@gmail.com> diff --git a/binaries/data/config/default.cfg b/binaries/data/config/default.cfg index 5015b15..9e7c9aa 100644
a b hotkey.selection.group.action.10 = "Ctrl+K" 203 203 hotkey.selection.group.action.11 = "Ctrl+L" 204 204 hotkey.selection.group.action.12 = "Ctrl+Semicolon" 205 205 hotkey.selection.group.action.13 = "Ctrl+SingleQuote" 206 hotkey.selection.group.action.reset = ForwardSlash 206 hotkey.selection.group.reset.0 = ForwardSlash 207 hotkey.selection.group.stance.0 = V 208 hotkey.selection.group.formation.0 = B 209 hotkey.selection.group.garrison.0 = N 210 hotkey.selection.group.ungarrison.0 = M 207 211 208 212 ; > SESSION CONTROLS 209 213 hotkey.session.kill = Delete ; Destroy selected units -
binaries/data/mods/public/gui/session/input.js
diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js index adb7bb5..743bdf8 100644
a b const INPUT_BATCHTRAINING = 6; 35 35 const INPUT_PRESELECTEDACTION = 7; 36 36 const INPUT_BUILDING_WALL_CLICK = 8; 37 37 const INPUT_BUILDING_WALL_PATHING = 9; 38 const INPUT_ACTION_STATE = 10; 38 39 39 40 var inputState = INPUT_NORMAL; 40 41 var placementSupport = new PlacementSupport(); … … function handleInputAfterGui(ev) 1028 1029 switch (inputState) 1029 1030 { 1030 1031 case INPUT_NORMAL: 1032 case INPUT_ACTION_STATE: 1031 1033 switch (ev.type) 1032 1034 { 1033 1035 case "mousemotion": … … function performCommand(entity, commandName) 1538 1540 openDeleteDialog(selection); 1539 1541 break; 1540 1542 case "garrison": 1541 inputState = INPUT_ PRESELECTEDACTION;1543 inputState = INPUT_SELECTING; 1542 1544 preSelectedAction = ACTION_GARRISON; 1543 1545 break; 1544 1546 case "repair": 1545 inputState = INPUT_ PRESELECTEDACTION;1547 inputState = INPUT_SELECTING; 1546 1548 preSelectedAction = ACTION_BUILD; 1547 1549 break; 1548 1550 case "unload-all": … … function handleHotkey(ev) 1593 1595 { 1594 1596 var sptr = ev.hotkey.split("."); 1595 1597 var now = new Date(); 1596 if ( inputState = INPUT_NORMAL&& (ev.hotkey == prevHotkey) &&1598 if ((inputState == INPUT_NORMAL) && (ev.hotkey == prevHotkey) && 1597 1599 ev.hotkey.indexOf("selection.group.select.") == 0 && 1598 1600 (now.getTime() - doublePressTimer < doublePressTime)) { 1599 1601 performGroup("snap", sptr[3]); … … function handleHotkey(ev) 1608 1610 } 1609 1611 1610 1612 // Performs the specified group 1611 function performGroup(action, nr)1613 function performGroup(action, x) 1612 1614 { 1613 if (nr == "reset")1614 {1615 resetPreselectedAction();1616 return;1617 }1618 1615 switch (action) 1619 1616 { 1620 1617 case "snap": … … function performGroup(action, nr) 1622 1619 case "add": 1623 1620 var toSelect = []; 1624 1621 g_Groups.update(); 1625 for (var ent in g_Groups.groups[ nr].ents)1622 for (var ent in g_Groups.groups[x].ents) 1626 1623 toSelect.push(+ent); 1627 1624 1628 1625 if (action != "add") … … function performGroup(action, nr) 1632 1629 1633 1630 if (action == "snap" && toSelect.length) 1634 1631 Engine.CameraFollow(toSelect[0]); 1635 break;1632 return; 1636 1633 case "save": 1637 1634 var selection = g_Selection.toList(); 1638 g_Groups.groups[ nr].reset();1639 g_Groups.addEntities( nr, selection);1635 g_Groups.groups[x].reset(); 1636 g_Groups.addEntities(x, selection); 1640 1637 updateGroups(); 1641 break;1638 return; 1642 1639 case "action": 1643 1640 var selection = g_Selection.toList(); 1644 1641 var player = Engine.GetPlayerID(); 1642 if (inputState != INPUT_ACTION_STATE) 1643 preSelectedAction = getDefaultActionForSelection(player, selection); 1644 break; 1645 case "reset": 1646 resetPreselectedAction(); 1647 return; 1648 case "garrison": 1649 preSelectedAction = ACTION_GARRISON; 1650 inputState = INPUT_PRESELECTEDACTION; 1651 return; 1652 case "ungarrison": 1653 preSelectedAction = ACTION_UNGARRISON; 1654 inputState = INPUT_ACTION_STATE; 1655 return; 1656 case "stance": 1657 preSelectedAction = ACTION_STANCE; 1658 inputState = INPUT_ACTION_STATE; 1659 return; 1660 case "formation": 1661 preSelectedAction = ACTION_FORMATION; 1662 inputState = INPUT_ACTION_STATE; 1663 return; 1664 } 1665 if (inputState == INPUT_ACTION_STATE) 1666 inputState = INPUT_NORMAL; 1667 if (preSelectedAction == ACTION_NONE) 1668 return; 1645 1669 1646 preSelectedAction = getDefaultActionForSelection(player, selection);1647 if (preSelectedAction == ACTION_NONE)1648 break;1670 var lst = selectAction(player, selection); 1671 if (!lst) // shouldn't happen 1672 return; 1649 1673 1650 var lst = selectAction(player, selection); 1651 if (!lst) // shouldn't happen 1652 break; 1674 if (preSelectedAction & ACTION_GARRISON) 1675 { 1676 if (++x > lst.length) 1677 x = lst.length; 1678 } else if (preSelectedAction != ACTION_UNGARRISON) { 1679 if (x >= lst.length) 1680 return; 1681 lst = lst[x]; 1682 } 1653 1683 1654 if (preSelectedAction & ACTION_GARRISON) 1655 { 1656 if (++nr > lst.length) 1657 nr = lst.length; 1658 } else if (preSelectedAction != ACTION_UNGARRISON) { 1659 if (nr >= lst.length) 1660 break; 1661 lst = lst[nr]; 1684 switch (preSelectedAction) 1685 { 1686 case ACTION_BUILD: 1687 var tmpl = GetTemplateData(lst); 1688 if (!tmpl.requiredTechnology || Engine.GuiInterfaceCall("IsTechnologyResearched", tmpl.requiredTechnology)) { 1689 // N.B. sets inputState = INPUT_BUILDING_PLACEMENT: 1690 startBuildingPlacement(lst); 1691 placementSupport.position = Engine.GetTerrainAtScreenPoint(mouseX, mouseY); 1692 initBuildingPlacementView(); 1662 1693 } 1663 1664 switch (preSelectedAction) 1665 { 1666 case ACTION_BUILD: 1667 var tmpl = GetTemplateData(lst); 1668 if (!tmpl.requiredTechnology || Engine.GuiInterfaceCall("IsTechnologyResearched", tmpl.requiredTechnology)) { 1669 // N.B. sets inputState = INPUT_BUILDING_PLACEMENT: 1670 startBuildingPlacement(lst); 1671 placementSupport.position = Engine.GetTerrainAtScreenPoint(mouseX, mouseY); 1672 initBuildingPlacementView(); 1673 } 1674 break; 1675 case ACTION_TRAIN: 1676 var tmpl = GetTemplateData(lst); 1677 if (!tmpl.requiredTechnology || Engine.GuiInterfaceCall("IsTechnologyResearched", tmpl.requiredTechnology)) { 1678 var ents = g_Selection.toList(); 1679 addTrainingToQueue(ents, lst); 1680 } 1681 break; 1682 case ACTION_GARRISON: // we garison nr+1 count 1683 g_Selection.reset(); 1684 lst.splice(nr, lst.length - nr) 1685 g_Selection.addList(lst); 1686 inputState = INPUT_PRESELECTEDACTION; 1687 break; 1688 case ACTION_UNGARRISON: 1689 if (lst.length > 1 || nr == 0) { 1690 if (nr >= lst.length) 1691 nr = lst.length - 1; 1692 if (lst.length != 1 && nr == 0) { 1693 // unload all from all buildings 1694 for each (var gh in lst) 1695 unloadAll(gh); 1696 } else { 1697 if (lst.length != 1) 1698 nr--; 1699 unloadAll(lst[nr]); 1700 } 1701 g_Selection.reset(); 1702 break; 1694 break; 1695 case ACTION_TRAIN: 1696 var tmpl = GetTemplateData(lst); 1697 if (!tmpl.requiredTechnology || Engine.GuiInterfaceCall("IsTechnologyResearched", tmpl.requiredTechnology)) { 1698 var ents = g_Selection.toList(); 1699 addTrainingToQueue(ents, lst); 1700 } 1701 break; 1702 case ACTION_GARRISON: // we garison x+1 count 1703 g_Selection.reset(); 1704 lst.splice(x, lst.length - x) 1705 g_Selection.addList(lst); 1706 inputState = INPUT_PRESELECTEDACTION; 1707 break; 1708 case ACTION_UNGARRISON: 1709 if (lst.length > 1 || x == 0) { 1710 if (x >= lst.length) 1711 x = lst.length - 1; 1712 if (lst.length != 1 && x == 0) { 1713 // unload all from all buildings 1714 for each (var gh in lst) 1715 unloadAll(gh); 1703 1716 } else { 1704 lst = lst[0]; 1705 var state = GetEntityState(lst); 1706 var gents = state.garrisonHolder.entities; 1707 if (nr > gents.length) 1708 nr = gents.length; 1709 while (nr--) 1710 Engine.PostNetworkCommand({"type": "unload", "entities": [gents[nr]], "garrisonHolder": lst}); 1711 // we could assign a key to follow them here 1712 break; 1717 if (lst.length != 1) 1718 x--; 1719 unloadAll(lst[x]); 1713 1720 } 1714 break; 1715 case ACTION_FORMATION: 1716 ents = g_Selection.toList(); 1717 var formationOk = Engine.GuiInterfaceCall("CanMoveEntsIntoFormation", { 1718 "ents": g_Selection.toList(), 1719 "formationName": lst 1720 }); 1721 if (formationOk) 1722 performFormation(ents, lst); 1723 break 1724 case ACTION_STANCE: 1725 ents = g_Selection.toList(); 1726 performStance(ents, lst); 1727 break; 1728 case ACTION_BARTER: //TODO 1729 break; 1730 case ACTION_TRADER: //TODO 1731 break; 1721 g_Selection.reset(); 1722 } else { 1723 lst = lst[0]; 1724 var state = GetEntityState(lst); 1725 var gents = state.garrisonHolder.entities; 1726 if (x > gents.length) 1727 x = gents.length; 1728 while (x--) 1729 Engine.PostNetworkCommand({"type": "unload", "entities": [gents[x]], "garrisonHolder": lst}); 1730 // we could assign a key to follow them here 1732 1731 } 1733 1732 break; 1733 case ACTION_FORMATION: 1734 ents = g_Selection.toList(); 1735 var formationOk = Engine.GuiInterfaceCall("CanMoveEntsIntoFormation", { 1736 "ents": g_Selection.toList(), 1737 "formationName": lst 1738 }); 1739 if (formationOk) 1740 performFormation(ents, lst); 1741 break 1742 case ACTION_STANCE: 1743 ents = g_Selection.toList(); 1744 performStance(ents, lst); 1745 break; 1746 case ACTION_BARTER: //TODO 1747 break; 1748 case ACTION_TRADER: //TODO 1749 break; 1734 1750 } 1735 1751 } 1736 1752 1737 1753 // This returns a list of actions. Caller still has to check Technology availability 1738 1754 function selectAction(player, selection) 1739 1755 { 1740 var ret = [];1741 1756 if (preSelectedAction == ACTION_FORMATION) 1742 {1743 1757 return Engine.GuiInterfaceCall("GetAvailableFormations"); 1744 } else if (preSelectedAction == ACTION_STANCE) 1745 { 1758 else if (preSelectedAction == ACTION_STANCE) 1746 1759 return ["violent", "aggressive", "passive", "defensive", "standground"]; 1747 } 1760 1761 var ret = []; 1748 1762 for each (var ent in selection) 1749 1763 { 1750 1764 var state = GetEntityState(ent); -
binaries/data/mods/public/gui/session/input.js
commit 286f76f2aa3bf8259fe4de6edb279e89d6215484 Author: Roel Kluin <roel.kluin@gmail.com> Date: Wed Jun 13 23:41:05 2012 +0200 don't mix up function argument and global Signed-off-by: Roel Kluin <roel.kluin@gmail.com> diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js index 37508f3..adb7bb5 100644
a b function handleInputAfterGui(ev) 1066 1066 switch (ev.type) 1067 1067 { 1068 1068 case "mousebuttondown": 1069 if (ev.button == SDL_BUTTON_LEFT && preSelectedAction )1069 if (ev.button == SDL_BUTTON_LEFT && preSelectedAction != ACTION_NONE) 1070 1070 { 1071 1071 var action = determineAction(ev.x, ev.y); 1072 1072 resetPreselectedAction(); … … function performGroup(action, nr) 1647 1647 if (preSelectedAction == ACTION_NONE) 1648 1648 break; 1649 1649 1650 var lst = selectAction(player, selection , action);1650 var lst = selectAction(player, selection); 1651 1651 if (!lst) // shouldn't happen 1652 1652 break; 1653 1653 … … function performGroup(action, nr) 1734 1734 } 1735 1735 } 1736 1736 1737 function selectAction(player, selection, action) 1737 // This returns a list of actions. Caller still has to check Technology availability 1738 function selectAction(player, selection) 1738 1739 { 1739 1740 var ret = []; 1740 if ( action == ACTION_FORMATION)1741 if (preSelectedAction == ACTION_FORMATION) 1741 1742 { 1742 1743 return Engine.GuiInterfaceCall("GetAvailableFormations"); 1743 } else if ( action == ACTION_STANCE)1744 } else if (preSelectedAction == ACTION_STANCE) 1744 1745 { 1745 1746 return ["violent", "aggressive", "passive", "defensive", "standground"]; 1746 1747 } … … function selectAction(player, selection, action) 1786 1787 return ret; 1787 1788 } 1788 1789 1789 // This returns a list of actions. Caller still has to check Technology availability1790 1790 function getDefaultActionForSelection(player, selection) 1791 1791 { 1792 1792 var action; … … function findEntity(classes, mode) 1911 1911 var newEntity = Engine.GuiInterfaceCall("FindEntity", data); 1912 1912 if (newEntity && newEntity != lastEntity) 1913 1913 { 1914 if (!selectAction(player, [newEntity] , preSelectedAction).length)1914 if (!selectAction(player, [newEntity]).length) 1915 1915 resetPreselectedAction(); 1916 1916 else if (preSelectedAction == ACTION_BUILD) 1917 1917 updateBuildingPlacementPreview(); -
binaries/data/mods/public/gui/session/input.js
commit 92ad5f0b42b98f9d7beae0c884af378a99bc60e9 Author: Roel Kluin <roel.kluin@gmail.com> Date: Wed Jun 13 23:31:36 2012 +0200 reorder a bit (no functional change) Signed-off-by: Roel Kluin <roel.kluin@gmail.com> diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js index 7e12d39..37508f3 100644
a b function handleInputAfterGui(ev) 1057 1057 break; 1058 1058 1059 1059 case "hotkeydown": 1060 if (ev.hotkey && ev.hotkey.indexOf("selection.group.") == 0) 1061 { 1062 var sptr = ev.hotkey.split("."); 1063 var now = new Date(); 1064 if ((now.getTime() - doublePressTimer < doublePressTime) && (ev.hotkey == prevHotkey) && ev.hotkey.indexOf("selection.group.select.") == 0) { 1065 performGroup("snap", sptr[3]); 1066 } 1067 else 1068 { 1069 performGroup(sptr[2], sptr[3]); 1070 1071 doublePressTimer = now.getTime(); 1072 prevHotkey = ev.hotkey; 1073 } 1074 } 1060 handleHotkey(ev); 1075 1061 break; 1076 1062 } 1077 1063 break; … … function handleInputAfterGui(ev) 1094 1080 break; 1095 1081 } 1096 1082 case "hotkeydown": 1097 if (ev.hotkey && ev.hotkey.indexOf("selection.group.action.") == 0) 1098 { 1099 var sptr = ev.hotkey.split("."); 1100 performGroup(sptr[2], sptr[3]); 1101 } 1083 handleHotkey(ev); 1102 1084 break; 1103 1085 default: 1104 1086 // Slight hack: If selection is empty, reset the input state … … function handleInputAfterGui(ev) 1268 1250 updateBuildingPlacementPreview(); 1269 1251 break; 1270 1252 default: 1271 if (ev.hotkey.indexOf("selection.group.action.") == 0) 1272 { // can switch buildings 1273 var sptr = ev.hotkey.split("."); 1274 performGroup(sptr[2], sptr[3]); 1275 } 1253 handleHotkey(ev); // to switch buildings 1276 1254 } 1277 1255 break; 1278 1256 … … function performFormation(entity, formationName) 1609 1587 } 1610 1588 } 1611 1589 1612 function selectAction(player, selection, action)1590 function handleHotkey(ev) 1613 1591 { 1614 var ret = []; 1615 if (action == ACTION_FORMATION) 1616 { 1617 return Engine.GuiInterfaceCall("GetAvailableFormations"); 1618 } else if (action == ACTION_STANCE) 1619 { 1620 return ["violent", "aggressive", "passive", "defensive", "standground"]; 1621 } 1622 for each (var ent in selection) 1592 if (ev.hotkey && ev.hotkey.indexOf("selection.group.") == 0) 1623 1593 { 1624 var state = GetEntityState(ent); 1625 if (!state || (state.player != player && !g_DevSettings.controlAll)) 1626 continue; 1627 1628 switch (preSelectedAction) 1594 var sptr = ev.hotkey.split("."); 1595 var now = new Date(); 1596 if (inputState = INPUT_NORMAL && (ev.hotkey == prevHotkey) && 1597 ev.hotkey.indexOf("selection.group.select.") == 0 && 1598 (now.getTime() - doublePressTimer < doublePressTime)) { 1599 performGroup("snap", sptr[3]); 1600 } 1601 else 1629 1602 { 1630 case ACTION_GARRISON: 1631 if (state.buildEntities || (hasClass(state, "Unit") && !hasClass(state, "Animal") && !state.garrisonHolder)) { 1632 inputState = INPUT_PRESELECTEDACTION; 1633 ret.push(ent); 1634 } 1635 break; 1636 case ACTION_BUILD: 1637 if (state.buildEntities && state.buildEntities.length) { 1638 if (inputState != INPUT_BUILDING_PLACEMENT) 1639 inputState = INPUT_PRESELECTEDACTION; 1640 return state.buildEntities; 1641 } 1642 break; 1643 case ACTION_TRAIN: 1644 if (state.production && state.production.entities.length) 1645 return state.production.entities; 1646 break; 1647 case ACTION_UNGARRISON: 1648 if (state.garrisonHolder && state.garrisonHolder.entities && state.garrisonHolder.entities.length) 1649 ret.push(ent); 1650 break; 1651 case ACTION_BARTER: 1652 if (state.barterMarket) 1653 ret.push(ent); 1654 break; 1655 case ACTION_TRADER: 1656 if (state.trader) 1657 ret.push([ent, state]); 1658 break; 1603 performGroup(sptr[2], sptr[3]); 1604 doublePressTimer = now.getTime(); 1605 prevHotkey = ev.hotkey; 1659 1606 } 1660 1607 } 1661 return ret;1662 }1663 1664 // This returns a list of actions. Caller still has to check Technology availability1665 function getDefaultActionForSelection(player, selection)1666 {1667 var action;1668 var count = 0;1669 for each (var ent in selection)1670 {1671 var state = GetEntityState(ent);1672 if (!state || (state.player != player && !g_DevSettings.controlAll))1673 continue;1674 1675 if (state.buildEntities && state.buildEntities.length)1676 return ACTION_BUILD; // by default1677 1678 if (state.production && state.production.entities.length)1679 action |= ACTION_TRAIN;1680 else if (!hasClass(state, "Unit") || hasClass(state, "Animal") ||1681 !state.garrisonHolder) {1682 if (++count > 1) //only works with at least two units1683 action |= ACTION_FORMATION;1684 } else if (state.barterMarket)1685 action |= ACTION_BARTER;1686 else if (state.trader)1687 action |= ACTION_TRADER;1688 }1689 if (action & ACTION_TRAIN)1690 return ACTION_TRAIN;1691 else if (action & ACTION_FORMATION)1692 return ACTION_FORMATION;1693 else if (action & ACTION_BARTER) {1694 setupUnitBarterPanel(state);1695 return ACTION_BARTER;1696 } else if (action & ACTION_TRADER) {1697 setupUnitTradingPanel(state, selection);1698 return ACTION_TRADER;1699 }1700 return 0; //shouldn't happen1701 1608 } 1702 1609 1703 1610 // Performs the specified group … … function performGroup(action, nr) 1827 1734 } 1828 1735 } 1829 1736 1737 function selectAction(player, selection, action) 1738 { 1739 var ret = []; 1740 if (action == ACTION_FORMATION) 1741 { 1742 return Engine.GuiInterfaceCall("GetAvailableFormations"); 1743 } else if (action == ACTION_STANCE) 1744 { 1745 return ["violent", "aggressive", "passive", "defensive", "standground"]; 1746 } 1747 for each (var ent in selection) 1748 { 1749 var state = GetEntityState(ent); 1750 if (!state || (state.player != player && !g_DevSettings.controlAll)) 1751 continue; 1752 1753 switch (preSelectedAction) 1754 { 1755 case ACTION_GARRISON: 1756 if (state.buildEntities || (hasClass(state, "Unit") && !hasClass(state, "Animal") && !state.garrisonHolder)) { 1757 inputState = INPUT_PRESELECTEDACTION; 1758 ret.push(ent); 1759 } 1760 break; 1761 case ACTION_BUILD: 1762 if (state.buildEntities && state.buildEntities.length) { 1763 if (inputState != INPUT_BUILDING_PLACEMENT) 1764 inputState = INPUT_PRESELECTEDACTION; 1765 return state.buildEntities; 1766 } 1767 break; 1768 case ACTION_TRAIN: 1769 if (state.production && state.production.entities.length) 1770 return state.production.entities; 1771 break; 1772 case ACTION_UNGARRISON: 1773 if (state.garrisonHolder && state.garrisonHolder.entities && state.garrisonHolder.entities.length) 1774 ret.push(ent); 1775 break; 1776 case ACTION_BARTER: 1777 if (state.barterMarket) 1778 ret.push(ent); 1779 break; 1780 case ACTION_TRADER: 1781 if (state.trader) 1782 ret.push([ent, state]); 1783 break; 1784 } 1785 } 1786 return ret; 1787 } 1788 1789 // This returns a list of actions. Caller still has to check Technology availability 1790 function getDefaultActionForSelection(player, selection) 1791 { 1792 var action; 1793 var count = 0; 1794 for each (var ent in selection) 1795 { 1796 var state = GetEntityState(ent); 1797 if (!state || (state.player != player && !g_DevSettings.controlAll)) 1798 continue; 1799 1800 if (state.buildEntities && state.buildEntities.length) 1801 return ACTION_BUILD; // by default 1802 1803 if (state.production && state.production.entities.length) 1804 action |= ACTION_TRAIN; 1805 else if (!hasClass(state, "Unit") || hasClass(state, "Animal") || 1806 !state.garrisonHolder) { 1807 if (++count > 1) //only works with at least two units 1808 action |= ACTION_FORMATION; 1809 } else if (state.barterMarket) 1810 action |= ACTION_BARTER; 1811 else if (state.trader) 1812 action |= ACTION_TRADER; 1813 } 1814 if (action & ACTION_TRAIN) 1815 return ACTION_TRAIN; 1816 else if (action & ACTION_FORMATION) 1817 return ACTION_FORMATION; 1818 else if (action & ACTION_BARTER) { 1819 setupUnitBarterPanel(state); 1820 return ACTION_BARTER; 1821 } else if (action & ACTION_TRADER) { 1822 setupUnitTradingPanel(state, selection); 1823 return ACTION_TRADER; 1824 } 1825 return 0; //shouldn't happen 1826 } 1827 1830 1828 // Performs the specified stance 1831 1829 function performStance(entity, stanceName) 1832 1830 { -
binaries/data/mods/public/gui/session/input.js
commit a459d5e2b2413a021e01bb7dd9ef4f16468778b3 Author: Roel Kluin <roel.kluin@gmail.com> Date: Wed Jun 13 23:25:14 2012 +0200 Generalize All unloaded following Signed-off-by: Roel Kluin <roel.kluin@gmail.com> diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js index 8897d01..7e12d39 100644
a b function handleInputBeforeGui(ev, hoveredObject) 666 666 mouseY = ev.y; 667 667 break; 668 668 } 669 if (followQueue.leng ht)669 if (followQueue.length) 670 670 { 671 671 var gents = followQueue; 672 672 var state = GetEntityState(gents[0]); 673 // FIXME this stalls until the selection actually occurs674 673 if (state.visibility == "hidden") 675 674 return true; 676 675 Engine.CameraFollow(0); 677 676 Engine.CameraFollow(gents[0]); 678 677 g_Selection.addList(gents); 679 678 resetPreselectedAction(); 680 followQueue = []; 679 followQueue = []; // for next time. 681 680 } 682 681 // Remember whether the mouse is over a GUI object or not 683 682 mouseIsOverObject = (hoveredObject != null); … … function performGroup(action, nr) 1784 1783 if (nr >= lst.length) 1785 1784 nr = lst.length - 1; 1786 1785 if (lst.length != 1 && nr == 0) { 1787 followQueue = [];1788 1786 // unload all from all buildings 1789 for each (var gh in lst) { 1790 var s = GetEntityState(gh); 1791 var gs = s.garrisonHolder.entities; 1792 followQueue = followQueue.concat(gs); 1787 for each (var gh in lst) 1793 1788 unloadAll(gh); 1794 }1795 1789 } else { 1796 1790 if (lst.length != 1) 1797 1791 nr--; 1798 lst = lst[nr]; 1799 1800 var state = GetEntityState(lst); 1801 var gents = state.garrisonHolder.entities; 1802 followQueue = gents; 1803 unloadAll(lst); 1792 unloadAll(lst[nr]); 1804 1793 } 1805 1794 g_Selection.reset(); 1806 1795 break; … … function unload(garrisonHolder, entities) 1953 1942 1954 1943 function unloadAll(garrisonHolder) 1955 1944 { 1945 var state = GetEntityState(garrisonHolder); 1946 var gents = state.garrisonHolder.entities; 1947 followQueue = followQueue.concat(gents); 1956 1948 Engine.PostNetworkCommand({"type": "unload-all", "garrisonHolder": garrisonHolder}); 1957 1949 } -
binaries/data/mods/public/gui/session/input.js
commit b89368e8dede26f9b2a412c1c62bde5aceefed9a Author: Roel Kluin <roel.kluin@gmail.com> Date: Wed Jun 13 22:45:44 2012 +0200 This patch makes a default choice active. e.g. for a worker the default action is to build, for a building to train. keys G to singlequote are implemented as choices. Setting non-default options aren't available anymore but a next patch will implement hotkeys for that. Signed-off-by: Roel Kluin <roel.kluin@gmail.com> diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js index eb6d59a..8897d01 100644
a b const ACTION_BARTER = 64; 23 23 const ACTION_TRADER =128; 24 24 var preSelectedAction = ACTION_NONE; 25 25 26 // N.B. reset this after selecting different units or buildings 27 var _optionsOfpreSelected = []; 26 var followQueue = []; 28 27 29 28 const INPUT_NORMAL = 0; 30 29 const INPUT_SELECTING = 1; … … const INPUT_BATCHTRAINING = 6; 36 35 const INPUT_PRESELECTEDACTION = 7; 37 36 const INPUT_BUILDING_WALL_CLICK = 8; 38 37 const INPUT_BUILDING_WALL_PATHING = 9; 39 const INPUT_FOLLOW_UNGARRISON = 10;40 38 41 39 var inputState = INPUT_NORMAL; 42 40 var placementSupport = new PlacementSupport(); … … function resetPreselectedAction() 188 186 { 189 187 preSelectedAction = ACTION_NONE; 190 188 inputState = INPUT_NORMAL; 191 _optionsOfpreSelected = [];192 189 placementSupport.Reset(); // or a hotkey may leave a building snapshot 193 190 updateCursorAndTooltip(); 194 191 … … function handleInputBeforeGui(ev, hoveredObject) 669 666 mouseY = ev.y; 670 667 break; 671 668 } 672 if ( inputState == INPUT_FOLLOW_UNGARRISON)669 if (followQueue.lenght) 673 670 { 674 var gents = _optionsOfpreSelected;671 var gents = followQueue; 675 672 var state = GetEntityState(gents[0]); 676 673 // FIXME this stalls until the selection actually occurs 677 674 if (state.visibility == "hidden") … … function handleInputBeforeGui(ev, hoveredObject) 680 677 Engine.CameraFollow(gents[0]); 681 678 g_Selection.addList(gents); 682 679 resetPreselectedAction(); 680 followQueue = []; 683 681 } 684 682 // Remember whether the mouse is over a GUI object or not 685 683 mouseIsOverObject = (hoveredObject != null); … … function handleInputAfterGui(ev) 1044 1042 return false; 1045 1043 1046 1044 case "mousebuttondown": 1047 _optionsOfpreSelected = [];1048 1045 if (ev.button == SDL_BUTTON_LEFT) 1049 1046 { 1050 1047 dragStart = [ ev.x, ev.y ]; … … function handleInputAfterGui(ev) 1245 1242 placementSupport.position = Engine.GetTerrainAtScreenPoint(ev.x, ev.y); 1246 1243 dragStart = [ ev.x, ev.y ]; 1247 1244 inputState = INPUT_BUILDING_CLICK; 1248 _optionsOfpreSelected = [];1249 1245 } 1250 1246 return true; 1251 1247 } … … function performFormation(entity, formationName) 1614 1610 } 1615 1611 } 1616 1612 1617 // This returns a list of actions. Caller still has to check Technology availability 1618 function getActionForSelection(player, selection) 1613 function selectAction(player, selection, action) 1619 1614 { 1620 1615 var ret = []; 1621 1616 if (action == ACTION_FORMATION) 1617 { 1618 return Engine.GuiInterfaceCall("GetAvailableFormations"); 1619 } else if (action == ACTION_STANCE) 1620 { 1621 return ["violent", "aggressive", "passive", "defensive", "standground"]; 1622 } 1622 1623 for each (var ent in selection) 1623 1624 { 1624 1625 var state = GetEntityState(ent); … … function getActionForSelection(player, selection) 1648 1649 if (state.garrisonHolder && state.garrisonHolder.entities && state.garrisonHolder.entities.length) 1649 1650 ret.push(ent); 1650 1651 break; 1651 case ACTION_FORMATION:1652 case ACTION_STANCE:1653 if (!hasClass(state, "Unit") || hasClass(state, "Animal") || state.garrisonHolder)1654 break;1655 1656 if (preSelectedAction == ACTION_STANCE)1657 return ["violent", "aggressive", "passive", "defensive", "standground"];1658 if (ret.length) // minimimum is 2 units for formation to be enabled1659 return Engine.GuiInterfaceCall("GetAvailableFormations");1660 ret.push(1);1661 break;1662 1652 case ACTION_BARTER: 1663 1653 if (state.barterMarket) 1664 1654 ret.push(ent); … … function getActionForSelection(player, selection) 1667 1657 if (state.trader) 1668 1658 ret.push([ent, state]); 1669 1659 break; 1670 default:1671 return ret; //shouldn't happen1672 1660 } 1673 1661 } 1674 1662 return ret; 1675 1663 } 1676 1664 1665 // This returns a list of actions. Caller still has to check Technology availability 1666 function getDefaultActionForSelection(player, selection) 1667 { 1668 var action; 1669 var count = 0; 1670 for each (var ent in selection) 1671 { 1672 var state = GetEntityState(ent); 1673 if (!state || (state.player != player && !g_DevSettings.controlAll)) 1674 continue; 1675 1676 if (state.buildEntities && state.buildEntities.length) 1677 return ACTION_BUILD; // by default 1678 1679 if (state.production && state.production.entities.length) 1680 action |= ACTION_TRAIN; 1681 else if (!hasClass(state, "Unit") || hasClass(state, "Animal") || 1682 !state.garrisonHolder) { 1683 if (++count > 1) //only works with at least two units 1684 action |= ACTION_FORMATION; 1685 } else if (state.barterMarket) 1686 action |= ACTION_BARTER; 1687 else if (state.trader) 1688 action |= ACTION_TRADER; 1689 } 1690 if (action & ACTION_TRAIN) 1691 return ACTION_TRAIN; 1692 else if (action & ACTION_FORMATION) 1693 return ACTION_FORMATION; 1694 else if (action & ACTION_BARTER) { 1695 setupUnitBarterPanel(state); 1696 return ACTION_BARTER; 1697 } else if (action & ACTION_TRADER) { 1698 setupUnitTradingPanel(state, selection); 1699 return ACTION_TRADER; 1700 } 1701 return 0; //shouldn't happen 1702 } 1703 1677 1704 // Performs the specified group 1678 1705 function performGroup(action, nr) 1679 1706 { … … function performGroup(action, nr) 1707 1734 updateGroups(); 1708 1735 break; 1709 1736 case "action": 1710 if (!_optionsOfpreSelected.length) { 1711 // action hotkey (first pass): With current selection, check possible 1712 // ACTION_XXX's and set preSelectedAction when applicable 1713 preSelectedAction = (1 << nr); 1714 1715 var selection = g_Selection.toList(); 1716 var player = Engine.GetPlayerID(); 1737 var selection = g_Selection.toList(); 1738 var player = Engine.GetPlayerID(); 1717 1739 1718 var actions = getActionForSelection(player, selection); 1719 if (!actions || !actions.length) { 1720 preSelectedAction = ACTION_NONE; 1721 break; 1722 } 1740 preSelectedAction = getDefaultActionForSelection(player, selection); 1741 if (preSelectedAction == ACTION_NONE) 1742 break; 1723 1743 1724 if (preSelectedAction == ACTION_BARTER) 1725 setupUnitBarterPanel(state); 1726 else if (preSelectedAction == ACTION_TRADER) 1727 setupUnitTradingPanel(state, selection); 1744 var lst = selectAction(player, selection, action); 1745 if (!lst) // shouldn't happen 1746 break; 1728 1747 1729 _optionsOfpreSelected = actions; 1730 } 1731 else 1748 if (preSelectedAction & ACTION_GARRISON) 1732 1749 { 1733 // 2nd action hotkey. Do preselectedAction[nr] 1734 // The result depends on the action. 1735 1736 var lst = _optionsOfpreSelected; 1737 if (!lst) // shouldn't happen 1750 if (++nr > lst.length) 1751 nr = lst.length; 1752 } else if (preSelectedAction != ACTION_UNGARRISON) { 1753 if (nr >= lst.length) 1738 1754 break; 1755 lst = lst[nr]; 1756 } 1739 1757 1740 if (preSelectedAction & ACTION_GARRISON) 1741 { 1742 if (++nr > lst.length) 1743 nr = lst.length; 1744 } else if (preSelectedAction != ACTION_UNGARRISON) { 1745 if (nr >= lst.length) 1746 break; 1747 lst = lst[nr]; 1758 switch (preSelectedAction) 1759 { 1760 case ACTION_BUILD: 1761 var tmpl = GetTemplateData(lst); 1762 if (!tmpl.requiredTechnology || Engine.GuiInterfaceCall("IsTechnologyResearched", tmpl.requiredTechnology)) { 1763 // N.B. sets inputState = INPUT_BUILDING_PLACEMENT: 1764 startBuildingPlacement(lst); 1765 placementSupport.position = Engine.GetTerrainAtScreenPoint(mouseX, mouseY); 1766 initBuildingPlacementView(); 1748 1767 } 1749 1750 switch (preSelectedAction) 1751 { 1752 case ACTION_BUILD: 1753 var tmpl = GetTemplateData(lst); 1754 if (!tmpl.requiredTechnology || Engine.GuiInterfaceCall("IsTechnologyResearched", tmpl.requiredTechnology)) { 1755 // N.B. sets inputState = INPUT_BUILDING_PLACEMENT: 1756 startBuildingPlacement(lst); 1757 placementSupport.position = Engine.GetTerrainAtScreenPoint(mouseX, mouseY); 1758 initBuildingPlacementView(); 1759 } 1760 break; 1761 case ACTION_TRAIN: 1762 var tmpl = GetTemplateData(lst); 1763 if (!tmpl.requiredTechnology || Engine.GuiInterfaceCall("IsTechnologyResearched", tmpl.requiredTechnology)) { 1764 var ents = g_Selection.toList(); 1765 addTrainingToQueue(ents, lst); 1766 } 1767 break; 1768 case ACTION_GARRISON: // we garison nr+1 count 1769 g_Selection.reset(); 1770 lst.splice(nr, lst.length - nr) 1771 g_Selection.addList(lst); 1772 inputState = INPUT_PRESELECTEDACTION; 1773 break; 1774 case ACTION_UNGARRISON: 1775 if (lst.length > 1 || nr == 0) { 1776 if (nr >= lst.length) 1777 nr = lst.length - 1; 1778 if (lst.length != 1 && nr == 0) { 1779 // unload all from all buildings 1780 _optionsOfpreSelected = []; 1781 for each (var gh in lst) { 1782 var s = GetEntityState(gh); 1783 var gs = s.garrisonHolder.entities; 1784 _optionsOfpreSelected = _optionsOfpreSelected.concat(gs); 1785 unloadAll(gh); 1786 } 1787 } else { 1788 if (lst.length != 1) 1789 nr--; 1790 lst = lst[nr]; 1791 1792 var state = GetEntityState(lst); 1793 var gents = state.garrisonHolder.entities; 1794 _optionsOfpreSelected = gents; 1795 unloadAll(lst); 1768 break; 1769 case ACTION_TRAIN: 1770 var tmpl = GetTemplateData(lst); 1771 if (!tmpl.requiredTechnology || Engine.GuiInterfaceCall("IsTechnologyResearched", tmpl.requiredTechnology)) { 1772 var ents = g_Selection.toList(); 1773 addTrainingToQueue(ents, lst); 1774 } 1775 break; 1776 case ACTION_GARRISON: // we garison nr+1 count 1777 g_Selection.reset(); 1778 lst.splice(nr, lst.length - nr) 1779 g_Selection.addList(lst); 1780 inputState = INPUT_PRESELECTEDACTION; 1781 break; 1782 case ACTION_UNGARRISON: 1783 if (lst.length > 1 || nr == 0) { 1784 if (nr >= lst.length) 1785 nr = lst.length - 1; 1786 if (lst.length != 1 && nr == 0) { 1787 followQueue = []; 1788 // unload all from all buildings 1789 for each (var gh in lst) { 1790 var s = GetEntityState(gh); 1791 var gs = s.garrisonHolder.entities; 1792 followQueue = followQueue.concat(gs); 1793 unloadAll(gh); 1796 1794 } 1797 g_Selection.reset();1798 inputState = INPUT_FOLLOW_UNGARRISON;1799 break;1800 1795 } else { 1801 lst = lst[0]; 1796 if (lst.length != 1) 1797 nr--; 1798 lst = lst[nr]; 1799 1802 1800 var state = GetEntityState(lst); 1803 1801 var gents = state.garrisonHolder.entities; 1804 if (nr > gents.length) 1805 nr = gents.length; 1806 while (nr--) 1807 Engine.PostNetworkCommand({"type": "unload", "entities": [gents[nr]], "garrisonHolder": lst}); 1808 // we could assign a key to follow them here 1809 break; 1802 followQueue = gents; 1803 unloadAll(lst); 1810 1804 } 1805 g_Selection.reset(); 1811 1806 break; 1812 case ACTION_FORMATION: 1813 ents = g_Selection.toList(); 1814 var formationOk = Engine.GuiInterfaceCall("CanMoveEntsIntoFormation", { 1815 "ents": g_Selection.toList(), 1816 "formationName": lst 1817 }); 1818 if (formationOk) 1819 performFormation(ents, lst); 1820 break 1821 case ACTION_STANCE: 1822 ents = g_Selection.toList(); 1823 performStance(ents, lst); 1824 break; 1825 case ACTION_BARTER: //TODO 1826 break; 1827 case ACTION_TRADER: //TODO 1807 } else { 1808 lst = lst[0]; 1809 var state = GetEntityState(lst); 1810 var gents = state.garrisonHolder.entities; 1811 if (nr > gents.length) 1812 nr = gents.length; 1813 while (nr--) 1814 Engine.PostNetworkCommand({"type": "unload", "entities": [gents[nr]], "garrisonHolder": lst}); 1815 // we could assign a key to follow them here 1828 1816 break; 1829 1817 } 1818 break; 1819 case ACTION_FORMATION: 1820 ents = g_Selection.toList(); 1821 var formationOk = Engine.GuiInterfaceCall("CanMoveEntsIntoFormation", { 1822 "ents": g_Selection.toList(), 1823 "formationName": lst 1824 }); 1825 if (formationOk) 1826 performFormation(ents, lst); 1827 break 1828 case ACTION_STANCE: 1829 ents = g_Selection.toList(); 1830 performStance(ents, lst); 1831 break; 1832 case ACTION_BARTER: //TODO 1833 break; 1834 case ACTION_TRADER: //TODO 1835 break; 1830 1836 } 1831 1837 break; 1832 1838 } … … function findAllVisibleEntities(classes, mode) 1895 1901 } 1896 1902 1897 1903 if (visibleEnts.length) { 1898 if (!get ActionForSelection(player, visibleEnts).length)1904 if (!getDefaultActionForSelection(player, visibleEnts).length) 1899 1905 resetPreselectedAction(); 1900 1906 g_Selection.reset(); 1901 1907 g_Selection.addList(visibleEnts); … … function findEntity(classes, mode) 1918 1924 var newEntity = Engine.GuiInterfaceCall("FindEntity", data); 1919 1925 if (newEntity && newEntity != lastEntity) 1920 1926 { 1921 if (! getActionForSelection(player, [newEntity]).length)1927 if (!selectAction(player, [newEntity], preSelectedAction).length) 1922 1928 resetPreselectedAction(); 1923 1929 else if (preSelectedAction == ACTION_BUILD) 1924 1930 updateBuildingPlacementPreview(); -
binaries/data/config/default.cfg
commit 273d868803cecf5e17938e49a2a0b6944327257e Author: Roel Kluin <roel.kluin@gmail.com> Date: Wed Jun 13 20:35:27 2012 +0200 as suggested by historic_bruno the backslash isn't always in line Also use Ctrl rather than shift for the 7+ keys (we may want to use shift for batchtrain later). Signed-off-by: Roel Kluin <roel.kluin@gmail.com> diff --git a/binaries/data/config/default.cfg b/binaries/data/config/default.cfg index 5201210..5015b15 100644
a b hotkey.selection.group.select.9 = 9 189 189 hotkey.selection.group.save.9 = "Ctrl+9" 190 190 hotkey.selection.group.add.9 = "Shift+9" 191 191 192 hotkey.selection.group.action.0 = H 193 hotkey.selection.group.action.1 = J 194 hotkey.selection.group.action.2 = K 195 hotkey.selection.group.action.3 = L 196 hotkey.selection.group.action.4 = Semicolon 197 hotkey.selection.group.action.5 = SingleQuote 198 hotkey.selection.group.action.6 = BackSlash 199 hotkey.selection.group.action.7 = "Shift+H" 200 hotkey.selection.group.action.8 = "Shift+J" 201 hotkey.selection.group.action.9 = "Shift+K" 202 hotkey.selection.group.action.10 = "Shift+L" 203 hotkey.selection.group.action.11 = Colon 204 hotkey.selection.group.action.12 = DoubleQuote 192 hotkey.selection.group.action.0 = G 193 hotkey.selection.group.action.1 = H 194 hotkey.selection.group.action.2 = J 195 hotkey.selection.group.action.3 = K 196 hotkey.selection.group.action.4 = L 197 hotkey.selection.group.action.5 = Semicolon 198 hotkey.selection.group.action.6 = SingleQuote 199 hotkey.selection.group.action.7 = "Ctrl+G" 200 hotkey.selection.group.action.8 = "Ctrl+H" 201 hotkey.selection.group.action.9 = "Ctrl+J" 202 hotkey.selection.group.action.10 = "Ctrl+K" 203 hotkey.selection.group.action.11 = "Ctrl+L" 204 hotkey.selection.group.action.12 = "Ctrl+Semicolon" 205 hotkey.selection.group.action.13 = "Ctrl+SingleQuote" 205 206 hotkey.selection.group.action.reset = ForwardSlash 206 207 207 208 ; > SESSION CONTROLS -
binaries/data/mods/public/gui/session/input.js
commit 97150316bb560554c7f1e5d3f45f90a71d574191 Author: Roel Kluin <roel.kluin@gmail.com> Date: Wed Jun 13 20:16:55 2012 +0200 Unload all from all selected buildings ensure selection occurs diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js index bc48d73..eb6d59a 100644
a b function handleInputBeforeGui(ev, hoveredObject) 671 671 } 672 672 if (inputState == INPUT_FOLLOW_UNGARRISON) 673 673 { 674 gents = _optionsOfpreSelected; 674 var gents = _optionsOfpreSelected; 675 var state = GetEntityState(gents[0]); 676 // FIXME this stalls until the selection actually occurs 677 if (state.visibility == "hidden") 678 return true; 675 679 Engine.CameraFollow(0); 676 680 Engine.CameraFollow(gents[0]); 677 681 g_Selection.addList(gents); … … function performGroup(action, nr) 1771 1775 if (lst.length > 1 || nr == 0) { 1772 1776 if (nr >= lst.length) 1773 1777 nr = lst.length - 1; 1774 if (lst.length != 1) // TODO: uload all from all 1775 lst = lst[nr]; // selected buildings 1776 else 1777 lst = lst[0]; 1778 var state = GetEntityState(lst); 1779 var gents = state.garrisonHolder.entities; 1780 _optionsOfpreSelected = gents; 1781 unloadAll(lst); 1778 if (lst.length != 1 && nr == 0) { 1779 // unload all from all buildings 1780 _optionsOfpreSelected = []; 1781 for each (var gh in lst) { 1782 var s = GetEntityState(gh); 1783 var gs = s.garrisonHolder.entities; 1784 _optionsOfpreSelected = _optionsOfpreSelected.concat(gs); 1785 unloadAll(gh); 1786 } 1787 } else { 1788 if (lst.length != 1) 1789 nr--; 1790 lst = lst[nr]; 1791 1792 var state = GetEntityState(lst); 1793 var gents = state.garrisonHolder.entities; 1794 _optionsOfpreSelected = gents; 1795 unloadAll(lst); 1796 } 1782 1797 g_Selection.reset(); 1783 1798 inputState = INPUT_FOLLOW_UNGARRISON; 1784 1799 break; … … function performGroup(action, nr) 1786 1801 lst = lst[0]; 1787 1802 var state = GetEntityState(lst); 1788 1803 var gents = state.garrisonHolder.entities; 1789 if (nr > =gents.length)1804 if (nr > gents.length) 1790 1805 nr = gents.length; 1791 1806 while (nr--) 1792 1807 Engine.PostNetworkCommand({"type": "unload", "entities": [gents[nr]], "garrisonHolder": lst}); -
binaries/data/mods/public/gui/session/input.js
commit a40750c24a7bf9faa84b7e45c4a465c1dafa96c9 Author: Roel Kluin <roel.kluin@gmail.com> Date: Wed Jun 13 19:37:50 2012 +0200 actually the INPUT_REPEATED_UNGARRISON state is not needed Signed-off-by: Roel Kluin <roel.kluin@gmail.com> diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js index eb0f140..bc48d73 100644
a b const INPUT_PRESELECTEDACTION = 7; 37 37 const INPUT_BUILDING_WALL_CLICK = 8; 38 38 const INPUT_BUILDING_WALL_PATHING = 9; 39 39 const INPUT_FOLLOW_UNGARRISON = 10; 40 const INPUT_REPEATED_UNGARRISON = 11;41 40 42 41 var inputState = INPUT_NORMAL; 43 42 var placementSupport = new PlacementSupport(); … … function handleInputBeforeGui(ev, hoveredObject) 677 676 Engine.CameraFollow(gents[0]); 678 677 g_Selection.addList(gents); 679 678 resetPreselectedAction(); 680 } else if (inputState == INPUT_REPEATED_UNGARRISON) {681 var garrisonHolder = _optionsOfpreSelected[0];682 var state = GetEntityState(garrisonHolder);683 var gents = state.garrisonHolder.entities;684 var gent = gents[_optionsOfpreSelected[1]]685 Engine.PostNetworkCommand({"type": "unload", "entities": [gent], "garrisonHolder": garrisonHolder});686 if (_optionsOfpreSelected[1]-- > 0)687 return true;688 resetPreselectedAction();689 679 } 690 680 // Remember whether the mouse is over a GUI object or not 691 681 mouseIsOverObject = (hoveredObject != null); … … function performGroup(action, nr) 1797 1787 var state = GetEntityState(lst); 1798 1788 var gents = state.garrisonHolder.entities; 1799 1789 if (nr >= gents.length) 1800 nr = gents.length - 1; 1801 // unload nr times, requires some update. 1802 _optionsOfpreSelected = [lst, nr]; 1803 inputState = INPUT_REPEATED_UNGARRISON; 1790 nr = gents.length; 1791 while (nr--) 1792 Engine.PostNetworkCommand({"type": "unload", "entities": [gents[nr]], "garrisonHolder": lst}); 1793 // we could assign a key to follow them here 1794 break; 1804 1795 } 1805 1796 break; 1806 1797 case ACTION_FORMATION: