Esempio n. 1
0
        void Loaded(PluginEvents.LoadCompleteEvent e)
        {
            var ortdp = getHoster().EnumPluings().FirstOrDefault(p => p.Name == "OsuRTDataProvider");
            var rtt   = getHoster().EnumPluings().FirstOrDefault(p => p.Name == "RealTimePPDisplayer");

            _rawFormat = new StringBuilder();
            try
            {
                if (rtt is RealTimePPDisplayer.RealTimePPDisplayerPlugin r)
                {
                    _rtppdInfo = new RtppdInfo();
                    if (_rtppdInfo != null)
                    {
                        _ortdpWrapper = new osuTools.OrtdpWrapper.OrtdpWrapper(ortdp as OsuRTDataProvider.OsuRTDataProviderPlugin, r, _rtppdInfo);
                        IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_INITSUC"));
                    }
                }
                IO.CurrentIO.Write(Environment.CurrentDirectory);
                var process = System.Diagnostics.Process.GetCurrentProcess();
                var curdir  = process.MainModule?.FileName.Replace("Sync.exe", "plugins");
                Environment.CurrentDirectory = curdir ?? "";
                GetAvaProperties(_ortdpWrapper);
            }
            catch (NullReferenceException ex)
            {
                IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_INITFAILED") + ex.ToString(), ConsoleColor.Red);
            }
            ThreadPool.QueueUserWorkItem(state => ConigFileWatcher());
            ThreadPool.QueueUserWorkItem(state => RefreshMmf());
        }
Esempio n. 2
0
        void GetOsz(InfoReader instance)
        {
            var ortdpWrapper = instance.GetOrtdp();

            Win32Class.SevenZip zip = new Win32Class.SevenZip {
                SevenZipDirectory = "..\\pg\\7-zip\\7za.exe"
            };
            StringBuilder tmp       = new StringBuilder(ortdpWrapper.FullPath);
            string        basicinfo = $"{ortdpWrapper.Artist} - {ortdpWrapper.Title}";
            string        pattern   = "[" + new string(Path.GetInvalidPathChars()) + new string(Path.GetInvalidFileNameChars()) + ":*]";

            System.Text.RegularExpressions.Regex    reg = new System.Text.RegularExpressions.Regex(pattern);
            Win32Class.SevenZip.Native.SevenZipArgs arg = new Win32Class.SevenZip.Native.SevenZipArgs
            {
                FileType = Win32Class.SevenZip.Native.ArchieveType.Zip
            };
            string newdir = reg.Replace($"{ortdpWrapper.Artist} - {ortdpWrapper.Title}", " ");

            arg.ArchieveFileName = "\"" + instance.Setting.OszDir + "\\" + ortdpWrapper.Beatmap.BeatmapSetId + " " + newdir + ".osz\"";
            if (File.Exists(arg.ArchieveFileName.Trim('\"')))
            {
                IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_OSZEXISTED"));
                File.Delete(arg.ArchieveFileName.Trim('\"'));
            }
            arg.OperationType = Win32Class.SevenZip.Native.Operation.Add;
            if (!instance.Setting.OszDir.ToString().EndsWith("\\"))
            {
                arg.Files = "\"" + ortdpWrapper.Beatmap.BeatmapFolder + "\\*.*" + "\"";
            }
            else
            {
                arg.Files = "\"" + ortdpWrapper.Beatmap.BeatmapFolder + "\"";
            }
            var sta = Win32Class.SevenZip.Native.Run7zCmd(zip.SevenZipDirectory, arg);

            if (sta == Win32Class.SevenZip.Native.SevenZipStateCode.Success)
            {
                IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_COMPRESSED"));
            }
            if (sta == Win32Class.SevenZip.Native.SevenZipStateCode.FaltalError)
            {
                IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_7ZSTATUS_FATALERR"), ConsoleColor.Red);
            }
            if (sta == Win32Class.SevenZip.Native.SevenZipStateCode.OutOfMemory)
            {
                IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_7ZSTATUS_OUTOFMEMORY"), ConsoleColor.Red);
            }
            if (sta == Win32Class.SevenZip.Native.SevenZipStateCode.Canceled)
            {
                IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_7ZSTATUS_OPERATIONCANCELED"), ConsoleColor.Red);
            }
            if (sta == Win32Class.SevenZip.Native.SevenZipStateCode.CommandLineError)
            {
                IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_7ZSTATUS_COMMANDLINEERR"), ConsoleColor.Red);
            }
            if (sta == Win32Class.SevenZip.Native.SevenZipStateCode.Warning)
            {
                IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_7ZSTATUS_WARNINGS"), ConsoleColor.Yellow);
            }
        }
Esempio n. 3
0
 public CommandProcessorException(string msg, ICommandProcessor processor, Exception innerException) : base(msg, innerException)
 {
     if (msg == NI18n.GetLanguageElement("LANG_ERR_PROCESSPREXCEPTION"))
     {
         Message = string.Format(msg, processor.MainCommand, innerException.Message);
     }
 }
Esempio n. 4
0
        public bool Process(InfoReader instance, CommandParser parser)
        {
            Beatmap currentBeatmap = instance.GetOrtdp().Beatmap;

            if (parser.Arguments[0] == "au")
            {
                if (currentBeatmap is null || string.IsNullOrEmpty(currentBeatmap.AudioFileName) || !File.Exists(currentBeatmap.FullAudioFileName))
                {
                    return(true);
                }
                string ext        = Path.GetExtension(currentBeatmap.FullAudioFileName);
                string targetPath = GetName(instance.Setting.DefaultMusicCopyingDirectory, currentBeatmap, ext);
                if (!File.Exists(targetPath))
                {
                    File.Copy(currentBeatmap.FullAudioFileName ?? throw new InvalidOperationException(), targetPath);
                }
                IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_COPYSUCCESS"));
            }
            else if (parser.Arguments[0] == "vi")
            {
                if (currentBeatmap is null || !currentBeatmap.HasVideo || string.IsNullOrEmpty(currentBeatmap.VideoFileName) || !File.Exists(currentBeatmap.FullVideoFileName))
                {
                    return(true);
                }
                string ext        = Path.GetExtension(currentBeatmap.VideoFileName);
                string targetPath = GetName(instance.Setting.DefaultMusicCopyingDirectory, currentBeatmap, ext);
                if (!File.Exists(targetPath))
                {
                    File.Copy(currentBeatmap.FullVideoFileName ?? throw new InvalidOperationException(), targetPath);
                }
                IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_COPYSUCCESS"));
            }
            else if (parser.Arguments[0] == "bg")
            {
                if (currentBeatmap is null || string.IsNullOrEmpty(currentBeatmap.BackgroundFileName) || !File.Exists(currentBeatmap.FullBackgroundFileName))
                {
                    return(true);
                }
                string ext        = Path.GetExtension(currentBeatmap.BackgroundFileName);
                string targetPath = GetName(instance.Setting.DefaultBackgroundCopyingDirectory, currentBeatmap, ext);
                if (!File.Exists(targetPath))
                {
                    File.Copy(currentBeatmap.FullBackgroundFileName ?? throw new InvalidOperationException(), targetPath);
                }
                IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_COPYSUCCESS"));
            }
            else if (parser.Arguments[0] == "osz")
            {
                GetOsz(instance);
            }
            else
            {
                IO.CurrentIO.Write(GetHelp());
            }
            return(true);
        }
Esempio n. 5
0
        public string GetHelp()
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine(NI18n.GetLanguageElement("LANG_HELP_GETINFO_EXTRA"));
            builder.AppendLine(NI18n.GetLanguageElement("LANG_INFO_AVAILABLECMDS"));
            foreach (var command in _infoReader.CommandProcessors.Processors)
            {
                builder.AppendLine(command.Value.MainCommand);
            }
            return(builder.ToString());
        }
Esempio n. 6
0
        public bool Process(InfoReader infoReader, CommandParser parser)
        {
            Type t = infoReader.GetOrtdp().GetType();

            PropertyInfo[] properties = t.GetProperties();
            StringBuilder  b          = new StringBuilder();

            foreach (var property in properties)
            {
                if (property.GetCustomAttribute <AvailableVariableAttribute>() is AvailableVariableAttribute attr)
                {
                    b.AppendLine($"{attr.VariableName}   {NI18n.GetLanguageElement(attr.LanguageElementName)}");
                }
                if (property.PropertyType.IsClass)
                {
                    var currentObject = property.GetValue(infoReader.GetOrtdp());
                    if (!(currentObject is null))
                    {
                        var currentProperties = currentObject.GetType().GetProperties();
                        foreach (var i in currentProperties)
                        {
                            if (i.GetCustomAttribute <AvailableVariableAttribute>() is AvailableVariableAttribute attra)
                            {
                                b.AppendLine($"{attra.VariableName}   {NI18n.GetLanguageElement(attra.LanguageElementName)}");
                            }
                        }
                    }
                }
            }
            if (File.Exists("vars.txt"))
            {
                MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider();
                provider.ComputeHash(File.ReadAllBytes("vars.txt"));
                string md5NewFile = MD5String.GetString(provider);
                provider.ComputeHash(b.ToString().ToBytes());
                string md5Target = MD5String.GetString(provider);
                if (md5NewFile != md5Target)
                {
                    IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_WRITINGHELP"));
                    File.WriteAllText("vars.txt", b.ToString());
                }
            }
            else
            {
                IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_WRITINGHELP"));
                File.WriteAllText("vars.txt", b.ToString());
            }
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo {
                FileName = "notepad.exe", Arguments = "vars.txt"
            });
            return(true);
        }
Esempio n. 7
0
        void Search(InfoReader infoReader, string varName)
        {
            var p = infoReader.GetOrtdp().GetType().GetProperties();

            Sync.Tools.IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_VARSEARCHRESULT"));
            foreach (System.Reflection.PropertyInfo info in p)
            {
                string argupper = varName.ToUpper();
                string perupper = info.Name.ToUpper();
                if (perupper.Contains(argupper))
                {
                    Sync.Tools.IO.CurrentIO.Write(info.Name, false, false);
                    Sync.Tools.IO.CurrentIO.Write(" ", false, false);
                }
            }
            Sync.Tools.IO.CurrentIO.Write("\n", true, false);
        }
Esempio n. 8
0
        public bool GetInfo(Arguments args)
        {
            Command.CommandParser parser    = new Command.CommandParser(args);
            ICommandProcessor     processor = null;

            if (CommandProcessors.Processors.ContainsKey(parser.MainCommand))
            {
                processor = CommandProcessors[parser.MainCommand];
            }
            try
            {
                if (processor != null)
                {
                    processor.Process(this, parser);
                }
                else
                {
                    IO.CurrentIO.Write(CommandProcessors["help"].GetHelp());
                    return(true);
                }
            }
            catch (Exception ex)
            {
                if (processor is ICommandProcessor p)
                {
                    if (!p.AutoCatch)
                    {
                        throw new CommandProcessorException(NI18n.GetLanguageElement("LANG_ERR_PROCESSOREXCEPTION"), p,
                                                            ex);
                    }
                    else
                    {
                        bool handled = p.OnUnhandledException(this, ex);
                        if (!handled)
                        {
                            string notification = string.Format(NI18n.GetLanguageElement("LANG_ERR_UNHANDLEDEXCEPTION"),
                                                                p.MainCommand, ex);
                            IO.CurrentIO.WriteColor(notification, ConsoleColor.Red);
                        }
                    }
                }
            }
            EventBus.RaiseEvent(new PEvent("getinfo"));
            return(true);
        }
Esempio n. 9
0
        public bool Process(InfoReader instance, CommandParser parser)
        {
            string apiKey = instance.Setting.ApiKey;

            if (parser.MainCommand == "user")
            {
                if (parser.Arguments[0] == "show")
                {
                    if (IsModeString(parser.Arguments.Last(), out int mode))
                    {
                        OnlineUserQuery query = new OnlineUserQuery
                        {
                            Mode      = (OsuGameMode)mode,
                            UserName  = CombineString(parser.Arguments.GetRange(1, parser.Arguments.Count - 2).ToArray()),
                            OsuApiKey = apiKey
                        };
                        try
                        {
                            if (query.UserInfo.UserId == 0)
                            {
                                string format = NI18n.GetLanguageElement("LANG_ERR_FAILTOQUERYUSERINFO");
                                throw new osuTools.Exceptions.OnlineQueryFailedException(string.Format(format,
                                                                                                       string.IsNullOrEmpty(query.UserName) ? query.UserId.ToString() : query.UserName));
                            }
                            IO.CurrentIO.Write(query.UserInfo.ToString());
                        }
                        catch (Exception e)
                        {
                            IO.CurrentIO.WriteColor(e.Message, ConsoleColor.Red);
                        }
                    }
                    else
                    {
                        IO.CurrentIO.WriteColor("模式必须在最后一个参数的位置被指定。",
                                                ConsoleColor.Red);
                        return(true);
                    }
                }
            }

            return(true);
        }
Esempio n. 10
0
        public MemFileMapFormat()
        {
            InitializeComponent();

            tabPage_playing.Text    = NI18n.GetLanguageElement("LANG_MMFWIN_PLAYING");
            tabPage_selectSong.Text = NI18n.GetLanguageElement("LANG_MMFWIN_SELECTSONG");
            tabPage_ranking.Text    = NI18n.GetLanguageElement("LANG_MMFWIN_RANKING");
            tabPage_editing.Text    = NI18n.GetLanguageElement("LANG_MMFWIN_EDITING");
            tabPage_matchSet.Text   = NI18n.GetLanguageElement("LANG_MMFWIN_MATCHSET");
            tabPage_idle.Text       = NI18n.GetLanguageElement("LANG_MMFWIN_IDLE");
            tabPage_lobby.Text      = NI18n.GetLanguageElement("LANG_MMFWIN_LOBBY");
            if (!Directory.Exists("FormatInfo"))
            {
                Directory.CreateDirectory("FormatInfo");
            }
            string[] dirs =
            {
                "FormatInfo\\PlayingFormatConfig.ini",
                "FormatInfo\\SelectSongFormatConfig.ini",
                "FormatInfo\\RankFormatConfig.ini",
                "FormatInfo\\LobbyFormatConfig.ini",
                "FormatInfo\\MatchSetupFormatConfig.ini",
                "FormatInfo\\IdleFormatConfig.ini",
                "FormatInfo\\EditingFormatConfig.ini",
            };
            foreach (var file in dirs)
            {
                if (!File.Exists(file))
                {
                    File.Create(file);
                }
            }
            tx_playing.Text    = File.ReadAllText("FormatInfo\\PlayingFormatConfig.ini");
            tx_selectSong.Text = File.ReadAllText("FormatInfo\\SelectSongFormatConfig.ini");
            tx_rank.Text       = File.ReadAllText("FormatInfo\\RankFormatConfig.ini");
            tx_lobby.Text      = File.ReadAllText("FormatInfo\\LobbyFormatConfig.ini");
            tx_matchSet.Text   = File.ReadAllText("FormatInfo\\MatchSetupFormatConfig.ini");
            tx_idle.Text       = File.ReadAllText("FormatInfo\\IdleFormatConfig.ini");
            tx_editing.Text    = File.ReadAllText("FormatInfo\\EditingFormatConfig.ini");
        }
Esempio n. 11
0
        string GetName(string folder, IBeatmap beatmap, string extension)
        {
            if (string.IsNullOrEmpty(folder))
            {
                throw new ArgumentException("文件夹名不能为空");
            }
            if (beatmap is null)
            {
                throw new ArgumentNullException(nameof(beatmap), "谱面不能为null");
            }
            string beatmapFolder = $"{beatmap.Artist} - {beatmap.Title}";

            folder = Path.Combine(folder, beatmapFolder);
            TryCreateDirectory(folder);
            string orignalName = $"{beatmap.Artist} - {beatmap.Title} [{beatmap.Version}]";

            if (folder.Length + orignalName.Length > 248)
            {
                orignalName = $"{beatmap.Title} [{beatmap.Version}]";
            }
            if (folder.Length + orignalName.Length > 248)
            {
                orignalName = $"{beatmap.Title}";
            }
            if (folder.Length + orignalName.Length > 248)
            {
                IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_ERR_PATHTOOLONG"), ConsoleColor.Red);
                return(null);
            }
            if (!extension.StartsWith("."))
            {
                extension = "." + extension;
            }
            orignalName = GetValidDir(orignalName);
            return(Path.Combine(folder, orignalName) + extension);
        }
Esempio n. 12
0
 void CommandInit(PluginEvents.InitCommandEvent e)
 {
     e.Commands.Dispatch.bind("getinfo", GetInfo, NI18n.GetLanguageElement("LANG_HELP_INFO"));//普通的获取信息,在Sync中输入getinfo help查看详细信息
 }
Esempio n. 13
0
 public string GetHelp() =>
 NI18n.GetLanguageElement("LANG_HELP_OPENER") +
 "getinfo open beatmap <page> [BeatmapId]\n" +
 "getinfo open userpage [username]\n" +
 "getinfo open <beatmapfolder|musicfolder|bgfolder|videofolder|oszfolder>";
Esempio n. 14
0
 public string GetHelp() => NI18n.GetLanguageElement("LANG_HELP_SEARCH");
Esempio n. 15
0
 public string GetHelp() => NI18n.GetLanguageElement("LANG_HELP_LISTVARS");
Esempio n. 16
0
 public string GetHelp() => NI18n.GetLanguageElement("LANG_HELP_GETUSERINFO");
Esempio n. 17
0
 public bool Process(InfoReader instance, CommandParser parser)
 {
     try
     {
         var osuprocesses = System.Diagnostics.Process.GetProcessesByName("osu!");
         if (osuprocesses.Length == 0)
         {
             if (string.IsNullOrEmpty(instance.Setting.GameDir))
             {
                 IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_WAITINGFOROSU"), ConsoleColor.Red);
                 while (osuprocesses.Length == 0)
                 {
                     System.Threading.Thread.Sleep(3000);
                 }
             }
             else
             {
                 IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_STARTOSU"), ConsoleColor.Red);
                 System.Diagnostics.Process.Start(instance.Setting.GameDir);
             }
         }
         osuprocesses = System.Diagnostics.Process.GetProcessesByName("osu!");
         var osuprocess = osuprocesses[0];
         var osu        = new HandleTypes.ProcessHandle(osuprocess);
         foreach (ProcessModule module in osuprocess.Modules)
         {
             if (module.ModuleName.ToUpper().Contains("Overlay.dll".ToUpper()))
             {
                 IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_HASINJECTED"));
                 return(true);
             }
         }
         Injector  injector = new Injector(osu.PID, $"{Environment.CurrentDirectory}\\..\\overlay.dll");
         var       res      = injector.Inject();
         Stopwatch s        = new Stopwatch();
         if (res)
         {
             var modules = osuprocess.Modules;
             s.Start();
             while (s.Elapsed.TotalSeconds < 0.5)
             {
                 foreach (ProcessModule module in modules)
                 {
                     if (module.ModuleName.ToUpper().Contains("Overlay.dll".ToUpper()))
                     {
                         IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_INJECTED"), ConsoleColor.DarkGreen);
                         IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_RESTARTSYNC"), ConsoleColor.DarkGreen);
                         System.Threading.Thread.Sleep(3000);
                         Sync.SyncHost.Instance.RestartSync();
                         return(true);
                     }
                 }
             }
             if (!File.Exists("injector.exe"))
             {
                 File.WriteAllBytes("injector.exe", Resource1.FallbackInjector);
             }
             var cinjector = System.Diagnostics.Process.Start(
                 new ProcessStartInfo
             {
                 FileName        = "injector",
                 Arguments       = $"\"{Environment.CurrentDirectory}\\..\\overlay.dll\" {osuprocess.Id}",
                 CreateNoWindow  = true,
                 UseShellExecute = false
             });
             while (s.Elapsed.TotalSeconds < 0.5)
             {
                 foreach (ProcessModule module in modules)
                 {
                     if (module.ModuleName.ToUpper().Contains("Overlay.dll".ToUpper()))
                     {
                         IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_INJECTED"), ConsoleColor.DarkGreen);
                         IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_RESTARTSYNC"), ConsoleColor.DarkGreen);
                         System.Threading.Thread.Sleep(3000);
                         Sync.SyncHost.Instance.RestartSync();
                         return(true);
                     }
                 }
             }
             IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_INJECTED"), ConsoleColor.DarkGreen);
             IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_INFO_RESTARTSYNC"), ConsoleColor.DarkGreen);
             System.Threading.Thread.Sleep(3000);
             Sync.SyncHost.Instance.RestartSync();
             return(true);
         }
         else
         {
             string msg = NI18n.GetLanguageElement("LANG_INJECTIONFAILED");
             msg += $"({WinAPI.ErrorHandle.GetLastError()}),{WinAPI.ErrorHandle.GetErrorString(WinAPI.ErrorHandle.FormatMessageFlags.FromSystem)}";
             IO.CurrentIO.WriteColor(msg, ConsoleColor.Red);
             return(true);
         }
     }
     catch (InvalidOperationException)
     {
         if (instance.Setting.GameDir == "")
         {
             IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_ERR_NOOSUDIR"), ConsoleColor.Red);
         }
         return(true);
     }
     catch (System.ComponentModel.Win32Exception)
     {
         if (!File.Exists(instance.Setting.GameDir))
         {
             IO.CurrentIO.WriteColor(NI18n.GetLanguageElement("LANG_ERR_NOOSU"), ConsoleColor.Red);
         }
         return(true);
     }
 }
Esempio n. 18
0
 public string GetHelp() => NI18n.GetLanguageElement("LANG_HELP_REINJECT");
Esempio n. 19
0
        public bool Process(InfoReader instance, CommandParser parser)
        {
            if (_viewer is null)
            {
                _viewer = new VariableViewer(instance.GetOrtdp());
            }

            if (parser.MainCommand == "var")
            {
                if (parser.Arguments[0] == "gui")
                {
                    if (!_msgLoopStarted)
                    {
                        if (instance.Setting.DebugMode.ToString().Equals("True", StringComparison.OrdinalIgnoreCase))
                        {
                            IO.CurrentIO.Write($"Message loop on window VariableViewer started.");
                        }

                        Thread th = new Thread(() =>
                        {
                            System.Windows.Forms.Application.Run(_viewer);
                        });
                        th.Start();
                        if (th.ThreadState == ThreadState.Running)
                        {
                            _msgLoopStarted = true;
                        }
                        return(true);
                    }
                    if (instance.Setting.DebugMode.ToString().Equals("True", StringComparison.OrdinalIgnoreCase))
                    {
                        IO.CurrentIO.Write($"Message loop on VariableViewer is running. Showing window...");
                    }
                    _viewer.Show();
                    return(true);
                }
                int      match             = 0;
                var      s                 = parser.Arguments[0];
                Type     t                 = instance.GetOrtdp().GetType();
                var      ps                = t.GetProperties();
                string[] gets              = s.Split('.');
                object   currentObject     = instance.GetOrtdp();
                var      currentProperties = ps;
                foreach (var name in gets)
                {
                    foreach (var property in currentProperties)
                    {
                        if (property.Name == name)
                        {
                            currentObject     = property.GetValue(currentObject);
                            currentProperties = currentObject.GetType().GetProperties();
                            match++;
                        }
                    }
                }

                IO.CurrentIO.Write(match == gets.Length
                    ? $"{s}:{currentObject}"
                    : NI18n.GetLanguageElement("LANG_ERR_VARNOTFOUND"));
                return(true);
            }


            return(true);
        }
Esempio n. 20
0
 public string GetHelp() => NI18n.GetLanguageElement("LANG_HELP_VARGETTER") + "\n" + NI18n.GetLanguageElement("LANG_HELP_VARGUI");
Esempio n. 21
0
 public string GetHelp() => NI18n.GetLanguageElement("LANG_HELP_MMFCONFIG");
Esempio n. 22
0
        public InfoReader() : base(PLUGIN_NAME, PLUGIN_AUTHOR)
        {
            if (!File.Exists("InfoReader.db"))
            {
                File.WriteAllBytes("InfoReader.db", Resource1.Database);
            }

            /*else
             * {
             *  byte[] dbBytes = File.ReadAllBytes("InfoReader.db");
             *  MD5 selfMd5 = MD5.Create(), fileMd5 = MD5.Create();
             *  selfMd5.ComputeHash(Resource1.Database);
             *  fileMd5.ComputeHash(dbBytes);
             *  MD5String selfMd5String = new MD5String(selfMd5), fileMd5String = new MD5String(fileMd5);
             *  if (selfMd5String != fileMd5String)
             *  {
             *      File.Delete("InfoReader.db");
             *      File.WriteAllBytes("InfoReader.db",Resource1.Database);
             *  }
             * }*/
            StringBuilder builder = new StringBuilder(32);

            GetPrivateProfileString("Sync.DefaultConfiguration", "Language", "zh-cn", builder, 32, "..\\config.ini");
            SyncLang     = builder.ToString();
            CurrentNi18N = NI18n.GetCurrentLanguage();
            CurrentNi18N.InitializeOperator();
            ScanCommand();
            if (File.Exists("RealTimePPDisplayer.dll"))
            {
                byte[] b = File.ReadAllBytes("RealTimePPDisplayer.dll");
                MD5    selfMd5 = MD5.Create(), fileMd5 = MD5.Create();
                selfMd5.ComputeHash(Resource1.ModifiedRealTimePPDisplayer);
                fileMd5.ComputeHash(b);
                if (MD5String.GetString(selfMd5) != MD5String.GetString(fileMd5))
                {
                    var dirInfo = Directory.CreateDirectory("..\\OrignalRealTimePPDisplayer\\");
                    IO.CurrentIO.Write(NI18n.GetLanguageElement("LANG_INFO_RTPPDREPLACED"));
                    if (File.Exists(Path.Combine(dirInfo.FullName, "RealTimePPDisplayer.dll")))
                    {
                        File.Delete(Path.Combine(dirInfo.FullName, "RealTimePPDisplayer.dll"));
                    }
                    File.Move("RealTimePPDisplayer.dll", Path.Combine(dirInfo.FullName, "RealTimePPDisplayer.dll"));
                    File.WriteAllBytes("RealTimePPDisplayer.dll", Resource1.ModifiedRealTimePPDisplayer);
                }
            }
            else
            {
                File.WriteAllBytes("RealTimePPDisplayer.dll", Resource1.ModifiedRealTimePPDisplayer);
            }

            /*if(!File.Exists("bass.dll"))
             *  File.WriteAllBytes("bass.dll",Resource1.bass);*/

            _outputInfoMap = MemoryMappedFile.CreateOrOpen("InfoReaderMmf", 128);
            EventBus.BindEvent <PluginEvents.InitPluginEvent>(Init);
            EventBus.BindEvent <PluginEvents.LoadCompleteEvent>(Loaded);
            EventBus.BindEvent <PluginEvents.InitCommandEvent>(CommandInit);
            PluginConfigurationManager manager = new Sync.Tools.PluginConfigurationManager(this);

            manager.AddItem(Setting);
        }
Esempio n. 23
0
 public string GetHelp() => NI18n.GetLanguageElement("LANG_HELP_FILEGETTER");