From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- .../src/Impostor.Plugins.Debugger/App.razor | 10 ++++ .../src/Impostor.Plugins.Debugger/DebugPlugin.cs | 13 ++++ .../DebugPluginStartup.cs | 35 +++++++++++ .../Impostor.Plugins.Debugger.csproj | 16 +++++ .../Impostor.Plugins.Debugger/Pages/Index.razor | 69 ++++++++++++++++++++++ .../Impostor.Plugins.Debugger/Pages/_Host.cshtml | 19 ++++++ .../Shared/MainLayout.razor | 5 ++ .../src/Impostor.Plugins.Debugger/_Imports.razor | 8 +++ 8 files changed, 175 insertions(+) create mode 100644 Impostor-dev/src/Impostor.Plugins.Debugger/App.razor create mode 100644 Impostor-dev/src/Impostor.Plugins.Debugger/DebugPlugin.cs create mode 100644 Impostor-dev/src/Impostor.Plugins.Debugger/DebugPluginStartup.cs create mode 100644 Impostor-dev/src/Impostor.Plugins.Debugger/Impostor.Plugins.Debugger.csproj create mode 100644 Impostor-dev/src/Impostor.Plugins.Debugger/Pages/Index.razor create mode 100644 Impostor-dev/src/Impostor.Plugins.Debugger/Pages/_Host.cshtml create mode 100644 Impostor-dev/src/Impostor.Plugins.Debugger/Shared/MainLayout.razor create mode 100644 Impostor-dev/src/Impostor.Plugins.Debugger/_Imports.razor (limited to 'Impostor-dev/src/Impostor.Plugins.Debugger') diff --git a/Impostor-dev/src/Impostor.Plugins.Debugger/App.razor b/Impostor-dev/src/Impostor.Plugins.Debugger/App.razor new file mode 100644 index 0000000..38e8633 --- /dev/null +++ b/Impostor-dev/src/Impostor.Plugins.Debugger/App.razor @@ -0,0 +1,10 @@ + + + + + + +

Sorry, there's nothing at this address.

+
+
+
\ No newline at end of file diff --git a/Impostor-dev/src/Impostor.Plugins.Debugger/DebugPlugin.cs b/Impostor-dev/src/Impostor.Plugins.Debugger/DebugPlugin.cs new file mode 100644 index 0000000..8f57e89 --- /dev/null +++ b/Impostor-dev/src/Impostor.Plugins.Debugger/DebugPlugin.cs @@ -0,0 +1,13 @@ +using Impostor.Api.Plugins; + +namespace Impostor.Plugins.Debugger +{ + [ImpostorPlugin( + package: "gg.impostor.debugger", + name: "Debugger", + author: "Gerard", + version: "1.0.0")] + public class DebugPlugin : PluginBase + { + } +} \ No newline at end of file diff --git a/Impostor-dev/src/Impostor.Plugins.Debugger/DebugPluginStartup.cs b/Impostor-dev/src/Impostor.Plugins.Debugger/DebugPluginStartup.cs new file mode 100644 index 0000000..cc36ce6 --- /dev/null +++ b/Impostor-dev/src/Impostor.Plugins.Debugger/DebugPluginStartup.cs @@ -0,0 +1,35 @@ +using Impostor.Api.Plugins; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Impostor.Plugins.Debugger +{ + public class DebugPluginStartup : IPluginStartup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddRazorPages(); + services.AddServerSideBlazor(); + } + + public void ConfigureHost(IHostBuilder host) + { + host.ConfigureWebHostDefaults(webBuilder => + { + webBuilder.Configure(app => + { + app.UseStaticFiles(); + app.UseRouting(); + + app.UseEndpoints(endpoints => + { + endpoints.MapBlazorHub(); + endpoints.MapFallbackToPage("/_Host"); + }); + }); + }); + } + } +} \ No newline at end of file diff --git a/Impostor-dev/src/Impostor.Plugins.Debugger/Impostor.Plugins.Debugger.csproj b/Impostor-dev/src/Impostor.Plugins.Debugger/Impostor.Plugins.Debugger.csproj new file mode 100644 index 0000000..9518e48 --- /dev/null +++ b/Impostor-dev/src/Impostor.Plugins.Debugger/Impostor.Plugins.Debugger.csproj @@ -0,0 +1,16 @@ + + + + net5.0 + Library + + + + + + + + + + + \ No newline at end of file diff --git a/Impostor-dev/src/Impostor.Plugins.Debugger/Pages/Index.razor b/Impostor-dev/src/Impostor.Plugins.Debugger/Pages/Index.razor new file mode 100644 index 0000000..1bfa478 --- /dev/null +++ b/Impostor-dev/src/Impostor.Plugins.Debugger/Pages/Index.razor @@ -0,0 +1,69 @@ +@page "/" +@implements IDisposable +@using Impostor.Api.Events.Managers +@using Impostor.Api.Games.Managers +@using Impostor.Api.Events +@using Impostor.Api.Events.Player +@implements Impostor.Api.Events.IEventListener +@inject IEventManager EventManager +@inject IGameManager GameManager + +
+

Games

+ @if (GameManager.Games.Any()) + { + + + + + + + + + @foreach (var game in GameManager.Games) + { + + + + + } + +
CodePlayers
@game.Code +
    + @foreach (var player in game.Players) + { +
  • @player.Client.Name
  • + } +
+
+ } + else + { +
+ There are no active games. +
+ } +
+ +@code { + private IDisposable _disposable; + + [EventListener(typeof(IGameCreatedEvent))] + [EventListener(typeof(IGameDestroyedEvent))] + [EventListener(typeof(IGamePlayerJoinedEvent))] + [EventListener(typeof(IGamePlayerLeftEvent))] + public void OnGameCreated(IGameEvent e) + { + StateHasChanged(); + } + + protected override void OnInitialized() + { + _disposable = EventManager.RegisterListener(this, InvokeAsync); + } + + public void Dispose() + { + _disposable?.Dispose(); + } +} \ No newline at end of file diff --git a/Impostor-dev/src/Impostor.Plugins.Debugger/Pages/_Host.cshtml b/Impostor-dev/src/Impostor.Plugins.Debugger/Pages/_Host.cshtml new file mode 100644 index 0000000..eed3aaf --- /dev/null +++ b/Impostor-dev/src/Impostor.Plugins.Debugger/Pages/_Host.cshtml @@ -0,0 +1,19 @@ +@page "/" +@namespace Impostor.Plugins.Debugger.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers + + + + + + + Impostor Debugger + + + + + + + + + \ No newline at end of file diff --git a/Impostor-dev/src/Impostor.Plugins.Debugger/Shared/MainLayout.razor b/Impostor-dev/src/Impostor.Plugins.Debugger/Shared/MainLayout.razor new file mode 100644 index 0000000..07da9d6 --- /dev/null +++ b/Impostor-dev/src/Impostor.Plugins.Debugger/Shared/MainLayout.razor @@ -0,0 +1,5 @@ +@inherits LayoutComponentBase + +
+ @Body +
\ No newline at end of file diff --git a/Impostor-dev/src/Impostor.Plugins.Debugger/_Imports.razor b/Impostor-dev/src/Impostor.Plugins.Debugger/_Imports.razor new file mode 100644 index 0000000..109ec4e --- /dev/null +++ b/Impostor-dev/src/Impostor.Plugins.Debugger/_Imports.razor @@ -0,0 +1,8 @@ +@using System.Net.Http +@using Microsoft.AspNetCore.Authorization +@using Microsoft.AspNetCore.Components.Authorization +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using Microsoft.JSInterop +@using Impostor.Plugins.Debugger.Shared \ No newline at end of file -- cgit v1.1-26-g67d0