hedgewars/uConsts.pas
changeset 2699 249adefa9c1c
parent 2697 75880595a9f1
child 2703 fbde0d971ba6
equal deleted inserted replaced
2698:90585aba87ad 2699:249adefa9c1c
    19 {$INCLUDE "options.inc"}
    19 {$INCLUDE "options.inc"}
    20 
    20 
    21 unit uConsts;
    21 unit uConsts;
    22 interface
    22 interface
    23 
    23 
    24 uses
    24 uses	SDLh, uFloat, uLocale,
    25 	SDLh,
       
    26 {$IFDEF GLES11}
    25 {$IFDEF GLES11}
    27 	gles11,
    26 	gles11;
    28 {$ELSE}
    27 {$ELSE}
    29 	GL,
    28 	GL;
    30 {$ENDIF}
    29 {$ENDIF}
    31 	uLocale;
    30 
    32 
    31 
    33 {$INCLUDE "proto.inc"}
    32 {$INCLUDE "proto.inc"}
    34 
    33 
    35 // typed const is a variable despite const qualifier
    34 // typed const is a variable despite const qualifier
    36 // in freepascal you may actually use var for the same purpose
    35 // in freepascal you may actually use var for the same purpose
    37 
    36 
    38 type
    37 type
    39 
    38 	HwColor4f = record
       
    39 		r, g, b, a: byte
       
    40 		end;
       
    41 		
    40 	TGameState = (gsLandGen, gsStart, gsGame, gsChat, gsConfirm, gsExit);
    42 	TGameState = (gsLandGen, gsStart, gsGame, gsChat, gsConfirm, gsExit);
    41 
    43 
    42 	TGameType = (gmtLocal, gmtDemo, gmtNet, gmtSave, gmtLandPreview);
    44 	TGameType = (gmtLocal, gmtDemo, gmtNet, gmtSave, gmtLandPreview);
    43 
    45 
    44 	TPathType = (ptNone, ptData, ptGraphics, ptThemes, ptCurrTheme, ptTeams, ptMaps,
    46 	TPathType = (ptNone, ptData, ptGraphics, ptThemes, ptCurrTheme, ptTeams, ptMaps,
   156 			vb, tb: array [0..3] of TVertex2f;
   158 			vb, tb: array [0..3] of TVertex2f;
   157 			end;
   159 			end;
   158 	PTexture = ^TTexture;
   160 	PTexture = ^TTexture;
   159 
   161 
   160 const
   162 const
       
   163 	// message constants
   161 	errmsgCreateSurface   = 'Error creating SDL surface';
   164 	errmsgCreateSurface   = 'Error creating SDL surface';
   162 	errmsgTransparentSet  = 'Error setting transparent color';
   165 	errmsgTransparentSet  = 'Error setting transparent color';
   163 	errmsgUnknownCommand  = 'Unknown command';
   166 	errmsgUnknownCommand  = 'Unknown command';
   164 	errmsgUnknownVariable = 'Unknown variable';
   167 	errmsgUnknownVariable = 'Unknown variable';
   165 	errmsgIncorrectUse    = 'Incorrect use';
   168 	errmsgIncorrectUse    = 'Incorrect use';
   171 	msgOK                = 'ok';
   174 	msgOK                = 'ok';
   172 	msgFailed            = 'failed';
   175 	msgFailed            = 'failed';
   173 	msgFailedSize        = 'failed due to size';
   176 	msgFailedSize        = 'failed due to size';
   174 	msgGettingConfig     = 'Getting game config...';
   177 	msgGettingConfig     = 'Getting game config...';
   175 
   178 
   176 const // image flags (for LoadImage())
   179 	// color constants
   177     ifNone        = $00000000; // nothing special
   180 	cWhiteColorChannels	: TSDL_Color = (r:$FF; g:$FF; b:$FF; unused:$FF);
   178     ifAlpha       = $00000001; // use alpha channel (unused right now?)
   181 	cNearBlackColorChannels	: TSDL_Color = (r:$00; g:$00; b:$10; unused:$FF);
   179     ifCritical    = $00000002; // image is critical for gameplay (exit game if unable to load)
   182 
   180     ifTransparent = $00000004; // image uses transparent pixels (color keying)
   183 	cWhiteColor		: Longword = $FFFFFFFF;
   181     ifIgnoreCaps  = $00000008; // ignore hardware capabilities when loading (i.e. image will not be drawn using OpenGL)
   184 	cYellowColor		: Longword = $FFFFFF00;
   182     ifLowRes      = $00000010; // try loading a low resolution image when it is critical
   185 	cExplosionBorderColor	: LongWord = $FF808080;
   183 
   186 
   184 const
   187 {$WARNINGS OFF}
   185 	cMaxPower     = 1500;
   188 	cAirPlaneSpeed: hwFloat = (isNegative: false; QWordValue:   3006477107); // 1.4
   186 	cMaxAngle     = 2048;
   189 	cBombsSpeed   : hwFloat = (isNegative: false; QWordValue:    429496729);
   187 	cPowerDivisor = 1500;
   190 {$WARNINGS ON}
   188 
   191 
   189 	MAXNAMELEN = 192;
   192 	// image flags (for LoadImage())
       
   193 	ifNone        = $00000000;	// nothing special
       
   194 	ifAlpha       = $00000001;	// use alpha channel (unused right now?)
       
   195 	ifCritical    = $00000002;	// image is critical for gameplay (exit game if unable to load)
       
   196 	ifTransparent = $00000004;	// image uses transparent pixels (color keying)
       
   197 	ifIgnoreCaps  = $00000008;	// ignore hardware capabilities when loading (i.e. image will not be drawn using OpenGL)
       
   198 	ifLowRes      = $00000010;	// try loading a low resolution image when it is critical
   190 
   199 
   191 	{*  REFERENCE
   200 	{*  REFERENCE
   192       4096 -> $FFFFF000
   201       4096 -> $FFFFF000
   193       2048 -> $FFFFF800
   202       2048 -> $FFFFF800
   194       1024 -> $FFFFFC00
   203       1024 -> $FFFFFC00
   209 
   218 
   210 	COLOR_LAND           = $FFFF;  // white
   219 	COLOR_LAND           = $FFFF;  // white
   211 	COLOR_INDESTRUCTIBLE = $88FF;  // red
   220 	COLOR_INDESTRUCTIBLE = $88FF;  // red
   212 	COLOR_OBJECT         = $44FF;  // no idea
   221 	COLOR_OBJECT         = $44FF;  // no idea
   213 
   222 
       
   223 	cMaxPower     = 1500;
       
   224 	cMaxAngle     = 2048;
       
   225 	cPowerDivisor = 1500;
       
   226 
       
   227 	MAXNAMELEN = 192;
       
   228 	
   214 	// some opengl headers do not have these macros
   229 	// some opengl headers do not have these macros
   215 	GL_BGR  = $80E0;
   230 	GL_BGR		 = $80E0;
   216 	GL_BGRA = $80E1;
   231 	GL_BGRA		 = $80E1;
   217 	GL_CLAMP_TO_EDGE = $812F;
   232 	GL_CLAMP_TO_EDGE = $812F;
   218 
   233 
       
   234 	cSendCursorPosTime	: LongWord = 50;
       
   235 	cVisibleWater		: LongInt = 128;
       
   236 	cCursorEdgesDist	: LongInt = 100;
       
   237 	cTeamHealthWidth	: LongInt = 128;
       
   238 	cWaterOpacity		: byte = $80;
   219 
   239 
   220 	cifRandomize = $00000001;
   240 	cifRandomize = $00000001;
   221 	cifTheme     = $00000002;
   241 	cifTheme     = $00000002;
   222 	cifMap       = $00000002; // either theme or map (or map+theme)
   242 	cifMap       = $00000002; // either theme or map (or map+theme)
   223 	cifAllInited = cifRandomize or cifTheme or cifMap;
   243 	cifAllInited = cifRandomize or cifTheme or cifMap;
   224 
   244 
   225 	cTransparentColor: Longword = $000000;
   245 	cTransparentColor: Longword = $00000000;
   226 
   246 
   227 	cMaxTeams        = 6;
   247 	cMaxTeams        = 6;
   228 	cMaxHHIndex      = 7;
   248 	cMaxHHIndex      = 7;
   229 	cMaxHHs          = 48;
   249 	cMaxHHs          = 48;
   230 	cMaxSpawnPoints  = 1024;
   250 	cMaxSpawnPoints  = 1024;
   336 	posCaseAmmo    = $00000001;
   356 	posCaseAmmo    = $00000001;
   337 	posCaseHealth  = $00000002;
   357 	posCaseHealth  = $00000002;
   338 	posCaseUtility = $00000004;
   358 	posCaseUtility = $00000004;
   339 
   359 
   340 	NoPointX = Low(LongInt);
   360 	NoPointX = Low(LongInt);
       
   361 	cTargetPointRef	: TPoint = (X: NoPointX; Y: 0);
   341 
   362 
   342 	// hog tag mask
   363 	// hog tag mask
   343 	htNone        = $00;
   364 	htNone        = $00;
   344 	htTeamName    = $01;
   365 	htTeamName    = $01;
   345 	htName        = $02;
   366 	htName        = $02;
   346 	htHealth      = $04;
   367 	htHealth      = $04;
   347 	htTransparent = $80;
   368 	htTransparent = $80;
   348 	
   369 	
   349 	cTagsMasks : array[0..7] of byte = (
   370 	cHHFileName = 'Hedgehog';
       
   371 	cCHFileName = 'Crosshair';
       
   372 	cThemeCFGFilename = 'theme.cfg';
       
   373 	
       
   374 	FontBorder = 2;
       
   375 var	PathPrefix: string;
       
   376 
       
   377 const	cTagsMasks : array[0..7] of byte = (
   350 				htTeamName or htName or htHealth,
   378 				htTeamName or htName or htHealth,
   351 				htName or htHealth,
   379 				htName or htHealth,
   352 				htHealth,
   380 				htHealth,
   353 				htNone,
   381 				htNone,
   354 				htTeamName or htName or htHealth or htTransparent,
   382 				htTeamName or htName or htHealth or htTransparent,
   355 				htName or htHealth or htTransparent,
   383 				htName or htHealth or htTransparent,
   356 				htHealth or htTransparent,
   384 				htHealth or htTransparent,
   357 				htNone
   385 				htNone
   358 				);
   386 				);
   359 
       
   360 	cHHFileName = 'Hedgehog';
       
   361 	cCHFileName = 'Crosshair';
       
   362 	cThemeCFGFilename = 'theme.cfg';
       
   363 
   387 
   364 	Fontz: array[THWFont] of THHFont = (
   388 	Fontz: array[THWFont] of THHFont = (
   365 			(Handle: nil;
   389 			(Handle: nil;
   366 			Height: 12;
   390 			Height: 12;
   367 			style: TTF_STYLE_NORMAL;
   391 			style: TTF_STYLE_NORMAL;
   386 			Height: 10;
   410 			Height: 10;
   387 			style: TTF_STYLE_NORMAL;
   411 			style: TTF_STYLE_NORMAL;
   388 			Name: 'DroidSansFallback.ttf')
   412 			Name: 'DroidSansFallback.ttf')
   389 			);
   413 			);
   390 
   414 
   391 	FontBorder = 2;
   415 var	Pathz: array[TPathType] of String;
   392 
   416 	
   393 	PathPrefix: string = './';
   417 const	SpritesData: array[TSprite] of record
   394 	Pathz: array[TPathType] of String = (
       
   395 			'',                              // ptNone
       
   396 			'',                              // ptData
       
   397 			'Graphics',                      // ptGraphics
       
   398 			'Themes',                        // ptThemes
       
   399 			'Themes/avematan',               // ptCurrTheme
       
   400 			'Teams',                         // ptTeams
       
   401 			'Maps',                          // ptMaps
       
   402 			'',                              // ptMapCurrent
       
   403 			'Demos',                         // ptDemos
       
   404 			'Sounds',                        // ptSounds
       
   405 			'Graphics/Graves',               // ptGraves
       
   406 			'Fonts',                         // ptFonts
       
   407 			'Forts',                         // ptForts
       
   408 			'Locale',                        // ptLocale
       
   409 			'Graphics/AmmoMenu',             // ptAmmoMenu
       
   410 			'Graphics/Hedgehog',             // ptHedgehog
       
   411 			'Sounds/voices',                 // ptVoices
       
   412 			'Graphics/Hats'                  // ptHats
       
   413 			);
       
   414 		(*
       
   415 	PathzBackup: array[TPathType] of String = (
       
   416 			'',                              // ptNone
       
   417 			'',                              // ptData
       
   418 			'Graphics',                      // ptGraphics
       
   419 			'Themes',                        // ptThemes
       
   420 			'Themes/avematan',               // ptCurrTheme
       
   421 			'Teams',                         // ptTeams
       
   422 			'Maps',                          // ptMaps
       
   423 			'',                              // ptMapCurrent
       
   424 			'Demos',                         // ptDemos
       
   425 			'Sounds',                        // ptSounds
       
   426 			'Graphics/Graves',               // ptGraves
       
   427 			'Fonts',                         // ptFonts
       
   428 			'Forts',                         // ptForts
       
   429 			'Locale',                        // ptLocale
       
   430 			'Graphics/AmmoMenu',             // ptAmmoMenu
       
   431 			'Graphics/Hedgehog',             // ptHedgehog
       
   432 			'Sounds/voices',                 // ptVoices
       
   433 			'Graphics/Hats'                  // ptHats
       
   434 			);
       
   435 		*)	
       
   436 	SpritesData: array[TSprite] of record
       
   437 			FileName: String[14];
   418 			FileName: String[14];
   438 			Path, AltPath: TPathType;
   419 			Path, AltPath: TPathType;
   439 			Texture: PTexture;
   420 			Texture: PTexture;
   440 			Surface: PSDL_Surface;
   421 			Surface: PSDL_Surface;
   441 			Width, Height, imageWidth, imageHeight: LongInt;
   422 			Width, Height, imageWidth, imageHeight: LongInt;
  1632 			PosCount: 1;
  1613 			PosCount: 1;
  1633 			PosSprite: sprWater)
  1614 			PosSprite: sprWater)
  1634 			);
  1615 			);
  1635 
  1616 
  1636 
  1617 
  1637 const conversionFormat: TSDL_PixelFormat = (
  1618 	conversionFormat: TSDL_PixelFormat = (
  1638 	palette: nil;
  1619 		palette: nil;
  1639 	BitsPerPixel : 32;
  1620 		BitsPerPixel : 32;
  1640 	BytesPerPixel: 4;
  1621 		BytesPerPixel: 4;
  1641 	Rloss : 0;
  1622 		Rloss : 0;
  1642 	Gloss : 0;
  1623 		Gloss : 0;
  1643 	Bloss : 0;
  1624 		Bloss : 0;
  1644 	Aloss : 0;
  1625 		Aloss : 0;
  1645 {$IFDEF ENDIAN_LITTLE}
  1626 {$IFDEF ENDIAN_LITTLE}
  1646 	Rshift: 0;
  1627 		Rshift: 0;
  1647         Gshift: 8;
  1628 		Gshift: 8;
  1648         Bshift: 16;
  1629 		Bshift: 16;
  1649         Ashift: 24;
  1630 		Ashift: 24;
  1650 {$ELSE}
  1631 {$ELSE}
  1651 	Rshift: 24;
  1632 		Rshift: 24;
  1652 	Gshift: 16;
  1633 		Gshift: 16;
  1653 	Bshift: 8;
  1634 		Bshift: 8;
  1654 	Ashift: 0;
  1635 		Ashift: 0;
  1655 {$ENDIF}
  1636 {$ENDIF}
  1656 	RMask : RMask;
  1637 		RMask : RMask;
  1657 	GMask : GMask;
  1638 		GMask : GMask;
  1658 	BMask : BMask;
  1639 		BMask : BMask;
  1659 	AMask : AMask;
  1640 		AMask : AMask;
  1660 	colorkey: 0;
  1641 		colorkey: 0;
  1661 	alpha : 255
  1642 		alpha : 255
  1662 );
  1643 	);
  1663 			
  1644 			
  1664 
  1645 
  1665 var CountTexz: array[1..Pred(AMMO_INFINITE)] of PTexture;
  1646 var CountTexz: array[1..Pred(AMMO_INFINITE)] of PTexture;
  1666 
  1647 
       
  1648 procedure init_uConsts;
       
  1649 
  1667 implementation
  1650 implementation
  1668 
  1651 
       
  1652 procedure init_uConsts;
       
  1653 var cPathz: array[TPathType] of String = (
       
  1654 		'',                              // ptNone
       
  1655 		'',                              // ptData
       
  1656 		'Graphics',                      // ptGraphics
       
  1657 		'Themes',                        // ptThemes
       
  1658 		'Themes/avematan',               // ptCurrTheme
       
  1659 		'Teams',                         // ptTeams
       
  1660 		'Maps',                          // ptMaps
       
  1661 		'',                              // ptMapCurrent
       
  1662 		'Demos',                         // ptDemos
       
  1663 		'Sounds',                        // ptSounds
       
  1664 		'Graphics/Graves',               // ptGraves
       
  1665 		'Fonts',                         // ptFonts
       
  1666 		'Forts',                         // ptForts
       
  1667 		'Locale',                        // ptLocale
       
  1668 		'Graphics/AmmoMenu',             // ptAmmoMenu
       
  1669 		'Graphics/Hedgehog',             // ptHedgehog
       
  1670 		'Sounds/voices',                 // ptVoices
       
  1671 		'Graphics/Hats'                  // ptHats
       
  1672 	);
       
  1673 begin
       
  1674 	PathPrefix := './';
       
  1675 	Pathz:= cPathz;
       
  1676 end;
       
  1677 
  1669 end.
  1678 end.