Skip to content

Commit 0036c7e

Browse files
committed
Merge branch 'LoudMode' of https://github.com/Spaghetti-bit/starlight-14 into LoudMode
2 parents 3f65307 + d826248 commit 0036c7e

871 files changed

Lines changed: 483753 additions & 573984 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/close-master-pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
steps:
1717
- uses: superbrothers/close-pull-request@v3
1818
with:
19-
comment: "Thank you for your contribution! It appears you created a PR from your master branch, this is [something you should avoid doing](https://jmeridth.com/posts/do-not-issue-pull-requests-from-your-master-branch/), and thus this PR has been automatically closed. \n \n We suggest you follow [our git usage documentation](https://docs.spacestation14.com/en/general-development/setup/git-for-the-ss14-developer.html). \n \n You can move your current work from the master branch to another branch by following [these commands](https://ohshitgit.com/#accidental-commit-master). And then you may recreate your PR using the new branch."
19+
comment: "Thank you for your contribution! It appears you created a pull request from the master branch or another main development branch. This is [something you should avoid doing](https://jmeridth.com/posts/do-not-issue-pull-requests-from-your-master-branch/), and thus this pull request has been automatically closed. \n \n We suggest you follow [our git usage documentation](https://docs.spacestation14.com/en/general-development/setup/git-for-the-ss14-developer.html). \n \n You can move your current work to another branch by following [these commands](https://ohshitgit.com/#accidental-commit-master). Then, you may recreate your pull request using the new branch."
2020

21-
# If you prefer to just comment on the pr and not close it, uncomment the bellow and comment the above
21+
# If you prefer to just comment on the pr and not close it, uncomment the below and comment the above
2222

2323
# - uses: actions/github-script@v7
2424
# with:

Content.Client/Atmos/EntitySystems/AtmosPipeAppearanceSystem.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ private void OnAppearanceChanged(EntityUid uid, PipeAppearanceComponent componen
6666
if (args.Sprite == null)
6767
return;
6868

69+
// Starlight Start
70+
71+
// Grabbing the color, moved up.
72+
if (!_appearance.TryGetData<Color>(uid, PipeColorVisuals.Color, out var color, args.Component))
73+
color = Color.White;
74+
75+
// Apply color to all explicitly opted-in layers
76+
foreach (var tintedLayer in component.ExtraColoredLayers)
77+
if (_sprite.LayerMapTryGet((uid, args.Sprite), tintedLayer, out var tintedIndex, false))
78+
args.Sprite[tintedIndex].Color = color;
79+
80+
// Starlight End
81+
6982
if (!args.Sprite.Visible)
7083
{
7184
// This entity is probably below a floor and is not even visible to the user -> don't bother updating sprite data.
@@ -81,8 +94,7 @@ private void OnAppearanceChanged(EntityUid uid, PipeAppearanceComponent componen
8194
return;
8295
}
8396

84-
if (!_appearance.TryGetData<Color>(uid, PipeColorVisuals.Color, out var color, args.Component))
85-
color = Color.White;
97+
// Starlight: Grabbing the Color moved to top of method in Starlight block
8698

8799
for (byte i = 0; i < numberOfPipeLayers; i++)
88100
{

Content.Client/Atmos/UI/GasFilterBoundUserInterface.cs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ protected override void Open()
2727
{
2828
base.Open();
2929

30-
var atmosSystem = EntMan.System<AtmosphereSystem>();
30+
var atmosSystem = EntMan.System<AtmosphereSystem>(); // Starlight
3131

3232
_window = this.CreateWindow<GasFilterWindow>();
33-
_window.PopulateGasList(atmosSystem.Gases);
33+
// _window.PopulateGasList(atmosSystem.Gases); // Starlight
3434

35-
_window.ToggleStatusButtonPressed += OnToggleStatusButtonPressed;
35+
_window.StatusChanged /*Starlight*/ += OnToggleStatusButtonPressed;
3636
_window.FilterTransferRateChanged += OnFilterTransferRatePressed;
37-
_window.SelectGasPressed += OnSelectGasPressed;
37+
_window.GasSelectionChanged += OnGasSelectionChanged; // Starlight
38+
// _window.SelectGasPressed += OnSelectGasPressed; // Starlight
3839
}
3940

4041
private void OnToggleStatusButtonPressed()
@@ -50,6 +51,7 @@ private void OnFilterTransferRatePressed(string value)
5051
SendMessage(new GasFilterChangeRateMessage(rate));
5152
}
5253

54+
/* Starlight BEGIN
5355
private void OnSelectGasPressed()
5456
{
5557
if (_window is null)
@@ -67,6 +69,7 @@ private void OnSelectGasPressed()
6769
SendMessage(new GasFilterSelectGasMessage(gas));
6870
}
6971
}
72+
Starlight END*/
7073

7174
/// <summary>
7275
/// Update the UI state based on server-sent info
@@ -81,19 +84,11 @@ protected override void UpdateState(BoundUserInterfaceState state)
8184
_window.Title = (cast.FilterLabel);
8285
_window.SetFilterStatus(cast.Enabled);
8386
_window.SetTransferRate(cast.TransferRate);
84-
if (cast.FilteredGas is not null)
85-
{
86-
var atmos = EntMan.System<AtmosphereSystem>();
87-
var gas = atmos.GetGas((Gas) cast.FilteredGas);
88-
var gasName = Loc.GetString(gas.Name);
89-
_window.SetGasFiltered(gas.ID, gasName);
90-
}
91-
else
92-
{
93-
_window.SetGasFiltered(null, Loc.GetString("comp-gas-filter-ui-filter-gas-none"));
94-
}
87+
_window.UpdateState(cast); // Starlight: Replaces FilteredGas selection
9588
}
9689

90+
private void OnGasSelectionChanged(HashSet<Gas> selectedGases) => SendMessage(new GasFilterSelectGasMessage(selectedGases)); // Starlight add
91+
9792
protected override void Dispose(bool disposing)
9893
{
9994
base.Dispose(disposing);

Content.Client/Atmos/UI/GasFilterWindow.xaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,23 @@
1717
<Label Name="CurrentGasLabel" />
1818
</BoxContainer>
1919

20-
<BoxContainer Orientation="Vertical" VerticalExpand="True">
20+
<!-- <BoxContainer Orientation="Vertical" VerticalExpand="True">
2121
<Label Text="{Loc comp-gas-filter-ui-filter-gas-select}" />
2222
<ItemList Name="GasList" SelectMode="Single" VerticalExpand="True"
2323
SizeFlagsStretchRatio="0.9" />
2424
<Button Name="SelectGasButton" Text="{Loc comp-gas-filter-ui-filter-gas-confirm}" HorizontalExpand="True" Disabled="True" />
25-
</BoxContainer>
25+
</BoxContainer> Starlight removed-->
26+
27+
<!--Starlight start-->
28+
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" SeparationOverride="5" Margin="0 5 0 0">
29+
<Button Name="CSelectAll" HorizontalExpand="True" Text="{Loc 'air-alarm-ui-scrubber-select-all-gases-label'}" />
30+
<Button Name="CDeselectAll" HorizontalExpand="True" Text="{Loc 'air-alarm-ui-scrubber-deselect-all-gases-label'}" />
31+
</BoxContainer>
32+
33+
<ScrollContainer VerticalExpand="True">
34+
<GridContainer Name="CGasContainer" HorizontalExpand="True" HorizontalAlignment="Center" Columns="3" Margin="0 5 0 0" />
35+
</ScrollContainer>
36+
<!--Starlight end-->
37+
2638
</BoxContainer>
2739
</DefaultWindow>

Content.Client/Atmos/UI/GasFilterWindow.xaml.cs

Lines changed: 102 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Globalization;
4+
using System.Numerics;
5+
using Content.Shared.Atmos;
6+
using Content.Shared.Atmos.EntitySystems;
7+
using Content.Shared.Atmos.Monitor.Components;
8+
using Content.Shared.Atmos.Piping.Trinary.Components;
9+
using Content.Shared.Atmos.Piping.Unary.Components;
410
using Content.Shared.Atmos.Prototypes;
511
using Robust.Client.AutoGenerated;
612
using Robust.Client.UserInterface.Controls;
713
using Robust.Client.UserInterface.CustomControls;
814
using Robust.Client.UserInterface.XAML;
915
using Robust.Shared.Localization;
16+
using Robust.Shared.Prototypes;
1017

1118
namespace Content.Client.Atmos.UI
1219
{
@@ -19,19 +26,31 @@ public sealed partial class GasFilterWindow : DefaultWindow
1926
private readonly ButtonGroup _buttonGroup = new();
2027

2128
public bool FilterStatus = true;
22-
public string? SelectedGas;
23-
public string? CurrentGasId;
29+
public HashSet<Gas> SelectedGases = new(); // Starlight
30+
// public string? CurrentGasId // Starlight
2431

25-
public event Action? ToggleStatusButtonPressed;
32+
public event Action? StatusChanged; // Starlight
2633
public event Action<string>? FilterTransferRateChanged;
27-
public event Action? SelectGasPressed;
34+
// public event Action? SelectGasPressed; // Starlight
35+
36+
#region Starlight
37+
[Dependency] private IEntityManager _entityManager = default!;
38+
[Dependency] private IPrototypeManager _prototypeManager = default!;
39+
private Dictionary<Gas, Button> _gasControls = new();
40+
private GridContainer _gases => CGasContainer;
41+
public event Action<HashSet<Gas>>? GasSelectionChanged;
42+
private Button _selectAll => CSelectAll;
43+
private Button _deselectAll => CDeselectAll;
44+
private bool _isUpdatingState;
45+
#endregion
2846

2947
public GasFilterWindow()
3048
{
3149
RobustXamlLoader.Load(this);
50+
IoCManager.InjectDependencies(this); // Starlight add
3251

3352
ToggleStatusButton.OnPressed += _ => SetFilterStatus(!FilterStatus);
34-
ToggleStatusButton.OnPressed += _ => ToggleStatusButtonPressed?.Invoke();
53+
ToggleStatusButton.OnPressed += _ => StatusChanged?.Invoke(); // Starlight
3554

3655
FilterTransferRateInput.OnTextChanged += _ => SetFilterRate.Disabled = false;
3756
SetFilterRate.OnPressed += _ =>
@@ -40,10 +59,57 @@ public GasFilterWindow()
4059
SetFilterRate.Disabled = true;
4160
};
4261

43-
SelectGasButton.OnPressed += _ => SelectGasPressed?.Invoke();
62+
// Starlight start
63+
var atmosphereSystem = _entityManager.System<SharedAtmosphereSystem>();
64+
var allGases = Enum.GetValues<Gas>();
65+
SetSize = new Vector2(520, 456);
4466

45-
GasList.OnItemSelected += GasListOnItemSelected;
46-
GasList.OnItemDeselected += GasListOnItemDeselected;
67+
68+
_selectAll.OnPressed += _ =>
69+
{
70+
if (_isUpdatingState) return;
71+
72+
SelectedGases = new HashSet<Gas>(allGases);
73+
UpdateGasButtonVisuals();
74+
GasSelectionChanged?.Invoke(SelectedGases);
75+
};
76+
77+
_deselectAll.OnPressed += _ =>
78+
{
79+
if (_isUpdatingState) return;
80+
81+
SelectedGases.Clear();
82+
UpdateGasButtonVisuals();
83+
GasSelectionChanged?.Invoke(SelectedGases);
84+
};
85+
86+
foreach (var value in allGases)
87+
{
88+
ProtoId<GasPrototype> gasProtoId = atmosphereSystem.GetGas(value);
89+
var gasName = _prototypeManager.Index(gasProtoId).Name;
90+
var gasButton = new Button
91+
{
92+
Name = value.ToString(),
93+
Text = Loc.GetString(gasName),
94+
ToggleMode = true,
95+
HorizontalExpand = true,
96+
HorizontalAlignment = HAlignment.Stretch
97+
};
98+
gasButton.OnToggled += args =>
99+
{
100+
if (_isUpdatingState) return;
101+
102+
if (args.Pressed)
103+
SelectedGases.Add(value);
104+
else
105+
SelectedGases.Remove(value);
106+
107+
GasSelectionChanged?.Invoke(SelectedGases);
108+
};
109+
_gasControls.Add(value, gasButton);
110+
_gases.AddChild(gasButton);
111+
}
112+
// Starlight end
47113
}
48114

49115
public void SetTransferRate(float rate)
@@ -64,6 +130,33 @@ public void SetFilterStatus(bool enabled)
64130
}
65131
}
66132

133+
#region Starlight
134+
public void UpdateState(GasFilterBoundUserInterfaceState state)
135+
{
136+
_isUpdatingState = true;
137+
138+
SetFilterStatus(state.Enabled);
139+
SetTransferRate(state.TransferRate);
140+
141+
SelectedGases = state.FilteredGases != null
142+
? new HashSet<Gas>(state.FilteredGases)
143+
: new HashSet<Gas>();
144+
145+
UpdateGasButtonVisuals();
146+
147+
_isUpdatingState = false;
148+
}
149+
150+
private void UpdateGasButtonVisuals()
151+
{
152+
foreach (var (gas, button) in _gasControls)
153+
{
154+
button.Pressed = SelectedGases.Contains(gas);
155+
}
156+
}
157+
#endregion
158+
159+
/* Starlight BEGIN
67160
public void SetGasFiltered(string? id, string name)
68161
{
69162
CurrentGasId = id;
@@ -107,5 +200,6 @@ private void GasListOnItemDeselected(ItemList.ItemListDeselectedEventArgs obj)
107200
SelectedGas = CurrentGasId;
108201
SelectGasButton.Disabled = true;
109202
}
203+
Starlight END*/
110204
}
111205
}

Content.Client/Decals/DecalSystem.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,24 @@ private void OnChunkUpdate(DecalChunkUpdateEvent ev)
120120
UpdateChunks(gridId, gridComp, updatedGridChunks);
121121
}
122122

123+
// Starlight Start: Diff chunks
124+
foreach (var (netGrid, diffs) in ev.Diffs)
125+
{
126+
if (diffs.Count == 0)
127+
continue;
128+
129+
var gridId = GetEntity(netGrid);
130+
131+
if (!TryComp(gridId, out DecalGridComponent? gridComp))
132+
{
133+
Log.Error($"Received decal diff for an entity without a decal component: {ToPrettyString(gridId)}");
134+
continue;
135+
}
136+
137+
ApplyChunkDiffs(gridId, gridComp, diffs);
138+
}
139+
// Starlight End
140+
123141
// Now we'll cull old chunks out of range as the server will send them to us anyway.
124142
foreach (var (netGrid, chunks) in ev.RemovedChunks)
125143
{
@@ -138,6 +156,39 @@ private void OnChunkUpdate(DecalChunkUpdateEvent ev)
138156
}
139157
}
140158

159+
// Starlight Start: Merge decal diffs instead of wholesale replace
160+
private void ApplyChunkDiffs(EntityUid gridId, DecalGridComponent gridComp, Dictionary<Vector2i, DecalChunkDiff> diffs)
161+
{
162+
var chunkCollection = gridComp.ChunkCollection.ChunkCollection;
163+
164+
foreach (var (index, diff) in diffs)
165+
{
166+
if (!chunkCollection.TryGetValue(index, out var chunk))
167+
{
168+
// We should always have this chunk already but if something desynced, don't crash, just start
169+
// a fresh chunk from the diff and let the next full resync correct anything missed.
170+
chunk = new DecalChunk();
171+
chunkCollection[index] = chunk;
172+
}
173+
174+
foreach (var removedId in diff.Removed)
175+
{
176+
if (chunk.Decals.ContainsKey(removedId))
177+
{
178+
OnDecalRemoved(gridId, removedId, gridComp, index, chunk);
179+
gridComp.DecalIndex.Remove(removedId);
180+
}
181+
}
182+
183+
foreach (var (decalId, decal) in diff.Upserted)
184+
{
185+
chunk.Decals[decalId] = decal;
186+
gridComp.DecalIndex[decalId] = index;
187+
}
188+
}
189+
}
190+
// Starlight End
191+
141192
private void UpdateChunks(EntityUid gridId, DecalGridComponent gridComp, Dictionary<Vector2i, DecalChunk> updatedGridChunks)
142193
{
143194
var chunkCollection = gridComp.ChunkCollection.ChunkCollection;

0 commit comments

Comments
 (0)