Commit c0d3cd8e by liulongfei

切换场景逻辑

parent d0c67204
......@@ -48,6 +48,11 @@ namespace VIZ.Package.Domain
public const string VIZ_COMMAND_CUSTOM_CONTROL_FIELD_SET = "VIZ_CUSTOM_CONTROL_FIELD_SET";
/// <summary>
/// VIZ切换逻辑默认出点
/// </summary>
public const string VIZ_TRANSITIONLOGIC_DEFAULT_OUT = "O";
/// <summary>
/// Viz 层集合
/// </summary>
public readonly static List<VizLayer> VIZ_LAYERS = new List<VizLayer> { VizLayer.FRONT_LAYER, VizLayer.MAIN_LAYER, VizLayer.BACK_LAYER };
......
......@@ -38,5 +38,69 @@ namespace VIZ.Package.Domain
return sceneInfo;
}
/// <summary>
/// 根据场景模板获取场景信息
/// </summary>
/// <param name="template">模板</param>
/// <returns>场景信息</returns>
public static SceneInfoModel GetSceneInfo(PageTemplateModel template)
{
ConnGroupModel group = ApplicationDomainEx.ConnGroups.FirstOrDefault(p => p.IsDefault);
if (group == null)
return null;
SceneInfoModel sceneInfo = ApplicationDomainEx.SceneInfoList.FirstOrDefault(p => p.ScenePath == template.ScenePath && p.ConnGroupID == group.GroupID);
if (sceneInfo != null)
return sceneInfo;
lock (ApplicationDomainEx.SceneInfoList)
{
SceneInfoModel sceneInfoInner = ApplicationDomainEx.SceneInfoList.FirstOrDefault(p => p.ScenePath == template.ScenePath && p.ConnGroupID == p.ConnGroupID);
if (sceneInfoInner != null)
return sceneInfoInner;
sceneInfo = new SceneInfoModel();
sceneInfo.ConnGroupID = group.GroupID;
sceneInfo.Scene = template.Scene;
sceneInfo.ScenePath = template.ScenePath;
ApplicationDomainEx.SceneInfoList.Add(sceneInfo);
}
return sceneInfo;
}
/// <summary>
/// 根据页或模板获取背景场景信息
/// </summary>
/// <param name="pageBase">页或模板</param>
/// <returns>背景场景信息</returns>
public static TransitionLogicSceneInfoModel GetSceneInfoWithTransitionLogic(PageModelBase pageBase)
{
if (string.IsNullOrWhiteSpace(pageBase.BackgroundScene))
return null;
string bgScenePath = $"{pageBase.GetSceneParent()}/{pageBase.BackgroundScene}";
TransitionLogicSceneInfoModel sceneInfo = ApplicationDomainEx.SceneInfoListWithTransitionLogic.FirstOrDefault(p => p.ScenePath == bgScenePath);
if (sceneInfo != null)
return sceneInfo;
lock (ApplicationDomainEx.SceneInfoList)
{
TransitionLogicSceneInfoModel sceneInfoInner = ApplicationDomainEx.SceneInfoListWithTransitionLogic.FirstOrDefault(p => p.ScenePath == bgScenePath);
if (sceneInfoInner != null)
return sceneInfoInner;
sceneInfo = new TransitionLogicSceneInfoModel();
sceneInfo.Scene = pageBase.BackgroundScene;
sceneInfo.ScenePath = bgScenePath;
ApplicationDomainEx.SceneInfoListWithTransitionLogic.Add(sceneInfo);
}
return sceneInfo;
}
}
}
......@@ -160,5 +160,13 @@ namespace VIZ.Package.Domain
/// 该值不会入库,仅在内存中保留
/// </remarks>
public static List<SceneInfoModel> SceneInfoList { get; private set; } = new List<SceneInfoModel>();
/// <summary>
/// 切换逻辑背景场景信息
/// </summary>
/// <remarks>
/// 该值不会入库,仅在内存中保留
/// </remarks>
public static List<TransitionLogicSceneInfoModel> SceneInfoListWithTransitionLogic { get; private set; } = new List<TransitionLogicSceneInfoModel>();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Domain
{
/// <summary>
/// 页模型扩展
/// </summary>
public static class PageModelExpand
{
/// <summary>
/// 获取场景信息
/// </summary>
/// <param name="pageBase">场景模型基类</param>
/// <returns>场景信息</returns>
public static SceneInfoModel GetSceneInfo(this PageModelBase pageBase)
{
if (pageBase is PageModel page)
{
return page.SceneInfo;
}
else if (pageBase is PageTemplateModel template)
{
return ApplicationDomainEx.GetSceneInfo(template);
}
else
{
return null;
}
}
/// <summary>
/// 获取场景父级
/// </summary>
/// <param name="pageBase">场景父级</param>
/// <returns>场景父级</returns>
public static string GetSceneParent(this PageModelBase pageBase)
{
string parent = ApplicationDomainEx.CurrentPage.ScenePath.Substring(0, ApplicationDomainEx.CurrentPage.ScenePath.LastIndexOf('/'));
return parent;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
namespace VIZ.Package.Domain
{
/// <summary>
/// 切换场景层信息
/// </summary>
public class TransitionLogicLayerInfo : ModelBase
{
#region BackgroundScene -- 所属背景层
private string backgroundScene;
/// <summary>
/// 所属背景层
/// </summary>
public string BackgroundScene
{
get { return backgroundScene; }
set { backgroundScene = value; this.RaisePropertyChanged(nameof(BackgroundScene)); }
}
#endregion
#region LayerIdentifier -- 逻辑层
private string layerIdentifier;
/// <summary>
/// 逻辑层
/// </summary>
public string LayerIdentifier
{
get { return layerIdentifier; }
set { layerIdentifier = value; this.RaisePropertyChanged(nameof(LayerIdentifier)); }
}
#endregion
#region StateIdentifier -- 状态点
private string stateIdentifier;
/// <summary>
/// 触发器Geom值
/// </summary>
public string StateIdentifier
{
get { return stateIdentifier; }
set { stateIdentifier = value; this.RaisePropertyChanged(nameof(StateIdentifier)); }
}
#endregion
#region SceneIdentifier -- 场景
private string sceneIdentifier;
/// <summary>
/// 场景
/// </summary>
public string SceneIdentifier
{
get { return sceneIdentifier; }
set { sceneIdentifier = value; this.RaisePropertyChanged(nameof(SceneIdentifier)); }
}
#endregion
#region ControlObject -- 控制对象值
private string controlObject;
/// <summary>
/// 控制对象值
/// </summary>
public string ControlObject
{
get { return controlObject; }
set { controlObject = value; this.RaisePropertyChanged(nameof(ControlObject)); }
}
#endregion
#region IsContinued -- 是否点击了继续
private bool isContinued;
/// <summary>
/// 是否点击了继续
/// </summary>
public bool IsContinued
{
get { return isContinued; }
set { isContinued = value; this.RaisePropertyChanged(nameof(IsContinued)); }
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
namespace VIZ.Package.Domain
{
/// <summary>
/// 切换逻辑层模型
/// </summary>
public class TransitionLogicModel : ModelBase
{
#region LayerInfos -- 层信息
private List<TransitionLogicLayerInfo> layerInfos = new List<TransitionLogicLayerInfo>();
/// <summary>
/// 层信息
/// </summary>
public List<TransitionLogicLayerInfo> LayerInfos
{
get { return layerInfos; }
set { layerInfos = value; this.RaisePropertyChanged(nameof(LayerInfos)); }
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
namespace VIZ.Package.Domain
{
/// <summary>
/// 切换场景场景信息
/// </summary>
public class TransitionLogicSceneInfoModel : SceneInfoModel
{
#region TransitionLogic -- 切换逻辑
private TransitionLogicModel transitionLogic = new TransitionLogicModel();
/// <summary>
/// 切换逻辑
/// </summary>
public TransitionLogicModel TransitionLogic
{
get { return transitionLogic; }
set { transitionLogic = value; this.RaisePropertyChanged(nameof(TransitionLogic)); }
}
#endregion
}
}
......@@ -112,6 +112,7 @@
<Compile Include="Model\Page\PageGroupModel.cs" />
<Compile Include="Model\Page\PageModel.cs" />
<Compile Include="Model\Page\PageModelBase.cs" />
<Compile Include="Expand\PageModelExpand.cs" />
<Compile Include="Model\Page\PageTemplateModel.cs" />
<Compile Include="Model\Resource\Enum\ResourceFileSelectionMode.cs" />
<Compile Include="Model\Resource\Enum\ResourceFileType.cs" />
......@@ -124,6 +125,9 @@
<Compile Include="Model\Resource\ResourceFileModelBase.cs" />
<Compile Include="Model\Resource\ResourceFolderModelBase.cs" />
<Compile Include="Model\Scene\SceneInfoModel.cs" />
<Compile Include="Model\Scene\TransitionLogicLayerInfo.cs" />
<Compile Include="Model\Scene\TransitionLogicModel.cs" />
<Compile Include="Model\Scene\TransitionLogicSceneInfoModel.cs" />
<Compile Include="Model\Setting\SettingPageModel.cs" />
<Compile Include="Model\Task\PackageTaskModel.cs" />
<Compile Include="Plugin\IPluginLifeCycle.cs" />
......
......@@ -115,11 +115,11 @@ namespace VIZ.Package.Module
{
if (obj.TransitionLogic)
{
this.controlController.TakeTransitionLogic(obj, view, conn);
this.controlController.TakeTransitionLogic(ApplicationDomainEx.CurrentTake, ApplicationDomainEx.CurrentPage, obj, view, conn);
}
else
{
this.controlController.TakeNormal(obj, view, conn);
this.controlController.TakeNormal(ApplicationDomainEx.CurrentTake, ApplicationDomainEx.CurrentPage, obj, view, conn);
}
},
over: () =>
......@@ -164,11 +164,11 @@ namespace VIZ.Package.Module
{
if (obj.TransitionLogic)
{
this.controlController.ContinueTransitionLogic(obj, view, conn);
this.controlController.ContinueTransitionLogic(ApplicationDomainEx.CurrentTake, ApplicationDomainEx.CurrentPage, obj, view, conn);
}
else
{
this.controlController.ContinueNormal(obj, view, conn);
this.controlController.ContinueNormal(ApplicationDomainEx.CurrentTake, ApplicationDomainEx.CurrentPage, obj, view, conn);
}
},
over: null);
......@@ -196,11 +196,11 @@ namespace VIZ.Package.Module
{
if (obj.TransitionLogic)
{
this.controlController.TakeOutTransitionLogic(obj, view, conn);
this.controlController.TakeOutTransitionLogic(ApplicationDomainEx.CurrentTake, ApplicationDomainEx.CurrentPage, obj, view, conn);
}
else
{
this.controlController.TakeOutNormal(obj, view, conn);
this.controlController.TakeOutNormal(ApplicationDomainEx.CurrentTake, ApplicationDomainEx.CurrentPage, obj, view, conn);
}
},
over: () =>
......@@ -248,11 +248,11 @@ namespace VIZ.Package.Module
{
if (obj.TransitionLogic)
{
this.controlController.UpdateTransitionLogic(obj, view, conn);
this.controlController.UpdateTransitionLogic(ApplicationDomainEx.CurrentTake, ApplicationDomainEx.CurrentPage, obj, view, conn);
}
else
{
this.controlController.UpdateNormal(obj, view, conn);
this.controlController.UpdateNormal(ApplicationDomainEx.CurrentTake, ApplicationDomainEx.CurrentPage, obj, view, conn);
}
},
over: null);
......
......@@ -526,6 +526,15 @@ namespace VIZ.Package.Module
sceneInfo.TakeInitedMessage = null;
}
}
lock (ApplicationDomainEx.SceneInfoListWithTransitionLogic)
{
foreach (TransitionLogicSceneInfoModel sceneInfo in ApplicationDomainEx.SceneInfoListWithTransitionLogic)
{
sceneInfo.TakeInitedProgress = 0d;
sceneInfo.TakeInitedMessage = null;
sceneInfo.TransitionLogic.LayerInfos.Clear();
}
}
// 开始清理
List<ConnGroupModel> groups = ApplicationDomainEx.ConnGroups.ToList();
......
......@@ -186,7 +186,7 @@ namespace VIZ.Package.Service
/// <returns>日志文件路径</returns>
private string GetFileName()
{
return Path.Combine(this.WorkFolder, $"{ DateTime.Now.ToString("yyyy_MM_dd__HH_mm_ss_fffffff")}.csv");
return Path.Combine(this.WorkFolder, $"{ DateTime.Now.ToString("yyyy_MM_dd__HH_mm_ss__fffffff")}.csv");
}
}
}
......@@ -412,18 +412,16 @@ namespace VIZ.Package.Service
// 切换场景
/// <summary>
/// 设置切换逻辑的控制对象值
/// 获取控制对象值字符串
/// </summary>
/// <param name="conn">连接</param>
/// <param name="obj">控制对象</param>
/// <param name="pageBase">页</param>
public void SetControlObjectOtherWithTransitionLogic(ConnModel conn, ControlObjectModel obj, PageModelBase pageBase)
/// <returns>控制对象值字符串</returns>
public string GetControlObjectStringWithTransitionLogic(ControlObjectModel obj)
{
string scenePathDir = pageBase.ScenePath.Substring(0, pageBase.ScenePath.LastIndexOf('/'));
string bgScenePath = $"{scenePathDir}/{pageBase.BackgroundScene}";
if (obj == null || obj.AllFiledNodes == null || obj.AllFiledNodes.Count == 0)
return string.Empty;
StringBuilder sb = new StringBuilder();
sb.Append($"SCENE*{bgScenePath}*TREE*${pageBase.LayerIdentifier}$other$object*FUNCTION*ControlObject*in SET ON ");
foreach (ControlFieldNodeModel field in obj.AllFiledNodes)
{
// 自定义字段不通过该方法上板
......@@ -433,7 +431,7 @@ namespace VIZ.Package.Service
sb.Append($"{field.FieldIdentifier} SET {field.Value}\\0");
}
conn.EndpointManager.Send(sb.ToString());
return sb.ToString();
}
/// <summary>
......@@ -442,22 +440,31 @@ namespace VIZ.Package.Service
/// <param name="conn">连接</param>
/// <param name="obj">控制对象</param>
/// <param name="pageBase">页</param>
public void SetControlObjectCurrentWithTransitionLogic(ConnModel conn, ControlObjectModel obj, PageModelBase pageBase)
public void SetControlObjectOtherWithTransitionLogic(ConnModel conn, ControlObjectModel obj, PageModelBase pageBase)
{
string scenePathDir = pageBase.ScenePath.Substring(0, pageBase.ScenePath.LastIndexOf('/'));
string bgScenePath = $"{scenePathDir}/{pageBase.BackgroundScene}";
string bgScenePath = $"{pageBase.GetSceneParent()}/{pageBase.BackgroundScene}";
StringBuilder sb = new StringBuilder();
sb.Append($"SCENE*{bgScenePath}*TREE*${pageBase.LayerIdentifier}$current$object*FUNCTION*ControlObject*in SET ON ");
foreach (ControlFieldNodeModel field in obj.AllFiledNodes)
{
// 自定义字段不通过该方法上板
if (field.IsCustom)
continue;
string value = this.GetControlObjectStringWithTransitionLogic(obj);
sb.Append($"SCENE*{bgScenePath}*TREE*${pageBase.LayerIdentifier}$other$object*FUNCTION*ControlObject*in SET ON {value}");
sb.Append($"{field.FieldIdentifier} SET {field.Value}\\0");
conn.EndpointManager.Send(sb.ToString());
}
/// <summary>
/// 设置切换逻辑的控制对象值
/// </summary>
/// <param name="conn">连接</param>
/// <param name="obj">控制对象</param>
/// <param name="pageBase">页</param>
public void SetControlObjectCurrentWithTransitionLogic(ConnModel conn, ControlObjectModel obj, PageModelBase pageBase)
{
string bgScenePath = $"{pageBase.GetSceneParent()}/{pageBase.BackgroundScene}";
StringBuilder sb = new StringBuilder();
string value = this.GetControlObjectStringWithTransitionLogic(obj);
sb.Append($"SCENE*{bgScenePath}*TREE*${pageBase.LayerIdentifier}$current$object*FUNCTION*ControlObject*in SET ON {value}");
conn.EndpointManager.Send(sb.ToString());
}
......
......@@ -345,53 +345,62 @@ namespace VIZ.Package.Service
/// 动画显示
/// </summary>
/// <param name="conn">连接</param>
/// <param name="pageBase">页</param>
public void DirectorShowWithTransitionLogic(ConnModel conn, PageModelBase pageBase)
/// <param name="layer">逻辑层</param>
/// <param name="state">状态</param>
public void DirectorShowWithTransitionLogic(ConnModel conn, string layer, string state)
{
if (conn == null)
throw new ArgumentNullException(nameof(conn));
if (pageBase == null)
throw new ArgumentNullException(nameof(pageBase));
if (string.IsNullOrWhiteSpace(layer))
throw new ArgumentNullException(nameof(layer));
conn.EndpointManager.Send($"RENDERER*MAIN_LAYER*STAGE*DIRECTOR*{pageBase.LayerIdentifier} SHOW ${pageBase.StateIdentifier}");
if (string.IsNullOrWhiteSpace(state))
throw new ArgumentNullException(nameof(state));
conn.EndpointManager.Send($"RENDERER*MAIN_LAYER*STAGE*DIRECTOR*{layer} SHOW ${state}");
}
/// <summary>
/// 动画切换
/// </summary>
/// <param name="conn">连接</param>
/// <param name="pageBase">页</param>
/// <param name="from">开始</param>
/// <param name="to">结束</param>
public void DirectorGotoTrioWithTransitionLogic(ConnModel conn, PageModelBase pageBase, string from, string to)
/// <param name="layer">逻辑层</param>
/// <param name="oldState">旧状态</param>
/// <param name="newState">新状态</param>
public void DirectorGoToWithTransitionLogic(ConnModel conn, string layer, string oldState, string newState)
{
if (conn == null)
throw new ArgumentNullException(nameof(conn));
if (pageBase == null)
throw new ArgumentNullException(nameof(pageBase));
if (string.IsNullOrWhiteSpace(layer))
throw new ArgumentNullException(nameof(layer));
if (string.IsNullOrWhiteSpace(oldState))
throw new ArgumentNullException(nameof(oldState));
if (string.IsNullOrWhiteSpace(newState))
throw new ArgumentNullException(nameof(newState));
conn.EndpointManager.Send($"RENDERER*MAIN_LAYER*STAGE*DIRECTOR*{pageBase.LayerIdentifier} GOTO_TRIO ${from} ${to}");
conn.EndpointManager.Send($"RENDERER*MAIN_LAYER*STAGE*DIRECTOR*{layer} GOTO_TRIO ${oldState} ${newState}");
}
/// <summary>
/// 设置切换逻辑层的GEOM
/// </summary>
/// <param name="conn">连接</param>
/// <param name="pageBase">页</param>
public void ToggleSetGeomWithTransitionLogic(ConnModel conn, PageModelBase pageBase)
/// <param name="bgScene">背景场景</param>
/// <param name="layer">逻辑层</param>
/// <param name="scene">场景</param>
public void ToggleSetGeomWithTransitionLogic(ConnModel conn, string bgScene, string layer, string scene)
{
if (conn == null)
throw new ArgumentNullException(nameof(conn));
if (pageBase == null)
throw new ArgumentNullException(nameof(pageBase));
string scenePathDir = pageBase.ScenePath.Substring(0, pageBase.ScenePath.LastIndexOf('/'));
string bgScenePath = $"{scenePathDir}/{pageBase.BackgroundScene}";
if (string.IsNullOrWhiteSpace(scene))
throw new ArgumentNullException(nameof(scene));
conn.EndpointManager.Send($"SCENE*{bgScenePath}*TREE*${pageBase.LayerIdentifier}*FUNCTION*Toggle*object SET GEOM*{pageBase.ScenePath}");
conn.EndpointManager.Send($"SCENE*{bgScene}*TREE*${layer}*FUNCTION*Toggle*object SET GEOM*{scene}");
}
/// <summary>
......@@ -433,16 +442,16 @@ namespace VIZ.Package.Service
/// 触发重置
/// </summary>
/// <param name="conn">连接</param>
/// <param name="pageBase">页</param>
public void ToggleResetWithTransitionLogic(ConnModel conn, PageModelBase pageBase)
/// <param name="logicLayer">切换逻辑层</param>
public void ToggleResetWithTransitionLogic(ConnModel conn, string logicLayer)
{
if (conn == null)
throw new ArgumentNullException(nameof(conn));
if (pageBase == null)
throw new ArgumentNullException(nameof(pageBase));
if (string.IsNullOrWhiteSpace(logicLayer))
throw new ArgumentNullException(nameof(logicLayer));
conn.EndpointManager.Send($"RENDERER*MAIN_LAYER*TREE*${pageBase.LayerIdentifier}*FUNCTION*Toggle*reset_current INVOKE");
conn.EndpointManager.Send($"RENDERER*MAIN_LAYER*TREE*${logicLayer}*FUNCTION*Toggle*reset_current INVOKE");
}
/// <summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment