| 2303 | } |
| 2304 | |
| 2305 | void Gui::MTB_parse(df::markup_text_boxst *mtb, string parse_text) |
| 2306 | { // Reverse-engineered from "markup_text_boxst::process_string_to_lines" FUN_1409f70b0 (v50.11 win64 Steam) |
| 2307 | CHECK_NULL_POINTER(mtb); |
| 2308 | auto &word_vec = mtb->word; |
| 2309 | |
| 2310 | if (parse_text.empty()) |
| 2311 | { |
| 2312 | auto ptr = new df::markup_text_wordst(); |
| 2313 | ptr->flags.bits.NEW_LINE = true; |
| 2314 | word_vec.push_back(ptr); |
| 2315 | return; |
| 2316 | } |
| 2317 | |
| 2318 | string str; |
| 2319 | int32_t link_index = -1; |
| 2320 | int32_t color = curses_color::White; // fg = curses_color::White; bg = curses_color::Black; bright = false |
| 2321 | bool use_char, no_split_space; |
| 2322 | |
| 2323 | size_t i_max = parse_text.size(); |
| 2324 | size_t i = 0; |
| 2325 | while (i < i_max) |
| 2326 | { |
| 2327 | char char_token = '\0'; |
| 2328 | use_char = true; |
| 2329 | no_split_space = false; |
| 2330 | |
| 2331 | if (parse_text[i] == ']') |
| 2332 | { |
| 2333 | if (++i >= i_max) // Skip over ']' |
| 2334 | break; |
| 2335 | |
| 2336 | if (parse_text[i] != ']') |
| 2337 | { |
| 2338 | i--; // Check this char again from top |
| 2339 | continue; |
| 2340 | } |
| 2341 | // else "]]", append ']' to str since use_char == true |
| 2342 | } |
| 2343 | else if (parse_text[i] == '[') |
| 2344 | { |
| 2345 | if (++i >= i_max) // Skip over '[' |
| 2346 | break; |
| 2347 | |
| 2348 | if (parse_text[i] == '.' || parse_text[i] == ':' || parse_text[i] == '?' || parse_text[i] == ' ' || parse_text[i] == '!') // Immediately after '[' |
| 2349 | no_split_space = true; // Completely pointless for everything but ' '? |
| 2350 | else if (parse_text[i] != '[') // else "[[", append '[' to str since use_char == true |
| 2351 | { |
| 2352 | use_char = false; |
| 2353 | |
| 2354 | string token_buffer = grab_token_string_pos(parse_text, i, ':'); // Capture until next ':', ']', or end |
| 2355 | i += token_buffer.size(); |
| 2356 | |
| 2357 | if (token_buffer == "CHAR") |
| 2358 | { |
| 2359 | if (++i >= i_max) // Skip over ':' |
| 2360 | break; |
| 2361 | |
| 2362 | string buff = grab_token_string_pos(parse_text, i, ':'); |
nothing calls this directly
no test coverage detected