Skip to content

Commit

Permalink
feat(UI): Add show hide for dialogue system
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Aug 16, 2024
1 parent 269ecc6 commit c47d999
Showing 1 changed file with 49 additions and 7 deletions.
56 changes: 49 additions & 7 deletions Assets/JCSUnity/Scripts/UI/Dialogue/JCS_DialogueSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ public class JCS_DialogueSystem : MonoBehaviour

[Separator("Runtime Variables (JCS_DialogueSystem)")]

[Tooltip("Default character image sprite.")]
[SerializeField]
private Sprite mTransparentSprite = null;

[Tooltip("Image displayed at the center.")]
[SerializeField]
private Image mCenterImage = null;
Expand Down Expand Up @@ -275,6 +271,44 @@ private void LateUpdate()
mActiveThisFrame = false;
}

/// <summary>
/// Return true if the dialgoue system is visible.
/// </summary>
public bool IsVisible()
{
return mPanelTrans.gameObject.activeSelf;
}

/// <summary>
/// Show the dialogue.
/// </summary>
public void Show(bool act = true)
{
PanelActive(act);
}

/// <summary>
/// Hide the dialogue.
/// </summary>
public void Hide()
{
Show(false);
}

/// <summary>
/// Toggle between show and hide.
/// </summary>
public void ToggleVisiblity()
{
if (!mActive)
return;

if (IsVisible())
Hide();
else
Show();
}

/// <summary>
/// Start the dialogue, in other word same as start a conversation.
/// </summary>
Expand Down Expand Up @@ -591,9 +625,11 @@ public void ResetStats()
ClearSelectBtnMessage();

// reset images
SendCenterImage(mTransparentSprite);
SendLeftImage(mTransparentSprite);
SendRightImage(mTransparentSprite);
var transSprite = JCS_UIUtil.SpriteTransparent();

SendCenterImage(transSprite);
SendLeftImage(transSprite);
SendRightImage(transSprite);

ResetButtonSelectionGroup();
}
Expand Down Expand Up @@ -706,6 +742,9 @@ public bool NextOrDispose()
if (!mActive || mActiveThisFrame)
return false;

if (!IsVisible())
return false;

if (SkipToEnd(mCompleteTextBeforeAction))
return false;

Expand Down Expand Up @@ -735,6 +774,9 @@ public bool SkipToEnd()
{
if (IsScrolling())
{
// immediately call it on the next frame.
mScrollTimer = mScrollTime;

mSkip = true;

return true;
Expand Down

0 comments on commit c47d999

Please sign in to comment.