Updates GUI for new working flow.
This commit is contained in:
parent
6c1ed05bd7
commit
ea4535ebb6
|
|
@ -2,6 +2,5 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.expandable {
|
.expandable {
|
||||||
flex-grow: 1;
|
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
<ui:UXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
<ui:UXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||||
<Style src="project://database/Assets/_Client/GUI/Main.uss?fileID=7433441132597879392&guid=fe550b4c3daa62b448a38ddf615910a6&type=3#Main" />
|
<Style src="project://database/Assets/_Client/GUI/Main.uss?fileID=7433441132597879392&guid=fe550b4c3daa62b448a38ddf615910a6&type=3#Main" />
|
||||||
<ui:VisualElement name="VE_Panel" style="flex-grow: 1;">
|
<ui:VisualElement name="VE_Panel" style="flex-grow: 1;">
|
||||||
<ui:Button text="Iniciar sessão" name="B_Session" />
|
<ui:Button text="Falar..." name="B_Talk" />
|
||||||
<ui:Label text="Chat:" />
|
|
||||||
<ui:TextField placeholder-text="Digite sua mensagem" name="TF_ChatInput" class="expandable" />
|
|
||||||
<ui:Button text="Enviar mensagem" name="B_SendChat" />
|
|
||||||
<ui:ProgressBar value="0" title="Processando... Por favor, espere..." name="PB_Progress" enabled="true" />
|
<ui:ProgressBar value="0" title="Processando... Por favor, espere..." name="PB_Progress" enabled="true" />
|
||||||
<ui:TextField placeholder-text="response" multiline="true" readonly="true" name="TF_ChatOutput" class="expandable" />
|
<ui:ScrollView>
|
||||||
|
<ui:TextField placeholder-text="response" multiline="true" readonly="true" name="TF_Dialogue" class="expandable" />
|
||||||
|
</ui:ScrollView>
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|
|
||||||
|
|
@ -6,40 +6,28 @@ using UnityEngine.UIElements;
|
||||||
|
|
||||||
namespace PPGIA.X540.Project3
|
namespace PPGIA.X540.Project3
|
||||||
{
|
{
|
||||||
[RequireComponent(typeof(UIController))]
|
[RequireComponent(typeof(UIDocument))]
|
||||||
public class UIController : MonoBehaviour
|
public class UIController : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
public enum UIState
|
||||||
|
{
|
||||||
|
Idle = 0,
|
||||||
|
Recording = 1,
|
||||||
|
Processing = 2
|
||||||
|
}
|
||||||
|
|
||||||
private UIDocument _uiDocument;
|
private UIDocument _uiDocument;
|
||||||
private VisualElement _root;
|
private VisualElement _root;
|
||||||
|
|
||||||
#region -- Fields & Properties ----------------------------------------
|
#region -- Fields & Properties ----------------------------------------
|
||||||
// Buttons ------------------------------------------------------------
|
private readonly string[] _sendChatButtonLabels = {
|
||||||
private readonly string[] _sessionButtonLabels = {
|
"Falar...",
|
||||||
"Iniciar Sessão",
|
"Enviar...",
|
||||||
"Encerrar Sessão"
|
"Processando... Aguarde..."
|
||||||
};
|
};
|
||||||
private Button _sessionButton;
|
|
||||||
private Button _sendChatButton;
|
|
||||||
|
|
||||||
private int _currentSessionState = 0;
|
// UI controls --------------------------------------------------------
|
||||||
public bool SessionActive
|
private Button _talkButton;
|
||||||
{
|
|
||||||
get => _currentSessionState == 1;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_currentSessionState = value ? 1 : 0;
|
|
||||||
_sessionButton.text = _sessionButtonLabels[_currentSessionState];
|
|
||||||
InputEnabled = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Chat Fields --------------------------------------------------------
|
|
||||||
private TextField _chatInputField;
|
|
||||||
public string ChatInput
|
|
||||||
{
|
|
||||||
get => _chatInputField.value;
|
|
||||||
set => _chatInputField.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TextField _chatOutputField;
|
private TextField _chatOutputField;
|
||||||
public string ChatOutput
|
public string ChatOutput
|
||||||
|
|
@ -48,22 +36,6 @@ namespace PPGIA.X540.Project3
|
||||||
set => _chatOutputField.value = value;
|
set => _chatOutputField.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool InputEnabled
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var value = _chatInputField.enabledSelf;
|
|
||||||
_sendChatButton.SetEnabled(value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_chatInputField.SetEnabled(value);
|
|
||||||
_sendChatButton.SetEnabled(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Progress Bar -------------------------------------------------------
|
|
||||||
private ProgressBar _progressBar;
|
private ProgressBar _progressBar;
|
||||||
public float Progress
|
public float Progress
|
||||||
{
|
{
|
||||||
|
|
@ -71,9 +43,30 @@ namespace PPGIA.X540.Project3
|
||||||
set => _progressBar.value = value;
|
set => _progressBar.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// State management ---------------------------------------------------
|
||||||
|
private UIState _currentState = UIState.Idle;
|
||||||
|
public UIState CurrentState
|
||||||
|
{
|
||||||
|
get => _currentState;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_currentState = value;
|
||||||
|
_talkButton.text = _sendChatButtonLabels[(int)value];
|
||||||
|
if (value == UIState.Processing)
|
||||||
|
{
|
||||||
|
_talkButton.SetEnabled(false);
|
||||||
|
_progressBar.value = 0.5f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_talkButton.SetEnabled(true);
|
||||||
|
_progressBar.value = 0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Event Handlers -----------------------------------------------------
|
// Event Handlers -----------------------------------------------------
|
||||||
public event Action OnSessionButtonClicked;
|
public event Action OnTalkButtonClicked;
|
||||||
public event Action<string> OnSendChatButtonClicked;
|
|
||||||
|
|
||||||
#endregion ------------------------------------------------------------
|
#endregion ------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -83,36 +76,43 @@ namespace PPGIA.X540.Project3
|
||||||
_uiDocument = GetComponent<UIDocument>();
|
_uiDocument = GetComponent<UIDocument>();
|
||||||
_root = _uiDocument.rootVisualElement;
|
_root = _uiDocument.rootVisualElement;
|
||||||
|
|
||||||
_sessionButton = _root.Q<Button>("B_Session");
|
_talkButton = _root.Q<Button>("B_Talk");
|
||||||
_sendChatButton = _root.Q<Button>("B_SendChat");
|
if (_talkButton == null)
|
||||||
_chatInputField = _root.Q<TextField>("TF_ChatInput");
|
{
|
||||||
_chatOutputField = _root.Q<TextField>("TF_ChatOutput");
|
Debug.LogError("Talk Button not found in UI.");
|
||||||
|
}
|
||||||
|
|
||||||
_progressBar = _root.Q<ProgressBar>("PB_Progress");
|
_progressBar = _root.Q<ProgressBar>("PB_Progress");
|
||||||
|
if (_progressBar == null)
|
||||||
|
{
|
||||||
|
Debug.LogError("Progress Bar not found in UI.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnEnable()
|
_chatOutputField = _root.Q<TextField>("TF_Dialogue");
|
||||||
|
if (_chatOutputField == null)
|
||||||
{
|
{
|
||||||
_sessionButton.clicked += OnSessionButtonClickedInternal;
|
Debug.LogError("Chat Output Field not found in UI.");
|
||||||
_sendChatButton.clicked += OnSendChatButtonClickedInternal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDisable()
|
CurrentState = UIState.Idle;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
_sessionButton.clicked -= OnSessionButtonClickedInternal;
|
_talkButton.clicked += OnTalkButtonClickedInternal;
|
||||||
_sendChatButton.clicked -= OnSendChatButtonClickedInternal;
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
_talkButton.clicked -= OnTalkButtonClickedInternal;
|
||||||
}
|
}
|
||||||
#endregion ------------------------------------------------------------
|
#endregion ------------------------------------------------------------
|
||||||
|
|
||||||
private void OnSessionButtonClickedInternal()
|
private void OnTalkButtonClickedInternal() => OnTalkButtonClicked?.Invoke();
|
||||||
{
|
|
||||||
OnSessionButtonClicked?.Invoke();
|
|
||||||
// SessionActive state should be updated externally, no logic here.
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnSendChatButtonClickedInternal()
|
public void AppendChatOutput(string newText)
|
||||||
{
|
{
|
||||||
OnSendChatButtonClicked?.Invoke(_chatInputField.value);
|
ChatOutput += newText;
|
||||||
_chatInputField.value = string.Empty;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ MonoBehaviour:
|
||||||
m_Match: 0
|
m_Match: 0
|
||||||
m_SortingOrder: 0
|
m_SortingOrder: 0
|
||||||
m_TargetDisplay: 0
|
m_TargetDisplay: 0
|
||||||
m_BindingLogLevel: 0
|
m_BindingLogLevel: 2
|
||||||
m_ClearDepthStencil: 1
|
m_ClearDepthStencil: 1
|
||||||
m_ClearColor: 0
|
m_ClearColor: 0
|
||||||
m_ColorClearValue: {r: 0, g: 0, b: 0, a: 0}
|
m_ColorClearValue: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue