/// <summary> /// 環境変数をセットする /// </summary> /// <remarks> /// 環境変数をセットする。 /// 通常スコープの場合はゾーンチェンジに消去される。 /// グローバルスコープの場合はアプリケーションの実行中、常に保持される。</remarks> /// <param name="name">変数名</param> /// <param name="value">値</param> /// <param name="global">グローバルスコープか?</param> public void SetVar( string name, object value, bool global = false) => TimelineExpressionsModel.SetVariable( name, value, global ? TimelineModel.GlobalZone : this.Zone);
private static IEnumerable <TextCommand> CreateExpressionsCommands() { var setCommand = new TextCommand( (string logLine, out Match match) => { match = null; if (!logLine.ContainsIgnoreCase(TimelineCommand)) { return(false); } match = SetVarCommandRegex.Match(logLine); return(match.Success); }, (string logLine, Match match) => { if (match == null || !match.Success) { return; } var name = match.Groups["name"].ToString(); var value = match.Groups["value"].ToString(); var option = match.Groups["option"]?.ToString() ?? string.Empty; var zone = TimelineController.CurrentController?.CurrentZoneName ?? string.Empty; option = option.ToLower(); if (option.ContainsIgnoreCase("global")) { zone = TimelineModel.GlobalZone; } else { if (option.ContainsIgnoreCase("temp")) { zone = string.Empty; } } TimelineExpressionsModel.SetVariable(name, value, zone); }); return(new[] { setCommand }); }
private void NotifyTrigger( TimelineTriggerModel tri) { if (string.IsNullOrEmpty(tri.Name) && string.IsNullOrEmpty(tri.Text) && string.IsNullOrEmpty(tri.Notice)) { return; } var now = DateTime.Now; var log = $"{TLSymbol} Notice from TL. " + $"name={tri.Name}, text={tri.TextReplaced}, notice={tri.NoticeReplaced}"; var notice = tri.NoticeReplaced ?? string.Empty; notice = TimelineExpressionsModel.ReplaceText(notice); if (string.Equals(notice, "auto", StringComparison.OrdinalIgnoreCase)) { notice = !string.IsNullOrEmpty(tri.Text) ? tri.Text : tri.Name; if (!string.IsNullOrEmpty(notice)) { notice += "。"; } } var isSync = (TimelineRazorModel.Instance?.SyncTTS ?? false) || tri.NoticeSync.Value; RaiseLog(log); NotifySoundAsync(notice, tri.NoticeDevice.GetValueOrDefault(), isSync, tri.NoticeVolume, tri.NoticeOffset); var vnotices = tri.VisualNoticeStatements .Where(x => x.Enabled.GetValueOrDefault()); var inotices = tri.ImageNoticeStatements .Where(x => x.Enabled.GetValueOrDefault()); if (!vnotices.Any() && !inotices.Any()) { return; } var placeholders = TimelineManager.Instance.GetPlaceholders(); foreach (var v in vnotices) { // ヒットしたログのシーケンスを格納する // ソート用 v.LogSeq = tri.LogSeq; switch (v.Text) { case TimelineVisualNoticeModel.ParentTextPlaceholder: v.TextToDisplay = tri.TextReplaced; break; case TimelineVisualNoticeModel.ParentNoticePlaceholder: v.TextToDisplay = tri.NoticeReplaced; break; default: v.TextToDisplay = tri.SyncMatch != null && tri.SyncMatch.Success ? tri.SyncMatch.Result(v.Text) : v.Text; break; } if (string.IsNullOrEmpty(v.TextToDisplay)) { continue; } v.TextToDisplay = TimelineExpressionsModel.ReplaceText(v.TextToDisplay); // PC名をルールに従って置換する v.TextToDisplay = XIVPluginHelper.Instance.ReplacePartyMemberName( v.TextToDisplay, Settings.Default.PCNameInitialOnDisplayStyle); WPFHelper.BeginInvoke(async() => { if (v.Delay > 0) { await Task.Delay(TimeSpan.FromSeconds(v.Delay ?? 0)); } TimelineNoticeOverlay.NoticeView?.AddNotice(v); v.SetSyncToHide(placeholders); v.AddSyncToHide(); }); } foreach (var i in inotices) { WPFHelper.BeginInvoke(async() => { if (i.Delay > 0) { await Task.Delay(TimeSpan.FromSeconds(i.Delay ?? 0)); } i.StartNotice(); i.SetSyncToHide(placeholders); i.AddSyncToHide(); }); } }
private void NotifyActivity( TimelineActivityModel act) { if (string.IsNullOrEmpty(act.Name) && string.IsNullOrEmpty(act.Text) && string.IsNullOrEmpty(act.Notice)) { act.IsNotified = true; return; } var now = DateTime.Now; var offset = this.CurrentTime - act.Time; var log = $"{TLSymbol} Notice from TL. " + $"name={act.Name}, text={act.TextReplaced}, notice={act.NoticeReplaced}, offset={offset.TotalSeconds:N1}"; var notice = act.NoticeReplaced ?? string.Empty; notice = TimelineExpressionsModel.ReplaceText(notice); if (string.Equals(notice, "auto", StringComparison.OrdinalIgnoreCase)) { notice = !string.IsNullOrEmpty(act.TextReplaced) ? act.TextReplaced : act.Name; if (offset.TotalSeconds <= -1.0) { var offsetText = (offset.TotalSeconds * -1).ToString("N0"); notice += $" まで、あと{offsetText}秒"; } if (!string.IsNullOrEmpty(notice)) { notice += "。"; } } var isSync = (TimelineRazorModel.Instance?.SyncTTS ?? false) || act.NoticeSync.Value; RaiseLog(log); NotifySoundAsync(notice, act.NoticeDevice.GetValueOrDefault(), isSync, act.NoticeVolume); var vnotices = act.VisualNoticeStatements .Where(x => x.Enabled.GetValueOrDefault()) .Select(x => x.Clone()); var inotices = act.ImageNoticeStatements .Where(x => x.Enabled.GetValueOrDefault()); if (!vnotices.Any() && !inotices.Any()) { return; } var placeholders = TimelineManager.Instance.GetPlaceholders(); foreach (var v in vnotices) { // ソート用にログ番号を格納する // 優先順位は最後尾とする v.LogSeq = long.MaxValue; v.Timestamp = DateTime.Now; switch (v.Text) { case TimelineVisualNoticeModel.ParentTextPlaceholder: v.TextToDisplay = act.TextReplaced; break; case TimelineVisualNoticeModel.ParentNoticePlaceholder: v.TextToDisplay = act.NoticeReplaced; break; default: v.TextToDisplay = act.SyncMatch != null && act.SyncMatch.Success ? act.SyncMatch.Result(v.Text) : v.Text; break; } if (string.IsNullOrEmpty(v.TextToDisplay)) { continue; } v.TextToDisplay = TimelineExpressionsModel.ReplaceText(v.TextToDisplay); // PC名をルールに従って置換する v.TextToDisplay = XIVPluginHelper.Instance.ReplacePartyMemberName( v.TextToDisplay, Settings.Default.PCNameInitialOnDisplayStyle); WPFHelper.BeginInvoke(async() => { if (v.Delay > 0) { await Task.Delay(TimeSpan.FromSeconds(v.Delay ?? 0)); } TimelineNoticeOverlay.NoticeView?.AddNotice(v); v.SetSyncToHide(placeholders); v.AddSyncToHide(); }); } foreach (var i in inotices) { WPFHelper.BeginInvoke(async() => { if (i.Delay > 0) { await Task.Delay(TimeSpan.FromSeconds(i.Delay ?? 0)); } i.StartNotice(); i.SetSyncToHide(placeholders); i.AddSyncToHide(); }); } }
/// <summary> /// 一時変数をセットする /// </summary> /// <remarks> /// タイムラインのリセット時に消去される一時変数をセットする</remarks> /// <param name="name">変数名</param> /// <param name="value">値</param> public void SetTemp( string name, object value) => TimelineExpressionsModel.SetVariable( name, value);
public TimelineRazorVariable() { this.variables = TimelineExpressionsModel.GetVariables(); }