Add standalone win64 release packaging, Forgejo release script, and borderless/focus UX

This commit is contained in:
Meta Vens 2026-12-05 20:14:38 +01:00
commit 385275f130
12 changed files with 698 additions and 84 deletions

42
client/ClientAssets.cs Normal file
View file

@ -0,0 +1,42 @@
using System;
using System.IO;
using Godot;
using RustToDust.Core;
namespace RustToDust.Client;
internal static class ClientAssets
{
private static bool _registered;
internal static void EnsureAssetsRootRegistered()
{
if (_registered)
{
return;
}
_registered = true;
if (OS.HasFeature("template"))
{
string exeAssets = Path.Combine(OS.GetExecutablePath().GetBaseDir(), "assets");
if (Directory.Exists(exeAssets))
{
AssetPathResolver.RegisterAssetsRoot(exeAssets);
return;
}
}
string baseAssets = Path.Combine(AppContext.BaseDirectory, "assets");
if (Directory.Exists(baseAssets))
{
AssetPathResolver.RegisterAssetsRoot(baseAssets);
}
}
internal static string LocateAssetsDirectory()
{
EnsureAssetsRootRegistered();
return AssetPathResolver.LocateAssetsRoot();
}
}

View file

@ -135,6 +135,7 @@ public partial class Main : Node3D
public override void _Ready()
{
ClientAssets.EnsureAssetsRootRegistered();
GetViewport().UseTaa = true;
_atmosphere = new AtmosphereSystem { Name = "AtmosphereSystem" };
AddChild(_atmosphere);
@ -310,6 +311,14 @@ public partial class Main : Node3D
}
_menuPreviewOut = System.Environment.GetEnvironmentVariable("RTD_MENU_PREVIEW_OUT");
bool hasWindowOverride = GetCliArg("--windowed", allowBareFlag: true) is not null
|| GetCliArg("--resolution") is not null
|| GetCliArg("-w", allowBareFlag: true) is not null;
if (!IsAutomatedRun && !hasWindowOverride)
{
DisplayServer.WindowSetMode(DisplayServer.WindowMode.Fullscreen);
}
bool perfCombat = _perfTargetFrames > 0 && System.Environment.GetEnvironmentVariable("RTD_PERF_COMBAT") == "1";
bool skipInitialDrop = InitialSkipDropOverride || perfCombat;
bool autoBypassMenu = InitialMapKindOverride.HasValue
@ -888,10 +897,56 @@ public partial class Main : Node3D
SyncMouseMode();
}
private bool IsAutomatedRun =>
DisplayServer.GetName() == "headless"
|| _perfTargetFrames > 0
|| _menuPreviewTargetFrames > 0
|| !string.IsNullOrEmpty(System.Environment.GetEnvironmentVariable("RTD_PERF_FRAMES"))
|| !string.IsNullOrEmpty(System.Environment.GetEnvironmentVariable("RTD_AUTO_EXIT_FRAMES"))
|| !string.IsNullOrEmpty(System.Environment.GetEnvironmentVariable("RTD_MENU_EXIT_FRAMES"));
public override void _Notification(int what)
{
if (what == NotificationApplicationFocusOut || what == NotificationWMWindowFocusOut)
{
Input.MouseMode = Input.MouseModeEnum.Visible;
}
else if (what == NotificationApplicationFocusIn || what == NotificationWMWindowFocusIn)
{
if (IsInsideTree())
{
SyncMouseMode();
}
}
}
private void ToggleBorderlessFullscreen()
{
if (DisplayServer.GetName() == "headless")
{
return;
}
var mode = DisplayServer.WindowGetMode();
if (mode == DisplayServer.WindowMode.Fullscreen || mode == DisplayServer.WindowMode.ExclusiveFullscreen)
{
DisplayServer.WindowSetMode(DisplayServer.WindowMode.Windowed);
}
else
{
DisplayServer.WindowSetMode(DisplayServer.WindowMode.Fullscreen);
}
}
private void SyncMouseMode()
{
if (DisplayServer.GetName() == "headless" || _perfTargetFrames > 0)
if (IsAutomatedRun)
{
Input.MouseMode = Input.MouseModeEnum.Visible;
return;
}
if (!IsInsideTree() || GetWindow() is not { } win || !win.HasFocus())
{
Input.MouseMode = Input.MouseModeEnum.Visible;
return;
}
if (_screenMode != ClientScreenMode.InMatch)
@ -1017,6 +1072,16 @@ public partial class Main : Node3D
{
if (@event is InputEventKey key && key.Pressed && !key.Echo)
{
bool isAltEnter = (key.Keycode == Key.Enter || key.Keycode == Key.KpEnter)
&& key.AltPressed && !key.CtrlPressed && !key.ShiftPressed;
bool isF11 = key.Keycode == Key.F11 && !key.AltPressed && !key.CtrlPressed && !key.ShiftPressed;
if (isAltEnter || isF11)
{
ToggleBorderlessFullscreen();
GetViewport().SetInputAsHandled();
return;
}
if (_screenMode == ClientScreenMode.MainMenu)
{
if (key.Keycode == Key.Escape && _mainMenu.IsHostPanelOpen)

View file

@ -29,13 +29,28 @@ internal static class NativeLibraries
if (OS.HasFeature("template"))
{
string exportPath = Path.Combine(
Path.GetDirectoryName(OS.GetExecutablePath())!,
$"data_RustToDust.Client_{Platform()}_{Arch()}",
fileName);
return File.Exists(exportPath) && NativeLibrary.TryLoad(exportPath, out var exportHandle)
? exportHandle
: IntPtr.Zero;
string exePath = OS.GetExecutablePath();
string exeDir = exePath.GetBaseDir();
string exeStem = Path.GetFileNameWithoutExtension(exePath);
string platArch = $"{Platform()}_{Arch()}";
string[] candidates =
{
Path.Combine(exeDir, fileName),
Path.Combine(exeDir, $"data_{exeStem}_{platArch}", fileName),
Path.Combine(exeDir, $"data_RustToDust_{platArch}", fileName),
Path.Combine(exeDir, $"data_RustToDust.Client_{platArch}", fileName),
Path.Combine(AppContext.BaseDirectory, fileName),
};
foreach (string candidate in candidates)
{
if (File.Exists(candidate) && NativeLibrary.TryLoad(candidate, out var exportHandle))
{
return exportHandle;
}
}
return IntPtr.Zero;
}
string debugPath = Path.Combine(ProjectSettings.GlobalizePath("res://.godot/mono/temp/bin/Debug"), fileName);

View file

@ -58,9 +58,7 @@ public partial class PomDecalPool : Node3D
Shader shader = GD.Load<Shader>("res://decal_pom.gdshader")
?? throw new InvalidOperationException("Failed to load res://decal_pom.gdshader");
string vehiclesDir = VehicleCatalogLoader.LocateVehiclesDirectory();
string assetsDir = Directory.GetParent(vehiclesDir)?.FullName
?? throw new DirectoryNotFoundException("Could not locate assets directory.");
string assetsDir = ClientAssets.LocateAssetsDirectory();
string decalsDir = Path.Combine(assetsDir, "decals");
_albedoTex = LoadTextureWithMips(Path.Combine(decalsDir, "decal_atlas_albedo.png"));

View file

@ -56,9 +56,7 @@ public sealed class ProceduralAudioBank
public static string LocateHavenAudioDirectory()
{
string vehiclesDir = VehicleCatalogLoader.LocateVehiclesDirectory();
string assetsDir = Directory.GetParent(vehiclesDir)?.FullName
?? throw new DirectoryNotFoundException("Could not locate assets directory.");
string assetsDir = ClientAssets.LocateAssetsDirectory();
string havenDir = Path.Combine(assetsDir, "audio", "haven");
if (!Directory.Exists(havenDir))
{

View file

@ -132,9 +132,9 @@ public sealed class VehicleAssetCache : IDisposable
public VehicleAssetCache()
{
ClientAssets.EnsureAssetsRootRegistered();
_vehiclesDir = VehicleCatalogLoader.LocateVehiclesDirectory();
string assetsDir = Directory.GetParent(_vehiclesDir)?.FullName
?? throw new DirectoryNotFoundException($"Could not locate assets parent directory of '{_vehiclesDir}'.");
string assetsDir = ClientAssets.LocateAssetsDirectory();
_gearDir = Path.Combine(assetsDir, "gear");
if (!Directory.Exists(_gearDir))
{

48
client/export_presets.cfg Normal file
View file

@ -0,0 +1,48 @@
[preset.0]
name="Windows Desktop"
platform="Windows Desktop"
runnable=true
advanced_options=false
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter="tests/*,*.uid"
export_path=""
patches=PackedStringArray()
encryption_include_filters=""
encryption_exclude_filters=""
seed=0
encrypt_pck=false
encrypt_directory=false
script_export_mode=2
[preset.0.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_wrapper=1
binary_format/embed_pck=false
texture_format/s3tc_bptc=true
texture_format/etc2_astc=false
shader_baker/enabled=false
binary_format/architecture="x86_64"
codesign/enable=false
application/modify_resources=true
application/icon=""
application/console_wrapper_icon=""
application/icon_interpolation=4
application/file_version=""
application/product_version=""
application/company_name="GameCult"
application/product_name="Rust to Dust"
application/file_description="Rust to Dust"
application/copyright=""
application/trademarks=""
application/export_angle=0
application/export_d3d12=0
application/d3d12_agility_sdk_multiarch=true
ssh_remote_deploy/enabled=false
dotnet/include_scripts_content=false
dotnet/include_debug_symbols=false