Ticket #1659: queuecapacitytweak3.diff

File queuecapacitytweak3.diff, 5.1 KB (added by zoot, 12 years ago)
  • 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.js

     
    271271    // Update music state
    272272    global.music.updateTimer();
    273273
    274     // When training is blocked, flash population (alternates colour every 500msec)
    275     if (g_IsTrainingBlocked && (Date.now() % 1000) < 500)
    276         getGUIObjectByName("resourcePop").textcolor = POPULATION_ALERT_COLOR;
    277     else
    278         getGUIObjectByName("resourcePop").textcolor = DEFAULT_POPULATION_COLOR;
    279 
    280274    // Clear renamed entities list
    281275    Engine.GuiInterfaceCall("ClearRenamedEntities");
    282276}
     
    450444    getGUIObjectByName("resourcePop").caption = playerState.popCount + "/" + playerState.popLimit;
    451445
    452446    g_IsTrainingBlocked = playerState.trainingBlocked;
     447
     448    // When training is blocked, flash population (alternates colour every 500msec)
     449    if (g_IsTrainingBlocked && (Date.now() % 1000) < 500)
     450        getGUIObjectByName("resourcePop").textcolor = POPULATION_ALERT_COLOR;
     451    else
     452        getGUIObjectByName("resourcePop").textcolor = DEFAULT_POPULATION_COLOR;
    453453}
    454454
    455455function selectAndMoveTo(ent)
  • 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="colour: 255 165 0 128" 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)