Implement Reaper of Souls Enchant. Fix text rendering bug with really small pixel values getting clamped by integer scaling causing the cached text to be cut off. Release Build 10683.

mac-build
sigonasr2 4 months ago
parent cfd73ab036
commit 9a65b731e9
  1. 4
      Adventures in Lestoria/Adventures in Lestoria.vcxproj
  2. 3
      Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters
  3. 1
      Adventures in Lestoria/Animation.cpp
  4. 16
      Adventures in Lestoria/Effect.cpp
  5. 19
      Adventures in Lestoria/Effect.h
  6. 2
      Adventures in Lestoria/Monster.cpp
  7. 89
      Adventures in Lestoria/MonsterSoul.cpp
  8. 2
      Adventures in Lestoria/Version.h
  9. 5
      Adventures in Lestoria/assets/config/audio/events.txt
  10. 2
      Adventures in Lestoria/assets/config/gfx/gfx.txt
  11. BIN
      Adventures in Lestoria/assets/gamepack.pak
  12. BIN
      Adventures in Lestoria/assets/monstersoul.png
  13. BIN
      Adventures in Lestoria/assets/monstersoulglow.png
  14. BIN
      Adventures in Lestoria/assets/sounds/collect_soul.ogg
  15. 8
      Adventures in Lestoria/olcPGEX_ViewPort.h
  16. 20
      Adventures in Lestoria/olcPixelGameEngine.h
  17. BIN
      x64/Release/Adventures in Lestoria.exe

@ -1000,6 +1000,10 @@
<SubType> <SubType>
</SubType> </SubType>
</ClCompile> </ClCompile>
<ClCompile Include="MonsterSoul.cpp">
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="NPC.cpp"> <ClCompile Include="NPC.cpp">
<SubType> <SubType>
</SubType> </SubType>

@ -1190,6 +1190,9 @@
<ClCompile Include="ItemEnchant.cpp"> <ClCompile Include="ItemEnchant.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="MonsterSoul.cpp">
<Filter>Source Files\Effects</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="cpp.hint" /> <None Include="cpp.hint" />

@ -371,6 +371,7 @@ void sig::Animation::InitializeAnimations(){
CreateStillAnimation("chain_lightning.png",{1,9}); CreateStillAnimation("chain_lightning.png",{1,9});
CreateHorizontalAnimationSequence("monstersoul.png",3,{24,24},AnimationData{.frameDuration{0.25f},.style{Animate2D::Style::Repeat}});
CreateHorizontalAnimationSequence("lightning_splash_effect.png",5,{24,24}); CreateHorizontalAnimationSequence("lightning_splash_effect.png",5,{24,24});
CreateHorizontalAnimationSequence("dagger_stab.png",2,{24,24},AnimationData{.frameDuration{0.1f},.style{Animate2D::Style::PingPong}}); CreateHorizontalAnimationSequence("dagger_stab.png",2,{24,24},AnimationData{.frameDuration{0.1f},.style{Animate2D::Style::PingPong}});
CreateHorizontalAnimationSequence("goblin_sword_slash.png",3,{24,24},{0.05f,Animate2D::Style::OneShot}); CreateHorizontalAnimationSequence("goblin_sword_slash.png",3,{24,24},{0.05f,Animate2D::Style::OneShot});

@ -42,6 +42,7 @@ All rights reserved.
INCLUDE_ANIMATION_DATA INCLUDE_ANIMATION_DATA
INCLUDE_game INCLUDE_game
INCLUDE_GFX
Effect::Effect(vf2d pos,float lifetime,std::string imgFile,bool upperLevel,float size,float fadeout,vf2d spd,Pixel col,float rotation,float rotationSpd,bool additiveBlending) Effect::Effect(vf2d pos,float lifetime,std::string imgFile,bool upperLevel,float size,float fadeout,vf2d spd,Pixel col,float rotation,float rotationSpd,bool additiveBlending)
:Effect::Effect(pos,lifetime,imgFile,upperLevel,0.f,fadeout,vf2d{size,size},spd,col,rotation,rotationSpd,additiveBlending){} :Effect::Effect(pos,lifetime,imgFile,upperLevel,0.f,fadeout,vf2d{size,size},spd,col,rotation,rotationSpd,additiveBlending){}
@ -84,13 +85,18 @@ void Effect::Draw()const{
const bool FadeInFinished{original_fadeInTime==0||fadein==original_fadeInTime}; const bool FadeInFinished{original_fadeInTime==0||fadein==original_fadeInTime};
const bool HasFadeout{fadeout>0}; const bool HasFadeout{fadeout>0};
if(GetZ()>0){
vf2d shadowScale=vf2d{8*size.x/3.f,1}/std::max(1.f,GetZ()/8);
game->view.DrawDecal(pos-vf2d{3,3}*shadowScale/2+vf2d{0,12*size.y},GFX["circle.png"].Decal(),shadowScale,BLACK);
}
[[unlikely]]if(!FadeInFinished){ [[unlikely]]if(!FadeInFinished){
game->view.DrawPartialRotatedDecal(pos,GetFrame().GetSourceImage()->Decal(),rotation,GetFrame().GetSourceRect().size/2,GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,size,{col.r,col.g,col.b,uint8_t(fadein/original_fadeInTime*col.a)}); game->view.DrawPartialRotatedDecal(pos-vf2d{0,GetZ()},GetFrame().GetSourceImage()->Decal(),rotation,GetFrame().GetSourceRect().size/2,GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,size,{col.r,col.g,col.b,uint8_t(fadein/original_fadeInTime*col.a)});
}else }else
[[likely]]if(HasFadeout){ [[likely]]if(HasFadeout){
game->view.DrawPartialRotatedDecal(pos,GetFrame().GetSourceImage()->Decal(),rotation,GetFrame().GetSourceRect().size/2,GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,size,{col.r,col.g,col.b,uint8_t(fadeout/original_fadeOutTime*col.a)}); game->view.DrawPartialRotatedDecal(pos-vf2d{0,GetZ()},GetFrame().GetSourceImage()->Decal(),rotation,GetFrame().GetSourceRect().size/2,GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,size,{col.r,col.g,col.b,uint8_t(fadeout/original_fadeOutTime*col.a)});
}else{ }else{
game->view.DrawPartialRotatedDecal(pos,GetFrame().GetSourceImage()->Decal(),rotation,GetFrame().GetSourceRect().size/2,GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,size,col); game->view.DrawPartialRotatedDecal(pos-vf2d{0,GetZ()},GetFrame().GetSourceImage()->Decal(),rotation,GetFrame().GetSourceRect().size/2,GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,size,col);
} }
game->SetDecalMode(DecalMode::NORMAL); game->SetDecalMode(DecalMode::NORMAL);
} }
@ -106,3 +112,7 @@ bool Effect::OnUpperLevel(){
const EffectType Effect::GetType()const{ const EffectType Effect::GetType()const{
return type; return type;
} }
const float Effect::GetZ()const{
return z;
}

@ -62,6 +62,7 @@ struct Effect{
float rotationSpd=0; float rotationSpd=0;
vf2d scaleSpd{}; vf2d scaleSpd{};
bool additiveBlending=false; bool additiveBlending=false;
float z{};
private: private:
bool dead=false; bool dead=false;
public: public:
@ -73,6 +74,7 @@ public:
virtual void Draw()const; virtual void Draw()const;
bool OnUpperLevel(); bool OnUpperLevel();
const EffectType GetType()const; const EffectType GetType()const;
const float GetZ()const;
protected: protected:
float original_fadeOutTime; float original_fadeOutTime;
float original_fadeInTime{}; float original_fadeInTime{};
@ -142,3 +144,20 @@ private:
float fadeinTime; float fadeinTime;
const Pixel originalCol; const Pixel originalCol;
}; };
//Spawns and moves towards the player after some amount of time.
struct MonsterSoul:Effect{
MonsterSoul(vf2d pos,float fadeoutTime,float size,vf2d spd,Pixel col,float rotation,float rotationSpd,bool additiveBlending=false);
virtual bool Update(float fElapsedTime)override final;
virtual void Draw()const override final;
public:
enum Phase{
RISING,
TRACKING_PLAYER,
DEAD,
};
uint8_t alpha{0U};
Phase phase{RISING};
float moveSpd{24.f};
float fadeoutTime;
};

@ -1001,6 +1001,8 @@ void Monster::OnDeath(){
if(strategyDeathFunc)GameEvent::AddEvent(std::make_unique<MonsterStrategyGameEvent>(strategyDeathFunc,*this,MONSTER_DATA[name].GetAIStrategy())); if(strategyDeathFunc)GameEvent::AddEvent(std::make_unique<MonsterStrategyGameEvent>(strategyDeathFunc,*this,MONSTER_DATA[name].GetAIStrategy()));
if(game->GetPlayer()->HasEnchant("Reaper of Souls"))game->AddEffect(std::make_unique<MonsterSoul>(GetPos(),0.3f,GetSizeMult(),vf2d{},WHITE,0.f,0.f,false));
SpawnDrops(); SpawnDrops();
game->GetPlayer()->AddAccumulatedXP(MONSTER_DATA.at(name).GetXP()); game->GetPlayer()->AddAccumulatedXP(MONSTER_DATA.at(name).GetXP());

@ -0,0 +1,89 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions or derivations of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice. This list of conditions and the following disclaimer must be
reproduced in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2024 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#include "Effect.h"
#include "util.h"
#include "AdventuresinLestoria.h"
#include "SoundEffect.h"
INCLUDE_game
INCLUDE_GFX
MonsterSoul::MonsterSoul(vf2d pos,float fadeoutTime,float size,vf2d spd,Pixel col,float rotation,float rotationSpd,bool additiveBlending)
:Effect(pos,INFINITE,"monstersoul.png",OnUpperLevel(),size,fadeoutTime,spd,col,rotation,rotationSpd,additiveBlending),fadeoutTime(fadeoutTime){}
bool MonsterSoul::Update(float fElapsedTime){
bool updateResult{Effect::Update(fElapsedTime)};
switch(phase){
case RISING:{
if(GetZ()<10.f){
z+=10.f*fElapsedTime;
alpha=uint8_t(util::lerp(0,255,z/10.f));
}else{
phase=TRACKING_PLAYER;
alpha=255;
}
}break;
case TRACKING_PLAYER:{
z=util::lerp(7,13,abs(sin(3*PI*lifetime)));
moveSpd+=48.f*fElapsedTime;
vf2d projectedPos{pos+util::pointTo(pos,game->GetPlayer()->GetPos())*moveSpd*fElapsedTime};
geom2d::line<float>collisionLine{pos,projectedPos};
pos=projectedPos;
if(geom2d::overlaps(collisionLine,geom2d::circle<float>(game->GetPlayer()->GetPos(),game->GetPlayer()->GetSizeMult()*8.f))){
lifetime=0.f;
fadeout=fadeoutTime;
game->GetPlayer()->Heal("Reaper of Souls"_ENC["HEALTH GAIN"]);
game->GetPlayer()->RestoreMana("Reaper of Souls"_ENC["MANA GAIN"]);
game->GetPlayer()->GetRightClickAbility().cooldown-="Reaper of Souls"_ENC["COOLDOWN REDUCTION"];
game->GetPlayer()->GetAbility1().cooldown-="Reaper of Souls"_ENC["COOLDOWN REDUCTION"];
game->GetPlayer()->GetAbility2().cooldown-="Reaper of Souls"_ENC["COOLDOWN REDUCTION"];
game->GetPlayer()->GetAbility3().cooldown-="Reaper of Souls"_ENC["COOLDOWN REDUCTION"];
game->GetPlayer()->GetAbility4().cooldown-="Reaper of Souls"_ENC["COOLDOWN REDUCTION"];
SoundEffect::PlaySFX("Collect Soul",pos);
phase=DEAD;
}
}break;
}
return updateResult;
}
void MonsterSoul::Draw()const{
game->SetDecalMode(DecalMode::ADDITIVE);
game->view.DrawRotatedDecal(pos-vf2d{0,GetZ()},GFX["monstersoulglow.png"].Decal(),0.f,GFX["monstersoulglow.png"].Sprite()->Size()/2,size*util::lerp(0.6f,1.4f,abs(sin(2*PI*lifetime))));
game->SetDecalMode(DecalMode::NORMAL);
Effect::Draw();
}

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 3 #define VERSION_PATCH 3
#define VERSION_BUILD 10670 #define VERSION_BUILD 10683
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -66,6 +66,11 @@ Events
# Specify file names, followed by volume %. Optional min and max pitch adjustment (Defaults are 90%,110%) # Specify file names, followed by volume %. Optional min and max pitch adjustment (Defaults are 90%,110%)
File[0] = chargeup.ogg, 70% File[0] = chargeup.ogg, 70%
} }
Collect Soul
{
# Specify file names, followed by volume %. Optional min and max pitch adjustment (Defaults are 90%,110%)
File[0] = collect_soul.ogg, 100%
}
Consume Potion Consume Potion
{ {
# Specify file names, followed by volume %. Optional min and max pitch adjustment (Defaults are 90%,110%) # Specify file names, followed by volume %. Optional min and max pitch adjustment (Defaults are 90%,110%)

@ -118,6 +118,8 @@ Images
GFX_PoisonPool = poison_pool.png GFX_PoisonPool = poison_pool.png
GFX_PoisonBottle = poison_bottle.png GFX_PoisonBottle = poison_bottle.png
GFX_Fragment = items/Fragment.png GFX_Fragment = items/Fragment.png
GFX_MonsterSoul = monstersoul.png
GFX_MonsterSoulGlow = monstersoulglow.png
GFX_Thief_Sheet = nico-thief.png GFX_Thief_Sheet = nico-thief.png
GFX_Trapper_Sheet = nico-trapper.png GFX_Trapper_Sheet = nico-trapper.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

@ -646,7 +646,7 @@ void olc::ViewPort::DrawStringDecal(const olc::vf2d& pos, std::string_view sText
const bool RerenderRequired=pge->garbageCollector.count(key)&&pge->garbageCollector[key].originalStr!=renderStr; const bool RerenderRequired=pge->garbageCollector.count(key)&&pge->garbageCollector[key].originalStr!=renderStr;
const bool ShadowRerenderRequired=pge->garbageCollector.count(key+"_SHADOW")&&pge->garbageCollector[key+"_SHADOW"].originalStr!=renderStr; const bool ShadowRerenderRequired=pge->garbageCollector.count(key+"_SHADOW")&&pge->garbageCollector[key+"_SHADOW"].originalStr!=renderStr;
if(!pge->garbageCollector.count(key)||RerenderRequired){ //If the text key already exists, don't have to recreate the decal, just update the expire time. if(!pge->garbageCollector.count(key)||RerenderRequired){ //If the text key already exists, don't have to recreate the decal, just update the expire time.
vi2d imageSize=pge->GetWrappedTextSize(originalKey,width,scale); vf2d imageSize=pge->GetWrappedTextSize(originalKey,width,scale);
if(imageSize.x<1||imageSize.y<1)return; if(imageSize.x<1||imageSize.y<1)return;
Decal*newDecal=nullptr; Decal*newDecal=nullptr;
if(!RerenderRequired){ if(!RerenderRequired){
@ -694,7 +694,7 @@ void olc::ViewPort::DrawStringPropDecal(const olc::vf2d& pos, std::string_view s
const bool RerenderRequired=pge->garbageCollector.count(key)&&pge->garbageCollector[key].originalStr!=renderStr; const bool RerenderRequired=pge->garbageCollector.count(key)&&pge->garbageCollector[key].originalStr!=renderStr;
const bool ShadowRerenderRequired=pge->garbageCollector.count(key+"_SHADOW")&&pge->garbageCollector[key+"_SHADOW"].originalStr!=renderStr; const bool ShadowRerenderRequired=pge->garbageCollector.count(key+"_SHADOW")&&pge->garbageCollector[key+"_SHADOW"].originalStr!=renderStr;
if(!pge->garbageCollector.count(key)||RerenderRequired){ //If the text key already exists, don't have to recreate the decal, just update the expire time. if(!pge->garbageCollector.count(key)||RerenderRequired){ //If the text key already exists, don't have to recreate the decal, just update the expire time.
vi2d imageSize=pge->GetWrappedTextSizeProp(originalKey,width,scale); vf2d imageSize=pge->GetWrappedTextSizeProp(originalKey,width,scale);
if(imageSize.x<1||imageSize.y<1)return; if(imageSize.x<1||imageSize.y<1)return;
Decal*newDecal=nullptr; Decal*newDecal=nullptr;
if(!RerenderRequired){ if(!RerenderRequired){
@ -726,7 +726,7 @@ void olc::ViewPort::DrawShadowStringDecal(const olc::vf2d& pos, std::string_view
const bool RerenderRequired=pge->garbageCollector.count(key)&&pge->garbageCollector[key].originalStr!=renderStr; const bool RerenderRequired=pge->garbageCollector.count(key)&&pge->garbageCollector[key].originalStr!=renderStr;
const bool ShadowRerenderRequired=pge->garbageCollector.count(key+"_SHADOW")&&pge->garbageCollector[key+"_SHADOW"].originalStr!=renderStr; const bool ShadowRerenderRequired=pge->garbageCollector.count(key+"_SHADOW")&&pge->garbageCollector[key+"_SHADOW"].originalStr!=renderStr;
if(!pge->garbageCollector.count(key)||RerenderRequired){ //If the text key already exists, don't have to recreate the decal, just update the expire time. if(!pge->garbageCollector.count(key)||RerenderRequired){ //If the text key already exists, don't have to recreate the decal, just update the expire time.
vi2d imageSize=pge->GetWrappedTextSize(originalKey,width,scale); vf2d imageSize=pge->GetWrappedTextSize(originalKey,width,scale);
if(imageSize.x<1||imageSize.y<1)return; if(imageSize.x<1||imageSize.y<1)return;
Decal*newDecal=nullptr; Decal*newDecal=nullptr;
if(!RerenderRequired){ if(!RerenderRequired){
@ -778,7 +778,7 @@ void olc::ViewPort::DrawShadowStringPropDecal(const olc::vf2d& pos, std::string_
const bool RerenderRequired=pge->garbageCollector.count(key)&&pge->garbageCollector[key].originalStr!=renderStr; const bool RerenderRequired=pge->garbageCollector.count(key)&&pge->garbageCollector[key].originalStr!=renderStr;
const bool ShadowRerenderRequired=pge->garbageCollector.count(key+"_SHADOW")&&pge->garbageCollector[key+"_SHADOW"].originalStr!=renderStr; const bool ShadowRerenderRequired=pge->garbageCollector.count(key+"_SHADOW")&&pge->garbageCollector[key+"_SHADOW"].originalStr!=renderStr;
if(!pge->garbageCollector.count(key)||RerenderRequired){ //If the text key already exists, don't have to recreate the decal, just update the expire time. if(!pge->garbageCollector.count(key)||RerenderRequired){ //If the text key already exists, don't have to recreate the decal, just update the expire time.
vi2d imageSize=pge->GetWrappedTextSizeProp(originalKey,width,scale); vf2d imageSize=pge->GetWrappedTextSizeProp(originalKey,width,scale);
if(imageSize.x<1||imageSize.y<1)return; if(imageSize.x<1||imageSize.y<1)return;
Decal*newDecal=nullptr; Decal*newDecal=nullptr;
if(!RerenderRequired){ if(!RerenderRequired){

@ -1120,8 +1120,8 @@ namespace olc
void DrawShadowStringProp(const olc::vi2d& pos, std::string_view sText, Pixel col = olc::WHITE, const Pixel shadowCol = olc::BLACK, const olc::vf2d& scale = { 1.0f, 1.0f },const float width=std::numeric_limits<float>::max(),const float shadowSizeFactor=1); void DrawShadowStringProp(const olc::vi2d& pos, std::string_view sText, Pixel col = olc::WHITE, const Pixel shadowCol = olc::BLACK, const olc::vf2d& scale = { 1.0f, 1.0f },const float width=std::numeric_limits<float>::max(),const float shadowSizeFactor=1);
olc::vi2d GetTextSize(std::string_view s); olc::vi2d GetTextSize(std::string_view s);
olc::vi2d GetTextSizeProp(std::string_view s); olc::vi2d GetTextSizeProp(std::string_view s);
olc::vi2d GetWrappedTextSize(std::string_view s,const float width=std::numeric_limits<int>::max(),const vf2d scale={1,1}); olc::vf2d GetWrappedTextSize(std::string_view s,const float width=std::numeric_limits<int>::max(),const vf2d scale={1,1});
olc::vi2d GetWrappedTextSizeProp(std::string_view s,const float width=std::numeric_limits<int>::max(),const vf2d scale={1,1}); olc::vf2d GetWrappedTextSizeProp(std::string_view s,const float width=std::numeric_limits<int>::max(),const vf2d scale={1,1});
void DrawString(const olc::vi2d& pos, std::string_view sText, Pixel col = olc::WHITE, uint32_t scale = 1,const float width=std::numeric_limits<float>::max(),const bool colorOverride=false); void DrawString(const olc::vi2d& pos, std::string_view sText, Pixel col = olc::WHITE, uint32_t scale = 1,const float width=std::numeric_limits<float>::max(),const bool colorOverride=false);
void DrawString(int32_t x, int32_t y, std::string_view sText, Pixel col = olc::WHITE, uint32_t scale = 1,const float width=std::numeric_limits<float>::max(),const bool colorOverride=false); void DrawString(int32_t x, int32_t y, std::string_view sText, Pixel col = olc::WHITE, uint32_t scale = 1,const float width=std::numeric_limits<float>::max(),const bool colorOverride=false);
@ -3495,7 +3495,7 @@ namespace olc
} }
const bool RerenderRequired=garbageCollector.count(key)&&garbageCollector[key].originalStr!=renderStr; const bool RerenderRequired=garbageCollector.count(key)&&garbageCollector[key].originalStr!=renderStr;
if(!garbageCollector.count(key)||RerenderRequired){ //If the text key already exists, don't have to recreate the decal, just update the expire time. if(!garbageCollector.count(key)||RerenderRequired){ //If the text key already exists, don't have to recreate the decal, just update the expire time.
vi2d imageSize=GetWrappedTextSize(originalKey,width,scale); vf2d imageSize=GetWrappedTextSize(originalKey,width,scale);
if(imageSize.x<1||imageSize.y<1)return; if(imageSize.x<1||imageSize.y<1)return;
Decal*newDecal=nullptr; Decal*newDecal=nullptr;
if(!RerenderRequired){ if(!RerenderRequired){
@ -3527,7 +3527,7 @@ namespace olc
} }
const bool RerenderRequired=garbageCollector.count(key)&&garbageCollector[key].originalStr!=renderStr; const bool RerenderRequired=garbageCollector.count(key)&&garbageCollector[key].originalStr!=renderStr;
if(!garbageCollector.count(key)||RerenderRequired){ //If the text key already exists, don't have to recreate the decal, just update the expire time. if(!garbageCollector.count(key)||RerenderRequired){ //If the text key already exists, don't have to recreate the decal, just update the expire time.
vi2d imageSize=GetWrappedTextSizeProp(originalKey,width,scale); vf2d imageSize=GetWrappedTextSizeProp(originalKey,width,scale);
if(imageSize.x<1||imageSize.y<1)return; if(imageSize.x<1||imageSize.y<1)return;
Decal*newDecal=nullptr; Decal*newDecal=nullptr;
if(!RerenderRequired){ if(!RerenderRequired){
@ -3559,7 +3559,7 @@ namespace olc
const bool RerenderRequired=garbageCollector.count(key)&&garbageCollector[key].originalStr!=renderStr; const bool RerenderRequired=garbageCollector.count(key)&&garbageCollector[key].originalStr!=renderStr;
const bool ShadowRerenderRequired=garbageCollector.count(key+"_SHADOW")&&garbageCollector[key+"_SHADOW"].originalStr!=renderStr; const bool ShadowRerenderRequired=garbageCollector.count(key+"_SHADOW")&&garbageCollector[key+"_SHADOW"].originalStr!=renderStr;
if(!garbageCollector.count(key)||RerenderRequired){ //If the text key already exists, don't have to recreate the decal, just update the expire time. if(!garbageCollector.count(key)||RerenderRequired){ //If the text key already exists, don't have to recreate the decal, just update the expire time.
vi2d imageSize=GetWrappedTextSize(originalKey,width,scale); vf2d imageSize=GetWrappedTextSize(originalKey,width,scale);
if(imageSize.x<1||imageSize.y<1)return; if(imageSize.x<1||imageSize.y<1)return;
Decal*newDecal=nullptr; Decal*newDecal=nullptr;
if(!RerenderRequired){ if(!RerenderRequired){
@ -3669,7 +3669,7 @@ namespace olc
const bool RerenderRequired=garbageCollector.count(key)&&garbageCollector[key].originalStr!=renderStr; const bool RerenderRequired=garbageCollector.count(key)&&garbageCollector[key].originalStr!=renderStr;
const bool ShadowRerenderRequired=garbageCollector.count(key+"_SHADOW")&&garbageCollector[key+"_SHADOW"].originalStr!=renderStr; const bool ShadowRerenderRequired=garbageCollector.count(key+"_SHADOW")&&garbageCollector[key+"_SHADOW"].originalStr!=renderStr;
if(!garbageCollector.count(key)||RerenderRequired){ //If the text key already exists, don't have to recreate the decal, just update the expire time. if(!garbageCollector.count(key)||RerenderRequired){ //If the text key already exists, don't have to recreate the decal, just update the expire time.
vi2d imageSize=GetWrappedTextSizeProp(originalKey,width,scale); vf2d imageSize=GetWrappedTextSizeProp(originalKey,width,scale);
if(imageSize.x<1||imageSize.y<1)return; if(imageSize.x<1||imageSize.y<1)return;
Decal*newDecal=nullptr; Decal*newDecal=nullptr;
if(!RerenderRequired){ if(!RerenderRequired){
@ -3799,7 +3799,7 @@ namespace olc
DrawRotatedStringPropDecal(pos, sText,fAngle,center,col,scale); DrawRotatedStringPropDecal(pos, sText,fAngle,center,col,scale);
} }
olc::vi2d PixelGameEngine::GetWrappedTextSize(std::string_view s,const float width,const vf2d scale) olc::vf2d PixelGameEngine::GetWrappedTextSize(std::string_view s,const float width,const vf2d scale)
{ {
float adjustedWidth=width; float adjustedWidth=width;
if(width!=std::numeric_limits<float>::max()){ if(width!=std::numeric_limits<float>::max()){
@ -3877,7 +3877,7 @@ namespace olc
} }
drawingMarker.x += lettersWidth; drawingMarker.x += lettersWidth;
maxWidth=std::max(maxWidth,drawingMarker.x); maxWidth=std::max(maxWidth,drawingMarker.x);
return vi2d(vf2d{maxWidth,planningMarker.y+8}*scale); return vf2d{maxWidth,planningMarker.y+8}*scale;
} }
olc::vi2d PixelGameEngine::GetTextSize(std::string_view s) olc::vi2d PixelGameEngine::GetTextSize(std::string_view s)
@ -4060,7 +4060,7 @@ namespace olc
return size; return size;
} }
olc::vi2d PixelGameEngine::GetWrappedTextSizeProp(std::string_view s,const float width,const vf2d scale) olc::vf2d PixelGameEngine::GetWrappedTextSizeProp(std::string_view s,const float width,const vf2d scale)
{ {
float adjustedWidth=width; float adjustedWidth=width;
if(width!=std::numeric_limits<float>::max()){ if(width!=std::numeric_limits<float>::max()){
@ -4138,7 +4138,7 @@ namespace olc
} }
drawingMarker.x += lettersWidth; drawingMarker.x += lettersWidth;
maxWidth=std::max(maxWidth,drawingMarker.x); maxWidth=std::max(maxWidth,drawingMarker.x);
return vi2d(vf2d{maxWidth,planningMarker.y+8}*scale); return vf2d{maxWidth,planningMarker.y+8}*scale;
} }
void PixelGameEngine::DrawStringProp(const olc::vi2d& pos, std::string_view sText, Pixel col, uint32_t scale,const float width,const bool colorOverride) void PixelGameEngine::DrawStringProp(const olc::vi2d& pos, std::string_view sText, Pixel col, uint32_t scale,const float width,const bool colorOverride)

Loading…
Cancel
Save