mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Compare commits
87 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c30fdf5fd | ||
|
|
0b7e8c2560 | ||
|
|
7982aa236c | ||
|
|
0559339143 | ||
|
|
89fcd1dd2b | ||
|
|
649378e59a | ||
|
|
0c7ace16d1 | ||
|
|
27f7f5ee36 | ||
|
|
fe0fcbd851 | ||
|
|
aca7847933 | ||
|
|
1621d25a92 | ||
|
|
b7e0a9bc03 | ||
|
|
9909416006 | ||
|
|
c3e487b61c | ||
|
|
89ad8b6c9f | ||
|
|
efbc9ef2bf | ||
|
|
ce240773e8 | ||
|
|
8563466011 | ||
|
|
af4d53fb54 | ||
|
|
3086fc446c | ||
|
|
5f3a54376d | ||
|
|
9bb7af364e | ||
|
|
92b0e7f1a8 | ||
|
|
47d1c372b2 | ||
|
|
453f763128 | ||
|
|
65a7942d63 | ||
|
|
f1f3c60d1f | ||
|
|
d4e8a27c23 | ||
|
|
18a17da8fa | ||
|
|
90a8c66e96 | ||
|
|
45c14b2bc3 | ||
|
|
d227613997 | ||
|
|
7557cc703c | ||
|
|
7b81d0d881 | ||
|
|
b59f7801ac | ||
|
|
d724c5b3eb | ||
|
|
f812dc4dac | ||
|
|
2a1bcb6f1e | ||
|
|
fa9030e59c | ||
|
|
8dcae8631b | ||
|
|
21c3535486 | ||
|
|
4e100d96bc | ||
|
|
14d3699ae2 | ||
|
|
350fa8736d | ||
|
|
5a82df216d | ||
|
|
32bca7cfd4 | ||
|
|
008babebc6 | ||
|
|
c65c4ba57e | ||
|
|
eb5b838e61 | ||
|
|
6b43036c9d | ||
|
|
f23a55793d | ||
|
|
46143d2589 | ||
|
|
ba7d1452c1 | ||
|
|
1c1343466e | ||
|
|
0d534e8bcd | ||
|
|
c83c6f9592 | ||
|
|
c794bd84bf | ||
|
|
d1d43f834b | ||
|
|
9505cb68df | ||
|
|
9763f5fdf4 | ||
|
|
80a963ec05 | ||
|
|
3a670ec25e | ||
|
|
e45950a557 | ||
|
|
6f1427ef3c | ||
|
|
9a7d1a39c1 | ||
|
|
9be903ee56 | ||
|
|
72f9f9c343 | ||
|
|
3ad760a99e | ||
|
|
e2f3722ce9 | ||
|
|
b4beca6562 | ||
|
|
ea02260230 | ||
|
|
3b243e487d | ||
|
|
f40ccb7558 | ||
|
|
f467a7027b | ||
|
|
c9d7d442d9 | ||
|
|
342626ad9b | ||
|
|
1c3ea968e4 | ||
|
|
f0ed3537ee | ||
|
|
74e7e61a98 | ||
|
|
fb9b0ae89b | ||
|
|
dbe297b1fc | ||
|
|
b84917e8e4 | ||
|
|
abb3f65fe4 | ||
|
|
41ec2dc131 | ||
|
|
e714dcc83c | ||
|
|
46291af1be | ||
|
|
ad929c9955 |
44
.github/workflows/build-docfx.yml
vendored
44
.github/workflows/build-docfx.yml
vendored
@@ -5,30 +5,30 @@ on:
|
||||
- cron: "0 0 * * 0"
|
||||
jobs:
|
||||
docfx:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3.6.0
|
||||
with:
|
||||
submodules: true
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v3.2.0
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v4.1.0
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
|
||||
- name: Install dependencies
|
||||
run: dotnet restore
|
||||
- name: Install dependencies
|
||||
run: dotnet restore
|
||||
|
||||
- name: Build Project
|
||||
run: dotnet build --no-restore /p:WarningsAsErrors=nullable
|
||||
- name: Build Project
|
||||
run: dotnet build --no-restore /p:WarningsAsErrors=nullable
|
||||
|
||||
- name: Build DocFX
|
||||
uses: nikeee/docfx-action@v1.0.0
|
||||
with:
|
||||
args: Robust.Docfx/docfx.json
|
||||
- name: Build DocFX
|
||||
uses: nikeee/docfx-action@v1.0.0
|
||||
with:
|
||||
args: Robust.Docfx/docfx.json
|
||||
|
||||
- name: Publish Docfx Documentation on GitHub Pages
|
||||
uses: maxheld83/ghpages@master
|
||||
env:
|
||||
BUILD_DIR: Robust.Docfx/_robust-site
|
||||
GH_PAT: ${{ secrets.GH_PAT }}
|
||||
- name: Publish Docfx Documentation on GitHub Pages
|
||||
uses: maxheld83/ghpages@master
|
||||
env:
|
||||
BUILD_DIR: Robust.Docfx/_robust-site
|
||||
GH_PAT: ${{ secrets.GH_PAT }}
|
||||
|
||||
37
.github/workflows/build-test.yml
vendored
37
.github/workflows/build-test.yml
vendored
@@ -2,33 +2,32 @@ name: Build & Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
branches: [master]
|
||||
|
||||
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] - temporarily disabled due to libfreetype.dll errors.
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3.6.0
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v3.2.0
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
- name: Install dependencies
|
||||
run: dotnet restore
|
||||
- name: Build
|
||||
run: dotnet build --no-restore /p:WarningsAsErrors=nullable
|
||||
- name: Robust.UnitTesting
|
||||
run: dotnet test --no-build Robust.UnitTesting/Robust.UnitTesting.csproj -- NUnit.ConsoleOut=0
|
||||
- name: Robust.Analyzers.Tests
|
||||
run: dotnet test --no-build Robust.Analyzers.Tests/Robust.Analyzers.Tests.csproj -- NUnit.ConsoleOut=0
|
||||
- uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v4.1.0
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
- name: Install dependencies
|
||||
run: dotnet restore
|
||||
- name: Build
|
||||
run: dotnet build --no-restore /p:WarningsAsErrors=nullable
|
||||
- name: Robust.UnitTesting
|
||||
run: dotnet test --no-build Robust.UnitTesting/Robust.UnitTesting.csproj -- NUnit.ConsoleOut=0
|
||||
- name: Robust.Analyzers.Tests
|
||||
run: dotnet test --no-build Robust.Analyzers.Tests/Robust.Analyzers.Tests.csproj -- NUnit.ConsoleOut=0
|
||||
|
||||
78
.github/workflows/codeql-analysis.yml
vendored
78
.github/workflows/codeql-analysis.yml
vendored
@@ -11,14 +11,8 @@
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
#on:
|
||||
# push:
|
||||
# branches: [ master ]
|
||||
# pull_request:
|
||||
# # The branches below must be a subset of the branches above
|
||||
# branches: [ master ]
|
||||
# schedule:
|
||||
# - cron: '30 18 * * 6'
|
||||
on:
|
||||
workflow_dispatch
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
@@ -28,50 +22,50 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'csharp' ]
|
||||
language: ["csharp"]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||
# Learn more:
|
||||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3.6.0
|
||||
with:
|
||||
submodules: true
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v3.2.0
|
||||
with:
|
||||
dotnet-version: 7.0.x
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v4.1.0
|
||||
with:
|
||||
dotnet-version: 7.0.x
|
||||
|
||||
- name: Build
|
||||
run: dotnet build
|
||||
- name: Build
|
||||
run: dotnet build
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
|
||||
73
.github/workflows/publish-client.yml
vendored
73
.github/workflows/publish-client.yml
vendored
@@ -3,51 +3,50 @@
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Parse version
|
||||
id: parse_version
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ver = [regex]::Match($env:GITHUB_REF, "refs/tags/v?(.+)").Groups[1].Value
|
||||
echo ("::set-output name=version::{0}" -f $ver)
|
||||
- name: Parse version
|
||||
id: parse_version
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ver = [regex]::Match($env:GITHUB_REF, "refs/tags/v?(.+)").Groups[1].Value
|
||||
echo ("::set-output name=version::{0}" -f $ver)
|
||||
|
||||
- uses: actions/checkout@v3.6.0
|
||||
with:
|
||||
submodules: true
|
||||
- uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v3.2.0
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v4.1.0
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
|
||||
- name: Package client
|
||||
run: Tools/package_client_build.py -p windows mac linux
|
||||
- name: Package client
|
||||
run: Tools/package_client_build.py -p windows mac linux
|
||||
|
||||
- name: Shuffle files around
|
||||
run: |
|
||||
mkdir "release/${{ steps.parse_version.outputs.version }}"
|
||||
mv release/*.zip "release/${{ steps.parse_version.outputs.version }}"
|
||||
- name: Shuffle files around
|
||||
run: |
|
||||
mkdir "release/${{ steps.parse_version.outputs.version }}"
|
||||
mv release/*.zip "release/${{ steps.parse_version.outputs.version }}"
|
||||
|
||||
- name: Upload files to Suns
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: suns.spacestation14.com
|
||||
username: robust-build-push
|
||||
key: ${{ secrets.CENTCOMM_ROBUST_BUILDS_PUSH_KEY }}
|
||||
source: "release/${{ steps.parse_version.outputs.version }}"
|
||||
target: "/var/lib/robust-builds/builds/"
|
||||
strip_components: 1
|
||||
|
||||
- name: Update manifest JSON
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: suns.spacestation14.com
|
||||
username: robust-build-push
|
||||
key: ${{ secrets.CENTCOMM_ROBUST_BUILDS_PUSH_KEY }}
|
||||
script: /home/robust-build-push/push.ps1 ${{ steps.parse_version.outputs.version }}
|
||||
- name: Upload files to Suns
|
||||
uses: appleboy/scp-action@master
|
||||
with:
|
||||
host: suns.spacestation14.com
|
||||
username: robust-build-push
|
||||
key: ${{ secrets.CENTCOMM_ROBUST_BUILDS_PUSH_KEY }}
|
||||
source: "release/${{ steps.parse_version.outputs.version }}"
|
||||
target: "/var/lib/robust-builds/builds/"
|
||||
strip_components: 1
|
||||
|
||||
- name: Update manifest JSON
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: suns.spacestation14.com
|
||||
username: robust-build-push
|
||||
key: ${{ secrets.CENTCOMM_ROBUST_BUILDS_PUSH_KEY }}
|
||||
script: /home/robust-build-push/push.ps1 ${{ steps.parse_version.outputs.version }}
|
||||
|
||||
55
.github/workflows/test-content.yml
vendored
55
.github/workflows/test-content.yml
vendored
@@ -2,40 +2,39 @@ name: Test content master against engine
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out content
|
||||
uses: actions/checkout@v3.6.0
|
||||
with:
|
||||
repository: space-wizards/space-station-14
|
||||
submodules: recursive
|
||||
- name: Check out content
|
||||
uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
repository: space-wizards/space-station-14
|
||||
submodules: recursive
|
||||
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v3.2.0
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
- name: Disable submodule autoupdate
|
||||
run: touch BuildChecker/DISABLE_SUBMODULE_AUTOUPDATE
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v4.1.0
|
||||
with:
|
||||
dotnet-version: 8.0.x
|
||||
- name: Disable submodule autoupdate
|
||||
run: touch BuildChecker/DISABLE_SUBMODULE_AUTOUPDATE
|
||||
|
||||
- name: Check out engine version
|
||||
run: |
|
||||
cd RobustToolbox
|
||||
git fetch origin ${{ github.sha }}
|
||||
git checkout FETCH_HEAD
|
||||
git submodule update --init --recursive
|
||||
- name: Install dependencies
|
||||
run: dotnet restore
|
||||
- name: Build
|
||||
run: dotnet build --configuration Tools --no-restore
|
||||
- name: Content.Tests
|
||||
run: dotnet test --no-build Content.Tests/Content.Tests.csproj -v n
|
||||
- name: Content.IntegrationTests
|
||||
run: COMPlus_gcServer=1 dotnet test --no-build Content.IntegrationTests/Content.IntegrationTests.csproj -v n
|
||||
- name: Check out engine version
|
||||
run: |
|
||||
cd RobustToolbox
|
||||
git fetch origin ${{ github.sha }}
|
||||
git checkout FETCH_HEAD
|
||||
git submodule update --init --recursive
|
||||
- name: Install dependencies
|
||||
run: dotnet restore
|
||||
- name: Build
|
||||
run: dotnet build --configuration Tools --no-restore
|
||||
- name: Content.Tests
|
||||
run: dotnet test --no-build Content.Tests/Content.Tests.csproj -v n
|
||||
- name: Content.IntegrationTests
|
||||
run: COMPlus_gcServer=1 dotnet test --no-build Content.IntegrationTests/Content.IntegrationTests.csproj -v n
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project>
|
||||
|
||||
<!-- This file automatically reset by Tools/version.py -->
|
||||
<!-- This file automatically reset by Tools/version.py -->
|
||||
|
||||
|
||||
Submodule NetSerializer updated: 7f51deaeca...4882400f2c
140
RELEASE-NOTES.md
140
RELEASE-NOTES.md
@@ -54,6 +54,146 @@ END TEMPLATE-->
|
||||
*None yet*
|
||||
|
||||
|
||||
## 237.3.0
|
||||
|
||||
### New features
|
||||
|
||||
* Added stack-like functions to `ValueList<T>` and added an `AddRange(ReadOnlySpan<T>)` overload.
|
||||
* Added new `AssetPassFilterDrop`.
|
||||
* Added a new RayCastSystem with the latest Box2D raycast + shapecasts implemented.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
* Fixed `IPrototypeManager.TryGetKindFrom()` not working for prototypes with automatically inferred kind names.
|
||||
|
||||
### Other
|
||||
|
||||
* Sandbox error reference locator now works with generic method calls.
|
||||
|
||||
|
||||
## 237.2.0
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* `SharedEyeSystem..SetTarget()` will now also automatically remove the old target from the session's ViewSubscriptions
|
||||
|
||||
### New features
|
||||
|
||||
* `ImmutableArray<T>` can now be serialized by `RobustSerializer`.
|
||||
* `RequiresLocationAttribute`, used by `ref readonly`, is now allowed by the sandbox.
|
||||
* Added `DAT-OBJ()` localization function, for the dative case in certain languages.
|
||||
* Client builds for FreeBSD are now made.
|
||||
* Added `FormattedMessage.TrimEnd()`.
|
||||
* Added Toolshed `with` for `ProtoId<T>`.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
* Fix `UniqueIndex<,>.RemoveRange()` and`UniqueIndexHkm<,>.RemoveRange()` clearing the whole set instead of just removing the specified values.
|
||||
* Avoid server crashes on some weird console setups (notably Pterodactyl).
|
||||
* Avoid unhandled exceptions during server shutdown getting swallowed due logging into a disposed logger.
|
||||
* Fix sandbox definitions for `Regex` functions returning `MatchCollection`.
|
||||
* Fix minor layout bugs with `SplitContainer` and `BoxContainer`.
|
||||
|
||||
### Other
|
||||
|
||||
* Changed how multi-window rendering presents to the screen with a new CVar `display.thread_unlock_before_swap`. This is an experiment to see if it solves some synchronization issues.
|
||||
* View Variables no longer clears the window on refresh while waiting on response from server.
|
||||
* `SpinBox` buttons now have a `+` prefix for the positive ones.
|
||||
* Improve Toolshed type intersection mechanism
|
||||
|
||||
### Internal
|
||||
|
||||
* Warning cleanup.
|
||||
|
||||
## 237.1.0
|
||||
|
||||
### New features
|
||||
|
||||
* csi's auto import-system can now handle generic types.
|
||||
* csi's reflection helpers (like `fld()`) handle private members up the inheritance chain.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
* Fix `UniqueIndexHkm<,>` and, by extension, entity data storage memory leaking.
|
||||
* Fix bugs related to UIScale on `OSWindow`s.
|
||||
|
||||
|
||||
## 237.0.0
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* `IClydeWindow.Size` is now settable, allowing window sizes to be changed after creation.
|
||||
|
||||
### New features
|
||||
|
||||
* The game server's `/update` endpoint now supports passing more information on why an update is available.
|
||||
* This information is accessible via `IWatchdogApi.RestartRequested`.
|
||||
* Information can be specified by passing a JSON object with a `Reason` code and `Message` field.
|
||||
* Added an "Erase" button to the tile spawn menu.
|
||||
* Added `OSWindow.Create()`, which allows OS windows to be created & initialised without immediately opening/showing them.
|
||||
|
||||
### Other
|
||||
|
||||
* Made `WatchdogApi` and some members of `IWatchdogApi` private. These symbols should never have been accessed by content.
|
||||
|
||||
|
||||
## 236.1.0
|
||||
|
||||
### New features
|
||||
|
||||
* `RequiredMemberAttribute` and `SetsRequiredMembersAttribute` have been added to the sandbox whitelist. I.e., you can now use the `required` keyword in client/shared code.
|
||||
* Added `SwitchExpressionException` to sandbox. This type gets used if you have a `switch` expression with no default case.
|
||||
* Added `LineEdit.SelectAllOnFocus`.
|
||||
* `GameTitle`, `WindowIconSet` and `SplashLogo` are exposed in `IGameController`. These will return said information set in game options or whatever is set in `manifest.yml`.
|
||||
* `BoundUserInterface` inheritors now have access to `PlayerManager`.
|
||||
* Added `MuteSounds` bool to `BaseButton`.
|
||||
* The engine has a new future-proof HWID system.
|
||||
* The auth server now manages HWIDs. This avoids HWID impersonation attacks.
|
||||
* The auth server can return multiple HWIDs. They are accessible in `NetUserData.ModernHWIds`.
|
||||
* The auth server also returns a trust score factor, accessible as `NetUserData.Trust`.
|
||||
* HWID can be disabled client side (`ROBUST_AUTH_ALLOW_HWID` env var) or server side (`net.hwid` cvar).
|
||||
* The old HWID system is still in place. It is intended that content switches to placing new bans against the new HWIDs.
|
||||
* Old HWIDs no longer work if the connection is not authenticated.
|
||||
* `launchauth` command now recognizes `SS14_LAUNCHER_APPDATA_NAME`.
|
||||
* Added new overload to `EntityLookupSystem.GetEntitiesIntersecting`.
|
||||
* Added `Control.RemoveChild(int childIndex)`.
|
||||
* `build.entities_category_filter` allows filtering the entity spawn panel to a specific category.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
* Fixed `SpriteView` offset calculations when scaled.
|
||||
|
||||
### Other
|
||||
|
||||
* Sprite flicks are applied immediately when started.
|
||||
* More warning fixes.
|
||||
* If the server gets shut down before finishing startup, the reason is now logged properly.
|
||||
|
||||
|
||||
## 236.0.0
|
||||
|
||||
### Breaking changes
|
||||
|
||||
* Revert IsTouching only being set to true if the contact were laready touching in clientside physics prediction.
|
||||
* Don't touch IsTouching if both bodies are asleep for clientside physics contacts. This change and the one above should fix a lot of clientside contact issues, particularly around repeated incorrect clientside contact events.
|
||||
|
||||
### New features
|
||||
|
||||
* Added an analyzer to detect duplicate Dependency fields.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
* Auto-networked dictionaries now use `TryAdd()` to avoid duplicate key errors when a dictionary contains multiple unknown networked entities.
|
||||
* Fixed `ICommonSession.Ping` always returning zero instead of the ping. Note that this will still return zero for client-side code when trying to get the ping of other players.
|
||||
* Hot reload XAML files on rename to fix them potentially not being reloaded with Visual Studio.
|
||||
* Fix TabContainer click detection for non-1.0 UI scales.
|
||||
|
||||
### Other
|
||||
|
||||
* Obsolete some static localization methods.
|
||||
* Tried to improve PVS tolerance to exceptions occurring.
|
||||
|
||||
|
||||
## 235.0.0
|
||||
|
||||
### Breaking changes
|
||||
|
||||
@@ -18,3 +18,9 @@
|
||||
description: entity-category-desc-hide
|
||||
hideSpawnMenu: true
|
||||
inheritable: false
|
||||
|
||||
# Entity prototypes added by the fork. With CVar you can hide all entities without this category
|
||||
- type: entityCategory
|
||||
id: ForkFiltered
|
||||
name: entity-category-name-fork
|
||||
description: entity-category-desc-fork
|
||||
@@ -20,6 +20,15 @@ zzzz-object-pronoun = { GENDER($ent) ->
|
||||
*[neuter] it
|
||||
}
|
||||
|
||||
# Used internally by the DAT-OBJ() function.
|
||||
# Not used in en-US. Created for supporting other languages.
|
||||
zzzz-dat-object = { GENDER($ent) ->
|
||||
[male] him
|
||||
[female] her
|
||||
[epicene] them
|
||||
*[neuter] it
|
||||
}
|
||||
|
||||
# Used internally by the POSS-PRONOUN() function.
|
||||
zzzz-possessive-pronoun = { GENDER($ent) ->
|
||||
[male] his
|
||||
|
||||
@@ -4,9 +4,16 @@ 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-erase-button-text = Erase Mode
|
||||
entity-spawn-window-override-menu-tooltip = Override placement
|
||||
|
||||
## TileSpawnWindow
|
||||
|
||||
tile-spawn-window-title = Place Tiles
|
||||
|
||||
## Console
|
||||
|
||||
console-line-edit-placeholder = Command Here
|
||||
|
||||
## Common Used
|
||||
|
||||
window-erase-button-text = Erase Mode
|
||||
|
||||
@@ -7,3 +7,6 @@ entity-category-desc-spawner = Entity prototypes that spawn other entities.
|
||||
|
||||
entity-category-name-hide = Hidden
|
||||
entity-category-desc-hide = Entity prototypes that should be hidden from entity spawn menus
|
||||
|
||||
entity-category-name-fork = Fork Filtered
|
||||
entity-category-desc-fork = Entity prototypes added by the fork. With CVar you can hide all entities without this category
|
||||
63
Robust.Analyzers.Tests/DuplicateDependencyAnalyzerTest.cs
Normal file
63
Robust.Analyzers.Tests/DuplicateDependencyAnalyzerTest.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CodeAnalysis.CSharp.Testing;
|
||||
using Microsoft.CodeAnalysis.Testing;
|
||||
using Microsoft.CodeAnalysis.Testing.Verifiers;
|
||||
using NUnit.Framework;
|
||||
using VerifyCS =
|
||||
Microsoft.CodeAnalysis.CSharp.Testing.NUnit.AnalyzerVerifier<Robust.Analyzers.DuplicateDependencyAnalyzer>;
|
||||
|
||||
namespace Robust.Analyzers.Tests;
|
||||
|
||||
[Parallelizable(ParallelScope.All | ParallelScope.Fixtures)]
|
||||
[TestFixture]
|
||||
[TestOf(typeof(DuplicateDependencyAnalyzer))]
|
||||
public sealed class DuplicateDependencyAnalyzerTest
|
||||
{
|
||||
private static Task Verifier(string code, params DiagnosticResult[] expected)
|
||||
{
|
||||
var test = new CSharpAnalyzerTest<DuplicateDependencyAnalyzer, NUnitVerifier>()
|
||||
{
|
||||
TestState =
|
||||
{
|
||||
Sources = { code }
|
||||
},
|
||||
};
|
||||
|
||||
TestHelper.AddEmbeddedSources(
|
||||
test.TestState,
|
||||
"Robust.Shared.IoC.DependencyAttribute.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.IoC;
|
||||
|
||||
public sealed class Foo
|
||||
{
|
||||
[Dependency]
|
||||
private object? Field;
|
||||
|
||||
[Dependency]
|
||||
private object? Field2;
|
||||
|
||||
[Dependency]
|
||||
private string? DifferentField;
|
||||
|
||||
private string? NonDependency1;
|
||||
private string? NonDependency2;
|
||||
}
|
||||
""";
|
||||
|
||||
await Verifier(code,
|
||||
// /0/Test0.cs(9,21): warning RA0032: Another [Dependency] field of type 'object?' already exists in this type as field 'Field'
|
||||
VerifyCS.Diagnostic().WithSpan(9, 21, 9, 27).WithArguments("object?", "Field"));
|
||||
}
|
||||
}
|
||||
126
Robust.Analyzers/DuplicateDependencyAnalyzer.cs
Normal file
126
Robust.Analyzers/DuplicateDependencyAnalyzer.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using System.Collections.Immutable;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.Diagnostics;
|
||||
using Robust.Roslyn.Shared;
|
||||
|
||||
namespace Robust.Analyzers;
|
||||
|
||||
#nullable enable
|
||||
|
||||
/// <summary>
|
||||
/// Analyzer that detects duplicate <c>[Dependency]</c> fields inside a single type.
|
||||
/// </summary>
|
||||
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
||||
public sealed class DuplicateDependencyAnalyzer : DiagnosticAnalyzer
|
||||
{
|
||||
private const string DependencyAttributeType = "Robust.Shared.IoC.DependencyAttribute";
|
||||
|
||||
private static readonly DiagnosticDescriptor Rule = new(
|
||||
Diagnostics.IdDuplicateDependency,
|
||||
"Duplicate dependency field",
|
||||
"Another [Dependency] field of type '{0}' already exists in this type with field '{1}'",
|
||||
"Usage",
|
||||
DiagnosticSeverity.Warning,
|
||||
true);
|
||||
|
||||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);
|
||||
|
||||
public override void Initialize(AnalysisContext context)
|
||||
{
|
||||
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
|
||||
context.EnableConcurrentExecution();
|
||||
context.RegisterCompilationStartAction(compilationContext =>
|
||||
{
|
||||
var dependencyAttributeType = compilationContext.Compilation.GetTypeByMetadataName(DependencyAttributeType);
|
||||
if (dependencyAttributeType == null)
|
||||
return;
|
||||
|
||||
compilationContext.RegisterSymbolStartAction(symbolContext =>
|
||||
{
|
||||
var typeSymbol = (INamedTypeSymbol)symbolContext.Symbol;
|
||||
// Only deal with non-static classes, doesn't make sense to have dependencies in anything else.
|
||||
if (typeSymbol.TypeKind != TypeKind.Class || typeSymbol.IsStatic)
|
||||
return;
|
||||
|
||||
var state = new AnalyzerState(dependencyAttributeType);
|
||||
symbolContext.RegisterSyntaxNodeAction(state.AnalyzeField, SyntaxKind.FieldDeclaration);
|
||||
symbolContext.RegisterSymbolEndAction(state.End);
|
||||
},
|
||||
SymbolKind.NamedType);
|
||||
});
|
||||
}
|
||||
|
||||
private sealed class AnalyzerState(INamedTypeSymbol dependencyAttributeType)
|
||||
{
|
||||
private readonly Dictionary<ITypeSymbol, List<IFieldSymbol>> _dependencyFields = new(SymbolEqualityComparer.Default);
|
||||
|
||||
public void AnalyzeField(SyntaxNodeAnalysisContext context)
|
||||
{
|
||||
var field = (FieldDeclarationSyntax)context.Node;
|
||||
if (field.AttributeLists.Count == 0)
|
||||
return;
|
||||
|
||||
if (context.ContainingSymbol is not IFieldSymbol fieldSymbol)
|
||||
return;
|
||||
|
||||
// Can't have [Dependency]s for non-reference types.
|
||||
if (!fieldSymbol.Type.IsReferenceType)
|
||||
return;
|
||||
|
||||
if (!IsDependency(context.ContainingSymbol))
|
||||
return;
|
||||
|
||||
lock (_dependencyFields)
|
||||
{
|
||||
if (!_dependencyFields.TryGetValue(fieldSymbol.Type, out var dependencyFields))
|
||||
{
|
||||
dependencyFields = [];
|
||||
_dependencyFields.Add(fieldSymbol.Type, dependencyFields);
|
||||
}
|
||||
|
||||
dependencyFields.Add(fieldSymbol);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsDependency(ISymbol symbol)
|
||||
{
|
||||
foreach (var attributeData in symbol.GetAttributes())
|
||||
{
|
||||
if (SymbolEqualityComparer.Default.Equals(attributeData.AttributeClass, dependencyAttributeType))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void End(SymbolAnalysisContext context)
|
||||
{
|
||||
lock (_dependencyFields)
|
||||
{
|
||||
foreach (var pair in _dependencyFields)
|
||||
{
|
||||
var fieldType = pair.Key;
|
||||
var fields = pair.Value;
|
||||
if (fields.Count <= 1)
|
||||
continue;
|
||||
|
||||
// Sort so we can have deterministic order to skip reporting for a single field.
|
||||
// Whichever sorts first doesn't get reported.
|
||||
fields.Sort(static (a, b) => string.Compare(a.Name, b.Name, StringComparison.Ordinal));
|
||||
|
||||
// Start at index 1 to skip first field.
|
||||
var firstField = fields[0];
|
||||
for (var i = 1; i < fields.Count; i++)
|
||||
{
|
||||
var field = fields[i];
|
||||
|
||||
context.ReportDiagnostic(
|
||||
Diagnostic.Create(Rule, field.Locations[0], fieldType.ToDisplayString(), firstField.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -669,7 +669,8 @@ public sealed partial class AudioSystem : SharedAudioSystem
|
||||
|
||||
// TODO clamp the offset inside of SetPlaybackPosition() itself.
|
||||
var offset = audioP.PlayOffsetSeconds;
|
||||
offset = Math.Clamp(offset, 0f, (float) stream.Length.TotalSeconds - 0.01f);
|
||||
var maxOffset = Math.Max((float) stream.Length.TotalSeconds - 0.01f, 0f);
|
||||
offset = Math.Clamp(offset, 0f, maxOffset);
|
||||
source.PlaybackPosition = offset;
|
||||
|
||||
// For server we will rely on the adjusted one but locally we will have to adjust it ourselves.
|
||||
|
||||
@@ -8,6 +8,7 @@ using Robust.Client.GameObjects;
|
||||
using Robust.Client.GameStates;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Graphics.Clyde;
|
||||
using Robust.Client.HWId;
|
||||
using Robust.Client.Input;
|
||||
using Robust.Client.Map;
|
||||
using Robust.Client.Placement;
|
||||
@@ -158,6 +159,7 @@ namespace Robust.Client
|
||||
|
||||
deps.Register<IXamlProxyHelper, XamlProxyHelper>();
|
||||
deps.Register<MarkupTagManager>();
|
||||
deps.Register<IHWId, BasicHWId>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,9 @@ namespace Robust.Client.Console.Commands
|
||||
{
|
||||
var wantName = args.Length > 0 ? args[0] : null;
|
||||
|
||||
var basePath = Path.GetDirectoryName(UserDataDir.GetUserDataDir(_gameController))!;
|
||||
var dbPath = Path.Combine(basePath, "launcher", "settings.db");
|
||||
var basePath = UserDataDir.GetRootUserDataDir(_gameController);
|
||||
var launcherDirName = Environment.GetEnvironmentVariable("SS14_LAUNCHER_APPDATA_NAME") ?? "launcher";
|
||||
var dbPath = Path.Combine(basePath, launcherDirName, "settings.db");
|
||||
|
||||
#if USE_SYSTEM_SQLITE
|
||||
SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlite3());
|
||||
|
||||
@@ -112,14 +112,28 @@ namespace Robust.Client
|
||||
_commandLineArgs = args;
|
||||
}
|
||||
|
||||
public string GameTitle()
|
||||
{
|
||||
return Options.DefaultWindowTitle ?? _resourceManifest!.DefaultWindowTitle ?? "RobustToolbox";
|
||||
}
|
||||
|
||||
public string WindowIconSet()
|
||||
{
|
||||
return Options.WindowIconSet?.ToString() ?? _resourceManifest!.WindowIconSet ?? "";
|
||||
}
|
||||
|
||||
public string SplashLogo()
|
||||
{
|
||||
return Options.SplashLogo?.ToString() ?? _resourceManifest!.SplashLogo ?? "";
|
||||
}
|
||||
|
||||
internal bool StartupContinue(DisplayMode displayMode)
|
||||
{
|
||||
DebugTools.AssertNotNull(_resourceManifest);
|
||||
|
||||
_clyde.InitializePostWindowing();
|
||||
_audio.InitializePostWindowing();
|
||||
_clyde.SetWindowTitle(
|
||||
Options.DefaultWindowTitle ?? _resourceManifest!.DefaultWindowTitle ?? "RobustToolbox");
|
||||
_clyde.SetWindowTitle(GameTitle());
|
||||
|
||||
_taskManager.Initialize();
|
||||
_parallelMgr.Initialize();
|
||||
@@ -399,10 +413,8 @@ namespace Robust.Client
|
||||
// Handle GameControllerOptions implicit CVar overrides.
|
||||
_configurationManager.OverrideConVars(new[]
|
||||
{
|
||||
(CVars.DisplayWindowIconSet.Name,
|
||||
options.WindowIconSet?.ToString() ?? _resourceManifest.WindowIconSet ?? ""),
|
||||
(CVars.DisplaySplashLogo.Name,
|
||||
options.SplashLogo?.ToString() ?? _resourceManifest.SplashLogo ?? "")
|
||||
(CVars.DisplayWindowIconSet.Name, WindowIconSet()),
|
||||
(CVars.DisplaySplashLogo.Name, SplashLogo())
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -143,6 +143,14 @@ namespace Robust.Client.GameObjects
|
||||
}
|
||||
#endif
|
||||
|
||||
foreach (var track in animation.AnimationTracks)
|
||||
{
|
||||
if (track is not AnimationTrackSpriteFlick)
|
||||
continue;
|
||||
|
||||
track.AdvancePlayback(ent.Owner, 0, 0, 0f);
|
||||
}
|
||||
|
||||
ent.Comp.PlayingAnimations.Add(key, playback);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Utility;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -241,7 +240,7 @@ namespace Robust.Client.GameObjects
|
||||
#if DEBUG
|
||||
var uid = GetEntity(netEntity);
|
||||
|
||||
if (TryComp<MetaDataComponent>(uid, out var meta))
|
||||
if (TryComp(uid, out MetaDataComponent? meta))
|
||||
{
|
||||
DebugTools.Assert((meta.Flags & ( MetaDataFlags.Detached | MetaDataFlags.InContainer) ) == MetaDataFlags.Detached,
|
||||
$"Adding entity {ToPrettyString(uid)} to list of expected entities for container {container.ID} in {ToPrettyString(container.Owner)}, despite it already being in a container.");
|
||||
|
||||
@@ -46,7 +46,6 @@ namespace Robust.Client.GameStates
|
||||
|
||||
// sum of all data point sizes in bytes
|
||||
private int _totalHistoryPayload;
|
||||
private int _totalUncompressed;
|
||||
|
||||
public EntityUid WatchEntId { get; set; }
|
||||
|
||||
|
||||
@@ -109,6 +109,9 @@ namespace Robust.Client.Graphics.Clyde
|
||||
|
||||
private void SendWindowResized(WindowReg reg, Vector2i oldSize)
|
||||
{
|
||||
if (!reg.IsVisible) // Only send this for open windows
|
||||
return;
|
||||
|
||||
var loaded = RtToLoaded(reg.RenderTarget);
|
||||
loaded.Size = reg.FramebufferSize;
|
||||
|
||||
|
||||
@@ -362,6 +362,11 @@ namespace Robust.Client.Graphics.Clyde
|
||||
rect.BottomLeft, rect.BottomRight, color, subRegion);
|
||||
}
|
||||
|
||||
public override void DrawTexture(Texture texture, Vector2 position, Color? modulate = null)
|
||||
{
|
||||
base.DrawTexture(texture, position, modulate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws an entity.
|
||||
/// </summary>
|
||||
|
||||
@@ -343,6 +343,8 @@ namespace Robust.Client.Graphics.Clyde
|
||||
if (isMain)
|
||||
_mainWindow = reg;
|
||||
|
||||
reg.IsVisible = parameters.Visible;
|
||||
|
||||
_windows.Add(reg);
|
||||
_windowHandles.Add(reg.Handle);
|
||||
|
||||
@@ -444,6 +446,12 @@ namespace Robust.Client.Graphics.Clyde
|
||||
_windowing!.CursorSet(_mainWindow!, cursor);
|
||||
}
|
||||
|
||||
private void SetWindowSize(WindowReg reg, Vector2i size)
|
||||
{
|
||||
DebugTools.AssertNotNull(_windowing);
|
||||
|
||||
_windowing!.WindowSetSize(reg, size);
|
||||
}
|
||||
|
||||
private void SetWindowVisible(WindowReg reg, bool visible)
|
||||
{
|
||||
@@ -533,7 +541,11 @@ namespace Robust.Client.Graphics.Clyde
|
||||
_clyde.DoDestroyWindow(Reg);
|
||||
}
|
||||
|
||||
public Vector2i Size => Reg.FramebufferSize;
|
||||
public Vector2i Size
|
||||
{
|
||||
get => Reg.FramebufferSize;
|
||||
set => _clyde.SetWindowSize(Reg, value);
|
||||
}
|
||||
|
||||
public IRenderTarget RenderTarget => Reg.RenderTarget;
|
||||
|
||||
|
||||
@@ -517,7 +517,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
RenderTarget = renderTarget;
|
||||
}
|
||||
|
||||
public Vector2i Size { get; } = default;
|
||||
public Vector2i Size { get; set; } = default;
|
||||
public bool IsDisposed { get; private set; }
|
||||
public WindowId Id { get; set; }
|
||||
public IRenderTarget RenderTarget { get; }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
@@ -176,6 +176,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
window.BlitDoneEvent!.Reset();
|
||||
window.BlitStartEvent!.Set();
|
||||
window.BlitDoneEvent.Wait();
|
||||
window.UnlockBeforeSwap = Clyde._cfg.GetCVar(CVars.DisplayThreadUnlockBeforeSwap);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -212,8 +213,15 @@ namespace Robust.Client.Graphics.Clyde
|
||||
GL.DrawArrays(PrimitiveType.TriangleStrip, 0, 4);
|
||||
Clyde.CheckGlError();
|
||||
|
||||
window.BlitDoneEvent?.Set();
|
||||
if (window.UnlockBeforeSwap)
|
||||
{
|
||||
window.BlitDoneEvent?.Set();
|
||||
}
|
||||
Clyde._windowing!.WindowSwapBuffers(window.Reg);
|
||||
if (!window.UnlockBeforeSwap)
|
||||
{
|
||||
window.BlitDoneEvent?.Set();
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe void BlitThreadInit(WindowData reg)
|
||||
@@ -336,6 +344,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
public Thread? BlitThread;
|
||||
public ManualResetEventSlim? BlitStartEvent;
|
||||
public ManualResetEventSlim? BlitDoneEvent;
|
||||
public bool UnlockBeforeSwap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,10 @@ namespace Robust.Client.Graphics.Clyde
|
||||
WinThreadWinSetMonitor(cmd);
|
||||
break;
|
||||
|
||||
case CmdWinSetSize cmd:
|
||||
WinThreadWinSetSize(cmd);
|
||||
break;
|
||||
|
||||
case CmdWinSetVisible cmd:
|
||||
WinThreadWinSetVisible(cmd);
|
||||
break;
|
||||
@@ -234,6 +238,11 @@ namespace Robust.Client.Graphics.Clyde
|
||||
nint Window
|
||||
) : CmdBase;
|
||||
|
||||
private sealed record CmdWinSetSize(
|
||||
nint Window,
|
||||
int W, int H
|
||||
) : CmdBase;
|
||||
|
||||
private sealed record CmdWinSetVisible(
|
||||
nint Window,
|
||||
bool Visible
|
||||
|
||||
@@ -84,6 +84,13 @@ namespace Robust.Client.Graphics.Clyde
|
||||
);
|
||||
}
|
||||
|
||||
public void WindowSetSize(WindowReg window, Vector2i size)
|
||||
{
|
||||
var reg = (GlfwWindowReg) window;
|
||||
|
||||
SendCmd(new CmdWinSetSize((nint) reg.GlfwWindow, size.X, size.Y));
|
||||
}
|
||||
|
||||
public void WindowSetVisible(WindowReg window, bool visible)
|
||||
{
|
||||
var reg = (GlfwWindowReg) window;
|
||||
@@ -92,6 +99,13 @@ namespace Robust.Client.Graphics.Clyde
|
||||
SendCmd(new CmdWinSetVisible((nint) reg.GlfwWindow, visible));
|
||||
}
|
||||
|
||||
private void WinThreadWinSetSize(CmdWinSetSize cmd)
|
||||
{
|
||||
var win = (Window*) cmd.Window;
|
||||
|
||||
GLFW.SetWindowSize(win, cmd.W, cmd.H);
|
||||
}
|
||||
|
||||
private void WinThreadWinSetVisible(CmdWinSetVisible cmd)
|
||||
{
|
||||
var win = (Window*) cmd.Window;
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
void WindowDestroy(WindowReg reg);
|
||||
void WindowSetTitle(WindowReg window, string title);
|
||||
void WindowSetMonitor(WindowReg window, IClydeMonitor monitor);
|
||||
void WindowSetSize(WindowReg window, Vector2i size);
|
||||
void WindowSetVisible(WindowReg window, bool visible);
|
||||
void WindowRequestAttention(WindowReg window);
|
||||
void WindowSwapBuffers(WindowReg window);
|
||||
|
||||
@@ -93,6 +93,10 @@ internal partial class Clyde
|
||||
WinThreadWinRequestAttention(cmd);
|
||||
break;
|
||||
|
||||
case CmdWinSetSize cmd:
|
||||
WinThreadWinSetSize(cmd);
|
||||
break;
|
||||
|
||||
case CmdWinSetVisible cmd:
|
||||
WinThreadWinSetVisible(cmd);
|
||||
break;
|
||||
@@ -246,6 +250,11 @@ internal partial class Clyde
|
||||
nint Window
|
||||
) : CmdBase;
|
||||
|
||||
private sealed record CmdWinSetSize(
|
||||
nint Window,
|
||||
int W, int H
|
||||
) : CmdBase;
|
||||
|
||||
private sealed record CmdWinSetVisible(
|
||||
nint Window,
|
||||
bool Visible
|
||||
|
||||
@@ -336,11 +336,22 @@ internal partial class Clyde
|
||||
_sawmill.Warning("WindowSetMonitor not implemented on SDL2");
|
||||
}
|
||||
|
||||
public void WindowSetSize(WindowReg window, Vector2i size)
|
||||
{
|
||||
SendCmd(new CmdWinSetSize(WinPtr(window), size.X, size.Y));
|
||||
}
|
||||
|
||||
public void WindowSetVisible(WindowReg window, bool visible)
|
||||
{
|
||||
window.IsVisible = visible;
|
||||
SendCmd(new CmdWinSetVisible(WinPtr(window), visible));
|
||||
}
|
||||
|
||||
private static void WinThreadWinSetSize(CmdWinSetSize cmd)
|
||||
{
|
||||
SDL_SetWindowSize(cmd.Window, cmd.W, cmd.H);
|
||||
}
|
||||
|
||||
private static void WinThreadWinSetVisible(CmdWinSetVisible cmd)
|
||||
{
|
||||
if (cmd.Visible)
|
||||
|
||||
@@ -211,6 +211,8 @@ namespace Robust.Client.Graphics
|
||||
public abstract void DrawLine(Vector2 from, Vector2 to, Color color);
|
||||
|
||||
public abstract void RenderInRenderTarget(IRenderTarget target, Action a, Color? clearColor);
|
||||
|
||||
public abstract void DrawTexture(Texture texture, Vector2 position, Color? modulate = null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Robust.Client.Graphics
|
||||
|
||||
public abstract void DrawTextureRectRegion(Texture texture, UIBox2 rect, UIBox2? subRegion = null, Color? modulate = null);
|
||||
|
||||
public void DrawTexture(Texture texture, Vector2 position, Color? modulate = null)
|
||||
public override void DrawTexture(Texture texture, Vector2 position, Color? modulate = null)
|
||||
{
|
||||
CheckDisposed();
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Robust.Client.Graphics
|
||||
/// <remarks>
|
||||
/// The sprite will have it's local dimensions calculated so that it has <see cref="EyeManager.PixelsPerMeter"/> texels per meter in the world.
|
||||
/// </remarks>
|
||||
public void DrawTexture(Texture texture, Vector2 position, Color? modulate = null)
|
||||
public override void DrawTexture(Texture texture, Vector2 position, Color? modulate = null)
|
||||
{
|
||||
CheckDisposed();
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Robust.Client.Graphics
|
||||
/// <param name="fallback">If the character is not available, render "<22>" instead.</param>
|
||||
/// <returns>How much to advance the cursor to draw the next character.</returns>
|
||||
public abstract float DrawChar(
|
||||
DrawingHandleScreen handle, Rune rune, Vector2 baseline, float scale,
|
||||
DrawingHandleBase handle, Rune rune, Vector2 baseline, float scale,
|
||||
Color color, bool fallback=true);
|
||||
|
||||
/// <summary>
|
||||
@@ -109,7 +109,7 @@ namespace Robust.Client.Graphics
|
||||
public override int GetDescent(float scale) => Handle.GetDescent(scale);
|
||||
public override int GetLineHeight(float scale) => Handle.GetLineHeight(scale);
|
||||
|
||||
public override float DrawChar(DrawingHandleScreen handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback=true)
|
||||
public override float DrawChar(DrawingHandleBase handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback=true)
|
||||
{
|
||||
var metrics = Handle.GetCharMetrics(rune, scale);
|
||||
if (!metrics.HasValue)
|
||||
@@ -132,7 +132,10 @@ namespace Robust.Client.Graphics
|
||||
}
|
||||
|
||||
baseline += new Vector2(metrics.Value.BearingX, -metrics.Value.BearingY);
|
||||
handle.DrawTexture(texture, baseline, color);
|
||||
if(handle is DrawingHandleWorld worldhandle)
|
||||
worldhandle.DrawTextureRect(texture, Box2.FromDimensions(baseline, texture.Size));
|
||||
else
|
||||
handle.DrawTexture(texture, baseline, color);
|
||||
return metrics.Value.Advance;
|
||||
}
|
||||
|
||||
@@ -169,7 +172,7 @@ namespace Robust.Client.Graphics
|
||||
public override int GetLineHeight(float scale) => _main.GetLineHeight(scale);
|
||||
|
||||
// DrawChar just proxies to the stack, or invokes _main's fallback.
|
||||
public override float DrawChar(DrawingHandleScreen handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback=true)
|
||||
public override float DrawChar(DrawingHandleBase handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback=true)
|
||||
{
|
||||
foreach (var f in Stack)
|
||||
{
|
||||
@@ -207,7 +210,7 @@ namespace Robust.Client.Graphics
|
||||
public override int GetDescent(float scale) => default;
|
||||
public override int GetLineHeight(float scale) => default;
|
||||
|
||||
public override float DrawChar(DrawingHandleScreen handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback=true)
|
||||
public override float DrawChar(DrawingHandleBase handle, Rune rune, Vector2 baseline, float scale, Color color, bool fallback=true)
|
||||
{
|
||||
// Nada, it's a dummy after all.
|
||||
return 0;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Robust.Client.Graphics
|
||||
WindowId Id { get; }
|
||||
IRenderTarget RenderTarget { get; }
|
||||
string Title { get; set; }
|
||||
Vector2i Size { get; }
|
||||
Vector2i Size { get; set; }
|
||||
bool IsFocused { get; }
|
||||
bool IsMinimized { get; }
|
||||
bool IsVisible { get; set; }
|
||||
|
||||
86
Robust.Client/HWId/BasicHWId.cs
Normal file
86
Robust.Client/HWId/BasicHWId.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using Microsoft.Win32;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Robust.Client.HWId;
|
||||
|
||||
internal sealed class BasicHWId : IHWId
|
||||
{
|
||||
[Dependency] private readonly IGameControllerInternal _gameController = default!;
|
||||
|
||||
public const int LengthHwid = 32;
|
||||
|
||||
public byte[] GetLegacy()
|
||||
{
|
||||
if (OperatingSystem.IsWindows())
|
||||
return GetWindowsHWid("Hwid");
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public byte[] GetModern()
|
||||
{
|
||||
byte[] raw;
|
||||
|
||||
if (OperatingSystem.IsWindows())
|
||||
raw = GetWindowsHWid("Hwid2");
|
||||
else
|
||||
raw = GetFileHWid();
|
||||
|
||||
return [0, ..raw];
|
||||
}
|
||||
|
||||
private static byte[] GetWindowsHWid(string keyName)
|
||||
{
|
||||
const string keyPath = @"HKEY_CURRENT_USER\SOFTWARE\Space Wizards\Robust";
|
||||
|
||||
var regKey = Registry.GetValue(keyPath, keyName, null);
|
||||
if (regKey is byte[] { Length: LengthHwid } bytes)
|
||||
return bytes;
|
||||
|
||||
var newId = new byte[LengthHwid];
|
||||
RandomNumberGenerator.Fill(newId);
|
||||
Registry.SetValue(
|
||||
keyPath,
|
||||
keyName,
|
||||
newId,
|
||||
RegistryValueKind.Binary);
|
||||
|
||||
return newId;
|
||||
}
|
||||
|
||||
private byte[] GetFileHWid()
|
||||
{
|
||||
var path = UserDataDir.GetRootUserDataDir(_gameController);
|
||||
var hwidPath = Path.Combine(path, ".hwid");
|
||||
|
||||
var value = ReadHWidFile(hwidPath);
|
||||
if (value != null)
|
||||
return value;
|
||||
|
||||
value = RandomNumberGenerator.GetBytes(LengthHwid);
|
||||
File.WriteAllBytes(hwidPath, value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private static byte[]? ReadHWidFile(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
var value = File.ReadAllBytes(path);
|
||||
if (value.Length == LengthHwid)
|
||||
return value;
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
// First time the file won't exist.
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -26,5 +26,20 @@ public interface IGameController
|
||||
/// This exists to give content module more control over tick updating.
|
||||
/// </summary>
|
||||
event Action<FrameEventArgs>? TickUpdateOverride;
|
||||
|
||||
/// <summary>
|
||||
/// Get the games Title, if Options.DefaultWindowTitle or if defaultWindowTitle is not set in the manifest.yml, it will default to RobustToolbox.
|
||||
/// </summary>
|
||||
string GameTitle();
|
||||
|
||||
/// <summary>
|
||||
/// Get the games Window Icon set, if Options.WindowIconSet or if windowIconSet is not set in the manifest.yml, it will default to an empty string.
|
||||
/// </summary>
|
||||
string WindowIconSet();
|
||||
|
||||
/// <summary>
|
||||
/// Get the games Splash Logo, if Options.SplashLogo or if splashLogo is not set in the manifest.yml, it will default to an empty string.
|
||||
/// </summary>
|
||||
string SplashLogo();
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,6 @@ public sealed partial class PhysicsSystem
|
||||
|
||||
if (activeA == false && activeB == false)
|
||||
{
|
||||
contact.IsTouching = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
|
||||
@@ -14,16 +15,16 @@ namespace Robust.Client.Placement.Modes
|
||||
public override void AlignPlacementMode(ScreenCoordinates mouseScreen)
|
||||
{
|
||||
// Go over diagonal size so when placing in a line it doesn't stop snapping.
|
||||
const float SearchBoxSize = 2f; // size of search box in meters
|
||||
const float searchBoxSize = 2f; // size of search box in meters
|
||||
|
||||
MouseCoords = ScreenToCursorGrid(mouseScreen).AlignWithClosestGridTile(SearchBoxSize, pManager.EntityManager, pManager.MapManager);
|
||||
MouseCoords = ScreenToCursorGrid(mouseScreen).AlignWithClosestGridTile(searchBoxSize, pManager.EntityManager, pManager.MapManager);
|
||||
|
||||
var gridId = MouseCoords.GetGridUid(pManager.EntityManager);
|
||||
var gridId = pManager.EntityManager.System<SharedTransformSystem>().GetGrid(MouseCoords);
|
||||
|
||||
if (!pManager.EntityManager.TryGetComponent<MapGridComponent>(gridId, out var mapGrid))
|
||||
return;
|
||||
|
||||
CurrentTile = mapGrid.GetTileRef(MouseCoords);
|
||||
CurrentTile = pManager.EntityManager.System<SharedMapSystem>().GetTileRef(gridId.Value, mapGrid, MouseCoords);
|
||||
float tileSize = mapGrid.TileSize; //convert from ushort to float
|
||||
GridDistancing = tileSize;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Numerics;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Maths;
|
||||
@@ -19,12 +18,12 @@ namespace Robust.Client.Placement.Modes
|
||||
MouseCoords = ScreenToCursorGrid(mouseScreen);
|
||||
|
||||
var tileSize = 1f;
|
||||
var gridIdOpt = MouseCoords.GetGridUid(pManager.EntityManager);
|
||||
var gridIdOpt = pManager.EntityManager.System<SharedTransformSystem>().GetGrid(MouseCoords);
|
||||
|
||||
if (gridIdOpt is EntityUid gridId && gridId.IsValid())
|
||||
if (gridIdOpt is { } gridId && gridId.IsValid())
|
||||
{
|
||||
var mapGrid = pManager.EntityManager.GetComponent<MapGridComponent>(gridId);
|
||||
CurrentTile = mapGrid.GetTileRef(MouseCoords);
|
||||
CurrentTile = pManager.EntityManager.System<SharedMapSystem>().GetTileRef(gridId, mapGrid ,MouseCoords);
|
||||
tileSize = mapGrid.TileSize; //convert from ushort to float
|
||||
}
|
||||
|
||||
@@ -50,12 +49,12 @@ namespace Robust.Client.Placement.Modes
|
||||
return false;
|
||||
}
|
||||
|
||||
var map = MouseCoords.GetMapId(pManager.EntityManager);
|
||||
var map = pManager.EntityManager.System<SharedTransformSystem>().GetMapId(MouseCoords);
|
||||
var bottomLeft = new Vector2(CurrentTile.X, CurrentTile.Y);
|
||||
var topRight = new Vector2(CurrentTile.X + 0.99f, CurrentTile.Y + 0.99f);
|
||||
var box = new Box2(bottomLeft, topRight);
|
||||
|
||||
return !EntitySystem.Get<EntityLookupSystem>().AnyEntitiesIntersecting(map, box);
|
||||
return !pManager.EntityManager.System<EntityLookupSystem>().AnyEntitiesIntersecting(map, box);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -754,14 +754,14 @@ namespace Robust.Client.Placement
|
||||
|
||||
if (CurrentPermission.IsTile)
|
||||
{
|
||||
var gridIdOpt = coordinates.GetGridUid(EntityManager);
|
||||
var gridIdOpt = EntityManager.System<SharedTransformSystem>().GetGrid(coordinates);
|
||||
// If we have actually placed something on a valid grid...
|
||||
if (gridIdOpt is EntityUid gridId && gridId.IsValid())
|
||||
if (gridIdOpt is { } gridId && gridId.IsValid())
|
||||
{
|
||||
var grid = EntityManager.GetComponent<MapGridComponent>(gridId);
|
||||
|
||||
// no point changing the tile to the same thing.
|
||||
if (grid.GetTileRef(coordinates).Tile.TypeId == CurrentPermission.TileType)
|
||||
if (EntityManager.System<SharedMapSystem>().GetTileRef(gridId, grid, coordinates).Tile.TypeId == CurrentPermission.TileType)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -197,8 +197,9 @@ namespace Robust.Client.Placement
|
||||
/// </summary>
|
||||
public TileRef GetTileRef(EntityCoordinates coordinates)
|
||||
{
|
||||
var gridUidOpt = coordinates.GetGridUid(pManager.EntityManager);
|
||||
return gridUidOpt is EntityUid gridUid && gridUid.IsValid() ? pManager.EntityManager.GetComponent<MapGridComponent>(gridUid).GetTileRef(MouseCoords)
|
||||
var gridUidOpt = pManager.EntityManager.System<SharedTransformSystem>().GetGrid(coordinates);
|
||||
return gridUidOpt is { } gridUid && gridUid.IsValid()
|
||||
? pManager.EntityManager.System<SharedMapSystem>().GetTileRef(gridUid, pManager.EntityManager.GetComponent<MapGridComponent>(gridUid), MouseCoords)
|
||||
: new TileRef(gridUidOpt ?? EntityUid.Invalid,
|
||||
MouseCoords.ToVector2i(pManager.EntityManager, pManager.MapManager, pManager.EntityManager.System<SharedTransformSystem>()), Tile.Empty);
|
||||
}
|
||||
|
||||
@@ -261,7 +261,6 @@ namespace Robust.Client.Player
|
||||
// This is a new userid, so we create a new session.
|
||||
DebugTools.Assert(state.UserId != LocalPlayer?.UserId);
|
||||
var newSession = (ICommonSessionInternal)CreateAndAddSession(state.UserId, state.Name);
|
||||
newSession.SetPing(state.Ping);
|
||||
SetStatus(newSession, state.Status);
|
||||
SetAttachedEntity(newSession, controlled, out _, true);
|
||||
dirty = true;
|
||||
@@ -271,7 +270,6 @@ namespace Robust.Client.Player
|
||||
// Check if the data is actually different
|
||||
if (session.Name == state.Name
|
||||
&& session.Status == state.Status
|
||||
&& session.Ping == state.Ping
|
||||
&& session.AttachedEntity == controlled)
|
||||
{
|
||||
continue;
|
||||
@@ -280,7 +278,6 @@ namespace Robust.Client.Player
|
||||
dirty = true;
|
||||
var local = (ICommonSessionInternal)session;
|
||||
local.SetName(state.Name);
|
||||
local.SetPing(state.Ping);
|
||||
SetStatus(local, state.Status);
|
||||
SetAttachedEntity(local, controlled, out _, true);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public sealed partial class ReplayLoadManager
|
||||
var uncompressedSize = BitConverter.ToInt32(intBuf);
|
||||
|
||||
var decompressedStream = new MemoryStream(uncompressedSize);
|
||||
decompressStream.CopyTo(decompressedStream, uncompressedSize);
|
||||
decompressStream.CopyTo(decompressedStream);
|
||||
decompressedStream.Position = 0;
|
||||
DebugTools.Assert(uncompressedSize == decompressedStream.Length);
|
||||
|
||||
|
||||
@@ -143,9 +143,9 @@ namespace Robust.Client.ResourceManagement
|
||||
}
|
||||
});
|
||||
|
||||
// Do not meta-atlas RSIs with custom load parameters.
|
||||
var atlasList = rsiList.Where(x => x.LoadParameters == TextureLoadParameters.Default).ToArray();
|
||||
var nonAtlasList = rsiList.Where(x => x.LoadParameters != TextureLoadParameters.Default).ToArray();
|
||||
var atlasLookup = rsiList.ToLookup(ShouldMetaAtlas);
|
||||
var atlasList = atlasLookup[true].ToArray();
|
||||
var nonAtlasList = atlasLookup[false].ToArray();
|
||||
|
||||
foreach (var data in nonAtlasList)
|
||||
{
|
||||
@@ -225,8 +225,9 @@ namespace Robust.Client.ResourceManagement
|
||||
|
||||
void FinalizeMetaAtlas(int toIndex, Image<Rgba32> sheet)
|
||||
{
|
||||
var atlas = Clyde.LoadTextureFromImage(sheet);
|
||||
for (int i = finalized + 1; i <= toIndex; i++)
|
||||
var fromIndex = finalized + 1;
|
||||
var atlas = Clyde.LoadTextureFromImage(sheet, $"Meta atlas {fromIndex}-{toIndex}");
|
||||
for (int i = fromIndex; i <= toIndex; i++)
|
||||
{
|
||||
var rsi = atlasList[i];
|
||||
rsi.AtlasTexture = atlas;
|
||||
@@ -282,7 +283,11 @@ namespace Robust.Client.ResourceManagement
|
||||
nonAtlasList.Length,
|
||||
errors,
|
||||
sw.Elapsed);
|
||||
}
|
||||
|
||||
private static bool ShouldMetaAtlas(RSIResource.LoadStepData rsi)
|
||||
{
|
||||
return rsi.MetaAtlas && rsi.LoadParameters == TextureLoadParameters.Default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +183,7 @@ namespace Robust.Client.ResourceManagement
|
||||
data.DimX = dimensionX;
|
||||
data.CallbackOffsets = callbackOffsets;
|
||||
data.LoadParameters = metadata.LoadParameters;
|
||||
data.MetaAtlas = metadata.MetaAtlas;
|
||||
}
|
||||
|
||||
internal static void LoadPostTexture(LoadStepData data)
|
||||
@@ -386,6 +387,7 @@ namespace Robust.Client.ResourceManagement
|
||||
public Vector2i AtlasOffset;
|
||||
public RSI Rsi = default!;
|
||||
public TextureLoadParameters LoadParameters;
|
||||
public bool MetaAtlas;
|
||||
}
|
||||
|
||||
internal struct StateReg
|
||||
|
||||
@@ -762,7 +762,23 @@ namespace Robust.Client.UserInterface
|
||||
throw new InvalidOperationException("The provided control is not a direct child of this control.");
|
||||
}
|
||||
|
||||
_orderedChildren.Remove(child);
|
||||
var childIndex = _orderedChildren.IndexOf(child);
|
||||
RemoveChild(childIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the child at a specific index from this control.
|
||||
/// </summary>
|
||||
/// <param name="childIndex">The index of the child to remove.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException">
|
||||
/// Thrown if the provided child index is out of range
|
||||
/// </exception>
|
||||
public void RemoveChild(int childIndex)
|
||||
{
|
||||
DebugTools.Assert(!Disposed, "Control has been disposed.");
|
||||
|
||||
var child = _orderedChildren[childIndex];
|
||||
_orderedChildren.RemoveAt(childIndex);
|
||||
|
||||
child.Parent = null;
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ using Robust.Client.Placement;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -19,6 +21,7 @@ namespace Robust.Client.UserInterface.Controllers.Implementations;
|
||||
|
||||
public sealed class EntitySpawningUIController : UIController
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly IPlacementManager _placement = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypes = default!;
|
||||
|
||||
@@ -192,6 +195,9 @@ public sealed class EntitySpawningUIController : UIController
|
||||
_window.SelectedButton = null;
|
||||
searchStr = searchStr?.ToLowerInvariant();
|
||||
|
||||
var categoryFilter = _cfg.GetCVar(CVars.EntitiesCategoryFilter);
|
||||
_prototypes.TryIndex<EntityCategoryPrototype>(categoryFilter, out var filter);
|
||||
|
||||
foreach (var prototype in _prototypes.EnumeratePrototypes<EntityPrototype>())
|
||||
{
|
||||
if (prototype.Abstract)
|
||||
@@ -204,6 +210,11 @@ public sealed class EntitySpawningUIController : UIController
|
||||
continue;
|
||||
}
|
||||
|
||||
if (filter is not null && !prototype.Categories.Contains(filter))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (searchStr != null && !DoesEntityMatchSearch(prototype, searchStr))
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -27,6 +27,7 @@ public sealed class TileSpawningUIController : UIController
|
||||
|
||||
private readonly List<ITileDefinition> _shownTiles = new();
|
||||
private bool _clearingTileSelections;
|
||||
private bool _eraseTile;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -35,6 +36,37 @@ public sealed class TileSpawningUIController : UIController
|
||||
_placement.PlacementChanged += ClearTileSelection;
|
||||
}
|
||||
|
||||
private void StartTilePlacement(int tileType)
|
||||
{
|
||||
var newObjInfo = new PlacementInformation
|
||||
{
|
||||
PlacementOption = "AlignTileAny",
|
||||
TileType = tileType,
|
||||
Range = 400,
|
||||
IsTile = true
|
||||
};
|
||||
|
||||
_placement.BeginPlacing(newObjInfo);
|
||||
}
|
||||
|
||||
private void OnTileEraseToggled(ButtonToggledEventArgs args)
|
||||
{
|
||||
if (_window == null || _window.Disposed)
|
||||
return;
|
||||
|
||||
_placement.Clear();
|
||||
|
||||
if (args.Pressed)
|
||||
{
|
||||
_eraseTile = true;
|
||||
StartTilePlacement(0);
|
||||
}
|
||||
else
|
||||
_eraseTile = false;
|
||||
|
||||
args.Button.Pressed = args.Pressed;
|
||||
}
|
||||
|
||||
public void ToggleWindow()
|
||||
{
|
||||
EnsureWindow();
|
||||
@@ -60,6 +92,8 @@ public sealed class TileSpawningUIController : UIController
|
||||
_window.SearchBar.OnTextChanged += OnTileSearchChanged;
|
||||
_window.TileList.OnItemSelected += OnTileItemSelected;
|
||||
_window.TileList.OnItemDeselected += OnTileItemDeselected;
|
||||
_window.EraseButton.Pressed = _eraseTile;
|
||||
_window.EraseButton.OnToggled += OnTileEraseToggled;
|
||||
BuildTileList();
|
||||
}
|
||||
|
||||
@@ -76,6 +110,7 @@ public sealed class TileSpawningUIController : UIController
|
||||
_clearingTileSelections = true;
|
||||
_window.TileList.ClearSelected();
|
||||
_clearingTileSelections = false;
|
||||
_window.EraseButton.Pressed = false;
|
||||
}
|
||||
|
||||
private void OnTileClearPressed(ButtonEventArgs args)
|
||||
@@ -102,16 +137,7 @@ public sealed class TileSpawningUIController : UIController
|
||||
private void OnTileItemSelected(ItemList.ItemListSelectedEventArgs args)
|
||||
{
|
||||
var definition = _shownTiles[args.ItemIndex];
|
||||
|
||||
var newObjInfo = new PlacementInformation
|
||||
{
|
||||
PlacementOption = "AlignTileAny",
|
||||
TileType = definition.TileId,
|
||||
Range = 400,
|
||||
IsTile = true
|
||||
};
|
||||
|
||||
_placement.BeginPlacing(newObjInfo);
|
||||
StartTilePlacement(definition.TileId);
|
||||
}
|
||||
|
||||
private void OnTileItemDeselected(ItemList.ItemListDeselectedEventArgs args)
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
private bool _enableAllKeybinds;
|
||||
private ButtonGroup? _group;
|
||||
private bool _toggleMode;
|
||||
private bool _muteSounds;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the group this button belongs to.
|
||||
@@ -135,7 +136,8 @@ namespace Robust.Client.UserInterface.Controls
|
||||
if (Pressed != value)
|
||||
return;
|
||||
|
||||
UserInterfaceManager.ClickSound();
|
||||
if (!MuteSounds)
|
||||
UserInterfaceManager.ClickSound();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -199,6 +201,16 @@ namespace Robust.Client.UserInterface.Controls
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If <c>true</c>, this button will not emit sounds when the mouse is pressed or hovered over.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public bool MuteSounds
|
||||
{
|
||||
get => _muteSounds;
|
||||
set => _muteSounds = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fired when the button is pushed down by the mouse.
|
||||
/// </summary>
|
||||
@@ -298,7 +310,8 @@ namespace Robust.Client.UserInterface.Controls
|
||||
}
|
||||
else
|
||||
{
|
||||
UserInterfaceManager.ClickSound();
|
||||
if (!MuteSounds)
|
||||
UserInterfaceManager.ClickSound();
|
||||
}
|
||||
|
||||
OnPressed?.Invoke(buttonEventArgs);
|
||||
@@ -353,7 +366,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
{
|
||||
base.MouseEntered();
|
||||
|
||||
if (!Disabled)
|
||||
if (!Disabled && !MuteSounds)
|
||||
{
|
||||
UserInterfaceManager.HoverSound();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
@@ -56,7 +57,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
protected override Vector2 MeasureOverride(Vector2 availableSize)
|
||||
{
|
||||
// Account for separation.
|
||||
var separation = ActualSeparation * (ChildCount - 1);
|
||||
var separation = ActualSeparation * (Children.Where(c => c.Visible).Count() - 1);
|
||||
var desiredSize = Vector2.Zero;
|
||||
if (Vertical)
|
||||
{
|
||||
@@ -136,13 +137,14 @@ namespace Robust.Client.UserInterface.Controls
|
||||
protected override Vector2 ArrangeOverride(Vector2 finalSize)
|
||||
{
|
||||
var separation = ActualSeparation;
|
||||
var visibleChildCount = Children.Where(c => c.Visible).Count();
|
||||
|
||||
var stretchAvail = Vertical ? finalSize.Y : finalSize.X;
|
||||
stretchAvail -= separation * (ChildCount - 1);
|
||||
stretchAvail -= separation * (visibleChildCount - 1);
|
||||
stretchAvail = Math.Max(0, stretchAvail);
|
||||
|
||||
// Step one: figure out the sizes of all our children and whether they want to stretch.
|
||||
var sizeList = new List<(Control control, float size, bool stretch)>(ChildCount);
|
||||
var sizeList = new List<(Control control, float size, bool stretch)>(visibleChildCount);
|
||||
var totalStretchRatio = 0f;
|
||||
foreach (var child in Children)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
@@ -89,8 +86,6 @@ public sealed class ColorSelectorSliders : Control
|
||||
private OptionButton _typeSelector;
|
||||
private List<ColorSelectorType> _types = new();
|
||||
|
||||
private static ShaderInstance _shader = default!;
|
||||
|
||||
private ColorSelectorStyleBox _topStyle;
|
||||
private ColorSelectorStyleBox _middleStyle;
|
||||
private ColorSelectorStyleBox _bottomStyle;
|
||||
|
||||
@@ -302,7 +302,6 @@ namespace Robust.Client.UserInterface.Controls
|
||||
{
|
||||
if (!child.Visible)
|
||||
{
|
||||
index--;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,15 @@ namespace Robust.Client.UserInterface.Controls
|
||||
private TimeSpan? _lastClickTime;
|
||||
private Vector2? _lastClickPosition;
|
||||
|
||||
// Keep track of the frame on which we got focus, so we can implement SelectAllOnFocus properly.
|
||||
// Otherwise, there's no way to keep track of whether the KeyDown is the one that focused the text box,
|
||||
// to avoid text selection stomping on the behavior.
|
||||
// This isn't a great way to do it.
|
||||
// A better fix would be to annotate all input events with some unique sequence ID,
|
||||
// and expose the input event that focused the control in KeyboardFocusEntered.
|
||||
// But that sounds like a refactor I'm not doing today.
|
||||
private uint _focusedOnFrame;
|
||||
|
||||
private bool IsPlaceHolderVisible => !(HidePlaceHolderOnFocus && HasKeyboardFocus()) && string.IsNullOrEmpty(_text) && _placeHolder != null;
|
||||
|
||||
public event Action<LineEditEventArgs>? OnTextChanged;
|
||||
@@ -190,6 +199,11 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
public bool IgnoreNext { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, all the text in the LineEdit will be automatically selected whenever it is focused.
|
||||
/// </summary>
|
||||
public bool SelectAllOnFocus { get; set; }
|
||||
|
||||
private (int start, int length)? _imeData;
|
||||
|
||||
|
||||
@@ -709,7 +723,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
args.Handle();
|
||||
}
|
||||
else
|
||||
else if (!(SelectAllOnFocus && _focusedOnFrame == _timing.CurFrame))
|
||||
{
|
||||
_lastClickTime = _timing.RealTime;
|
||||
_lastClickPosition = args.PointerLocation.Position;
|
||||
@@ -868,6 +882,13 @@ namespace Robust.Client.UserInterface.Controls
|
||||
{
|
||||
_clyde.TextInputStart();
|
||||
}
|
||||
|
||||
_focusedOnFrame = _timing.CurFrame;
|
||||
if (SelectAllOnFocus)
|
||||
{
|
||||
CursorPosition = _text.Length;
|
||||
SelectionStart = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected internal override void KeyboardFocusExited()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Numerics;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -33,9 +32,9 @@ namespace Robust.Client.UserInterface.Controls
|
||||
public IClydeWindow? Owner { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the window is currently open.
|
||||
/// Whether the window is created and currently open.
|
||||
/// </summary>
|
||||
public bool IsOpen => ClydeWindow != null;
|
||||
public bool IsOpen => ClydeWindow?.IsVisible ?? false;
|
||||
|
||||
/// <summary>
|
||||
/// The title of the window.
|
||||
@@ -97,12 +96,13 @@ namespace Robust.Client.UserInterface.Controls
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show the window to the user.
|
||||
/// Create the window if not already created.
|
||||
/// This window is not visible by default, call <see cref="Show"/> to display it.
|
||||
/// </summary>
|
||||
public void Show()
|
||||
public IClydeWindow Create()
|
||||
{
|
||||
if (IsOpen)
|
||||
return;
|
||||
if (ClydeWindow != null)
|
||||
return ClydeWindow;
|
||||
|
||||
var parameters = new WindowCreateParameters();
|
||||
|
||||
@@ -127,6 +127,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
parameters.Styles = WindowStyles;
|
||||
parameters.Owner = Owner;
|
||||
parameters.StartupLocation = StartupLocation;
|
||||
parameters.Visible = false;
|
||||
|
||||
ClydeWindow = _clyde.CreateWindow(parameters);
|
||||
ClydeWindow.RequestClosed += OnWindowRequestClosed;
|
||||
@@ -136,6 +137,19 @@ namespace Robust.Client.UserInterface.Controls
|
||||
_root = UserInterfaceManager.CreateWindowRoot(ClydeWindow);
|
||||
_root.AddChild(this);
|
||||
|
||||
// Resize the window by our UIScale
|
||||
ClydeWindow.Size = new((int)(ClydeWindow.Size.X * UIScale), (int)(ClydeWindow.Size.Y * UIScale));
|
||||
return ClydeWindow;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show the window to the user, creating it if necessary
|
||||
/// </summary>
|
||||
public void Show()
|
||||
{
|
||||
ClydeWindow = Create();
|
||||
ClydeWindow.IsVisible = true;
|
||||
|
||||
Shown();
|
||||
}
|
||||
|
||||
@@ -179,7 +193,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
private void OnWindowResized(WindowResizedEventArgs obj)
|
||||
{
|
||||
SetSize = obj.NewSize;
|
||||
SetSize = obj.NewSize / UIScale;
|
||||
}
|
||||
|
||||
private void RealClosed()
|
||||
|
||||
@@ -127,11 +127,11 @@ namespace Robust.Client.UserInterface.Controls
|
||||
ClearButtons();
|
||||
foreach (var num in leftButtons)
|
||||
{
|
||||
AddLeftButton(num, num.ToString());
|
||||
AddLeftButton(num, num.ToString("+#;-#;0"));
|
||||
}
|
||||
foreach (var num in rightButtons)
|
||||
{
|
||||
AddRightButton(num, num.ToString());
|
||||
AddRightButton(num, num.ToString("+#;-#;0"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -268,12 +268,15 @@ namespace Robust.Client.UserInterface.Controls
|
||||
var first = GetChild(0);
|
||||
var second = GetChild(1);
|
||||
|
||||
firstMinSize ??= (Vertical ? first.DesiredSize.Y : first.DesiredSize.X);
|
||||
secondMinSize ??= (Vertical ? second.DesiredSize.Y : second.DesiredSize.X);
|
||||
var size = Vertical ? controlSize.Y : controlSize.X;
|
||||
if (first.IsMeasureValid && second.IsMeasureValid)
|
||||
{
|
||||
firstMinSize ??= (Vertical ? first.DesiredSize.Y : first.DesiredSize.X);
|
||||
secondMinSize ??= (Vertical ? second.DesiredSize.Y : second.DesiredSize.X);
|
||||
var size = Vertical ? controlSize.Y : controlSize.X;
|
||||
|
||||
_splitStart = MathHelper.Clamp(_splitStart, firstMinSize.Value,
|
||||
size - (secondMinSize.Value + _splitWidth));
|
||||
_splitStart = MathHelper.Clamp(_splitStart, firstMinSize.Value,
|
||||
size - (secondMinSize.Value + _splitWidth));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
var offset = SpriteOffset
|
||||
? Vector2.Zero
|
||||
: - (-_eyeRotation).RotateVec(sprite.Offset) * new Vector2(1, -1) * EyeManager.PixelsPerMeter;
|
||||
: - (-_eyeRotation).RotateVec(sprite.Offset * _scale) * new Vector2(1, -1) * EyeManager.PixelsPerMeter;
|
||||
|
||||
var position = PixelSize / 2 + offset * stretch * UIScale;
|
||||
var scale = Scale * UIScale * stretch;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared.Input;
|
||||
@@ -21,6 +22,8 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
private int _currentTab;
|
||||
private bool _tabsVisible = true;
|
||||
// The right-most coordinate of each tab header
|
||||
private List<float> _tabRight = new();
|
||||
|
||||
public int CurrentTab
|
||||
{
|
||||
@@ -157,11 +160,14 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
var headerOffset = 0f;
|
||||
|
||||
_tabRight.Clear();
|
||||
|
||||
// Then, draw the tabs.
|
||||
for (var i = 0; i < ChildCount; i++)
|
||||
{
|
||||
if (!GetTabVisible(i))
|
||||
{
|
||||
_tabRight.Add(headerOffset);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -214,6 +220,8 @@ namespace Robust.Client.UserInterface.Controls
|
||||
}
|
||||
|
||||
headerOffset += boxAdvance;
|
||||
// Remember the right-most point of this tab, for testing clicked areas
|
||||
_tabRight.Add(headerOffset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,46 +291,17 @@ namespace Robust.Client.UserInterface.Controls
|
||||
args.Handle();
|
||||
|
||||
var relX = args.RelativePixelPosition.X;
|
||||
|
||||
var font = _getFont();
|
||||
var boxActive = _getTabBoxActive();
|
||||
var boxInactive = _getTabBoxInactive();
|
||||
|
||||
var headerOffset = 0f;
|
||||
|
||||
float tabLeft = 0;
|
||||
for (var i = 0; i < ChildCount; i++)
|
||||
{
|
||||
if (!GetTabVisible(i))
|
||||
if (relX > tabLeft && relX <= _tabRight[i])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var title = GetActualTabTitle(i);
|
||||
|
||||
var titleLength = 0;
|
||||
// Get string length.
|
||||
foreach (var rune in title.EnumerateRunes())
|
||||
{
|
||||
if (!font.TryGetCharMetrics(rune, UIScale, out var metrics))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
titleLength += metrics.Advance;
|
||||
}
|
||||
|
||||
var active = _currentTab == i;
|
||||
var box = active ? boxActive : boxInactive;
|
||||
var boxAdvance = titleLength + (box?.MinimumSize.X ?? 0);
|
||||
|
||||
if (headerOffset < relX && headerOffset + boxAdvance > relX)
|
||||
{
|
||||
// Got em.
|
||||
CurrentTab = i;
|
||||
return;
|
||||
}
|
||||
|
||||
headerOffset += boxAdvance;
|
||||
// Next tab starts here
|
||||
tabLeft = _tabRight[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
</ScrollContainer>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Button Name="ReplaceButton" Access="Public" ToggleMode="True" Text="{Loc entity-spawn-window-replace-button-text}"/>
|
||||
<Button Name="EraseButton" Access="Public" ToggleMode="True" Text="{Loc entity-spawn-window-erase-button-text}"/>
|
||||
<Button Name="EraseButton" Access="Public" ToggleMode="True" Text="{Loc window-erase-button-text}"/>
|
||||
<OptionButton Name="OverrideMenu" Access="Public" HorizontalExpand="True" ToolTip="{Loc entity-spawn-window-override-menu-tooltip}" />
|
||||
</BoxContainer>
|
||||
<Label Name="RotationLabel" Access="Public"/>
|
||||
|
||||
@@ -131,11 +131,6 @@ internal sealed class TextEditRopeViz : OSWindow
|
||||
throw new ArgumentOutOfRangeException(nameof(node));
|
||||
}
|
||||
}
|
||||
|
||||
static UIBox2 Around(Vector2 vec, float size)
|
||||
{
|
||||
return new UIBox2(vec - new Vector2(size, size), vec + new Vector2(size, size));
|
||||
}
|
||||
}
|
||||
|
||||
private static Color[] CalcLeafColors()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<TileSpawnWindow
|
||||
xmlns="https://spacestation14.io"
|
||||
Title="Place Tiles"
|
||||
Title="{Loc tile-spawn-window-title}"
|
||||
SetSize="300 300"
|
||||
MinSize="300 200">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
@@ -9,5 +9,8 @@
|
||||
<Button Name="ClearButton" Access="Public" Text="Clear"/>
|
||||
</BoxContainer>
|
||||
<ItemList Name="TileList" Access="Public" VerticalExpand="True"/>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Button Name="EraseButton" Access="Public" ToggleMode="True" Text="{Loc window-erase-button-text}"/>
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
</TileSpawnWindow>
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace Robust.Client.UserInterface
|
||||
|
||||
public readonly void Draw(
|
||||
MarkupTagManager tagManager,
|
||||
DrawingHandleScreen handle,
|
||||
DrawingHandleBase handle,
|
||||
Font defaultFont,
|
||||
UIBox2 drawBox,
|
||||
float verticalOffset,
|
||||
|
||||
@@ -35,6 +35,7 @@ internal partial class UserInterfaceManager
|
||||
return;
|
||||
_controlFocused?.ControlFocusExited();
|
||||
_controlFocused = value;
|
||||
_needUpdateActiveCursor = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -28,10 +29,11 @@ internal sealed partial class UserInterfaceManager
|
||||
{
|
||||
MouseFilter = Control.MouseFilterMode.Ignore,
|
||||
HorizontalAlignment = Control.HAlignment.Stretch,
|
||||
VerticalAlignment = Control.VAlignment.Stretch,
|
||||
UIScaleSet = window.ContentScale.X
|
||||
VerticalAlignment = Control.VAlignment.Stretch
|
||||
};
|
||||
|
||||
newRoot.UIScaleSet = CalculateAutoScale(newRoot);
|
||||
|
||||
_roots.Add(newRoot);
|
||||
_windowsToRoot.Add(window.Id, newRoot);
|
||||
|
||||
|
||||
@@ -58,16 +58,16 @@ internal sealed class XamlHotReloadManager : IXamlHotReloadManager
|
||||
var watcher = new FileSystemWatcher(location)
|
||||
{
|
||||
IncludeSubdirectories = true,
|
||||
NotifyFilter = NotifyFilters.LastWrite,
|
||||
NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName,
|
||||
};
|
||||
|
||||
watcher.Changed += (_, args) =>
|
||||
void OnWatcherEvent(object sender, FileSystemEventArgs args)
|
||||
{
|
||||
switch (args.ChangeType)
|
||||
{
|
||||
case WatcherChangeTypes.Renamed:
|
||||
case WatcherChangeTypes.Deleted:
|
||||
return;
|
||||
case WatcherChangeTypes.Renamed:
|
||||
case WatcherChangeTypes.Created:
|
||||
case WatcherChangeTypes.Changed:
|
||||
case WatcherChangeTypes.All:
|
||||
@@ -98,7 +98,10 @@ internal sealed class XamlHotReloadManager : IXamlHotReloadManager
|
||||
|
||||
_xamlProxyManager.SetImplementation(resourceFileName, newText);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
watcher.Changed += OnWatcherEvent;
|
||||
watcher.Renamed += OnWatcherEvent;
|
||||
watcher.EnableRaisingEvents = true;
|
||||
return watcher;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Robust.Client.Utility
|
||||
{
|
||||
@@ -9,6 +8,12 @@ namespace Robust.Client.Utility
|
||||
{
|
||||
[Pure]
|
||||
public static string GetUserDataDir(IGameControllerInternal gameController)
|
||||
{
|
||||
return Path.Combine(GetRootUserDataDir(gameController), "data");
|
||||
}
|
||||
|
||||
[Pure]
|
||||
public static string GetRootUserDataDir(IGameControllerInternal gameController)
|
||||
{
|
||||
string appDataDir;
|
||||
|
||||
@@ -30,8 +35,7 @@ namespace Robust.Client.Utility
|
||||
appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
#endif
|
||||
|
||||
return Path.Combine(appDataDir, gameController.Options.UserDataDirectoryName, "data");
|
||||
return Path.Combine(appDataDir, gameController.Options.UserDataDirectoryName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Numerics;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.ViewVariables.Instances;
|
||||
@@ -36,7 +37,7 @@ namespace Robust.Client.ViewVariables.Traits
|
||||
|
||||
public override async void Refresh()
|
||||
{
|
||||
_memberList.DisposeAllChildren();
|
||||
List<Control> replacementControls = [];
|
||||
|
||||
if (Instance.Object != null)
|
||||
{
|
||||
@@ -51,7 +52,7 @@ namespace Robust.Client.ViewVariables.Traits
|
||||
|
||||
foreach (var control in group)
|
||||
{
|
||||
_memberList.AddChild(control);
|
||||
replacementControls.Add(control);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,10 +83,16 @@ namespace Robust.Client.ViewVariables.Traits
|
||||
selectorChain, o, r);
|
||||
};
|
||||
|
||||
_memberList.AddChild(propertyEdit);
|
||||
replacementControls.Add(propertyEdit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_memberList.DisposeAllChildren();
|
||||
foreach (var item in replacementControls)
|
||||
{
|
||||
_memberList.AddChild(item);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void CreateMemberGroupHeader(ref bool first, string groupName, Control container)
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Robust.Packaging.AssetProcessing.Passes;
|
||||
|
||||
/// <summary>
|
||||
/// Asset pass that drops all files that match a predicate. Files that do not match are ignored.
|
||||
/// </summary>
|
||||
public sealed class AssetPassFilterDrop(Func<AssetFile, bool> predicate) : AssetPass
|
||||
{
|
||||
public Func<AssetFile, bool> Predicate { get; } = predicate;
|
||||
|
||||
protected override AssetFileAcceptResult AcceptFile(AssetFile file)
|
||||
{
|
||||
// Just do nothing with the file so it gets discarded.
|
||||
if (Predicate(file))
|
||||
return AssetFileAcceptResult.Consumed;
|
||||
|
||||
return base.AcceptFile(file);
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ public static class Diagnostics
|
||||
public const string IdDataFieldNoVVReadWrite = "RA0029";
|
||||
public const string IdUseNonGenericVariant = "RA0030";
|
||||
public const string IdPreferOtherType = "RA0031";
|
||||
public const string IdDuplicateDependency = "RA0032";
|
||||
|
||||
public static SuppressionDescriptor MeansImplicitAssignment =>
|
||||
new SuppressionDescriptor("RADC1000", "CS0649", "Marked as implicitly assigned.");
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Robust.Server
|
||||
[Dependency] private readonly ITaskManager _taskManager = default!;
|
||||
[Dependency] private readonly IRuntimeLog _runtimeLog = default!;
|
||||
[Dependency] private readonly IModLoaderInternal _modLoader = default!;
|
||||
[Dependency] private readonly IWatchdogApi _watchdogApi = default!;
|
||||
[Dependency] private readonly IWatchdogApiInternal _watchdogApi = default!;
|
||||
[Dependency] private readonly HubManager _hubManager = default!;
|
||||
[Dependency] private readonly IScriptHost _scriptHost = default!;
|
||||
[Dependency] private readonly IMetricsManagerInternal _metricsManager = default!;
|
||||
@@ -223,10 +223,10 @@ namespace Robust.Server
|
||||
|
||||
if (!Path.IsPathRooted(fullPath))
|
||||
{
|
||||
logPath = PathHelpers.ExecutableRelativeFile(fullPath);
|
||||
fullPath = PathHelpers.ExecutableRelativeFile(fullPath);
|
||||
}
|
||||
|
||||
logHandler = new FileLogHandler(logPath);
|
||||
logHandler = new FileLogHandler(fullPath);
|
||||
}
|
||||
|
||||
_log.RootSawmill.Level = _config.GetCVar(CVars.LogLevel);
|
||||
@@ -566,7 +566,7 @@ namespace Robust.Server
|
||||
// Don't start the main loop. This only works if a reason is passed to Shutdown(...)
|
||||
if (_shutdownReason != null)
|
||||
{
|
||||
_logger.Fatal("Shutdown has been requested before the main loop has been started, complying.");
|
||||
_logger.Fatal("Shutdown has been requested before the main loop has been started, complying. Reason: {0}", _shutdownReason);
|
||||
}
|
||||
else _mainLoop.Run();
|
||||
|
||||
|
||||
@@ -162,7 +162,6 @@ namespace Robust.Server.Console
|
||||
{
|
||||
var message = new MsgConCmdReg();
|
||||
|
||||
var counter = 0;
|
||||
var toolshedCommands = _toolshed.DefaultEnvironment.AllCommands().ToArray();
|
||||
message.Commands = new List<MsgConCmdReg.Command>(AvailableCommands.Count + toolshedCommands.Length);
|
||||
var commands = new HashSet<string>();
|
||||
|
||||
@@ -174,7 +174,8 @@ namespace Robust.Server.Console
|
||||
while (Con.KeyAvailable)
|
||||
{
|
||||
ConsoleKeyInfo key = Con.ReadKey(true);
|
||||
Con.SetCursorPosition(0, Con.CursorTop);
|
||||
if (Con.WindowWidth > 0)
|
||||
Con.SetCursorPosition(0, Con.CursorTop);
|
||||
if (!Char.IsControl(key.KeyChar))
|
||||
{
|
||||
currentBuffer = currentBuffer.Insert(internalCursor++, key.KeyChar.ToString());
|
||||
@@ -277,6 +278,7 @@ namespace Robust.Server.Console
|
||||
|
||||
public void DrawCommandLine()
|
||||
{
|
||||
if (Con.WindowWidth <= 0) return;
|
||||
ClearCurrentLine();
|
||||
Con.SetCursorPosition(0, Con.CursorTop);
|
||||
Con.Write("> " + currentBuffer);
|
||||
|
||||
@@ -53,20 +53,21 @@ namespace Robust.Server.GameObjects
|
||||
var query = AllEntityQuery<MapGridComponent>();
|
||||
while (query.MoveNext(out var uid, out var grid))
|
||||
{
|
||||
if (!GridEmpty(grid)) continue;
|
||||
if (!GridEmpty((uid, grid)))
|
||||
continue;
|
||||
toDelete.Add(uid);
|
||||
}
|
||||
|
||||
foreach (var uid in toDelete)
|
||||
{
|
||||
MapManager.DeleteGrid(uid);
|
||||
EntityManager.DeleteEntity(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool GridEmpty(MapGridComponent grid)
|
||||
private bool GridEmpty(Entity<MapGridComponent> entity)
|
||||
{
|
||||
return !(grid.GetAllTiles().Any());
|
||||
return !(GetAllTiles(entity, entity).Any());
|
||||
}
|
||||
|
||||
private void HandleGridEmpty(EntityUid uid, MapGridComponent component, EmptyGridEvent args)
|
||||
@@ -74,7 +75,7 @@ namespace Robust.Server.GameObjects
|
||||
if (!_deleteEmptyGrids || TerminatingOrDeleted(uid) || HasComp<MapComponent>(uid))
|
||||
return;
|
||||
|
||||
MapManager.DeleteGrid(args.GridId);
|
||||
EntityManager.DeleteEntity(args.GridId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,9 +141,10 @@ internal sealed class PvsChunk
|
||||
{
|
||||
// TODO ARCH multi-component queries
|
||||
if (!meta.TryGetComponent(child, out var childMeta)
|
||||
|| !xform.TryGetComponent(child, out var childXform))
|
||||
|| !xform.TryGetComponent(child, out var childXform)
|
||||
|| childMeta.EntityLifeStage >= EntityLifeStage.Terminating)
|
||||
{
|
||||
DebugTools.Assert($"PVS chunk contains a deleted entity: {child}");
|
||||
DebugTools.Assert($"PVS chunk contains a delete or terminating entity: {child}");
|
||||
MarkDirty();
|
||||
return false;
|
||||
}
|
||||
@@ -188,9 +189,10 @@ internal sealed class PvsChunk
|
||||
{
|
||||
// TODO ARCH multi-component queries
|
||||
if (!meta.TryGetComponent(child, out var childMeta)
|
||||
|| !xform.TryGetComponent(child, out var childXform))
|
||||
|| !xform.TryGetComponent(child, out var childXform)
|
||||
|| childMeta.EntityLifeStage >= EntityLifeStage.Terminating)
|
||||
{
|
||||
DebugTools.Assert($"PVS chunk contains a deleted entity: {child}");
|
||||
DebugTools.Assert($"PVS chunk contains a delete or terminating entity: {child}");
|
||||
MarkDirty();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -184,10 +184,9 @@ internal sealed partial class PvsSystem
|
||||
return;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
var i = 0;
|
||||
if (session.AttachedEntity is { } local)
|
||||
{
|
||||
DebugTools.Assert(!session.ViewSubscriptions.Contains(local));
|
||||
Array.Resize(ref pvsSession.Viewers, session.ViewSubscriptions.Count + 1);
|
||||
pvsSession.Viewers[i++] = (local, Transform(local), _eyeQuery.CompOrNull(local));
|
||||
}
|
||||
@@ -198,7 +197,8 @@ internal sealed partial class PvsSystem
|
||||
|
||||
foreach (var ent in session.ViewSubscriptions)
|
||||
{
|
||||
pvsSession.Viewers[i++] = (ent, Transform(ent), _eyeQuery.CompOrNull(ent));
|
||||
if (ent != session.AttachedEntity)
|
||||
pvsSession.Viewers[i++] = (ent, Transform(ent), _eyeQuery.CompOrNull(ent));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,6 +232,7 @@ internal sealed partial class PvsSystem
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void AddEntityToChunk(EntityUid uid, MetaDataComponent meta, PvsChunkLocation location)
|
||||
{
|
||||
DebugTools.Assert(meta.EntityLifeStage < EntityLifeStage.Terminating);
|
||||
ref var chunk = ref CollectionsMarshal.GetValueRefOrAddDefault(_chunks, location, out var existing);
|
||||
if (!existing)
|
||||
{
|
||||
@@ -240,7 +241,7 @@ internal sealed partial class PvsSystem
|
||||
{
|
||||
chunk.Initialize(location, _metaQuery, _xformQuery);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception)
|
||||
{
|
||||
_chunks.Remove(location);
|
||||
throw;
|
||||
|
||||
@@ -129,7 +129,6 @@ internal sealed partial class PvsSystem : EntitySystem
|
||||
|
||||
SubscribeLocalEvent<MapChangedEvent>(OnMapChanged);
|
||||
SubscribeLocalEvent<GridRemovalEvent>(OnGridRemoved);
|
||||
SubscribeLocalEvent<EntityTerminatingEvent>(OnEntityTerminating);
|
||||
SubscribeLocalEvent<TransformComponent, TransformStartupEvent>(OnTransformStartup);
|
||||
|
||||
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
|
||||
@@ -137,6 +136,7 @@ internal sealed partial class PvsSystem : EntitySystem
|
||||
EntityManager.EntityAdded += OnEntityAdded;
|
||||
EntityManager.EntityDeleted += OnEntityDeleted;
|
||||
EntityManager.AfterEntityFlush += AfterEntityFlush;
|
||||
EntityManager.BeforeEntityTerminating += OnEntityTerminating;
|
||||
|
||||
Subs.CVar(_configManager, CVars.NetPVS, SetPvs, true);
|
||||
Subs.CVar(_configManager, CVars.NetMaxUpdateRange, OnViewsizeChanged, true);
|
||||
@@ -162,6 +162,7 @@ internal sealed partial class PvsSystem : EntitySystem
|
||||
EntityManager.EntityAdded -= OnEntityAdded;
|
||||
EntityManager.EntityDeleted -= OnEntityDeleted;
|
||||
EntityManager.AfterEntityFlush -= AfterEntityFlush;
|
||||
EntityManager.BeforeEntityTerminating -= OnEntityTerminating;
|
||||
|
||||
_parallelMgr.ParallelCountChanged -= ResetParallelism;
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ namespace Robust.Server.Physics
|
||||
foreach (var index in node.Indices)
|
||||
{
|
||||
var tilePos = offset + index;
|
||||
tileData.Add((tilePos, oldGrid.GetTileRef(tilePos).Tile));
|
||||
tileData.Add((tilePos, _maps.GetTileRef(oldGridUid, oldGrid, tilePos).Tile));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ namespace Robust.Server.Physics
|
||||
}
|
||||
|
||||
// Set tiles on old grid
|
||||
oldGrid.SetTiles(tileData);
|
||||
_maps.SetTiles(oldGridUid, oldGrid, tileData);
|
||||
GenerateSplitNodes(newGridUid, newGrid);
|
||||
SendNodeDebug(newGridUid);
|
||||
}
|
||||
@@ -388,7 +388,7 @@ namespace Robust.Server.Physics
|
||||
|
||||
private void GenerateSplitNodes(EntityUid gridUid, MapGridComponent grid)
|
||||
{
|
||||
foreach (var chunk in grid.GetMapChunks().Values)
|
||||
foreach (var chunk in _maps.GetMapChunks(gridUid, grid).Values)
|
||||
{
|
||||
var group = CreateNodes(gridUid, grid, chunk);
|
||||
_nodes[gridUid].Add(chunk.Indices, group);
|
||||
@@ -479,7 +479,7 @@ namespace Robust.Server.Physics
|
||||
if (index.X == 0)
|
||||
{
|
||||
// Check West
|
||||
if (grid.TryGetChunk(new Vector2i(chunk.Indices.X - 1, chunk.Indices.Y), out neighborChunk) &&
|
||||
if (_maps.TryGetChunk(gridEuid, grid, new Vector2i(chunk.Indices.X - 1, chunk.Indices.Y), out neighborChunk) &&
|
||||
TryGetNode(gridEuid, neighborChunk, new Vector2i(chunk.ChunkSize - 1, index.Y), out neighborNode))
|
||||
{
|
||||
chunkNode.Neighbors.Add(neighborNode);
|
||||
@@ -490,7 +490,7 @@ namespace Robust.Server.Physics
|
||||
if (index.Y == 0)
|
||||
{
|
||||
// Check South
|
||||
if (grid.TryGetChunk(new Vector2i(chunk.Indices.X, chunk.Indices.Y - 1), out neighborChunk) &&
|
||||
if (_maps.TryGetChunk(gridEuid, grid, new Vector2i(chunk.Indices.X, chunk.Indices.Y - 1), out neighborChunk) &&
|
||||
TryGetNode(gridEuid, neighborChunk, new Vector2i(index.X, chunk.ChunkSize - 1), out neighborNode))
|
||||
{
|
||||
chunkNode.Neighbors.Add(neighborNode);
|
||||
@@ -501,7 +501,7 @@ namespace Robust.Server.Physics
|
||||
if (index.X == chunk.ChunkSize - 1)
|
||||
{
|
||||
// Check East
|
||||
if (grid.TryGetChunk(new Vector2i(chunk.Indices.X + 1, chunk.Indices.Y), out neighborChunk) &&
|
||||
if (_maps.TryGetChunk(gridEuid, grid, new Vector2i(chunk.Indices.X + 1, chunk.Indices.Y), out neighborChunk) &&
|
||||
TryGetNode(gridEuid, neighborChunk, new Vector2i(0, index.Y), out neighborNode))
|
||||
{
|
||||
chunkNode.Neighbors.Add(neighborNode);
|
||||
@@ -512,7 +512,7 @@ namespace Robust.Server.Physics
|
||||
if (index.Y == chunk.ChunkSize - 1)
|
||||
{
|
||||
// Check North
|
||||
if (grid.TryGetChunk(new Vector2i(chunk.Indices.X, chunk.Indices.Y + 1), out neighborChunk) &&
|
||||
if (_maps.TryGetChunk(gridEuid, grid, new Vector2i(chunk.Indices.X, chunk.Indices.Y + 1), out neighborChunk) &&
|
||||
TryGetNode(gridEuid, neighborChunk, new Vector2i(index.X, 0), out neighborNode))
|
||||
{
|
||||
chunkNode.Neighbors.Add(neighborNode);
|
||||
|
||||
@@ -137,8 +137,7 @@ namespace Robust.Server.Player
|
||||
{
|
||||
UserId = client.UserId,
|
||||
Name = client.Name,
|
||||
Status = client.Status,
|
||||
Ping = client.Channel!.Ping
|
||||
Status = client.Status
|
||||
};
|
||||
list.Add(info);
|
||||
}
|
||||
|
||||
@@ -126,13 +126,29 @@ namespace Robust.Server
|
||||
AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
|
||||
{
|
||||
var message = ((Exception) args.ExceptionObject).ToString();
|
||||
uh.Log(args.IsTerminating ? LogLevel.Fatal : LogLevel.Error, message);
|
||||
try
|
||||
{
|
||||
uh.Log(args.IsTerminating ? LogLevel.Fatal : LogLevel.Error, message);
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
// Avoid eating the exception if it's during shutdown and the sawmill is already gone.
|
||||
System.Console.WriteLine($"UnhandledException but sawmill is disposed! {message}");
|
||||
}
|
||||
};
|
||||
|
||||
var uo = mgr.GetSawmill("unobserved");
|
||||
TaskScheduler.UnobservedTaskException += (sender, args) =>
|
||||
{
|
||||
uo.Error(args.Exception!.ToString());
|
||||
try
|
||||
{
|
||||
uo.Error(args.Exception!.ToString());
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
// Avoid eating the exception if it's during shutdown and the sawmill is already gone.
|
||||
System.Console.WriteLine($"UnobservedTaskException but sawmill is disposed! {args.Exception}");
|
||||
}
|
||||
#if EXCEPTION_TOLERANCE
|
||||
args.SetObserved(); // don't crash
|
||||
#endif
|
||||
|
||||
@@ -79,6 +79,7 @@ namespace Robust.Server
|
||||
deps.Register<IViewVariablesManager, ServerViewVariablesManager>();
|
||||
deps.Register<IServerViewVariablesInternal, ServerViewVariablesManager>();
|
||||
deps.Register<IWatchdogApi, WatchdogApi>();
|
||||
deps.Register<IWatchdogApiInternal, WatchdogApi>();
|
||||
deps.Register<IScriptHost, ScriptHost>();
|
||||
deps.Register<IMetricsManager, MetricsManager>();
|
||||
deps.Register<IMetricsManagerInternal, MetricsManager>();
|
||||
@@ -97,6 +98,7 @@ namespace Robust.Server
|
||||
deps.Register<NetworkResourceManager>();
|
||||
deps.Register<IHttpClientHolder, HttpClientHolder>();
|
||||
deps.Register<UploadedContentManager>();
|
||||
deps.Register<IHWId, DummyHWId>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,92 @@ using System;
|
||||
|
||||
namespace Robust.Server.ServerStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// API for interacting with <c>SS14.Watchdog</c>.
|
||||
/// </summary>
|
||||
public interface IWatchdogApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Raised when the game server should restart for an update.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This only indicates that the game server should restart as soon as possible without disruption,
|
||||
/// e.g. at the end of a round. It should not shut down immediately unless possible.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This the same event as <see cref="RestartRequested"/>, but without additional data available such as reason.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
event Action UpdateReceived;
|
||||
|
||||
/// <summary>
|
||||
/// Raised when the watchdog has indicated that the server should restart as soon as possible.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This only indicates that the game server should restart as soon as possible without disruption,
|
||||
/// e.g. at the end of a round. It should not shut down immediately unless possible.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This the same event as <see cref="UpdateReceived"/>, but with additional data.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
event Action<RestartRequestedData> RestartRequested;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Engine-internal API for <see cref="IWatchdogApi"/>.
|
||||
/// </summary>
|
||||
internal interface IWatchdogApiInternal : IWatchdogApi
|
||||
{
|
||||
void Heartbeat();
|
||||
|
||||
void Initialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event data used by <see cref="IWatchdogApi.RestartRequested"/>.
|
||||
/// </summary>
|
||||
public sealed class RestartRequestedData
|
||||
{
|
||||
internal static readonly RestartRequestedData DefaultData = new(RestartRequestedReason.UpdateAvailable, null);
|
||||
|
||||
/// <summary>
|
||||
/// Primary reason code for why the server should be restarted.
|
||||
/// </summary>
|
||||
public RestartRequestedReason Reason { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A message provided with additional information about the restart reason. Not always provided.
|
||||
/// </summary>
|
||||
public string? AdditionalMessage { get; }
|
||||
|
||||
internal RestartRequestedData(RestartRequestedReason reason, string? additionalMessage)
|
||||
{
|
||||
Reason = reason;
|
||||
AdditionalMessage = additionalMessage;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Primary reason codes for why the server should restart in <see cref="RestartRequestedData"/>.
|
||||
/// </summary>
|
||||
public enum RestartRequestedReason : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Restart reason does not fall in an existing category.
|
||||
/// </summary>
|
||||
Other = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The server should restart because an update is available.
|
||||
/// </summary>
|
||||
UpdateAvailable,
|
||||
|
||||
/// <summary>
|
||||
/// The server should restart for maintenance.
|
||||
/// </summary>
|
||||
Maintenance,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace Robust.Server.ServerStatus;
|
||||
|
||||
internal sealed partial class StatusHost
|
||||
{
|
||||
private (string binFolder, string[] assemblies)? _aczInfo;
|
||||
private IMagicAczProvider? _magicAczProvider;
|
||||
private IFullHybridAczProvider? _fullHybridAczProvider;
|
||||
|
||||
@@ -158,8 +157,7 @@ internal sealed partial class StatusHost
|
||||
{
|
||||
_aczSawmill.Verbose("Using default magic ACZ provider");
|
||||
// Default provider
|
||||
var (binFolderPath, assemblyNames) =
|
||||
_aczInfo ?? ("Content.Client", new[] { "Content.Client", "Content.Shared" });
|
||||
var (binFolderPath, assemblyNames) = ("Content.Client", new[] { "Content.Client", "Content.Shared" });
|
||||
|
||||
var info = new DefaultMagicAczInfo(binFolderPath, assemblyNames);
|
||||
provider = new DefaultMagicAczProvider(info, _deps);
|
||||
|
||||
@@ -103,6 +103,22 @@ namespace Robust.Server.ServerStatus
|
||||
["desc"] = _serverDescCache,
|
||||
};
|
||||
|
||||
var privacyPolicyLink = _cfg.GetCVar(CVars.StatusPrivacyPolicyLink);
|
||||
var privacyPolicyIdentifier = _cfg.GetCVar(CVars.StatusPrivacyPolicyIdentifier);
|
||||
var privacyPolicyVersion = _cfg.GetCVar(CVars.StatusPrivacyPolicyVersion);
|
||||
|
||||
if (!string.IsNullOrEmpty(privacyPolicyLink)
|
||||
&& !string.IsNullOrEmpty(privacyPolicyIdentifier)
|
||||
&& !string.IsNullOrEmpty(privacyPolicyVersion))
|
||||
{
|
||||
jObject["privacy_policy"] = new JsonObject
|
||||
{
|
||||
["identifier"] = privacyPolicyIdentifier,
|
||||
["version"] = privacyPolicyVersion,
|
||||
["link"] = privacyPolicyLink,
|
||||
};
|
||||
}
|
||||
|
||||
OnInfoRequest?.Invoke(jObject);
|
||||
|
||||
await context.RespondJsonAsync(jObject);
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Mime;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
@@ -15,11 +16,9 @@ using Robust.Shared.Network;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Robust.Server.ServerStatus
|
||||
{
|
||||
public sealed class WatchdogApi : IWatchdogApi, IPostInjectInit
|
||||
internal sealed class WatchdogApi : IWatchdogApiInternal, IPostInjectInit
|
||||
{
|
||||
[Dependency] private readonly IStatusHost _statusHost = default!;
|
||||
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||
@@ -42,7 +41,7 @@ namespace Robust.Server.ServerStatus
|
||||
HttpClientUserAgent.AddUserAgent(_httpClient);
|
||||
}
|
||||
|
||||
public void PostInject()
|
||||
void IPostInjectInit.PostInject()
|
||||
{
|
||||
_sawmill = Logger.GetSawmill("watchdogApi");
|
||||
|
||||
@@ -52,7 +51,7 @@ namespace Robust.Server.ServerStatus
|
||||
|
||||
private async Task<bool> UpdateHandler(IStatusHandlerContext context)
|
||||
{
|
||||
if (context.RequestMethod != HttpMethod.Post || context.Url!.AbsolutePath != "/update")
|
||||
if (context.RequestMethod != HttpMethod.Post || context.Url.AbsolutePath != "/update")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -73,7 +72,46 @@ namespace Robust.Server.ServerStatus
|
||||
return true;
|
||||
}
|
||||
|
||||
_taskManager.RunOnMainThread(() => UpdateReceived?.Invoke());
|
||||
RestartRequestParameters? parameters = null;
|
||||
if (context.RequestHeaders.TryGetValue("Content-Type", out var contentType)
|
||||
&& contentType == MediaTypeNames.Application.Json)
|
||||
{
|
||||
try
|
||||
{
|
||||
parameters = await context.RequestBodyJsonAsync<RestartRequestParameters>();
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
// parameters null so it'll catch the block down below.
|
||||
}
|
||||
|
||||
if (parameters == null)
|
||||
{
|
||||
await context.RespondErrorAsync(HttpStatusCode.BadRequest);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
RestartRequestedData restartData;
|
||||
if (parameters == null)
|
||||
{
|
||||
restartData = RestartRequestedData.DefaultData;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Allow parsing to fail for forwards compatibility.
|
||||
var reasonCode = Enum.TryParse<RestartRequestedReason>(parameters.Reason, out var code)
|
||||
? code
|
||||
: RestartRequestedReason.Other;
|
||||
|
||||
restartData = new RestartRequestedData(reasonCode, parameters.Message);
|
||||
}
|
||||
|
||||
_taskManager.RunOnMainThread(() =>
|
||||
{
|
||||
RestartRequested?.Invoke(restartData);
|
||||
UpdateReceived?.Invoke();
|
||||
});
|
||||
|
||||
await context.RespondAsync("Success", HttpStatusCode.OK);
|
||||
|
||||
@@ -86,7 +124,7 @@ namespace Robust.Server.ServerStatus
|
||||
/// </remarks>
|
||||
private async Task<bool> ShutdownHandler(IStatusHandlerContext context)
|
||||
{
|
||||
if (context.RequestMethod != HttpMethod.Post || context.Url!.AbsolutePath != "/shutdown")
|
||||
if (context.RequestMethod != HttpMethod.Post || context.Url.AbsolutePath != "/shutdown")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -106,7 +144,8 @@ namespace Robust.Server.ServerStatus
|
||||
if (auth != _watchdogToken)
|
||||
{
|
||||
_sawmill.Verbose(
|
||||
"received POST /shutdown with invalid authentication token. Ignoring {0}, {1}", auth,
|
||||
"received POST /shutdown with invalid authentication token. Ignoring {0}, {1}",
|
||||
auth,
|
||||
_watchdogToken);
|
||||
await context.RespondErrorAsync(HttpStatusCode.Unauthorized);
|
||||
return true;
|
||||
@@ -137,6 +176,7 @@ namespace Robust.Server.ServerStatus
|
||||
}
|
||||
|
||||
public event Action? UpdateReceived;
|
||||
public event Action<RestartRequestedData>? RestartRequested;
|
||||
|
||||
public async void Heartbeat()
|
||||
{
|
||||
@@ -204,5 +244,12 @@ namespace Robust.Server.ServerStatus
|
||||
// ReSharper disable once RedundantDefaultMemberInitializer
|
||||
public string Reason { get; set; } = default!;
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
private sealed class RestartRequestParameters
|
||||
{
|
||||
public string Reason { get; set; } = nameof(RestartRequestedReason.Other);
|
||||
public string? Message { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -745,6 +745,21 @@ namespace Robust.Shared.Maths
|
||||
return remainder == T.Zero ? value : (value | mask) + T.One;
|
||||
}
|
||||
|
||||
public static bool IsValid(this float value)
|
||||
{
|
||||
if (float.IsNaN(value))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (float.IsInfinity(value))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion Public Members
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public static class Matrix3Helpers
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Angle Rotation(this Matrix3x2 t)
|
||||
{
|
||||
return new Vector2(t.M11, t.M12).ToAngle();
|
||||
return new Angle(Math.Atan2(t.M12, t.M11));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Robust.Shared.Maths;
|
||||
|
||||
@@ -14,6 +15,34 @@ public static class Vector2Helpers
|
||||
/// </summary>
|
||||
public static readonly Vector2 Half = new(0.5f, 0.5f);
|
||||
|
||||
public static bool IsValid(this Vector2 v)
|
||||
{
|
||||
if (float.IsNaN(v.X) || float.IsNaN(v.Y))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (float.IsInfinity(v.X) || float.IsInfinity(v.Y))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Vector2 GetLengthAndNormalize(this Vector2 v, ref float length)
|
||||
{
|
||||
length = v.Length();
|
||||
if (length < float.Epsilon)
|
||||
{
|
||||
return Vector2.Zero;
|
||||
}
|
||||
|
||||
float invLength = 1.0f / length;
|
||||
var n = new Vector2(invLength * v.X, invLength * v.Y);
|
||||
return n;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector2 InterpolateCubic(Vector2 preA, Vector2 a, Vector2 b, Vector2 postB, float t)
|
||||
{
|
||||
@@ -255,6 +284,12 @@ public static class Vector2Helpers
|
||||
return new(-s * a.Y, s * a.X);
|
||||
}
|
||||
|
||||
[Pure]
|
||||
public static Vector2 RightPerp(this Vector2 v)
|
||||
{
|
||||
return new Vector2(v.Y, -v.X);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Perform the cross product on a scalar and a vector. In 2D this produces
|
||||
/// a vector.
|
||||
|
||||
@@ -87,33 +87,33 @@ namespace Robust.Shared.Scripting
|
||||
|
||||
public object? prop(object target, string name)
|
||||
{
|
||||
return target.GetType().GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic)
|
||||
!.GetValue(target);
|
||||
var prop = (PropertyInfo?) ReflectionGetInstanceMember(target.GetType(), MemberTypes.Property, name);
|
||||
return prop!.GetValue(target);
|
||||
}
|
||||
|
||||
public void setprop(object target, string name, object? value)
|
||||
{
|
||||
target.GetType().GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
|
||||
!.SetValue(target, value);
|
||||
var prop = (PropertyInfo?) ReflectionGetInstanceMember(target.GetType(), MemberTypes.Property, name);
|
||||
prop!.SetValue(target, value);
|
||||
}
|
||||
|
||||
public object? fld(object target, string name)
|
||||
{
|
||||
return target.GetType().GetField(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
|
||||
!.GetValue(target);
|
||||
var fld = (FieldInfo?) ReflectionGetInstanceMember(target.GetType(), MemberTypes.Field, name);
|
||||
return fld!.GetValue(target);
|
||||
}
|
||||
|
||||
public void setfld(object target, string name, object? value)
|
||||
{
|
||||
target.GetType().GetField(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
|
||||
!.SetValue(target, value);
|
||||
var fld = (FieldInfo?) ReflectionGetInstanceMember(target.GetType(), MemberTypes.Field, name);
|
||||
fld!.SetValue(target, value);
|
||||
}
|
||||
|
||||
public object? call(object target, string name, params object[] args)
|
||||
{
|
||||
var t = target.GetType();
|
||||
// TODO: overloads
|
||||
var m = t.GetMethod(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||
var m = (MethodInfo?) ReflectionGetInstanceMember(t, MemberTypes.Method, name);
|
||||
return m!.Invoke(target, args);
|
||||
}
|
||||
|
||||
@@ -287,5 +287,21 @@ namespace Robust.Shared.Scripting
|
||||
}
|
||||
|
||||
public Dictionary<string, object?> Variables { get; } = new();
|
||||
|
||||
private static MemberInfo? ReflectionGetInstanceMember(Type type, MemberTypes memberType, string name)
|
||||
{
|
||||
for (var curType = type; curType != null; curType = curType.BaseType)
|
||||
{
|
||||
var member = curType.GetMember(
|
||||
name,
|
||||
memberType,
|
||||
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
if (member.Length > 0)
|
||||
return member[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Loader;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Lidgren.Network;
|
||||
using Microsoft.CodeAnalysis;
|
||||
@@ -14,14 +15,13 @@ using Microsoft.CodeAnalysis.CSharp.Scripting;
|
||||
using Microsoft.CodeAnalysis.CSharp.Scripting.Hosting;
|
||||
using Microsoft.CodeAnalysis.Scripting;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Reflection;
|
||||
using Robust.Shared.Utility;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Robust.Shared.Scripting
|
||||
{
|
||||
internal static class ScriptInstanceShared
|
||||
internal static partial class ScriptInstanceShared
|
||||
{
|
||||
public static CSharpParseOptions ParseOptions { get; } =
|
||||
new(kind: SourceCodeKind.Script, languageVersion: LanguageVersion.Latest);
|
||||
@@ -186,11 +186,12 @@ namespace Robust.Shared.Scripting
|
||||
var assemblies = ScriptInstanceShared.GetAutoImportAssemblies(refl).ToArray();
|
||||
foreach (var m in missing)
|
||||
{
|
||||
var mName = ConvertMissingTypeName(m);
|
||||
foreach (var assembly in assemblies)
|
||||
{
|
||||
foreach (var type in assembly.DefinedTypes)
|
||||
{
|
||||
if (type.IsPublic && type.Name == m)
|
||||
if (type.IsPublic && type.Name == mName)
|
||||
{
|
||||
found.Add(type.Namespace!);
|
||||
goto nextMissing;
|
||||
@@ -225,5 +226,22 @@ namespace Robust.Shared.Scripting
|
||||
return "<CSharpObjectFormatter.FormatObject threw>";
|
||||
}
|
||||
}
|
||||
|
||||
private static string ConvertMissingTypeName(string name)
|
||||
{
|
||||
var match = TypeMissingParserRegex().Match(name);
|
||||
var typeName = match.Groups[1].Value;
|
||||
if (match.Groups[2].Success)
|
||||
{
|
||||
// We have generics
|
||||
var genericCount = match.Groups[2].Length + 1;
|
||||
return $"{typeName}`{genericCount}";
|
||||
}
|
||||
|
||||
return match.Groups[1].Value;
|
||||
}
|
||||
|
||||
[GeneratedRegex("^(.+?)(?:<(,*)>)?$")]
|
||||
private static partial Regex TypeMissingParserRegex();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,6 +394,18 @@ namespace Robust.Shared
|
||||
public static readonly CVarDef<int> NetEncryptionThreadChannelSize =
|
||||
CVarDef.Create("net.encryption_thread_channel_size", 16);
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server should request HWID system for client identification.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Note that modern HWIDs are only available if the connection is authenticated.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public static readonly CVarDef<bool> NetHWId =
|
||||
CVarDef.Create("net.hwid", true, CVar.SERVERONLY);
|
||||
|
||||
|
||||
/**
|
||||
* SUS
|
||||
*/
|
||||
@@ -616,6 +628,43 @@ namespace Robust.Shared
|
||||
public static readonly CVarDef<string> StatusConnectAddress =
|
||||
CVarDef.Create("status.connectaddress", "", CVar.ARCHIVE | CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// HTTP(S) link to a privacy policy that the user must accept to connect to the server.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This must be set along with <see cref="StatusPrivacyPolicyIdentifier"/> and
|
||||
/// <see cref="StatusPrivacyPolicyVersion"/> for the user to be prompted about a privacy policy.
|
||||
/// </remarks>
|
||||
public static readonly CVarDef<string> StatusPrivacyPolicyLink =
|
||||
CVarDef.Create("status.privacy_policy_link", "https://example.com/privacy", CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// An identifier for privacy policy specified by <see cref="StatusPrivacyPolicyLink"/>.
|
||||
/// This must be globally unique.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This value must be globally unique per server community. Servers that want to enforce a
|
||||
/// privacy policy should set this to a value that is unique to their server and, preferably, recognizable.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This value is stored by the launcher to keep track of what privacy policies a player has accepted.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public static readonly CVarDef<string> StatusPrivacyPolicyIdentifier =
|
||||
CVarDef.Create("status.privacy_policy_identifier", "", CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// A "version" for the privacy policy specified by <see cref="StatusPrivacyPolicyLink"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This parameter is stored by the launcher and should be modified whenever your server's privacy policy changes.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public static readonly CVarDef<string> StatusPrivacyPolicyVersion =
|
||||
CVarDef.Create("status.privacy_policy_version", "", CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/*
|
||||
* BUILD
|
||||
*/
|
||||
@@ -671,6 +720,13 @@ namespace Robust.Shared
|
||||
public static readonly CVarDef<string> BuildManifestHash =
|
||||
CVarDef.Create("build.manifest_hash", "");
|
||||
|
||||
/// <summary>
|
||||
/// Allows you to disable the display of all entities in the spawn menu that are not labeled with the ShowSpawnMenu category.
|
||||
/// This is useful for forks that just want to disable the standard upstream content
|
||||
/// </summary>
|
||||
public static readonly CVarDef<string> EntitiesCategoryFilter =
|
||||
CVarDef.Create("build.entities_category_filter", "");
|
||||
|
||||
/*
|
||||
* WATCHDOG
|
||||
*/
|
||||
@@ -1086,6 +1142,14 @@ namespace Robust.Shared
|
||||
public static readonly CVarDef<bool> DisplayThreadWindowBlit =
|
||||
CVarDef.Create("display.thread_window_blit", true, CVar.CLIENTONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Diagnostic flag for testing. When using a separate thread for multi-window blitting,
|
||||
/// should the worker be unblocked before the SwapBuffers(). Setting to true may improve
|
||||
/// performance but may cause crashes or rendering errors.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> DisplayThreadUnlockBeforeSwap =
|
||||
CVarDef.Create("display.thread_unlock_before_swap", false, CVar.CLIENTONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Buffer size of input command channel from windowing thread to main game thread.
|
||||
/// </summary>
|
||||
|
||||
@@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -589,6 +590,12 @@ public struct ValueList<T> : IEnumerable<T>
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddRange(Span<T> span)
|
||||
{
|
||||
AddRange((ReadOnlySpan<T>) span);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddRange(ReadOnlySpan<T> span)
|
||||
{
|
||||
var spanCount = span.Length;
|
||||
EnsureCapacity(Count + spanCount);
|
||||
@@ -618,4 +625,72 @@ public struct ValueList<T> : IEnumerable<T>
|
||||
Add(result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Push a value onto the end of this list. This is equivalent to <see cref="Add"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method is added to provide completeness with other stack-like functions.
|
||||
/// </remarks>
|
||||
/// <param name="item">The item to add to the list.</param>
|
||||
public void Push(T item)
|
||||
{
|
||||
Add(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove and return the value at the end of the list.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the list is empty.</exception>
|
||||
public T Pop()
|
||||
{
|
||||
if (!TryPop(out var value))
|
||||
throw new InvalidOperationException("List is empty");
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the value at the end of the list, but do not remove it.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the list is empty.</exception>
|
||||
public T Peek()
|
||||
{
|
||||
if (!TryPeek(out var value))
|
||||
throw new InvalidOperationException("List is empty");
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove and return the value at the end of the list, only if the list is not empty.
|
||||
/// </summary>
|
||||
/// <returns>True if the list was not empty and an item was removed.</returns>
|
||||
public bool TryPop([MaybeNullWhen(false)] out T value)
|
||||
{
|
||||
if (Count == 0)
|
||||
{
|
||||
value = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
value = _items![--Count];
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove and return the value at the end of the list, only if the list is not empty.
|
||||
/// </summary>
|
||||
/// <returns>True if the list was not empty and an item was removed.</returns>
|
||||
public bool TryPeek([MaybeNullWhen(false)] out T value)
|
||||
{
|
||||
if (Count == 0)
|
||||
{
|
||||
value = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
value = _items![Count];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,13 @@ namespace Robust.Shared.Console
|
||||
bool IsServer { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The remote peer that owns this shell, or the local player if this is a client-side local shell (<see cref="IsLocal" /> is true and <see cref="IsClient"/> is true).
|
||||
/// The remote peer that owns this shell, or the local player if this is a local shell.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This parameter is null for commands executed directly from the server console, as that has no player.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
ICommonSession? Player { get; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -367,7 +367,7 @@ namespace Robust.Shared.Containers
|
||||
if (!xform.ParentUid.Valid)
|
||||
return false;
|
||||
|
||||
if (entityQuery.Resolve(xform.ParentUid, ref foundComponent, false))
|
||||
if (entityQuery.TryComp(xform.ParentUid, out foundComponent))
|
||||
return true;
|
||||
|
||||
return TryFindComponentOnEntityContainerOrParent(xform.ParentUid, entityQuery, ref foundComponent);
|
||||
|
||||
@@ -39,7 +39,7 @@ internal sealed partial class AssemblyTypeChecker
|
||||
{
|
||||
if (instruction.TryGetEntityHandle(out var handle))
|
||||
{
|
||||
if (refs.Contains(handle))
|
||||
if (refs.Overlaps(ExpandHandle(reader, handle)))
|
||||
{
|
||||
var type = GetTypeFromDefinition(reader, methodDef.GetDeclaringType());
|
||||
_sawmill.Error(
|
||||
@@ -56,6 +56,12 @@ internal sealed partial class AssemblyTypeChecker
|
||||
{
|
||||
switch (handle.Kind)
|
||||
{
|
||||
case HandleKind.MethodSpecification:
|
||||
var methodSpec = reader.GetMethodSpecification((MethodSpecificationHandle)handle);
|
||||
var methodProvider = new TypeProvider();
|
||||
var spec = methodSpec.DecodeSignature(methodProvider, 0);
|
||||
return $"{DisplayHandle(reader, methodSpec.Method)}<{string.Join(", ", spec.Select(t => t.ToString()))}>";
|
||||
|
||||
case HandleKind.MemberReference:
|
||||
var memberRef = reader.GetMemberReference((MemberReferenceHandle)handle);
|
||||
var name = reader.GetString(memberRef.Name);
|
||||
@@ -92,6 +98,17 @@ internal sealed partial class AssemblyTypeChecker
|
||||
handles.UnionWith(toAdd);
|
||||
}
|
||||
|
||||
private static IEnumerable<EntityHandle> ExpandHandle(MetadataReader reader, EntityHandle handle)
|
||||
{
|
||||
// Annoying, S.R.M gives no way to iterate over the MethodSpec table.
|
||||
// This means the only way to correlate MethodSpec references is to do it for each handle.
|
||||
|
||||
yield return handle;
|
||||
|
||||
if (handle.Kind == HandleKind.MethodSpecification)
|
||||
yield return reader.GetMethodSpecification((MethodSpecificationHandle)handle).Method;
|
||||
}
|
||||
|
||||
private readonly struct ILInstruction
|
||||
{
|
||||
public readonly ILOpCode OpCode;
|
||||
|
||||
@@ -480,6 +480,7 @@ Types:
|
||||
NotNullAttribute: { All: True }
|
||||
NotNullIfNotNullAttribute: { All: True }
|
||||
NotNullWhenAttribute: { All: True }
|
||||
SetsRequiredMembersAttribute: { All : True}
|
||||
SuppressMessageAttribute: { All: True }
|
||||
System.Diagnostics:
|
||||
DebuggableAttribute: { All: True }
|
||||
@@ -588,7 +589,6 @@ Types:
|
||||
Vector2: { All: True }
|
||||
Vector3: { All: True }
|
||||
Vector4: { All: True }
|
||||
Matrix3x2: { All: True }
|
||||
System.Reflection:
|
||||
Assembly:
|
||||
Methods:
|
||||
@@ -653,8 +653,11 @@ Types:
|
||||
NullableContextAttribute: { All: True }
|
||||
PreserveBaseOverridesAttribute: { All: True }
|
||||
RefSafetyRulesAttribute: { All: True }
|
||||
RequiredMemberAttribute: { All: True }
|
||||
RequiresLocationAttribute: { All: True }
|
||||
RuntimeCompatibilityAttribute: { All: True }
|
||||
RuntimeHelpers: { All: True }
|
||||
SwitchExpressionException: { All: True }
|
||||
TaskAwaiter: { All: True }
|
||||
TaskAwaiter`1: { All: True }
|
||||
TupleElementNamesAttribute: { All: True }
|
||||
@@ -720,11 +723,11 @@ Types:
|
||||
- "System.Text.RegularExpressions.Match Match(string, string)"
|
||||
- "System.Text.RegularExpressions.Match Match(string, string, System.Text.RegularExpressions.RegexOptions)"
|
||||
- "System.Text.RegularExpressions.Match Match(string, string, System.Text.RegularExpressions.RegexOptions, System.TimeSpan)"
|
||||
- "System.Text.RegularExpressions.Match[] Matches(string)"
|
||||
- "System.Text.RegularExpressions.Match[] Matches(string, int)"
|
||||
- "System.Text.RegularExpressions.Match[] Matches(string, string)"
|
||||
- "System.Text.RegularExpressions.Match[] Matches(string, string, System.Text.RegularExpressions.RegexOptions)"
|
||||
- "System.Text.RegularExpressions.Match[] Matches(string, string, System.Text.RegularExpressions.RegexOptions, System.TimeSpan)"
|
||||
- "System.Text.RegularExpressions.MatchCollection Matches(string)"
|
||||
- "System.Text.RegularExpressions.MatchCollection Matches(string, int)"
|
||||
- "System.Text.RegularExpressions.MatchCollection Matches(string, string)"
|
||||
- "System.Text.RegularExpressions.MatchCollection Matches(string, string, System.Text.RegularExpressions.RegexOptions)"
|
||||
- "System.Text.RegularExpressions.MatchCollection Matches(string, string, System.Text.RegularExpressions.RegexOptions, System.TimeSpan)"
|
||||
- "System.Text.RegularExpressions.RegexOptions get_Options()"
|
||||
- "System.TimeSpan get_MatchTimeout()"
|
||||
- "void .ctor()"
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Robust.Shared.GameObjects
|
||||
public abstract class BoundUserInterface : IDisposable
|
||||
{
|
||||
[Dependency] protected readonly IEntityManager EntMan = default!;
|
||||
[Dependency] private readonly ISharedPlayerManager _playerManager = default!;
|
||||
[Dependency] protected readonly ISharedPlayerManager PlayerManager = default!;
|
||||
protected readonly SharedUserInterfaceSystem UiSystem;
|
||||
|
||||
public readonly Enum UiKey;
|
||||
@@ -59,6 +59,27 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calls <see cref="UpdateState"/> if the supplied state exists and calls <see cref="Update"/>
|
||||
/// </summary>
|
||||
public void Update<T>() where T : BoundUserInterfaceState
|
||||
{
|
||||
if (UiSystem.TryGetUiState<T>(Owner, UiKey, out var state))
|
||||
{
|
||||
UpdateState(state);
|
||||
}
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generic update method called whenever the BUI should update.
|
||||
/// </summary>
|
||||
public virtual void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method that gets called upon prototype reload.
|
||||
/// </summary>
|
||||
@@ -79,7 +100,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
UiSystem.CloseUi(Owner, UiKey, _playerManager.LocalEntity, predicted: true);
|
||||
UiSystem.CloseUi(Owner, UiKey, PlayerManager.LocalEntity, predicted: true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -69,6 +69,12 @@ namespace Robust.Shared.GameObjects
|
||||
[DataField]
|
||||
public bool RequireInputValidation = true;
|
||||
|
||||
public InterfaceData(string clientType, float interactionRange = 2f, bool requireInputValidation = true)
|
||||
{
|
||||
ClientType = clientType;
|
||||
InteractionRange = interactionRange;
|
||||
RequireInputValidation = requireInputValidation;
|
||||
}
|
||||
public InterfaceData(InterfaceData data)
|
||||
{
|
||||
ClientType = data.ClientType;
|
||||
|
||||
@@ -707,6 +707,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[Pure]
|
||||
public bool HasComponent<T>(EntityUid uid) where T : IComponent
|
||||
{
|
||||
var dict = _entTraitArray[CompIdx.ArrayIndex<T>()];
|
||||
@@ -716,6 +717,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[Pure]
|
||||
public bool HasComponent<T>(EntityUid? uid) where T : IComponent
|
||||
{
|
||||
return uid.HasValue && HasComponent<T>(uid.Value);
|
||||
@@ -723,6 +725,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[Pure]
|
||||
public bool HasComponent(EntityUid uid, Type type)
|
||||
{
|
||||
var dict = _entTraitDict[type];
|
||||
@@ -731,6 +734,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[Pure]
|
||||
public bool HasComponent(EntityUid? uid, Type type)
|
||||
{
|
||||
if (!uid.HasValue)
|
||||
@@ -744,6 +748,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[Pure]
|
||||
public bool HasComponent(EntityUid uid, ushort netId, MetaDataComponent? meta = null)
|
||||
{
|
||||
if (!MetaQuery.Resolve(uid, ref meta))
|
||||
@@ -754,6 +759,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
/// <inheritdoc />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[Pure]
|
||||
public bool HasComponent(EntityUid? uid, ushort netId, MetaDataComponent? meta = null)
|
||||
{
|
||||
if (!uid.HasValue)
|
||||
@@ -821,6 +827,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[Pure]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public T GetComponent<T>(EntityUid uid) where T : IComponent
|
||||
{
|
||||
@@ -837,6 +844,7 @@ namespace Robust.Shared.GameObjects
|
||||
throw new KeyNotFoundException($"Entity {uid} does not have a component of type {typeof(T)}");
|
||||
}
|
||||
|
||||
[Pure]
|
||||
public IComponent GetComponent(EntityUid uid, CompIdx type)
|
||||
{
|
||||
var dict = _entTraitArray[type.Value];
|
||||
@@ -850,6 +858,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[Pure]
|
||||
public IComponent GetComponent(EntityUid uid, Type type)
|
||||
{
|
||||
// ReSharper disable once InvertIf
|
||||
@@ -866,12 +875,14 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[Pure]
|
||||
public IComponent GetComponent(EntityUid uid, ushort netId, MetaDataComponent? meta = null)
|
||||
{
|
||||
return (meta ?? MetaQuery.GetComponentInternal(uid)).NetComponents[netId];
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[Pure]
|
||||
public IComponent GetComponentInternal(EntityUid uid, CompIdx type)
|
||||
{
|
||||
var dict = _entTraitArray[type.Value];
|
||||
@@ -1450,6 +1461,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[Pure]
|
||||
public IComponentState? GetComponentState(IEventBus eventBus, IComponent component, ICommonSession? session, GameTick fromTick)
|
||||
{
|
||||
DebugTools.Assert(component.NetSyncEnabled, $"Attempting to get component state for an un-synced component: {component.GetType()}");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user