aboutsummaryrefslogtreecommitdiff
path: root/game/menus/ButtonReplaySubScript.cpp
blob: 26cb8ee72ce7966e89fab64cd3831e87a9aebe24 (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
31
#include "ButtonReplaySubScript.h"
#include "MenusConfig.h"

#include <crepe/api/AudioSource.h>
#include <crepe/types.h>
#include "../Events.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;
}