Ticket #1659: queuecapacitytweak2.diff

File queuecapacitytweak2.diff, 4.4 KB (added by zoot, 12 years ago)
  • binaries/data/mods/public/gui/session/sprites.xml

     
    684684        <image backcolor="0 255 0 128"/>
    685685    </sprite>
    686686
     687    <sprite name="queueProgressLamp">
     688        <image backcolor="255 165 0 128"/>
     689    </sprite>
     690
    687691    <sprite name="healthBackground">
    688692        <image backcolor="red"/>
    689693    </sprite>
  • binaries/data/mods/public/gui/session/unit_commands.js

     
    322322                break;
    323323
    324324            case QUEUE:
     325                var slider = getGUIObjectByName("unit"+guiName+"ProgressSlider["+i+"]");
     326                var lamp = getGUIObjectByName("unit"+guiName+"ProgressLamp["+i+"]");
    325327                var tooltip = getEntityNames(template);
     328                if (item.slots < 0) {
     329                    tooltip += "\nInsufficient population capacity: [color=\"red\"]"+Math.abs(item.slots)+"[/color]";
     330                        // When training is blocked, flash icon (alternates colour every 500msec)
     331                        if (g_IsTrainingBlocked && (Date.now() % 1000) < 500)
     332                    {
     333                        slider.hidden = true;
     334                                lamp.hidden = false; //POPULATION_ALERT_COLOR
     335                    }
     336                        else
     337                    {
     338                        slider.hidden = true;
     339                                lamp.hidden = true; //DEFAULT_POPULATION_COLOR
     340                    }
     341                }
     342                else
     343                {
     344                    slider.hidden = false;
     345                            lamp.hidden = true;
     346                }
     347
    326348                var progress = Math.round(item.progress*100) + "%";
    327349                getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = (item.count > 1 ? item.count : "");
    328350
  • binaries/data/mods/public/gui/session/session.xml

     
    894894                <object name="unitQueueButton[n]" hidden="true" style="iconButton" type="button" size="0 0 40 40" tooltip_style="sessionToolTipBottom">
    895895                <object name="unitQueueIcon[n]" ghost="true" type="image" size="3 3 37 37"/>
    896896                <object name="unitQueueProgressSlider[n]" type="image" sprite="queueProgressSlider" ghost="true" size="3 3 37 37" z="20"/>
     897                <object name="unitQueueProgressLamp[n]" type="image" sprite="queueProgressLamp" ghost="true" size="3 3 37 37" z="20"/>
    897898                <object name="unitQueueCount[n]" ghost="true" style="groupIconsText" type="text" z="20"/>
    898899                </object>
    899900            </repeat>
  • binaries/data/mods/public/simulation/components/ProductionQueue.js

     
    353353            "unitTemplate": item.unitTemplate,
    354354            "technologyTemplate": item.technologyTemplate,
    355355            "count": item.count,
     356            "slots": item.slots,
    356357            "progress": 1-(item.timeRemaining/item.timeTotal),
    357358            "metadata": item.metadata,
    358359        });
     
    506507            {
    507508                // Batch's training hasn't started yet.
    508509                // Try to reserve the necessary population slots
    509                 if (item.unitTemplate && !cmpPlayer.TryReservePopulationSlots(item.population * item.count))
     510                item.slots = cmpPlayer.TryReservePopulationSlots(item.population * item.count);
     511                if (item.unitTemplate && item.slots < 0)
    510512                {
    511513                    // No slots available - don't train this batch now
    512514                    // (we'll try again on the next timeout)
  • binaries/data/mods/public/simulation/components/Player.js

     
    7373    return this.colour;
    7474};
    7575
     76// Try reserving num population slots. Returns num if successful or the inverse of the number of missing slots if failed.
    7677Player.prototype.TryReservePopulationSlots = function(num)
    7778{
    7879    if (num != 0 && num > (this.GetPopulationLimit() - this.GetPopulationCount()))
    79         return false;
     80        return (this.GetPopulationLimit() - this.GetPopulationCount()) - num;
    8081
    8182    this.popUsed += num;
    82     return true;
     83    return num;
    8384};
    8485
    8586Player.prototype.UnReservePopulationSlots = function(num)