Skip to content

Commit

Permalink
Options are shown before question when false starts are disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirKhil committed Dec 22, 2023
1 parent f96b282 commit d1695a8
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/Common/SIEngine.Core/FalseStartHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public static class FalseStartHelper
/// </summary>
/// <param name="script">Question script.</param>
/// <param name="parameters">Question parameters.</param>
/// <param name="falseStartMode"></param>
/// <returns></returns>
/// <param name="falseStartMode">False start mode.</param>
/// <returns>Index of first step that should allow button press.</returns>
public static int? GetAskAnswerStartIndex(
Script script,
StepParameters? parameters,
Expand Down
2 changes: 1 addition & 1 deletion src/Common/SIEngine.Core/IQuestionEnginePlayHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface IQuestionEnginePlayHandler
/// <summary>
/// Allows to press the button.
/// </summary>
void OnButtonPressStart();
bool OnButtonPressStart();

/// <summary>
/// Sets question answerer(s).
Expand Down
6 changes: 5 additions & 1 deletion src/Common/SIEngine.Core/QuestionEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,11 @@ public bool PlayNext()
case StepTypes.ShowContent:
if (_stepIndex == _askAnswerStartIndex)
{
_playHandler.OnButtonPressStart();
if (_playHandler.OnButtonPressStart())
{
return true;
}

_askAnswerStartIndex = null;
}

Expand Down
8 changes: 4 additions & 4 deletions src/Common/SIUI/Table.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@
</Setter>

<Style.Triggers>
<DataTrigger Binding="{Binding DataContext.AnimateText, RelativeSource={RelativeSource AncestorType=ItemsControl}}" Value="True">
<DataTrigger Binding="{Binding DataContext.AnimateText, RelativeSource={RelativeSource AncestorType=ItemsControl, AncestorLevel=2}}" Value="True">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate DataType="{x:Type vm:ContentViewModel}">
Expand All @@ -515,7 +515,7 @@
</Setter>
</DataTrigger>

<DataTrigger Binding="{Binding DataContext.PartialText, RelativeSource={RelativeSource AncestorType=ItemsControl}}" Value="True">
<DataTrigger Binding="{Binding DataContext.PartialText, RelativeSource={RelativeSource AncestorType=ItemsControl, AncestorLevel=2}}" Value="True">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate DataType="{x:Type vm:ContentViewModel}">
Expand Down Expand Up @@ -557,14 +557,14 @@
Name="image"
Stretch="Uniform"
Source="{Binding Value, Converter={StaticResource UriConverter}}"
lb:ImageController.LoadHandler="{Binding DataContext, RelativeSource={RelativeSource AncestorType=ItemsControl}}" />
lb:ImageController.LoadHandler="{Binding DataContext, RelativeSource={RelativeSource AncestorType=ItemsControl, AncestorLevel=2}}" />
</DataTemplate>

<DataTemplate x:Key="{x:Static vm:ContentType.Video}">
<MediaElement
Source="{Binding Value}"
Stretch="Uniform"
lb:MediaController.LoadHandler="{Binding DataContext, RelativeSource={RelativeSource AncestorType=ItemsControl}}" />
lb:MediaController.LoadHandler="{Binding DataContext, RelativeSource={RelativeSource AncestorType=ItemsControl, AncestorLevel=2}}" />
</DataTemplate>

<DataTemplate x:Key="{x:Static vm:ContentType.Html}">
Expand Down
2 changes: 1 addition & 1 deletion src/SICore/SICore/Clients/Game/GameLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4712,7 +4712,7 @@ internal void OnAnswerOptions(bool questionHasScreenContent, AnswerOption[] answ
_gameActions.SendMessage(messageBuilder.ToString());
}

internal void ShowAnswerOptions(Action continuation)
internal void ShowAnswerOptions(Action? continuation)
{
if (ClientData.QuestionPlayState.AnswerOptions == null)
{
Expand Down
21 changes: 18 additions & 3 deletions src/SICore/SICore/Clients/Game/QuestionPlayHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,30 @@ public void OnAskAnswerStop()
GameData.IsPlayingMedia = false;
}

public void OnButtonPressStart()
public bool OnButtonPressStart()
{
if (GameLogic == null || GameData == null)
{
return;
return false;
}

// TODO: merge somehow with GameLogic.AskToPress() and OnAskAnswer() for buttons
if (GameData.QuestionPlayState.AnswerOptions != null && !GameData.QuestionPlayState.LayoutShown)
{
GameLogic.OnAnswerOptions(false, GameData.QuestionPlayState.AnswerOptions);
GameData.QuestionPlayState.LayoutShown = true;
}

if (GameData.QuestionPlayState.AnswerOptions != null && !GameData.QuestionPlayState.AnswerOptionsShown)
{
GameLogic.ShowAnswerOptions(null);
GameData.QuestionPlayState.AnswerOptionsShown = true;
return true;
}

GameData.AnswerMode = StepParameterValues.AskAnswerMode_Button;
GameLogic.OnButtonPressStart(); // TODO: merge somehow with GameLogic.AskToPress()
GameLogic.OnButtonPressStart();
return false;
}

public void OnContentStart(IEnumerable<ContentItem> contentItems)
Expand Down
1 change: 1 addition & 0 deletions src/SICore/SICore/Clients/Viewer/ViewerHumanLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1772,5 +1772,6 @@ public void OnAnswerOptions(bool questionHasScreenContent, IEnumerable<string> o
{
TInfo.AnswerOptions.Options = optionsTypes.Select(i => new ItemViewModel()).ToArray();
TInfo.LayoutMode = LayoutMode.AnswerOptions;
TInfo.TStage = TableStage.Question;
}
}
5 changes: 1 addition & 4 deletions test/Common/SIEngine.Tests/QuestionEnginePlayHandlerMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ public void OnAskAnswerStop()

}

public void OnButtonPressStart()
{
throw new NotImplementedException();
}
public bool OnButtonPressStart() => false;

public void OnContentStart(IEnumerable<ContentItem> contentItems)
{
Expand Down

0 comments on commit d1695a8

Please sign in to comment.