menu navigation, adding images

This commit is contained in:
Bluub
2021-06-07 10:28:00 +02:00
72 changed files with 1517 additions and 743 deletions

View File

@@ -5,16 +5,14 @@
#include <algorithm>
#include "Component/Button/ButtonComponent.hpp"
#include "Component/Position/PositionComponent.hpp"
#include "System/MenuControllable/MenuControllableSystem.hpp"
#include "System/MenuControllable/MenuControllableSystem.hpp"
#include "Component/Controllable/ControllableComponent.hpp"
#include "Entity/Entity.hpp"
namespace BBM
{
MenuControllableSystem::MenuControllableSystem()
: WAL::System({
typeid(ControllableComponent)
})
MenuControllableSystem::MenuControllableSystem(WAL::Wal &wal)
: System(wal), wal(wal)
{}
void MenuControllableSystem::updateButtonIndex(int length)
@@ -28,9 +26,9 @@ namespace BBM
}
void MenuControllableSystem::onFixedUpdate(WAL::Entity &entity)
void MenuControllableSystem::onFixedUpdate(WAL::ViewEntity<ControllableComponent> &entity)
{
auto &controllable = entity.getComponent<ControllableComponent>();
auto &controllable = entity.get<ControllableComponent>();
move = controllable.move;
select = controllable.bomb;
@@ -38,24 +36,24 @@ namespace BBM
void MenuControllableSystem::onSelfUpdate(void)
{
auto buttons = ecs.view<<ButtonComponent>(entities);
auto &buttons = wal.scene->view<ButtonComponent>();
ssize_t index = 0;
std::sort(buttons.begin(), buttons.end(),
[](WAL::Entity &first, WAL::Entity &second) {
auto &posA = first.getComponent<PositionComponent>();
auto &posB = second.getComponent<PositionComponent>();
return (posA.position.y < posB.position.y);
});
updateButtonIndex(buttons.length);
auto currentButton = buttons[_buttonIndex].getComponent<ButtonComponent>();
currentButton.onSelected();
if (select)
currentButton.onClick();
//std::sort(buttons.begin(), buttons.end(),
//[](WAL::Entity &first, WAL::Entity &second) {
// auto &posA = first.getComponent<PositionComponent>();
// auto &posB = second.getComponent<PositionComponent>();
//
// return (posA.position.y < posB.position.y);
//});
updateButtonIndex(buttons.size());
for (auto &button : buttons) {
if (index++ == _buttonIndex)
if (index++ == _buttonIndex) {
button.get<ButtonComponent>().onHover(button);
if (select)
button.get<ButtonComponent>().onClick(button);
continue;
button.onIdle();
}
button.get<ButtonComponent>().onIdle(button);
}
}
}