hedgewars/uStore.pas
changeset 6394 f0a9042e7387
parent 6382 0e76c5cd4250
child 6415 af2047bb4f70
equal deleted inserted replaced
6393:701eb3f3556a 6394:f0a9042e7387
    40 procedure ShowWeaponTooltip(x, y: LongInt);
    40 procedure ShowWeaponTooltip(x, y: LongInt);
    41 procedure FreeWeaponTooltip;
    41 procedure FreeWeaponTooltip;
    42 procedure MakeCrossHairs;
    42 procedure MakeCrossHairs;
    43 
    43 
    44 implementation
    44 implementation
    45 uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands, uDebug;
    45 uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands, uDebug, uWorld;
    46 
    46 
    47 //type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple);
    47 //type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple);
    48 
    48 
    49 var MaxTextureSize: LongInt;
    49 var MaxTextureSize: LongInt;
    50 //    cGPUVendor: TGPUVendor;
    50 //    cGPUVendor: TGPUVendor;
   275             end;
   275             end;
   276 
   276 
   277 WriteNames(fnt16);
   277 WriteNames(fnt16);
   278 MakeCrossHairs;
   278 MakeCrossHairs;
   279 LoadGraves;
   279 LoadGraves;
   280 
   280 if not reload then
   281 AddProgress;
   281     AddProgress;
       
   282 
   282 for ii:= Low(TSprite) to High(TSprite) do
   283 for ii:= Low(TSprite) to High(TSprite) do
   283     with SpritesData[ii] do
   284     with SpritesData[ii] do
   284         // FIXME - add a sprite attribute to match on rq flags?
   285         // FIXME - add a sprite attribute to match on rq flags?
   285         if (((cReducedQuality and (rqNoBackground or rqLowRes)) = 0) or   // why rqLowRes?
   286         if (((cReducedQuality and (rqNoBackground or rqLowRes)) = 0) or   // why rqLowRes?
   286                 (not (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR]))) and
   287                 (not (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR]))) and
   356                 end
   357                 end
   357             else
   358             else
   358                 Surface:= nil
   359                 Surface:= nil
   359         end;
   360         end;
   360 
   361 
   361 AddProgress;
   362 if not reload then
       
   363     AddProgress;
   362 
   364 
   363 tmpsurf:= LoadImage(UserPathz[ptGraphics] + '/' + cHHFileName, ifAlpha or ifTransparent);
   365 tmpsurf:= LoadImage(UserPathz[ptGraphics] + '/' + cHHFileName, ifAlpha or ifTransparent);
   364 if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, ifAlpha or ifCritical or ifTransparent);
   366 if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, ifAlpha or ifCritical or ifTransparent);
   365 HHTexture:= Surface2Tex(tmpsurf, false);
   367 HHTexture:= Surface2Tex(tmpsurf, false);
   366 SDL_FreeSurface(tmpsurf);
   368 SDL_FreeSurface(tmpsurf);
   369 
   371 
   370 PauseTexture:= RenderStringTex(trmsg[sidPaused], cYellowColor, fntBig);
   372 PauseTexture:= RenderStringTex(trmsg[sidPaused], cYellowColor, fntBig);
   371 ConfirmTexture:= RenderStringTex(trmsg[sidConfirm], cYellowColor, fntBig);
   373 ConfirmTexture:= RenderStringTex(trmsg[sidConfirm], cYellowColor, fntBig);
   372 SyncTexture:= RenderStringTex(trmsg[sidSync], cYellowColor, fntBig);
   374 SyncTexture:= RenderStringTex(trmsg[sidSync], cYellowColor, fntBig);
   373 
   375 
   374 AddProgress;
   376 if not reload then
       
   377     AddProgress;
   375 
   378 
   376 // name of weapons in ammo menu
   379 // name of weapons in ammo menu
   377 for ai:= Low(TAmmoType) to High(TAmmoType) do
   380 for ai:= Low(TAmmoType) to High(TAmmoType) do
   378     with Ammoz[ai] do
   381     with Ammoz[ai] do
   379         begin
   382         begin
   394     FreeTexture(CountTexz[i]);
   397     FreeTexture(CountTexz[i]);
   395     CountTexz[i]:= Surface2Tex(tmpsurf, false);
   398     CountTexz[i]:= Surface2Tex(tmpsurf, false);
   396     SDL_FreeSurface(tmpsurf)
   399     SDL_FreeSurface(tmpsurf)
   397 end;
   400 end;
   398 
   401 
   399 AddProgress;
   402 if not reload then
       
   403     AddProgress;
   400 IMG_Quit();
   404 IMG_Quit();
   401 end;
   405 end;
   402 
   406 
   403 procedure StoreRelease(reload: boolean);
   407 procedure StoreRelease(reload: boolean);
   404 var ii: TSprite;
   408 var ii: TSprite;
   414             SDL_FreeSurface(SpritesData[ii].Surface);
   418             SDL_FreeSurface(SpritesData[ii].Surface);
   415             SpritesData[ii].Surface:= nil
   419             SpritesData[ii].Surface:= nil
   416             end
   420             end
   417         end;
   421         end;
   418     SDL_FreeSurface(MissionIcons);
   422     SDL_FreeSurface(MissionIcons);
       
   423 
       
   424     // free the textures declared in uVariables
       
   425     FreeTexture(WeaponTooltipTex);
       
   426     WeaponTooltipTex:= nil;
       
   427     FreeTexture(PauseTexture);
       
   428     PauseTexture:= nil;
       
   429     FreeTexture(SyncTexture);
       
   430     SyncTexture:= nil;
       
   431     FreeTexture(ConfirmTexture);
       
   432     ConfirmTexture:= nil;
   419     FreeTexture(ropeIconTex);
   433     FreeTexture(ropeIconTex);
   420     ropeIconTex:= nil;
   434     ropeIconTex:= nil;
   421     FreeTexture(HHTexture);
   435     FreeTexture(HHTexture);
   422     HHTexture:= nil;
   436     HHTexture:= nil;
   423     FreeTexture(PauseTexture);
   437 
   424     PauseTexture:= nil;
       
   425     FreeTexture(ConfirmTexture);
       
   426     ConfirmTexture:= nil;
       
   427     FreeTexture(SyncTexture);
       
   428     SyncTexture:= nil;
       
   429     // free all ammo name textures
   438     // free all ammo name textures
   430     for ai:= Low(TAmmoType) to High(TAmmoType) do
   439     for ai:= Low(TAmmoType) to High(TAmmoType) do
   431         begin
   440         begin
   432         FreeTexture(Ammoz[ai].NameTex);
   441         FreeTexture(Ammoz[ai].NameTex);
   433         Ammoz[ai].NameTex:= nil
   442         Ammoz[ai].NameTex:= nil
   758     inc(Step);
   767     inc(Step);
   759 end;
   768 end;
   760 
   769 
   761 procedure FinishProgress;
   770 procedure FinishProgress;
   762 begin
   771 begin
       
   772     uMobile.GameLoaded();
   763     WriteLnToConsole('Freeing progress surface... ');
   773     WriteLnToConsole('Freeing progress surface... ');
   764     FreeTexture(ProgrTex);
   774     FreeTexture(ProgrTex);
   765     uMobile.GameLoaded();
   775     ProgrTex:= nil;
   766     Step:= 0
   776     Step:= 0
   767 end;
   777 end;
   768 
   778 
   769 function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
   779 function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
   770 var tmpsurf: PSDL_SURFACE;
   780 var tmpsurf: PSDL_SURFACE;
   971     else
   981     else
   972         begin
   982         begin
   973         SetScale(cDefaultZoomLevel);
   983         SetScale(cDefaultZoomLevel);
   974 {$IF DEFINED(DARWIN) OR DEFINED(WIN32)}
   984 {$IF DEFINED(DARWIN) OR DEFINED(WIN32)}
   975         reinit:= true;
   985         reinit:= true;
       
   986         StoreRelease(true);
       
   987         ResetLand;
       
   988         ResetWorldTex;
       
   989         //uTextures.freeModule; //DEBUG ONLY
   976 {$ENDIF}
   990 {$ENDIF}
   977         AddFileLog('Freeing old primary surface...');
   991         AddFileLog('Freeing old primary surface...');
   978         SDL_FreeSurface(SDLPrimSurface);
   992         SDL_FreeSurface(SDLPrimSurface);
   979         SDLPrimSurface:= nil;
   993         SDLPrimSurface:= nil;
   980         end;
   994         end;
  1025 {$ENDIF}
  1039 {$ENDIF}
  1026 
  1040 
  1027     SetupOpenGL();
  1041     SetupOpenGL();
  1028     if reinit then
  1042     if reinit then
  1029         begin
  1043         begin
       
  1044         // clean the window from any previous content
       
  1045         glClear(GL_COLOR_BUFFER_BIT);
  1030         if SuddenDeathDmg then
  1046         if SuddenDeathDmg then
  1031              glClearColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255, 0.99)
  1047              glClearColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255, 0.99)
  1032         else if ((cReducedQuality and rqNoBackground) = 0) then 
  1048         else if ((cReducedQuality and rqNoBackground) = 0) then 
  1033              glClearColor(SkyColor.r / 255, SkyColor.g / 255, SkyColor.b / 255, 0.99)
  1049              glClearColor(SkyColor.r / 255, SkyColor.g / 255, SkyColor.b / 255, 0.99)
  1034         else glClearColor(RQSkyColor.r / 255, RQSkyColor.g / 255, RQSkyColor.b / 255, 0.99);
  1050         else glClearColor(RQSkyColor.r / 255, RQSkyColor.g / 255, RQSkyColor.b / 255, 0.99);
  1035 
  1051 
  1036         StoreRelease(true);
  1052         // reload everything we had before
  1037         ReloadCaptions;
  1053         ReloadCaptions(false);
  1038         ReloadLines;
  1054         ReloadLines;
  1039         StoreLoad(true);
  1055         StoreLoad(true);
  1040 
  1056         // redraw all land
  1041         ResetLand;
       
  1042         UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT);
  1057         UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT);
  1043         end;
  1058         end;
  1044 end;
  1059 end;
  1045 
  1060 
  1046 procedure initModule;
  1061 procedure initModule;