Jump to content
  • Advertisement
Sign in to follow this  
Fire Lancer

Parsing some simple markup and displaaying it

This topic is 3333 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 what would be the best way to quickly parse a string to pull out formatting data, and then be able to format it quickly later with some sort of error handeling (eg if the format string expects a .name atribute and the object passed doesnt have that attribute). The format of the script does not have to be as describe here, just able to achive the same effect. Eg I have that following string:
Your ship <col=yellow><var>this.name</var></col> was destroyed by <col=yellow><var>killer.name</var></col> in sector <col=yellow></var>this.sector.name</var></col>.



Then when a ship killed I need to pass the info to the renderer (ie the two ship objects involed) so that it can render some text from the above format string on the screen (wrapping to multiple lines correctly if it wont fit within the avaible width). The ship objects have methods like string GetName() and Sector GetSector() (and a GetName for the sector object too) for accessing the info about them. I'm using d3d9 and d3d10 with c++ and am currently using the D3DX Font interfaces for text rendering. Previously I was hardcoding such format stuff but then regretted it when trying to implement the large number of diffrently formatted strings for log entries and mission breifings and stuff like that. [Edited by - Fire Lancer on June 7, 2009 1:45:11 PM]

Share this post


Link to post
Share on other sites
Advertisement
I have no idea what programming language you're working in, but I'm going to guess C++. Have you looked into Boost.Spirit? It's a pretty powerful, yet relatively simple tool.

Share this post


Link to post
Share on other sites
Ok, so that can parse the string (when I work out how...I guess some sort of object model), how am I meant to store the format data, fill out the <var> sections with the argument data and then render it?

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!