I am currently looking into making a combat log for a game in C++ using Directx9.

I know there is a game forum, but my question is more general. Also, every chat/combat log post I look for tends to be about client/server winsock stuff

Basically I am wondering how the chat/combat log data is best stored, with the following in mind:

- The data will not be stored to a file- The data will be stored on a line-by-line basis- The data can be of any total length (A game can technically go on indefinitely)- A single line will probably have a maximum length- The data will need to have the ability to store graphics as well as text. i.e. I would like the text to be able to say "Player 1 has gained 3 [image of a yellow star]". This would also need to allow me to hover of the yellow star image to display a tooltip.- The data will need to have filter options. i.e. filtering it so you only see Player 1's actions, or you only see environment effects.

Ideally I would like to be able to use ID3DXFont's DrawTextW method for actually printing the text as I already have this functioning and scaling for resolution. My main issues are whether the above outlined code is suitable for the job and how I would determine and place a ChatIcon within the line of text.

Right now my best guess is I that I would need to read through the CombatLogLine and get each position of a ChatIcon and split the text for each icon, making a rectangle of the text up to that point using DrawTextW and placing the icon image at the end of the rectangle's position (setting it's screenPosition) and repeat this process with the remaining text until the line is drawn.

From there I can loop through my ChatIcons for the visible text lines and see if my cursor is hovering over any of them and display the correct tooltip.

What worries me here is the drawing of the lines, as it would seem I need to perform this action every frame with a specialised method to split the text up and intersperse it with icons. I am not sure how much of an impact such an operation would have, but I generally see the program displaying a maximum of 20 lines at once.

Any advice or confirmation/suggestions of methods here is much appreciated.

Buy the book Design Patterns: Elements of Reusable Object-Oriented Software, by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides. It sounds like you're at the point where it'd be rather useful.

For filtering reasons I would add a type field to your CombatLogLine struct.

Have you profiled this case for being slow already, if not don´t worry about it untill it becomes a problem, but an idea to reduce the drawcalls is to combine all of the CombatLogLines into one string seperated with carrage return feed symbol if they don't contain an image. This will then only use one call to D3DXFont::DrawText for that portion of text.

Buy the book Design Patterns: Elements of Reusable Object-Oriented Software, by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides. It sounds like you're at the point where it'd be rather useful.

Thank you for the book suggestion. Added a link to the book for when I am not horrifically poor

For filtering reasons I would add a type field to your CombatLogLine struct.

Have you profiled this case for being slow already, if not don´t worry about it untill it becomes a problem, but an idea to reduce the drawcalls is to combine all of the CombatLogLines into one string seperated with carrage return feed symbol if they don't contain an image. This will then only use one call to D3DXFont::DrawText for that portion of text.

Yeah, a type field would probably be a good idea, maybe with a source and flags for the type. Like Source = Player 1 and Type = LTYPE_COMBAT | LTYPE_GETHIT

You're right, I probably should worry about performance when it actually becomes an issue. ^^

For images in the chat log take a look at half life and team fortress. They actually use custom fonts to render images in the chat window. Lets say your game doesn't use the £ symbol anywhere then you could replace that with a star in your font. There are a few font creators online that you can use.