提交修改
This commit is contained in:
parent
d44dacf0ff
commit
848b08eaf9
@ -26,6 +26,8 @@ public class TextQuestionAction : IAction
|
||||
string absolutely = string.Empty;
|
||||
string finishedEvent = string.Empty;
|
||||
string optionType = null;
|
||||
string des;
|
||||
string cellSize;
|
||||
public static TextQuestionAction Allocate(Dictionary<string, string> datas, System.Action onDelayFinish = null)
|
||||
{
|
||||
var retNode = mPool.Allocate();
|
||||
@ -44,6 +46,8 @@ public class TextQuestionAction : IAction
|
||||
retNode.absolutely = datas.ContainsKey("absolutely") ? datas["absolutely"] : string.Empty;
|
||||
retNode.finishedEvent = datas.ContainsKey("finishedEvent") ? datas["finishedEvent"] : string.Empty;
|
||||
retNode.optionType = datas.ContainsKey("optionType") ? datas["optionType"] : "0";
|
||||
retNode.des = datas.ContainsKey("des") ? datas["des"] : string.Empty;
|
||||
retNode.cellSize = datas.ContainsKey("cellSize") ? datas["cellSize"] : string.Empty;
|
||||
return retNode;
|
||||
}
|
||||
|
||||
@ -87,6 +91,8 @@ public class TextQuestionAction : IAction
|
||||
bool.TryParse(absolutely, out data.absolutely);
|
||||
}
|
||||
int.TryParse(optionType, out data.OptionType);
|
||||
data.des = des;
|
||||
data.cellSize = cellSize;
|
||||
UIKit.OpenPanelAsync<UITextQuestion>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish());
|
||||
}
|
||||
|
||||
|
||||
104
Assets/Scripts/Actions/TextQuestionAction1.cs
Normal file
104
Assets/Scripts/Actions/TextQuestionAction1.cs
Normal file
@ -0,0 +1,104 @@
|
||||
//using System.Collections;
|
||||
//using System.Collections.Generic;
|
||||
//using UnityEngine;
|
||||
//using QFramework;
|
||||
//using System;
|
||||
//using QFramework.Example;
|
||||
//using System.Linq;
|
||||
//public class TextQuestionAction : IAction
|
||||
//{
|
||||
// public ulong ActionID { get; set; }
|
||||
// public bool Deinited { get; set; }
|
||||
// public bool Paused { get; set; }
|
||||
// public ActionStatus Status { get; set; }
|
||||
|
||||
// private static readonly SimpleObjectPool<TextQuestionAction> mPool =
|
||||
// new SimpleObjectPool<TextQuestionAction>(() => new TextQuestionAction(), null, 10);
|
||||
// string title = string.Empty;
|
||||
// string options = string.Empty;
|
||||
// string answers = string.Empty;
|
||||
// string btns = string.Empty;
|
||||
// string wait = string.Empty;
|
||||
// string showAnswer = string.Empty;
|
||||
// string rightScore = string.Empty;
|
||||
// string errorScore = string.Empty;
|
||||
// string scoreName = string.Empty;
|
||||
// string absolutely = string.Empty;
|
||||
// string finishedEvent = string.Empty;
|
||||
// string optionType = null;
|
||||
// string des;
|
||||
// string cellSize;
|
||||
// public static TextQuestionAction Allocate(Dictionary<string, string> datas, System.Action onDelayFinish = null)
|
||||
// {
|
||||
// var retNode = mPool.Allocate();
|
||||
// retNode.ActionID = ActionKit.ID_GENERATOR++;
|
||||
// retNode.Deinited = false;
|
||||
// retNode.Reset();
|
||||
// retNode.title = datas.ContainsKey("title") ? datas["title"] : string.Empty;
|
||||
// retNode.options = datas.ContainsKey("options") ? datas["options"] : string.Empty;
|
||||
// retNode.btns = datas.ContainsKey("btns") ? datas["btns"] : string.Empty;
|
||||
// retNode.answers = datas.ContainsKey("answers") ? datas["answers"] : string.Empty;
|
||||
// retNode.wait = datas.ContainsKey("wait") ? datas["wait"] : string.Empty;
|
||||
// retNode.showAnswer = datas.ContainsKey("showAnswer") ? datas["showAnswer"] : string.Empty;
|
||||
// retNode.rightScore = datas.ContainsKey("rightScore") ? datas["rightScore"] : string.Empty;
|
||||
// retNode.errorScore = datas.ContainsKey("errorScore") ? datas["errorScore"] : string.Empty;
|
||||
// retNode.scoreName = datas.ContainsKey("scoreName") ? datas["scoreName"] : string.Empty;
|
||||
// retNode.absolutely = datas.ContainsKey("absolutely") ? datas["absolutely"] : string.Empty;
|
||||
// retNode.finishedEvent = datas.ContainsKey("finishedEvent") ? datas["finishedEvent"] : string.Empty;
|
||||
// retNode.optionType = datas.ContainsKey("optionType") ? datas["optionType"] : "0";
|
||||
// retNode.des = datas.ContainsKey("des") ? datas["des"] : string.Empty;
|
||||
// retNode.cellSize = datas.ContainsKey("cellSize") ? datas["cellSize"] : string.Empty;
|
||||
// return retNode;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// public void Deinit()
|
||||
// {
|
||||
// if (!Deinited)
|
||||
// {
|
||||
// Deinited = true;
|
||||
// mPool.Recycle(this);
|
||||
// }
|
||||
// }
|
||||
|
||||
// public void OnExecute(float dt)
|
||||
// {
|
||||
// }
|
||||
|
||||
// public void OnFinish()
|
||||
// {
|
||||
// }
|
||||
|
||||
// public void OnStart()
|
||||
// {
|
||||
// UITextQuestionData data = new UITextQuestionData();
|
||||
// data.title = title;
|
||||
// data.options = options.Split('|').ToList();
|
||||
// foreach (var item in answers.Split(','))
|
||||
// {
|
||||
// data.answers.Add(item);
|
||||
// }
|
||||
// data.btns = btns.Split(',').ToList();
|
||||
// float.TryParse(wait, out data.waitCloseTime);
|
||||
// bool.TryParse(showAnswer, out data.showAnswer);
|
||||
// data.finishedEvent = finishedEvent;
|
||||
// if (string.IsNullOrEmpty(scoreName) == false)
|
||||
// {
|
||||
// data.scoreName = scoreName;
|
||||
// float.TryParse(rightScore, out data.rightScore);
|
||||
// float.TryParse(errorScore, out data.errorScore);
|
||||
// bool.TryParse(absolutely, out data.absolutely);
|
||||
// }
|
||||
// int.TryParse(optionType, out data.OptionType);
|
||||
// data.des = des;
|
||||
// data.cellSize = cellSize;
|
||||
// UIKit.OpenPanelAsync<UITextQuestion>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish());
|
||||
// }
|
||||
|
||||
// public void Reset()
|
||||
// {
|
||||
// Status = ActionStatus.NotStart;
|
||||
// Paused = false;
|
||||
// }
|
||||
//}
|
||||
11
Assets/Scripts/Actions/TextQuestionAction1.cs.meta
Normal file
11
Assets/Scripts/Actions/TextQuestionAction1.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90b3cf548c2bdb34788351fd16249c85
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
5
Assets/Scripts/UI/UITextQuestion.Designer.cs
generated
5
Assets/Scripts/UI/UITextQuestion.Designer.cs
generated
@ -5,7 +5,7 @@ using QFramework;
|
||||
|
||||
namespace QFramework.Example
|
||||
{
|
||||
// Generate Id:32288864-cf64-4f8d-82e1-661c04d7b98d
|
||||
// Generate Id:cacabdaf-864d-4da0-b775-b628479cac82
|
||||
public partial class UITextQuestion
|
||||
{
|
||||
public const string Name = "UITextQuestion";
|
||||
@ -15,6 +15,8 @@ namespace QFramework.Example
|
||||
[SerializeField]
|
||||
public UnityEngine.UI.ToggleGroup OptionContent;
|
||||
[SerializeField]
|
||||
public TMPro.TextMeshProUGUI Des;
|
||||
[SerializeField]
|
||||
public RectTransform BtnContent;
|
||||
[SerializeField]
|
||||
public UnityEngine.UI.Button BtnPrefab;
|
||||
@ -27,6 +29,7 @@ namespace QFramework.Example
|
||||
{
|
||||
Title = null;
|
||||
OptionContent = null;
|
||||
Des = null;
|
||||
BtnContent = null;
|
||||
BtnPrefab = null;
|
||||
OptionPrefab = null;
|
||||
|
||||
@ -4,9 +4,8 @@ using QFramework;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using System;
|
||||
using Microsoft.SqlServer.Server;
|
||||
using XMLTool;
|
||||
using static OperationController;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace QFramework.Example
|
||||
{
|
||||
@ -23,6 +22,8 @@ namespace QFramework.Example
|
||||
public string scoreName = string.Empty;
|
||||
public string format;
|
||||
public string finishedEvent;
|
||||
public string des;
|
||||
public string cellSize;
|
||||
/// <summary>
|
||||
/// 0:×Ô¶¯ÅÐ¶Ï 1:µ¥Ñ¡ 2:¶àÑ¡
|
||||
/// </summary>
|
||||
@ -49,8 +50,13 @@ namespace QFramework.Example
|
||||
{
|
||||
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged).UnRegisterWhenDisabled(gameObject);
|
||||
mData = uiData as UITextQuestionData ?? new UITextQuestionData();
|
||||
Des.text = string.Empty;
|
||||
Title.text = mData.title;
|
||||
OptionContent.transform.RemoveAllChildren();
|
||||
if (string.IsNullOrEmpty(mData.cellSize) == false)
|
||||
{
|
||||
OptionContent.GetComponent<GridLayoutGroup>().cellSize = Utility.GetVector2FromStrArray(mData.cellSize);
|
||||
}
|
||||
for (int i = 0; i < mData.options.Count; i++)
|
||||
{
|
||||
var item = mData.options[i];
|
||||
@ -85,6 +91,11 @@ namespace QFramework.Example
|
||||
label.text = item;
|
||||
obj.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(mData.des) == false && Des.text != string.Empty)
|
||||
{
|
||||
HideSelf();
|
||||
return;
|
||||
}
|
||||
if (mData.showAnswer)
|
||||
{
|
||||
for (int i = 0; i < OptionContent.transform.childCount; i++)
|
||||
@ -97,6 +108,7 @@ namespace QFramework.Example
|
||||
}
|
||||
}
|
||||
|
||||
// 分数名不为空
|
||||
if (string.IsNullOrEmpty(mData.scoreName) == false)
|
||||
{
|
||||
if (mData.rightScore != 0)
|
||||
@ -125,13 +137,31 @@ namespace QFramework.Example
|
||||
}
|
||||
}
|
||||
|
||||
if (mData.waitCloseTime != -1)
|
||||
// 解析不为空
|
||||
if (string.IsNullOrEmpty(mData.des) == false)
|
||||
{
|
||||
|
||||
ActionKit.Delay(mData.waitCloseTime, () => HideSelf()).Start(this);
|
||||
Check(true, count =>
|
||||
{
|
||||
if (count != mData.answers.Count)
|
||||
{
|
||||
Des.text = mData.des;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
HideSelf();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (mData.waitCloseTime != -1)
|
||||
{
|
||||
ActionKit.Delay(mData.waitCloseTime, () => HideSelf()).Start(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
HideSelf();
|
||||
});
|
||||
|
||||
@ -788,6 +788,16 @@ namespace XMLTool
|
||||
{
|
||||
act.args.Add("optionType", optionType.Value);
|
||||
}
|
||||
XAttribute des = action.Attribute("des");
|
||||
if (des != null)
|
||||
{
|
||||
act.args.Add("des", des.Value);
|
||||
}
|
||||
XAttribute cellSize = action.Attribute("cellSize");
|
||||
if (cellSize != null)
|
||||
{
|
||||
act.args.Add("cellSize", cellSize.Value);
|
||||
}
|
||||
newAction = act;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -30,7 +30,8 @@
|
||||
|
||||
|
||||
|
||||
</Action>
|
||||
|
||||
</Action>
|
||||
</Enter>
|
||||
</State>
|
||||
|
||||
@ -165,12 +166,18 @@
|
||||
|
||||
|
||||
|
||||
<Action type="Input" title="观察宝石内部特征,输入观察结果" finishedEvent="UI关闭事件通知用StrEvent接收">
|
||||
<!--<Action type="Input" title="观察宝石内部特征,输入观察结果" finishedEvent="UI关闭事件通知用StrEvent接收">
|
||||
<Input name="暗域照明法是观察宝石:" answer="内部特征"></Input>
|
||||
<Input name="在暗色的背景下,显得十分清晰,是常用的一种照明方法。而且有利于:" answer="长时间|长时间观察"></Input>
|
||||
<Btn name="确定" clickEvent="确定点击" checkAnswer="true" wrongLabel="输入错误" wrongCount="3" autoHide="1" ></Btn>
|
||||
|
||||
</Action>
|
||||
</Action>-->
|
||||
|
||||
<Action type="TextQuestion" title="显微镜暗域照明法是观察宝石( ),在暗色的背景下,显得十分清晰,是常用的一种照明方法。而且有利于( )的观察。"
|
||||
options="A、外部特征、长时间。|B、内部特征、短时间。|C、内部特征、长时间。|D、外部特征、短时间。" answers="3" btns="确定" finishedEvent="UI关闭事件通知用StrEvent接收"
|
||||
des="显微镜暗域照明法是观察宝石内部特征,在暗色的背景下,显得十分清晰,是常用的一种照明方法。而且有利于长时间的观察。"></Action>
|
||||
|
||||
|
||||
<Condition type="StrEvent" value="UI关闭事件通知用StrEvent接收"></Condition>
|
||||
|
||||
<Action type="NextOperation"></Action>
|
||||
|
||||
@ -99,6 +99,7 @@
|
||||
<Btn name="取消"></Btn>
|
||||
</Action>
|
||||
|
||||
|
||||
<!--文字选择题 scoreName="分数名"
|
||||
rightScore="5" 可以是正确加分
|
||||
wrongScore="-5" 也可以是错误减分
|
||||
@ -107,8 +108,12 @@
|
||||
注意:rightScore与wrongScore不能同时存在 同时存在则只生效rightScore
|
||||
finishedEvent 用于监听选择题UI消失
|
||||
optionType 0 根据答案数量自动判断单选还是多选 1 单选 2多选
|
||||
des 答案解析 不为空的情况下 点击确定显示解析 在点确定 关闭窗口
|
||||
cellSize : 选项的格子宽高 默认370,43 可以修改
|
||||
-->
|
||||
<Action type="TextQuestion" title="这里是标题" options="A.111|B.222|C.333|D.4444" answers="2" btns="确定" wait="1" showAnswer="true" scoreName="分数名" rightScore="5" wrongScore="-5" absolutely="false" format="{0:F1}" finishedEvent="事件名" optionType="0"></Action>
|
||||
<Action type="TextQuestion" title="这里是标题" options="A.111|B.222|C.333|D.4444" answers="2" btns="确定" wait="1" showAnswer="true" scoreName="分数名" rightScore="5" wrongScore="-5" absolutely="false" format="{0:F1}" finishedEvent="事件名" optionType="0"
|
||||
des="这里是答案解析"
|
||||
cellSize="370,43"></Action>
|
||||
<!--提示 time为显示的时间 -1则一直显示 icon是前面的绿色图标是否显示 audio是音频 位于data文件夹下的Audio-->
|
||||
<Action type="Hint" value="这里是文字描述" time="5" icon="false" audio="音频.mp3"></Action>
|
||||
<!--设置变量 value只能是数字可以是小数-->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user