Пример #1
0
        public static string LoadSaveDefaults(List <string> strings)
        {
            if (strings.Count < 1 || strings[0] != "reset")
            {
                return(@"This command will overwrite your settings file at:
  Documents\Mount and Blade II Bannerlord\Configs\KingdomColor.xml
Run the command ""kingdomcolor.load_and_save_defaults reset"" to confirm.");
            }

            if (Campaign.Current == null || MBObjectManager.Instance == null)
            {
                return("You must have a game loaded.");
            }

            try
            {
                var settings = DefaultLoader.Load();
                Settings.Instance = settings;
                Settings.Save();
                KingdomColorModule.Instance.ApplyOverrides();

                return(@"Your settings file at:
  Documents\Mount and Blade II Bannerlord\Configs\KingdomColor.xml
  has been overwritten with defaults.
Open and close the Clan page to take effect.");
            }
            catch (Exception ex)
            {
                return("Error loading defaults:\n" + KingdomColorModule.FormatException(ex).Replace("\r", ""));
            }
        }
Пример #2
0
        public static string SetKingdomColor(List <string> strings)
        {
            var args = ConsoleUtilities.Resplit(strings);

            if (args.Count == 1 && args[0] == "colors")
            {
                string output = $"\nAvailable colors\n==============================\n";
                foreach (var paletteEntry in BannerManager.ColorPalette)
                {
                    var c = Color.FromUint(paletteEntry.Value.Color);
                    output += $" Id: {paletteEntry.Key}, {c.ToString()}, rgba({(int)(c.Red * 255f)}, {(int)(c.Green * 255)}, {(int)(c.Blue * 255)}, {c.Alpha})\n";
                }
                return(output);
            }
            else if (args.Count == 1 && args[0] == "kingdoms")
            {
                return(ConsoleUtilities.GetObjectList <Kingdom>());
            }
            else if (args.Count < 3)
            {
                return($@"Usage: ""kingdomcolor.set_kingdom_color [KingdomId/KingdomName] [ColorId] [ColorId] [UniformColor] [UniformColor]""
UniformColors are optional and can be an HTML color ('#ffffff') or color id
Use ""kingdomcolor.set_kingdom_color colors/kingdoms"" to list available colors or kingdoms");
            }
            var kingdom = ConsoleUtilities.FindObjectByIdName <Kingdom>(args[0]);

            if (kingdom == null)
            {
                return("Couldn't find kingdom.");
            }
            int bannerColor;
            int bannerColor2;

            if (!int.TryParse(args[1], out bannerColor))
            {
                return("Invalid color1 specified");
            }
            if (!int.TryParse(args[2], out bannerColor2))
            {
                return("Invalid color2 specified");
            }
            uint primaryBannerColor   = BannerManager.GetColor(bannerColor);
            uint secondaryBannerColor = BannerManager.GetColor(bannerColor2);
            uint?color1 = null;
            uint?color2 = null;

            if (args.Count >= 4)
            {
                color1 = KingdomColorModule.ParseUniformColor(args[3]);
                color2 = KingdomColorModule.ParseUniformColor(args[4]);
            }
            KingdomColorModule.Instance.SetKingdomColors(kingdom, primaryBannerColor, secondaryBannerColor, color1 ?? primaryBannerColor, color2 ?? secondaryBannerColor);
            return($"Set {kingdom.Name} colors. Open and close the Clan page to take effect.");
        }
Пример #3
0
 protected override void OnSubModuleLoad()
 {
     base.OnSubModuleLoad();
     try
     {
         Instance = this;
         var harmony = new Harmony("KingdomColor patches 😎");
         harmony.PatchAll();
         Settings.Load();
         // And make sure the file exists to allow editing, including new defaults
         Settings.Save();
     }
     catch (Exception ex)
     {
         DelayMessage("KingdomColor encountered an error while initializing, details copied to clipboard.", Color.FromUint(0xffff0000));
         Input.SetClipboardText(FormatException(ex));
     }
 }
Пример #4
0
 protected override void OnSubModuleUnloaded()
 {
     Instance = null;
 }