Skip to content

Commit

Permalink
hopefully fixes [this](#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
headassbtw committed Jul 19, 2021
1 parent 816049d commit 3d4b598
Showing 1 changed file with 49 additions and 33 deletions.
82 changes: 49 additions & 33 deletions CustomMenuText/Views/TextSelector/TextSelectorViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,44 +284,60 @@ public void SetupTextList()

foreach(var TextEntry in Plugin.allEntries)
{
if(TextEntry.Length > 4)
{
line1 = TextEntry[0];
line1 = line1.Substring(0, 10);
line2 = TextEntry[1];
line2 = line2.Substring(0, 7) + "...";
}
if(TextEntry.Length != 2)
{
string regex = "(<size[^a-b]{2,}?>)";
string top = "";
string bottom = "";
for (int i = 0; i < TextEntry.Length; i++)
if (i < TextEntry.Length / 2 && i != 0) top += " " + TextEntry[i];
else if (i < TextEntry.Length / 2) top += TextEntry[i];
else bottom += " " + TextEntry[i];

line1 = Regex.Replace(top, regex, "");
line2 = Regex.Replace(bottom, regex, "");

if (Regex.Replace(line1, "(<[^x]{2,}?>)", "").Length > 20) line1 = line1.Substring(0, 20);
if (Regex.Replace(line2, "(<[^x]{2,}?>)", "").Length > 20) line2 = line2.Substring(0, 17) + "...";
//line1 = String.Join("\n", TextEntry);
//line2 = "";
}
if(TextEntry.Length == 2)
try
{
string regex = "(<size[^a-b]{2,}?>)";
if (TextEntry.Length > 4)
{
line1 = TextEntry[0];
line1 = line1.Substring(0, 10);
line2 = TextEntry[1];
line2 = line2.Substring(0, 7) + "...";
}

if (TextEntry.Length != 2)
{
string regex = "(<size[^a-b]{2,}?>)";
string top = "";
string bottom = "";
for (int i = 0; i < TextEntry.Length; i++)
if (i < TextEntry.Length / 2 && i != 0) top += " " + TextEntry[i];
else if (i < TextEntry.Length / 2) top += TextEntry[i];
else bottom += " " + TextEntry[i];

line1 = Regex.Replace(top, regex, "");
line2 = Regex.Replace(bottom, regex, "");

if (Regex.Replace(line1, "(<[^x]{2,}?>)", "").Length > 20) line1 = line1.Substring(0, 20);
if (Regex.Replace(line2, "(<[^x]{2,}?>)", "").Length > 20)
line2 = line2.Substring(0, 17) + "...";
//line1 = String.Join("\n", TextEntry);
//line2 = "";
}

if (TextEntry.Length == 2)
{
string regex = "(<size[^a-b]{2,}?>)";



line1 = Regex.Replace(TextEntry[0], regex, "");
line2 = Regex.Replace(TextEntry[1], regex, "");
}

line1 = Regex.Replace(TextEntry[0], regex, "");
line2 = Regex.Replace(TextEntry[1], regex, "");
}

if (line1 != "" || line2 != "") line1 = Tools.ColorToHex(Plugin.MainColor) + line1;
if (line1 != "" || line2 != "") line2 = Tools.ColorToHex(Plugin.BottomColor) + line2;
if (TextEntry.Length == 0)
{
line1 = "[Empty]";
line2 = " ";
}

if (line1 != "" || line2 != "") line1 = Tools.ColorToHex(Plugin.MainColor) + line1;
if (line1 != "" || line2 != "") line2 = Tools.ColorToHex(Plugin.BottomColor) + line2;
}
catch (Exception e)
{
line1 = "Failed to";
line2 = "load preview";
}

Cell toAdd = new Cell(line1, line2);
CellList.Add(toAdd);
Expand Down

0 comments on commit 3d4b598

Please sign in to comment.