mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Compare commits
91 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e4e8aad34 | ||
|
|
257127afcd | ||
|
|
810e4e454d | ||
|
|
e0ff1e83e2 | ||
|
|
856cdb8a3d | ||
|
|
b783cd79be | ||
|
|
b5ba964f61 | ||
|
|
09676a1d9f | ||
|
|
6959f21927 | ||
|
|
26a1fb35b5 | ||
|
|
7fb3ce0e70 | ||
|
|
5497b52100 | ||
|
|
18b5f33080 | ||
|
|
30d3367c50 | ||
|
|
f6aabd1a22 | ||
|
|
6d229a3eb2 | ||
|
|
da28bdbce5 | ||
|
|
0181988225 | ||
|
|
fb2ba7460a | ||
|
|
b70d20a217 | ||
|
|
ebc33df457 | ||
|
|
697af6771c | ||
|
|
20706870da | ||
|
|
372fa39228 | ||
|
|
d6bfbe4f6f | ||
|
|
54645b4adf | ||
|
|
7c16573f3e | ||
|
|
8935b39987 | ||
|
|
388f8369a8 | ||
|
|
217d889e36 | ||
|
|
f243baccf2 | ||
|
|
790f42ea70 | ||
|
|
a5fcf122b8 | ||
|
|
df2d6ab8c2 | ||
|
|
23c90c0c45 | ||
|
|
c69756e7f1 | ||
|
|
07fbd5263c | ||
|
|
a1cdd60602 | ||
|
|
6fcaee91b6 | ||
|
|
4d4f353680 | ||
|
|
9f0dad80e4 | ||
|
|
c3f4b9bd67 | ||
|
|
641411288f | ||
|
|
1fb7d3e723 | ||
|
|
8cbc5d4cd8 | ||
|
|
b4863dcc38 | ||
|
|
e771530de2 | ||
|
|
ce3a5f6bfa | ||
|
|
1cd802640a | ||
|
|
1983734e2d | ||
|
|
ea380056b4 | ||
|
|
9c26fba308 | ||
|
|
3de48d7595 | ||
|
|
7a510298e1 | ||
|
|
046db645e9 | ||
|
|
63e383bb17 | ||
|
|
e316649fd1 | ||
|
|
121b58ee9a | ||
|
|
d11f4bcc14 | ||
|
|
735ef09d42 | ||
|
|
772173cbaf | ||
|
|
4bd7aa16c1 | ||
|
|
bc4b4d3e6f | ||
|
|
7d9a039252 | ||
|
|
857f9a540b | ||
|
|
6ae332d543 | ||
|
|
f4786f2d90 | ||
|
|
dcbe0505dc | ||
|
|
c3489d4ded | ||
|
|
8498634993 | ||
|
|
3d289fbd83 | ||
|
|
ebce0daa1b | ||
|
|
bbbfcca303 | ||
|
|
e195ac4ce6 | ||
|
|
dc5cbd085b | ||
|
|
c4dff678a9 | ||
|
|
cd9616c87c | ||
|
|
d1c6c11755 | ||
|
|
1ebac7c894 | ||
|
|
6b41be8901 | ||
|
|
c876eb1f4c | ||
|
|
1037fc735e | ||
|
|
d5df765467 | ||
|
|
93cf9f4227 | ||
|
|
d2977e2a63 | ||
|
|
a3f0ea19c4 | ||
|
|
d9032b8757 | ||
|
|
cba6e37f9f | ||
|
|
90ec9a80c9 | ||
|
|
7eaf2f590b | ||
|
|
0439ea9893 |
2
.github/workflows/build-test.yml
vendored
2
.github/workflows/build-test.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest] # , macos-latest] - temporarily disabled due to libfreetype.dll errors.
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
|
||||
2
.github/workflows/publish-client.yml
vendored
2
.github/workflows/publish-client.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
dotnet-version: 9.0.x
|
||||
|
||||
- name: Package client
|
||||
run: Tools/package_client_build.py -p windows mac linux
|
||||
run: Tools/package_client_build.py
|
||||
|
||||
- name: Shuffle files around
|
||||
run: |
|
||||
|
||||
@@ -44,10 +44,11 @@
|
||||
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
|
||||
<PackageVersion Include="Nett" Version="0.15.0" />
|
||||
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.2" />
|
||||
<PackageVersion Include="OpenTK.OpenAL" Version="4.7.7" />
|
||||
<PackageVersion Include="OpenTK.Audio.OpenAL" Version="4.9.4" />
|
||||
<PackageVersion Include="OpenToolkit.Graphics" Version="4.0.0-pre9.1" />
|
||||
<PackageVersion Include="Pidgin" Version="3.3.0" />
|
||||
<PackageVersion Include="Robust.Natives" Version="0.1.1" />
|
||||
<PackageVersion Include="Robust.Natives" Version="0.2.1" />
|
||||
<PackageVersion Include="Robust.Natives.Zstd" Version="0.1.0-zstd1.5.7" />
|
||||
<PackageVersion Include="Robust.Natives.Cef" Version="131.3.5" />
|
||||
<PackageVersion Include="Robust.Shared.AuthLib" Version="0.1.2" />
|
||||
<PackageVersion Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.10" />
|
||||
@@ -55,11 +56,13 @@
|
||||
<PackageVersion Include="Serilog" Version="4.2.0" />
|
||||
<PackageVersion Include="Serilog.Sinks.Loki" Version="4.0.0-beta3" />
|
||||
<PackageVersion Include="SharpZstd.Interop" Version="1.5.2-beta2" />
|
||||
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.7" />
|
||||
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.11" />
|
||||
<PackageVersion Include="SpaceWizards.HttpListener" Version="0.1.1" />
|
||||
<PackageVersion Include="SpaceWizards.NFluidsynth" Version="0.1.1" />
|
||||
<PackageVersion Include="SpaceWizards.SharpFont" Version="1.0.2" />
|
||||
<PackageVersion Include="SpaceWizards.NFluidsynth" Version="0.2.2" />
|
||||
<PackageVersion Include="SpaceWizards.SharpFont" Version="1.1.0" />
|
||||
<PackageVersion Include="SpaceWizards.Sodium" Version="0.2.1" />
|
||||
<PackageVersion Include="libsodium" Version="1.0.20.1" />
|
||||
<PackageVersion Include="System.Management" Version="9.0.8" />
|
||||
<PackageVersion Include="TerraFX.Interop.Windows" Version="10.0.26100.1" />
|
||||
<PackageVersion Include="TerraFX.Interop.Xlib" Version="6.4.0" />
|
||||
<PackageVersion Include="VorbisPizza" Version="1.3.0" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project>
|
||||
|
||||
<!-- This file automatically reset by Tools/version.py -->
|
||||
<!-- This file automatically reset by Tools/version.py -->
|
||||
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\Robust.Client.NameGenerator\Robust.Client.NameGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\Robust.Client.Injectors\Robust.Client.Injectors.csproj" ReferenceOutputAssembly="false"/>
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\Robust.Client.Injectors\Robust.Client.Injectors.csproj" ReferenceOutputAssembly="false">
|
||||
<SetConfiguration Condition="'$(Configuration)' == 'DebugOpt'">Configuration=Debug</SetConfiguration>
|
||||
<SetConfiguration Condition="'$(Configuration)' == 'Tools'">Configuration=Release</SetConfiguration>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- XamlIL does not make use of special Robust configurations like DebugOpt. Convert these down. -->
|
||||
|
||||
Submodule NetSerializer updated: ced82e76ad...84ab8fec64
@@ -54,6 +54,99 @@ END TEMPLATE-->
|
||||
*None yet*
|
||||
|
||||
|
||||
## 267.0.2
|
||||
|
||||
|
||||
## 267.0.1
|
||||
|
||||
|
||||
## 267.0.0
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* When a player disconnects, the relevant callbacks are now fired *after* removing the channel from `INetManager`.
|
||||
|
||||
### New features
|
||||
|
||||
* Engine builds are now published for ARM64 & FreeBSD.
|
||||
* CPU model names are now detected on Windows & Linux ARM64.
|
||||
* Toolshed's `spawn:in` command now works on entities without `Physics` component.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
* SDL3 windowing backend fixes:
|
||||
* Avoid macOS freezes with multiple windows.
|
||||
* Fix macOS rendering breaking when closing secondary windows.
|
||||
* File dialogs properly associate parent windows.
|
||||
* Fix IME positions not working with UI scaling properly.
|
||||
* Properly specify library names for loading native library.
|
||||
|
||||
* WinBit threads don't permanently stay stuck when their window closes.
|
||||
* Checking for the "`null`" literal in serialization is now culture invariant.
|
||||
|
||||
### Other
|
||||
|
||||
* Compat mode on the client now defaults to on for Windows Snapdragon devices, to work around driver bugs.
|
||||
* Update various libraries & natives. This enables out-of-the-box ARM64 support on all platforms and is a long-overdue modernization.
|
||||
* Key name displays now use proper Unicode symbols for macOS ⌥ and ⌘.
|
||||
* Automated CI for RobustToolbox runs on macOS again.
|
||||
* Autocompletions for `ProtoId<T>` in Toolshed now use `PrototypeIdsLimited` instead of arbitrarily cutting out if more than 256 of a prototype exists.
|
||||
|
||||
|
||||
## 266.0.0
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* A new analyzer has been added that will error if you attempt to subscribe to `AfterAutoHandleStateEvent` on a
|
||||
component that doesn't have the `AutoGenerateComponentState` attribute, or doesn't have the first argument of that
|
||||
attribute set to `true`. In most cases you will want to set said argument to `true`.
|
||||
* The fields on `AutoGenerateComponentStateAttribute` are now `readonly`. Setting these directly (instead of using the constructor arguments) never worked in the first place, so this change only catches existing programming errors.
|
||||
* When a player disconnects, `ISharedPlayerManager.PlayerStatusChanged` is now fired *after* removing the session from the `Sessions` list.
|
||||
* `.rsi` files are now compacted into individual `.rsic` files on packaging. This should significantly reduce file count & improve performance all over release builds, but breaks the ability to access `.png` files into RSIs directly. To avoid this, `"rsic": false` can be specified in the RSI's JSON metadata.
|
||||
* The `scale` command has been removed, with the intent of it being moved to content instead.
|
||||
|
||||
### New features
|
||||
|
||||
* ViewVariables editors for `ProtoId` fields now have a Select button which opens a window listing all available prototypes of the appropriate type.
|
||||
* added **IConfigurationManager**.*SubscribeMultiple* ext. method to provide simpler way to unsubscribe from multiple cvar at once
|
||||
* Added `SharedMapSystem.QueueDeleteMap`, which deletes a map with the specified MapId in the next tick.
|
||||
* Added generic version of `ComponentRegistry.TryGetComponent`.
|
||||
* `AttributeHelper.HasAttribute` has had an overload's type signature loosened from `INamedTypeSymbol` to `ITypeSymbol`.
|
||||
* Errors are now logged when sending messages to disconnected `INetChannel`s.
|
||||
* Warnings are now logged if sending a message via Lidgren failed for some reason.
|
||||
* `.yml` and `.ftl` files in the same directory are now concatenated onto each other, to reduce file count in packaged builds. This is done through the new `AssetPassMergeTextDirectories` pass.
|
||||
* Added `System.Linq.ImmutableArrayExtensions` to sandbox.
|
||||
* `ImmutableDictionary<TKey, TValue>` and `ImmutableHashSet<T>` can now be network serialized.
|
||||
* `[AutoPausedField]` now works on fields of type `Dictionary<TKey, TimeSpan>`.
|
||||
* `[NotYamlSerializable]` analyzer now detects nullable fields of the not-serializable type.
|
||||
* `ItemList` items can now have a scale applied for the icon.
|
||||
* Added new OS mouse cursor shapes for the SDL3 backend. These are not available on the GLFW backend.
|
||||
* Added `IMidiRenderer.MinVolume` to scale the volume of MIDI notes.
|
||||
* Added `SharedPhysicsSystem.ScaleFixtures`, to apply the physics-only changes of the prior `scale` command.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
* `LayoutContainer.SetMarginsPreset` and `SetAnchorAndMarginPreset` now correctly use the provided control's top anchor when calculating the margins for its presets; it previously used the bottom anchor instead. This may result in a few UI differences, by a few pixels at most.
|
||||
* `IConfigurationManager` no longer logs a warning when saving configuration in an integration test.
|
||||
* Fixed impossible-to-source `ChannelClosedException`s when sending some net messages to disconnected `INetChannel`s.
|
||||
* Fixed an edge case causing some color values to throw an error in `ColorNaming`.
|
||||
* Fresh builds from specific projects should no longer cause errors related to `Robust.Client.Injectors` not being found.
|
||||
* Stopped errors getting logged about `NoteOff` and `NoteOn` operations failing in MIDI.
|
||||
* Fixed MIDI players not resuming properly when re-entering PVS range.
|
||||
|
||||
### Other
|
||||
|
||||
* Updated ImageSharp to 3.1.11 to stop the warning about a DoS vulnerability.
|
||||
* Prototype YAML documents that are completely empty are now skipped by the prototype loader. Previously they would cause a load error for the whole file.
|
||||
* `TileSpawnWindow` can now be localized.
|
||||
* `BaseWindow` uses the new mouse cursor shapes for diagonal resizing.
|
||||
* `NFluidsynth` has been updated to 0.2.0
|
||||
|
||||
### Internal
|
||||
|
||||
* Added `uitest` tab for standard mouse cursor shapes.
|
||||
|
||||
|
||||
## 265.0.0
|
||||
|
||||
### Breaking changes
|
||||
|
||||
@@ -21,6 +21,7 @@ color-brown = brown
|
||||
color-white = white
|
||||
color-gray = gray
|
||||
color-black = black
|
||||
color-unknown = unknown color, you should not see this
|
||||
|
||||
color-pink-color-red = pinkish red
|
||||
color-red-color-orange = reddish orange
|
||||
|
||||
@@ -411,9 +411,6 @@ cmd-spawn-help = spawn <prototype> OR spawn <prototype> <relative entity ID> OR
|
||||
cmd-cspawn-desc = Spawns a client-side entity with specific type at your feet.
|
||||
cmd-cspawn-help = cspawn <entity type>
|
||||
|
||||
cmd-scale-desc = Increases or decreases an entity's size naively.
|
||||
cmd-scale-help = scale <entityUid> <float>
|
||||
|
||||
cmd-dumpentities-desc = Dump entity list.
|
||||
cmd-dumpentities-help = Dumps entity list of UIDs and prototype.
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
## EntitySpawnWindow
|
||||
|
||||
entity-spawn-window-title = Entity Spawn Panel
|
||||
entity-spawn-window-search-bar-placeholder = search
|
||||
entity-spawn-window-clear-button = Clear
|
||||
entity-spawn-window-replace-button-text = Replace
|
||||
entity-spawn-window-override-menu-tooltip = Override placement
|
||||
|
||||
@@ -22,3 +20,5 @@ output-panel-scroll-down-button-text = Scroll Down
|
||||
## Common Used
|
||||
|
||||
window-erase-button-text = Erase Mode
|
||||
window-search-bar-placeholder = Search
|
||||
window-clear-button = Clear
|
||||
|
||||
@@ -2,6 +2,7 @@ input-key-Escape = Escape
|
||||
input-key-Control = Control
|
||||
input-key-Shift = Shift
|
||||
input-key-Alt = Alt
|
||||
input-key-Alt-mac = ⌥
|
||||
input-key-Menu = Menu
|
||||
input-key-F1 = F1
|
||||
input-key-F2 = F2
|
||||
@@ -70,8 +71,8 @@ input-key-MouseButton9 = Mouse 9
|
||||
|
||||
input-key-LSystem-win = Left Win
|
||||
input-key-RSystem-win = Right Win
|
||||
input-key-LSystem-mac = Left Cmd
|
||||
input-key-RSystem-mac = Right Cmd
|
||||
input-key-LSystem-mac = Left ⌘
|
||||
input-key-RSystem-mac = Right ⌘
|
||||
input-key-LSystem-linux = Left Meta
|
||||
input-key-RSystem-linux = Right Meta
|
||||
|
||||
|
||||
@@ -25,3 +25,9 @@ vv-sound-reference-distance = Reference Distance
|
||||
vv-sound-loop = Loop
|
||||
vv-sound-play-offset = Play Offset (s)
|
||||
vv-sound-variation = Pitch variation
|
||||
|
||||
|
||||
## ProtoId
|
||||
vv-protoid-id-placeholder = Prototype ID
|
||||
vv-protoid-select-button-label = Select
|
||||
vv-protoid-addwindow-title = Set Prototype
|
||||
|
||||
110
Robust.Analyzers.Tests/AfterAutoHandleStateAnalyzerTest.cs
Normal file
110
Robust.Analyzers.Tests/AfterAutoHandleStateAnalyzerTest.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CodeAnalysis.CSharp.Testing;
|
||||
using Microsoft.CodeAnalysis.Testing;
|
||||
using NUnit.Framework;
|
||||
using VerifyCS =
|
||||
Microsoft.CodeAnalysis.CSharp.Testing.CSharpAnalyzerVerifier<Robust.Analyzers.AfterAutoHandleStateAnalyzer,
|
||||
Microsoft.CodeAnalysis.Testing.DefaultVerifier>;
|
||||
|
||||
namespace Robust.Analyzers.Tests;
|
||||
|
||||
[Parallelizable(ParallelScope.All | ParallelScope.Fixtures)]
|
||||
[TestFixture, TestOf(typeof(AfterAutoHandleStateAnalyzer))]
|
||||
public sealed class AfterAutoHandleStateAnalyzerTest
|
||||
{
|
||||
private const string SubscribeEventDef = """
|
||||
using System;
|
||||
namespace Robust.Shared.GameObjects;
|
||||
|
||||
public readonly struct EntityUid;
|
||||
|
||||
public abstract class EntitySystem
|
||||
{
|
||||
public void SubscribeLocalEvent<T, TEvent>() where TEvent : notnull { }
|
||||
}
|
||||
|
||||
public interface IComponent;
|
||||
public interface IComponentState;
|
||||
""";
|
||||
|
||||
// A rare case for block-scoped namespace, I thought. Then I realized this
|
||||
// only needed the one type definition.
|
||||
private const string OtherTypeDefs = """
|
||||
using System;
|
||||
|
||||
namespace JetBrains.Annotations
|
||||
{
|
||||
public sealed class BaseTypeRequiredAttribute(Type baseType) : Attribute;
|
||||
}
|
||||
""";
|
||||
|
||||
private static Task Verifier(string code, params DiagnosticResult[] expected)
|
||||
{
|
||||
var test = new CSharpAnalyzerTest<AfterAutoHandleStateAnalyzer, DefaultVerifier>
|
||||
{
|
||||
TestState = { Sources = { code } }
|
||||
};
|
||||
|
||||
TestHelper.AddEmbeddedSources(test.TestState,
|
||||
"Robust.Shared.Analyzers.ComponentNetworkGeneratorAuxiliary.cs",
|
||||
"Robust.Shared.GameObjects.EventBusAttributes.cs");
|
||||
|
||||
test.TestState.Sources.Add(("EntitySystem.Subscriptions.cs", SubscribeEventDef));
|
||||
test.TestState.Sources.Add(("Types.cs", OtherTypeDefs));
|
||||
|
||||
test.TestState.ExpectedDiagnostics.AddRange(expected);
|
||||
|
||||
return test.RunAsync();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Test()
|
||||
{
|
||||
const string code = """
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
[AutoGenerateComponentState(true)]
|
||||
public sealed class AutoGenTrue;
|
||||
[AutoGenerateComponentState(true, true)]
|
||||
public sealed class AutoGenTrueTrue;
|
||||
|
||||
public sealed class NotAutoGen;
|
||||
[AutoGenerateComponentState]
|
||||
public sealed class AutoGenNoArgs;
|
||||
[AutoGenerateComponentState(false)]
|
||||
public sealed class AutoGenFalse;
|
||||
|
||||
public sealed class Foo : EntitySystem
|
||||
{
|
||||
public void Good()
|
||||
{
|
||||
// Subscribing to other events works
|
||||
SubscribeLocalEvent<AutoGenNoArgs, object>();
|
||||
// First arg true allows subscribing
|
||||
SubscribeLocalEvent<AutoGenTrue, AfterAutoHandleStateEvent>();
|
||||
SubscribeLocalEvent<AutoGenTrueTrue, AfterAutoHandleStateEvent>();
|
||||
}
|
||||
|
||||
public void Bad()
|
||||
{
|
||||
// Can't subscribe if AutoGenerateComponentState isn't even present
|
||||
SubscribeLocalEvent<NotAutoGen, AfterAutoHandleStateEvent>();
|
||||
|
||||
// Can't subscribe if first arg is not specified/false
|
||||
SubscribeLocalEvent<AutoGenNoArgs, AfterAutoHandleStateEvent>();
|
||||
SubscribeLocalEvent<AutoGenFalse, AfterAutoHandleStateEvent>();
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
await Verifier(code,
|
||||
// /0/Test0.cs(29,9): error RA0040: Tried to subscribe to AfterAutoHandleStateEvent for 'NotAutoGen' which doesn't have an AutoGenerateComponentState attribute
|
||||
VerifyCS.Diagnostic(AfterAutoHandleStateAnalyzer.MissingAttribute).WithSpan(29, 9, 29, 69).WithArguments("NotAutoGen"),
|
||||
// /0/Test0.cs(32,9): error RA0041: Tried to subscribe to AfterAutoHandleStateEvent for 'AutoGenNoArgs' which doesn't have raiseAfterAutoHandleState set
|
||||
VerifyCS.Diagnostic(AfterAutoHandleStateAnalyzer.MissingAttributeParam).WithSpan(32, 9, 32, 72).WithArguments("AutoGenNoArgs"),
|
||||
// /0/Test0.cs(33,9): error RA0041: Tried to subscribe to AfterAutoHandleStateEvent for 'AutoGenFalse' which doesn't have raiseAfterAutoHandleState set
|
||||
VerifyCS.Diagnostic(AfterAutoHandleStateAnalyzer.MissingAttributeParam).WithSpan(33, 9, 33, 71).WithArguments("AutoGenFalse")
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
extern alias SerializationGenerator;
|
||||
extern alias SerializationGenerator;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.CodeAnalysis;
|
||||
@@ -126,6 +126,48 @@ public sealed class ComponentPauseGeneratorTest
|
||||
""");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDictionary()
|
||||
{
|
||||
var result = RunGenerator("""
|
||||
[AutoGenerateComponentPause]
|
||||
public sealed partial class FooComponent : IComponent
|
||||
{
|
||||
[AutoPausedField]
|
||||
public Dictionary<string, TimeSpan> Foo;
|
||||
}
|
||||
""");
|
||||
|
||||
ExpectNoDiagnostics(result);
|
||||
ExpectSource(
|
||||
result,
|
||||
"""
|
||||
// <auto-generated />
|
||||
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
public partial class FooComponent
|
||||
{
|
||||
[RobustAutoGenerated]
|
||||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public sealed class FooComponent_AutoPauseSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<FooComponent, EntityUnpausedEvent>(OnEntityUnpaused);
|
||||
}
|
||||
|
||||
private void OnEntityUnpaused(EntityUid uid, FooComponent component, ref EntityUnpausedEvent args)
|
||||
{
|
||||
foreach (var key in component.Foo.Keys)
|
||||
component.Foo[key] += args.PausedTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
""");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAutoState()
|
||||
{
|
||||
|
||||
@@ -203,6 +203,8 @@ public sealed class DataDefinitionAnalyzerTest
|
||||
|
||||
[NotYamlSerializable]
|
||||
public sealed class NotSerializableClass { }
|
||||
[NotYamlSerializable]
|
||||
public readonly struct NotSerializableStruct { }
|
||||
|
||||
[DataDefinition]
|
||||
public sealed partial class Foo
|
||||
@@ -213,6 +215,21 @@ public sealed class DataDefinitionAnalyzerTest
|
||||
[DataField]
|
||||
public NotSerializableClass BadProperty { get; set; }
|
||||
|
||||
[DataField]
|
||||
public NotSerializableClass? BadNullableField;
|
||||
|
||||
[DataField]
|
||||
public NotSerializableStruct BadStructField;
|
||||
|
||||
[DataField]
|
||||
public NotSerializableStruct BadStructProperty { get; set; }
|
||||
|
||||
[DataField]
|
||||
public NotSerializableStruct? BadNullableStructField;
|
||||
|
||||
[DataField]
|
||||
public NotSerializableStruct? BadNullableStructProperty { get; set; }
|
||||
|
||||
public NotSerializableClass GoodField; // Not a DataField, not a problem
|
||||
|
||||
public NotSerializableClass GoodProperty { get; set; } // Not a DataField, not a problem
|
||||
@@ -220,10 +237,20 @@ public sealed class DataDefinitionAnalyzerTest
|
||||
""";
|
||||
|
||||
await Verifier(code,
|
||||
// /0/Test0.cs(10,12): error RA0033: Data field BadField in data definition Foo is type NotSerializableClass, which is not YAML serializable
|
||||
VerifyCS.Diagnostic(DataDefinitionAnalyzer.DataFieldYamlSerializableRule).WithSpan(10, 12, 10, 32).WithArguments("BadField", "Foo", "NotSerializableClass"),
|
||||
// /0/Test0.cs(13,12): error RA0033: Data field BadProperty in data definition Foo is type NotSerializableClass, which is not YAML serializable
|
||||
VerifyCS.Diagnostic(DataDefinitionAnalyzer.DataFieldYamlSerializableRule).WithSpan(13, 12, 13, 32).WithArguments("BadProperty", "Foo", "NotSerializableClass")
|
||||
// /0/Test0.cs(12,12): error RA0033: Data field BadField in data definition Foo is type NotSerializableClass, which is not YAML serializable
|
||||
VerifyCS.Diagnostic(DataDefinitionAnalyzer.DataFieldYamlSerializableRule).WithSpan(12, 12, 12, 32).WithArguments("BadField", "Foo", "NotSerializableClass"),
|
||||
// /0/Test0.cs(15,12): error RA0033: Data field BadProperty in data definition Foo is type NotSerializableClass, which is not YAML serializable
|
||||
VerifyCS.Diagnostic(DataDefinitionAnalyzer.DataFieldYamlSerializableRule).WithSpan(15, 12, 15, 32).WithArguments("BadProperty", "Foo", "NotSerializableClass"),
|
||||
// /0/Test0.cs(18,12): error RA0036: Data field BadNullableField in data definition Foo is type NotSerializableClass, which is not YAML serializable
|
||||
VerifyCS.Diagnostic(DataDefinitionAnalyzer.DataFieldYamlSerializableRule).WithSpan(18, 12, 18, 33).WithArguments("BadNullableField", "Foo", "NotSerializableClass"),
|
||||
// /0/Test0.cs(21,12): error RA0036: Data field BadStructField in data definition Foo is type NotSerializableStruct, which is not YAML serializable
|
||||
VerifyCS.Diagnostic(DataDefinitionAnalyzer.DataFieldYamlSerializableRule).WithSpan(21, 12, 21, 33).WithArguments("BadStructField", "Foo", "NotSerializableStruct"),
|
||||
// /0/Test0.cs(24,12): error RA0036: Data field BadStructProperty in data definition Foo is type NotSerializableStruct, which is not YAML serializable
|
||||
VerifyCS.Diagnostic(DataDefinitionAnalyzer.DataFieldYamlSerializableRule).WithSpan(24, 12, 24, 33).WithArguments("BadStructProperty", "Foo", "NotSerializableStruct"),
|
||||
// /0/Test0.cs(27,12): error RA0036: Data field BadNullableStructField in data definition Foo is type NotSerializableStruct, which is not YAML serializable
|
||||
VerifyCS.Diagnostic(DataDefinitionAnalyzer.DataFieldYamlSerializableRule).WithSpan(27, 12, 27, 34).WithArguments("BadNullableStructField", "Foo", "NotSerializableStruct"),
|
||||
// /0/Test0.cs(30,12): error RA0036: Data field BadNullableStructProperty in data definition Foo is type NotSerializableStruct, which is not YAML serializable
|
||||
VerifyCS.Diagnostic(DataDefinitionAnalyzer.DataFieldYamlSerializableRule).WithSpan(30, 12, 30, 34).WithArguments("BadNullableStructProperty", "Foo", "NotSerializableStruct")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\Robust.Shared\Analyzers\AccessAttribute.cs" LogicalName="Robust.Shared.Analyzers.AccessAttribute.cs" LinkBase="Implementations" />
|
||||
<EmbeddedResource Include="..\Robust.Shared\Analyzers\AccessPermissions.cs" LogicalName="Robust.Shared.Analyzers.AccessPermissions.cs" LinkBase="Implementations" />
|
||||
<EmbeddedResource Include="..\Robust.Shared\Analyzers\ComponentNetworkGeneratorAuxiliary.cs" LogicalName="Robust.Shared.Analyzers.ComponentNetworkGeneratorAuxiliary.cs" LinkBase="Implementations" />
|
||||
<EmbeddedResource Include="..\Robust.Shared\Analyzers\MustCallBaseAttribute.cs" LogicalName="Robust.Shared.IoC.MustCallBaseAttribute.cs" LinkBase="Implementations" />
|
||||
<EmbeddedResource Include="..\Robust.Shared\Analyzers\PreferNonGenericVariantForAttribute.cs" LogicalName="Robust.Shared.Analyzers.PreferNonGenericVariantForAttribute.cs" LinkBase="Implementations" />
|
||||
<EmbeddedResource Include="..\Robust.Shared\Analyzers\PreferOtherTypeAttribute.cs" LogicalName="Robust.Shared.Analyzers.PreferOtherTypeAttribute.cs" LinkBase="Implementations" />
|
||||
|
||||
85
Robust.Analyzers/AfterAutoHandleStateAnalyzer.cs
Normal file
85
Robust.Analyzers/AfterAutoHandleStateAnalyzer.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
#nullable enable
|
||||
using System.Collections.Immutable;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Diagnostics;
|
||||
using Microsoft.CodeAnalysis.Operations;
|
||||
using Robust.Roslyn.Shared;
|
||||
|
||||
namespace Robust.Analyzers;
|
||||
|
||||
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
||||
public sealed class AfterAutoHandleStateAnalyzer : DiagnosticAnalyzer
|
||||
{
|
||||
private const string AfterAutoHandleStateEventName = "AfterAutoHandleStateEvent";
|
||||
private const string AutoGenStateAttribute = "Robust.Shared.Analyzers.AutoGenerateComponentStateAttribute";
|
||||
private const string SubscribeLocalEventName = "SubscribeLocalEvent";
|
||||
|
||||
public static readonly DiagnosticDescriptor MissingAttribute = new(
|
||||
Diagnostics.IdAutoGenStateAttributeMissing,
|
||||
"Unreachable AfterAutoHandleState subscription",
|
||||
"Tried to subscribe to AfterAutoHandleStateEvent for '{0}' which doesn't have an "
|
||||
+ "AutoGenerateComponentState attribute",
|
||||
"Usage",
|
||||
DiagnosticSeverity.Error,
|
||||
true,
|
||||
// Does this even show up anywhere in Rider? >:(
|
||||
"You must mark your component with '[AutoGenerateComponentState(true)]' to subscribe to this event."
|
||||
);
|
||||
|
||||
public static readonly DiagnosticDescriptor MissingAttributeParam = new(
|
||||
Diagnostics.IdAutoGenStateParamMissing,
|
||||
"Unreachable AfterAutoHandleState subscription",
|
||||
"Tried to subscribe to AfterAutoHandleStateEvent for '{0}' which doesn't have "
|
||||
+ "raiseAfterAutoHandleState set",
|
||||
"Usage",
|
||||
DiagnosticSeverity.Error,
|
||||
true,
|
||||
"The AutoGenerateComponentState attribute must be passed 'true' in order to subscribe to this event."
|
||||
);
|
||||
|
||||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics =>
|
||||
[MissingAttribute, MissingAttributeParam];
|
||||
|
||||
public override void Initialize(AnalysisContext context)
|
||||
{
|
||||
// This is more to stop user error rather than code generation error
|
||||
// (Plus this shouldn't affect code gen anyway)
|
||||
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
|
||||
context.EnableConcurrentExecution();
|
||||
|
||||
context.RegisterCompilationStartAction(compilationContext =>
|
||||
{
|
||||
var autoGenStateAttribute = compilationContext.Compilation.GetTypeByMetadataName(AutoGenStateAttribute);
|
||||
// No attribute, no analyzer.
|
||||
if (autoGenStateAttribute is null)
|
||||
return;
|
||||
|
||||
compilationContext.RegisterOperationAction(
|
||||
analysisContext => CheckEventSubscription(analysisContext, autoGenStateAttribute),
|
||||
OperationKind.Invocation);
|
||||
});
|
||||
}
|
||||
|
||||
private static void CheckEventSubscription(OperationAnalysisContext context, ITypeSymbol autoGenStateAttribute)
|
||||
{
|
||||
if (context.Operation is not IInvocationOperation operation)
|
||||
return;
|
||||
|
||||
// Check the method has the right name and has the right type args
|
||||
if (operation.TargetMethod is not
|
||||
{ Name: SubscribeLocalEventName, TypeArguments: [var component, { Name: AfterAutoHandleStateEventName }] })
|
||||
return;
|
||||
|
||||
// Search the component's attributes for something matching autoGenStateAttribute
|
||||
AttributeHelper.HasAttribute(component, autoGenStateAttribute, out var autoGenAttribute);
|
||||
|
||||
// First argument is raiseAfterAutoHandleState—note it shouldn't ever
|
||||
// be null, since it has a default, but eh.
|
||||
if (autoGenAttribute?.ConstructorArguments[0].Value is true)
|
||||
return;
|
||||
|
||||
context.ReportDiagnostic(Diagnostic.Create(autoGenAttribute is null ? MissingAttribute : MissingAttributeParam,
|
||||
operation.Syntax.GetLocation(),
|
||||
component.Name));
|
||||
}
|
||||
}
|
||||
@@ -186,6 +186,8 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
|
||||
if (context.SemanticModel.GetSymbolInfo(field.Declaration.Type).Symbol is not ITypeSymbol fieldTypeSymbol)
|
||||
continue;
|
||||
|
||||
fieldTypeSymbol = TypeSymbolHelper.GetNullableUnderlyingTypeOrSelf(fieldTypeSymbol);
|
||||
|
||||
if (IsNotYamlSerializable(fieldSymbol, fieldTypeSymbol))
|
||||
{
|
||||
context.ReportDiagnostic(Diagnostic.Create(DataFieldYamlSerializableRule,
|
||||
@@ -239,6 +241,8 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
|
||||
if (context.SemanticModel.GetSymbolInfo(property.Type).Symbol is not ITypeSymbol propertyTypeSymbol)
|
||||
return;
|
||||
|
||||
propertyTypeSymbol = TypeSymbolHelper.GetNullableUnderlyingTypeOrSelf(propertyTypeSymbol);
|
||||
|
||||
if (IsNotYamlSerializable(propertySymbol, propertyTypeSymbol))
|
||||
{
|
||||
context.ReportDiagnostic(Diagnostic.Create(DataFieldYamlSerializableRule,
|
||||
|
||||
@@ -6,7 +6,7 @@ using Xilium.CefGlue;
|
||||
|
||||
namespace Robust.Client.WebView.Cef
|
||||
{
|
||||
public static class Program
|
||||
internal static class Program
|
||||
{
|
||||
// This was supposed to be the main entry for the subprocess program... It doesn't work.
|
||||
public static int Main(string[] args)
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -24,6 +25,7 @@ namespace Robust.Client.WebView.Cef
|
||||
|
||||
[Dependency] private readonly IDependencyCollection _dependencyCollection = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IGameControllerInternal _gameController = default!;
|
||||
[Dependency] private readonly IResourceManagerInternal _resourceManager = default!;
|
||||
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
@@ -61,7 +63,10 @@ namespace Robust.Client.WebView.Cef
|
||||
|
||||
var cachePath = "";
|
||||
if (_resourceManager.UserData is WritableDirProvider userData)
|
||||
cachePath = userData.GetFullPath(new ResPath("/cef_cache"));
|
||||
{
|
||||
var rootDir = UserDataDir.GetRootUserDataDir(_gameController);
|
||||
cachePath = Path.Combine(rootDir, "cef_cache", "0");
|
||||
}
|
||||
|
||||
var settings = new CefSettings()
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using OpenTK.Audio.OpenAL.Extensions.Creative.EFX;
|
||||
using Robust.Client.Audio.Sources;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Shared;
|
||||
@@ -145,7 +144,7 @@ internal sealed partial class AudioManager : IAudioInternal
|
||||
private static void RemoveEfx((int sourceHandle, int filterHandle) handles)
|
||||
{
|
||||
if (handles.filterHandle != 0)
|
||||
EFX.DeleteFilter(handles.filterHandle);
|
||||
ALC.EFX.DeleteFilter(handles.filterHandle);
|
||||
}
|
||||
|
||||
private void _checkAlcError(ALDevice device,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using OpenTK.Audio.OpenAL.Extensions.Creative.EFX;
|
||||
using Robust.Client.Audio.Effects;
|
||||
using Robust.Shared.Audio.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using OpenTK.Audio.OpenAL.Extensions.Creative.EFX;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Effects;
|
||||
using Robust.Shared.Maths;
|
||||
@@ -16,16 +16,16 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
|
||||
public AudioEffect(IAudioInternal manager)
|
||||
{
|
||||
Handle = EFX.GenEffect();
|
||||
Handle = ALC.EFX.GenEffect();
|
||||
_master = manager;
|
||||
EFX.Effect(Handle, EffectInteger.EffectType, (int) EffectType.EaxReverb);
|
||||
ALC.EFX.Effect(Handle, EffectInteger.EffectType, (int) EffectType.EaxReverb);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Handle != 0)
|
||||
{
|
||||
EFX.DeleteEffect(Handle);
|
||||
ALC.EFX.DeleteEffect(Handle);
|
||||
Handle = 0;
|
||||
}
|
||||
}
|
||||
@@ -44,14 +44,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbDensity, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbDensity, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbDensity, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbDensity, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -62,14 +62,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbDiffusion, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbDiffusion, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbDiffusion, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbDiffusion, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -80,14 +80,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbGain, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbGain, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbGain, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbGain, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -98,14 +98,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbGainHF, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbGainHF, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbGainHF, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbGainHF, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -116,14 +116,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbGainLF, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbGainLF, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbGainLF, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbGainLF, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -134,14 +134,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbDecayTime, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbDecayTime, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbDecayTime, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbDecayTime, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -152,14 +152,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbDecayHFRatio, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbDecayHFRatio, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbDecayHFRatio, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbDecayHFRatio, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -170,14 +170,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbDecayLFRatio, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbDecayLFRatio, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbDecayLFRatio, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbDecayLFRatio, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -188,14 +188,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbReflectionsGain, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbReflectionsGain, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbReflectionsGain, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbReflectionsGain, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -206,14 +206,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbReflectionsDelay, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbReflectionsDelay, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbReflectionsDelay, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbReflectionsDelay, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -224,7 +224,7 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
var value = EFX.GetEffect(Handle, EffectVector3.EaxReverbReflectionsPan);
|
||||
var value = ALC.EFX.GetEffect(Handle, EffectVector3.EaxReverbReflectionsPan);
|
||||
_master._checkAlError();
|
||||
return new Vector3(value.X, value.Z, value.Y);
|
||||
}
|
||||
@@ -232,7 +232,7 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
{
|
||||
_checkDisposed();
|
||||
var openVec = new OpenTK.Mathematics.Vector3(value.X, value.Y, value.Z);
|
||||
EFX.Effect(Handle, EffectVector3.EaxReverbReflectionsPan, ref openVec);
|
||||
ALC.EFX.Effect(Handle, EffectVector3.EaxReverbReflectionsPan, ref openVec);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -243,14 +243,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbLateReverbGain, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbLateReverbGain, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbLateReverbGain, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbLateReverbGain, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -261,14 +261,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbLateReverbDelay, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbLateReverbDelay, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbLateReverbDelay, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbLateReverbDelay, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -279,7 +279,7 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
var value = EFX.GetEffect(Handle, EffectVector3.EaxReverbLateReverbPan);
|
||||
var value = ALC.EFX.GetEffect(Handle, EffectVector3.EaxReverbLateReverbPan);
|
||||
_master._checkAlError();
|
||||
return new Vector3(value.X, value.Z, value.Y);
|
||||
}
|
||||
@@ -287,7 +287,7 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
{
|
||||
_checkDisposed();
|
||||
var openVec = new OpenTK.Mathematics.Vector3(value.X, value.Y, value.Z);
|
||||
EFX.Effect(Handle, EffectVector3.EaxReverbLateReverbPan, ref openVec);
|
||||
ALC.EFX.Effect(Handle, EffectVector3.EaxReverbLateReverbPan, ref openVec);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -298,14 +298,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbEchoTime, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbEchoTime, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbEchoTime, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbEchoTime, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -316,14 +316,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbEchoDepth, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbEchoDepth, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbEchoDepth, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbEchoDepth, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -334,14 +334,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbModulationTime, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbModulationTime, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbModulationTime, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbModulationTime, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -352,14 +352,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbModulationDepth, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbModulationDepth, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbModulationDepth, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbModulationDepth, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -370,14 +370,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbAirAbsorptionGainHF, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbAirAbsorptionGainHF, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbAirAbsorptionGainHF, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbAirAbsorptionGainHF, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -388,14 +388,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbHFReference, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbHFReference, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbHFReference, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbHFReference, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -406,14 +406,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbLFReference, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbLFReference, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbLFReference, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbLFReference, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -424,14 +424,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectFloat.EaxReverbRoomRolloffFactor, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectFloat.EaxReverbRoomRolloffFactor, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectFloat.EaxReverbRoomRolloffFactor, value);
|
||||
ALC.EFX.Effect(Handle, EffectFloat.EaxReverbRoomRolloffFactor, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
@@ -442,14 +442,14 @@ internal sealed class AudioEffect : IAudioEffect
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.GetEffect(Handle, EffectInteger.EaxReverbDecayHFLimit, out var value);
|
||||
ALC.EFX.GetEffect(Handle, EffectInteger.EaxReverbDecayHFLimit, out var value);
|
||||
_master._checkAlError();
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_checkDisposed();
|
||||
EFX.Effect(Handle, EffectInteger.EaxReverbDecayHFLimit, value);
|
||||
ALC.EFX.Effect(Handle, EffectInteger.EaxReverbDecayHFLimit, value);
|
||||
_master._checkAlError();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using OpenTK.Audio.OpenAL.Extensions.Creative.EFX;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using Robust.Shared.Audio.Effects;
|
||||
|
||||
namespace Robust.Client.Audio.Effects;
|
||||
@@ -6,13 +6,13 @@ namespace Robust.Client.Audio.Effects;
|
||||
/// <inheritdoc />
|
||||
internal sealed class AuxiliaryAudio : IAuxiliaryAudio
|
||||
{
|
||||
internal int Handle = EFX.GenAuxiliaryEffectSlot();
|
||||
internal int Handle = ALC.EFX.GenAuxiliaryEffectSlot();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Handle != -1)
|
||||
{
|
||||
EFX.DeleteAuxiliaryEffectSlot(Handle);
|
||||
ALC.EFX.DeleteAuxiliaryEffectSlot(Handle);
|
||||
Handle = -1;
|
||||
}
|
||||
}
|
||||
@@ -22,11 +22,11 @@ internal sealed class AuxiliaryAudio : IAuxiliaryAudio
|
||||
{
|
||||
if (effect is AudioEffect audEffect)
|
||||
{
|
||||
EFX.AuxiliaryEffectSlot(Handle, EffectSlotInteger.Effect, audEffect.Handle);
|
||||
ALC.EFX.AuxiliaryEffectSlot(Handle, EffectSlotInteger.Effect, audEffect.Handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
EFX.AuxiliaryEffectSlot(Handle, EffectSlotInteger.Effect, 0);
|
||||
ALC.EFX.AuxiliaryEffectSlot(Handle, EffectSlotInteger.Effect, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,4 +213,6 @@ public interface IMidiRenderer : IDisposable
|
||||
/// Actually disposes of this renderer. Do NOT use outside the MIDI thread.
|
||||
/// </summary>
|
||||
internal void InternalDispose();
|
||||
|
||||
byte MinVolume { get; set; }
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ internal sealed partial class MidiManager : IMidiManager
|
||||
[Dependency] private readonly IRuntimeLog _runtime = default!;
|
||||
|
||||
private AudioSystem _audioSys = default!;
|
||||
private SharedPhysicsSystem _broadPhaseSystem = default!;
|
||||
private SharedPhysicsSystem _physics = default!;
|
||||
private SharedTransformSystem _xformSystem = default!;
|
||||
|
||||
public IReadOnlyList<IMidiRenderer> Renderers
|
||||
@@ -81,7 +81,7 @@ internal sealed partial class MidiManager : IMidiManager
|
||||
private Thread? _midiThread;
|
||||
private ISawmill _midiSawmill = default!;
|
||||
private float _gain = 0f;
|
||||
private bool _volumeDirty = true;
|
||||
private bool _gainDirty = true;
|
||||
|
||||
// Not reliable until Fluidsynth is initialized!
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
@@ -96,7 +96,7 @@ internal sealed partial class MidiManager : IMidiManager
|
||||
return;
|
||||
|
||||
_cfgMan.SetCVar(CVars.MidiVolume, clamped);
|
||||
_volumeDirty = true;
|
||||
_gainDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,8 @@ internal sealed partial class MidiManager : IMidiManager
|
||||
"/usr/share/sounds/sf2/TimGM6mb.sf2",
|
||||
};
|
||||
|
||||
private static readonly string WindowsSoundfont = $@"{Environment.GetEnvironmentVariable("SystemRoot")}\system32\drivers\gm.dls";
|
||||
private static readonly string WindowsSoundfont =
|
||||
$@"{Environment.GetEnvironmentVariable("SystemRoot")}\system32\drivers\gm.dls";
|
||||
|
||||
private const string OsxSoundfont =
|
||||
"/System/Library/Components/CoreAudio.component/Contents/Resources/gs_instruments.dls";
|
||||
@@ -145,11 +146,13 @@ internal sealed partial class MidiManager : IMidiManager
|
||||
{
|
||||
if (FluidsynthInitialized || _failedInitialize) return;
|
||||
|
||||
_cfgMan.OnValueChanged(CVars.MidiVolume, value =>
|
||||
{
|
||||
_gain = value;
|
||||
_volumeDirty = true;
|
||||
}, true);
|
||||
_cfgMan.OnValueChanged(CVars.MidiVolume,
|
||||
value =>
|
||||
{
|
||||
_gain = value;
|
||||
_gainDirty = true;
|
||||
},
|
||||
true);
|
||||
|
||||
_midiSawmill = _logger.GetSawmill("midi");
|
||||
#if DEBUG
|
||||
@@ -167,13 +170,15 @@ internal sealed partial class MidiManager : IMidiManager
|
||||
// not a directory, preserve the old file and create an actual directory
|
||||
else if (!_resourceManager.UserData.IsDir(CustomSoundfontDirectory))
|
||||
{
|
||||
_resourceManager.UserData.Rename(CustomSoundfontDirectory, CustomSoundfontDirectory.WithName(CustomSoundfontDirectory.Filename + ".old"));
|
||||
_resourceManager.UserData.Rename(CustomSoundfontDirectory,
|
||||
CustomSoundfontDirectory.WithName(CustomSoundfontDirectory.Filename + ".old"));
|
||||
_resourceManager.UserData.CreateDir(CustomSoundfontDirectory);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
NFluidsynth.Logger.SetLoggerMethod(_loggerDelegate); // Will cause a safe DllNotFoundException if not available.
|
||||
NFluidsynth.Logger
|
||||
.SetLoggerMethod(_loggerDelegate); // Will cause a safe DllNotFoundException if not available.
|
||||
|
||||
_settings = new Settings();
|
||||
_settings["synth.sample-rate"].DoubleValue = 44100;
|
||||
@@ -193,7 +198,7 @@ internal sealed partial class MidiManager : IMidiManager
|
||||
//_settings["synth.verbose"].IntValue = 1; // Useful for debugging.
|
||||
|
||||
var midiParallel = _cfgMan.GetCVar(CVars.MidiParallelism);
|
||||
_settings["synth.polyphony"].IntValue = Math.Clamp(1024 + (int)(Math.Log2(midiParallel) * 2048), 1, 65535);
|
||||
_settings["synth.polyphony"].IntValue = Math.Clamp(1024 + (int) (Math.Log2(midiParallel) * 2048), 1, 65535);
|
||||
_settings["synth.cpu-cores"].IntValue = Math.Clamp(midiParallel, 1, 256);
|
||||
|
||||
_midiSawmill.Debug($"Synth Cores: {_settings["synth.cpu-cores"].IntValue}");
|
||||
@@ -219,7 +224,7 @@ internal sealed partial class MidiManager : IMidiManager
|
||||
};
|
||||
|
||||
_audioSys = _entityManager.EntitySysManager.GetEntitySystem<AudioSystem>();
|
||||
_broadPhaseSystem = _entityManager.EntitySysManager.GetEntitySystem<SharedPhysicsSystem>();
|
||||
_physics = _entityManager.EntitySysManager.GetEntitySystem<SharedPhysicsSystem>();
|
||||
_xformSystem = _entityManager.System<SharedTransformSystem>();
|
||||
_entityManager.GetEntityQuery<PhysicsComponent>();
|
||||
_entityManager.GetEntityQuery<TransformComponent>();
|
||||
@@ -263,7 +268,8 @@ internal sealed partial class MidiManager : IMidiManager
|
||||
{
|
||||
soundfontLoader.SetCallbacks(_soundfontLoaderCallbacks);
|
||||
|
||||
var renderer = new MidiRenderer(_settings!, soundfontLoader, mono, this, _audio, _taskManager, _midiSawmill);
|
||||
var renderer =
|
||||
new MidiRenderer(_settings!, soundfontLoader, mono, this, _audio, _taskManager, _midiSawmill);
|
||||
|
||||
LoadSoundFontSetup(renderer);
|
||||
|
||||
@@ -273,6 +279,7 @@ internal sealed partial class MidiManager : IMidiManager
|
||||
{
|
||||
_renderers.Add(renderer);
|
||||
}
|
||||
|
||||
return renderer;
|
||||
}
|
||||
finally
|
||||
@@ -309,99 +316,23 @@ internal sealed partial class MidiManager : IMidiManager
|
||||
|
||||
_updateSemaphore.Release();
|
||||
|
||||
_volumeDirty = false;
|
||||
_gainDirty = false;
|
||||
}
|
||||
|
||||
private void UpdateRenderer(IMidiRenderer renderer, MapCoordinates listener)
|
||||
{
|
||||
// TODO: This should be sharing more code with AudioSystem.
|
||||
try
|
||||
{
|
||||
if (renderer.Disposed)
|
||||
return;
|
||||
|
||||
if (_volumeDirty)
|
||||
{
|
||||
renderer.Source.Gain = Gain;
|
||||
}
|
||||
|
||||
if (!renderer.Mono)
|
||||
{
|
||||
renderer.Source.Global = true;
|
||||
return;
|
||||
}
|
||||
|
||||
MapCoordinates mapPos;
|
||||
|
||||
if (renderer.TrackingEntity is {} trackedEntity && !_entityManager.Deleted(trackedEntity))
|
||||
{
|
||||
renderer.TrackingCoordinates = _xformSystem.GetMapCoordinates(renderer.TrackingEntity.Value);
|
||||
|
||||
// Pause it if the attached entity is paused.
|
||||
if (_entityManager.IsPaused(renderer.TrackingEntity))
|
||||
{
|
||||
renderer.Source.Pause();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (renderer.TrackingCoordinates == null)
|
||||
{
|
||||
renderer.Source.Pause();
|
||||
return;
|
||||
}
|
||||
|
||||
mapPos = renderer.TrackingCoordinates.Value;
|
||||
|
||||
// If it's on a different map then just mute it, not pause.
|
||||
if (mapPos.MapId == MapId.Nullspace || mapPos.MapId != listener.MapId)
|
||||
{
|
||||
renderer.Source.Gain = 0f;
|
||||
return;
|
||||
}
|
||||
|
||||
// Was previously muted maybe so try unmuting it?
|
||||
if (renderer.Source.Gain == 0f)
|
||||
{
|
||||
renderer.Source.Gain = Gain;
|
||||
}
|
||||
|
||||
var worldPos = mapPos.Position;
|
||||
var delta = worldPos - listener.Position;
|
||||
var distance = delta.Length();
|
||||
|
||||
// Update position
|
||||
// Out of range so just clip it for us.
|
||||
if (distance > renderer.Source.MaxDistance)
|
||||
{
|
||||
// Still keeps the source playing, just with no volume.
|
||||
renderer.Source.Gain = 0f;
|
||||
return;
|
||||
}
|
||||
|
||||
// Same imprecision suppression as audiosystem.
|
||||
if (distance > 0f && distance < 0.01f)
|
||||
{
|
||||
worldPos = listener.Position;
|
||||
delta = Vector2.Zero;
|
||||
distance = 0f;
|
||||
}
|
||||
|
||||
renderer.Source.Position = worldPos;
|
||||
|
||||
// Update velocity (doppler).
|
||||
if (!_entityManager.Deleted(renderer.TrackingEntity))
|
||||
{
|
||||
var velocity = _broadPhaseSystem.GetMapLinearVelocity(renderer.TrackingEntity.Value);
|
||||
renderer.Source.Velocity = velocity;
|
||||
}
|
||||
if (!renderer.Source.Global)
|
||||
UpdateLocalRenderer(renderer, listener);
|
||||
else
|
||||
{
|
||||
renderer.Source.Velocity = Vector2.Zero;
|
||||
}
|
||||
|
||||
// Update occlusion
|
||||
var occlusion = _audioSys.GetOcclusion(listener, delta, distance, renderer.TrackingEntity);
|
||||
renderer.Source.Occlusion = occlusion;
|
||||
UpdateGlobalRenderer(renderer);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -409,6 +340,58 @@ internal sealed partial class MidiManager : IMidiManager
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateLocalRenderer(IMidiRenderer renderer, MapCoordinates listener)
|
||||
{
|
||||
if (_entityManager.Deleted(renderer.TrackingEntity) || _entityManager.IsPaused(renderer.TrackingEntity))
|
||||
{
|
||||
renderer.Source.Gain = 0f;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MapCoordinates mapCoords = _xformSystem.GetMapCoordinates(renderer.TrackingEntity.Value);
|
||||
renderer.TrackingCoordinates = mapCoords;
|
||||
|
||||
if (mapCoords.MapId == MapId.Nullspace || mapCoords.MapId != listener.MapId)
|
||||
{
|
||||
renderer.Source.Gain = 0f;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2 mapPosition = mapCoords.Position;
|
||||
Vector2 listenerDelta = mapPosition - listener.Position;
|
||||
var listenerDeltaLength = listenerDelta.Length();
|
||||
|
||||
if (listenerDeltaLength > renderer.Source.MaxDistance)
|
||||
{
|
||||
renderer.Source.Gain = 0f;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (listenerDeltaLength is > 0f and < 0.01f)
|
||||
{
|
||||
mapPosition = listener.Position;
|
||||
listenerDelta = Vector2.Zero;
|
||||
listenerDeltaLength = 0f;
|
||||
}
|
||||
|
||||
if (_gainDirty || renderer.Source.Gain == 0f)
|
||||
renderer.Source.Gain = Gain;
|
||||
|
||||
renderer.Source.Position = mapPosition;
|
||||
renderer.Source.Velocity = _physics.GetMapLinearVelocity(renderer.TrackingEntity.Value);
|
||||
renderer.Source.Occlusion =
|
||||
_audioSys.GetOcclusion(listener, listenerDelta, listenerDeltaLength, renderer.TrackingEntity);
|
||||
}
|
||||
|
||||
private void UpdateGlobalRenderer(IMidiRenderer renderer)
|
||||
{
|
||||
if (_gainDirty)
|
||||
renderer.Source.Gain = Gain;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Main method for the thread rendering the midi audio.
|
||||
/// </summary>
|
||||
@@ -428,7 +411,7 @@ internal sealed partial class MidiManager : IMidiManager
|
||||
{
|
||||
if (!renderer.Disposed)
|
||||
{
|
||||
if (renderer.Master is { Disposed: true })
|
||||
if (renderer.Master is {Disposed: true})
|
||||
renderer.Master = null;
|
||||
|
||||
renderer.Render();
|
||||
|
||||
@@ -214,6 +214,11 @@ internal sealed partial class MidiRenderer : IMidiRenderer
|
||||
[ViewVariables]
|
||||
public BitArray FilteredChannels { get; } = new(RobustMidiEvent.MaxChannels);
|
||||
|
||||
[ViewVariables]
|
||||
public byte MinVolume { get => _minVolume; set => _minVolume = value; }
|
||||
|
||||
private byte _minVolume;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public byte? VelocityOverride { get; set; } = null;
|
||||
|
||||
@@ -539,14 +544,7 @@ internal sealed partial class MidiRenderer : IMidiRenderer
|
||||
if (velocity <= 0)
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
_synth.NoteOn(channel, key, velocity);
|
||||
}
|
||||
catch (FluidSynthInteropException e)
|
||||
{
|
||||
_midiSawmill.Error($"CH:{channel} KEY:{key} VEL:{velocity} {e.ToStringBetter()}");
|
||||
}
|
||||
_synth.TryNoteOn(channel, key, velocity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,7 +572,7 @@ internal sealed partial class MidiRenderer : IMidiRenderer
|
||||
{
|
||||
case RobustMidiCommand.NoteOff:
|
||||
_rendererState.NoteVelocities.AsSpan[midiEvent.Channel].AsSpan[midiEvent.Key] = 0;
|
||||
_synth.NoteOff(midiEvent.Channel, midiEvent.Key);
|
||||
_synth.TryNoteOff(midiEvent.Channel, midiEvent.Key);
|
||||
|
||||
break;
|
||||
case RobustMidiCommand.NoteOn:
|
||||
@@ -583,7 +581,7 @@ internal sealed partial class MidiRenderer : IMidiRenderer
|
||||
if (velocity == 0)
|
||||
{
|
||||
_rendererState.NoteVelocities.AsSpan[midiEvent.Channel].AsSpan[midiEvent.Key] = 0;
|
||||
_synth.NoteOn(midiEvent.Channel, midiEvent.Key, velocity);
|
||||
_synth.TryNoteOn(midiEvent.Channel, midiEvent.Key, velocity);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -591,10 +589,13 @@ internal sealed partial class MidiRenderer : IMidiRenderer
|
||||
if (FilteredChannels[midiEvent.Channel])
|
||||
break;
|
||||
|
||||
velocity = VelocityOverride ?? midiEvent.Velocity;
|
||||
if (MinVolume > 0)
|
||||
velocity = (byte)Math.Floor(MathHelper.Lerp(MinVolume, 127, (float)velocity / 127));
|
||||
|
||||
velocity = VelocityOverride ?? velocity;
|
||||
|
||||
_rendererState.NoteVelocities.AsSpan[midiEvent.Channel].AsSpan[midiEvent.Key] = velocity;
|
||||
_synth.NoteOn(midiEvent.Channel, midiEvent.Key, velocity);
|
||||
_synth.TryNoteOn(midiEvent.Channel, midiEvent.Key, velocity);
|
||||
|
||||
break;
|
||||
case RobustMidiCommand.AfterTouch:
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using OpenTK.Audio.OpenAL.Extensions.Creative.EFX;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -77,7 +76,7 @@ internal sealed class AudioSource : BaseAudioSource
|
||||
else
|
||||
{
|
||||
if (FilterHandle != 0)
|
||||
EFX.DeleteFilter(FilterHandle);
|
||||
ALC.EFX.DeleteFilter(FilterHandle);
|
||||
|
||||
AL.DeleteSource(SourceHandle);
|
||||
Master.RemoveAudioSource(SourceHandle);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using OpenTK.Audio.OpenAL.Extensions.Creative.EFX;
|
||||
using Robust.Client.Audio.Effects;
|
||||
using Robust.Shared.Audio.Effects;
|
||||
using Robust.Shared.Audio.Sources;
|
||||
@@ -82,9 +81,9 @@ public abstract class BaseAudioSource : IAudioSource
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
var state = AL.GetSourceState(SourceHandle);
|
||||
var state = AL.GetSource(SourceHandle, ALGetSourcei.SourceState);
|
||||
Master._checkAlError();
|
||||
return state == ALSourceState.Playing;
|
||||
return state == (int)ALSourceState.Playing;
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -362,11 +361,11 @@ public abstract class BaseAudioSource : IAudioSource
|
||||
|
||||
if (audio is AuxiliaryAudio impAudio)
|
||||
{
|
||||
EFX.Source(SourceHandle, EFXSourceInteger3.AuxiliarySendFilter, impAudio.Handle, 0, 0);
|
||||
ALC.EFX.Source(SourceHandle, EFXSourceInteger3.AuxiliarySendFilter, impAudio.Handle, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
EFX.Source(SourceHandle, EFXSourceInteger3.AuxiliarySendFilter, 0, 0, 0);
|
||||
ALC.EFX.Source(SourceHandle, EFXSourceInteger3.AuxiliarySendFilter, 0, 0, 0);
|
||||
}
|
||||
|
||||
Master._checkAlError();
|
||||
@@ -376,12 +375,12 @@ public abstract class BaseAudioSource : IAudioSource
|
||||
{
|
||||
if (FilterHandle == 0)
|
||||
{
|
||||
FilterHandle = EFX.GenFilter();
|
||||
EFX.Filter(FilterHandle, FilterInteger.FilterType, (int) FilterType.Lowpass);
|
||||
FilterHandle = ALC.EFX.GenFilter();
|
||||
ALC.EFX.Filter(FilterHandle, FilterInteger.FilterType, (int) FilterType.Lowpass);
|
||||
}
|
||||
|
||||
EFX.Filter(FilterHandle, FilterFloat.LowpassGain, gain);
|
||||
EFX.Filter(FilterHandle, FilterFloat.LowpassGainHF, cutoff);
|
||||
ALC.EFX.Filter(FilterHandle, FilterFloat.LowpassGain, gain);
|
||||
ALC.EFX.Filter(FilterHandle, FilterFloat.LowpassGainHF, cutoff);
|
||||
AL.Source(SourceHandle, ALSourcei.EfxDirectFilter, FilterHandle);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using OpenTK.Audio.OpenAL.Extensions.Creative.EFX;
|
||||
using Robust.Shared.Audio.Sources;
|
||||
|
||||
namespace Robust.Client.Audio.Sources;
|
||||
@@ -37,9 +36,9 @@ internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSourc
|
||||
get
|
||||
{
|
||||
_checkDisposed();
|
||||
var state = AL.GetSourceState(SourceHandle);
|
||||
var state = AL.GetSource(SourceHandle, ALGetSourcei.SourceState);
|
||||
_master._checkAlError();
|
||||
return state == ALSourceState.Playing;
|
||||
return state == (int)ALSourceState.Playing;
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -84,7 +83,7 @@ internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSourc
|
||||
else
|
||||
{
|
||||
if (FilterHandle != 0)
|
||||
EFX.DeleteFilter(FilterHandle);
|
||||
ALC.EFX.DeleteFilter(FilterHandle);
|
||||
|
||||
AL.DeleteSource(SourceHandle);
|
||||
AL.DeleteBuffers(BufferHandles);
|
||||
|
||||
@@ -154,6 +154,7 @@ Suspendisse hendrerit blandit urna ut laoreet. Suspendisse ac elit at erat males
|
||||
|
||||
_sprite = new TabSpriteView();
|
||||
_tabContainer.AddChild(_sprite);
|
||||
_tabContainer.AddChild(TabCursorShapes());
|
||||
}
|
||||
|
||||
public void OnClosed()
|
||||
@@ -210,6 +211,53 @@ Suspendisse hendrerit blandit urna ut laoreet. Suspendisse ac elit at erat males
|
||||
return label;
|
||||
}
|
||||
|
||||
private Control TabCursorShapes()
|
||||
{
|
||||
var box = new BoxContainer
|
||||
{
|
||||
Orientation = BoxContainer.LayoutOrientation.Vertical,
|
||||
};
|
||||
var styleBox = new StyleBoxFlat
|
||||
{
|
||||
BackgroundColor = Color.Black
|
||||
};
|
||||
foreach (var cursorName in Enum.GetNames<CursorShape>())
|
||||
{
|
||||
// Go over names due to duplicate definitions in the enum.
|
||||
var cursor = Enum.Parse<CursorShape>(cursorName);
|
||||
// Wow was I bad at API design.
|
||||
if (cursor == CursorShape.Custom)
|
||||
continue;
|
||||
|
||||
var panel = new PanelContainer
|
||||
{
|
||||
PanelOverride = styleBox,
|
||||
DefaultCursorShape = cursor,
|
||||
MouseFilter = MouseFilterMode.Stop,
|
||||
MinHeight = 30,
|
||||
Children =
|
||||
{
|
||||
new Label
|
||||
{
|
||||
Text = cursorName,
|
||||
VerticalAlignment = VAlignment.Center,
|
||||
Margin = new Thickness(4)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
box.AddChild(panel);
|
||||
}
|
||||
|
||||
return new ScrollContainer
|
||||
{
|
||||
Children = { box },
|
||||
VScrollEnabled = true,
|
||||
HScrollEnabled = false,
|
||||
Name = nameof(Tab.TabCursorShapes),
|
||||
};
|
||||
}
|
||||
|
||||
public void SelectTab(Tab tab)
|
||||
{
|
||||
_tabContainer.CurrentTab = (int)tab;
|
||||
@@ -226,6 +274,7 @@ Suspendisse hendrerit blandit urna ut laoreet. Suspendisse ac elit at erat males
|
||||
TextEdit = 6,
|
||||
RichText = 7,
|
||||
SpriteView = 8,
|
||||
TabCursorShapes = 9,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -387,7 +387,7 @@ namespace Robust.Client
|
||||
|
||||
_prof.Initialize();
|
||||
|
||||
_resManager.Initialize(Options.LoadConfigAndUserData ? userDataDir : null);
|
||||
_resManager.Initialize(Options.LoadConfigAndUserData ? userDataDir : null, hideUserDataDir: true);
|
||||
|
||||
var mountOptions = _commandLineArgs != null
|
||||
? MountOptions.Merge(_commandLineArgs.MountOptions, Options.MountOptions)
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Robust.Client.GameObjects;
|
||||
|
||||
public sealed class ScaleVisualsSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<ScaleVisualsComponent, AppearanceChangeEvent>(OnChangeData);
|
||||
}
|
||||
|
||||
private void OnChangeData(EntityUid uid, ScaleVisualsComponent component, ref AppearanceChangeEvent ev)
|
||||
{
|
||||
if (!ev.AppearanceData.TryGetValue(ScaleVisuals.Scale, out var scale) ||
|
||||
ev.Sprite == null) return;
|
||||
|
||||
var vecScale = (Vector2)scale;
|
||||
|
||||
// Set it directly because prediction may call this multiple times.
|
||||
ev.Sprite.Scale = vecScale;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Log;
|
||||
#if WINDOWS
|
||||
using TerraFX.Interop.Windows;
|
||||
using TerraFX.Interop.DirectX;
|
||||
#endif
|
||||
|
||||
namespace Robust.Client.Graphics.Clyde
|
||||
{
|
||||
@@ -13,6 +17,8 @@ namespace Robust.Client.Graphics.Clyde
|
||||
|
||||
private void InitGLContextManager()
|
||||
{
|
||||
CheckForceCompatMode();
|
||||
|
||||
// Advanced GL contexts currently disabled due to lack of testing etc.
|
||||
if (OperatingSystem.IsWindows() && _cfg.GetCVar(CVars.DisplayAngle))
|
||||
{
|
||||
@@ -55,6 +61,74 @@ namespace Robust.Client.Graphics.Clyde
|
||||
_glContext = new GLContextWindow(this);
|
||||
}
|
||||
|
||||
private void CheckForceCompatMode()
|
||||
{
|
||||
#if WINDOWS
|
||||
// Qualcomm (Snapdragon/Adreno) devices have broken OpenGL drivers on Windows.
|
||||
|
||||
if (CheckIsQualcommDevice())
|
||||
{
|
||||
_sawmillOgl.Info("We appear to be on a Qualcomm device. Enabling compat mode due to broken OpenGL driver");
|
||||
_cfg.OverrideDefault(CVars.DisplayCompat, true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if WINDOWS
|
||||
private static unsafe bool CheckIsQualcommDevice()
|
||||
{
|
||||
// Ideally we would check the OpenGL driver instead... but OpenGL is terrible so that's impossible.
|
||||
// Let's just check with DXGI instead.
|
||||
|
||||
IDXGIFactory1* dxgiFactory;
|
||||
ThrowIfFailed(
|
||||
nameof(DirectX.CreateDXGIFactory1),
|
||||
DirectX.CreateDXGIFactory1(Windows.__uuidof<IDXGIFactory1>(), (void**) &dxgiFactory));
|
||||
|
||||
try
|
||||
{
|
||||
uint idx = 0;
|
||||
IDXGIAdapter* adapter;
|
||||
while (dxgiFactory->EnumAdapters(idx, &adapter) != DXGI.DXGI_ERROR_NOT_FOUND)
|
||||
{
|
||||
try
|
||||
{
|
||||
DXGI_ADAPTER_DESC desc;
|
||||
ThrowIfFailed("GetDesc", adapter->GetDesc(&desc));
|
||||
|
||||
var descString = ((ReadOnlySpan<char>)desc.Description).TrimEnd('\0');
|
||||
if (descString.Contains("qualcomm", StringComparison.OrdinalIgnoreCase) ||
|
||||
descString.Contains("snapdragon", StringComparison.OrdinalIgnoreCase) ||
|
||||
descString.Contains("adreno", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
adapter->Release();
|
||||
}
|
||||
|
||||
idx += 1;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
dxgiFactory->Release();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void ThrowIfFailed(string methodName, HRESULT hr)
|
||||
{
|
||||
if (Windows.FAILED(hr))
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(hr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private struct GLContextSpec
|
||||
{
|
||||
public int Major;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Robust.Client.Input;
|
||||
@@ -101,6 +102,10 @@ namespace Robust.Client.Graphics.Clyde
|
||||
|
||||
_windowingThread = Thread.CurrentThread;
|
||||
|
||||
// Default to SDL3 on ARM64. GLFW is not feature complete there (lacking file dialog implementation)
|
||||
if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
|
||||
_cfg.SetCVar(CVars.DisplayWindowingApi, "sdl3");
|
||||
|
||||
var windowingApi = _cfg.GetCVar(CVars.DisplayWindowingApi);
|
||||
IWindowingImpl winImpl;
|
||||
|
||||
@@ -374,6 +379,8 @@ namespace Robust.Client.Graphics.Clyde
|
||||
if (reg.IsDisposed)
|
||||
return;
|
||||
|
||||
_sawmillWin.Debug($"Destroying window {reg.Id}");
|
||||
|
||||
reg.IsDisposed = true;
|
||||
|
||||
_glContext!.WindowDestroyed(reg);
|
||||
|
||||
@@ -128,7 +128,11 @@ namespace Robust.Client.Graphics.Clyde
|
||||
// macOS cannot.
|
||||
if (OperatingSystem.IsWindows() || OperatingSystem.IsLinux())
|
||||
_cfg.OverrideDefault(CVars.DisplayThreadWindowApi, true);
|
||||
|
||||
#if MACOS
|
||||
// Trust macOS to not need threaded window blitting.
|
||||
// (threaded window blitting is a workaround to avoid having to frequently MakeCurrent() on Windows, as it is broken).
|
||||
_cfg.OverrideDefault(CVars.DisplayThreadWindowBlit, false);
|
||||
#endif
|
||||
_threadWindowBlit = _cfg.GetCVar(CVars.DisplayThreadWindowBlit);
|
||||
_threadWindowApi = _cfg.GetCVar(CVars.DisplayThreadWindowApi);
|
||||
|
||||
|
||||
@@ -102,6 +102,8 @@ namespace Robust.Client.Graphics.Clyde
|
||||
{
|
||||
var data = _windowData[reg.Id];
|
||||
data.BlitDoneEvent?.Set();
|
||||
// Set events so blit thread properly wakes up and notices it needs to shut down.
|
||||
data.BlitStartEvent?.Set();
|
||||
|
||||
_windowData.Remove(reg.Id);
|
||||
}
|
||||
|
||||
@@ -128,6 +128,19 @@ namespace Robust.Client.Graphics.Clyde
|
||||
AddStandardCursor(StandardCursorShape.Hand, CursorShape.Hand);
|
||||
AddStandardCursor(StandardCursorShape.HResize, CursorShape.HResize);
|
||||
AddStandardCursor(StandardCursorShape.VResize, CursorShape.VResize);
|
||||
AddStandardCursor(StandardCursorShape.Progress, CursorShape.Arrow);
|
||||
AddStandardCursor(StandardCursorShape.NWSEResize, CursorShape.Crosshair);
|
||||
AddStandardCursor(StandardCursorShape.NESWResize, CursorShape.Crosshair);
|
||||
AddStandardCursor(StandardCursorShape.Move, CursorShape.Crosshair);
|
||||
AddStandardCursor(StandardCursorShape.NotAllowed, CursorShape.Arrow);
|
||||
AddStandardCursor(StandardCursorShape.NWResize, CursorShape.Crosshair);
|
||||
AddStandardCursor(StandardCursorShape.NResize, CursorShape.VResize);
|
||||
AddStandardCursor(StandardCursorShape.NEResize, CursorShape.Crosshair);
|
||||
AddStandardCursor(StandardCursorShape.EResize, CursorShape.HResize);
|
||||
AddStandardCursor(StandardCursorShape.SEResize, CursorShape.Crosshair);
|
||||
AddStandardCursor(StandardCursorShape.SResize, CursorShape.VResize);
|
||||
AddStandardCursor(StandardCursorShape.SWResize, CursorShape.Crosshair);
|
||||
AddStandardCursor(StandardCursorShape.WResize, CursorShape.HResize);
|
||||
}
|
||||
|
||||
private sealed class CursorImpl : ICursor
|
||||
|
||||
@@ -49,6 +49,7 @@ public static partial class SDL
|
||||
|
||||
public const string SDL_PROP_FILE_DIALOG_NFILTERS_NUMBER = "SDL.filedialog.nfilters";
|
||||
public const string SDL_PROP_FILE_DIALOG_FILTERS_POINTER = "SDL.filedialog.filters";
|
||||
public const string SDL_PROP_FILE_DIALOG_WINDOW_POINTER = "SDL.filedialog.window";
|
||||
|
||||
public static int SDL_VERSIONNUM_MAJOR(int version) => version / 1000000;
|
||||
public static int SDL_VERSIONNUM_MINOR(int version) => version / 1000 % 1000;
|
||||
|
||||
@@ -76,7 +76,7 @@ public static unsafe partial class SDL
|
||||
}
|
||||
}
|
||||
|
||||
private const string nativeLibName = "SDL3";
|
||||
internal const string nativeLibName = "SDL3";
|
||||
|
||||
// /usr/local/include/SDL3/SDL_stdinc.h
|
||||
|
||||
|
||||
@@ -94,6 +94,19 @@ internal partial class Clyde
|
||||
Add(StandardCursorShape.Hand, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_POINTER);
|
||||
Add(StandardCursorShape.HResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_EW_RESIZE);
|
||||
Add(StandardCursorShape.VResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_NS_RESIZE);
|
||||
Add(StandardCursorShape.Progress, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_PROGRESS);
|
||||
Add(StandardCursorShape.NWSEResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_NWSE_RESIZE);
|
||||
Add(StandardCursorShape.NESWResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_NESW_RESIZE);
|
||||
Add(StandardCursorShape.Move, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_MOVE);
|
||||
Add(StandardCursorShape.NotAllowed, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_NOT_ALLOWED);
|
||||
Add(StandardCursorShape.NWResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_NW_RESIZE);
|
||||
Add(StandardCursorShape.NResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_N_RESIZE);
|
||||
Add(StandardCursorShape.NEResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_NE_RESIZE);
|
||||
Add(StandardCursorShape.EResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_E_RESIZE);
|
||||
Add(StandardCursorShape.SEResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_SE_RESIZE);
|
||||
Add(StandardCursorShape.SResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_S_RESIZE);
|
||||
Add(StandardCursorShape.SWResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_SW_RESIZE);
|
||||
Add(StandardCursorShape.WResize, SDL.SDL_SystemCursor.SDL_SYSTEM_CURSOR_W_RESIZE);
|
||||
|
||||
void Add(StandardCursorShape shape, SDL.SDL_SystemCursor sysCursor)
|
||||
{
|
||||
|
||||
@@ -81,6 +81,11 @@ internal partial class Clyde
|
||||
case EventQuit:
|
||||
ProcessEventQuit();
|
||||
break;
|
||||
#if MACOS
|
||||
case EventWindowDestroyed:
|
||||
ProcessEventWindowDestroyed();
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
_sawmill.Error($"Unknown SDL3 event type: {evb.GetType().Name}");
|
||||
break;
|
||||
@@ -255,5 +260,15 @@ internal partial class Clyde
|
||||
{
|
||||
_clyde.SendInputModeChanged();
|
||||
}
|
||||
|
||||
#if MACOS
|
||||
private void ProcessEventWindowDestroyed()
|
||||
{
|
||||
// For some reason, on macOS, closing a secondary window
|
||||
// causes the GL context on the primary thread to crap itself.
|
||||
// Rebinding it seems to fix it.
|
||||
GLMakeContextCurrent(_clyde._mainWindow);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,10 @@ internal partial class Clyde
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Giving a parent window is required to avoid the file dialog being blocking on macOS.
|
||||
var mainWindow = (Sdl3WindowReg)_clyde._mainWindow!;
|
||||
SDL.SDL_SetPointerProperty(props, SDL.SDL_PROP_FILE_DIALOG_WINDOW_POINTER, mainWindow.Sdl3Window);
|
||||
|
||||
var task = ShowFileDialogWithProperties(type, props);
|
||||
|
||||
SDL.SDL_DestroyProperties(props);
|
||||
|
||||
@@ -278,5 +278,9 @@ internal partial class Clyde
|
||||
private sealed class EventKeyMapChanged : EventBase;
|
||||
|
||||
private sealed class EventQuit : EventBase;
|
||||
|
||||
#if MACOS
|
||||
private sealed class EventWindowDestroyed : EventBase;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,10 @@ using Robust.Shared.Maths;
|
||||
using SDL3;
|
||||
using TerraFX.Interop.Windows;
|
||||
using TerraFX.Interop.Xlib;
|
||||
#if WINDOWS
|
||||
using BOOL = TerraFX.Interop.Windows.BOOL;
|
||||
using Windows = TerraFX.Interop.Windows.Windows;
|
||||
#endif
|
||||
using GLAttr = SDL3.SDL.SDL_GLAttr;
|
||||
using X11Window = TerraFX.Interop.Xlib.Window;
|
||||
|
||||
@@ -142,9 +144,12 @@ internal partial class Clyde
|
||||
});
|
||||
}
|
||||
|
||||
private static void WinThreadWinDestroy(CmdWinDestroy cmd)
|
||||
private void WinThreadWinDestroy(CmdWinDestroy cmd)
|
||||
{
|
||||
SDL.SDL_DestroyWindow(cmd.Window);
|
||||
#if MACOS
|
||||
SendEvent(new EventWindowDestroyed());
|
||||
#endif
|
||||
}
|
||||
|
||||
private (nint window, nint context) CreateSdl3WindowForRenderer(
|
||||
@@ -461,6 +466,7 @@ internal partial class Clyde
|
||||
var reg = (Sdl3WindowReg)window;
|
||||
var windowPtr = WinPtr(reg);
|
||||
|
||||
#if WINDOWS
|
||||
// On Windows, SwapBuffers does not correctly sync to the DWM compositor.
|
||||
// This means OpenGL vsync is effectively broken by default on Windows.
|
||||
// We manually sync via DwmFlush(). GLFW does this automatically, SDL3 does not.
|
||||
@@ -473,7 +479,7 @@ internal partial class Clyde
|
||||
var dwmFlush = false;
|
||||
var swapInterval = 0;
|
||||
|
||||
if (OperatingSystem.IsWindows() && !reg.Fullscreen && reg.SwapInterval > 0)
|
||||
if (!reg.Fullscreen && reg.SwapInterval > 0)
|
||||
{
|
||||
BOOL compositing;
|
||||
// 6.2 is Windows 8
|
||||
@@ -492,9 +498,12 @@ internal partial class Clyde
|
||||
swapInterval = reg.SwapInterval;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//_sawmill.Debug($"Swapping: {window.Id} @ {_clyde._gameTiming.CurFrame}");
|
||||
SDL.SDL_GL_SwapWindow(windowPtr);
|
||||
|
||||
#if WINDOWS
|
||||
if (dwmFlush)
|
||||
{
|
||||
var i = swapInterval;
|
||||
@@ -505,6 +514,7 @@ internal partial class Clyde
|
||||
|
||||
SDL.SDL_GL_SetSwapInterval(swapInterval);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public uint? WindowGetX11Id(WindowReg window)
|
||||
@@ -547,17 +557,18 @@ internal partial class Clyde
|
||||
|
||||
public void TextInputSetRect(WindowReg reg, UIBox2i rect, int cursor)
|
||||
{
|
||||
var ratio = ((Sdl3WindowReg)reg).PixelRatio;
|
||||
SendCmd(new CmdTextInputSetRect
|
||||
{
|
||||
Window = WinPtr(reg),
|
||||
Rect = new SDL.SDL_Rect
|
||||
{
|
||||
x = rect.Left,
|
||||
y = rect.Top,
|
||||
w = rect.Width,
|
||||
h = rect.Height
|
||||
x = (int)(rect.Left / ratio.X),
|
||||
y = (int)(rect.Top / ratio.Y),
|
||||
w = (int)(rect.Width / ratio.X),
|
||||
h = (int)(rect.Height / ratio.Y)
|
||||
},
|
||||
Cursor = cursor
|
||||
Cursor = (int)(cursor / ratio.X)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,10 @@ internal partial class Clyde
|
||||
// https://github.com/libsdl-org/SDL/issues/11813
|
||||
SDL.SDL_SetHint(SDL.SDL_HINT_WINDOWS_GAMEINPUT, "0");
|
||||
|
||||
#if MACOS
|
||||
SDL.SDL_SetHint(SDL.SDL_HINT_MAC_OPENGL_ASYNC_DISPATCH, "1");
|
||||
#endif
|
||||
|
||||
var res = SDL.SDL_Init(SDL.SDL_InitFlags.SDL_INIT_VIDEO | SDL.SDL_InitFlags.SDL_INIT_EVENTS);
|
||||
if (!res)
|
||||
{
|
||||
|
||||
@@ -15,6 +15,11 @@ namespace Robust.Client.Graphics
|
||||
/// </summary>
|
||||
IBeam,
|
||||
|
||||
/// <summary>
|
||||
/// Alias for <see cref="IBeam"/>.
|
||||
/// </summary>
|
||||
Text = IBeam,
|
||||
|
||||
/// <summary>
|
||||
/// The crosshair shape. Used when dragging and dropping.
|
||||
/// </summary>
|
||||
@@ -25,16 +30,135 @@ namespace Robust.Client.Graphics
|
||||
/// </summary>
|
||||
Hand,
|
||||
|
||||
/// <summary>
|
||||
/// Alias for <see cref="Hand"/>
|
||||
/// </summary>
|
||||
Pointer = Hand,
|
||||
|
||||
/// <summary>
|
||||
/// The horizontal resize shape. Used when mousing over something that can be horizontally resized.
|
||||
/// </summary>
|
||||
HResize,
|
||||
|
||||
/// <summary>
|
||||
/// Alias for <see cref="EWResize"/>
|
||||
/// </summary>
|
||||
EWResize = HResize,
|
||||
|
||||
/// <summary>
|
||||
/// The vertical resize shape. Used when mousing over something that can be vertically resized.
|
||||
/// </summary>
|
||||
VResize,
|
||||
|
||||
/// <summary>
|
||||
/// Alias for <see cref="VResize"/>.
|
||||
/// </summary>
|
||||
NSResize = VResize,
|
||||
|
||||
/// <summary>
|
||||
/// Program is busy doing something.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This cursor is not always available and may be substituted.
|
||||
/// </remarks>
|
||||
Progress,
|
||||
|
||||
/// <summary>
|
||||
/// Diagonal resize shape for northwest-southeast resizing.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This cursor is not always available and may be substituted.
|
||||
/// </remarks>
|
||||
NWSEResize,
|
||||
|
||||
/// <summary>
|
||||
/// Diagonal resize shape for northeast-southwest resizing.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This cursor is not always available and may be substituted.
|
||||
/// </remarks>
|
||||
NESWResize,
|
||||
|
||||
/// <summary>
|
||||
/// 4-way arrow move icon.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This cursor is not always available and may be substituted.
|
||||
/// </remarks>
|
||||
Move,
|
||||
|
||||
/// <summary>
|
||||
/// An action is not allowed.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This cursor is not always available and may be substituted.
|
||||
/// </remarks>
|
||||
NotAllowed,
|
||||
|
||||
/// <summary>
|
||||
/// One-directional resize to the northwest.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This cursor is not always available and may be substituted.
|
||||
/// </remarks>
|
||||
NWResize,
|
||||
|
||||
/// <summary>
|
||||
/// One-directional resize to the north.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This cursor is not always available and may be substituted.
|
||||
/// </remarks>
|
||||
NResize,
|
||||
|
||||
/// <summary>
|
||||
/// One-directional resize to the northeast.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This cursor is not always available and may be substituted.
|
||||
/// </remarks>
|
||||
NEResize,
|
||||
|
||||
/// <summary>
|
||||
/// One-directional resize to the east.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This cursor is not always available and may be substituted.
|
||||
/// </remarks>
|
||||
EResize,
|
||||
|
||||
/// <summary>
|
||||
/// One-directional resize to the southeast.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This cursor is not always available and may be substituted.
|
||||
/// </remarks>
|
||||
SEResize,
|
||||
|
||||
/// <summary>
|
||||
/// One-directional resize to the south.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This cursor is not always available and may be substituted.
|
||||
/// </remarks>
|
||||
SResize,
|
||||
|
||||
/// <summary>
|
||||
/// One-directional resize to the southwest.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This cursor is not always available and may be substituted.
|
||||
/// </remarks>
|
||||
SWResize,
|
||||
|
||||
/// <summary>
|
||||
/// One-directional resize to the west.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This cursor is not always available and may be substituted.
|
||||
/// </remarks>
|
||||
WResize,
|
||||
|
||||
/// <summary>
|
||||
/// Not a real value
|
||||
/// </summary>
|
||||
|
||||
@@ -197,6 +197,13 @@ namespace Robust.Client.Input
|
||||
locId += "-linux";
|
||||
}
|
||||
|
||||
#if MACOS
|
||||
if (key == Key.Alt)
|
||||
{
|
||||
locId += "-mac";
|
||||
}
|
||||
#endif
|
||||
|
||||
if (loc.TryGetString(locId, out var name))
|
||||
return name;
|
||||
|
||||
|
||||
@@ -138,9 +138,16 @@ namespace Robust.Client.ResourceManagement
|
||||
var sw = Stopwatch.StartNew();
|
||||
var resList = GetTypeData<RSIResource>().Resources;
|
||||
|
||||
var rsiList = _manager.ContentFindFiles("/Textures/")
|
||||
var foundRsiList = _manager.ContentFindFiles("/Textures/")
|
||||
.Where(p => p.ToString().EndsWith(".rsi/meta.json"))
|
||||
.Select(c => c.Directory)
|
||||
.Select(c => c.Directory);
|
||||
|
||||
var foundRsicList = _manager.ContentFindFiles("/Textures/")
|
||||
.Where(p => p.Extension == "rsic")
|
||||
.Select(c => c.WithExtension("rsi"));
|
||||
|
||||
var rsiList = foundRsiList
|
||||
.Concat(foundRsicList)
|
||||
.Where(p => !resList.ContainsKey(p))
|
||||
.Select(p => new RSIResource.LoadStepData {Path = p})
|
||||
.ToArray();
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.Graphics;
|
||||
using Robust.Shared.Graphics.RSI;
|
||||
@@ -58,12 +57,88 @@ namespace Robust.Client.ResourceManagement
|
||||
internal static void LoadPreTexture(IResourceManager manager, LoadStepData data)
|
||||
{
|
||||
var manifestPath = data.Path / "meta.json";
|
||||
if (manager.TryContentFileRead(manifestPath, out var manifestFile))
|
||||
{
|
||||
LoadPreTextureFolder(manager, data, manifestFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
var rsicPath = data.Path.WithExtension("rsic");
|
||||
if (manager.TryContentFileRead(rsicPath, out var rsicFile))
|
||||
{
|
||||
LoadPreTextureRsic(data, rsicFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new FileNotFoundException($"Unable to find .rsi file: {data.Path}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void LoadPreTextureFolder(IResourceManager manager, LoadStepData data, Stream manifestFile)
|
||||
{
|
||||
RsiLoading.RsiMetadata metadata;
|
||||
using (var manifestFile = manager.ContentFileRead(manifestPath))
|
||||
using (manifestFile)
|
||||
{
|
||||
metadata = RsiLoading.LoadRsiMetadata(manifestFile);
|
||||
}
|
||||
|
||||
data.FrameCounts = RsiLoading.CalculateFrameCounts(metadata);
|
||||
data.Images = RsiLoading.LoadImages(
|
||||
metadata,
|
||||
SixLabors.ImageSharp.Configuration.Default,
|
||||
name =>
|
||||
{
|
||||
var texPath = data.Path / (name + ".png");
|
||||
return manager.ContentFileRead(texPath);
|
||||
});
|
||||
|
||||
var sheet = RsiLoading.GenerateAtlas(
|
||||
metadata,
|
||||
data.FrameCounts,
|
||||
data.Images,
|
||||
SixLabors.ImageSharp.Configuration.Default,
|
||||
out var dimensionX);
|
||||
|
||||
LoadPreTextureCommon(metadata, data);
|
||||
|
||||
data.AtlasSheet = sheet;
|
||||
data.DimX = dimensionX;
|
||||
data.LoadParameters = metadata.LoadParameters;
|
||||
data.MetaAtlas = metadata.MetaAtlas;
|
||||
}
|
||||
|
||||
private static void LoadPreTextureRsic(LoadStepData data, Stream rsicFile)
|
||||
{
|
||||
Image<Rgba32> image;
|
||||
using (rsicFile)
|
||||
{
|
||||
image = Image.Load<Rgba32>(rsicFile);
|
||||
}
|
||||
|
||||
data.AtlasSheet = image;
|
||||
|
||||
var textDataList = image.Metadata.GetPngMetadata().TextData;
|
||||
if (!textDataList.TryFirstOrNull(
|
||||
static data => data.Keyword == RsiLoading.RsicPngField,
|
||||
out var pngMetadata))
|
||||
throw new InvalidDataException(".rsic does not have metadata field");
|
||||
|
||||
var metadata = RsiLoading.LoadRsiMetadata(pngMetadata.Value.Value);
|
||||
|
||||
data.FrameCounts = RsiLoading.CalculateFrameCounts(metadata);
|
||||
|
||||
LoadPreTextureCommon(metadata, data);
|
||||
|
||||
data.DimX = image.Width / metadata.Size.X;
|
||||
data.LoadParameters = metadata.LoadParameters;
|
||||
data.MetaAtlas = metadata.MetaAtlas;
|
||||
}
|
||||
|
||||
private static void LoadPreTextureCommon(
|
||||
RsiLoading.RsiMetadata metadata,
|
||||
LoadStepData data)
|
||||
{
|
||||
var stateCount = metadata.States.Length;
|
||||
var toAtlas = new StateReg[stateCount];
|
||||
|
||||
@@ -72,40 +147,12 @@ namespace Robust.Client.ResourceManagement
|
||||
|
||||
var callbackOffsets = new Dictionary<RSI.StateId, Vector2i[][]>(stateCount);
|
||||
|
||||
// Check for duplicate states
|
||||
for (var i = 0; i < metadata.States.Length; i++)
|
||||
{
|
||||
var stateId = metadata.States[i].StateId;
|
||||
|
||||
for (int j = i + 1; j < metadata.States.Length; j++)
|
||||
{
|
||||
if (stateId == metadata.States[j].StateId)
|
||||
throw new RSILoadException($"RSI '{data.Path}' has a duplicate stateId '{stateId}'.");
|
||||
}
|
||||
}
|
||||
|
||||
// Do every state.
|
||||
for (var index = 0; index < metadata.States.Length; index++)
|
||||
{
|
||||
ref var reg = ref toAtlas[index];
|
||||
|
||||
var stateObject = metadata.States[index];
|
||||
// Load image from disk.
|
||||
var texPath = data.Path / (stateObject.StateId + ".png");
|
||||
using (var stream = manager.ContentFileRead(texPath))
|
||||
{
|
||||
reg.Src = Image.Load<Rgba32>(stream);
|
||||
}
|
||||
|
||||
if (reg.Src.Width % frameSize.X != 0 || reg.Src.Height % frameSize.Y != 0)
|
||||
{
|
||||
var regDims = $"{reg.Src.Width}x{reg.Src.Height}";
|
||||
var iconDims = $"{frameSize.X}x{frameSize.Y}";
|
||||
throw new RSILoadException($"State '{stateObject.StateId}' image size ({regDims}) is not a multiple of the icon size ({iconDims}).");
|
||||
}
|
||||
|
||||
// Load all frames into a list so we can operate on it more sanely.
|
||||
reg.TotalFrameCount = stateObject.Delays.Sum(delayList => delayList.Length);
|
||||
|
||||
var (foldedDelays, foldedIndices) = FoldDelays(stateObject.Delays);
|
||||
|
||||
@@ -130,60 +177,23 @@ namespace Robust.Client.ResourceManagement
|
||||
_ => throw new InvalidOperationException()
|
||||
};
|
||||
|
||||
var state = new RSI.State(frameSize, rsi, stateObject.StateId, dirType, foldedDelays,
|
||||
var state = new RSI.State(
|
||||
frameSize,
|
||||
rsi,
|
||||
stateObject.StateId,
|
||||
dirType,
|
||||
foldedDelays,
|
||||
textures);
|
||||
|
||||
rsi.AddState(state);
|
||||
|
||||
callbackOffsets[stateObject.StateId] = callbackOffset;
|
||||
}
|
||||
|
||||
// Poorly hacked in texture atlas support here.
|
||||
var totalFrameCount = toAtlas.Sum(p => p.TotalFrameCount);
|
||||
|
||||
// Generate atlas.
|
||||
var dimensionX = (int) MathF.Ceiling(MathF.Sqrt(totalFrameCount));
|
||||
var dimensionY = (int) MathF.Ceiling((float) totalFrameCount / dimensionX);
|
||||
|
||||
var sheet = new Image<Rgba32>(dimensionX * frameSize.X, dimensionY * frameSize.Y);
|
||||
|
||||
var sheetIndex = 0;
|
||||
for (var index = 0; index < toAtlas.Length; index++)
|
||||
{
|
||||
ref var reg = ref toAtlas[index];
|
||||
// Blit all the frames over.
|
||||
for (var i = 0; i < reg.TotalFrameCount; i++)
|
||||
{
|
||||
var srcWidth = (reg.Src.Width / frameSize.X);
|
||||
var srcColumn = i % srcWidth;
|
||||
var srcRow = i / srcWidth;
|
||||
var srcPos = (srcColumn * frameSize.X, srcRow * frameSize.Y);
|
||||
|
||||
var sheetColumn = (sheetIndex + i) % dimensionX;
|
||||
var sheetRow = (sheetIndex + i) / dimensionX;
|
||||
var sheetPos = (sheetColumn * frameSize.X, sheetRow * frameSize.Y);
|
||||
|
||||
var srcBox = UIBox2i.FromDimensions(srcPos, frameSize);
|
||||
|
||||
reg.Src.Blit(srcBox, sheet, sheetPos);
|
||||
}
|
||||
|
||||
sheetIndex += reg.TotalFrameCount;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toAtlas.Length; i++)
|
||||
{
|
||||
ref var reg = ref toAtlas[i];
|
||||
reg.Src.Dispose();
|
||||
}
|
||||
|
||||
data.Rsi = rsi;
|
||||
data.AtlasSheet = sheet;
|
||||
data.CallbackOffsets = callbackOffsets;
|
||||
data.AtlasList = toAtlas;
|
||||
data.FrameSize = frameSize;
|
||||
data.DimX = dimensionX;
|
||||
data.CallbackOffsets = callbackOffsets;
|
||||
data.LoadParameters = metadata.LoadParameters;
|
||||
data.MetaAtlas = metadata.MetaAtlas;
|
||||
}
|
||||
|
||||
internal static void LoadPostTexture(LoadStepData data)
|
||||
@@ -216,7 +226,7 @@ namespace Robust.Client.ResourceManagement
|
||||
}
|
||||
}
|
||||
|
||||
sheetOffset += reg.TotalFrameCount;
|
||||
sheetOffset += data.FrameCounts[toAtlasIndex];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,6 +391,8 @@ namespace Robust.Client.ResourceManagement
|
||||
public Image<Rgba32> AtlasSheet = default!;
|
||||
public int DimX;
|
||||
public StateReg[] AtlasList = default!;
|
||||
public int[] FrameCounts = default!;
|
||||
public Image<Rgba32>[] Images = default!;
|
||||
public Vector2i FrameSize;
|
||||
public Dictionary<RSI.StateId, Vector2i[][]> CallbackOffsets = default!;
|
||||
public Texture AtlasTexture = default!;
|
||||
@@ -392,11 +404,9 @@ namespace Robust.Client.ResourceManagement
|
||||
|
||||
internal struct StateReg
|
||||
{
|
||||
public Image<Rgba32> Src;
|
||||
public Texture[][] Output;
|
||||
public int[][] Indices;
|
||||
public Vector2i[][] Offsets;
|
||||
public int TotalFrameCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<PackageReference Include="SpaceWizards.NFluidsynth" PrivateAssets="compile" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" />
|
||||
<PackageReference Include="OpenToolkit.Graphics" PrivateAssets="compile" />
|
||||
<PackageReference Include="OpenTK.OpenAL" PrivateAssets="compile" />
|
||||
<PackageReference Include="OpenTK.Audio.OpenAL" PrivateAssets="compile" />
|
||||
<PackageReference Include="SpaceWizards.SharpFont" PrivateAssets="compile" />
|
||||
<PackageReference Include="Robust.Natives" />
|
||||
<PackageReference Include="TerraFX.Interop.Windows" PrivateAssets="compile" />
|
||||
@@ -63,6 +63,7 @@
|
||||
<RobustLinkAssemblies Include="TerraFX.Interop.Windows" />
|
||||
<RobustLinkAssemblies Include="TerraFX.Interop.Xlib" />
|
||||
<RobustLinkAssemblies Include="OpenToolkit.Graphics" />
|
||||
<RobustLinkAssemblies Include="SpaceWizards.SharpFont" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\MSBuild\Robust.Properties.targets" />
|
||||
|
||||
@@ -11,14 +11,124 @@ namespace Robust.Client.UserInterface
|
||||
/// <summary>
|
||||
/// Default common cursor shapes available in the UI.
|
||||
/// </summary>
|
||||
/// <seealso cref="StandardCursorShape"/>
|
||||
public enum CursorShape: byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.Arrow"/>
|
||||
/// </summary>
|
||||
Arrow,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.IBeam"/>
|
||||
/// </summary>
|
||||
IBeam,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.Text"/>
|
||||
/// </summary>
|
||||
Text = IBeam,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.Crosshair"/>
|
||||
/// </summary>
|
||||
Crosshair,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.Hand"/>
|
||||
/// </summary>
|
||||
Hand,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.Pointer"/>
|
||||
/// </summary>
|
||||
Pointer = Hand,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.HResize"/>
|
||||
/// </summary>
|
||||
HResize,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.EWResize"/>
|
||||
/// </summary>
|
||||
EWResize = HResize,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.VResize"/>
|
||||
/// </summary>
|
||||
VResize,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.NSResize"/>
|
||||
/// </summary>
|
||||
NSResize = VResize,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.Progress"/>
|
||||
/// </summary>
|
||||
Progress,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.NWSEResize"/>
|
||||
/// </summary>
|
||||
NWSEResize,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.NESWResize"/>
|
||||
/// </summary>
|
||||
NESWResize,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.Move"/>
|
||||
/// </summary>
|
||||
Move,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.NotAllowed"/>
|
||||
/// </summary>
|
||||
NotAllowed,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.NWResize"/>
|
||||
/// </summary>
|
||||
NWResize,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.NResize"/>
|
||||
/// </summary>
|
||||
NResize,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.NEResize"/>
|
||||
/// </summary>
|
||||
NEResize,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.EResize"/>
|
||||
/// </summary>
|
||||
EResize,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.SEResize"/>
|
||||
/// </summary>
|
||||
SEResize,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.SResize"/>
|
||||
/// </summary>
|
||||
SResize,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.SWResize"/>
|
||||
/// </summary>
|
||||
SWResize,
|
||||
|
||||
/// <summary>
|
||||
/// Corresponds to <see cref="StandardCursorShape.WResize"/>
|
||||
/// </summary>
|
||||
WResize,
|
||||
|
||||
/// <summary>
|
||||
/// Special cursor shape indicating that <see cref="CustomCursorShape"/> is set and being used.
|
||||
/// </summary>
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
var itemHeight = 0f;
|
||||
if (item.Icon != null)
|
||||
{
|
||||
itemHeight = item.IconSize.Y;
|
||||
itemHeight = item.IconSize.Y * item.IconScale;
|
||||
}
|
||||
|
||||
itemHeight = Math.Max(itemHeight, ActualFont.GetHeight(UIScale));
|
||||
@@ -111,21 +111,21 @@ namespace Robust.Client.UserInterface.Controls
|
||||
Recalculate();
|
||||
}
|
||||
|
||||
public void AddItems(IEnumerable<string> texts, Texture? icon = null, bool selectable = true, object? metadata = null)
|
||||
public void AddItems(IEnumerable<string> texts, Texture? icon = null, bool selectable = true, object? metadata = null, float iconScale = 1)
|
||||
{
|
||||
var items = new ValueList<Item>();
|
||||
|
||||
foreach (var text in texts)
|
||||
{
|
||||
items.Add(new Item(this) {Text = text, Icon = icon, Selectable = selectable, Metadata = metadata});
|
||||
items.Add(new Item(this) {Text = text, Icon = icon, IconScale = iconScale, Selectable = selectable, Metadata = metadata});
|
||||
}
|
||||
|
||||
Add(items);
|
||||
}
|
||||
|
||||
public Item AddItem(string text, Texture? icon = null, bool selectable = true, object? metadata = null)
|
||||
public Item AddItem(string text, Texture? icon = null, bool selectable = true, object? metadata = null, float iconScale = 1)
|
||||
{
|
||||
var item = new Item(this) {Text = text, Icon = icon, Selectable = selectable, Metadata = metadata};
|
||||
var item = new Item(this) {Text = text, Icon = icon, IconScale = iconScale, Selectable = selectable, Metadata = metadata};
|
||||
Add(item);
|
||||
return item;
|
||||
}
|
||||
@@ -477,7 +477,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
var itemHeight = 0f;
|
||||
if (item.Icon != null)
|
||||
{
|
||||
itemHeight = item.IconSize.Y;
|
||||
itemHeight = item.IconSize.Y * item.IconScale;
|
||||
}
|
||||
|
||||
itemHeight = Math.Max(itemHeight, font.GetHeight(UIScale));
|
||||
@@ -496,19 +496,19 @@ namespace Robust.Client.UserInterface.Controls
|
||||
{
|
||||
if (item.IconRegion.Size == Vector2.Zero)
|
||||
{
|
||||
handle.DrawTextureRect(item.Icon, UIBox2.FromDimensions(drawOffset, item.Icon.Size),
|
||||
handle.DrawTextureRect(item.Icon, UIBox2.FromDimensions(drawOffset, item.Icon.Size * item.IconScale),
|
||||
item.IconModulate);
|
||||
}
|
||||
else
|
||||
{
|
||||
handle.DrawTextureRectRegion(item.Icon, UIBox2.FromDimensions(drawOffset, item.Icon.Size),
|
||||
handle.DrawTextureRectRegion(item.Icon, UIBox2.FromDimensions(drawOffset, item.Icon.Size * item.IconScale),
|
||||
item.IconRegion, item.IconModulate);
|
||||
}
|
||||
}
|
||||
|
||||
if (item.Text != null)
|
||||
{
|
||||
var textBox = new UIBox2(contentBox.Left + item.IconSize.X, contentBox.Top, contentBox.Right,
|
||||
var textBox = new UIBox2(contentBox.Left + item.IconSize.X * item.IconScale, contentBox.Top, contentBox.Right,
|
||||
contentBox.Bottom);
|
||||
DrawTextInternal(handle, item.Text, textBox);
|
||||
}
|
||||
@@ -722,6 +722,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
public Texture? Icon { get; set; }
|
||||
public UIBox2 IconRegion { get; set; }
|
||||
public Color IconModulate { get; set; } = Color.White;
|
||||
public float IconScale { get; set; } = 1;
|
||||
public bool Selectable { get; set; } = true;
|
||||
public bool TooltipEnabled { get; set; } = true;
|
||||
public UIBox2? Region { get; set; }
|
||||
|
||||
@@ -326,7 +326,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
var parentSize = control.Parent?.Size ?? Vector2.Zero;
|
||||
|
||||
var anchorLeft = control.GetValue<float>(AnchorLeftProperty);
|
||||
var anchorTop = control.GetValue<float>(AnchorBottomProperty);
|
||||
var anchorTop = control.GetValue<float>(AnchorTopProperty);
|
||||
var anchorRight = control.GetValue<float>(AnchorRightProperty);
|
||||
var anchorBottom = control.GetValue<float>(AnchorBottomProperty);
|
||||
|
||||
|
||||
@@ -119,9 +119,12 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
|
||||
case DragMode.Bottom | DragMode.Left:
|
||||
case DragMode.Top | DragMode.Right:
|
||||
cursor = CursorShape.NESWResize;
|
||||
break;
|
||||
|
||||
case DragMode.Bottom | DragMode.Right:
|
||||
case DragMode.Top | DragMode.Left:
|
||||
cursor = CursorShape.Crosshair;
|
||||
cursor = CursorShape.NWSEResize;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
MinSize="350 200">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<LineEdit Name="SearchBar" Access="Public" HorizontalExpand="True" PlaceHolder="{Loc entity-spawn-window-search-bar-placeholder}"/>
|
||||
<Button Name="ClearButton" Access="Public" Disabled="True" Text="{Loc entity-spawn-window-clear-button}" />
|
||||
<LineEdit Name="SearchBar" Access="Public" HorizontalExpand="True" PlaceHolder="{Loc window-search-bar-placeholder}"/>
|
||||
<Button Name="ClearButton" Access="Public" Disabled="True" Text="{Loc window-clear-button}" />
|
||||
</BoxContainer>
|
||||
<ScrollContainer Name="PrototypeScrollContainer" Access="Public" MinSize="200 0" VerticalExpand="True">
|
||||
<PrototypeListContainer Name="PrototypeList" Access="Public"/>
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
MinSize="300 200">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<LineEdit Name="SearchBar" Access="Public" HorizontalExpand="True" PlaceHolder="Search"/>
|
||||
<Button Name="ClearButton" Access="Public" Text="Clear"/>
|
||||
<LineEdit Name="SearchBar" Access="Public" HorizontalExpand="True" PlaceHolder="{Loc window-search-bar-placeholder}"/>
|
||||
<Button Name="ClearButton" Access="Public" Text="{Loc window-clear-button}"/>
|
||||
</BoxContainer>
|
||||
<ItemList Name="TileList" Access="Public" VerticalExpand="True"/>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
|
||||
@@ -202,7 +202,14 @@ internal partial class UserInterfaceManager
|
||||
return;
|
||||
}
|
||||
|
||||
var shape = cursorTarget.DefaultCursorShape switch
|
||||
var shape = MapCursorShape(cursorTarget.DefaultCursorShape);
|
||||
|
||||
_clyde.SetCursor(_clyde.GetStandardCursor(shape));
|
||||
}
|
||||
|
||||
private static StandardCursorShape MapCursorShape(Control.CursorShape shape)
|
||||
{
|
||||
return shape switch
|
||||
{
|
||||
Control.CursorShape.Arrow => StandardCursorShape.Arrow,
|
||||
Control.CursorShape.IBeam => StandardCursorShape.IBeam,
|
||||
@@ -210,10 +217,21 @@ internal partial class UserInterfaceManager
|
||||
Control.CursorShape.Crosshair => StandardCursorShape.Crosshair,
|
||||
Control.CursorShape.VResize => StandardCursorShape.VResize,
|
||||
Control.CursorShape.HResize => StandardCursorShape.HResize,
|
||||
Control.CursorShape.Progress => StandardCursorShape.Progress,
|
||||
Control.CursorShape.NWSEResize => StandardCursorShape.NWSEResize,
|
||||
Control.CursorShape.NESWResize => StandardCursorShape.NESWResize,
|
||||
Control.CursorShape.Move => StandardCursorShape.Move,
|
||||
Control.CursorShape.NotAllowed => StandardCursorShape.NotAllowed,
|
||||
Control.CursorShape.NWResize => StandardCursorShape.NWResize,
|
||||
Control.CursorShape.NResize => StandardCursorShape.NResize,
|
||||
Control.CursorShape.NEResize => StandardCursorShape.NEResize,
|
||||
Control.CursorShape.EResize => StandardCursorShape.EResize,
|
||||
Control.CursorShape.SEResize => StandardCursorShape.SEResize,
|
||||
Control.CursorShape.SResize => StandardCursorShape.SResize,
|
||||
Control.CursorShape.SWResize => StandardCursorShape.SWResize,
|
||||
Control.CursorShape.WResize => StandardCursorShape.WResize,
|
||||
_ => StandardCursorShape.Arrow
|
||||
};
|
||||
|
||||
_clyde.SetCursor(_clyde.GetStandardCursor(shape));
|
||||
}
|
||||
|
||||
public void MouseWheel(MouseWheelEventArgs args)
|
||||
|
||||
@@ -3,7 +3,9 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Asynchronous;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
@@ -18,24 +20,25 @@ namespace Robust.Client.UserInterface.XAML.Proxy;
|
||||
/// </remarks>
|
||||
internal sealed class XamlHotReloadManager : IXamlHotReloadManager
|
||||
{
|
||||
private const string MarkerFileName = "SpaceStation14.sln";
|
||||
|
||||
[Dependency] ILogManager _logManager = null!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = null!;
|
||||
[Dependency] private readonly ILogManager _logManager = null!;
|
||||
[Dependency] private readonly IResourceManager _resources = null!;
|
||||
[Dependency] private readonly ITaskManager _taskManager = null!;
|
||||
[Dependency] private readonly IXamlProxyManager _xamlProxyManager = null!;
|
||||
|
||||
private ISawmill _sawmill = null!;
|
||||
private FileSystemWatcher? _watcher;
|
||||
private string _markerFileName = null!;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_markerFileName = _cfg.GetCVar(CVars.XamlHotReloadMarkerName);
|
||||
_sawmill = _logManager.GetSawmill("xamlhotreload");
|
||||
var codeLocation = InferCodeLocation();
|
||||
|
||||
if (codeLocation == null)
|
||||
{
|
||||
_sawmill.Warning($"could not find code -- where is {MarkerFileName}?");
|
||||
_sawmill.Warning($"could not find code -- where is {_markerFileName}?");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -129,7 +132,7 @@ internal sealed class XamlHotReloadManager : IXamlHotReloadManager
|
||||
}
|
||||
catch (IOException) { } // this is allowed to fail, and if so we just keep going up
|
||||
|
||||
if (files.Any(f => Path.GetFileName(f).Equals(MarkerFileName, StringComparison.InvariantCultureIgnoreCase)))
|
||||
if (files.Any(f => Path.GetFileName(f).Equals(_markerFileName, StringComparison.InvariantCultureIgnoreCase)))
|
||||
{
|
||||
return systemPath;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
#if !WINDOWS
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using SDL3;
|
||||
|
||||
namespace Robust.Client.Utility
|
||||
{
|
||||
@@ -9,32 +12,40 @@ namespace Robust.Client.Utility
|
||||
[ModuleInitializer]
|
||||
internal static void Initialize()
|
||||
{
|
||||
if (OperatingSystem.IsWindows())
|
||||
return;
|
||||
|
||||
NativeLibrary.SetDllImportResolver(typeof(ClientDllMap).Assembly, (name, assembly, path) =>
|
||||
{
|
||||
if (name == "swnfd.dll")
|
||||
{
|
||||
if (OperatingSystem.IsLinux())
|
||||
return NativeLibrary.Load("libswnfd.so", assembly, path);
|
||||
|
||||
if (OperatingSystem.IsMacOS())
|
||||
return NativeLibrary.Load("libswnfd.dylib", assembly, path);
|
||||
|
||||
return IntPtr.Zero;
|
||||
#if LINUX || FREEBSD
|
||||
return NativeLibrary.Load("libswnfd.so", assembly, path);
|
||||
#elif MACOS
|
||||
return NativeLibrary.Load("libswnfd.dylib", assembly, path);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (name == "libEGL.dll")
|
||||
{
|
||||
if (OperatingSystem.IsLinux())
|
||||
return NativeLibrary.Load("libEGL.so", assembly, path);
|
||||
#if LINUX || FREEBSD
|
||||
return NativeLibrary.Load("libEGL.so", assembly, path);
|
||||
#endif
|
||||
}
|
||||
|
||||
return IntPtr.Zero;
|
||||
if (name == SDL.nativeLibName)
|
||||
{
|
||||
#if LINUX || FREEBSD
|
||||
return NativeLibrary.Load("libSDL3.so.0", assembly, path);
|
||||
#elif MACOS
|
||||
return NativeLibrary.Load("libSDL3.0.dylib", assembly, path);
|
||||
#endif
|
||||
}
|
||||
|
||||
return IntPtr.Zero;
|
||||
});
|
||||
|
||||
#if MACOS
|
||||
OpenALLibraryNameContainer.OverridePath = "libopenal.1.dylib";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,38 +1,85 @@
|
||||
using System.Linq;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Robust.Client.ViewVariables.Editors;
|
||||
|
||||
internal sealed class VVPropEditorProtoId<T> : VVPropEditor where T : class, IPrototype
|
||||
{
|
||||
[Dependency] private readonly ILocalizationManager _loc = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protoManager = default!;
|
||||
|
||||
private ViewVariablesAddWindow? _addWindow;
|
||||
private LineEdit? _lineEdit;
|
||||
|
||||
protected override Control MakeUI(object? value)
|
||||
{
|
||||
var lineEdit = new LineEdit
|
||||
// ID LineEdit
|
||||
_lineEdit = new LineEdit
|
||||
{
|
||||
Text = (ProtoId<T>) (value ?? ""),
|
||||
Text = (ProtoId<T>)(value ?? ""),
|
||||
PlaceHolder = _loc.GetString("vv-protoid-id-placeholder"),
|
||||
Editable = !ReadOnly,
|
||||
HorizontalExpand = true,
|
||||
};
|
||||
|
||||
if (!ReadOnly)
|
||||
{
|
||||
lineEdit.OnTextEntered += e =>
|
||||
_lineEdit.OnTextEntered += e =>
|
||||
{
|
||||
var id = (ProtoId<T>)e.Text;
|
||||
|
||||
if (!_protoManager.HasIndex(id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ValueChanged(id);
|
||||
SetValue(e.Text);
|
||||
};
|
||||
}
|
||||
|
||||
return lineEdit;
|
||||
// Select button
|
||||
var selectButton = new Button
|
||||
{
|
||||
Text = _loc.GetString("vv-protoid-select-button-label"),
|
||||
Disabled = ReadOnly,
|
||||
};
|
||||
selectButton.OnPressed += OnListButtonPressed;
|
||||
|
||||
// Container
|
||||
var hBox = new BoxContainer
|
||||
{
|
||||
Orientation = BoxContainer.LayoutOrientation.Horizontal,
|
||||
HorizontalExpand = true,
|
||||
Children =
|
||||
{
|
||||
_lineEdit,
|
||||
selectButton,
|
||||
}
|
||||
};
|
||||
|
||||
return hBox;
|
||||
}
|
||||
|
||||
private void OnListButtonPressed(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
_addWindow?.Close();
|
||||
|
||||
var list = _protoManager.EnumeratePrototypes<T>().Select(p => p.ID);
|
||||
|
||||
_addWindow = new ViewVariablesAddWindow(list, _loc.GetString("vv-protoid-addwindow-title"));
|
||||
_addWindow.AddButtonPressed += OnAddButtonPressed;
|
||||
_addWindow.OpenCentered();
|
||||
}
|
||||
|
||||
private void OnAddButtonPressed(ViewVariablesAddWindow.AddButtonPressedEventArgs args)
|
||||
{
|
||||
_lineEdit?.SetText(args.Entry);
|
||||
_addWindow?.Close();
|
||||
|
||||
SetValue(args.Entry);
|
||||
}
|
||||
|
||||
private void SetValue(string value)
|
||||
{
|
||||
var proto = (ProtoId<T>)value;
|
||||
if (_protoManager.HasIndex(proto))
|
||||
ValueChanged(proto, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Robust.Shared.Analyzers;
|
||||
using System.Text;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.Collections;
|
||||
|
||||
namespace Robust.Packaging.AssetProcessing;
|
||||
@@ -199,6 +200,17 @@ public class AssetPass
|
||||
/// </summary>
|
||||
public void InjectFileFromMemory(string path, byte[] memory) => InjectFile(new AssetFileMemory(path, memory));
|
||||
|
||||
/// <summary>
|
||||
/// Convenience method to <see cref="InjectFile"/> a <see cref="AssetFileMemory"/>.
|
||||
/// </summary>
|
||||
public void InjectFileFromMemory(string path, ReadOnlySpan<byte> memory) => InjectFile(new AssetFileMemory(path, memory.ToArray()));
|
||||
|
||||
/// <summary>
|
||||
/// Convenience method to <see cref="InjectFile"/> a <see cref="AssetFileMemory"/> made from text.
|
||||
/// </summary>
|
||||
public void InjectFileFromText(string path, string text) =>
|
||||
InjectFile(new AssetFileMemory(path, Encoding.UTF8.GetBytes(text)));
|
||||
|
||||
/// <summary>
|
||||
/// Called when all depended-on passes have finished processing, meaning no more files will come in.
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Packaging.AssetProcessing.Passes;
|
||||
|
||||
public sealed class AssetPassMergeTextDirectories : AssetPass
|
||||
{
|
||||
private readonly ResPath _prefixPath;
|
||||
private readonly string _extension;
|
||||
private readonly Func<string, string>? _formatterHead;
|
||||
private readonly Func<string, string>? _formatterTail;
|
||||
|
||||
private readonly Dictionary<ResPath, DirectoryDatum> _data = new();
|
||||
|
||||
public AssetPassMergeTextDirectories(
|
||||
string prefixPath,
|
||||
string extension,
|
||||
Func<string, string>? formatterHead = null,
|
||||
Func<string, string>? formatterTail = null)
|
||||
{
|
||||
_prefixPath = new ResPath(prefixPath);
|
||||
_extension = extension;
|
||||
_formatterHead = formatterHead;
|
||||
_formatterTail = formatterTail;
|
||||
}
|
||||
|
||||
protected override AssetFileAcceptResult AcceptFile(AssetFile file)
|
||||
{
|
||||
var resPath = new ResPath(file.Path);
|
||||
if (!resPath.TryRelativeTo(_prefixPath, out _))
|
||||
return AssetFileAcceptResult.Pass;
|
||||
|
||||
if (resPath.Extension != _extension)
|
||||
return AssetFileAcceptResult.Pass;
|
||||
|
||||
var directory = resPath.Directory;
|
||||
lock (_data)
|
||||
{
|
||||
var datum = _data.GetOrNew(directory);
|
||||
datum.Files.Add(file);
|
||||
}
|
||||
|
||||
return AssetFileAcceptResult.Consumed;
|
||||
}
|
||||
|
||||
protected override void AcceptFinished()
|
||||
{
|
||||
RunJob(() =>
|
||||
{
|
||||
lock (_data)
|
||||
{
|
||||
var ms = new MemoryStream();
|
||||
var writer = new StreamWriter(ms, EncodingHelpers.UTF8);
|
||||
|
||||
foreach (var (directory, datum) in _data)
|
||||
{
|
||||
ms.Position = 0;
|
||||
var mergedFile = directory / $"__merged.{_extension}";
|
||||
WriteForDatum(datum, writer);
|
||||
writer.Flush();
|
||||
|
||||
SendFileFromMemory(mergedFile.ToString(), ms.GetBuffer()[..(int)ms.Position]);
|
||||
}
|
||||
|
||||
_data.Clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void WriteForDatum(DirectoryDatum datum, StreamWriter writer)
|
||||
{
|
||||
foreach (var file in datum.Files.OrderBy(f => f.Path, StringComparer.Ordinal))
|
||||
{
|
||||
if (_formatterHead != null)
|
||||
{
|
||||
writer.Write(_formatterHead(file.Path));
|
||||
writer.Write('\n');
|
||||
}
|
||||
|
||||
using var stream = file.Open();
|
||||
using var reader = new StreamReader(stream);
|
||||
while (reader.ReadLine() is { } line)
|
||||
{
|
||||
writer.Write(line);
|
||||
writer.Write('\n');
|
||||
}
|
||||
|
||||
if (_formatterTail != null)
|
||||
{
|
||||
writer.Write(_formatterTail(file.Path));
|
||||
writer.Write('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class DirectoryDatum
|
||||
{
|
||||
public readonly List<AssetFile> Files = [];
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,8 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Resources;
|
||||
using Robust.Shared.Utility;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Formats.Png;
|
||||
using SixLabors.ImageSharp.Formats.Png.Chunks;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
|
||||
namespace Robust.Packaging.AssetProcessing.Passes;
|
||||
|
||||
@@ -15,13 +12,21 @@ namespace Robust.Packaging.AssetProcessing.Passes;
|
||||
/// Packs .rsi bundles into .rsic files,
|
||||
/// that are single pre-atlassed PNG files with JSON metadata embedded in the PNG header.
|
||||
/// </summary>
|
||||
internal sealed class AssetPassPackRsis : AssetPass
|
||||
public sealed class AssetPassPackRsis : AssetPass
|
||||
{
|
||||
private readonly Dictionary<string, RsiDat> _foundRsis = new();
|
||||
|
||||
private static readonly Regex RegexMetaJson = new(@"^(.+)\.rsi/meta\.json$");
|
||||
private static readonly Regex RegexPng = new(@"^(.+)\.rsi/(.+)\.png$");
|
||||
|
||||
private readonly Configuration _imageConfiguration;
|
||||
|
||||
public AssetPassPackRsis()
|
||||
{
|
||||
_imageConfiguration = Configuration.Default.Clone();
|
||||
_imageConfiguration.PreferContiguousImageBuffers = true;
|
||||
}
|
||||
|
||||
protected override AssetFileAcceptResult AcceptFile(AssetFile file)
|
||||
{
|
||||
if (!file.Path.Contains(".rsi/"))
|
||||
@@ -69,12 +74,27 @@ internal sealed class AssetPassPackRsis : AssetPass
|
||||
// Console.WriteLine($"Packing RSI: {key}");
|
||||
|
||||
var result = PackRsi($"{key}.rsi", dat);
|
||||
if (result == null)
|
||||
{
|
||||
// Don't rsic pack this one.
|
||||
SkipRsiPack(dat);
|
||||
return;
|
||||
}
|
||||
SendFile(result);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static AssetFile PackRsi(string rsiPath, RsiDat dat)
|
||||
private void SkipRsiPack(RsiDat dat)
|
||||
{
|
||||
SendFile(dat.MetaJson!);
|
||||
foreach (var file in dat.StatesFound.Values)
|
||||
{
|
||||
SendFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
private AssetFile? PackRsi(string rsiPath, RsiDat dat)
|
||||
{
|
||||
RsiLoading.RsiMetadata metadata;
|
||||
string metaJson;
|
||||
@@ -87,100 +107,30 @@ internal sealed class AssetPassPackRsis : AssetPass
|
||||
metaJson = sr.ReadToEnd();
|
||||
}
|
||||
|
||||
// Check for duplicate states
|
||||
for (var i = 0; i < metadata.States.Length; i++)
|
||||
{
|
||||
var stateId = metadata.States[i].StateId;
|
||||
if (!metadata.Rsic)
|
||||
return null;
|
||||
|
||||
for (int j = i + 1; j < metadata.States.Length; j++)
|
||||
var frameCounts = RsiLoading.CalculateFrameCounts(metadata);
|
||||
var images = RsiLoading.LoadImages(metadata, _imageConfiguration, name => dat.StatesFound[name].Open());
|
||||
|
||||
try
|
||||
{
|
||||
using var sheet = RsiLoading.GenerateAtlas(metadata, frameCounts, images, _imageConfiguration, out _);
|
||||
var ms = new MemoryStream();
|
||||
sheet.Metadata.GetPngMetadata().TextData.Add(new PngTextData(RsiLoading.RsicPngField, metaJson, "", ""));
|
||||
sheet.SaveAsPng(ms);
|
||||
|
||||
Logger?.Verbose($"Done packing {rsiPath}");
|
||||
|
||||
return new AssetFileMemory($"{rsiPath}c", ms.ToArray());
|
||||
}
|
||||
finally
|
||||
{
|
||||
foreach (var image in images)
|
||||
{
|
||||
if (stateId == metadata.States[j].StateId)
|
||||
throw new RSILoadException($"RSI '{rsiPath}' has a duplicate stateId '{stateId}'.");
|
||||
image.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
var stateCount = metadata.States.Length;
|
||||
var toAtlas = new StateReg[stateCount];
|
||||
|
||||
var frameSize = metadata.Size;
|
||||
|
||||
// Do every state.
|
||||
for (var index = 0; index < metadata.States.Length; index++)
|
||||
{
|
||||
ref var reg = ref toAtlas[index];
|
||||
|
||||
var stateObject = metadata.States[index];
|
||||
// Load image from disk.
|
||||
var texFile = dat.StatesFound[stateObject.StateId];
|
||||
using (var stream = texFile.Open())
|
||||
{
|
||||
reg.Src = Image.Load<Rgba32>(stream);
|
||||
}
|
||||
|
||||
if (reg.Src.Width % frameSize.X != 0 || reg.Src.Height % frameSize.Y != 0)
|
||||
{
|
||||
var regDims = $"{reg.Src.Width}x{reg.Src.Height}";
|
||||
var iconDims = $"{frameSize.X}x{frameSize.Y}";
|
||||
throw new RSILoadException(
|
||||
$"State '{stateObject.StateId}' image size ({regDims}) is not a multiple of the icon size ({iconDims}).");
|
||||
}
|
||||
|
||||
// Load all frames into a list so we can operate on it more sanely.
|
||||
reg.TotalFrameCount = stateObject.Delays.Sum(delayList => delayList.Length);
|
||||
}
|
||||
|
||||
// Poorly hacked in texture atlas support here.
|
||||
var totalFrameCount = toAtlas.Sum(p => p.TotalFrameCount);
|
||||
|
||||
// Generate atlas.
|
||||
var dimensionX = (int) MathF.Ceiling(MathF.Sqrt(totalFrameCount));
|
||||
var dimensionY = (int) MathF.Ceiling((float) totalFrameCount / dimensionX);
|
||||
|
||||
var sheet = new Image<Rgba32>(dimensionX * frameSize.X, dimensionY * frameSize.Y);
|
||||
|
||||
var sheetIndex = 0;
|
||||
for (var index = 0; index < toAtlas.Length; index++)
|
||||
{
|
||||
ref var reg = ref toAtlas[index];
|
||||
// Blit all the frames over.
|
||||
for (var i = 0; i < reg.TotalFrameCount; i++)
|
||||
{
|
||||
var srcWidth = (reg.Src.Width / frameSize.X);
|
||||
var srcColumn = i % srcWidth;
|
||||
var srcRow = i / srcWidth;
|
||||
var srcPos = (srcColumn * frameSize.X, srcRow * frameSize.Y);
|
||||
|
||||
var sheetColumn = (sheetIndex + i) % dimensionX;
|
||||
var sheetRow = (sheetIndex + i) / dimensionX;
|
||||
var sheetPos = (sheetColumn * frameSize.X, sheetRow * frameSize.Y);
|
||||
|
||||
var srcBox = UIBox2i.FromDimensions(srcPos, frameSize);
|
||||
|
||||
ImageOps.Blit(reg.Src, srcBox, sheet, sheetPos);
|
||||
}
|
||||
|
||||
sheetIndex += reg.TotalFrameCount;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toAtlas.Length; i++)
|
||||
{
|
||||
ref var reg = ref toAtlas[i];
|
||||
reg.Src.Dispose();
|
||||
}
|
||||
|
||||
var ms = new MemoryStream();
|
||||
sheet.Metadata.GetPngMetadata().TextData.Add(new PngTextData("Description", metaJson, "", ""));
|
||||
sheet.SaveAsPng(ms);
|
||||
|
||||
sheet.Dispose();
|
||||
|
||||
return new AssetFileMemory($"{rsiPath}c", ms.ToArray());
|
||||
}
|
||||
|
||||
internal struct StateReg
|
||||
{
|
||||
public Image<Rgba32> Src;
|
||||
public int TotalFrameCount;
|
||||
}
|
||||
|
||||
private sealed class RsiDat
|
||||
|
||||
@@ -15,6 +15,9 @@ public sealed class RobustClientAssetGraph
|
||||
public AssetPassPipe PresetPasses { get; }
|
||||
public AssetPassPipe Output { get; }
|
||||
public AssetPassNormalizeText NormalizeText { get; }
|
||||
public AssetPassMergeTextDirectories MergePrototypeDirectories { get; }
|
||||
public AssetPassMergeTextDirectories MergeLocaleDirectories { get; }
|
||||
public AssetPassPackRsis PackRsis { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Collection of all passes in this preset graph.
|
||||
@@ -30,11 +33,41 @@ public sealed class RobustClientAssetGraph
|
||||
PresetPasses = new AssetPassPipe { Name = "RobustClientAssetGraphPresetPasses" };
|
||||
Output = new AssetPassPipe { Name = "RobustClientAssetGraphOutput", CheckDuplicates = true };
|
||||
NormalizeText = new AssetPassNormalizeText { Name = "RobustClientAssetGraphNormalizeText" };
|
||||
MergePrototypeDirectories = new AssetPassMergeTextDirectories(
|
||||
"Prototypes",
|
||||
"yml",
|
||||
// Separate each merged YAML file with a document to provide proper isolation.
|
||||
formatterHead: file => $"--- # BEGIN {file}",
|
||||
formatterTail: file => $"# END {file}")
|
||||
{
|
||||
Name = "RobustClientAssetGraphMergePrototypeDirectories"
|
||||
};
|
||||
MergeLocaleDirectories = new AssetPassMergeTextDirectories(
|
||||
"Locale",
|
||||
"ftl",
|
||||
formatterHead: file => $"# BEGIN {file}",
|
||||
formatterTail: file => $"# END {file}")
|
||||
{
|
||||
Name = "RobustClientAssetGraphMergeLocaleDirectories"
|
||||
};
|
||||
PackRsis = new AssetPassPackRsis
|
||||
{
|
||||
Name = "RobustClientAssetGraphPackRsis",
|
||||
};
|
||||
|
||||
PresetPasses.AddDependency(Input);
|
||||
PackRsis.AddDependency(PresetPasses).AddBefore(NormalizeText);
|
||||
MergePrototypeDirectories.AddDependency(PresetPasses).AddBefore(NormalizeText);
|
||||
MergeLocaleDirectories.AddDependency(PresetPasses).AddBefore(NormalizeText);
|
||||
NormalizeText.AddDependency(PresetPasses).AddBefore(Output);
|
||||
// RSI packing goes through text normalization,
|
||||
// to catch meta.jsons that have been skipped by the RSI packing pass.
|
||||
NormalizeText.AddDependency(PackRsis).AddBefore(Output);
|
||||
Output.AddDependency(PresetPasses);
|
||||
Output.AddDependency(NormalizeText);
|
||||
Output.AddDependency(MergePrototypeDirectories);
|
||||
Output.AddDependency(MergeLocaleDirectories);
|
||||
Output.AddDependency(PackRsis);
|
||||
|
||||
AllPasses = new AssetPass[]
|
||||
{
|
||||
@@ -42,6 +75,9 @@ public sealed class RobustClientAssetGraph
|
||||
PresetPasses,
|
||||
Output,
|
||||
NormalizeText,
|
||||
MergePrototypeDirectories,
|
||||
MergeLocaleDirectories,
|
||||
PackRsis
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ public static class AttributeHelper
|
||||
}
|
||||
|
||||
public static bool HasAttribute(
|
||||
INamedTypeSymbol symbol,
|
||||
INamedTypeSymbol attribute,
|
||||
ITypeSymbol symbol,
|
||||
ITypeSymbol attribute,
|
||||
[NotNullWhen(true)] out AttributeData? matchedAttribute)
|
||||
{
|
||||
matchedAttribute = null;
|
||||
|
||||
@@ -43,6 +43,8 @@ public static class Diagnostics
|
||||
public const string IdPrototypeNetSerializable = "RA0037";
|
||||
public const string IdPrototypeSerializable = "RA0038";
|
||||
public const string IdPrototypeInstantiation = "RA0039";
|
||||
public const string IdAutoGenStateAttributeMissing = "RA0040";
|
||||
public const string IdAutoGenStateParamMissing = "RA0041";
|
||||
|
||||
public static SuppressionDescriptor MeansImplicitAssignment =>
|
||||
new SuppressionDescriptor("RADC1000", "CS0649", "Marked as implicitly assigned.");
|
||||
|
||||
@@ -54,4 +54,19 @@ public static class TypeSymbolHelper
|
||||
current = current.BaseType;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If <paramref name="type"/> is a Nullable{T}, returns the <see cref="ITypeSymbol"/> of the underlying type.
|
||||
/// Otherwise, returns <paramref name="type"/>.
|
||||
/// </summary>
|
||||
// Modified from https://www.meziantou.net/working-with-types-in-a-roslyn-analyzer.htm
|
||||
public static ITypeSymbol GetNullableUnderlyingTypeOrSelf(ITypeSymbol type)
|
||||
{
|
||||
if (type is INamedTypeSymbol namedType && namedType.ConstructedFrom.SpecialType == SpecialType.System_Nullable_T)
|
||||
{
|
||||
return namedType.TypeArguments[0];
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Collections.Immutable;
|
||||
using System.Text;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
@@ -85,12 +85,17 @@ public sealed class ComponentPauseGenerator : IIncrementalGenerator
|
||||
|
||||
var invalid = false;
|
||||
var nullable = false;
|
||||
var dictionary = false;
|
||||
if (namedType.Name != "TimeSpan")
|
||||
{
|
||||
if (namedType is { Name: "Nullable", TypeArguments: [{Name: "TimeSpan"}] })
|
||||
{
|
||||
nullable = true;
|
||||
}
|
||||
else if (namedType is { Name: "Dictionary", TypeArguments: [{}, {Name: "TimeSpan"}]})
|
||||
{
|
||||
dictionary = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
invalid = true;
|
||||
@@ -101,7 +106,7 @@ public sealed class ComponentPauseGenerator : IIncrementalGenerator
|
||||
if (AttributeHelper.HasAttribute(member, AutoNetworkFieldAttributeName, out var _))
|
||||
dirty = true;
|
||||
|
||||
fieldBuilder.Add(new FieldInfo(member.Name, nullable, invalid, member.Locations[0]));
|
||||
fieldBuilder.Add(new FieldInfo(member.Name, nullable, invalid, dictionary, member.Locations[0]));
|
||||
}
|
||||
|
||||
return new ComponentInfo(
|
||||
@@ -181,6 +186,13 @@ public sealed class ComponentPauseGenerator : IIncrementalGenerator
|
||||
component.{field.Name} = component.{field.Name}.Value + args.PausedTime;
|
||||
""");
|
||||
}
|
||||
else if (field.Dictionary)
|
||||
{
|
||||
builder.AppendLine($"""
|
||||
foreach (var key in component.{field.Name}.Keys)
|
||||
component.{field.Name}[key] += args.PausedTime;
|
||||
""");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AppendLine($" component.{field.Name} += args.PausedTime;");
|
||||
@@ -247,7 +259,7 @@ public sealed class ComponentPauseGenerator : IIncrementalGenerator
|
||||
bool NotComponent,
|
||||
Location Location);
|
||||
|
||||
public sealed record FieldInfo(string Name, bool Nullable, bool Invalid, Location Location);
|
||||
public sealed record FieldInfo(string Name, bool Nullable, bool Invalid, bool Dictionary, Location Location);
|
||||
|
||||
public sealed record AllFieldInfo(string Name, string ParentDisplayName, Location Location);
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ namespace Robust.Server
|
||||
: null;
|
||||
|
||||
// Set up the VFS
|
||||
_resources.Initialize(dataDir);
|
||||
_resources.Initialize(dataDir, hideUserDataDir: false);
|
||||
|
||||
var mountOptions = _commandLineArgs != null
|
||||
? MountOptions.Merge(_commandLineArgs.MountOptions, Options.MountOptions) : Options.MountOptions;
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Robust.Server.Console.Commands;
|
||||
|
||||
public sealed class ScaleCommand : LocalizedCommands
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
public override string Command => "scale";
|
||||
|
||||
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||
{
|
||||
switch (args.Length)
|
||||
{
|
||||
case 1:
|
||||
return CompletionResult.FromOptions(CompletionHelper.NetEntities(args[0], entManager: _entityManager));
|
||||
case 2:
|
||||
return CompletionResult.FromHint(Loc.GetString("cmd-hint-float"));
|
||||
default:
|
||||
return CompletionResult.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length != 2)
|
||||
{
|
||||
shell.WriteError($"Insufficient number of args supplied: expected 2 and received {args.Length}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!NetEntity.TryParse(args[0], out var netEntity))
|
||||
{
|
||||
shell.WriteError($"Unable to find entity {args[0]}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!float.TryParse(args[1], out var scale))
|
||||
{
|
||||
shell.WriteError($"Invalid scale supplied of {args[0]}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (scale < 0f)
|
||||
{
|
||||
shell.WriteError($"Invalid scale supplied that is negative!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Event for content to use
|
||||
// We'll just set engine stuff here
|
||||
var physics = _entityManager.System<SharedPhysicsSystem>();
|
||||
var appearance = _entityManager.System<AppearanceSystem>();
|
||||
|
||||
var uid = _entityManager.GetEntity(netEntity);
|
||||
_entityManager.EnsureComponent<ScaleVisualsComponent>(uid);
|
||||
var @event = new ScaleEntityEvent();
|
||||
_entityManager.EventBus.RaiseLocalEvent(uid, ref @event);
|
||||
|
||||
var appearanceComponent = _entityManager.EnsureComponent<AppearanceComponent>(uid);
|
||||
if (!appearance.TryGetData<Vector2>(uid, ScaleVisuals.Scale, out var oldScale, appearanceComponent))
|
||||
oldScale = Vector2.One;
|
||||
|
||||
appearance.SetData(uid, ScaleVisuals.Scale, oldScale * scale, appearanceComponent);
|
||||
|
||||
if (_entityManager.TryGetComponent(uid, out FixturesComponent? manager))
|
||||
{
|
||||
foreach (var (id, fixture) in manager.Fixtures)
|
||||
{
|
||||
switch (fixture.Shape)
|
||||
{
|
||||
case EdgeShape edge:
|
||||
physics.SetVertices(uid, id, fixture,
|
||||
edge,
|
||||
edge.Vertex0 * scale,
|
||||
edge.Vertex1 * scale,
|
||||
edge.Vertex2 * scale,
|
||||
edge.Vertex3 * scale, manager);
|
||||
break;
|
||||
case PhysShapeCircle circle:
|
||||
physics.SetPositionRadius(uid, id, fixture, circle, circle.Position * scale, circle.Radius * scale, manager);
|
||||
break;
|
||||
case PolygonShape poly:
|
||||
var verts = poly.Vertices;
|
||||
|
||||
for (var i = 0; i < poly.VertexCount; i++)
|
||||
{
|
||||
verts[i] *= scale;
|
||||
}
|
||||
|
||||
physics.SetVertices(uid, id, fixture, poly, verts, manager);
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ByRefEvent]
|
||||
public readonly record struct ScaleEntityEvent(EntityUid Uid) {}
|
||||
}
|
||||
@@ -103,6 +103,7 @@ namespace Robust.Server.Player
|
||||
if (!TryGetSessionById(user, out var session))
|
||||
return;
|
||||
|
||||
RemoveSession(session.UserId);
|
||||
SetStatus(session, SessionStatus.Disconnected);
|
||||
SetAttachedEntity(session, null, out _, true);
|
||||
|
||||
@@ -112,7 +113,6 @@ namespace Robust.Server.Player
|
||||
viewSys.RemoveViewSubscriber(eye, session);
|
||||
}
|
||||
|
||||
RemoveSession(session.UserId);
|
||||
PlayerCountMetric.Set(PlayerCount);
|
||||
Dirty();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
<PackageReference Include="TerraFX.Interop.Windows" PrivateAssets="compile" />
|
||||
<PackageReference Include="Microsoft.Extensions.ObjectPool" PrivateAssets="compile" />
|
||||
<PackageReference Include="SpaceWizards.Sodium" PrivateAssets="compile" />
|
||||
<PackageReference Include="SharpZstd.Interop" PrivateAssets="compile" />
|
||||
<PackageReference Include="SharpZstd.Interop" PrivateAssets="compile" ExcludeAssets="native" />
|
||||
<PackageReference Include="Robust.Natives.Zstd" />
|
||||
<PackageReference Condition="'$(RobustToolsBuild)' == 'True'" Include="JetBrains.Profiler.Api" />
|
||||
<PackageReference Include="Microsoft.NET.ILLink.Tasks" />
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@ public sealed class AutoGenerateComponentStateAttribute : Attribute
|
||||
/// If this is true, the autogenerated code will raise a <see cref="AfterAutoHandleStateEvent"/> component event
|
||||
/// so that user-defined systems can have effects after handling state without redefining all replication.
|
||||
/// </summary>
|
||||
public bool RaiseAfterAutoHandleState;
|
||||
public readonly bool RaiseAfterAutoHandleState;
|
||||
|
||||
/// <summary>
|
||||
/// Should delta states be generated for every field.
|
||||
/// </summary>
|
||||
public bool FieldDeltas;
|
||||
public readonly bool FieldDeltas;
|
||||
|
||||
public AutoGenerateComponentStateAttribute(bool raiseAfterAutoHandleState = false, bool fieldDeltas = false)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using Lidgren.Network;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
@@ -1486,7 +1487,7 @@ namespace Robust.Shared
|
||||
/// Non-default seek modes WILL result in worse performance.
|
||||
/// </remarks>
|
||||
public static readonly CVarDef<int> ResStreamSeekMode =
|
||||
CVarDef.Create("res.stream_seek_mode", (int)ContentPack.StreamSeekMode.None);
|
||||
CVarDef.Create("res.stream_seek_mode", (int)StreamSeekMode.None);
|
||||
|
||||
/// <summary>
|
||||
/// Whether to watch prototype files for prototype reload on the client. Only applies to development builds.
|
||||
@@ -1882,11 +1883,28 @@ namespace Robust.Shared
|
||||
public static readonly CVarDef<int> ToolshedNearbyEntitiesLimit =
|
||||
CVarDef.Create("toolshed.nearby_entities_limit", 5, CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// The max amount of prototype ids that can be sent to the client when autocompleting prototype ids.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<int> ToolshedPrototypesAutocompleteLimit =
|
||||
CVarDef.Create("toolshed.prototype_autocomplete_limit", 256, CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/*
|
||||
* Localization
|
||||
*/
|
||||
|
||||
public static readonly CVarDef<string> LocCultureName =
|
||||
CVarDef.Create("loc.culture_name", "en-US", CVar.ARCHIVE);
|
||||
|
||||
/*
|
||||
* UI
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// The file XamlHotReloadManager looks for when locating the root of the project.
|
||||
/// By default, this is Space Station 14's sln, but it can be any file at the same root level.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<string> XamlHotReloadMarkerName =
|
||||
CVarDef.Create("ui.xaml_hot_reload_marker_name", "SpaceStation14.sln", CVar.CLIENTONLY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace Robust.Shared.Collections;
|
||||
|
||||
@@ -77,7 +77,7 @@ internal struct InvokeList<T>
|
||||
for (var i = 0; i < _entries.Length; i++)
|
||||
{
|
||||
var entry = _entries[i];
|
||||
if (equality.Equals(entry))
|
||||
if (equality.Equals(entry.Equality))
|
||||
{
|
||||
entryIdx = i;
|
||||
break;
|
||||
@@ -94,14 +94,12 @@ internal struct InvokeList<T>
|
||||
|
||||
// Create new backing array and copy stuff into it.
|
||||
var newEntries = new Entry[_entries.Length - 1];
|
||||
for (var i = 0; i < entryIdx; i++)
|
||||
for (int srcIdx = 0, dstIdx = 0; dstIdx < newEntries.Length; srcIdx++, dstIdx++)
|
||||
{
|
||||
newEntries[i] = _entries[i];
|
||||
}
|
||||
if (srcIdx == entryIdx)
|
||||
srcIdx++;
|
||||
|
||||
for (var i = entryIdx + 1; i < _entries.Length; i++)
|
||||
{
|
||||
newEntries[entryIdx - 1] = _entries[entryIdx];
|
||||
newEntries[dstIdx] = _entries[srcIdx];
|
||||
}
|
||||
|
||||
return new InvokeList<T>
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Shared.ColorNaming;
|
||||
|
||||
@@ -21,7 +22,8 @@ public static class ColorNaming
|
||||
(float.DegreesToRadians(285f), "color-purple"),
|
||||
(float.DegreesToRadians(330f), "color-pink"),
|
||||
};
|
||||
private static readonly (float Hue, string Loc) HueFallback = (float.DegreesToRadians(360f), "color-pink");
|
||||
// one past 360 because we're now inclusive on the upper for testing if we're out of bounds
|
||||
private static readonly (float Hue, string Loc) HueFallback = (float.DegreesToRadians(361f), "color-pink");
|
||||
|
||||
private const float BrownLightnessThreshold = 0.675f;
|
||||
private static readonly LocId OrangeString = "color-orange";
|
||||
@@ -63,7 +65,7 @@ public static class ColorNaming
|
||||
var prevData = HueNames[i];
|
||||
var nextData = i+1 < HueNames.Length ? HueNames[i+1] : HueFallback;
|
||||
|
||||
if (prevData.Hue >= hue || hue > nextData.Hue)
|
||||
if (prevData.Hue > hue || hue >= nextData.Hue)
|
||||
continue;
|
||||
|
||||
var loc = prevData.Loc;
|
||||
@@ -85,7 +87,8 @@ public static class ColorNaming
|
||||
return (localization.GetString(loc), adjustedLightness);
|
||||
}
|
||||
|
||||
throw new ArgumentOutOfRangeException("oklch", $"colour ({oklch}) hue {hue} is outside of expected bounds");
|
||||
DebugTools.Assert($"colour ({oklch}) hue {hue} is outside of expected bounds");
|
||||
return (localization.GetString("color-unknown"), lightness);
|
||||
}
|
||||
|
||||
private static string? DescribeChroma(Vector4 oklch, ILocalizationManager localization)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -25,7 +26,7 @@ namespace Robust.Shared.Configuration
|
||||
|
||||
private const char TABLE_DELIMITER = '.';
|
||||
protected readonly Dictionary<string, ConfigVar> _configVars = new();
|
||||
private string? _configFile;
|
||||
private ConfigFileStorage? _configFile;
|
||||
protected bool _isServer;
|
||||
|
||||
protected readonly ReaderWriterLockSlim Lock = new();
|
||||
@@ -182,7 +183,7 @@ namespace Robust.Shared.Configuration
|
||||
{
|
||||
using var file = File.OpenRead(configFile);
|
||||
var result = LoadFromTomlStream(file);
|
||||
_configFile = configFile;
|
||||
SetSaveFile(configFile);
|
||||
_sawmill.Info($"Configuration loaded from file");
|
||||
return result;
|
||||
}
|
||||
@@ -195,7 +196,12 @@ namespace Robust.Shared.Configuration
|
||||
|
||||
public void SetSaveFile(string configFile)
|
||||
{
|
||||
_configFile = configFile;
|
||||
_configFile = new ConfigFileStorageDisk { Path = configFile };
|
||||
}
|
||||
|
||||
public void SetVirtualConfig()
|
||||
{
|
||||
_configFile = new ConfigFileStorageVirtual();
|
||||
}
|
||||
|
||||
public void CheckUnusedCVars()
|
||||
@@ -312,8 +318,27 @@ namespace Robust.Shared.Configuration
|
||||
var memoryStream = new MemoryStream();
|
||||
SaveToTomlStream(memoryStream, cvars);
|
||||
memoryStream.Position = 0;
|
||||
using var file = File.Create(_configFile);
|
||||
memoryStream.CopyTo(file);
|
||||
|
||||
switch (_configFile)
|
||||
{
|
||||
case ConfigFileStorageDisk disk:
|
||||
{
|
||||
using var file = File.Create(disk.Path);
|
||||
memoryStream.CopyTo(file);
|
||||
break;
|
||||
}
|
||||
case ConfigFileStorageVirtual @virtual:
|
||||
{
|
||||
@virtual.Stream.SetLength(0);
|
||||
memoryStream.CopyTo(@virtual.Stream);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw new UnreachableException();
|
||||
}
|
||||
}
|
||||
|
||||
_sawmill.Info($"config saved to '{_configFile}'.");
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -954,6 +979,30 @@ namespace Robust.Shared.Configuration
|
||||
}
|
||||
|
||||
protected delegate void ValueChangedDelegate(object value, in CVarChangeInfo info);
|
||||
|
||||
private abstract class ConfigFileStorage;
|
||||
|
||||
private sealed class ConfigFileStorageDisk : ConfigFileStorage
|
||||
{
|
||||
public required string Path;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Path;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class ConfigFileStorageVirtual : ConfigFileStorage
|
||||
{
|
||||
// I did not realize when adding this class that there is currently no way to *load* this data again.
|
||||
// Oh well, might be useful for a future unit test.
|
||||
public readonly MemoryStream Stream = new();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "<VIRTUAL>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Robust.Shared.Configuration;
|
||||
|
||||
public static class ConfigurationManagerExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Subscribe to multiple cvar in succession and dispose object to unsubscribe from all of them when needed.
|
||||
/// </summary>
|
||||
public static ConfigurationMultiSubscriptionBuilder SubscribeMultiple(this IConfigurationManager manager)
|
||||
{
|
||||
return new ConfigurationMultiSubscriptionBuilder(manager);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Container for batch-unsubscription of config changed events.
|
||||
/// Call Dispose() when subscriptions are not needed anymore.
|
||||
/// </summary>
|
||||
public sealed class ConfigurationMultiSubscriptionBuilder(IConfigurationManager manager) : IDisposable
|
||||
{
|
||||
private readonly List<Action> _unsubscribeActions = [];
|
||||
|
||||
/// <inheritdoc cref="IConfigurationManager.OnValueChanged{T}(CVarDef{T},Action{T},bool)"/>>
|
||||
public ConfigurationMultiSubscriptionBuilder OnValueChanged<T>(
|
||||
CVarDef<T> cVar,
|
||||
CVarChanged<T> onValueChanged,
|
||||
bool invokeImmediately = false
|
||||
)
|
||||
where T : notnull
|
||||
{
|
||||
manager.OnValueChanged(cVar, onValueChanged, invokeImmediately);
|
||||
|
||||
_unsubscribeActions.Add(() => manager.UnsubValueChanged(cVar, onValueChanged));
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IConfigurationManager.OnValueChanged{T}(string,Action{T},bool)"/>>
|
||||
public ConfigurationMultiSubscriptionBuilder OnValueChanged<T>(
|
||||
string name,
|
||||
CVarChanged<T> onValueChanged,
|
||||
bool invokeImmediately = false
|
||||
)
|
||||
where T : notnull
|
||||
{
|
||||
manager.OnValueChanged(name, onValueChanged, invokeImmediately);
|
||||
|
||||
_unsubscribeActions.Add(() => manager.UnsubValueChanged(name, onValueChanged));
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IConfigurationManager.OnValueChanged{T}(CVarDef{T},CVarChanged{T},bool)"/>>
|
||||
public ConfigurationMultiSubscriptionBuilder OnValueChanged<T>(
|
||||
CVarDef<T> cVar,
|
||||
Action<T> onValueChanged,
|
||||
bool invokeImmediately = false
|
||||
)
|
||||
where T : notnull
|
||||
{
|
||||
manager.OnValueChanged(cVar, onValueChanged, invokeImmediately);
|
||||
|
||||
_unsubscribeActions.Add(() => manager.UnsubValueChanged(cVar, onValueChanged));
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IConfigurationManager.OnValueChanged{T}(string,CVarChanged{T},bool)"/>>
|
||||
public ConfigurationMultiSubscriptionBuilder OnValueChanged<T>(
|
||||
string name,
|
||||
Action<T> onValueChanged,
|
||||
bool invokeImmediately = false
|
||||
)
|
||||
where T : notnull
|
||||
{
|
||||
manager.OnValueChanged(name, onValueChanged, invokeImmediately);
|
||||
|
||||
_unsubscribeActions.Add(() => manager.UnsubValueChanged(name, onValueChanged));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var action in _unsubscribeActions)
|
||||
{
|
||||
action();
|
||||
}
|
||||
_unsubscribeActions.Clear();
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,15 @@ namespace Robust.Shared.Configuration
|
||||
void LoadCVarsFromAssembly(Assembly assembly);
|
||||
void LoadCVarsFromType(Type containingType);
|
||||
|
||||
/// <summary>
|
||||
/// Indicate that config should be stored in-memory.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This suppresses warnings from <see cref="IConfigurationManager.SaveToFile"/>
|
||||
/// if no config is otherwise loaded.
|
||||
/// </remarks>
|
||||
void SetVirtualConfig();
|
||||
|
||||
void Initialize(bool isServer);
|
||||
|
||||
void Shutdown();
|
||||
|
||||
@@ -60,9 +60,7 @@ namespace Robust.Shared.ContentPack
|
||||
|
||||
internal string GetPath(ResPath relPath)
|
||||
{
|
||||
return Path.GetFullPath(Path.Combine(_directory.FullName, relPath.ToRelativeSystemPath()))
|
||||
// Sanitise platform-specific path and standardize it for engine use.
|
||||
.Replace(Path.DirectorySeparatorChar, '/');
|
||||
return PathHelpers.SafeGetResourcePath(_directory.FullName, relPath);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -14,7 +14,11 @@ namespace Robust.Shared.ContentPack
|
||||
/// The directory to use for user data.
|
||||
/// If null, a virtual temporary file system is used instead.
|
||||
/// </param>
|
||||
void Initialize(string? userData);
|
||||
/// <param name="hideUserDataDir">
|
||||
/// If true, <see cref="IWritableDirProvider.RootDir"/> will be hidden on
|
||||
/// <see cref="IResourceManager.UserData"/>.
|
||||
/// </param>
|
||||
void Initialize(string? userData, bool hideUserDataDir);
|
||||
|
||||
/// <summary>
|
||||
/// Mounts a single stream as a content file. Useful for unit testing.
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Robust.Shared.ContentPack
|
||||
{
|
||||
/// <summary>
|
||||
/// The root path of this provider.
|
||||
/// Can be null if it's a virtual provider.
|
||||
/// Can be null if it's a virtual provider or the path is protected (e.g. on the client).
|
||||
/// </summary>
|
||||
string? RootDir { get; }
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Robust.Shared.ContentPack
|
||||
{
|
||||
@@ -63,5 +64,27 @@ namespace Robust.Shared.ContentPack
|
||||
!OperatingSystem.IsWindows()
|
||||
&& !OperatingSystem.IsMacOS();
|
||||
|
||||
|
||||
internal static string SafeGetResourcePath(string baseDir, ResPath path)
|
||||
{
|
||||
var relSysPath = path.ToRelativeSystemPath();
|
||||
if (relSysPath.Contains("\\..") || relSysPath.Contains("/.."))
|
||||
{
|
||||
// Hard cap on any exploit smuggling a .. in there.
|
||||
// Since that could allow leaving sandbox.
|
||||
throw new InvalidOperationException($"This branch should never be reached. Path: {path}");
|
||||
}
|
||||
|
||||
var retPath = Path.GetFullPath(Path.Join(baseDir, relSysPath));
|
||||
// better safe than sorry check
|
||||
if (!retPath.StartsWith(baseDir))
|
||||
{
|
||||
// Allow path to match if it's just missing the directory separator at the end.
|
||||
if (retPath != baseDir.TrimEnd(Path.DirectorySeparatorChar))
|
||||
throw new InvalidOperationException($"This branch should never be reached. Path: {path}");
|
||||
}
|
||||
|
||||
return retPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,13 +41,13 @@ namespace Robust.Shared.ContentPack
|
||||
public IWritableDirProvider UserData { get; private set; } = default!;
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void Initialize(string? userData)
|
||||
public virtual void Initialize(string? userData, bool hideRootDir)
|
||||
{
|
||||
Sawmill = _logManager.GetSawmill("res");
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
UserData = new WritableDirProvider(Directory.CreateDirectory(userData));
|
||||
UserData = new WritableDirProvider(Directory.CreateDirectory(userData), hideRootDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -379,6 +379,10 @@ namespace Robust.Shared.ContentPack
|
||||
{
|
||||
var rootDir = loader.GetPath(new ResPath(@"/"));
|
||||
|
||||
// TODO: GET RID OF THIS.
|
||||
// This code shouldn't be passing OS disk paths through ResPath.
|
||||
rootDir = rootDir.Replace(Path.DirectorySeparatorChar, '/');
|
||||
|
||||
yield return new ResPath(rootDir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,6 +591,7 @@ Types:
|
||||
Enumerable: { All: True }
|
||||
IGrouping`2: { All: True }
|
||||
IOrderedEnumerable`1: { All: True }
|
||||
ImmutableArrayExtensions: { All: True }
|
||||
System.Net:
|
||||
DnsEndPoint: { }
|
||||
IPAddress: { All: True }
|
||||
|
||||
@@ -10,17 +10,22 @@ namespace Robust.Shared.ContentPack
|
||||
/// <inheritdoc />
|
||||
internal sealed class WritableDirProvider : IWritableDirProvider
|
||||
{
|
||||
/// <inheritdoc />
|
||||
private readonly bool _hideRootDir;
|
||||
|
||||
public string RootDir { get; }
|
||||
|
||||
string? IWritableDirProvider.RootDir => _hideRootDir ? null : RootDir;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs an instance of <see cref="WritableDirProvider"/>.
|
||||
/// </summary>
|
||||
/// <param name="rootDir">Root file system directory to allow writing.</param>
|
||||
public WritableDirProvider(DirectoryInfo rootDir)
|
||||
/// <param name="hideRootDir">If true, <see cref="IWritableDirProvider.RootDir"/> is reported as null.</param>
|
||||
public WritableDirProvider(DirectoryInfo rootDir, bool hideRootDir)
|
||||
{
|
||||
// FullName does not have a trailing separator, and we MUST have a separator.
|
||||
RootDir = rootDir.FullName + Path.DirectorySeparatorChar.ToString();
|
||||
_hideRootDir = hideRootDir;
|
||||
}
|
||||
|
||||
#region File Access
|
||||
@@ -119,7 +124,7 @@ namespace Robust.Shared.ContentPack
|
||||
throw new FileNotFoundException();
|
||||
|
||||
var dirInfo = new DirectoryInfo(GetFullPath(path));
|
||||
return new WritableDirProvider(dirInfo);
|
||||
return new WritableDirProvider(dirInfo, _hideRootDir);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -180,20 +185,7 @@ namespace Robust.Shared.ContentPack
|
||||
|
||||
path = path.Clean();
|
||||
|
||||
return GetFullPath(RootDir, path);
|
||||
}
|
||||
|
||||
private static string GetFullPath(string root, ResPath path)
|
||||
{
|
||||
var relPath = path.ToRelativeSystemPath();
|
||||
if (relPath.Contains("\\..") || relPath.Contains("/.."))
|
||||
{
|
||||
// Hard cap on any exploit smuggling a .. in there.
|
||||
// Since that could allow leaving sandbox.
|
||||
throw new InvalidOperationException($"This branch should never be reached. Path: {path}");
|
||||
}
|
||||
|
||||
return Path.GetFullPath(Path.Combine(root, relPath));
|
||||
return PathHelpers.SafeGetResourcePath(RootDir, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Robust.Shared.GameObjects;
|
||||
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class ScaleVisualsComponent : Component {}
|
||||
@@ -1,30 +1,39 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
using Robust.Shared.Serialization.Markdown.Mapping;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Robust.Shared.GameObjects
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface used to allow the map loader to override prototype data with map data.
|
||||
/// Interface used to allow the map loader to override prototype data with map data.
|
||||
/// </summary>
|
||||
internal interface IEntityLoadContext
|
||||
{
|
||||
/// <summary>
|
||||
/// Tries getting the data of the provided component
|
||||
/// </summary>
|
||||
/// <summary>Tries getting the data of the given component.</summary>
|
||||
/// <param name="componentName">Name of component to find.</param>
|
||||
/// <param name="component">Found component or null.</param>
|
||||
/// <returns>True if the component was found, false otherwise.</returns>
|
||||
/// <seealso cref="TryGetComponent{T}"/>
|
||||
bool TryGetComponent(string componentName, [NotNullWhen(true)] out IComponent? component);
|
||||
|
||||
/// <summary>Tries getting the data of the given component.</summary>
|
||||
/// <typeparam name="TComponent">Type of component to be found.</typeparam>
|
||||
/// <param name="componentFactory">Component factory required for the lookup.</param>
|
||||
/// <param name="component">Found component or null.</param>
|
||||
/// <returns>True if the component was found, false otherwise.</returns>
|
||||
/// <seealso cref="TryGetComponent"/>
|
||||
bool TryGetComponent<TComponent>(
|
||||
IComponentFactory componentFactory,
|
||||
[NotNullWhen(true)] out TComponent? component
|
||||
) where TComponent : class, IComponent, new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets all components registered for the entityloadcontext, overrides as well as extra components
|
||||
/// Gets all components registered for the entityloadcontext, overrides as well as extra components
|
||||
/// </summary>
|
||||
IEnumerable<string> GetExtraComponentTypes();
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether a given component should be added to an entity. Used to prevent certain prototype components from being added while spawning an entity.
|
||||
/// Checks whether a given component should be added to an entity.
|
||||
/// Used to prevent certain prototype components from being added while spawning an entity.
|
||||
/// </summary>
|
||||
bool ShouldSkipComponent(string compName);
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
using System;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Robust.Shared.GameObjects;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum ScaleVisuals : byte
|
||||
{
|
||||
// Blep
|
||||
Scale,
|
||||
}
|
||||
@@ -262,12 +262,24 @@ public abstract partial class SharedMapSystem
|
||||
return (uid, AddComp<MapComponent>(uid), meta);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a map with the specified map id.
|
||||
/// </summary>
|
||||
public void DeleteMap(MapId mapId)
|
||||
{
|
||||
if (TryGetMap(mapId, out var uid))
|
||||
Del(uid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a map with the specified map id in the next tick.
|
||||
/// </summary>
|
||||
public void QueueDeleteMap(MapId mapId)
|
||||
{
|
||||
if (TryGetMap(mapId, out var uid))
|
||||
QueueDel(uid);
|
||||
}
|
||||
|
||||
public IEnumerable<MapId> GetAllMapIds()
|
||||
{
|
||||
return Maps.Keys;
|
||||
|
||||
@@ -55,12 +55,25 @@ public sealed partial class NetManager
|
||||
NetChannel channel,
|
||||
NetMessage message)
|
||||
{
|
||||
if (!channel.IsConnected)
|
||||
{
|
||||
_logger.Error(
|
||||
$"Tried to send message \"{message}\" to disconnected channel {channel}\n{Environment.StackTrace}");
|
||||
return;
|
||||
}
|
||||
|
||||
var packet = BuildMessage(message, channel.Connection.Peer);
|
||||
var method = message.DeliveryMethod;
|
||||
|
||||
LogSend(message, method, packet);
|
||||
|
||||
var item = new EncryptChannelItem { Message = packet, Method = method };
|
||||
var item = new EncryptChannelItem
|
||||
{
|
||||
Message = packet,
|
||||
Method = method,
|
||||
Owner = this,
|
||||
RobustMessage = message,
|
||||
};
|
||||
|
||||
// If the message is ordered, we have to send it to the encryption channel.
|
||||
if (method is NetDeliveryMethod.ReliableOrdered
|
||||
@@ -70,7 +83,7 @@ public sealed partial class NetManager
|
||||
if (channel.EncryptionChannel is { } encryptionChannel)
|
||||
{
|
||||
var task = encryptionChannel.WriteAsync(item);
|
||||
if (!task.IsCompleted)
|
||||
if (!task.IsCompletedSuccessfully)
|
||||
task.AsTask().Wait();
|
||||
}
|
||||
else
|
||||
@@ -101,12 +114,20 @@ public sealed partial class NetManager
|
||||
{
|
||||
channel.Encryption?.Encrypt(item.Message);
|
||||
|
||||
channel.Connection.Peer.SendMessage(item.Message, channel.Connection, item.Method);
|
||||
var result = channel.Connection.Peer.SendMessage(item.Message, channel.Connection, item.Method);
|
||||
if (result is not (NetSendResult.Sent or NetSendResult.Queued))
|
||||
{
|
||||
// Logging stack trace here won't be useful as it'll likely be thread pooled on production scenarios.
|
||||
item.Owner._logger.Warning(
|
||||
$"Failed to send message {item.RobustMessage} to {channel} via Lidgren: {result}");
|
||||
}
|
||||
}
|
||||
|
||||
private struct EncryptChannelItem
|
||||
{
|
||||
public required NetOutgoingMessage Message { get; init; }
|
||||
public required NetDeliveryMethod Method { get; init; }
|
||||
public required NetOutgoingMessage Message;
|
||||
public required NetDeliveryMethod Method;
|
||||
public required NetMessage RobustMessage;
|
||||
public required NetManager Owner;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -827,6 +827,10 @@ namespace Robust.Shared.Network
|
||||
_assignedUsernames.Remove(channel.UserName);
|
||||
_assignedUserIds.Remove(channel.UserId);
|
||||
|
||||
_channels.Remove(connection);
|
||||
peer.RemoveChannel(channel);
|
||||
channel.EncryptionChannel?.Complete();
|
||||
|
||||
#if EXCEPTION_TOLERANCE
|
||||
try
|
||||
{
|
||||
@@ -842,9 +846,6 @@ namespace Robust.Shared.Network
|
||||
_logger.Error("Caught exception in OnDisconnected handler:\n{0}", e);
|
||||
}
|
||||
#endif
|
||||
_channels.Remove(connection);
|
||||
peer.RemoveChannel(channel);
|
||||
channel.EncryptionChannel?.Complete();
|
||||
|
||||
if (IsClient)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -71,6 +73,45 @@ public abstract partial class SharedPhysicsSystem
|
||||
_fixtures.FixtureUpdate(uid, manager: manager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increases or decreases all fixtures of an entity in size by a certain factor.
|
||||
/// </summary>
|
||||
public void ScaleFixtures(Entity<FixturesComponent?> ent, float factor)
|
||||
{
|
||||
if (!Resolve(ent, ref ent.Comp))
|
||||
return;
|
||||
|
||||
foreach (var (id, fixture) in ent.Comp.Fixtures)
|
||||
{
|
||||
switch (fixture.Shape)
|
||||
{
|
||||
case EdgeShape edge:
|
||||
SetVertices(ent, id, fixture,
|
||||
edge,
|
||||
edge.Vertex0 * factor,
|
||||
edge.Vertex1 * factor,
|
||||
edge.Vertex2 * factor,
|
||||
edge.Vertex3 * factor, ent.Comp);
|
||||
break;
|
||||
case PhysShapeCircle circle:
|
||||
SetPositionRadius(ent, id, fixture, circle, circle.Position * factor, circle.Radius * factor, ent.Comp);
|
||||
break;
|
||||
case PolygonShape poly:
|
||||
var verts = poly.Vertices;
|
||||
|
||||
for (var i = 0; i < poly.VertexCount; i++)
|
||||
{
|
||||
verts[i] *= factor;
|
||||
}
|
||||
|
||||
SetVertices(ent, id, fixture, poly, verts, ent.Comp);
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Collision Masks & Layers
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -413,6 +413,7 @@ namespace Robust.Shared.Prototypes
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryGetComponent(string componentName, [NotNullWhen(true)] out IComponent? component)
|
||||
{
|
||||
var success = TryGetValue(componentName, out var comp);
|
||||
@@ -421,11 +422,30 @@ namespace Robust.Shared.Prototypes
|
||||
return success;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryGetComponent<TComponent>(
|
||||
IComponentFactory componentFactory,
|
||||
[NotNullWhen(true)] out TComponent? component
|
||||
) where TComponent : class, IComponent, new()
|
||||
{
|
||||
component = null;
|
||||
var componentName = componentFactory.GetComponentName<TComponent>();
|
||||
if (TryGetComponent(componentName, out var foundComponent))
|
||||
{
|
||||
component = (TComponent)foundComponent;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<string> GetExtraComponentTypes()
|
||||
{
|
||||
return Keys;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool ShouldSkipComponent(string compName)
|
||||
{
|
||||
return false; //Registries cannot represent the "remove this component" state.
|
||||
|
||||
@@ -52,21 +52,36 @@ public partial class PrototypeManager
|
||||
return (file, Array.Empty<ExtractedMappingData>());
|
||||
|
||||
var extractedList = new List<ExtractedMappingData>();
|
||||
var i = 0;
|
||||
foreach (var document in DataNodeParser.ParseYamlStream(reader))
|
||||
{
|
||||
i += 1;
|
||||
LoadedData?.Invoke(document);
|
||||
|
||||
var seq = (SequenceDataNode)document.Root;
|
||||
foreach (var mapping in seq.Sequence)
|
||||
switch (document.Root)
|
||||
{
|
||||
var data = ExtractMapping((MappingDataNode)mapping);
|
||||
if (data != null)
|
||||
{
|
||||
if (ignored)
|
||||
AbstractPrototype(data.Data);
|
||||
case SequenceDataNode seq:
|
||||
foreach (var mapping in seq.Sequence)
|
||||
{
|
||||
var data = ExtractMapping((MappingDataNode)mapping);
|
||||
if (data != null)
|
||||
{
|
||||
if (ignored)
|
||||
AbstractPrototype(data.Data);
|
||||
|
||||
extractedList.Add(data);
|
||||
}
|
||||
extractedList.Add(data);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case ValueDataNode { Value: "" }:
|
||||
// Documents with absolutely nothing in them get deserialized as this.
|
||||
// How does this happen? Text file merger generates separate documents for each file.
|
||||
// Just skip it.
|
||||
break;
|
||||
default:
|
||||
sawmill.Error($"{file} document #{i} is not a sequence! Did you forget to indent your prototype with a '-'?");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Graphics;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Formats;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using ImageConfiguration = SixLabors.ImageSharp.Configuration;
|
||||
|
||||
namespace Robust.Shared.Resources;
|
||||
|
||||
@@ -27,6 +32,18 @@ internal static class RsiLoading
|
||||
/// </summary>
|
||||
public const uint MAXIMUM_RSI_VERSION = 1;
|
||||
|
||||
internal const string RsicPngField = "robusttoolbox_rsic_meta";
|
||||
|
||||
internal static RsiMetadata LoadRsiMetadata(string metadata)
|
||||
{
|
||||
var manifestJson = JsonSerializer.Deserialize<RsiJsonMetadata>(metadata, SerializerOptions);
|
||||
|
||||
if (manifestJson == null)
|
||||
throw new RSILoadException("Manifest JSON failed to deserialize!");
|
||||
|
||||
return LoadRsiMetadataCore(manifestJson);
|
||||
}
|
||||
|
||||
internal static RsiMetadata LoadRsiMetadata(Stream manifestFile)
|
||||
{
|
||||
var manifestJson = JsonSerializer.Deserialize<RsiJsonMetadata>(manifestFile, SerializerOptions);
|
||||
@@ -34,6 +51,11 @@ internal static class RsiLoading
|
||||
if (manifestJson == null)
|
||||
throw new RSILoadException($"Manifest JSON failed to deserialize!");
|
||||
|
||||
return LoadRsiMetadataCore(manifestJson);
|
||||
}
|
||||
|
||||
private static RsiMetadata LoadRsiMetadataCore(RsiJsonMetadata manifestJson)
|
||||
{
|
||||
var size = manifestJson.Size;
|
||||
var states = new StateMetadata[manifestJson.States.Length];
|
||||
|
||||
@@ -104,7 +126,135 @@ internal static class RsiLoading
|
||||
};
|
||||
}
|
||||
|
||||
return new RsiMetadata(size, states, textureParams, manifestJson.MetaAtlas);
|
||||
// Check for duplicate states
|
||||
for (var i = 0; i < states.Length; i++)
|
||||
{
|
||||
var stateId = states[i].StateId;
|
||||
|
||||
for (int j = i + 1; j < states.Length; j++)
|
||||
{
|
||||
if (stateId == states[j].StateId)
|
||||
throw new RSILoadException($"RSI has a duplicate stateId '{stateId}'.");
|
||||
}
|
||||
}
|
||||
|
||||
return new RsiMetadata(size, states, textureParams, manifestJson.MetaAtlas, manifestJson.Rsic);
|
||||
}
|
||||
|
||||
internal static int[] CalculateFrameCounts(RsiMetadata metadata)
|
||||
{
|
||||
var counts = new int[metadata.States.Length];
|
||||
|
||||
for (var i = 0; i < metadata.States.Length; i++)
|
||||
{
|
||||
var state = metadata.States[i];
|
||||
counts[i] = state.Delays.Sum(delayList => delayList.Length);
|
||||
}
|
||||
|
||||
return counts;
|
||||
}
|
||||
|
||||
internal static Image<Rgba32>[] LoadImages(
|
||||
RsiMetadata metadata,
|
||||
ImageConfiguration configuration,
|
||||
Func<string, Stream> openStream)
|
||||
{
|
||||
var images = new Image<Rgba32>[metadata.States.Length];
|
||||
|
||||
var decoderOptions = new DecoderOptions
|
||||
{
|
||||
Configuration = configuration,
|
||||
};
|
||||
|
||||
var frameSize = metadata.Size;
|
||||
|
||||
try
|
||||
{
|
||||
for (var i = 0; i < metadata.States.Length; i++)
|
||||
{
|
||||
var state = metadata.States[i];
|
||||
using var stream = openStream(state.StateId);
|
||||
|
||||
var image = Image.Load<Rgba32>(decoderOptions, stream);
|
||||
images[i] = image;
|
||||
|
||||
if (image.Width % frameSize.X != 0 || image.Height % frameSize.Y != 0)
|
||||
{
|
||||
var regDims = $"{image.Width}x{image.Height}";
|
||||
var iconDims = $"{frameSize.X}x{frameSize.Y}";
|
||||
throw new RSILoadException($"State '{state.StateId}' image size ({regDims}) is not a multiple of the icon size ({iconDims}).");
|
||||
}
|
||||
}
|
||||
|
||||
return images;
|
||||
}
|
||||
catch
|
||||
{
|
||||
foreach (var image in images)
|
||||
{
|
||||
// ReSharper disable once ConditionalAccessQualifierIsNonNullableAccordingToAPIContract
|
||||
image?.Dispose();
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Image<Rgba32> GenerateAtlas(
|
||||
RsiMetadata metadata,
|
||||
int[] frameCounts,
|
||||
Image<Rgba32>[] images,
|
||||
ImageConfiguration configuration,
|
||||
out int dimX)
|
||||
{
|
||||
var frameSize = metadata.Size;
|
||||
|
||||
// Poorly hacked in texture atlas support here.
|
||||
var totalFrameCount = frameCounts.Sum();
|
||||
|
||||
// Generate atlas.
|
||||
var dimensionX = (int) MathF.Ceiling(MathF.Sqrt(totalFrameCount));
|
||||
var dimensionY = (int) MathF.Ceiling((float) totalFrameCount / dimensionX);
|
||||
|
||||
dimX = dimensionX;
|
||||
|
||||
var sheet = new Image<Rgba32>(configuration, dimensionX * frameSize.X, dimensionY * frameSize.Y);
|
||||
|
||||
try
|
||||
{
|
||||
var sheetIndex = 0;
|
||||
for (var index = 0; index < frameCounts.Length; index++)
|
||||
{
|
||||
var frameCount = frameCounts[index];
|
||||
var image = images[index];
|
||||
|
||||
// Blit all the frames over.
|
||||
for (var i = 0; i < frameCount; i++)
|
||||
{
|
||||
var srcWidth = (image.Width / frameSize.X);
|
||||
var srcColumn = i % srcWidth;
|
||||
var srcRow = i / srcWidth;
|
||||
var srcPos = (srcColumn * frameSize.X, srcRow * frameSize.Y);
|
||||
|
||||
var sheetColumn = (sheetIndex + i) % dimensionX;
|
||||
var sheetRow = (sheetIndex + i) / dimensionX;
|
||||
var sheetPos = (sheetColumn * frameSize.X, sheetRow * frameSize.Y);
|
||||
|
||||
var srcBox = UIBox2i.FromDimensions(srcPos, frameSize);
|
||||
|
||||
ImageOps.Blit(image, srcBox, sheet, sheetPos);
|
||||
}
|
||||
|
||||
sheetIndex += frameCount;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
sheet.Dispose();
|
||||
throw;
|
||||
}
|
||||
|
||||
return sheet;
|
||||
}
|
||||
|
||||
public static void Warmup()
|
||||
@@ -114,12 +264,13 @@ internal static class RsiLoading
|
||||
JsonSerializer.Deserialize<RsiJsonMetadata>(warmupJson, SerializerOptions);
|
||||
}
|
||||
|
||||
internal sealed class RsiMetadata(Vector2i size, StateMetadata[] states, TextureLoadParameters loadParameters, bool metaAtlas)
|
||||
internal sealed class RsiMetadata(Vector2i size, StateMetadata[] states, TextureLoadParameters loadParameters, bool metaAtlas, bool rsic)
|
||||
{
|
||||
public readonly Vector2i Size = size;
|
||||
public readonly StateMetadata[] States = states;
|
||||
public readonly TextureLoadParameters LoadParameters = loadParameters;
|
||||
public readonly bool MetaAtlas = metaAtlas;
|
||||
public readonly bool Rsic = rsic;
|
||||
}
|
||||
|
||||
internal sealed class StateMetadata
|
||||
@@ -145,7 +296,8 @@ internal static class RsiLoading
|
||||
Vector2i Size,
|
||||
StateJsonMetadata[] States,
|
||||
RsiJsonLoad? Load,
|
||||
bool MetaAtlas = true);
|
||||
bool MetaAtlas = true,
|
||||
bool Rsic = true);
|
||||
|
||||
[UsedImplicitly]
|
||||
private sealed record StateJsonMetadata(string Name, int? Directions, float[][]? Delays);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<PackageReference Include="Microsoft.ILVerification" PrivateAssets="compile" />
|
||||
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" />
|
||||
<PackageReference Include="Nett" PrivateAssets="compile" />
|
||||
<PackageReference Include="System.Management" />
|
||||
<PackageReference Include="VorbisPizza" PrivateAssets="compile" />
|
||||
<PackageReference Include="Pidgin" />
|
||||
<PackageReference Include="prometheus-net" />
|
||||
@@ -20,8 +21,10 @@
|
||||
<PackageReference Include="YamlDotNet" />
|
||||
<PackageReference Include="Microsoft.Win32.Registry" PrivateAssets="compile" />
|
||||
<PackageReference Include="Linguini.Bundle" />
|
||||
<PackageReference Include="SharpZstd.Interop" PrivateAssets="compile" />
|
||||
<PackageReference Include="SharpZstd.Interop" PrivateAssets="compile" ExcludeAssets="native" />
|
||||
<PackageReference Include="SpaceWizards.Sodium" PrivateAssets="compile" />
|
||||
<!-- Add libsodium to control version, SpaceWizards.Sodium's dependency is behind -->
|
||||
<PackageReference Include="libsodium" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" />
|
||||
<PackageReference Include="TerraFX.Interop.Windows" PrivateAssets="compile" />
|
||||
|
||||
|
||||
@@ -58,7 +58,8 @@ namespace Robust.Shared.Serialization.Markdown.Value
|
||||
|
||||
public override bool IsEmpty => string.IsNullOrWhiteSpace(Value);
|
||||
|
||||
public static bool IsNullLiteral(string? value) => value != null && value.Trim().ToLower() is "null" ;
|
||||
public static bool IsNullLiteral(string? value) =>
|
||||
value != null && string.Equals(value.Trim(), "null", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
public override ValueDataNode Copy()
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user