|
17 | 17 |
|
18 | 18 | // Headers
|
19 | 19 | #include <map>
|
| 20 | +#include <numeric> |
20 | 21 |
|
21 | 22 | #include "dynrpg_easyrpg.h"
|
22 | 23 | #include "string_view.h"
|
@@ -99,42 +100,82 @@ bool DynRpg::EasyRpgPlugin::EasyRaw(dyn_arg_list args, Game_Interpreter* interpr
|
99 | 100 | Constants constList;
|
100 | 101 |
|
101 | 102 | const std::string func = "easyrpg_raw";
|
102 |
| - bool okay = false; |
| 103 | + |
103 | 104 | int codeArgIndex = 0;
|
104 | 105 | int stringArgIndex = 1;
|
| 106 | + int indentArgIndex = -1; |
| 107 | + |
| 108 | + std::string tempArg; |
105 | 109 | bool endOfLine = false;
|
| 110 | + bool okay = false; |
106 | 111 |
|
107 | 112 | lcf::rpg::EventCommand cmd;
|
| 113 | + lcf::rpg::EventCommand _cmd; |
108 | 114 | std::vector<int32_t> outputArgs;
|
109 | 115 | std::vector<lcf::rpg::EventCommand> cmdList;
|
110 | 116 |
|
111 | 117 | for (size_t i = 0; i < args.size(); ++i) {
|
| 118 | + |
| 119 | + bool valid = !args[i].empty(); |
| 120 | + |
| 121 | + if (valid && args[i].front() == '[') args[i] = args[i].substr(1); |
| 122 | + if (valid && args[i].back() == ']') { |
| 123 | + args[i] = args[i].substr(0, args[i].length() - 1); |
| 124 | + indentArgIndex = i + 1; |
| 125 | + } |
| 126 | + |
112 | 127 | if (i == args.size() - 1) {
|
113 |
| - if (args[i].back() == ';') args[i] = args[i].substr(0, args[i].length() - 1); |
114 | 128 | endOfLine = true;
|
115 | 129 | }
|
116 | 130 |
|
117 |
| - // TODO: Implement multi-line command interpretation split by ';'. |
| 131 | + else if (args[i] == ";") { |
| 132 | + endOfLine = true; |
| 133 | + valid = 0; |
| 134 | + } |
| 135 | + |
| 136 | + if (valid && i == codeArgIndex) { |
| 137 | + |
| 138 | + size_t start_pos = args[i].find_first_not_of(" \t\r\n"); |
| 139 | + if (start_pos != std::string::npos) |
| 140 | + args[i] = args[i].substr(start_pos); |
| 141 | + |
| 142 | + Output::Debug("code ----> {}", args[i]); |
118 | 143 |
|
119 |
| - if (i == codeArgIndex) { |
120 | 144 | if (args[i].front() == '@') args[i] = constList.get("EventCode", args[i].substr(1));
|
121 |
| - std::tie(cmd.code) = DynRpg::ParseArgs<int>(func, args, &okay); |
| 145 | + std::tie(cmd.code) = DynRpg::ParseArgs<int>(func, args.subspan(i), &okay); |
122 | 146 | }
|
123 |
| - else if (i == stringArgIndex) { |
| 147 | + else if (valid && i == stringArgIndex) { |
| 148 | + Output::Debug("str ----> {}", args[i]); |
124 | 149 | auto [stringArg] = DynRpg::ParseArgs<std::string>(func, args.subspan(i), &okay);
|
125 | 150 | cmd.string = lcf::DBString(stringArg);
|
126 | 151 | }
|
127 |
| - else { |
128 |
| - if (args[i].front() == '@') args[i] = constList.get("DestinyScript", args[i].substr(1)); |
| 152 | + else if (valid){ |
| 153 | + |
| 154 | + if (valid && args[i].front() == '@') args[i] = constList.get("DestinyScript", args[i].substr(1)); |
129 | 155 | auto [intArg] = DynRpg::ParseArgs<int>(func, args.subspan(i), &okay);
|
130 |
| - outputArgs.push_back(intArg); |
| 156 | + |
| 157 | + if (indentArgIndex == i) { |
| 158 | + Output::Debug("idt ----> {}", args[i]); |
| 159 | + indentArgIndex = -1; |
| 160 | + cmd.indent = intArg; |
| 161 | + } |
| 162 | + else Output::Debug("pls ----> {}", args[i]), outputArgs.push_back(intArg); |
131 | 163 | }
|
132 | 164 |
|
133 | 165 | if (endOfLine) {
|
134 |
| - codeArgIndex = i + 1; |
135 |
| - stringArgIndex = i + 2; |
| 166 | + Output::Debug("com ----> {}\n\n", cmd.code); |
136 | 167 | cmd.parameters = lcf::DBArray<int32_t>(outputArgs.begin(), outputArgs.end());
|
137 | 168 | cmdList.push_back(cmd);
|
| 169 | + outputArgs.clear(); |
| 170 | + |
| 171 | + cmd.code = 0; |
| 172 | + cmd.string = ""; |
| 173 | + cmd.parameters = lcf::DBArray<int32_t>(outputArgs.begin(), outputArgs.end()); |
| 174 | + |
| 175 | + codeArgIndex = i + 1; |
| 176 | + stringArgIndex = i + 2; |
| 177 | + |
| 178 | + endOfLine = false; |
138 | 179 | }
|
139 | 180 |
|
140 | 181 | if (!okay) return true;
|
|
0 commit comments