diff --git a/Crawler/CharacterMenuWindow.cpp b/Crawler/CharacterMenuWindow.cpp index 4183ad99..9daac4e4 100644 --- a/Crawler/CharacterMenuWindow.cpp +++ b/Crawler/CharacterMenuWindow.cpp @@ -135,7 +135,7 @@ void Menu::InitializeCharacterMenuWindow(){ equipList->RemoveAllComponents(); for(int counter=0;Item&it:availableEquipment){ Item&itemInvRef=Inventory::GetItem(it.ActualName()); - auto equip=equipList->ADD("Equip Item "+std::to_string(counter),RowItemDisplay)({{2,2+counter*28.f},{120-15,28}},itemInvRef, + auto equip=equipList->ADD("Equip Item "+std::to_string(counter),RowItemDisplay)({{2,2+counter*29.f},{120-15,28}},itemInvRef, [](MenuFuncData data){ RowItemDisplay*comp=dynamic_cast(data.component); if(comp!=nullptr){ diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 774e6643..1e621a3b 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -1305,9 +1305,9 @@ void Crawler::RenderCooldowns(){ if(loadoutSlot!=-1){ uint32_t itemAmt=GetLoadoutItem(loadoutSlot).Amt(); if(itemAmt>0){ - std::string amtString="x"+std::to_string(itemAmt); - vf2d qtySize=vf2d{GetTextSize(amtString)}*vf2d{0.5f,0.75f}; - DrawShadowStringDecal(pos+vf2d{20,20}-qtySize/2,amtString,WHITE,BLACK,{0.5f,0.75f}); + std::string amtString="x"+std::to_string(itemAmt); + vf2d qtySize=vf2d{GetTextSize(amtString)}*vf2d{0.5f,0.75f}; + DrawShadowStringDecal(pos+vf2d{20,20}-qtySize/2,amtString,WHITE,BLACK,{0.5f,0.75f}); }else{ DrawDecal(pos,GFX["square_skill_overlay_icon_empty.png"].Decal(),{1,1},DARK_RED); shortNameCol=RED; @@ -1491,6 +1491,7 @@ void Crawler::InitializeLevel(std::string mapFile,MapName map){ void Crawler::LoadLevel(MapName map){ SPAWNER_LIST.clear(); foregroundTileGroups.clear(); + MONSTER_LIST.clear(); currentLevel=map; levelTime=0; bossName=""; @@ -1500,6 +1501,8 @@ void Crawler::LoadLevel(MapName map){ totalBossEncounterMobs=0; Inventory::Clear("Monster Loot"); Inventory::Clear("Stage Loot"); + GetPlayer()->SetState(State::NORMAL); + GetPlayer()->GetCastInfo()={}; #pragma region Monster Spawn Data Setup for(auto&[key,value]:MAP_DATA[map].SpawnerData){ @@ -2265,8 +2268,7 @@ void Crawler::SetLoadoutItem(int slot,std::string itemName){ bool Crawler::UseLoadoutItem(int slot){ if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+")."); if(GetLoadoutItem(slot).Amt()>0){ - Inventory::UseItem(loadout[slot].ActualName()); - GetLoadoutItem(slot).OnUseAction(); + Inventory::UseItem(GetLoadoutItem(slot).ActualName()); GetLoadoutItem(slot).amt--; return true; } @@ -2276,6 +2278,44 @@ bool Crawler::UseLoadoutItem(int slot){ void Crawler::ClearLoadoutItem(int slot){ if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+")."); loadout[slot].it=nullptr; + InputGroup*inputGroup=nullptr; + switch(slot){ + case 0:{ + inputGroup=&Player::KEY_ITEM1; + }break; + case 1:{ + inputGroup=&Player::KEY_ITEM2; + }break; + case 2:{ + inputGroup=&Player::KEY_ITEM3; + }break; + } + Ability itemAbility{"???","","",0,0,inputGroup,""}; + switch(slot){ + case 0:{ + itemAbility.action=[&](Player*p,vf2d pos={}){ + bool itemUsed=game->UseLoadoutItem(0); + + return itemUsed; + }; + game->GetPlayer()->SetItem1UseFunc(itemAbility); + Component(MenuType::ITEM_LOADOUT,"Loadout Item 1")->UpdateIcon(); + }break; + case 1:{ + itemAbility.action=[&](Player*p,vf2d pos={}){ + return game->UseLoadoutItem(1); + }; + game->GetPlayer()->SetItem2UseFunc(itemAbility); + Component(MenuType::ITEM_LOADOUT,"Loadout Item 2")->UpdateIcon(); + }break; + case 2:{ + itemAbility.action=[&](Player*p,vf2d pos={}){ + return game->UseLoadoutItem(2); + }; + game->GetPlayer()->SetItem3UseFunc(itemAbility); + Component(MenuType::ITEM_LOADOUT,"Loadout Item 3")->UpdateIcon(); + }break; + } } void Crawler::RenderFadeout(){ diff --git a/Crawler/Item.cpp b/Crawler/Item.cpp index 071fc324..a549edc8 100644 --- a/Crawler/Item.cpp +++ b/Crawler/Item.cpp @@ -318,17 +318,20 @@ bool Inventory::RemoveItem(IT it,ITCategory inventory,uint32_t amt){ if (!itemAmt)return false; if (amt>=itemAmt){ - inv.erase(inv.begin()+count); + if(!eraseFromLootWindow){ _inventory.erase(it); + }else{ + inv.erase(inv.begin()+count); } //Callback for GUI inventories. Menu::InventorySlotsUpdated(inventory); return true; }else{ - inv.at(count).amt-=amt; if(!eraseFromLootWindow){ _inventory.at(it).amt-=amt; + }else{ + inv.at(count).amt-=amt; } return false; } diff --git a/Crawler/Player.cpp b/Crawler/Player.cpp index 4b6e6b14..3fc20751 100644 --- a/Crawler/Player.cpp +++ b/Crawler/Player.cpp @@ -438,10 +438,6 @@ void Player::Update(float fElapsedTime){ if(CanAct(ability)){ if(ability.cooldown==0&&GetMana()>=ability.manaCost){ if(key.Held()||key.Released()&&&ability==castPrepAbility&&GetState()==State::PREP_CAST){ - if(GetState()==State::CASTING){ - SetState(State::NORMAL); - castInfo.castTimer=castInfo.castTotalTime=0; - } if(AllowedToCast(ability)&&ability.action(this,{})){ ability.cooldown=ability.COOLDOWN_TIME; ConsumeMana(ability.manaCost); diff --git a/Crawler/Player.h b/Crawler/Player.h index 02f3c608..8303addd 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -55,7 +55,7 @@ struct DamageNumber; class MenuComponent; struct CastInfo{ - std::string name; + std::string name="???"; float castTimer; float castTotalTime; vf2d castPos; diff --git a/Crawler/State_GameRun.cpp b/Crawler/State_GameRun.cpp index e72b2a80..23c051aa 100644 --- a/Crawler/State_GameRun.cpp +++ b/Crawler/State_GameRun.cpp @@ -91,7 +91,7 @@ void State_GameRun::OnUserUpdate(Crawler*game){ } void State_GameRun::Draw(Crawler*game){ game->RenderHud(); - FontTest(); //Enable to test font coloring. + //FontTest(); //Enable to test font coloring. //FontSpriteTest(); //Enable to test font coloring. } diff --git a/Crawler/Version.h b/Crawler/Version.h index 68d64c4a..4cd902f4 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 1 -#define VERSION_BUILD 4446 +#define VERSION_BUILD 4462 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/olcPGEX_TransformedView.h b/Crawler/olcPGEX_TransformedView.h index 169bb86a..00786929 100644 --- a/Crawler/olcPGEX_TransformedView.h +++ b/Crawler/olcPGEX_TransformedView.h @@ -178,10 +178,10 @@ namespace olc void DrawRotatedDecal(const olc::vf2d& pos, olc::Decal* decal, const float fAngle, const olc::vf2d& center = { 0.0f, 0.0f }, const olc::vf2d& scale = { 1.0f,1.0f }, const olc::Pixel& tint = olc::WHITE); void DrawPartialRotatedDecal(const olc::vf2d& pos, olc::Decal* decal, const float fAngle, const olc::vf2d& center, const olc::vf2d& source_pos, const olc::vf2d& source_size, const olc::vf2d& scale = { 1.0f, 1.0f }, const olc::Pixel& tint = olc::WHITE); // Draws a multiline string as a decal, with tiniting and scaling - void DrawStringDecal(const olc::vf2d& pos, const std::string& sText, const olc::Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f }); - void DrawStringPropDecal(const olc::vf2d& pos, const std::string& sText, const olc::Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f }); - void DrawShadowStringDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col = olc::WHITE, const Pixel shadowCol = olc::BLACK, const olc::vf2d& scale = { 1.0f, 1.0f },const float shadowSizeFactor=1); - void DrawShadowStringPropDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col = olc::WHITE, const Pixel shadowCol = olc::BLACK, const olc::vf2d& scale = { 1.0f, 1.0f },const float shadowSizeFactor=1); + void DrawStringDecal(const olc::vf2d& pos, std::string_view sText, const olc::Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f },const float width=std::numeric_limits::max()); + void DrawStringPropDecal(const olc::vf2d& pos, std::string_view sText, const olc::Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f },const float width=std::numeric_limits::max()); + void DrawShadowStringDecal(const olc::vf2d& pos, std::string_view sText, const Pixel col = olc::WHITE, const Pixel shadowCol = olc::BLACK, const olc::vf2d& scale = { 1.0f, 1.0f },const float width=std::numeric_limits::max(),const float shadowSizeFactor=1); + void DrawShadowStringPropDecal(const olc::vf2d& pos, std::string_view sText, const Pixel col = olc::WHITE, const Pixel shadowCol = olc::BLACK, const olc::vf2d& scale = { 1.0f, 1.0f },const float width=std::numeric_limits::max(),const float shadowSizeFactor=1); // Draws a single shaded filled rectangle as a decal void FillRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col = olc::WHITE); void DrawRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col = olc::WHITE); @@ -624,22 +624,22 @@ namespace olc pge->DrawPartialRotatedDecal(WorldToScreen(pos), decal, fAngle, center, source_pos, source_size, scale * m_vWorldScale * m_vRecipPixel, tint); } - void TransformedView::DrawStringDecal(const olc::vf2d & pos, const std::string & sText, const olc::Pixel col, const olc::vf2d & scale) + void TransformedView::DrawStringDecal(const olc::vf2d & pos, std::string_view sText, const olc::Pixel col, const olc::vf2d & scale,const float width) { - pge->DrawStringDecal(WorldToScreen(pos), sText, col, scale * m_vWorldScale * m_vRecipPixel); + pge->DrawStringDecal(WorldToScreen(pos), sText, col, scale * m_vWorldScale * m_vRecipPixel,width); } - void TransformedView::DrawStringPropDecal(const olc::vf2d & pos, const std::string & sText, const olc::Pixel col, const olc::vf2d & scale ) + void TransformedView::DrawStringPropDecal(const olc::vf2d & pos, std::string_view sText, const olc::Pixel col, const olc::vf2d & scale,const float width ) { - pge->DrawStringPropDecal(WorldToScreen(pos), sText, col, scale * m_vWorldScale * m_vRecipPixel); + pge->DrawStringPropDecal(WorldToScreen(pos), sText, col, scale * m_vWorldScale * m_vRecipPixel,width); } - void TransformedView::DrawShadowStringDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float shadowSizeFactor){ - pge->DrawShadowStringDecal(WorldToScreen(pos),sText,col,shadowCol,scale,shadowSizeFactor); + void TransformedView::DrawShadowStringDecal(const olc::vf2d& pos, std::string_view sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float width,const float shadowSizeFactor){ + pge->DrawShadowStringDecal(WorldToScreen(pos),sText,col,shadowCol,scale,width,shadowSizeFactor); } - void TransformedView::DrawShadowStringPropDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float shadowSizeFactor){ - pge->DrawShadowStringPropDecal(WorldToScreen(pos),sText,col,shadowCol,scale,shadowSizeFactor); + void TransformedView::DrawShadowStringPropDecal(const olc::vf2d& pos, std::string_view sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float width,const float shadowSizeFactor){ + pge->DrawShadowStringPropDecal(WorldToScreen(pos),sText,col,shadowCol,scale,width,shadowSizeFactor); } void TransformedView::FillRectDecal(const olc::vf2d & pos, const olc::vf2d & size, const olc::Pixel col) diff --git a/Crawler/olcPGEX_ViewPort.h b/Crawler/olcPGEX_ViewPort.h index 29e0c317..ce30fbb8 100644 --- a/Crawler/olcPGEX_ViewPort.h +++ b/Crawler/olcPGEX_ViewPort.h @@ -636,6 +636,7 @@ void olc::ViewPort::DrawStringDecal(const olc::vf2d& pos, std::string_view sText if(sText.length()==0)return; static std::mapgarbageCollector; std::string key{sText}; + key+=std::to_string(width); if(!disableDynamicScaling){ key+=scale.str(); } @@ -690,6 +691,7 @@ void olc::ViewPort::DrawStringPropDecal(const olc::vf2d& pos, std::string_view s if(sText.length()==0)return; static std::mapgarbageCollector; std::string key{sText}; + key+=std::to_string(width); if(!disableDynamicScaling){ key+=scale.str(); } diff --git a/Crawler/olcPixelGameEngine.h b/Crawler/olcPixelGameEngine.h index a9d323a4..ac57c52f 100644 --- a/Crawler/olcPixelGameEngine.h +++ b/Crawler/olcPixelGameEngine.h @@ -3361,6 +3361,7 @@ namespace olc if(sText.length()==0)return; static std::mapgarbageCollector; std::string key{sText}; + key+=std::to_string(width); if(!disableDynamicScaling){ key+=scale.str(); } @@ -3394,6 +3395,7 @@ namespace olc if(sText.length()==0)return; static std::mapgarbageCollector; std::string key{sText}; + key+=std::to_string(width); if(!disableDynamicScaling){ key+=scale.str(); }