Skip to content

Commit 7184ddd

Browse files
authored
Merge pull request #160 from Hazeolation/feature/152-add-show-hide-buttons-for-comm-box
Feature/152 Add show and hide buttons for commentator box controls
2 parents 891893f + 67dad05 commit 7184ddd

41 files changed

Lines changed: 1216 additions & 196 deletions

Some content is hidden

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

Backend/DSB.StreamBackend/Context/StreamToolDbContext.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Microsoft.EntityFrameworkCore;
22
using DSB.StreamBackend.Models;
3+
using DSB.StreamBackend.Enums;
34

45
namespace DSB.StreamBackend.Context;
56

@@ -42,12 +43,35 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
4243
modelBuilder.Entity<MapStateEntity>()
4344
.HasKey(x => x.Id);
4445

46+
modelBuilder.Entity<SocialsEntity>()
47+
.HasKey(x => x.Id);
48+
49+
modelBuilder.Entity<CommentatorBoxTimeDataEntity>()
50+
.HasKey(x => x.Id);
51+
4552
modelBuilder.Entity<BroadcastStateEntity>()
4653
.HasMany(x => x.Maps)
4754
.WithOne(x => x.BroadcastState)
4855
.HasForeignKey(x => x.BroadcastStateEntityId)
4956
.OnDelete(DeleteBehavior.Cascade);
5057

58+
modelBuilder.Entity<SocialsEntity>()
59+
.HasData(new SocialsEntity
60+
{
61+
Id = 1,
62+
XHandle = string.Empty,
63+
DiscordInvite = string.Empty
64+
});
65+
66+
modelBuilder.Entity<CommentatorBoxTimeDataEntity>()
67+
.HasData(new CommentatorBoxTimeDataEntity
68+
{
69+
Id = 1,
70+
ShowDisplayIntervalInSeconds = 50,
71+
HideDisplayIntervalInSeconds = 5,
72+
DisplayMode = (int)CommBoxDisplayMode.Manual
73+
});
74+
5175
modelBuilder.Entity<BroadcastStateEntity>()
5276
.HasData(new BroadcastStateEntity
5377
{

Backend/DSB.StreamBackend/Dtos/CommentatorBoxTimeDataDto.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using DSB.StreamBackend.Enums;
2+
13
namespace DSB.StreamBackend.Dtos;
24

35
/// <summary>
@@ -9,14 +11,21 @@ public class CommentatorBoxTimeDataDto
911
/// Gets or sets the single identifier for the commentator box time data
1012
/// </summary>
1113
public int Id { get; set; } = 1;
12-
14+
1315
/// <summary>
14-
/// Gets or sets the time in seconds that the display should be visible
16+
/// Gets or sets the time in seconds that sets when the display should be visible again
1517
/// </summary>
1618
public int ShowDisplayIntervalInSeconds { get; set; } = 0;
1719

1820
/// <summary>
19-
/// Gets or sets the time in seconds that the display should be hidden
21+
/// Gets or sets the time in seconds that sets when the display should be hidden again
2022
/// </summary>
2123
public int HideDisplayIntervalInSeconds { get; set; } = 0;
24+
25+
/// <summary>
26+
/// Gets or sets the display mode in which the blending in and out happens
27+
/// 0 - Manual, the streamer has to click a button when the comm box should appear and disappear
28+
/// 1 - Automatic, the streamer can set two input time values and the comm box handles the blending automatically
29+
/// </summary>
30+
public int DisplayMode { get; set; } = (int)CommBoxDisplayMode.Manual;
2231
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace DSB.StreamBackend.Enums;
2+
3+
public enum CommBoxDisplayMode
4+
{
5+
Manual,
6+
Automatic
7+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using Microsoft.AspNetCore.SignalR;
2+
3+
namespace DSB.StreamBackend.Hubs;
4+
5+
/// <summary>
6+
/// A SignalR hub for event clients.
7+
/// </summary>
8+
/// <remarks>
9+
/// This hub provides a communication channel for streaming event clients
10+
/// to receive real-time updates from the backend.
11+
/// </remarks>
12+
public class EventHub : Hub<IEventClient>
13+
{
14+
/// <summary>
15+
/// Notifies all clients of a commentator box hide event when it gets invoked from the client
16+
/// </summary>
17+
public async Task CommBoxHideButtonClicked()
18+
{
19+
await Clients.All.CommBoxHideButtonClicked();
20+
}
21+
22+
/// <summary>
23+
/// Notifies all clients of a commentator box show event when it gets invoked from the client
24+
/// </summary>
25+
public async Task CommBoxShowButtonClicked()
26+
{
27+
await Clients.All.CommBoxShowButtonClicked();
28+
}
29+
30+
/// <summary>
31+
/// Notifies all clients of a commentator box show temp event when it gets invoked from the client
32+
/// </summary>
33+
public async Task CommBoxShowTempButtonClicked()
34+
{
35+
await Clients.All.CommBoxShowTempButtonClicked();
36+
}
37+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace DSB.StreamBackend.Hubs;
2+
3+
/// <summary>
4+
/// Defines client-side event callbacks that can be invoked from the server.
5+
/// </summary>
6+
public interface IEventClient
7+
{
8+
/// <summary>
9+
/// Sends the button click event that hides the commentator box to connected event clients.
10+
/// </summary>
11+
Task CommBoxHideButtonClicked();
12+
13+
/// <summary>
14+
/// Sends the button click event that shows the commentator box to connected event clients.
15+
/// </summary>
16+
Task CommBoxShowButtonClicked();
17+
18+
/// <summary>
19+
/// Sends the button click event that shows the commentator box temporarily to connected event clients.
20+
/// </summary>
21+
Task CommBoxShowTempButtonClicked();
22+
}

Backend/DSB.StreamBackend/Migrations/20260620151217_AddWeek.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ protected override void Up(MigrationBuilder migrationBuilder)
3131
table.PrimaryKey("PK_Socials", x => x.Id);
3232
});
3333

34+
migrationBuilder.InsertData(
35+
table: "Socials",
36+
columns: new[] { "Id", "XHandle", "DiscordInvite" },
37+
values: new object[] { 1, string.Empty, string.Empty }
38+
);
39+
3440
migrationBuilder.UpdateData(
3541
table: "BroadcastStates",
3642
keyColumn: "Id",

Backend/DSB.StreamBackend/Migrations/20260623051911_AddCommentatorBoxTimeData.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ protected override void Up(MigrationBuilder migrationBuilder)
2323
{
2424
table.PrimaryKey("PK_CommentatorBoxTimeData", x => x.Id);
2525
});
26+
27+
migrationBuilder.InsertData(
28+
table: "CommentatorBoxTimeData",
29+
columns: new[] { "Id", "ShowDisplayIntervalInSeconds", "HideDisplayIntervalInSeconds" },
30+
values: new object[] { 1, 5, 50 }
31+
);
2632
}
2733

2834
/// <inheritdoc />

Backend/DSB.StreamBackend/Migrations/20260703144744_addTimeDataDisplayMode.Designer.cs

Lines changed: 210 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)