272 begin |
272 begin |
273 if (Length(Hat) > 39) and (Copy(Hat,1,8) = 'Reserved') and (Copy(Hat,9,32) = PlayerHash) then |
273 if (Length(Hat) > 39) and (Copy(Hat,1,8) = 'Reserved') and (Copy(Hat,9,32) = PlayerHash) then |
274 texsurf:= LoadImage(Pathz[ptHats] + '/Reserved/' + Copy(Hat,9,Length(s)-8), ifNone) |
274 texsurf:= LoadImage(Pathz[ptHats] + '/Reserved/' + Copy(Hat,9,Length(s)-8), ifNone) |
275 else |
275 else |
276 texsurf:= LoadImage(Pathz[ptHats] + '/' + Hat, ifNone); |
276 texsurf:= LoadImage(Pathz[ptHats] + '/' + Hat, ifNone); |
277 if texsurf <> nil then |
277 if texsurf <> nil then |
278 begin |
278 begin |
279 HatTex:= Surface2Tex(texsurf, true); |
279 HatTex:= Surface2Tex(texsurf, true); |
280 SDL_FreeSurface(texsurf) |
280 SDL_FreeSurface(texsurf) |
281 end; |
281 end; |
282 texsurf:= nil; |
282 texsurf:= nil; |
283 end |
283 end |
284 end; |
284 end; |
285 end; |
285 end; |
286 MissionIcons:= LoadImage(Pathz[ptGraphics] + '/missions', ifCritical); |
286 MissionIcons:= LoadImage(Pathz[ptGraphics] + '/missions', ifCritical); |
287 iconsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 28, 28, 32, RMask, GMask, BMask, AMask); |
287 iconsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 28, 28, 32, RMask, GMask, BMask, AMask); |
288 if iconsurf <> nil then |
288 if iconsurf <> nil then |
289 begin |
289 begin |
290 r.x:= 0; |
290 r.x:= 0; |
291 r.y:= 0; |
291 r.y:= 0; |
292 r.w:= 28; |
292 r.w:= 28; |
293 r.h:= 28; |
293 r.h:= 28; |
294 DrawRoundRect(@r, cWhiteColor, cNearBlackColor, iconsurf, true); |
294 DrawRoundRect(@r, cWhiteColor, cNearBlackColor, iconsurf, true); |
295 ropeIconTex:= Surface2Tex(iconsurf, false); |
295 ropeIconTex:= Surface2Tex(iconsurf, false); |
296 SDL_FreeSurface(iconsurf); |
296 SDL_FreeSurface(iconsurf); |
297 iconsurf:= nil; |
297 iconsurf:= nil; |
298 end; |
298 end; |
299 end; |
299 end; |
300 |
300 |
301 procedure MakeCrossHairs; |
301 procedure MakeCrossHairs; |
302 var t: LongInt; |
302 var t: LongInt; |
323 if SDL_MustLock(texsurf) then |
323 if SDL_MustLock(texsurf) then |
324 SDLTry(SDL_LockSurface(texsurf) >= 0, true); |
324 SDLTry(SDL_LockSurface(texsurf) >= 0, true); |
325 |
325 |
326 // make black pixel be alpha-transparent |
326 // make black pixel be alpha-transparent |
327 for i:= 0 to texsurf^.w * texsurf^.h - 1 do |
327 for i:= 0 to texsurf^.w * texsurf^.h - 1 do |
328 if PLongwordArray(texsurf^.pixels)^[i] = AMask then PLongwordArray(texsurf^.pixels)^[i]:= 0; |
328 if PLongwordArray(texsurf^.pixels)^[i] = AMask then PLongwordArray(texsurf^.pixels)^[i]:= (RMask or GMask or BMask) and Color; |
329 |
329 |
330 if SDL_MustLock(texsurf) then |
330 if SDL_MustLock(texsurf) then |
331 SDL_UnlockSurface(texsurf); |
331 SDL_UnlockSurface(texsurf); |
332 |
332 |
333 CrosshairTex:= Surface2Tex(texsurf, false); |
333 CrosshairTex:= Surface2Tex(texsurf, false); |
1080 |
1080 |
1081 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
1081 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; |
1082 var tmpsurf: PSDL_Surface; |
1082 var tmpsurf: PSDL_Surface; |
1083 s: shortstring; |
1083 s: shortstring; |
1084 begin |
1084 begin |
1085 WriteToConsole(msgLoading + filename + '.png (flags: ' + inttostr(imageFlags)+') '); |
1085 WriteToConsole(msgLoading + filename + '.png [flags:'); |
1086 {$IFDEF DEBUGFILE} |
|
1087 WriteToConsole('[flag translation:'); |
|
1088 if imageFlags = ifNone then |
1086 if imageFlags = ifNone then |
1089 WriteToConsole(' None') |
1087 WriteToConsole(' None') |
1090 else |
1088 else |
1091 begin |
1089 begin |
1092 if (imageFlags and ifAlpha) <> 0 then WriteToConsole(' Alpha'); |
1090 if (imageFlags and ifAlpha) <> 0 then WriteToConsole(' Alpha'); |
1093 if (imageFlags and ifCritical) <> 0 then WriteToConsole(' Critical'); |
1091 if (imageFlags and ifCritical) <> 0 then WriteToConsole(' Critical'); |
1094 if (imageFlags and ifTransparent) <> 0 then WriteToConsole(' Transparent'); |
1092 if (imageFlags and ifTransparent) <> 0 then WriteToConsole(' Transparent'); |
1095 if (imageFlags and ifIgnoreCaps) <> 0 then WriteToConsole(' IgnoreCaps'); |
1093 if (imageFlags and ifIgnoreCaps) <> 0 then WriteToConsole(' IgnoreCaps'); |
1096 end; |
1094 end; |
1097 WriteToConsole('] '); |
1095 WriteToConsole('] '); |
1098 {$ENDIF} |
|
1099 |
1096 |
1100 s:= filename + '.png'; |
1097 s:= filename + '.png'; |
1101 tmpsurf:= IMG_Load(Str2PChar(s)); |
1098 tmpsurf:= IMG_Load(Str2PChar(s)); |
1102 |
1099 |
1103 if tmpsurf = nil then |
1100 if tmpsurf = nil then |
1109 if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then |
1106 if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then |
1110 begin |
1107 begin |
1111 SDL_FreeSurface(tmpsurf); |
1108 SDL_FreeSurface(tmpsurf); |
1112 OutError(msgFailedSize, (imageFlags and ifCritical) <> 0); |
1109 OutError(msgFailedSize, (imageFlags and ifCritical) <> 0); |
1113 // dummy surface to replace non-critical textures that failed to load due to their size |
1110 // dummy surface to replace non-critical textures that failed to load due to their size |
1114 exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, RMask, GMask, BMask, AMask)); |
1111 exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask)); |
1115 end; |
1112 end; |
1116 |
1113 |
1117 tmpsurf:= doSurfaceConversion(tmpsurf); |
1114 tmpsurf:= doSurfaceConversion(tmpsurf); |
1118 |
1115 |
1119 if (imageFlags and ifTransparent) <> 0 then |
1116 if (imageFlags and ifTransparent) <> 0 then |