mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-26 12:21:39 +00:00
remove regex usage
This commit is contained in:
parent
9c7fb185f0
commit
726120f661
2 changed files with 27 additions and 16 deletions
|
|
@ -196,7 +196,7 @@ void DrawTextBasic(const ImFont* font, float fontSize, const ImVec2& pos, ImU32
|
|||
drawList->AddText(font, fontSize, pos, colour, text, nullptr);
|
||||
}
|
||||
|
||||
void DrawTextWithMarquee(const ImFont* font, float fontSize, const ImVec2& pos, const ImVec2& min, const ImVec2& max, ImU32 color, const char* text, double time, double delay, double speed)
|
||||
void DrawTextWithMarquee(const ImFont* font, float fontSize, const ImVec2& position, const ImVec2& min, const ImVec2& max, ImU32 color, const char* text, double time, double delay, double speed)
|
||||
{
|
||||
auto drawList = ImGui::GetForegroundDrawList();
|
||||
auto rectWidth = max.x - min.x;
|
||||
|
|
@ -500,27 +500,38 @@ Paragraph CalculateAnnotatedParagraph(const std::vector<std::string>& lines)
|
|||
for (const auto& line : lines)
|
||||
{
|
||||
std::vector<TextSegment> segments;
|
||||
std::regex regex(R"(\[([^\:]+):([^\]]+)\])"); // Matches "[text:annotation]"
|
||||
std::smatch match;
|
||||
|
||||
auto searchStart = line.cbegin();
|
||||
while (std::regex_search(searchStart, line.cend(), match, regex))
|
||||
size_t pos = 0;
|
||||
size_t start = 0;
|
||||
|
||||
while ((start = line.find('[', pos)) != std::string::npos)
|
||||
{
|
||||
if (searchStart != match[0].first)
|
||||
size_t end = line.find(']', start);
|
||||
if (end == std::string::npos)
|
||||
break;
|
||||
|
||||
size_t colon = line.find(':', start);
|
||||
if (colon != std::string::npos && colon < end)
|
||||
{
|
||||
segments.push_back({ false, std::string(searchStart, match[0].first), "" });
|
||||
if (start != pos)
|
||||
{
|
||||
segments.push_back({ false, line.substr(pos, start - pos), "" });
|
||||
}
|
||||
|
||||
segments.push_back({ true, line.substr(start + 1, colon - start - 1), line.substr(colon + 1, end - colon - 1) });
|
||||
|
||||
result.annotated = true;
|
||||
pos = end + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = start + 1;
|
||||
}
|
||||
|
||||
segments.push_back({ true, match[1].str(), match[2].str() });
|
||||
|
||||
result.annotated = true;
|
||||
|
||||
searchStart = match[0].second;
|
||||
}
|
||||
|
||||
if (searchStart != line.cend())
|
||||
if (pos < line.size())
|
||||
{
|
||||
segments.push_back({ false, std::string(searchStart, line.cend()), "" });
|
||||
segments.push_back({ false, line.substr(pos), "" });
|
||||
}
|
||||
|
||||
result.lines.push_back(segments);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ double ComputeMotion(double duration, double offset, double total);
|
|||
void DrawPauseContainer(ImVec2 min, ImVec2 max, float alpha = 1);
|
||||
void DrawTextBasic(const ImFont* font, float fontSize, const ImVec2& pos, ImU32 colour, const char* text);
|
||||
void DrawPauseHeaderContainer(ImVec2 min, ImVec2 max, float alpha = 1);
|
||||
void DrawTextWithMarquee(const ImFont* font, float fontSize, const ImVec2& pos, const ImVec2& min, const ImVec2& max, ImU32 color, const char* text, double time, double delay, double speed);
|
||||
void DrawTextWithMarquee(const ImFont* font, float fontSize, const ImVec2& position, const ImVec2& min, const ImVec2& max, ImU32 color, const char* text, double time, double delay, double speed);
|
||||
void DrawTextWithMarqueeShadow(const ImFont* font, float fontSize, const ImVec2& pos, const ImVec2& min, const ImVec2& max, ImU32 colour, const char* text, double time, double delay, double speed, float offset = 2.0f, float radius = 1.0f, ImU32 shadowColour = IM_COL32(0, 0, 0, 255));
|
||||
void DrawTextWithOutline(const ImFont* font, float fontSize, const ImVec2& pos, ImU32 color, const char* text, float outlineSize, ImU32 outlineColor, uint32_t shaderModifier = IMGUI_SHADER_MODIFIER_NONE);
|
||||
void DrawTextWithShadow(const ImFont* font, float fontSize, const ImVec2& pos, ImU32 colour, const char* text, float offset = 2.0f, float radius = 1.0f, ImU32 shadowColour = IM_COL32(0, 0, 0, 255));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue