Freeciv-3.2
Loading...
Searching...
No Matches
themes_common.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#ifdef HAVE_CONFIG_H
14#include <fc_config.h>
15#endif
16
17#include <unistd.h>
18#include <string.h>
19#include <sys/stat.h>
20
21/* utility */
22#include "log.h"
23#include "mem.h"
24#include "shared.h"
25#include "string_vector.h"
26#include "support.h"
27
28/* client/include */
29#include "themes_g.h"
30
31/* client */
32#include "themes_common.h"
33
34/***************************************************************************
35 A theme is a portion of client data, which for following reasons should
36 be separated from a tileset:
37 - Theme is not only graphic related
38 - Theme can be changed independently from tileset
39 - Theme implementation is gui specific and most themes can not be shared
40 between different guis.
41 Theme is recognized by its name.
42
43 Theme is stored in a directory called like the theme. The directory contains
44 some data files. Each gui defines its own format in the
45 get_usable_themes_in_directory() function.
46****************************************************************************/
47
48/* A directory containing a list of usable themes */
50 /* Path on the filesystem */
51 char *path;
52 /* Array of theme names */
53 char **themes;
54 /* Themes array length */
56};
57
58/* List of all directories with themes */
59static int num_directories;
61
62/************************************************************************/
65void init_themes(void)
66{
67 int i;
68
69 /* Get GUI-specific theme directories */
70 char **gui_directories =
72
75
76 for (i = 0; i < num_directories; i++) {
78
79 /* Get usable themes in this directory */
83 }
85}
86
87/************************************************************************/
90const struct strvec *get_themes_list(const struct option *poption)
91{
92 static struct strvec *themes_list = NULL;
93
94 if (NULL == themes_list) {
95 int i, j, k;
96
98 for (i = 0; i < num_directories; i++) {
99 for (j = 0; j < directories[i].num_themes; j++) {
100 for (k = 0; k < strvec_size(themes_list); k++) {
102 directories[i].themes[j]) == 0) {
103 break;
104 }
105 }
106 if (k == strvec_size(themes_list)) {
108 }
109 }
110 }
111 }
112
113 return themes_list;
114}
115
116/************************************************************************/
120bool load_theme(const char *theme_name)
121{
122 int i, j;
123
124 for (i = 0; i < num_directories; i++) {
125 for (j = 0; j < directories[i].num_themes; j++) {
126 if (strcmp(theme_name, directories[i].themes[j]) == 0) {
127 gui_load_theme(directories[i].path, directories[i].themes[j]);
128 return TRUE;
129 }
130 }
131 }
132 return FALSE;
133}
134
135/************************************************************************/
139{
140 const char *theme_name = option_str_get(poption);
141
142 fc_assert_ret(NULL != theme_name && theme_name[0] != '\0');
144}
char * incite_cost
Definition comments.c:75
static bool load_theme
Definition theme_dlg.c:30
char ** get_gui_specific_themes_directories(int *count)
Definition themes.c:104
void gui_load_theme(const char *directory, const char *theme_name)
Definition themes.c:45
#define fc_assert_ret(condition)
Definition log.h:191
#define fc_malloc(sz)
Definition mem.h:34
const char * option_str_get(const struct option *poption)
Definition options.c:893
void strvec_append(struct strvec *psv, const char *string)
const char * strvec_get(const struct strvec *psv, size_t svindex)
struct strvec * strvec_new(void)
size_t strvec_size(const struct strvec *psv)
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
void theme_reread_callback(struct option *poption)
struct theme_directory * directories
static int num_directories
const struct strvec * get_themes_list(const struct option *poption)
void init_themes(void)
get_usable_themes_in_directory
Definition themes_g.h:22