Sign in to follow this  
Followers 0
howlingflute

Show icons as red if not enough resources

20 posts in this topic

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

Share this post


Link to post
Share on other sites

If you created a Trac account, then you should. Nice patch BTW, this would be better than the little message that shows up.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

I tried it quickly (in an inelegant way, and I want to leave the implementation to howlingflute anyway) and I guess something that ranges from alpha 75 to alpha 175 for a lack of resource from 0 to 500 would work well.

Share this post


Link to post
Share on other sites

but I am not to be able to log into Trac for some reason.

Take a look at your private messages here in the forums if you haven't already... :)

Share this post


Link to post
Share on other sites

Nice :).

Maybe you can also enfatize the missing resources using a red color for them in the tooltip.

Share this post


Link to post
Share on other sites

Maybe you can also enfatize the missing resources using a red color for them in the tooltip.

Agreed.

Share this post


Link to post
Share on other sites

Another enhancement is to have the resource up in the ribbon flash when you hover over the icon of the building or unit to be built.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Please put this in a Trac ticket if it isn't already. Don't leave patches on the forum. They will disappear and die...

2 people like this

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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).

Share this post


Link to post
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")?

Share this post


Link to post
Share on other sites

The phase button is grey rather than red when resources are missing. Is this intended?

Share this post


Link to post
Share on other sites

Its greyed out when you haven't built the required buildings, after you have and still don't have enough resources its red :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0