comparison libmlk-rpg/mlk/rpg/map-loader.h @ 631:bb67f935a93f

rpg: rework a little tileset/map loaders
author David Demelier <markand@malikania.fr>
date Sun, 27 Aug 2023 11:28:35 +0200
parents f9e85d0aca74
children
comparison
equal deleted inserted replaced
630:8d8fe99b357c 631:bb67f935a93f
138 */ 138 */
139 struct mlk_map_block * (*expand_blocks)(struct mlk_map_loader *self, 139 struct mlk_map_block * (*expand_blocks)(struct mlk_map_loader *self,
140 struct mlk_map *map, 140 struct mlk_map *map,
141 struct mlk_map_block *blocks, 141 struct mlk_map_block *blocks,
142 size_t blocksz); 142 size_t blocksz);
143
144 /**
145 * (read-write, optional)
146 *
147 * Cleanup resources allocated for this mao.
148 *
149 * This is different than finalizing the loader itself, it should be
150 * re-usable after calling this function.
151 *
152 * \param self this loader
153 * \param map the underlying map to cleanup
154 */
155 void (*clear)(struct mlk_map_loader *self, struct mlk_map *map);
156
157 /**
158 * (read-write, optional)
159 *
160 * Cleanup the map loader.
161 *
162 * \param self this loader
163 */
164 void (*finish)(struct mlk_map_loader *self);
143 }; 165 };
144 166
145 #if defined(__cplusplus) 167 #if defined(__cplusplus)
146 extern "C" { 168 extern "C" {
147 #endif 169 #endif
177 mlk_map_loader_openmem(struct mlk_map_loader *loader, 199 mlk_map_loader_openmem(struct mlk_map_loader *loader,
178 struct mlk_map *map, 200 struct mlk_map *map,
179 const void *data, 201 const void *data,
180 size_t datasz); 202 size_t datasz);
181 203
204 /**
205 * Cleanup data for this map.
206 *
207 * The loader is re-usable after calling this function to load a new map.
208 *
209 * Invokes ::mlk_map_loader::clear.
210 *
211 * \pre loader != NULL
212 * \param loader the loader interface
213 * \param map the map used with this loader
214 */
215 void
216 mlk_map_loader_clear(struct mlk_map_loader *loader, struct mlk_map *map);
217
218 /**
219 * Finalize the loader itself.
220 *
221 * The underlying interface should also clear map resources by convenience
222 * if the user forgot to call ::mlk_map_loader_clear.
223 *
224 * Invokes ::mlk_map_loader::finish.
225 *
226 * \pre loader != NULL
227 * \param loader the loader to finalize
228 */
229 void
230 mlk_map_loader_finish(struct mlk_map_loader *loader);
231
182 #if defined(__cplusplus) 232 #if defined(__cplusplus)
183 } 233 }
184 #endif 234 #endif
185 235
186 #endif /* !MLK_RPG_MAP_FILE_H */ 236 #endif /* !MLK_RPG_MAP_FILE_H */