Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-sdl2/themebackgrounds.c Source File

Freeciv-3.1

Loading...
Searching...
No Matches
themebackgrounds.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2005 - The Freeciv Project
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 "registry.h"
20#include "mem.h"
21
22/* client/gui-sdl2 */
23#include "graphics.h"
24#include "themespec.h"
25
26#include "themebackgrounds.h"
27
28 struct theme_background_system {
29 char *backgrounds[BACKGROUND_LAST];
30};
31
32 static char *background_names[] = {
33 "changeresearchdlg",
34 "choosegovernmentdlg",
35 "citydlg",
36 "citygovdlg",
37 "cityrep",
38 "connectdlg",
39 "connlistdlg",
40 "economydlg",
41 "hlpdlg",
42 "joingamedlg",
43 "loadgamedlg",
44 "mainpage",
45 "messagewin",
46 "nationdlg",
47 "newcitydlg",
48 "optiondlg",
49 "revolutiondlg",
50 "sciencedlg",
51 "spystealdlg",
52 "startmenu",
53 "unitsrep",
54 "userpasswddlg",
55 "wldlg",
56};
57
58/************************************************************************/
61 struct theme_background_system *theme_background_system_read(struct section_file *file)
62{
63 int i;
64 struct theme_background_system *backgrounds = fc_malloc(sizeof(*backgrounds));
65
66 fc_assert_ret_val(ARRAY_SIZE(background_names) == BACKGROUND_LAST, NULL);
67
68 for (i = 0; i < BACKGROUND_LAST; i++) {
69 backgrounds->backgrounds[i] =
70 themespec_gfx_filename(secfile_lookup_str(file, "backgrounds.%s",
71 background_names[i]));
72 }
73
74 return backgrounds;
75}
76
77/************************************************************************/
80 void theme_background_system_free(struct theme_background_system *backgrounds)
81{
82 int i;
83
84 for (i = 0; i < BACKGROUND_LAST; i++) {
85 FC_FREE(backgrounds->backgrounds[i]);
86 }
87
88 free(backgrounds);
89}
90
91/************************************************************************/
94SDL_Surface *theme_get_background(const struct theme *t,
95 enum theme_background background)
96{
97 return load_surf(theme_get_background_system(t)->backgrounds[background]);
98}
load_surf
SDL_Surface * load_surf(const char *fname)
Definition graphics.c:307
graphics.h
fc_assert_ret_val
#define fc_assert_ret_val(condition, val)
Definition log.h:194
mem.h
FC_FREE
#define FC_FREE(ptr)
Definition mem.h:41
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
registry.h
secfile_lookup_str
const char * secfile_lookup_str(const struct section_file *secfile, const char *path,...)
Definition registry_ini.c:2112
ARRAY_SIZE
#define ARRAY_SIZE(x)
Definition shared.h:85
section_file
Definition section_file.h:36
theme_background_system
Definition themebackgrounds.c:28
theme_background_system::backgrounds
char * backgrounds[BACKGROUND_LAST]
Definition themebackgrounds.c:29
theme
Definition themespec.c:133
theme_background_system_read
struct theme_background_system * theme_background_system_read(struct section_file *file)
Definition themebackgrounds.c:61
theme_background_system_free
void theme_background_system_free(struct theme_background_system *backgrounds)
Definition themebackgrounds.c:80
theme_get_background
SDL_Surface * theme_get_background(const struct theme *t, enum theme_background background)
Definition themebackgrounds.c:94
background_names
static char * background_names[]
Definition themebackgrounds.c:32
themebackgrounds.h
theme_background
theme_background
Definition themebackgrounds.h:27
BACKGROUND_LAST
@ BACKGROUND_LAST
Definition themebackgrounds.h:52
themespec_gfx_filename
char * themespec_gfx_filename(const char *gfx_filename)
Definition themespec.c:685
theme_get_background_system
struct theme_background_system * theme_get_background_system(const struct theme *t)
Definition themespec.c:1116
themespec.h