Ejemplo n.º 1
0
 public static bool GetKeyActive(this Menu config, string name)
 {
     try
     {
         return(config.Item(name).GetValue <KeyBind>().Active);
     }
     catch (Exception)
     {
         DeBug.WriteConsole("[菜单取值]", $"名为{name}的菜单项的值类型不是KeyActive", DebugLevel.Wrang);
     }
     return(false);
 }
Ejemplo n.º 2
0
 public static KeyBind GetKeyBind(this Menu config, string name)
 {
     try
     {
         return(config.Item(name).GetValue <KeyBind>());
     }
     catch (Exception)
     {
         DeBug.WriteConsole("[菜单取值]", $"名为{name}的菜单项的值类型不是KeyBind", DebugLevel.Wrang);
     }
     return(new KeyBind());
 }
Ejemplo n.º 3
0
 public static int GetSliderValue(this Menu config, string name)
 {
     try
     {
         return(config.Item(name).GetValue <Slider>().Value);
     }
     catch (Exception)
     {
         DeBug.WriteConsole("[菜单取值]", $"名为{name}的菜单项的值类型不是SliderValue", DebugLevel.Wrang);
     }
     return(0);
 }
Ejemplo n.º 4
0
 public static Color GetCircleColor(this Menu config, string name)
 {
     try
     {
         return(config.Item(name).GetValue <Circle>().Color);
     }
     catch (Exception)
     {
         DeBug.WriteConsole("[菜单取值]", $"名为{name}的菜单项的值类型不是CircleColor", DebugLevel.Wrang);
     }
     return(Color.White);
 }
Ejemplo n.º 5
0
 public static int GetStringIndex(this Menu config, string name)
 {
     try
     {
         return(config.Item(name).GetValue <StringList>().SelectedIndex);
     }
     catch (Exception)
     {
         DeBug.WriteConsole("[菜单取值]", $"名为{name}的菜单项的值类型不是StringIndex", DebugLevel.Wrang);
     }
     return(0);
 }
Ejemplo n.º 6
0
 public static StringList GetStringList(this Menu config, string name)
 {
     try
     {
         return(config.Item(name).GetValue <StringList>());
     }
     catch (Exception)
     {
         DeBug.WriteConsole("[菜单取值]", $"名为{name}的菜单项的值类型不是StringList", DebugLevel.Wrang);
     }
     return(new StringList());
 }
Ejemplo n.º 7
0
 public static bool GetBool(this Menu config, string name)
 {
     try
     {
         return(config.Item(name).GetValue <bool>());
     }
     catch (Exception ex)
     {
         DeBug.WriteConsole("[菜单取值]", $"名为{name}的菜单项的值类型不是bool", DebugLevel.Wrang);
     }
     return(false);
 }
Ejemplo n.º 8
0
        private static async void UpdateCheck()
        {
            try
            {
                using (var web = new WebClient())
                {
                    var rawFile = await web.DownloadStringTaskAsync(CheckUrl);

                    var checkFile =
                        new Regex(@"\[assembly\: AssemblyVersion\(""(\d{1,})\.(\d{1,})\.(\d{1,})\.(\d{1,})""\)\]").Match
                            (rawFile);
                    if (!checkFile.Success)
                    {
                        return;
                    }
                    var gitVersion =
                        new System.Version(
                            $"{checkFile.Groups[1]}.{checkFile.Groups[2]}.{checkFile.Groups[3]}.{checkFile.Groups[4]}");
                    if (gitVersion > Assembly.GetExecutingAssembly().GetName().Version)
                    {
                        Game.PrintChat("[版本检查]".ToHtml(Color.Gold, FontStlye.Bold)
                                       + " "
                                       + MenuConfig.DisplayName.ToHtml(Color.SkyBlue, FontStlye.Bold)
                                       + " "
                                       + "有新版本".ToHtml(Color.SkyBlue) + gitVersion.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                Game.PrintChat("[版本检查]".ToHtml(Color.Gold, FontStlye.Bold)
                               + " "
                               + MenuConfig.DisplayName.ToHtml(Color.Red, FontStlye.Bold)
                               + " "
                               + "的版本检查发生了异常".ToHtml(Color.Red));

                DeBug.WriteConsole("[版本检查]", MenuConfig.DisplayName + "的版本检查发生了异常\n" + ex.Message, DebugLevel.Warning);
            }
        }
Ejemplo n.º 9
0
        private static async void News()
        {
            try
            {
                using (var web = new WebClient())
                {
                    var rawFile = await web.DownloadStringTaskAsync(NewsUrl);

                    if (!string.IsNullOrEmpty(rawFile))
                    {
                        Game.PrintChat("[新闻]".ToHtml(Color.Gold, FontStlye.Bold)
                                       + " "
                                       + MenuConfig.DisplayName.ToHtml(Color.SkyBlue, FontStlye.Bold)
                                       + rawFile);
                    }
                }
            }
            catch (Exception ex)
            {
                DeBug.WriteConsole("[新闻]", MenuConfig.DisplayName + "获取新闻发生了异常\n" + ex.Message, DebugLevel.Warning);
            }
        }