00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00031
00032 #pragma once
00033
00034 #include "../api_display.h"
00035 #include "../../Core/Text/string_types.h"
00036 #include "../Render/graphic_context.h"
00037 #include "../Render/texture.h"
00038 #include "../Image/pixel_buffer.h"
00039 #include <vector>
00040
00041 class CL_SpriteDescription_Impl;
00042 class CL_ResourceManager;
00043
00047 class CL_SpriteDescriptionFrame
00048 {
00049 public:
00050 enum FrameType
00051 {
00052 type_pixelbuffer,
00053 type_texture
00054 };
00055
00056 public:
00057
00062 CL_SpriteDescriptionFrame(CL_PixelBuffer pixelbuffer, CL_Rect rect) : pixelbuffer(pixelbuffer), rect(rect), type(type_pixelbuffer), delay(1.0) { }
00063
00068 CL_SpriteDescriptionFrame(CL_Texture texture, CL_Rect rect) : texture(texture), rect(rect), type(type_texture), delay(1.0) { }
00069
00070 CL_PixelBuffer pixelbuffer;
00071 CL_Texture texture;
00072 CL_Rect rect;
00073 FrameType type;
00074 double delay;
00075 };
00076
00085 class CL_API_DISPLAY CL_SpriteDescription
00086 {
00089 public:
00094 CL_SpriteDescription();
00095
00101 CL_SpriteDescription(CL_GraphicContext &gc, const CL_StringRef &resource_id, CL_ResourceManager *resources, const CL_ImageImportDescription &import_desc = CL_ImageImportDescription ());
00102
00106 CL_SpriteDescription(const CL_SpriteDescription ©);
00107
00108 ~CL_SpriteDescription();
00109
00113 public:
00115 const std::vector<CL_SpriteDescriptionFrame> &get_frames() const;
00116
00120 public:
00122 CL_SpriteDescription &operator =(const CL_SpriteDescription ©);
00123
00129 void add_frame(const CL_PixelBuffer &pixelbuffer);
00130
00134 void add_frame(const CL_Texture &texture);
00135
00139 void add_frame(const CL_StringRef &fullname, const CL_ImageImportDescription &import_desc = CL_ImageImportDescription ());
00140
00145 void add_frame(CL_IODevice &file, const CL_String &image_type, const CL_ImageImportDescription &import_desc = CL_ImageImportDescription ());
00146
00151 void add_frame(const CL_StringRef &filename, CL_VirtualDirectory &dir, const CL_ImageImportDescription &import_desc = CL_ImageImportDescription ());
00152
00158 void add_frames(const CL_Texture &texture, CL_Rect *frames, int num_frames);
00159
00161
00169 void add_gridclipped_frames(
00170 const CL_PixelBuffer &pixelbuffer,
00171 int xpos, int ypos,
00172 int width, int height,
00173 int xarray = 1, int yarray = 1,
00174 int array_skipframes = 0,
00175 int xspacing = 0, int yspacing = 0);
00176
00177 void add_gridclipped_frames(
00178 const CL_Texture &texture,
00179 int xpos, int ypos,
00180 int width, int height,
00181 int xarray = 1, int yarray = 1,
00182 int array_skipframes = 0,
00183 int xspacing = 0, int yspacing = 0);
00184
00186
00195 void add_alphaclipped_frames(
00196 const CL_PixelBuffer &pixelbuffer,
00197 int xpos = 0, int ypos = 0,
00198 double trans_limit = 0.05f);
00199
00200 void add_alphaclipped_frames(
00201 const CL_Texture &texture,
00202 int xpos = 0, int ypos = 0,
00203 double trans_limit = 0.05f);
00204
00206
00214 void add_alphaclipped_frames_free(
00215 const CL_PixelBuffer &pixelbuffer,
00216 int xpos = 0, int ypos = 0,
00217 double trans_limit = 0.05f);
00218
00219 void add_alphaclipped_frames_free(
00220 const CL_Texture &texture,
00221 int xpos = 0, int ypos = 0,
00222 double trans_limit = 0.05f);
00223
00225 void set_frame_delay(int frame, double delay);
00226
00230 private:
00232 CL_SharedPtr<CL_SpriteDescription_Impl> impl;
00234 };
00235