|
|
|
@ -53,17 +53,27 @@ void Minimap::Initialize(){ |
|
|
|
|
} |
|
|
|
|
mapCircleHud=ViewPort{enlargedCircle,vi2d{game->ScreenWidth()-"Minimap.Minimap HUD Size"_I-4,4}}; |
|
|
|
|
|
|
|
|
|
enlargedCircle.clear(); |
|
|
|
|
for(int i=360;i>=0;i-=4){ |
|
|
|
|
float angle=util::degToRad(float(i))-PI/2; |
|
|
|
|
if(i==360){enlargedCircle.push_back(vf2d{cos(angle),sin(angle)}*game->ScreenWidth()/3+game->ScreenWidth()/3);} |
|
|
|
|
enlargedCircle.push_back(vf2d{cos(angle),sin(angle)}*game->ScreenWidth()/3+game->ScreenWidth()/3); |
|
|
|
|
} |
|
|
|
|
mapCircleLargeHud=ViewPort{enlargedCircle,vi2d{game->ScreenWidth()/2-game->ScreenWidth()/3,game->ScreenHeight()/2-game->ScreenWidth()/3}}; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Minimap::Reset(){ |
|
|
|
|
if(minimap.Sprite()==nullptr)minimap.Create(1,1); |
|
|
|
|
if(cover.Sprite()==nullptr)cover.Create(1,1); |
|
|
|
|
if(coverOutline.Sprite()==nullptr)coverOutline.Create(1,1); |
|
|
|
|
|
|
|
|
|
Sprite baseMinimap; |
|
|
|
|
|
|
|
|
|
#pragma region Cleanup minimap and cover images |
|
|
|
|
minimap.Sprite()->Resize(game->GetCurrentMapData().width,game->GetCurrentMapData().height); |
|
|
|
|
cover.Sprite()->Resize(game->GetCurrentMapData().width,game->GetCurrentMapData().height); |
|
|
|
|
coverOutline.Sprite()->Resize(game->GetCurrentMapData().width,game->GetCurrentMapData().height); |
|
|
|
|
baseMinimap.Resize(game->GetCurrentMapData().width,game->GetCurrentMapData().height); |
|
|
|
|
game->SetDrawTarget(minimap.Sprite()); |
|
|
|
|
game->SetPixelMode(Pixel::ALPHA); |
|
|
|
@ -72,6 +82,8 @@ void Minimap::Reset(){ |
|
|
|
|
game->Clear(BLANK); |
|
|
|
|
game->SetDrawTarget(cover.Sprite()); |
|
|
|
|
game->Clear(BLANK); |
|
|
|
|
game->SetDrawTarget(coverOutline.Sprite()); |
|
|
|
|
game->Clear(BLANK); |
|
|
|
|
game->SetPixelMode(Pixel::NORMAL); |
|
|
|
|
//Will update the minimap decal at the end, since we are about to change it anyways.
|
|
|
|
|
cover.Decal()->Update(); |
|
|
|
@ -137,7 +149,11 @@ void Minimap::Reset(){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Minimap::Update(){ |
|
|
|
|
|
|
|
|
|
if(game->GetKey(TAB).bPressed){ |
|
|
|
|
if(displayMode==MinimapMode::SMALL)displayMode=MinimapMode::LARGE; |
|
|
|
|
else if(displayMode==MinimapMode::LARGE)displayMode=MinimapMode::OFF; |
|
|
|
|
else if(displayMode==MinimapMode::OFF)displayMode=MinimapMode::SMALL; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Minimap::UpdateChunk(const MapName map,const vi2d chunkPos){ |
|
|
|
@ -153,11 +169,15 @@ void Minimap::UpdateChunk(const MapName map,const vi2d chunkPos){ |
|
|
|
|
//We start twice the distance we are supposed to outwards.
|
|
|
|
|
for(int y=pixelPos.y;y<chunkEndPixelPos.y;y++){ |
|
|
|
|
for(int x=pixelPos.x;x<chunkEndPixelPos.x;x++){ |
|
|
|
|
if(cover.Sprite()->GetPixel(x,y).a==255||minimap.Sprite()->GetPixel(x,y).a==0)continue; //Already revealed or invisible anyways.
|
|
|
|
|
Pixel sourceCol=minimap.Sprite()->GetPixel(x,y); |
|
|
|
|
bool sourceWasBlack=sourceCol==BLACK; |
|
|
|
|
|
|
|
|
|
if(cover.Sprite()->GetPixel(x,y).a==255||sourceCol.a==0)continue; //Already revealed or invisible anyways.
|
|
|
|
|
|
|
|
|
|
vi2d chunk=vi2d{x,y}/"Minimap.Chunk Size"_I; |
|
|
|
|
if(chunk==chunkPos){ |
|
|
|
|
cover.Sprite()->SetPixel(x,y,minimap.Sprite()->GetPixel(x,y)); |
|
|
|
|
cover.Sprite()->SetPixel(x,y,sourceCol); |
|
|
|
|
if(sourceWasBlack)coverOutline.Sprite()->SetPixel(x,y,sourceCol); |
|
|
|
|
}else{ |
|
|
|
|
const vi2d chunkOffset={"Minimap.Chunk Size"_I/2,"Minimap.Chunk Size"_I/2}; |
|
|
|
|
|
|
|
|
@ -166,21 +186,32 @@ void Minimap::UpdateChunk(const MapName map,const vi2d chunkPos){ |
|
|
|
|
|
|
|
|
|
if(cover.Sprite()->GetPixel(x,y).a>alpha)continue; //The distance was uncovered by another closer chunk, don't need to reveal it here.
|
|
|
|
|
|
|
|
|
|
Pixel sourceCol=minimap.Sprite()->GetPixel(x,y); |
|
|
|
|
sourceCol.a=alpha; |
|
|
|
|
cover.Sprite()->SetPixel(x,y,sourceCol); |
|
|
|
|
if(sourceWasBlack)coverOutline.Sprite()->SetPixel(x,y,sourceCol); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cover.Decal()->Update(); |
|
|
|
|
coverOutline.Decal()->Update(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Minimap::Draw(){ |
|
|
|
|
const vf2d minimapPos=vf2d{float("Minimap.Minimap HUD Size"_I),float("Minimap.Minimap HUD Size"_I)}/2; |
|
|
|
|
if(!game->InBossEncounter())mapCircleHud.DrawRotatedDecal(minimapPos,cover.Decal(),0.f,game->GetPlayer()->GetPos()/game->GetCurrentMapData().tilewidth,vf2d{0.5f,0.5f}); |
|
|
|
|
if(!game->InBossEncounter()){ |
|
|
|
|
switch(displayMode){ |
|
|
|
|
case MinimapMode::SMALL:{ |
|
|
|
|
mapCircleHud.DrawRotatedDecal(minimapPos,cover.Decal(),0.f,game->GetPlayer()->GetPos()/game->GetCurrentMapData().tilewidth,vf2d{0.5f,0.5f}); |
|
|
|
|
game->DrawRotatedDecal(mapCircleHud.GetOffset()+minimapPos,GFX["skill_overlay_icon.png"].Decal(),0.f,GFX["skill_overlay_icon.png"].Sprite()->Size()/2,vf2d{float("Minimap.Minimap HUD Size"_I),float("Minimap.Minimap HUD Size"_I)}/24.f*1.05f); |
|
|
|
|
game->DrawRotatedDecal(mapCircleHud.GetOffset()+minimapPos,game->GetPlayer()->GetMinimapImage().Decal(),0.f,vi2d{"Player.Minimap Image Size"_i[0],"Player.Minimap Image Size"_i[1]}/2,{0.5f,0.5f}); |
|
|
|
|
}break; |
|
|
|
|
case MinimapMode::LARGE:{ |
|
|
|
|
mapCircleLargeHud.DrawRotatedDecal(vf2d{game->ScreenWidth()/3.f,game->ScreenWidth()/3.f},coverOutline.Decal(),0.f,game->GetPlayer()->GetPos()/game->GetCurrentMapData().tilewidth,vf2d{2.f,2.f},{255,255,255,48}); |
|
|
|
|
}break; |
|
|
|
|
case MinimapMode::OFF:{}break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Minimap::EraseChunkData(){ |
|
|
|
|