Skip to content

Commit

Permalink
feat(UI): Add auto progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Aug 6, 2024
1 parent 7ab0abf commit f654d7f
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4124,7 +4124,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &764007139224113502
RectTransform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -4237,8 +4237,6 @@ MonoBehaviour:
mRightImage: {fileID: 6393945804426866846}
mNameTag: {fileID: 7830457409021631893}
mTextBox: {fileID: 4721417465960552238}
mCompleteTextBeforeAction: 0
mCompleteTextBeforeActionOnButton: 0
mScrollTime: 0.01
mDeltaTimeType: 0
mPanelTrans: {fileID: 0}
Expand All @@ -4258,6 +4256,10 @@ MonoBehaviour:
- {fileID: 7296028875851633172}
- {fileID: 8791215142036938067}
mButtonSelectionGroup: {fileID: 5080200581021259784}
mCompleteTextBeforeAction: 0
mCompleteTextBeforeActionOnButton: 0
mAutoProgress: 0
mAutoDelay: 2
mActiveSound: {fileID: 8300000, guid: 4913222f00b7466419656d01e8bae9d6, type: 3}
mDisposeSound: {fileID: 8300000, guid: ffcf3906540e3b74fa27dc938e19d461, type: 3}
--- !u!1 &7811244761158602352
Expand Down
8 changes: 5 additions & 3 deletions Assets/JCSUnity/Resources/UI/JCS_DialogueSystem.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -2338,7 +2338,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &984955064616139632
RectTransform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -2451,8 +2451,6 @@ MonoBehaviour:
mRightImage: {fileID: 6546777816282174048}
mNameTag: {fileID: 827766543013699587}
mTextBox: {fileID: 6267707290331941680}
mCompleteTextBeforeAction: 0
mCompleteTextBeforeActionOnButton: 0
mScrollTime: 0.01
mDeltaTimeType: 0
mPanelTrans: {fileID: 0}
Expand All @@ -2472,6 +2470,10 @@ MonoBehaviour:
- {fileID: 526192977114094584}
- {fileID: 7604726519187752915}
mButtonSelectionGroup: {fileID: 1527436958594954669}
mCompleteTextBeforeAction: 0
mCompleteTextBeforeActionOnButton: 0
mAutoProgress: 0
mAutoDelay: 2
mActiveSound: {fileID: 0}
mDisposeSound: {fileID: 0}
--- !u!1 &4528894428773322394
Expand Down
10 changes: 0 additions & 10 deletions Assets/JCSUnity/Scenes/Utilities/JCS_ScriptTester.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1290,11 +1290,6 @@ PrefabInstance:
propertyPath: m_Name
value: JCS_DialogueSystem (Game Pad)
objectReference: {fileID: 0}
- target: {fileID: 7657870147620464614, guid: c7ea891da8aadd741a2b75f708a50d65,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
Expand Down Expand Up @@ -1413,11 +1408,6 @@ PrefabInstance:
propertyPath: m_Name
value: JCS_DialogueSystem
objectReference: {fileID: 0}
- target: {fileID: 4431048296620540127, guid: 11e5c739135b1e34d8a1164d3c66f6f8,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
Expand Down
70 changes: 57 additions & 13 deletions Assets/JCSUnity/Scripts/UI/Dialogue/JCS_DialogueSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,6 @@ public class JCS_DialogueSystem : MonoBehaviour
[SerializeField]
private JCS_TextObject mTextBox = null;

[Tooltip("Complete text before run action.")]
[SerializeField]
private bool mCompleteTextBeforeAction = false;

[Tooltip("Complete text before run action on button's event.")]
[SerializeField]
private bool mCompleteTextBeforeActionOnButton = false;

[Tooltip("Speed of scrolling the text.")]
[SerializeField]
[Range(0.01f, 10.0f)]
Expand Down Expand Up @@ -175,13 +167,36 @@ public class JCS_DialogueSystem : MonoBehaviour
private string mSelectStringFront = "#L" + 0 + "##b";
private string mSelectStringBack = "#k#l";

[Header("- Optional Variables")]
[Header("Controller")]

[Tooltip("Button selection group for this dialogue system.")]
[SerializeField]
private JCS_ButtonSelectionGroup mButtonSelectionGroup = null;

[Header("- Sound")]
[Header("Completing")]

[Tooltip("Complete text before run action.")]
[SerializeField]
private bool mCompleteTextBeforeAction = false;

[Tooltip("Complete text before run action on button's event.")]
[SerializeField]
private bool mCompleteTextBeforeActionOnButton = false;

[Header("Auto")]

[Tooltip("If true, auto progress the dialgoue.")]
[SerializeField]
private bool mAutoProgress = false;

[Tooltip("Delay before start the next text popup.")]
[SerializeField]
[Range(0.0f, 30.0f)]
private float mAutoDelay = 2.0f;

private float mAutoTimer = 0.0f;

[Header("Sound")]

[Tooltip("Sound plays when active dialogue.")]
[SerializeField]
Expand All @@ -199,14 +214,16 @@ public class JCS_DialogueSystem : MonoBehaviour
public bool Skip { get { return this.mSkip; } }

public bool MakeHoverSelect { get { return this.mMakeHoverSelect; } set { this.mMakeHoverSelect = value; } }
public bool CompleteTextBeforeAction { get { return this.mCompleteTextBeforeAction; } set { this.mCompleteTextBeforeAction = value; } }
public bool CompleteTextBeforeActionOnButton { get { return this.mCompleteTextBeforeActionOnButton; } set { this.mCompleteTextBeforeActionOnButton = value; } }
public JCS_DeltaTimeType DeltaTimeType { get { return this.mDeltaTimeType; } set { this.mDeltaTimeType = value; } }
public JCS_DialogueScript DialogueScript { get { return this.mDialogueScript; } set { this.mDialogueScript = value; } }
public string SelectStringFront { get { return this.mSelectStringFront; } }
public string SelectStringBack { get { return this.mSelectStringBack; } }
public JCS_ButtonSelectionGroup ButtonSelectionGroup { get { return this.mButtonSelectionGroup; } set { this.mButtonSelectionGroup = value; } }

public JCS_ButtonSelectionGroup ButtonSelectionGroup { get { return this.mButtonSelectionGroup; } set { this.mButtonSelectionGroup = value; } }
public bool CompleteTextBeforeAction { get { return this.mCompleteTextBeforeAction; } set { this.mCompleteTextBeforeAction = value; } }
public bool CompleteTextBeforeActionOnButton { get { return this.mCompleteTextBeforeActionOnButton; } set { this.mCompleteTextBeforeActionOnButton = value; } }
public bool AutoProgress { get { return this.mAutoProgress; } set { this.mAutoProgress = value; } }
public float AutoDelay { get { return this.AutoDelay; } set { this.mAutoDelay = value; } }
public AudioClip AcitveSound { get { return this.mActiveSound; } set { this.mActiveSound = value; } }
public AudioClip DisposeSound { get { return this.mDisposeSound; } set { this.mDisposeSound = value; } }

Expand Down Expand Up @@ -253,6 +270,8 @@ private void LateUpdate()

ScrollSelectBtnText();

DoAuto();

mActiveThisFrame = false;
}

Expand Down Expand Up @@ -550,6 +569,9 @@ public void Dispose()
/// </summary>
public void ResetStats()
{
mScrollTimer = 0.0f;
mAutoTimer = 0.0f;

mScrolling = false;
mSkip = false;
mTextIndex = 0;
Expand Down Expand Up @@ -875,6 +897,28 @@ private void CompleteSelectionsScroll()
}
}

/// <summary>
/// Automatically start the next text popup.
/// </summary>
private void DoAuto()
{
if (!mAutoProgress)
return;

if (IsScrolling())
return;

mAutoTimer += JCS_Time.DeltaTime(mDeltaTimeType);

if (mAutoTimer < mAutoDelay)
return;

// Reset timer.
mAutoTimer = 0.0f;

NextOrDispose();
}

/// <summary>
/// Active the panel?
/// </summary>
Expand Down
6 changes: 4 additions & 2 deletions docs/ScriptReference/UI/Dialogue/JCS_DialogueSystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ Dialogue system core implementation.
|:----------------------------------|:---------------------------------------------------|
| onDispose | Callback when successfully dispose the dialogue. |
| mMakeHoverSelect | If the mouse hover then select the selection. |
| mCompleteTextBeforeAction | Complete text before run action. |
| mCompleteTextBeforeActionOnButton | Complete text before run action on button's event. |
| mCenterImage | Image displayed at the center. |
| mLeftImage | Image displayed at the left. |
| mRightImage | Image displayed at the right. |
| mNameTag | Current name tag. |
| mScrollTime | Speed of scrolling the text. |
| mButtonSelectionGroup | Make control from the gamepad. |
| mCompleteTextBeforeAction | Complete text before run action. |
| mCompleteTextBeforeActionOnButton | Complete text before run action on button's event. |
| mAutoProgress | If true, auto progress the dialgoue. |
| mAutoDelay | Delay before start the next text popup. |
| mActiveSound | Sound plays when active dialogue. |
| mDisposeSound | Sound plays when dispose dialogue. |

Expand Down

0 comments on commit f654d7f

Please sign in to comment.