Page 1 of 1

getting tool tips to work

PostPosted: Wed Dec 07, 2011 06:46
by janitor61
https://gist.github.com/1441721

(actual .cpp edits start at 486)

I am able to get the tool tip reading out the information on hover, and I could write out InventoryItem->getText(), which gives me a string like "1 blahblah 2", so I decided to add descriptions in init.lua and try to percolate them through the various objects and interfaces, all to no avail. Strangely enough the "Wooden Plank" works fine, but everything else is blank.

I've added the description member to the serialization methods in ContentFeatures (for nodes), and the IToolDefManager and ICraftItemDefManager implementors, I can't think of what else I need to do. Any thoughts?

PostPosted: Wed Dec 07, 2011 12:11
by dannydark
@Janitor61: I can't currently help out as I'm on my work computer, but I will try and have a look when I get home from work. Tool tips have been needed for some time now so its great to see somebody working on them ^_^

PostPosted: Wed Dec 07, 2011 17:52
by janitor61
oh, and here's my branch: https://github.com/janitor61/minetest/tree/testbranch (apologies for the nondescript name)

If all else fails I suppose I could add a dictionary for the description names using the InventoryItem->getText() return as a key with something like irr::core::map...

PostPosted: Thu Dec 08, 2011 05:42
by kahrl
You defined "std::string getDescription()" in InventoryItem and MaterialItem, but "std::string getDescription() const" in CraftItem and ToolItem. These are different overloads.

PostPosted: Thu Dec 08, 2011 09:46
by janitor61
kahrl wrote:You defined "std::string getDescription()" in InventoryItem and MaterialItem, but "std::string getDescription() const" in CraftItem and ToolItem. These are different overloads.


You're right - thank you for pointing that out; I was able to get this to work, updated my fork and made a feature branch:

https://github.com/celeron55/minetest/pull/31

PostPosted: Thu Dec 08, 2011 12:01
by dannydark
Nice work Janitor61 ^_^ I'll definitely be merging this when I get home.

PostPosted: Sat Dec 10, 2011 16:00
by dannydark
Been playing around with this and I like it, my only criticism is that you used buttons for the tooltip I would have thought that making the tooltip static text with a slightly transparent background would have been better.