commit 0e369958e9c17997d7e77c3e2aae28c5971ff7a0
Author: Roel Kluin <roel.kluin@gmail.com>
Date: Tue Jun 12 01:24:00 2012 +0200
Find all visible idle workers,warriors,buildings with Shift ./,/U/etc
revert behavior and leave view to garrisonholder as the ungarrisoned
cannot be followed.
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 24f32a5..43cc741 100644
a
|
b
|
function performGroup(action, nr)
|
1767 | 1767 | lst = lst[nr]; // selected buildings |
1768 | 1768 | else |
1769 | 1769 | lst = lst[0]; |
1770 | | // FIXME: follow when ungarrisoning all |
1771 | 1770 | var state = GetEntityState(lst); |
1772 | 1771 | var gents = state.garrisonHolder.entities; |
1773 | 1772 | unloadAll(lst); |
1774 | | Engine.CameraFollow(0); |
1775 | | g_Selection.reset(); |
1776 | | g_Selection.addList(gents); |
1777 | | Engine.CameraFollow(gents[0]); |
| 1773 | // FIXME: follow when ungarrisoning all |
| 1774 | // sadly these gents cannot be viewed after ungarissoning: |
| 1775 | if (gents) |
| 1776 | { |
| 1777 | //Engine.CameraFollow(0); |
| 1778 | g_Selection.reset(); |
| 1779 | g_Selection.addList(gents); |
| 1780 | Engine.CameraFollow(gents); |
| 1781 | } |
1778 | 1782 | } else { |
1779 | 1783 | lst = lst[0]; |
1780 | 1784 | var state = GetEntityState(lst); |
… |
… |
function resetEntitySearch()
|
1847 | 1851 | currEntClass = 0; |
1848 | 1852 | } |
1849 | 1853 | |
| 1854 | function findAllVisibleEntities(classes, mode) |
| 1855 | { |
| 1856 | var player = Engine.GetPlayerID(); |
| 1857 | var plEnts = Engine.PickFriendlyEntitiesOnScreen(player); |
| 1858 | // Or we could do somthing alike the below, but this is resolution dependent |
| 1859 | //var plEnts = Engine.PickFriendlyEntitiesInRect(250, 250, 1400, 750, player); |
| 1860 | if (!plEnts.length) |
| 1861 | return; |
| 1862 | var visibleEnts = []; |
| 1863 | for each (cls in classes) |
| 1864 | { |
| 1865 | var data = { |
| 1866 | entClass: cls, |
| 1867 | searchMode: mode, |
| 1868 | playerEnts: plEnts, |
| 1869 | }; |
| 1870 | var entities = Engine.GuiInterfaceCall("SubsetMatchedEnts", data); |
| 1871 | if (entities.length) |
| 1872 | visibleEnts = visibleEnts.concat(entities); |
| 1873 | } |
| 1874 | |
| 1875 | if (visibleEnts.length) { |
| 1876 | if (!getActionForSelection(player, visibleEnts).length) |
| 1877 | resetPreselectedAction(); |
| 1878 | g_Selection.reset(); |
| 1879 | g_Selection.addList(visibleEnts); |
| 1880 | Engine.CameraFollow(visibleEnts[0]); |
| 1881 | } |
| 1882 | } |
| 1883 | |
1850 | 1884 | function findEntity(classes, mode) |
1851 | 1885 | { |
| 1886 | var queued = Engine.HotkeyIsPressed("session.queue"); |
| 1887 | if (queued) { |
| 1888 | findAllVisibleEntities(classes, mode) |
| 1889 | return; |
| 1890 | } |
1852 | 1891 | var player = Engine.GetPlayerID(); |
1853 | 1892 | // Cycle through idling classes before giving up |
1854 | 1893 | for (var i = 0; i <= classes.length; ++i) |
diff --git a/binaries/data/mods/public/simulation/components/GuiInterface.js b/binaries/data/mods/public/simulation/components/GuiInterface.js
index a2c29ba..6fd71d9 100644
a
|
b
|
GuiInterface.prototype.PlaySound = function(player, data)
|
1426 | 1426 | PlaySound(data.name, data.entity); |
1427 | 1427 | }; |
1428 | 1428 | |
| 1429 | GuiInterface.prototype.MatchEnt = function(ent, data) |
| 1430 | { |
| 1431 | var ret; |
| 1432 | var cmpId = Engine.QueryInterface(ent, IID_Identity); |
| 1433 | if (cmpId && cmpId.HasClass(data.entClass)) { |
| 1434 | if (data.searchMode == 0) { |
| 1435 | ret = ent; |
| 1436 | } else if (data.searchMode == 1) { // Search idle villager/soldier |
| 1437 | var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); |
| 1438 | if (cmpUnitAI && cmpUnitAI.IsIdle() && !cmpUnitAI.IsGarrisoned()) |
| 1439 | ret = ent; |
| 1440 | } |
| 1441 | } |
| 1442 | return ret; |
| 1443 | } |
| 1444 | |
| 1445 | GuiInterface.prototype.SubsetMatchedEnts = function(player, data) |
| 1446 | { |
| 1447 | var ret = []; |
| 1448 | for each (var ent in data.playerEnts) |
| 1449 | { |
| 1450 | var match = this.MatchEnt(ent, data); |
| 1451 | if (match) |
| 1452 | ret.push(match); |
| 1453 | } |
| 1454 | return ret; |
| 1455 | } |
| 1456 | |
1429 | 1457 | GuiInterface.prototype.FindEntity = function(player, data) |
1430 | 1458 | { |
1431 | 1459 | var rangeMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); |
… |
… |
GuiInterface.prototype.FindEntity = function(player, data)
|
1435 | 1463 | // so that we cycle around in a predictable order |
1436 | 1464 | for each (var ent in playerEntities) |
1437 | 1465 | { |
1438 | | var cmpId = Engine.QueryInterface(ent, IID_Identity); |
1439 | | if (ent > data.prevEntity && cmpId && cmpId.HasClass(data.entClass)) { |
1440 | | if (data.searchMode == 0) { |
1441 | | return ent; |
1442 | | } else if (data.searchMode == 1) { // Search idle villager/soldier |
1443 | | var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); |
1444 | | if (cmpUnitAI && cmpUnitAI.IsIdle() && !cmpUnitAI.IsGarrisoned()) |
1445 | | return ent; |
1446 | | } |
| 1466 | if (ent > data.prevEntity) |
| 1467 | { |
| 1468 | var match = this.MatchEnt(ent, data); |
| 1469 | if (match) |
| 1470 | return match; |
1447 | 1471 | } |
1448 | 1472 | } |
1449 | 1473 | |
… |
… |
var exposedFunctions = {
|
1570 | 1594 | "SetWallPlacementPreview": 1, |
1571 | 1595 | "GetFoundationSnapData": 1, |
1572 | 1596 | "PlaySound": 1, |
| 1597 | "SubsetMatchedEnts": 1, |
1573 | 1598 | "FindEntity": 1, |
1574 | 1599 | "GetTradingDetails": 1, |
1575 | 1600 | "CanAttack": 1, |