zoot Posted September 6, 2012 Report Share Posted September 6, 2012 I've devised another little UI tweak: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 Quote Link to comment Share on other sites More sharing options...
zoot Posted September 7, 2012 Author Report Share Posted September 7, 2012 (edited) I've made it blink (shiny):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 September 7, 2012 by zoot Quote Link to comment Share on other sites More sharing options...
Deiz Posted September 8, 2012 Report Share Posted September 8, 2012 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. Quote Link to comment Share on other sites More sharing options...
zoot Posted September 8, 2012 Author Report Share Posted September 8, 2012 (edited) Thanks for the feedback. I've updated the patch accordingly. Edited September 8, 2012 by zoot Quote Link to comment Share on other sites More sharing options...
Gen.Kenobi Posted September 8, 2012 Report Share Posted September 8, 2012 Moved to the right place Quote Link to comment Share on other sites More sharing options...
zoot Posted September 8, 2012 Author Report Share Posted September 8, 2012 patch it and upload to trac. It already is. Quote Link to comment Share on other sites More sharing options...
zoot Posted September 12, 2012 Author Report Share Posted September 12, 2012 I can't seem to login on Trac, so I'll ask here: Deiz, what would in your view be the cleanest way to update that graphic per frame instead of per turn? It seems sad not being able to do so for UI stuff. Quote Link to comment Share on other sites More sharing options...
Deiz Posted September 12, 2012 Report Share Posted September 12, 2012 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);} Quote Link to comment Share on other sites More sharing options...
zoot Posted September 16, 2012 Author Report Share Posted September 16, 2012 (edited) 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 September 16, 2012 by zoot Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.