|
Load a string from a datafile |
James Stanley
Member #7,275
May 2006
|
Hi, char *help_text; help_text = (char*)dat_menu[MNU_HELP].dat; But there's nothing in help_text. Am I doing something wrong? EDIT: |
Trent Gamblin
Member #261
April 2000
|
You need to register a loader with Allegro. Use something like this: and a function to destroy the string: void DestroyString(void* data) { delete (char*)data; } Then call register_datafile_object with a line something like this: register_datafile_object(DAT_ID('T', 'E', 'X', 'T'), ReadStringFromPackfile, DestroyString); Now give the text objects the type "TEXT" and load your datafile and dat_menu[MNU_HELP].dat will be a pointer to the character string.
|
Andrei Ellman
Member #3,434
April 2003
|
Trent Gamblin said:
You need to register a loader with Allegro. Use something like this: For simple text data, this is overkill. The method that James uses is adequate, and is the method I use to retrieve text-data from datafiles. AE. -- |
ImLeftFooted
Member #3,935
October 2003
|
Beware of newline problems... |
Trent Gamblin
Member #261
April 2000
|
Oh, I didn't know Allegro would read it in as raw data without registering a loader. I guess I should have read the manual.
|
James Stanley
Member #7,275
May 2006
|
Dustin: Trent: |
|