Jump to content
  • Advertisement
Sign in to follow this  
Antonym

How To: Info boxes

This topic is 3327 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering how I could do something similar to what blizzard does with its icons, that if you place the cursor on top of one a small box will display with all the information. I use direct 3d and c++. [Edited by - Antonym on April 18, 2009 3:15:36 AM]

Share this post


Link to post
Share on other sites
Advertisement
You'll have to write that yourself. Mostly if you already have an UI and icons it shouldn't be too difficult to know when the cursor enters the client area of your icons, have a timer to know how long the cursor remains in the client area and then display a tooltip (just a quad with text) which gets destroyed when the cursor leaves the area. Of course if you don't have the framework already it's much trickier :).

Share this post


Link to post
Share on other sites
A quad with text?

I am not sure if what I have so far could be called a framework. I have an icon class. Whenever a player clicks the screen an IconClicked() function on each instance of the class is called to check if the click occurred within the icon's rect.

Share this post


Link to post
Share on other sites
You need to break this down a bit.

  • You need to be able to render text somehow.
  • You need to be able to format and render text into a rectangle with wordwrap and so on, also perhaps with a border.
  • You need to store the previous mouse position each frame.
  • You need to time how long the mouse position remains the same as it was last frame (or, "the same" within a certain tolerance).
  • Once this timer passes a certain threshold, you need to detect what is under the mouse and decide whether to display a tip.
  • You need to display the tip, using the above rendering methods.
  • You need to keep track of the fact that this tip is displayed so that when the mouse moves outside the icon, you can stop displaying the tip. This is going to be highly dependant on your implementation.


  • IIRC, you are working on a Direct3D application. ID3DXFont will give you the capacity to render text, although performance may not be great.

    Since you have to re-render the whole screen each iteration of your game loop, you will need to store some kind of state that can track whether a tip is displayed, where it is displayed and what is displayed.

    Share this post


    Link to post
    Share on other sites
    Sign in to follow this  

    • Advertisement
    ×

    Important Information

    By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

    Participate in the game development conversation and more when you create an account on GameDev.net!

    Sign me up!