1131 procedure LoadMask(mapName: shortstring); |
1131 procedure LoadMask(mapName: shortstring); |
1132 var tmpsurf: PSDL_Surface; |
1132 var tmpsurf: PSDL_Surface; |
1133 p: PLongwordArray; |
1133 p: PLongwordArray; |
1134 x, y, cpX, cpY: Longword; |
1134 x, y, cpX, cpY: Longword; |
1135 begin |
1135 begin |
1136 tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); |
1136 tmpsurf:= LoadImage(UserPathz[ptMapCurrent] + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); |
1137 if (tmpsurf = nil) and (mapName <> '') then |
1137 if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); |
1138 tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName +'/mask', ifAlpha or ifTransparent or ifIgnoreCaps); |
1138 if tmpsurf = nil then |
|
1139 begin |
|
1140 mapName:= ExtractFileName(Pathz[ptMapCurrent]); |
|
1141 tmpsurf:= LoadImage(UserPathz[ptMissionMaps] + '/' + mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); |
|
1142 if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/mask', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
|
1143 end; |
1139 |
1144 |
1140 if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then |
1145 if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then |
1141 begin |
1146 begin |
1142 cpX:= (LAND_WIDTH - tmpsurf^.w) div 2; |
1147 cpX:= (LAND_WIDTH - tmpsurf^.w) div 2; |
1143 cpY:= LAND_HEIGHT - tmpsurf^.h; |
1148 cpY:= LAND_HEIGHT - tmpsurf^.h; |
1177 WriteLnToConsole('Loading land from file...'); |
1182 WriteLnToConsole('Loading land from file...'); |
1178 AddProgress; |
1183 AddProgress; |
1179 tmpsurf:= LoadImage(UserPathz[ptMapCurrent] + '/map', ifAlpha or ifTransparent or ifIgnoreCaps); |
1184 tmpsurf:= LoadImage(UserPathz[ptMapCurrent] + '/map', ifAlpha or ifTransparent or ifIgnoreCaps); |
1180 if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', ifAlpha or ifTransparent or ifIgnoreCaps); |
1185 if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', ifAlpha or ifTransparent or ifIgnoreCaps); |
1181 if tmpsurf = nil then |
1186 if tmpsurf = nil then |
1182 begin |
1187 begin |
1183 mapName:= ExtractFileName(Pathz[ptMapCurrent]); |
1188 mapName:= ExtractFileName(Pathz[ptMapCurrent]); |
1184 tmpsurf:= LoadImage(UserPathz[ptMissionMaps] + '/' + mapName + '/map', ifAlpha or ifTransparent or ifIgnoreCaps); |
1189 tmpsurf:= LoadImage(UserPathz[ptMissionMaps] + '/' + mapName + '/map', ifAlpha or ifTransparent or ifIgnoreCaps); |
1185 if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
1190 if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); |
1186 end; |
1191 end; |
1187 TryDo((tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT), 'Map dimensions too big!', true); |
1192 TryDo((tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT), 'Map dimensions too big!', true); |
1188 |
1193 |
1189 // unC0Rr - should this be passed from the GUI? I am not sure which layer does what |
1194 // unC0Rr - should this be passed from the GUI? I am not sure which layer does what |
1190 s:= UserPathz[ptMapCurrent] + '/map.cfg'; |
1195 s:= UserPathz[ptMapCurrent] + '/map.cfg'; |
1191 if not FileExists(s) then s:= Pathz[ptMapCurrent] + '/map.cfg'; |
1196 if not FileExists(s) then s:= Pathz[ptMapCurrent] + '/map.cfg'; |