16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-17 23:39:18 +02:00

Replace ExchangeCharInString with std::ranges::replace

This commit is contained in:
docentYT
2026-05-01 00:43:22 +02:00
parent 2faf3293b1
commit 350123fb9e
4 changed files with 5 additions and 23 deletions

View File

@@ -1600,7 +1600,9 @@ transcripts_panel::update() {
for( auto const &transcript : ui::Transcripts.aLines ) { for( auto const &transcript : ui::Transcripts.aLines ) {
if( Global.fTimeAngleDeg + ( transcript.fShow - Global.fTimeAngleDeg > 180 ? 360 : 0 ) < transcript.fShow ) { continue; } if( Global.fTimeAngleDeg + ( transcript.fShow - Global.fTimeAngleDeg > 180 ? 360 : 0 ) < transcript.fShow ) { continue; }
text_lines.emplace_back( ExchangeCharInString( transcript.asText, '|', ' ' ), colors::white ); std::string text = transcript.asText;
std::ranges::replace(text, '|', ' ');
text_lines.emplace_back( text, colors::white );
} }
} }

View File

@@ -20,7 +20,8 @@ TTranscripts::AddLine( std::string const &txt, float show, float hide, bool it )
hide = Global.fTimeAngleDeg + hide / 240.0; hide = Global.fTimeAngleDeg + hide / 240.0;
TTranscript transcript; TTranscript transcript;
transcript.asText = ExchangeCharInString( txt, '|', ' ' ); // NOTE: legacy transcript lines use | as new line mark transcript.asText = txt;
std::ranges::replace(transcript.asText, '|', ' '); // NOTE: legacy transcript lines use | as new line mark
transcript.fShow = show; transcript.fShow = show;
transcript.fHide = hide; transcript.fHide = hide;
transcript.bItalic = it; transcript.bItalic = it;

View File

@@ -154,26 +154,6 @@ bool FuzzyLogicAI(double Test, double Threshold, double Probability)
return false; return false;
} }
std::string ExchangeCharInString(std::string const &Source, char const From, char const To)
{
std::string replacement;
replacement.reserve(Source.size());
std::for_each(std::begin(Source), std::end(Source),
[&](char const idx)
{
if (idx != From)
{
replacement += idx;
}
else
{
replacement += To;
}
});
return replacement;
}
std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems) std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems)
{ // dzieli tekst na wektor tekstow { // dzieli tekst na wektor tekstow

View File

@@ -122,7 +122,6 @@ bool FuzzyLogicAI(double Test, double Threshold, double Probability);
/*to samo ale zawsze niezaleznie od DebugFlag*/ /*to samo ale zawsze niezaleznie od DebugFlag*/
/*operacje na stringach*/ /*operacje na stringach*/
std::string ExchangeCharInString(std::string const &Source, char const From, char const To); // zamienia jeden znak na drugi
std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems); std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems);
std::vector<std::string> Split(const std::string &s, char delim); std::vector<std::string> Split(const std::string &s, char delim);
// std::vector<std::string> Split(const std::string &s); // std::vector<std::string> Split(const std::string &s);