Render the spawn list and stage name/chapter name in level select.

pull/28/head
sigonasr2 1 year ago
parent bc07f58c9a
commit 88e01b8503
  1. 6
      Crawler/ConnectionPoint.h
  2. 14
      Crawler/Crawler.cpp
  3. 1
      Crawler/Crawler.vcxproj
  4. 3
      Crawler/Crawler.vcxproj.filters
  5. 30
      Crawler/EncountersSpawnListScrollableWindowComponent.h
  6. 2
      Crawler/Map.cpp
  7. 2
      Crawler/Menu.h
  8. 6
      Crawler/OverworldMapLevelWindow.cpp
  9. 6
      Crawler/ScrollableWindowComponent.h
  10. 7
      Crawler/State_OverworldMap.cpp
  11. 2
      Crawler/TMXParser.h
  12. 2
      Crawler/Version.h
  13. 2
      Crawler/assets/Campaigns/World_Map.tmx

@ -7,8 +7,10 @@ struct ConnectionPoint{
std::string map; std::string map;
std::string unlockCondition; std::string unlockCondition;
std::array<int,8>neighbors; //Indices into the connectionPoint array. std::array<int,8>neighbors; //Indices into the connectionPoint array.
inline ConnectionPoint(geom2d::rect<float>rect,std::string name,std::string map,std::string unlockCondition) std::vector<int>spawns;
:rect(rect),name(name),map(map),unlockCondition(unlockCondition){ bool levelDataExists=false;
inline ConnectionPoint(geom2d::rect<float>rect,std::string name,std::string map,std::string unlockCondition,std::vector<int>spawns)
:rect(rect),name(name),map(map),unlockCondition(unlockCondition),spawns(spawns){
neighbors.fill(-1); neighbors.fill(-1);
} }
bool IsNeighbor(ConnectionPoint&testPoint); bool IsNeighbor(ConnectionPoint&testPoint);

@ -1212,6 +1212,16 @@ void Crawler::InitializeLevel(std::string mapFile,MapName map){
std::cout<<" Clearing Layer Data..."<<std::endl; std::cout<<" Clearing Layer Data..."<<std::endl;
MAP_DATA[map].LayerData.clear(); MAP_DATA[map].LayerData.clear();
} }
for(ConnectionPoint&cp:State_OverworldMap::connections){
if(LEVEL_NAMES.count(cp.map)&&&MapHelper::MapFromString(cp.map)==&MAP_DATA[map]){
for(int spawn:MAP_DATA[map].spawns){
cp.spawns.push_back(spawn);
}
cp.levelDataExists=true;
break;
}
}
} }
void Crawler::LoadLevel(MapName map){ void Crawler::LoadLevel(MapName map){
@ -1674,8 +1684,8 @@ bool Crawler::OnUserDestroy(){
void Crawler::InitializeLevels(){ void Crawler::InitializeLevels(){
#define INITLEVEL(map) \ #define INITLEVEL(map) \
InitializeLevel("map_path"_S + "Levels."#map ## _S,map); \ LEVEL_NAMES[#map]=map; \
LEVEL_NAMES[#map]=map; InitializeLevel("map_path"_S + "Levels."#map ## _S,map);
INITLEVEL(WORLD_MAP); INITLEVEL(WORLD_MAP);
INITLEVEL(CAMPAIGN_1_1); INITLEVEL(CAMPAIGN_1_1);

@ -275,6 +275,7 @@
<ClInclude Include="DEFINES.h" /> <ClInclude Include="DEFINES.h" />
<ClInclude Include="Effect.h" /> <ClInclude Include="Effect.h" />
<ClInclude Include="Emitter.h" /> <ClInclude Include="Emitter.h" />
<ClInclude Include="EncountersSpawnListScrollableWindowComponent.h" />
<ClInclude Include="Error.h" /> <ClInclude Include="Error.h" />
<ClInclude Include="GameState.h" /> <ClInclude Include="GameState.h" />
<ClInclude Include="Item.h" /> <ClInclude Include="Item.h" />

@ -231,6 +231,9 @@
<ClInclude Include="Ability.h"> <ClInclude Include="Ability.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="EncountersSpawnListScrollableWindowComponent.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Player.cpp"> <ClCompile Include="Player.cpp">

@ -0,0 +1,30 @@
#pragma once
#include "Menu.h"
#include "MenuLabel.h"
#include "Crawler.h"
#include "ScrollableWindowComponent.h"
#include "DEFINES.h"
#include "Error.h"
INCLUDE_MONSTER_DATA
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){
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){
MenuLabel*spawnLabel=NEW MenuLabel(OVERWORLD_LEVEL_SELECT,{vf2d{0,float(offsetY)},{parentSize.x,12}},MONSTER_DATA.at(spawn-1).GetDisplayName());
AddComponent(Menu::menus.at(OVERWORLD_LEVEL_SELECT),"Spawn "+std::to_string(spawn),spawnLabel);
offsetY+=14;
}
}
protected:
virtual inline void Cleanup()override{
}
};

@ -9,7 +9,7 @@ float TileGroup::FADE_TIME=0.3;
uint8_t TileGroup::FADE_AMT=160; uint8_t TileGroup::FADE_AMT=160;
Map&MapHelper::MapFromString(std::string mapName){ Map&MapHelper::MapFromString(std::string mapName){
return game->MAP_DATA[LEVEL_NAMES[mapName]]; return game->MAP_DATA.at(LEVEL_NAMES.at(mapName));
} }
void TileGroup::InsertTile(TileRenderData tile){ void TileGroup::InsertTile(TileRenderData tile){

@ -9,6 +9,8 @@
class Crawler; class Crawler;
class MenuComponent; class MenuComponent;
#define COMPONENT(type,menu,componentName) ((type*)Menu::menus[menu]->components.at(componentName))
enum MenuType{ enum MenuType{
TEST, TEST,
TEST_2, TEST_2,

@ -2,7 +2,7 @@
#include "Crawler.h" #include "Crawler.h"
#include "DEFINES.h" #include "DEFINES.h"
#include "Menu.h" #include "Menu.h"
#include "ScrollableWindowComponent.h" #include "EncountersSpawnListScrollableWindowComponent.h"
#include "MenuLabel.h" #include "MenuLabel.h"
#include "MenuComponent.h" #include "MenuComponent.h"
#include "State_OverworldMap.h" #include "State_OverworldMap.h"
@ -28,7 +28,7 @@ void Menu::InitializeOverworldMapLevelWindow(){
levelSelectWindow->AddComponent(MONSTER_DATA[key].GetDisplayName()+" Display Label",testLabel); levelSelectWindow->AddComponent(MONSTER_DATA[key].GetDisplayName()+" Display Label",testLabel);
}*/ }*/
MenuLabel*chapterLabel=NEW MenuLabel(OVERWORLD_LEVEL_SELECT,{{0,4},{windowSize.x,16}},"Chapter "+std::to_string(game->GetCurrentChapter()),1,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN); MenuLabel*chapterLabel=NEW MenuLabel(OVERWORLD_LEVEL_SELECT,{{0,4},{windowSize.x,16}},"Chapter",1,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN);
MenuLabel*stageLabel=NEW MenuLabel(OVERWORLD_LEVEL_SELECT,{{0,24},{windowSize.x,16}},"Stage",1,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN); MenuLabel*stageLabel=NEW MenuLabel(OVERWORLD_LEVEL_SELECT,{{0,24},{windowSize.x,16}},"Stage",1,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN);
MenuLabel*panel1Back=NEW MenuLabel(OVERWORLD_LEVEL_SELECT,{{0,0},{windowSize.x-1,44}},"",1,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE); MenuLabel*panel1Back=NEW MenuLabel(OVERWORLD_LEVEL_SELECT,{{0,0},{windowSize.x-1,44}},"",1,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE);
@ -37,7 +37,7 @@ void Menu::InitializeOverworldMapLevelWindow(){
levelSelectWindow->AddComponent("Stage Label",stageLabel); levelSelectWindow->AddComponent("Stage Label",stageLabel);
MenuLabel*encountersLabel=NEW MenuLabel(OVERWORLD_LEVEL_SELECT,{{0,52},{windowSize.x-1,12}},"Encounters:",1,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN); MenuLabel*encountersLabel=NEW MenuLabel(OVERWORLD_LEVEL_SELECT,{{0,52},{windowSize.x-1,12}},"Encounters:",1,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN);
ScrollableWindowComponent*spawns=NEW ScrollableWindowComponent(OVERWORLD_LEVEL_SELECT,{{1,64},{windowSize.x-2,84}},ComponentAttr::BACKGROUND); EncountersSpawnListScrollableWindowComponent*spawns=NEW EncountersSpawnListScrollableWindowComponent(OVERWORLD_LEVEL_SELECT,{{1,64},{windowSize.x-2,84}},ComponentAttr::BACKGROUND);
MenuLabel*panel2Back=NEW MenuLabel(OVERWORLD_LEVEL_SELECT,{{0,52},{windowSize.x-1,96}},"",1,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE); MenuLabel*panel2Back=NEW MenuLabel(OVERWORLD_LEVEL_SELECT,{{0,52},{windowSize.x-1,96}},"",1,ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE);
levelSelectWindow->AddComponent("Panel 2 Back",panel2Back); levelSelectWindow->AddComponent("Panel 2 Back",panel2Back);

@ -19,7 +19,7 @@ protected:
float scrollBarHoverTime=0; float scrollBarHoverTime=0;
protected: protected:
inline bool OnScreen(MenuComponent*component){ inline bool OnScreen(MenuComponent*component){
return geom2d::overlaps(rect,geom2d::rect<float>{component->rect.pos+V(A::SCROLL_OFFSET)+vf2d{2,2},component->rect.size-vf2d{2,2}}); return geom2d::overlaps(geom2d::rect<float>{{},rect.size},geom2d::rect<float>{component->rect.pos+V(A::SCROLL_OFFSET)+vf2d{2,2},component->rect.size-vf2d{2,2}});
} }
public: public:
inline ScrollableWindowComponent(MenuType parent,geom2d::rect<float>rect,ComponentAttr attributes=ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE) inline ScrollableWindowComponent(MenuType parent,geom2d::rect<float>rect,ComponentAttr attributes=ComponentAttr::BACKGROUND|ComponentAttr::OUTLINE)
@ -100,10 +100,10 @@ protected:
game->SetDrawTarget(r.Sprite()); game->SetDrawTarget(r.Sprite());
game->Clear(BLANK); game->Clear(BLANK);
for(MenuComponent*component:components){ for(MenuComponent*component:components){
component->_Draw(game,rect.pos+V(A::SCROLL_OFFSET)); component->_Draw(game,V(A::SCROLL_OFFSET));
} }
game->SetDrawTarget(prevDrawTarget); game->SetDrawTarget(prevDrawTarget);
game->DrawSprite(parentPos,r.Sprite()); game->DrawSprite(parentPos+rect.pos,r.Sprite());
} }
inline void DrawScrollbar(Crawler*game,vf2d parentPos,bool focused){ inline void DrawScrollbar(Crawler*game,vf2d parentPos,bool focused){

@ -6,6 +6,8 @@
#include "Unlock.h" #include "Unlock.h"
#include "ConnectionPoint.h" #include "ConnectionPoint.h"
#include "utils.h" #include "utils.h"
#include "MenuLabel.h"
#include "EncountersSpawnListScrollableWindowComponent.h"
INCLUDE_MONSTER_LIST INCLUDE_MONSTER_LIST
INCLUDE_game INCLUDE_game
@ -24,7 +26,10 @@ void State_OverworldMap::OnStateChange(GameState*prevState){
game->GetPlayer()->UpdateWalkingAnimation(DOWN); game->GetPlayer()->UpdateWalkingAnimation(DOWN);
game->GetPlayer()->SetState(State::FORCE_WALK); game->GetPlayer()->SetState(State::FORCE_WALK);
game->GetPlayer()->SetSizeMult(1); game->GetPlayer()->SetSizeMult(1);
game->camera.MoveCamera(game->GetPlayer()->GetPos()); game->camera.MoveCamera(currentConnectionPoint->rect.middle()+vf2d{game->GetScreenSize().x/6.0f,0});
COMPONENT(MenuLabel,OVERWORLD_LEVEL_SELECT,"Chapter Label")->SetLabel("Chapter "+std::to_string(game->GetCurrentChapter()));
COMPONENT(MenuLabel,OVERWORLD_LEVEL_SELECT,"Stage Label")->SetLabel(currentConnectionPoint->name);
COMPONENT(EncountersSpawnListScrollableWindowComponent,OVERWORLD_LEVEL_SELECT,"Spawns List")->UpdateSpawns(currentConnectionPoint->spawns);
Menu::OpenMenu(OVERWORLD_LEVEL_SELECT,false); Menu::OpenMenu(OVERWORLD_LEVEL_SELECT,false);
}; };
void State_OverworldMap::OnUserUpdate(Crawler*game){ void State_OverworldMap::OnUserUpdate(Crawler*game){

@ -408,7 +408,7 @@ typedef std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
for(auto key:stagePlates){ for(auto key:stagePlates){
StagePlate&plate=key.second; StagePlate&plate=key.second;
idToIndexMap[plate.tag.GetInteger("id")]=State_OverworldMap::connections.size(); idToIndexMap[plate.tag.GetInteger("id")]=State_OverworldMap::connections.size();
ConnectionPoint newConnection={{{plate.tag.GetFloat("x"),plate.tag.GetFloat("y")},{plate.tag.GetFloat("width"),plate.tag.GetFloat("height")}},plate.tag.data["name"],plate.properties["Map"].value,plate.properties["Unlock Condition"].value}; ConnectionPoint newConnection={{{plate.tag.GetFloat("x"),plate.tag.GetFloat("y")},{plate.tag.GetFloat("width"),plate.tag.GetFloat("height")}},plate.tag.data["name"],plate.properties["Map"].value,plate.properties["Unlock Condition"].value,{}};
int iterationCount=0; int iterationCount=0;
for(auto key2:plate.properties){ for(auto key2:plate.properties){
if(key2.first.starts_with("Connection ")){ if(key2.first.starts_with("Connection ")){

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 1 #define VERSION_PATCH 1
#define VERSION_BUILD 2736 #define VERSION_BUILD 2759
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -558,6 +558,8 @@
<properties> <properties>
<property name="Connection 1" type="object" value="4"/> <property name="Connection 1" type="object" value="4"/>
<property name="Connection 2" type="object" value="5"/> <property name="Connection 2" type="object" value="5"/>
<property name="Map" propertytype="Level" value="CAMPAIGN_1_1"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_1"/>
</properties> </properties>
</object> </object>
<object id="4" name="Stage I-II" type="StagePlate" x="248" y="552" width="44" height="16"> <object id="4" name="Stage I-II" type="StagePlate" x="248" y="552" width="44" height="16">

Loading…
Cancel
Save