Skip to content

Commit

Permalink
Update fna + client updates
Browse files Browse the repository at this point in the history
  • Loading branch information
SignatureBeef committed Dec 31, 2024
1 parent 46fe58f commit 8356159
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 101 deletions.
2 changes: 1 addition & 1 deletion FNA
Submodule FNA updated 328 files
2 changes: 1 addition & 1 deletion OTAPI.Client.Launcher/Actions/OTAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace OTAPI.Client.Launcher.Actions;

static class OTAPI
{
static Assembly Terraria;
static Assembly? Terraria;

static void CompileAndInstall() //considering to keep or not. this can recompile OTAPI mods on launch...which will be great for developing it. will look into when i get back to it one day
{
Expand Down
1 change: 1 addition & 0 deletions OTAPI.Client.Launcher/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public MainWindow()
private void OnConsoleLineReceived(string line)
{
Context.Console.Insert(0, $"[{DateTime.Now:yyyyMMdd HH:mm:ss}] {line}");
System.Diagnostics.Debug.WriteLine($"[OTAPI.Launcher] {line}");
}

protected override void OnClosing(WindowClosingEventArgs e)
Expand Down
5 changes: 3 additions & 2 deletions OTAPI.Client.Launcher/MessageBoxWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2020 DeathCradle
Copyright (C) 2020-2024 SignatureBeef
This file is part of Open Terraria API v3 (OTAPI)
Expand Down Expand Up @@ -59,7 +59,8 @@ public static void Show(string text, string title)
}
};
wnd.Show();
Application.Current.Run(wnd);
var app = Application.Current ?? throw new System.Exception("Failed to launch MessageBoxWindow");
app.Run(wnd);
}
}

Expand Down
4 changes: 3 additions & 1 deletion OTAPI.Client.Launcher/OTAPI.Client.Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<Nullable>enable</Nullable>
<DebugType>embedded</DebugType>
<RunPostBuildEvent>Always</RunPostBuildEvent>
<UseCurrentRuntimeIdentifier Condition="'$(UseCurrentRuntimeIdentifier)' == ''">true</UseCurrentRuntimeIdentifier>
<SelfContained Condition="'$(SelfContained)' == ''">false</SelfContained>
</PropertyGroup>
<ItemGroup>
<AvaloniaXaml Remove="Properties\**" />
Expand Down Expand Up @@ -86,7 +88,7 @@
<DependentUpon>MessageBoxWindow.axaml</DependentUpon>
</Compile>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="AfterBuild;PostBuildEvent">
<Target Name="PostBuild" AfterTargets="AfterBuild;PreBuildEvent">
<Message Text="Copying OTAPI patch files" Importance="high" />
<MakeDir Directories="$(TargetDir)modifications/" />
<RemoveDir Directories="$(TargetDir)modifications/" />
Expand Down
26 changes: 12 additions & 14 deletions OTAPI.Client.Launcher/Targets/InstallTarget.Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,13 @@ class GHArtifact
public string? BrowserDownloadUrl { get; set; }
}

public static string PublishHostLauncher(this IPlatformTarget target)
public static async Task<string> PublishHostLauncherAsync(this IPlatformTarget target)
{
var url = "https://api.github.com/repos/DeathCradle/Open-Terraria-API/releases";
var url = "https://api.github.com/repos/SignatureBeef/Open-Terraria-API/releases";

using HttpClient client = new();
client.DefaultRequestHeaders.UserAgent.ParseAdd("OTAPI3-Installer");
var data = client.GetStringAsync(url).Result;
var data = await client.GetStringAsync(url);
var releases = Newtonsoft.Json.JsonConvert.DeserializeObject<GHRelease[]>(data) ?? throw new Exception("Unable to read release data");

GHRelease release;
Expand All @@ -311,7 +311,7 @@ public static string PublishHostLauncher(this IPlatformTarget target)
?? throw new Exception("Failed to find zip file in installer release");

Console.WriteLine(target.Status = "Downloading launcher, this may take a long time...");
using var launcher = client.GetStreamAsync(url).Result;
using var launcher = await client.GetStreamAsync(url);

if (File.Exists("launcher.zip")) File.Delete("launcher.zip");
using (var fs = File.OpenWrite("launcher.zip"))
Expand All @@ -320,7 +320,7 @@ public static string PublishHostLauncher(this IPlatformTarget target)
int read;
while (launcher.CanRead)
{
if ((read = launcher.Read(buffer, 0, buffer.Length)) == 0)
if ((read = await launcher.ReadAsync(buffer, 0, buffer.Length)) == 0)
break;

fs.Write(buffer, 0, read);
Expand Down Expand Up @@ -471,7 +471,7 @@ public static void CopyInstallFiles(this IPlatformTarget target, string otapiIns

public async static Task InstallLibsAsync(this IPlatformTarget target, string installPath, CancellationToken cancellationToken)
{
var zipPath = await target.DownloadZipAsync("https://github.com/DeathCradle/fnalibs/raw/main/fnalibs.20211125.tar.bz2", "fnalibs", cancellationToken);
var zipPath = await target.DownloadZipAsync("https://github.com/SignatureBeef/fnalibs/raw/refs/heads/main/fnalibs.20241231.tar.bz2", "fnalibs", cancellationToken);
target.ExtractBZip2(zipPath, installPath);
}

Expand Down Expand Up @@ -502,7 +502,7 @@ public async static Task InstallSteamworks64Async(this IPlatformTarget target, s
}
}

public static void PatchOSXLaunch(this IPlatformTarget target, string installPath)
public static async Task PatchOSXLaunchAsync(this IPlatformTarget target, string installPath)
{
var launch_script = Path.Combine(installPath, "MacOS/Terraria");
var backup_launch_script = Path.Combine(installPath, "MacOS/Terraria.bak.otapi");
Expand Down Expand Up @@ -554,9 +554,8 @@ cd ../otapi
// publish and copy OTAPI.Client.Launcher
{
Console.WriteLine("Publishing and creating launcher...this will take a while.");
var output = target.PublishHostLauncher();
var output = await target.PublishHostLauncherAsync();
var launcher = Path.Combine(output, "Terraria");
//var otapi = Path.Combine(installPath, "OTAPI.Client.Launcher");

if (!File.Exists(launcher))
throw new Exception($"Failed to produce launcher to: {launcher}");
Expand All @@ -566,7 +565,7 @@ cd ../otapi
}
}

public static void PatchWindowsLaunch(this IPlatformTarget target, string installPath)
public static async Task PatchWindowsLaunch(this IPlatformTarget target, string installPath)
{
var launch_file = Path.Combine(installPath, "Terraria.exe");

Expand All @@ -582,7 +581,7 @@ public static void PatchWindowsLaunch(this IPlatformTarget target, string instal

// publish and copy OTAPI.Client.Launcher
{
var output = target.PublishHostLauncher();
var output = await target.PublishHostLauncherAsync();
var launcher = Path.Combine(output, "Terraria.exe");

if (!File.Exists(launcher))
Expand All @@ -595,7 +594,7 @@ public static void PatchWindowsLaunch(this IPlatformTarget target, string instal
}
}

public static void PatchLinuxLaunch(this IPlatformTarget target, string installPath)
public static async Task PatchLinuxLaunch(this IPlatformTarget target, string installPath)
{
var otapi_launcher = Path.Combine(installPath, "otapi_launcher");
var launch_script = Path.Combine(installPath, "Terraria");
Expand Down Expand Up @@ -651,9 +650,8 @@ cd ../otapi
// publish and copy OTAPI.Client.Launcher
{
Console.WriteLine("Publishing and creating launcher...this will take a while.");
var output = target.PublishHostLauncher();
var output = await target.PublishHostLauncherAsync();
var launcher = Path.Combine(output, "Terraria");
//var otapi = Path.Combine(installPath, "OTAPI.Client.Launcher");

if (!File.Exists(launcher))
throw new Exception($"Failed to produce launcher to: {launcher}");
Expand Down
53 changes: 37 additions & 16 deletions OTAPI.Client.Launcher/csharp/plugins/scripts/otapi/cef-runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Runtime.InteropServices;
using ImGuiNET;

//ChromiumWebBrowser browser;
Expand All @@ -24,12 +25,12 @@ void OnUpdate(On.Terraria.Main.orig_Update orig, Terraria.Main self, GameTime ga
try
{

if (CefRuntime.IsInitialized && CefRuntime.Platform != CefRuntimePlatform.Windows)
if (CefRuntime.IsInitialized) // && CefRuntime.Platform != CefRuntimePlatform.Windows)
{
CefRuntime.DoMessageLoopWork();
}
}
catch(Exception ex)
catch (Exception ex)
{
Console.WriteLine("CEF.OnUpdate", ex);
}
Expand Down Expand Up @@ -86,7 +87,7 @@ void OnGUI(On.Terraria.Main.orig_OnExtGUI orig)
}
}
}
catch(Exception ex)
catch (Exception ex)
{
Console.WriteLine("CEF.OnGUI", ex);
}
Expand All @@ -96,6 +97,7 @@ void OnGUI(On.Terraria.Main.orig_OnExtGUI orig)
void OnStart()
{
System.Console.WriteLine("Starting CefSharp");
//System.Diagnistics.Debug.WriteLine("Starting CefSharpx");
ready = true;
}

Expand Down Expand Up @@ -298,13 +300,13 @@ public override void Render(IntPtr buffer)
buffer,
_target.Width * _target.Height
);
// var length = _target.Width * _target.Height;
// int[] imgData = new int[length];
// var temporaryBuffer = new int[length];
//var length = _target.Width * _target.Height;
//int[] imgData = new int[length];
//var temporaryBuffer = new int[length];

// Marshal.Copy(buffer, temporaryBuffer, 0, length);
//Marshal.Copy(buffer, temporaryBuffer, 0, length);

// _target.SetData(temporaryBuffer);
_target.SetData(temporaryBuffer);
}

private bool disposedValue;
Expand Down Expand Up @@ -391,14 +393,24 @@ public OffscreenBrowser(IOffscreenRenderTarget renderTarget, string url)

Client.LifeSpanHandler.Created += LifeSpanHandler_Created;

if (!CefRuntime.IsInitialized)
{
var cefsettings = new CefSettings()
{
WindowlessRenderingEnabled = true
};
CefLoader.Load(cefsettings);
}
//if (!CefRuntime.IsInitialized)
//{
// var cachePath = Path.Combine(Environment.CurrentDirectory, "cef-cache");
// if (!Directory.Exists(cachePath))
// Directory.CreateDirectory(cachePath);
// var cefsettings = new CefSettings()
// {
// WindowlessRenderingEnabled = true,
// LogSeverity = CefLogSeverity.Verbose,
// LogFile = "cef_debug.log",
// RootCachePath = cachePath,
// MultiThreadedMessageLoop = true,
// SingleProcess = false,
// };
// CefLoader.Load(cefsettings);
//}

CefLoader.Load();

//Browser = CefBrowserHost.CreateBrowserSync(wi, client, bsettings, "https://google.com.au/");
CefBrowserHost.CreateBrowser(wi, Client, bsettings, url);
Expand Down Expand Up @@ -572,6 +584,15 @@ public static OffscreenApp Load(CefSettings? settings = null, OffscreenApp? app
settings.BrowserSubprocessPath = DiscoverSubProcess();
settings.UncaughtExceptionStackSize = 10;

settings.WindowlessRenderingEnabled = true;
settings.LogSeverity = CefLogSeverity.Verbose;
settings.LogFile = "cef_debug.log";

var cachePath = Path.Combine(Environment.CurrentDirectory, "cef-cache");
if (!Directory.Exists(cachePath))
Directory.CreateDirectory(cachePath);
settings.RootCachePath = cachePath;

switch (CefRuntime.Platform)
{
case CefRuntimePlatform.Windows:
Expand Down
1 change: 0 additions & 1 deletion OTAPI.Server.Launcher/OTAPI.Server.Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<PackageReference Include="System.IO.Packaging" Version="9.0.0" />
<PackageReference Include="System.Security.Permissions" Version="9.0.0" />
<PackageReference Include="Mono.Cecil" Version="0.11.6" />
<!--<PackageReference Include="MonoMod.RuntimeDetour.HookGen" Version="22.7.31.1" />-->
<PackageReference Include="MonoMod" Version="22.7.31.1">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</PackageReference>
Expand Down
Loading

0 comments on commit 8356159

Please sign in to comment.