Skip to content

Commit

Permalink
Hotfix: Choice box display
Browse files Browse the repository at this point in the history
  • Loading branch information
RhenaudTheLukark committed May 15, 2019
1 parent ab418c0 commit f60f597
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Assets/Scripts/Lua/CLRBindings/Overworld/LuaGeneralOW.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ [CYFEventFunction] public void SetChoice(DynValue choices, string question = "",
textMsgChoice.AddToText("[mugshot:null]");
List<string> finalText = new List<string>();
bool[] oneLiners = new bool[2];
List<string[]> preTexts = new List<string[]>();
bool threeLiner = false;

//Do not put more than 3 lines and 2 choices
//If the 3rd parameter is a string, it has to be a question
Expand All @@ -71,24 +73,29 @@ [CYFEventFunction] public void SetChoice(DynValue choices, string question = "",
if (choices.Table.Get(i + 1).String == null)
continue;

string[] preText = choices.Table.Get(i + 1).String.Split('\n');
preTexts.Add(choices.Table.Get(i + 1).String.Split('\n'));
string[] preText = preTexts[preTexts.Count - 1];
oneLiners[i] = preText.Length == 1 && question != "";
if (preText.Length == 3)
threeLiner = true;
if (oneLiners[i]) {
string line = preText[0];
preText = new string[] { "", line };
preTexts[preTexts.Count - 1] = new string[] { "", line };
}
}

for (int j = 0; j < 3; j++) {
for (int i = 0; i < 2; i++) {
string[] preText = preTexts[i];
for (int j = 0; j < (threeLiner ? 3 : 2); j++) {
if (j == finalText.Count)
finalText.Add("");
finalText[j] += "[charspacing:8] [charspacing:2]" + (i == 0 ? " " : "") + (j >= preText.Length ? "" : preText[j]) + (i == 0 ? "\t" : "");
if (j == 2)
break;
finalText[j] += "[charspacing:8] [charspacing:2]" + (j >= preText.Length ? "" : preText[j]) + (i == 0 ? "\t" : "");
}
}

//Add the text to the text to print then the SetChoice function with its parameters
for (int i = 0; i < finalText.Count; i++) {
Debug.Log(finalText[i]);
if (finalText[i] != "\t")
textMsgChoice.AddToText(finalText[i] + ((i == finalText.Count - 1) ? "" : "\n"));
}
Expand Down

0 comments on commit f60f597

Please sign in to comment.