added speed to the save

This commit is contained in:
EternalRat
2021-06-16 11:47:46 +02:00
parent 384c5e1188
commit 2ed5b79cfc
10 changed files with 54 additions and 14 deletions
+26 -4
View File
@@ -3,6 +3,7 @@
#include <Wal.hpp>
#include "Runner.hpp"
#include <map>
#include <Parser/ParserYaml.hpp>
#include "Component/Music/MusicComponent.hpp"
#include "Component/Sound/SoundComponent.hpp"
#include "Component/Controllable/ControllableComponent.hpp"
@@ -52,6 +53,26 @@ namespace BBM
{
gameState.nextScene = BBM::GameState::SceneID::GameScene;
});
auto &save = scene->addEntity("save & quit button")
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 240, 0)
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_save.png")
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_save.png");
})
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_save_hovered.png");
})
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
{
ParserYAML::save(Runner::gameState._loadedScenes[GameState::SceneID::GameScene]);
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
});
auto &settings = scene->addEntity("settings button")
.addComponent<PositionComponent>(1920 / 2.5, 1080 - 360, 0)
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_settings.png")
@@ -72,7 +93,7 @@ namespace BBM
gameState.nextScene = BBM::GameState::SceneID::SettingsScene;
});
auto &exit = scene->addEntity("exit button")
.addComponent<PositionComponent>(1920 / 1.5, 1080 - 360, 0)
.addComponent<PositionComponent>(1920 / 1.55, 1080 - 360, 0)
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_exit.png")
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
@@ -92,9 +113,10 @@ namespace BBM
});
//needed material
//music
play.getComponent<OnClickComponent>().setButtonLinks(nullptr, nullptr, nullptr, &settings);
settings.getComponent<OnClickComponent>().setButtonLinks(nullptr, nullptr, &play, &exit);
exit.getComponent<OnClickComponent>().setButtonLinks(nullptr, nullptr, &settings, nullptr);
save.getComponent<OnClickComponent>().setButtonLinks(&play);
play.getComponent<OnClickComponent>().setButtonLinks(nullptr, &save, nullptr, &settings);
settings.getComponent<OnClickComponent>().setButtonLinks(nullptr, &save, &play, &exit);
exit.getComponent<OnClickComponent>().setButtonLinks(nullptr, &save, &settings, nullptr);
return scene;
}
}