hedgewars/uStore.pas
changeset 3765 ebfe7c9b3085
parent 3764 eb91c02f2d84
child 3773 f552c7b439fa
equal deleted inserted replaced
3764:eb91c02f2d84 3765:ebfe7c9b3085
   391     with SpritesData[ii] do
   391     with SpritesData[ii] do
   392         // FIXME - add a sprite attribute
   392         // FIXME - add a sprite attribute
   393         if ((cReducedQuality and rqNoBackground) = 0) or (not (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR, sprFlake, sprSplash, sprDroplet])) then // FIXME: hack
   393         if ((cReducedQuality and rqNoBackground) = 0) or (not (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR, sprFlake, sprSplash, sprDroplet])) then // FIXME: hack
   394         begin
   394         begin
   395             if AltPath = ptNone then
   395             if AltPath = ptNone then
   396                 if ii in [sprHorizontL, sprHorizontR, sprSkyL, sprSkyR] then // FIXME: hack
   396                 if ii in [sprHorizontL, sprHorizontR, sprSkyL, sprSkyR, sprFlake] then // FIXME: hack
   397                     tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent)
   397                     tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent)
   398                 else
   398                 else
   399                     tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical)
   399                     tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical)
   400             else begin
   400             else begin
   401                 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent);
   401                 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent);
   404                 end;
   404                 end;
   405 
   405 
   406             if tmpsurf <> nil then
   406             if tmpsurf <> nil then
   407             begin
   407             begin
   408                 if getImageDimensions then
   408                 if getImageDimensions then
   409                     begin
   409                 begin
   410                     imageWidth:= tmpsurf^.w;
   410                     imageWidth:= tmpsurf^.w;
   411                     imageHeight:= tmpsurf^.h
   411                     imageHeight:= tmpsurf^.h
   412                     end;
   412                 end;
   413                 if getDimensions then
   413                 if getDimensions then
   414                     begin
   414                 begin
   415                     Width:= tmpsurf^.w;
   415                     Width:= tmpsurf^.w;
   416                     Height:= tmpsurf^.h
   416                     Height:= tmpsurf^.h
   417                     end;
   417                 end;
   418                 if (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR]) then
   418                 if (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR]) then
   419                     begin
   419                 begin
   420                     Texture:= Surface2Tex(tmpsurf, true);
   420                     Texture:= Surface2Tex(tmpsurf, true);
   421                     Texture^.Scale:= 2
   421                     Texture^.Scale:= 2
   422                     end
   422                 end
   423                 else
   423                 else
   424                     begin
   424                 begin
   425                     Texture:= Surface2Tex(tmpsurf, false);
   425                     Texture:= Surface2Tex(tmpsurf, false);
   426                     if (ii = sprWater) and ((cReducedQuality and (rq2DWater or rqClampLess)) = 0) then // HACK: We should include some sprite attribute to define the texture wrap directions
   426                     if (ii = sprWater) and ((cReducedQuality and (rq2DWater or rqClampLess)) = 0) then // HACK: We should include some sprite attribute to define the texture wrap directions
   427                     begin
       
   428                         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
   427                         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
   429                     end;
       
   430                 end;
   428                 end;
   431                 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, priority);
   429                 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, priority);
   432                 if saveSurf then Surface:= tmpsurf else SDL_FreeSurface(tmpsurf)
   430                 if saveSurf then
       
   431                     Surface:= tmpsurf else SDL_FreeSurface(tmpsurf)
   433                 end
   432                 end
   434             else
   433             else
   435                 Surface:= nil
   434                 Surface:= nil
   436         end;
   435         end;
   437 
   436 
   450 AddProgress;
   449 AddProgress;
   451 
   450 
   452 // name of weapons in ammo menu
   451 // name of weapons in ammo menu
   453 for ai:= Low(TAmmoType) to High(TAmmoType) do
   452 for ai:= Low(TAmmoType) to High(TAmmoType) do
   454     with Ammoz[ai] do
   453     with Ammoz[ai] do
   455         begin
   454     begin
   456         TryDo(trAmmo[NameId] <> '','No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true);
   455         TryDo(trAmmo[NameId] <> '','No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true);
   457         tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, Str2PChar(trAmmo[NameId]), cWhiteColorChannels);
   456         tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, Str2PChar(trAmmo[NameId]), cWhiteColorChannels);
   458         TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true);
   457         TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true);
   459         tmpsurf:= doSurfaceConversion(tmpsurf);
   458         tmpsurf:= doSurfaceConversion(tmpsurf);
   460         NameTex:= Surface2Tex(tmpsurf, false);
   459         NameTex:= Surface2Tex(tmpsurf, false);
   461         SDL_FreeSurface(tmpsurf)
   460         SDL_FreeSurface(tmpsurf)
   462         end;
   461     end;
   463 
   462 
   464 // number of weapons in ammo menu
   463 // number of weapons in ammo menu
   465 for i:= Low(CountTexz) to High(CountTexz) do
   464 for i:= Low(CountTexz) to High(CountTexz) do
   466     begin
   465 begin
   467     tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels);
   466     tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels);
   468     tmpsurf:= doSurfaceConversion(tmpsurf);
   467     tmpsurf:= doSurfaceConversion(tmpsurf);
   469     CountTexz[i]:= Surface2Tex(tmpsurf, false);
   468     CountTexz[i]:= Surface2Tex(tmpsurf, false);
   470     SDL_FreeSurface(tmpsurf)
   469     SDL_FreeSurface(tmpsurf)
   471     end;
   470 end;
   472 
   471 
   473 {$IFDEF DUMP}
       
   474 //not working anymore, where are LandSurface and StoreSurface defined?
       
   475 //SDL_SaveBMP_RW(LandSurface, SDL_RWFromFile('LandSurface.bmp', 'wb'), 1);
       
   476 //SDL_SaveBMP_RW(StoreSurface, SDL_RWFromFile('StoreSurface.bmp', 'wb'), 1);
       
   477 {$ENDIF}
       
   478 AddProgress;
   472 AddProgress;
   479 
   473 
   480 {$IFDEF SDL_IMAGE_NEWER}
   474 {$IFDEF SDL_IMAGE_NEWER}
   481 IMG_Quit();
   475 IMG_Quit();
   482 {$ENDIF}
   476 {$ENDIF}
   490 procedure DrawFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
   484 procedure DrawFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
   491 var rr: TSDL_Rect;
   485 var rr: TSDL_Rect;
   492     _l, _r, _t, _b: real;
   486     _l, _r, _t, _b: real;
   493     VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
   487     VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
   494 begin
   488 begin
   495 if (SourceTexture^.h = 0) or (SourceTexture^.w = 0) then exit;
   489 if (SourceTexture = nil) or (SourceTexture^.h = 0) or (SourceTexture^.w = 0) then exit;
   496 
   490 
   497 // don't draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
   491 // don't draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
   498 if (abs(X) > W) and ((abs(X + W / 2) - W / 2) > cScreenWidth / cScaleFactor) then
   492 if (abs(X) > W) and ((abs(X + W / 2) - W / 2) > cScreenWidth / cScaleFactor) then
   499     exit;
   493     exit;
   500 if (abs(Y) > H) and ((abs(Y + H / 2 - (0.5 * cScreenHeight)) - H / 2) > cScreenHeight / cScaleFactor) then
   494 if (abs(Y) > H) and ((abs(Y + H / 2 - (0.5 * cScreenHeight)) - H / 2) > cScreenHeight / cScaleFactor) then