private void RemoveRecoder(LoLRecorder recoder, Boolean force = false) { if (!Dispatcher.CheckAccess()) { RemoveRecoderDelegate refresh = new RemoveRecoderDelegate(RemoveRecoder); Dispatcher.BeginInvoke(refresh, recoder, force); } else { if (Recorders.ContainsKey(recoder)) { Thread t = this.Recorders[recoder]; if (t.IsAlive && force) { t.Abort(); recoder.removeFromList(); } this.Recorders.Remove(recoder); SimpleLoLRecord slr = replayManager.GetRecordFromRecorder(recoder); if (slr != null) { this.replayManager.RemoveRecord(slr); } UpdateStatusBar(); } } }
public static String ReplaceParticipantProperty(LoLRecorder recoder, String format) { try { int nth = 0; if (recoder.record.gameStats.Players.Count == 0) { return(format); } for (; nth < recoder.record.gameStats.Players.Count; nth++) { if (recoder.record.gameStats.Players[nth].SummonerName == recoder.selfPlayerInfo.playerName) { break; } } PlayerStats selfStats = recoder.record.gameStats.Players[nth]; format = format.Replace("<Kill>", selfStats.Statistics.K.ToString()); format = format.Replace("<Death>", selfStats.Statistics.D.ToString()); format = format.Replace("<Assist>", selfStats.Statistics.A.ToString()); format = format.Replace("<KDA>", string.Format("{0:N1}", selfStats.Statistics.KDAValue)); format = format.Replace("<WinLose>", selfStats.Statistics.Win ? Utilities.GetString("Win") as string : Utilities.GetString("Lose") as string); } catch (Exception) { } return(format); }
public SimpleLoLRecord GetRecordFromRecorder(LoLRecorder recorder) { if (recorderToRecords.ContainsKey(recorder)) { return(recorderToRecords[recorder]); } return(null); }
public static String ReplaceEndOfGameStatsProperty(LoLRecorder recoder, String format) { format = format.Replace("<Map>", Utilities.GetString(recoder.record.gameStats.GameMode) as string); if (recoder.record.gameStats.Players != null) { format = ReplaceParticipantProperty(recoder, format); } return(format); }
private void Recorder_prepareContentDoneEvent(LoLRecorder recoder) { if (!Dispatcher.CheckAccess()) { Recorder_prepareContentDoneEventDelegate dele = new Recorder_prepareContentDoneEventDelegate(Recorder_prepareContentDoneEvent); Dispatcher.Invoke(dele, recoder); } else { StartLoLLauncher(new LoLLauncher(recoder)); } }
public void UpdateRecordingRecord(LoLRecorder recorder) { if (recorderToRecords.ContainsKey(recorder)) { recorderToRecords[recorder].UpdateSummonerData(); } else { SimpleLoLRecord slr = ReadRecord(recorder.record, true); slr.RecoringRecorder = recorder; recorderToRecords.Add(recorder, slr); } }
public void RecordInfoDone(LoLRecorder recoder) { replayManager.UpdateRecordingRecord(recoder); UpdateRecordList(); if (!recoder.selfGame && recoder.exeData != null) //要是觀戰且必須有LoL可以關 { if (Properties.Settings.Default.KillProcess) { if (!recoder.exeData.LoLProcess.HasExited) { recoder.exeData.LoLProcess.CloseMainWindow(); } } } }
public void StartRecordFeaturedGame(GameInfo info, FeaturedGameJson gameData, Boolean playNow) { PlayerInfo[] playerInfo = new PlayerInfo[gameData.participants.Length]; for (int i = 0; i < gameData.BlueTeamParticipants.Length; i++) { playerInfo[i] = gameData.BlueTeamParticipants[i].ToPlayerInfo(); playerInfo[i].clientID = i; } for (int i = 0; i < gameData.PurpleTeamParticipants.Length; i++) { int num = gameData.PurpleTeamParticipants.Length + i; playerInfo[num] = gameData.PurpleTeamParticipants[i].ToPlayerInfo(); playerInfo[num].clientID = num; } LoLRecorder recorder = StartNewRecoding(info, playNow, false, playerInfo); }
public static String ReplaceGeneralProperty(LoLRecorder recoder, String format) { if (recoder.selfPlayerInfo != null) { format = format.Replace("<SummonerName>", recoder.selfPlayerInfo.playerName); format = format.Replace("<Champion>", LoLStaticData.Champion.Instance.GetNameByKey(recoder.selfPlayerInfo.championName)); } DateTime dt = DateTime.Now; format = format.Replace("<Year>", dt.Year.ToString()); format = format.Replace("<Month>", dt.Month.ToString()); format = format.Replace("<Day>", dt.Day.ToString()); format = format.Replace("<Hour>", dt.Hour.ToString("00")); format = format.Replace("<Minute>", dt.Minute.ToString("00")); format = format.Replace("<Second>", dt.Second.ToString("00")); return(format); }
public static String GenerateFilename(LoLRecorder recoder) { if (!recoder.selfGame) { return(Utilities.GetString("Spectate") as String + "-" + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss.lpr")); } String format = Properties.Settings.Default.FileNameFormat; format = ReplaceGeneralProperty(recoder, format); if (recoder.record.HasResult) { format = ReplaceEndOfGameStatsProperty(recoder, format); } format = format.Replace('<', '('); format = format.Replace('>', ')'); return(format); }
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); }
public void RecordDone(LoLRecorder sender, bool isSuccess, string reason) { RemoveRecoder(sender as LoLRecorder); if (isSuccess) { String sb = FileNameGenerater.GenerateFilename(sender); string path = Properties.Settings.Default.ReplayDir + @"\" + sb; Utilities.IfDirectoryNotExitThenCreate(Properties.Settings.Default.ReplayDir); if (System.IO.File.Exists(path)) { path = path.Insert(path.Length - 4, (new Random().Next(9999)).ToString()); } sender.record.writeToFile(path); Dispatcher.Invoke(() => ShowRecordSucceedMessage()); if (sender.selfGame) { Properties.Settings.Default.SummonerName = sender.selfPlayerInfo.PlayerName; Properties.Settings.Default.Save(); BRapi.Service.RecordingService.ReportSuccess(sender.GameInfo.PlatformId); } if (sender.record.HasResult) { BRapi.Service.GameService.SendEndOfGameStats(sender.record.GamePlatform, Newtonsoft.Json.JsonConvert.SerializeObject(sender.record.gameStats.OriginalAMFObject), sender.record.GameId); } } else { Dispatcher.Invoke(() => ShowRecordFailedMessageBox(reason)); if (sender.selfGame) { BRapi.Service.RecordingService.ReportFail(sender.record.GamePlatform); } } Dispatcher.Invoke(() => UpdateStatusBar()); }
public LoLLauncher(LoLRecorder recordingRecorder) { _recoder = recordingRecorder; _record = recordingRecorder.record; _localPlay = true; }