Skip to content

Commit

Permalink
Expand customization
Browse files Browse the repository at this point in the history
FossilOrigin-Name: dcfe34bfcff553d90ae7f55ce1e77833c281b246f830e5b9cc1581193be6556b
  • Loading branch information
librarianmage committed Jul 24, 2022
1 parent d1b67a4 commit 774e5a3
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 28 deletions.
5 changes: 3 additions & 2 deletions Options.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<options>
<option ID="Books_FinderOfRuin_Color" DisplayText="&amp;MColor&amp;y hint text (requires restart)" Category="Finder of Ruin" Type="Checkbox" Default="Yes" />
<option ID="Books_FinderOfRuin_Capitalization" DisplayText="CAPTIALIZE hint text (requires restart)" Category="Finder of Ruin" Type="Combo" Values="Default,Key Words,Entire Clue" Default="Default" />
<option ID="Books_FinderOfRuin_Highlight" DisplayText="Highlight hint text" Category="Finder of Ruin" Type="Combo" Values="None,Key Words,Entire Clue" Default="Key Words"/>
<option ID="Books_FinderOfRuin_HighlightStyle" DisplayText="Highlight color style" Category="Finder of Ruin" Type="Combo" Values="White,Colored Key Words" Default="Colored Key Words" />
<option ID="Books_FinderOfRuin_Capitalization" DisplayText="CAPTIALIZE hint text" Category="Finder of Ruin" Type="Combo" Values="Default,Key Words,Entire Clue" Default="Default" />
</options>
77 changes: 51 additions & 26 deletions ruin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,68 @@ class LorePatcher
{
static void Postfix(ref string __result)
{
String Color = Options.GetOption("Books_FinderOfRuin_Color", "No");
String Highlight = Options.GetOption("Books_FinderOfRuin_Highlight", "Key Words");
String HighlightStyle = Options.GetOption("Books_FinderOfRuin_HighlightStyle", "Colored Key Words");
String Capitalization = Options.GetOption("Books_FinderOfRuin_Capitalization", "Default");

if (Capitalization == "Key Words")
if (Highlight == "Entire Clue" || Capitalization == "Entire Clue")
{
__result = __result
.Replace("masterwork", "MASTERWORK")
.Replace("Ruin", "RUIN")
.Replace("House Isner", "HOUSE ISNER");
}
else if (Capitalization == "Entire Clue") {
Regex rx = new Regex(@"\{(.*)\}");
MatchEvaluator evaluator = new MatchEvaluator(Capitalize);

Func<Match, String> match = (Match m) =>
{
String hint = m.Captures[0].Value;
if (Capitalization == "Entire Clue") { hint = hint.ToUpper(); };
if (Highlight == "Entire Clue") { hint = "&Y" + hint + "&y"; }
return hint;
};

MatchEvaluator evaluator = new MatchEvaluator(match);
__result = rx.Replace(__result, evaluator);
}

if (Color == "Yes")
if (Highlight == "Key Words" || Capitalization == "Key Words" || (Highlight == "Entire Clue" && HighlightStyle == "Colored Key Words"))
{
if (Capitalization == "Default")
{
__result = __result
.Replace("masterwork", "&cmasterwork&y")
.Replace("Ruin", "&rRuin&y")
.Replace("House Isner", "&MHouse Isner&y");
}
else
Regex rx = new Regex(@"(masterwork|ruin|house isner)", RegexOptions.IgnoreCase);

Func<Match, String> match = (Match m) =>
{
__result = __result
.Replace("MASTERWORK", "&cMASTERWORK&y")
.Replace("RUIN", "&rRUIN&y")
.Replace("HOUSE ISNER", "&MHOUSE ISNER&y");
}
}
String hint = m.Captures[0].Value;
if (Capitalization == "Key Words") { hint = hint.ToUpper(); };
if (Highlight != "Default" && HighlightStyle == "Colored Key Words")
{
String restColor = (Highlight == "Entire Clue") ? "&Y" : "&y";
String startColor;

if (hint.ToLower() == "masterwork")
{
startColor = "&c";
}
else if (hint.ToLower() == "ruin")
{
startColor = "&r";
}
else if (hint.ToLower() == "house isner")
{
startColor = "&M";
}
else
{
startColor = restColor;
}

}
hint = startColor + hint + restColor;
}
else if (Highlight == "Key Words" && HighlightStyle == "White")
{
hint = "&Y" + hint + "&y";
}
return hint;
};

static string Capitalize(Match m) => m.Captures[0].Value.ToUpper();
MatchEvaluator evaluator = new MatchEvaluator(match);
__result = rx.Replace(__result, evaluator);
}
}
}
}

0 comments on commit 774e5a3

Please sign in to comment.