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
|
#include "Deserializer.h"
#include "Exception.h"
void Deserializer::set_target(Museum * museum) {
this->museum = museum;
}
Deserializer::~Deserializer() {
this->finalize();
}
void Deserializer::finalize() {
// TODO: remove artists outside the canvas
}
Museum & Deserializer::get_target() {
if (this->museum == nullptr)
throw Exception("no museum given to Deserializer");
return *this->museum;
}
void Deserializer::add_artist(ArtistData data) {
printf("add artist(%1.2f, %1.2f)...\n", data.x, data.y);
Museum & museum = this->get_target();
// museum.people.add_artist(data);
}
void Deserializer::set_canvas(CanvasData data) {
printf("set canvas(%dx%d)...\n", data.rows, data.columns);
Museum & museum = this->get_target();
museum.canvas.data = data;
museum.canvas.update();
}
void Deserializer::add_tile(unsigned int x, unsigned int y, TileData data) {
printf("add tile(%d,%d) data(%c)...\n", x, y, data.type);
Museum & museum = this->get_target();
museum.canvas.set_tile(x, y, data);
}
void Deserializer::add_type(char type, Color color, unsigned int weight) {
if (type == '\0') return;
printf("add type(%c) color(#%02x%02x%02x) weight(%d)...\n", type, color.red,
color.green, color.blue, weight);
}
|