Subversion Repositories Games.Chess Giants

Rev

Rev 10 | Rev 81 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 10 Rev 11
Line 17... Line 17...
17
   theme_count = 0;
17
   theme_count = 0;
18
 
18
 
19
   // the selected them isn't known yet
19
   // the selected them isn't known yet
20
   selectedtheme_index = -1;
20
   selectedtheme_index = -1;
21
 
21
 
22
   // build the search pattern string out of the path
22
   // build the search pattern string out of the path and initiate the search from that point
23
   swprintf_s (search_pattern, WCHAR_SIZEOF (search_pattern), L"%s\\themes\\*.*", app_path);
23
   swprintf_s (search_pattern, WCHAR_SIZEOF (search_pattern), L"%s\\themes\\*.*", app_path);
24
 
-
 
25
   // initiate the search from that point
-
 
26
   hFind = FindFirstFile (search_pattern, &wfd);
24
   hFind = FindFirstFile (search_pattern, &wfd);
27
   if (hFind != INVALID_HANDLE_VALUE)
25
   if (hFind != INVALID_HANDLE_VALUE)
28
   {
26
   {
29
      // start doing this...
27
      // start doing this...
30
      do
28
      do
Line 51... Line 49...
51
      } while (FindNextFile (hFind, &wfd)); // ...and don't stop as long as there are files to go
49
      } while (FindNextFile (hFind, &wfd)); // ...and don't stop as long as there are files to go
52
 
50
 
53
      FindClose (hFind); // close the search handle
51
      FindClose (hFind); // close the search handle
54
   }
52
   }
55
 
53
 
56
   // consistency check (this is not the real reason for the error, but who cares)
54
   // consistency check: we need at least one theme
57
   if (theme_count == 0)
55
   if (theme_count == 0)
58
   {
56
   {
59
      MessageBox (NULL, LOCALIZE (L"Error_UnableToAddTextureD3DXCreateTextureFromFileFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK);
57
      MessageBox (NULL, LOCALIZE (L"Error_UnableToLoadThemes"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK);
60
      return (false); // if none of these extensions match, bomb out
58
      return (false); // if none of these extensions match, bomb out
61
   }
59
   }
62
 
60
 
63
   // have we found the selected theme ?
61
   // have we found the selected theme ?
64
   if (selectedtheme_index != -1)
62
   if (selectedtheme_index != -1)
Line 105... Line 103...
105
 
103
 
106
void Theme_Load (theme_t *theme, bool want_all)
104
void Theme_Load (theme_t *theme, bool want_all)
107
{
105
{
108
   // this function loads a particular theme out of a theme subdirectory's files
106
   // this function loads a particular theme out of a theme subdirectory's files
109
 
107
 
-
 
108
   #define THEME_LOAD_STEP(id) if ((theme->load_index == (id)) || (want_all && (theme->load_index < ((id) + 1))))
-
 
109
   #define THEME_LOAD_TEXTURE(varname,texture_name) \
-
 
110
   { \
-
 
111
      theme->varname = Render_LoadTexture (L"%s/themes/%s/" texture_name L".*", app_path, theme->name); \
-
 
112
      if (theme->varname == -1) \
-
 
113
         MessageBox (NULL, LOCALIZE (L"Error_UnableToAddTextureD3DXCreateTextureFromFileFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); \
-
 
114
   }
110
   #define THEME_LOAD_MESH(varname,mesh_name) \
115
   #define THEME_LOAD_MESH(varname,mesh_name) \
111
   { \
116
   { \
112
      theme->varname = Render_LoadMesh (L"themes/%s/models/" mesh_name L".*", theme->name); \
117
      theme->varname = Render_LoadMesh (L"%s/themes/%s/" mesh_name L".*", app_path, theme->name); \
113
      if (theme->varname == -1) \
118
      if (theme->varname == -1) \
114
         MessageBox (NULL, LOCALIZE (L"Error_UnableToAddMeshD3DXLoadMeshFromXFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); \
119
         MessageBox (NULL, LOCALIZE (L"Error_UnableToAddMeshD3DXLoadMeshFromXFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); \
-
 
120
   }
-
 
121
   #define THEME_LOAD_SPRITE(varname,sprite_name) \
-
 
122
   { \
-
 
123
      theme->varname = Render_LoadSprite (L"%s/themes/%s/" sprite_name L".*", app_path, theme->name); \
-
 
124
      if (theme->varname == -1) \
-
 
125
         MessageBox (NULL, LOCALIZE (L"Error_UnableToAddSpriteD3DXCreateSpriteFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); \
115
   }
126
   }
116
   #define THEME_LOAD_PART(part_id,part_name) \
127
   #define THEME_LOAD_PART(part_id,part_name) \
117
   { \
128
   { \
118
      theme->part_meshes[part_id] = -1; \
129
      theme->part_meshes[part_id] = -1; \
119
      if (options.want_hiquality) \
130
      if (options.want_hiquality) \
120
         theme->part_meshes[part_id] = Render_LoadMesh (L"themes/%s/models/" part_name L"-hidef.*", theme->name); \
131
         theme->part_meshes[part_id] = Render_LoadMesh (L"%s/themes/%s/" part_name L"-hidef.*", app_path, theme->name); \
121
      if (theme->part_meshes[part_id] == -1) \
132
      if (theme->part_meshes[part_id] == -1) \
122
         theme->part_meshes[part_id] = Render_LoadMesh (L"themes/%s/models/" part_name L".*", theme->name); \
133
         theme->part_meshes[part_id] = Render_LoadMesh (L"%s/themes/%s/" part_name L".*", app_path, theme->name); \
123
      if (theme->part_meshes[part_id] == -1) \
134
      if (theme->part_meshes[part_id] == -1) \
124
         MessageBox (NULL, LOCALIZE (L"Error_UnableToAddMeshD3DXLoadMeshFromXFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); \
135
         MessageBox (NULL, LOCALIZE (L"Error_UnableToAddMeshD3DXLoadMeshFromXFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); \
125
   }
136
   }
126
 
137
 
127
   struct _stat fileinfo;
138
   struct _stat fileinfo;
Line 137... Line 148...
137
   int green;
148
   int green;
138
   int blue;
149
   int blue;
139
   FILE *fp;
150
   FILE *fp;
140
 
151
 
141
   // allocate space for and load its description
152
   // allocate space for and load its description
142
   swprintf_s (filename, WCHAR_SIZEOF (filename), L"themes/%s/readme.txt", theme->name);
153
   swprintf_s (filename, WCHAR_SIZEOF (filename), L"%s/themes/%s/readme.txt", app_path, theme->name);
143
   if (_wstat (filename, &fileinfo) == 0)
154
   if (_wstat (filename, &fileinfo) == 0)
144
   {
155
   {
145
      desc_buffer = (char *) SAFE_malloc (fileinfo.st_size, sizeof (char), false);
156
      desc_buffer = (char *) SAFE_malloc (fileinfo.st_size, sizeof (char), false);
146
      _wfopen_s (&fp, filename, L"rb");
157
      _wfopen_s (&fp, filename, L"rb");
147
      fread (desc_buffer, fileinfo.st_size, 1, fp); // read file in whole in ASCII form
158
      fread (desc_buffer, fileinfo.st_size, 1, fp); // read file in whole in ASCII form
Line 152... Line 163...
152
   }
163
   }
153
   else
164
   else
154
      theme->description = NULL; // this theme has no description
165
      theme->description = NULL; // this theme has no description
155
 
166
 
156
   // load its background image
167
   // load its background image
157
   if ((theme->load_index == 0) || (want_all && (theme->load_index < 1)))
-
 
158
   {
-
 
159
      swprintf_s (filename, WCHAR_SIZEOF (filename), L"themes/%s/background/background.*", theme->name);
168
   THEME_LOAD_STEP (0) Background_LoadImage (&theme->bg, L"%s/themes/%s/background/background.*", app_path, theme->name);
160
      Background_LoadImage (&theme->bg, filename);
-
 
161
   }
-
 
162
 
169
 
163
   // load board meshes
170
   // load board meshes
164
   if ((theme->load_index == 1) || (want_all && (theme->load_index < 2)))
-
 
165
      THEME_LOAD_MESH (board_meshindex, L"board");
171
   THEME_LOAD_STEP (1) THEME_LOAD_MESH (board_meshindex, L"models/board");
166
   if ((theme->load_index == 2) || (want_all && (theme->load_index < 3)))
-
 
167
      THEME_LOAD_MESH (table_meshindex, L"table");
172
   THEME_LOAD_STEP (2) THEME_LOAD_MESH (table_meshindex, L"models/table");
168
   if ((theme->load_index == 3) || (want_all && (theme->load_index < 4)))
-
 
169
      THEME_LOAD_MESH (trim_meshindex, L"trim");
173
   THEME_LOAD_STEP (3) THEME_LOAD_MESH (trim_meshindex, L"models/trim");
170
   if ((theme->load_index == 4) || (want_all && (theme->load_index < 5)))
-
 
171
      THEME_LOAD_MESH (tile_meshindex, L"tile");
174
   THEME_LOAD_STEP (4) THEME_LOAD_MESH (tile_meshindex, L"models/tile");
172
 
175
 
173
   // load part meshes
176
   // load part meshes
174
   if ((theme->load_index == 5) || (want_all && (theme->load_index < 6)))
-
 
175
      THEME_LOAD_PART (PART_KING, L"king");
177
   THEME_LOAD_STEP (5) THEME_LOAD_PART (PART_KING, L"models/king");
176
   if ((theme->load_index == 6) || (want_all && (theme->load_index < 7)))
-
 
177
      THEME_LOAD_PART (PART_QUEEN, L"queen");
178
   THEME_LOAD_STEP (6) THEME_LOAD_PART (PART_QUEEN, L"models/queen");
178
   if ((theme->load_index == 7) || (want_all && (theme->load_index < 8)))
-
 
179
      THEME_LOAD_PART (PART_BISHOP, L"bishop");
179
   THEME_LOAD_STEP (7) THEME_LOAD_PART (PART_BISHOP, L"models/bishop");
180
   if ((theme->load_index == 8) || (want_all && (theme->load_index < 9)))
-
 
181
      THEME_LOAD_PART (PART_KNIGHT, L"knight");
180
   THEME_LOAD_STEP (8) THEME_LOAD_PART (PART_KNIGHT, L"models/knight");
182
   if ((theme->load_index == 9) || (want_all && (theme->load_index < 10)))
-
 
183
      THEME_LOAD_PART (PART_ROOK, L"rook");
181
   THEME_LOAD_STEP (9) THEME_LOAD_PART (PART_ROOK, L"models/rook");
184
   if ((theme->load_index == 10) || (want_all && (theme->load_index < 11)))
-
 
185
      THEME_LOAD_PART (PART_PAWN, L"pawn");
182
   THEME_LOAD_STEP (10) THEME_LOAD_PART (PART_PAWN, L"models/pawn");
186
 
183
 
187
   // load part textures
184
   // load part textures
188
   if ((theme->load_index == 11) || (want_all && (theme->load_index < 12)))
-
 
189
      theme->part_colors[COLOR_BLACK].texture = Render_LoadTexture (L"themes/%s/models/part-black.*", theme->name);
185
   THEME_LOAD_STEP (11) THEME_LOAD_TEXTURE (part_colors[COLOR_BLACK].texture, L"models/part-black");
190
   if ((theme->load_index == 12) || (want_all && (theme->load_index < 13)))
-
 
191
      theme->part_colors[COLOR_WHITE].texture = Render_LoadTexture (L"themes/%s/models/part-white.*", theme->name);
186
   THEME_LOAD_STEP (12) THEME_LOAD_TEXTURE (part_colors[COLOR_WHITE].texture, L"models/part-white");
192
 
187
 
193
   // load board, table, grid and trim textures
188
   // load board, table, grid and trim textures
194
   if ((theme->load_index == 13) || (want_all && (theme->load_index < 14)))
-
 
195
      theme->board_texture = Render_LoadTexture (L"themes/%s/models/board.*", theme->name);
189
   THEME_LOAD_STEP (13) THEME_LOAD_TEXTURE (board_texture, L"models/board");
196
   if ((theme->load_index == 14) || (want_all && (theme->load_index < 15)))
-
 
197
      theme->table_texture = Render_LoadTexture (L"themes/%s/models/table.*", theme->name);
190
   THEME_LOAD_STEP (14) THEME_LOAD_TEXTURE (table_texture, L"models/table");
198
   if ((theme->load_index == 15) || (want_all && (theme->load_index < 16)))
-
 
199
      theme->trim_texture = Render_LoadTexture (L"themes/%s/models/trim.*", theme->name);
191
   THEME_LOAD_STEP (15) THEME_LOAD_TEXTURE (trim_texture, L"models/trim");
200
   if ((theme->load_index == 16) || (want_all && (theme->load_index < 17)))
-
 
201
      theme->grid_texture = Render_LoadTexture (L"themes/%s/models/grid.*", theme->name);
192
   THEME_LOAD_STEP (16) THEME_LOAD_TEXTURE (grid_texture, L"models/grid");
202
 
193
 
203
   // load overlay textures
194
   // load overlay textures
204
   if ((theme->load_index == 17) || (want_all && (theme->load_index < 18)))
195
   THEME_LOAD_STEP (17) THEME_LOAD_TEXTURE (shadow_textureindex, L"shadow");
205
      theme->shadow_textureindex = Render_LoadTexture (L"themes/%s/shadow.*", theme->name);
-
 
206
   if ((theme->load_index == 18) || (want_all && (theme->load_index < 19)))
196
   THEME_LOAD_STEP (18) THEME_LOAD_TEXTURE (hovered_textureindex, L"hovered");
207
      theme->hovered_textureindex = Render_LoadTexture (L"themes/%s/hovered.*", theme->name);
-
 
208
   if ((theme->load_index == 19) || (want_all && (theme->load_index < 20)))
197
   THEME_LOAD_STEP (19) THEME_LOAD_TEXTURE (check_textureindex, L"check");
209
      theme->check_textureindex = Render_LoadTexture (L"themes/%s/check.*", theme->name);
-
 
210
   if ((theme->load_index == 20) || (want_all && (theme->load_index < 21)))
198
   THEME_LOAD_STEP (20) THEME_LOAD_TEXTURE (threat_textureindex, L"takeable");
211
      theme->threat_textureindex = Render_LoadTexture (L"themes/%s/takeable.*", theme->name);
-
 
212
   if ((theme->load_index == 21) || (want_all && (theme->load_index < 22)))
-
 
213
      theme->lastmovesource_textureindex = Render_LoadTexture (L"themes/%s/lastmovesource.*", theme->name);
199
   THEME_LOAD_STEP (21) THEME_LOAD_TEXTURE (lastmovesource_textureindex, L"lastmovesource");
214
   if ((theme->load_index == 22) || (want_all && (theme->load_index < 23)))
-
 
215
      theme->lastmovetarget_textureindex = Render_LoadTexture (L"themes/%s/lastmovetarget.*", theme->name);
200
   THEME_LOAD_STEP (22) THEME_LOAD_TEXTURE (lastmovetarget_textureindex, L"lastmovetarget");
216
   if ((theme->load_index == 23) || (want_all && (theme->load_index < 24)))
-
 
217
      theme->selected_textureindex = Render_LoadTexture (L"themes/%s/selected.*", theme->name);
201
   THEME_LOAD_STEP (23) THEME_LOAD_TEXTURE (selected_textureindex, L"selected");
218
   if ((theme->load_index == 24) || (want_all && (theme->load_index < 25)))
-
 
219
      theme->possiblemove_textureindex = Render_LoadTexture (L"themes/%s/possiblemove.*", theme->name);
202
   THEME_LOAD_STEP (24) THEME_LOAD_TEXTURE (possiblemove_textureindex, L"possiblemove");
220
   if ((theme->load_index == 25) || (want_all && (theme->load_index < 26)))
203
   THEME_LOAD_STEP (25) THEME_LOAD_TEXTURE (takeable_textureindex, L"takeable");
221
      theme->takeable_textureindex = Render_LoadTexture (L"themes/%s/takeable.*", theme->name);
-
 
222
 
204
 
223
   // load sprites
205
   // load sprites
224
   if ((theme->load_index == 26) || (want_all && (theme->load_index < 27)))
-
 
225
      theme->flatsprites[COLOR_WHITE][PART_PAWN] = Render_LoadSprite (L"themes/%s/parts/pawn-white.*", theme->name);
206
   THEME_LOAD_STEP (26) THEME_LOAD_SPRITE (flatsprites[COLOR_WHITE][PART_PAWN], L"parts/pawn-white");
226
   if ((theme->load_index == 27) || (want_all && (theme->load_index < 28)))
-
 
227
      theme->flatsprites[COLOR_WHITE][PART_ROOK] = Render_LoadSprite (L"themes/%s/parts/rook-white.*", theme->name);
207
   THEME_LOAD_STEP (27) THEME_LOAD_SPRITE (flatsprites[COLOR_WHITE][PART_ROOK], L"parts/rook-white");
228
   if ((theme->load_index == 28) || (want_all && (theme->load_index < 29)))
-
 
229
      theme->flatsprites[COLOR_WHITE][PART_KNIGHT] = Render_LoadSprite (L"themes/%s/parts/knight-white.*", theme->name);
208
   THEME_LOAD_STEP (28) THEME_LOAD_SPRITE (flatsprites[COLOR_WHITE][PART_KNIGHT], L"parts/knight-white");
230
   if ((theme->load_index == 29) || (want_all && (theme->load_index < 30)))
-
 
231
      theme->flatsprites[COLOR_WHITE][PART_BISHOP] = Render_LoadSprite (L"themes/%s/parts/bishop-white.*", theme->name);
209
   THEME_LOAD_STEP (29) THEME_LOAD_SPRITE (flatsprites[COLOR_WHITE][PART_BISHOP], L"parts/bishop-white");
232
   if ((theme->load_index == 30) || (want_all && (theme->load_index < 31)))
-
 
233
      theme->flatsprites[COLOR_WHITE][PART_QUEEN] = Render_LoadSprite (L"themes/%s/parts/queen-white.*", theme->name);
210
   THEME_LOAD_STEP (30) THEME_LOAD_SPRITE (flatsprites[COLOR_WHITE][PART_QUEEN], L"parts/queen-white");
234
   if ((theme->load_index == 31) || (want_all && (theme->load_index < 32)))
-
 
235
      theme->flatsprites[COLOR_WHITE][PART_KING] = Render_LoadSprite (L"themes/%s/parts/king-white.*", theme->name);
211
   THEME_LOAD_STEP (31) THEME_LOAD_SPRITE (flatsprites[COLOR_WHITE][PART_KING], L"parts/king-white");
236
   if ((theme->load_index == 32) || (want_all && (theme->load_index < 33)))
-
 
237
      theme->flatsprites[COLOR_BLACK][PART_PAWN] = Render_LoadSprite (L"themes/%s/parts/pawn-black.*", theme->name);
212
   THEME_LOAD_STEP (32) THEME_LOAD_SPRITE (flatsprites[COLOR_BLACK][PART_PAWN], L"parts/pawn-black");
238
   if ((theme->load_index == 33) || (want_all && (theme->load_index < 34)))
-
 
239
      theme->flatsprites[COLOR_BLACK][PART_ROOK] = Render_LoadSprite (L"themes/%s/parts/rook-black.*", theme->name);
213
   THEME_LOAD_STEP (33) THEME_LOAD_SPRITE (flatsprites[COLOR_BLACK][PART_ROOK], L"parts/rook-black");
240
   if ((theme->load_index == 34) || (want_all && (theme->load_index < 35)))
-
 
241
      theme->flatsprites[COLOR_BLACK][PART_KNIGHT] = Render_LoadSprite (L"themes/%s/parts/knight-black.*", theme->name);
214
   THEME_LOAD_STEP (34) THEME_LOAD_SPRITE (flatsprites[COLOR_BLACK][PART_KNIGHT], L"parts/knight-black");
242
   if ((theme->load_index == 35) || (want_all && (theme->load_index < 36)))
-
 
243
      theme->flatsprites[COLOR_BLACK][PART_BISHOP] = Render_LoadSprite (L"themes/%s/parts/bishop-black.*", theme->name);
215
   THEME_LOAD_STEP (35) THEME_LOAD_SPRITE (flatsprites[COLOR_BLACK][PART_BISHOP], L"parts/bishop-black");
244
   if ((theme->load_index == 36) || (want_all && (theme->load_index < 37)))
-
 
245
      theme->flatsprites[COLOR_BLACK][PART_QUEEN] = Render_LoadSprite (L"themes/%s/parts/queen-black.*", theme->name);
216
   THEME_LOAD_STEP (36) THEME_LOAD_SPRITE (flatsprites[COLOR_BLACK][PART_QUEEN], L"parts/queen-black");
246
   if ((theme->load_index == 37) || (want_all && (theme->load_index < 38)))
-
 
247
      theme->flatsprites[COLOR_BLACK][PART_KING] = Render_LoadSprite (L"themes/%s/parts/king-black.*", theme->name);
217
   THEME_LOAD_STEP (37) THEME_LOAD_SPRITE (flatsprites[COLOR_BLACK][PART_KING], L"parts/king-black");
248
   if ((theme->load_index == 38) || (want_all && (theme->load_index < 39)))
-
 
249
      theme->lastmovesource_spriteindex = Render_LoadSprite (L"themes/%s/lastmovesource.*", theme->name);
218
   THEME_LOAD_STEP (38) THEME_LOAD_SPRITE (lastmovesource_spriteindex, L"lastmovesource");
250
   if ((theme->load_index == 39) || (want_all && (theme->load_index < 40)))
-
 
251
      theme->lastmovetarget_spriteindex = Render_LoadSprite (L"themes/%s/lastmovetarget.*", theme->name);
219
   THEME_LOAD_STEP (39) THEME_LOAD_SPRITE (lastmovetarget_spriteindex, L"lastmovetarget");
252
 
220
 
253
   // load the flat pieces textures
221
   // load the flat pieces textures
254
   if ((theme->load_index == 40) || (want_all && (theme->load_index < 41)))
-
 
255
      theme->flattextures[COLOR_WHITE][PART_PAWN] = Render_LoadTexture (L"themes/%s/parts/pawn-white.*", theme->name);
222
   THEME_LOAD_STEP (40) THEME_LOAD_TEXTURE (flattextures[COLOR_WHITE][PART_PAWN], L"parts/pawn-white");
256
   if ((theme->load_index == 41) || (want_all && (theme->load_index < 42)))
-
 
257
      theme->flattextures[COLOR_WHITE][PART_ROOK] = Render_LoadTexture (L"themes/%s/parts/rook-white.*", theme->name);
223
   THEME_LOAD_STEP (41) THEME_LOAD_TEXTURE (flattextures[COLOR_WHITE][PART_ROOK], L"parts/rook-white");
258
   if ((theme->load_index == 42) || (want_all && (theme->load_index < 43)))
-
 
259
      theme->flattextures[COLOR_WHITE][PART_KNIGHT] = Render_LoadTexture (L"themes/%s/parts/knight-white.*", theme->name);
224
   THEME_LOAD_STEP (42) THEME_LOAD_TEXTURE (flattextures[COLOR_WHITE][PART_KNIGHT], L"parts/knight-white");
260
   if ((theme->load_index == 43) || (want_all && (theme->load_index < 44)))
-
 
261
      theme->flattextures[COLOR_WHITE][PART_BISHOP] = Render_LoadTexture (L"themes/%s/parts/bishop-white.*", theme->name);
225
   THEME_LOAD_STEP (43) THEME_LOAD_TEXTURE (flattextures[COLOR_WHITE][PART_BISHOP], L"parts/bishop-white");
262
   if ((theme->load_index == 44) || (want_all && (theme->load_index < 45)))
-
 
263
      theme->flattextures[COLOR_WHITE][PART_QUEEN] = Render_LoadTexture (L"themes/%s/parts/queen-white.*", theme->name);
226
   THEME_LOAD_STEP (44) THEME_LOAD_TEXTURE (flattextures[COLOR_WHITE][PART_QUEEN], L"parts/queen-white");
264
   if ((theme->load_index == 45) || (want_all && (theme->load_index < 46)))
-
 
265
      theme->flattextures[COLOR_WHITE][PART_KING] = Render_LoadTexture (L"themes/%s/parts/king-white.*", theme->name);
227
   THEME_LOAD_STEP (45) THEME_LOAD_TEXTURE (flattextures[COLOR_WHITE][PART_KING], L"parts/king-white");
266
   if ((theme->load_index == 46) || (want_all && (theme->load_index < 47)))
-
 
267
      theme->flattextures[COLOR_BLACK][PART_PAWN] = Render_LoadTexture (L"themes/%s/parts/pawn-black.*", theme->name);
228
   THEME_LOAD_STEP (46) THEME_LOAD_TEXTURE (flattextures[COLOR_BLACK][PART_PAWN], L"parts/pawn-black");
268
   if ((theme->load_index == 47) || (want_all && (theme->load_index < 48)))
-
 
269
      theme->flattextures[COLOR_BLACK][PART_ROOK] = Render_LoadTexture (L"themes/%s/parts/rook-black.*", theme->name);
229
   THEME_LOAD_STEP (47) THEME_LOAD_TEXTURE (flattextures[COLOR_BLACK][PART_ROOK], L"parts/rook-black");
270
   if ((theme->load_index == 48) || (want_all && (theme->load_index < 49)))
-
 
271
      theme->flattextures[COLOR_BLACK][PART_KNIGHT] = Render_LoadTexture (L"themes/%s/parts/knight-black.*", theme->name);
230
   THEME_LOAD_STEP (48) THEME_LOAD_TEXTURE (flattextures[COLOR_BLACK][PART_KNIGHT], L"parts/knight-black");
272
   if ((theme->load_index == 49) || (want_all && (theme->load_index < 50)))
-
 
273
      theme->flattextures[COLOR_BLACK][PART_BISHOP] = Render_LoadTexture (L"themes/%s/parts/bishop-black.*", theme->name);
231
   THEME_LOAD_STEP (49) THEME_LOAD_TEXTURE (flattextures[COLOR_BLACK][PART_BISHOP], L"parts/bishop-black");
274
   if ((theme->load_index == 50) || (want_all && (theme->load_index < 51)))
-
 
275
      theme->flattextures[COLOR_BLACK][PART_QUEEN] = Render_LoadTexture (L"themes/%s/parts/queen-black.*", theme->name);
232
   THEME_LOAD_STEP (50) THEME_LOAD_TEXTURE (flattextures[COLOR_BLACK][PART_QUEEN], L"parts/queen-black");
276
   if ((theme->load_index == 51) || (want_all && (theme->load_index < 52)))
-
 
277
      theme->flattextures[COLOR_BLACK][PART_KING] = Render_LoadTexture (L"themes/%s/parts/king-black.*", theme->name);
233
   THEME_LOAD_STEP (51) THEME_LOAD_TEXTURE (flattextures[COLOR_BLACK][PART_KING], L"parts/king-black");
278
 
234
 
279
   //////////////////////////////
235
   //////////////////////////////
280
   // read scene lights from file
236
   // read scene lights from file
281
 
237
 
282
   if ((theme->load_index == 52) || (want_all && (theme->load_index < 53)))
238
   THEME_LOAD_STEP (52)
283
   {
239
   {
284
      theme->illum.lights = NULL; // no lights for the scene so far
240
      theme->illum.lights = NULL; // no lights for the scene so far
285
      theme->illum.light_count = 0; // reset the known lights count
241
      theme->illum.light_count = 0; // reset the known lights count
286
 
242
 
287
      // open the INI file
243
      // open the INI file
288
      swprintf_s (filename, WCHAR_SIZEOF (filename), L"themes/%s/lights.ini", theme->name);
244
      swprintf_s (filename, WCHAR_SIZEOF (filename), L"%s/themes/%s/lights.ini", app_path, theme->name);
289
      inifile = INIFile_LoadINIFile (filename);
245
      inifile = INIFile_LoadINIFile (filename);
290
 
246
 
291
      // read the global light values and the parts illumination values
247
      // read the global light values and the parts illumination values
292
      swscanf_s (INIFile_ReadEntryAsString (inifile, L"global", L"ambient light", L"50, 50, 50"), L"%d , %d , %d", &red, &green, &blue);
248
      swscanf_s (INIFile_ReadEntryAsString (inifile, L"global", L"ambient light", L"50, 50, 50"), L"%d , %d , %d", &red, &green, &blue);
293
      theme->illum.ambient_light = RGB_TO_RGBACOLOR (red, green, blue);
249
      theme->illum.ambient_light = RGB_TO_RGBACOLOR (red, green, blue);
Line 340... Line 296...
340
      theme->is_loaded = true; // when everything has been loaded, remember this theme is now usable
296
      theme->is_loaded = true; // when everything has been loaded, remember this theme is now usable
341
 
297
 
342
   return; // finished, theme data is loaded a bit more
298
   return; // finished, theme data is loaded a bit more
343
 
299
 
344
   #undef THEME_LOAD_PART
300
   #undef THEME_LOAD_PART
-
 
301
   #undef THEME_LOAD_SPRITE
345
   #undef THEME_LOAD_MESH
302
   #undef THEME_LOAD_MESH
-
 
303
   #undef THEME_LOAD_TEXTURE
-
 
304
   #undef THEME_LOAD_STEP
346
}
305
}
347
 
306
 
348
 
307
 
349
void Background_LoadImage (backgroundsprite_t *bg, const wchar_t *image_pathname)
308
void Background_LoadImage (backgroundsprite_t *bg, const wchar_t *fmt, ...)
350
{
309
{
351
   // this function loads the specified background image for the specified theme
310
   // this function loads the specified background image for the specified theme
352
 
311
 
-
 
312
   static wchar_t bgimage_pathname[MAX_PATH];
-
 
313
   va_list argptr;
353
   int width;
314
   int width;
354
   int height;
315
   int height;
-
 
316
 
-
 
317
   // concatenate all the arguments in one string
-
 
318
   va_start (argptr, fmt);
-
 
319
   wvsprintf (bgimage_pathname, fmt, argptr);
-
 
320
   va_end (argptr);
355
 
321
 
356
   // does the background file look like an image we can comprehend ? try to get its width and height
322
   // does the background file look like an image we can comprehend ? try to get its width and height
357
   if (GetImageSize (image_pathname, &width, &height))
323
   if (GetImageSize (bgimage_pathname, &width, &height))
358
   {
324
   {
359
      // yes it is, so load it as our background and round its size to the highest multiple of two
325
      // yes it is, so load it as our background and round its size to the highest multiple of two
360
      bg->sprite_width = 2;
326
      bg->sprite_width = 2;
361
      while (bg->sprite_width < width)
327
      while (bg->sprite_width < width)
362
         bg->sprite_width *= 2; // save them rounded to the next power of two
328
         bg->sprite_width *= 2; // save them rounded to the next power of two
363
      bg->sprite_height = 2;
329
      bg->sprite_height = 2;
364
      while (bg->sprite_height < height)
330
      while (bg->sprite_height < height)
365
         bg->sprite_height *= 2; // save them rounded to the next power of two
331
         bg->sprite_height *= 2; // save them rounded to the next power of two
366
 
332
 
367
      bg->sprite_index = Render_LoadSprite (image_pathname); // load texture as sprite
333
      bg->sprite_index = Render_LoadSprite (bgimage_pathname); // load texture as sprite
368
   }
334
   }
369
   else
335
   else
370
   {
336
   {
371
      // no it's not, so load a default texture
337
      // no it's not, so load a default texture
372
      bg->sprite_index = Render_LoadSprite (L"data/notexture.png");
338
      bg->sprite_index = Render_LoadSprite (L"%s/data/notexture.png", app_path);
373
      bg->sprite_width = 2;
339
      bg->sprite_width = 2;
374
      bg->sprite_height = 2;
340
      bg->sprite_height = 2;
375
   }
341
   }
376
 
342
 
377
   return; // finished, theme background image is loaded
343
   return; // finished, theme background image is loaded