-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathContentMigration.cpp
More file actions
113 lines (100 loc) · 3.43 KB
/
Copy pathContentMigration.cpp
File metadata and controls
113 lines (100 loc) · 3.43 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include "Common.h"
FO_USING_NAMESPACE();
FO_BEGIN_NAMESPACE
///@ EngineHook
FO_SCRIPT_API auto ConfigSectionParseHook(string_view fname, string_view section, string& out_section, map<string, string>& init_section_kv) -> bool;
///@ EngineHook
FO_SCRIPT_API auto ConfigEntryParseHook(string_view fname, string_view section, string_view key, string_view value, string& out_key, string& out_value) -> bool;
FO_END_NAMESPACE
auto FO_NAMESPACE ConfigSectionParseHook(string_view fname, string_view section, string& out_section, map<string, string>& init_section_kv) -> bool
{
FO_STACK_TRACE_ENTRY();
ignore_unused(fname, init_section_kv);
if (section == "Tile") {
out_section = "Item";
return true;
}
return false;
}
auto FO_NAMESPACE ConfigEntryParseHook(string_view fname, string_view section, string_view key, string_view value, string& out_key, string& out_value) -> bool
{
FO_STACK_TRACE_ENTRY();
ignore_unused(fname);
out_key = string(key);
out_value = string(value);
auto changed = false;
if (section == "Tile") {
if (key == "PicMap") {
out_key = "$Proto";
out_value = "tile_" + strex(value).extract_file_name().erase_file_extension().str();
changed = true;
}
else if (key == "IsRoof") {
out_key = "IsRoofTile";
changed = true;
}
else if (key == "Layer") {
out_key = "TileLayer";
changed = true;
}
}
if (section == "ProtoMap" || section == "Critter" || section == "Item" || section == "ProtoItem" || section == "Tile") {
static thread_local string prev_key;
static thread_local string prev_value;
if (key == "HexX") {
prev_key = string(key);
prev_value = string(value);
out_key = "Hex";
out_value = strex("{} 0", value);
changed = true;
}
else if (key == "HexY") {
out_value = strex("{} {}", prev_key == "HexX" ? prev_value : "0", value);
out_key = "Hex";
prev_key = "";
changed = true;
}
else if (key == "OffsetX") {
prev_key = string(key);
prev_value = string(value);
out_key = "Offset";
out_value = strex("{} 0", value);
changed = true;
}
else if (key == "OffsetY") {
out_key = "Offset";
out_value = strex("{} {}", prev_key == "OffsetX" ? prev_value : "0", value);
prev_key = "";
changed = true;
}
else if (key == "Height") {
prev_key = string(key);
prev_value = string(value);
out_key.clear();
changed = true;
}
else if (key == "Width") {
out_key = "Size";
out_value = strex("{} {}", value, prev_value);
prev_key = "";
changed = true;
}
else if (key == "WorkHexX") {
prev_key = string(key);
prev_value = string(value);
out_key = "WorkHex";
out_value = strex("{} 0", value);
changed = true;
}
else if (key == "WorkHexY") {
out_value = strex("{} {}", prev_key == "WorkHexX" ? prev_value : "0", value);
out_key = "WorkHex";
prev_key = "";
changed = true;
}
else {
prev_key = "";
}
}
return changed;
}