Skip to content

Commit 78a2bd0

Browse files
committed
dialogue system compatible with mouse hover state.
1 parent 5d7a911 commit 78a2bd0

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,18 @@ private void RunAction()
10341034
if (!mActive)
10351035
return;
10361036

1037+
/*
1038+
* NOTE(jenchieh): If there is selections occurs
1039+
* in last status, then we make sure the hover working
1040+
* for selecting the selection.
1041+
*
1042+
* If I hover the selection 5, then selection should
1043+
* be 5 even I did notclick on selection five. Next
1044+
* button should just know the selection should be
1045+
* five for next 'RunAction'.
1046+
*/
1047+
MakeHoverSelections();
1048+
10371049
// initialize every run (before running the script)
10381050
ResetStats();
10391051

@@ -1046,6 +1058,50 @@ private void RunAction()
10461058
Selection = -1;
10471059
}
10481060

1061+
/// <summary>
1062+
/// If a selection is hover make sure the selection is been
1063+
/// chosen for next status.
1064+
/// </summary>
1065+
private void MakeHoverSelections()
1066+
{
1067+
if (mButtonSelectionGroup == null)
1068+
return;
1069+
1070+
int hoverChoiceIndex = FindSelectedButton();
1071+
1072+
/* Return because no selection is active. */
1073+
if (hoverChoiceIndex == -1)
1074+
return;
1075+
1076+
Selection = hoverChoiceIndex;
1077+
}
1078+
1079+
/// <summary>
1080+
/// Find the active button selection's index!
1081+
/// </summary>
1082+
/// <returns></returns>
1083+
private int FindSelectedButton()
1084+
{
1085+
for (int index = 0;
1086+
index < mSelectBtn.Length;
1087+
++index)
1088+
{
1089+
JCS_Button jcsbtn = mSelectBtn[index];
1090+
1091+
if (jcsbtn == null || jcsbtn.ButtonSelection == null)
1092+
continue;
1093+
1094+
if (jcsbtn.ButtonSelection.Active)
1095+
return index;
1096+
}
1097+
1098+
// Selection was not active. Meaning the send choice
1099+
// did not been called by last status.
1100+
//
1101+
// NOTE(jenchieh): We are appoarching to new status right now.
1102+
return -1;
1103+
}
1104+
10491105

10501106
/// <summary>
10511107
/// What if "Next Button" clicked?

0 commit comments

Comments
 (0)