Freeciv-3.2
Loading...
Searching...
No Matches
sprite.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2005 The Freeciv Team
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* SDL3 */
19#include <SDL3/SDL.h>
20#include <SDL3_image/SDL_image.h>
21
22/* utility */
23#include "fcintl.h"
24#include "log.h"
25#include "mem.h"
26
27/* client/gui-sdl3 */
28#include "colors.h"
29#include "graphics.h"
30
31#include "sprite.h"
32
33static struct sprite *ctor_sprite(SDL_Surface *surf);
34
35/************************************************************************/
40const char **gfx_fileextensions(void)
41{
42 static const char *ext[] = {
43 "png",
44 "xpm",
45 NULL
46 };
47
48 return ext;
49}
50
51/************************************************************************/
56struct sprite *load_gfxfile(const char *filename, bool svgflag)
57{
60
61 if ((pbuf = IMG_Load(filename)) == NULL) {
62 log_error(_("load_gfxfile(): Unable to load graphic file %s!"), filename);
63 return NULL; /* Should I use abort() ? */
64 }
65
68
69 return ctor_sprite(pconv);
70}
71
72/************************************************************************/
98 int x, int y, int width, int height,
99 struct sprite *mask,
101 float scale, bool smooth)
102{
106
107 if (mask) {
110 return ctor_sprite(pdest);
111 }
112
113 return ctor_sprite(psrc);
114}
115
116/************************************************************************/
119struct sprite *create_sprite(int width, int height, struct color *pcolor)
120{
122
126
128
131 NULL,
132 pcolor->color->r,
133 pcolor->color->g,
134 pcolor->color->b,
135 pcolor->color->a));
136
137 return ctor_sprite(mypixbuf);
138}
139
140/************************************************************************/
144{
145 *width = GET_SURF(sprite)->w;
146 *height = GET_SURF(sprite)->h;
147}
148
149/************************************************************************/
152void free_sprite(struct sprite *s)
153{
154 fc_assert_ret(s != NULL);
156 FC_FREE(s);
157}
158
159/************************************************************************/
162static struct sprite *ctor_sprite(SDL_Surface *surf)
163{
164 struct sprite *result = fc_malloc(sizeof(struct sprite));
165
166 result->psurface = surf;
167
168 return result;
169}
170
171/************************************************************************/
174struct sprite *load_gfxnumber(int num)
175{
176 /* Not supported in sdl3-client */
177 return NULL;
178}
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int int int struct sprite *sprite struct canvas struct color * pcolor
Definition canvas_g.h:56
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
char * incite_cost
Definition comments.c:75
#define _(String)
Definition fcintl.h:67
static GtkWidget * source
Definition gotodlg.c:58
void free_sprite(struct sprite *s)
Definition sprite.c:278
struct sprite * create_sprite(int width, int height, struct color *pcolor)
Definition sprite.c:84
struct sprite * load_gfxnumber(int num)
Definition sprite.c:526
struct sprite * load_gfxfile(const char *filename, bool svgflag)
Definition sprite.c:170
const char ** gfx_fileextensions(void)
Definition sprite.c:117
SDL_Surface * mask_surface(SDL_Surface *src, SDL_Surface *mask, int mask_offset_x, int mask_offset_y)
Definition graphics.c:262
SDL_Surface * crop_rect_from_surface(SDL_Surface *psource, SDL_Rect *prect)
Definition graphics.c:236
SDL_Surface * convert_surf(SDL_Surface *surf_in)
Definition graphics.c:359
#define FREESURFACE(ptr)
Definition graphics.h:322
static struct sprite * ctor_sprite(SDL_Surface *surf)
Definition sprite.c:177
#define GET_SURF(m_sprite)
Definition sprite.h:29
#define GET_SURF_REAL(m_sprite)
Definition sprite.h:26
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define log_error(message,...)
Definition log.h:103
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_malloc(sz)
Definition mem.h:34
struct sprite int int int int struct sprite * mask
Definition sprite_g.h:32
struct sprite int int y
Definition sprite_g.h:31
struct sprite int int int int struct sprite int int float scale
Definition sprite_g.h:33
struct sprite int int int int struct sprite int mask_offset_x
Definition sprite_g.h:32
struct sprite int x
Definition sprite_g.h:31
crop_sprite
Definition sprite_g.h:30
struct sprite int int int int struct sprite int int float bool smooth get_sprite_dimensions
Definition sprite_g.h:36
struct sprite int int int int struct sprite int int mask_offset_y
Definition sprite_g.h:32
Definition colors.h:21
struct SDL_Surface * psurface
Definition sprite.h:21