Example #1
0
        private static IEnumerable <string> GetPlantedNames(string pathBCSV, string fn = "FgMainParam.bcsv")
        {
            var bcsv     = BCSVConverter.GetBCSV(pathBCSV, fn);
            var dict     = bcsv.GetFieldDictionary();
            var fType    = dict[0x48EF0398];
            var fname    = dict[0x87BF00E8];
            var findex   = dict[0x54706054];
            var fcomment = dict[0x3F45F2BF];

            var result = new List <string>();

            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var iid  = bcsv.ReadValue(i, findex);
                var ival = (ushort)short.Parse(iid);

                var name    = bcsv.ReadValue(i, fname).TrimEnd('\0');
                var comment = bcsv.ReadValue(i, fcomment).TrimEnd('\0');
                var type    = bcsv.ReadValue(i, fType).TrimEnd('\0');

                if (!Enum.TryParse <FieldItemKind>(type, out var k))
                {
                    throw new InvalidEnumArgumentException($"{type} is not a known enum value @ index {i}. Update the enum index first.");
                }

                var v   = $"new {nameof(FieldItemDefinition)}(0x{ival:X}, \"{name}\", {nameof(FieldItemKind)}.{k})";
                var kvp = $"{{0x{ival:X}, {v}}}, // {comment}";
                result.Add(kvp);
            }

            result.Sort();
            return(result);
        }
Example #2
0
        public static List <string> GetMilestoneList(string pathBCSV, string fn = "EventFlagsLifeSupportAchievementParam.bcsv")
        {
            var bcsv = BCSVConverter.GetBCSV(pathBCSV, fn);

            var dict   = bcsv.GetFieldDictionary();
            var findex = dict[0x54706054];
            var fname  = dict[0x45F320F2];
            var fjp    = dict[0x85CF1615];

            var result = new List <string>();

            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var iid  = bcsv.ReadValue(i, findex);
                var ival = ushort.Parse(iid);

                var name = bcsv.ReadValue(i, fname).TrimEnd('\0');
                var jp   = bcsv.ReadValue(i, fjp).TrimEnd('\0');

                var kvp = $"{{{ival:00}, \"{name}\"}}, // {jp}";
                result.Add(kvp);
            }

            result.Sort();
            return(result);
        }
Example #3
0
        /// <summary>
        /// Dumps everything the program uses to the provided <see cref="dest"/>, using the provided <see cref="pathBCSV"/>.
        /// </summary>
        /// <param name="pathBCSV">Source of <see cref="BCSV"/> files.</param>
        /// <param name="dest">Destination folder where the dumps will be saved.</param>
        public static void UpdateDumps(string pathBCSV, string dest)
        {
            BCSVConverter.DumpAll(pathBCSV, dest);
            var itemNames = GameInfo.Strings.itemlist;

            void DumpS(string fn, IEnumerable <string> lines)
            {
                File.WriteAllLines(Path.Combine(dest, fn), lines);
                Console.WriteLine($"Created {fn}");
            }

            void DumpB(string fn, byte[] bytes)
            {
                File.WriteAllBytes(Path.Combine(dest, fn), bytes);
                Console.WriteLine($"Created {fn}");
            }

            DumpS("milestones.txt", GetMilestoneList(pathBCSV));
            DumpS("recipeDictionary.txt", GetRecipeList(pathBCSV));
            DumpS("outsideAcres.txt", GetAcreNames(pathBCSV));

            DumpS("fish.txt", GetFishList(pathBCSV, itemNames));
            DumpS("bugs.txt", GetInsectList(pathBCSV, itemNames));

            DumpS("ItemKind.txt", GetPossibleEnum(pathBCSV, "ItemParam.bcsv", 0xFC275E86));
            DumpS("PlantKind.txt", GetPossibleEnum(pathBCSV, "FgMainParam.bcsv", 0x48EF0398));

            DumpB("item_kind.bin", GetItemKindArray(pathBCSV));
            DumpS("plants.txt", GetPlantedNames(pathBCSV));
        }
Example #4
0
        private static IEnumerable <string> GetLandEventFlagNames(string pathBCSV, string fn = "EventFlagsLandParam.bcsv")
        {
            var bcsv     = BCSVConverter.GetBCSV(pathBCSV, fn);
            var dict     = bcsv.GetFieldDictionary();
            var fv1      = dict[0x4C24F1CF];
            var fv2      = dict[0x344B17D7];
            var fname    = dict[0x45F320F2];
            var findex   = dict[0x54706054];
            var fcomment = dict[0x85CF1615];

            var result = new List <string>();

            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var iv1  = bcsv.ReadValue(i, fv1).Substring(2);
                var iv1a = short.Parse(iv1, NumberStyles.HexNumber);

                var iv2  = bcsv.ReadValue(i, fv2).Substring(2);
                var iv2a = short.Parse(iv2, NumberStyles.HexNumber);

                var iid  = bcsv.ReadValue(i, findex);
                var ival = (ushort)short.Parse(iid);

                var name    = bcsv.ReadValue(i, fname).TrimEnd('\0');
                var comment = bcsv.ReadValue(i, fcomment).TrimEnd('\0');

                var paddedName = $"\"{name}\"".PadRight(45, ' ');
                var v          = $"new {nameof(EventFlagLand)}({iv1a,-2}, {iv2a,-5}, {ival:0000}, {paddedName})";
                var kvp        = $"{{0x{ival:X3}, {v}}}, // {comment}";
                result.Add(kvp);
            }

            result.Sort();
            return(result);
        }
Example #5
0
        public static List <string> GetRecipeList(string pathBCSV, string fn = "RecipeCraftParam.bcsv")
        {
            var bcsv = BCSVConverter.GetBCSV(pathBCSV, fn);

            var dict    = bcsv.GetFieldDictionary();
            var frecipe = dict[0x54706054];
            var fitemID = dict[0x89A3482C];

            var items = GameInfo.Strings.itemlist;

            var result = new List <string>();

            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var iid  = bcsv.ReadValue(i, fitemID);
                var ival = ushort.Parse(iid);

                var rid  = bcsv.ReadValue(i, frecipe);
                var rval = ushort.Parse(rid);

                var kvp = $"{{0x{rval:X3}, {ival:00000}}}, // {items[ival]}";
                result.Add(kvp);
            }

            result.Sort();
            return(result);
        }
Example #6
0
        private static IEnumerable <string> GetVillagerEventFlagNamesMemoryPlayer(string pathBCSV, string fn = "EventFlagsNpcMemoryParam.bcsv")
        {
            var bcsv     = BCSVConverter.GetBCSV(pathBCSV, fn);
            var dict     = bcsv.GetFieldDictionary();
            var finit    = dict[0xD55938BD];
            var fmax     = dict[0xBD7682F5];
            var fname    = dict[0x45F320F2];
            var findex   = dict[0x54706054];
            var fcomment = dict[0x85CF1615];

            var result = new List <string>();

            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var isinit = bcsv.ReadValue(i, finit);
                var iinit  = short.Parse(isinit);

                var ismax = bcsv.ReadValue(i, fmax);
                var imax  = short.Parse(ismax);

                var iid   = bcsv.ReadValue(i, findex);
                var index = (ushort)short.Parse(iid);

                var name    = bcsv.ReadValue(i, fname).TrimEnd('\0');
                var comment = bcsv.ReadValue(i, fcomment).TrimEnd('\0');

                var paddedName = $"\"{name}\"".PadRight(45, ' ');
                var v          = $"new {nameof(EventFlagVillagerMemoryPlayer)}({iinit,-2}, {imax,-3}, {index:000}, {paddedName})";
                var kvp        = $"{{0x{index:X2}, {v}}}, // {comment}";
                result.Add(kvp);
            }

            result.Sort();
            return(result);
        }
Example #7
0
        public static List <string> GetLifeSupportAchievementList(string pathBCSV, string fn = "EventFlagsLifeSupportAchievementParam.bcsv")
        {
            var bcsv = BCSVConverter.GetBCSV(pathBCSV, fn);

            var dict     = bcsv.GetFieldDictionary();
            var findex   = dict[0x54706054];
            var fname    = dict[0x45F320F2];
            var fcomment = dict[0x85CF1615];
            var fLand    = dict[0x3FE43170];
            var fPlayer  = dict[0x4171A41D];

            var fmaxLevel   = dict[0x1BE772F0];
            var fThreshold1 = dict[0xCE0933FC];
            var fThreshold2 = dict[0x89A9492C];
            var fThreshold3 = dict[0xB4C9609C];
            var fThreshold4 = dict[0x06E9BC8C];
            var fThreshold5 = dict[0x3B89953C];

            var result = new List <string>();

            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                int readHex(BCSVFieldParam p) => int.Parse(bcsv.ReadValue(i, p).Substring(2), NumberStyles.HexNumber);

                var iid   = bcsv.ReadValue(i, findex);
                var index = ushort.Parse(iid);

                var land   = readHex(fLand);
                var player = readHex(fPlayer);

                var name       = bcsv.ReadValue(i, fname).TrimEnd('\0');
                var paddedName = $"\"{name}\"".PadRight(30, ' ');

                var comment = bcsv.ReadValue(i, fcomment).TrimEnd('\0');

                var tmp = bcsv.ReadValue(i, fmaxLevel);
                var max = ushort.Parse(tmp);
                var t1  = readHex(fThreshold1);
                var t2  = readHex(fThreshold2);
                var t3  = readHex(fThreshold3);
                var t4  = readHex(fThreshold4);
                var t5  = readHex(fThreshold5);

                var values = $"{max}, {t1:0000}, {t2:0000}, {t3:0000}, {t4:0000}, {t5:0000}";

                var v   = $"new {nameof(LifeSupportAchievement)}({index:000}, {values}, {land,3}, {player,3}, {paddedName})";
                var kvp = $"{{0x{index:X2}, {v}}}, // {comment}";
                result.Add(kvp);
            }

            result.Sort();
            return(result);
        }
Example #8
0
        private static IEnumerable<ushort> GetItemList(string pathBCSV, string fn, uint keyItemIDColumn)
        {
            var bcsv = BCSVConverter.GetBCSV(pathBCSV, fn);
            var dict = bcsv.GetFieldDictionary();
            var findex = dict[keyItemIDColumn];

            var result = new List<ushort>();
            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var iid = bcsv.ReadValue(i, findex);
                var ival = ushort.Parse(iid);
                result.Add(ival);
            }

            result.Sort();
            return result;
        }
Example #9
0
        /// <summary>
        /// Dumps everything the program uses to the provided <see cref="dest"/>, using the provided <see cref="pathBCSV"/>.
        /// </summary>
        /// <param name="pathBCSV">Source of <see cref="BCSV"/> files.</param>
        /// <param name="dest">Destination folder where the dumps will be saved.</param>
        /// <param name="csv">Convert all <see cref="BCSV"/> files to CSV for easy viewing.</param>
        /// <param name="delim">Delimiter when exporting the <see cref="csv"/> files</param>
        public static void UpdateDumps(string pathBCSV, string dest, bool csv = false, string delim = "\t")
        {
            var itemNames = GameInfo.Strings.itemlist;

            void DumpS(string fn, IEnumerable<string> lines)
            {
                File.WriteAllLines(Path.Combine(dest, fn), lines);
                Console.WriteLine($"Created {fn}");
            }

            void DumpB(string fn, byte[] bytes)
            {
                File.WriteAllBytes(Path.Combine(dest, fn), bytes);
                Console.WriteLine($"Created {fn}");
            }

            DumpS("lifeSupportAchievement.txt", GetLifeSupportAchievementList(pathBCSV));
            DumpS("recipeDictionary.txt", GetRecipeList(pathBCSV));
            DumpS("outsideAcres.txt", GetAcreNames(pathBCSV));

            DumpS("fish.txt", GetFishList(pathBCSV, itemNames));
            DumpS("bugs.txt", GetInsectList(pathBCSV, itemNames));
            DumpS("fossils.txt", GetFossilList(pathBCSV, itemNames));
            DumpS("eventFlagPlayer.txt", GetEventFlagNames(pathBCSV));
            DumpS("eventFlagVillager.txt", GetVillagerEventFlagNames(pathBCSV));
            DumpS("eventFlagLand.txt", GetLandEventFlagNames(pathBCSV));

            DumpS("ItemKind.txt", GetPossibleEnum(pathBCSV, "ItemParam.bcsv", 0xFC275E86));
            DumpS("ItemSize.txt", GetPossibleEnum(pathBCSV, "ItemParam.bcsv", 0xE06FB090));
            DumpS("PlantKind.txt", GetPossibleEnum(pathBCSV, "FgMainParam.bcsv", 0x48EF0398));
            DumpS("TerrainKind.txt", GetNumberedEnumValues(pathBCSV, "FieldLandMakingUnitModelParam.bcsv", 0x39B5A93D, 0x54706054));
            DumpS("BridgeKind.txt", GetNumberedEnumValues(pathBCSV, "StructureBridgeParam.bcsv", 0x39B5A93D, 0x54706054));
            DumpS("BridgeMaterial.txt", GetNumberedEnumValues(pathBCSV, "StructureBridgeTypeParam.bcsv", 0x68CF5938, 0x54706054));
            DumpS("SlopeKind.txt", GetNumberedEnumValues(pathBCSV, "StructureSlopeParam.bcsv", 0x39B5A93D, 0x54706054));
            DumpS("RoofKind.txt", GetNumberedEnumValues(pathBCSV, "StructureHouseRoofParam.bcsv", 0x39B5A93D, 0x54706054));
            DumpS("DoorKind.txt", GetNumberedEnumValues(pathBCSV, "StructureHouseDoorParam.bcsv", 0x39B5A93D, 0x54706054));
            DumpS("WallKind.txt", GetNumberedEnumValues(pathBCSV, "StructureHouseWallParam.bcsv", 0x39B5A93D, 0x54706054));

            DumpB("item_kind.bin", GetItemKindArray(pathBCSV));
            DumpB("item_size.bin", GetItemSizeArray(pathBCSV));
            DumpS("plants.txt", GetPlantedNames(pathBCSV));
            DumpS("item_size_dictionary.txt", GetItemSizeDictionary(pathBCSV));

            if (csv)
                BCSVConverter.DumpAll(pathBCSV, dest, delim);
        }
Example #10
0
        private static IEnumerable<string> GetAcreNames(string pathBCSV, string fn = "FieldOutsideParts.bcsv")
        {
            var bcsv = BCSVConverter.GetBCSV(pathBCSV, fn);
            var dict = bcsv.GetFieldDictionary();
            var findex = dict[0x54706054];
            var fname = dict[0x39B5A93D];

            var result = new List<string>();
            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var iid = bcsv.ReadValue(i, findex);
                var ival = ushort.Parse(iid);

                var name = bcsv.ReadValue(i, fname).TrimEnd('\0');

                var kvp = $"{{0x{ival:X2}, \"{name}\"}}, // {ival}";
                result.Add(kvp);
            }

            result.Sort();
            return result;
        }
        public static List <string> GetLifeSupportAchievementList(string pathBCSV, string fn = "EventFlagsLifeSupportAchievementParam.bcsv")
        {
            var bcsv = BCSVConverter.GetBCSV(pathBCSV, fn);

            var dict     = bcsv.GetFieldDictionary();
            var findex   = dict[0x54706054];
            var fname    = dict[0x45F320F2];
            var fcomment = dict[0x85CF1615];
            var fv1      = dict[0x3FE43170];
            var fv2      = dict[0x4171A41D];

            var result = new List <string>();

            for (int i = 0; i < bcsv.EntryCount; i++)
            {
                var iid  = bcsv.ReadValue(i, findex);
                var ival = ushort.Parse(iid);

                ival++; // offset by 1; index 0 is used for something else

                var iv1  = bcsv.ReadValue(i, fv1).Substring(2);
                var iv1a = int.Parse(iv1, NumberStyles.HexNumber);

                var iv2  = bcsv.ReadValue(i, fv2).Substring(2);
                var iv2a = int.Parse(iv2, NumberStyles.HexNumber);

                var name    = bcsv.ReadValue(i, fname).TrimEnd('\0');
                var comment = bcsv.ReadValue(i, fcomment).TrimEnd('\0');

                var paddedName = $"\"{name}\"".PadRight(30, ' ');
                var v          = $"new {nameof(LifeSupportAchievement)}({iv1a,2}, {iv2a,4}, {ival:0000}, {paddedName})";
                var kvp        = $"{{0x{ival:X3}, {v}}}, // {comment}";
                result.Add(kvp);
            }

            result.Sort();
            return(result);
        }
Example #12
0
 public static void UpdateCSV(string pathBCSV, string dest, bool remapColumns = false, string delim = "\t")
 {
     BCSV.DecodeColumnNames = remapColumns;
     Directory.CreateDirectory(dest);
     BCSVConverter.DumpAll(pathBCSV, dest, delim);
 }