Compare commits

..

604 Commits

Author SHA1 Message Date
Myra
f4cf5565fa Add linux wayland support to claudia (#6249)
* Add linux wayland support to claudia

Could not do x11 because quote "oh my god x11 support might be a hecking nightmare" -pjb

but the skeleton is there i guess

* Review

* Ok massivly misunderstood pjb
2025-10-10 20:43:28 +02:00
PJB3005
e784ac8d86 Handle vsync and surface formats properly 2025-10-09 21:28:32 +02:00
PJB3005
be7b134e1d Make macOS work 2025-10-09 19:32:17 +02:00
PJB3005
4930df85f1 Fix path to default-sprite.swsl
These shaders aren't used anymore but there's still a bunch of surrounding infrastructure I haven't torn out yet so I can't *quite* nuke them.
2025-10-09 17:10:59 +02:00
PJB3005
9a00bd89ef Add support for passing features to WESL compilation 2025-10-09 17:10:20 +02:00
PJB3005
3d6fda1aca WESL-based shader compilation 2025-10-09 03:03:23 +02:00
PJB3005
312944eb9a Fix window open and close 2025-10-08 00:57:37 +02:00
PJB3005
88a115ddbc Add backend to RHI description 2025-10-08 00:57:25 +02:00
PJB3005
2669c4c402 Increase requested texture size so we can have a single meta-atlas again on SS14. 2025-10-08 00:04:54 +02:00
PJB3005
05c8814118 Fix more enums
godo
2025-10-08 00:04:24 +02:00
PJB3005
819ce1d8e4 Commit DotSettings file for RobustNative 2025-10-07 23:44:19 +02:00
PJB3005
91650fb4fb WebGPU renders again 2025-10-07 23:44:04 +02:00
PJB3005
b6a5300f81 Fix Robust.Analyzers.Tests.csproj 2025-10-07 18:19:27 +02:00
PJB3005
b7a3526131 Move RHI to its own project
Move some of Robust.Shared to a new project so it can be depended upon without adding longer dependency chains.
2025-10-07 18:18:48 +02:00
PJB3005
617d3e81b2 Add Robust.Client.Interop.RobustNative project 2025-10-05 16:59:12 +02:00
PJB3005
729ab4970e Remove GLFW entirely 2025-10-05 16:33:54 +02:00
PJB3005
ccbf6c0817 Merge branch '23-05-06-webgpu' into 25-10-04-claudia
Well I did my best solving conflicts but it sure as hell doesn't
compile.
2025-10-05 16:07:58 +02:00
PJB3005
c4b32ec592 Add robust-native project 2025-10-05 02:57:24 +02:00
Nikita (Nick)
a8a73e28f4 Fix casing in Sandbox.yml (2 characters changed) (#6243)
* Fix casing in DateOnly property in Sandbox.yml

* another typo
2025-10-04 17:08:59 +02:00
PJB3005
e5983a9ec1 Add DateOnly and TimeOnly to sandbox
Added in .NET 6
2025-10-02 19:02:28 +02:00
PJB3005
b7fa39d8cc Update Robust.Natives 2025-10-02 03:19:49 +02:00
Leon Friedrich
3c30ed749c Fix yaml hotreloading (#6239)
* Fix yaml hotreloading

* ToRelativeSystemPath removes the leading /
2025-09-28 19:00:56 +02:00
haiwwkes
eb1a2ae9b4 init (#6234) 2025-09-27 11:32:02 -04:00
PJB3005
ee0c31a8c3 Make SDL3 default
Fixes #5570
2025-09-27 00:31:52 +02:00
PJB3005
4ab61b840a Remove compat mode forcing
Was broken and I'm moving it to the launcher
2025-09-26 15:02:57 +02:00
PJB3005
df29fa438a Re-allow internal access to Content.Benchmarks, only on development builds 2025-09-26 14:19:58 +02:00
PJB3005
a3756c29bd Merge duplicate AssemblyInfo.cs files in Robust.Shared 2025-09-26 14:15:14 +02:00
PJB3005
4dc17f3aca Version: 267.2.1 2025-09-26 13:40:39 +02:00
PJB3005
d22280f177 Validate that content assemblies have a limited list of names.
Also, only read assemblies once from disk

(cherry picked from commit 443a8dfca65be7d60c4bd46181b4c749b4756114)
2025-09-26 13:40:38 +02:00
ElectroJr
9e8f7092ea Version: 267.2.0 2025-09-26 20:03:34 +12:00
pathetic meowmeow
de188cc773 Defer PredictedQueueDel detachment on the client (#6154)
* Defer PredictedQueueDel detachment on the client

* release notes

* fixes

* I love ambiguous implicit casts

* avoid deferral issues

---------

Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
2025-09-26 19:13:14 +12:00
DrSmugleaf
784a02c0e7 Fix rga and mapfile validators breaking because the PYYaml author published a broken version (#6230)
* Version: 162.2.1

* Fix rga and mapfile validators breaking because the PYYaml author published a broken version

* Revert "Version: 162.2.1"

This reverts commit 9b7f4d48cf.
2025-09-26 14:04:21 +12:00
PJB3005
c8db7f98db Move IResourceManager.GetContentRoots() to be internal, make it return strings instead
Previous API shouldn't have been content-accessible. It also returned OS paths over ResPath which is incorrect.
2025-09-23 15:07:58 +02:00
DrSmugleaf
318c37e686 Fix CollectionExtensions.TryGetValue erroring for indexes under 0 (#6222)
* Version: 162.2.1

* Fix CollectionExtensions.TryGetValue erroring for indexes under 0

* Revert "Version: 162.2.1"

This reverts commit 9b7f4d48cf.

* release notes

---------

Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
2025-09-23 16:04:09 +12:00
Leon Friedrich
524be86449 Add new DetachEntity overload (#6217) 2025-09-23 15:47:29 +12:00
Leon Friedrich
ddeb78accd Make toolshed's CommandImplementationAttribute optional (#6218) 2025-09-23 15:47:21 +12:00
Leon Friedrich
585e847818 Fix warnings (#6224)
* Fix warnings

* remove usings
2025-09-23 15:41:08 +12:00
OnsenCapy
ac3cb4dc2a SpriteComponent: allow animations to optionally stop instead of looping (#6210)
* Loop false

* Removed goobstation comments

* Addressed changes

* Add layer field, set auto animated

* release notes

---------

Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
2025-09-21 14:36:07 +12:00
PJB3005
c06ca39009 Version: 267.1.0 2025-09-19 01:24:02 +02:00
PJB3005
06b11a51f1 Update release notes
That's a lotta stuff.

Decided to try to categorize things this time. See how this works out going forward.
2025-09-19 01:22:36 +02:00
DrSmugleaf
4938a159d4 Change PhysicsSystem.Island.FinalisePositions to TryComp transform component (#6135)
* Change PhysicsSystem.Island.FinalisePositions to TryComp transform component

* Add comment

---------

Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-09-18 17:58:54 +02:00
Kara
27f2e270ce Fix compat mode floats in light attenuation + release notes (#6209)
* Fix compat mode float shit

* release notes
2025-09-18 17:44:02 +02:00
Kara
94e60e0b10 More accurate & controllable pointlight attenuation (#6160)
* modify light attenuation function

* support for changing attenuation curve type + lots of docs

* this is what i defaulted to typing in a prototype, so i guess it should just be this instead

* Allow a continuous range of values between inverse and inversequadratic rather than two set curves

* calc is slang for calculator

* fix

* oops committed it at 1 while testing i think, values are balanced for 0
2025-09-18 16:58:35 +02:00
slarticodefast
c6863033a5 fix PlacementManager.CurrentMousePosition during integration tests (#6208)
* fix CurrentMousePosition

* shorter

* rerun test
2025-09-18 16:38:39 +02:00
metalgearsloth
917878d05f Autocomplete more map commands (#5797)
* Autocomplete more map commands

Also added some extra helper features.

* Finish

* Fix bug, avoid IocResolves

* grid is grid

* file filename clash

* turn hint into option

* a

---------

Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
2025-09-18 12:38:17 +10:00
Leon Friedrich
10e4766809 Try fix UI state debug assert (#6191)
* Try fix UI state debug assert

* comment
2025-09-18 00:31:57 +02:00
Leon Friedrich
abd5149245 Improve map serialization error logging & exception tolerance (#6188)
* Improve map serialization error logging

* Prevent remove children of erroring entities

* better logging

* Improve error tolerance

* Even more exception tolerance

* missing !

* Improve handling of category errors

Helps prevents weird bugs that arise due to deleting un-initialized entities

* release notes

* Typo fix

---------

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2025-09-17 21:44:56 +02:00
Leon Friedrich
912b6da20a Fix serialization of data-records with get-only properties (#6204)
* Fix serialization of data-records with get-only properties

* even less nesting

* asserts
2025-09-17 19:11:12 +02:00
eoineoineoin
94fe0b7721 Fix bug wrapping wide utf16 characters; add documentation for function (#6194) 2025-09-17 13:31:07 +02:00
PJB3005
9fac1e78fb Make ACZ status host explicitly respond with UTF-8 charset
See 0b2b814e4f
2025-09-17 12:55:43 +02:00
PJB3005
6697b76683 Fix download_manifest_file.py to always decode as UTF-8
See 0b2b814e4f
2025-09-17 12:52:13 +02:00
Andi Lilaj
b2ab247b5b Created Debug Version Panel and Version Info Printer similar to DebugSystemPanel (#5624)
* Created Debug Version Panel and Version Info Printer similar to DebugSystemPanel

* dependency injection

* remove VersionInformationPrinter

* Fix sorting
2025-09-17 17:32:25 +10:00
deltanedas
7411ae8138 replace AnchorEntity debug assert with a log (#5508)
* replace AnchorEntity debug assert with a log

* unfuck cefglue

* no!

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
2025-09-17 17:13:18 +10:00
slarticodefast
d398e3a75b Improve error logging in SharedAudioSystem (#6202) 2025-09-17 16:56:21 +10:00
DrSmugleaf
a5047224bb Make net.interp and net.buffer_size CVars CLIENT, REPLICATED instead of CLIENTONLY (#6196)
Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-09-17 12:16:12 +10:00
PJB3005
058821c08b Make sending net messages while disconnected on client log an error. 2025-09-16 18:59:24 +02:00
PJB3005
0c691b061d Don't send client replicated CVars when not connected to a server 2025-09-16 18:59:23 +02:00
Skye
51bbc5dc45 Fix resource loading on non-Windows platforms (#6201) 2025-09-16 11:10:30 +02:00
gus
2d3522e752 Allow multiple clients running WebView on a singular machine. (#5947)
* Multiple CEF instances on a single machine

* remove unused

* meh implementation

* cefextension

* me when partials, race conditions and extractiion of methods exists

* Change remote debugging handling

It now defaults to 9222 again. This doesn't seem to cause any issues when launching 3 clients. The debug port can be reconfigured via CVar if desired.

Also disabled debugging by default outside dev builds.

* Lower MaxAttempts to 15

100 was way too much and gave me anxiety idk.

* Fix non-TOOLS default of remote debug port

* Rewrite locking implementation.

It is much smaller, less complicated and probably more robust too. Should be fully atomic (the previous one wasn't).

* Undo unnecessary style changes

---------

Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-09-16 02:19:59 +02:00
PJB3005
d4f265c314 Fix incorrect path combine in DirLoader and WritableDirProvider
This (and the other couple past commits) reported by Elelzedel.
2025-09-14 14:49:14 +02:00
PJB3005
7654d38612 Move CEF cache out of data directory
Don't want content messing with this...
2025-09-14 14:49:14 +02:00
PJB3005
cdcc255123 Make Robust.Client.WebView.Cef.Program internal. 2025-09-14 14:49:14 +02:00
PJB3005
2f56a6a110 Update SpaceWizards.NFluidSynth to 0.2.2 2025-09-14 14:49:13 +02:00
PJB3005
16fc48cef2 Hide IWritableDirProvider.RootDir on client
This shouldn't be exposed.
2025-09-14 14:49:13 +02:00
āda
5cecbb2cff Fix TransformBounds(Matrix3x2 , Box2Rotated) (#6171)
* jouneys-end

* test

* more tests

* test overkill

* i'm tired

* rip it out

* Keep method but mark it as obsolete

* Release notes

* grammar

---------

Co-authored-by: iaada <iaada@users.noreply.github.com>
Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
2025-09-13 15:11:59 +10:00
PJB3005
6115d6d5cc Give secondary window rendertextures names. 2025-09-13 01:21:22 +02:00
PJB3005
60d26be139 Add devwindow tab listing render targets
Copy TableContainer from content into engine. It's internal though.

Add various stuff to Clyde to allow the UI to access it. Includes a new IClydeInternal.RenderNow() which seems to not completely explode in my face.
2025-09-13 01:21:22 +02:00
ShadowCommander
186392ea80 Refactor grid or map methods (#5124)
* Rename TryGetMapOrGridCoordinates to make it clearer it gets grid first

* Add terminating or deleted checks to TryGetGridOrMapCoordinates

* Add comment to check if TerminatingOrDeleted check is necessary

* Reorganize AttachToGridOrMap to match TryGetGridOrMapCoordinates

* Move validation to method

* Replace internals with TryGetGridOrMapCoordinates

* Explicitly set coordinates type

* Format

* Change name back for now

* Don't duplicate `TerminatingOrDeleted()` check

* Don't call `GetInvWorldMatrix` for the map

* Don't check `TerminatingOrDeleted(uid)` in `TryGetMapOrGridCoordinates()`

* Fix parenting to terminating grid

* Fix matrix error

---------

Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-09-11 18:05:04 +10:00
PJB3005
ebe4538d4c Add viewport stuff for caching rendering resources properly.
Content nowadays has a bunch of Overlays that all cache IRenderTextures for various funny operations. These are all broken in the face of multiple viewports, as they need to be cached *per viewport*.

This commit adds an ID field & an event to allow content to properly handle these resources.

Also adds some debug commands
2025-09-07 00:38:55 +02:00
PJB3005
745d0e5532 Add WeakReference<T> to sandbox 2025-09-07 00:17:07 +02:00
PJB3005
d4f7e60432 dmetamem command is now behind #if TOOLS 2025-09-06 18:24:25 +02:00
IProduceWidgets
ced127c164 loadgrid no fail (#6169)
* yoink unneeded map check

* yarr

* command line feedback
2025-09-04 23:40:17 +02:00
Kara
f91bcb62b1 Add ability to specify easings for AnimationTrackProperty keyframes (#6180)
* Add ability to specify easing functions in `AnimationTrackProperty`

* should actually be per keyframe
2025-09-04 18:47:30 +02:00
Pieter-Jan Briers
5268a4a3f0 Move SDL3 binding to NuGet package (#6184)
I'm worried about the IDE performance overhead of the 20k lines of LibraryImport it generates into Robust.Client.

Also, this allows me to trim the binding, which saves a tiny amount of space from publishes. Always nice to have.
2025-09-04 18:44:49 +02:00
PJB3005
1f1e50539b Remove EngineFonts/ and Midi/ from server packaging
Unnecessary on server
2025-09-04 17:33:40 +02:00
PJB3005
ea3132bbba Add asset pass to drop all files from the Audio/ directory
Fixes #6183

This drops MidiCustom and attribution YAML files. Other audio files were already handled by the audio metadata pass.
2025-09-04 17:33:14 +02:00
Kyoth25f
67ccaec418 Add UnicodeCategory to sandbox (#6181) 2025-09-04 11:30:53 +02:00
Kara
40b70e9447 Fix predicted audio having incorrect position & occlusion until the next tick (#6178) 2025-09-03 00:20:42 +02:00
Wachtel
7d37db9ce0 CleanContainter Del to PredictedDel (#6174) 2025-09-02 23:50:21 +02:00
Kara
dd8688df3d Fix ProcessStream using the wrong entity (#6177) 2025-09-02 22:29:11 +02:00
DrSmugleaf
b02c53c6ad Fix OutputPanel.SetMessage causing the panel to bounce if setting a message other than the last one (#6163) 2025-09-02 22:10:09 +02:00
PJB3005
38d3b83818 Add display.max_fps CVar.
Applies when vsync is not enabled.

Had to shuffle stuff around to GameController since it involves the game loop.

The implementation isn't great and undershoots the target FPS value (because the OS overshoots the desired sleep value). I tried using SDL_DelayPrecise too but this causes significantly increased CPU usage probably because it spinwaits and all that nonsense, so I decided against it.

I don't know why I bothered to do this. I just got the idea in my head. Kinda feels like a waste of time, but there's no point not committing it at this point.
2025-09-02 22:05:28 +02:00
Pieter-Jan Briers
f02cd0083a Make SpriteSpecifier.Texture fail validation if it contains ".rsi" (#6155)
No pointing to PNGs inside RSIs.
2025-09-02 22:05:13 +02:00
PJB3005
c2c8af16d0 Fix framerate dependent UI animations 2025-08-30 17:37:36 +02:00
PJB3005
b61003e2a0 Fix DebugConsole completions in devwindow
PopupContainer now supports an AltOriginUpProperty so that the completion popup doesn't overlap the input bar.
2025-08-30 17:21:15 +02:00
John
fb0ec52f8c Fix TimeSpan overflow on Read (#6170)
A lot of areas use TimeSpan.MaxValue but when saved and read the current time is added which results in an overflow.
A check is now performed to prevent this.
2025-08-30 00:59:39 +02:00
PJB3005
fee79d8aa5 Make popups/modals in secondary windows work
We were relying on a global PopupRoot & ModalRoot, which only existed in the main window. This means things like OptionButton would pop out on the *main* window when put on secondary windows.

These two roots are now on the UIRoot instead. WindowRoot needs to have a function called to create these if you're using it manually, OSWindow supports it automatically.
2025-08-30 00:58:52 +02:00
PJB3005
4508105412 Make devwindow & uitest2 use OSWindow 2025-08-29 01:07:09 +02:00
PJB3005
a0ebb290e2 Add WrapContainer control
Lays items out sequentially, wrapping them onto different rows/columns if they stop fitting.

Has multiple options and should be very useful, in both content and engine.

Uses the new Axis system to implement layout on 4 axis, re-uses BoxContainer's code so BoxContainer also got a mild refactor.
2025-08-29 00:41:21 +02:00
PJB3005
d45497e53b Add Axis helper types to make UI layout code generic over multiple axis. 2025-08-29 00:16:35 +02:00
PJB3005
ff8dd021c3 Make uitest (not uitest2) also support tab parameter. 2025-08-29 00:14:35 +02:00
PJB3005
34a371ef1f Make OrderedChildCollection implement IReadOnlyList<T>
Implements indexing operation.
2025-08-27 19:39:54 +02:00
Amy
83109b08e9 Add hashing lib to sandbox (#6167)
* box  your sand

* I only need this one anyway
2025-08-25 22:12:07 +02:00
DrSmugleaf
3d7b83db05 Fix crash on startup with more than 255 CVars (#6157)
* Fix crash on startup with more than 255 CVars

* Oop
2025-08-25 00:40:52 +02:00
leonidussaks
41b2ee19a1 add check if state name is empty in rsi validator (#6145)
* add check if state name exists

* Apply suggestions from code review

---------

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2025-08-20 18:49:45 +02:00
PJB3005
856cdb8a3d Version: 267.0.0 2025-08-19 00:36:36 +02:00
PJB3005
b783cd79be Release notes for next release 2025-08-19 00:22:27 +02:00
PJB3005
b5ba964f61 Update client publish script to remove more natives
You know I can probably tell the .NET SDK to not copy these, but figuring that out would be effort.
2025-08-19 00:22:18 +02:00
PJB3005
09676a1d9f Re-enable FreeBSD builds 2025-08-19 00:21:30 +02:00
PJB3005
6959f21927 Disable apphost when publishing client builds
Not used anyways.

Fixes FreeBSD builds.
2025-08-19 00:21:01 +02:00
PJB3005
26a1fb35b5 Fix zstd library load on Linux
Probably important
2025-08-18 23:53:28 +02:00
PJB3005
7fb3ce0e70 Guess we aren't having FreeBSD 2025-08-18 23:51:22 +02:00
PJB3005
5497b52100 Re-enable macOS CI
We should have the missing natives now

Fixes #5076
2025-08-18 22:56:42 +02:00
PJB3005
18b5f33080 Enable ARM64 RIDs for publish
Fixes #5830
2025-08-18 22:55:09 +02:00
PJB3005
30d3367c50 Enable SDL3 by default on ARM64
Enough to unblock releasing ARM64 engines
2025-08-18 22:53:27 +02:00
PJB3005
f6aabd1a22 Update NFluidsynth to 0.2.1
MacOS correct library name loading. Yay
2025-08-18 22:42:21 +02:00
PJB3005
6d229a3eb2 Use OpenAL Soft on macOS
Fixes #6148
2025-08-18 22:38:02 +02:00
PJB3005
da28bdbce5 Fix loading of SDL3 on Unix platforms
Didn't pass the assembly info so it wasn't using the proper resolution system.
2025-08-18 22:30:46 +02:00
PJB3005
0181988225 Update native dependencies
Holy shit
2025-08-18 22:20:17 +02:00
Quantum-cross
fb2ba7460a allow toolshed command spawn:in to work if the prototype doesn't have a PhysicsComponent (#6151) 2025-08-18 11:33:35 +02:00
Hannah Giovanna Dawson
b70d20a217 Update OpenTK and OpenTK.Audio.OpenAL to latest (#6107) 2025-08-18 11:32:19 +02:00
DrSmugleaf
ebc33df457 Make Toolshed ProtoId autocomplete use PrototypeIdsLimited instead of caching completions (#6146)
* Make Toolshed ProtoId autoclomplete use PrototypeIdsLimited instead of caching completions

* Add check for entity prototype
2025-08-17 16:46:20 +02:00
PJB3005
697af6771c Put ClientDllMap.cs behind #if fully 2025-08-17 16:39:35 +02:00
PJB3005
20706870da Add SDL3 to DLL map 2025-08-17 16:39:34 +02:00
PJB3005
372fa39228 Merge branch 'dont-skip-leg-day' 2025-08-17 16:27:20 +02:00
PJB3005
d6bfbe4f6f Disable ARM64 targets by default for now 2025-08-17 16:27:14 +02:00
PJB3005
54645b4adf Use fancy mac symbols for key names 2025-08-17 16:24:04 +02:00
PJB3005
7c16573f3e Force enable compat mode on Qualcomm Windows devices
Broken OpenGL driver.
2025-08-17 16:12:59 +02:00
PJB3005
8935b39987 Remove some unnecessary windows natives from client package
Saves like a megabyte. Oops.
2025-08-17 15:54:14 +02:00
PJB3005
388f8369a8 Trim sharpfont on publish
Saves like 100 KB. Wow.
2025-08-17 15:54:14 +02:00
PJB3005
217d889e36 Update to new SharpFont version 2025-08-17 15:54:13 +02:00
Pieter-Jan Briers
f243baccf2 Get CPU model on Linux ARM64
Uses /proc/cpuinfo
2025-08-16 14:22:46 +02:00
PJB3005
790f42ea70 Try to load zstd as libzstd.1.dylib on macOS
This is the correct name for the dynamic library.

We can make this change without breaking old engine versions, as the launcher overrides the import resolver for zstd.
2025-08-16 14:09:53 +02:00
PJB3005
a5fcf122b8 Unhardcode XAML hot reload marker sln
Was previously hardcoded to just "Space Station14.sln"

Co-authored-by: kaylie <moony@hellomouse.net>
2025-08-16 14:09:53 +02:00
PJB3005
df2d6ab8c2 Detect CPU model name on Windows ARM
Uses WMI query
2025-08-16 14:09:53 +02:00
PGray
23c90c0c45 Serialization: Make null literal check culture-invariant (#6136)
Use StringComparison.OrdinalIgnoreCase instead of ToLower() to avoid culture-sensitive casing issues (e.g., Turkish-i) when detecting YAML null literals.
2025-08-12 13:28:30 +02:00
PJB3005
c69756e7f1 Merge remote-tracking branch 'upstream/master' into dont-skip-leg-day 2025-08-07 21:27:41 +02:00
PJB3005
07fbd5263c Run disconnect callbacks after removing channel from lists
Similar to the previous changes to player sessions, but now one layer lower.

Fixed ServerSendToAll from the relevant callbacks sending to a disconnected channel.
2025-08-07 00:44:06 +02:00
PJB3005
a1cdd60602 Version: 266.0.0 2025-08-06 16:14:11 +02:00
PJB3005
6fcaee91b6 Update release notes 2025-08-06 16:11:03 +02:00
slarticodefast
4d4f353680 Move ScaleVisuals to Content (and improve it) (#6096)
* împrove ScaleVisuals

* toolshedify

* fix

* rerun tests

* remove redundant code

* move to content
2025-08-06 14:33:35 +02:00
Hannah Giovanna Dawson
9f0dad80e4 Fix instrument pausing when outside PVS range (#6113) 2025-08-06 01:12:55 +02:00
Hannah Giovanna Dawson
c3f4b9bd67 Update MidiRenderer to use TryNoteOn and TryNoteOff (#6106)
Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-08-06 01:02:15 +02:00
PJB3005
641411288f Update NFluidsynth to 0.2.0 2025-08-06 00:48:40 +02:00
Hannah Giovanna Dawson
1fb7d3e723 Minimum MIDI note volume (#6127) 2025-08-05 23:35:48 +02:00
PJB3005
8cbc5d4cd8 Raise PlayerStatusChanged after removing disconnected players
This makes it so players aren't in the Sessions list anymore when their status is Disconnected.

Fixes SS14's lobby code sending lobby status updates to the just-disconnected player, which logs an error with the recent net message changes.
2025-08-05 17:31:29 +02:00
PJB3005
b4863dcc38 Properly stop sending messages to disconnected channels.
Log errors, and fix the ChannelClosedException it caused.
2025-08-05 17:12:43 +02:00
Tayrtahn
e771530de2 Mark AutoGenerateComponentStateAttribute fields as readonly (redo) (#6129)
* Mark AutoGenerateComponentStateAttribute fields as readonly

* Remove no-longer-valid test case
2025-08-05 00:48:36 -04:00
Tayrtahn
ce3a5f6bfa Revert "Mark AutoGenerateComponentStateAttribute fields as readonly (#6126)" (#6128)
This reverts commit 1cd802640a.
2025-08-04 18:32:54 -04:00
Tayrtahn
1cd802640a Mark AutoGenerateComponentStateAttribute fields as readonly (#6126) 2025-08-04 18:25:09 -04:00
Perry Fraser
1983734e2d feat: add analyzer for correct AfterAutoHandleStateEvent usage (#6117)
* feat: add analyzer for AfterAutoHandleStateEvent

* fix: correct TestOf attribute

Oopsieeeee.

Also weird newline plus unused import.

* Rerun content tests

* refactor: use ==, not .Contains

* feat: make AttributeHelper.HasAttribute looser

* refactor: use AttributeHelper.HasAttribute

* perf: cache AutoGenStateAttribute's type

* refactor: more pattern matching

ElementAtOrDefault with constant arg is bad; just use positional
matching.
2025-08-04 18:22:06 -04:00
PJB3005
ea380056b4 Make BaseWindow dragging use new cursor shapes
Technology.
2025-08-04 16:34:38 +02:00
PJB3005
9c26fba308 Add uitest tab for mouse cursor shapes 2025-08-04 16:31:51 +02:00
PJB3005
3de48d7595 Add more SDL3-exclusive mouse cursor shapes
They just fall back on GLFW.
2025-08-04 16:31:43 +02:00
pathetic meowmeow
7a510298e1 Add the ability to scale ItemList icons (#6125) 2025-08-04 10:34:46 +02:00
PJB3005
046db645e9 Update ImageSharp to shut up vulnerability warnings
It's just a DoS attack so nothing too major (for us) but still annoying.
2025-08-02 21:52:01 +02:00
Tayrtahn
63e383bb17 Fix NotYamlSerializable analyzer ignoring nullable structs (#5934)
Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-08-02 19:25:48 +02:00
Tayrtahn
e316649fd1 Add a Select button to ProtoId VV editor (#6097)
* Add a Select button to ProtoId VV editor

* Changelog

* Fix ftl string name

---------

Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-08-02 19:08:24 +02:00
Fildrance
121b58ee9a feat: added generic method for getting component from ComponentRegistry (#6082)
* feat: added generic method for getting component from ComponentRegistry

* refactor: corrected xml-doc

* refactor: moved emthod to ComponentRegistry

* Fix release notes entry.

Wording + it was in the template.

* Fix doc comments

* Do not use inappropriate fallible cast.

---------

Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-08-02 18:55:49 +02:00
PJB3005
d11f4bcc14 Fix release notes AGAIN 2025-08-02 18:53:29 +02:00
Fildrance
735ef09d42 Better unsubscription for multiple ConfigurationManager subscriptions (#6115)
* feat: new method or aggregating multiple config changed subscriptions into one disposable object or more slim unsubscribing code

* refactor: moved nested private class declaration to bottom of class

* refactor: reusing stateful object in tests is not smart

* fix: invalid code for forming new array during InvokeList.Remove call

* refactor: extracted new sub-multiple builder into configuration manager extensions

* refactor: remove unused code

* refactor: removed UnSubscribeActionsDelegates

* refactor: whitespaces and renaming

---------

Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2025-08-02 18:35:38 +02:00
Connor Huffine
772173cbaf Fix Non-solution Build: second attempt (#6098)
Downselect Robust.Client.Injectors to 'Debug' or 'Release' when built outside of solution context
2025-08-02 18:23:13 +02:00
PJB3005
4bd7aa16c1 Config no longer logs a warning when saved in integration test
Supersedes #6108

See https://github.com/space-wizards/space-station-14/issues/39196
2025-08-02 17:54:09 +02:00
pathetic meowmeow
bc4b4d3e6f Fix color naming crash (#6102) 2025-08-02 17:15:49 +02:00
Łukasz Mędrek
7d9a039252 add: Dictionary<T, TimeSpan> OnUnpaused generator (#6119)
* add: Dictionary<T, TimeSpan> OnUnpaused generator

* fix

* add: test

* Fix compiler warning from duplicate using

---------

Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-08-02 16:57:43 +02:00
Zeneganto
857f9a540b Add localization support for TileSpawnWindow (#6121) 2025-08-02 16:53:14 +02:00
Perry Fraser
6ae332d543 fix: use the actual top anchor in SetMarginsPreset (#6118) 2025-08-01 13:10:26 +02:00
slarticodefast
f4786f2d90 add QueueDeleteMap to SharedMapSystem (#6116) 2025-07-31 11:13:28 -04:00
Pieter-Jan Briers
dcbe0505dc Revert "Add WeakEntityReference (#5577)" (#6112)
This reverts commit c3489d4ded.
2025-07-29 18:22:17 +02:00
Leon Friedrich
c3489d4ded Add WeakEntityReference (#5577)
* Add WeakEntityReference

* Use NetEntity

* release notes

* A

* Fix merge conflicts

* comments

* A

* Add network serialization test

* Add ToPrettyString support for WeakEntityReference?

* inheritdoc

* Add GetWeakReference methods

* Not-nullable too

* Make EntitySystem proxy method signatures match EntityManager

* Add TryGetEntity

* interface

* fix test

* De-ref GetWeakReference methods

---------

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
2025-07-29 11:12:49 -04:00
DrSmugleaf
8498634993 Add tests for immutable dicts and sets (#6109) 2025-07-29 01:17:29 +02:00
PJB3005
3d289fbd83 Update NetSerializer
Adds ImmutableDictionary and ImmutableHashSet serializers.
2025-07-29 01:17:19 +02:00
PJB3005
ebce0daa1b Merge remote-tracking branch 'upstream/master' into dont-skip-leg-day 2025-07-28 20:54:36 +02:00
PJB3005
bbbfcca303 Fix RSI preloading with .rsic files 2025-07-28 18:50:20 +02:00
DrSmugleaf
e195ac4ce6 Add ImmutableArrayExtensions All to sandbox.yml (#6110) 2025-07-28 16:05:05 +02:00
PJB3005
dc5cbd085b Enable RSI packing pass in RobustClientAssetGraph 2025-07-26 02:08:34 +02:00
PJB3005
c4dff678a9 Make .rsic packing in asset packaging work
Finishing what I started a couple years ago, the packaging system now packages .rsi files into single .rsic files. This means a single .rsi "file" (1 + N files) becomes a single file when packaged.

This should improve performance on game startup, downloading, etc etc. The total file count for SS14 goes down from 30,000 to 6,000 (with the previous change for merging text files too).

Mostly just involved shuffling a bunch of the RSI loading code around so that it can be re-used for this purpose nicely. The original prototype in the code was copy-pasted, which obviously couldn't be relied upon.

This does mean that if you're loading an RSI's interior PNG directly via a texture path, that PNG will now be unavailable on packaged builds. To avoid this, you can set "rsic": false in the meta.json, so that it gets left alone by the pass.
2025-07-26 01:51:17 +02:00
PJB3005
cd9616c87c Add new text file merge asset pass to RobustClientAssetGraph 2025-07-25 15:57:47 +02:00
PJB3005
d1c6c11755 Add asset pass to merge text files in directories.
This massively reduces the file count of published SS14 builds by a few thousand, by combining YAML prototypes and Fluent files in the same folder into one file.
2025-07-25 15:57:18 +02:00
PJB3005
1ebac7c894 Make prototype load ignore documents with empty values
This happens if you have a YAML file like this:

---
# commented prototype
---
# Real prototype
- type: bla

This case is generated by my (next commit) prototype file merger asset pass, and I don't see any harm in just skipping in this case.

Also improve the logging in general.
2025-07-25 15:54:58 +02:00
PJB3005
6b41be8901 Make AssetPassPackRsis not crap out due to ImageSharp errors.
Still just for testing.
2025-07-25 15:50:21 +02:00
PJB3005
51c929c8ec Version: 265.0.0 2025-07-23 01:47:41 +02:00
PJB3005
4863b09f0a Update release notes 2025-07-23 01:47:16 +02:00
Pieter-Jan Briers
cdd3afaa4c Remove redundant custom math types (#6078)
Vector3, Vector4, Matrix4, and Quaternion are now gone. Use System.Numerics instead.

This commit is just replacing usages, cleaning up using declarations, and moving over the (couple) helpers that are actually important.
2025-07-23 01:15:27 +02:00
slarticodefast
fee67b648c Allow AutoNetworkedField to work with inherited datafields (#6090)
* allow AutoNetworkedField to work for inherited datafields

* fix

* test fix

* typo

* Update Robust.UnitTesting/Shared/GameState/AutoNetworkingTest.cs

---------

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2025-07-23 01:15:12 +02:00
Perry Fraser
0bf4123b8d feat: Add VV editor for tuples (#6065)
* feat: Add VV editor for tuples

* refactor: make tuple editor work in more cases

* feat: support other arity tuples

* fix: correct release notes entry

* refactor: use a new index selector for tuples

Also yank out silly unused code.

* fix: make all non-ValueTuples readonly

* refactor: spell out ValueTuple arities

,,,,,,,,,,,,,,,,,,,,,
2025-07-22 22:31:19 +02:00
Tayrtahn
9ea51432d1 Un-hardcode EntitySpawnWindow's placement mode dropdown (#5994)
* Find PlacementModes by attribute

* Let modes specify priority

* Make some PlacementManager dependencies public so Content can use them

* Space out the priorities a bit more

* xmldoc for attribute

* Revert "xmldoc for attribute"

This reverts commit f1f0299c55.

* Revert "Space out the priorities a bit more"

This reverts commit 549eac1eb2.

* Revert "Make some PlacementManager dependencies public so Content can use them"

This reverts commit c060f6cb2d.

* Revert "Let modes specify priority"

This reverts commit f113b40c7f.

* Revert "Find PlacementModes by attribute"

This reverts commit 27efb6c5cf.

* Completely redo to use PlacementManager's mode dictionary

* Backwards compat

* Cache the value of AllModeNames
2025-07-22 22:14:53 +02:00
Perry Fraser
c8da6f30a3 fix: resolve remaining ResolvedSoundSpecifier warnings (#6057)
Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-07-22 22:08:31 +02:00
Tayrtahn
974c1e827d Change a bunch of static Loc.GetString calls to be properly resolved (#6010)
* Add Loc shortcut to LocalizedCommands

* Fix static methods in commands

---------

Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-07-22 20:33:43 +02:00
Tayrtahn
3c48b24539 Cleanup prototype instantiation warnings in unit tests (#6058) 2025-07-22 20:32:49 +02:00
Fildrance
d8aefe5118 feat: now view-variable controls can be registered from content, or even dynamically added (#6077)
* feat: now view-variable controls can be registered from content, or even dynamically added

* refactor: whitespaces and xml-doc

* refactor: added changelog entry

* refactor: added methods for adding condition at start and at the end

* refactor: merged start/end methods, for IViewVariableControlFactory, improved changelog message

* refactor: replaced bool insertLast with InsertPosition enum

* refactor: reverse order of checks registration in ViewVariableControlFactory c-tor

---------

Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2025-07-22 19:48:12 +02:00
Tayrtahn
6d9a4719a9 Validate VV EntProtoId values (#6095) 2025-07-22 19:30:01 +02:00
Pieter-Jan Briers
893173ab17 Add workflow to build all configurations. (#6094)
* Add workflow to build all configurations.

Builds Debug, Tools, Release against Linux, Windows and MacOS TargetOS.

See https://github.com/space-wizards/RobustToolbox/pull/6069#issuecomment-3050607114

* Very epic, GitHub

* Whoops

* Actually add Tools configuration to sln
2025-07-22 19:21:21 +02:00
PJB3005
7c0f1b8031 Fix unused dependency warning outside DEBUG
Supersedes #6069
2025-07-22 18:10:49 +02:00
Tayrtahn
bb57f82811 More informative logging for PVS deleted/uninitialized entity errors (#6084) 2025-07-22 12:33:18 +02:00
Perry Fraser
0fc9b0acd0 Lint for prototype IDs with spaces (#6087)
* feat: lint for prototype IDs with spaces

* feat: also disallow periods

* Update RELEASE-NOTES.md

---------

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
2025-07-22 12:16:57 +02:00
Hannah Giovanna Dawson
f2b7f0d8d2 NoteOn actually being a NoteOff fix (#6092) 2025-07-22 12:10:58 +02:00
PJB3005
0ec189dece IPrototypeManager TryIndex changes
This effectively gracefully reverts 94f98073b0.

IPrototypeManager.TryIndex now no longer logs an error. This is done by adding a new overload without the logError parameter, so most existing code switches to it. The overload with the logError parameter is now obsolete.

As a replacement for defensive programming situations, the new Resolve() should be used instead.

IPrototypeManager.TryIndex() should not be used for handling IDs that should always be valid, only for handling user input and similar.

I also added a lot of docs.
2025-07-22 00:11:59 +02:00
PJB3005
c876eb1f4c Fix TextInputSetRect not accounting for pixel ratio properly.
Fixes it being positioned wrong on macOS.
2025-07-20 19:51:09 +02:00
PJB3005
1037fc735e Make SDL3 file dialogs have parent window.
Somehow needed to avoid causing it to block on macOS.
2025-07-19 18:45:14 +02:00
PJB3005
d5df765467 Package FreeBSD by default.
We won't officially support FreeBSD launcher builds, but this at least allows third-party launcher builds to have an engine to load properly.
2025-07-19 18:21:51 +02:00
PJB3005
93cf9f4227 Disable threaded window blit on macOS
Can probably do this on Linux too, but I didn't test that.

This feature is, fundamentally, a workaround to avoid WGL MakeCurrent() constantly breaking. The extra threading complexity is not a good thing on other platforms, so get rid of it.
2025-07-19 13:22:27 +02:00
PJB3005
d2977e2a63 Fix secondary window closing breaking rendering on macOS 2025-07-19 02:04:46 +02:00
PJB3005
a3f0ea19c4 Avoid WinBlit threads getting stuck forever when their window closes. 2025-07-19 00:42:31 +02:00
PJB3005
d9032b8757 Move some swapping code behind #ifdef
idk I just did this while debugging something and there's no harm committing it.
2025-07-19 00:42:00 +02:00
PJB3005
cba6e37f9f Fix SDL multiwindow freezing in some cases on macOS
Need SDL_HINT_MAC_OPENGL_ASYNC_DISPATCH set, apparently.
2025-07-19 00:41:27 +02:00
PJB3005
90ec9a80c9 Fix publishing script not passing TargetOS properly 2025-07-16 22:04:15 +02:00
PJB3005
7eaf2f590b Merge remote-tracking branch 'upstream/master' into dont-skip-leg-day 2025-07-15 15:23:23 +02:00
PJB3005
0439ea9893 Update packaging script to support ARM64 properly. 2025-07-15 15:14:40 +02:00
PJB3005
74aa8fa9ed Fix ParallelManager cutting off exception info
0% tested
2025-07-12 23:06:35 +02:00
Nemanja
ceeb002692 Mark ValidatePrototypeIdAttribute as obsolete (#6062) 2025-07-12 15:20:08 +02:00
portfiend
78d807b13c Refactor ColorSelectorSliders.cs, fix color slider event stack overflow (#6072)
* add: IColorSelectorStrategy class

defines some common variables and functions that depend on the slider type
my hope is to kill all the switch statements in here

* add: IColorSelectorStrategy FromColorData method

* add: RGB and HSV color slider strategies

* add: initialize ColorSelectorStrategy

* refactor: rename IColorSelectorStrategy to IColorSliderStrategy

this makes more sense i think

* refactor: nuke switch statements, use strategy in colorselectorsliders

* remove: remove GetSliderLabels in favor of strategy

* refactor: better abstraction for slider InputBox.ValueChanged

* refactor: rename OnColorSet to OnSliderValueChanged
more intuitive

* refactor: turn alpha slider max value into a const
no magic numbers

* tweak: make color sliders update channels individually

* fix: add braces around this callback

* tweak: move some variables around
i realize there's an Order to this so

* add: throw error if UpdateSlider is called with invalid value

* add: documentation comments to ColorSelectorSliders

* refactor: simplify UpdateSlider

* refactor: simplify GetColorValueDivisor

* fix: solved the color slider stack overflow

* fix: ensure _strategy is set before other functions use it

* tweak: rename Update to UpdateAllSliders
clearer

* fix: update slider colors on update
accidentally removed it and forgot to put it back

* remove: redundant comment
false alarm

* fix: prevent inputbox infinite event loop
this was also erroneously changing the color whenever the slider type changed

* fix: reviews part 1
- changed ColorSliderStrategy into abstract class
- fixed "strategy" typo
- changed NotImplementedException into ArgumentOutOfRangeException

* fix: make selector strategy static instances
2025-07-12 14:51:02 +02:00
PJB3005
5cd4c187bf Fix VV member group headers 2025-07-12 02:22:04 +02:00
Perry Fraser
fec477bf41 fix: remove unneeded delta in SharedAudioSystem (#6055) 2025-07-12 01:56:22 +02:00
PJB3005
9d00b1f093 Make VV KeyValuePair prop editor have a minimum width
Avoid buttons for references being squashed to zero width.
2025-07-12 01:47:49 +02:00
PJB3005
de0871d17b Fix VV handling of remote KVPair types
There was a bunch of complex code to analyze the full type string the server sent, except I have no idea what use this was. It's both incorrect (the type string isn't guaranteed to work if the remote .NET version is different) and unnecessary as PropertyFor already handles all the cases.
2025-07-12 01:47:49 +02:00
Perry Fraser
053c469cac fix: loosen random timespan debug assert (#6064)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
2025-07-11 21:36:13 +02:00
Leon Friedrich
efa8975bc6 Fix pool manager conflicts (#6075) 2025-07-11 20:55:49 +02:00
Errant
4851e913b0 More TimespanSerializer improvements (#5910)
* improved public TryTimeSpan

* don't want any locale shenanigans or misconceptions with the input

* missed a test line

* also support capitalized time unit indicators

* Doesn't need to be nullable.

---------

Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-07-11 20:37:39 +02:00
PJB3005
74a318c521 Allow content to skip certain paths in client/server resource copying
Intended so content can ignore the MapImages folder
2025-07-11 18:15:10 +02:00
pathetic meowmeow
e52a6bbbf2 Add OKLCH-based colour descriptions for colorblindness accessibility (#6067)
* Add OKLCH-based colour descriptions for colorblindness accessibility

* my docs so comment

* my feed so back
2025-07-11 15:40:41 +02:00
PJB3005
e169d6a5a2 Enforce integration instance idleness for more helper members
Also allow them to be accessed regardless if from the integration instance thread.
2025-07-10 16:29:16 +02:00
PJB3005
3634ee636b Pooled integration instances now get marked non-idle
Otherwise, pooled integration instances could behave differently from freshly-spawned ones, creating heisentests.
2025-07-10 16:26:56 +02:00
āda
2349728eab out of my element (#6074)
Co-authored-by: iaada <iaada@users.noreply.github.com>
2025-07-10 12:43:51 +02:00
PJB3005
777f02cadd Fix physics closure allocs and some avoidable struct copies 2025-07-10 12:33:17 +02:00
Myra
0fc6f2bce6 Config load fail is now an error instead of a warning (#6070)
* Config load fail is now an error instead of a warning

* Update RELEASE-NOTES.md

---------

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2025-07-06 20:28:49 +02:00
Tayrtahn
dc3705e520 Add ForbidLiteral to IPrototypeManager methods (#6066)
* Add ForbidLiteral to IPrototypeManager methods

* Cleanup violations
2025-07-06 20:27:32 +02:00
Tayrtahn
01f71ca55a Remove prototype instantiation from AssetPassAudioMetadata (#6059) 2025-06-28 22:18:46 +02:00
PJB3005
c5e812836b Fix loading textures in root folder
Fixes #6052

Also clean up a warning while I'm at it.
2025-06-28 01:37:14 +02:00
PJB3005
56eda3ea92 Version: 264.0.0 2025-06-27 22:03:33 +02:00
Tayrtahn
9dffd36319 Use non-generic TryComp to get MetaDataComponent in DebugAnchoringSystem (#6051) 2025-06-27 20:38:10 +02:00
Tayrtahn
a45b72a1c5 IRobustCloneable and generator support (#5692)
* Add IRobustCloneable and check for it in compnet generator.

* Redo compnetgenerator support; add test

* Disconnect client at end of test

* Actually test for client entities

* Cleanup

* Cleanup 2
2025-06-27 20:37:43 +02:00
Perry Fraser
bd0579ed6d fix: apply scale when calculating sprite bounding box (#6046)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
2025-06-26 23:23:57 +02:00
Pieter-Jan Briers
c73b54862e Add analyzers to detect some prototype misuse (#6048)
* Add analyzers to detect some prototype misuse

Detects people marking prototype as NetSerializable.

Detects people creating new prototype instances themselves.

* Update Robust.Analyzers/PrototypeNetSerializableAnalyzer.cs

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>

---------

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
2025-06-26 22:24:23 +02:00
PJB3005
6436ff8040 Fix prototype manager Index exceptions
Index<T> was documented to throw KeyNotFoundException, but actually threw UnknownPrototypeException. Index(Type type, string id) threw KeyNotFoundException.

This has now been made consistent to be UnknownPrototypeException everywhere.
2025-06-26 16:58:35 +02:00
PJB3005
98313ae369 Update NetSerializer submodule
Makes it report where broken serialization types come from.
2025-06-26 16:58:21 +02:00
PJB3005
0e63391203 Add PrototypeManagerExt.Index that takes nullable ProtoId<T> 2025-06-26 16:52:18 +02:00
wixoa
261bfaeeb8 Add AlwaysActive to WebViewControl (#6047) 2025-06-25 21:50:07 +02:00
Tayrtahn
4017e1f57e Make some PlacementManager dependency fields public (#6044)
* Make some PlacementManager dependency fields public

* Revert "Make some PlacementManager dependency fields public"

This reverts commit 99fe37b502.

* Now part of IPlacementManager
2025-06-23 22:48:25 +02:00
lzk
e170bf1ad2 genetive case (#6045)
* dative

* slipped it

* slipped it twice

* 1

* Update _engine_lib.ftl
2025-06-23 22:47:50 +02:00
PJB3005
da0abd2535 Make functions static to avoid delegate allocations in DataDefinitionAnalyzer. 2025-06-22 13:48:50 +02:00
PJB3005
f9d0dd551a Version: 263.0.0 2025-06-22 13:36:07 +02:00
Aiden
b2540a6e08 Static Field Assert (#5926)
* Static Field Assert

* Update Robust.Shared/Prototypes/PrototypeManager.ValidateFields.cs

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>

---------

Co-authored-by: GoobBot <uristmchands@proton.me>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2025-06-21 23:51:28 +02:00
DrSmugleaf
66d898ee91 Add GetMessage and SetMessage methods to OutputPanel (#5956)
* Add GetMessage and SetMessage methods to OutputPanel

* Copy paste bad

---------

Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-06-21 23:33:03 +02:00
ThereDrD
310dc676ea fix: use maxSizeX instead of Width in rich text entry measure (#5989)
Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-06-21 15:16:38 +02:00
Perry Fraser
41844d2d30 Adjust how OpenAL extensions are requested (#6000)
* fix: use correct device in OAL extension lookup

* fix: don't try to set non-existent window icons

* Revert "fix: don't try to set non-existent window icons"

This reverts commit 793958fb8c.

Moving to other PR.
2025-06-21 15:16:02 +02:00
slarticodefast
c6f3af20d6 fully obsolete container methods (#6007) 2025-06-21 14:42:57 +02:00
Pieter-Jan Briers
5501209b35 Add API to load maps from byte stream (#6029)
In case you don't want to load from a ResPath.
2025-06-21 14:41:32 +02:00
Tayrtahn
9b2ef75762 Optimize DataDefinitionAnalyzer a bit (#6035)
* Skip fields/properties not in DataDefs

* Only check IsDataField once per field/property

* Remove pointless foreach loop

* Remove an extra IsDataDefinition check

* Revert unneeded changes from testing

* Revert "Remove pointless foreach loop"

This reverts commit f05d566904.

* Restore analysis of multiple declarations
2025-06-21 01:15:59 +02:00
Tayrtahn
196e59b7e4 Clean up all missing EntitySystem proxy method uses (#6027)
* Clean up all missing EntitySystem proxy method uses

* Restore comment

* Fix bad change that caused closure allocation

* tuple

* Revert "tuple"

This reverts commit 14581a40aa.

* Revert "Fix bad change that caused closure allocation"

This reverts commit 215b2559ed.

* Revert "Restore comment"

This reverts commit 4a47a36557.

* Revert "Clean up all missing EntitySystem proxy method uses"

This reverts commit 3b1fe4ce7f.

* Redo with improved code fixer.
Let's see how it fares this time
2025-06-21 00:05:09 +02:00
Perry Fraser
2c936b5973 fix: don't delete people who are teleported to themselves (#6040) 2025-06-20 14:00:27 +02:00
Tayrtahn
7765e71dca Add tests for remaining DataDefinitionAnalyzer diagnostics (#6034)
* Add tests for partial datadefs and partial nested datadefs

* Add test for redundant datafield tag

* Blank lines upset me
2025-06-20 02:26:08 +02:00
TrixxedHeart
d8ae71d8cd adds typeselector (thanks pbj) (#6038) 2025-06-20 02:24:03 +02:00
Tayrtahn
a74812ce5b Make AddComp where clause consistent with AddComponent (#6028) 2025-06-19 10:21:13 +10:00
PJB3005
a7f9b0a6db Fix debug assert when loading MIDI on Windows.
Fixes #6020

The assert was caused by the native OS path (C:\Windows\...) being passed through a ResPath. Bad. While looking at this I realized the sound font loader callback system was a mess and I should probably clean it up, so I did.

The file name is now properly namespaced in the loader callback, which should avoid spaghetti like this in the future. The details of how this works are a pain in the ass because Fluidsynth isn't well-designed.

I split LoadSoundfont() into two functions: one for resource, one for user paths. The other is kept there but compatible.

I can't believe I spent 3 hours on dealing with this nonsense and most of it is just due to Fluidsynth being poorly designed...
2025-06-18 03:25:58 +02:00
Amy
3aac92e4b2 soft only plz (#6030) 2025-06-17 18:56:44 +02:00
PJB3005
c152fb8953 Fix culture-based parsing in TimespanSerializer 2025-06-17 16:03:20 +02:00
DrSmugleaf
10ea5498cf Fix error in some localization functions when an argument is not an EntityUid (#6022) 2025-06-15 14:07:13 +02:00
Walker Fowlkes
324606e5a3 Add a new toolshed command spawn:in (#6021)
* added spawn:in command.

* better annotations

* use EntityManager.System

* ftl

* make it lazy cached.

* Fix typo (it's -> its)

---------

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2025-06-15 14:05:27 +02:00
Tayrtahn
a8227f7faa Replace static logger call in FileDialogManager (#6018) 2025-06-13 23:20:23 +02:00
PJB3005
9f55400c58 Avoid closure allocation in physics SolveIsland()
There's a parallel call in there that's only used when the island should be processed parallel internally. This isn't done for all islands, so allocating the closure in every case is a massive waste.
2025-06-13 15:00:47 +02:00
PJB3005
8b971f7ae7 Add CompletionHelper.PrototypeIdsLimited API
Somebody ignored the doc comment saying "don't use this with EntityPrototype" so now just *typing* a Tippy command causes the server to lag. Great.

This still isn't too great for performance but at least it's better, and I don't want to commit to making PrototypeManager semi-thread-safe.
2025-06-13 00:15:17 +02:00
PJB3005
e3c7e361ae Avoid server stutters from scsi init
Task.Run go brr
2025-06-12 23:33:48 +02:00
Tayrtahn
5c48dcb211 Fix TabContainer.CurrentTab setter (#6017) 2025-06-12 00:31:03 +02:00
B_Kirill
694de028c2 AudioSystem logging extension (#5959)
* AudioSystem logging extension

* Redo

* Fix

* review
2025-06-11 02:17:49 +02:00
PJB3005
d41c9e7662 Properly catch errors when executing client commands.
Previously these errors propagated all the way into Clyde. Guh.

Probably still need more error handling around the input system, but this is important regardless.
2025-06-11 02:11:32 +02:00
B3CKDOOR
76134e0f8d Adding "Attribution-NonCommercial-NoDerivatives 4.0 International" (#6008)
* Adding "Attribution-NonCommercial-NoDerivatives 4.0 International"

Adding the "Attribution-NonCommercial-NoDerivatives 4.0 International" License type, this is getting marked as an "invalid" license when its actually a valid license.

[License link](https://creativecommons.org/licenses/by-nc-nd/4.0/)

* Darn, forgot a comma
2025-06-09 20:57:54 +02:00
Perry Fraser
2983517e43 fix: don't try to set non-existent window icons (#6016) 2025-06-09 20:56:01 +02:00
metalgearsloth
18849be0b4 Version: 262.0.0 2025-06-09 23:56:58 +10:00
Leon Friedrich
c6a1d82bb1 Validate that Toolshed command arguments have parsers (#6014)
* Add Nullable<T> support to ToolshedManager.TryParse

* Check that command arguments are parseable

* release notes

* a

* A is for Array

* Fix test

* Fix indentation
2025-06-09 23:47:29 +10:00
Leon Friedrich
d89e1a43c6 Add PvsResetTest (#6015) 2025-06-09 23:39:06 +10:00
Leon Friedrich
d894ef70ef Misc SpriteSystem fixes (#6001)
* Move GetPrototypeTextures to SpriteSystem

* Fix tests

* Fix #6002

* release notes

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2025-06-09 18:59:37 +10:00
DrSmugleaf
c7ea2793ca Fix TransformComponent state handling changing the coordinates of detached entities (#6006)
* Fix TransformComponent state handling changing the coordinates of detached entities

* Make ResetPredictedEntities not handle state for detached entities
2025-06-09 17:44:36 +10:00
Perry Fraser
0c61ff2bee fix: default audio params for PlayStatic (#6011) 2025-06-09 00:28:12 +02:00
Tayrtahn
343a34eac7 Fix warning CS0168 in EntityDeserializer (#6013)
* Fix warning CS0168 in EntityDeserializer

* Actually, why use try-catch just to rethrow anyway?
2025-06-09 00:04:03 +02:00
metalgearsloth
7be41f4890 Add ignoredcomps to IsDefault (#5998) 2025-06-05 23:54:47 +10:00
metalgearsloth
293470a5fe Fix incorrect saved window positions (#5927)
* Fix incorrect saved window positions

As of however many UI PRs ago windows store their last position on the client and it re-opens windows at that position.

The issue is that the code to avoid windows being able to go off-screen was immediately bulldozing this value, at least if the x <= 0. Now we just don't run it until we have a valid measure (probably the frame after) and avoid unnecessarily having an incorrect position applied.

* Explainer
2025-06-05 23:35:28 +10:00
metalgearsloth
2b8057acf0 Version: 261.2.0 2025-06-05 22:55:09 +10:00
Tayrtahn
bec3caa5da Fix error when using tpto on a grid (#5991)
* Fix error when using tpto on a grid

* Calculate map coords outside of loop
2025-06-05 22:45:30 +10:00
metalgearsloth
ea6126563b Add NearestChunkEnumerator (#5972)
Not super fast but want it for biome loading to prio chunks nearby first.
2025-06-05 22:36:22 +10:00
slarticodefast
00494ad9eb fix TryQueueDelete (#5996) 2025-06-05 22:34:50 +10:00
Tayrtahn
6672b7b1bd Correct misleading error message in ShareMapSystem.OnParentChange (#5992) 2025-06-05 22:29:47 +10:00
ruddygreat
8dc55e8748 fix the lifestage checks on predicted entity deletion (#5993)
Co-authored-by: Ruddygreat <ruddygreat1@gmail.com>
2025-06-05 22:29:22 +10:00
Tayrtahn
44ea2cd396 Implement IEquatable for ResolvedPathSpecifier and ResolvedCollectionSpecifier (#5980) 2025-06-01 18:10:55 +10:00
metalgearsloth
2c5604432b Update some GetComponentName usages (#5942)
Rider tells me to use generic and generic one seems better.
2025-06-01 17:54:43 +10:00
Tayrtahn
c696466522 Remove ITileDefinition.ID (#5982) 2025-06-01 17:51:59 +10:00
slarticodefast
01bb98e400 fix static grid center of mass (#5985) 2025-05-29 23:05:54 +10:00
metalgearsloth
af08e747de Defer grid state handling TileChangedEvent (#5981)
Rather than doing the old raise-event-per-tile we just raise it at the end.
2025-05-29 09:21:45 +10:00
metalgearsloth
8c35c2c380 Version: 261.1.0 2025-05-29 00:15:26 +10:00
Tayrtahn
6d46d3f4a5 Cleanup most warnings in unit tests (#5946)
* 2 warnings in JointDeletion_Test

* 1 warning in Collision_Test

* 2 warnings in Color_Test (deleted test of deprecated HCY color space)

* 1 warning in MapVelocity_Test

* 2 warnings in MapManager_Tests

* 2 warnings in MapPauseTests

* 1 warning in NetDisconnectMessageTest

* 1 warning in ContainerTests

* Suppress 1 warning in EntityEventBusTests.ComponentEvent

* 4 warnings in MapGridMap_Tests

* 1 warning in GridDeletion_Test

* Remove TryGetContainingContainer foolishness

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2025-05-29 00:12:58 +10:00
Tayrtahn
50e06e43fa Automatic Sawmill generation for UIControllers (#5967) 2025-05-29 00:06:55 +10:00
metalgearsloth
986b0f979d Fix physics forces not autoclearing (#5978)
* Fix physics forces not autoclearing

* Changes
2025-05-29 00:04:55 +10:00
metalgearsloth
a51d786dee Version: 261.0.0 2025-05-28 19:34:47 +10:00
metalgearsloth
5f5fed5d6c Update contact xform usage (#5977)
Forgot this one as well.
2025-05-28 19:30:50 +10:00
Tayrtahn
e475cc7898 Cleanup warning in SpriteBoundsOverlay (#5944)
* Cleanup warning in SpriteBoundsOverlay

* Make better use of the primary constructor
2025-05-28 19:28:53 +10:00
metalgearsloth
ee8ea4ec3b Purge PhysicsMapComponent (#5766)
* Replace PhysicsMapComponent

- Dumb idea
- Lots of book-keeping and perf overhead.
- Much saner this way.

* stuff

* More work

* Purge

* Fixes

* Eh?

* Fixes

* Also this

* weh

* Fixes

* ice-cream

* Fix

* Fix stacking / gravity

* Gravity query

* MoveBuffer optimisations

* Fixes for test

* World gravity

* Fix build

* Avoid some transform resolves for contactless ents

* Less getcomps

* Fix contact caching

* Possibly less copies

* reh

* bulldoze

* Test "fix"

* seikrets

* a

* I saw this but now I decideded against it

* true
2025-05-28 19:18:36 +10:00
slarticodefast
7482451ec4 optimize ToMapCoordinates (#5953) 2025-05-28 12:07:23 +10:00
metalgearsloth
dddf5cd2fb Add entities to SpawnEntitiesAttachedTo (#5971)
* Add entities to SpawnEntitiesAttachedTo

Need it for biome stuff.

* factorio
2025-05-27 19:45:48 +10:00
metalgearsloth
01979c451d Make RaiseMoveEvent internal (#5918)
I don't think content should really be calling this tbh.
2025-05-27 19:45:04 +10:00
slarticodefast
181a5ef0b4 fix GetMapLinearVelocity (#5950)
* fix GetMapLinearVelocity

* resolve and adjust other methods
2025-05-27 19:41:43 +10:00
Princess Cheeseballs
e7c7011cc0 Init Commit (#5909) 2025-05-27 19:34:32 +10:00
metalgearsloth
dc97615fd4 Add some Box2i methods (#5969)
Equivalent to Box2.
2025-05-27 19:26:50 +10:00
metalgearsloth
3b4944376b Fix FastNoiseLite fractal bounding (#5970)
This shouldn't be datafielded because it gets set by other datafields.
2025-05-27 19:14:49 +10:00
Tayrtahn
fa6bd8f7ba Cleanup TypeSerializer Logger warnings (#5966) 2025-05-24 20:23:28 +02:00
Whatstone
2398cbcf26 GameController: init LocMgr before init broadcast (#5965) 2025-05-24 19:02:26 +02:00
Tayrtahn
38ce48a83f Cleanup 3 warnings in SharedContainerSystem (#5949)
* Cleanup 3 warnings in SharedContainerSystem

* Don't call Transform twice
2025-05-24 19:00:57 +02:00
PJB3005
4e7de2f272 File dialog fixes and improvements
File dialog requests can now specify the share and access mode they want out of the opened file. This means read-only access is now possible.

While doing this I noticed that the SDL3 backend had a memory leak *and* didn't match the behavior of the other backends. Cleaned up the code to avoid that.

In-engine commands that *can* specify read-only access on file open now do.
2025-05-24 16:38:01 +02:00
Cami
b61075c660 Stopped recursive updates for controls that are not visible, as it vi… (#5960)
* Stopped recursive updates for controls that are not visible, as it violates framerate in large menus.

* Update Robust.Client/UserInterface/Control.cs

---------

Co-authored-by: Cam <Nop>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2025-05-23 17:42:47 +02:00
Tayrtahn
7b571dc80e Fix 2 instances of warning CS0162 (#5951) 2025-05-23 17:37:08 +02:00
TemporalOroboros
f1c76ca899 Remove unused obsolete TryGetContainingContainer override (#5660)
* Remove unused obsolete TryGetContainingContainer override

* poke tests

---------

Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-05-23 17:36:38 +02:00
metalgearsloth
84dcd658aa Version: 260.2.0 2025-05-21 23:30:58 +10:00
metalgearsloth
a634d6bd04 Add WorldNormal to StartCollideEvent (#5954)
We already have the value just a matter of adding it to the event.
2025-05-21 20:41:57 +10:00
DrSmugleaf
36f9df3079 Add System.Text.StringBuilder Insert(int, string) to sandbox.yml (#5955) 2025-05-21 11:20:10 +02:00
keronshb
824c018a69 Version: 260.1.0 2025-05-19 13:11:32 -04:00
Tayrtahn
4b6b688c72 Cleanup warnings in PlacementManager (#5939) 2025-05-18 19:14:16 +10:00
Tayrtahn
71df25b251 Cleanup warning in Clyde.Sprite (#5940) 2025-05-18 18:51:27 +10:00
metalgearsloth
be14a3c249 Expose CompFactory to systems (#5941) 2025-05-18 00:56:09 -04:00
metalgearsloth
3c2a4d5c79 Version: 260.0.0 2025-05-18 03:07:24 +10:00
metalgearsloth
44180b3ee0 Fix / remove startcollidevent worldpoint (#5936)
Now it's worldpoints because it may not necessarily be 1 pointr and internally we fix the actual points themselves.
2025-05-18 03:03:12 +10:00
metalgearsloth
bb0e77e937 Add some EntProtoId overloads (#5938)
Need it for some content stuff didn't feel like doing the rest yet.
2025-05-17 18:28:12 +10:00
ArtisticRoomba
684b9bc852 Add new Vertical property to progress bars (#5932) 2025-05-17 18:27:44 +10:00
Tayrtahn
9f3db6693e Add SpriteSystem dependency to VisualizerSystem (#5935)
* Add protected SpriteSystem reference to VisualizerSystem

* Capital S
2025-05-17 13:26:40 +10:00
metalgearsloth
40d869948d Version: 259.0.0 2025-05-15 20:26:10 +10:00
Tayrtahn
5c97b15849 Mark Entity methods as readonly (#5919)
* Mark Entity methods as readonly

* Add to GenericEntityPrint

* No but really
2025-05-15 20:23:29 +10:00
Tayrtahn
3d8a9a41fa Combine TileChangedEvents in SetTiles (#5912)
* Combine TileChangedEvents in SetTiles

* Raise event after regenerating collision

* continue, not return

* No need for GetComponent

* Swap TileRef for Tile + Vector2i

* Estimate size of tileChanges
2025-05-15 20:22:05 +10:00
metalgearsloth
92fc8722da Version: 258.0.1 2025-05-15 19:28:25 +10:00
metalgearsloth
73f6555624 Fix static ent collision spawn (#5933)
* Fix static ent collision spawn

* Fix test

* cool
2025-05-15 19:11:20 +10:00
metalgearsloth
2ac7bc3ce4 Version: 258.0.0 2025-05-15 00:51:12 +10:00
Leon Friedrich
05cb4bb1c9 Make SpriteSystem.LayerMapReserve not throw (#5930)
* Make SpriteSystem.LayerMapReserve not throw

* fix SpriteComponent.Visible

* remove region
2025-05-14 23:23:51 +10:00
Leon Friedrich
a393efc87a Modify markup tag interfaces and fix some bugs (#5442)
* Modify markup tag interfaces

* Why are nullable structs like this.

* AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

* Avoid breaking changes

* Replace IMarkupTag with IMarkupTagHandler in engine

* Its a breaking change now I guess

* cleanup
2025-05-12 14:09:18 +10:00
Leon Friedrich
4d47cfa1a6 Minor respath improvements (#5876)
* Minor respath improvements

* Add helpers

* tweak helper

* Throw on more than 1 char

* comments

* No emoji separators
2025-05-12 13:04:40 +10:00
DrSmugleaf
2b1d755d9f Fix Container state handling not forcing inserts (#5916) 2025-05-11 22:45:31 +10:00
ElectroJr
db7de0a99f Version: 257.0.2 2025-05-11 23:47:14 +12:00
Leon Friedrich
47f18703af Fix unshaded sprite layers (#5924)
* Fix unshaded sprite layers

* update comment
2025-05-11 21:42:40 +10:00
Leon Friedrich
97c1548301 Add SpriteBoundsTest (#5922) 2025-05-11 15:30:14 +10:00
ElectroJr
cd97f1583f Version: 257.0.1 2025-05-11 13:56:27 +12:00
Leon Friedrich
5fbe25ec9d Fix sprite layer bounds (#5920) 2025-05-11 11:52:20 +10:00
metalgearsloth
516ee47b51 Version: 257.0.0 2025-05-10 22:12:35 +10:00
metalgearsloth
89be682e24 Don't raise wake events for terminating contacts (#5757) 2025-05-10 22:02:22 +10:00
metalgearsloth
6086076559 Avoid checking grid traversal for rotation events (#5778)
* Avoid checking grid traversal for rotation events

* Also this one
2025-05-10 22:01:43 +10:00
beck-thompson
5bd90c908a Optimization RSI preloading / atlas creation (#5817)
* First commit

* Fix multiatlas bug

* Use ValueList instead

* Add FFDH sorting for atlases

* Minor cleanup and value lists
2025-05-10 22:00:03 +10:00
Leon Friedrich
a3d0921cc9 Pause entities that leave PVS range (#5878)
* Pause entities that leave PVS range

* Fix merge

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2025-05-10 21:57:04 +10:00
Leon Friedrich
15d5b9aa02 Move parts of SpriteComponent to SpriteSystem (#5602)
* Partial sprite component ECS

* release notes

* tests

* Why

* SetSnapCardinals

* NoRotation

* DirectionOverride

* This is why I love distinct overrides that take in object

* LayerSetData

* ISerializationHooks continue to haunt me

* Relocate SetShader

* LayerSetSprite

* LayerSetTexture

* yipeeeee

* LayerSetRsi

* Remove GetFallbackState

* LayerSet Scale,Rotation,Color,Visible

* Fix LayerSetRsi

* LayerSetOffset

* LayerSetDirOffset

* Add overrides that take in a Layer

* LayerSetAnimationTime

* LayerSetRenderingStrategy

* Reduce Resolves, Add Layer.Index

* Access

* Try fix NREs

* Asserts

* LayerGetState

* Cleanup

* Merge helper partial classes

* partial rendering

* GetLayerDirectionCount

* Cache local bounds

* RenderLayer

* RefreshCachedState

* RoundToCardinalAngle

* Fix the pr

* Fix debug assert

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2025-05-10 21:56:53 +10:00
Leon Friedrich
d24854d94f Improve yaml validation errors for ignored prototypes (#5886)
* Improve yaml validation errors for ignored prototypes

* release notes

* Comments
2025-05-10 21:37:42 +10:00
Tayrtahn
b3cf427013 Catch NotYamlSerializable DataFields with analyzer (#5704)
* Catch NotYamlSerializable DataFields with analyzer

* Extract common defs into shared source
2025-05-10 21:36:33 +10:00
Leon Friedrich
c458abdc69 Move TestPair & PoolManager to engine (#5877)
* Engine pool manager

* Move documentation

* Move namespace

* Move TestMapData to engine

* Option to prevent loading test assembly

* release notes

* Rename to avoid conflicts
2025-05-10 21:35:28 +10:00
metalgearsloth
c76444a33f Version: 256.0.0 2025-05-10 13:40:38 +10:00
B_Kirill
4754661467 Cleanup warnings: CS0649 (#5891)
* Clean up

* Remove "struct UpdateTreesJob"

* Use #pragma

* Use #if DEBUG

* More #if DEBUG
2025-05-10 12:40:15 +10:00
B_Kirill
2a8b776ee9 Cleanup warnings: CS0414 (#5892)
* Clean up

* Use #pragma
2025-05-10 12:39:46 +10:00
SpaceManiac
7d8e5a5841 Fix linear lookup on a dictionary in PlacementManager (#5911) 2025-05-06 16:05:58 +02:00
Centronias
8e416e4519 Makes ItemList not run deselection callback on all list items (#5861)
* Makes ItemList not run deselection callback on all list items

even when they weren't selected

* I cannot be expected to do things intelligently at 2a

* Optimize local usage.

* I'm pretty sure the test failure isn't from ItemList

* switch to avoiding doing anything in the `Selected` setter if the value-to-set-to is the same as the current value.
2025-05-06 14:05:05 +02:00
SlamBamActionman
65f74943d3 Add support for rotated/mirrored tiles (#5652)
* Initial commit

* Add tile rotation/mirror perms

* Nicer UI for the rotation

* Review fixes (also seemed to have missed applying the serialization reading oops)

* One less byte, one less struct size!

* Pretty sure it goes here too

* Fix error
2025-05-05 23:13:31 +10:00
Errant
eb5ed12270 Serialize TimeSpan from text (#5865)
* timespanserializer cleanup

* string reading

* high speed, low drag

* unit tests

* Update Robust.Shared/Serialization/TypeSerializers/Implementations/TimespanSerializer.cs

---------

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
2025-05-05 00:57:01 +02:00
PJB3005
c43b7b16c0 Add CancellationTokenRegistration to sandbox 2025-05-05 00:45:05 +02:00
slarticodefast
aee03f0805 fix yaml hotreloading (#5907) 2025-05-04 04:33:37 +02:00
dffdff2423
cfd2b03248 Check audio file signatures instead of extensions (#5894)
* Check audio file signatures instead of extensions

Fixes #5789

Test audio files based on their magic bytes.

* Test for a seekable stream

* Remove Take and Skip linq
2025-05-04 04:33:01 +02:00
dffdff2423
8905a3fe14 Add documentation to the serializer interfaces and remove ITypeReaderWriter (#5897)
* Add documentation to the serializer interfaces

* Remove ITypeReaderWriter and fix the docs

* Fix spelling errors and incorrect docstrings
2025-05-04 04:03:17 +02:00
PJB3005
a878da5b80 Allow texture preload to be skipped for some textures
This is a far cry from a proper resource tracking system, but it's something to avoid a ton of otherwise-unused parallax textures being loaded at game start and consuming VRAM.
2025-05-04 02:24:57 +02:00
Leon Friedrich
806c23e034 Move EntityExt.AsNullable extension methods into the Entity struct (#5899)
* Move `EntityExt.AsNullable` extension methods into the Entity struct

* use constructor

* a
2025-05-04 01:24:23 +02:00
metalgearsloth
e80f5d13a1 Add Vector2i / bitmask conversions (#5901)
Content uses for a couple tile-based flags.
2025-05-04 01:23:04 +02:00
PJB3005
a6905151b6 Move PointLight component states to shared
Necessary so the client can calculate an initial state, which is necessary for prediction and replay seeking to work properly.

Fixes the nuke in SS14 not having its light turn off when going back in a replay.
2025-05-02 01:21:17 +02:00
PJB3005
e742f021fa Dev window tab to show all loaded textures 2025-04-30 15:50:39 +02:00
metalgearsloth
62b4714f1f Version: 255.1.0 2025-04-30 23:38:21 +10:00
Leon Friedrich
1d0404953f Add GridUidChangedEvent and MapUidChangedEvent (#5893)
* Add GridUidChangedEvent and MapUidChangedEvent

* cleanup

* Fix assert

* more fixes

* docs

* record struct

* Use implicit tuple constructor

* stinky review

---------

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2025-04-30 18:36:53 +10:00
Leon Friedrich
d0da13f895 Fix CompileRobustXamlTask for benchmarks (#5902)
* Fix benchmarks

* I love it when path separators are also escape chars
2025-04-30 13:16:28 +10:00
metalgearsloth
ff23f98b26 Document container events (#5904)
It's hard to discern what it's raised directed on and this makes it much easier.
2025-04-30 13:10:03 +10:00
Leon Friedrich
ccfef2a786 Fix PVS NRE (#5900) 2025-04-28 20:11:18 +10:00
B_Kirill
62ce9724fc Clean up (#5890) 2025-04-26 22:59:02 +10:00
Milon
3bbe0e7f44 ftl hot reloading (#5874)
* sloth is so going to kill me

* the voices in my head told me to do this

* Register ILocalizationManagerInternal on client

* Avoid breaking change

* Cleanup

* Release notes
2025-04-26 22:38:56 +10:00
chromiumboy
addd8b5bdd Initial commit (#5880) 2025-04-25 22:19:11 +10:00
ElectroJr
03f8d4d3e0 Version: 255.0.0 2025-04-25 17:32:45 +12:00
Leon Friedrich
728d541ca5 Remove assert in UserInterfaceManager.KeyBindDown (#5889) 2025-04-25 15:30:26 +10:00
Leon Friedrich
4cbce064b8 Fix grid fixtures using locale dependent ids (#5887) 2025-04-24 12:49:04 +02:00
IProduceWidgets
93bb7b1532 Sandbox whitelist for calendar stuff. (#5888) 2025-04-24 12:46:41 +02:00
Pieter-Jan Briers
3ba91d2ed0 Add cycle detection when setting MIDI renderer masters (#5879)
If these things ever get in a cycle (as they did in some SS14 replays),
it'll likely get the client stuck in an infinite loop. Avoid that.
2025-04-24 18:12:59 +10:00
Tayrtahn
8f9e0f6bab Fix warnings in PhysicsMap_Test (#5884) 2025-04-24 18:10:13 +10:00
Tayrtahn
3ed408de5d Fix warnings in Joints_Test (#5885) 2025-04-24 18:09:27 +10:00
DrSmugleaf
2f85408f8f Fix SharedPhysicsSystem.CollideContacts looping contacts that are in nullspace (#5881)
* Fix SharedJointSystem.CreateDistanceJoint taking in an int for minimumDistance instead of a float

* Fix SharedPhysicsSystem.CollideContacts looping contacts that are in nullspace
2025-04-22 22:50:56 +10:00
Leon Friedrich
f49b01b1b7 PredictedDeleteEntity fixes (#5873)
* PredictedDeleteEntity fixes

* release notes
2025-04-20 23:38:43 +10:00
Leon Friedrich
3ce764311d Make RobustIntegrationTest pool by default (#5872) 2025-04-20 17:53:55 +10:00
B_Kirill
adf0b6ae78 Fix CA2264 in Resource Manager (#5870) 2025-04-20 05:02:16 +02:00
metalgearsloth
04406311dc Use EntityQuery for map / grid calls (#5869)
Avoids the type lookup etc etc.
2025-04-20 12:59:06 +10:00
Kyle Tyo
ee45a608b9 Replace IsMap and IsGrid calls with HasComp (#5866) 2025-04-20 12:21:19 +10:00
metalgearsloth
077c91a54b Add autocomplete to scale command (#5864)
* Add autocomplete to scale command

* Also the scale

* this
2025-04-19 22:50:09 +10:00
metalgearsloth
2ac17009ee Deep-copy fixtures on client (#5863)
Fixes a LOTTA bugs
2025-04-19 19:31:36 +10:00
metalgearsloth
a73d1b6666 Update container log warning for pred spawns (#5860)
This was on the full branch I just forgot to pull it out. This is intended that they can go into containers.
2025-04-19 18:08:19 +10:00
metalgearsloth
e5d6f194be Add nullable PredictedDel overloads (#5859)
Forgor when I updated it to Entity<T>
2025-04-19 17:47:25 +10:00
Pieter-Jan Briers
72d893dec5 Add "obsolete inheritance" analyzer (#5858)
This allows us to make it obsolete to *inherit* from a class, and only that.

Intended so people stop inheriting UI controls for no good reason.

Fixes #5856
2025-04-19 17:29:17 +10:00
metalgearsloth
191d7ab81c Version: 254.1.0 2025-04-19 16:53:53 +10:00
metalgearsloth
65d2f2dd2f Entity spawn prediction v1 (#5841)
* Entity spawn prediction v1

Client can't properly interact with this but that requires additional work on top so we can cleanly split this.

* This

* delete fix

* cats
2025-04-19 16:50:41 +10:00
Dae
02b451db2a Add no derivatives licenses to rga validation (#5749) 2025-04-19 12:23:21 +10:00
Ed
d5d4584e11 Update Clyde.GridRendering.cs (#5852) 2025-04-19 00:01:16 +02:00
metalgearsloth
b146b1b82c Version: 254.0.0 2025-04-18 19:06:45 +10:00
Leon Friedrich
2f8f4f2f7a Make MappingDataNode use string keys (#5783)
* string keys

* obsoletions

* Fix ValueTupleSerializer

* Release notes

* fix release note conflict

* cleanup

* Fix yaml validator & tests

* cleanup release notes

* a

* enumerator allocations

* Also sequence enumerator alloc
2025-04-18 19:01:34 +10:00
Tayrtahn
7365a59bd9 Cleanup warnings in CollisionWake_Test (#5847) 2025-04-18 12:05:48 +10:00
Tayrtahn
37560f663b Add GetContainingContainers method to SharedContainerSystem (#5803)
* Add SharedContainerSystem.EnumerateContainingContainers

* More obvious name
2025-04-17 21:51:23 +10:00
TemporalOroboros
bd489e9218 A compilation of simple one-line fixes (#5661)
* Fix warnings in SharedJointSystem

* Fix reference to EC TransformComponent method
Replaces call to TransformComponent.GetMapUid with SharedTransformSystem.GetMap

* Fix obsolete calls in SharedPhysicsSystem.Contacts.cs
Fixes a couple calls to obsolete varients of SetAwake and an obsolete call to RegenerateContacts by converting them to their Entity<T> varients

* Fix obsolete call in SharedPhysicsSystem.Components.cs
Adds one set of parenthesis to convert a 'uid, comp, comp, comp' call to an 'Entity<T, T, T> call.

* Removes unused local var
Removes an unused list of broadphases that was being allocated in TryCollideRect

* One-line fixes in SharedPhysicsSystem.Islands.cs
Fixes all of the easy warnings regarding physics island processing, the rest require more complicated changes than a simple argument rearrangement

* Fix obsolete method call in SharedMapSystem

* Fix a few obsolete ToMap calls in EntityLookup.Queries

* Fix calls to obsolete EntityCoordinate methods in SharedMapSystem.Grids

* Fix calls to obsolete EntityCoordinate methods in SharedLookupSystem.ComponentQueries

* Fix a few obsolete method calls in entity spawning

* Fix obsolete method calls in MapLoaderSystem

* Fix obsolete method call in GridFixtureSystem

* Fix obsolete IsMapInitialized call in SaveMap command

* Fix obsolete MapPosition reference in Client.EyeSystem

* Fix obsolete EntitySystem.Get<TSystem> references in DebugLightTreeSystem

* Fix obsolete EntitySystem.Get<TSystem> reference in DebugEntityLookup command

* Fix obsolete method calls in SpriteBoundsOverlay
Slightly more complicated than the rest, but it's really just changing an unused dependency over to use SharedTransformSystem

* Remove unused IClyde references from controls
LineEdit and TextEdit never use their IClyde dependencies and it generates a warning so yeet

* Remove use of EntitySystem.Get from lightbb command

* Fix DebugDrawingSystem
Removes a bunch of unused private IEntityManager vars
Also removes an obsolete use of TransformComponent.GetWorldPositionRotation

* Removes duplicate position set when splitting grids
There's nothing saying why this is this way and the blame looks like it was an oversight when replacing a bit where they set position and then rotation
Please, oh Chesterton's Fence, spare me your wrath

* Fix obsolete method use in PlacementMode

* Fix obsolete method use in Placement Modes

* Removes unused local var in gamestate management

* Fix unreachable code warnings in gamestate management
Use #else sections to make sure they don't complain about being on the wrong side of a throw

* Fix obsolete ToMap use in EyeManager

* Make InputManager use a sawmill to log

* Fix obsolete ContainerManagerComponent method calls in ContainerSystem

* Make ClientPrototypeManager use a sawmill for logging

* poke tests

* Use LocalizedEntityCommands for SpriteBoundsOverlay toggle

* Use LocalizedEntityCommands for system toggles

---------

Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
2025-04-17 11:57:03 +10:00
metalgearsloth
33166e8866 Component lifecycle generics (#5844)
Non-breaking minor.
2025-04-16 21:46:14 +10:00
Leon Friedrich
ed16032280 Disable tile edges (#5842) 2025-04-16 21:25:31 +10:00
metalgearsloth
cf785c886b Mark GetCollidingEntities as obsolete (#5831)
Bad methods, entitylookup is better (it does everything for area queries) and anyone who wants contacts should be querying those directly.
2025-04-14 18:50:01 +10:00
metalgearsloth
6f28c396cf Version: 253.0.0 2025-04-14 14:12:32 +10:00
metalgearsloth
b631f408f2 ItemList optimisation (#5796)
- VV AddComponent window no longer takes 300ms every time you press a key.
- Significantly optimise ItemList internally.
2025-04-14 13:55:48 +10:00
Leon Friedrich
34f4cf9452 More map validator fixes (#5820) 2025-04-14 13:55:02 +10:00
B_Kirill
6a4e4cf3b4 Cleanup warnings: Commands (#5825) 2025-04-14 13:54:42 +10:00
metalgearsloth
8aefa5c53e Make TestPoint use generics (#5828) 2025-04-14 01:49:07 +10:00
DrSmugleaf
2cfc981aa3 Fix popup text overflowing the sides of the screen (#5788)
* Fix popup text overflowing the sides of the screen

* Fix not escaping text
2025-04-13 12:59:23 +02:00
Leon Friedrich
4987c324d9 Fix bad debug assert (#5826) 2025-04-13 20:50:46 +10:00
DrSmugleaf
5450ddd0ba Fix SharedJointSystem.CreateDistanceJoint taking in an int for minimumDistance instead of a float (#5824) 2025-04-13 16:22:22 +10:00
Tayrtahn
378a10678c Improve location reporting for non-writeable DataFields (#5715)
* Better location reporting for readonly DataField errors

* Better location reporting for readonly DataField property errors

* Use SyntaxKind instead of string for TryGetModifierLocation
2025-04-13 16:22:05 +10:00
Leon Friedrich
2e0735b92f Fix NRE in screen-space overlays (#5823)
* Fix pre-init screen-space overlays

* Debug asserts
2025-04-13 16:21:02 +10:00
Leon Friedrich
5756d15333 Make BoundUserInterfaceMessageAttempt broadcast again (#5821) 2025-04-12 18:22:13 +10:00
Leon Friedrich
b6f74b8dea Fix logMissing in EntitySystem.Resolve() (#5822) 2025-04-12 17:40:08 +10:00
Leon Friedrich
3800c5707e Add new SerializationManager.PushComposition overload (#5785) 2025-04-12 12:58:40 +10:00
Leon Friedrich
8f49785b4e Fix RemCompDeferred not always setting lifestage (#5786)
* Fix RemCompDeferred not setting lifestage

* spaelling
2025-04-12 12:57:11 +10:00
metalgearsloth
f274de0f10 Version: 252.0.0 2025-04-12 01:43:29 +10:00
Milon
e128338f9d hi (#5811) 2025-04-12 01:29:41 +10:00
metalgearsloth
588c46273e Version: 251.0.0 2025-04-10 20:53:09 +10:00
Whatstone
919de8ce0e SharedPhysicsSystem.Island: set position after velocity (#5801) 2025-04-09 01:10:17 +10:00
Errant
af27d2d872 equatable FormattedMessage, take 2 (#5780)
* improved Equals and getHashCode

* less jank
2025-04-08 16:50:08 +02:00
Tayrtahn
45bb8740a0 Add ForbidLiteralAttribute and analyzer (#5808)
* Add ForbidLiteral attribute, analyzer, and test

* Removed unused code

* Switch order of methods. It's better this way.
2025-04-08 16:39:38 +02:00
Tobias Berger
4a24539629 Don't implement GetMassData twice (#5816)
The removed body didn't calculate mass for circles
2025-04-09 00:14:45 +10:00
PJB3005
7536c4ec68 Log late MsgEntity again
Yay :)
2025-04-07 15:50:40 +02:00
metalgearsloth
9268c8629d Refactor TileEdgeOverlay (#5295)
* Refactor TileEdgeOverlay

* weh

* Updates

* exweh

* Stupid weh noises

* I am le stupid

* Add logging about tile atlas build time

Seems fine, but wanted to check.

* Don't over-allocate edge tile region array

* Add DirectionExtensions.AllDirections

* Clean up iteration in ClydeTileDefinitionManager

* Don't stackalloc large chunk edge buffers, other code cleanup.

* More release notes

---------

Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-04-03 07:52:28 +02:00
PJB3005
0bc0cafe64 Show entity name in "physics shapeinfo" output 2025-04-03 02:59:09 +02:00
PJB3005
8891f3fa0a Make EntitySystem.Subscriptions.SubscribeLocalEvent not require EntityEventArgs
This means it can be used with struct events.
2025-04-03 02:58:20 +02:00
Tornado Tech
4f96c2d233 Added separate localization & clean up (#5227)
* Added separate localization & clean up

* Added new methods docs

* Added GetFoundCultures method

* Clean up code

* Removed some formating shit

* Do better CultureInfo comparison

* Oops

* Review

* Command fixes

---------

Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-04-02 16:41:02 +02:00
PJB3005
ab55d5b2f2 Revert "Add Loc property to LocalizedCommands"
This reverts commit 806c5b694b.
2025-04-02 05:23:43 +02:00
PJB3005
806c5b694b Add Loc property to LocalizedCommands
Avoids some ~300 usages of static Loc in SS14 and RT
2025-04-02 05:21:43 +02:00
metalgearsloth
6898053dbd Add autocomplete to tp command (#5795) 2025-04-02 03:48:16 +02:00
metalgearsloth
ae625ebad8 Inline manifold points (#5794)
* Inline manifold points

Max is 2 so no reason to use an array over a fixedarray.

* this
2025-04-02 00:04:51 +11:00
metalgearsloth
3c754a4f49 Don't disable contacting collisionwake ents (#5798)
Good for some content stuff I don't think it caused issues.
2025-04-01 15:04:05 +11:00
Tayrtahn
d84cb6327c Fix SharedTransformSystem methods erroring on failed Resolves (#5787)
* Don't error when GetGrid fails

* Fix other Resolves in SharedTransformSystem
2025-04-01 04:59:47 +11:00
Ciarán Walsh
4bfd92dbc5 Add button to jump to live chat when scrolled up (#5750)
* Add button to jump to live chat when scrolled up

* Expose scroll button class name as a public constant

* Add localisation string to engine

* Make enabling the OutputPanel scroll button opt-in

* Enable scroll button for the debug console

* De-duplicate visibility logic

* Update scroll button visibility when the enabling property is changed
2025-03-30 03:07:54 +02:00
metalgearsloth
c7d228c223 savemap / savegrid autocomplete (#5784)
How mappers coping without this.
2025-03-27 18:54:13 +11:00
Tayrtahn
f244c94905 Switch from checking comp.Owner == ent to GetComp(ent) == comp (#5776) 2025-03-27 15:21:05 +11:00
Tayrtahn
01cac6465b Cleanup warnings in EntityCoordinates_Tests (#5771)
* Fix warnings

* Use transform refs to simplify WithEntityId
2025-03-27 15:20:20 +11:00
metalgearsloth
5a5f238d9a Version: 250.0.0 2025-03-27 15:12:01 +11:00
Tayrtahn
089224cd44 Cleanup warnings in EntityLookup_Test (#5775)
* Replace MapManager.DeleteMap calls with MapSystem.DeleteMap

* Remove unused resolves
2025-03-27 15:07:05 +11:00
Tayrtahn
9f807f1ad2 Cleanup warnings in ClientGameStateManager (#5774)
* Fix unreachable code

* Remove unused variable
2025-03-27 15:06:37 +11:00
metalgearsloth
4be95ea375 Add OtherBody API to contacts (#5779)
* Add OtherBody API to contacts

Thought I had a pr for this.

* Update Robust.Shared/Physics/Dynamics/Contacts/Contact.cs

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
2025-03-27 15:06:04 +11:00
Jerry
03010bf4be Fix DirectoryNotFoundException when saving map or grid on Unix systems (#5773)
* fix(maploader): Fix DirectoryNotFoundException

Someone forgor to create directory before saving map or grid, this caused
an exception on trying to save smth anywhere else than /

* update release notes
2025-03-27 13:56:26 +11:00
Tayrtahn
dacaa974d4 Replace MapManager.DeleteMap with SharedMapSystem.DeleteMap in misc tests (#5777)
* Replace MapManager.DeleteMap with SharedMapSystem.DeleteMap in various tests

* Poke tests

* I guess this is was technically a breaking change?
2025-03-27 13:50:56 +11:00
DrSmugleaf
9f73e0398a Make MappingDataNode.Equals take 2952 times less time to run when loading maps (#5781) 2025-03-27 12:52:29 +11:00
Tayrtahn
ccc383b1bf Cleanup: Remove redundant Prototype names (#5721)
* Cleanup: Remove redundant Prototype names

* Actually this one probably should stay

* Suppress warning

* Remove warning suppression on AudioMetadataPrototype

* But wait, there's more!
2025-03-26 01:39:10 +01:00
PJB3005
ceb59402a1 Make status and info APIs have CORS allow-origin: *
Allows it to be queried from browser JS. No harm in not allowing this.

Added helper function StatusExt.AddAllowOriginAny to make this easy to add.
2025-03-26 01:16:23 +01:00
Errant
5a6b29fcd2 equatable FormattedMessage (#5772) 2025-03-25 15:32:47 +01:00
PJB3005
6b87cd1e1c Deprecate HCY color space functions
These functions use the wrong color primaries (Rec 601 instead of 709) to calculate the luminance, so I'm just gonna throw them out.

Also, I don't actually trust anybody to know to do sRGB conversion before using them.

Discovered this as a result of reviewing #5360
2025-03-24 04:47:34 +01:00
Leon Friedrich
cf2d6a1dbf Make unshaded sprite layers not require shader/texture changes. (#5248)
* Make unshaded sprite layers not require shader/texture changes.

* Always sample texture

* revert some variable name changes

* Use color SIMD
2025-03-24 02:37:04 +01:00
chromiumboy
f8c838f425 Pass AnimationPlayerComponent in AnimationCompletionEvent (#5755)
* Added a field for the animation player component to the animation completion event

* Addressed review comment

* Updated
2025-03-24 02:22:46 +01:00
Tayrtahn
7405904041 Add entity description as tooltip on entity spawn panel (#5761) 2025-03-23 14:07:22 +01:00
metalgearsloth
2eeebab275 Add pure to some angle methods (#5763)
Saw some of these floating around in mover code.
2025-03-22 13:43:18 +01:00
PJB3005
2856bb3626 Shut up RS1038 warnings
We aren't going to fix these until #5610 is figured out, and these aren't even an indicator of an issue itself.

They indicate that we have code fixes in the same assembly as analyzers, meaning the analyzers COULD fail if we relied on some code fix libs - something we don't do.
2025-03-22 06:20:43 +01:00
PJB3005
be0189748b Fix serialization source gen with partial types
This fixes RMC compilation
2025-03-22 06:09:48 +01:00
Tayrtahn
4529a7569a Replace uses of ProtoId<EntityPrototype> with ProtoId<EntityCategoryPrototype> (#5762) 2025-03-21 04:08:12 +01:00
metalgearsloth
2b16e4db96 Version: 249.0.0 2025-03-21 00:52:45 +11:00
metalgearsloth
64f2245194 Add UpdateVisibilityMask method (#5745)
* Add UpdateVisibilityMask method

We tipped over to the point of systems stepping on each other's toes. Now we do the normal thing and just use the eventbus and it makes content a whole lot cleaner.

* Update resolve

* Update name in line with normal.

* Unserialize this

* weh
2025-03-21 00:47:40 +11:00
Milon
1029047e2f fix (#5752) 2025-03-20 22:30:59 +11:00
metalgearsloth
45dc9ad80e Inline polygon vertices (#5758)
* FastPoly

* Inline polygon vertices

No more pooling, pooling bad. No more arrays in engine, only span.

I made a slim version that's only the 4 verts so no padding on it compared to Polygon. Slightly more clamplicated code but entitylookup + mapmanager are both hotpaths and it's easy to do. Memory usage will likely go up for now but heap allocations should drop significantly due to removing the pooling.

* Unhide these

* Fixes

* More fixes

* More fixes

* Avoid potential bomb
2025-03-20 21:26:05 +11:00
metalgearsloth
54ad808eea Add GetWorldManifold overload (#5756)
* Add GetWorldManifold overload

* revert
2025-03-20 21:10:04 +11:00
metalgearsloth
37c75df6a2 Fix showvelocities (#5759)
* Fix showvelocities

Can't use StateRoot anymore so just pretend it's a window.

* Also file-scoped
2025-03-20 21:05:58 +11:00
slarticodefast
e93c1fae61 Add velocity and angular velocity debug overlays (#5693)
* add velocity and angular velocity debug overlays

* minor improvement

* add descriptions

* fix

* review

* Update RELEASE-NOTES.md

* Update RELEASE-NOTES.md

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2025-03-20 13:10:16 +11:00
metalgearsloth
cd0a35f542 Fix light Aabb query (#5744)
Forgot when this got dropped but we need it for grid-tree query as lights spill over grids.
2025-03-13 19:18:23 +11:00
PJB3005
80f2dc6dd3 Fix BoxContainer stretching causing controls to be made too small
In which I fix a bug by just deleting a ton of code and doing nothing else.

(also I added unit tests)
2025-03-13 01:01:18 +01:00
metalgearsloth
139b6f796c Version: 248.0.2 2025-03-12 20:26:50 +11:00
metalgearsloth
2ee7c35fd3 Don't throw on invalid MapUids for overlays (#5740) 2025-03-12 20:16:13 +11:00
metalgearsloth
56eae5ad08 Reduce EntityManager.IsDefault allocations (#5741)
* Reduce EntityManager.IsDefault allocations

We don't actually need the MappingDataNode so we can avoid allocating the entire class per entity.

* Adjust this order
2025-03-12 19:42:08 +11:00
DrSmugleaf
0662cae224 Version: 248.0.1 2025-03-11 19:38:08 -07:00
metalgearsloth
0e2b00edd0 Fix NaN gain audio (#5737) 2025-03-10 20:16:05 +11:00
Richard Van Tassel
d48f7ecb5b bumps ImageSharp version (#5733) 2025-03-08 15:19:23 +01:00
metalgearsloth
e064b7a4f9 Version: 248.0.0 2025-03-08 15:34:53 +11:00
metalgearsloth
654480862e Use Prototype for ITileDef (#5731)
Forgot to push this.
2025-03-08 15:20:25 +11:00
metalgearsloth
353c044b52 Hot reload resources (#5443)
* Fix ResPath CanonPath

Apparently this is supposed to standardise to / but this isn't always the case. Alternatively we could just assert for performance reasons I'm good with either. The comment as written says this should happen.

* Fixes

* change

* assert

* Fix bad respath input

* Buffer

* Merge conflicts

* review

* Fix
2025-03-08 15:16:31 +11:00
Whatstone
3dda8d9e93 Try/catch blocks around BUI open/dispose calls (#5730) 2025-03-08 15:16:11 +11:00
metalgearsloth
41ea10083d Fix ResPath CanonPath (#5452)
* Fix ResPath CanonPath

Apparently this is supposed to standardise to / but this isn't always the case. Alternatively we could just assert for performance reasons I'm good with either. The comment as written says this should happen.

* assert

* Fix bad respath input

* review
2025-03-08 15:02:46 +11:00
eoineoineoin
6290bb7af1 Adds method to Controls.ItemList which updates the item list without erasing contents (#5425)
* Add algorithm from ss14#30292 to ItemList, for use in other UIs

* Add overload for common case of comparing items by their text label
2025-03-08 14:43:43 +11:00
metalgearsloth
348ab70a8d Update B2DynamicTree (#5332)
* Update B2DynamicTree

* API updates

* weh

* forcing it

* Fix all of the bugs

* Rebuild

* A crumb of danger

* Fix merge conflicts
2025-03-08 14:15:47 +11:00
IProduceWidgets
47e11e988c Fix map netId completions (#5495)
* make map netId completions function.

* Update Robust.Shared/Console/CompletionHelper.cs

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2025-03-08 13:57:13 +11:00
Leon Friedrich
c459b55052 Add TryLoadGrid override (#5701)
* Add TryLoadGrid override

* fix cmd-addmap-help
2025-03-08 13:50:14 +11:00
Tayrtahn
f10e96a6d1 Clean up warnings in Stack_Test (#5705) 2025-03-08 13:49:52 +11:00
metalgearsloth
e8bac558c6 Use Entity<T> for TileChangedEvent (#5698)
Content is manually resolving this in a few spots so we can avoid that overhead.
2025-03-08 13:48:32 +11:00
metalgearsloth
ffa3bb7202 Fix savedpos caching on UI shutdown (#5729)
Don't need this as it gets handled already.
2025-03-08 13:28:29 +11:00
Dylan Craine
9bcdc95651 Fix deceptive "successfully saved" messages for mappers (#5714)
* Actually check if map save succeeded before displaying success message

It would be great to offer more clarity to the mapper about *why* the
save didn't succeed, but at least they won't be deceived into thinking
their work has been saved when it hasn't.

Portuguese localization text is via DuckDuckGo Translate, so I hope it's
reasonable.

* Actually check save success for saving grids

These messages need localization, too, but that seems out of scope for
my PR.

* Improve map save error message

Now it tells the mapper to go look at the server log.
Still translated via DuckDuckGo Translate.

* Normalize indentation and style
2025-03-08 13:27:59 +11:00
TemporalOroboros
543088ea1f Remove unused private members/local vars (#5722) 2025-03-05 15:50:54 +01:00
deltanedas
56daa63783 make map loading logs better (#5723)
Co-authored-by: deltanedas <@deltanedas:kde.org>
2025-03-05 15:49:20 +01:00
metalgearsloth
9fe9730d4a Add public API for physicshull (#5719) 2025-03-03 22:07:38 +11:00
SlamBamActionman
a1a7ea92d9 Add Regex.Count and StringBuilder.set_Chars to sandbox whitelist (#5717) 2025-03-01 22:42:19 +01:00
poklj
0dec6a425f Modify TryCopyComponents metadata TryGetComponent (#5710) 2025-02-27 11:25:28 +11:00
metalgearsloth
56ced913b7 Audio fixes (#5707) 2025-02-26 22:08:17 +11:00
PJB3005
76b46479b6 Version: 247.2.0 2025-02-23 01:44:44 +01:00
PJB3005
de9a8d286a Release notes 2025-02-23 01:43:58 +01:00
Milon
a1df0fb4af fix some issues with ClientDisconnect (#5625)
* fix

* actually fix for real this time

* just use HappyEyeballsHttp :godo:

* review
2025-02-23 01:33:58 +01:00
pathetic meowmeow
e6bc5a1057 Proxy scrollbar values and value targets in ScrollContainer (#5697) 2025-02-22 22:10:32 +01:00
beck-thompson
11b24579a2 Fix MultiRootInheritanceGraph not detecting circular inheritance (#5672)
* Fix

* This is better!

* Fixes
2025-02-22 22:08:31 +01:00
metalgearsloth
685d002bb7 Move VisibilitySystem to shared (#5694)
* Move VisibilitySystem to shared

* this

* Remove redundant qualifiers.

---------

Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
2025-02-22 21:36:49 +01:00
Tobias Berger
2e0d18aeaf Fix wrong parameters for Regex.Escape in Sandbox whitelist (#5688) 2025-02-22 18:08:28 +01:00
Kyle Tyo
06dbff0429 believe that should be all of em. (#5691) 2025-02-22 18:01:07 +01:00
Southbridge
15958a9447 Fix issue regarding Tilemaps not saving when modified (#5696)
* One line C# fix

* fixed typo

* after spending way too long trying to figure out the problem, turns out all we needed was a simple one line change
2025-02-22 17:33:33 +01:00
pathetic meowmeow
fd5a4d9b8a Refactor audio system to send collection IDs over the network (#5540)
This is important groundwork for future features such as captioning,
as a caption and other data can be associated with the collection
prototype instead of passing extra data everywhere with the sound.
2025-02-22 17:29:47 +01:00
DrSmugleaf
6d958847cb Fix prototype hot reloading crashing when adding a component that an existing entity already has (#5695) 2025-02-22 16:30:05 +01:00
Milon
8a04a4f3a5 Add a method for copying components (#5654)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2025-02-21 09:46:13 +11:00
ElectroJr
7104a4f459 Version: 247.1.0 2025-02-20 16:26:04 +13:00
Leon Friedrich
f29949a32c Revert "Add ICloneable support to ComponentNetworkGenerator (#5656)" (#5687)
This reverts commit e14537074e.
2025-02-20 14:22:36 +11:00
Leon Friedrich
3bbbabf238 Update map format validator (#5686)
* Update map format validator

* string -> str
2025-02-20 12:11:12 +11:00
metalgearsloth
d95aca3d9e Fix DirtyFields proxy method (#5684) 2025-02-20 00:15:05 +11:00
Tayrtahn
e14537074e Add ICloneable support to ComponentNetworkGenerator (#5656) 2025-02-18 23:21:40 +11:00
DrSmugleaf
af2d01981f Add optional minimumDistance parameter to SharedJointSystem.CreateDistanceJoint (#5682) 2025-02-18 14:18:15 +11:00
Fildrance
7df23e047c feat: shaders now can accept array of Color as parameter (#5679)
* feat: shaders now can accept array of Color as parameter

* fix: Clyde.SetUniformDirect for Color[] doesn't mutate original array, removed invalid 'in' keyword on SetUniform

---------

Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2025-02-16 14:13:04 +01:00
ElectroJr
5c7ab43049 Fix typo in RELEASE-NOTES.md 2025-02-17 00:15:27 +13:00
ElectroJr
8f75560ec4 Version: 247.0.0 2025-02-17 00:14:18 +13:00
Leon Friedrich
b323c8bd1e Add support for optional and params T[] toolshed command arguments. (#5573)
* Include argument name in completion suggestions

* Support optional args

* It (not so shrimply) works

* Add tests

* Add TestGenericPipeInference

* Fix tests

* Release notes

* Overzealous YAMLLinter

* Improve help signatures, fix map command

* Improve NoImplementationError

* Better type argument help signatures

* better pipe syntax

* fix NRE

* Add test

* a

* Fix silent toolshed failure

* Fix GetConcreteMethodInternal

* Improve vars command

* EntProtoId IAsType

* More GetConcreteMethodInternal fixes

* I hate this so much

* update tp command description

The command arguments call the the "other" entity the "target"

* Support localized argument hints/signatures
2025-02-16 21:55:05 +11:00
Leon Friedrich
faef44daaa Make PVS overrides respect vismasks (#5598)
* Make overrides respect vismasks

* Thread safety

* Release notes

* Use ExpandPvsEvent.Mask for other overrides

* check if already queued
2025-02-16 21:32:23 +11:00
Leon Friedrich
fbc706f37b Refactor map loading & saving (#5572)
* Refactor map loading & saving

* test fixes

* ISerializationManager tweaks

* Fix component composition

* Try fix entity deserialization component composition

* comments

* CL

* error preinit

* a

* cleanup

* error if version is too new

* Add AlwaysPushSerializationTest

* Add auto-inclusion test

* Better categorization

* Combine test components

* Save -> TrySave

Also better handling for saving multiple entities individually

* Create new partial class for map loading

* Add OrphanSerializationTest

* Include MapIds in BeforeSerializationEvent

* Addd LifetimeSerializationTest

* Add TestMixedLifetimeSerialization

* Add CategorizationTest

* explicitly serialize list of nullspace entities

* Add backwards compatibility test

* Version comments

also fixes wrong v4 format

* add MapMergeTest

* Add NetEntity support

* Optimize EntityDeserializer

Avoid unnecessary component deserialization

* fix assert & other bugs

* fucking containers strike again

* Fix deletion of pre-init entities

* fix release note merge conflict

* Update Robust.Shared/Map/MapManager.GridCollection.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* VV

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2025-02-16 21:25:07 +11:00
metalgearsloth
9d1b15ab4b Version: 246.0.0 2025-02-16 19:32:42 +11:00
metalgearsloth
ea1cc5e446 Planet lighting pre-reqs (#5490)
* Add another lookup overload

* Fix RenderInRenderTarget

See the linked issue for what happens.

* Also this one

* stuff

* Fix stencilling

* fixes

* mix blend

* fix

* blur fixes

* Tile flag

* Minor tweak

* Fixes

* Render state fixes

* Fixes

* Fix stupidity

* More state render bug fixes

* MapUid on overlay draw

* Remove blur comment

* Fixes

* Fixes

* Remove

* Engine vibe
2025-02-16 19:29:32 +11:00
metalgearsloth
bcb5c2d35d Version: 245.1.0 2025-02-16 14:56:39 +11:00
metalgearsloth
c011eff80e Increase audio despawn buffer (#5665)
Apparently it can clip and the buffer is really just there so we despawn 'at some point' and rather than hunching over my debugger for potentially an hour this is easier and almost no impact.

I've also considered flagging some audio as "play the full thing" if someone misses the start of it but need to thonk on that one a bit in future.
2025-02-16 14:30:18 +11:00
Fildrance
e163c496c3 fix: fixed EntityPrototypeView not reacting on SetPrototype when EnteredTree already was called with _currentPrototype empty (#5649)
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2025-02-16 14:29:59 +11:00
Tayrtahn
fec81bc2a1 Add more info to AnchorEntity debug assert (#5668) 2025-02-16 03:16:23 +01:00
Leon Friedrich
7016facb9a Tweak UserInterfaceComponent shutdown to prevent bugs (#5678) 2025-02-14 18:16:24 +11:00
Simon
0c41a041e3 Move ParseObject method into a public class for content to use (#5674) 2025-02-14 14:21:22 +11:00
ElectroJr
55571ef5b1 Version: 245.0.0 2025-02-14 16:11:50 +13:00
Leon Friedrich
afaef645b0 Fix MappingDataNode.TryAddCopy() (#5677) 2025-02-14 14:10:13 +11:00
Milon
d442d90d60 no more (#5676) 2025-02-13 01:41:42 -05:00
metalgearsloth
fea592e1d5 Version: 244.0.0 2025-02-12 13:31:03 +11:00
metalgearsloth
bb9517fd19 Check equatable on client-predicted BUI states (#5671) 2025-02-12 13:29:19 +11:00
metalgearsloth
a734bc50fa Avoid unnecessary UpdateState calls for BUIs (#5670) 2025-02-12 12:50:33 +11:00
metalgearsloth
9e9ac56c95 Bump physics speed cap (#5667) 2025-02-11 20:54:21 +11:00
metalgearsloth
6979a63b1e Add CreateWindowCenteredRight method (#5666) 2025-02-11 15:02:31 +11:00
metalgearsloth
ae7725aafe Add compreg methods to entitymanager (#5655) 2025-02-10 21:39:41 +11:00
metalgearsloth
1a7e490e4b Version: 243.0.1 2025-02-08 19:06:50 +11:00
metalgearsloth
51971d0994 Revert basewindow change (#5664) 2025-02-08 17:38:40 +11:00
Mohamed Dwidar
d2aa8ecb5a Fixing guidebook not resizable from left and right (#5618)
* Fixing guidebook not resizable from left and right

issue 34504 in space-wizards/space-station-14 needs this fix

* update fix guideBood not resizable

a safer and more error resistent solution to https://github.com/space-wizards/space-station-14/issues/34504

* Mask DragMode.Move

---------

Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
2025-02-08 17:14:08 +11:00
ScarKy0
c4a5752c2a Shared portion of PvsOverrideSystem to allow for usage in shared (#5651) 2025-02-04 12:23:42 -05:00
metalgearsloth
6a336d236b Version: 243.0.0 2025-02-04 00:25:15 +11:00
metalgearsloth
fc55c8e0d3 Add saved BUI positions (#5650) 2025-02-04 00:19:22 +11:00
metalgearsloth
2719b9f0c8 Tweak grid state slightly (#5644) 2025-02-04 00:15:36 +11:00
metalgearsloth
bd69d51d36 Version: 242.0.1 2025-02-02 12:29:24 +11:00
metalgearsloth
1bf0687671 Fix poly pooling (#5645) 2025-02-01 15:19:34 +11:00
Leon Friedrich
bdef9e3401 Fix reloading prototypes with AlwaysPushInheritance (#5612) 2025-01-31 15:38:13 +11:00
metalgearsloth
43648201ce Drop debug allocs a lot (#5638)
IDK why the lifestage one in particular ballooned my dotmemory one up in particular but it did; I would've thought if it's boxing the other ones would've shown up. Doesn't matter for release just QOL to drop allocs by more than half.
2025-01-30 05:07:57 +01:00
slarticodefast
2b2d08ba47 don't normalize direction vector when calling atan2 (#5641) 2025-01-30 12:07:34 +11:00
metalgearsloth
d7f6a9ba43 Version: 242.0.0 2025-01-29 23:45:59 +11:00
metalgearsloth
15f81751f7 Reduce lookup allocs significantly (#5639) 2025-01-29 23:43:20 +11:00
metalgearsloth
033c52751a MergeImplicitData fix (#5640) 2025-01-29 23:36:14 +11:00
Leon Friedrich
51edceae4d Ensure parents are always initialized & started before children (#5595)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2025-01-29 23:16:14 +11:00
ShadowCommander
5d7720755a Fix keyboard not focusing on search bar of the tile spawn window on open (#5630) 2025-01-29 22:48:59 +11:00
Leon Friedrich
acc7bf7595 Add support for overlays to draw controls (#5223)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2025-01-29 22:48:11 +11:00
Fildrance
de55d1bc52 fix: EntityPrototypeView now only creates entities when the UI is open
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2025-01-28 00:25:52 +11:00
metalgearsloth
d5e6e91b58 Make collisionwake resolve false (#5637) 2025-01-28 00:05:29 +11:00
metalgearsloth
da2bfdaa10 Version: 241.0.0 2025-01-27 21:31:31 +11:00
Leon Friedrich
af6cac14d6 Add CollisionPredictionTest (#5493)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2025-01-27 21:23:23 +11:00
Leon Friedrich
3f37846731 Avoid unnecessary DirtyField() calls (#5620) 2025-01-27 21:21:53 +11:00
metalgearsloth
d9bf1d1afb BUI deferral tweaks (#5503) 2025-01-27 21:04:27 +11:00
metalgearsloth
b9b80192e7 Minor contact QOL (#5560) 2025-01-27 16:20:04 +11:00
DrSmugleaf
e03aec47ef Fix component network generator not working for dicts with entityuid values but not keys 2025-01-21 19:09:22 -08:00
DrSmugleaf
ee906af16e Version: 240.1.2 2025-01-21 18:43:28 -08:00
wixoa
e205ae3627 Use the color arg when drawing a font character in world space (#5626) 2025-01-21 22:39:07 +01:00
Jerry
d818c5aa0c fix StatusHost RespondJsonAsync method (#5622) 2025-01-21 16:58:37 +01:00
ElectroJr
aa8fe8ac92 Version: 240.1.1 2025-01-20 14:16:39 +13:00
Leon Friedrich
4ba6687b9d Fix OverlayManager.RemoveOverlay (#5623) 2025-01-20 12:14:58 +11:00
ElectroJr
8f2817aa4e Version: 240.1.0 2025-01-20 13:04:19 +13:00
Leon Friedrich
89c7839fe2 Fix exception in DestroyContacts (#5619) 2025-01-19 16:25:58 +11:00
DrSmugleaf
9799132001 Make GamePrototypeLoadManager send a single message with all uploaded prototypes in a single message (#5616) 2025-01-19 11:49:27 +11:00
Milon
34ffa56c57 add AsNullable() extension method to Entity<T> (#5617)
* just works first try

* use a constructor instead
2025-01-18 20:52:18 +01:00
ElectroJr
f8410a4674 Version: 240.0.1 2025-01-18 16:54:03 +13:00
Leon Friedrich
43b991c690 Fix SharedBroadphaseSystem.GetBroadphases (#5615) 2025-01-18 14:37:54 +11:00
PJB3005
c463fc5e78 Make source generators emit EditorBrowsable(Never)
This hides the generated types from intellisense if you have the relevant option in Rider enabled.

Good because honestly these just bloat IntelliSense, and if you want to show them there's an IDE setting for it.
2025-01-18 01:23:35 +01:00
PJB3005
e21b3e069a Version: 240.0.0 2025-01-17 17:57:31 +01:00
PJB3005
c8f94ab40d Update release notes 2025-01-17 17:57:14 +01:00
Tornado Tech
2a882b5555 Moved Overlay sorting to OverlayManager (#5614)
* Moved Overlay sorting to OverlayManager

* Changed Add to AddRange
2025-01-17 17:47:13 +01:00
Leon Friedrich
32d8a1cba9 Misc grid state changes (#5597) 2025-01-17 17:07:09 +01:00
Leon Friedrich
5d84be9c78 Make ComponentRegistry not implement ISerializationContext (#5613) 2025-01-17 15:01:25 +01:00
PJB3005
eaaa70437a Reduce DynamicMethod use in Serv3
Data definitions created individual read/write methods for every single field that can be serialized. This was extremely inefficient and likely caused lots of overhead.

These methods are necessary because, in some cases, we can't directly use expression trees to write fields. But... we can still do it most of the time! So now for most data fields we can avoid a DynamicMethod entirely.
2025-01-16 15:10:35 +01:00
Leon Friedrich
448e8b0c2c Validate static EntProtoId<T> fields (#5593) 2025-01-16 10:36:47 +01:00
Leon Friedrich
42948d8f8e Fix autocompletion hint for toolshed strings (#5584)
* Fix autocompletion hint for toolshed strings

* Split functionality

* Remove combined flag
2025-01-16 10:30:42 +01:00
c4llv07e
039468f4b6 Add function to check if localization culture was already loaded. (#5603) 2025-01-16 10:28:15 +01:00
Leon Friedrich
6a3f88b1c6 Fix replay playback bugs (#5604)
* Sort replay entities

* Fix nameof(TState)

* I forgot to generate implicit states

* release notes
2025-01-16 10:26:53 +01:00
PJB3005
a314c5f797 Tickrate is now a ushort
Fixes #5592

This allows net.tickrate to be set to a max of 65535 instead of 255.

I didn't raise it fully to a uint because there are many places it's cast to an int, so uint would cause various compiler errors and compat issues I don't wanna deal with.
2025-01-16 01:13:50 +01:00
Pieter-Jan Briers
f7124cf755 Game goes in-game.
Viewport's pink though.
2023-06-13 00:26:40 +02:00
Pieter-Jan Briers
6679c31d4b Merge branch 'master' into 23-05-06-webgpu 2023-06-11 20:22:34 +02:00
Pieter-Jan Briers
8ed78975eb Merge branch 'master' into 23-05-06-webgpu 2023-06-02 20:51:15 +02:00
Pieter-Jan Briers
b423235a4c Do uniform pass data correctly.
So you can resize devwindow without it breaking.
2023-05-30 01:54:13 +02:00
Pieter-Jan Briers
27f7d9a8fb One more test for CeilingPowerOfTwo
Idk I wrote this as a sanity check. May as well commit it.
2023-05-30 01:52:03 +02:00
Pieter-Jan Briers
86a4253585 Make DebugClydePanel work again. 2023-05-30 01:20:17 +02:00
Pieter-Jan Briers
d8bb3cb896 Merge branch 'master' into 23-05-06-webgpu 2023-05-30 00:02:46 +02:00
Pieter-Jan Briers
26e4270312 Adapter properties and limits in devwindow 2023-05-29 16:37:06 +02:00
Pieter-Jan Briers
850b26b14d Dynamically expand vertex buffers in sprite batch. 2023-05-28 19:12:04 +02:00
Pieter-Jan Briers
db005b7ed9 Implement RhiBuffer.MapState
Needed this but didn't end up using it.
2023-05-28 18:54:29 +02:00
Pieter-Jan Briers
b8fbca251e Hardcode surface format for now 2023-05-27 01:14:51 +02:00
Pieter-Jan Briers
1cb2029e9d Minor changes
Clamp scissor rect in RenderHandle
Reset pass state in BeginPass()
Bit of constants
Increase temporary vertex buffer size.
2023-05-25 00:24:16 +02:00
Pieter-Jan Briers
e83affa97d Walter White falling over gif
It's my own project, I can shitpost in the commits
2023-05-24 00:17:24 +02:00
Pieter-Jan Briers
100dd2b66d Implement scissoring in SpriteBatch, general state framework 2023-05-24 00:12:30 +02:00
Pieter-Jan Briers
5e3ecfc4a7 Fix enum definitions for texture sampler modes.
Had wrong numeric values.
2023-05-23 23:34:56 +02:00
Pieter-Jan Briers
32dcf9a76e Explicit default WebGPU limits
In case we ever need to get the GLES3.0 backend working.
2023-05-23 23:34:56 +02:00
Pieter-Jan Briers
33bd0af9c1 Merge pull request #4 from 20kdc/wgpu-scissoring 2023-05-23 23:27:57 +02:00
20kdc
0213606c4b WebGPU: Scissoring (Rhi boilerplate ONLY)
THe actual meat of this PR got moved to a tag because of the issues, wgpu-scissoring-before-cut if you care
2023-05-23 18:07:38 +01:00
Pieter-Jan Briers
0a205640d9 Implement pixel snapping 2023-05-22 01:33:00 +02:00
Pieter-Jan Briers
3fd5d6a49f Make fonts work
Implement SetSubImage().
Make FontManager not rely on texture swizzle.
2023-05-22 00:55:44 +02:00
Pieter-Jan Briers
3f87700ca8 Handle window resizing 2023-05-22 00:26:55 +02:00
Pieter-Jan Briers
3467362236 Basic multi-window support 2023-05-22 00:18:32 +02:00
Pieter-Jan Briers
7f7294f0cc We can render some basic UI 2023-05-21 23:59:25 +02:00
Pieter-Jan Briers
747ffd75c3 WebGPU init improvements.
CVar for which API backend to use.
Respect power preference CVar.
Minor code cleanup.
Make code work on DX12 backend (fix shader issue)
2023-05-18 22:49:44 +02:00
Pieter-Jan Briers
1ccb636a33 I have learned how matrices work and they shall bow before me. 2023-05-18 21:39:25 +02:00
Pieter-Jan Briers
f4670562e5 Merge pull request #3 from 20kdc/wgpu-platform-support 2023-05-18 11:48:01 +02:00
20kdc
e122f69b91 Implement (untested) MacOS support
Not a MacOS user so I can't actually test this, but hopefully what goes wrong should be easy enough to correct.
2023-05-17 00:48:05 +01:00
20kdc
d87319c69b WebGPU: Implement X11 WSI setup support and try loading appropriate Linux/Mac dynamic libraries 2023-05-17 00:28:06 +01:00
Pieter-Jan Briers
99e8dc5927 I can batch sprites 2023-05-16 20:10:57 +02:00
Pieter-Jan Briers
9343fb78c9 Remove D3D11 RHI 2023-05-07 18:15:14 +02:00
Pieter-Jan Briers
d2feebc4c8 Have WebGPU trongle 2023-05-07 18:13:33 +02:00
Pieter-Jan Briers
0f51519f45 I can do D3D11 pink too 2023-05-06 23:24:42 +02:00
Pieter-Jan Briers
d634b25b87 Fix warnings from updating TerraFX 2023-05-06 15:19:37 +02:00
Pieter-Jan Briers
e2a3796ceb Update TerraFX 2023-05-06 15:17:15 +02:00
Pieter-Jan Briers
86c350119d I have pink 2023-05-06 15:14:37 +02:00
Pieter-Jan Briers
379971eaea Yeet all the OpenGL 2023-05-06 01:45:31 +02:00
1181 changed files with 47201 additions and 38986 deletions

View File

@@ -0,0 +1,34 @@
name: Build All Configurations
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build:
strategy:
matrix:
targetOS: [Windows, Linux, MacOS]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
with:
submodules: true
- name: Setup .NET
uses: actions/setup-dotnet@v4.1.0
with:
dotnet-version: 9.0.x
- name: Install dependencies
run: dotnet restore
- name: Build Debug
run: dotnet build --no-restore --configuration Debug /p:WarningsAsErrors=nullable /p:TargetOS=${{ matrix.targetOS }}
- name: Build Tools
run: dotnet build --no-restore --configuration Tools /p:WarningsAsErrors=nullable /p:TargetOS=${{ matrix.targetOS }}
- name: Build Release
run: dotnet build --no-restore --configuration Release /p:WarningsAsErrors=nullable /p:TargetOS=${{ matrix.targetOS }}

View File

@@ -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 }}

View File

@@ -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: |

View File

@@ -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.3" />
<PackageVersion Include="Robust.Natives.Zstd" Version="0.1.1-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,14 @@
<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.6" />
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.11" />
<PackageVersion Include="SpaceWizards.HttpListener" Version="0.1.1" />
<PackageVersion Include="SpaceWizards.NFluidsynth" Version="0.2.2" />
<PackageVersion Include="SpaceWizards.SharpFont" Version="1.0.2" />
<PackageVersion Include="SpaceWizards.Sdl" Version="1.0.0" />
<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" />

View File

@@ -1,4 +1,4 @@
<Project>
<!-- This file automatically reset by Tools/version.py -->
<!-- This file automatically reset by Tools/version.py -->

View File

@@ -28,5 +28,5 @@
<Import Project="Robust.Analyzers.targets" Condition="'$(SkipRobustAnalyzer)' != 'true'" />
<!-- serialization generator -->
<Import Project="Robust.Serialization.Generator.targets" Condition="'$(SkipRobustAnalyzer)' != 'true'" />
<Import Project="Robust.Serialization.Generator.targets" Condition="'$(SkipRobustAnalyzer)' != 'true' And '$(SkipRobustSerializationGenerator)' != 'true'" />
</Project>

View File

@@ -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. -->
@@ -71,6 +74,6 @@
</PropertyGroup>
<Exec
Condition="'$(_RobustUseExternalMSBuild)' == 'true'"
Command="&quot;$(DOTNET_HOST_PATH)&quot; msbuild /nodereuse:false $(MSBuildProjectFile) /t:CompileRobustXaml /p:_RobustForceInternalMSBuild=true /p:Configuration=$(Configuration) /p:RuntimeIdentifier=$(RuntimeIdentifier) /p:TargetFramework=$(TargetFramework) /p:BuildProjectReferences=false"/>
Command="&quot;$(DOTNET_HOST_PATH)&quot; msbuild /nodereuse:false $(MSBuildProjectFile) /t:CompileRobustXaml /p:_RobustForceInternalMSBuild=true /p:Configuration=$(Configuration) /p:RuntimeIdentifier=$(RuntimeIdentifier) /p:TargetFramework=$(TargetFramework) /p:BuildProjectReferences=false /p:IntermediateOutputPath=&quot;$(IntermediateOutputPath.TrimEnd('\'))/&quot;"/>
</Target>
</Project>

View File

@@ -1,18 +0,0 @@
//
// Cursor.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Opaque handle to a GLFW cursor.
/// </summary>
public struct Cursor
{
}
}

View File

@@ -1,33 +0,0 @@
//
// ClientApi.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// The context client APIs.
/// </summary>
/// <seealso cref="GLFW.WindowHint(WindowHintClientApi,ClientApi)"/>
public enum ClientApi
{
/// <summary>
/// No context API is created.
/// </summary>
NoApi = 0,
/// <summary>
/// OpenGL context is created.
/// </summary>
OpenGlApi = 0x00030001,
/// <summary>
/// OpenGL ES context is created.
/// </summary>
OpenGlEsApi = 0x00030002
}
}

View File

@@ -1,27 +0,0 @@
//
// ConnectedState.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Specifies connected state of devices.
/// </summary>
public enum ConnectedState
{
/// <summary>
/// Indicates that a device is connected.
/// </summary>
Connected = 0x00040001,
/// <summary>
/// Indicates that a device is disconnected.
/// </summary>
Disconnected = 0x00040002
}
}

View File

@@ -1,27 +0,0 @@
//
// ContextApi.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// The context API used to create the window context.
/// </summary>
public enum ContextApi
{
/// <summary>
/// Uses the native context API to create the window context.
/// </summary>
NativeContextApi = 0x00036001,
/// <summary>
/// Uses Egl to create the window context.
/// </summary>
EglContextApi = 0x00036002
}
}

View File

@@ -1,37 +0,0 @@
//
// CursorModeValue.cs
//
// Copyright (C) 2018 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// The GLFW cursor modes.
/// See <a href="https://www.glfw.org/docs/latest/input_guide.html#cursor_mode">cursor modes</a>.
/// </summary>
public enum CursorModeValue
{
/// <summary>
/// The regular arrow cursor (or another cursor set with <see cref="GLFW.SetCursor"/>) is used
/// and cursor motion is not limited.
/// </summary>
CursorNormal = 0x00034001,
/// <summary>
/// Hides the arrow cursor when over a window.
/// </summary>
CursorHidden = 0x00034002,
/// <summary>
/// Will hide the cursor and lock it to the specified window.
/// GLFW will then take care of all the details of cursor re-centering and offset calculation
/// and providing the application with a virtual cursor position.
/// This virtual position is provided normally via both the cursor position callback and through polling.
/// </summary>
CursorDisabled = 0x00034003
}
}

View File

@@ -1,47 +0,0 @@
//
// CursorShape.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Standard cursor shapes.
/// </summary>
public enum CursorShape
{
/// <summary>
/// The standard arrow shape. Used in almost all situations.
/// </summary>
Arrow = 0x00036001,
/// <summary>
/// The I-Beam shape. Used when mousing over a place where text can be entered.
/// </summary>
IBeam = 0x00036002,
/// <summary>
/// The crosshair shape. Used when dragging and dropping.
/// </summary>
Crosshair = 0x00036003,
/// <summary>
/// The hand shape. Used when mousing over something that can be dragged around.
/// </summary>
Hand = 0x00036004,
/// <summary>
/// The horizontal resize shape. Used when mousing over something that can be horizontally resized.
/// </summary>
HResize = 0x00036005,
/// <summary>
/// The vertical resize shape. Used when mousing over something that can be vertically resized.
/// </summary>
VResize = 0x00036006
}
}

View File

@@ -1,24 +0,0 @@
//
// CursorStateAttribute.cs
//
// Copyright (C) 2018 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Attribute for setting <see cref="CursorModeValue"/> of the cursor.
/// </summary>
/// <seealso cref="GLFW.SetInputMode(Window*,CursorStateAttribute,CursorModeValue)"/>
/// <seealso cref="GLFW.GetInputMode(Window*,CursorStateAttribute)"/>
public enum CursorStateAttribute
{
/// <summary>
/// Attribute for setting <see cref="CursorModeValue"/> of the cursor.
/// </summary>
Cursor = 0x00033001,
}
}

View File

@@ -1,103 +0,0 @@
//
// ErrorCode.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Error codes, used in the error callback.
/// </summary>
public enum ErrorCode
{
/// <summary>
/// Everything is running as intended. Yay!
/// </summary>
NoError = 0,
/// <summary>
/// Called a function before calling <see cref="GLFW.Init"/>. Initialize GLFW and then try again.
/// </summary>
NotInitialized = 0x00010001,
/// <summary>
/// No OpenGL/OpenGL ES context on this thread.
/// </summary>
NoContext = 0x00010002,
/// <summary>
/// Used an invalid enum value on a function.
/// </summary>
/// <remarks>
/// <para>
/// This should hopefully never happen in the bindings, due to the added type safety of C# enums VS. GLFW's native #defines
/// </para>
/// </remarks>
InvalidEnum = 0x00010003,
/// <summary>
/// Called a function with an invalid argument.
/// </summary>
/// <remarks>
/// <para>
/// This can happen if you request an OpenGL version that doesn't exist, like 2.7.
/// </para>
/// <para>
/// If you request a version of OpenGL that exists, but isn't supported by this graphics card, it will return VersionUnavailable instead.
/// </para>
/// </remarks>
InvalidValue = 0x00010004,
/// <summary>
/// A memory allocation failed on GLFW's end.
/// </summary>
/// <remarks>
/// <para>
/// Report this to the GLFW issue tracker if encountered.
/// </para>
/// </remarks>
OutOfMemory = 0x00010005,
/// <summary>
/// The requested API is not available on the system.
/// </summary>
ApiUnavailable = 0x00010006,
/// <summary>
/// The requested OpenGL version is not available on the system.
/// </summary>
VersionUnavailable = 0x00010007,
/// <summary>
/// A platform-specific error occurred that doesn't fit into any more specific category.
/// </summary>
/// <remarks>
/// <para>
/// Report this to the GLFW issue tracker if encountered.
/// </para>
/// </remarks>
PlatformError = 0x00010008,
/// <summary>
/// The requested format is unavailable.
/// </summary>
/// <remarks>
/// <para>
/// If emitted during window creation, the requested pixel format isn't available.
/// </para>
/// <para>
/// If emitted when using the clipboard, the contents of the clipboard couldn't be converted to the requested format.
/// </para>
/// </remarks>
FormatUnavailable = 0x00010009,
/// <summary>
/// There is no OpenGL/OpenGL ES context attached to this window.
/// </summary>
NoWindowContext = 0x0001000A
}
}

View File

@@ -1,46 +0,0 @@
//
// InitHint.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Initialization hints are set before <see cref="GLFW.Init"/> and affect how the library behaves until termination.
/// Hints are set with <see cref="GLFW.InitHint(InitHintBool, bool)"/>.
/// </summary>
public enum InitHintBool
{
/// <summary>
/// Used to specify whether to also expose joystick hats as buttons,
/// for compatibility with earlier versions of GLFW that did not have
/// <see cref="GLFW.GetJoystickHats"/>.
/// Set this with <see cref="GLFW.InitHint(InitHintBool, bool)"/>.
/// </summary>
JoystickHatButtons = 0x00050001,
/// <summary>
/// Used to specify whether to set the current directory to the application to the Contents/Resources
/// subdirectory of the application's bundle, if present.
/// Set this with <see cref="GLFW.InitHint(InitHintBool, bool)"/>.
/// </summary>
/// <remarks>
/// Only affects macOS; no effect on other platforms.
/// </remarks>
CocoaChdirResources = 0x00051001,
/// <summary>
/// Used to specify whether to create a basic menu bar, either from a nib or manually,
/// when the first window is created, which is when AppKit is initialized.
/// Set this with <see cref="GLFW.InitHint(InitHintBool, bool)"/>.
/// </summary>
/// <remarks>
/// Only affects macOS; no effect on other platforms.
/// </remarks>
CocoaMenubar = 0x00051002
}
}

View File

@@ -1,15 +0,0 @@
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Initialization hints are set before <see cref="GLFW.Init"/> and affect how the library behaves until termination.
/// Hints are set with <see cref="GLFW.InitHint(InitHintInt, int)"/>.
/// </summary>
/// <remarks>
/// While this enum has no members,
/// it can still be useful because it allows you to access the direct <c>glfwInitHint(int, int)</c> API.
/// In case a future version of GLFW adds an int-taking int hint and we don't handle it.
/// </remarks>
public enum InitHintInt
{
}
}

View File

@@ -1,33 +0,0 @@
//
// InputAction.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Defines event information for <see cref="GLFWCallbacks.KeyCallback"/>
/// or <see cref="GLFWCallbacks.MouseButtonCallback"/>.
/// </summary>
public enum InputAction : byte
{
/// <summary>
/// The key or mouse button was released.
/// </summary>
Release = 0,
/// <summary>
/// The key or mouse button was pressed.
/// </summary>
Press = 1,
/// <summary>
/// The key was held down until it repeated.
/// </summary>
Repeat = 2
}
}

View File

@@ -1,53 +0,0 @@
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Status of a joystick hat.
/// </summary>
public enum JoystickHats : byte
{
/// <summary>
/// Hat is centered.
/// </summary>
Centered = 0,
/// <summary>
/// Hat is pointing up.
/// </summary>
Up = 1,
/// <summary>
/// Hat is pointing right.
/// </summary>
Right = 2,
/// <summary>
/// Hat is pointing down.
/// </summary>
Down = 4,
/// <summary>
/// Hat is pointing left.
/// </summary>
Left = 8,
/// <summary>
/// Hat is pointing up and to the right.
/// </summary>
RightUp = Right | Up,
/// <summary>
/// Hat is pointing down and to the right.
/// </summary>
RightDown = Right | Down,
/// <summary>
/// Hat is pointing up and to the left.
/// </summary>
LeftUp = Left | Up,
/// <summary>
/// Hat is pointing down and to the left.
/// </summary>
LeftDown = Left | Down,
}
}

View File

@@ -1,50 +0,0 @@
//
// KeyModifiers.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
using System;
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Key modifiers, such as Shift or CTRL.
/// </summary>
[Flags]
public enum KeyModifiers : byte
{
/// <summary>
/// if one or more Shift keys were held down.
/// </summary>
Shift = 0x0001,
/// <summary>
/// If one or more Control keys were held down.
/// </summary>
Control = 0x0002,
/// <summary>
/// If one or more Alt keys were held down.
/// </summary>
Alt = 0x0004,
/// <summary>
/// If one or more Super keys were held down.
/// </summary>
Super = 0x0008,
/// <summary>
/// If caps lock is enabled.
/// </summary>
CapsLock = 0x0010,
/// <summary>
/// If num lock is enabled.
/// </summary>
NumLock = 0x0020,
}
}

View File

@@ -1,627 +0,0 @@
//
// Keys.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Specifies key codes and modifiers in US keyboard layout.
/// </summary>
public enum Keys : short
{
/// <summary>
/// An unknown key.
/// </summary>
Unknown = -1,
/// <summary>
/// The spacebar key.
/// </summary>
Space = 32,
/// <summary>
/// The apostrophe key.
/// </summary>
Apostrophe = 39 /* ' */,
/// <summary>
/// The comma key.
/// </summary>
Comma = 44 /* , */,
/// <summary>
/// The minus key.
/// </summary>
Minus = 45 /* - */,
/// <summary>
/// The period key.
/// </summary>
Period = 46 /* . */,
/// <summary>
/// The slash key.
/// </summary>
Slash = 47 /* / */,
/// <summary>
/// The 0 key.
/// </summary>
D0 = 48,
/// <summary>
/// The 1 key.
/// </summary>
D1 = 49,
/// <summary>
/// The 2 key.
/// </summary>
D2 = 50,
/// <summary>
/// The 3 key.
/// </summary>
D3 = 51,
/// <summary>
/// The 4 key.
/// </summary>
D4 = 52,
/// <summary>
/// The 5 key.
/// </summary>
D5 = 53,
/// <summary>
/// The 6 key.
/// </summary>
D6 = 54,
/// <summary>
/// The 7 key.
/// </summary>
D7 = 55,
/// <summary>
/// The 8 key.
/// </summary>
D8 = 56,
/// <summary>
/// The 9 key.
/// </summary>
D9 = 57,
/// <summary>
/// The semicolon key.
/// </summary>
Semicolon = 59 /* ; */,
/// <summary>
/// The equal key.
/// </summary>
Equal = 61 /* = */,
/// <summary>
/// The A key.
/// </summary>
A = 65,
/// <summary>
/// The B key.
/// </summary>
B = 66,
/// <summary>
/// The C key.
/// </summary>
C = 67,
/// <summary>
/// The D key.
/// </summary>
D = 68,
/// <summary>
/// The E key.
/// </summary>
E = 69,
/// <summary>
/// The F key.
/// </summary>
F = 70,
/// <summary>
/// The G key.
/// </summary>
G = 71,
/// <summary>
/// The H key.
/// </summary>
H = 72,
/// <summary>
/// The I key.
/// </summary>
I = 73,
/// <summary>
/// The J key.
/// </summary>
J = 74,
/// <summary>
/// The K key.
/// </summary>
K = 75,
/// <summary>
/// The L key.
/// </summary>
L = 76,
/// <summary>
/// The M key.
/// </summary>
M = 77,
/// <summary>
/// The N key.
/// </summary>
N = 78,
/// <summary>
/// The O key.
/// </summary>
O = 79,
/// <summary>
/// The P key.
/// </summary>
P = 80,
/// <summary>
/// The Q key.
/// </summary>
Q = 81,
/// <summary>
/// The R key.
/// </summary>
R = 82,
/// <summary>
/// The S key.
/// </summary>
S = 83,
/// <summary>
/// The T key.
/// </summary>
T = 84,
/// <summary>
/// The U key.
/// </summary>
U = 85,
/// <summary>
/// The V key.
/// </summary>
V = 86,
/// <summary>
/// The W key.
/// </summary>
W = 87,
/// <summary>
/// The X key.
/// </summary>
X = 88,
/// <summary>
/// The Y key.
/// </summary>
Y = 89,
/// <summary>
/// The Z key.
/// </summary>
Z = 90,
/// <summary>
/// The left bracket(opening bracket) key.
/// </summary>
LeftBracket = 91 /* [ */,
/// <summary>
/// The backslash.
/// </summary>
Backslash = 92 /* \ */,
/// <summary>
/// The right bracket(closing bracket) key.
/// </summary>
RightBracket = 93 /* ] */,
/// <summary>
/// The grave accent key.
/// </summary>
GraveAccent = 96 /* ` */,
/// <summary>
/// Non US keyboard layout key 1.
/// </summary>
World1 = 161 /* non-US #1 */,
/// <summary>
/// Non US keyboard layout key 2.
/// </summary>
World2 = 162 /* non-US #2 */,
/// <summary>
/// The escape key.
/// </summary>
Escape = 256,
/// <summary>
/// The enter key.
/// </summary>
Enter = 257,
/// <summary>
/// The tab key.
/// </summary>
Tab = 258,
/// <summary>
/// The backspace key.
/// </summary>
Backspace = 259,
/// <summary>
/// The insert key.
/// </summary>
Insert = 260,
/// <summary>
/// The delete key.
/// </summary>
Delete = 261,
/// <summary>
/// The right arrow key.
/// </summary>
Right = 262,
/// <summary>
/// The left arrow key.
/// </summary>
Left = 263,
/// <summary>
/// The down arrow key.
/// </summary>
Down = 264,
/// <summary>
/// The up arrow key.
/// </summary>
Up = 265,
/// <summary>
/// The page up key.
/// </summary>
PageUp = 266,
/// <summary>
/// The page down key.
/// </summary>
PageDown = 267,
/// <summary>
/// The home key.
/// </summary>
Home = 268,
/// <summary>
/// The end key.
/// </summary>
End = 269,
/// <summary>
/// The caps lock key.
/// </summary>
CapsLock = 280,
/// <summary>
/// The scroll lock key.
/// </summary>
ScrollLock = 281,
/// <summary>
/// The num lock key.
/// </summary>
NumLock = 282,
/// <summary>
/// The print screen key.
/// </summary>
PrintScreen = 283,
/// <summary>
/// The pause key.
/// </summary>
Pause = 284,
/// <summary>
/// The F1 key.
/// </summary>
F1 = 290,
/// <summary>
/// The F2 key.
/// </summary>
F2 = 291,
/// <summary>
/// The F3 key.
/// </summary>
F3 = 292,
/// <summary>
/// The F4 key.
/// </summary>
F4 = 293,
/// <summary>
/// The F5 key.
/// </summary>
F5 = 294,
/// <summary>
/// The F6 key.
/// </summary>
F6 = 295,
/// <summary>
/// The F7 key.
/// </summary>
F7 = 296,
/// <summary>
/// The F8 key.
/// </summary>
F8 = 297,
/// <summary>
/// The F9 key.
/// </summary>
F9 = 298,
/// <summary>
/// The F10 key.
/// </summary>
F10 = 299,
/// <summary>
/// The F11 key.
/// </summary>
F11 = 300,
/// <summary>
/// The F12 key.
/// </summary>
F12 = 301,
/// <summary>
/// The F13 key.
/// </summary>
F13 = 302,
/// <summary>
/// The F14 key.
/// </summary>
F14 = 303,
/// <summary>
/// The F15 key.
/// </summary>
F15 = 304,
/// <summary>
/// The F16 key.
/// </summary>
F16 = 305,
/// <summary>
/// The F17 key.
/// </summary>
F17 = 306,
/// <summary>
/// The F18 key.
/// </summary>
F18 = 307,
/// <summary>
/// The F19 key.
/// </summary>
F19 = 308,
/// <summary>
/// The F20 key.
/// </summary>
F20 = 309,
/// <summary>
/// The F21 key.
/// </summary>
F21 = 310,
/// <summary>
/// The F22 key.
/// </summary>
F22 = 311,
/// <summary>
/// The F23 key.
/// </summary>
F23 = 312,
/// <summary>
/// The F24 key.
/// </summary>
F24 = 313,
/// <summary>
/// The F25 key.
/// </summary>
F25 = 314,
/// <summary>
/// The 0 key on the key pad.
/// </summary>
KeyPad0 = 320,
/// <summary>
/// The 1 key on the key pad.
/// </summary>
KeyPad1 = 321,
/// <summary>
/// The 2 key on the key pad.
/// </summary>
KeyPad2 = 322,
/// <summary>
/// The 3 key on the key pad.
/// </summary>
KeyPad3 = 323,
/// <summary>
/// The 4 key on the key pad.
/// </summary>
KeyPad4 = 324,
/// <summary>
/// The 5 key on the key pad.
/// </summary>
KeyPad5 = 325,
/// <summary>
/// The 6 key on the key pad.
/// </summary>
KeyPad6 = 326,
/// <summary>
/// The 7 key on the key pad.
/// </summary>
KeyPad7 = 327,
/// <summary>
/// The 8 key on the key pad.
/// </summary>
KeyPad8 = 328,
/// <summary>
/// The 9 key on the key pad.
/// </summary>
KeyPad9 = 329,
/// <summary>
/// The decimal key on the key pad.
/// </summary>
KeyPadDecimal = 330,
/// <summary>
/// The divide key on the key pad.
/// </summary>
KeyPadDivide = 331,
/// <summary>
/// The multiply key on the key pad.
/// </summary>
KeyPadMultiply = 332,
/// <summary>
/// The subtract key on the key pad.
/// </summary>
KeyPadSubtract = 333,
/// <summary>
/// The add key on the key pad.
/// </summary>
KeyPadAdd = 334,
/// <summary>
/// The enter key on the key pad.
/// </summary>
KeyPadEnter = 335,
/// <summary>
/// The equal key on the key pad.
/// </summary>
KeyPadEqual = 336,
/// <summary>
/// The left shift key.
/// </summary>
LeftShift = 340,
/// <summary>
/// The left control key.
/// </summary>
LeftControl = 341,
/// <summary>
/// The left alt key.
/// </summary>
LeftAlt = 342,
/// <summary>
/// The left super key.
/// </summary>
LeftSuper = 343,
/// <summary>
/// The right shift key.
/// </summary>
RightShift = 344,
/// <summary>
/// The right control key.
/// </summary>
RightControl = 345,
/// <summary>
/// The right alt key.
/// </summary>
RightAlt = 346,
/// <summary>
/// The right super key.
/// </summary>
RightSuper = 347,
/// <summary>
/// The menu key.
/// </summary>
Menu = 348,
/// <summary>
/// The last valid key in this enum.
/// </summary>
LastKey = Menu
}
}

View File

@@ -1,68 +0,0 @@
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Specifies the buttons of a mouse.
/// </summary>
public enum MouseButton : byte
{
/// <summary>
/// The first button.
/// </summary>
Button1 = 0,
/// <summary>
/// The second button.
/// </summary>
Button2 = 1,
/// <summary>
/// The third button.
/// </summary>
Button3 = 2,
/// <summary>
/// The fourth button.
/// </summary>
Button4 = 3,
/// <summary>
/// The fifth button.
/// </summary>
Button5 = 4,
/// <summary>
/// The sixth button.
/// </summary>
Button6 = 5,
/// <summary>
/// The seventh button.
/// </summary>
Button7 = 6,
/// <summary>
/// The eighth button.
/// </summary>
Button8 = 7,
/// <summary>
/// The left mouse button. This corresponds to <see cref="Button1"/>.
/// </summary>
Left = Button1,
/// <summary>
/// The right mouse button. This corresponds to <see cref="Button2"/>.
/// </summary>
Right = Button2,
/// <summary>
/// The middle mouse button. This corresponds to <see cref="Button3"/>.
/// </summary>
Middle = Button3,
/// <summary>
/// The highest mouse button available.
/// </summary>
Last = Button8,
}
}

View File

@@ -1,32 +0,0 @@
//
// OpenGlProfile.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// The OpenGL context profiles.
/// </summary>
public enum OpenGlProfile
{
/// <summary>
/// Used for unknown OpenGL profile or OpenGL ES.
/// </summary>
Any = 0,
/// <summary>
/// Known OpenGL Core profile.
/// </summary>
Core = 0x00032001,
/// <summary>
/// Known OpenGL compatibility profile.
/// </summary>
Compat = 0x00032002
}
}

View File

@@ -1,33 +0,0 @@
//
// ReleaseBehavior.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// The context release behaviors.
/// </summary>
/// <seealso cref="GLFW.WindowHint(WindowHintReleaseBehavior,ReleaseBehavior)"/>
public enum ReleaseBehavior
{
/// <summary>
/// Use the default release behavior of the platform.
/// </summary>
Any = 0,
/// <summary>
/// The pipeline will be flushed whenever the context is released from being the current one.
/// </summary>
Flush = 0x00035001,
/// <summary>
/// The pipeline will not be flushed on release.
/// </summary>
None = 0x00035002
}
}

View File

@@ -1,32 +0,0 @@
//
// Robustness.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// OpenGL context robustness strategy.
/// </summary>
public enum Robustness
{
/// <summary>
/// No context robustness strategy.
/// </summary>
NoRobustness = 0,
/// <summary>
/// Robust context without a reset notification.
/// </summary>
NoResetNotification = 0x00031001,
/// <summary>
/// Lose context on reset.
/// </summary>
LoseContextOnReset = 0x00031002
}
}

View File

@@ -1,29 +0,0 @@
//
// StickyAttributes.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Attributes related to sticky keys and buttons.
/// </summary>
/// <seealso cref="GLFW.SetInputMode(Window*,StickyAttributes,bool)"/>
/// <seealso cref="GLFW.GetInputMode(Window*,StickyAttributes)"/>
public enum StickyAttributes
{
/// <summary>
/// Specify whether keyboard input should be sticky or not.
/// </summary>
StickyKeys = 0x00033002,
/// <summary>
/// Specify whether mouse button input should be sticky or not.
/// </summary>
StickyMouseButtons = 0x00033003
}
}

View File

@@ -1,96 +0,0 @@
//
// WindowAttributeSetter.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Used to get window related attributes.
/// </summary>
/// <seealso cref="GLFW.GetWindowAttrib"/>
public enum WindowAttributeGetter
{
/// <summary>
/// Indicates whether the specified window has input focus.
/// Initial input focus is controlled by the window hint with the same name
/// </summary>
Focused = WindowHintBool.Focused,
/// <summary>
/// Indicates whether the specified window is iconified,
/// whether by the user or with <see cref="GLFW.IconifyWindow"/>.
/// </summary>
Iconified = WindowHintBool.Iconified,
/// <summary>
/// Indicates whether the specified window is resizable by the user.
/// This is set on creation with the window hint with the same name.
/// </summary>
Resizable = WindowHintBool.Resizable,
/// <summary>
/// Indicates whether the specified window is visible.
/// Window visibility can be controlled with <see cref="GLFW.ShowWindow"/> and <see cref="GLFW.HideWindow"/>
/// and initial visibility is controlled by the window hint with the same name.
/// </summary>
Visible = WindowHintBool.Visible,
/// <summary>
/// Indicates whether the specified window has decorations such as a border,a close widget, etc.
/// This is set on creation with the window hint with the same name.
/// </summary>
Decorated = WindowHintBool.Decorated,
/// <summary>
/// Specifies whether the full screen window will automatically iconify and restore
/// the previous video mode on input focus loss.
/// Possible values are <c>true</c> and <c>false</c>. This hint is ignored for windowed mode windows.
/// </summary>
AutoIconify = WindowHintBool.AutoIconify,
/// <summary>
/// Indicates whether the specified window is floating, also called topmost or always-on-top.
/// This is controlled by the window hint with the same name.
/// </summary>
Floating = WindowHintBool.Floating,
/// <summary>
/// Indicates whether the specified window is maximized,
/// whether by the user or with <see cref="GLFW.MaximizeWindow"/>.
/// </summary>
Maximized = WindowHintBool.Maximized,
/// <summary>
/// Specifies whether the cursor should be centered over newly created full screen windows.
/// Possible values are <c>true</c> and <c>false</c>. This hint is ignored for windowed mode windows.
/// </summary>
CenterCursor = WindowHintBool.CenterCursor,
/// <summary>
/// Specifies whether the window framebuffer will be transparent.
/// If enabled and supported by the system, the window framebuffer alpha channel will be used
/// to combine the framebuffer with the background.
/// This does not affect window decorations. Possible values are <c>true</c> and <c>false</c>.
/// </summary>
TransparentFramebuffer = WindowHintBool.TransparentFramebuffer,
/// <summary>
/// indicates whether the cursor is currently directly over the client area of the window,
/// with no other windows between.
/// See <a href="https://www.glfw.org/docs/3.3/input_guide.html#cursor_enter">Cursor enter/leave events</a>
/// for details.
/// </summary>
Hovered = WindowHintBool.Hovered,
/// <summary>
/// Specifies whether the window will be given input focus when <see cref="GLFW.ShowWindow"/> is called.
/// Possible values are <c>true</c> and <c>false</c>.
/// </summary>
FocusOnShow = WindowHintBool.FocusOnShow,
}
}

View File

@@ -1,49 +0,0 @@
//
// WindowAttributeSetter.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Used to set window related attributes.
/// </summary>
/// <seealso cref="GLFW.SetWindowAttrib"/>
public enum WindowAttributeSetter
{
/// <summary>
/// Indicates whether the specified window is resizable by the user.
/// This is set on creation with the window hint with the same name.
/// </summary>
Resizable = WindowHintBool.Resizable,
/// <summary>
/// Indicates whether the specified window has decorations such as a border,a close widget, etc.
/// This is set on creation with the window hint with the same name.
/// </summary>
Decorated = WindowHintBool.Decorated,
/// <summary>
/// Specifies whether the full screen window will automatically iconify and restore
/// the previous video mode on input focus loss.
/// Possible values are <c>true</c> and <c>false</c>. This hint is ignored for windowed mode windows.
/// </summary>
AutoIconify = WindowHintBool.AutoIconify,
/// <summary>
/// Indicates whether the specified window is floating, also called topmost or always-on-top.
/// This is controlled by the window hint with the same name.
/// </summary>
Floating = WindowHintBool.Floating,
/// <summary>
/// Specifies whether the window will be given input focus when <see cref="GLFW.ShowWindow"/> is called.
/// Possible values are <c>true</c> and <c>false</c>.
/// </summary>
FocusOnShow = WindowHintBool.FocusOnShow
}
}

View File

@@ -1,135 +0,0 @@
//
// WindowHintBool.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Context related boolean attributes.
/// </summary>
/// <seealso cref="GLFW.WindowHint(WindowHintBool,bool)"/>
public enum WindowHintBool
{
/// <summary>
/// Indicates whether the specified window has input focus.
/// Initial input focus is controlled by the window hint with the same name
/// </summary>
Focused = 0x00020001,
/// <summary>
/// Indicates whether the specified window is iconified,
/// whether by the user or with <see cref="GLFW.IconifyWindow"/>.
/// </summary>
Iconified = 0x00020002,
/// <summary>
/// Indicates whether the specified window is resizable by the user.
/// This is set on creation with the window hint with the same name.
/// </summary>
Resizable = 0x00020003,
/// <summary>
/// Indicates whether the specified window is visible.
/// Window visibility can be controlled with <see cref="GLFW.ShowWindow"/> and <see cref="GLFW.HideWindow"/>
/// and initial visibility is controlled by the window hint with the same name.
/// </summary>
Visible = 0x00020004,
/// <summary>
/// Indicates whether the specified window has decorations such as a border,a close widget, etc.
/// This is set on creation with the window hint with the same name.
/// </summary>
Decorated = 0x00020005,
/// <summary>
/// Specifies whether the full screen window will automatically iconify and restore
/// the previous video mode on input focus loss.
/// Possible values are <c>true</c> and <c>false</c>. This hint is ignored for windowed mode windows.
/// </summary>
AutoIconify = 0x00020006,
/// <summary>
/// Indicates whether the specified window is floating, also called topmost or always-on-top.
/// This is controlled by the window hint with the same name.
/// </summary>
Floating = 0x00020007,
/// <summary>
/// Indicates whether the specified window is maximized,
/// whether by the user or with <see cref="GLFW.MaximizeWindow"/>.
/// </summary>
Maximized = 0x00020008,
/// <summary>
/// Specifies whether the cursor should be centered over newly created full screen windows.
/// Possible values are <c>true</c> and <c>false</c>. This hint is ignored for windowed mode windows.
/// </summary>
CenterCursor = 0x00020009,
/// <summary>
/// Specifies whether the window framebuffer will be transparent.
/// If enabled and supported by the system, the window framebuffer alpha channel will be used
/// to combine the framebuffer with the background.
/// This does not affect window decorations. Possible values are <c>true</c> and <c>false</c>.
/// </summary>
TransparentFramebuffer = 0x0002000A,
/// <summary>
/// Indicates whether the cursor is currently directly over the client area of the window,
/// with no other windows between.
/// See <a href="https://www.glfw.org/docs/3.3/input_guide.html#cursor_enter">Cursor enter/leave events</a>
/// for details.
/// </summary>
Hovered = 0x0002000B,
/// <summary>
/// Specifies whether the window will be given input focus when <see cref="GLFW.ShowWindow"/> is called.
/// Possible values are <c>true</c> and <c>false</c>.
/// </summary>
FocusOnShow = 0x0002000C,
/// <summary>
/// Specifies whether the window's context is an OpenGL forward-compatible one.
/// Possible values are <c>true</c> and <c>false</c>.
/// </summary>
OpenGLForwardCompat = 0x00022006,
/// <summary>
/// Specifies whether the window's context is an OpenGL debug context.
/// Possible values are <c>true</c> and <c>false</c>.
/// </summary>
OpenGLDebugContext = 0x00022007,
/// <summary>
/// Specifies whether errors should be generated by the context.
/// If enabled, situations that would have generated errors instead cause undefined behavior.
/// </summary>
ContextNoError = 0x0002200A,
/// <summary>
/// Specifies whether to use stereoscopic rendering. This is a hard constraint.
/// </summary>
Stereo = 0x0002100C,
/// <summary>
/// Specifies whether the framebuffer should be double buffered.
/// You nearly always want to use double buffering. This is a hard constraint.
/// </summary>
DoubleBuffer = 0x00021010,
/// <summary>
/// Specifies whether the framebuffer should be sRGB capable.
/// If supported, a created OpenGL context will support the
/// <c>GL_FRAMEBUFFER_SRGB</c> enable( also called <c>GL_FRAMEBUFFER_SRGB_EXT</c>)
/// for controlling sRGB rendering and a created OpenGL ES context will always have sRGB rendering enabled.
/// </summary>
SrgbCapable = 0x0002100E,
ScaleToMonitor = 0x0002200C,
}
}

View File

@@ -1,26 +0,0 @@
//
// WindowHintClientApi.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Context related client API attribute.
/// </summary>
/// <seealso cref="GLFW.WindowHint(WindowHintClientApi,ClientApi)"/>
public enum WindowHintClientApi
{
/// <summary>
/// Indicates the client API provided by the window's context;
/// either <see cref="GraphicsLibraryFramework.ClientApi.OpenGlApi"/>,
/// <see cref="GraphicsLibraryFramework.ClientApi.OpenGlEsApi"/> or
/// <see cref="GraphicsLibraryFramework.ClientApi.NoApi"/>.
/// </summary>
ClientApi = 0x00022001,
}
}

View File

@@ -1,24 +0,0 @@
//
// WindowHintContextApi.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Used to specify the context creation API.
/// </summary>
/// <seealso cref="GLFW.WindowHint(WindowHintContextApi,ContextApi)"/>
public enum WindowHintContextApi
{
/// <summary>
/// Indicates the context creation API used to create the window's context;
/// either <see cref="ContextApi.NativeContextApi"/> or <see cref="ContextApi.EglContextApi"/>.
/// </summary>
ContextCreationApi = 0x0002200B,
}
}

View File

@@ -1,117 +0,0 @@
//
// WindowHintInt.cs
//
// Copyright (C) 2018 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Context related attributes.
/// </summary>
/// <seealso cref="GLFW.WindowHint(WindowHintInt,int)"/>
public enum WindowHintInt
{
/// <summary>
/// Indicate the client API version(major part) of the window's context.
/// </summary>
ContextVersionMajor = 0x00022002,
/// <summary>
/// Indicate the client API version(minor part) of the window's context.
/// </summary>
ContextVersionMinor = 0x00022003,
/// <summary>
/// Indicate the client API version(revision part) of the window's context.
/// </summary>
ContextRevision = 0x00022004,
/// <summary>
/// Specify the desired bit depths of the red component of the default framebuffer.
/// <see cref="GLFW.DontCare"/> means the application has no preference.
/// </summary>
RedBits = 0x00021001,
/// <summary>
/// Specify the desired bit depths of the green component of the default framebuffer.
/// <see cref="GLFW.DontCare"/> means the application has no preference.
/// </summary>
GreenBits = 0x00021002,
/// <summary>
/// Specify the desired bit depths of the blue component of the default framebuffer.
/// <see cref="GLFW.DontCare"/> means the application has no preference.
/// </summary>
BlueBits = 0x00021003,
/// <summary>
/// Specify the desired bit depths of the alpha component of the default framebuffer.
/// <see cref="GLFW.DontCare"/> means the application has no preference.
/// </summary>
AlphaBits = 0x00021004,
/// <summary>
/// Specify the desired bit depths of the depth component of the default framebuffer.
/// <see cref="GLFW.DontCare"/> means the application has no preference.
/// </summary>
DepthBits = 0x00021005,
/// <summary>
/// Specify the desired bit depths of the stencil component of the default framebuffer.
/// <see cref="GLFW.DontCare"/> means the application has no preference.
/// </summary>
StencilBits = 0x00021006,
/// <summary>
/// Specify the desired bit depths of the red component of the accumulation buffer.
/// <see cref="GLFW.DontCare"/> means the application has no preference.
/// </summary>
/// <remarks>Accumulation buffers are a legacy OpenGL feature and should not be used in new code.</remarks>
AccumRedBits = 0x00021007,
/// <summary>
/// Specify the desired bit depths of the green component of the accumulation buffer.
/// <see cref="GLFW.DontCare"/> means the application has no preference.
/// </summary>
/// <remarks>Accumulation buffers are a legacy OpenGL feature and should not be used in new code.</remarks>
AccumGreenBits = 0x00021008,
/// <summary>
/// Specify the desired bit depths of the blue component of the accumulation buffer.
/// <see cref="GLFW.DontCare"/> means the application has no preference.
/// </summary>
/// <remarks>Accumulation buffers are a legacy OpenGL feature and should not be used in new code.</remarks>
AccumBlueBits = 0x00021009,
/// <summary>
/// Specify the desired bit depths of the alpha component of the accumulation buffer.
/// <see cref="GLFW.DontCare"/> means the application has no preference.
/// </summary>
/// <remarks>Accumulation buffers are a legacy OpenGL feature and should not be used in new code.</remarks>
AccumAlphaBits = 0x0002100A,
/// <summary>
/// Specifies the desired number of auxiliary buffers.
/// <see cref="GLFW.DontCare"/> means the application has no preference.
/// </summary>
/// <remarks>Auxiliary buffers are a legacy OpenGL feature and should not be used in new code.</remarks>
AuxBuffers = 0x0002100B,
/// <summary>
/// Specifies the desired number of samples to use for multisampling. Zero disables multisampling.
/// <see cref="GLFW.DontCare"/> means the application has no preference.
/// </summary>
Samples = 0x0002100D,
/// <summary>
/// Specifies the desired refresh rate for full screen windows.
/// If set to <see cref="GLFW.DontCare"/>,
/// the highest available refresh rate will be used. This hint is ignored for windowed mode windows.
/// </summary>
RefreshRate = 0x0002100F,
}
}

View File

@@ -1,29 +0,0 @@
//
// WindowHintOpenGlProfile.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Used to set the OpenGlProfile attribute.
/// </summary>
/// <seealso cref="GLFW.WindowHint(WindowHintOpenGlProfile,OpenGlProfile)"/>
public enum WindowHintOpenGlProfile
{
/// <summary>
/// Indicates the OpenGL profile used by the context.
/// This is <see cref="GraphicsLibraryFramework.OpenGlProfile.Core"/>
/// or <see cref="GraphicsLibraryFramework.OpenGlProfile.Compat"/>
/// if the context uses a known profile, or <see cref="GraphicsLibraryFramework.OpenGlProfile.Any"/>
/// if the OpenGL profile is unknown or the context is an OpenGL ES context.
/// Note that the returned profile may not match the profile bits of the context flags,
/// as GLFW will try other means of detecting the profile when no bits are set. TODO: enum for missing crefs
/// </summary>
OpenGlProfile = 0x00022008,
}
}

View File

@@ -1,30 +0,0 @@
//
// WindowHintReleaseBehavior.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Used to specify the release behavior used by the local context.
/// </summary>
/// <seealso cref="GLFW.WindowHint(WindowHintReleaseBehavior,ReleaseBehavior)"/>
public enum WindowHintReleaseBehavior
{
/// <summary>
/// Specifies the release behavior to be used by the context.
/// Possible values are one of <see cref="ReleaseBehavior.Any"/>,
/// <see cref="ReleaseBehavior.Flush"/> or <see cref="ReleaseBehavior.None"/>.
/// If the behavior is <see cref="ReleaseBehavior"/>, the default behavior
/// of the context creation API will be used.
/// If the behavior is <see cref="ReleaseBehavior.Flush"/>, the pipeline will be flushed
/// whenever the context is released from being the current one.
/// If the behavior is <see cref="ReleaseBehavior.None"/>, the pipeline will not be flushed on release.
/// </summary>
ContextReleaseBehavior = 0x00022009,
}
}

View File

@@ -1,25 +0,0 @@
//
// WindowHintRobustness.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Used to set context robustness attribute.
/// </summary>
/// <seealso cref="GLFW.WindowHint(WindowHintRobustness,Robustness)"/>
public enum WindowHintRobustness
{
/// <summary>
/// Indicates the robustness strategy used by the context.
/// This is <see cref="Robustness.LoseContextOnReset"/> or <see cref="Robustness.NoResetNotification"/>
/// if the window's context supports robustness, or <see cref="Robustness.NoRobustness"/> otherwise.
/// </summary>
ContextRobustness = 0x00022005,
}
}

View File

@@ -1,23 +0,0 @@
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Window hints for the WindowHintString function.
/// </summary>
public enum WindowHintString
{
/// <summary>
/// Sets the frame name on Cocoa. On any other platform, this does nothing.
/// </summary>
CocoaFrameName = 0x00023002,
/// <summary>
/// Sets the class name on X11. On any other platform, this does nothing.
/// </summary>
X11ClassName = 0x00024001,
/// <summary>
/// Sets the instance name on X11. on any other platform, this does nothing.
/// </summary>
X11InstanceName = 0x00024002,
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,180 +0,0 @@
//
// GLFWCallbacks.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
using System;
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Class containing GLFW related callbacks.
/// </summary>
public static unsafe class GLFWCallbacks
{
/// <summary>
/// The function signature for Unicode character callback functions.
/// </summary>
/// <param name="window">The window that received the event.</param>
/// <param name="codepoint">The Unicode code point of the character.</param>
/// <seealso cref="GLFW.SetCharCallback"/>
public delegate void CharCallback(Window* window, uint codepoint);
/// <summary>
/// The function signature for Unicode character with modifiers callback functions.
/// It is called for each input character, regardless of what modifier keys are held down.
/// </summary>
/// <param name="window">The window that received the event.</param>
/// <param name="codepoint">The Unicode code point of the character.</param>
/// <param name="modifiers">Bit field describing which modifier keys were held down.</param>
/// <seealso cref="GLFW.SetCharModsCallback"/>
public delegate void CharModsCallback(Window* window, uint codepoint, KeyModifiers modifiers);
/// <summary>
/// The function signature for cursor enter/leave callback functions.
/// </summary>
/// <param name="window">The window that received the event.</param>
/// <param name="entered"><c>true</c> if the cursor entered the window's client area, or <c>false</c> if it left it.</param>
/// <seealso cref="GLFW.SetCursorEnterCallback"/>
public delegate void CursorEnterCallback(Window* window, bool entered);
/// <summary>
/// The function signature for cursor position callback functions.
/// </summary>
/// <param name="window">The window that received the event.</param>
/// <param name="x">The new cursor x-coordinate, relative to the left edge of the client area.</param>
/// <param name="y">The new cursor y-coordinate, relative to the top edge of the client area.</param>
/// <seealso cref="GLFW.SetCursorPosCallback"/>
public delegate void CursorPosCallback(Window* window, double x, double y);
/// <summary>
/// The function signature for file drop callbacks.
/// </summary>
/// <param name="window">The window that received the event.</param>
/// <param name="count">The number of dropped files.</param>
/// <param name="paths">The UTF-8 encoded file and/or directory path names.</param>
/// <seealso cref="GLFW.SetDropCallback"/>
public delegate void DropCallback(Window* window, int count, byte** paths);
/// <summary>
/// The function signature for joystick configuration callback functions.
/// </summary>
/// <param name="joystick">The joystick that was connected or disconnected.</param>
/// <param name="state">
/// One of <see cref="ConnectedState.Connected"/> or <see cref="ConnectedState.Disconnected"/>.
/// </param>
/// <seealso cref="GLFW.SetJoystickCallback"/>
public delegate void JoystickCallback(int joystick, ConnectedState state);
/// <summary>
/// The function signature for keyboard key callback functions.
/// </summary>
/// <param name="window">The window that received the event.</param>
/// <param name="key">The keyboard key that was pressed or released.</param>
/// <param name="scanCode">The system-specific scancode of the key.</param>
/// <param name="action">The <see cref="InputAction"/> for that <paramref name="key"/>.</param>
/// <param name="mods">Bit field describing which modifier keys were held down.</param>
/// <seealso cref="GLFW.SetKeyCallback"/>
public delegate void KeyCallback(Window* window, Keys key, int scanCode, InputAction action, KeyModifiers mods);
/// <summary>
/// The function signature for mouse button callback functions.
/// </summary>
/// <param name="window">The window that received the event.</param>
/// <param name="button">The mouse button that was pressed or released.</param>
/// <param name="action">One of <see cref="InputAction.Press"/> or <see cref="InputAction.Release"/>.</param>
/// <param name="mods">Bit field describing which modifier keys were held down.</param>
/// <seealso cref="GLFW.SetMouseButtonCallback"/>
public delegate void MouseButtonCallback(Window* window, MouseButton button, InputAction action, KeyModifiers mods); // TODO: Make enums for int params in callback
/// <summary>
/// The function signature for scroll callback functions.
/// </summary>
/// <param name="window">The window that received the event.</param>
/// <param name="offsetX">The scroll offset along the x-axis.</param>
/// <param name="offsetY">The scroll offset along the y-axis.</param>
/// <seealso cref="GLFW.SetScrollCallback"/>
public delegate void ScrollCallback(Window* window, double offsetX, double offsetY);
/// <summary>
/// The function signature for monitor configuration callback functions.
/// </summary>
/// <param name="monitor">The monitor that was connected or disconnected.</param>
/// <param name="state">
/// One <see cref="ConnectedState.Connected"/> of or <see cref="ConnectedState.Disconnected"/>.
/// </param>
/// <seealso cref="GLFW.SetMonitorCallback"/>
public delegate void MonitorCallback(Monitor* monitor, ConnectedState state);
/// <summary>
/// The function signature for window close callback functions.
/// </summary>
/// <param name="window">The window that the user attempted to close.</param>
/// <seealso cref="GLFW.SetWindowCloseCallback"/>
public delegate void WindowCloseCallback(Window* window);
/// <summary>
/// The function signature for window focus callback functions.
/// </summary>
/// <param name="window">The window that gained or lost input focus.</param>
/// <param name="focused"><c>true</c> if the window was given input focus, or <c>false</c> if it lost it.</param>
/// <seealso cref="GLFW.SetWindowFocusCallback"/>
public delegate void WindowFocusCallback(Window* window, bool focused);
/// <summary>
/// The function signature for window iconify/restore callback functions.
/// </summary>
/// <param name="window">The window that was iconified or restored.</param>
/// <param name="iconified"><c>true</c> if the window was iconified(minimized), or <c>false</c> if it was restored.</param>
/// <seealso cref="GLFW.SetWindowIconifyCallback"/>
public delegate void WindowIconifyCallback(Window* window, bool iconified);
/// <summary>
/// The function signature for window position callback functions.
/// </summary>
/// <param name="window">The window that was moved.</param>
/// <param name="x">
/// The new x-coordinate, in screen coordinates, of the upper-left corner of the client area of the window.
/// </param>
/// <param name="y">
/// The new y-coordinate, in screen coordinates, of the upper-left corner of the client area of the window.
/// </param>
/// <seealso cref="GLFW.SetWindowPosCallback"/>
public delegate void WindowPosCallback(Window* window, int x, int y);
/// <summary>
/// The function signature for window size callback functions.
/// </summary>
/// <param name="window">The window that was resized.</param>
/// <param name="width">The new width, in screen coordinates, of the window.</param>
/// <param name="height">The new height, in screen coordinates, of the window.</param>
/// <seealso cref="GLFW.SetWindowSizeCallback"/>
public delegate void WindowSizeCallback(Window* window, int width, int height);
/// <summary>
/// The function signature for error callback functions.
/// </summary>
/// <param name="error">An error code.</param>
/// <param name="description">A UTF-8 encoded string describing the error.</param>
public delegate void ErrorCallback(ErrorCode error, string description);
/// <summary>
/// The function signature for window refresh functions.
/// </summary>
/// <param name="window">The window that needs to be refreshed.</param>
public delegate void WindowRefreshCallback(Window* window);
/// <summary>
/// This is the function pointer type for window content scale callbacks.
/// </summary>
/// <param name="window">The window whose content scale changed. </param>
/// <param name="xscale">The new x-axis content scale of the window. </param>
/// <param name="yscale">The new y-axis content scale of the window.</param>
/// <seealso cref="GLFW.SetWindowContentScaleCallback"/>
public delegate void WindowContentScaleCallback(Window* window, float xscale, float yscale);
}
}

View File

@@ -1,65 +0,0 @@
//
// GLFWException.cs
//
// Copyright (C) 2018 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
using System;
using System.Runtime.Serialization;
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Represents errors that occur within GLFW.
/// </summary>
[Serializable]
public class GLFWException : Exception
{
/// <summary>
/// Gets the underlying GLFW-error code.
/// </summary>
public ErrorCode ErrorCode { get; }
/// <summary>
/// Initializes a new instance of the <see cref="GLFWException"/> class.
/// </summary>
public GLFWException()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="GLFWException"/> class with the specified detailed description.
/// </summary>
/// <param name="message">A detailed description of the error.</param>
public GLFWException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="GLFWException"/> class
/// with the specified detailed description and GLFW error code.
/// </summary>
/// <param name="message">A detailed description of the error.</param>
/// <param name="errorCode">The GLFW error code causing the exception.</param>
public GLFWException(string message, ErrorCode errorCode)
: base(message)
{
ErrorCode = errorCode;
}
/// <summary>
/// Initializes a new instance of the <see cref="GLFWException"/> class with the specified detailed description
/// and the specified exception.
/// </summary>
/// <param name="message">A detailed description of the error.</param>
/// <param name="innerException">A reference to the inner exception that is the cause of this exception.</param>
public GLFWException(string message, Exception innerException)
: base(message, innerException)
{
}
}
}

View File

@@ -1,414 +0,0 @@
using System;
using System.Runtime.InteropServices;
namespace OpenToolkit.GraphicsLibraryFramework
{
internal static unsafe class GLFWNative
{
private const string LibraryName = "glfw3.dll";
public const int GLFW_TRUE = 1;
public const int GLFW_FALSE = 0;
#if NETCOREAPP
static GLFWNative()
{
// Register DllImport resolver so that the correct dynamic library is loaded on all platforms.
// On net472, we rely on Mono's DllMap for this. See the .dll.config file.
NativeLibrary.SetDllImportResolver(typeof(GLFWNative).Assembly, (name, assembly, path) =>
{
// Please keep in sync with what Robust.Shared/DllMapHelper.cs does.
if (name != "glfw3.dll")
{
return IntPtr.Zero;
}
string rName = null;
if (OperatingSystem.IsLinux() || OperatingSystem.IsFreeBSD()) rName = "libglfw.so.3";
else if (OperatingSystem.IsMacOS()) rName = "libglfw.3.dylib";
if ((rName != null) && NativeLibrary.TryLoad(rName, assembly, path, out var handle))
return handle;
return IntPtr.Zero;
});
}
#endif
[DllImport(LibraryName)]
public static extern int glfwInit();
[DllImport(LibraryName)]
public static extern void glfwTerminate();
[DllImport(LibraryName)]
public static extern void glfwInitHint(int hint, int value);
[DllImport(LibraryName)]
public static extern void glfwGetVersion(int* major, int* minor, int* revision);
[DllImport(LibraryName)]
public static extern byte* glfwGetVersionString();
[DllImport(LibraryName)]
public static extern ErrorCode glfwGetError(byte** description);
[DllImport(LibraryName)]
public static extern Monitor** glfwGetMonitors(int* count);
[DllImport(LibraryName)]
public static extern void glfwGetMonitorPos(Monitor* monitor, int* x, int* y);
[DllImport(LibraryName)]
public static extern void glfwGetMonitorPhysicalSize(Monitor* monitor, int* width, int* height);
[DllImport(LibraryName)]
public static extern void glfwGetMonitorContentScale(Monitor* monitor, float* xscale, float* yscale);
[DllImport(LibraryName)]
public static extern byte* glfwGetMonitorName(Monitor* monitor);
[DllImport(LibraryName)]
public static extern void glfwSetMonitorUserPointer(Monitor* monitor, void* pointer);
[DllImport(LibraryName)]
public static extern void* glfwGetMonitorUserPointer(Monitor* monitor);
[DllImport(LibraryName)]
public static extern VideoMode* glfwGetVideoModes(Monitor* monitor, int* count);
[DllImport(LibraryName)]
public static extern void glfwSetGamma(Monitor* monitor, float gamma);
[DllImport(LibraryName)]
public static extern GammaRamp* glfwGetGammaRamp(Monitor* monitor);
[DllImport(LibraryName)]
public static extern void glfwSetGammaRamp(Monitor* monitor, GammaRamp* ramp);
[DllImport(LibraryName)]
public static extern void glfwDefaultWindowHints();
[DllImport(LibraryName)]
public static extern void glfwWindowHintString(int hint, byte* value);
[DllImport(LibraryName)]
public static extern void glfwSetWindowSizeLimits(Window* window, int minwidth, int minheight, int maxwidth, int maxheight);
[DllImport(LibraryName)]
public static extern void glfwSetWindowAspectRatio(Window* window, int numer, int denom);
[DllImport(LibraryName)]
public static extern void glfwGetWindowFrameSize(Window* window, int* left, int* top, int* right, int* bottom);
[DllImport(LibraryName)]
public static extern void glfwGetWindowContentScale(Window* window, float* xscale, float* yscale);
[DllImport(LibraryName)]
public static extern float glfwGetWindowOpacity(Window* window);
[DllImport(LibraryName)]
public static extern void glfwSetWindowOpacity(Window* window, float opacity);
[DllImport(LibraryName)]
public static extern void glfwRequestWindowAttention(Window* window);
[DllImport(LibraryName)]
public static extern void glfwSetWindowAttrib(Window* window, WindowAttributeSetter attrib, int value);
[DllImport(LibraryName)]
public static extern int glfwRawMouseMotionSupported();
[DllImport(LibraryName)]
public static extern byte* glfwGetKeyName(Keys key, int scancode);
[DllImport(LibraryName)]
public static extern int glfwGetKeyScancode(Keys key);
[DllImport(LibraryName)]
public static extern InputAction glfwGetKey(Window* window, Keys key);
[DllImport(LibraryName)]
public static extern InputAction glfwGetMouseButton(Window* window, MouseButton button);
[DllImport(LibraryName)]
public static extern void glfwGetCursorPos(Window* window, double* xpos, double* ypos);
[DllImport(LibraryName)]
public static extern void glfwSetCursorPos(Window* window, double xpos, double ypos);
[DllImport(LibraryName)]
public static extern Cursor* glfwCreateCursor(Image* image, int xhot, int yhot);
[DllImport(LibraryName)]
public static extern Cursor* glfwCreateStandardCursor(CursorShape shape);
[DllImport(LibraryName)]
public static extern void glfwDestroyCursor(Cursor* cursor);
[DllImport(LibraryName)]
public static extern void glfwSetCursor(Window* window, Cursor* cursor);
[DllImport(LibraryName)]
public static extern int glfwJoystickPresent(int jid);
[DllImport(LibraryName)]
public static extern float* glfwGetJoystickAxes(int jid, int* count);
[DllImport(LibraryName)]
public static extern InputAction* glfwGetJoystickButtons(int jid, int* count);
[DllImport(LibraryName)]
public static extern JoystickHats* glfwGetJoystickHats(int jid, int* count);
[DllImport(LibraryName)]
public static extern byte* glfwGetJoystickName(int jid);
[DllImport(LibraryName)]
public static extern byte* glfwGetJoystickGUID(int jid);
[DllImport(LibraryName)]
public static extern void glfwSetJoystickUserPointer(int jid, void* ptr);
[DllImport(LibraryName)]
public static extern void* glfwGetJoystickUserPointer(int jid);
[DllImport(LibraryName)]
public static extern int glfwJoystickIsGamepad(int jid);
[DllImport(LibraryName)]
public static extern int glfwUpdateGamepadMappings(byte* newMapping);
[DllImport(LibraryName)]
public static extern byte* glfwGetGamepadName(int jid);
[DllImport(LibraryName)]
public static extern int glfwGetGamepadState(int jid, GamepadState* state);
[DllImport(LibraryName)]
public static extern double glfwGetTime();
[DllImport(LibraryName)]
public static extern void glfwSetTime(double time);
[DllImport(LibraryName)]
public static extern long glfwGetTimerValue();
[DllImport(LibraryName)]
public static extern long glfwGetTimerFrequency();
[DllImport(LibraryName)]
public static extern Window* glfwGetCurrentContext();
[DllImport(LibraryName)]
public static extern void glfwSwapBuffers(Window* window);
[DllImport(LibraryName)]
public static extern int glfwExtensionSupported(byte* extensionName);
[DllImport(LibraryName)]
public static extern IntPtr glfwGetProcAddress(byte* procame);
[DllImport(LibraryName)]
public static extern Window* glfwCreateWindow(int width, int height, byte* title, Monitor* monitor, Window* share);
[DllImport(LibraryName)]
public static extern Monitor* glfwGetPrimaryMonitor();
[DllImport(LibraryName)]
public static extern void glfwDestroyWindow(Window* window);
[DllImport(LibraryName)]
public static extern void glfwFocusWindow(Window* window);
[DllImport(LibraryName)]
public static extern void glfwGetFramebufferSize(Window* window, int* width, int* height);
[DllImport(LibraryName)]
public static extern CursorModeValue glfwGetInputMode(Window* window, CursorStateAttribute mode);
[DllImport(LibraryName)]
public static extern int glfwGetInputMode(Window* window, StickyAttributes mode);
[DllImport(LibraryName)]
public static extern void glfwRestoreWindow(Window* window);
[DllImport(LibraryName)]
public static extern VideoMode* glfwGetVideoMode(Monitor* monitor);
[DllImport(LibraryName)]
public static extern int glfwGetWindowAttrib(Window* window, WindowAttributeGetter attribute);
[DllImport(LibraryName)]
public static extern void glfwGetWindowSize(Window* window, int* width, int* height);
[DllImport(LibraryName)]
public static extern void glfwGetWindowPos(Window* window, int* x, int* y);
[DllImport(LibraryName)]
public static extern Monitor* glfwGetWindowMonitor(Window* window);
[DllImport(LibraryName)]
public static extern void glfwHideWindow(Window* window);
[DllImport(LibraryName)]
public static extern void glfwIconifyWindow(Window* window);
[DllImport(LibraryName)]
public static extern void glfwMakeContextCurrent(Window* window);
[DllImport(LibraryName)]
public static extern void glfwMaximizeWindow(Window* window);
[DllImport(LibraryName)]
public static extern void glfwPollEvents();
[DllImport(LibraryName)]
public static extern void glfwPostEmptyEvent();
[DllImport(LibraryName)]
public static extern void glfwWindowHint(WindowHintInt hint, int value);
[DllImport(LibraryName)]
public static extern void glfwWindowHint(WindowHintBool hint, int value);
[DllImport(LibraryName)]
public static extern void glfwWindowHint(WindowHintClientApi hint, ClientApi value);
[DllImport(LibraryName)]
public static extern void glfwWindowHint(WindowHintReleaseBehavior hint, ReleaseBehavior value);
[DllImport(LibraryName)]
public static extern void glfwWindowHint(WindowHintContextApi hint, ContextApi value);
[DllImport(LibraryName)]
public static extern void glfwWindowHint(WindowHintRobustness hint, Robustness value);
[DllImport(LibraryName)]
public static extern void glfwWindowHint(WindowHintOpenGlProfile hint, OpenGlProfile value);
[DllImport(LibraryName)]
public static extern int glfwWindowShouldClose(Window* window);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetCharCallback(Window* window, IntPtr callback);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetCharModsCallback(Window* window, IntPtr callback);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetCursorEnterCallback(Window* window, IntPtr callback);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetCursorPosCallback(Window* window, IntPtr callback);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetDropCallback(Window* window, IntPtr callback);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetErrorCallback(IntPtr callback);
[DllImport(LibraryName)]
public static extern void glfwSetInputMode(Window* window, CursorStateAttribute mode, CursorModeValue value);
[DllImport(LibraryName)]
public static extern void glfwSetInputMode(Window* window, StickyAttributes mode, int value);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetJoystickCallback(IntPtr callback);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetKeyCallback(Window* window, IntPtr callback);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetScrollCallback(Window* window, IntPtr callback);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetMonitorCallback(IntPtr callback);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetMouseButtonCallback(Window* window, IntPtr callback);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetWindowCloseCallback(Window* window, IntPtr callback);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetWindowFocusCallback(Window* window, IntPtr callback);
[DllImport(LibraryName)]
public static extern void glfwSetWindowIcon(Window* window, int count, Image* images);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetWindowIconifyCallback(Window* window, IntPtr callback);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetWindowContentScaleCallback(Window* window, IntPtr callback);
[DllImport(LibraryName)]
public static extern void glfwSetWindowTitle(Window* window, byte* title);
[DllImport(LibraryName)]
public static extern void glfwShowWindow(Window* window);
[DllImport(LibraryName)]
public static extern void glfwSetWindowSize(Window* window, int width, int height);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetWindowSizeCallback(Window* window, IntPtr callback);
[DllImport(LibraryName)]
public static extern void glfwSetWindowShouldClose(Window* window, int value);
[DllImport(LibraryName)]
public static extern void glfwSetWindowMonitor(Window* window, Monitor* monitor, int x, int y, int width, int height, int refreshRate);
[DllImport(LibraryName)]
public static extern void glfwSetWindowPos(Window* window, int x, int y);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetWindowPosCallback(Window* window, IntPtr callback);
[DllImport(LibraryName)]
public static extern IntPtr glfwSetWindowRefreshCallback(Window* window, IntPtr callback);
[DllImport(LibraryName)]
public static extern void glfwSwapInterval(int interval);
[DllImport(LibraryName)]
public static extern void glfwWaitEvents();
[DllImport(LibraryName)]
public static extern void glfwWaitEventsTimeout(double timeout);
[DllImport(LibraryName)]
public static extern byte* glfwGetClipboardString(Window* window);
[DllImport(LibraryName)]
public static extern void glfwSetClipboardString(Window* window, byte* data);
[DllImport(LibraryName)]
public static extern int glfwVulkanSupported();
[DllImport(LibraryName)]
public static extern byte** glfwGetRequiredInstanceExtensions(uint* count);
[DllImport(LibraryName)]
public static extern IntPtr glfwGetInstanceProcAddress(VkHandle instance, byte* procName);
[DllImport(LibraryName)]
public static extern int glfwGetPhysicalDevicePresentationSupport(VkHandle instance, VkHandle device, int queueFamily);
[DllImport(LibraryName)]
public static extern int glfwCreateWindowSurface(VkHandle instance, Window* window, void* allocator, VkHandle surface);
[DllImport(LibraryName)]
public static extern uint glfwGetX11Window(Window* window);
[DllImport(LibraryName)]
public static extern IntPtr glfwGetX11Display(Window* window);
[DllImport(LibraryName)]
public static extern IntPtr glfwGetWin32Window(Window* window);
}
}

View File

@@ -1,27 +0,0 @@
//
// GamepadState.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// This describes the input state of a gamepad.
/// </summary>
public struct GamepadState
{
/// <summary>
/// State of each of the 15 gamepad buttons, equal to <see cref="InputAction.Press"/> or <see cref="InputAction.Release"/>.
/// </summary>
public unsafe fixed byte Buttons[15];
/// <summary>
/// State of each of the 6 gamepad axes, ranging from -1.0 to 1.0.
/// </summary>
public unsafe fixed float Axes[6];
}
}

View File

@@ -1,37 +0,0 @@
//
// GammaRamp.cs
//
// Copyright (C) 2019 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Gamma ramp for a <see cref="Monitor"/>.
/// </summary>
public unsafe struct GammaRamp
{
/// <summary>
/// Red components of the gamma ramp.
/// </summary>
public ushort* Red;
/// <summary>
/// Green components of the gamma ramp.
/// </summary>
public ushort* Green;
/// <summary>
/// Blue components of the gamma ramp.
/// </summary>
public ushort* Blue;
/// <summary>
/// Length of the arrays.
/// </summary>
public uint Size;
}
}

View File

@@ -1,47 +0,0 @@
//
// Image.cs
//
// Copyright (C) 2018 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
using System;
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Contains GLFW Image data.
/// </summary>
public unsafe struct Image
{
/// <summary>
/// Initializes a new instance of the <see cref="Image"/> struct.
/// </summary>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
/// <param name="pixels"><see cref="IntPtr"/> pointing to the RGBA pixel data of the image.</param>
public Image(int width, int height, byte* pixels)
{
Width = width;
Height = height;
Pixels = pixels;
}
/// <summary>
/// The width, in pixels, of this <see cref="Image"/>.
/// </summary>
public int Width;
/// <summary>
/// The height, in pixels, of this <see cref="Image"/>.
/// </summary>
public int Height;
/// <summary>
/// A <see cref="byte"/> pointer pointing to the RGBA pixel data.
/// </summary>
public byte* Pixels;
}
}

View File

@@ -1,23 +0,0 @@
# MIT License
Copyright (c) 2006-2019 Stefanos Apostolopoulos for the Open Toolkit project.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
#### Third party licenses may be applicable. These have been disclosed in [THIRD_PARTIES.md](THIRD_PARTIES.md)

View File

@@ -1,18 +0,0 @@
//
// Monitor.cs
//
// Copyright (C) 2018 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Opaque handle to a GLFW monitor.
/// </summary>
public struct Monitor
{
}
}

View File

@@ -1,20 +0,0 @@
# Third parties
## AdvancedDLSupport
> OpenTK uses AdvancedDLSupport for native interoperability. To enable compatibility with the LGPLv3 License, Firwood has given us a licensing exception.
* Read the [license grant](AdvancedDLSupport-LICENSE.pdf).
* Read the [license summary](Short-LICENSE.md) for an easy-to-understand version.
## OpenEXR
> OpenTK.Half offers Half-to-Single and Single-to-Half conversions based on OpenEXR source code, which is covered by the following license:
Copyright (c) 2002, Industrial Light & Magic, a division of Lucas Digital Ltd. LLC. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Industrial Light & Magic nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -1,50 +0,0 @@
//
// VideoMode.cs
//
// Copyright (C) 2018 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
using System.Runtime.InteropServices;
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Replicated handle to a GLFW VideoMode.
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct VideoMode
{
/// <summary>
/// The width, in screen coordinates, of the <see cref="VideoMode"/>.
/// </summary>
public int Width;
/// <summary>
/// The height, in screen coordinates, of the <see cref="VideoMode"/>.
/// </summary>
public int Height;
/// <summary>
/// The bit depth of the red channel of the <see cref="VideoMode"/>.
/// </summary>
public int RedBits;
/// <summary>
/// The bit depth of the green channel of the <see cref="VideoMode"/>.
/// </summary>
public int GreenBits;
/// <summary>
/// The bit depth of the blue channel of the <see cref="VideoMode"/>.
/// </summary>
public int BlueBits;
/// <summary>
/// The refresh rate, in Hz, of the <see cref="VideoMode"/>.
/// </summary>
public int RefreshRate;
}
}

View File

@@ -1,29 +0,0 @@
using System;
using System.Runtime.InteropServices;
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// A handle to a Vulkan object.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct VkHandle
{
/// <summary>
/// The actual value of the Vulkan handle.
/// </summary>
public IntPtr Handle;
/// <summary>
/// Initializes a new instance of the <see cref="VkHandle"/> struct.
/// </summary>
/// <param name="handle">
/// The native Vulkan handle.
/// This is NOT a pointer to a field containing the handle, this is the actual handle itself.
/// </param>
public VkHandle(IntPtr handle)
{
Handle = handle;
}
}
}

View File

@@ -1,18 +0,0 @@
//
// Window.cs
//
// Copyright (C) 2018 OpenTK
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
//
namespace OpenToolkit.GraphicsLibraryFramework
{
/// <summary>
/// Opaque handle to a GLFW window.
/// </summary>
public struct Window
{
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1005,22 +1005,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- name: GLFW
license: |
Copyright © 2002-2006 Marcus Geelnard
Copyright © 2006-2019 Camilla Löwy
This software is provided as-is, without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
This notice may not be removed or altered from any source distribution.
- name: FluidSynth
license: |
GNU LESSER GENERAL PUBLIC LICENSE

View File

@@ -4,6 +4,12 @@
kind: canvas
light_mode: unshaded
# Simple mix blend
- type: shader
id: Mix
kind: canvas
blend_mode: Mix
- type: shader
id: shaded
kind: canvas

View File

@@ -0,0 +1,27 @@
import Robust::SpriteBatch::{VertexInput, VertexOutput, mainTexture, mainSampler, View};
import Robust::Math::srgb_to_linear;
@vertex
fn vs_main(input: VertexInput) -> VertexOutput {
var transformed = vec3(input.position, 1.0) * View.projViewMatrix;
transformed += 1.0;
transformed /= View.screenPixelSize * 2.0;
transformed = floor(transformed + 0.5);
transformed *= View.screenPixelSize * 2.0;
transformed -= 1.0;
var out: VertexOutput;
out.position = vec4(transformed, 0.0, 1.0);
out.texCoord = input.texCoord;
out.color = srgb_to_linear(input.color);
return out;
}
@fragment
fn fs_main(input: VertexOutput) -> @location(0) vec4f {
var color = textureSample(mainTexture, mainSampler, input.texCoord);
color = color * input.color;
return color;
}

View File

@@ -0,0 +1,6 @@
fn srgb_to_linear(srgb: vec4f) -> vec4f {
let higher = pow((srgb.rgb + 0.055) / 1.055, vec3(2.4));
let lower = srgb.rgb / 12.92;
let s = max(vec3(0.0), sign(srgb.rgb - 0.04045));
return vec4(mix(lower, higher, s), srgb.a);
}

View File

@@ -0,0 +1,33 @@
// Group 0: global constants.
struct UniformConstants {
time: f32
}
@group(0) @binding(0) var<uniform> Constants: UniformConstants;
// Group 1: parameters that change infrequently in a draw pass.
struct UniformView {
projViewMatrix: mat2x3f,
screenPixelSize: vec2f
}
@group(1) @binding(0) var<uniform> View: UniformView;
// Group 2: per-draw parameters.
@group(2) @binding(0)
var mainTexture: texture_2d<f32>;
@group(2) @binding(1)
var mainSampler: sampler;
struct VertexInput {
@location(0) position: vec2f,
@location(1) texCoord: vec2f,
@location(2) color: vec4f
}
struct VertexOutput {
@builtin(position) position: vec4f,
@location(0) texCoord: vec2f,
@location(1) color: vec4f,
}

View File

@@ -0,0 +1 @@

View File

@@ -21,7 +21,8 @@ zzzz-object-pronoun = { GENDER($ent) ->
}
# Used internally by the DAT-OBJ() function.
# Not used in en-US. Created for supporting other languages.
# Not used in en-US. Created to support other languages.
# (e.g., "to him," "for her")
zzzz-dat-object = { GENDER($ent) ->
[male] him
[female] her
@@ -29,6 +30,16 @@ zzzz-dat-object = { GENDER($ent) ->
*[neuter] it
}
# Used internally by the GENITIVE() function.
# Not used in en-US. Created to support other languages.
# e.g., "у него" (Russian), "seines Vaters" (German).
zzzz-genitive = { GENDER($ent) ->
[male] his
[female] her
[epicene] their
*[neuter] its
}
# Used internally by the POSS-PRONOUN() function.
zzzz-possessive-pronoun = { GENDER($ent) ->
[male] his

View File

@@ -0,0 +1,3 @@
generic-map = map
generic-grid = grid
generic-mapid = map Id

View File

@@ -0,0 +1,33 @@
color-hue-chroma-lightness = {$lightness} {$chroma} {$hue}
color-hue-chroma = {$chroma} {$hue}
color-hue-lightness = {$lightness} {$hue}
color-very-dark = very dark
color-dark = dark
color-light = light
color-very-light = very light
color-mixed-hue = {$a} {$b}
color-pale = pale
color-gray-adjective = gray
color-strong = strong
color-pink = pink
color-red = red
color-orange = orange
color-yellow = yellow
color-green = green
color-cyan = cyan
color-blue = blue
color-purple = purple
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
color-orange-color-yellow = orangeish yellow
color-yellow-color-green = yellowish green
color-green-color-cyan = greenish cyan
color-cyan-color-blue = cyanish blue
color-blue-color-purple = blueish purple
color-purple-color-pink = purpleish pink

View File

@@ -1,5 +1,7 @@
### Localization for engine console commands
cmd-hint-float = [float]
## generic command errors
cmd-invalid-arg-number-error = Invalid number of arguments.
@@ -11,6 +13,7 @@ cmd-parse-failure-uid = {$arg} is not a valid entity UID.
cmd-parse-failure-mapid = {$arg} is not a valid MapId.
cmd-parse-failure-enum = {$arg} is not a {$enum} Enum.
cmd-parse-failure-grid = {$arg} is not a valid grid.
cmd-parse-failure-cultureinfo = "{$arg}" is not valid CultureInfo.
cmd-parse-failure-entity-exist = UID {$arg} does not correspond to an existing entity.
cmd-parse-failure-session = There is no session with username: {$username}
@@ -156,6 +159,7 @@ cmd-savemap-not-exist = Target map does not exist.
cmd-savemap-init-warning = Attempted to save a post-init map without forcing the save.
cmd-savemap-attempt = Attempting to save map {$mapId} to {$path}.
cmd-savemap-success = Map successfully saved.
cmd-savemap-error = Could not save map! See server log for details.
cmd-hint-savemap-id = <MapID>
cmd-hint-savemap-path = <Path>
cmd-hint-savemap-force = [bool]
@@ -293,7 +297,7 @@ cmd-lsgrid-desc = Lists grids.
cmd-lsgrid-help = lsgrid
cmd-addmap-desc = Adds a new empty map to the round. If the mapID already exists, this command does nothing.
cmd-addmap-help = addmap <mapID> [initialize]
cmd-addmap-help = addmap <mapID> [pre-init]
cmd-rmmap-desc = Removes a map from the world. You cannot remove nullspace.
cmd-rmmap-help = rmmap <mapId>
@@ -407,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.
@@ -427,11 +428,20 @@ cmd-entfo-help = Usage: entfo <entityuid>
The entity UID can be prefixed with 'c' to convert it to a client entity UID.
cmd-fuck-desc = Throws an exception
cmd-fuck-help = Throws an exception
cmd-fuck-help = Usage: fuck
cmd-showpos-desc = Enables debug drawing over all entity positions in the game.
cmd-showpos-desc = Show the position of all entities on the screen.
cmd-showpos-help = Usage: showpos
cmd-showrot-desc = Show the rotation of all entities on the screen.
cmd-showrot-help = Usage: showrot
cmd-showvel-desc = Show the local velocity of all entites on the screen.
cmd-showvel-help = Usage: showvel
cmd-showangvel-desc = Show the angular velocity of all entities on the screen.
cmd-showangvel-help = Usage: showangvel
cmd-sggcell-desc = Lists entities on a snap grid cell.
cmd-sggcell-help = Usage: sggcell <gridID> <vector2i>\nThat vector2i param is in the form x<int>,y<int>.
@@ -562,3 +572,10 @@ cmd-pvs-override-info-desc = Prints information about any PVS overrides associat
cmd-pvs-override-info-empty = Entity {$nuid} has no PVS overrides.
cmd-pvs-override-info-global = Entity {$nuid} has a global override.
cmd-pvs-override-info-clients = Entity {$nuid} has a session override for {$clients}.
cmd-localization_set_culture-desc = Set DefaultCulture for the client LocalizationManager
cmd-localization_set_culture-help = Usage: localization_set_culture <cultureName>
cmd-localization_set_culture-culture-name = <cultureName>
cmd-localization_set_culture-changed = Localization changed to { $code } ({ $nativeName } / { $englishName })
cmd-addmap-hint-2 = runMapInit [true / false]

View File

@@ -1,19 +1,24 @@
## 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
## TileSpawnWindow
tile-spawn-window-title = Place Tiles
tile-spawn-window-mirror-button-text = Mirror Tiles
## Console
console-line-edit-placeholder = Command Here
## OutputPanel
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

View File

@@ -0,0 +1,25 @@
## "Textures" dev window tab
dev-window-tab-textures-title = Textures
dev-window-tab-textures-reload = Reload
dev-window-tab-textures-filter = Filter
dev-window-tab-textures-summary = Total (est): { $bytes }
dev-window-tab-textures-info = Width: { $width } Height: { $height }
PixelType: { $pixelType } sRGB: { $srgb }
Name: { $name }
Est. memory usage: { $bytes }
## "Render Targets" dev window tab
dev-window-tab-render-targets-title = Render Targets
dev-window-tab-render-targets-reload = Reload
dev-window-tab-render-targets-filter = Filter
dev-window-tab-render-targets-column-id = ID
dev-window-tab-render-targets-column-name = Name
dev-window-tab-render-targets-column-size = Size
dev-window-tab-render-targets-column-type = Type
dev-window-tab-render-targets-column-vram = VRAM
dev-window-tab-render-targets-column-thumbnail = Thumbnail
dev-window-tab-render-targets-value-null = null
dev-window-tab-render-targets-value-not-available = Not available
dev-window-tab-render-targets-summary = Total VRAM: { $vram }

View File

@@ -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

View File

@@ -42,8 +42,7 @@ command-description-as =
command-description-count =
Counts the amount of entries in it's input, returning an integer.
command-description-map =
Maps the input over the given block, with the provided expected return type.
This command may be modified to not need an explicit return type in the future.
Maps the input over the given block.
command-description-select =
Selects N objects or N% of objects from the input.
One can additionally invert this command with not to make it select everything except N objects instead.
@@ -149,7 +148,7 @@ command-description-max =
Returns the maximum of two values.
command-description-BitAndCommand =
Performs bitwise AND.
command-description-BitOrCommand =
command-description-bitor =
Performs bitwise OR.
command-description-BitXorCommand =
Performs bitwise XOR.
@@ -196,6 +195,8 @@ command-description-spawn-at =
Spawns an entity at the given coordinates.
command-description-spawn-on =
Spawns an entity on the given entity, at it's coordinates.
command-description-spawn-in =
Spawns an entity in the given container on the given entity, dropping it at its coordinates if it doesn't fit
command-description-spawn-attached =
Spawns an entity attached to the given entity, at (0 0) relative to it.
command-description-mappos =
@@ -203,11 +204,11 @@ command-description-mappos =
command-description-pos =
Returns an entity's coordinates.
command-description-tp-coords =
Teleports the target to the given coordinates.
Teleports the given entities to the target coordinates.
command-description-tp-to =
Teleports the target to the given other entity.
Teleports the given entities to the target entity.
command-description-tp-into =
Teleports the target "into" the given other entity, attaching it at (0 0) relative to it.
Teleports the given entities "into" the target entity, attaching it at (0 0) relative to it.
command-description-comp-get =
Gets the given component from the given entity.
command-description-comp-add =
@@ -277,7 +278,7 @@ command-description-ModVecCommand =
Performs the modulus operation over the input with the given constant right-hand value.
command-description-BitAndNotCommand =
Performs bitwise AND-NOT over the input.
command-description-BitOrNotCommand =
command-description-bitornot =
Performs bitwise OR-NOT over the input.
command-description-BitXnorCommand =
Performs bitwise XNOR over the input.

View File

@@ -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

View File

@@ -136,6 +136,7 @@ cmd-savemap-not-exist = O mapa de destino não existe.
cmd-savemap-init-warning = Tentativa de salvar um mapa pós-inicialização sem forçar o salvamento.
cmd-savemap-attempt = Tentando salvar o mapa {$mapId} em {$path}.
cmd-savemap-success = Mapa salvo com sucesso.
cmd-savemap-error = Não foi possível salvar o mapa! Consulte o log do servidor para obter detalhes.
cmd-hint-savemap-id = <MapID>
cmd-hint-savemap-path = <Path>
cmd-hint-savemap-force = [bool]

View File

@@ -14,6 +14,8 @@ uniform highp vec2 lightCenter;
uniform highp float lightRange;
uniform highp float lightPower;
uniform highp float lightSoftness;
uniform highp float lightFalloff;
uniform highp float lightCurveFactor;
uniform highp float lightIndex;
uniform sampler2D shadowMap;
@@ -47,8 +49,15 @@ void fragment()
discard;
}
highp float dist = dot(diff, diff) + LIGHTING_HEIGHT;
highp float val = clamp((1.0 - clamp(sqrt(dist) / lightRange, 0.0, 1.0)) * (1.0 / (sqrt(dist + 1.0))), 0.0, 1.0);
// this implementation of light attenuation primarily adapted from
// https://lisyarus.github.io/blog/posts/point-light-attenuation.html
highp float sqr_dist = dot(diff, diff) + LIGHTING_HEIGHT;
highp float s = clamp(sqrt(sqr_dist) / lightRange, 0.0, 1.0);
highp float s2 = s * s;
// controls curve by lerping between two variants (inverse-shape and inversequadratic-shape)
highp float curveFactor = mix(s, s2, clamp(lightCurveFactor, 0.0, 1.0));
highp float val = clamp(((1.0 - s2) * (1.0 - s2)) / (1.0 + lightFalloff * curveFactor), 0.0, 1.0);
val *= lightPower;
val *= mask;

View 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")
);
}
}

View File

@@ -1,4 +1,4 @@
extern alias SerializationGenerator;
extern alias SerializationGenerator;
using System.Linq;
using System.Reflection;
using Microsoft.CodeAnalysis;
@@ -66,6 +66,7 @@ public sealed class ComponentPauseGeneratorTest
public partial class FooComponent
{
[RobustAutoGenerated]
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public sealed class FooComponent_AutoPauseSystem : EntitySystem
{
public override void Initialize()
@@ -106,6 +107,7 @@ public sealed class ComponentPauseGeneratorTest
public partial class FooComponent
{
[RobustAutoGenerated]
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public sealed class FooComponent_AutoPauseSystem : EntitySystem
{
public override void Initialize()
@@ -124,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()
{
@@ -147,6 +191,7 @@ public sealed class ComponentPauseGeneratorTest
public partial class FooComponent
{
[RobustAutoGenerated]
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public sealed class FooComponent_AutoPauseSystem : EntitySystem
{
public override void Initialize()
@@ -188,6 +233,7 @@ public sealed class ComponentPauseGeneratorTest
public partial class FooComponent
{
[RobustAutoGenerated]
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public sealed class FooComponent_AutoPauseSystem : EntitySystem
{
public override void Initialize()

View File

@@ -21,47 +21,53 @@ public sealed class DataDefinitionAnalyzerTest
},
};
test.TestState.Sources.Add(("TestTypeDefs.cs", TestTypeDefs));
// ExpectedDiagnostics cannot be set, so we need to AddRange here...
test.TestState.ExpectedDiagnostics.AddRange(expected);
return test.RunAsync();
}
private const string TestTypeDefs = """
using System;
namespace Robust.Shared.ViewVariables
{
public sealed class ViewVariablesAttribute : Attribute
{
public readonly VVAccess Access = VVAccess.ReadOnly;
public ViewVariablesAttribute() { }
public ViewVariablesAttribute(VVAccess access)
{
Access = access;
}
}
public enum VVAccess : byte
{
ReadOnly = 0,
ReadWrite = 1,
}
}
namespace Robust.Shared.Serialization.Manager.Attributes
{
public class DataFieldBaseAttribute : Attribute;
public class DataFieldAttribute(string? tag = null) : DataFieldBaseAttribute;
public sealed class DataDefinitionAttribute : Attribute;
public sealed class NotYamlSerializableAttribute : Attribute;
}
""";
[Test]
public async Task Test()
public async Task NoVVReadOnlyTest()
{
const string code = """
using System;
using Robust.Shared.ViewVariables;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Robust.Shared.ViewVariables
{
public sealed class ViewVariablesAttribute : Attribute
{
public readonly VVAccess Access = VVAccess.ReadOnly;
public ViewVariablesAttribute() { }
public ViewVariablesAttribute(VVAccess access)
{
Access = access;
}
}
public enum VVAccess : byte
{
ReadOnly = 0,
ReadWrite = 1,
}
}
namespace Robust.Shared.Serialization.Manager.Attributes
{
public class DataFieldBaseAttribute : Attribute;
public class DataFieldAttribute : DataFieldBaseAttribute;
public sealed class DataDefinitionAttribute : Attribute;
}
[DataDefinition]
public sealed partial class Foo
{
@@ -83,8 +89,168 @@ public sealed class DataDefinitionAnalyzerTest
""";
await Verifier(code,
// /0/Test0.cs(35,17): info RA0028: Data field Bad in data definition Foo has ViewVariables attribute with ReadWrite access, which is redundant
VerifyCS.Diagnostic(DataDefinitionAnalyzer.DataFieldNoVVReadWriteRule).WithSpan(35, 17, 35, 50).WithArguments("Bad", "Foo")
// /0/Test0.cs(7,17): info RA0028: Data field Bad in data definition Foo has ViewVariables attribute with ReadWrite access, which is redundant
VerifyCS.Diagnostic(DataDefinitionAnalyzer.DataFieldNoVVReadWriteRule).WithSpan(7, 17, 7, 50).WithArguments("Bad", "Foo")
);
}
[Test]
public async Task ReadOnlyFieldTest()
{
const string code = """
using Robust.Shared.Serialization.Manager.Attributes;
[DataDefinition]
public sealed partial class Foo
{
[DataField]
public readonly int Bad;
[DataField]
public int Good;
}
""";
await Verifier(code,
// /0/Test0.cs(7,12): error RA0019: Data field Bad in data definition Foo is readonly
VerifyCS.Diagnostic(DataDefinitionAnalyzer.DataFieldWritableRule).WithSpan(7, 12, 7, 20).WithArguments("Bad", "Foo")
);
}
[Test]
public async Task PartialDataDefinitionTest()
{
const string code = """
using Robust.Shared.Serialization.Manager.Attributes;
[DataDefinition]
public sealed class Foo { }
""";
await Verifier(code,
// /0/Test0.cs(4,15): error RA0017: Type Foo is a DataDefinition but is not partial
VerifyCS.Diagnostic(DataDefinitionAnalyzer.DataDefinitionPartialRule).WithSpan(4, 15, 4, 20).WithArguments("Foo")
);
}
[Test]
public async Task NestedPartialDataDefinitionTest()
{
const string code = """
using Robust.Shared.Serialization.Manager.Attributes;
public sealed class Foo
{
[DataDefinition]
public sealed partial class Nested { }
}
""";
await Verifier(code,
// /0/Test0.cs(3,15): error RA0018: Type Foo contains nested data definition Nested but is not partial
VerifyCS.Diagnostic(DataDefinitionAnalyzer.NestedDataDefinitionPartialRule).WithSpan(3, 15, 3, 20).WithArguments("Foo", "Nested")
);
}
[Test]
public async Task RedundantDataFieldTagTest()
{
const string code = """
using Robust.Shared.Serialization.Manager.Attributes;
[DataDefinition]
public sealed partial class Foo
{
[DataField("someValue")]
public int SomeValue;
}
""";
await Verifier(code,
// /0/Test0.cs(6,6): info RA0027: Data field SomeValue in data definition Foo has an explicitly set tag that matches autogenerated tag
VerifyCS.Diagnostic(DataDefinitionAnalyzer.DataFieldRedundantTagRule).WithSpan(6, 6, 6, 28).WithArguments("SomeValue", "Foo")
);
}
[Test]
public async Task ReadOnlyPropertyTest()
{
const string code = """
using Robust.Shared.Serialization.Manager.Attributes;
[DataDefinition]
public sealed partial class Foo
{
[DataField]
public int Bad { get; }
[DataField]
public int Good { get; private set; }
}
""";
await Verifier(code,
// /0/Test0.cs(7,20): error RA0020: Data field property Bad in data definition Foo does not have a setter
VerifyCS.Diagnostic(DataDefinitionAnalyzer.DataFieldPropertyWritableRule).WithSpan(7, 20, 7, 28).WithArguments("Bad", "Foo")
);
}
[Test]
public async Task NotYamlSerializableTest()
{
const string code = """
using Robust.Shared.Serialization.Manager.Attributes;
[NotYamlSerializable]
public sealed class NotSerializableClass { }
[NotYamlSerializable]
public readonly struct NotSerializableStruct { }
[DataDefinition]
public sealed partial class Foo
{
[DataField]
public NotSerializableClass BadField;
[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
}
""";
await Verifier(code,
// /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")
);
}
}

View File

@@ -0,0 +1,189 @@
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.ForbidLiteralAnalyzer, Microsoft.CodeAnalysis.Testing.DefaultVerifier>;
namespace Robust.Analyzers.Tests;
[Parallelizable(ParallelScope.All | ParallelScope.Fixtures)]
[TestFixture]
public sealed class ForbidLiteralAnalyzerTest
{
private static Task Verifier(string code, params DiagnosticResult[] expected)
{
var test = new CSharpAnalyzerTest<ForbidLiteralAnalyzer, DefaultVerifier>()
{
TestState =
{
Sources = { code },
},
};
TestHelper.AddEmbeddedSources(
test.TestState,
"Robust.Shared.Analyzers.ForbidLiteralAttribute.cs"
);
test.TestState.Sources.Add(("TestTypeDefs.cs", TestTypeDefs));
// ExpectedDiagnostics cannot be set, so we need to AddRange here...
test.TestState.ExpectedDiagnostics.AddRange(expected);
return test.RunAsync();
}
private const string TestTypeDefs = """
using System.Collections.Generic;
using Robust.Shared.Analyzers;
public sealed class TestClass
{
public static void OneParameterForbidden([ForbidLiteral] string value) { }
public static void TwoParametersFirstForbidden([ForbidLiteral] string first, string second) { }
public static void TwoParametersBothForbidden([ForbidLiteral] string first, [ForbidLiteral] string second) { }
public static void ListParameterForbidden([ForbidLiteral] List<string> values) { }
public static void ParamsListParameterForbidden([ForbidLiteral] params List<string> values) { }
}
public record struct StringWrapper(string value)
{
private readonly string _value = value;
public static implicit operator string(StringWrapper wrapper)
{
return wrapper._value;
}
}
""";
[Test]
public async Task TestOneParameter()
{
const string code = """
public sealed class Tester
{
private const string _constValue = "foo";
private static readonly string StaticValue = "bar";
private static readonly StringWrapper WrappedValue = new("biz");
public void Test()
{
TestClass.OneParameterForbidden(_constValue);
TestClass.OneParameterForbidden(StaticValue);
TestClass.OneParameterForbidden(WrappedValue);
TestClass.OneParameterForbidden("baz");
}
}
""";
await Verifier(code,
// /0/Test0.cs(12,41): error RA0033: The "value" parameter of OneParameterForbidden forbids literal values
VerifyCS.Diagnostic().WithSpan(12, 41, 12, 46).WithArguments("value", "OneParameterForbidden")
);
}
[Test]
public async Task TestTwoParametersFirstForbidden()
{
const string code = """
public sealed class Tester
{
private const string _constValue = "foo";
public void Test()
{
TestClass.TwoParametersFirstForbidden(_constValue, "whatever");
TestClass.TwoParametersFirstForbidden(_constValue, _constValue);
TestClass.TwoParametersFirstForbidden("foo", "whatever");
}
}
""";
await Verifier(code,
// /0/Test0.cs(9,47): error RA0033: The "first" parameter of TwoParametersFirstForbidden forbids literal values
VerifyCS.Diagnostic().WithSpan(9, 47, 9, 52).WithArguments("first", "TwoParametersFirstForbidden")
);
}
[Test]
public async Task TestTwoParametersBothForbidden()
{
const string code = """
public sealed class Tester
{
private const string _constValue = "foo";
private static readonly string StaticValue = "bar";
public void Test()
{
TestClass.TwoParametersBothForbidden(_constValue, _constValue);
TestClass.TwoParametersBothForbidden(_constValue, StaticValue);
TestClass.TwoParametersBothForbidden(_constValue, "whatever");
TestClass.TwoParametersBothForbidden("whatever", _constValue);
}
}
""";
await Verifier(code,
// /0/Test0.cs(10,59): error RA0033: The "second" parameter of TwoParametersBothForbidden forbids literal values
VerifyCS.Diagnostic().WithSpan(10, 59, 10, 69).WithArguments("second", "TwoParametersBothForbidden"),
// /0/Test0.cs(11,46): error RA0033: The "first" parameter of TwoParametersBothForbidden forbids literal values
VerifyCS.Diagnostic().WithSpan(11, 46, 11, 56).WithArguments("first", "TwoParametersBothForbidden")
);
}
[Test]
public async Task TestListParameter()
{
const string code = """
public sealed class Tester
{
private const string _constValue = "foo";
private static readonly string StaticValue = "bar";
private static readonly StringWrapper WrappedValue = new("biz");
public void Test()
{
TestClass.ListParameterForbidden([_constValue, StaticValue, WrappedValue]);
TestClass.ListParameterForbidden(["foo", _constValue, "bar"]);
}
}
""";
await Verifier(code,
// /0/Test0.cs(10,43): warning RA0033: The "values" parameter of ListParameterForbidden forbids literal values
VerifyCS.Diagnostic().WithSpan(10, 43, 10, 48).WithArguments("values", "ListParameterForbidden"),
// /0/Test0.cs(10,63): warning RA0033: The "values" parameter of ListParameterForbidden forbids literal values
VerifyCS.Diagnostic().WithSpan(10, 63, 10, 68).WithArguments("values", "ListParameterForbidden")
);
}
[Test]
public async Task TestParamsListParameter()
{
const string code = """
public sealed class Tester
{
private const string _constValue = "foo";
private static readonly string StaticValue = "bar";
private static readonly StringWrapper WrappedValue = new("biz");
public void Test()
{
TestClass.ParamsListParameterForbidden(_constValue, StaticValue, WrappedValue);
TestClass.ParamsListParameterForbidden("foo", _constValue, "bar");
}
}
""";
await Verifier(code,
// /0/Test0.cs(10,48): warning RA0033: The "values" parameter of ParamsListParameterForbidden forbids literal values
VerifyCS.Diagnostic().WithSpan(10, 48, 10, 53).WithArguments("values", "ParamsListParameterForbidden"),
// /0/Test0.cs(10,68): warning RA0033: The "values" parameter of ParamsListParameterForbidden forbids literal values
VerifyCS.Diagnostic().WithSpan(10, 68, 10, 73).WithArguments("values", "ParamsListParameterForbidden")
);
}
}

View File

@@ -0,0 +1,86 @@
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.ObsoleteInheritanceAnalyzer, Microsoft.CodeAnalysis.Testing.DefaultVerifier>;
namespace Robust.Analyzers.Tests;
/// <summary>
/// Analyzer that implements <c>[ObsoleteInheritance]</c> checking, to give obsoletion warnings for inheriting types
/// that should never have been virtual.
/// </summary>
[Parallelizable(ParallelScope.All | ParallelScope.Fixtures)]
[TestFixture]
public sealed class ObsoleteInheritanceAnalyzerTest
{
private static Task Verifier(string code, params DiagnosticResult[] expected)
{
var test = new CSharpAnalyzerTest<ObsoleteInheritanceAnalyzer, DefaultVerifier>()
{
TestState =
{
Sources = { code },
},
};
TestHelper.AddEmbeddedSources(
test.TestState,
"Robust.Shared.Analyzers.ObsoleteInheritanceAttribute.cs"
);
// ExpectedDiagnostics cannot be set, so we need to AddRange here...
test.TestState.ExpectedDiagnostics.AddRange(expected);
return test.RunAsync();
}
[Test]
public async Task TestBasic()
{
const string code = """
using Robust.Shared.Analyzers;
[ObsoleteInheritance]
public class Base;
public class NotAllowed : Base;
""";
await Verifier(code,
// /0/Test0.cs(6,14): warning RA0034: Type 'NotAllowed' inherits from 'Base', which has obsoleted inheriting from itself
VerifyCS.Diagnostic(ObsoleteInheritanceAnalyzer.Rule).WithSpan(6, 14, 6, 24).WithArguments("NotAllowed", "Base")
);
}
[Test]
public async Task TestMessage()
{
const string code = """
using Robust.Shared.Analyzers;
[ObsoleteInheritance("Sus")]
public class Base;
public class NotAllowed : Base;
""";
await Verifier(code,
// /0/Test0.cs(6,14): warning RA0034: Type 'NotAllowed' inherits from 'Base', which has obsoleted inheriting from itself: "Sus"
VerifyCS.Diagnostic(ObsoleteInheritanceAnalyzer.RuleWithMessage).WithSpan(6, 14, 6, 24).WithArguments("NotAllowed", "Base", "Sus")
);
}
[Test]
public async Task TestNormal()
{
const string code = """
public class Base;
public class AllowedAllowed : Base;
""";
await Verifier(code);
}
}

View File

@@ -0,0 +1,64 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using NUnit.Framework;
using VerifyCS =
Microsoft.CodeAnalysis.CSharp.Testing.CSharpAnalyzerVerifier<Robust.Analyzers.PrototypeInstantiationAnalyzer, Microsoft.CodeAnalysis.Testing.DefaultVerifier>;
namespace Robust.Analyzers.Tests;
[Parallelizable(ParallelScope.All | ParallelScope.Fixtures)]
[TestFixture]
[TestOf(typeof(PrototypeInstantiationAnalyzer))]
public sealed class PrototypeInstantiationAnalyzerTest
{
private static Task Verifier(string code, params DiagnosticResult[] expected)
{
var test = new RTAnalyzerTest<PrototypeInstantiationAnalyzer>()
{
TestState =
{
Sources = { code }
},
};
TestHelper.AddEmbeddedSources(
test.TestState,
"Robust.Shared.Prototypes.Attributes.cs",
"Robust.Shared.Prototypes.IPrototype.cs",
"Robust.Shared.Serialization.Manager.Attributes.DataFieldAttribute.cs"
);
// ExpectedDiagnostics cannot be set, so we need to AddRange here...
test.TestState.ExpectedDiagnostics.AddRange(expected);
return test.RunAsync();
}
[Test]
public async Task Test()
{
const string code = """
using Robust.Shared.Serialization;
using Robust.Shared.Prototypes;
[Prototype]
public sealed class FooPrototype : IPrototype
{
[IdDataField]
public string ID { get; private set; } = default!;
}
public static class Bad
{
public static FooPrototype Real()
{
return new FooPrototype();
}
}
""";
await Verifier(code,
// /0/Test0.cs(15,16): warning RA0039: Do not instantiate prototypes directly. Prototypes should always be instantiated by the prototype manager.
VerifyCS.Diagnostic().WithSpan(15, 16, 15, 34));
}
}

View File

@@ -0,0 +1,61 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using NUnit.Framework;
using VerifyCS =
Microsoft.CodeAnalysis.CSharp.Testing.CSharpAnalyzerVerifier<Robust.Analyzers.PrototypeNetSerializableAnalyzer, Microsoft.CodeAnalysis.Testing.DefaultVerifier>;
namespace Robust.Analyzers.Tests;
[Parallelizable(ParallelScope.All | ParallelScope.Fixtures)]
[TestFixture]
[TestOf(typeof(PrototypeNetSerializableAnalyzer))]
public sealed class PrototypeNetSerializableAnalyzerTest
{
private static Task Verifier(string code, params DiagnosticResult[] expected)
{
var test = new RTAnalyzerTest<PrototypeNetSerializableAnalyzer>()
{
TestState =
{
Sources = { code }
},
};
TestHelper.AddEmbeddedSources(
test.TestState,
"Robust.Shared.Serialization.NetSerializableAttribute.cs",
"Robust.Shared.Prototypes.Attributes.cs",
"Robust.Shared.Prototypes.IPrototype.cs",
"Robust.Shared.Serialization.Manager.Attributes.DataFieldAttribute.cs"
);
// ExpectedDiagnostics cannot be set, so we need to AddRange here...
test.TestState.ExpectedDiagnostics.AddRange(expected);
return test.RunAsync();
}
[Test]
public async Task Test()
{
const string code = """
using System;
using Robust.Shared.Serialization;
using Robust.Shared.Prototypes;
[Prototype]
[Serializable, NetSerializable]
public sealed class FooPrototype : IPrototype
{
[IdDataField]
public string ID { get; private set; } = default!;
}
""";
await Verifier(code,
// /0/Test0.cs(7,21): warning RA0037: Type FooPrototype is a prototype and marked as [NetSerializable]. Prototypes should not be directly sent over the network, send their IDs instead.
VerifyCS.Diagnostic(PrototypeNetSerializableAnalyzer.RuleNetSerializable).WithSpan(7, 21, 7, 33).WithArguments("FooPrototype"),
// /0/Test0.cs(7,21): warning RA0038: Type FooPrototype is a prototype and marked as [Serializable]. Prototypes should not be directly sent over the network, send their IDs instead.
VerifyCS.Diagnostic(PrototypeNetSerializableAnalyzer.RuleSerializable).WithSpan(7, 21, 7, 33).WithArguments("FooPrototype"));
}
}

View File

@@ -0,0 +1,17 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Testing;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Testing;
namespace Robust.Analyzers.Tests;
public sealed class RTAnalyzerTest<TAnalyzer> : CSharpAnalyzerTest<TAnalyzer, DefaultVerifier>
where TAnalyzer : DiagnosticAnalyzer, new()
{
protected override ParseOptions CreateParseOptions()
{
var baseOptions = (CSharpParseOptions) base.CreateParseOptions();
return baseOptions.WithPreprocessorSymbols("ROBUST_ANALYZERS_TEST");
}
}

View File

@@ -10,11 +10,18 @@
<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" />
<EmbeddedResource Include="..\Robust.Shared\IoC\DependencyAttribute.cs" LogicalName="Robust.Shared.IoC.DependencyAttribute.cs" LinkBase="Implementations" />
<EmbeddedResource Include="..\Robust.Shared\Analyzers\ForbidLiteralAttribute.cs" LogicalName="Robust.Shared.Analyzers.ForbidLiteralAttribute.cs" LinkBase="Implementations" />
<EmbeddedResource Include="..\Robust.Shared.Utility\Analyzers\ObsoleteInheritanceAttribute.cs" LogicalName="Robust.Shared.Analyzers.ObsoleteInheritanceAttribute.cs" LinkBase="Implementations" />
<EmbeddedResource Include="..\Robust.Shared.Utility\IoC\DependencyAttribute.cs" LogicalName="Robust.Shared.IoC.DependencyAttribute.cs" LinkBase="Implementations" />
<EmbeddedResource Include="..\Robust.Shared\GameObjects\EventBusAttributes.cs" LogicalName="Robust.Shared.GameObjects.EventBusAttributes.cs" LinkBase="Implementations" />
<EmbeddedResource Include="..\Robust.Shared\Serialization\NetSerializableAttribute.cs" LogicalName="Robust.Shared.Serialization.NetSerializableAttribute.cs" LinkBase="Implementations" />
<EmbeddedResource Include="..\Robust.Shared\Prototypes\Attributes.cs" LogicalName="Robust.Shared.Prototypes.Attributes.cs" LinkBase="Implementations" />
<EmbeddedResource Include="..\Robust.Shared\Prototypes\IPrototype.cs" LogicalName="Robust.Shared.Prototypes.IPrototype.cs" LinkBase="Implementations" />
<EmbeddedResource Include="..\Robust.Shared\Serialization\Manager\Attributes\DataFieldAttribute.cs" LogicalName="Robust.Shared.Serialization.Manager.Attributes.DataFieldAttribute.cs" LinkBase="Implementations" />
</ItemGroup>
<PropertyGroup>

View 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));
}
}

View File

@@ -18,10 +18,11 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
private const string ImplicitDataDefinitionNamespace = "Robust.Shared.Serialization.Manager.Attributes.ImplicitDataDefinitionForInheritorsAttribute";
private const string DataFieldBaseNamespace = "Robust.Shared.Serialization.Manager.Attributes.DataFieldBaseAttribute";
private const string ViewVariablesNamespace = "Robust.Shared.ViewVariables.ViewVariablesAttribute";
private const string NotYamlSerializableName = "Robust.Shared.Serialization.Manager.Attributes.NotYamlSerializableAttribute";
private const string DataFieldAttributeName = "DataField";
private const string ViewVariablesAttributeName = "ViewVariables";
private static readonly DiagnosticDescriptor DataDefinitionPartialRule = new(
public static readonly DiagnosticDescriptor DataDefinitionPartialRule = new(
Diagnostics.IdDataDefinitionPartial,
"Type must be partial",
"Type {0} is a DataDefinition but is not partial",
@@ -31,7 +32,7 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
"Make sure to mark any type that is a data definition as partial."
);
private static readonly DiagnosticDescriptor NestedDataDefinitionPartialRule = new(
public static readonly DiagnosticDescriptor NestedDataDefinitionPartialRule = new(
Diagnostics.IdNestedDataDefinitionPartial,
"Type must be partial",
"Type {0} contains nested data definition {1} but is not partial",
@@ -41,7 +42,7 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
"Make sure to mark any type containing a nested data definition as partial."
);
private static readonly DiagnosticDescriptor DataFieldWritableRule = new(
public static readonly DiagnosticDescriptor DataFieldWritableRule = new(
Diagnostics.IdDataFieldWritable,
"Data field must not be readonly",
"Data field {0} in data definition {1} is readonly",
@@ -51,7 +52,7 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
"Make sure to remove the readonly modifier."
);
private static readonly DiagnosticDescriptor DataFieldPropertyWritableRule = new(
public static readonly DiagnosticDescriptor DataFieldPropertyWritableRule = new(
Diagnostics.IdDataFieldPropertyWritable,
"Data field property must have a setter",
"Data field property {0} in data definition {1} does not have a setter",
@@ -61,7 +62,7 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
"Make sure to add a setter."
);
private static readonly DiagnosticDescriptor DataFieldRedundantTagRule = new(
public static readonly DiagnosticDescriptor DataFieldRedundantTagRule = new(
Diagnostics.IdDataFieldRedundantTag,
"Data field has redundant tag specified",
"Data field {0} in data definition {1} has an explicitly set tag that matches autogenerated tag",
@@ -81,9 +82,19 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
"Make sure to remove the ViewVariables attribute."
);
public static readonly DiagnosticDescriptor DataFieldYamlSerializableRule = new(
Diagnostics.IdDataFieldYamlSerializable,
"Data field type is not YAML serializable",
"Data field {0} in data definition {1} is type {2}, which is not YAML serializable",
"Usage",
DiagnosticSeverity.Error,
true,
"Make sure to use a type that is YAML serializable."
);
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(
DataDefinitionPartialRule, NestedDataDefinitionPartialRule, DataFieldWritableRule, DataFieldPropertyWritableRule,
DataFieldRedundantTagRule, DataFieldNoVVReadWriteRule
DataFieldRedundantTagRule, DataFieldNoVVReadWriteRule, DataFieldYamlSerializableRule
);
public override void Initialize(AnalysisContext context)
@@ -91,23 +102,31 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.None);
context.EnableConcurrentExecution();
context.RegisterSyntaxNodeAction(AnalyzeDataDefinition, SyntaxKind.ClassDeclaration);
context.RegisterSyntaxNodeAction(AnalyzeDataDefinition, SyntaxKind.StructDeclaration);
context.RegisterSyntaxNodeAction(AnalyzeDataDefinition, SyntaxKind.RecordDeclaration);
context.RegisterSyntaxNodeAction(AnalyzeDataDefinition, SyntaxKind.RecordStructDeclaration);
context.RegisterSyntaxNodeAction(AnalyzeDataDefinition, SyntaxKind.InterfaceDeclaration);
context.RegisterSymbolStartAction(symbolContext =>
{
if (symbolContext.Symbol is not INamedTypeSymbol typeSymbol)
return;
context.RegisterSyntaxNodeAction(AnalyzeDataField, SyntaxKind.FieldDeclaration);
context.RegisterSyntaxNodeAction(AnalyzeDataFieldProperty, SyntaxKind.PropertyDeclaration);
if (!IsDataDefinition(typeSymbol))
return;
symbolContext.RegisterSyntaxNodeAction(AnalyzeDataDefinition, SyntaxKind.ClassDeclaration);
symbolContext.RegisterSyntaxNodeAction(AnalyzeDataDefinition, SyntaxKind.StructDeclaration);
symbolContext.RegisterSyntaxNodeAction(AnalyzeDataDefinition, SyntaxKind.RecordDeclaration);
symbolContext.RegisterSyntaxNodeAction(AnalyzeDataDefinition, SyntaxKind.RecordStructDeclaration);
symbolContext.RegisterSyntaxNodeAction(AnalyzeDataDefinition, SyntaxKind.InterfaceDeclaration);
symbolContext.RegisterSyntaxNodeAction(AnalyzeDataField, SyntaxKind.FieldDeclaration);
symbolContext.RegisterSyntaxNodeAction(AnalyzeDataFieldProperty, SyntaxKind.PropertyDeclaration);
}, SymbolKind.NamedType);
}
private void AnalyzeDataDefinition(SyntaxNodeAnalysisContext context)
private static void AnalyzeDataDefinition(SyntaxNodeAnalysisContext context)
{
if (context.Node is not TypeDeclarationSyntax declaration)
return;
var type = context.SemanticModel.GetDeclaredSymbol(declaration)!;
if (!IsDataDefinition(type))
if (context.ContainingSymbol is not INamedTypeSymbol type)
return;
if (!IsPartial(declaration))
@@ -118,7 +137,7 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
var containingType = type.ContainingType;
while (containingType != null)
{
var containingTypeDeclaration = (TypeDeclarationSyntax) containingType.DeclaringSyntaxReferences[0].GetSyntax();
var containingTypeDeclaration = (TypeDeclarationSyntax)containingType.DeclaringSyntaxReferences[0].GetSyntax();
if (!IsPartial(containingTypeDeclaration))
{
context.ReportDiagnostic(Diagnostic.Create(NestedDataDefinitionPartialRule, containingTypeDeclaration.Keyword.GetLocation(), containingType.Name, type.Name));
@@ -128,31 +147,31 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
}
}
private void AnalyzeDataField(SyntaxNodeAnalysisContext context)
private static void AnalyzeDataField(SyntaxNodeAnalysisContext context)
{
if (context.Node is not FieldDeclarationSyntax field)
return;
var typeDeclaration = field.FirstAncestorOrSelf<TypeDeclarationSyntax>();
if (typeDeclaration == null)
return;
var type = context.SemanticModel.GetDeclaredSymbol(typeDeclaration)!;
if (!IsDataDefinition(type))
if (context.ContainingSymbol?.ContainingType is not INamedTypeSymbol type)
return;
foreach (var variable in field.Declaration.Variables)
{
var fieldSymbol = context.SemanticModel.GetDeclaredSymbol(variable);
if (fieldSymbol == null)
continue;
if (!IsDataField(fieldSymbol, out _, out var datafieldAttribute))
continue;
if (IsReadOnlyDataField(type, fieldSymbol))
{
context.ReportDiagnostic(Diagnostic.Create(DataFieldWritableRule, context.Node.GetLocation(), fieldSymbol.Name, type.Name));
TryGetModifierLocation(field, SyntaxKind.ReadOnlyKeyword, out var location);
context.ReportDiagnostic(Diagnostic.Create(DataFieldWritableRule, location, fieldSymbol.Name, type.Name));
}
if (HasRedundantTag(fieldSymbol))
if (HasRedundantTag(fieldSymbol, datafieldAttribute))
{
TryGetAttributeLocation(field, DataFieldAttributeName, out var location);
context.ReportDiagnostic(Diagnostic.Create(DataFieldRedundantTagRule, location, fieldSymbol.Name, type.Name));
@@ -163,32 +182,51 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
TryGetAttributeLocation(field, ViewVariablesAttributeName, out var location);
context.ReportDiagnostic(Diagnostic.Create(DataFieldNoVVReadWriteRule, location, fieldSymbol.Name, type.Name));
}
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,
(context.Node as FieldDeclarationSyntax)?.Declaration.Type.GetLocation(),
fieldSymbol.Name,
type.Name,
fieldTypeSymbol.MetadataName
));
}
}
}
private void AnalyzeDataFieldProperty(SyntaxNodeAnalysisContext context)
private static void AnalyzeDataFieldProperty(SyntaxNodeAnalysisContext context)
{
if (context.Node is not PropertyDeclarationSyntax property)
return;
var typeDeclaration = property.FirstAncestorOrSelf<TypeDeclarationSyntax>();
if (typeDeclaration == null)
if (context.ContainingSymbol is not IPropertySymbol propertySymbol)
return;
var type = context.SemanticModel.GetDeclaredSymbol(typeDeclaration)!;
if (!IsDataDefinition(type) || type.IsRecord || type.IsValueType)
if (propertySymbol.ContainingType is not INamedTypeSymbol type)
return;
if (type.IsRecord || type.IsValueType)
return;
var propertySymbol = context.SemanticModel.GetDeclaredSymbol(property);
if (propertySymbol == null)
return;
if (!IsDataField(propertySymbol, out _, out var datafieldAttribute))
return;
if (IsReadOnlyDataField(type, propertySymbol))
{
context.ReportDiagnostic(Diagnostic.Create(DataFieldPropertyWritableRule, context.Node.GetLocation(), propertySymbol.Name, type.Name));
var location = property.AccessorList != null ? property.AccessorList.GetLocation() : property.GetLocation();
context.ReportDiagnostic(Diagnostic.Create(DataFieldPropertyWritableRule, location, propertySymbol.Name, type.Name));
}
if (HasRedundantTag(propertySymbol))
if (HasRedundantTag(propertySymbol, datafieldAttribute))
{
TryGetAttributeLocation(property, DataFieldAttributeName, out var location);
context.ReportDiagnostic(Diagnostic.Create(DataFieldRedundantTagRule, location, propertySymbol.Name, type.Name));
@@ -199,13 +237,25 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
TryGetAttributeLocation(property, ViewVariablesAttributeName, out var location);
context.ReportDiagnostic(Diagnostic.Create(DataFieldNoVVReadWriteRule, location, propertySymbol.Name, type.Name));
}
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,
(context.Node as PropertyDeclarationSyntax)?.Type.GetLocation(),
propertySymbol.Name,
type.Name,
propertyTypeSymbol.Name
));
}
}
private static bool IsReadOnlyDataField(ITypeSymbol type, ISymbol field)
{
if (!IsDataField(field, out _, out _))
return false;
return IsReadOnlyMember(type, field);
}
@@ -285,6 +335,20 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
return false;
}
private static bool TryGetModifierLocation(MemberDeclarationSyntax syntax, SyntaxKind modifierKind, out Location location)
{
foreach (var modifier in syntax.Modifiers)
{
if (modifier.IsKind(modifierKind))
{
location = modifier.GetLocation();
return true;
}
}
location = syntax.GetLocation();
return false;
}
private static bool IsReadOnlyMember(ITypeSymbol type, ISymbol member)
{
if (member is IFieldSymbol field)
@@ -316,17 +380,14 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
return false;
}
private static bool HasRedundantTag(ISymbol symbol)
private static bool HasRedundantTag(ISymbol symbol, AttributeData datafieldAttribute)
{
if (!IsDataField(symbol, out var _, out var attribute))
return false;
// No args, no problem
if (attribute.ConstructorArguments.Length == 0)
if (datafieldAttribute.ConstructorArguments.Length == 0)
return false;
// If a tag is explicitly specified, it will be the first argument...
var tagArgument = attribute.ConstructorArguments[0];
var tagArgument = datafieldAttribute.ConstructorArguments[0];
// ...but the first arg could also something else, since tag is optional
// so we make sure that it's a string
if (tagArgument.Value is not string explicitName)
@@ -341,9 +402,6 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
private static bool HasVVReadWrite(ISymbol symbol)
{
if (!IsDataField(symbol, out _, out _))
return false;
// Make sure it has ViewVariablesAttribute
AttributeData? viewVariablesAttribute = null;
foreach (var attr in symbol.GetAttributes())
@@ -367,6 +425,11 @@ public sealed class DataDefinitionAnalyzer : DiagnosticAnalyzer
return (VVAccess)accessByte == VVAccess.ReadWrite;
}
private static bool IsNotYamlSerializable(ISymbol field, ITypeSymbol type)
{
return HasAttribute(type, NotYamlSerializableName);
}
private static bool IsImplicitDataDefinition(ITypeSymbol type)
{
if (HasAttribute(type, ImplicitDataDefinitionNamespace))

View File

@@ -0,0 +1,101 @@
using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
using Robust.Roslyn.Shared;
namespace Robust.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class ForbidLiteralAnalyzer : DiagnosticAnalyzer
{
private const string ForbidLiteralType = "Robust.Shared.Analyzers.ForbidLiteralAttribute";
public static DiagnosticDescriptor ForbidLiteralRule = new(
Diagnostics.IdForbidLiteral,
"Parameter forbids literal values",
"The {0} parameter of {1} forbids literal values",
"Usage",
DiagnosticSeverity.Warning,
true,
"Pass in a validated wrapper type like ProtoId, or a const or static value."
);
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => [ForbidLiteralRule];
public override void Initialize(AnalysisContext context)
{
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
context.EnableConcurrentExecution();
context.RegisterOperationAction(AnalyzeOperation, OperationKind.Invocation);
}
private void AnalyzeOperation(OperationAnalysisContext context)
{
if (context.Operation is not IInvocationOperation invocationOperation)
return;
// Check each parameter of the method invocation
foreach (var argumentOperation in invocationOperation.Arguments)
{
// Check for our attribute on the parameter
if (!AttributeHelper.HasAttribute(argumentOperation.Parameter, ForbidLiteralType, out _))
continue;
// Handle parameters using the params keyword
if (argumentOperation.Syntax is InvocationExpressionSyntax subExpressionSyntax)
{
// Check each param value
foreach (var subArgument in subExpressionSyntax.ArgumentList.Arguments)
{
CheckArgumentSyntax(context, argumentOperation, subArgument);
}
continue;
}
// Not params, so just check the single parameter
if (argumentOperation.Syntax is not ArgumentSyntax argumentSyntax)
continue;
CheckArgumentSyntax(context, argumentOperation, argumentSyntax);
}
}
private void CheckArgumentSyntax(OperationAnalysisContext context, IArgumentOperation operation, ArgumentSyntax argumentSyntax)
{
// Handle collection types
if (argumentSyntax.Expression is CollectionExpressionSyntax collectionExpressionSyntax)
{
// Check each value of the collection
foreach (var elementSyntax in collectionExpressionSyntax.Elements)
{
if (elementSyntax is not ExpressionElementSyntax expressionSyntax)
continue;
// Check if a literal was passed in
if (expressionSyntax.Expression is not LiteralExpressionSyntax)
continue;
context.ReportDiagnostic(Diagnostic.Create(ForbidLiteralRule,
expressionSyntax.GetLocation(),
operation.Parameter.Name,
(context.Operation as IInvocationOperation).TargetMethod.Name
));
}
return;
}
// Not a collection, just a single value to check
// Check if it's a literal
if (argumentSyntax.Expression is not LiteralExpressionSyntax)
return;
context.ReportDiagnostic(Diagnostic.Create(ForbidLiteralRule,
argumentSyntax.GetLocation(),
operation.Parameter.Name,
(context.Operation as IInvocationOperation).TargetMethod.Name
));
}
}

View File

@@ -0,0 +1,75 @@
#nullable enable
using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Robust.Roslyn.Shared;
namespace Robust.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class ObsoleteInheritanceAnalyzer : DiagnosticAnalyzer
{
private const string Attribute = "Robust.Shared.Analyzers.ObsoleteInheritanceAttribute";
public static readonly DiagnosticDescriptor Rule = new(
Diagnostics.IdObsoleteInheritance,
"Parent type has obsoleted inheritance",
"Type '{0}' inherits from '{1}', which has obsoleted inheriting from itself",
"Usage",
DiagnosticSeverity.Warning,
true);
public static readonly DiagnosticDescriptor RuleWithMessage = new(
Diagnostics.IdObsoleteInheritanceWithMessage,
"Parent type has obsoleted inheritance",
"Type '{0}' inherits from '{1}', which has obsoleted inheriting from itself: \"{2}\"",
"Usage",
DiagnosticSeverity.Warning,
true);
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => [Rule, RuleWithMessage];
public override void Initialize(AnalysisContext context)
{
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
context.EnableConcurrentExecution();
context.RegisterSymbolAction(CheckClass, SymbolKind.NamedType);
}
private static void CheckClass(SymbolAnalysisContext context)
{
if (context.Symbol is not INamedTypeSymbol typeSymbol)
return;
if (typeSymbol.IsValueType || typeSymbol.BaseType is not { } baseType)
return;
if (!AttributeHelper.HasAttribute(baseType, Attribute, out var data))
return;
var location = context.Symbol.Locations[0];
if (GetMessageFromAttributeData(data) is { } message)
{
context.ReportDiagnostic(Diagnostic.Create(
RuleWithMessage,
location,
[typeSymbol.Name, baseType.Name, message]));
}
else
{
context.ReportDiagnostic(Diagnostic.Create(
Rule,
location,
[typeSymbol.Name, baseType.Name]));
}
}
private static string? GetMessageFromAttributeData(AttributeData data)
{
if (data.ConstructorArguments is not [var message, ..])
return null;
return message.Value as string;
}
}

View File

@@ -0,0 +1,48 @@
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 PrototypeInstantiationAnalyzer : DiagnosticAnalyzer
{
private const string PrototypeInterfaceType = "Robust.Shared.Prototypes.IPrototype";
public static readonly DiagnosticDescriptor Rule = new(
Diagnostics.IdPrototypeInstantiation,
"Do not instantiate prototypes directly",
"Do not instantiate prototypes directly. Prototypes should always be instantiated by the prototype manager.",
"Usage",
DiagnosticSeverity.Warning,
true);
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => [Rule];
public override void Initialize(AnalysisContext context)
{
context.EnableConcurrentExecution();
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
context.RegisterCompilationStartAction(static ctx =>
{
var prototypeInterface = ctx.Compilation.GetTypeByMetadataName(PrototypeInterfaceType);
if (prototypeInterface == null)
return;
ctx.RegisterOperationAction(symContext => Check(prototypeInterface, symContext), OperationKind.ObjectCreation);
});
}
private static void Check(INamedTypeSymbol prototypeInterface, OperationAnalysisContext ctx)
{
if (ctx.Operation is not IObjectCreationOperation { Type: { } resultType } creationOp)
return;
if (!TypeSymbolHelper.ImplementsInterface(resultType, prototypeInterface))
return;
ctx.ReportDiagnostic(Diagnostic.Create(Rule, creationOp.Syntax.GetLocation()));
}
}

View File

@@ -0,0 +1,76 @@
using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Robust.Roslyn.Shared;
namespace Robust.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class PrototypeNetSerializableAnalyzer : DiagnosticAnalyzer
{
private const string PrototypeInterfaceType = "Robust.Shared.Prototypes.IPrototype";
private const string NetSerializableAttributeType = "Robust.Shared.Serialization.NetSerializableAttribute";
public static readonly DiagnosticDescriptor RuleNetSerializable = new(
Diagnostics.IdPrototypeNetSerializable,
"Prototypes should not be [NetSerializable]",
"Type {0} is a prototype and marked as [NetSerializable]. Prototypes should not be directly sent over the network, send their IDs instead.",
"Usage",
DiagnosticSeverity.Warning,
true);
public static readonly DiagnosticDescriptor RuleSerializable = new(
Diagnostics.IdPrototypeSerializable,
"Prototypes should not be [Serializable]",
"Type {0} is a prototype and marked as [Serializable]. Prototypes should not be directly sent over the network, send their IDs instead.",
"Usage",
DiagnosticSeverity.Warning,
true);
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => [
RuleNetSerializable,
RuleSerializable
];
public override void Initialize(AnalysisContext context)
{
context.EnableConcurrentExecution();
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
context.RegisterCompilationStartAction(static ctx =>
{
var prototypeInterface = ctx.Compilation.GetTypeByMetadataName(PrototypeInterfaceType);
var netSerializableAttribute = ctx.Compilation.GetTypeByMetadataName(NetSerializableAttributeType);
if (prototypeInterface == null || netSerializableAttribute == null)
return;
ctx.RegisterSymbolAction(symbolContext => CheckClass(prototypeInterface, netSerializableAttribute, symbolContext), SymbolKind.NamedType);
});
}
private static void CheckClass(
INamedTypeSymbol prototypeInterface,
INamedTypeSymbol netSerializableAttribute,
SymbolAnalysisContext symbolContext)
{
if (symbolContext.Symbol is not INamedTypeSymbol symbol)
return;
if (!TypeSymbolHelper.ImplementsInterface(symbol, prototypeInterface))
return;
if (AttributeHelper.HasAttribute(symbol, netSerializableAttribute, out _))
{
symbolContext.ReportDiagnostic(
Diagnostic.Create(RuleNetSerializable, symbol.Locations[0], symbol.ToDisplayString()));
}
if (symbol.IsSerializable)
{
symbolContext.ReportDiagnostic(
Diagnostic.Create(RuleSerializable, symbol.Locations[0], symbol.ToDisplayString()));
}
}
}

View File

@@ -0,0 +1,96 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using JetBrains.Annotations;
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.UnitTesting.Server;
namespace Robust.Benchmarks.EntityManager;
[Virtual]
public partial class HasComponentBenchmark
{
private static readonly Consumer Consumer = new();
private ISimulation _simulation = default!;
private IEntityManager _entityManager = default!;
private ComponentRegistration _compReg = default!;
private A _dummyA = new();
[UsedImplicitly]
[Params(1, 10, 100, 1000)]
public int N;
[GlobalSetup]
public void GlobalSetup()
{
_simulation = RobustServerSimulation
.NewSimulation()
.RegisterComponents(f => f.RegisterClass<A>())
.InitializeInstance();
_entityManager = _simulation.Resolve<IEntityManager>();
var map = _simulation.CreateMap().Uid;
var coords = new EntityCoordinates(map, default);
_compReg = _entityManager.ComponentFactory.GetRegistration(typeof(A));
for (var i = 0; i < N; i++)
{
var uid = _entityManager.SpawnEntity(null, coords);
_entityManager.AddComponent<A>(uid);
}
}
[Benchmark]
public void HasComponentGeneric()
{
for (var i = 2; i <= N+1; i++)
{
var uid = new EntityUid(i);
var result = _entityManager.HasComponent<A>(uid);
Consumer.Consume(result);
}
}
[Benchmark]
public void HasComponentCompReg()
{
for (var i = 2; i <= N+1; i++)
{
var uid = new EntityUid(i);
var result = _entityManager.HasComponent(uid, _compReg);
Consumer.Consume(result);
}
}
[Benchmark]
public void HasComponentType()
{
for (var i = 2; i <= N+1; i++)
{
var uid = new EntityUid(i);
var result = _entityManager.HasComponent(uid, typeof(A));
Consumer.Consume(result);
}
}
[Benchmark]
public void HasComponentGetType()
{
for (var i = 2; i <= N+1; i++)
{
var uid = new EntityUid(i);
var type = _dummyA.GetType();
var result = _entityManager.HasComponent(uid, type);
Consumer.Consume(result);
}
}
[ComponentProtoName("A")]
public sealed partial class A : Component
{
}
}

View File

@@ -26,10 +26,10 @@ public class PhysicsTumblerBenchmark
var entManager = _sim.Resolve<IEntityManager>();
var physics = entManager.System<SharedPhysicsSystem>();
var fixtures = entManager.System<FixtureSystem>();
entManager.System<SharedMapSystem>().CreateMap(out var mapId);
var mapUid = entManager.System<SharedMapSystem>().CreateMap(out var mapId);
SetupTumbler(entManager, mapId);
for (var i = 0; i < 800; i++)
for (var i = 0; i < 300; i++)
{
entManager.TickUpdate(0.016f, false);
var boxUid = entManager.SpawnEntity(null, new MapCoordinates(0f, 10f, mapId));
@@ -42,6 +42,9 @@ public class PhysicsTumblerBenchmark
physics.WakeBody(boxUid, body: box);
physics.SetSleepingAllowed(boxUid, box, false);
}
if (entManager.TryGetComponent(mapUid, out BroadphaseComponent? mapBroadphase))
entManager.System<SharedBroadphaseSystem>().RebuildBottomUp(mapBroadphase);
}
[Benchmark]
@@ -49,7 +52,7 @@ public class PhysicsTumblerBenchmark
{
var entManager = _sim.Resolve<IEntityManager>();
for (var i = 0; i < 5000; i++)
for (var i = 0; i < 1000; i++)
{
entManager.TickUpdate(0.016f, false);
}

View File

@@ -42,8 +42,8 @@ public class RecursiveMoveBenchmark : RobustIntegrationTest
public void GlobalSetup()
{
ProgramShared.PathOffset = "../../../../";
var server = StartServer();
var client = StartClient();
var server = StartServer(new() {Pool = false});
var client = StartClient(new() {Pool = false});
Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync()).Wait();

View File

@@ -0,0 +1,4 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Robust.Client")]
[module: SkipLocalsInit]

View File

@@ -0,0 +1,22 @@
global using Robust.Client.Interop.RobustNative.Webgpu;
global using static Robust.Client.Interop.RobustNative.Webgpu.Wgpu;
global using static Robust.Shared.Utility.FfiHelper;
global using unsafe WGPUTexture = Robust.Client.Interop.RobustNative.Webgpu.WGPUTextureImpl*;
global using unsafe WGPUDevice = Robust.Client.Interop.RobustNative.Webgpu.WGPUDeviceImpl*;
global using unsafe WGPUQueue = Robust.Client.Interop.RobustNative.Webgpu.WGPUQueueImpl*;
global using unsafe WGPUAdapter = Robust.Client.Interop.RobustNative.Webgpu.WGPUAdapterImpl*;
global using unsafe WGPUInstance = Robust.Client.Interop.RobustNative.Webgpu.WGPUInstanceImpl*;
global using unsafe WGPUTextureView = Robust.Client.Interop.RobustNative.Webgpu.WGPUTextureViewImpl*;
global using unsafe WGPUBindGroup = Robust.Client.Interop.RobustNative.Webgpu.WGPUBindGroupImpl*;
global using unsafe WGPUBindGroupLayout = Robust.Client.Interop.RobustNative.Webgpu.WGPUBindGroupLayoutImpl*;
global using unsafe WGPUBuffer = Robust.Client.Interop.RobustNative.Webgpu.WGPUBufferImpl*;
global using unsafe WGPUSampler = Robust.Client.Interop.RobustNative.Webgpu.WGPUSamplerImpl*;
global using unsafe WGPUCommandBuffer = Robust.Client.Interop.RobustNative.Webgpu.WGPUCommandBufferImpl*;
global using unsafe WGPUCommandEncoder = Robust.Client.Interop.RobustNative.Webgpu.WGPUCommandEncoderImpl*;
global using unsafe WGPURenderPassEncoder = Robust.Client.Interop.RobustNative.Webgpu.WGPURenderPassEncoderImpl*;
global using unsafe WGPURenderPipeline = Robust.Client.Interop.RobustNative.Webgpu.WGPURenderPipelineImpl*;
global using unsafe WGPUPipelineLayout = Robust.Client.Interop.RobustNative.Webgpu.WGPUPipelineLayoutImpl*;
global using unsafe WGPUShaderModule = Robust.Client.Interop.RobustNative.Webgpu.WGPUShaderModuleImpl*;
global using unsafe WGPUSurface = Robust.Client.Interop.RobustNative.Webgpu.WGPUSurfaceImpl*;

View File

@@ -0,0 +1,131 @@
using Robust.Client.Graphics.Rhi.WebGpu;
using Robust.Shared.Maths;
namespace Robust.Client.Graphics.Rhi;
public abstract partial class RhiBase
{
//
// Clyde <-> RHI API.
//
internal abstract void Init(in RhiInitParams initParams, out RhiWebGpu.WindowData windowData);
internal abstract void Shutdown();
/// <summary>
/// A window was created by Clyde. It should be initialized by the RHI to make it ready for rendering.
/// </summary>
/// <remarks>
/// Does not get called for the main window.
/// </remarks>
internal abstract RhiWebGpu.WindowData WindowCreated(in RhiWindowSurfaceParams surfaceParams, Vector2i size, bool vsync);
/// <summary>
/// A window is about to be destroyed by Clyde. Clean up resources for it.
/// </summary>
internal abstract void WindowDestroy(RhiWebGpu.WindowData reg);
/// <summary>
/// Recreate the native swap chain, in case it has become suboptimal (e.g. due to window resizing).
/// </summary>
internal abstract void WindowRecreateSwapchain(RhiWebGpu.WindowData reg, Vector2i size, bool vsyncEnabled);
internal abstract RhiTexture GetSurfaceTextureForWindow(RhiWebGpu.WindowData reg);
internal abstract void WindowPresent(RhiWebGpu.WindowData reg);
//
// RHI-internal API to de-OOP the public RHI API.
//
internal abstract RhiRenderPassEncoder CommandEncoderBeginRenderPass(
RhiCommandEncoder encoder,
in RhiRenderPassDescriptor descriptor
);
internal abstract RhiCommandBuffer CommandEncoderFinish(
in RhiCommandEncoder encoder,
in RhiCommandBufferDescriptor descriptor);
internal abstract void RenderPassEncoderSetPipeline(
in RhiRenderPassEncoder encoder,
RhiRenderPipeline pipeline
);
internal abstract void RenderPassEncoderDraw(
in RhiRenderPassEncoder encoder,
uint vertexCount,
uint instanceCount,
uint firstVertex,
uint firstInstance
);
internal abstract void RenderPassEncoderEnd(RhiRenderPassEncoder encoder);
internal abstract void QueueSubmit(RhiQueue queue, RhiCommandBuffer[] commandBuffers);
internal abstract void QueueWriteTexture(
RhiQueue queue,
in RhiImageCopyTexture destination,
ReadOnlySpan<byte> data,
in RhiImageDataLayout dataLayout,
RhiExtent3D size
);
public abstract void QueueWriteBuffer(RhiBuffer buffer, ulong bufferOffset, ReadOnlySpan<byte> data);
internal abstract RhiTextureView TextureCreateView(RhiTexture texture, in RhiTextureViewDescriptor descriptor);
internal abstract void TextureViewDrop(RhiTextureView textureView);
internal abstract void BindGroupDrop(RhiBindGroup rhiBindGroup);
internal abstract void RenderPassEncoderSetBindGroup(
RhiRenderPassEncoder encoder,
uint index,
RhiBindGroup? bindGroup
);
internal abstract void RenderPassEncoderSetVertexBuffer(RhiRenderPassEncoder encoder,
uint slot,
RhiBuffer? buffer,
ulong offset,
ulong? size);
internal abstract void RenderPassEncoderSetScissorRect(RhiRenderPassEncoder encoder,
uint x,
uint y,
uint w,
uint h);
internal abstract void CommandBufferDrop(RhiCommandBuffer commandBuffer);
internal abstract RhiBufferMapState BufferGetMapState(RhiBuffer buffer);
internal abstract ValueTask BufferMapAsync(RhiBuffer buffer, RhiMapModeFlags mode, nuint offset, nuint size);
internal abstract RhiMappedBufferRange BufferGetMappedRange(RhiBuffer buffer, nuint offset, nuint size);
internal abstract void BufferUnmap(RhiBuffer buffer);
internal abstract void BufferDrop(RhiBuffer buffer);
internal struct RhiInitParams
{
public required string Backends;
public required RhiPowerPreference PowerPreference;
public required RhiWindowSurfaceParams MainWindowSurfaceParams;
}
internal unsafe struct RhiWindowSurfaceParams
{
#if WINDOWS
public void* HInstance;
public void* HWnd;
#elif MACOS
public void* MetalLayer;
#elif LINUX
public bool Wayland; // False = X11
public void* X11Display;
public void* X11Window;
public void* WaylandDisplay;
public void* WaylandSurface;
#endif
}
}
internal record struct RhiHandle(long Value);

View File

@@ -0,0 +1,40 @@
using System.Numerics;
using System.Runtime.InteropServices;
namespace Robust.Client.Graphics.Rhi;
/// <summary>
/// Equivalent to a WGSL <c>mat2x3f</c>.
/// </summary>
/// <remarks>
/// This matrix is columnar and 2 columns, 3 rows. This is equivalent to .NET's <see cref="Matrix3x2"/>!
/// </remarks>
[StructLayout(LayoutKind.Explicit)]
public struct ShaderMat2x3F
{
[FieldOffset(0)]
public float M11;
[FieldOffset(4)]
public float M21;
[FieldOffset(8)]
public float M31;
[FieldOffset(16)]
public float M12;
[FieldOffset(20)]
public float M22;
[FieldOffset(24)]
public float M32;
public static ShaderMat2x3F FromMatrix(in Matrix3x2 matrix)
{
var ret = default(ShaderMat2x3F);
ret.M11 = matrix.M11;
ret.M12 = matrix.M12;
ret.M21 = matrix.M21;
ret.M22 = matrix.M22;
ret.M31 = matrix.M31;
ret.M32 = matrix.M32;
return ret;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\MSBuild\Robust.Engine.props"/>
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<SkipRobustSerializationGenerator>true</SkipRobustSerializationGenerator>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Robust.Client.Interop.RobustNative\Robust.Client.Interop.RobustNative.csproj" />
<ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" />
<ProjectReference Include="..\Robust.Shared.Utility\Robust.Shared.Utility.csproj" />
</ItemGroup>
<Import Project="..\MSBuild\Robust.Properties.targets"/>
</Project>

View File

@@ -0,0 +1,113 @@
namespace Robust.Client.Graphics.Rhi.WebGpu;
internal sealed unsafe partial class RhiWebGpu
{
private readonly Dictionary<RhiHandle, BindGroupLayoutReg> _bindGroupLayoutRegistry = new();
private readonly Dictionary<RhiHandle, BindGroupReg> _bindGroupRegistry = new();
internal override void BindGroupDrop(RhiBindGroup rhiBindGroup)
{
wgpuBindGroupRelease(_bindGroupRegistry[rhiBindGroup.Handle].Native);
_bindGroupRegistry.Remove(rhiBindGroup.Handle);
}
public override RhiBindGroupLayout CreateBindGroupLayout(in RhiBindGroupLayoutDescriptor descriptor)
{
Span<byte> buffer = stackalloc byte[512];
var pDescriptor = BumpAllocate<WGPUBindGroupLayoutDescriptor>(ref buffer);
pDescriptor->label = BumpAllocateStringView(ref buffer, descriptor.Label);
var entries = descriptor.Entries;
pDescriptor->entryCount = (uint)entries.Length;
pDescriptor->entries = BumpAllocate<WGPUBindGroupLayoutEntry>(ref buffer, entries.Length);
for (var i = 0; i < entries.Length; i++)
{
ref var entry = ref entries[i];
var pEntry = &pDescriptor->entries[i];
pEntry->binding = entry.Binding;
pEntry->visibility = (ulong)entry.Visibility;
switch (entry.Layout)
{
case RhiSamplerBindingLayout sampler:
pEntry->sampler.type = (WGPUSamplerBindingType)sampler.Type;
break;
case RhiTextureBindingLayout texture:
pEntry->texture.multisampled = texture.Multisampled ? 1u : 0u;
pEntry->texture.sampleType = (WGPUTextureSampleType)texture.SampleType;
pEntry->texture.viewDimension =
(WGPUTextureViewDimension)ValidateTextureViewDimension(texture.ViewDimension);
break;
case RhiBufferBindingLayout layoutBuffer:
pEntry->buffer.type = (WGPUBufferBindingType) layoutBuffer.Type;
pEntry->buffer.hasDynamicOffset = layoutBuffer.HasDynamicOffset ? 1u : 0u;
pEntry->buffer.minBindingSize = layoutBuffer.MinBindingSize;
break;
default:
throw new ArgumentOutOfRangeException();
}
}
var native = wgpuDeviceCreateBindGroupLayout(_wgpuDevice, pDescriptor);
// TODO: Thread safety
var handle = AllocRhiHandle();
_bindGroupLayoutRegistry.Add(handle, new BindGroupLayoutReg { Native = native });
return new RhiBindGroupLayout(this, handle);
}
public override RhiBindGroup CreateBindGroup(in RhiBindGroupDescriptor descriptor)
{
// TODO: SAFETY
Span<byte> buffer = stackalloc byte[1024];
var pDescriptor = BumpAllocate<WGPUBindGroupDescriptor>(ref buffer);
pDescriptor->label = BumpAllocateStringView(ref buffer, descriptor.Label);
pDescriptor->layout = _bindGroupLayoutRegistry[descriptor.Layout.Handle].Native;
var entries = descriptor.Entries;
pDescriptor->entryCount = (uint) entries.Length;
pDescriptor->entries = BumpAllocate<WGPUBindGroupEntry>(ref buffer, entries.Length);
for (var i = 0; i < entries.Length; i++)
{
ref var entry = ref descriptor.Entries[i];
var pEntry = &pDescriptor->entries[i];
pEntry->binding = entry.Binding;
switch (entry.Resource)
{
case RhiSampler rhiSampler:
pEntry->sampler = _samplerRegistry[rhiSampler.Handle].Native;
break;
case RhiTextureView rhiTextureView:
pEntry->textureView = _textureViewRegistry[rhiTextureView.Handle].Native;
break;
case RhiBufferBinding bufferBinding:
pEntry->buffer = _bufferRegistry[bufferBinding.Buffer.Handle].Native;
pEntry->offset = bufferBinding.Offset;
pEntry->size = bufferBinding.Size ?? WGPU_WHOLE_SIZE;
break;
default:
throw new ArgumentOutOfRangeException();
}
}
var bindGroup = wgpuDeviceCreateBindGroup(_wgpuDevice, pDescriptor);
var handle = AllocRhiHandle();
_bindGroupRegistry.Add(handle, new BindGroupReg { Native = bindGroup });
return new RhiBindGroup(this, handle);
}
private sealed class BindGroupLayoutReg
{
public WGPUBindGroupLayout Native;
}
private sealed class BindGroupReg
{
public WGPUBindGroup Native;
}
}

View File

@@ -0,0 +1,148 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Robust.Client.Graphics.Rhi.WebGpu;
internal sealed partial class RhiWebGpu
{
private readonly Dictionary<RhiHandle, BufferReg> _bufferRegistry = new();
public override unsafe RhiBuffer CreateBuffer(in RhiBufferDescriptor descriptor)
{
Span<byte> buffer = stackalloc byte[512];
var pDescriptor = BumpAllocate<WGPUBufferDescriptor>(ref buffer);
pDescriptor->label = BumpAllocateStringView(ref buffer, descriptor.Label);
pDescriptor->mappedAtCreation = descriptor.MappedAtCreation ? 1u : 0u;
pDescriptor->size = descriptor.Size;
pDescriptor->usage = (ulong) descriptor.Usage;
var native = wgpuDeviceCreateBuffer(_wgpuDevice, pDescriptor);
var handle = AllocRhiHandle();
_bufferRegistry.Add(handle, new BufferReg { Native = native });
var rhiBuffer= new RhiBuffer(this, handle);
if (pDescriptor->mappedAtCreation == 1)
{
rhiBuffer.Mapping = new RhiBuffer.ActiveMapping(rhiBuffer) { Valid = true };
}
return rhiBuffer;
}
internal override unsafe RhiBufferMapState BufferGetMapState(RhiBuffer buffer)
{
var nativeBuffer = _bufferRegistry[buffer.Handle].Native;
return (RhiBufferMapState) wgpuBufferGetMapState(nativeBuffer);
}
internal override async ValueTask BufferMapAsync(RhiBuffer buffer, RhiMapModeFlags mode, nuint offset, nuint size)
{
// TODO: Probably need some more locks here idk.
// So people can't map the buffer at the same time as or something.
buffer.MapState = RhiBufferMapState.Pending;
WgpuMapBufferAsyncResult result;
using (var promise = new WgpuPromise<WgpuMapBufferAsyncResult>())
{
unsafe
{
var nativeBuffer = _bufferRegistry[buffer.Handle].Native;
wgpuBufferMapAsync(
nativeBuffer,
(ulong) mode,
offset,
size,
new WGPUBufferMapCallbackInfo
{
callback = &WgpuMapBufferAsyncCallback,
userdata1 = promise.UserData,
}
);
}
// TODO: are we handling the error correctly, here?
result = await promise.Task;
buffer.Mapping = new RhiBuffer.ActiveMapping(buffer) { Valid = true };
}
if (result.Status != WGPUMapAsyncStatus.WGPUMapAsyncStatus_Success)
throw new RhiException(result.Status.ToString());
buffer.MapState = RhiBufferMapState.Mapped;
}
internal override unsafe RhiMappedBufferRange BufferGetMappedRange(RhiBuffer buffer, nuint offset, nuint size)
{
if (size > int.MaxValue)
throw new ArgumentException("Mapped area too big!");
if (buffer.Mapping == null)
throw new InvalidOperationException("Buffer is not mapped");
lock (buffer.Mapping)
{
if (!buffer.Mapping.Valid)
{
// Not sure if this is possible, but can't hurt.
throw new InvalidOperationException();
}
var nativeBuffer = _bufferRegistry[buffer.Handle].Native;
var mapped = wgpuBufferGetMappedRange(nativeBuffer, offset, size);
return new RhiMappedBufferRange(buffer.Mapping, mapped, (int) size);
}
}
internal override unsafe void BufferUnmap(RhiBuffer buffer)
{
if (buffer.Mapping == null)
throw new InvalidOperationException("Buffer is not mapped!");
lock (buffer.Mapping)
{
if (!buffer.Mapping.Valid)
{
// Not sure if this is possible, but can't hurt.
throw new InvalidOperationException();
}
if (buffer.Mapping.ActiveSpans > 0)
throw new InvalidOperationException("Current thread has buffer accessible as span, cannot unmap!");
var nativeBuffer = _bufferRegistry[buffer.Handle].Native;
wgpuBufferUnmap(nativeBuffer);
buffer.Mapping.Valid = false;
buffer.Mapping = null;
buffer.MapState = RhiBufferMapState.Unmapped;
}
}
internal override unsafe void BufferDrop(RhiBuffer buffer)
{
wgpuBufferRelease(_bufferRegistry[buffer.Handle].Native);
_bufferRegistry.Remove(buffer.Handle);
}
private sealed unsafe class BufferReg
{
public WGPUBuffer Native;
}
private record struct WgpuMapBufferAsyncResult(WGPUMapAsyncStatus Status);
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
private static unsafe void WgpuMapBufferAsyncCallback(
WGPUMapAsyncStatus status,
WGPUStringView stringView,
void* userdata1,
void* userdata2)
{
WgpuPromise<WgpuMapBufferAsyncResult>.SetResult(userdata1, new WgpuMapBufferAsyncResult(status));
}
}

View File

@@ -0,0 +1,21 @@
namespace Robust.Client.Graphics.Rhi.WebGpu;
internal sealed unsafe partial class RhiWebGpu
{
private readonly Dictionary<RhiHandle, CommandBufferReg> _commandBufferRegistry = new();
/// <summary>
/// Command buffer was dropped natively, either via explicit call or implicit side effect (e.g. queue submit).
/// </summary>
private void CommandBufferDropped(RhiCommandBuffer commandBuffer)
{
_commandBufferRegistry.Remove(commandBuffer.Handle);
GC.SuppressFinalize(commandBuffer);
}
internal override void CommandBufferDrop(RhiCommandBuffer commandBuffer)
{
wgpuCommandBufferRelease(_commandBufferRegistry[commandBuffer.Handle].Native);
CommandBufferDropped(commandBuffer);
}
}

View File

@@ -0,0 +1,221 @@
namespace Robust.Client.Graphics.Rhi.WebGpu;
internal sealed unsafe partial class RhiWebGpu
{
private readonly Dictionary<RhiHandle, CommandEncoderReg> _commandEncoderRegistry = new();
private readonly Dictionary<RhiHandle, RenderPassEncoderReg> _renderPassEncoderRegistry = new();
public override RhiCommandEncoder CreateCommandEncoder(in RhiCommandEncoderDescriptor descriptor)
{
WGPUCommandEncoder nativeEncoder;
fixed (byte* pLabel = MakeLabel(descriptor.Label))
{
var nativeDescriptor = new WGPUCommandEncoderDescriptor
{
label = new WGPUStringView {data = (sbyte*)pLabel, length = WGPU_STRLEN}
};
nativeEncoder = wgpuDeviceCreateCommandEncoder(_wgpuDevice, &nativeDescriptor);
}
// TODO: thread safety
var handle = AllocRhiHandle();
_commandEncoderRegistry.Add(handle, new CommandEncoderReg { Native = nativeEncoder });
return new RhiCommandEncoder(this, handle);
}
internal override RhiRenderPassEncoder CommandEncoderBeginRenderPass(
RhiCommandEncoder encoder,
in RhiRenderPassDescriptor descriptor)
{
// TODO: Ensure not disposed
// TODO: Thread safety
Span<byte> buffer = stackalloc byte[512];
var pDescriptor = BumpAllocate<WGPURenderPassDescriptor>(ref buffer);
pDescriptor->label = BumpAllocateStringView(ref buffer, descriptor.Label);
var colorAttachments = descriptor.ColorAttachments;
pDescriptor->colorAttachmentCount = (uint)colorAttachments.Length;
pDescriptor->colorAttachments = BumpAllocate<WGPURenderPassColorAttachment>(ref buffer, colorAttachments.Length);
for (var i = 0; i < colorAttachments.Length; i++)
{
ref var attachment = ref colorAttachments[i];
var pAttachment = &pDescriptor->colorAttachments[i];
pAttachment->view = _textureViewRegistry[attachment.View.Handle].Native;
if (attachment.ResolveTarget is { } resolveTarget)
pAttachment->resolveTarget = _textureViewRegistry[resolveTarget.Handle].Native;
pAttachment->clearValue = WgpuColor(attachment.ClearValue);
pAttachment->loadOp = (WGPULoadOp)attachment.LoadOp;
pAttachment->storeOp = (WGPUStoreOp)attachment.StoreOp;
pAttachment->depthSlice = WGPU_DEPTH_SLICE_UNDEFINED;
}
if (descriptor.DepthStencilAttachment is { } depthStencilAttachment)
{
var pDepthStencilAttachment = BumpAllocate<WGPURenderPassDepthStencilAttachment>(ref buffer);
pDescriptor->depthStencilAttachment = pDepthStencilAttachment;
pDepthStencilAttachment->view = _textureViewRegistry[depthStencilAttachment.View.Handle].Native;
pDepthStencilAttachment->depthLoadOp = (WGPULoadOp)depthStencilAttachment.DepthLoadOp;
pDepthStencilAttachment->depthStoreOp = (WGPUStoreOp)depthStencilAttachment.DepthStoreOp;
pDepthStencilAttachment->depthClearValue = depthStencilAttachment.DepthClearValue;
pDepthStencilAttachment->depthReadOnly = depthStencilAttachment.DepthReadOnly ? 1u : 0u;
pDepthStencilAttachment->stencilLoadOp = (WGPULoadOp)depthStencilAttachment.StencilLoadOp;
pDepthStencilAttachment->stencilStoreOp = (WGPUStoreOp)depthStencilAttachment.StencilStoreOp;
pDepthStencilAttachment->stencilClearValue = depthStencilAttachment.StencilClearValue;
pDepthStencilAttachment->stencilReadOnly = depthStencilAttachment.StencilReadOnly ? 1u : 0u;
}
if (descriptor.OcclusionQuerySet != null)
throw new NotImplementedException();
var pDescriptorMaxDrawCount = BumpAllocate<WGPURenderPassMaxDrawCount>(ref buffer);
pDescriptor->nextInChain = (WGPUChainedStruct*)pDescriptorMaxDrawCount;
pDescriptorMaxDrawCount->chain.sType = WGPUSType.WGPUSType_RenderPassMaxDrawCount;
pDescriptorMaxDrawCount->maxDrawCount = descriptor.MaxDrawCount;
var nativeEncoder = wgpuCommandEncoderBeginRenderPass(
_commandEncoderRegistry[encoder.Handle].Native,
pDescriptor
);
// TODO: thread safety
var handle = AllocRhiHandle();
_renderPassEncoderRegistry.Add(handle, new RenderPassEncoderReg { Native = nativeEncoder });
return new RhiRenderPassEncoder(this, handle);
}
internal override void RenderPassEncoderSetPipeline(
in RhiRenderPassEncoder encoder,
RhiRenderPipeline pipeline)
{
// TODO: safety
wgpuRenderPassEncoderSetPipeline(
_renderPassEncoderRegistry[encoder.Handle].Native,
_renderPipelineRegistry[pipeline.Handle].Native
);
}
internal override void RenderPassEncoderDraw(
in RhiRenderPassEncoder encoder,
uint vertexCount,
uint instanceCount,
uint firstVertex,
uint firstInstance)
{
// TODO: safety
wgpuRenderPassEncoderDraw(
_renderPassEncoderRegistry[encoder.Handle].Native,
vertexCount,
instanceCount,
firstVertex,
firstInstance
);
}
internal override void RenderPassEncoderEnd(RhiRenderPassEncoder encoder)
{
// TODO: safety
var handle = encoder.Handle;
wgpuRenderPassEncoderEnd(_renderPassEncoderRegistry[handle].Native);
RenderPassEncoderDropped(handle);
}
internal override void RenderPassEncoderSetBindGroup(
RhiRenderPassEncoder encoder,
uint index,
RhiBindGroup? bindGroup)
{
wgpuRenderPassEncoderSetBindGroup(
_renderPassEncoderRegistry[encoder.Handle].Native,
index,
_bindGroupRegistry[bindGroup!.Handle].Native,
0, null
);
}
internal override void RenderPassEncoderSetVertexBuffer(
RhiRenderPassEncoder encoder,
uint slot,
RhiBuffer? buffer,
ulong offset,
ulong? size)
{
WGPUBuffer nativeBuffer = null;
if (buffer != null)
nativeBuffer = _bufferRegistry[buffer.Handle].Native;
wgpuRenderPassEncoderSetVertexBuffer(
_renderPassEncoderRegistry[encoder.Handle].Native,
slot,
nativeBuffer,
offset,
size ?? WGPU_WHOLE_SIZE
);
}
internal override void RenderPassEncoderSetScissorRect(
RhiRenderPassEncoder encoder,
uint x, uint y, uint w, uint h)
{
// TODO: safety
wgpuRenderPassEncoderSetScissorRect(
_renderPassEncoderRegistry[encoder.Handle].Native,
x,
y,
w,
h
);
}
internal override RhiCommandBuffer CommandEncoderFinish(
in RhiCommandEncoder encoder,
in RhiCommandBufferDescriptor descriptor)
{
// TODO: safety
var handle = encoder.Handle;
Span<byte> buffer = stackalloc byte[512];
var pDescriptor = BumpAllocate<WGPUCommandBufferDescriptor>(ref buffer);
pDescriptor->label = BumpAllocateStringView(ref buffer, descriptor.Label);
var nativeBuffer = wgpuCommandEncoderFinish(
_commandEncoderRegistry[handle].Native,
pDescriptor
);
CommandEncoderDropped(handle);
var bufferHandle = AllocRhiHandle();
_commandBufferRegistry.Add(bufferHandle, new CommandBufferReg { Native = nativeBuffer });
return new RhiCommandBuffer(this, bufferHandle);
}
private void CommandEncoderDropped(RhiHandle encoder)
{
_commandEncoderRegistry.Remove(encoder);
}
private void RenderPassEncoderDropped(RhiHandle encoder)
{
_renderPassEncoderRegistry.Remove(encoder);
}
private sealed class CommandEncoderReg
{
public WGPUCommandEncoder Native;
}
private sealed class RenderPassEncoderReg
{
public WGPURenderPassEncoder Native;
}
private sealed class CommandBufferReg
{
public WGPUCommandBuffer Native;
}
}

View File

@@ -0,0 +1,228 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Text;
namespace Robust.Client.Graphics.Rhi.WebGpu;
internal sealed unsafe partial class RhiWebGpu
{
private static string WgpuVersionToString(uint version)
{
var a = (version >> 24) & 0xFF;
var b = (version >> 16) & 0xFF;
var c = (version >> 08) & 0xFF;
var d = (version >> 00) & 0xFF;
return $"{a}.{b}.{c}.{d}";
}
private static WGPUOptionalBool WgpuOptionalBool(bool? value)
{
return value switch
{
null => WGPUOptionalBool.WGPUOptionalBool_Undefined,
false => WGPUOptionalBool.WGPUOptionalBool_False,
true => WGPUOptionalBool.WGPUOptionalBool_True,
};
}
private static WGPUColor WgpuColor(RhiColor color) => new()
{
r = color.R,
g = color.G,
b = color.B,
a = color.A
};
private static WGPUExtent3D WgpuExtent3D(RhiExtent3D extent)
{
return new WGPUExtent3D
{
width = extent.Width,
height = extent.Height,
depthOrArrayLayers = extent.Depth
};
}
private static WGPUOrigin3D WgpuOrigin3D(RhiOrigin3D origin)
{
return new WGPUOrigin3D
{
x = origin.X,
y = origin.Y,
z = origin.Z
};
}
private static string? GetString(WGPUStringView stringView)
{
if (stringView.data == null)
{
if (stringView.length == WGPU_STRLEN)
return null;
if (stringView.length == 0)
return "";
throw new RhiException("Null address to WGPUStringView");
}
if (stringView.length == WGPU_STRLEN)
return Marshal.PtrToStringUTF8((IntPtr)stringView.data);
if (stringView.length > int.MaxValue)
throw new RhiException("WGPUStringView too long!");
var span = new ReadOnlySpan<byte>(stringView.data, (int)stringView.length);
return Encoding.UTF8.GetString(span);
}
private static RhiTextureFormat ToRhiFormat(WGPUTextureFormat format)
{
return (RhiTextureFormat)format;
}
private static WGPUTextureFormat ValidateTextureFormat(RhiTextureFormat format)
{
if (format is 0 or >= RhiTextureFormat.Final)
throw new ArgumentException($"Invalid {nameof(RhiTextureFormat)}");
return (WGPUTextureFormat)format;
}
private static WGPUTextureDimension ValidateTextureDimension(RhiTextureDimension dimension)
{
if (dimension > RhiTextureDimension.Dim3D)
throw new ArgumentException($"Invalid {nameof(RhiTextureDimension)}");
return dimension switch
{
RhiTextureDimension.Dim1D => WGPUTextureDimension.WGPUTextureDimension_1D,
RhiTextureDimension.Dim2D => WGPUTextureDimension.WGPUTextureDimension_2D,
RhiTextureDimension.Dim3D => WGPUTextureDimension.WGPUTextureDimension_3D,
_ => throw new UnreachableException()
};
}
private static RhiTextureUsage ValidateTextureUsage(RhiTextureUsage usage)
{
if (usage >= RhiTextureUsage.Final)
throw new ArgumentException($"Invalid {nameof(RhiTextureUsage)}");
return usage;
}
private static RhiTextureViewDimension ValidateTextureViewDimension(RhiTextureViewDimension dimension)
{
if (dimension >= RhiTextureViewDimension.Final)
throw new ArgumentException($"Invalid {nameof(RhiTextureViewDimension)}");
return dimension;
}
private static RhiTextureAspect ValidateTextureAspect(RhiTextureAspect aspect)
{
if (aspect >= RhiTextureAspect.Final)
throw new ArgumentException($"Invalid {nameof(RhiTextureAspect)}");
return aspect;
}
private static RhiAddressMode ValidateAddressMode(RhiAddressMode addressMode)
{
if (addressMode >= RhiAddressMode.Final)
throw new ArgumentException($"Invalid {nameof(RhiAddressMode)}");
return addressMode;
}
private static RhiFilterMode ValidateFilterMode(RhiFilterMode filterMode)
{
if (filterMode >= RhiFilterMode.Final)
throw new ArgumentException($"Invalid {nameof(RhiFilterMode)}");
return filterMode;
}
private static RhiMipmapFilterMode ValidateMipmapFilterMode(RhiMipmapFilterMode mipmapFilterMode)
{
if (mipmapFilterMode >= RhiMipmapFilterMode.Final)
throw new ArgumentException($"Invalid {nameof(RhiMipmapFilterMode)}");
return mipmapFilterMode;
}
private static RhiCompareFunction ValidateCompareFunction(RhiCompareFunction compareFunction)
{
if (compareFunction >= RhiCompareFunction.Final)
throw new ArgumentException($"Invalid {nameof(RhiCompareFunction)}");
return compareFunction;
}
private static WGPUPowerPreference ValidatePowerPreference(RhiPowerPreference powerPreference)
{
if (powerPreference >= RhiPowerPreference.Final)
throw new ArgumentException($"Invalid {nameof(RhiPowerPreference)}");
return (WGPUPowerPreference) powerPreference;
}
private static string MarshalFromString(byte* str)
{
return Marshal.PtrToStringUTF8((nint)str)!;
}
[return: NotNullIfNotNull(nameof(label))]
private static byte[]? MakeLabel(string? label)
{
// TODO: Replace with stackalloc
if (label == null)
return null;
return Encoding.UTF8.GetBytes(label);
}
private static WGPUStringView BumpAllocateStringView(ref Span<byte> buf, string? str)
{
if (str == null)
return WGPUStringView.Null;
var byteCount = Encoding.UTF8.GetByteCount(str) ;
var ptr = BumpAllocate(ref buf, byteCount);
var dstSpan = new Span<byte>(ptr, byteCount);
Encoding.UTF8.GetBytes(str, dstSpan);
return new WGPUStringView
{
data = (sbyte*)ptr,
length = (nuint)byteCount
};
}
private sealed class WgpuPromise<TResult> : IDisposable
{
private readonly TaskCompletionSource<TResult> _tcs;
private GCHandle _gcHandle;
public Task<TResult> Task => _tcs.Task;
public void* UserData => (void*) GCHandle.ToIntPtr(_gcHandle);
public WgpuPromise()
{
_tcs = new TaskCompletionSource<TResult>();
_gcHandle = GCHandle.Alloc(this);
}
public static void SetResult(void* userdata, TResult result)
{
var self = (WgpuPromise<TResult>)GCHandle.FromIntPtr((nint) userdata).Target!;
self._tcs.SetResult(result);
}
public void Dispose()
{
_gcHandle.Free();
}
}
}

View File

@@ -0,0 +1,85 @@
namespace Robust.Client.Graphics.Rhi.WebGpu;
internal sealed unsafe partial class RhiWebGpu
{
public override RhiQueue Queue { get; }
// queue is ignored as parameter, since WebGPU only supports one queue for now.
internal override void QueueWriteTexture(
RhiQueue queue,
in RhiImageCopyTexture destination,
ReadOnlySpan<byte> data,
in RhiImageDataLayout dataLayout,
RhiExtent3D size)
{
// TODO: Thread safety
var nativeTexture = _textureRegistry[destination.Texture.Handle].Native;
var nativeDestination = new WGPUTexelCopyTextureInfo
{
aspect = (WGPUTextureAspect)ValidateTextureAspect(destination.Aspect),
texture = nativeTexture,
origin = WgpuOrigin3D(destination.Origin),
mipLevel = destination.MipLevel
};
var nativeDataLayout = new WGPUTexelCopyBufferLayout
{
// TODO: Validation
offset = dataLayout.Offset,
bytesPerRow = dataLayout.BytesPerRow,
rowsPerImage = dataLayout.RowsPerImage
};
var nativeSize = WgpuExtent3D(size);
fixed (byte* pData = data)
{
wgpuQueueWriteTexture(
_wgpuQueue,
&nativeDestination,
pData, (nuint) data.Length,
&nativeDataLayout,
&nativeSize
);
}
}
public override void QueueWriteBuffer(RhiBuffer buffer, ulong bufferOffset, ReadOnlySpan<byte> data)
{
var nativeBuffer = _bufferRegistry[buffer.Handle].Native;
fixed (byte* pData = data)
{
wgpuQueueWriteBuffer(
_wgpuQueue,
nativeBuffer,
bufferOffset,
pData,
(nuint) data.Length);
}
}
internal override void QueueSubmit(RhiQueue queue, RhiCommandBuffer[] commandBuffers)
{
// TODO: Safety
var pBuffers = stackalloc WGPUCommandBuffer[commandBuffers.Length];
for (var i = 0; i < commandBuffers.Length; i++)
{
pBuffers[i] = _commandBufferRegistry[commandBuffers[i].Handle].Native;
}
wgpuQueueSubmit(
_wgpuQueue,
(uint) commandBuffers.Length,
pBuffers
);
foreach (var commandBuffer in commandBuffers)
{
CommandBufferDropped(commandBuffer);
}
}
}

View File

@@ -0,0 +1,8 @@
namespace Robust.Client.Graphics.Rhi.WebGpu;
internal sealed partial class RhiWebGpu
{
private long _rhiHandleCounter;
private RhiHandle AllocRhiHandle() => new(Interlocked.Increment(ref _rhiHandleCounter));
}

View File

@@ -0,0 +1,226 @@
using System.Runtime.InteropServices;
namespace Robust.Client.Graphics.Rhi.WebGpu;
internal sealed unsafe partial class RhiWebGpu
{
private readonly Dictionary<RhiHandle, RenderPipelineReg> _renderPipelineRegistry = new();
private readonly Dictionary<RhiHandle, PipelineLayoutReg> _pipelineLayoutRegistry = new();
public override RhiPipelineLayout CreatePipelineLayout(in RhiPipelineLayoutDescriptor descriptor)
{
// TODO: SAFETY
Span<byte> buffer = stackalloc byte[128];
var pDescriptor = BumpAllocate<WGPUPipelineLayoutDescriptor>(ref buffer);
pDescriptor->label = BumpAllocateStringView(ref buffer, descriptor.Label);
var layouts = descriptor.BindGroupLayouts;
pDescriptor->bindGroupLayoutCount = (uint) layouts.Length;
pDescriptor->bindGroupLayouts = BumpAllocatePtr<WGPUBindGroupLayoutImpl>(ref buffer, layouts.Length);
for (var i = 0; i < layouts.Length; i++)
{
pDescriptor->bindGroupLayouts[i] = _bindGroupLayoutRegistry[layouts[i].Handle].Native;
}
var native = wgpuDeviceCreatePipelineLayout(_wgpuDevice, pDescriptor);
// TODO: Thread safety
var handle = AllocRhiHandle();
_pipelineLayoutRegistry.Add(handle, new PipelineLayoutReg { Native = native });
return new RhiPipelineLayout(this, handle);
}
public override RhiRenderPipeline CreateRenderPipeline(in RhiRenderPipelineDescriptor descriptor)
{
// TODO: THREAD SAFETY
// TODO: INPUT VALIDATION
var vertexShader = _shaderModuleRegistry[descriptor.Vertex.ProgrammableStage.ShaderModule.Handle].Native;
const int bufferSize = 8192;
var bufferPtr = NativeMemory.AlignedAlloc(bufferSize, 8);
WGPURenderPipeline nativePipeline;
try
{
var buffer = new Span<byte>(bufferPtr, bufferSize);
WGPURenderPipelineDescriptor pipelineDesc = default;
pipelineDesc.label = BumpAllocateStringView(ref buffer, descriptor.Label);
// Pipeline layout
switch (descriptor.Layout)
{
case RhiPipelineLayout pipelineLayout:
pipelineDesc.layout = _pipelineLayoutRegistry[pipelineLayout.Handle].Native;
break;
case RhiAutoLayoutMode:
throw new NotSupportedException("wgpu does not support auto layout yet");
// Default case: no layout given, do nothing
}
// Vertex state
pipelineDesc.vertex.module = vertexShader;
pipelineDesc.vertex.entryPoint = BumpAllocateStringView(
ref buffer,
descriptor.Vertex.ProgrammableStage.EntryPoint);
WgpuProgrammableConstants(
ref buffer,
descriptor.Vertex.ProgrammableStage.Constants,
out pipelineDesc.vertex.constantCount,
out pipelineDesc.vertex.constants);
var buffers = descriptor.Vertex.Buffers;
pipelineDesc.vertex.bufferCount = (uint)buffers.Length;
pipelineDesc.vertex.buffers = BumpAllocate<WGPUVertexBufferLayout>(ref buffer, buffers.Length);
for (var i = 0; i < buffers.Length; i++)
{
ref var bufferLayout = ref pipelineDesc.vertex.buffers[i];
bufferLayout.arrayStride = buffers[i].ArrayStride;
bufferLayout.stepMode = buffers[i].StepMode == RhiVertexStepMode.Instance
? WGPUVertexStepMode.WGPUVertexStepMode_Instance
: WGPUVertexStepMode.WGPUVertexStepMode_Vertex;
var attributes = buffers[i].Attributes;
bufferLayout.attributeCount = (uint)attributes.Length;
bufferLayout.attributes = BumpAllocate<WGPUVertexAttribute>(ref buffer, attributes.Length);
for (var j = 0; j < attributes.Length; j++)
{
ref var attribute = ref bufferLayout.attributes[j];
attribute.format = (WGPUVertexFormat)attributes[j].Format;
attribute.offset = attributes[j].Offset;
attribute.shaderLocation = attributes[j].ShaderLocation;
}
}
// Primitive state
pipelineDesc.primitive.topology = (WGPUPrimitiveTopology)descriptor.Primitive.Topology;
pipelineDesc.primitive.stripIndexFormat = (WGPUIndexFormat)descriptor.Primitive.StripIndexformat;
pipelineDesc.primitive.frontFace = (WGPUFrontFace)descriptor.Primitive.FrontFace;
pipelineDesc.primitive.cullMode = (WGPUCullMode)descriptor.Primitive.CullMode;
pipelineDesc.primitive.unclippedDepth = descriptor.Primitive.UnclippedDepth ? 1u : 0u;
// Depth stencil state
if (descriptor.DepthStencil is { } depthStencil)
{
var pDepthStencil = BumpAllocate<WGPUDepthStencilState>(ref buffer);
pipelineDesc.depthStencil = pDepthStencil;
pDepthStencil->format = (WGPUTextureFormat)depthStencil.Format;
pDepthStencil->depthWriteEnabled = WgpuOptionalBool(depthStencil.DepthWriteEnabled);
pDepthStencil->depthCompare = (WGPUCompareFunction)depthStencil.DepthCompare;
pDepthStencil->stencilFront = WgpuStencilFaceState(depthStencil.StencilFront ?? new RhiStencilFaceState());
pDepthStencil->stencilBack = WgpuStencilFaceState(depthStencil.StencilBack ?? new RhiStencilFaceState());
pDepthStencil->stencilReadMask = depthStencil.StencilReadMask;
pDepthStencil->stencilWriteMask = depthStencil.StencilWriteMask;
pDepthStencil->depthBias = depthStencil.DepthBias;
pDepthStencil->depthBiasSlopeScale = depthStencil.DepthBiasSlopeScale;
pDepthStencil->depthBiasClamp = depthStencil.DepthBiasClamp;
}
// Multisample state
pipelineDesc.multisample.count = descriptor.Multisample.Count;
pipelineDesc.multisample.mask = descriptor.Multisample.Mask;
pipelineDesc.multisample.alphaToCoverageEnabled = descriptor.Multisample.AlphaToCoverageEnabled ? 1u : 0u;
// Fragment state
if (descriptor.Fragment is { } fragment)
{
var fragmentShader = _shaderModuleRegistry[fragment.ProgrammableStage.ShaderModule.Handle].Native;
var pFragment = BumpAllocate<WGPUFragmentState>(ref buffer);
pipelineDesc.fragment = pFragment;
pFragment->module = fragmentShader;
pFragment->entryPoint = BumpAllocateStringView(ref buffer, fragment.ProgrammableStage.EntryPoint);
WgpuProgrammableConstants(
ref buffer,
fragment.ProgrammableStage.Constants,
out pFragment->constantCount,
out pFragment->constants);
var targets = fragment.Targets;
pFragment->targetCount = (uint)targets.Length;
pFragment->targets = BumpAllocate<WGPUColorTargetState>(ref buffer, targets.Length);
for (var i = 0; i < targets.Length; i++)
{
ref var target = ref pFragment->targets[i];
target.format = (WGPUTextureFormat)targets[i].Format;
if (targets[i].Blend is { } blend)
{
var pBlend = BumpAllocate<WGPUBlendState>(ref buffer);
target.blend = pBlend;
pBlend->alpha = WgpuBlendComponent(blend.Alpha);
pBlend->color = WgpuBlendComponent(blend.Color);
}
target.writeMask = (ulong)targets[i].WriteMask;
}
}
nativePipeline = wgpuDeviceCreateRenderPipeline(_wgpuDevice, &pipelineDesc);
}
finally
{
NativeMemory.AlignedFree(bufferPtr);
}
// TODO: Thread safety
var handle = AllocRhiHandle();
_renderPipelineRegistry.Add(handle, new RenderPipelineReg { Native = nativePipeline });
return new RhiRenderPipeline(this, handle);
}
private static WGPUStencilFaceState WgpuStencilFaceState(in RhiStencilFaceState state)
{
return new WGPUStencilFaceState
{
compare = (WGPUCompareFunction)state.Compare,
failOp = (WGPUStencilOperation)state.FailOp,
depthFailOp = (WGPUStencilOperation)state.DepthFailOp,
passOp = (WGPUStencilOperation)state.PassOp
};
}
private static void WgpuProgrammableConstants(
ref Span<byte> buffer,
RhiConstantEntry[] constants,
out nuint constantCount,
out WGPUConstantEntry* pConstants)
{
constantCount = (uint)constants.Length;
pConstants = BumpAllocate<WGPUConstantEntry>(ref buffer, constants.Length);
for (var i = 0; i < constants.Length; i++)
{
ref var constant = ref pConstants[i];
constant.key = BumpAllocateStringView(ref buffer, constants[i].Key);
constant.value = constants[i].Value;
}
}
private static WGPUBlendComponent WgpuBlendComponent(in RhiBlendComponent component)
{
return new WGPUBlendComponent
{
operation = (WGPUBlendOperation)component.Operation,
dstFactor = (WGPUBlendFactor)component.DstFactor,
srcFactor = (WGPUBlendFactor)component.SrcFactor,
};
}
private sealed class RenderPipelineReg
{
public WGPURenderPipeline Native;
}
private sealed class PipelineLayoutReg
{
public WGPUPipelineLayout Native;
}
}

Some files were not shown because too many files have changed in this diff Show More