Jump to content

Show icons as red if not enough resources


Recommended Posts

So I created a patch that puts a red overlay over icons if there are not enough resources to build that building or unit. Additionally it puts in the unit tooltip how much more resources are required to build that building. Buildings that are already greyed out because of technologies remain so but with how many more resources are required to build them added to the tooltip. I would have added this to Trac, but I am not to be able to log into Trac for some reason.

resourceCheck.diff.zip

post-12995-0-29611900-1335647957_thumb.p

post-12995-0-90012400-1335647980_thumb.p

Link to comment
Share on other sites

Good idea.

Not sure if that's actually feasible, but I think using the resource icon and not the name would improve readability. Ever so slightly, but still.

Also: it might make it look a lot like a Christmas tree, which would be bad, but have you tried coloring more and more red as the resource lacking are important (with alpha)? So that at a glance, we'd now how much we need more. If it works from an aesthetic point of view, it could be useful. I think the effect can be quite potent even with small differences in the alpha, so that it looks good, and useful.

Edit: I also recommend changing your code in Unit_command.js to this:

if(guiName == CONSTRUCTION || guiName == TRAINING){
selection.hidden = true;
var totalCosts = {};

var multiplier = 1;
if (guiName == TRAINING && Engine.HotkeyIsPressed("session.batchtrain"))
multiplier = 5;
for each (var r in ["food", "wood", "stone", "metal"])
totalCosts[r] = Math.floor(template.cost[r]*multiplier);
var neededC = Engine.GuiInterfaceCall("FindCostNeeded", totalCosts);
if(neededC.length){
//only put on the red overlay if the button is not already grayed out
if(button.enabled != false){
button.enabled = false;
selection.hidden = false;
}
button.tooltip += "\n[font=\"serif-bold-13\"]Insufficient resources:[/font]\n"+neededC.join(", ");
}
}

It will show red properly if the user clicks on "shift", which is much more intuitive. It doesn't take into account the batch size, though, I'm not too sure how to get that.

Edited by wraitii
Link to comment
Share on other sites

 This sounds very nice! A helpful feature. The 'amount' of minimum red could be tweaked so you can see it clearly. But what about the maximum? Should it depend on the resources the unit/building needs to be build or a fixed amount (lets say 1000)? 

Edited by FeXoR
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...

Since we haven't heard from the original poster in a few weeks (on this post anyway) and I really liked that patch, I've taken the liberty to update it.

Some small differences:

For units, when you push "shift" it will display accordingly if you an create a batch of 5. The "rediness" of icons will increase slightly as the resources needed increase (I'm not sure if it's useful).

It works for technologies too, but I wasn't too sure how to handle paired resources (since they already have a red overlay). They gain an additional faintly red overlay and the tooltip indication.

redIcons.patch

Link to comment
Share on other sites

Awesome job Wraitii. I am glad someone was interested in updating this patch to be more usefull. Looks like you made some nice improvements. Hopefully this patch will help some with the user interface making it easier to identify at a glance what can be built and what cannot be built.

Link to comment
Share on other sites

  • 4 weeks later...

I think there is a small bug/lack in this feature: if several buildings of the same type (e.g. fortress) is selected, the icon will not show as red if there aren't enough resources to build the given unit from all the selected buildings, even though that is what will happen if clicking the icon.

Also, it would IMO be nice if in addition to turning the icon red, it actually disabled the button - it's annoying to Shift-click the icon 10 times, see it turn red, accidentally click it another time, and then get the "not enough resources" message and having to start all over.

Link to comment
Share on other sites

I think the training behaviour is desirable, as it mirrors the command implementation. The training command is sent to each entity individually, so if you have 3 fortresses selected and are trying to train a batch that requires 500 metal while you have 1400 metal in total, one of the fortresses will fail to queue the batch, but the other two will succeed.

Buttons are supposed to be disabled when the red overlay is present. Can you tell me how to reproduce that issue? I can presently manage to do it because the overlay display is calculated at render-time, so if I click more than once per rendered frame, I can end up attempting to queue more than I have resources for.

I was thinking that right click should probably decrement the batch size by five, much as left click increments it by five. That'd at least allow you to correct mistakes (whether your batch is about to fail or you just didn't want that many units).

Link to comment
Share on other sites

Buttons are supposed to be disabled when the red overlay is present. Can you tell me how to reproduce that issue? I can presently manage to do it because the overlay display is calculated at render-time, so if I click more than once per rendered frame, I can end up attempting to queue more than I have resources for.

Indeed, that was what I meant. Perhaps a check could be made when the button is clicked ("sufficient resources? if not, ignore click")?

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...