--- a/hedgewars/SDLh.pas Fri Sep 29 21:44:35 2017 +0200
+++ b/hedgewars/SDLh.pas Fri Sep 29 22:39:31 2017 +0200
@@ -77,6 +77,9 @@
///////////////////// CONSTANT DEFINITIONS /////////////////////
/////////////////////////////////////////////////////////////////
+ SDL_FALSE = 0;
+ SDL_TRUE = 1;
+
// SDL_Init() flags
SDL_INIT_TIMER = $00000001;
SDL_INIT_AUDIO = $00000010;
--- a/hedgewars/uConsts.pas Fri Sep 29 21:44:35 2017 +0200
+++ b/hedgewars/uConsts.pas Fri Sep 29 22:39:31 2017 +0200
@@ -90,10 +90,11 @@
rqDesyncVBlank= $00000800; // don't sync on vblank
// image flags (for LoadImage())
+ // TODO: discuss whether ifAlpha and ifColorKey are actually needed and if and where we want to support which colorkeys
ifNone = $00000000; // nothing special
ifAlpha = $00000001; // use alpha channel (unused right now?)
ifCritical = $00000002; // image is critical for gameplay (exit game if unable to load)
- ifTransparent = $00000004; // image uses transparent pixels (color keying)
+ ifColorKey = $00000004; // image uses transparent pixels (color keying)
ifIgnoreCaps = $00000008; // ignore hardware capabilities when loading (i.e. image will not be drawn using OpenGL)
// texture priority (allows OpenGL to keep frequently used textures in video memory more easily)
--- a/hedgewars/uLand.pas Fri Sep 29 21:44:35 2017 +0200
+++ b/hedgewars/uLand.pas Fri Sep 29 22:39:31 2017 +0200
@@ -53,7 +53,7 @@
x, yd, yu: LongInt;
targetMask: Word;
begin
- tmpsurf:= LoadDataImage(ptCurrTheme, 'Border', ifCritical or ifIgnoreCaps or ifTransparent);
+ tmpsurf:= LoadDataImage(ptCurrTheme, 'Border', ifCritical or ifIgnoreCaps or ifColorKey);
// if mask only, all land gets filled with landtex and therefore needs borders
if maskOnly then
@@ -251,7 +251,7 @@
SDL_UnlockSurface(mapsurf);
// freed in freeModule() below
- LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifTransparent);
+ LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifColorKey);
if (LandBackSurface <> nil) and GrayScale then Surface2GrayScale(LandBackSurface);
end;
@@ -278,7 +278,7 @@
SDL_FreeSurface(tmpsurf);
// freed in freeModule() below
- LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifTransparent);
+ LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifColorKey);
if (LandBackSurface <> nil) and GrayScale then Surface2GrayScale(LandBackSurface);
end;
@@ -544,11 +544,11 @@
if mirror then
begin
// not critical because if no R we can fallback to mirrored L
- tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'R', ifAlpha or ifTransparent or ifIgnoreCaps);
+ tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'R', ifAlpha or ifColorKey or ifIgnoreCaps);
// fallback
if tmpsurf = nil then
begin
- tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
+ tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifColorKey or ifIgnoreCaps);
BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf, 0, true);
end
else
@@ -557,7 +557,7 @@
end
else
begin
- tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
+ tmpsurf:= LoadDataImage(ptForts, SpawnClansArray[i]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifColorKey or ifIgnoreCaps);
BlitImageAndGenerateCollisionInfo(leftX + sectionWidth * i + ((sectionWidth - tmpsurf^.w) div 2), LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf);
SDL_FreeSurface(tmpsurf);
end;
@@ -597,11 +597,11 @@
x, y, cpX, cpY: Longword;
mapName: shortstring;
begin
-tmpsurf:= LoadDataImage(ptMapCurrent, 'mask', ifAlpha or ifTransparent or ifIgnoreCaps);
+tmpsurf:= LoadDataImage(ptMapCurrent, 'mask', ifAlpha or ifColorKey or ifIgnoreCaps);
if tmpsurf = nil then
begin
mapName:= ExtractFileName(cPathz[ptMapCurrent]);
- tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps);
+ tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/mask', ifAlpha or ifColorKey or ifIgnoreCaps);
end;
@@ -639,7 +639,7 @@
if not disableLandBack then
begin
// freed in freeModule() below
- LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifTransparent);
+ LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifColorKey);
if (LandBackSurface <> nil) and GrayScale then
Surface2GrayScale(LandBackSurface)
end;
@@ -656,11 +656,11 @@
begin
WriteLnToConsole('Loading land from file...');
AddProgress;
-tmpsurf:= LoadDataImage(ptMapCurrent, 'map', ifAlpha or ifTransparent or ifIgnoreCaps);
+tmpsurf:= LoadDataImage(ptMapCurrent, 'map', ifAlpha or ifColorKey or ifIgnoreCaps);
if tmpsurf = nil then
begin
mapName:= ExtractFileName(cPathz[ptMapCurrent]);
- tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
+ tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/map', ifAlpha or ifCritical or ifColorKey or ifIgnoreCaps);
if not allOK then exit;
end;
// (bare) Sanity check. Considering possible LongInt comparisons as well as just how much system memoery it would take
--- a/hedgewars/uLandObjects.pas Fri Sep 29 21:44:35 2017 +0200
+++ b/hedgewars/uLandObjects.pas Fri Sep 29 22:39:31 2017 +0200
@@ -259,7 +259,7 @@
bRes: boolean;
begin
if girSurf = nil then
- girSurf:= LoadDataImageAltPath(ptCurrTheme, ptGraphics, 'Girder', ifCritical or ifTransparent or ifIgnoreCaps);
+ girSurf:= LoadDataImageAltPath(ptCurrTheme, ptGraphics, 'Girder', ifCritical or ifColorKey or ifIgnoreCaps);
girderHeight:= girSurf^.h;
@@ -685,10 +685,10 @@
with ThemeObjects.objs[Pred(ThemeObjects.Count)] do
begin
i:= Pos(',', s);
- Surf:= LoadDataImage(ptCurrTheme, Trim(Copy(s, 1, Pred(i))), ifTransparent or ifIgnoreCaps or ifCritical);
+ Surf:= LoadDataImage(ptCurrTheme, Trim(Copy(s, 1, Pred(i))), ifColorKey or ifIgnoreCaps or ifCritical);
Width:= Surf^.w;
Height:= Surf^.h;
- Mask:= LoadDataImage(ptCurrTheme, Trim(Copy(s, 1, Pred(i)))+'_mask', ifTransparent or ifIgnoreCaps);
+ Mask:= LoadDataImage(ptCurrTheme, Trim(Copy(s, 1, Pred(i)))+'_mask', ifColorKey or ifIgnoreCaps);
Delete(s, 1, i);
i:= Pos(',', s);
Maxcnt:= StrToInt(Trim(Copy(s, 1, Pred(i))));
@@ -762,7 +762,7 @@
with SprayObjects.objs[Pred(SprayObjects.Count)] do
begin
i:= Pos(',', s);
- Surf:= LoadDataImage(ptCurrTheme, Trim(Copy(s, 1, Pred(i))), ifTransparent or ifIgnoreCaps);
+ Surf:= LoadDataImage(ptCurrTheme, Trim(Copy(s, 1, Pred(i))), ifAlpha or ifIgnoreCaps);
Width:= Surf^.w;
Height:= Surf^.h;
Delete(s, 1, i);
--- a/hedgewars/uRenderUtils.pas Fri Sep 29 21:44:35 2017 +0200
+++ b/hedgewars/uRenderUtils.pas Fri Sep 29 22:39:31 2017 +0200
@@ -336,7 +336,7 @@
WriteInRoundRect(finalSurface, 0, 0, Color, font, s, maxLength);
- checkFails(SDL_SetColorKey(finalSurface, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, false);
+ checkFails(SDL_SetColorKey(finalSurface, SDL_TRUE, 0) = 0, errmsgTransparentSet, false);
RenderStringTexLim:= Surface2Tex(finalSurface, false);
--- a/hedgewars/uStore.pas Fri Sep 29 21:44:35 2017 +0200
+++ b/hedgewars/uStore.pas Fri Sep 29 22:39:31 2017 +0200
@@ -152,7 +152,7 @@
texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask);
if not checkFails(texsurf <> nil, errmsgCreateSurface, true) then
- checkFails(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
+ checkFails(SDL_SetColorKey(texsurf, SDL_TRUE, 0) = 0, errmsgTransparentSet, true);
if not allOK then exit(nil);
@@ -201,7 +201,7 @@
r.h:= 32;
texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask);
if not checkFails(texsurf <> nil, errmsgCreateSurface, true) then
- checkFails(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
+ checkFails(SDL_SetColorKey(texsurf, SDL_TRUE, 0) = 0, errmsgTransparentSet, true);
if not allOK then exit;
r.w:= 26;
@@ -344,7 +344,7 @@
begin
if GraveName = '' then
GraveName:= 'Statue';
- texsurf:= LoadDataImageAltFile(ptGraves, GraveName, 'Statue', ifCritical or ifTransparent);
+ texsurf:= LoadDataImageAltFile(ptGraves, GraveName, 'Statue', ifCritical or ifColorKey);
GraveTex:= Surface2Tex(texsurf, false);
SDL_FreeSurface(texsurf)
end
@@ -412,7 +412,7 @@
tmpsurf:= Surface
else
begin
- imflags := (ifAlpha or ifTransparent);
+ imflags := (ifAlpha or ifColorKey);
// these sprites are optional
if not (ii in [sprHorizont, sprHorizontL, sprHorizontR, sprSky, sprSkyL, sprSkyR, sprChunk, sprFlakeL, sprSDFlakeL, sprCloudL, sprSDCloudL]) then // FIXME: hack
@@ -491,7 +491,7 @@
if not reload then
AddProgress;
- tmpsurf:= LoadDataImage(ptGraphics, cHHFileName, ifAlpha or ifCritical or ifTransparent);
+ tmpsurf:= LoadDataImage(ptGraphics, cHHFileName, ifAlpha or ifCritical or ifColorKey);
HHTexture:= Surface2Tex(tmpsurf, false);
SDL_FreeSurface(tmpsurf);
@@ -663,8 +663,8 @@
tmpsurf:= doSurfaceConversion(tmpsurf);
- if (imageFlags and ifTransparent) <> 0 then
- if checkFails(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true) then exit;
+ if (imageFlags and ifColorKey) <> 0 then
+ if checkFails(SDL_SetColorKey(tmpsurf, SDL_TRUE, 0) = 0, errmsgTransparentSet, true) then exit;
WriteLnToConsole(msgOK + ' (' + inttostr(tmpsurf^.w) + 'x' + inttostr(tmpsurf^.h) + ')');
@@ -799,7 +799,7 @@
if Step = 0 then
begin
WriteToConsole(msgLoading + 'progress sprite: ');
- texsurf:= LoadDataImage(ptGraphics, 'Progress', ifCritical or ifTransparent);
+ texsurf:= LoadDataImage(ptGraphics, 'Progress', ifCritical or ifColorKey);
ProgrTex:= Surface2Tex(texsurf, false);