Subversion Repositories Games.Chess Giants

Rev

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

Rev 11 Rev 81
Line 133... Line 133...
133
         theme->part_meshes[part_id] = Render_LoadMesh (L"%s/themes/%s/" part_name L".*", app_path, theme->name); \
133
         theme->part_meshes[part_id] = Render_LoadMesh (L"%s/themes/%s/" part_name L".*", app_path, theme->name); \
134
      if (theme->part_meshes[part_id] == -1) \
134
      if (theme->part_meshes[part_id] == -1) \
135
         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); \
136
   }
136
   }
137
 
137
 
138
   struct _stat fileinfo;
138
   unsigned long file_size;
139
   char *desc_buffer;
139
   char *desc_buffer;
140
   wchar_t filename[256];
140
   wchar_t filename[256];
141
   wchar_t section_name[32];
141
   wchar_t section_name[32];
142
   wchar_t value[128];
142
   wchar_t value[128];
143
   light_t light;
143
   light_t light;
144
   void *inifile;
144
   void *inifile;
145
   int light_index;
145
   int light_index;
146
   int light_count;
146
   int light_count;
-
 
147
   int length;
-
 
148
   int pos;
147
   int red;
149
   int red;
148
   int green;
150
   int green;
149
   int blue;
151
   int blue;
150
   FILE *fp;
152
   FILE *fp;
151
 
153
 
152
   // allocate space for and load its description
154
   // allocate space for and load its description
153
   swprintf_s (filename, WCHAR_SIZEOF (filename), L"%s/themes/%s/readme.txt", app_path, theme->name);
155
   swprintf_s (filename, WCHAR_SIZEOF (filename), L"%s/themes/%s/readme.txt", app_path, theme->name);
154
   if (_wstat (filename, &fileinfo) == 0)
156
   _wfopen_s (&fp, filename, L"rb");
-
 
157
   if (fp != NULL)
155
   {
158
   {
156
      desc_buffer = (char *) SAFE_malloc (fileinfo.st_size, sizeof (char), false);
159
      fseek (fp, 0, SEEK_END); // seek at end of file
-
 
160
      file_size = ftell (fp); // get file size
-
 
161
      fseek (fp, 0, SEEK_SET); // and rewind
157
      _wfopen_s (&fp, filename, L"rb");
162
      if (file_size > 0)
-
 
163
      {
-
 
164
         desc_buffer = (char *) SAFE_malloc (file_size, sizeof (char), false);
158
      fread (desc_buffer, fileinfo.st_size, 1, fp); // read file in whole in ASCII form
165
         fread (desc_buffer, file_size, 1, fp); // read file in whole in ASCII form
159
      fclose (fp); // close it and then convert it to wide char
166
         fclose (fp); // close it and then convert it to wide char
160
      theme->description = (wchar_t *) SAFE_malloc (fileinfo.st_size, sizeof (wchar_t), false);
167
         theme->description = (wchar_t *) SAFE_malloc (file_size, sizeof (wchar_t), false);
161
      ConvertToWideChar (theme->description, fileinfo.st_size, desc_buffer);
168
         ConvertToWideChar (theme->description, file_size, desc_buffer);
162
      SAFE_free ((void **) &desc_buffer); // we no longer need the ASCII buffer
169
         SAFE_free ((void **) &desc_buffer); // we no longer need the ASCII buffer
-
 
170
      }
-
 
171
      else
-
 
172
         theme->description = NULL; // this theme has no description
-
 
173
      fclose (fp);
163
   }
174
   }
164
   else
-
 
165
      theme->description = NULL; // this theme has no description
-
 
166
 
175
 
167
   // load its background image
176
   // load its background image
168
   THEME_LOAD_STEP (0) Background_LoadImage (&theme->bg, L"%s/themes/%s/background/background.*", app_path, theme->name);
177
   THEME_LOAD_STEP (0) Background_LoadImage (&theme->bg, L"%s/themes/%s/background/background.*", app_path, theme->name);
169
 
178
 
170
   // load board meshes
179
   // load board meshes