IPB Style© Fisana

Jump to content


Show icons as red if not enough resources


  • Please log in to reply
19 replies to this topic

#1 howlingflute

howlingflute

  • Community Members
    Pip

  • Discens
    (59 posts)

Posted 28 April 2012 - 09:24 PM

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.

Attached Thumbnails

  • Attached Image: unitRed.png
  • Attached Image: constructionRed.png

Attached Files



#2 Geek377

Geek377

  • Web Development Team

  • Primus Pilus
    (1,718 posts)

Posted 28 April 2012 - 10:48 PM

If you created a Trac account, then you should. Nice patch BTW, this would be better than the little message that shows up.
The Geek [ aka Geek377]
Wildfire Games Webmaster
Contact me: Posted Image Posted Image

#3 wraitii

wraitii

  • WFG Programming Team

  • Primus Pilus
    (1,003 posts)

Posted 29 April 2012 - 06:38 AM

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, 29 April 2012 - 07:20 AM.

Wraitii
Wildfire Games Programmer, AI developer, auxiliary map designer, dealing with anything water.
Contact me: wraitii@wildfiregames.com

Also the world's only three-dimensional poodle.

#4 FeXoR

FeXoR

  • Community Members
    PipPipPipPipPip

  • Centurio
    (659 posts)

Posted 29 April 2012 - 08:27 AM

 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, 29 April 2012 - 08:28 AM.

Posted Image Im Übrigen bin ich der Meinung, dass 0A.D. Auslöser braucht. (IMO 0A.D. needs triggers ASAP.)

#5 wraitii

wraitii

  • WFG Programming Team

  • Primus Pilus
    (1,003 posts)

Posted 29 April 2012 - 10:17 AM

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.
Wraitii
Wildfire Games Programmer, AI developer, auxiliary map designer, dealing with anything water.
Contact me: wraitii@wildfiregames.com

Also the world's only three-dimensional poodle.

#6 feneur

feneur

  • 0 A.D. Project Leader

  • Cartographer of imaginary worlds
    (7,059 posts)

Posted 29 April 2012 - 01:27 PM

View Posthowlingflute, on 28 April 2012 - 09:24 PM, said:

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

Erik Johansson [ aka feneur ]

Wildfire Games
Contact me: feneur@wildfiregames.com



Support Wildfire Games!


#7 fabio

fabio

  • WFG Programming Team

  • Triplicarius
    (441 posts)

Posted 29 April 2012 - 01:31 PM

Nice :).

Maybe you can also enfatize the missing resources using a red color for them in the tooltip.
Graphics problems with 0 A.D. under Ubuntu and free drivers? Check out the Updated and Optimized Graphics Drivers Archive: includes updated mesa drivers with fixes for 0 A.D., OpenGL 3.1+, S3TC Compressed Textures (to save 75% of video memory), llvm support (for faster gallium drivers) and a lot more!

#8 historic_bruno

historic_bruno

  • WFG Programming Team

  • Primus Pilus
    (1,923 posts)

Posted 29 April 2012 - 10:00 PM

View Postfabio, on 29 April 2012 - 01:31 PM, said:

Maybe you can also enfatize the missing resources using a red color for them in the tooltip.
Agreed.
Ben Brian [ aka historic_bruno ]

Wildfire Games Programmer
Contact me: ben@wildfiregames.com

#9 Mythos_Ruler

Mythos_Ruler

  • 0 A.D. Project Leader

  • Megas Philhellene
    (13,778 posts)

Posted 29 April 2012 - 10:45 PM

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.
Michael D. Hafer [aka Mythos_Ruler]

Wildfire Games Project Leader
Contact me: michaeldhafer[at]gmail.com
Support Wildfire Games!


0 A.D.

#10 wraitii

wraitii

  • WFG Programming Team

  • Primus Pilus
    (1,003 posts)

Posted 08 May 2012 - 07:51 AM

Any update?
Wraitii
Wildfire Games Programmer, AI developer, auxiliary map designer, dealing with anything water.
Contact me: wraitii@wildfiregames.com

Also the world's only three-dimensional poodle.

#11 majapahit

majapahit

  • Community Members
    PipPip

  • Sesquiplicarius
    (157 posts)

Posted 08 May 2012 - 08:33 AM

Thats practical & helpful (y)
----------
Fried Banana, Steamed Banana, Banana Kolak, Nagasari, Banana Ceriping, and still many more delicious banana based cuisine.

#12 wraitii

wraitii

  • WFG Programming Team

  • Primus Pilus
    (1,003 posts)

Posted 01 August 2012 - 10:14 AM

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.

Attached Files


Wraitii
Wildfire Games Programmer, AI developer, auxiliary map designer, dealing with anything water.
Contact me: wraitii@wildfiregames.com

Also the world's only three-dimensional poodle.

#13 k776

k776

  • Open Source Development Manager

  • Centurio
    (656 posts)

Posted 02 August 2012 - 05:12 AM

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

Kieran P [ aka k776 ]
Wildfire Games Open Source Development Manager
Contact me: kieran@wildfiregames.com


#14 wraitii

wraitii

  • WFG Programming Team

  • Primus Pilus
    (1,003 posts)

Posted 02 August 2012 - 06:12 AM

Allright :)
Wraitii
Wildfire Games Programmer, AI developer, auxiliary map designer, dealing with anything water.
Contact me: wraitii@wildfiregames.com

Also the world's only three-dimensional poodle.

#15 howlingflute

howlingflute

  • Community Members
    Pip

  • Discens
    (59 posts)

Posted 03 August 2012 - 04:47 PM

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.

#16 zoot

zoot

  • Community Members
    PipPipPipPipPipPip

  • Primus Pilus
    (1,472 posts)

Posted 26 August 2012 - 07:10 PM

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.

#17 Deiz

Deiz

  • WFG Programming Team

  • Princeps Civitatis
    (76 posts)

Posted 26 August 2012 - 07:48 PM

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).
Deiz
Wildfire Games Programmer
Contact me: deiz@wildfiregames.com

#18 zoot

zoot

  • Community Members
    PipPipPipPipPipPip

  • Primus Pilus
    (1,472 posts)

Posted 26 August 2012 - 08:10 PM

View PostDeiz, on 26 August 2012 - 07:48 PM, said:

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")?

#19 fabio

fabio

  • WFG Programming Team

  • Triplicarius
    (441 posts)

Posted 02 September 2012 - 10:00 AM

The phase button is grey rather than red when resources are missing. Is this intended?
Graphics problems with 0 A.D. under Ubuntu and free drivers? Check out the Updated and Optimized Graphics Drivers Archive: includes updated mesa drivers with fixes for 0 A.D., OpenGL 3.1+, S3TC Compressed Textures (to save 75% of video memory), llvm support (for faster gallium drivers) and a lot more!

#20 Shield Bearer

Shield Bearer

  • 0 A.D. Art Team

  • Primus Pilus
    (1,578 posts)

Posted 02 September 2012 - 12:26 PM

Its greyed out when you haven't built the required buildings, after you have and still don't have enough resources its red :)
Amish Coelho [aka Shield Bearer aka gAMeboy]
Wildfire Games Art Department
Contact me: amish13@gmail.com
AIM handle: Mythgamer
MSN Account: amish13@live.com


"The fate of 0 AD is in the hands of those who have vision and perseverance." - Ken Wood




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users