Fix repair kits swapping, bad parsing
This commit is contained in:
@@ -277,7 +277,10 @@ namespace UIFixes
|
||||
var match = Regex.Match(text, @" %\((.*)\)");
|
||||
if (match.Success)
|
||||
{
|
||||
float value = float.Parse(match.Groups[1].Value);
|
||||
float value;
|
||||
// If this fails to parse, I don't know what it is, leave it be
|
||||
if (float.TryParse(match.Groups[1].Value, out value))
|
||||
{
|
||||
string sign = value > 0 ? "+" : "";
|
||||
string color = (attribute.LessIsGood && value < 0) || (!attribute.LessIsGood && value > 0) ? increasingColorHex : decreasingColorHex;
|
||||
|
||||
@@ -291,34 +294,42 @@ namespace UIFixes
|
||||
text = Regex.Replace(text, @"%\(.*\)", "%<color=" + color + ">(" + sign + value.ToString("P1") + ")</color>");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Others are rendered as num + "%", so there's no space before the %. These are percents but are from 0-100, not 0-1.
|
||||
match = Regex.Match(text, @"(\S)%\((.*)\)");
|
||||
if (match.Success)
|
||||
{
|
||||
float value = float.Parse(match.Groups[2].Value);
|
||||
float value;
|
||||
// If this fails to parse, I don't know what it is, leave it be
|
||||
if (float.TryParse(match.Groups[2].Value, out value))
|
||||
{
|
||||
string sign = value > 0 ? "+" : "";
|
||||
string color = (attribute.LessIsGood && value < 0) || (!attribute.LessIsGood && value > 0) ? increasingColorHex : decreasingColorHex;
|
||||
text = Regex.Replace(text, @"(\S)%\((.*)\)", match.Groups[1].Value + "%<color=" + color + ">(" + sign + value + "%)</color>");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Finally the ones that aren't percents
|
||||
match = Regex.Match(text, @"\((.*)\)");
|
||||
if (match.Success)
|
||||
{
|
||||
float value = float.Parse(match.Groups[1].Value);
|
||||
float value;
|
||||
// If this fails to parse, I don't know what it is, leave it be
|
||||
if (float.TryParse(match.Groups[1].Value, out value))
|
||||
{
|
||||
string sign = value > 0 ? "+" : "";
|
||||
string color = (attribute.LessIsGood && value < 0) || (!attribute.LessIsGood && value > 0) ? increasingColorHex : decreasingColorHex;
|
||||
text = Regex.Replace(text, @"\((.*)\)", "<color=" + color + ">(" + sign + value + ")</color>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove trailing 0s
|
||||
text = Regex.Replace(text, @"\.([1-9]*)0+\b", ".$1");
|
||||
text = Regex.Replace(text, @"\.\B", "");
|
||||
text = Regex.Replace(text, @"(\d)(\.[0-9]*[^0])?\.?0+\b", "$1$2");
|
||||
|
||||
// Fix spacing
|
||||
text = text.Replace(" %", "%");
|
||||
|
@@ -160,7 +160,7 @@ namespace UIFixes
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
private static void Postfix(GridView __instance, ItemContextClass itemContext, ItemContextAbstractClass targetItemContext, ref object operation, ref bool __result)
|
||||
private static void Postfix(GridView __instance, ItemContextClass itemContext, ItemContextAbstractClass targetItemContext, ref object operation, ref bool __result, Dictionary<string, ItemView> ___dictionary_0)
|
||||
{
|
||||
if (!ValidPrerequisites(itemContext, targetItemContext, operation))
|
||||
{
|
||||
@@ -177,6 +177,16 @@ namespace UIFixes
|
||||
return;
|
||||
}
|
||||
|
||||
// Repair kits are special
|
||||
ItemView targetItemView;
|
||||
if (___dictionary_0.TryGetValue(targetItem.Id, out targetItemView))
|
||||
{
|
||||
if (targetItemView.CanInteract(itemContext))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// This is the location you're dragging it over, including rotation
|
||||
LocationInGrid itemToLocation = __instance.CalculateItemLocation(itemContext);
|
||||
|
||||
|
Reference in New Issue
Block a user