hedgewars/uLandObjects.pas
changeset 5441 39962b855540
parent 5240 9135c1905415
child 5654 1cb68f420aa6
equal deleted inserted replaced
5439:25d3784dc0f6 5441:39962b855540
   370 
   370 
   371 procedure ReadThemeInfo(var ThemeObjects: TThemeObjects; var SprayObjects: TSprayObjects);
   371 procedure ReadThemeInfo(var ThemeObjects: TThemeObjects; var SprayObjects: TSprayObjects);
   372 var s, key: shortstring;
   372 var s, key: shortstring;
   373     f: textfile;
   373     f: textfile;
   374     i: LongInt;
   374     i: LongInt;
   375     ii: Longword;
   375     ii, t: Longword;
   376     c1, c2: TSDL_Color;
   376     c1, c2: TSDL_Color;
   377 
   377 
   378     procedure CheckRect(Width, Height, x, y, w, h: LongWord);
   378     procedure CheckRect(Width, Height, x, y, w, h: LongWord);
   379     begin
   379     begin
   380     if (x + w > Width) then OutError('Object''s rectangle exceeds image: x + w (' + inttostr(x) + ' + ' + inttostr(w) + ') > Width (' + inttostr(Width) + ')', true);
   380     if (x + w > Width) then OutError('Object''s rectangle exceeds image: x + w (' + inttostr(x) + ' + ' + inttostr(w) + ') > Width (' + inttostr(Width) + ')', true);
   413         Delete(s, 1, i);
   413         Delete(s, 1, i);
   414         i:= Pos(',', s);
   414         i:= Pos(',', s);
   415         c1.g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   415         c1.g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   416         Delete(s, 1, i);
   416         Delete(s, 1, i);
   417         c1.b:= StrToInt(Trim(s));
   417         c1.b:= StrToInt(Trim(s));
       
   418         if cGrayScale then
       
   419             begin
       
   420             t:= round(c1.r * RGB_LUMINANCE_RED + c1.g * RGB_LUMINANCE_GREEN + c1.b * RGB_LUMINANCE_BLUE);
       
   421             if t > 255 then t:= 255;
       
   422             c1.r:= t;
       
   423             c1.g:= t;
       
   424             c1.b:= t
       
   425             end;
   418         glClearColor(c1.r / 255, c1.g / 255, c1.b / 255, 0.99);
   426         glClearColor(c1.r / 255, c1.g / 255, c1.b / 255, 0.99);
   419         SDSkyColor.r:= byte(c1.r * SDTint div 255);
   427         SDSkyColor.r:= byte(c1.r * SDTint div 255);
   420         SDSkyColor.g:= byte(c1.g * SDTint div 255);
   428         SDSkyColor.g:= byte(c1.g * SDTint div 255);
   421         SDSkyColor.b:= byte(c1.b * SDTint div 255);
   429         SDSkyColor.b:= byte(c1.b * SDTint div 255);
   422         end
   430         end
   439         i:= Pos(',', s);
   447         i:= Pos(',', s);
   440         WaterColorArray[0].g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   448         WaterColorArray[0].g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   441         Delete(s, 1, i);
   449         Delete(s, 1, i);
   442         WaterColorArray[0].b:= StrToInt(Trim(s));
   450         WaterColorArray[0].b:= StrToInt(Trim(s));
   443         WaterColorArray[0].a := 255;
   451         WaterColorArray[0].a := 255;
       
   452         if cGrayScale then
       
   453             begin
       
   454             t:= round(WaterColorArray[0].r * RGB_LUMINANCE_RED + WaterColorArray[0].g * RGB_LUMINANCE_GREEN + WaterColorArray[0].b * RGB_LUMINANCE_BLUE);
       
   455             if t > 255 then t:= 255;
       
   456             WaterColorArray[0].r:= t;
       
   457             WaterColorArray[0].g:= t;
       
   458             WaterColorArray[0].b:= t
       
   459             end;
   444         WaterColorArray[1]:= WaterColorArray[0];
   460         WaterColorArray[1]:= WaterColorArray[0];
   445         end
   461         end
   446     else if key = 'water-bottom' then
   462     else if key = 'water-bottom' then
   447         begin
   463         begin
   448         i:= Pos(',', s);
   464         i:= Pos(',', s);
   451         i:= Pos(',', s);
   467         i:= Pos(',', s);
   452         WaterColorArray[2].g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   468         WaterColorArray[2].g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   453         Delete(s, 1, i);
   469         Delete(s, 1, i);
   454         WaterColorArray[2].b:= StrToInt(Trim(s));
   470         WaterColorArray[2].b:= StrToInt(Trim(s));
   455         WaterColorArray[2].a := 255;
   471         WaterColorArray[2].a := 255;
       
   472         if cGrayScale then
       
   473             begin
       
   474             t:= round(WaterColorArray[2].r * RGB_LUMINANCE_RED + WaterColorArray[2].g * RGB_LUMINANCE_GREEN + WaterColorArray[2].b * RGB_LUMINANCE_BLUE);
       
   475             if t > 255 then t:= 255;
       
   476             WaterColorArray[2].r:= t;
       
   477             WaterColorArray[2].g:= t;
       
   478             WaterColorArray[2].b:= t
       
   479             end;
   456         WaterColorArray[3]:= WaterColorArray[2];
   480         WaterColorArray[3]:= WaterColorArray[2];
   457         end
   481         end
   458     else if key = 'water-opacity' then
   482     else if key = 'water-opacity' then
   459         begin
   483         begin
   460         cWaterOpacity:= StrToInt(Trim(s));
   484         cWaterOpacity:= StrToInt(Trim(s));
   564         i:= Pos(',', s);
   588         i:= Pos(',', s);
   565         SDWaterColorArray[0].g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   589         SDWaterColorArray[0].g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   566         Delete(s, 1, i);
   590         Delete(s, 1, i);
   567         SDWaterColorArray[0].b:= StrToInt(Trim(s));
   591         SDWaterColorArray[0].b:= StrToInt(Trim(s));
   568         SDWaterColorArray[0].a := 255;
   592         SDWaterColorArray[0].a := 255;
       
   593         if cGrayScale then
       
   594             begin
       
   595             t:= round(SDWaterColorArray[0].r * RGB_LUMINANCE_RED + SDWaterColorArray[0].g * RGB_LUMINANCE_GREEN + SDWaterColorArray[0].b * RGB_LUMINANCE_BLUE);
       
   596             if t > 255 then t:= 255;
       
   597             SDWaterColorArray[0].r:= t;
       
   598             SDWaterColorArray[0].g:= t;
       
   599             SDWaterColorArray[0].b:= t
       
   600             end;
   569         SDWaterColorArray[1]:= SDWaterColorArray[0];
   601         SDWaterColorArray[1]:= SDWaterColorArray[0];
   570         end
   602         end
   571     else if key = 'sd-water-bottom' then
   603     else if key = 'sd-water-bottom' then
   572         begin
   604         begin
   573         i:= Pos(',', s);
   605         i:= Pos(',', s);
   576         i:= Pos(',', s);
   608         i:= Pos(',', s);
   577         SDWaterColorArray[2].g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   609         SDWaterColorArray[2].g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   578         Delete(s, 1, i);
   610         Delete(s, 1, i);
   579         SDWaterColorArray[2].b:= StrToInt(Trim(s));
   611         SDWaterColorArray[2].b:= StrToInt(Trim(s));
   580         SDWaterColorArray[2].a := 255;
   612         SDWaterColorArray[2].a := 255;
       
   613         if cGrayScale then
       
   614             begin
       
   615             t:= round(SDWaterColorArray[2].r * RGB_LUMINANCE_RED + SDWaterColorArray[2].g * RGB_LUMINANCE_GREEN + SDWaterColorArray[2].b * RGB_LUMINANCE_BLUE);
       
   616             if t > 255 then t:= 255;
       
   617             SDWaterColorArray[2].r:= t;
       
   618             SDWaterColorArray[2].g:= t;
       
   619             SDWaterColorArray[2].b:= t
       
   620             end;
   581         SDWaterColorArray[3]:= SDWaterColorArray[2];
   621         SDWaterColorArray[3]:= SDWaterColorArray[2];
   582         end
   622         end
   583     else if key = 'sd-water-opacity' then cSDWaterOpacity:= StrToInt(Trim(s))
   623     else if key = 'sd-water-opacity' then cSDWaterOpacity:= StrToInt(Trim(s))
   584     else if key = 'sd-clouds' then cSDCloudsNumber:= Word(StrToInt(Trim(s))) * cScreenSpace div LAND_WIDTH
   624     else if key = 'sd-clouds' then cSDCloudsNumber:= Word(StrToInt(Trim(s))) * cScreenSpace div LAND_WIDTH
   585     else if key = 'sd-flakes' then
   625     else if key = 'sd-flakes' then
   610             Delete(s, 1, i);
   650             Delete(s, 1, i);
   611             i:= Pos(',', s);
   651             i:= Pos(',', s);
   612             c1.g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   652             c1.g:= StrToInt(Trim(Copy(s, 1, Pred(i))));
   613             Delete(s, 1, i);
   653             Delete(s, 1, i);
   614             c1.b:= StrToInt(Trim(s));
   654             c1.b:= StrToInt(Trim(s));
       
   655             if cGrayScale then
       
   656                 begin
       
   657                 t:= round(c1.r * RGB_LUMINANCE_RED + c1.g * RGB_LUMINANCE_GREEN + c1.b * RGB_LUMINANCE_BLUE);
       
   658                 if t > 255 then t:= 255;
       
   659                 c1.r:= t;
       
   660                 c1.g:= t;
       
   661                 c1.b:= t
       
   662                 end;
   615             glClearColor(c1.r / 255, c1.g / 255, c1.b / 255, 0.99);
   663             glClearColor(c1.r / 255, c1.g / 255, c1.b / 255, 0.99);
   616             SDSkyColor.r:= byte(c1.r * SDTint div 255);
   664             SDSkyColor.r:= byte(c1.r * SDTint div 255);
   617             SDSkyColor.g:= byte(c1.g * SDTint div 255);
   665             SDSkyColor.g:= byte(c1.g * SDTint div 255);
   618             SDSkyColor.b:= byte(c1.b * SDTint div 255);
   666             SDSkyColor.b:= byte(c1.b * SDTint div 255);
   619             end
   667             end