Generate mock-up map textures when commerical assets are not found.
This commit is contained in:
parent
38729877b8
commit
e6808dfef2
@ -1385,7 +1385,48 @@ void Crawler::InitializeLevel(std::string mapFile,MapName map){
|
||||
MAP_TILESETS["assets/maps/"+baseSourceDir].animationData=tileset.GetData().AnimationData;
|
||||
MAP_TILESETS["assets/maps/"+baseSourceDir].reflectiveData=tileset.GetData().ReflectiveData;
|
||||
std::cout<<"assets/maps/"+baseSourceDir<<" Animation Data Size: "<<MAP_TILESETS["assets/maps/"+baseSourceDir].animationData.size()<<std::endl;
|
||||
r->Load("assets/maps/"+tileset.GetData().ImageData.data["source"]);
|
||||
std::string mapPath="assets/maps/"+tileset.GetData().ImageData.data["source"];
|
||||
if(std::filesystem::exists(mapPath)){
|
||||
r->Load(mapPath);
|
||||
}else{
|
||||
std::cout<<"WARNING! "<<mapPath<<" does not exist, auto-generating mock-up texture"<<std::endl;
|
||||
r->Create(tileset.GetData().imagewidth,tileset.GetData().imageheight);
|
||||
SetDrawTarget(r->Sprite());
|
||||
int tileXCount=tileset.GetData().imagewidth/tileset.GetData().tilewidth;
|
||||
int tileYCount=tileset.GetData().imageheight/tileset.GetData().tileheight;
|
||||
vi2d tileSize={tileset.GetData().tilewidth,tileset.GetData().tileheight};
|
||||
|
||||
const int colorCombinations=255*6;
|
||||
|
||||
for(int y=0;y<tileYCount;y++){
|
||||
for(int x=0;x<tileXCount;x++){
|
||||
int colorCycleIndex=(y*255+x)%colorCombinations;
|
||||
Pixel tileCol=WHITE;
|
||||
if(colorCycleIndex<255){
|
||||
tileCol={uint8_t(colorCycleIndex%255),0,0};
|
||||
}else
|
||||
if(colorCycleIndex<255*2){
|
||||
tileCol={0,uint8_t(colorCycleIndex%255),0};
|
||||
}else
|
||||
if(colorCycleIndex<255*3){
|
||||
tileCol={0,0,uint8_t(colorCycleIndex%255)};
|
||||
}else
|
||||
if(colorCycleIndex<255*4){
|
||||
tileCol={uint8_t(colorCycleIndex%255),uint8_t(colorCycleIndex%255),0};
|
||||
}else
|
||||
if(colorCycleIndex<255*5){
|
||||
tileCol={0,uint8_t(colorCycleIndex%255),uint8_t(colorCycleIndex%255)};
|
||||
}else{
|
||||
tileCol={uint8_t(colorCycleIndex%255),0,uint8_t(colorCycleIndex%255)};
|
||||
}
|
||||
FillRect(vi2d{x,y}*tileSize,tileSize,tileCol);
|
||||
DrawRect(vi2d{x,y}*tileSize,tileSize,GREY);
|
||||
DrawString(vi2d{x,y}*tileSize+vi2d{1,1},std::to_string(y*255+x),DARK_GREY);
|
||||
}
|
||||
}
|
||||
SetDrawTarget(nullptr);
|
||||
r->Decal()->Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -49,6 +49,7 @@ using namespace olc;
|
||||
struct Tileset{
|
||||
XMLTag ImageData;
|
||||
int tilewidth=0,tileheight=0;
|
||||
int imagewidth=0,imageheight=0;
|
||||
std::map<int,XMLTag> ForegroundTileData;
|
||||
std::map<int,XMLTag> UpperForegroundTileData;
|
||||
std::map<int,TileCollisionData> CollisionData;
|
||||
@ -136,6 +137,8 @@ class TSXParser{
|
||||
} else
|
||||
if (newTag.tag=="image") {
|
||||
parsedTilesetInfo.ImageData=newTag;
|
||||
parsedTilesetInfo.imagewidth=newTag.GetInteger("width");
|
||||
parsedTilesetInfo.imageheight=newTag.GetInteger("height");
|
||||
} else
|
||||
if (newTag.tag=="tile"&&newTag.data["type"]=="ForegroundTile"){
|
||||
previousTag=newTag.tag;
|
||||
|
||||
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 1
|
||||
#define VERSION_BUILD 3937
|
||||
#define VERSION_BUILD 3941
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
||||
@ -1 +0,0 @@
|
||||
Files located in this directory will not be included in the actual repository, which means they will not get distributed elsewhere illegally!
|
||||
Loading…
x
Reference in New Issue
Block a user