src/gfxinit.cpp
branchcpp_gui
changeset 6285 187e3ef04cc9
parent 6268 4b5241e5dd10
child 6298 c30fe89622df
child 6573 7624f942237f
equal deleted inserted replaced
6284:45d0233e7d79 6285:187e3ef04cc9
     1 /* $Id$ */
     1 /* $Id$ */
       
     2 
       
     3 /** @file gfxinit.cpp */
     2 
     4 
     3 #include "stdafx.h"
     5 #include "stdafx.h"
     4 #include "openttd.h"
     6 #include "openttd.h"
     5 #include "debug.h"
     7 #include "debug.h"
     6 #include "functions.h"
     8 #include "functions.h"
    15 #include "variables.h"
    17 #include "variables.h"
    16 #include "fontcache.h"
    18 #include "fontcache.h"
    17 #include <string.h>
    19 #include <string.h>
    18 
    20 
    19 typedef struct MD5File {
    21 typedef struct MD5File {
    20 	const char * filename;     // filename
    22 	const char * filename;     ///< filename
    21 	md5_byte_t hash[16]; // md5 sum of the file
    23 	md5_byte_t hash[16];       ///< md5 sum of the file
    22 } MD5File;
    24 } MD5File;
    23 
    25 
    24 typedef struct FileList {
    26 typedef struct FileList {
    25 	MD5File basic[4];     // grf files that always have to be loaded
    27 	MD5File basic[4];          ///< grf files that always have to be loaded
    26 	MD5File landscape[3]; // landscape specific grf files
    28 	MD5File landscape[3];      ///< landscape specific grf files
    27 } FileList;
    29 } FileList;
    28 
    30 
    29 enum {
    31 enum {
    30 	SKIP = 0xFFFE,
    32 	SKIP = 0xFFFE,
    31 	END  = 0xFFFF
    33 	END  = 0xFFFF
   108 static bool FileMD5(const MD5File file, bool warn)
   110 static bool FileMD5(const MD5File file, bool warn)
   109 {
   111 {
   110 	FILE *f;
   112 	FILE *f;
   111 	char buf[MAX_PATH];
   113 	char buf[MAX_PATH];
   112 
   114 
   113 	// open file
   115 	/* open file */
   114 	snprintf(buf, lengthof(buf), "%s%s", _paths.data_dir, file.filename);
   116 	snprintf(buf, lengthof(buf), "%s%s", _paths.data_dir, file.filename);
   115 	f = fopen(buf, "rb");
   117 	f = fopen(buf, "rb");
   116 
   118 
   117 #if !defined(WIN32)
   119 #if !defined(WIN32)
   118 	if (f == NULL) {
   120 	if (f == NULL) {
   161  *
   163  *
   162  * (Note: Also checks sample.cat for corruption) */
   164  * (Note: Also checks sample.cat for corruption) */
   163 void CheckExternalFiles(void)
   165 void CheckExternalFiles(void)
   164 {
   166 {
   165 	uint i;
   167 	uint i;
   166 	// count of files from this version
   168 	/* count of files from this version */
   167 	uint dos = 0;
   169 	uint dos = 0;
   168 	uint win = 0;
   170 	uint win = 0;
   169 
   171 
   170 	for (i = 0; i < 2; i++) if (FileMD5(files_dos.basic[i], true)) dos++;
   172 	for (i = 0; i < 2; i++) if (FileMD5(files_dos.basic[i], true)) dos++;
   171 	for (i = 0; i < 3; i++) if (FileMD5(files_dos.landscape[i], true)) dos++;
   173 	for (i = 0; i < 3; i++) if (FileMD5(files_dos.landscape[i], true)) dos++;
   200 	}
   202 	}
   201 }
   203 }
   202 
   204 
   203 
   205 
   204 static const SpriteID trg1idx[] = {
   206 static const SpriteID trg1idx[] = {
   205 	   0,    1, // Mouse cursor, ZZZ
   207 	   0,    1, ///< Mouse cursor, ZZZ
   206 /* Medium font */
   208 /* Medium font */
   207 	   2,   92, // ' ' till 'z'
   209 	   2,   92, ///< ' ' till 'z'
   208 	SKIP,   36,
   210 	SKIP,   36,
   209 	 160,  160, // Move ¾ to the correct position
   211 	 160,  160, ///< Move ¾ to the correct position
   210 	  98,   98, // Up arrow
   212 	  98,   98, ///< Up arrow
   211 	 131,  133,
   213 	 131,  133,
   212 	SKIP,    1, // skip currency sign
   214 	SKIP,    1, ///< skip currency sign
   213 	 135,  135,
   215 	 135,  135,
   214 	SKIP,    1,
   216 	SKIP,    1,
   215 	 137,  137,
   217 	 137,  137,
   216 	SKIP,    1,
   218 	SKIP,    1,
   217 	 139,  139,
   219 	 139,  139,
   218 	 140,  140, // TODO Down arrow
   220 	 140,  140, ///< @todo Down arrow
   219 	 141,  141,
   221 	 141,  141,
   220 	 142,  142, // TODO Check mark
   222 	 142,  142, ///< @todo Check mark
   221 	 143,  143, // TODO Cross
   223 	 143,  143, ///< @todo Cross
   222 	 144,  144,
   224 	 144,  144,
   223 	 145,  145, // TODO Right arrow
   225 	 145,  145, ///< @todo Right arrow
   224 	 146,  149,
   226 	 146,  149,
   225 	 118,  122, // Transport markers
   227 	 118,  122, ///< Transport markers
   226 	SKIP,    2,
   228 	SKIP,    2,
   227 	 157,  157,
   229 	 157,  157,
   228 	 114,  115, // Small up/down arrows
   230 	 114,  115, ///< Small up/down arrows
   229 	SKIP,    1,
   231 	SKIP,    1,
   230 	 161,  225,
   232 	 161,  225,
   231 /* Small font */
   233 /* Small font */
   232 	 226,  316, // ' ' till 'z'
   234 	 226,  316, ///< ' ' till 'z'
   233 	SKIP,   36,
   235 	SKIP,   36,
   234 	 384,  384, // Move ¾ to the correct position
   236 	 384,  384, ///< Move ¾ to the correct position
   235 	 322,  322, // Up arrow
   237 	 322,  322, ///< Up arrow
   236 	 355,  357,
   238 	 355,  357,
   237 	SKIP,    1, // skip currency sign
   239 	SKIP,    1, ///< skip currency sign
   238 	 359,  359,
   240 	 359,  359,
   239 	SKIP,    1,
   241 	SKIP,    1,
   240 	 361,  361,
   242 	 361,  361,
   241 	SKIP,    1,
   243 	SKIP,    1,
   242 	 363,  363,
   244 	 363,  363,
   243 	 364,  364, // TODO Down arrow
   245 	 364,  364, ////< @todo Down arrow
   244 	 365,  366,
   246 	 365,  366,
   245 	SKIP,    1,
   247 	SKIP,    1,
   246 	 368,  368,
   248 	 368,  368,
   247 	 369,  369, // TODO Right arrow
   249 	 369,  369, ///< @todo Right arrow
   248 	 370,  373,
   250 	 370,  373,
   249 	SKIP,    7,
   251 	SKIP,    7,
   250 	 381,  381,
   252 	 381,  381,
   251 	SKIP,    3,
   253 	SKIP,    3,
   252 	 385,  449,
   254 	 385,  449,
   253 /* Big font */
   255 /* Big font */
   254 	 450,  540, // ' ' till 'z'
   256 	 450,  540, ///< ' ' till 'z'
   255 	SKIP,   36,
   257 	SKIP,   36,
   256 	 608,  608, // Move ¾ to the correct position
   258 	 608,  608, ///< Move ¾ to the correct position
   257 	SKIP,    1,
   259 	SKIP,    1,
   258 	 579,  581,
   260 	 579,  581,
   259 	SKIP,    1,
   261 	SKIP,    1,
   260 	 583,  583,
   262 	 583,  583,
   261 	SKIP,    5,
   263 	SKIP,    5,
   286  * the old sprite-count offset from SPR_OPENTTD_BASE. With this there is no
   288  * the old sprite-count offset from SPR_OPENTTD_BASE. With this there is no
   287  * correspondence of any kind with the ID's in the grf file, but results in
   289  * correspondence of any kind with the ID's in the grf file, but results in
   288  * a maximum use of sprite slots. */
   290  * a maximum use of sprite slots. */
   289 static const SpriteID _openttd_grf_indexes[] = {
   291 static const SpriteID _openttd_grf_indexes[] = {
   290 	SPR_IMG_AUTORAIL, SPR_CURSOR_WAYPOINT, // icons etc
   292 	SPR_IMG_AUTORAIL, SPR_CURSOR_WAYPOINT, // icons etc
   291 	134, 134,  // euro symbol medium size
   293 	134, 134,  ///< euro symbol medium size
   292 	582, 582,  // euro symbol large size
   294 	582, 582,  ///<  euro symbol large size
   293 	358, 358,  // euro symbol tiny
   295 	358, 358,  ///<  euro symbol tiny
   294 	SPR_CURSOR_CANAL, SPR_IMG_FASTFORWARD, // more icons
   296 	SPR_CURSOR_CANAL, SPR_IMG_FASTFORWARD, // more icons
   295 	648, 648, // nordic char: æ
   297 	648, 648, ///<  nordic char: æ
   296 	616, 616, // nordic char: Æ
   298 	616, 616, ///<  nordic char: Æ
   297 	666, 666, // nordic char: ø
   299 	666, 666, ///<  nordic char: ø
   298 	634, 634, // nordic char: Ø
   300 	634, 634, ///<  nordic char: Ø
   299 	SPR_PIN_UP, SPR_CURSOR_CLONE_TRAIN, // more icons
   301 	SPR_PIN_UP, SPR_CURSOR_CLONE_TRAIN, // more icons
   300 	382, 383, // ¼ ½ tiny
   302 	382, 383, ///<  ¼ ½ tiny
   301 	158, 159, // ¼ ½ medium
   303 	158, 159, ///<  ¼ ½ medium
   302 	606, 607, // ¼ ½ large
   304 	606, 607, ///<  ¼ ½ large
   303 	360, 360, // ¦ tiny
   305 	360, 360, ///<  ¦ tiny
   304 	362, 362, // ¨ tiny
   306 	362, 362, ///<  ¨ tiny
   305 	136, 136, // ¦ medium
   307 	136, 136, ///<  ¦ medium
   306 	138, 138, // ¨ medium
   308 	138, 138, ///<  ¨ medium
   307 	584, 584, // ¦ large
   309 	584, 584, ///<  ¦ large
   308 	586, 586, // ¨ large
   310 	586, 586, ///<  ¨ large
   309 	626, 626, // Ð large
   311 	626, 626, ///<  Ð large
   310 	658, 658, // ð large
   312 	658, 658, ///<  ð large
   311 	374, 374, // ´ tiny
   313 	374, 374, ///<  ´ tiny
   312 	378, 378, // ¸ tiny
   314 	378, 378, ///<  ¸ tiny
   313 	150, 150, // ´ medium
   315 	150, 150, ///<  ´ medium
   314 	154, 154, // ¸ medium
   316 	154, 154, ///<  ¸ medium
   315 	598, 598, // ´ large
   317 	598, 598, ///<  ´ large
   316 	602, 602, // ¸ large
   318 	602, 602, ///<  ¸ large
   317 	640, 640, // Þ large
   319 	640, 640, ///<  Þ large
   318 	672, 672, // þ large
   320 	672, 672, ///<  þ large
   319 	380, 380, // º tiny
   321 	380, 380, ///<  º tiny
   320 	156, 156, // º medium
   322 	156, 156, ///<  º medium
   321 	604, 604, // º large
   323 	604, 604, ///<  º large
   322 	317, 320, // { | } ~ tiny
   324 	317, 320, ///<  { | } ~ tiny
   323 	 93,  96, // { | } ~ medium
   325 	 93,  96, ///<  { | } ~ medium
   324 	541, 544, // { | } ~ large
   326 	541, 544, ///<  { | } ~ large
   325 	SPR_HOUSE_ICON, SPR_HOUSE_ICON,
   327 	SPR_HOUSE_ICON, SPR_HOUSE_ICON,
   326 	585, 585, // § large
   328 	585, 585, ///<  § large
   327 	587, 587, // © large
   329 	587, 587, ///<  © large
   328 	592, 592, // ® large
   330 	592, 592, ///<  ® large
   329 	594, 597, // ° ± ² ³ large
   331 	594, 597, ///<  ° ± ² ³ large
   330 	633, 633, // × large
   332 	633, 633, ///<  × large
   331 	665, 665, // ÷ large
   333 	665, 665, ///<  ÷ large
   332 	SPR_SELL_TRAIN, SPR_SHARED_ORDERS_ICON,
   334 	SPR_SELL_TRAIN, SPR_SHARED_ORDERS_ICON,
   333 	377, 377, // · small
   335 	377, 377, ///<  · small
   334 	153, 153, // · medium
   336 	153, 153, ///<  · medium
   335 	601, 601, // · large
   337 	601, 601, ///<  · large
   336 	SPR_WARNING_SIGN, SPR_WARNING_SIGN,
   338 	SPR_WARNING_SIGN, SPR_WARNING_SIGN,
   337 	END
   339 	END
   338 };
   340 };
   339 
   341 
   340 
   342