private void DoBigCraftableEditorConnections(Node editor, TreeItem entry) { activeBig = bigs[entry]; if (activeBig.Recipe == null) { activeBig.Recipe = new RecipeData(); } DoEditorConnections(editor, activeBig); var intEdit = editor.GetNode <SpinBox>("Texture/SubImageEditor/Values/SubRectWidth/SpinBox"); intEdit.Value = 16; intEdit.Editable = false; intEdit = editor.GetNode <SpinBox>("Texture/SubImageEditor/Values/SubRectHeight/SpinBox"); intEdit.Value = 32; intEdit.Editable = false; intEdit = editor.GetNode <SpinBox>("ReserveExtraIndices/SubImageEditor/Values/SubRectHeight/SpinBox"); intEdit.Value = 32; intEdit.Editable = false; }
private void loadData(IContentPack contentPack) { Log.info($"\t{contentPack.Manifest.Name} {contentPack.Manifest.Version} by {contentPack.Manifest.Author} - {contentPack.Manifest.Description}"); // load objects DirectoryInfo objectsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Objects")); if (objectsDir.Exists) { foreach (DirectoryInfo dir in objectsDir.EnumerateDirectories()) { string relativePath = $"Objects/{dir.Name}"; // load data ObjectData obj = contentPack.ReadJsonFile <ObjectData>($"{relativePath}/object.json"); if (obj == null) { continue; } // save object obj.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/object.png"); if (obj.IsColored) { obj.textureColor = contentPack.LoadAsset <Texture2D>($"{relativePath}/color.png"); } this.objects.Add(obj); // save ring if (obj.Category == ObjectData.Category_.Ring) { this.myRings.Add(obj); } } } // load crops DirectoryInfo cropsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Crops")); if (cropsDir.Exists) { foreach (DirectoryInfo dir in cropsDir.EnumerateDirectories()) { string relativePath = $"Crops/{dir.Name}"; // load data CropData crop = contentPack.ReadJsonFile <CropData>($"{relativePath}/crop.json"); if (crop == null) { continue; } // save crop crop.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/crop.png"); crops.Add(crop); // save seeds crop.seed = new ObjectData { texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/seeds.png"), Name = crop.SeedName, Description = crop.SeedDescription, Category = ObjectData.Category_.Seeds, Price = crop.SeedPurchasePrice, CanPurchase = true, PurchaseFrom = crop.SeedPurchaseFrom, PurchasePrice = crop.SeedPurchasePrice, PurchaseRequirements = crop.SeedPurchaseRequirements ?? new List <string>() }; // TODO: Clean up this chunk // I copy/pasted it from the unofficial update decompiled string str = ""; string[] array = new string[] { "spring", "summer", "fall", "winter" }.Except(crop.Seasons).ToArray <string>(); for (int i = 0; i < array.Length; i++) { string season = array[i]; str += string.Format("/z {0}", season); } string strtrimstart = str.TrimStart(new char[] { '/' }); if (crop.SeedPurchaseRequirements != null && crop.SeedPurchaseRequirements.Count > 0) { for (int index = 0; index < crop.SeedPurchaseRequirements.Count; index++) { if (SeasonLimiter.IsMatch(crop.SeedPurchaseRequirements[index])) { crop.SeedPurchaseRequirements[index] = strtrimstart; Log.warn(string.Format(" Faulty season requirements for {0}!\n", crop.SeedName) + string.Format(" Fixed season requirements: {0}", crop.SeedPurchaseRequirements[index])); } } if (!crop.SeedPurchaseRequirements.Contains(str.TrimStart(new char[] { '/' }))) { Log.trace(string.Format(" Adding season requirements for {0}:\n", crop.SeedName) + string.Format(" New season requirements: {0}", strtrimstart)); crop.seed.PurchaseRequirements.Add(strtrimstart); } } else { Log.trace(string.Format(" Adding season requirements for {0}:\n", crop.SeedName) + string.Format(" New season requirements: {0}", strtrimstart)); crop.seed.PurchaseRequirements.Add(strtrimstart); } objects.Add(crop.seed); } } // load fruit trees DirectoryInfo fruitTreesDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "FruitTrees")); if (fruitTreesDir.Exists) { foreach (DirectoryInfo dir in fruitTreesDir.EnumerateDirectories()) { string relativePath = $"FruitTrees/{dir.Name}"; // load data FruitTreeData tree = contentPack.ReadJsonFile <FruitTreeData>($"{relativePath}/tree.json"); if (tree == null) { continue; } // save fruit tree tree.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/tree.png"); fruitTrees.Add(tree); // save seed tree.sapling = new ObjectData { texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/sapling.png"), Name = tree.SaplingName, Description = tree.SaplingDescription, Category = ObjectData.Category_.Seeds, Price = tree.SaplingPurchasePrice, CanPurchase = true, PurchaseRequirements = tree.SaplingPurchaseRequirements, PurchaseFrom = tree.SaplingPurchaseFrom, PurchasePrice = tree.SaplingPurchasePrice }; objects.Add(tree.sapling); } } // load big craftables DirectoryInfo bigCraftablesDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "BigCraftables")); if (bigCraftablesDir.Exists) { foreach (DirectoryInfo dir in bigCraftablesDir.EnumerateDirectories()) { string relativePath = $"BigCraftables/{dir.Name}"; // load data BigCraftableData craftable = contentPack.ReadJsonFile <BigCraftableData>($"{relativePath}/big-craftable.json"); if (craftable == null) { continue; } // save craftable craftable.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/big-craftable.png"); bigCraftables.Add(craftable); } } // load objects DirectoryInfo hatsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Hats")); if (hatsDir.Exists) { foreach (DirectoryInfo dir in hatsDir.EnumerateDirectories()) { string relativePath = $"Hats/{dir.Name}"; // load data HatData hat = contentPack.ReadJsonFile <HatData>($"{relativePath}/hat.json"); if (hat == null) { continue; } // save object hat.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/hat.png"); hats.Add(hat); } } }
private void loadData(IContentPack contentPack) { Log.info($"\t{contentPack.Manifest.Name} {contentPack.Manifest.Version} by {contentPack.Manifest.Author} - {contentPack.Manifest.Description}"); // load objects DirectoryInfo objectsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Objects")); if (objectsDir.Exists) { foreach (DirectoryInfo dir in objectsDir.EnumerateDirectories()) { string relativePath = $"Objects/{dir.Name}"; // load data ObjectData obj = contentPack.ReadJsonFile <ObjectData>($"{relativePath}/object.json"); if (obj == null) { continue; } // save object obj.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/object.png"); if (obj.IsColored) { obj.textureColor = contentPack.LoadAsset <Texture2D>($"{relativePath}/color.png"); } this.objects.Add(obj); // save ring if (obj.Category == ObjectData.Category_.Ring) { this.myRings.Add(obj); } // Duplicate check if (dupObjects.ContainsKey(obj.Name)) { Log.error($"Duplicate object: {obj.Name} just added by {contentPack.Manifest.Name}, already added by {dupObjects[obj.Name].Manifest.Name}!"); } else { dupObjects[obj.Name] = contentPack; } } } // load crops DirectoryInfo cropsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Crops")); if (cropsDir.Exists) { foreach (DirectoryInfo dir in cropsDir.EnumerateDirectories()) { string relativePath = $"Crops/{dir.Name}"; // load data CropData crop = contentPack.ReadJsonFile <CropData>($"{relativePath}/crop.json"); if (crop == null) { continue; } // save crop crop.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/crop.png"); crops.Add(crop); // save seeds crop.seed = new ObjectData { texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/seeds.png"), Name = crop.SeedName, Description = crop.SeedDescription, Category = ObjectData.Category_.Seeds, Price = crop.SeedPurchasePrice, CanPurchase = true, PurchaseFrom = crop.SeedPurchaseFrom, PurchasePrice = crop.SeedPurchasePrice, PurchaseRequirements = crop.SeedPurchaseRequirements ?? new List <string>(), NameLocalization = crop.SeedNameLocalization, DescriptionLocalization = crop.SeedDescriptionLocalization }; // TODO: Clean up this chunk // I copy/pasted it from the unofficial update decompiled string str = ""; string[] array = new[] { "spring", "summer", "fall", "winter" } .Except(crop.Seasons) .ToArray(); foreach (var season in array) { str += $"/z {season}"; } string strtrimstart = str.TrimStart(new char[] { '/' }); if (crop.SeedPurchaseRequirements != null && crop.SeedPurchaseRequirements.Count > 0) { for (int index = 0; index < crop.SeedPurchaseRequirements.Count; index++) { if (SeasonLimiter.IsMatch(crop.SeedPurchaseRequirements[index])) { crop.SeedPurchaseRequirements[index] = strtrimstart; Log.warn($" Faulty season requirements for {crop.SeedName}!\n Fixed season requirements: {crop.SeedPurchaseRequirements[index]}"); } } if (!crop.SeedPurchaseRequirements.Contains(str.TrimStart('/'))) { Log.trace($" Adding season requirements for {crop.SeedName}:\n New season requirements: {strtrimstart}"); crop.seed.PurchaseRequirements.Add(strtrimstart); } } else { Log.trace($" Adding season requirements for {crop.SeedName}:\n New season requirements: {strtrimstart}"); crop.seed.PurchaseRequirements.Add(strtrimstart); } objects.Add(crop.seed); // Duplicate check if (dupCrops.ContainsKey(crop.Name)) { Log.error($"Duplicate crop: {crop.Name} just added by {contentPack.Manifest.Name}, already added by {dupCrops[crop.Name].Manifest.Name}!"); } else { dupCrops[crop.Name] = contentPack; } } } // load fruit trees DirectoryInfo fruitTreesDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "FruitTrees")); if (fruitTreesDir.Exists) { foreach (DirectoryInfo dir in fruitTreesDir.EnumerateDirectories()) { string relativePath = $"FruitTrees/{dir.Name}"; // load data FruitTreeData tree = contentPack.ReadJsonFile <FruitTreeData>($"{relativePath}/tree.json"); if (tree == null) { continue; } // save fruit tree tree.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/tree.png"); fruitTrees.Add(tree); // save seed tree.sapling = new ObjectData { texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/sapling.png"), Name = tree.SaplingName, Description = tree.SaplingDescription, Category = ObjectData.Category_.Seeds, Price = tree.SaplingPurchasePrice, CanPurchase = true, PurchaseRequirements = tree.SaplingPurchaseRequirements, PurchaseFrom = tree.SaplingPurchaseFrom, PurchasePrice = tree.SaplingPurchasePrice, NameLocalization = tree.SaplingNameLocalization, DescriptionLocalization = tree.SaplingDescriptionLocalization }; objects.Add(tree.sapling); // Duplicate check if (dupFruitTrees.ContainsKey(tree.Name)) { Log.error($"Duplicate fruit tree: {tree.Name} just added by {contentPack.Manifest.Name}, already added by {dupFruitTrees[tree.Name].Manifest.Name}!"); } else { dupFruitTrees[tree.Name] = contentPack; } } } // load big craftables DirectoryInfo bigCraftablesDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "BigCraftables")); if (bigCraftablesDir.Exists) { foreach (DirectoryInfo dir in bigCraftablesDir.EnumerateDirectories()) { string relativePath = $"BigCraftables/{dir.Name}"; // load data BigCraftableData craftable = contentPack.ReadJsonFile <BigCraftableData>($"{relativePath}/big-craftable.json"); if (craftable == null) { continue; } // save craftable craftable.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/big-craftable.png"); bigCraftables.Add(craftable); // Duplicate check if (dupBigCraftables.ContainsKey(craftable.Name)) { Log.error($"Duplicate big craftable: {craftable.Name} just added by {contentPack.Manifest.Name}, already added by {dupBigCraftables[craftable.Name].Manifest.Name}!"); } else { dupBigCraftables[craftable.Name] = contentPack; } } } // load hats DirectoryInfo hatsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Hats")); if (hatsDir.Exists) { foreach (DirectoryInfo dir in hatsDir.EnumerateDirectories()) { string relativePath = $"Hats/{dir.Name}"; // load data HatData hat = contentPack.ReadJsonFile <HatData>($"{relativePath}/hat.json"); if (hat == null) { continue; } // save object hat.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/hat.png"); hats.Add(hat); // Duplicate check if (dupHats.ContainsKey(hat.Name)) { Log.error($"Duplicate hat: {hat.Name} just added by {contentPack.Manifest.Name}, already added by {dupHats[hat.Name].Manifest.Name}!"); } else { dupBigCraftables[hat.Name] = contentPack; } } } // Load weapons // load objects DirectoryInfo weaponsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Weapons")); if (weaponsDir.Exists) { foreach (DirectoryInfo dir in weaponsDir.EnumerateDirectories()) { string relativePath = $"Weapons/{dir.Name}"; // load data WeaponData weapon = contentPack.ReadJsonFile <WeaponData>($"{relativePath}/weapon.json"); if (weapon == null) { continue; } // save object weapon.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/weapon.png"); weapons.Add(weapon); // Duplicate check if (dupWeapons.ContainsKey(weapon.Name)) { Log.error($"Duplicate weapon: {weapon.Name} just added by {contentPack.Manifest.Name}, already added by {dupWeapons[weapon.Name].Manifest.Name}!"); } else { dupBigCraftables[weapon.Name] = contentPack; } } } }
private void loadData(IContentPack contentPack) { Log.info($"\t{contentPack.Manifest.Name} {contentPack.Manifest.Version} by {contentPack.Manifest.Author} - {contentPack.Manifest.Description}"); // load objects DirectoryInfo objectsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Objects")); if (objectsDir.Exists) { foreach (DirectoryInfo dir in objectsDir.EnumerateDirectories()) { string relativePath = $"Objects/{dir.Name}"; // load data ObjectData obj = contentPack.ReadJsonFile <ObjectData>($"{relativePath}/object.json"); if (obj == null) { continue; } // save object obj.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/object.png"); if (obj.IsColored) { obj.textureColor = contentPack.LoadAsset <Texture2D>($"{relativePath}/color.png"); } this.objects.Add(obj); // save ring if (obj.Category == ObjectData.Category_.Ring) { this.myRings.Add(obj); } } } // load crops DirectoryInfo cropsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Crops")); if (cropsDir.Exists) { foreach (DirectoryInfo dir in cropsDir.EnumerateDirectories()) { string relativePath = $"Crops/{dir.Name}"; // load data CropData crop = contentPack.ReadJsonFile <CropData>($"{relativePath}/crop.json"); if (crop == null) { continue; } // save crop crop.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/crop.png"); crops.Add(crop); // save seeds crop.seed = new ObjectData { texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/seeds.png"), Name = crop.SeedName, Description = crop.SeedDescription, Category = ObjectData.Category_.Seeds, Price = crop.SeedPurchasePrice, CanPurchase = true, PurchaseFrom = crop.SeedPurchaseFrom, PurchasePrice = crop.SeedPurchasePrice, PurchaseRequirements = crop.SeedPurchaseRequirements ?? new List <string>() }; string[] excludeSeasons = new[] { "spring", "summer", "fall", "winter" }.Except(crop.Seasons).ToArray(); crop.seed.PurchaseRequirements.Add($"z {string.Join(" ", excludeSeasons)}"); objects.Add(crop.seed); } } // load fruit trees DirectoryInfo fruitTreesDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "FruitTrees")); if (fruitTreesDir.Exists) { foreach (DirectoryInfo dir in fruitTreesDir.EnumerateDirectories()) { string relativePath = $"FruitTrees/{dir.Name}"; // load data FruitTreeData tree = contentPack.ReadJsonFile <FruitTreeData>($"{relativePath}/tree.json"); if (tree == null) { continue; } // save fruit tree tree.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/tree.png"); fruitTrees.Add(tree); // save seed tree.sapling = new ObjectData { texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/sapling.png"), Name = tree.SaplingName, Description = tree.SaplingDescription, Category = ObjectData.Category_.Seeds, Price = tree.SaplingPurchasePrice, CanPurchase = true, PurchaseRequirements = tree.SaplingPurchaseRequirements, PurchaseFrom = tree.SaplingPurchaseFrom, PurchasePrice = tree.SaplingPurchasePrice }; objects.Add(tree.sapling); } } // load big craftables DirectoryInfo bigCraftablesDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "BigCraftables")); if (bigCraftablesDir.Exists) { foreach (DirectoryInfo dir in bigCraftablesDir.EnumerateDirectories()) { string relativePath = $"BigCraftables/{dir.Name}"; // load data BigCraftableData craftable = contentPack.ReadJsonFile <BigCraftableData>($"{relativePath}/big-craftable.json"); if (craftable == null) { continue; } // save craftable craftable.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/big-craftable.png"); bigCraftables.Add(craftable); } } // load objects DirectoryInfo hatsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Hats")); if (hatsDir.Exists) { foreach (DirectoryInfo dir in hatsDir.EnumerateDirectories()) { string relativePath = $"Hats/{dir.Name}"; // load data HatData hat = contentPack.ReadJsonFile <HatData>($"{relativePath}/hat.json"); if (hat == null) { continue; } // save object hat.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/hat.png"); hats.Add(hat); } } }