Skip to content

Commit b01eb39

Browse files
committed
feat: Complete dialogue system
1 parent a1681fe commit b01eb39

File tree

2 files changed

+59
-8
lines changed

2 files changed

+59
-8
lines changed

Assets/JCSUnity/Scripts/UI/Dialogue/JCS_DialogueSystem.cs

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ public class JCS_DialogueSystem : MonoBehaviour
9999
[SerializeField]
100100
private Image mRightImage = null;
101101

102-
[Tooltip("Name tag.")]
102+
[Tooltip("Text box to display names.")]
103103
[SerializeField]
104104
private JCS_TextObject mNameTag = null;
105105

106-
[Tooltip("Main text GUI component to scroll.")]
106+
[Tooltip("Text box to display content messages.")]
107107
[SerializeField]
108108
private JCS_TextObject mTextBox = null;
109109

@@ -209,6 +209,21 @@ public class JCS_DialogueSystem : MonoBehaviour
209209
public bool ScrollingSelectBtnText { get { return this.mScrollingSelectBtnText; } }
210210
public bool Skip { get { return this.mSkip; } }
211211

212+
public Image CenterImage { get { return this.mCenterImage; } }
213+
public Image LeftImage { get { return this.mLeftImage; } }
214+
public Image RightImage { get { return this.mRightImage; } }
215+
public JCS_TextObject NameTag { get { return this.mNameTag; } }
216+
public JCS_TextObject TextBox { get { return this.mTextBox; } }
217+
public RectTransform PanelTrans { get { return this.mPanelTrans; } }
218+
public JCS_Button OkBtn { get { return this.mOkBtn; } }
219+
public JCS_Button ExitBtn { get { return this.mExitBtn; } }
220+
public JCS_Button YesBtn { get { return this.mYesBtn; } }
221+
public JCS_Button NoBtn { get { return this.mNoBtn; } }
222+
public JCS_Button PreviousBtn { get { return this.mPreviousBtn; } }
223+
public JCS_Button NextBtn { get { return this.mNextBtn; } }
224+
public JCS_Button AcceptBtn { get { return this.mAcceptBtn; } }
225+
public JCS_Button DeclineBtn { get { return this.mDeclineBtn; } }
226+
212227
public bool MakeHoverSelect { get { return this.mMakeHoverSelect; } set { this.mMakeHoverSelect = value; } }
213228
public JCS_DeltaTimeType DeltaTimeType { get { return this.mDeltaTimeType; } set { this.mDeltaTimeType = value; } }
214229
public JCS_DialogueScript DialogueScript { get { return this.mDialogueScript; } set { this.mDialogueScript = value; } }
@@ -646,7 +661,10 @@ public void ResetStats()
646661
mRenderSelectTextIndex = 0;
647662
mSelectTextIndex = 0;
648663

649-
// reset message.
664+
// clear name tag
665+
mNameTag.text = "";
666+
667+
// clear text box
650668
mMessage = "";
651669
mTextBox.text = "";
652670

@@ -766,10 +784,28 @@ public void DecPage()
766784
}
767785

768786
/// <summary>
769-
/// Continue with default condition.
787+
/// Go to previous page of the dialogue.
770788
/// </summary>
771-
/// <returns> Return true if successful continue the dialogue. </returns>
772-
public bool NextOrDispose()
789+
public bool Previous()
790+
{
791+
if (!mActive || mActiveThisFrame)
792+
return false;
793+
794+
if (!IsVisible())
795+
return false;
796+
797+
if (SkipToEnd(mCompleteTextBeforeAction))
798+
return false;
799+
800+
PreviousBtnCallback();
801+
802+
return true;
803+
}
804+
805+
/// <summary>
806+
/// Go to next page of the dialogue.
807+
/// </summary>
808+
public bool Next()
773809
{
774810
if (!mActive || mActiveThisFrame)
775811
return false;
@@ -782,6 +818,18 @@ public bool NextOrDispose()
782818

783819
NextBtnCallback();
784820

821+
return true;
822+
}
823+
824+
/// <summary>
825+
/// Like `Next` function but dispose it when possible.
826+
/// </summary>
827+
/// <returns> Return true if successful continue the dialogue. </returns>
828+
public bool NextOrDispose()
829+
{
830+
if (!Next())
831+
return false;
832+
785833
if (mMessage == "")
786834
{
787835
Dispose();

docs/ScriptReference/UI/Dialogue/JCS_DialogueSystem.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ Dialogue system core implementation.
1111
| mCenterImage | Image displayed at the center. |
1212
| mLeftImage | Image displayed at the left. |
1313
| mRightImage | Image displayed at the right. |
14-
| mNameTag | Current name tag. |
14+
| mNameTag | Text box to display names. |
15+
| mTextBox | Text box to display content messages. |
1516
| mScrollTime | Speed of scrolling the text. |
1617
| mButtonSelectionGroup | Make control from the gamepad. |
1718
| mCompleteTextBeforeAction | Complete text before run action. |
@@ -44,7 +45,9 @@ Dialogue system core implementation.
4445
| SendRightImage | Set the sprite to the image component. (Right) |
4546
| IncPage | Increament one from page. |
4647
| DecPage | Decreament one from page. |
47-
| NextOrDispose | Continue with default condition. |
48+
| Previous | Go to previous page of the dialogue. |
49+
| Next | Go to next page of the dialogue. |
50+
| NextOrDispose | Like `Next` function but dispose it when possible. |
4851
| IsScrolling | Return true if the dialogue system is still animating the text. |
4952
| SkipToEnd | Skip the current text scroll. |
5053
| IsVisible | Return true if the dialgoue system is visible. |

0 commit comments

Comments
 (0)