resor.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #ifndef RESOR_H_INCLUDED
  2. #define RESOR_H_INCLUDED
  3. #include "rebox.h"
  4. enum ResorKind_ {
  5. RESOR_NONE = 0,
  6. RESOR_BITMAP = 1,
  7. RESOR_FONT = 2,
  8. RESOR_AUDIO_STREAM = 3,
  9. RESOR_SAMPLE = 4,
  10. RESOR_CONFIG = 5,
  11. RESOR_OTHER = 8,
  12. RESOR_TILEMAP = 9,
  13. };
  14. enum ResorStatus_ {
  15. RESOR_OK = 0,
  16. RESOR_EMPTY = 1,
  17. RESOR_ENOENT = 2,
  18. RESOR_ENOMEM = 3,
  19. RESOR_NULL = 4,
  20. };
  21. typedef enum ResorKind_ ResorKind;
  22. typedef enum ResorStatus_ ResorStatus;
  23. typedef union ResorData_ ResorData;
  24. typedef struct Resor_ Resor;
  25. union ResorData_ {
  26. ALLEGRO_BITMAP * bitmap;
  27. ALLEGRO_FONT * font;
  28. ALLEGRO_SAMPLE * sample;
  29. ALLEGRO_AUDIO_STREAM * stream;
  30. ALLEGRO_CONFIG * config;
  31. void * other;
  32. };
  33. typedef int ResorDestructor(Resor * self);
  34. typedef void* ResorLoader(const char * vpath, void * extra);
  35. ALLEGRO_SAMPLE *resor_sample(Resor *self);
  36. ALLEGRO_AUDIO_STREAM *resor_audio_stream(Resor *self);
  37. ALLEGRO_BITMAP *resor_bitmap(Resor *self);
  38. ALLEGRO_FONT *resor_font(Resor *self);
  39. void * resor_other(Resor * self, unsigned kind);
  40. Resor *
  41. resor_grab_font_from_resor(Resor * res, int count, int ranges[]);
  42. Resor *resor_load_bitmap(const char *vpath);
  43. Resor *resor_load_bitmap_flags(const char *vpath,int flags);
  44. Resor *resor_load_sample(const char *vpath);
  45. Resor *resor_load_audio_stream(const char *vpath,size_t buffer_count,int samples);
  46. Resor *resor_load_bitmap_font(const char *vpath);
  47. Resor *resor_load_bitmap_font_flags(const char *vpath,int flags);
  48. Resor *resor_load_ttf_font(const char *vpath,int h,int flags);
  49. Resor *resor_load_ttf_font_stretch(const char *vpath,int w,int h,int flags);
  50. Resor *
  51. resor_load_other(const char *vpath, ResorKind kind,
  52. ResorLoader * loader, ResorDestructor * destroy, void *extra);
  53. Resor *resor_new_audio_stream(ALLEGRO_AUDIO_STREAM *stream);
  54. Resor *resor_new_sample(ALLEGRO_SAMPLE *sample);
  55. Resor *resor_new_bitmap(ALLEGRO_BITMAP *bitmap);
  56. Resor *resor_new_font(ALLEGRO_FONT *font);
  57. Resor *resor_new(ResorKind kind,ResorData data,ResorDestructor *free);
  58. Resor *resor_new_other(ResorKind kind, void * data, ResorDestructor * free);
  59. Resor *resor_alloc();
  60. Resor *resor_init(Resor *self,ResorKind kind,ResorData data,ResorDestructor *free);
  61. int resor_kind(Resor *self);
  62. int resor_free(Resor *self);
  63. int resor_done(Resor *self);
  64. bool resor_get_bitmap_format(Resor *self,int *value);
  65. bool resor_get_bitmap_flags(Resor *self,int *value);
  66. bool resor_get_bitmap_height(Resor *self,int *value);
  67. bool resor_get_bitmap_width(Resor *self,int *value);
  68. bool resor_get_ustr_dimensions(Resor *self,ALLEGRO_USTR *text,Rebox *value);
  69. bool resor_get_ustr_width(Resor *self,ALLEGRO_USTR *text,int *value);
  70. bool resor_get_text_dimensions(Resor *self,char *text,Rebox *value);
  71. bool resor_get_text_width(Resor *self,char *text,int *value);
  72. bool resor_get_font_line_height(Resor *self,int *value);
  73. bool resor_get_font_descent(Resor *self,int *value);
  74. bool resor_get_font_ascent(Resor *self,int *value);
  75. #endif /* RESOR_H_INCLUDED */