aboutsummaryrefslogtreecommitdiff
path: root/game/menus/ButtonReplaySubScript.cpp
blob: 93083503e11a6a048d708139ff82e9f44be38336 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "ButtonReplaySubScript.h"
#include "MenusConfig.h"

#include "../Events.h"
#include <crepe/api/AudioSource.h>
#include <crepe/types.h>

using namespace crepe;
using namespace std;

void ButtonReplaySubScript::init() {
	IButtonScript::init();
	this->subscribe<ButtonPressEvent>([this](const ButtonPressEvent & e) {
		return this->on_button_press(e);
	});
	this->subscribe<EndGameEvent>([this](const EndGameEvent & e) {
		return this->set_recording();
	});
	replay.record_start();
}

bool ButtonReplaySubScript::on_button_press(const ButtonPressEvent & e) {
	replay.play(this->recording);
	return false;
}

bool ButtonReplaySubScript::set_recording() {
	this->recording = replay.record_end();
	return false;
}