summaryrefslogtreecommitdiff
path: root/Impostor-dev/src/Impostor.Plugins.Debugger
diff options
context:
space:
mode:
Diffstat (limited to 'Impostor-dev/src/Impostor.Plugins.Debugger')
-rw-r--r--Impostor-dev/src/Impostor.Plugins.Debugger/App.razor10
-rw-r--r--Impostor-dev/src/Impostor.Plugins.Debugger/DebugPlugin.cs13
-rw-r--r--Impostor-dev/src/Impostor.Plugins.Debugger/DebugPluginStartup.cs35
-rw-r--r--Impostor-dev/src/Impostor.Plugins.Debugger/Impostor.Plugins.Debugger.csproj16
-rw-r--r--Impostor-dev/src/Impostor.Plugins.Debugger/Pages/Index.razor69
-rw-r--r--Impostor-dev/src/Impostor.Plugins.Debugger/Pages/_Host.cshtml19
-rw-r--r--Impostor-dev/src/Impostor.Plugins.Debugger/Shared/MainLayout.razor5
-rw-r--r--Impostor-dev/src/Impostor.Plugins.Debugger/_Imports.razor8
8 files changed, 175 insertions, 0 deletions
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 @@
+<Router AppAssembly="@typeof(DebugPlugin).Assembly">
+ <Found Context="routeData">
+ <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
+ </Found>
+ <NotFound>
+ <LayoutView Layout="@typeof(MainLayout)">
+ <p>Sorry, there's nothing at this address.</p>
+ </LayoutView>
+ </NotFound>
+</Router> \ 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 @@
+<Project Sdk="Microsoft.NET.Sdk.Web">
+
+ <PropertyGroup>
+ <TargetFramework>net5.0</TargetFramework>
+ <OutputType>Library</OutputType>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\Impostor.Api\Impostor.Api.csproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <Folder Include="Properties\" />
+ </ItemGroup>
+
+</Project> \ 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
+
+<div class="container">
+ <h2>Games</h2>
+ @if (GameManager.Games.Any())
+ {
+ <table class="table table-striped">
+ <thead>
+ <tr>
+ <th>Code</th>
+ <th>Players</th>
+ </tr>
+ </thead>
+ <tbody>
+ @foreach (var game in GameManager.Games)
+ {
+ <tr>
+ <td>@game.Code</td>
+ <td>
+ <ul class="mb-0">
+ @foreach (var player in game.Players)
+ {
+ <li>@player.Client.Name</li>
+ }
+ </ul>
+ </td>
+ </tr>
+ }
+ </tbody>
+ </table>
+ }
+ else
+ {
+ <div class="text-center">
+ <i class="text-muted">There are no active games.</i>
+ </div>
+ }
+</div>
+
+@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
+
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+ <title>Impostor Debugger</title>
+ <base href="~/"/>
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
+</head>
+<body>
+<component type="typeof(App)" render-mode="Server"/>
+
+<script src="_framework/blazor.server.js"></script>
+</body>
+</html> \ 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
+
+<div class="page">
+ @Body
+</div> \ 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