Skip to content

Commit 774e5a3

Browse files
committed
Expand customization
FossilOrigin-Name: dcfe34bfcff553d90ae7f55ce1e77833c281b246f830e5b9cc1581193be6556b
1 parent d1b67a4 commit 774e5a3

File tree

2 files changed

+54
-28
lines changed

2 files changed

+54
-28
lines changed

Options.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<options>
3-
<option ID="Books_FinderOfRuin_Color" DisplayText="&amp;MColor&amp;y hint text (requires restart)" Category="Finder of Ruin" Type="Checkbox" Default="Yes" />
4-
<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" />
3+
<option ID="Books_FinderOfRuin_Highlight" DisplayText="Highlight hint text" Category="Finder of Ruin" Type="Combo" Values="None,Key Words,Entire Clue" Default="Key Words"/>
4+
<option ID="Books_FinderOfRuin_HighlightStyle" DisplayText="Highlight color style" Category="Finder of Ruin" Type="Combo" Values="White,Colored Key Words" Default="Colored Key Words" />
5+
<option ID="Books_FinderOfRuin_Capitalization" DisplayText="CAPTIALIZE hint text" Category="Finder of Ruin" Type="Combo" Values="Default,Key Words,Entire Clue" Default="Default" />
56
</options>

ruin.cs

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,68 @@ class LorePatcher
1212
{
1313
static void Postfix(ref string __result)
1414
{
15-
String Color = Options.GetOption("Books_FinderOfRuin_Color", "No");
15+
String Highlight = Options.GetOption("Books_FinderOfRuin_Highlight", "Key Words");
16+
String HighlightStyle = Options.GetOption("Books_FinderOfRuin_HighlightStyle", "Colored Key Words");
1617
String Capitalization = Options.GetOption("Books_FinderOfRuin_Capitalization", "Default");
1718

18-
if (Capitalization == "Key Words")
19+
if (Highlight == "Entire Clue" || Capitalization == "Entire Clue")
1920
{
20-
__result = __result
21-
.Replace("masterwork", "MASTERWORK")
22-
.Replace("Ruin", "RUIN")
23-
.Replace("House Isner", "HOUSE ISNER");
24-
}
25-
else if (Capitalization == "Entire Clue") {
2621
Regex rx = new Regex(@"\{(.*)\}");
27-
MatchEvaluator evaluator = new MatchEvaluator(Capitalize);
22+
23+
Func<Match, String> match = (Match m) =>
24+
{
25+
String hint = m.Captures[0].Value;
26+
if (Capitalization == "Entire Clue") { hint = hint.ToUpper(); };
27+
if (Highlight == "Entire Clue") { hint = "&Y" + hint + "&y"; }
28+
return hint;
29+
};
30+
31+
MatchEvaluator evaluator = new MatchEvaluator(match);
2832
__result = rx.Replace(__result, evaluator);
2933
}
3034

31-
if (Color == "Yes")
35+
if (Highlight == "Key Words" || Capitalization == "Key Words" || (Highlight == "Entire Clue" && HighlightStyle == "Colored Key Words"))
3236
{
33-
if (Capitalization == "Default")
34-
{
35-
__result = __result
36-
.Replace("masterwork", "&cmasterwork&y")
37-
.Replace("Ruin", "&rRuin&y")
38-
.Replace("House Isner", "&MHouse Isner&y");
39-
}
40-
else
37+
Regex rx = new Regex(@"(masterwork|ruin|house isner)", RegexOptions.IgnoreCase);
38+
39+
Func<Match, String> match = (Match m) =>
4140
{
42-
__result = __result
43-
.Replace("MASTERWORK", "&cMASTERWORK&y")
44-
.Replace("RUIN", "&rRUIN&y")
45-
.Replace("HOUSE ISNER", "&MHOUSE ISNER&y");
46-
}
47-
}
41+
String hint = m.Captures[0].Value;
42+
if (Capitalization == "Key Words") { hint = hint.ToUpper(); };
43+
if (Highlight != "Default" && HighlightStyle == "Colored Key Words")
44+
{
45+
String restColor = (Highlight == "Entire Clue") ? "&Y" : "&y";
46+
String startColor;
4847

48+
if (hint.ToLower() == "masterwork")
49+
{
50+
startColor = "&c";
51+
}
52+
else if (hint.ToLower() == "ruin")
53+
{
54+
startColor = "&r";
55+
}
56+
else if (hint.ToLower() == "house isner")
57+
{
58+
startColor = "&M";
59+
}
60+
else
61+
{
62+
startColor = restColor;
63+
}
4964

50-
}
65+
hint = startColor + hint + restColor;
66+
}
67+
else if (Highlight == "Key Words" && HighlightStyle == "White")
68+
{
69+
hint = "&Y" + hint + "&y";
70+
}
71+
return hint;
72+
};
5173

52-
static string Capitalize(Match m) => m.Captures[0].Value.ToUpper();
74+
MatchEvaluator evaluator = new MatchEvaluator(match);
75+
__result = rx.Replace(__result, evaluator);
76+
}
77+
}
5378
}
5479
}

0 commit comments

Comments
 (0)