Added custom encounter menu component and populated spawns in overworld menu.
This commit is contained in:
parent
88e01b8503
commit
4c6be02543
@ -304,6 +304,7 @@
|
||||
<ClInclude Include="safemap.h" />
|
||||
<ClInclude Include="ScrollableWindowComponent.h" />
|
||||
<ClInclude Include="InventoryScrollableWindowComponent.h" />
|
||||
<ClInclude Include="SpawnEncounterLabel.h" />
|
||||
<ClInclude Include="State.h" />
|
||||
<ClInclude Include="State_GameRun.h" />
|
||||
<ClInclude Include="State_MainMenu.h" />
|
||||
|
||||
@ -234,6 +234,9 @@
|
||||
<ClInclude Include="EncountersSpawnListScrollableWindowComponent.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SpawnEncounterLabel.h">
|
||||
<Filter>Header Files\Interface</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Player.cpp">
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "Menu.h"
|
||||
#include "MenuLabel.h"
|
||||
#include "SpawnEncounterLabel.h"
|
||||
#include "Crawler.h"
|
||||
#include "ScrollableWindowComponent.h"
|
||||
#include "DEFINES.h"
|
||||
@ -18,7 +18,7 @@ public:
|
||||
vf2d parentPos=Menu::menus.at(OVERWORLD_LEVEL_SELECT)->pos;
|
||||
vf2d parentSize=Menu::menus.at(OVERWORLD_LEVEL_SELECT)->size;
|
||||
for(int spawn:spawns){
|
||||
MenuLabel*spawnLabel=NEW MenuLabel(OVERWORLD_LEVEL_SELECT,{vf2d{0,float(offsetY)},{parentSize.x,12}},MONSTER_DATA.at(spawn-1).GetDisplayName());
|
||||
SpawnEncounterLabel*spawnLabel=NEW SpawnEncounterLabel(OVERWORLD_LEVEL_SELECT,{vf2d{0,float(offsetY)},{parentSize.x,12}},MONSTER_DATA.at(spawn-1).GetDisplayName(),spawn-1);
|
||||
AddComponent(Menu::menus.at(OVERWORLD_LEVEL_SELECT),"Spawn "+std::to_string(spawn),spawnLabel);
|
||||
offsetY+=14;
|
||||
}
|
||||
|
||||
45
Crawler/SpawnEncounterLabel.h
Normal file
45
Crawler/SpawnEncounterLabel.h
Normal file
@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
#include "MenuLabel.h"
|
||||
#include "DEFINES.h"
|
||||
#include "Crawler.h"
|
||||
#include "utils.h"
|
||||
|
||||
INCLUDE_game
|
||||
INCLUDE_MONSTER_DATA
|
||||
INCLUDE_ANIMATION_DATA
|
||||
|
||||
class SpawnEncounterLabel:public MenuLabel{
|
||||
int monsterID;
|
||||
Animate2D::Animation<std::string>anim;
|
||||
Animate2D::AnimationState state;
|
||||
public:
|
||||
inline SpawnEncounterLabel(MenuType parent,geom2d::rect<float>rect,std::string label,int monsterID)
|
||||
:MenuLabel(parent,rect,label),monsterID(monsterID){
|
||||
anim.AddState("IDLE",ANIMATION_DATA.at(MONSTER_DATA.at(monsterID).GetIdleAnimation()));
|
||||
anim.ChangeState(state,"IDLE");
|
||||
anim.UpdateState(state,util::random(1));
|
||||
}
|
||||
inline ~SpawnEncounterLabel(){
|
||||
|
||||
}
|
||||
protected:
|
||||
virtual void inline Update(Crawler*game)override{
|
||||
MenuComponent::Update(game);
|
||||
anim.UpdateState(state,game->GetElapsedTime());
|
||||
}
|
||||
virtual void inline Draw(Crawler*game,vf2d parentPos)override{
|
||||
|
||||
}
|
||||
virtual void inline DrawDecal(Crawler*game,vf2d parentPos,bool focused)override{
|
||||
const geom2d::rect<int>&imgRect=anim.GetFrame(state).GetSourceRect();
|
||||
vf2d imgSize=vf2d{rect.size.y,rect.size.y};
|
||||
vf2d imgScale=imgSize/vf2d{imgRect.size};
|
||||
game->DrawPartialDecal(parentPos+rect.pos,imgSize,anim.GetFrame(state).GetSourceImage()->Decal(),imgRect.pos,imgRect.size);
|
||||
float verticalAlignYOffset=(rect.size.y-8)/2;
|
||||
std::string monsterName=MONSTER_DATA.at(monsterID).GetDisplayName();
|
||||
vf2d monsterNameTextSize=game->GetTextSizeProp(monsterName);
|
||||
float textXSpaceAvailable=rect.size.x-imgSize.x-4-16/*12 for the scrollbar*/;
|
||||
float textXScaling=textXSpaceAvailable/monsterNameTextSize.x;
|
||||
game->DrawShadowStringPropDecal(parentPos+rect.pos+vf2d{imgSize.x+4,verticalAlignYOffset},monsterName,WHITE,BLACK,{std::min(1.f,textXScaling),1});
|
||||
}
|
||||
};
|
||||
@ -2,7 +2,7 @@
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 1
|
||||
#define VERSION_BUILD 2759
|
||||
#define VERSION_BUILD 2774
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user