Beispiel #1
0
        public static string RegionDirectory(string region_name)
        {
            FormatX.GetInt32(region_name, "L{X}R#", out int area);
            string loc = region_name.Substring(region_name.Length - 1, 1);

            return($"Location{area.ToString()}\\Region{loc.ToUpper()}");
        }
Beispiel #2
0
 public static bool TrackCollectionName(string CName)
 {
     // Allowed format: Track_#, where # is ushort
     if (!CName.StartsWith("Track_"))
     {
         return(false);
     }
     if (!FormatX.GetInt32(CName, "Track_{X}", out int result))
     {
         return(false);
     }
     return(result <= ushort.MaxValue);
 }
Beispiel #3
0
 public static bool TrackRegionName(string region_name)
 {
     // Allowed format: L#R&, where # = int number, & = ascii char
     if (!region_name.StartsWith("L"))
     {
         return(false);
     }
     if (region_name.Substring(region_name.Length - 2, 1) != "R")
     {
         return(false);
     }
     if ((byte)region_name[region_name.Length - 1] > sbyte.MaxValue)
     {
         return(false);
     }
     if (!FormatX.GetInt32(region_name, "L{X}R#", out int result))
     {
         return(false);
     }
     return(true);
 }
Beispiel #4
0
 public static string TrackDirectory(string region_name, string CName)
 {
     FormatX.GetInt32(region_name, "L{X}R#", out int area);
     return($"Location{area.ToString()}\\{CName}");
 }
Beispiel #5
0
        private static string ExecuteUpdateFNG(BasicBase db, string node, string field, string value)
        {
            if (!db.TryGetCollection(node, FNGroups, out var collection))
            {
                return($"Collection {node} does not exist in root {FNGroups}.");
            }
            if (!(collection is FNGroup fng))
            {
                return($"Collection {node} is not a {FNGroups} collection.");
            }

            if (!SAT.CanBeColor(value))
            {
                return($"Value {value} is not an 8-digit hexadecimal color-type.");
            }

            var color = new FEngColor(null);

            color.Alpha = SAT.GetAlpha(value);
            color.Red   = SAT.GetRed(value);
            color.Green = SAT.GetGreen(value);
            color.Blue  = SAT.GetBlue(value);

            if (field.StartsWith("ReplaceSame"))
            {
                if (field.StartsWith("ReplaceSameNoAlpha[") && field.EndsWith("]"))
                {
                    if (FormatX.GetInt32(field, "ReplaceSameNoAlpha[{X}]", out int index))
                    {
                        fng.TrySetSame(index, color, true);
                    }
                    else
                    {
                        return($"Unable to get color index from field named {field}.");
                    }
                }
                else if (field.StartsWith("ReplaceSameWithAlpha[") && field.EndsWith("]"))
                {
                    if (FormatX.GetInt32(field, "ReplaceSameWithAlpha[{X}]", out int index))
                    {
                        fng.TrySetSame(index, color, false);
                    }
                    else
                    {
                        return($"Unable to get color index from field named {field}.");
                    }
                }
                else
                {
                    return($"Incorrect passed parameter named {field}.");
                }
            }
            else if (field == "ReplaceAllNoAlpha")
            {
                fng.TrySetAll(color, true);
            }
            else if (field == "ReplaceAllWithAlpha")
            {
                fng.TrySetAll(color, false);
            }
            else
            {
                int index = SAT.GetIndex(field);
                if (index >= fng.InfoLength || index == -1)
                {
                    return($"Field named {field} does not exist.");
                }
                fng.TrySetOne(index, color);
            }
            return(null);
        }