hedgewars/uLandObjects.pas
changeset 4806 48c1a395f0a7
parent 4792 68f9b331014a
child 4835 a6924450e694
equal deleted inserted replaced
4805:01332828b568 4806:48c1a395f0a7
   396     Readln(f, s);
   396     Readln(f, s);
   397     if Length(s) = 0 then continue;
   397     if Length(s) = 0 then continue;
   398     if s[1] = ';' then continue;
   398     if s[1] = ';' then continue;
   399 
   399 
   400     i:= Pos('=', s);
   400     i:= Pos('=', s);
   401     key:= Trim(Copy(s, 1, i - 1));
   401     key:= Trim(Copy(s, 1, Pred(i)));
   402     Delete(s, 1, i);
   402     Delete(s, 1, i);
   403 
   403 
   404     if key = 'sky' then
   404     if key = 'sky' then
   405         begin
   405         begin
   406         i:= Pos(',', s);
   406         i:= Pos(',', s);
   407         c1.r:= StrToInt(Trim(Copy(s, 1, i - 1)));
   407         c1.r:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   408         Delete(s, 1, i);
   408         Delete(s, 1, i);
   409         i:= Pos(',', s);
   409         i:= Pos(',', s);
   410         c1.g:= StrToInt(Trim(Copy(s, 1, i - 1)));
   410         c1.g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   411         Delete(s, 1, i);
   411         Delete(s, 1, i);
   412         c1.b:= StrToInt(Trim(s));
   412         c1.b:= StrToInt(Trim(s));
   413         glClearColor(c1.r / 255, c1.g / 255, c1.b / 255, 0.99);
   413         glClearColor(c1.r / 255, c1.g / 255, c1.b / 255, 0.99);
   414         end
   414         end
   415     else if key = 'border' then
   415     else if key = 'border' then
   416         begin
   416         begin
   417         i:= Pos(',', s);
   417         i:= Pos(',', s);
   418         c2.r:= StrToInt(Trim(Copy(s, 1, i - 1)));
   418         c2.r:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   419         Delete(s, 1, i);
   419         Delete(s, 1, i);
   420         i:= Pos(',', s);
   420         i:= Pos(',', s);
   421         c2.g:= StrToInt(Trim(Copy(s, 1, i - 1)));
   421         c2.g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   422         Delete(s, 1, i);
   422         Delete(s, 1, i);
   423         c2.b:= StrToInt(Trim(s));
   423         c2.b:= StrToInt(Trim(s));
   424         cExplosionBorderColor:= c2.value or AMask;
   424         cExplosionBorderColor:= c2.value or AMask;
   425         end
   425         end
   426     else if key = 'water-top' then
   426     else if key = 'water-top' then
   427         begin
   427         begin
   428         i:= Pos(',', s);
   428         i:= Pos(',', s);
   429         WaterColorArray[0].r:= StrToInt(Trim(Copy(s, 1, i - 1)));
   429         WaterColorArray[0].r:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   430         Delete(s, 1, i);
   430         Delete(s, 1, i);
   431         i:= Pos(',', s);
   431         i:= Pos(',', s);
   432         WaterColorArray[0].g:= StrToInt(Trim(Copy(s, 1, i - 1)));
   432         WaterColorArray[0].g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   433         Delete(s, 1, i);
   433         Delete(s, 1, i);
   434         WaterColorArray[0].b:= StrToInt(Trim(s));
   434         WaterColorArray[0].b:= StrToInt(Trim(s));
   435         WaterColorArray[0].a := 255;
   435         WaterColorArray[0].a := 255;
   436         WaterColorArray[1]:= WaterColorArray[0];
   436         WaterColorArray[1]:= WaterColorArray[0];
   437         end
   437         end
   438     else if key = 'water-bottom' then
   438     else if key = 'water-bottom' then
   439         begin
   439         begin
   440         i:= Pos(',', s);
   440         i:= Pos(',', s);
   441         WaterColorArray[2].r:= StrToInt(Trim(Copy(s, 1, i - 1)));
   441         WaterColorArray[2].r:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   442         Delete(s, 1, i);
   442         Delete(s, 1, i);
   443         i:= Pos(',', s);
   443         i:= Pos(',', s);
   444         WaterColorArray[2].g:= StrToInt(Trim(Copy(s, 1, i - 1)));
   444         WaterColorArray[2].g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   445         Delete(s, 1, i);
   445         Delete(s, 1, i);
   446         WaterColorArray[2].b:= StrToInt(Trim(s));
   446         WaterColorArray[2].b:= StrToInt(Trim(s));
   447         WaterColorArray[2].a := 255;
   447         WaterColorArray[2].a := 255;
   448         WaterColorArray[3]:= WaterColorArray[2];
   448         WaterColorArray[3]:= WaterColorArray[2];
   449         end
   449         end
   450     else if key = 'water-opacity' then cWaterOpacity:= StrToInt(Trim(s))
   450     else if key = 'water-opacity' then
       
   451         begin
       
   452         cWaterOpacity:= StrToInt(Trim(s));
       
   453         cSDWaterOpacity:= cWaterOpacity
       
   454         end
   451     else if key = 'music' then MusicFN:= Trim(s)
   455     else if key = 'music' then MusicFN:= Trim(s)
   452     else if key = 'clouds' then
   456     else if key = 'clouds' then
   453         begin
   457         begin
   454         cCloudsNumber:= StrToInt(Trim(s)) * cScreenSpace div LAND_WIDTH;
   458         cCloudsNumber:= StrToInt(Trim(s)) * cScreenSpace div LAND_WIDTH;
   455         cSDCloudsNumber:= cCloudsNumber
   459         cSDCloudsNumber:= cCloudsNumber
   458         begin
   462         begin
   459         inc(ThemeObjects.Count);
   463         inc(ThemeObjects.Count);
   460         with ThemeObjects.objs[Pred(ThemeObjects.Count)] do
   464         with ThemeObjects.objs[Pred(ThemeObjects.Count)] do
   461             begin
   465             begin
   462             i:= Pos(',', s);
   466             i:= Pos(',', s);
   463             Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + Trim(Copy(s, 1, i - 1)), ifCritical or ifTransparent or ifIgnoreCaps);
   467             Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + Trim(Copy(s, 1, Pred(i))), ifCritical or ifTransparent or ifIgnoreCaps);
   464             Width:= Surf^.w;
   468             Width:= Surf^.w;
   465             Height:= Surf^.h;
   469             Height:= Surf^.h;
   466             Delete(s, 1, i);
   470             Delete(s, 1, i);
   467             i:= Pos(',', s);
   471             i:= Pos(',', s);
   468             Maxcnt:= StrToInt(Trim(Copy(s, 1, i - 1)));
   472             Maxcnt:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   469             Delete(s, 1, i);
   473             Delete(s, 1, i);
   470             if (Maxcnt < 1) or (Maxcnt > MAXTHEMEOBJECTS) then OutError('Object''s max count should be between 1 and '+ inttostr(MAXTHEMEOBJECTS) +' (it was '+ inttostr(Maxcnt) +').', true);
   474             if (Maxcnt < 1) or (Maxcnt > MAXTHEMEOBJECTS) then OutError('Object''s max count should be between 1 and '+ inttostr(MAXTHEMEOBJECTS) +' (it was '+ inttostr(Maxcnt) +').', true);
   471             with inland do
   475             with inland do
   472                 begin
   476                 begin
   473                 i:= Pos(',', s);
   477                 i:= Pos(',', s);
   474                 x:= StrToInt(Trim(Copy(s, 1, i - 1)));
   478                 x:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   475                 Delete(s, 1, i);
   479                 Delete(s, 1, i);
   476                 i:= Pos(',', s);
   480                 i:= Pos(',', s);
   477                 y:= StrToInt(Trim(Copy(s, 1, i - 1)));
   481                 y:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   478                 Delete(s, 1, i);
   482                 Delete(s, 1, i);
   479                 i:= Pos(',', s);
   483                 i:= Pos(',', s);
   480                 w:= StrToInt(Trim(Copy(s, 1, i - 1)));
   484                 w:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   481                 Delete(s, 1, i);
   485                 Delete(s, 1, i);
   482                 i:= Pos(',', s);
   486                 i:= Pos(',', s);
   483                 h:= StrToInt(Trim(Copy(s, 1, i - 1)));
   487                 h:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   484                 Delete(s, 1, i);
   488                 Delete(s, 1, i);
   485                 CheckRect(Width, Height, x, y, w, h)
   489                 CheckRect(Width, Height, x, y, w, h)
   486                 end;
   490                 end;
   487             i:= Pos(',', s);
   491             i:= Pos(',', s);
   488             rectcnt:= StrToInt(Trim(Copy(s, 1, i - 1)));
   492             rectcnt:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   489             Delete(s, 1, i);
   493             Delete(s, 1, i);
   490             for ii:= 1 to rectcnt do
   494             for ii:= 1 to rectcnt do
   491                 with outland[ii] do
   495                 with outland[ii] do
   492                     begin
   496                     begin
   493                     i:= Pos(',', s);
   497                     i:= Pos(',', s);
   494                     x:= StrToInt(Trim(Copy(s, 1, i - 1)));
   498                     x:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   495                     Delete(s, 1, i);
   499                     Delete(s, 1, i);
   496                     i:= Pos(',', s);
   500                     i:= Pos(',', s);
   497                     y:= StrToInt(Trim(Copy(s, 1, i - 1)));
   501                     y:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   498                     Delete(s, 1, i);
   502                     Delete(s, 1, i);
   499                     i:= Pos(',', s);
   503                     i:= Pos(',', s);
   500                     w:= StrToInt(Trim(Copy(s, 1, i - 1)));
   504                     w:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   501                     Delete(s, 1, i);
   505                     Delete(s, 1, i);
   502                     if ii = rectcnt then h:= StrToInt(Trim(s))
   506                     if ii = rectcnt then h:= StrToInt(Trim(s))
   503                     else
   507                     else
   504                         begin
   508                         begin
   505                         i:= Pos(',', s);
   509                         i:= Pos(',', s);
   506                         h:= StrToInt(Trim(Copy(s, 1, i - 1)));
   510                         h:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   507                         Delete(s, 1, i)
   511                         Delete(s, 1, i)
   508                         end;
   512                         end;
   509                     CheckRect(Width, Height, x, y, w, h)
   513                     CheckRect(Width, Height, x, y, w, h)
   510                     end;
   514                     end;
   511             end;
   515             end;
   514         begin
   518         begin
   515         inc(SprayObjects.Count);
   519         inc(SprayObjects.Count);
   516         with SprayObjects.objs[Pred(SprayObjects.Count)] do
   520         with SprayObjects.objs[Pred(SprayObjects.Count)] do
   517             begin
   521             begin
   518             i:= Pos(',', s);
   522             i:= Pos(',', s);
   519             Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + Trim(Copy(s, 1, i - 1)), ifCritical or ifTransparent or ifIgnoreCaps);
   523             Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + Trim(Copy(s, 1, Pred(i))), ifCritical or ifTransparent or ifIgnoreCaps);
   520             Width:= Surf^.w;
   524             Width:= Surf^.w;
   521             Height:= Surf^.h;
   525             Height:= Surf^.h;
   522             Delete(s, 1, i);
   526             Delete(s, 1, i);
   523             Maxcnt:= StrToInt(Trim(s));
   527             Maxcnt:= StrToInt(Trim(s));
   524             end;
   528             end;
   525         end
   529         end
   526     else if key = 'flakes' then
   530     else if key = 'flakes' then
   527         begin
   531         begin
   528         i:= Pos(',', s);
   532         i:= Pos(',', s);
   529         vobCount:= StrToInt(Trim(Copy(s, 1, i - 1)));
   533         vobCount:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   530         Delete(s, 1, i);
   534         Delete(s, 1, i);
   531         if vobCount > 0 then
   535         if vobCount > 0 then
   532             begin
   536             begin
   533             i:= Pos(',', s);
   537             i:= Pos(',', s);
   534             vobFramesCount:= StrToInt(Trim(Copy(s, 1, i - 1)));
   538             vobFramesCount:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   535             Delete(s, 1, i);
   539             Delete(s, 1, i);
   536             i:= Pos(',', s);
   540             i:= Pos(',', s);
   537             vobFrameTicks:= StrToInt(Trim(Copy(s, 1, i - 1)));
   541             vobFrameTicks:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   538             Delete(s, 1, i);
   542             Delete(s, 1, i);
   539             i:= Pos(',', s);
   543             i:= Pos(',', s);
   540             vobVelocity:= StrToInt(Trim(Copy(s, 1, i - 1)));
   544             vobVelocity:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   541             Delete(s, 1, i);
   545             Delete(s, 1, i);
   542             vobFallSpeed:= StrToInt(Trim(s));
   546             vobFallSpeed:= StrToInt(Trim(s));
       
   547             vobCount:= vobCount * cScreenSpace div LAND_WIDTH;
   543             end;
   548             end;
   544         end
   549         end
   545     else if key = 'sd-water-top' then
   550     else if key = 'sd-water-top' then
   546         begin
   551         begin
   547         i:= Pos(',', s);
   552         i:= Pos(',', s);
   548         SDWaterColorArray[0].r:= StrToInt(Trim(Copy(s, 1, i - 1)));
   553         SDWaterColorArray[0].r:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   549         Delete(s, 1, i);
   554         Delete(s, 1, i);
   550         i:= Pos(',', s);
   555         i:= Pos(',', s);
   551         SDWaterColorArray[0].g:= StrToInt(Trim(Copy(s, 1, i - 1)));
   556         SDWaterColorArray[0].g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   552         Delete(s, 1, i);
   557         Delete(s, 1, i);
   553         SDWaterColorArray[0].b:= StrToInt(Trim(s));
   558         SDWaterColorArray[0].b:= StrToInt(Trim(s));
   554         SDWaterColorArray[0].a := 255;
   559         SDWaterColorArray[0].a := 255;
   555         SDWaterColorArray[1]:= SDWaterColorArray[0];
   560         SDWaterColorArray[1]:= SDWaterColorArray[0];
   556         end
   561         end
   557     else if key = 'sd-water-bottom' then
   562     else if key = 'sd-water-bottom' then
   558         begin
   563         begin
   559         i:= Pos(',', s);
   564         i:= Pos(',', s);
   560         SDWaterColorArray[2].r:= StrToInt(Trim(Copy(s, 1, i - 1)));
   565         SDWaterColorArray[2].r:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   561         Delete(s, 1, i);
   566         Delete(s, 1, i);
   562         i:= Pos(',', s);
   567         i:= Pos(',', s);
   563         SDWaterColorArray[2].g:= StrToInt(Trim(Copy(s, 1, i - 1)));
   568         SDWaterColorArray[2].g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   564         Delete(s, 1, i);
   569         Delete(s, 1, i);
   565         SDWaterColorArray[2].b:= StrToInt(Trim(s));
   570         SDWaterColorArray[2].b:= StrToInt(Trim(s));
   566         SDWaterColorArray[2].a := 255;
   571         SDWaterColorArray[2].a := 255;
   567         SDWaterColorArray[3]:= SDWaterColorArray[2];
   572         SDWaterColorArray[3]:= SDWaterColorArray[2];
   568         end
   573         end
   569     else if key = 'sd-water-opacity' then cSDWaterOpacity:= StrToInt(Trim(s))
   574     else if key = 'sd-water-opacity' then cSDWaterOpacity:= StrToInt(Trim(s))
   570     else if key = 'sd-clouds' then cSDCloudsNumber:= StrToInt(Trim(s)) * cScreenSpace div LAND_WIDTH
   575     else if key = 'sd-clouds' then cSDCloudsNumber:= StrToInt(Trim(s)) * cScreenSpace div LAND_WIDTH
   571     else if key = 'sd-flakes' then continue //TODO: make :P
   576     else if key = 'sd-flakes' then
       
   577         begin
       
   578         i:= Pos(',', s);
       
   579         vobSDCount:= StrToInt(Trim(Copy(s, 1, Pred(i))));
       
   580         Delete(s, 1, i);
       
   581         if vobSDCount > 0 then
       
   582             begin
       
   583             i:= Pos(',', s);
       
   584             vobSDFramesCount:= StrToInt(Trim(Copy(s, 1, Pred(i))));
       
   585             Delete(s, 1, i);
       
   586             i:= Pos(',', s);
       
   587             vobSDFrameTicks:= StrToInt(Trim(Copy(s, 1, Pred(i))));
       
   588             Delete(s, 1, i);
       
   589             i:= Pos(',', s);
       
   590             vobSDVelocity:= StrToInt(Trim(Copy(s, 1, Pred(i))));
       
   591             Delete(s, 1, i);
       
   592             vobSDFallSpeed:= StrToInt(Trim(s));
       
   593             vobSDCount:= vobSDCount * cScreenSpace div LAND_WIDTH;
       
   594             end;
       
   595         end
   572     end;
   596     end;
   573 
       
   574 // adjust amount of flakes scaled by screen space
       
   575 vobCount:= longint(vobCount);
       
   576 numFlakes:= vobCount * cScreenSpace div LAND_WIDTH;
       
   577 
       
   578 if (cReducedQuality and rqKillFlakes) <> 0 then
       
   579     numFlakes:= 0;
       
   580 
       
   581 if ((GameFlags and gfBorder) <> 0) or ((Theme <> 'Snow') and (Theme <> 'Christmas')) then
       
   582     for i:= 0 to Pred(numFlakes) do
       
   583         AddVisualGear(cLeftScreenBorder + random(cScreenSpace), random(1024+200) - 100 + LAND_HEIGHT, vgtFlake)
       
   584 else
       
   585     for i:= 0 to Pred(numFlakes div 3) do
       
   586         AddVisualGear(cLeftScreenBorder + random(cScreenSpace), random(1024+200) - 100 + LAND_HEIGHT, vgtFlake);
       
   587 
   597 
   588 Close(f);
   598 Close(f);
   589 {$I+}
   599 {$I+}
   590 TryDo(IOResult = 0, 'Bad data or cannot access file ' + cThemeCFGFilename, true);
   600 TryDo(IOResult = 0, 'Bad data or cannot access file ' + cThemeCFGFilename, true);
   591 AddProgress;
   601 AddProgress;