Skip to content

Commit 7c6f8b1

Browse files
committed
SIGame fixes
#106 Allow to disable apellations #105 Allow to enable download external media option directly from the game screen #103 Prevent from selecting package with size over 100 MB in Online mode #101 Disable question read highlighting ("karaoke") in managed mode Also support html question content. Remove obsolete IsRight and Wrong messages.
1 parent 5e10786 commit 7c6f8b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1188
-466
lines changed

.github/workflows/dotnet.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: .NET
1+
name: Build All
22

33
on:
44
push:

.github/workflows/siquester-release.yml

+10-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: SIQuester release
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version'
8+
required: true
9+
default: '1.0.0'
510

611
jobs:
712
build:
@@ -19,12 +24,12 @@ jobs:
1924
- name: Restore dependencies
2025
run: dotnet restore SIQuester.sln
2126
- name: Publish x86
22-
run: dotnet publish src\SIQuester\SIQuester\SIQuester.csproj -c Release -p:PublishSingleFile=true -r win-x86 --self-contained true -p:EnableCompressionInSingleFile=true /property:Version=5.8.1
27+
run: dotnet publish --no-restore src\SIQuester\SIQuester\SIQuester.csproj -c Release -p:PublishSingleFile=true -r win-x86 --self-contained true -p:EnableCompressionInSingleFile=true /property:Version=${{ github.event.inputs.version }}
2328
- name: Publish x64
24-
run: dotnet publish src\SIQuester\SIQuester\SIQuester.csproj -c Release -p:PublishSingleFile=true -r win-x64 --self-contained true -p:EnableCompressionInSingleFile=true /property:Version=5.8.1
29+
run: dotnet publish --no-restore src\SIQuester\SIQuester\SIQuester.csproj -c Release -p:PublishSingleFile=true -r win-x64 --self-contained true -p:EnableCompressionInSingleFile=true /property:Version=${{ github.event.inputs.version }}
2530
- name: Build MSI x86
26-
run: msbuild deploy\SIQuester.Setup\SIQuester.Setup.wixproj /p:Configuration=Release /p:Platform=x86 /p:OutputPath=../../bin/.Release/SIQuester.Setup/x86 /p:BuildProjectReferences=false /p:MsiProductVersion=5.8.1
31+
run: msbuild deploy\SIQuester.Setup\SIQuester.Setup.wixproj /p:Configuration=Release /p:Platform=x86 /p:OutputPath=../../bin/.Release/SIQuester.Setup/x86 /p:BuildProjectReferences=false /p:MsiProductVersion=${{ github.event.inputs.version }}
2732
- name: Build MSI x64
28-
run: msbuild deploy\SIQuester.Setup\SIQuester.Setup.wixproj /p:Configuration=Release /p:Platform=x64 /p:OutputPath=../../bin/.Release/SIQuester.Setup/x64 /p:BuildProjectReferences=false /p:MsiProductVersion=5.8.1
33+
run: msbuild deploy\SIQuester.Setup\SIQuester.Setup.wixproj /p:Configuration=Release /p:Platform=x64 /p:OutputPath=../../bin/.Release/SIQuester.Setup/x64 /p:BuildProjectReferences=false /p:MsiProductVersion=${{ github.event.inputs.version }}
2934
- name: Build Setup
30-
run: msbuild deploy\SIQuester.Bootstrapper\SIQuester.Bootstrapper.wixproj /p:Configuration=Release /p:OutputPath=../../bin/.Release/SIQuester.Bootstrapper /p:BuildProjectReferences=false /p:MsiProductVersion=5.8.1
35+
run: msbuild deploy\SIQuester.Bootstrapper\SIQuester.Bootstrapper.wixproj /p:Configuration=Release /p:OutputPath=../../bin/.Release/SIQuester.Bootstrapper /p:BuildProjectReferences=false /p:MsiProductVersion=${{ github.event.inputs.version }}

src/Common/SI.GameServer.Client/IGameServerClient.cs

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public interface IGameServerClient : IAsyncDisposable
3232

3333
Task OpenAsync(string userName, CancellationToken token = default);
3434

35+
/// <summary>
36+
/// Gets game server configuration info.
37+
/// </summary>
38+
/// <param name="cancellationToken">Cancellation token.</param>
3539
Task<HostInfo> GetGamesHostInfoAsync(CancellationToken cancellationToken = default);
3640

3741
Task<string> GetNewsAsync(CancellationToken cancellationToken = default);

src/Common/SIEngine/EngineBase.cs

+16
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ public void OnIntroFinished()
172172
public event Action<IMedia, IMedia> QuestionImage;
173173
public event Action<IMedia> QuestionSound;
174174
public event Action<IMedia> QuestionVideo;
175+
public event Action<IMedia> QuestionHtml;
175176
public event Action<Atom> QuestionOther;
176177
public event Action<Question, bool, bool> QuestionProcessed;
177178
public event Action QuestionFinished;
@@ -240,6 +241,8 @@ protected EngineBase(SIDocument document, IEngineSettingsProvider settingsProvid
240241

241242
protected void OnQuestionVideo(IMedia video) => QuestionVideo?.Invoke(video);
242243

244+
protected void OnQuestionHtml(IMedia html) => QuestionHtml?.Invoke(html);
245+
243246
protected void OnQuestionOther(Atom atom) => QuestionOther?.Invoke(atom);
244247

245248
protected void OnQuestionProcessed(Question question, bool finished, bool pressMode) => QuestionProcessed?.Invoke(question, finished, pressMode);
@@ -602,6 +605,19 @@ protected QuestionPlayMode PlayQuestionAtom()
602605
break;
603606
}
604607

608+
case AtomTypes.Html:
609+
var html = GetMedia();
610+
611+
if (html == null)
612+
{
613+
break;
614+
}
615+
616+
OnQuestionHtml(html);
617+
618+
_atomIndex++;
619+
break;
620+
605621
case AtomTypes.Marker:
606622
_atomIndex++;
607623

src/Common/SIPackages/Helpers/ZipHelper.cs

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public static async Task ExtractToDirectoryAsync(
5656
foreach (var entry in archive.Entries)
5757
{
5858
cancellationToken.ThrowIfCancellationRequested();
59-
6059
await ExtractEntryToDirectoryAsync(entry, destinationDirectoryPath, extractedFileNamingMode, cancellationToken);
6160
}
6261
}

src/Common/SIUI.ViewModel/Enums.cs

+12-7
Original file line numberDiff line numberDiff line change
@@ -76,36 +76,41 @@ public enum TableStage
7676
}
7777

7878
/// <summary>
79-
/// Тип содержимого вопроса, отображаемого на табло
79+
/// Defines well-known content types displayed on the table.
8080
/// </summary>
8181
[DataContract]
8282
public enum QuestionContentType
8383
{
8484
/// <summary>
85-
/// Пустое содержимое
85+
/// Empty content.
8686
/// </summary>
8787
[EnumMember]
8888
None,
8989
/// <summary>
90-
/// Текст
90+
/// Text content.
9191
/// </summary>
9292
[EnumMember]
9393
Text,
9494
/// <summary>
95-
/// Изображение
95+
/// Image content.
9696
/// </summary>
9797
[EnumMember]
9898
Image,
9999
/// <summary>
100-
/// Видео
100+
/// Video content.
101101
/// </summary>
102102
[EnumMember]
103103
Video,
104104
/// <summary>
105-
/// Специальный текст
105+
/// Special text content.
106106
/// </summary>
107107
[EnumMember]
108-
SpecialText
108+
SpecialText,
109+
/// <summary>
110+
/// Html content.
111+
/// </summary>
112+
[EnumMember]
113+
Html
109114
}
110115

111116
/// <summary>

src/Common/SIUI.ViewModel/TableInfoViewModel.cs

+34-12
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace SIUI.ViewModel
99
{
1010
/// <summary>
11-
/// Информация для табло
11+
/// Defines game table view model.
1212
/// </summary>
1313
public sealed class TableInfoViewModel : ViewModelBase<TableInfo>
1414
{
@@ -17,22 +17,37 @@ public sealed class TableInfoViewModel : ViewModelBase<TableInfo>
1717
private TableStage _tStage = TableStage.Void;
1818

1919
/// <summary>
20-
/// Текущее состояние табло
20+
/// Current table stage.
2121
/// </summary>
2222
public TableStage TStage
2323
{
24-
get { return _tStage; }
25-
set { if (_tStage != value) { _tStage = value; OnPropertyChanged(); } }
24+
get => _tStage;
25+
set
26+
{
27+
if (_tStage != value)
28+
{
29+
_tStage = value;
30+
31+
try
32+
{
33+
OnPropertyChanged();
34+
}
35+
catch (NotImplementedException exc) when (exc.Message.Contains("The Source property cannot be set to null"))
36+
{
37+
// https://github.com/MicrosoftEdge/WebView2Feedback/issues/1136
38+
}
39+
}
40+
}
2641
}
2742

2843
public object TStageLock { get; } = new object();
2944

3045
/// <summary>
31-
/// Пауза в игре
46+
/// Is game paused.
3247
/// </summary>
3348
public bool Pause
3449
{
35-
get { return _model.Pause; }
50+
get => _model.Pause;
3651
set
3752
{
3853
if (_model.Pause != value)
@@ -48,7 +63,7 @@ public bool Pause
4863

4964
public bool IsMediaStopped
5065
{
51-
get { return _isMediaStopped; }
66+
get => _isMediaStopped;
5267
set
5368
{
5469
if (_isMediaStopped != value)
@@ -78,7 +93,7 @@ private void UpdateMediaState()
7893
/// </summary>
7994
public string Text
8095
{
81-
get { return _text; }
96+
get => _text;
8297
set { if (_text != value) { _text = value; OnPropertyChanged(); } }
8398
}
8499

@@ -90,7 +105,7 @@ public string Text
90105
/// </summary>
91106
public int TextLength
92107
{
93-
get { return _textLength; }
108+
get => _textLength;
94109
set { if (_textLength != value) { _textLength = value; OnPropertyChanged(); } }
95110
}
96111

@@ -137,12 +152,19 @@ public bool AnimateText
137152
private double _textSpeed = 0.05;
138153

139154
/// <summary>
140-
/// Скорость чтения текста
155+
/// Text reading speed (chars / second). Zero speed disables the reading.
141156
/// </summary>
142157
public double TextSpeed
143158
{
144-
get { return _textSpeed; }
145-
set { _textSpeed = value; OnPropertyChanged(); }
159+
get => _textSpeed;
160+
set
161+
{
162+
if (_textSpeed != value && _textSpeed >= 0.0)
163+
{
164+
_textSpeed = value;
165+
OnPropertyChanged();
166+
}
167+
}
146168
}
147169

148170
private double _timeLeft = 1.0;

src/Common/SIUI/Behaviors/QuestionReading.cs

+23-22
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@
88

99
namespace SIUI.Behaviors
1010
{
11+
/// <summary>
12+
/// Enables text reading effects ("karaoke").
13+
/// </summary>
1114
public static class QuestionReading
1215
{
13-
public static bool GetIsAttached(DependencyObject obj)
14-
{
15-
return (bool)obj.GetValue(IsAttachedProperty);
16-
}
16+
public static bool GetIsAttached(DependencyObject obj) => (bool)obj.GetValue(IsAttachedProperty);
1717

18-
public static void SetIsAttached(DependencyObject obj, bool value)
19-
{
20-
obj.SetValue(IsAttachedProperty, value);
21-
}
18+
public static void SetIsAttached(DependencyObject obj, bool value) => obj.SetValue(IsAttachedProperty, value);
2219

2320
// Using a DependencyProperty as the backing store for IsAttached. This enables animation, styling, binding, etc...
2421
public static readonly DependencyProperty IsAttachedProperty =
@@ -29,6 +26,11 @@ public static void OnIsAttachedChanged(DependencyObject d, DependencyPropertyCha
2926
var textBlock = (TextBlock)d;
3027
var tableInfoViewModel = (TableInfoViewModel)textBlock.DataContext;
3128

29+
if (tableInfoViewModel.TextSpeed < double.Epsilon)
30+
{
31+
return;
32+
}
33+
3234
textBlock.Loaded += (sender, e2) =>
3335
{
3436
textBlock.TextEffects[0].BeginAnimation(
@@ -41,28 +43,32 @@ public static void OnIsAttachedChanged(DependencyObject d, DependencyPropertyCha
4143
};
4244
}
4345

44-
public static bool GetIsAttachedPartial(DependencyObject obj)
45-
{
46-
return (bool)obj.GetValue(IsAttachedPartialProperty);
47-
}
46+
public static bool GetIsAttachedPartial(DependencyObject obj) => (bool)obj.GetValue(IsAttachedPartialProperty);
4847

49-
public static void SetIsAttachedPartial(DependencyObject obj, bool value)
50-
{
51-
obj.SetValue(IsAttachedPartialProperty, value);
52-
}
48+
public static void SetIsAttachedPartial(DependencyObject obj, bool value) => obj.SetValue(IsAttachedPartialProperty, value);
5349

5450
// Using a DependencyProperty as the backing store for IsAttachedPartial. This enables animation, styling, binding, etc...
5551
public static readonly DependencyProperty IsAttachedPartialProperty =
5652
DependencyProperty.RegisterAttached("IsAttachedPartial", typeof(bool), typeof(QuestionReading), new PropertyMetadata(false, OnIsAttachedPartialChanged));
5753

5854
// Пока сделано синглтоном
59-
public static int CurrentTarget;
55+
private static int CurrentTarget;
6056

6157
public static void OnIsAttachedPartialChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
6258
{
6359
var textBlock = (TextBlock)d;
6460
var tableInfoViewModel = (TableInfoViewModel)textBlock.DataContext;
6561

62+
if (!(bool)e.NewValue)
63+
{
64+
return;
65+
}
66+
67+
if (tableInfoViewModel.TextSpeed < double.Epsilon)
68+
{
69+
return;
70+
}
71+
6672
void handler(object sender, PropertyChangedEventArgs e2)
6773
{
6874
if (e2.PropertyName == nameof(TableInfoViewModel.TextLength))
@@ -71,11 +77,6 @@ void handler(object sender, PropertyChangedEventArgs e2)
7177
}
7278
}
7379

74-
if (!(bool)e.NewValue)
75-
{
76-
return;
77-
}
78-
7980
tableInfoViewModel.PropertyChanged += handler;
8081

8182
textBlock.Loaded += (sender, e2) =>

src/Common/SIUI/SIUI.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<Resource Include="Fonts\Clefs.ttf" />
3232
<Resource Include="Fonts\DINCondensedC.ttf" />
3333
<None Include="key.snk" />
34+
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1343.22" />
3435
<Compile Update="Properties\Resources.Designer.cs">
3536
<DesignTime>True</DesignTime>
3637
<AutoGen>True</AutoGen>

src/Common/SIUI/Table.xaml

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
xmlns:locals="clr-namespace:SIUI.Selectors"
1313
xmlns:vm="clr-namespace:SIUI.ViewModel;assembly=SIUI.ViewModel"
1414
xmlns:sys="clr-namespace:System;assembly=mscorlib"
15+
xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
1516
mc:Ignorable="d"
1617
DataContextChanged="UserControl_DataContextChanged"
1718
d:DesignHeight="300"
@@ -353,19 +354,27 @@
353354
FontFamily="pack://application:,,,/SIUI;component/Fonts/#Clefs" />
354355
</ContentControl>
355356
</DataTemplate>
357+
356358
<DataTemplate x:Key="{x:Static vm:QuestionContentType.Text}">
357359
<ContentControl Content="{Binding}" ContentTemplateSelector="{StaticResource QuestionTextSelector}" />
358360
</DataTemplate>
361+
359362
<DataTemplate x:Key="{x:Static vm:QuestionContentType.Image}">
360363
<Image
361364
Name="image"
362365
Stretch="Uniform"
363366
Source="{Binding MediaSource.Uri, Converter={StaticResource UriConverter}}"
364367
lb:ImageController.IsAttached="True" />
365368
</DataTemplate>
369+
366370
<DataTemplate x:Key="{x:Static vm:QuestionContentType.Video}">
367371
<MediaElement Source="{Binding MediaSource.Uri}" Stretch="Uniform" lb:MediaController.IsAttached="True" />
368372
</DataTemplate>
373+
374+
<DataTemplate x:Key="{x:Static vm:QuestionContentType.Html}">
375+
<wv2:WebView2 Source="{Binding MediaSource.Uri}" />
376+
</DataTemplate>
377+
369378
<DataTemplate x:Key="{x:Static vm:QuestionContentType.SpecialText}">
370379
<TextBlock
371380
Text="{Binding Text}"

src/Common/Utils/Utils.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<Description>SIGame utils</Description>
1010
<SignAssembly>True</SignAssembly>
1111
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
12+
<Nullable>enable</Nullable>
1213
</PropertyGroup>
1314

1415
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">

0 commit comments

Comments
 (0)