hedgewars/uStore.pas
changeset 4874 f508adb769b8
parent 4850 434cd1284204
child 4889 f71e30eb1d37
equal deleted inserted replaced
4873:98dbb9b985e5 4874:f508adb769b8
    30 procedure StoreRelease;
    30 procedure StoreRelease;
    31 procedure RenderHealth(var Hedgehog: THedgehog);
    31 procedure RenderHealth(var Hedgehog: THedgehog);
    32 procedure AddProgress;
    32 procedure AddProgress;
    33 procedure FinishProgress;
    33 procedure FinishProgress;
    34 function  LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
    34 function  LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
       
    35 procedure LoadHedgehogHat(HHGear: PGear; newHat: shortstring);
    35 procedure SetupOpenGL;
    36 procedure SetupOpenGL;
    36 procedure SetScale(f: GLfloat);
    37 procedure SetScale(f: GLfloat);
    37 function  RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
    38 function  RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture;
    38 procedure RenderWeaponTooltip(atype: TAmmoType);
    39 procedure RenderWeaponTooltip(atype: TAmmoType);
    39 procedure ShowWeaponTooltip(x, y: LongInt);
    40 procedure ShowWeaponTooltip(x, y: LongInt);
   139         PLongwordArray(texsurf^.pixels)^[32 * 16 +  2]:= cNearBlackColor;
   140         PLongwordArray(texsurf^.pixels)^[32 * 16 +  2]:= cNearBlackColor;
   140         PLongwordArray(texsurf^.pixels)^[32 * 16 + 23]:= cNearBlackColor;
   141         PLongwordArray(texsurf^.pixels)^[32 * 16 + 23]:= cNearBlackColor;
   141 
   142 
   142         FlagTex:= Surface2Tex(texsurf, false);
   143         FlagTex:= Surface2Tex(texsurf, false);
   143         SDL_FreeSurface(texsurf);
   144         SDL_FreeSurface(texsurf);
       
   145         texsurf:= nil;
   144 
   146 
   145         AIKillsTex := RenderStringTex(inttostr(stats.AIKills), Clan^.Color, fnt16);
   147         AIKillsTex := RenderStringTex(inttostr(stats.AIKills), Clan^.Color, fnt16);
   146 
   148 
   147         dec(drY, r.h + 2);
   149         dec(drY, r.h + 2);
   148         DrawHealthY:= drY;
   150         DrawHealthY:= drY;
   152                     begin
   154                     begin
   153                     NameTagTex:= RenderStringTex(Name, Clan^.Color, CheckCJKFont(Name,fnt16));
   155                     NameTagTex:= RenderStringTex(Name, Clan^.Color, CheckCJKFont(Name,fnt16));
   154                     if Hat <> 'NoHat' then
   156                     if Hat <> 'NoHat' then
   155                         begin
   157                         begin
   156                         if (Length(Hat) > 39) and (Copy(Hat,1,8) = 'Reserved') and (Copy(Hat,9,32) = PlayerHash) then
   158                         if (Length(Hat) > 39) and (Copy(Hat,1,8) = 'Reserved') and (Copy(Hat,9,32) = PlayerHash) then
   157                             texsurf:= LoadImage(Pathz[ptHats] + '/Reserved/' + Copy(Hat,9,Length(s)-8), ifNone)
   159                             LoadHedgehogHat(Gear, 'Reserved/' + Copy(Hat,9,Length(s)-8))
   158                         else
   160                         else
   159                             texsurf:= LoadImage(Pathz[ptHats] + '/' + Hat, ifNone);
   161                             LoadHedgehogHat(Gear, Hat);
   160                         if texsurf <> nil then
       
   161                             begin
       
   162                             HatTex:= Surface2Tex(texsurf, true);
       
   163                             SDL_FreeSurface(texsurf)
       
   164                             end;
       
   165                         texsurf:= nil;
       
   166                         end
   162                         end
   167                     end;
   163                     end;
   168         end;
   164         end;
   169     MissionIcons:= LoadImage(Pathz[ptGraphics] + '/missions', ifCritical);
   165     MissionIcons:= LoadImage(Pathz[ptGraphics] + '/missions', ifCritical);
   170     iconsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 28, 28, 32, RMask, GMask, BMask, AMask);
   166     iconsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 28, 28, 32, RMask, GMask, BMask, AMask);
   433     WriteLnToConsole(msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')');
   429     WriteLnToConsole(msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')');
   434 
   430 
   435     LoadImage:= tmpsurf //Result
   431     LoadImage:= tmpsurf //Result
   436 end;
   432 end;
   437 
   433 
       
   434 procedure LoadHedgehogHat(HHGear: PGear; newHat: shortstring);
       
   435 var texsurf: PSDL_Surface;
       
   436 begin
       
   437     texsurf:= LoadImage(Pathz[ptHats] + '/' + newHat, ifNone);
       
   438 
       
   439     // only do something if the hat could be loaded
       
   440     if texsurf <> nil then
       
   441         begin
       
   442         // free the mem of any previously assigned texture
       
   443         FreeTexture(HHGear^.Hedgehog^.HatTex);
       
   444 
       
   445         // assign new hat to hedgehog
       
   446         HHGear^.Hedgehog^.HatTex:= Surface2Tex(texsurf, true);
       
   447 
       
   448         // cleanup: free temporary surface mem
       
   449         SDL_FreeSurface(texsurf)
       
   450         end;
       
   451 end;
       
   452 
   438 function glLoadExtension(extension : shortstring) : boolean;
   453 function glLoadExtension(extension : shortstring) : boolean;
   439 begin
   454 begin
   440 {$IF GLunit = gles11}
   455 {$IF GLunit = gles11}
   441     // FreePascal doesn't come with OpenGL ES 1.1 Extension headers
   456     // FreePascal doesn't come with OpenGL ES 1.1 Extension headers
   442     extension:= extension; // avoid hint
   457     extension:= extension; // avoid hint