Jump to content
  • Advertisement
Sign in to follow this  
White Scorpion

My own message box ?

This topic is 5400 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

Hi everyone ! I'm making an engine for a little game I'll try to make but there's one thing I don't know how to do, I'd want to have my own message box (just like many many games out there, you output a message with a message box proper to your game, not Win32's) but I don't know how I would do a box that would adjust to length of the text outputted and how would I do the box itself ? I know it must be pretty hard but if any of you guys have any idea, I'd really appreciate it thank you guys

Share this post


Link to post
Share on other sites
Advertisement
Hey,

There are quite a number of ways of doing this. One would be to choose a font that has the same width for every alphabet (which is mostly the case in the pre made Font Engine in DirectX), so you would simply need to count the number of characters to get the width. From this you could then create a simple quad of 2 polygons, which would act as your messagebox. This quad would have the simple layout of your messagebox as the texture, and you would simply need to write on it using the DirectX font engine ;) This would be a simple one, but if you want a more advanced one, writing your own font engine (theres been a thread here somewhere on this) would be a good idea, and maybe a whole wrapper class for this.

Share this post


Link to post
Share on other sites
Fixed-width fonts usually look pretty awkward, especially if words have lots of narrow characters, such as 'i' or 'l'. It's not too big a deal admittedly, but you'll definately notice the difference. Just store a width tag with each character, and use this when calculating text-length, and drawing.

Another consideration for message boxes is whether to make them modal or not, ie does your engine continue running in the background, or does it stop until you dismiss the message box. Hooking a modal message box into the system can be a pain, especially if you want to be able to input text into it.

It's worth taking the time to create a good, flexible font & dialog box system, it's very re-usable.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!