hedgewars/uLocale.pas
changeset 7110 c91d33837b0d
parent 7069 bcf9d8e64e92
child 8026 4a4f21070479
child 8028 dc30104660d3
equal deleted inserted replaced
7020:846cea23aea2 7110:c91d33837b0d
    24 
    24 
    25 const MAX_EVENT_STRINGS = 100;
    25 const MAX_EVENT_STRINGS = 100;
    26 
    26 
    27 procedure LoadLocale(FileName: shortstring);
    27 procedure LoadLocale(FileName: shortstring);
    28 function  Format(fmt: shortstring; var arg: shortstring): shortstring;
    28 function  Format(fmt: shortstring; var arg: shortstring): shortstring;
    29 function  Format(fmt: ansistring; var arg: ansistring): ansistring;
    29 function  FormatA(fmt: ansistring; var arg: ansistring): ansistring;
    30 function  GetEventString(e: TEventId): ansistring;
    30 function  GetEventString(e: TEventId): ansistring;
    31 
    31 
       
    32 {$IFDEF HWLIBRARY}
       
    33 procedure LoadLocaleWrapper(str: pchar); cdecl; export;
       
    34 {$ENDIF}
       
    35 
    32 implementation
    36 implementation
    33 uses uRandom, uUtils, uVariables, uDebug, uConsole;
    37 uses uRandom, uUtils, uVariables, uDebug;
    34 
    38 
    35 var trevt: array[TEventId] of array [0..Pred(MAX_EVENT_STRINGS)] of ansistring;
    39 var trevt: array[TEventId] of array [0..Pred(MAX_EVENT_STRINGS)] of ansistring;
    36     trevt_n: array[TEventId] of integer;
    40     trevt_n: array[TEventId] of integer;
    37 
    41 
    38 procedure LoadLocale(FileName: shortstring);
    42 procedure LoadLocale(FileName: shortstring);
    94             5: if (b >=0) and (b <= ord(High(TGoalStrId))) then
    98             5: if (b >=0) and (b <= ord(High(TGoalStrId))) then
    95                 trgoal[TGoalStrId(b)]:= s;
    99                 trgoal[TGoalStrId(b)]:= s;
    96            end;
   100            end;
    97        end;
   101        end;
    98    Close(f);
   102    Close(f);
    99    {$IFNDEF HWLIBRARY}WriteLnToConsole('Locale loaded "' + FileName + '"');{$ENDIF}
       
   100    end;
   103    end;
   101 {$I+}
   104 {$I+}
   102 end;
   105 end;
   103 
   106 
   104 function GetEventString(e: TEventId): ansistring;
   107 function GetEventString(e: TEventId): ansistring;
   117     Format:= fmt
   120     Format:= fmt
   118 else
   121 else
   119     Format:= copy(fmt, 1, i - 1) + arg + Format(copy(fmt, i + 2, Length(fmt) - i - 1), arg)
   122     Format:= copy(fmt, 1, i - 1) + arg + Format(copy(fmt, i + 2, Length(fmt) - i - 1), arg)
   120 end;
   123 end;
   121 
   124 
   122 function Format(fmt: ansistring; var arg: ansistring): ansistring;
   125 function FormatA(fmt: ansistring; var arg: ansistring): ansistring;
   123 var i: LongInt;
   126 var i: LongInt;
   124 begin
   127 begin
   125 i:= Pos('%1', fmt);
   128 i:= Pos('%1', fmt);
   126 if i = 0 then
   129 if i = 0 then
   127     Format:= fmt
   130     FormatA:= fmt
   128 else
   131 else
   129     Format:= copy(fmt, 1, i - 1) + arg + Format(copy(fmt, i + 2, Length(fmt) - i - 1), arg)
   132     FormatA:= copy(fmt, 1, i - 1) + arg + FormatA(copy(fmt, i + 2, Length(fmt) - i - 1), arg)
   130 end;
   133 end;
   131 
   134 
       
   135 {$IFDEF HWLIBRARY}
   132 procedure LoadLocaleWrapper(str: pchar); cdecl; export;
   136 procedure LoadLocaleWrapper(str: pchar); cdecl; export;
   133 begin
   137 begin
   134     LoadLocale(Strpas(str));
   138     LoadLocale(Strpas(str));
   135 end;
   139 end;
       
   140 {$ENDIF}
   136 
   141 
   137 end.
   142 end.