Skip to content

Commit

Permalink
feat: Complete dialogue system
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Oct 31, 2024
1 parent a1681fe commit b01eb39
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 8 deletions.
60 changes: 54 additions & 6 deletions Assets/JCSUnity/Scripts/UI/Dialogue/JCS_DialogueSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ public class JCS_DialogueSystem : MonoBehaviour
[SerializeField]
private Image mRightImage = null;

[Tooltip("Name tag.")]
[Tooltip("Text box to display names.")]
[SerializeField]
private JCS_TextObject mNameTag = null;

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

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

public Image CenterImage { get { return this.mCenterImage; } }
public Image LeftImage { get { return this.mLeftImage; } }
public Image RightImage { get { return this.mRightImage; } }
public JCS_TextObject NameTag { get { return this.mNameTag; } }
public JCS_TextObject TextBox { get { return this.mTextBox; } }
public RectTransform PanelTrans { get { return this.mPanelTrans; } }
public JCS_Button OkBtn { get { return this.mOkBtn; } }
public JCS_Button ExitBtn { get { return this.mExitBtn; } }
public JCS_Button YesBtn { get { return this.mYesBtn; } }
public JCS_Button NoBtn { get { return this.mNoBtn; } }
public JCS_Button PreviousBtn { get { return this.mPreviousBtn; } }
public JCS_Button NextBtn { get { return this.mNextBtn; } }
public JCS_Button AcceptBtn { get { return this.mAcceptBtn; } }
public JCS_Button DeclineBtn { get { return this.mDeclineBtn; } }

public bool MakeHoverSelect { get { return this.mMakeHoverSelect; } set { this.mMakeHoverSelect = 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; } }
Expand Down Expand Up @@ -646,7 +661,10 @@ public void ResetStats()
mRenderSelectTextIndex = 0;
mSelectTextIndex = 0;

// reset message.
// clear name tag
mNameTag.text = "";

// clear text box
mMessage = "";
mTextBox.text = "";

Expand Down Expand Up @@ -766,10 +784,28 @@ public void DecPage()
}

/// <summary>
/// Continue with default condition.
/// Go to previous page of the dialogue.
/// </summary>
/// <returns> Return true if successful continue the dialogue. </returns>
public bool NextOrDispose()
public bool Previous()
{
if (!mActive || mActiveThisFrame)
return false;

if (!IsVisible())
return false;

if (SkipToEnd(mCompleteTextBeforeAction))
return false;

PreviousBtnCallback();

return true;
}

/// <summary>
/// Go to next page of the dialogue.
/// </summary>
public bool Next()
{
if (!mActive || mActiveThisFrame)
return false;
Expand All @@ -782,6 +818,18 @@ public bool NextOrDispose()

NextBtnCallback();

return true;
}

/// <summary>
/// Like `Next` function but dispose it when possible.
/// </summary>
/// <returns> Return true if successful continue the dialogue. </returns>
public bool NextOrDispose()
{
if (!Next())
return false;

if (mMessage == "")
{
Dispose();
Expand Down
7 changes: 5 additions & 2 deletions docs/ScriptReference/UI/Dialogue/JCS_DialogueSystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Dialogue system core implementation.
| mCenterImage | Image displayed at the center. |
| mLeftImage | Image displayed at the left. |
| mRightImage | Image displayed at the right. |
| mNameTag | Current name tag. |
| mNameTag | Text box to display names. |
| mTextBox | Text box to display content messages. |
| mScrollTime | Speed of scrolling the text. |
| mButtonSelectionGroup | Make control from the gamepad. |
| mCompleteTextBeforeAction | Complete text before run action. |
Expand Down Expand Up @@ -44,7 +45,9 @@ Dialogue system core implementation.
| SendRightImage | Set the sprite to the image component. (Right) |
| IncPage | Increament one from page. |
| DecPage | Decreament one from page. |
| NextOrDispose | Continue with default condition. |
| Previous | Go to previous page of the dialogue. |
| Next | Go to next page of the dialogue. |
| NextOrDispose | Like `Next` function but dispose it when possible. |
| IsScrolling | Return true if the dialogue system is still animating the text. |
| SkipToEnd | Skip the current text scroll. |
| IsVisible | Return true if the dialgoue system is visible. |
Expand Down

0 comments on commit b01eb39

Please sign in to comment.