logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

load_datafile_callback - Loads a datafile into memory, calling a hook per object. Allegro game

Description

       Loads a datafile into memory, calling the specified hook function once  for  each  object  in  the  file,
       passing  it  a pointer to the object just read. You can use this to implement very simple loading screens
       where every time the hook is called, the screen is updated to let the user know  your  program  is  still
       loading from disk:

          void load_callback(DATAFILE *dat_obj)
          {
             static const char indicator[] = "-\\|/-.oOXOo.";
             static int current = 0;

             /* Show a different character every time. */
             textprintf_ex(screen, font, 0, 0, makecol(0, 0, 0),
                           makecol(255, 255, 255), "%c Loading %c",
                           indicator[current], indicator[current]);
             /* Increase index and check if we need to reset it. */
             current++;
             if (!indicator[current])
                current = 0;
          }
             ...
             dat = load_datafile_callback("data.dat", load_callback);

Name

       load_datafile_callback  -  Loads  a  datafile  into  memory,  calling  a  hook  per  object. Allegro game
       programming library.

Return Value

       Returns  a pointer to the DATAFILE or NULL on error. Remember to free this DATAFILE later to avoid memory
       leaks.

See Also

load_datafile(3alleg4),             unload_datafile(3alleg4),              load_datafile_object(3alleg4),
       set_color_conversion(3alleg4),            fixup_datafile(3alleg4),            packfile_password(3alleg4),
       find_datafile_object(3alleg4), register_datafile_object(3alleg4)

Allegro                                           version 4.4.3                  load_datafile_callback(3alleg4)

Synopsis

#include<allegro.h>DATAFILE*load_datafile_callback(constchar*filename,void(*callback)(DATAFILE*d));

See Also