hedgewars/uMisc.pas
changeset 3611 ed00aa2b339e
parent 3599 715a43602da8
child 3613 cfd3c6536a09
equal deleted inserted replaced
3610:8590424bdfb0 3611:ed00aa2b339e
    27 var
    27 var
    28     isCursorVisible : boolean;
    28     isCursorVisible : boolean;
    29     isTerminated    : boolean;
    29     isTerminated    : boolean;
    30     isInLag         : boolean;
    30     isInLag         : boolean;
    31     isPaused        : boolean;
    31     isPaused        : boolean;
    32     isSoundEnabled  : boolean;
    32 
    33     isMusicEnabled  : boolean;
       
    34     isSEBackup      : boolean;
    33     isSEBackup      : boolean;
    35     isInMultiShoot  : boolean;
    34     isInMultiShoot  : boolean;
    36     isSpeed         : boolean;
    35     isSpeed         : boolean;
    37     isFirstFrame    : boolean;
    36     isFirstFrame    : boolean;
    38 
    37 
    39     fastUntilLag    : boolean;
    38     fastUntilLag    : boolean;
    40 
    39 
    41     GameState   : TGameState;
    40     GameState       : TGameState;
    42     GameType    : TGameType;
    41     GameType        : TGameType;
    43     GameFlags   : Longword;
    42     GameFlags       : Longword;
    44     TrainingFlags   : Longword;
    43     TrainingFlags   : Longword;
    45     TurnTimeLeft    : Longword;
    44     TurnTimeLeft    : Longword;
    46     cSuddenDTurns   : LongInt;
    45     cSuddenDTurns   : LongInt;
    47     cDamagePercent  : LongInt;
    46     cDamagePercent  : LongInt;
    48     cMineDudPercent : LongWord;
    47     cMineDudPercent : LongWord;
    53     cHedgehogTurnTime: Longword;
    52     cHedgehogTurnTime: Longword;
    54     cMinesTime       : LongInt;
    53     cMinesTime       : LongInt;
    55     cMaxAIThinkTime  : Longword;
    54     cMaxAIThinkTime  : Longword;
    56 
    55 
    57     cCloudsNumber    : LongInt;
    56     cCloudsNumber    : LongInt;
    58     cScreenWidth     : LongInt;
    57 
    59     cScreenHeight    : LongInt;
       
    60     cInitWidth       : LongInt;
       
    61     cInitHeight      : LongInt;
       
    62     cVSyncInUse      : boolean;
       
    63     cBits            : LongInt;
       
    64     cBitsStr         : string[2];
       
    65     cTagsMask        : byte;
    58     cTagsMask        : byte;
    66     zoom             : GLfloat;
    59     zoom             : GLfloat;
    67     ZoomValue        : GLfloat;
    60     ZoomValue        : GLfloat;
    68 
    61 
    69     cWaterLine       : LongInt;
    62     cWaterLine       : LongInt;
    70     cGearScrEdgesDist: LongInt;
    63     cGearScrEdgesDist: LongInt;
    71     cAltDamage       : boolean;
       
    72 
    64 
    73     GameTicks   : LongWord;
    65     GameTicks   : LongWord;
    74     TrainingTimeInc : Longword;
    66     TrainingTimeInc : Longword;
    75     TrainingTimeInD : Longword;
    67     TrainingTimeInD : Longword;
    76     TrainingTimeInM : Longword;
    68     TrainingTimeInM : Longword;
    77     TrainingTimeMax : Longword;
    69     TrainingTimeMax : Longword;
    78 
    70 
    79     TimeTrialStartTime: Longword;
    71     TimeTrialStartTime: Longword;
    80     TimeTrialStopTime : Longword;
    72     TimeTrialStopTime : Longword;
    81     
    73     
    82     recordFileName  : shortstring;
    74     // init flags
    83     cShowFPS    : boolean;
    75     cScreenWidth    : LongInt = 1024;
    84     cCaseFactor : Longword;
    76     cScreenHeight   : LongInt = 768;
       
    77     cBits           : LongInt = 32;
       
    78     cBitsStr        : string[2] = '32';
       
    79     //ipcPort is in uIO
       
    80     cFullScreen     : boolean = false;
       
    81     isSoundEnabled  : boolean = true;
       
    82     isMusicEnabled  : boolean = false;
       
    83     cVSyncInUse     : boolean = true;    
       
    84     cWeaponTooltips : boolean = true;
       
    85     cLocaleFName    : shortstring = 'en.txt';
       
    86     cInitVolume     : LongInt = 50;
       
    87     cTimerInterval  : LongInt = 8;
       
    88     //pathPrefix is in uConsts
       
    89     cShowFPS        : boolean = false;
       
    90     cAltDamage      : boolean = true;
       
    91     cReducedQuality : LongInt = 0;
       
    92 
       
    93     recordFileName  : shortstring = '';
       
    94     
       
    95     cCaseFactor     : Longword;
    85     cLandAdditions  : Longword;
    96     cLandAdditions  : Longword;
    86     cExplosives : Longword;
    97     cExplosives     : Longword;
    87     cFullScreen : boolean;
    98 
    88     cReducedQuality : LongInt;
    99     cSeed           : shortstring;
    89     cLocaleFName    : shortstring;
       
    90     cSeed       : shortstring;
       
    91     cInitVolume : LongInt;
       
    92     cVolumeDelta    : LongInt;
   100     cVolumeDelta    : LongInt;
    93     cTimerInterval  : Longword;
   101     cHasFocus       : boolean;
    94     cHasFocus   : boolean;
   102     cInactDelay     : Longword;
    95     cInactDelay : Longword;
       
    96 
   103 
    97     bBetweenTurns   : boolean;
   104     bBetweenTurns   : boolean;
    98     cHealthDecrease : LongWord;
   105     cHealthDecrease : LongWord;
    99     bWaterRising    : Boolean;
   106     bWaterRising    : Boolean;
   100 
   107 
   101     ShowCrosshair   : boolean;
   108     ShowCrosshair   : boolean;
   102     CursorMovementX : LongInt;
   109     CursorMovementX : LongInt;
   103     CursorMovementY : LongInt;
   110     CursorMovementY : LongInt;
   104     cDrownSpeed : hwFloat;
   111     cDrownSpeed     : hwFloat;
   105     cDrownSpeedf : float;
   112     cDrownSpeedf    : float;
   106     cMaxWindSpeed   : hwFloat;
   113     cMaxWindSpeed   : hwFloat;
   107     cWindSpeed  : hwFloat;
   114     cWindSpeed      : hwFloat;
   108     cWindSpeedf  : float;
   115     cWindSpeedf     : float;
   109     cGravity    : hwFloat;
   116     cGravity        : hwFloat;
   110     cGravityf    : float;
   117     cGravityf       : float;
   111     cDamageModifier : hwFloat;
   118     cDamageModifier : hwFloat;
   112     cLaserSighting  : boolean;
   119     cLaserSighting  : boolean;
   113     cVampiric   : boolean;
   120     cVampiric       : boolean;
   114     cArtillery  : boolean;
   121     cArtillery      : boolean;
   115     WeaponTooltipTex : PTexture;
   122     WeaponTooltipTex : PTexture;
   116     cWeaponTooltips: boolean;
       
   117 
   123 
   118     flagMakeCapture : boolean;
   124     flagMakeCapture : boolean;
   119 
   125 
   120     InitStepsFlags  : Longword;
   126     InitStepsFlags  : Longword;
   121     RealTicks   : Longword;
   127     RealTicks       : Longword;
   122     AttackBar   : LongInt;
   128     AttackBar       : LongInt;
   123 
   129 
   124     WaterColorArray : array[0..3] of HwColor4f;
   130     WaterColorArray : array[0..3] of HwColor4f;
   125 
   131 
   126     CursorPoint : TPoint;
   132     CursorPoint     : TPoint;
   127     TargetPoint : TPoint;
   133     TargetPoint     : TPoint;
   128 
   134 
   129     TextureList : PTexture;
   135     TextureList     : PTexture;
   130 
   136 
   131     ScreenFade : TScreenFade;
   137     ScreenFade      : TScreenFade;
   132     ScreenFadeValue : LongInt;
   138     ScreenFadeValue : LongInt;
   133     ScreenFadeSpeed : LongInt;
   139     ScreenFadeSpeed : LongInt;
   134 
   140 
   135 {$IFDEF SDL13}
   141 {$IFDEF SDL13}
   136     SDLwindow: PSDL_Window;
   142     SDLwindow       : PSDL_Window;
   137 {$ENDIF}
   143 {$ENDIF}
   138 
   144 
   139 procedure initModule;
   145 procedure initModule;
   140 procedure freeModule;
   146 procedure freeModule;
   141 procedure SplitBySpace(var a, b: shortstring);
   147 procedure SplitBySpace(var a, b: shortstring);
   142 procedure SplitByChar(var a, b: ansistring; c: char);
   148 procedure SplitByChar(var a, b: ansistring; c: char);
   143 function EnumToStr(const en : TGearType) : shortstring; overload;
   149 function  EnumToStr(const en : TGearType) : shortstring; overload;
   144 function EnumToStr(const en : TSound) : shortstring; overload;
   150 function  EnumToStr(const en : TSound) : shortstring; overload;
   145 function EnumToStr(const en : TAmmoType) : shortstring; overload;
   151 function  EnumToStr(const en : TAmmoType) : shortstring; overload;
   146 procedure movecursor(dx, dy: LongInt);
   152 procedure movecursor(dx, dy: LongInt);
   147 function  hwSign(r: hwFloat): LongInt;
   153 function  hwSign(r: hwFloat): LongInt;
   148 function  Min(a, b: LongInt): LongInt;
   154 function  Min(a, b: LongInt): LongInt;
   149 function  Max(a, b: LongInt): LongInt;
   155 function  Max(a, b: LongInt): LongInt;
   150 procedure OutError(Msg: shortstring; isFatalError: boolean);
   156 procedure OutError(Msg: shortstring; isFatalError: boolean);
   290 end;
   296 end;
   291 
   297 
   292 procedure SetTextureParameters(enableClamp: Boolean);
   298 procedure SetTextureParameters(enableClamp: Boolean);
   293 begin
   299 begin
   294     //if enableClamp and not cReducedQuality then
   300     //if enableClamp and not cReducedQuality then
   295     if enableClamp and ((cReducedQuality and rqNoBackground) = 0) then
   301     if enableClamp and ((cReducedQuality and rqClampLess) = 0) then
   296     begin
   302     begin
   297         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
   303         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
   298         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
   304         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
   299     end;
   305     end;
   300     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
   306     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
   716     cDamagePercent      := 100;
   722     cDamagePercent      := 100;
   717     cMineDudPercent     := 0;
   723     cMineDudPercent     := 0;
   718     cTemplateFilter     := 0;
   724     cTemplateFilter     := 0;
   719     cMapGen             := 0;//MAPGEN_REGULAR
   725     cMapGen             := 0;//MAPGEN_REGULAR
   720     cMazeSize           := 0;
   726     cMazeSize           := 0;
   721 
       
   722     cHedgehogTurnTime   := 45000;
   727     cHedgehogTurnTime   := 45000;
   723     cMinesTime          := 3000;
   728     cMinesTime          := 3000;
   724     cMaxAIThinkTime     := 9000;
   729     cMaxAIThinkTime     := 9000;
   725 
       
   726     cCloudsNumber       := 9;
   730     cCloudsNumber       := 9;
   727     cScreenWidth        := 1024;
   731 
   728     cScreenHeight       := 768;
       
   729     cInitWidth      := cScreenWidth;
       
   730     cInitHeight     := cScreenHeight;
       
   731     cBits           := 32;
       
   732     cTagsMask       := 0;
   732     cTagsMask       := 0;
   733     KBnum           := 0;
   733     KBnum           := 0;
   734     InitStepsFlags  := 0;
   734     InitStepsFlags  := 0;
   735     RealTicks       := 0;
   735     RealTicks       := 0;
   736     AttackBar       := 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP
   736     AttackBar       := 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP
   737     
   737     cCaseFactor     := 5;  {0..9}
   738     // tgametype and glfloat and string
   738     cLandAdditions  := 4;
       
   739     cExplosives     := 2;
       
   740         
   739     GameState       := Low(TGameState);
   741     GameState       := Low(TGameState);
   740     GameType        := gmtLocal;
   742     GameType        := gmtLocal;
   741     zoom            := 2.0;
   743     zoom            := 2.0;
   742     ZoomValue       := 2.0;
   744     ZoomValue       := 2.0;
   743     cBitsStr        := '32';
       
   744     WeaponTooltipTex:= nil;
   745     WeaponTooltipTex:= nil;
   745 
       
   746     // booleans
       
   747     cLaserSighting  := false;
   746     cLaserSighting  := false;
   748     cVampiric       := false;
   747     cVampiric       := false;
   749     cArtillery      := false;
   748     cArtillery      := false;
   750     flagMakeCapture := false;
   749     flagMakeCapture := false;
   751     bBetweenTurns   := false;
   750     bBetweenTurns   := false;
   752     bWaterRising    := false;
   751     bWaterRising    := false;
   753     isCursorVisible := false;
   752     isCursorVisible := false;
   754     isTerminated    := false;
   753     isTerminated    := false;
   755     isInLag         := false;
   754     isInLag         := false;
   756     isPaused        := false;
   755     isPaused        := false;
   757     isMusicEnabled  := false;
       
   758     isInMultiShoot  := false;
   756     isInMultiShoot  := false;
   759     isSpeed         := false;
   757     isSpeed         := false;
   760     fastUntilLag    := false;
   758     fastUntilLag    := false;
   761     isFirstFrame    := true;
   759     isFirstFrame    := true;
   762     cVSyncInUse     := true;    
       
   763     isSoundEnabled  := true;
       
   764     isSEBackup      := true;
   760     isSEBackup      := true;
   765     
       
   766     // init flags
       
   767     recordFileName  := '';
       
   768     cShowFPS        := false;
       
   769     cCaseFactor     := 5;  {0..9}
       
   770     cLandAdditions  := 4;
       
   771     cExplosives     := 2;
       
   772     cFullScreen     := false;
       
   773     cReducedQuality := 0;
       
   774     cLocaleFName    := 'en.txt';
       
   775     cSeed           := '';
   761     cSeed           := '';
   776     cInitVolume     := 50;
       
   777     cVolumeDelta    := 0;
   762     cVolumeDelta    := 0;
   778     cTimerInterval  := 8;
       
   779     cHasFocus       := true;
   763     cHasFocus       := true;
   780     cInactDelay     := 1250;
   764     cInactDelay     := 1250;
   781     cAltDamage      := true;
       
   782 
   765 
   783     ScreenFade      := sfNone;
   766     ScreenFade      := sfNone;
   784     
   767     
   785 {$IFDEF SDL13}
   768 {$IFDEF SDL13}
   786     SDLwindow       := nil;
   769     SDLwindow       := nil;