Light Style© by Fisana

Jump to content


Photo

Show icons as red if not enough resources


  • Please log in to reply
19 replies to this topic

#1 howlingflute

howlingflute

    Discens

  • Community Members
  • Pip
  • 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

  • unitRed.png
  • constructionRed.png

Attached Files


  • 0

#2 MishFTW

MishFTW

    Primus Pilus

  • Web Development Team
  • 1,919 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.
  • 0
Mish [Adarash Mishra]
Wildfire Games Webmaster
Email Me | About Me

#3 wraitii

wraitii

    Primus Pilus

  • WFG Programming Team
  • 1,654 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.

  • 0
Lancelot de Ferrière le Vayer [ aka 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

    Centurio

  • Community Members
  • PipPipPipPipPip
  • 937 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.

  • 0

#5 wraitii

wraitii

    Primus Pilus

  • WFG Programming Team
  • 1,654 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.
  • 0
Lancelot de Ferrière le Vayer [ aka 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

    Cartographer of imaginary worlds

  • 0 A.D. Project Leader
  • 7,803 posts

Posted 29 April 2012 - 01:27 PM

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

Erik Johansson [ aka feneur ]

Wildfire Games
Contact me: feneur@wildfiregames.com



Support Wildfire Games!


#7 fabio

fabio

    Centurio

  • WFG Programming Team
  • 644 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.
  • 0

Graphics problems with 0 A.D. under Ubuntu and free drivers? Check out the Updated and Optimized Graphics Drivers Archive: includes updated drivers with fixes and improvements for games, including 0 A.D..


#8 historic_bruno

historic_bruno

    Primus Pilus

  • WFG Programming Team
  • 2,399 posts

Posted 29 April 2012 - 10:00 PM

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

Agreed.
  • 0
Ben Brian [ aka historic_bruno ]

Wildfire Games Programmer
Contact me: ben [at] wildfiregames [dot] com

#9 Mythos_Ruler

Mythos_Ruler

    Senator

  • WFG Retired
  • 14,965 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.
  • 0

#10 wraitii

wraitii

    Primus Pilus

  • WFG Programming Team
  • 1,654 posts

Posted 08 May 2012 - 07:51 AM

Any update?
  • 0
Lancelot de Ferrière le Vayer [ aka 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

    Sesquiplicarius

  • Community Members
  • PipPip
  • 157 posts

Posted 08 May 2012 - 08:33 AM

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

#12 wraitii

wraitii

    Primus Pilus

  • WFG Programming Team
  • 1,654 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


  • 0
Lancelot de Ferrière le Vayer [ aka 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

    Centurio

  • WFG Retired
  • 724 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...
  • 2

Kieran P [ aka k776 ]


#14 wraitii

wraitii

    Primus Pilus

  • WFG Programming Team
  • 1,654 posts

Posted 02 August 2012 - 06:12 AM

Allright :)
  • 0
Lancelot de Ferrière le Vayer [ aka 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

    Discens

  • Community Members
  • Pip
  • 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.
  • 0

#16 zoot

zoot

    Primus Pilus

  • Community Members
  • PipPipPipPipPipPip
  • 1,562 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.
  • 0

#17 Deiz

Deiz

    Princeps Civitatis

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

#18 zoot

zoot

    Primus Pilus

  • Community Members
  • PipPipPipPipPipPip
  • 1,562 posts

Posted 26 August 2012 - 08:10 PM

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

#19 fabio

fabio

    Centurio

  • WFG Programming Team
  • 644 posts

Posted 02 September 2012 - 10:00 AM

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

Graphics problems with 0 A.D. under Ubuntu and free drivers? Check out the Updated and Optimized Graphics Drivers Archive: includes updated drivers with fixes and improvements for games, including 0 A.D..


#20 Shield Bearer

Shield Bearer

    Primus Pilus

  • WFG Retired
  • 1,621 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 :)
  • 0

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