diff --git a/Crawler/CharacterAbilityPreviewComponent.h b/Crawler/CharacterAbilityPreviewComponent.h index 80b7388f..df4bad92 100644 --- a/Crawler/CharacterAbilityPreviewComponent.h +++ b/Crawler/CharacterAbilityPreviewComponent.h @@ -55,13 +55,21 @@ protected: MenuLabel::Update(game); } virtual void inline DrawDecal(ViewPort&window,vf2d parentPos,bool focused)override{ + MenuLabel::DrawDecal(window,parentPos,focused); vi2d iconPos=parentPos+rect.pos+vi2d{5,5}; - vi2d textPos=iconPos+vi2d{12,12}; + vi2d textPos=iconPos; float textWidth=game->GetTextSizeProp(ability->input->GetDisplayName()).x*0.5f+4; float boxWidth=rect.size.y-4; //No, the y is not a typo. It's a square, we use the y to determine the x. + window.DrawRectDecal(parentPos+rect.pos+vi2d{2,2},vi2d{int(rect.size.y)-4,int(rect.size.y)-4}); + window.DrawDecal(iconPos,GFX[ability->icon].Decal()); + + vi2d descriptionPos=iconPos+vi2d{int(rect.size.y)-2,-1}; + + window.DrawShadowStringPropDecal(descriptionPos,util::WrapText(game,ability->description,int(rect.size.x-(descriptionPos.x-rect.pos.x)),true,{0.8f,1.0f}),WHITE,BLACK,{0.8f,1.f}); + if(textWidth>boxWidth){ window.DrawShadowStringPropDecal(textPos,ability->input->GetDisplayName(),WHITE,BLACK,{boxWidth/textWidth*0.5f,0.5}); }else{ diff --git a/Crawler/CharacterRotatingDisplay.h b/Crawler/CharacterRotatingDisplay.h index eaed9816..44e5c2ec 100644 --- a/Crawler/CharacterRotatingDisplay.h +++ b/Crawler/CharacterRotatingDisplay.h @@ -64,10 +64,10 @@ protected: } virtual inline void DrawDecal(ViewPort&window,vf2d parentPos,bool focused)override{ window.DrawWarpedDecal(icon,std::array{ - Menu::menus[parentMenu]->pos+rect.pos+vf2d{abs(sin(timer)),sin(float(timer+PI))}*vf2d{rotatingFactor,perspectiveFactor}, - Menu::menus[parentMenu]->pos+rect.pos+vf2d{0,rect.size.y}+vf2d{abs(sin(timer)),sin(timer)}*vf2d{rotatingFactor,perspectiveFactor}, - Menu::menus[parentMenu]->pos+rect.pos+rect.size+vf2d{-abs(sin(float(timer+PI))),sin(float(timer+PI))}*vf2d{rotatingFactor,perspectiveFactor}, - Menu::menus[parentMenu]->pos+rect.pos+vf2d{rect.size.x,0}+vf2d{-abs(sin(float(timer+PI))),sin(timer)}*vf2d{rotatingFactor,perspectiveFactor}, + rect.pos+vf2d{abs(sin(timer)),sin(float(timer+PI))}*vf2d{rotatingFactor,perspectiveFactor}, + rect.pos+vf2d{0,rect.size.y}+vf2d{abs(sin(timer)),sin(timer)}*vf2d{rotatingFactor,perspectiveFactor}, + rect.pos+rect.size+vf2d{-abs(sin(float(timer+PI))),sin(float(timer+PI))}*vf2d{rotatingFactor,perspectiveFactor}, + rect.pos+vf2d{rect.size.x,0}+vf2d{-abs(sin(float(timer+PI))),sin(timer)}*vf2d{rotatingFactor,perspectiveFactor}, }); } }; \ No newline at end of file diff --git a/Crawler/Crawler.vcxproj b/Crawler/Crawler.vcxproj index 896a2b93..47101f4e 100644 --- a/Crawler/Crawler.vcxproj +++ b/Crawler/Crawler.vcxproj @@ -154,12 +154,14 @@ true stdcpp20 /MP8 %(AdditionalOptions) + C:\Users\sigon\Documents\include; Console true true true + freetype.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File update_version.ps1 "./version.h" @@ -175,12 +177,14 @@ true stdcpp20 /MP8 %(AdditionalOptions) + C:\Users\sigon\Documents\include; Console true true true + freetype.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File update_version.ps1 "./version.h" @@ -220,12 +224,14 @@ true stdcpp20 /MP8 %(AdditionalOptions) + C:\Users\sigon\Documents\include; Console true true true + freetype.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File update_version.ps1 "./version.h" @@ -244,12 +250,14 @@ true stdcpp20 /MP8 %(AdditionalOptions) + C:\Users\sigon\Documents\include; Console true true true + freetype.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File update_version.ps1 "./version.h" diff --git a/Crawler/MenuComponent.cpp b/Crawler/MenuComponent.cpp index db2d44ea..c368fe84 100644 --- a/Crawler/MenuComponent.cpp +++ b/Crawler/MenuComponent.cpp @@ -96,7 +96,6 @@ void MenuComponent::_Update(Crawler*game){ void MenuComponent::OnEquipStatsUpdate(){} void MenuComponent::DrawDecal(ViewPort&window,vf2d parentPos,bool focused){ - parentPos+=Menu::menus[parentMenu]->pos; if(background){ window.FillRectDecal(rect.pos+parentPos,rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),hoverEffect/"ThemeGlobal.HighlightTime"_F)); } @@ -104,10 +103,10 @@ void MenuComponent::DrawDecal(ViewPort&window,vf2d parentPos,bool focused){ window.FillRectDecal(rect.pos+parentPos,rect.size,PixelLerp(Menu::themes[Menu::themeSelection].GetButtonCol(),Menu::themes[Menu::themeSelection].GetHighlightCol(),util::lerp(0.75f,1.0f,hoverEffect/"ThemeGlobal.HighlightTime"_F))); } if(border){ - window.FillRectDecal(rect.pos+parentPos,{rect.size.x,1}); - window.FillRectDecal(rect.pos+parentPos,{1,rect.size.y}); - window.FillRectDecal(rect.pos+parentPos+vf2d{rect.size.x-1,0},{1,rect.size.y}); - window.FillRectDecal(rect.pos+parentPos+vf2d{0,rect.size.y-1},{rect.size.x,1}); + window.FillRectDecal(rect.pos+parentPos,{rect.size.x+1,1}); + window.FillRectDecal(rect.pos+parentPos,{1,rect.size.y+1}); + window.FillRectDecal(rect.pos+parentPos+vf2d{rect.size.x-1+1,0},{1,rect.size.y+1}); + window.FillRectDecal(rect.pos+parentPos+vf2d{0,rect.size.y-1+1},{rect.size.x+1,1}); } if(showDefaultLabel){ window.DrawStringPropDecal(rect.pos+parentPos+rect.size/2-vf2d(game->GetTextSizeProp(label))/2.f*labelScaling,label,WHITE,labelScaling); diff --git a/Crawler/MenuLabel.h b/Crawler/MenuLabel.h index 9e2959f7..ded2c3f2 100644 --- a/Crawler/MenuLabel.h +++ b/Crawler/MenuLabel.h @@ -66,7 +66,6 @@ protected: } virtual void inline DrawDecal(ViewPort&window,vf2d parentPos,bool focused)override{ MenuComponent::DrawDecal(window,parentPos,focused); - parentPos+=Menu::menus[parentMenu]->pos; std::string wrappedText=util::WrapText(game,label,int(rect.size.x),true,{float(scale),float(scale)}); vf2d drawPos=parentPos+rect.middle()-vf2d{game->GetTextSizeProp(wrappedText)}*float(scale)/2; //Assume centered. if(!centered){ diff --git a/Crawler/Version.h b/Crawler/Version.h index f02867db..0f7a266d 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 3881 +#define VERSION_BUILD 3909 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/olcPGEX_ViewPort.h b/Crawler/olcPGEX_ViewPort.h index f8f3c3c0..cbf7d721 100644 --- a/Crawler/olcPGEX_ViewPort.h +++ b/Crawler/olcPGEX_ViewPort.h @@ -2,6 +2,7 @@ #include "olcPixelGameEngine.h" #include "olcPGEX_TTF.h" +#include "olcUTIL_Geometry2D.h" #include #include @@ -9,6 +10,7 @@ #include #include #include +#include // Declarations namespace olc { @@ -16,6 +18,7 @@ namespace olc { public: ViewPort(); ViewPort(std::vector vertices, vf2d offset = {0, 0}); + geom2d::rectrect; virtual ~ViewPort(); void addPoint(vf2d point); void clear(); @@ -178,13 +181,15 @@ void olc::ViewPort::setOffset(vf2d offset) { olc::ViewPort olc::ViewPort::rectViewPort(vf2d topLeft, vf2d size, olc::vf2d offset) { - return {{ + olc::ViewPort newPort={{ topLeft, {topLeft.x, topLeft.y + size.y}, topLeft + size, {topLeft.x + size.x, topLeft.y}, }, offset}; + newPort.rect={topLeft,size}; + return newPort; } void olc::ViewPort::DrawDecal(const olc::vf2d &pos, @@ -527,6 +532,15 @@ void olc::ViewPort::drawClippedDecal(Decal *decal, std::vector outputWs{ws, ws + elements}; std::vector outputCols{col, col + elements}; + vf2d min={std::numeric_limits::max(),std::numeric_limits::max()},max; + bool pointsOutside=false; + for(vf2d&points:outputList){ + if(!geom2d::contains(rect,points)){ + pointsOutside=true; + break; + } + } + if(!pointsOutside)goto render; for (auto i = 0u; i < clipVertices.size(); i++) { auto clipA = clipVertices[i]; auto clipB = clipVertices[(i + 1) % 4]; @@ -585,6 +599,8 @@ void olc::ViewPort::drawClippedDecal(Decal *decal, return; } + render: + for (auto &point : outputList) { point += offset; } @@ -833,10 +849,10 @@ void olc::ViewPort::DrawDropShadowStringDecal(Font&font, const olc::vf2d& pos, c } void olc::ViewPort::DrawRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel col)const{ - FillRectDecal(pos,{size.x,float(pge->GetPixelSize().y)},col); - FillRectDecal(pos+vf2d{0,size.y-float(pge->GetPixelSize().y)},{size.x,float(pge->GetPixelSize().y)},col); - FillRectDecal(pos+vf2d{0,float(pge->GetPixelSize().y)},{float(pge->GetPixelSize().x),size.y-float(pge->GetPixelSize().y)*2},col); - FillRectDecal(pos+vf2d{size.x-float(pge->GetPixelSize().x),float(pge->GetPixelSize().y)},{float(pge->GetPixelSize().x),size.y-float(pge->GetPixelSize().y)*2},col); + FillRectDecal(pos,{size.x+1,1},col); + FillRectDecal(pos+vf2d{0,size.y-1+1},{size.x+1,1},col); + FillRectDecal(pos+vf2d{0,1},{1,size.y-1*2+1},col); + FillRectDecal(pos+vf2d{size.x-1+1,1},{1,size.y-1*2+1},col); } #endif \ No newline at end of file diff --git a/x64/Release/Crawler.exe b/x64/Release/Crawler.exe index 8503c1e4..c40dcc5c 100644 Binary files a/x64/Release/Crawler.exe and b/x64/Release/Crawler.exe differ