Subversion Repositories Games.Chess Giants

Rev

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

Rev 1 Rev 10
Line 104... Line 104...
104
 
104
 
105
 
105
 
106
void Theme_Load (theme_t *theme, bool want_all)
106
void Theme_Load (theme_t *theme, bool want_all)
107
{
107
{
108
   // this function loads a particular theme out of a theme subdirectory's files
108
   // this function loads a particular theme out of a theme subdirectory's files
-
 
109
 
-
 
110
   #define THEME_LOAD_MESH(varname,mesh_name) \
-
 
111
   { \
-
 
112
      theme->varname = Render_LoadMesh (L"themes/%s/models/" mesh_name L".*", theme->name); \
-
 
113
      if (theme->varname == -1) \
-
 
114
         MessageBox (NULL, LOCALIZE (L"Error_UnableToAddMeshD3DXLoadMeshFromXFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); \
-
 
115
   }
-
 
116
   #define THEME_LOAD_PART(part_id,part_name) \
-
 
117
   { \
-
 
118
      theme->part_meshes[part_id] = -1; \
-
 
119
      if (options.want_hiquality) \
-
 
120
         theme->part_meshes[part_id] = Render_LoadMesh (L"themes/%s/models/" part_name L"-hidef.*", theme->name); \
-
 
121
      if (theme->part_meshes[part_id] == -1) \
-
 
122
         theme->part_meshes[part_id] = Render_LoadMesh (L"themes/%s/models/" part_name L".*", theme->name); \
-
 
123
      if (theme->part_meshes[part_id] == -1) \
-
 
124
         MessageBox (NULL, LOCALIZE (L"Error_UnableToAddMeshD3DXLoadMeshFromXFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); \
-
 
125
   }
109
 
126
 
110
   struct _stat fileinfo;
127
   struct _stat fileinfo;
111
   char *desc_buffer;
128
   char *desc_buffer;
112
   wchar_t filename[256];
129
   wchar_t filename[256];
113
   wchar_t section_name[32];
130
   wchar_t section_name[32];
Line 130... Line 147...
130
      fread (desc_buffer, fileinfo.st_size, 1, fp); // read file in whole in ASCII form
147
      fread (desc_buffer, fileinfo.st_size, 1, fp); // read file in whole in ASCII form
131
      fclose (fp); // close it and then convert it to wide char
148
      fclose (fp); // close it and then convert it to wide char
132
      theme->description = (wchar_t *) SAFE_malloc (fileinfo.st_size, sizeof (wchar_t), false);
149
      theme->description = (wchar_t *) SAFE_malloc (fileinfo.st_size, sizeof (wchar_t), false);
133
      ConvertToWideChar (theme->description, fileinfo.st_size, desc_buffer);
150
      ConvertToWideChar (theme->description, fileinfo.st_size, desc_buffer);
134
      SAFE_free ((void **) &desc_buffer); // we no longer need the ASCII buffer
151
      SAFE_free ((void **) &desc_buffer); // we no longer need the ASCII buffer
135
   }
152
   }
136
   else
153
   else
137
      theme->description = NULL; // this theme has no description
154
      theme->description = NULL; // this theme has no description
138
 
155
 
139
   // load its background image
156
   // load its background image
140
   if ((theme->load_index == 0) || (want_all && (theme->load_index < 1)))
157
   if ((theme->load_index == 0) || (want_all && (theme->load_index < 1)))
Line 143... Line 160...
143
      Background_LoadImage (&theme->bg, filename);
160
      Background_LoadImage (&theme->bg, filename);
144
   }
161
   }
145
 
162
 
146
   // load board meshes
163
   // load board meshes
147
   if ((theme->load_index == 1) || (want_all && (theme->load_index < 2)))
164
   if ((theme->load_index == 1) || (want_all && (theme->load_index < 2)))
148
      theme->board_meshindex = Render_LoadMesh (L"themes/%s/models/board.*", theme->name);
165
      THEME_LOAD_MESH (board_meshindex, L"board");
149
   if ((theme->load_index == 2) || (want_all && (theme->load_index < 3)))
166
   if ((theme->load_index == 2) || (want_all && (theme->load_index < 3)))
150
      theme->table_meshindex = Render_LoadMesh (L"themes/%s/models/table.*", theme->name);
167
      THEME_LOAD_MESH (table_meshindex, L"table");
151
   if ((theme->load_index == 3) || (want_all && (theme->load_index < 4)))
168
   if ((theme->load_index == 3) || (want_all && (theme->load_index < 4)))
152
      theme->trim_meshindex = Render_LoadMesh (L"themes/%s/models/trim.*", theme->name);
169
      THEME_LOAD_MESH (trim_meshindex, L"trim");
153
   if ((theme->load_index == 4) || (want_all && (theme->load_index < 5)))
170
   if ((theme->load_index == 4) || (want_all && (theme->load_index < 5)))
154
      theme->tile_meshindex = Render_LoadMesh (L"themes/%s/models/tile.*", theme->name);
171
      THEME_LOAD_MESH (tile_meshindex, L"tile");
155
 
172
 
156
   // load part meshes
173
   // load part meshes
157
   if ((theme->load_index == 5) || (want_all && (theme->load_index < 6)))
174
   if ((theme->load_index == 5) || (want_all && (theme->load_index < 6)))
158
      theme->part_meshes[PART_KING] = Render_LoadMesh (L"themes/%s/models/king.*", theme->name);
175
      THEME_LOAD_PART (PART_KING, L"king");
159
   if ((theme->load_index == 6) || (want_all && (theme->load_index < 7)))
176
   if ((theme->load_index == 6) || (want_all && (theme->load_index < 7)))
160
      theme->part_meshes[PART_QUEEN] = Render_LoadMesh (L"themes/%s/models/queen.*", theme->name);
177
      THEME_LOAD_PART (PART_QUEEN, L"queen");
161
   if ((theme->load_index == 7) || (want_all && (theme->load_index < 8)))
178
   if ((theme->load_index == 7) || (want_all && (theme->load_index < 8)))
162
      theme->part_meshes[PART_BISHOP] = Render_LoadMesh (L"themes/%s/models/bishop.*", theme->name);
179
      THEME_LOAD_PART (PART_BISHOP, L"bishop");
163
   if ((theme->load_index == 8) || (want_all && (theme->load_index < 9)))
180
   if ((theme->load_index == 8) || (want_all && (theme->load_index < 9)))
164
      theme->part_meshes[PART_KNIGHT] = Render_LoadMesh (L"themes/%s/models/knight.*", theme->name);
181
      THEME_LOAD_PART (PART_KNIGHT, L"knight");
165
   if ((theme->load_index == 9) || (want_all && (theme->load_index < 10)))
182
   if ((theme->load_index == 9) || (want_all && (theme->load_index < 10)))
166
      theme->part_meshes[PART_ROOK] = Render_LoadMesh (L"themes/%s/models/rook.*", theme->name);
183
      THEME_LOAD_PART (PART_ROOK, L"rook");
167
   if ((theme->load_index == 10) || (want_all && (theme->load_index < 11)))
184
   if ((theme->load_index == 10) || (want_all && (theme->load_index < 11)))
168
      theme->part_meshes[PART_PAWN] = Render_LoadMesh (L"themes/%s/models/pawn.*", theme->name);
185
      THEME_LOAD_PART (PART_PAWN, L"pawn");
169
 
186
 
170
   // load part textures
187
   // load part textures
171
   if ((theme->load_index == 11) || (want_all && (theme->load_index < 12)))
188
   if ((theme->load_index == 11) || (want_all && (theme->load_index < 12)))
172
      theme->part_colors[COLOR_BLACK].texture = Render_LoadTexture (L"themes/%s/models/part-black.*", theme->name);
189
      theme->part_colors[COLOR_BLACK].texture = Render_LoadTexture (L"themes/%s/models/part-black.*", theme->name);
173
   if ((theme->load_index == 12) || (want_all && (theme->load_index < 13)))
190
   if ((theme->load_index == 12) || (want_all && (theme->load_index < 13)))
Line 321... Line 338...
321
   theme->load_index++; // this bit has been loaded
338
   theme->load_index++; // this bit has been loaded
322
   if (theme->load_index == 53)
339
   if (theme->load_index == 53)
323
      theme->is_loaded = true; // when everything has been loaded, remember this theme is now usable
340
      theme->is_loaded = true; // when everything has been loaded, remember this theme is now usable
324
 
341
 
325
   return; // finished, theme data is loaded a bit more
342
   return; // finished, theme data is loaded a bit more
-
 
343
 
-
 
344
   #undef THEME_LOAD_PART
-
 
345
   #undef THEME_LOAD_MESH
326
}
346
}
327
 
347
 
328
 
348
 
329
void Background_LoadImage (backgroundsprite_t *bg, const wchar_t *image_pathname)
349
void Background_LoadImage (backgroundsprite_t *bg, const wchar_t *image_pathname)
330
{
350
{