-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathScene.h
56 lines (50 loc) · 1.17 KB
/
Scene.h
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef SCENE_H_
#define SCENE_H_
#include "Column.h"
#include "Generator.h"
#include "SysTool.h"
#include <iostream>
#include <thread>
#include <chrono>
#include <memory>
#include<algorithm>
class Scene
{
public:
Scene(int, int, int = SysTool::TIME_LOW);
template<typename... StringType>
void execute(StringType&&... st)
{
while (true)
{
char ch = SysTool::getchNonBlocking();
if (ch == 'q')
{
break;
}
else if (ch == 'p')
{
std::cin.get();
}
else if (ch == 'j')
{
millisec = (millisec == SysTool::TIME_LOW) ? millisec : millisec - SysTool::TIME_DELTA;
}
else if (ch == 'k')
{
millisec = (millisec == SysTool::TIME_HIGH) ? millisec : millisec + SysTool::TIME_DELTA;
}
showScene();
std::for_each(column.begin(), column.end(), [&](Column & d){ d.refresh(generator, SysTool::COLOR_HEAD, SysTool::getColorBody(), SysTool::COLOR_TAIL, SysTool::COLOR_EMPTY, std::forward<StringType>(st)...); });
std::this_thread::sleep_for(std::chrono::milliseconds(millisec));
}
}
private:
const int COLS;
Generator generator;
vector<std::unique_ptr<Char *[]>> scene;
vector<Column> column;
int millisec;
void showScene();
};
#endif