Add Dynamic Game Page Generation
This commit is contained in:
parent
253dccb25b
commit
2c42c46033
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NotPogo.Model;
|
||||
using System.IO.Compression;
|
||||
using System.Net;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
@ -16,17 +17,39 @@ namespace NotPogo.Controllers
|
||||
// might aswell provide a minimal way to play the games supported
|
||||
[HttpGet]
|
||||
[Route("/play-game")]
|
||||
public IActionResult GetGamePage(string game)
|
||||
public IActionResult GamePage(string? name,
|
||||
string game,
|
||||
string appletClass,
|
||||
string site,
|
||||
string locale,
|
||||
string hostedGameClass)
|
||||
{
|
||||
var path = Path.Combine(AppContext.BaseDirectory, "StaticFiles", "GameAssets", game, "index.html");
|
||||
|
||||
_logger.LogInformation("Attempting To Serve Game Applet At {Path}", path);
|
||||
return new ContentResult
|
||||
var gamePage = new GamePage
|
||||
{
|
||||
Content = System.IO.File.Exists(path) ? System.IO.File.ReadAllText(path) : $"Game Not Found - {game}",
|
||||
ContentType = "text/html",
|
||||
StatusCode = (int)HttpStatusCode.OK
|
||||
GameName = name ?? game,
|
||||
InternalName = game,
|
||||
JavaAppletClass = appletClass,
|
||||
JavaAppletParameters = new()
|
||||
{
|
||||
{ "name", game },
|
||||
{ "hosted.game.class", hostedGameClass },
|
||||
{ "standalone", "false" },
|
||||
{ "type", game },
|
||||
{ "config", $"client-props.jsp?game={game}" },
|
||||
{ "locale", locale },
|
||||
{ "site", site },
|
||||
{ "rkey", "" },
|
||||
{ "unid", "" },
|
||||
{ "sourceid", "" },
|
||||
{ "launchPage", "" },
|
||||
{ "lkey", "" },
|
||||
{ "cnid", "" },
|
||||
{ "isSingleApplet", "true" },
|
||||
{ "browserInfo", "" }
|
||||
}
|
||||
};
|
||||
|
||||
return View(gamePage);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
|
||||
12
Model/GamePage.cs
Normal file
12
Model/GamePage.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace NotPogo.Model
|
||||
{
|
||||
public class GamePage : PageModel
|
||||
{
|
||||
public string GameName { get; set; } = string.Empty;
|
||||
public string InternalName { get; set; } = string.Empty;
|
||||
public string JavaAppletClass { get; set; } = string.Empty;
|
||||
public Dictionary<string, string> JavaAppletParameters { get; set; } = [];
|
||||
}
|
||||
}
|
||||
22
Views/Shared/GamePage.cshtml
Normal file
22
Views/Shared/GamePage.cshtml
Normal file
@ -0,0 +1,22 @@
|
||||
@model NotPogo.Model.GamePage
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>@($"Not Pogo - {Model.GameName}")</title>
|
||||
</head>
|
||||
|
||||
<body style="margin:0; padding:0;">
|
||||
<applet code="@Model.JavaAppletClass"
|
||||
codebase="@($"{Context.Request.Scheme}://{Context.Request.Host.Value}")"
|
||||
archive="@($"{Context.Request.Scheme}://{Context.Request.Host.Value}/get-jar?game={Model.InternalName}")"
|
||||
width="784" height="506">
|
||||
|
||||
@foreach (var kv in Model.JavaAppletParameters)
|
||||
{
|
||||
<param name="@kv.Key" value="@kv.Value">
|
||||
}
|
||||
Unfortunately, In Order To Use Not Pogo, You Need To Use A Browser That Still Supports Java Applets
|
||||
</applet>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user