Class Info Screen completed.
This commit is contained in:
parent
3f78565655
commit
5d939e866f
46
Crawler/CharacterAbilityPreviewComponent.h
Normal file
46
Crawler/CharacterAbilityPreviewComponent.h
Normal file
@ -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::rect<float>rect,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});
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -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);
|
||||
}
|
||||
@ -264,6 +264,7 @@
|
||||
<ClInclude Include="Buff.h" />
|
||||
<ClInclude Include="Bullet.h" />
|
||||
<ClInclude Include="BulletTypes.h" />
|
||||
<ClInclude Include="CharacterAbilityPreviewComponent.h" />
|
||||
<ClInclude Include="CharacterRotatingDisplay.h" />
|
||||
<ClInclude Include="Class.h" />
|
||||
<ClInclude Include="ClassInfo.h" />
|
||||
|
||||
@ -201,6 +201,9 @@
|
||||
<ClInclude Include="ClassInfo.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CharacterAbilityPreviewComponent.h">
|
||||
<Filter>Header Files\Interface</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Player.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?"<<std::endl;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@ -43,6 +43,7 @@ public:
|
||||
void Draw(Crawler*game);
|
||||
static void InitializeMenus();
|
||||
static void OpenMenu(MenuType menu);
|
||||
static void CloseMenu();
|
||||
static std::vector<Menu*>stack;
|
||||
static std::string themeSelection;
|
||||
static safeunorderedmap<std::string,Theme>themes;
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user