hedgewars/uStore.pas
branchwebgl
changeset 8096 453917e94e55
parent 8032 f8fcece14302
parent 8057 93e16240f178
child 8330 aaefa587e277
equal deleted inserted replaced
8053:2e836bebb518 8096:453917e94e55
    68 procedure SetColorPointer(p: Pointer;n: Integer);
    68 procedure SetColorPointer(p: Pointer;n: Integer);
    69 procedure BeginWater;
    69 procedure BeginWater;
    70 procedure EndWater;
    70 procedure EndWater;
    71 
    71 
    72 implementation
    72 implementation
    73 uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands,
    73 uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands
    74      uDebug{$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF}
    74     , uPhysFSLayer
    75      {$IF NOT DEFINED(SDL13) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF};
    75     , uDebug
       
    76     {$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF}
       
    77     {$IF NOT DEFINED(SDL13) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF};
    76 
    78 
    77 //type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple);
    79 //type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple);
    78 
    80 
    79 var MaxTextureSize: LongInt;
    81 var MaxTextureSize: LongInt;
    80 {$IFDEF SDL13}
    82 {$IFDEF SDL13}
   169     r, rr: TSDL_Rect;
   171     r, rr: TSDL_Rect;
   170     drY: LongInt;
   172     drY: LongInt;
   171     texsurf, flagsurf, iconsurf: PSDL_Surface;
   173     texsurf, flagsurf, iconsurf: PSDL_Surface;
   172     foundBot: boolean;
   174     foundBot: boolean;
   173 begin
   175 begin
       
   176     if cOnlyStats then exit;
   174 r.x:= 0;
   177 r.x:= 0;
   175 r.y:= 0;
   178 r.y:= 0;
   176 drY:= - 4;
   179 drY:= - 4;
   177 for t:= 0 to Pred(TeamsCount) do
   180 for t:= 0 to Pred(TeamsCount) do
   178     with TeamsArray[t]^ do
   181     with TeamsArray[t]^ do
   331 WriteLnToConsole('Entering StoreLoad');
   334 WriteLnToConsole('Entering StoreLoad');
   332 if not reload then
   335 if not reload then
   333     for fi:= Low(THWFont) to High(THWFont) do
   336     for fi:= Low(THWFont) to High(THWFont) do
   334         with Fontz[fi] do
   337         with Fontz[fi] do
   335             begin
   338             begin
   336             s:= UserPathz[ptFonts] + '/' + Name;
   339             s:= cPathz[ptFonts] + '/' + Name;
   337             if not FileExists(s) then
       
   338                 s:= Pathz[ptFonts] + '/' + Name;
       
   339             WriteToConsole(msgLoading + s + ' (' + inttostr(Height) + 'pt)... ');
   340             WriteToConsole(msgLoading + s + ' (' + inttostr(Height) + 'pt)... ');
   340             Handle:= TTF_OpenFont(Str2PChar(s), Height);
   341             Handle:= TTF_OpenFontRW(rwopsOpenRead(s), true, Height);
   341             SDLTry(Handle <> nil, true);
   342             SDLTry(Handle <> nil, true);
   342             TTF_SetFontStyle(Handle, style);
   343             TTF_SetFontStyle(Handle, style);
   343             WriteLnToConsole(msgOK)
   344             WriteLnToConsole(msgOK)
   344             end;
   345             end;
   345 
   346 
   589 begin
   590 begin
   590     LoadImage:= nil;
   591     LoadImage:= nil;
   591     WriteToConsole(msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + '] ');
   592     WriteToConsole(msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + '] ');
   592 
   593 
   593     s:= filename + '.png';
   594     s:= filename + '.png';
   594     tmpsurf:= IMG_Load(Str2PChar(s));
   595     tmpsurf:= IMG_Load_RW(rwopsOpenRead(s), true);
   595 
   596 
   596     if tmpsurf = nil then
   597     if tmpsurf = nil then
   597     begin
   598     begin
   598         OutError(msgFailed, (imageFlags and ifCritical) <> 0);
   599         OutError(msgFailed, (imageFlags and ifCritical) <> 0);
   599         exit;
   600         exit;
   600     end;
   601     end;
   601 
   602 
   602     if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
   603     if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
   603     begin
   604     begin
   604         SDL_FreeSurface(tmpsurf);
   605         SDL_FreeSurface(tmpsurf);
   605         OutError(msgFailedSize, (imageFlags and ifCritical) <> 0);
   606         OutError(msgFailedSize, ((not cOnlyStats) and ((imageFlags and ifCritical) <> 0)));
   606         // dummy surface to replace non-critical textures that failed to load due to their size
   607         // dummy surface to replace non-critical textures that failed to load due to their size
   607         LoadImage:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask);
   608         LoadImage:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask);
   608         exit;
   609         exit;
   609     end;
   610     end;
   610 
   611 
   621 
   622 
   622 function LoadDataImage(const path: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
   623 function LoadDataImage(const path: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
   623 var tmpsurf: PSDL_Surface;
   624 var tmpsurf: PSDL_Surface;
   624 begin
   625 begin
   625     // check for file in user dir (never critical)
   626     // check for file in user dir (never critical)
   626     tmpsurf:= LoadImage(UserPathz[path] + '/' + filename, imageFlags and (not ifCritical));
   627     tmpsurf:= LoadImage(cPathz[path] + '/' + filename, imageFlags);
   627 
       
   628     // if unsuccessful check data dir
       
   629     if (tmpsurf = nil) then
       
   630         tmpsurf:= LoadImage(Pathz[path] + '/' + filename, imageFlags);
       
   631 
       
   632     LoadDataImage:= tmpsurf;
       
   633 end;
   628 end;
   634 
   629 
   635 
   630 
   636 function LoadDataImageAltPath(const path, altPath: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
   631 function LoadDataImageAltPath(const path, altPath: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
   637 var tmpsurf: PSDL_Surface;
   632 var tmpsurf: PSDL_Surface;
  1195 ////////////////////////////////////////////////////////////////////////////////
  1190 ////////////////////////////////////////////////////////////////////////////////
  1196 procedure AddProgress;
  1191 procedure AddProgress;
  1197 var r: TSDL_Rect;
  1192 var r: TSDL_Rect;
  1198     texsurf: PSDL_Surface;
  1193     texsurf: PSDL_Surface;
  1199 begin
  1194 begin
       
  1195     if cOnlyStats then exit;
  1200     if Step = 0 then
  1196     if Step = 0 then
  1201     begin
  1197     begin
  1202         WriteToConsole(msgLoading + 'progress sprite: ');
  1198         WriteToConsole(msgLoading + 'progress sprite: ');
  1203         texsurf:= LoadDataImage(ptGraphics, 'Progress', ifCritical or ifTransparent);
  1199         texsurf:= LoadDataImage(ptGraphics, 'Progress', ifCritical or ifTransparent);
  1204 
  1200 
  1450 var flags: Longword = 0;
  1446 var flags: Longword = 0;
  1451     reinit: boolean = false;
  1447     reinit: boolean = false;
  1452     {$IFNDEF DARWIN}ico: PSDL_Surface;{$ENDIF}
  1448     {$IFNDEF DARWIN}ico: PSDL_Surface;{$ENDIF}
  1453     {$IFDEF SDL13}x, y: LongInt;{$ENDIF}
  1449     {$IFDEF SDL13}x, y: LongInt;{$ENDIF}
  1454 begin
  1450 begin
       
  1451     if cOnlyStats then
       
  1452         begin
       
  1453         MaxTextureSize:= 1024;
       
  1454         exit
       
  1455         end;
  1455     if Length(s) = 0 then
  1456     if Length(s) = 0 then
  1456         cFullScreen:= (not cFullScreen)
  1457          cFullScreen:= (not cFullScreen)
  1457     else
  1458     else cFullScreen:= s = '1';
  1458         cFullScreen:= s = '1';
       
  1459 
  1459 
  1460     AddFileLog('Preparing to change video parameters...');
  1460     AddFileLog('Preparing to change video parameters...');
  1461 {$IFDEF SDL13}
  1461 {$IFDEF SDL13}
  1462     if SDLwindow = nil then
  1462     if SDLwindow = nil then
  1463 {$ELSE}
  1463 {$ELSE}