Ticket #1915: garrisonCapacity-v3.diff

File garrisonCapacity-v3.diff, 3.7 KB (added by mimo, 11 years ago)
  • binaries/data/mods/public/simulation/components/GuiInterface.js

     
    297297    {
    298298        ret.garrisonHolder = {
    299299            "entities": cmpGarrisonHolder.GetEntities(),
    300             "allowedClasses": cmpGarrisonHolder.GetAllowedClassesList()
     300            "allowedClasses": cmpGarrisonHolder.GetAllowedClassesList(),
     301            "capacity": cmpGarrisonHolder.GetCapacity()
    301302        };
    302303    }
    303304   
  • binaries/data/mods/public/gui/session/input.js

     
    227227            data.command = "garrison";
    228228            data.target = target;
    229229            cursor = "action-garrison";
     230            tooltip = "Current garrison: " + targetState.garrisonHolder.entities.length
     231                + "/" + targetState.garrisonHolder.capacity;
     232            if (targetState.garrisonHolder.entities.length >= targetState.garrisonHolder.capacity)
     233                tooltip = "[color=\"orange\"]" + tooltip + "[/color]";
    230234        }
    231235        else if (targetState.resourceSupply)
    232236        {
     
    311315        case "garrison":
    312316            if (hasClass(entState, "Unit") && targetState.garrisonHolder && (playerOwned || mutualAllyOwned))
    313317            {
     318                var tooltip = "Current garrison: " + targetState.garrisonHolder.entities.length
     319                    + "/" + targetState.garrisonHolder.capacity;
     320                if (targetState.garrisonHolder.entities.length >= targetState.garrisonHolder.capacity)
     321                    tooltip = "[color=\"orange\"]" + tooltip + "[/color]";
    314322                var allowedClasses = targetState.garrisonHolder.allowedClasses;
    315323                for each (var unitClass in entState.identity.classes)
    316324                {
    317325                    if (allowedClasses.indexOf(unitClass) != -1)
    318326                    {
    319                         return {"possible": true};
     327                        return {"possible": true, "tooltip": tooltip};
    320328                    }
    321329                }
    322330            }
     
    460468        target = targets[0];
    461469    }
    462470
     471    var actionInfo = undefined;
    463472    if (preSelectedAction != ACTION_NONE)
    464473    {
    465474        switch (preSelectedAction)
    466475        {
    467476        case ACTION_GARRISON:
    468             if (getActionInfo("garrison", target).possible)
    469                 return {"type": "garrison", "cursor": "action-garrison", "target": target};
     477            if ((actionInfo = getActionInfo("garrison", target)).possible)
     478                return {"type": "garrison", "cursor": "action-garrison", "tooltip": actionInfo.tooltip, "target": target};
    470479            else
    471                 return  {"type": "none", "cursor": "action-garrison-disabled", "target": undefined};
     480                return {"type": "none", "cursor": "action-garrison-disabled", "target": undefined};
    472481            break;
    473482        case ACTION_REPAIR:
    474483            if (getActionInfo("repair", target).possible)
     
    482491    {
    483492        return {"type": "attack", "cursor": "action-attack", "target": target};
    484493    }
    485     else if (Engine.HotkeyIsPressed("session.garrison") && getActionInfo("garrison", target).possible)
     494    else if (Engine.HotkeyIsPressed("session.garrison") && (actionInfo = getActionInfo("garrison", target)).possible)
    486495    {
    487         return {"type": "garrison", "cursor": "action-garrison", "target": target};
     496        return {"type": "garrison", "cursor": "action-garrison", "tooltip": actionInfo.tooltip, "target": target};
    488497    }
    489498    else if (Engine.HotkeyIsPressed("session.attackmove") && getActionInfo("attack-move", target).possible)
    490499    {
     
    492501    }
    493502    else
    494503    {
    495         var actionInfo = undefined;
    496504        if ((actionInfo = getActionInfo("setup-trade-route", target)).possible)
    497505            return {"type": "setup-trade-route", "cursor": "action-setup-trade-route", "tooltip": actionInfo.tooltip, "target": target};
    498506        else if ((actionInfo = getActionInfo("gather", target)).possible)