forked from 15-466/15-466-f20-base4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdialogue_generation.cpp
44 lines (40 loc) · 1.09 KB
/
dialogue_generation.cpp
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
#include "GL.hpp"
#include "load_save_png.hpp"
#include "read_write_chunk.hpp"
#include "data_path.hpp"
#include <iostream>
#include <fstream>
#include <glm/glm.hpp>
#include <string>
#include <vector>
#include <stdint.h>
int main(int argc, char **argv) {
std::ifstream metafile;
// std::vector<> data;
metafile.open(data_path("../tmp_dialogue.txt"));
std::vector<char> characters;
std::vector<std::pair<int, int>> ranges;
std::string line;
if (metafile.is_open()) {
int cur = 0;
while (std::getline(metafile, line)) {
int length = line.length();
for (int i = 0; i < length; i++) {
characters.push_back(line[i]);
}
ranges.push_back(std::pair<int, int>(cur, cur + length));
cur += length;
}
std::cout << cur;
metafile.close();
std::ofstream chars_stream;
std::ofstream ranges_stream;
chars_stream.open(data_path("../chars.asset"));
ranges_stream.open(data_path("../ranges.asset"));
write_chunk(std::string("char"), characters, &chars_stream);
write_chunk(std::string("rang"), ranges, &ranges_stream);
chars_stream.close();
ranges_stream.close();
}
return 0;
}