Skip to content

Commit

Permalink
Include index on choice instances for convenience
Browse files Browse the repository at this point in the history
  • Loading branch information
joethephish committed Mar 2, 2016
1 parent a79d9ce commit fb8388d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions ink-engine-runtime/ChoiceInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public class ChoiceInstance : Runtime.Object
{
public string choiceText { get; set; }
public string pathStringOnChoice { get { return choice.pathStringOnChoice; } }
public int choiceIndex { get; set; }

internal Choice choice { get; private set; }
internal bool hasBeenChosen { get; set; }
Expand Down
11 changes: 9 additions & 2 deletions ink-engine-runtime/Story.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ public List<ChoiceInstance> currentChoices
get
{
// Don't include invisible choices for external usage.
return _state.currentChoices.Where (c => !c.choice.isInvisibleDefault).ToList ();
var choices = new List<ChoiceInstance>();
foreach (var c in _state.currentChoices) {
if (!c.choice.isInvisibleDefault) {
c.choiceIndex = choices.Count;
choices.Add (c);
}
}
return choices;
}
}

Expand Down Expand Up @@ -579,7 +586,7 @@ bool PerformLogicAndFlowControl(Runtime.Object contentObj)
if (state.callStack.currentElement.type != pop.type || !state.callStack.canPop) {

var names = new Dictionary<PushPopType, string> ();
names [PushPopType.Function] = "function return statement (~ ~ ~)";
names [PushPopType.Function] = "function return statement (~ return)";
names [PushPopType.Tunnel] = "tunnel onwards statement (->->)";

string expected = names [state.callStack.currentElement.type];
Expand Down

0 comments on commit fb8388d

Please sign in to comment.