-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimeline.cpp
More file actions
90 lines (71 loc) · 1.82 KB
/
Timeline.cpp
File metadata and controls
90 lines (71 loc) · 1.82 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "Timeline.h"
Timeline::Timeline(string tag)
{
numCommands = 0;
currentCommand = 0;
FILE* fin = fopen("Data/Timeline.txt","rt");
if(fin==NULL)
{
printf("Data/Timeline.txt not found");
exit(0);
}
int i;
bool flag = false;
double time = 0;
char templine[256];
// printf("Executing %s:\n",tag);
while(!feof(fin))
{
fgets(templine,255,fin);
if(templine[0]=='/'&&templine[1]=='/')
continue;
if(templine[0]=='/'&&templine[1]=='*')
{
while(!feof(fin))
{
fgets(templine,255,fin);
if(strstr(templine,"*/"))
break;
}
if(feof(fin))
break;
continue;
}
//printf(templine);
if(strstr(templine,"TIM")==templine)
{
// printf(templine);
sscanf(templine,"TIM %lf",&time);
}
if(strstr(templine,tag.c_str())==templine)
{
sprintf(commands[numCommands++],"%lf %s",time,templine+4);
// printf(commands[numCommands-1]);
}
}
fclose(fin);
printf("Displaying %s:\n",tag.c_str());
displayLines();
printf("\n");
}
char* Timeline::readNextCommand(double &peektime)
{
if(currentCommand==numCommands)
return " ";
if(currentCommand<numCommands-1)
sscanf(commands[currentCommand+1],"%lf",&peektime);
else
peektime = 240;
return commands[currentCommand++];
}
void Timeline::displayLines()
{
for(int i=0; i<numCommands; i++)
{ printf(commands[i]);}
}
Timeline::~Timeline()
{
/* for(vector<char*>::iterator it = lines.begin(); it!=lines.end(); ++it)
{ delete[] *it;}
*/
}