Add toggle between small,large, and hidden minimap. Release Build 8868.

mac-build
sigonasr2 8 months ago
parent 0b25bf1d1b
commit 1680b37671
  1. 6
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 45
      Adventures in Lestoria/Minimap.cpp
  3. 9
      Adventures in Lestoria/Minimap.h
  4. 2
      Adventures in Lestoria/Version.h
  5. BIN
      x64/Release/Adventures in Lestoria.exe

@ -1740,6 +1740,9 @@ void AiL::RenderHud(){
}
}
};
minimap.Update();
minimap.Draw();
RenderAimingCursor();
@ -1811,9 +1814,6 @@ void AiL::RenderHud(){
std::string displayText=player->notificationDisplay.first;
DrawShadowStringPropDecal(vf2d{float(ScreenWidth()/2),float(ScreenHeight()/4)-24}-GetTextSizeProp(displayText)/2,displayText,BLUE,VERY_DARK_BLUE);
}
minimap.Update();
minimap.Draw();
DisplayBossEncounterInfo();
#ifdef _DEBUG

@ -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});
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});
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(){

@ -39,6 +39,12 @@ All rights reserved.
#include "olcPGEX_ViewPort.h"
enum class MinimapMode{
SMALL,
LARGE,
OFF,
};
class Minimap{
public:
void Initialize();
@ -52,7 +58,10 @@ public:
const std::unordered_map<MapName,std::unordered_set<std::string>>&GetChunkData();
private:
ViewPort mapCircleHud;
ViewPort mapCircleLargeHud;
Renderable minimap;
Renderable cover;
Renderable coverOutline;
std::unordered_map<MapName,std::unordered_set<std::string>>loadedChunks;
MinimapMode displayMode=MinimapMode::SMALL;
};

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 1
#define VERSION_PATCH 0
#define VERSION_BUILD 8851
#define VERSION_BUILD 8868
#define stringify(a) stringify_(a)
#define stringify_(a) #a

Loading…
Cancel
Save