From 5d939e866f7d7b47ee78870233c90dd97f2cb962 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sun, 22 Oct 2023 21:56:09 -0500 Subject: [PATCH] Class Info Screen completed. --- Crawler/CharacterAbilityPreviewComponent.h | 46 ++++++++++++++++++++++ Crawler/CharacterInfoWindow.cpp | 31 +++++++++++---- Crawler/Crawler.vcxproj | 1 + Crawler/Crawler.vcxproj.filters | 3 ++ Crawler/Menu.cpp | 9 +++++ Crawler/Menu.h | 1 + Crawler/Version.h | 2 +- 7 files changed, 84 insertions(+), 9 deletions(-) create mode 100644 Crawler/CharacterAbilityPreviewComponent.h diff --git a/Crawler/CharacterAbilityPreviewComponent.h b/Crawler/CharacterAbilityPreviewComponent.h new file mode 100644 index 00000000..1256c58a --- /dev/null +++ b/Crawler/CharacterAbilityPreviewComponent.h @@ -0,0 +1,46 @@ +#pragma once +#include "MenuLabel.h" +#include "DEFINES.h" +#include "Crawler.h" +#include "utils.h" +#include "Ability.h" + +INCLUDE_game +INCLUDE_GFX + +#define ICONPOS vi2d iconPos=parentPos+rect.pos+vi2d{5,5}; + +class CharacterAbilityPreviewComponent:public MenuLabel{ + Ability*ability; +public: + inline CharacterAbilityPreviewComponent(MenuType parent,geom2d::rectrect,Ability*ability) + :MenuLabel(parent,rect,"",1,true,false,true,true),ability(ability){} +protected: + virtual void inline Update(Crawler*game)override{ + MenuLabel::Update(game); + } + virtual void inline Draw(Crawler*game,vf2d parentPos,bool focused)override{ + MenuLabel::Draw(game,parentPos,focused); + game->DrawRect(parentPos+rect.pos+vi2d{2,2},vi2d{int(rect.size.y)-4,int(rect.size.y)-4}); + ICONPOS + game->DrawSprite(iconPos,GFX[ability->icon].Sprite()); + + vi2d descriptionPos=iconPos+vi2d{int(rect.size.y)-2,1}; + + game->DrawShadowStringProp(descriptionPos,util::WrapText(game,ability->description,rect.size.x-(descriptionPos.x-rect.pos.x),true,{1,1})); + } + virtual void inline DrawDecal(Crawler*game,vf2d parentPos,bool focused)override{ + ICONPOS + vi2d textPos=iconPos+vi2d{12,12}; + + float textWidth=game->GetTextSizeProp(ability->input->GetDisplayName()).x*0.5+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. + + if(textWidth>boxWidth){ + game->DrawShadowStringPropDecal(textPos,ability->input->GetDisplayName(),WHITE,BLACK,{boxWidth/textWidth*0.5f,0.5}); + }else{ + game->DrawShadowStringPropDecal(textPos,ability->input->GetDisplayName(),WHITE,BLACK,{0.5,0.5}); + } + } +}; \ No newline at end of file diff --git a/Crawler/CharacterInfoWindow.cpp b/Crawler/CharacterInfoWindow.cpp index afa4b2af..49b4fde5 100644 --- a/Crawler/CharacterInfoWindow.cpp +++ b/Crawler/CharacterInfoWindow.cpp @@ -2,9 +2,9 @@ #include "Crawler.h" #include "DEFINES.h" #include "Menu.h" -#include "MenuLabel.h" #include "CharacterRotatingDisplay.h" #include "ClassInfo.h" +#include "CharacterAbilityPreviewComponent.h" INCLUDE_game INCLUDE_GFX @@ -12,12 +12,12 @@ INCLUDE_DATA typedef Attribute A; void Menu::InitializeClassInfoWindow(){ - Menu*classInfoWindow=CreateMenu(CLASS_INFO,CENTERED,game->GetScreenSize()-vi2d{64,64}); + Menu*classInfoWindow=CreateMenu(CLASS_INFO,CENTERED,game->GetScreenSize()-vi2d{24,24}); Menu*classSelectionWindow=Menu::menus[CLASS_SELECTION]; ClassInfo data=classutils::GetClassInfo(classSelectionWindow->S(A::CLASS_SELECTION)); - MenuLabel*label=new MenuLabel(CLASS_INFO,{{0,8},{classInfoWindow->size.x-1,28}},data.className,2,true,true,true,true); + MenuLabel*label=new MenuLabel(CLASS_INFO,{{0,0},{classInfoWindow->size.x-1,24}},data.className,2,true,true,true,true); classInfoWindow->AddComponent("Class Name",label); @@ -25,16 +25,31 @@ void Menu::InitializeClassInfoWindow(){ classInfoWindow->AddComponent("Rotating Character Display",classDisplay); - vf2d baseStatsLabelPos={classInfoWindow->size.x/3,classInfoWindow->pos.y+20}; - vf2d labelSize={2*classInfoWindow->size.x/3,16}; + vf2d healthDisplayLabelPos={classInfoWindow->size.x/3,label->GetPos().y+24}; + vf2d labelSize={2*classInfoWindow->size.x/3-1,16}; - MenuLabel*baseStatsLabel=new MenuLabel(CLASS_INFO,{baseStatsLabelPos,labelSize},"Base Stats",1,true,true,true); - MenuLabel*healthDisplayLabel=new MenuLabel(CLASS_INFO,{baseStatsLabelPos+vf2d{0,16*1+8},labelSize},"Health: "+std::to_string(data.baseHealth)+" + "+std::to_string(data.healthGrowthRate).substr(0,3)+" per level",1,false,true,true); - MenuLabel*atkDisplayLabel=new MenuLabel(CLASS_INFO,{baseStatsLabelPos+vf2d{0,16*2+8},labelSize},"Attack: "+std::to_string(data.baseAtk)+" + "+std::to_string(data.atkGrowthRate).substr(0,3)+" per level",1,false,true,true); + MenuLabel*baseStatsLabel=new MenuLabel(CLASS_INFO,{{0,label->GetPos().y+24},{classInfoWindow->size.x/3,labelSize.y}},"Base Stats",1,true,true,true); + + MenuLabel*healthDisplayLabel=new MenuLabel(CLASS_INFO,{healthDisplayLabelPos+vf2d{0,16*0},labelSize},"Health: "+std::to_string(data.baseHealth)+" + "+std::to_string(data.healthGrowthRate).substr(0,3)+" per level",1,false,true,true); + MenuLabel*atkDisplayLabel=new MenuLabel(CLASS_INFO,{healthDisplayLabelPos+vf2d{0,16*1},labelSize},"Attack: "+std::to_string(data.baseAtk)+" + "+std::to_string(data.atkGrowthRate).substr(0,3)+" per level",1,false,true,true); classInfoWindow->AddComponent("Base Stats Text",baseStatsLabel); classInfoWindow->AddComponent("Health Display Text",healthDisplayLabel); classInfoWindow->AddComponent("Attack Display Text",atkDisplayLabel); + vf2d abilityIconOffsets = {0,32}; + CharacterAbilityPreviewComponent*ability1=new CharacterAbilityPreviewComponent(CLASS_INFO,{healthDisplayLabelPos+vf2d{0,32*0}+abilityIconOffsets,labelSize*vf2d{1,2}},data.ability1); + CharacterAbilityPreviewComponent*ability2=new CharacterAbilityPreviewComponent(CLASS_INFO,{healthDisplayLabelPos+vf2d{0,32*1}+abilityIconOffsets,labelSize*vf2d{1,2}},data.ability2); + CharacterAbilityPreviewComponent*ability3=new CharacterAbilityPreviewComponent(CLASS_INFO,{healthDisplayLabelPos+vf2d{0,32*2}+abilityIconOffsets,labelSize*vf2d{1,2}},data.ability3); + CharacterAbilityPreviewComponent*rightClickAbility=new CharacterAbilityPreviewComponent(CLASS_INFO,{healthDisplayLabelPos+vf2d{0,32*3}+abilityIconOffsets,labelSize*vf2d{1,2}},data.rightClickAbility); + + classInfoWindow->AddComponent("Ability 1 Display",ability1); + classInfoWindow->AddComponent("Ability 2 Display",ability2); + classInfoWindow->AddComponent("Ability 3 Display",ability3); + classInfoWindow->AddComponent("Right Click Ability Display",rightClickAbility); + + MenuComponent*backButton=new MenuComponent(CLASS_INFO,{{classInfoWindow->center().x/2,healthDisplayLabelPos.y+32*4+abilityIconOffsets.y+12},{classInfoWindow->size.x/2,16}},"Back",[](MenuFuncData data){Menu::CloseMenu();}); + + classInfoWindow->AddComponent("Back Button",backButton); } \ No newline at end of file diff --git a/Crawler/Crawler.vcxproj b/Crawler/Crawler.vcxproj index 8485afcf..352b7b62 100644 --- a/Crawler/Crawler.vcxproj +++ b/Crawler/Crawler.vcxproj @@ -264,6 +264,7 @@ + diff --git a/Crawler/Crawler.vcxproj.filters b/Crawler/Crawler.vcxproj.filters index 0b679bef..4114a6fc 100644 --- a/Crawler/Crawler.vcxproj.filters +++ b/Crawler/Crawler.vcxproj.filters @@ -201,6 +201,9 @@ Header Files + + Header Files\Interface + diff --git a/Crawler/Menu.cpp b/Crawler/Menu.cpp index 4a5901a8..d58ab5bf 100644 --- a/Crawler/Menu.cpp +++ b/Crawler/Menu.cpp @@ -589,4 +589,13 @@ void Menu::AddInventoryListener(MenuComponent*component,ITCategory category){ vf2d Menu::center(){ return size/2; +} + +void Menu::CloseMenu(){ + if(stack.size()>0){ + stack.pop_back(); + }else{ + std::cout<<"WARNING! Trying to close out no menu?? Why are we doing this?"<stack; static std::string themeSelection; static safeunorderedmapthemes; diff --git a/Crawler/Version.h b/Crawler/Version.h index 6afe01c7..c627e79a 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 2258 +#define VERSION_BUILD 2306 #define stringify(a) stringify_(a) #define stringify_(a) #a