Пример #1
0
        private static void Game_OnInput(GameInputEventArgs args)
        {
            if (!Config.Item(ObjectManager.Player.Name).GetValue <bool>())
            {
                return;
            }

            string from, to, TranslatedString = "";

            from = ((Language)Config.Item("src").GetValue <StringList>().SelectedIndex).ToString();
            to   = ((Language)Config.Item("dec").GetValue <StringList>().SelectedIndex).ToString();

            string msg = Utill.Utf2Ansi(args.Input);

            switch (Config.Item("API").GetValue <StringList>().SelectedIndex)
            {
            case 0:
                TranslatedString = Utill.TranslateByBaidu(msg, from, to);
                break;

            default:
                TranslatedString = Utill.TranslateByBaidu(msg, from, to);
                break;
            }

            if (!string.IsNullOrEmpty(TranslatedString))
            {
                Game.Say(TranslatedString);
                args.Process = false;
            }
            else
            {
                Game.PrintChat("出错了!没有得到翻译结果");
            }
        }
Пример #2
0
        private static void Game_OnChat(GameChatEventArgs args)
        {
            if (args.Sender.IsMe)
            {
                return;
            }
            if (!Config.Item(args.Sender.Name).GetValue <bool>())
            {
                return;
            }

            string from, to, TranslatedString = "";

            from = ((Language)Config.Item("src").GetValue <StringList>().SelectedIndex).ToString();
            to   = ((Language)Config.Item("dec").GetValue <StringList>().SelectedIndex).ToString();

            switch (Config.Item("API").GetValue <StringList>().SelectedIndex)
            {
            case 0:
                TranslatedString = Utill.TranslateByBaidu(Utill.Utf2Ansi(args.Message), from, to);
                break;

            default:
                TranslatedString = Utill.TranslateByBaidu(Utill.Utf2Ansi(args.Message), from, to);
                break;
            }
            if (!string.IsNullOrEmpty(TranslatedString))
            {
                Game.PrintChat("[{0}]{1}({2}):{3}",
                               new TimeSpan(0, 0, (int)Game.ClockTime),
                               args.Sender.Name,
                               args.Sender.ChampionName,
                               TranslatedString);
                if (Config.Item("DonotProcess").GetValue <bool>())
                {
                    args.Process = false;
                }
            }
            else
            {
                Game.PrintChat("出错了!没有得到翻译结果");
            }
        }