shoko/Protocols/AboutProtoHandler.cs

97 lines
2.8 KiB
C#
Raw Normal View History

2023-10-02 18:49:24 +00:00
using System.Reflection;
using System.Text;
2023-10-02 22:13:48 +00:00
using System.Web;
2023-10-02 18:49:24 +00:00
using ImGuiNET;
using Raylib_cs;
namespace Shoko;
[Protocol("about")]
[Protocol("shoko")]
class AboutProtoHandler : ProtoHandler
{
2023-10-02 22:13:48 +00:00
string txtDebug = "";
2023-10-02 18:49:24 +00:00
public AboutProtoHandler(Uri url)
{
URL = url;
}
2023-10-20 04:59:28 +00:00
public override Task Load()
2023-10-02 18:49:24 +00:00
{
var path = new UriBuilder(URL).Path;
Content = new MemoryStream(new byte[]{});
switch(path)
{
case "blank":
case "":
case "about":
case "shoko":
case "version":
case "demo":
break;
2023-10-02 22:13:48 +00:00
case "debugtext":
txtDebug = HttpUtility.UrlDecode(URL.Query);
if(txtDebug.Length > 0) txtDebug = txtDebug[1..];
break;
2023-10-02 18:49:24 +00:00
default:
throw new NotImplementedException();
}
MediaType = "text/plain";
Status = "OK";
2023-10-20 04:59:28 +00:00
OnLoaded();
return Task.CompletedTask;
2023-10-02 18:49:24 +00:00
}
2023-10-20 04:59:28 +00:00
2023-10-02 18:49:24 +00:00
public override void Render()
{
var path = new UriBuilder(URL).Path;
switch(path)
{
case "":
case "about":
case "shoko":
case "version":
var info = Assembly.GetExecutingAssembly().GetName();
ImGui.Text("硝子 (shōko) v"+info.Version.ToString());
ImGui.Text("an experimental browser");
ImGui.Separator();
ImGui.Text("(c) 2023 a39 studios");
ImGui.Text("licensed under LiLiQ-P");
ImGui.Separator();
ImGui.Text(".NET v" + Environment.Version.ToString());
ImGui.Text("Dear ImGui v" + ImGui.GetVersion());
ImGui.Text("Raylib v" + Raylib.RAYLIB_VERSION);
ImGui.Separator();
Gui.TreeNode("Supported protos", ()=>{
foreach(var proto in SupportedProtos)
ImGui.BulletText(proto);
});
Gui.TreeNode("Supported media", ()=>{
foreach(var media in MediaHandler.SupportedMedia)
ImGui.BulletText(media);
});
break;
case "demo":
ImGui.ShowDemoWindow();
break;
2023-10-02 22:13:48 +00:00
case "debugtext":
ImGui.InputText("Text", ref txtDebug, 1024);
ImGui.SameLine();
Gui.Button("Debug", ()=>{
var tourl = new UriBuilder(URL)
{
Query = txtDebug
};
CurrentTab.Load(tourl.Uri.ToString());
});
ImGui.DebugTextEncoding(HttpUtility.UrlDecode(URL.Query));
break;
2023-10-02 18:49:24 +00:00
default:
break;
}
}
}