Beispiel #1
0
 private void LoLWatchTimer_Tick(object sender, EventArgs args)
 {
     if (!LeagueOfLegendsAnalyzer.IsLoLExists())
     {
         LoLWatchTimer.Stop();
         if (_recordPlayer != null)
         {
             _recordPlayer.StopPlaying();
         }
         if (AnyEvent != null)
         {
             AnyEvent(true, null);
         }
     }
     else
     {   //
         //if (!_cameraToolInjected && Properties.Settings.Default.EnableCameraRotation)
         //{
         //    ProcessMemory processMemory = new ProcessMemory();
         //    processMemory.openProcess(lol);
         //    _cameraToolInjected = processMemory.injectDll(Constants.CameraToolDllName);
         //    processMemory.closeProcess();
         //}
     }
 }
Beispiel #2
0
        private void UpdateLoL()
        {
            Process pastLol = lol;

            lol = Utilities.GetProcess(Constants.LoLExeName);
            if (pastLol == null && lol != null)
            {
                ExecutionData                = new LoLExeData();
                ExecutionData.Process        = lol;
                ExecutionData.ExecutablePath = LeagueOfLegendsAnalyzer.GetLoLExecutingPath();
                ExecutionData.LogFilePath    = GetLogFilePath(ExecutionData.ExecutablePath);
                ExecutionData.CommandLine    = Utilities.GetCommandLine(lol.Id);
                ExecutionData.LoLProcess     = lol;
                LoLCommandAnalyzer analyzer = new LoLCommandAnalyzer(ExecutionData.CommandLine);

                ExecutionData.MatchInfo = analyzer.GetGameInfo();
                if (LoLStartedEvent != null)
                {
                    LoLStarted dele = new LoLStarted(LoLStartedEvent);
                    Dispatcher.Invoke(dele, this, ExecutionData, analyzer.IsSuccess);
                }
            }
            else if (pastLol != null && lol == null)
            {
                ExecutionData = null;
                if (LoLFinishedEvent != null)
                {
                    LoLFinishedEvent();
                }
            }
        }
Beispiel #3
0
        public static String GetExecutablePath(String processName)
        {
            String        exePath = null;
            Process       p       = Utilities.GetProcess(processName);
            ProcessModule module  = null;

            try
            {
                module = p.MainModule;
            }
            catch (Exception e)
            {
                Logger.Instance.WriteLog("Get process MainModule failed: " + e.Message);
            }

            try
            {
                exePath = module.FileName;
            }
            catch (Exception e)
            {
                Logger.Instance.WriteLog("Get process MainModule FileName failed: " + e.Message);
            }

            if (exePath == null)
            {
                try
                {
                    exePath = LeagueOfLegendsAnalyzer.GetMainModuleFilepath(p.Id);
                }
                catch (Exception e)
                {
                    Logger.Instance.WriteLog("GetExecutablePath: " + e.Message);
                }
            }

            if (exePath == null)
            {
                if (System.Environment.OSVersion.Version.Major >= 6)
                {
                    ProcessMemory pm = new ProcessMemory();
                    pm.openProcess(Constants.LoLExeName);
                    exePath = pm.GetProcessPath();
                    pm.closeProcess();
                }
            }

            if (exePath == null)
            {
                Logger.Instance.WriteLog(String.Format("Can't get {0} path", processName));
            }
            else
            {
                Logger.Instance.WriteLog(String.Format("{0} path is {1}", processName, exePath));
            }
            return(exePath);
        }
Beispiel #4
0
 public void PlayGame(GameInfo info)
 {
     if (!LeagueOfLegendsAnalyzer.IsLoLExists())
     {
         if (!LeagueOfLegendsAnalyzer.CheckLoLExeSelected())
         {
             return;
         }
     }
     StartLoLLauncher(new LoLLauncher(info));
 }
Beispiel #5
0
 private void StartLoLLauncher(LoLLauncher launcher)
 {
     if (!LeagueOfLegendsAnalyzer.CheckLoLExeSelected())
     {
         return;
     }
     _launcher           = launcher;
     _launcher.Parent    = this;
     _launcher.AnyEvent += LoLLauncherDone;
     _launcher.StartPlaying();
 }
Beispiel #6
0
        private bool GetAppropriateLoLExe()
        {
            String nowSimpleVer = null;

            Logger.Instance.WriteLog("Get appropriate LoL version.");
            try
            {
                string nowExeVer = FileVersionInfo.GetVersionInfo(_exePath).ProductVersion;
                Logger.Instance.WriteLog(String.Format("LoL version is: {0}", nowExeVer));
                nowSimpleVer = Utilities.GetSimpleVersionNumber(nowExeVer);
                Logger.Instance.WriteLog(String.Format("LoL short version is: {0}", nowSimpleVer));
            }
            catch
            {
                Logger.Instance.WriteLog("Wrong League of Legends.exe");
                LeagueOfLegendsAnalyzer.ResetLoLExePath();
                return(false);
            }

            String targetVer = null;

            //String spVer = null;
            try
            {
                if (_localPlay)
                {
                    targetVer = Utilities.GetSimpleVersionNumber(new String(_record.lolVersion));
                    if (String.Compare(targetVer, nowSimpleVer) != 0)
                    {
                        return(false);
                    }
                }
                else
                {
                    targetVer = nowSimpleVer;
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Beispiel #7
0
        public LoLRecorder StartNewRecoding(GameInfo info = null, Boolean playNow = false, Boolean externalStart = false, PlayerInfo[] players = null)
        {
            if (!LeagueOfLegendsAnalyzer.IsLoLExists())     //觀戰用,LoL沒在執行時要先確定有LoL路徑
            {
                if (!LeagueOfLegendsAnalyzer.CheckLoLExeSelected())
                {
                    return(null);
                }
            }
            LoLRecorder r = new LoLRecorder(info, externalStart);

            r.doneEvent     += new RecordDoneDelegate(RecordDone);
            r.infoDoneEvent += new BaronReplays.LoLRecorder.RecordEventDelegate(RecordInfoDone);

            if (players != null)
            {
                r.record.players = players;
            }


            if (playNow)
            {
                if (!LeagueOfLegendsAnalyzer.CheckLoLExeSelected())
                {
                    return(r);
                }
                r.prepareContentDoneEvent += Recorder_prepareContentDoneEvent;
            }

            ThreadStart recoderfunc = new ThreadStart(r.startRecording);
            Thread      t           = new Thread(recoderfunc);

            t.IsBackground = true;
            t.Name         = "Recorder";
            this.Recorders.Add(r, t);
            t.Start();
            Logger.Instance.WriteLog(String.Format("Recorder thread created {0}({1})", t.ManagedThreadId, t.Name));

            UpdateStatusBar();
            return(r);
        }