changeset 1051:8679b03f72e8

Move declaration about sprite to a separated header file.
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 24 Nov 2010 14:19:00 +0800
parents 83f39fdfbdaa
children 1f93f38688c2
files include/mb.h include/mb_redraw_man.h include/mb_sprite.h include/mb_types.h src/sprite.c tools/mb_c_source.m4
diffstat 6 files changed, 72 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/include/mb.h	Wed Nov 24 12:42:30 2010 +0800
+++ b/include/mb.h	Wed Nov 24 14:19:00 2010 +0800
@@ -16,5 +16,6 @@
 #include "mb_animate.h"
 #include "mb_shapes.h"
 #include "mb_backend.h"
+#include "mb_sprite.h"
 
 #endif /* __MB_H_ */
--- a/include/mb_redraw_man.h	Wed Nov 24 12:42:30 2010 +0800
+++ b/include/mb_redraw_man.h	Wed Nov 24 14:19:00 2010 +0800
@@ -220,23 +220,8 @@
  *
  */
 #define rdman_attach_backend(rdman,backend) (((rdman)->rt)=(backend))
-/*! \brief Load sprite dymanicly from the shared object module.
- *
- * The search path can be changed by sprite_set_search_path. The name
- * can have a relative path in the front of it.
- * This function will search the object in the current working directory
- * and then search the system search path.
- */
-extern mb_sprite_t *sprite_load(const char *name, redraw_man_t *rdman,
-				coord_t *root);
-
-/*! \brief Set the search path of dymanic object loading.
- *
- */
-extern void sprite_set_search_path(const char *path);
 
 extern paint_t *rdman_img_ldr_load_paint(redraw_man_t *rdman,
 					 const char *img_id);
 
-
 #endif /* __REDRAW_MAN_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/mb_sprite.h	Wed Nov 24 14:19:00 2010 +0800
@@ -0,0 +1,69 @@
+#ifndef __MB_SPRITE_H_
+#define __MB_SPRITE_H_
+
+#include "mb_types.h"
+#include "mb_redraw_man.h"
+
+/*! \defgroup mb_sprite  Implement sprites for animation.
+ * @{
+ */
+/*! \brief A sprite is a set of graphics that being an object in animation.
+ *
+ * A sprite include graphics comprise an object.  For example, a tank, in
+ * example tank, is comprised a set of graphics that is represented as a
+ * sprite.
+ */
+struct _mb_sprite {
+    void (*free)(mb_sprite_t *);
+    mb_obj_t *(*get_obj_with_name)(mb_sprite_t *sprite, const char *id);
+    /*! Return non-zero for error. */
+    int (*goto_scene)(mb_sprite_t *sprite, int scene_no);
+};
+
+#define MB_SPRITE_FREE(sprite) ((mb_sprite_t *)(sprite))->free(sprite)
+#define MB_SPRITE_GET_OBJ(sprite, name)					\
+    ((mb_sprite_t *)(sprite))->get_obj_with_name((mb_sprite_t *)(sprite), \
+						 (name))
+#define MB_SPRITE_GOTO_SCENE(sprite, scene_no)				\
+    ((mb_sprite_t *)(sprite))->goto_scene((mb_sprite_t *)(sprite), scene_no)
+
+
+/*! \brief Load sprite dymanicly from the shared object module.
+ *
+ * The search path can be changed by sprite_set_search_path. The name
+ * can have a relative path in the front of it.
+ * This function will search the object in the current working directory
+ * and then search the system search path.
+ */
+extern mb_sprite_t *sprite_load(const char *name, redraw_man_t *rdman,
+				coord_t *root);
+
+/*! \brief Set the search path of dymanic object loading.
+ *
+ */
+extern void sprite_set_search_path(const char *path);
+
+/*! \defgroup mb_sprite_lsym Sprite with linear symbol table.
+ * @{
+ */
+struct _mb_sprite_lsym_entry {
+    const char *sym;
+    const int offset;
+};
+typedef struct _mb_sprite_lsym_entry mb_sprite_lsym_entry_t;
+
+/*! \brief A sub-type of mb_sprite_t with linear symbol table.
+ *
+ * This type of sprite search symbols with linear/or binary searching.
+ */
+struct _mb_sprite_lsym {
+    mb_sprite_t sprite;
+    int num_entries;
+    mb_sprite_lsym_entry_t *entries;
+};
+typedef struct _mb_sprite_lsym mb_sprite_lsym_t;
+/* @} */
+/* @} */
+
+#endif /* __MB_SPRITE_H_ */
+
--- a/include/mb_types.h	Wed Nov 24 12:42:30 2010 +0800
+++ b/include/mb_types.h	Wed Nov 24 14:19:00 2010 +0800
@@ -428,48 +428,4 @@
 #define sh_set_stroke_width(sh, v) do { (sh)->stroke_width = (v); } while(0)
 #define sh_get_stroke_width(sh) (sh)->stroke_width
 
-
-/*! \brief A sprite is a set of graphics that being an object in animation.
- *
- * A sprite include graphics comprise an object.  For example, a tank, in
- * example tank, is comprised a set of graphics that is represented as a
- * sprite.
- */
-struct _mb_sprite {
-    void (*free)(mb_sprite_t *);
-    mb_obj_t *(*get_obj_with_name)(mb_sprite_t *sprite, const char *id);
-    /*! Return non-zero for error. */
-    int (*goto_scene)(mb_sprite_t *sprite, int scene_no);
-};
-
-#define MB_SPRITE_FREE(sprite) ((mb_sprite_t *)(sprite))->free(sprite)
-#define MB_SPRITE_GET_OBJ(sprite, name)					\
-    ((mb_sprite_t *)(sprite))->get_obj_with_name((mb_sprite_t *)(sprite), \
-						 (name))
-#define MB_SPRITE_GOTO_SCENE(sprite, scene_no)				\
-    ((mb_sprite_t *)(sprite))->goto_scene((mb_sprite_t *)(sprite), scene_no)
-
-
-/*! \defgroup mb_sprite_lsym Sprite with linear symbol table.
- * @{
- */
-struct _mb_sprite_lsym_entry {
-    const char *sym;
-    const int offset;
-};
-typedef struct _mb_sprite_lsym_entry mb_sprite_lsym_entry_t;
-
-/*! \brief A sub-type of mb_sprite_t with linear symbol table.
- *
- * This type of sprite search symbols with linear/or binary searching.
- */
-struct _mb_sprite_lsym {
-    mb_sprite_t sprite;
-    int num_entries;
-    mb_sprite_lsym_entry_t *entries;
-};
-typedef struct _mb_sprite_lsym mb_sprite_lsym_t;
-
-/* @} */
-
 #endif /* __MB_TYPES_H_ */
--- a/src/sprite.c	Wed Nov 24 12:42:30 2010 +0800
+++ b/src/sprite.c	Wed Nov 24 14:19:00 2010 +0800
@@ -3,15 +3,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "mb_graph_engine.h"
 #include <dlfcn.h>
 #include <sys/stat.h>
 #include "mb_types.h"
-#include "mb_shapes.h"
-#include "mb_tools.h"
 #include "mb_redraw_man.h"
-#include "mb_observer.h"
-#include "mb_prop.h"
+#include "mb_sprite.h"
 
 #define ASSERT(x)
 #define OK 0
--- a/tools/mb_c_source.m4	Wed Nov 24 12:42:30 2010 +0800
+++ b/tools/mb_c_source.m4	Wed Nov 24 14:19:00 2010 +0800
@@ -475,6 +475,7 @@
 #include <mb_redraw_man.h>
 #include <mb_shapes.h>
 #include <mb_paint.h>
+#include <mb_sprite.h>
 #include "$1.h"
 
 #ifdef MB_SPRITE_OFFSET