Add RC propellers and fix textblock <color> replacement regex
This commit is contained in:
parent
3c00d05a3b
commit
c3dc80fc84
3 changed files with 16 additions and 24 deletions
|
@ -35,14 +35,8 @@ namespace Pixi.Robots
|
||||||
|
|
||||||
if (!botprints.ContainsKey(root.name) || RobotInternetImporter.CubeSize != 3)
|
if (!botprints.ContainsKey(root.name) || RobotInternetImporter.CubeSize != 3)
|
||||||
{
|
{
|
||||||
if (!parent.textBlockInfo.ContainsKey(name))
|
BlockJsonInfo copy = root;
|
||||||
{
|
copy.name = $"TextBlock\t{root.name} ({CubeUtility.CubeIdDescription(uint.Parse(root.name))})\tPixi";
|
||||||
parent.textBlockInfo[name] = new FasterList<string>();
|
|
||||||
}
|
|
||||||
BlockJsonInfo copy = root;
|
|
||||||
copy.name = "TextBlock";
|
|
||||||
Logging.MetaLog($"Parsing uint from '{root.name}'");
|
|
||||||
parent.textBlockInfo[name].Add(root.name + " (" + CubeUtility.CubeIdDescription(uint.Parse(root.name)) + ")");
|
|
||||||
return new BlockJsonInfo[1] {copy};
|
return new BlockJsonInfo[1] {copy};
|
||||||
}
|
}
|
||||||
BlockJsonInfo[] blueprint = botprints[root.name];
|
BlockJsonInfo[] blueprint = botprints[root.name];
|
||||||
|
|
|
@ -27,8 +27,6 @@ namespace Pixi.Robots
|
||||||
public BlueprintProvider BlueprintProvider { get; }
|
public BlueprintProvider BlueprintProvider { get; }
|
||||||
|
|
||||||
public static int CubeSize = 3;
|
public static int CubeSize = 3;
|
||||||
|
|
||||||
internal readonly Dictionary<string, FasterList<string>> textBlockInfo = new Dictionary<string, FasterList<string>>();
|
|
||||||
|
|
||||||
public RobotInternetImporter()
|
public RobotInternetImporter()
|
||||||
{
|
{
|
||||||
|
@ -126,34 +124,26 @@ namespace Pixi.Robots
|
||||||
blocks[i].position += pos;
|
blocks[i].position += pos;
|
||||||
}
|
}
|
||||||
// set textblock colors (replace <color="white"> with <color=#HEX> in textblocks)
|
// set textblock colors (replace <color="white"> with <color=#HEX> in textblocks)
|
||||||
Regex pattern = new Regex("<color=(\"white\")|(white)>", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
Regex pattern = new Regex("<color=((?:\"white\")|(?:white))>", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
|
||||||
for (int i = 0; i < blocks.Length; i++)
|
for (int i = 0; i < blocks.Length; i++)
|
||||||
{
|
{
|
||||||
if (blocks[i].block == BlockIDs.TextBlock)
|
if (blocks[i].block == BlockIDs.TextBlock)
|
||||||
{
|
{
|
||||||
// TODO this blindly replaces color tags anywhere in metadata, not just ones that will go in the TextBlock's text field
|
// TODO this blindly replaces color tags anywhere in metadata, not just ones that will go in the TextBlock's text field
|
||||||
|
#if DEBUG
|
||||||
|
Logging.MetaLog($"Replacing text field in block with colour {blocks[i].color} with #{ColorUtility.ToHtmlStringRGBA(ColorSpaceUtility.UnquantizeToColor(blocks[i].color))}");
|
||||||
|
#endif
|
||||||
blocks[i].metadata = pattern.Replace(
|
blocks[i].metadata = pattern.Replace(
|
||||||
blocks[i].metadata,
|
blocks[i].metadata,
|
||||||
$"<color=#{ColorUtility.ToHtmlStringRGBA(ColorSpaceUtility.UnquantizeToColor(blocks[i].color))}>");
|
$"<color=#{ColorUtility.ToHtmlStringRGBA(ColorSpaceUtility.UnquantizeToColor(blocks[i].color))}>");
|
||||||
|
// NOTE: Regex.Replace replaces the whole match string only when there's a capture group (it's dumb, idk why).
|
||||||
|
// The non-capturing groups may be messing with .NET or something
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PostProcess(string name, ref Block[] blocks)
|
public void PostProcess(string name, ref Block[] blocks)
|
||||||
{
|
{
|
||||||
int textBlockInfoIndex = 0;
|
|
||||||
for (int c = 0; c < blocks.Length; c++)
|
|
||||||
{
|
|
||||||
Block block = blocks[c];
|
|
||||||
// the goal is for this to never evaluate to true (ie all cubes are translated correctly)
|
|
||||||
if (block.Type == BlockIDs.TextBlock)
|
|
||||||
{
|
|
||||||
block.Specialise<TextBlock>().Text = textBlockInfo[name][textBlockInfoIndex];
|
|
||||||
textBlockInfoIndex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
textBlockInfo.Remove(name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue