static bool saved  = true;    //标记是否已经保存
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     cp = GetCustomPool();
     foreach (var item in cp.Infos)
     {
         List_PoolDisplay.Items.Add(item.PoolName);
     }
     if (List_PoolDisplay.Items.Count != 0)//默认选中最后一项
     {
         List_PoolDisplay.SelectedItem = List_PoolDisplay.Items[List_PoolDisplay.Items.Count - 1];
     }
 }
        private void menuLoad_Click(object sender, RoutedEventArgs e)
        {
            if (!saved)
            {
                if (MessageBox.Show("尚未保存,是否重新载入?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
                {
                    return;
                }
            }
            saved = true;
            //打开文件选择面板
            OpenFileDialog dialog = new OpenFileDialog
            {
                Filter = "Json文件|*.json"
            };

            if (dialog.ShowDialog() == true)
            {
                try
                {
                    cp = JsonConvert.DeserializeObject <CustomPool>(File.ReadAllText(dialog.FileName));
                    List_PoolDisplay.Items.Clear();
                    List_PoolContentDisplay.Items.Clear();
                    StackPanel_Main.Children.Clear();

                    foreach (var item in cp.Infos)
                    {
                        List_PoolDisplay.Items.Add(item.PoolName);
                    }
                    if (List_PoolDisplay.Items.Count != 0)
                    {
                        List_PoolDisplay.SelectedItem = List_PoolDisplay.Items[List_PoolDisplay.Items.Count - 1];
                    }
                    MessageBox.Show("载入成功", "提示");
                }
                catch (Exception exc)
                {
                    MessageBox.Show($"Json解析失败,错误信息:{exc.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
 public void SetUp()
 {
     pool = DeskPool.Instance;
 }
Beispiel #4
0
        public static int main()
        {
            CustomPool cp   = new CustomPool();
            PoolInfo   pool = new PoolInfo()
            {
                PoolName            = "PCR",
                OneOrder            = "1",
                TenOrder            = "10",
                HasBaodi            = true,
                BaodiNum            = 10,
                InfoPicPath         = @"G:\酷Q机器人插件开发\CQP-xiaoi\酷Q Pro\data\app\me.cqp.luohuaming.Gacha\装备卡\框\标配十连.png",
                PerGachaConsumption = 150
            };
            List <PoolContent> contents = new List <PoolContent>()
            {
                new PoolContent()
                {
                    Name           = "佩可",
                    Value          = 100,
                    CanBeFolded    = false,
                    StarCount      = 1,
                    Count          = 1,
                    EmptyStarCount = 4,
                    BoardPath      = BackGroundColor.Blue,
                    Type           = GachaType.Character,
                    Displaymode1   = DisplayMode_1.显示星星,
                    Displaymode2   = DisplayMode_2.显示个数,
                    MinNumber      = 1,
                    MaxNumber      = 1,
                    IsBaodi        = false,
                    Probablity     = 10,
                    PicPath        = @"G:\PCR解包\取\角色小图\fav_push_notif_105801.png"
                },
                new PoolContent()
                {
                    Name           = "凯露",
                    Value          = 100,
                    CanBeFolded    = false,
                    StarCount      = 1,
                    Count          = 1,
                    EmptyStarCount = 4,
                    BoardPath      = BackGroundColor.Blue,
                    Type           = GachaType.Character,
                    Displaymode1   = DisplayMode_1.显示星星,
                    Displaymode2   = DisplayMode_2.显示个数,
                    MinNumber      = 1,
                    MaxNumber      = 1,

                    IsBaodi    = false,
                    Probablity = 10,
                    PicPath    = @"G:\PCR解包\取\角色小图\fav_push_notif_106001.png"
                },
                new PoolContent()
                {
                    Name           = "宫子",
                    Value          = 100,
                    CanBeFolded    = false,
                    StarCount      = 2,
                    Count          = 1,
                    EmptyStarCount = 3,
                    BoardPath      = BackGroundColor.Purple,
                    Type           = GachaType.Character,
                    Displaymode1   = DisplayMode_1.显示星星,
                    Displaymode2   = DisplayMode_2.显示个数,
                    MinNumber      = 1,
                    MaxNumber      = 1,

                    IsBaodi    = true,
                    Probablity = 8,
                    PicPath    = @"G:\PCR解包\取\角色小图\fav_push_notif_100701.png"
                }, new PoolContent()
                {
                    Name           = "雪",
                    Value          = 100,
                    CanBeFolded    = false,
                    StarCount      = 2,
                    Count          = 1,
                    EmptyStarCount = 3,
                    BoardPath      = BackGroundColor.Purple,
                    Type           = GachaType.Character,
                    Displaymode1   = DisplayMode_1.显示星星,
                    Displaymode2   = DisplayMode_2.显示个数,
                    MinNumber      = 1,
                    MaxNumber      = 1,

                    IsBaodi    = true,
                    Probablity = 8,
                    PicPath    = @"G:\PCR解包\取\角色小图\fav_push_notif_100801.png"
                },
                new PoolContent()
                {
                    Name           = "可可萝",
                    Value          = 100,
                    CanBeFolded    = false,
                    StarCount      = 1,
                    Count          = 1,
                    EmptyStarCount = 4,
                    BoardPath      = BackGroundColor.Blue,
                    Type           = GachaType.Character,
                    Displaymode1   = DisplayMode_1.显示星星,
                    Displaymode2   = DisplayMode_2.显示个数,
                    MinNumber      = 1,
                    MaxNumber      = 1,

                    IsBaodi    = false,
                    Probablity = 10,
                    PicPath    = @"G:\PCR解包\取\角色小图\fav_push_notif_105901.png"
                },
                new PoolContent()
                {
                    Name           = "亚丽莎",
                    Value          = 100,
                    CanBeFolded    = false,
                    StarCount      = 3,
                    Count          = 1,
                    EmptyStarCount = 2,
                    BoardPath      = BackGroundColor.MutiColor,
                    Type           = GachaType.Character,
                    Displaymode1   = DisplayMode_1.显示星星,
                    Displaymode2   = DisplayMode_2.显示个数,
                    MinNumber      = 1,
                    MaxNumber      = 1,

                    IsBaodi    = true,
                    Probablity = 2,
                    PicPath    = @"G:\PCR解包\取\角色小图\fav_push_notif_106301.png"
                },
                new PoolContent()
                {
                    Name           = "璃乃",
                    Value          = 100,
                    CanBeFolded    = false,
                    StarCount      = 3,
                    Count          = 1,
                    EmptyStarCount = 2,
                    BoardPath      = BackGroundColor.MutiColor,
                    Type           = GachaType.Character,
                    Displaymode1   = DisplayMode_1.显示星星,
                    Displaymode2   = DisplayMode_2.显示个数,
                    MinNumber      = 1,
                    MaxNumber      = 1,

                    IsBaodi    = true,
                    Probablity = 2,
                    PicPath    = @"G:\PCR解包\取\角色小图\fav_push_notif_101101.png"
                },
                new PoolContent()
                {
                    Name           = "真步",
                    Value          = 100,
                    CanBeFolded    = false,
                    StarCount      = 3,
                    Count          = 1,
                    EmptyStarCount = 2,
                    BoardPath      = BackGroundColor.MutiColor,
                    Type           = GachaType.Character,
                    Displaymode1   = DisplayMode_1.显示星星,
                    Displaymode2   = DisplayMode_2.显示个数,
                    MinNumber      = 1,
                    MaxNumber      = 1,
                    IsBaodi        = true,
                    Probablity     = 2,
                    PicPath        = @"G:\PCR解包\取\角色小图\fav_push_notif_101001.png"
                },
                new PoolContent()
                {
                    Name           = "初音",
                    Value          = 100,
                    CanBeFolded    = false,
                    StarCount      = 3,
                    Count          = 1,
                    EmptyStarCount = 2,
                    BoardPath      = BackGroundColor.MutiColor,
                    Type           = GachaType.Character,
                    Displaymode1   = DisplayMode_1.显示星星,
                    Displaymode2   = DisplayMode_2.显示个数,
                    MinNumber      = 1,
                    MaxNumber      = 1,
                    IsBaodi        = true,
                    Probablity     = 2,
                    PicPath        = @"G:\PCR解包\取\角色小图\fav_push_notif_101201.png"
                },
            };

            pool.PoolContents = contents;
            cp.Infos.Add(pool);
            File.WriteAllText("pool.json", JsonConvert.SerializeObject(cp));
            Console.WriteLine("Sucess!");
            return(0);
        }
Beispiel #5
0
    private KMComponentPool ConvertPool(CustomMission mission, CustomPool pool)
    {
        KMComponentPool componentpool = new KMComponentPool();
        string          Source        = pool.Source;

        // If no source is specified try to figure out what the user wanted.
        if (Source == null)
        {
            if (pool.Modules != null)
            {
                Source = "none";
            }
            else if (pool.Group != null)
            {
                Source = "group";
            }
            else if (pool.Pools != null)
            {
                Source = "pools";
            }
            else
            {
                Log("No source was able to be determined for a pool in the mission located at {0}.", mission.Path);
                return(null);
            }
        }
        else
        {
            Source = Source.ToLowerInvariant();
        }

        if (Source == "group")
        {
            if (pool.Group == null)
            {
                Log("Source was set to Group but no Group parameter found in mission located at {0}.", mission.Path);
                return(null);
            }

            if (Groups.ContainsKey(pool.Group))
            {
                CustomGroup group = Groups[pool.Group];
                pool.Group  = null;
                pool.Source = group.Source;
                pool.Mods   = group.Mods;
                pool.Base   = group.Base;

                if (pool.Blacklist != null)
                {
                    pool.Modules = group.Modules.Except(pool.Blacklist).ToList();
                }
                else
                {
                    pool.Modules = group.Modules;
                }

                Source = pool.Source != null?pool.Source.ToLowerInvariant() : "none";
            }
            else
            {
                Log("Unable to find group {0} for the mission located at {2}.", pool.Group, mission.Path);
            }
        }

        if (Source == "pools")
        {
            if (pool.Pools == null)
            {
                Log("Source was set to Pools but no Pools parameter found in mission located at {0}.", mission.Path);
                return(null);
            }

            componentpool.Count = pool.Count;

            HashSet <string> Modules = new HashSet <string>();
            HashSet <KMComponentPool.ComponentTypeEnum> ComponentTypes = new HashSet <KMComponentPool.ComponentTypeEnum>();
            foreach (CustomPool pool2 in pool.Pools)
            {
                KMComponentPool componentpool2 = ConvertPool(mission, pool2);
                foreach (string module in componentpool2.ModTypes)
                {
                    Modules.Add(module);
                }

                foreach (KMComponentPool.ComponentTypeEnum module in componentpool2.ComponentTypes)
                {
                    ComponentTypes.Add(module);
                }
            }

            componentpool.ModTypes       = Modules.ToList();
            componentpool.ComponentTypes = ComponentTypes.ToList();

            if (ComponentTypes.Count > 0 && !(Modules.Count > 0))
            {
                componentpool.AllowedSources = KMComponentPool.ComponentSource.Base;
            }
            else if (!(ComponentTypes.Count > 0) && Modules.Count > 0)
            {
                componentpool.AllowedSources = KMComponentPool.ComponentSource.Mods;
            }
            else
            {
                componentpool.AllowedSources = KMComponentPool.ComponentSource.Base | KMComponentPool.ComponentSource.Mods;
            }

            componentpool.SpecialComponentType = KMComponentPool.SpecialComponentTypeEnum.None;
        }

        if (Source == "none")
        {
            if (pool.Modules == null)
            {
                Log("Source was set to None but no Modules parameter found in the mission located at {0}.", mission.Path);
                return(null);
            }

            List <string> modded = new List <string>();
            List <KMComponentPool.ComponentTypeEnum> vanilla = new List <KMComponentPool.ComponentTypeEnum>();

            foreach (string module in pool.Modules)
            {
                if (Enum.IsDefined(typeof(KMComponentPool.ComponentTypeEnum), module))
                {
                    if (module != "Empty" && module != "Timer")
                    {
                        vanilla.Add((KMComponentPool.ComponentTypeEnum)Enum.Parse(typeof(KMComponentPool.ComponentTypeEnum), module));
                    }
                }
                else
                {
                    modded.Add(module);
                }
            }

            bool hasModded = modded.Count > 0;
            if (hasModded)
            {
                componentpool.ModTypes = modded;
            }
            bool hasVanilla = vanilla.Count > 0;
            componentpool.ComponentTypes = hasVanilla ? vanilla : new List <KMComponentPool.ComponentTypeEnum>();

            if (hasVanilla && !hasModded)
            {
                componentpool.AllowedSources = KMComponentPool.ComponentSource.Base;
            }
            else if (!hasVanilla && hasModded)
            {
                componentpool.AllowedSources = KMComponentPool.ComponentSource.Mods;
            }
            else
            {
                componentpool.AllowedSources = KMComponentPool.ComponentSource.Base | KMComponentPool.ComponentSource.Mods;
            }

            componentpool.SpecialComponentType = KMComponentPool.SpecialComponentTypeEnum.None;
        }
        else
        {
            if (!pool.Base && !pool.Mods)
            {
                Log("A source besides None was used but has both base and mods disabled in the mission located at {0}. Skipping pool.", mission.Path);
                return(null);
            }

            if (pool.Base && !pool.Mods)
            {
                componentpool.AllowedSources = KMComponentPool.ComponentSource.Base;
            }
            else if (!pool.Base && pool.Mods)
            {
                componentpool.AllowedSources = KMComponentPool.ComponentSource.Mods;
            }
            else
            {
                componentpool.AllowedSources = KMComponentPool.ComponentSource.Base | KMComponentPool.ComponentSource.Mods;
            }
            componentpool.ComponentTypes = new List <KMComponentPool.ComponentTypeEnum>();

            if (Source == "solvable")
            {
                if (pool.Mods)
                {
                    componentpool.ModTypes = new List <string>();
                    foreach (KMBombModule module in GetAllModObjects <KMBombModule>())
                    {
                        if (pool.Blacklist == null || !pool.Blacklist.Contains(module.ModuleType))
                        {
                            componentpool.ModTypes.Add(module.ModuleType);
                        }
                    }
                }

                if (pool.Base)
                {
                    componentpool.ComponentTypes = new List <KMComponentPool.ComponentTypeEnum>();
                    foreach (string name in Enum.GetNames(typeof(KMComponentPool.ComponentTypeEnum)))
                    {
                        if (!name.StartsWith("Needy") && name != "Empty" && name != "Timer" && (pool.Blacklist == null || !pool.Blacklist.Contains(name)))
                        {
                            componentpool.ComponentTypes.Add((KMComponentPool.ComponentTypeEnum)Enum.Parse(typeof(KMComponentPool.ComponentTypeEnum), name));
                        }
                    }
                }
            }
            else if (Source == "needy")
            {
                if (pool.Mods)
                {
                    componentpool.ModTypes = new List <string>();
                    foreach (KMNeedyModule module in GetAllModObjects <KMNeedyModule>())
                    {
                        if (pool.Blacklist == null || !pool.Blacklist.Contains(module.ModuleType))
                        {
                            componentpool.ModTypes.Add(module.ModuleType);
                        }
                    }
                }

                if (pool.Base)
                {
                    componentpool.ComponentTypes = new List <KMComponentPool.ComponentTypeEnum>();
                    foreach (string name in Enum.GetNames(typeof(KMComponentPool.ComponentTypeEnum)))
                    {
                        if (name.StartsWith("Needy") && (pool.Blacklist == null || !pool.Blacklist.Contains(name)))
                        {
                            componentpool.ComponentTypes.Add((KMComponentPool.ComponentTypeEnum)Enum.Parse(typeof(KMComponentPool.ComponentTypeEnum), name));
                        }
                    }
                }
            }
            else
            {
                Log("Unkown source format of {0} was found in the mission located at {1}.", pool.Source, mission.Path);
                return(null);
            }
        }

        componentpool.Count = pool.Count;

        return(componentpool);
    }