扩展UITools功能支持自动关闭
This commit is contained in:
parent
114b996c3c
commit
632966423e
@ -111,10 +111,8 @@ public class ActionHelper
|
|||||||
}
|
}
|
||||||
case "UITools":
|
case "UITools":
|
||||||
{
|
{
|
||||||
var strAction = (XMLTool.StringListAction)act;
|
var strAction = (XMLTool.DictionaryAction)act;
|
||||||
return UIToolsAction.Allocate(strAction.args[0], strAction.args[1], strAction.args[2], strAction.args[3],
|
return UIToolsAction.Allocate(strAction.args);
|
||||||
strAction.args[4], strAction.args[5], strAction.args[6], strAction.args[7],
|
|
||||||
strAction.args[8], strAction.args[9]);
|
|
||||||
}
|
}
|
||||||
case "PointQuestion":
|
case "PointQuestion":
|
||||||
return PointQuestionAction.Allocate(act.Value);
|
return PointQuestionAction.Allocate(act.Value);
|
||||||
|
|||||||
@ -14,35 +14,34 @@ public class UIToolsAction : IAction
|
|||||||
|
|
||||||
private static readonly SimpleObjectPool<UIToolsAction> mPool =
|
private static readonly SimpleObjectPool<UIToolsAction> mPool =
|
||||||
new SimpleObjectPool<UIToolsAction>(() => new UIToolsAction(), null, 10);
|
new SimpleObjectPool<UIToolsAction>(() => new UIToolsAction(), null, 10);
|
||||||
string answer = string.Empty;
|
string answer;
|
||||||
string devices = string.Empty;
|
string devices;
|
||||||
string setActive = string.Empty;
|
string setActive;
|
||||||
string rightLabel = string.Empty;
|
string rightLabel;
|
||||||
string wrongLabel = string.Empty;
|
string wrongLabel;
|
||||||
string rightEvent = string.Empty;
|
string rightEvent;
|
||||||
string wrongEvent = string.Empty;
|
string wrongEvent;
|
||||||
string rightScore = string.Empty;
|
string rightScore;
|
||||||
string wrongScore = string.Empty;
|
string wrongScore;
|
||||||
string scoreStepName = string.Empty;
|
string scoreStepName;
|
||||||
public static UIToolsAction Allocate(string devices, string answer,
|
string autoHide;
|
||||||
string setActive, string rightLabel, string wrongLabel, string rightEvent,
|
public static UIToolsAction Allocate(Dictionary<string, string> datas, System.Action onDelayFinish = null)
|
||||||
string wrongEvent,string rightScore, string wrongScore, string scoreStepName,
|
|
||||||
System.Action onDelayFinish = null)
|
|
||||||
{
|
{
|
||||||
var retNode = mPool.Allocate();
|
var retNode = mPool.Allocate();
|
||||||
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
||||||
retNode.Deinited = false;
|
retNode.Deinited = false;
|
||||||
retNode.Reset();
|
retNode.Reset();
|
||||||
retNode.answer = answer;
|
retNode.answer = datas.ContainsKey("answers") ? datas["answers"] : "";
|
||||||
retNode.devices = devices;
|
retNode.devices = datas.ContainsKey("devices") ? datas["devices"] : "";
|
||||||
retNode.setActive = setActive;
|
retNode.setActive = datas.ContainsKey("setActive") ? datas["setActive"] : "true";
|
||||||
retNode.rightLabel = rightLabel;
|
retNode.rightLabel = datas.ContainsKey("rightLabel") ? datas["rightLabel"] : "";
|
||||||
retNode.wrongLabel = wrongLabel;
|
retNode.wrongLabel = datas.ContainsKey("wrongLabel") ? datas["wrongLabel"] : "";
|
||||||
retNode.rightEvent = rightEvent;
|
retNode.rightEvent = datas.ContainsKey("rightEvent") ? datas["rightEvent"] : "";
|
||||||
retNode.wrongEvent = wrongEvent;
|
retNode.wrongEvent = datas.ContainsKey("wrongEvent") ? datas["wrongEvent"] : "";
|
||||||
retNode.rightScore = rightScore;
|
retNode.rightScore = datas.ContainsKey("rightScore") ? datas["rightScore"] : "";
|
||||||
retNode.wrongScore = wrongScore;
|
retNode.wrongScore = datas.ContainsKey("wrongScore") ? datas["wrongScore"] : "";
|
||||||
retNode.scoreStepName = scoreStepName;
|
retNode.scoreStepName = datas.ContainsKey("scoreStepName") ? datas["scoreStepName"] : "";
|
||||||
|
retNode.autoHide = datas.ContainsKey("autoHide") ? datas["autoHide"] : "";
|
||||||
return retNode;
|
return retNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +77,7 @@ public class UIToolsAction : IAction
|
|||||||
float.TryParse(wrongScore, out data.wrongScore);
|
float.TryParse(wrongScore, out data.wrongScore);
|
||||||
data.scoreStepName = scoreStepName;
|
data.scoreStepName = scoreStepName;
|
||||||
bool.TryParse(setActive, out data.SetActive);
|
bool.TryParse(setActive, out data.SetActive);
|
||||||
|
float.TryParse(autoHide, out data.autoHideResult);
|
||||||
UIKit.OpenPanelAsync<UITools>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish());
|
UIKit.OpenPanelAsync<UITools>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ namespace QFramework.Example
|
|||||||
{
|
{
|
||||||
public bool isRight = false;
|
public bool isRight = false;
|
||||||
public string label;
|
public string label;
|
||||||
|
public float autoHideTime = -1;
|
||||||
public Action callback;
|
public Action callback;
|
||||||
}
|
}
|
||||||
public partial class UIResultTip : UIPanel
|
public partial class UIResultTip : UIPanel
|
||||||
@ -44,15 +45,31 @@ namespace QFramework.Example
|
|||||||
}
|
}
|
||||||
obj.SetActive(true);
|
obj.SetActive(true);
|
||||||
obj.transform.Find("Bg/Label").GetComponent<TextMeshProUGUI>().text = mData.label;
|
obj.transform.Find("Bg/Label").GetComponent<TextMeshProUGUI>().text = mData.label;
|
||||||
|
if (mData.autoHideTime == -1)
|
||||||
|
{
|
||||||
Button btn = obj.GetComponent<Button>();
|
Button btn = obj.GetComponent<Button>();
|
||||||
btn.onClick.RemoveAllListeners();
|
btn.onClick.RemoveAllListeners();
|
||||||
btn.onClick.AddListener(() =>
|
btn.onClick.AddListener(() =>
|
||||||
{
|
{
|
||||||
mData.callback?.Invoke();
|
SetHide();
|
||||||
Hide();
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ActionKit.Delay(mData.autoHideTime, () =>
|
||||||
|
{
|
||||||
|
SetHide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetHide()
|
||||||
|
{
|
||||||
|
mData.callback?.Invoke();
|
||||||
|
Hide();
|
||||||
|
|
||||||
|
}
|
||||||
protected override void OnShow()
|
protected override void OnShow()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ namespace QFramework.Example
|
|||||||
public float rightScore;
|
public float rightScore;
|
||||||
public float wrongScore;
|
public float wrongScore;
|
||||||
public string scoreStepName;
|
public string scoreStepName;
|
||||||
|
public float autoHideResult = -1;
|
||||||
}
|
}
|
||||||
public partial class UITools : UIPanel
|
public partial class UITools : UIPanel
|
||||||
{
|
{
|
||||||
@ -51,7 +52,7 @@ namespace QFramework.Example
|
|||||||
foreach (var device in mData.devices)
|
foreach (var device in mData.devices)
|
||||||
{
|
{
|
||||||
var item = DeviceController.Instance.GetDevice(device);
|
var item = DeviceController.Instance.GetDevice(device);
|
||||||
if (item==null)
|
if (item == null)
|
||||||
{
|
{
|
||||||
Debug.LogError(device + ":没有找到对应的Device配置");
|
Debug.LogError(device + ":没有找到对应的Device配置");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -402,82 +402,54 @@ namespace XMLTool
|
|||||||
break;
|
break;
|
||||||
case "UITools":
|
case "UITools":
|
||||||
{
|
{
|
||||||
var act = new StringListAction();
|
var act = new DictionaryAction();
|
||||||
act.args.Add(action.Attribute("devices").Value);
|
act.args.Add("devices", action.Attribute("devices").Value);
|
||||||
act.args.Add(action.Attribute("answers").Value);
|
act.args.Add("answers", action.Attribute("answers").Value);
|
||||||
var setActive = action.Attribute("setActive");
|
var setActive = action.Attribute("setActive");
|
||||||
if (setActive != null)
|
if (setActive != null)
|
||||||
{
|
{
|
||||||
act.args.Add(setActive.Value);
|
act.args.Add("setActive", setActive.Value);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
act.args.Add("true");
|
|
||||||
}
|
}
|
||||||
var rightLabel = action.Attribute("rightLabel");
|
var rightLabel = action.Attribute("rightLabel");
|
||||||
if (rightLabel != null)
|
if (rightLabel != null)
|
||||||
{
|
{
|
||||||
act.args.Add(rightLabel.Value);
|
act.args.Add("rightLabel", rightLabel.Value);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
act.args.Add("");
|
|
||||||
}
|
}
|
||||||
var wrongLabel = action.Attribute("wrongLabel");
|
var wrongLabel = action.Attribute("wrongLabel");
|
||||||
if (wrongLabel != null)
|
if (wrongLabel != null)
|
||||||
{
|
{
|
||||||
act.args.Add(wrongLabel.Value);
|
act.args.Add("wrongLabel", wrongLabel.Value);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
act.args.Add("");
|
|
||||||
}
|
}
|
||||||
var rightEvent = action.Attribute("rightEvent");
|
var rightEvent = action.Attribute("rightEvent");
|
||||||
if (rightEvent != null)
|
if (rightEvent != null)
|
||||||
{
|
{
|
||||||
act.args.Add(rightEvent.Value);
|
act.args.Add("rightEvent", rightEvent.Value);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
act.args.Add("");
|
|
||||||
}
|
}
|
||||||
var wrongEvent = action.Attribute("wrongEvent");
|
var wrongEvent = action.Attribute("wrongEvent");
|
||||||
if (wrongEvent != null)
|
if (wrongEvent != null)
|
||||||
{
|
{
|
||||||
act.args.Add(wrongEvent.Value);
|
act.args.Add("wrongEvent", wrongEvent.Value);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
act.args.Add("");
|
|
||||||
}
|
}
|
||||||
var rightScore = action.Attribute("rightScore");
|
var rightScore = action.Attribute("rightScore");
|
||||||
if (rightScore != null)
|
if (rightScore != null)
|
||||||
{
|
{
|
||||||
act.args.Add(rightScore.Value);
|
act.args.Add("rightScore", rightScore.Value);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
act.args.Add("");
|
|
||||||
}
|
}
|
||||||
var wrongScore = action.Attribute("wrongScore");
|
var wrongScore = action.Attribute("wrongScore");
|
||||||
if (wrongScore != null)
|
if (wrongScore != null)
|
||||||
{
|
{
|
||||||
act.args.Add(wrongScore.Value);
|
act.args.Add("wrongScore", wrongScore.Value);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
act.args.Add("");
|
|
||||||
}
|
}
|
||||||
var scoreStepName = action.Attribute("scoreStepName");
|
var scoreStepName = action.Attribute("scoreStepName");
|
||||||
if (scoreStepName != null)
|
if (scoreStepName != null)
|
||||||
{
|
{
|
||||||
act.args.Add(scoreStepName.Value);
|
act.args.Add("scoreStepName", scoreStepName.Value);
|
||||||
}
|
}
|
||||||
else
|
var autoHide = action.Attribute("autoHide");
|
||||||
|
if (autoHide != null)
|
||||||
{
|
{
|
||||||
act.args.Add("");
|
act.args.Add("autoHide", autoHide.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
newAction = act;
|
newAction = act;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1093,7 +1065,7 @@ namespace XMLTool
|
|||||||
Point3DQuestion.Data data = new Point3DQuestion.Data();
|
Point3DQuestion.Data data = new Point3DQuestion.Data();
|
||||||
data.name = item.Attribute("name")?.Value;
|
data.name = item.Attribute("name")?.Value;
|
||||||
XAttribute atr = item.Attribute("deviceName");
|
XAttribute atr = item.Attribute("deviceName");
|
||||||
if (atr!=null)
|
if (atr != null)
|
||||||
{
|
{
|
||||||
data.deviceName = item.Attribute("deviceName").Value;
|
data.deviceName = item.Attribute("deviceName").Value;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,9 @@
|
|||||||
<Action type="Anim" value="物体路径" deviceName="" animName="动画名字" frame="-1" speed="1"></Action>
|
<Action type="Anim" value="物体路径" deviceName="" animName="动画名字" frame="-1" speed="1"></Action>
|
||||||
<!--右下角生成按钮 可生成多个 用逗号分开-->
|
<!--右下角生成按钮 可生成多个 用逗号分开-->
|
||||||
<Action type="Btns" value="按钮1,按钮2,按钮3"></Action>
|
<Action type="Btns" value="按钮1,按钮2,按钮3"></Action>
|
||||||
<!--用于右侧道具栏选择正确的道具 event用于配合StrEventCondition 做检测 rightScore 正确选择一个 得分 wrongScore 错误一个 得分 scoreStepName是评分的key -->
|
<!--用于右侧道具栏选择正确的道具 event用于配合StrEventCondition 做检测
|
||||||
|
rightScore 正确选择一个 得分 wrongScore 错误一个 得分 scoreStepName是评分的key
|
||||||
|
autoHide =-1 则点击结束 否则 等待对应时间后自动结束-->
|
||||||
<Action type="UITools" devices="道具名字1" answers="正确道具"
|
<Action type="UITools" devices="道具名字1" answers="正确道具"
|
||||||
setActive="true"
|
setActive="true"
|
||||||
rightLabel="提示:器械选择正确。"
|
rightLabel="提示:器械选择正确。"
|
||||||
@ -30,7 +32,8 @@
|
|||||||
wrongEvent=""
|
wrongEvent=""
|
||||||
rightScore=""
|
rightScore=""
|
||||||
wrongScore=""
|
wrongScore=""
|
||||||
scoreStepName="手术准备器械选择"></Action>
|
scoreStepName="手术准备器械选择"
|
||||||
|
autoHide="-1"></Action>
|
||||||
|
|
||||||
<!--物体点位选择 物体的中心点-->
|
<!--物体点位选择 物体的中心点-->
|
||||||
<Action type="PointQuestion" value="路径1,路径2"></Action>
|
<Action type="PointQuestion" value="路径1,路径2"></Action>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user