The open source repository for the action RPG game in development by Sig Productions titled 'Adventures in Lestoria'! https://forums.lestoria.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AdventuresInLestoria/Crawler/EncountersSpawnListScrollab...

39 lines
1.5 KiB

#pragma once
#include "State_OverworldMap.h"
#include "Menu.h"
#include "SpawnEncounterLabel.h"
#include "Crawler.h"
#include "ScrollableWindowComponent.h"
#include "DEFINES.h"
#include "Error.h"
INCLUDE_MONSTER_DATA
INCLUDE_LEVEL_NAMES
class EncountersSpawnListScrollableWindowComponent:public ScrollableWindowComponent{
protected:
public:
inline EncountersSpawnListScrollableWindowComponent(MenuType parent,geom2d::rect<float>rect,ComponentAttr attributes=ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE)
:ScrollableWindowComponent(parent,rect,attributes){}
virtual inline void UpdateSpawns(std::vector<int>&spawns){
Menu::menus.at(parentMenu)->components.erase_if([&](auto key){
if(key.first.starts_with("Spawn ")){
std::erase_if(components,[&](MenuComponent*component){return key.second==component;});
delete key.second;
return true;
}
return false;});
int offsetY=0;
vf2d parentPos=Menu::menus.at(OVERWORLD_LEVEL_SELECT)->pos;
vf2d parentSize=Menu::menus.at(OVERWORLD_LEVEL_SELECT)->size;
for(int spawn:spawns){
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;
}
}
protected:
virtual inline void Cleanup()override{
}
};