hedgewars/uUtils.pas
branchwebgl
changeset 8847 ff7fbab7cd56
parent 8841 338f7c2bac2c
parent 8838 aa2ffd427f6a
child 8850 ae8a957c69fd
equal deleted inserted replaced
8844:b216eccfb77a 8847:ff7fbab7cd56
    28 
    28 
    29 {$IFNDEF PAS2C}
    29 {$IFNDEF PAS2C}
    30 procedure SplitByChar(var a, b: ansistring; c: char);
    30 procedure SplitByChar(var a, b: ansistring; c: char);
    31 {$ENDIF}
    31 {$ENDIF}
    32 
    32 
    33 //{$IFNDEF PAS2C}
       
    34 function  EnumToStr(const en : TGearType) : shortstring; overload;
    33 function  EnumToStr(const en : TGearType) : shortstring; overload;
    35 function  EnumToStr(const en : TVisualGearType) : shortstring; overload;
    34 function  EnumToStr(const en : TVisualGearType) : shortstring; overload;
    36 function  EnumToStr(const en : TSound) : shortstring; overload;
    35 function  EnumToStr(const en : TSound) : shortstring; overload;
    37 function  EnumToStr(const en : TAmmoType) : shortstring; overload;
    36 function  EnumToStr(const en : TAmmoType) : shortstring; overload;
    38 function  EnumToStr(const en : THogEffect) : shortstring; overload;
    37 function  EnumToStr(const en : THogEffect) : shortstring; overload;
    39 function  EnumToStr(const en : TCapGroup) : shortstring; overload;
    38 function  EnumToStr(const en : TCapGroup) : shortstring; overload;
    40 //{$ENDIF}
       
    41 
    39 
    42 function  Min(a, b: LongInt): LongInt; inline;
    40 function  Min(a, b: LongInt): LongInt; inline;
    43 function  Max(a, b: LongInt): LongInt; inline;
    41 function  Max(a, b: LongInt): LongInt; inline;
    44 
    42 
    45 function  IntToStr(n: LongInt): shortstring;
    43 function  IntToStr(n: LongInt): shortstring;
   141     setlength(a, Pred(i));
   139     setlength(a, Pred(i));
   142     end else b:= '';
   140     end else b:= '';
   143 end; { SplitByChar }
   141 end; { SplitByChar }
   144 {$ENDIF}
   142 {$ENDIF}
   145 
   143 
   146 //{$IFNDEF PAS2C}
       
   147 function EnumToStr(const en : TGearType) : shortstring; overload;
   144 function EnumToStr(const en : TGearType) : shortstring; overload;
   148 begin
   145 begin
   149 EnumToStr:= GetEnumName(TypeInfo(TGearType), ord(en))
   146 EnumToStr:= GetEnumName(TypeInfo(TGearType), ord(en))
   150 end;
   147 end;
       
   148 
   151 function EnumToStr(const en : TVisualGearType) : shortstring; overload;
   149 function EnumToStr(const en : TVisualGearType) : shortstring; overload;
   152 begin
   150 begin
   153 EnumToStr:= GetEnumName(TypeInfo(TVisualGearType), ord(en))
   151 EnumToStr:= GetEnumName(TypeInfo(TVisualGearType), ord(en))
   154 end;
   152 end;
   155 
   153 
   170 
   168 
   171 function EnumToStr(const en: TCapGroup) : shortstring; overload;
   169 function EnumToStr(const en: TCapGroup) : shortstring; overload;
   172 begin
   170 begin
   173 EnumToStr := GetEnumName(TypeInfo(TCapGroup), ord(en))
   171 EnumToStr := GetEnumName(TypeInfo(TCapGroup), ord(en))
   174 end;
   172 end;
   175 //{$ENDIF}
   173 
   176 
   174 
   177 function Min(a, b: LongInt): LongInt;
   175 function Min(a, b: LongInt): LongInt;
   178 begin
   176 begin
   179 if a < b then
   177 if a < b then
   180     Min:= a
   178     Min:= a