Freeciv-3.2
Loading...
Searching...
No Matches
svgflag.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/* utility */
19#include "fcintl.h"
20#include "mem.h"
21#include "support.h"
22
23/* client */
24#include "canvas_g.h"
25#include "sprite_g.h"
26
27#include "svgflag.h"
28
29
31
32static const char **ordered_extensions = NULL;
33
34/**********************************************************************/
40{
41#ifdef FREECIV_SVG_FLAGS
43
44 return TRUE;
45#else // FREECIV_SVG_FLAGS
46 return FALSE;
47#endif // FREECIV_SVG_FLAGS
48}
49
50/**********************************************************************/
53const char **ordered_gfx_fextensions(void)
54{
55 const char **incoming;
56
57 if (ordered_extensions != NULL) {
58 return ordered_extensions;
59 }
60
62
63 if (is_svg_flag_enabled()) {
64 int count;
65 int svg = -1;
66 int i;
67
68 for (count = 0; incoming[count] != NULL; count++) {
69 if (!fc_strcasecmp("svg", incoming[count])) {
70 svg = count;
71 }
72 }
73
74 if (svg < 0) {
75 /* No svg, disable svg flag features */
77
78 log_warn(_("Client has no required support for svg. "
79 "Disabled use of svg flags."));
80
82 } else {
83 log_verbose(_("Client is capable of using svg flags."));
84 }
85
86 ordered_extensions = fc_malloc((count + 1) * sizeof(char *));
87
88 /* Put svg first */
90
91 for (i = 0; i < svg; i++) {
93 }
94 for (; i < count; i++) {
96 }
98
99 } else {
101 }
102
103 return ordered_extensions;
104}
105
106/**********************************************************************/
110{
111 if (ordered_extensions != NULL) {
112 if (is_svg_flag_enabled()) {
114 }
115
117 }
118}
119
120/**********************************************************************/
123void get_flag_dimensions(struct sprite *flag, struct area_rect *rect,
124 int svg_height)
125{
126 get_sprite_dimensions(flag, &(rect->w), &(rect->h));
127
128 if (is_svg_flag_enabled()) {
129 rect->w = rect->w * svg_height / rect->h;
130 rect->h = svg_height;
131 }
132}
133
134/**********************************************************************/
138 int canvas_x, int canvas_y, int canvas_w, int canvas_h,
139 struct sprite *flag)
140{
141 if (is_svg_flag_enabled()) {
143 flag);
144 } else {
146 }
147}
struct canvas int int canvas_y
Definition canvas_g.h:43
struct canvas int canvas_x
Definition canvas_g.h:43
struct canvas int int int canvas_w
Definition canvas_g.h:49
struct canvas int int int int canvas_h
Definition canvas_g.h:49
struct canvas * pcanvas
Definition canvas_g.h:42
canvas_put_sprite_full_scaled
Definition canvas_g.h:48
char * incite_cost
Definition comments.c:75
#define _(String)
Definition fcintl.h:67
void canvas_put_sprite_full(struct canvas *pcanvas, int canvas_x, int canvas_y, struct sprite *sprite)
Definition canvas.c:144
const char ** gfx_fileextensions(void)
Definition sprite.c:117
#define log_warn(message,...)
Definition log.h:105
#define log_verbose(message,...)
Definition log.h:109
#define fc_malloc(sz)
Definition mem.h:34
struct sprite int int int int struct sprite int int float bool smooth get_sprite_dimensions
Definition sprite_g.h:36
int w
Definition svgflag.h:24
int h
Definition svgflag.h:24
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
void free_svg_flag_API(void)
Definition svgflag.c:109
void canvas_put_flag_sprite(struct canvas *pcanvas, int canvas_x, int canvas_y, int canvas_w, int canvas_h, struct sprite *flag)
Definition svgflag.c:137
bool _prefer_svg
Definition svgflag.c:30
bool svg_flag_enable(void)
Definition svgflag.c:39
static const char ** ordered_extensions
Definition svgflag.c:32
const char ** ordered_gfx_fextensions(void)
Definition svgflag.c:53
void get_flag_dimensions(struct sprite *flag, struct area_rect *rect, int svg_height)
Definition svgflag.c:123
#define is_svg_flag_enabled()
Definition svgflag.h:30