Пример #1
0
        private void CheckForKeybindConflict()
        {
            try
            {
                if (Helper.ModRegistry.IsLoaded("CJBok.CheatsMenu"))
                {
                    // whether the pet menu is set to the default
                    if (Config.PetMenuKey.IsBound && Config.PetMenuKey.Keybinds.Length == 1 && Config.PetMenuKey.Keybinds[0].Buttons.Length == 1 && Config.PetMenuKey.Keybinds[0].Buttons[0] == SButton.P)
                    {
                        var data = Helper.ModRegistry.Get("CJBok.CheatsMenu");

                        var path = data.GetType().GetProperty("DirectoryPath");

                        if (path != null && path.GetValue(data) != null)
                        {
                            var list = ReadConfigFile("config.json", path.GetValue(data) as string, new[] { "OpenMenuKey" }, data.Manifest.Name);

                            if (list["OpenMenuKey"] == "P")
                            {
                                Config.PetMenuKey = KeybindList.Parse("");
                                DebugLog("Unassigned pet menu key because cjb cheats menu is bound to the same key.");
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Пример #2
0
        private void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
        {
            fluteBlockApi = Helper.ModRegistry.GetApi <IAdvancedFluteBlocksApi>("aedenthorn.AdvancedFluteBlocks");
            trainTrackApi = Helper.ModRegistry.GetApi <ITrainTracksApi>("aedenthorn.TrainTracks");

            // get Generic Mod Config Menu's API (if it's installed)
            var configMenu = Helper.ModRegistry.GetApi <IGenericModConfigMenuApi>("spacechase0.GenericModConfigMenu");

            if (configMenu is null)
            {
                return;
            }

            // register mod
            configMenu.Register(
                mod: ModManifest,
                reset: () => Config = new ModConfig(),
                save: () => Helper.WriteConfig(Config)
                );

            configMenu.AddBoolOption(
                mod: ModManifest,
                name: () => "Mod Enabled?",
                getValue: () => Config.EnableMod,
                setValue: value => Config.EnableMod = value
                );
            configMenu.AddTextOption(
                mod : ModManifest,
                name : () => "Import Key",
                getValue : () => Config.ImportKey.ToString(),
                setValue : delegate(string value) { try { Config.ImportKey = KeybindList.Parse(value); } catch { } }
                );
        }
Пример #3
0
        public KeyBindGui() : base("Key Bind UI")
        {
            var mods = Environment.CurrentDirectory + "/" + "Mods";

            foreach (var info in new DirectoryInfo(mods).GetDirectories())
            {
                var keyBindListInfo = new KeyBindListInfo();
                var config          = new FileInfo(info.FullName + "/config.json");
                keyBindListInfo.ConfigFileInfo = config;
                if (!config.Exists)
                {
                    continue;
                }

                keyBindListInfo.Name = info.Name;
                var read     = new JsonTextReader(config.OpenText());
                var readFrom = (JObject)JToken.ReadFrom(read);
                read.Close();
                foreach (var keyValuePair in readFrom)
                {
                    if (keyValuePair.Value == null || keyValuePair.Value.Type != JTokenType.String)
                    {
                        continue;
                    }
                    try
                    {
                        keyBindListInfo.KeyBindList[keyValuePair.Key] =
                            KeybindList.Parse(keyValuePair.Value.ToString()).ToString();
                    }
                    catch (Exception e)
                    {
                        // ignored
                    }
                }

                AddElement(new Button(info.Name,
                                      ModEntry.GetInstance().Helper.Translation.Get("KeyBindUI.Framework.Screen.ModsGui.KeySetting"))
                {
                    OnLeftClicked = () => { OpenScreenGui(new KeyBindListGui(keyBindListInfo)); }
                });
            }
        }
Пример #4
0
        private void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
        {
            // get Generic Mod Config Menu's API (if it's installed)
            var configMenu = Helper.ModRegistry.GetApi <IGenericModConfigMenuApi>("spacechase0.GenericModConfigMenu");

            if (configMenu is not null)
            {
                // register mod
                configMenu.Register(
                    mod: ModManifest,
                    reset: () => Config = new ModConfig(),
                    save: () => Helper.WriteConfig(Config)
                    );

                configMenu.AddBoolOption(
                    mod: ModManifest,
                    name: () => "Mod Enabled",
                    getValue: () => Config.EnableMod,
                    setValue: value => Config.EnableMod = value
                    );
                configMenu.AddKeybind(
                    mod: ModManifest,
                    name: () => "Deal Down",
                    getValue: () => Config.DealDownModButton,
                    setValue: value => Config.DealDownModButton = value
                    );
                configMenu.AddKeybind(
                    mod: ModManifest,
                    name: () => "Deal Up",
                    getValue: () => Config.DealUpModButton,
                    setValue: value => Config.DealUpModButton = value
                    );
                configMenu.AddTextOption(
                    mod : ModManifest,
                    name : () => "Create Deck",
                    getValue : () => Config.CreateDeckButton.ToString(),
                    setValue : delegate(string value) { try { Config.CreateDeckButton = KeybindList.Parse(value); } catch { }; }
                    );
                configMenu.AddTextOption(
                    mod : ModManifest,
                    name : () => "Shuffle Deck",
                    getValue : () => Config.ShuffleDeckButton.ToString(),
                    setValue : delegate(string value) { try { Config.ShuffleDeckButton = KeybindList.Parse(value); } catch { }; }
                    );
            }
        }
Пример #5
0
        private void UpdateConfig(bool GMCM)
        {
            if (!GMCM)
            {
                config = Helper.ReadConfig <ModConfig>();
            }

            int fix = 0;

            foreach (var item in config.SeeInfoForBelowData.ToArray())//updates old configs to new format
            {
                foreach (var effect in item.Value.ToArray())
                {
                    if (effect.Key.Equals("DOUBLE", StringComparison.Ordinal))
                    {
                        config.SeeInfoForBelowData[item.Key].Remove(effect.Key);
                        if (item.Key.Equals("Wild Bait", StringComparison.Ordinal))
                        {
                            config.SeeInfoForBelowData[item.Key]["EXTRA_MAX"]    = 2;
                            config.SeeInfoForBelowData[item.Key]["EXTRA_CHANCE"] = 20;
                        }
                        else
                        {
                            config.SeeInfoForBelowData[item.Key]["EXTRA_MAX"]    = 0;
                            config.SeeInfoForBelowData[item.Key]["EXTRA_CHANCE"] = 0;
                        }
                        fix++;
                    }
                }
            }
            if (fix > 0)
            {
                Helper.WriteConfig(config);
            }

            Minigames.itemData = config.SeeInfoForBelowData;

            if (Minigames.voices == null)
            {
                Minigames.voices = new Dictionary <string, SoundEffect>();
                try
                {
                    DirectoryInfo dir = new DirectoryInfo(Path.Combine(Helper.DirectoryPath, "assets/audio"));

                    if (!dir.Exists)
                    {
                        throw new DirectoryNotFoundException();
                    }

                    FileInfo[] files = dir.GetFiles("*.wav");

                    foreach (FileInfo file in files)
                    {
                        Minigames.voices[Path.GetFileNameWithoutExtension(file.Name)] = SoundEffect.FromStream(file.Open(FileMode.Open));
                    }
                    //Minigames.fishySound["Mute"] = SoundEffect.FromStream(new FileStream(Path.Combine(Helper.DirectoryPath, "assets/audio", "Mute.wav"), FileMode.Open));
                }
                catch (Exception ex)
                {
                    Monitor.Log($"error loading audio: {ex}", LogLevel.Error);
                }
            }

            for (int i = 0; i < 4; i++)
            {
                if (!config.Voice_Test_Ignore_Me[i].Equals(config.VoiceVolume + "/" + config.VoiceType[i] + "/" + config.VoicePitch[i], StringComparison.Ordinal)) //play voice and save it if changed
                {
                    config.Voice_Test_Ignore_Me[i] = config.VoiceVolume + "/" + config.VoiceType[i] + "/" + config.VoicePitch[i];
                    if (Minigames.voices.TryGetValue(config.VoiceType[i], out SoundEffect sfx))
                    {
                        sfx.Play(config.VoiceVolume / 100f * 0.98f, config.VoicePitch[i] / 100f, 0f);
                    }
                    Helper.WriteConfig(config);
                }

                try //keybinds
                {
                    if (config.KeyBinds.Equals("") || config.KeyBinds.Equals(" "))
                    {
                        throw new FormatException("String can't be empty.");
                    }
                    Minigames.keyBinds[i] = KeybindList.Parse(config.KeyBinds[i]);
                }
                catch (Exception e)
                {
                    string def = "MouseLeft, C, ControllerX";
                    Minigames.keyBinds[i] = KeybindList.Parse(def);
                    config.KeyBinds[i]    = def;
                    Helper.WriteConfig(config);
                    Monitor.Log(e.Message + " Resetting KeyBinds for screen " + (i + 1) + " to default. For key names, see: https://stardewcommunitywiki.com/Modding:Player_Guide/Key_Bindings", LogLevel.Error);
                }

                Minigames.voicePitch[i] = config.VoicePitch[i] / 100f;
            }
            if (Context.IsWorldReady)
            {
                Minigames.voiceVolume             = config.VoiceVolume / 100f;
                Minigames.voiceType               = config.VoiceType;
                Minigames.freeAim                 = config.FreeAim;
                Minigames.startMinigameStyle      = config.StartMinigameStyle;
                Minigames.endMinigameStyle        = config.EndMinigameStyle;
                Minigames.endCanLoseTreasure      = config.EndLoseTreasureIfFailed;
                Minigames.minigameDamage          = config.EndMinigameDamage;
                Minigames.minigameDifficulty      = config.MinigameDifficulty;
                Minigames.festivalMode            = config.FestivalMode;
                Minigames.realisticSizes          = config.RealisticSizes;
                Minigames.fishTankSprites         = config.FishTankHoldSprites;
                Minigames.minigameColor           = config.MinigameColor;
                MinigamesStart.minigameStyle      = config.StartMinigameStyle;
                MinigamesStart.minigameColor      = config.MinigameColor;
                MinigamesStart.minigameDifficulty = config.MinigameDifficulty;
                MinigamesStart.startMinigameScale = config.StartMinigameScale;
                MinigamesStart.tutorialSkip       = config.TutorialSkip;
                MinigamesStart.bossTransparency   = config.BossTransparency;
                if (LocalizedContentManager.CurrentLanguageCode == 0 && Minigames.metricSizes != config.ConvertToMetric)
                {
                    Minigames.metricSizes = config.ConvertToMetric;
                    Helper.Content.InvalidateCache("Strings/StringsFromCSFiles");
                }
                Helper.Content.InvalidateCache("Data/ObjectInformation");
            }
        }
Пример #6
0
        private void GenericMCColorPicker(IGenericModConfigMenuApi GenericMC, IManifest mod)
        {
            MinigameColor state = null;

            void Draw(SpriteBatch b, Vector2 pos)
            {
                if (state == null)
                {
                    state = new MinigameColor()
                    {
                        color = config.MinigameColor, pos = pos, whichSlider = 0
                    }
                }
                ;

                KeybindList click = KeybindList.Parse("MouseLeft");
                int         width = Math.Min(Game1.uiViewport.Width / 4, 400);

                byte mousePercentage = (byte)(int)((Utility.Clamp(Game1.getOldMouseX(), pos.X, pos.X + width) - pos.X) / width * 255);

                Rectangle barR = new Rectangle((int)pos.X, (int)pos.Y, width, 24);
                Rectangle barG = new Rectangle((int)pos.X, (int)pos.Y + 80, width, 24);
                Rectangle barB = new Rectangle((int)pos.X, (int)pos.Y + 160, width, 24);

                if ((barR.Contains(Game1.getMouseX(), Game1.getMouseY()) && click.JustPressed()) || (state.whichSlider == 1 && click.IsDown()))
                {
                    state.whichSlider = 1;
                    state.color.R     = mousePercentage;
                }
                else if ((barG.Contains(Game1.getMouseX(), Game1.getMouseY()) && click.JustPressed()) || (state.whichSlider == 2 && click.IsDown()))
                {
                    state.whichSlider = 2;
                    state.color.G     = mousePercentage;
                }
                else if ((barB.Contains(Game1.getMouseX(), Game1.getMouseY()) && click.JustPressed()) || (state.whichSlider == 3 && click.IsDown()))
                {
                    state.whichSlider = 3;
                    state.color.B     = mousePercentage;
                }
                else if (state.whichSlider != 0)
                {
                    state.whichSlider = 0;
                }

                float scale = width / 400f;

                Rectangle posR = new Rectangle((int)(pos.X + (state.color.R / 255f) * (width - 40)), (int)pos.Y, 40, 24);
                Rectangle posG = new Rectangle((int)(pos.X + (state.color.G / 255f) * (width - 40)), (int)pos.Y + 80, 40, 24);
                Rectangle posB = new Rectangle((int)(pos.X + (state.color.B / 255f) * (width - 40)), (int)pos.Y + 160, 40, 24);

                StardewValley.Menus.IClickableMenu.drawTextureBox(b, Game1.mouseCursors, new Rectangle(403, 383, 6, 6), barR.X, barR.Y, barR.Width, barR.Height, Color.White, Game1.pixelZoom, false);
                StardewValley.Menus.IClickableMenu.drawTextureBox(b, Game1.mouseCursors, new Rectangle(403, 383, 6, 6), barG.X, barG.Y, barG.Width, barG.Height, Color.White, Game1.pixelZoom, false);
                StardewValley.Menus.IClickableMenu.drawTextureBox(b, Game1.mouseCursors, new Rectangle(403, 383, 6, 6), barB.X, barB.Y, barB.Width, barB.Height, Color.White, Game1.pixelZoom, false);

                b.Draw(Game1.mouseCursors, new Vector2(posR.X, posR.Y), new Rectangle(420, 441, 10, 6), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.9f);
                b.Draw(Game1.mouseCursors, new Vector2(posG.X, posG.Y), new Rectangle(420, 441, 10, 6), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.9f);
                b.Draw(Game1.mouseCursors, new Vector2(posB.X, posB.Y), new Rectangle(420, 441, 10, 6), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.9f);

                b.DrawString(Game1.smallFont, "R:" + string.Format("{0,6}", state.color.R), new Vector2(barR.X + width + 20, barR.Y - 4), Color.Black);
                b.DrawString(Game1.smallFont, "G:" + string.Format("{0,6}", state.color.G), new Vector2(barG.X + width + 20, barG.Y - 4), Color.Black);
                b.DrawString(Game1.smallFont, "B:" + string.Format("{0,6}", state.color.B), new Vector2(barB.X + width + 20, barB.Y - 4), Color.Black);

                Vector2 screenMid = new Vector2(pos.X - (width / 1.5f), pos.Y + 90);

                b.Draw(Game1.mouseCursors, screenMid, new Rectangle(31, 1870, 73, 49), state.color, 0f, new Vector2(36.5f, 22.5f), 4f * scale, SpriteEffects.None, 0.2f);
                b.Draw(MinigamesStart.minigameTextures[0], screenMid, null, state.color, 0f, new Vector2(69f, 37f), 2f * scale, SpriteEffects.None, 0.3f);
                b.Draw(MinigamesStart.minigameTextures[1], screenMid + new Vector2(-50f, 0f), new Rectangle(355, 86, 26, 26), state.color, 0f, new Vector2(13f), 1f * scale, SpriteEffects.None, 0.4f);

                b.Draw(MinigamesStart.minigameTextures[1], screenMid + new Vector2(50f, 0), new Rectangle(322, 82, 12, 12), state.color, 0f, new Vector2(6f), 2f * scale, SpriteEffects.None, 0.4f);
                b.Draw(Game1.mouseCursors, screenMid, new Rectangle(301, 288, 15, 15), state.color * 0.95f, 0f, new Vector2(7.5f, 7.5f), 2f * scale, SpriteEffects.None, 0.5f);
                b.DrawString(Game1.smallFont, "5", screenMid + new Vector2(0, 2f), state.color, 0f, Game1.smallFont.MeasureString("5") / 2f, 1f * scale, SpriteEffects.None, 0.51f);

                b.Draw(Game1.mouseCursors, screenMid + new Vector2(width * -0.6f, -45), new Rectangle(395, 497, 3, 8), state.color, 0f, new Vector2(1.5f, 4f), 4f, SpriteEffects.None, 0.98f);
                b.Draw(Game1.mouseCursors, screenMid + new Vector2(width * -0.6f, 0), new Rectangle(407, 1660, 10, 10), state.color, 0f, new Vector2(5f), 3.3f, SpriteEffects.None, 0.98f);
                b.Draw(Game1.mouseCursors, screenMid + new Vector2(width * -0.6f, 45), new Rectangle(473, 36, 24, 24), state.color, 0f, new Vector2(12f), 2f, SpriteEffects.None, 0.98f);
                b.DrawString(Game1.smallFont, "A", screenMid + new Vector2(width * -0.6f, 47) - (Game1.smallFont.MeasureString("A") / 2 * 1.2f), state.color, 0f, Vector2.Zero, 1.2f, SpriteEffects.None, 1f); //text
            }

            void Save()
            {
                if (state == null)
                {
                    return;
                }
                config.MinigameColor = state.color;
            }

            GenericMC.AddSectionTitle(mod, () => ".   " + translate.Get("GenericMC.MinigameColor"));
            GenericMC.AddComplexOption(mod, () => "", () => "", Draw, Save, () => 300);
        }