77 lines
2.3 KiB
C++
77 lines
2.3 KiB
C++
/**
|
|
* @file
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "testcore/TestApp.h"
|
|
#include "voxelrender/RawVolumeRenderer.h"
|
|
#include "voxelrender/VoxelFontRenderer.h"
|
|
#include "core/EventBus.h"
|
|
#include "audio/SoundManager.h"
|
|
|
|
#include "TrazeEvents.h"
|
|
#include "TrazeProtocol.h"
|
|
|
|
#include "util/MessageQueue.h"
|
|
|
|
/**
|
|
* @brief Example application that renders the state of a traze board. See https://traze.iteratec.de/ for more details.
|
|
*/
|
|
class TestTraze : public TestApp,
|
|
public core::IEventBusHandler<traze::NewGridEvent>,
|
|
public core::IEventBusHandler<traze::PlayerListEvent>,
|
|
public core::IEventBusHandler<traze::TickerEvent>,
|
|
public core::IEventBusHandler<traze::SpawnEvent>,
|
|
public core::IEventBusHandler<traze::BikeEvent>,
|
|
public core::IEventBusHandler<traze::ScoreEvent>,
|
|
public core::IEventBusHandler<traze::NewGamesEvent> {
|
|
private:
|
|
using Super = TestApp;
|
|
|
|
core::VarPtr _name;
|
|
|
|
traze::Protocol _protocol;
|
|
voxelrender::RawVolumeRenderer _rawVolumeRenderer;
|
|
voxelrender::VoxelFontRenderer _voxelFontRender;
|
|
MessageQueue _messageQueue;
|
|
audio::SoundManager _soundMgr;
|
|
|
|
bool _renderBoard = true;
|
|
bool _renderPlayerNames = true;
|
|
|
|
glm::ivec2 _spawnPosition { 0 };
|
|
double _spawnTime = 0.0;
|
|
|
|
int _maxLength = 200;
|
|
video::Camera _textCamera;
|
|
|
|
std::vector<traze::GameInfo> _games;
|
|
std::vector<traze::Player> _players;
|
|
int8_t _currentGameIndex = -1;
|
|
double _nextConnectTime = 0.0;
|
|
|
|
void doRender() override;
|
|
|
|
void sound(const char *soundId);
|
|
|
|
const core::String& playerName(traze::PlayerId playerId) const;
|
|
const traze::Player& player(traze::PlayerId playerId) const;
|
|
public:
|
|
TestTraze(const metric::MetricPtr& metric, const io::FilesystemPtr& filesystem, const core::EventBusPtr& eventBus, const core::TimeProviderPtr& timeProvider);
|
|
|
|
void onEvent(const traze::BikeEvent& event) override;
|
|
void onEvent(const traze::NewGamesEvent& event) override;
|
|
void onEvent(const traze::TickerEvent& event) override;
|
|
void onEvent(const traze::SpawnEvent& event) override;
|
|
void onEvent(const traze::NewGridEvent& event) override;
|
|
void onEvent(const traze::PlayerListEvent& event) override;
|
|
void onEvent(const traze::ScoreEvent& event) override;
|
|
|
|
virtual void onRenderUI() override;
|
|
virtual app::AppState onConstruct() override;
|
|
virtual app::AppState onInit() override;
|
|
virtual app::AppState onRunning() override;
|
|
virtual app::AppState onCleanup() override;
|
|
};
|