hedgewars/uWeb.pas
branchwebgl
changeset 8026 4a4f21070479
equal deleted inserted replaced
8023:7de85783b823 8026:4a4f21070479
       
     1 
       
     2 // defines functions used for web port
       
     3 
       
     4 unit uWeb;
       
     5 interface
       
     6 
       
     7 type
       
     8     TResourceList = record
       
     9         count : Integer;
       
    10         files : array[0..500] of shortstring;
       
    11     end;
       
    12 
       
    13 function generateResourceList:TResourceList;
       
    14 
       
    15 implementation
       
    16 
       
    17 uses uConsts, uVariables, uTypes;
       
    18 
       
    19 function readThemeCfg:TResourceList; forward;
       
    20 
       
    21 function generateResourceList:TResourceList;
       
    22 var
       
    23     cfgRes : TResourceList;
       
    24     i,j : Integer;
       
    25     t, t2 : shortstring;
       
    26     si : TSprite;
       
    27     res : TResourceList;
       
    28 
       
    29 begin
       
    30 
       
    31     res.count := 0;
       
    32 
       
    33     for i:= 0 to Pred(TeamsCount) do
       
    34         with TeamsArray[i]^ do
       
    35             begin
       
    36                 Str(i, t);
       
    37                 
       
    38                 res.files[res.count] := UserPathz[ptGraves] + '/' + GraveName;
       
    39                 res.files[res.count + 1] := UserPathz[ptForts] + '/' + FortName;
       
    40                 res.files[res.count + 2] := UserPathz[ptGraphics] + '/' + FortName;
       
    41                 res.files[res.count + 3] := UserPathz[ptFlags] + '/' + flag;
       
    42 
       
    43                 inc(res.count, 4);
       
    44                 
       
    45             end;
       
    46             
       
    47     for si:= Low(TSprite) to High(TSprite) do
       
    48     with SpritesData[si] do
       
    49         begin
       
    50             Str(si, t);
       
    51             res.files[res.count] := UserPathz[Path] + '/' + FileName;
       
    52             res.files[res.count + 1] := UserPathz[AltPath] + '/' + FileName;
       
    53             inc(res.count, 2);
       
    54 
       
    55         end;
       
    56         
       
    57     for i:= 0 to Pred(ClansCount) do
       
    58     with CLansArray[i]^ do
       
    59     begin
       
    60         for j:= 0 to Pred(TeamsNumber) do
       
    61         begin
       
    62             with Teams[j]^ do
       
    63             begin
       
    64                 Str(i, t);
       
    65                 Str(j, t2);
       
    66                 res.files[res.count] := UserPathz[ptForts] + '/' + FortName;
       
    67                 inc(res.count);
       
    68 
       
    69             end;
       
    70         end;
       
    71     end;
       
    72     
       
    73     cfgRes := readThemeCfg();
       
    74     
       
    75     for i:= 0 to Pred(cfgRes.count) do
       
    76     begin
       
    77         res.files[res.count] := cfgRes.files[i];
       
    78         inc(res.count);
       
    79     end;
       
    80     
       
    81     res.files[res.count] := UserPathz[ptFlags] + '/cpu';
       
    82     inc(res.count);
       
    83     
       
    84     res.files[res.count] := UserPathz[ptFlags] + '/hedgewars';
       
    85     inc(res.count);
       
    86     
       
    87     res.files[res.count] := UserPathz[ptGraphics] + '/' + cHHFileName;
       
    88     inc(res.count);
       
    89     
       
    90     res.files[res.count] := UserPathz[ptGraphics] + '/Girder';
       
    91     inc(res.count);
       
    92     
       
    93     res.files[res.count] := UserPathz[ptCurrTheme] + '/LandTex';
       
    94     inc(res.count);
       
    95     
       
    96     res.files[res.count] := UserPathz[ptCurrTheme] + '/LandBackTex';
       
    97     inc(res.count);
       
    98     
       
    99     res.files[res.count] := UserPathz[ptCurrTheme] + '/Girder';
       
   100     inc(res.count);
       
   101     
       
   102     res.files[res.count] := UserPathz[ptCurrTheme] + '/Border';
       
   103     inc(res.count);
       
   104     
       
   105     res.files[res.count] := UserPathz[ptMapCurrent] + '/mask';
       
   106     inc(res.count);
       
   107     
       
   108     res.files[res.count] := UserPathz[ptMapCurrent] + '/map';
       
   109     inc(res.count);
       
   110     
       
   111     res.files[res.count] := UserPathz[ptGraphics] + '/missions';
       
   112     inc(res.count);
       
   113     
       
   114     res.files[res.count] := UserPathz[ptGraphics] + '/Progress';
       
   115     inc(res.count);
       
   116         
       
   117     res.files[res.count] := UserPathz[ptGraves] + '/Statue';
       
   118     inc(res.count);
       
   119 
       
   120     res.files[res.count] := UserPathz[ptGraphics] + '/' + cCHFileName;
       
   121     inc(res.count);
       
   122 
       
   123     generateResourceList:=res;
       
   124 end;
       
   125 
       
   126 function readThemeCfg : TResourceList;
       
   127 var
       
   128 s,key : shortstring;
       
   129 f : TextFile;
       
   130 i: Integer;
       
   131 res : TResourceList;
       
   132 begin
       
   133     s:=Pathz[ptCurrTheme] + '/' + cThemeCFGFilename;
       
   134 
       
   135     Assign(f, s);
       
   136     {$I-}
       
   137 
       
   138     filemode := 0;
       
   139     Reset(f);
       
   140 
       
   141     res.count := 0;
       
   142     
       
   143     while not eof(f) do
       
   144     begin
       
   145     Readln(f, s);
       
   146     
       
   147     if Length(s) = 0 then
       
   148         continue;
       
   149     if s[1] = ';' then
       
   150         continue;
       
   151         
       
   152     i:= Pos('=', s);
       
   153     key:= Trim(Copy(s, 1, Pred(i)));
       
   154     Delete(s, 1, i);
       
   155     
       
   156     if (key = 'object') or (key = 'spray') then
       
   157     begin
       
   158         i:=Pos(',', s);
       
   159         
       
   160         res.files[res.count] := Pathz[ptCurrTheme] + '/' + Trim(Copy(s, 1, Pred(i)));
       
   161         res.files[res.count + 1] := Pathz[ptGraphics] + '/' + Trim(Copy(s, 1, Pred(i)));
       
   162         inc(res.count, 2);
       
   163         
       
   164     end;
       
   165     
       
   166     end;
       
   167 
       
   168     close(f);
       
   169     {$I+}
       
   170     
       
   171     readThemeCfg := res;
       
   172 end;
       
   173 
       
   174 end.