Jump to content

Insufficient capacity tooltip


Recommended Posts

I've devised another little UI tweak:

iRiaS.jpg

When you've added a training order to the production queue, and there aren't sufficient population capacity for the order to commence, hovering over the production icon in the queue will show the amount of capacity missing (so you can determine at a glance how many houses you need to build etc.)

(Feel free to come up with a better wording than "Insufficient population capacity".)

queuecapacitytweak.diff

Link to comment
Share on other sites

I've made it blink (shiny):

6x7JS.gif

Caveats:

- I had to make a new GUI 'sprite' for the orange overlay because I couldn't find a way to alter the color of the existing overlay.

- The blinking on the queue icon runs separately from the blinking of the population count in the top bar of the screen and seems slightly out of sync.

queuecapacitytweak2.diff

Edited by zoot
Link to comment
Share on other sites

You could deal with the desync by moving the population counter blinking into onSimulationUpdate. It seems odd to have the GUI flashing while the simulation is paused, anyhow.

The second sprite isn't a very nice solution, but it's unfortunately the nicest solution available. Sprites aren't exposed to Javascript at all and I believe they're designed to be immutable. There is the "colour: r g b a" sprite hack that's used in a few places, but as far as I know there's no way to turn a named colour like "orange" into separate RGBA values that you can then make a new sprite with. Perhaps in the future this'll change - it's quite a mess at the moment.

Your indenting in unit_commands.js is somewhat wonky, other than that the patch looks good.

Link to comment
Share on other sites

I'm not sure there is a particularly clean way to do it.

The nicest way I can think of would be to keep a list of objects to update each frame in session.js, along with an anonymous function that adjusts them when needed. The objects would be inserted and deleted as necessary by unit_commands.js, resulting in something like this:


var updateOnTick = {
"unitQueueProgressLamp[0]": function(obj) { obj.hidden = (Date.now() % 1000 < 500) },
"unitQueueProgressSlider[0]": function(obj) { obj.hidden = (Date.now() % 1000 >= 500) }
}

Which session.js would invoke with something like:


for (var objName in updateOnTick)
{
var obj = getGUIObjectByName(objName);
updateOnTick[objName](obj);
}

Link to comment
Share on other sites

I'm not sure there is a particularly clean way to do it.

The nicest way I can think of would be to keep a list of objects to update each frame in session.js, along with an anonymous function that adjusts them when needed. The objects would be inserted and deleted as necessary by unit_commands.js, resulting in something like this:


var updateOnTick = {
"unitQueueProgressLamp[0]": function(obj) { obj.hidden = (Date.now() % 1000 < 500) },
"unitQueueProgressSlider[0]": function(obj) { obj.hidden = (Date.now() % 1000 >= 500) }
}

Which session.js would invoke with something like:


for (var objName in updateOnTick)
{
var obj = getGUIObjectByName(objName);
updateOnTick[objName](obj);
}

How should unit_commands.js insert and delete items in the list? I am not too clear on how things are scoped.

Via a global, e.g. g_UpdateOnTick?

Edited by zoot
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...