Example #1
0
        public static bool Prefix(ref int bundle_type, ref bool use_seed)
        {
            Main.DebugMessage("Generating bundle...");

            SetBundleData(bundle_type, use_seed);

            switch (bundle_type)
            {
            case 0: Main.DebugMessage("'Normal' bundle generated"); break;

            case 1: Main.DebugMessage("'Remixed' bundle generated"); break;

            default: Main.DebugMessage("'Unknown' bundle generated with id of " + bundle_type); break;
            }
            return(false);
        }
        public static void Postfix(Bundle __instance, ref string rawBundleInfo)
        {
            string[] split = rawBundleInfo.Split('/');

            if (split.Length < 6)
            {
                return;
            }

            string[] sprite_index = split[5].Split(':');

            // Load bundle image from spritesheet
            try
            {
                if (sprite_index[0] == "Data\\BundleSprites")
                {
                    __instance.bundleTextureOverride      = LoadPNG(Path.Combine(Stream, "Data\\BundleSprites.png"));
                    __instance.bundleTextureIndexOverride = int.Parse(sprite_index[1]);
                }
            }
            catch (Exception)
            {
                __instance.bundleTextureOverride      = null;
                __instance.bundleTextureIndexOverride = -1;
                Main.DebugMessage("Error loading bundle image.");
            }
        }
Example #3
0
        public static bool Prefix(AdvancedGameOptions __instance)
        {
            Main.DebugMessage("Populated options");

            __instance.options.Clear();
            __instance.tooltips.Clear();
            __instance.applySettingCallbacks.Clear();
            __instance.options.Add(new OptionsElement(Game1.content.LoadString("Strings\\UI:AGO_Label")));
            __instance.options.Add(new OptionsElement(Game1.content.LoadString("Strings\\UI:AGO_CCB"))
            {
                style = OptionsElement.Style.OptionLabel
            });
            __instance.AddDropdown("", Game1.content.LoadString("Strings\\UI:AGO_CCB_Tooltip"), () => Game1.bundleType, delegate(Game1.BundleType val)
            {
                Game1.bundleType = val;
            }, new KeyValuePair <string, Game1.BundleType>(Game1.content.LoadString("Strings\\UI:AGO_CCB_Normal"), Game1.BundleType.Default), new KeyValuePair <string, Game1.BundleType>(Game1.content.LoadString("Strings\\UI:AGO_CCB_Remixed"), Game1.BundleType.Remixed), new KeyValuePair <string, Game1.BundleType>("Randomized", (Game1.BundleType) 2));
            __instance.AddCheckbox(Game1.content.LoadString("Strings\\UI:AGO_Year1Completable"), Game1.content.LoadString("Strings\\UI:AGO_Year1Completable_Tooltip"), () => Game1.game1.GetNewGameOption <bool>("YearOneCompletable"), delegate(bool val)
            {
                Game1.game1.SetNewGameOption("YearOneCompletable", val);
            });
            __instance.options.Add(new OptionsElement(Game1.content.LoadString("Strings\\UI:AGO_MineTreasureShuffle"))
            {
                style = OptionsElement.Style.OptionLabel
            });
            __instance.AddDropdown("", Game1.content.LoadString("Strings\\UI:AGO_MineTreasureShuffle_Tooltip"), () => Game1.game1.GetNewGameOption <Game1.MineChestType>("MineChests"), delegate(Game1.MineChestType val)
            {
                Game1.game1.SetNewGameOption("MineChests", val);
            }, new KeyValuePair <string, Game1.MineChestType>(Game1.content.LoadString("Strings\\UI:AGO_CCB_Normal"), Game1.MineChestType.Default), new KeyValuePair <string, Game1.MineChestType>(Game1.content.LoadString("Strings\\UI:AGO_CCB_Remixed"), Game1.MineChestType.Remixed));
            __instance.AddCheckbox(Game1.content.LoadString("Strings\\UI:AGO_FarmMonsters"), Game1.content.LoadString("Strings\\UI:AGO_FarmMonsters_Tooltip"), () => Game1.spawnMonstersAtNight, delegate(bool val)
            {
                Game1.spawnMonstersAtNight = val;
            });
            __instance.AddDropdown(Game1.content.LoadString("Strings\\UI:Character_Difficulty"), Game1.content.LoadString("Strings\\UI:AGO_ProfitMargin_Tooltip"), () => Game1.player.difficultyModifier, delegate(float val)
            {
                Game1.player.difficultyModifier = val;
            }, new KeyValuePair <string, float>(Game1.content.LoadString("Strings\\UI:Character_Normal"), 1f), new KeyValuePair <string, float>("75%", 0.75f), new KeyValuePair <string, float>("50%", 0.5f), new KeyValuePair <string, float>("25%", 0.25f));
            __instance.options.Add(new OptionsElement(Game1.content.LoadString("Strings\\UI:AGO_MPOptions_Label")));
            __instance.AddDropdown(Game1.content.LoadString("Strings\\UI:Character_StartingCabins"), Game1.content.LoadString("Strings\\UI:AGO_StartingCabins_Tooltip"), () => Game1.startingCabins, delegate(int val)
            {
                Game1.startingCabins = val;
            }, new KeyValuePair <string, int>(Game1.content.LoadString("Strings\\UI:Character_none"), 0), new KeyValuePair <string, int>("1", 1), new KeyValuePair <string, int>("2", 2), new KeyValuePair <string, int>("3", 3));
            __instance.AddDropdown(Game1.content.LoadString("Strings\\UI:Character_CabinLayout"), Game1.content.LoadString("Strings\\UI:AGO_CabinLayout_Tooltip"), () => Game1.cabinsSeparate, delegate(bool val)
            {
                Game1.cabinsSeparate = val;
            }, new KeyValuePair <string, bool>(Game1.content.LoadString("Strings\\UI:Character_Close"), value: false), new KeyValuePair <string, bool>(Game1.content.LoadString("Strings\\UI:Character_Separate"), value: true));
            __instance.options.Add(new OptionsElement(Game1.content.LoadString("Strings\\UI:AGO_OtherOptions_Label")));
            __instance.options.Add(new OptionsElement(Game1.content.LoadString("Strings\\UI:AGO_RandomSeed"))
            {
                style = OptionsElement.Style.OptionLabel
            });
            OptionsTextEntry optionsTextEntry = __instance.AddTextEntry("", Game1.content.LoadString("Strings\\UI:AGO_RandomSeed_Tooltip"), () => (!Game1.startingGameSeed.HasValue) ? "" : Game1.startingGameSeed.Value.ToString(), delegate(string val)
            {
                val.Trim();
                if (string.IsNullOrEmpty(val))
                {
                    Game1.startingGameSeed = null;
                }
                else
                {
                    ulong result = 0uL;
                    while (val.Length > 0)
                    {
                        if (ulong.TryParse(val, out result))
                        {
                            Game1.startingGameSeed = result;
                            break;
                        }
                        val = val.Substring(0, val.Length - 1);
                    }
                }
            });

            optionsTextEntry.textBox.numbersOnly = true;
            optionsTextEntry.textBox.textLimit   = 9;
            for (int i = __instance.options.Count; i < 7; i++)
            {
                __instance.options.Add(new OptionsElement(""));
            }

            return(false);
        }
        public Item ParseItemString(string item_string)
        {
            string[] parts = item_string.Trim().Split(' ');
            int      index = 0;
            int      count = int.Parse(parts[index]);

            index++;
            int quality = 0;

            try
            {
                // No quality
                if (parts[index] == "NQ")
                {
                    quality = 0;
                    index++;
                }
                // Silver quality
                else if (parts[index] == "SQ")
                {
                    quality = 1;
                    index++;
                }
                // Gold quality
                else if (parts[index] == "GQ")
                {
                    quality = 2;
                    index++;
                }
                // Iridium quality
                else if (parts[index] == "IQ")
                {
                    quality = 4;
                    index++;
                }
            }
            catch (Exception)
            {
                Main.DebugMessage("Item: " + item_string);
            }

            string item_name = string.Join(" ", parts, index, parts.Length - index);

            if (char.IsDigit(item_name[0]))
            {
                StardewValley.Object @object = new StardewValley.Object(int.Parse(item_name), count);
                (@object as StardewValley.Object).Quality = quality;
                return(@object);
            }
            Item found_item = null;

            if (item_name.ToLowerInvariant().EndsWith("category"))
            {
                try
                {
                    FieldInfo field = typeof(StardewValley.Object).GetField(item_name);
                    if (field != null)
                    {
                        int category_index = (int)field.GetValue(null);
                        found_item = new StardewValley.Object(Vector2.Zero, category_index, 1);
                    }
                }
                catch (Exception)
                {
                }
            }
            if (found_item == null)
            {
                found_item = Utility.fuzzyItemSearch(item_name);
                if (found_item is StardewValley.Object)
                {
                    (found_item as StardewValley.Object).Quality = quality;
                }
            }

            if (found_item == null)
            {
                Main.DebugMessage("Name: " + item_name);
            }

            found_item.Stack = count;
            return(found_item);
        }