Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…on-14 into master-ru
  • Loading branch information
MilenVolf committed Aug 14, 2023
2 parents dbf4f46 + 1edd6e5 commit 82eac4f
Show file tree
Hide file tree
Showing 27 changed files with 4,629 additions and 4,435 deletions.
70 changes: 57 additions & 13 deletions Content.Client/Administration/UI/Notes/AdminNotesControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,64 @@ private bool NoteClicked(AdminNotesLine line)
};

_popup.OnDeletePressed += (noteId, noteType) => NoteDeleted?.Invoke(noteId, noteType);
_popup.OnPopupHide += OnPopupHide;

var box = UIBox2.FromDimensions(UserInterfaceManager.MousePositionScaled.Position, Vector2.One);
_popup.Open(box);

return true;
}

private void OnPopupHide()
{
if (_popup == null ||
!Inputs.TryGetValue((_popup.NoteId, _popup.NoteType), out var input))
{
return;
}

UpdateNoteLineAlpha(input);
}

private void NoteMouseEntered(GUIMouseHoverEventArgs args)
{
if (args.SourceControl is not AdminNotesLine line)
return;

line.Modulate = line.Modulate.WithAlpha(1f);
}

private void NoteMouseExited(GUIMouseHoverEventArgs args)
{
if (args.SourceControl is not AdminNotesLine line)
return;

if (_popup?.NoteId == line.Note.Id && _popup.Visible)
return;

UpdateNoteLineAlpha(line);
}

private void UpdateNoteLineAlpha(AdminNotesLine input)
{
var timeDiff = DateTime.UtcNow - input.Note.CreatedAt;
float alpha;
if (_noteFreshDays == 0 || timeDiff.TotalDays <= _noteFreshDays)
{
alpha = 1f;
}
else if (_noteStaleDays == 0 || timeDiff.TotalDays > _noteStaleDays)
{
alpha = 0f;
}
else
{
alpha = (float) (1 - Math.Clamp((timeDiff.TotalDays - _noteFreshDays) / (_noteStaleDays - _noteFreshDays), 0, 1));
}

input.Modulate = input.Modulate.WithAlpha(alpha);
}

public void SetNotes(Dictionary<(int, NoteType), SharedAdminNote> notes)
{
foreach (var (key, input) in Inputs)
Expand All @@ -119,25 +171,17 @@ public void SetNotes(Dictionary<(int, NoteType), SharedAdminNote> notes)

input = new AdminNotesLine(_sprites, note);
input.OnClicked += NoteClicked;
input.OnMouseEntered += NoteMouseEntered;
input.OnMouseExited += NoteMouseExited;

var timeDiff = DateTime.UtcNow - note.CreatedAt;
float alpha;
if (_noteFreshDays == 0 || timeDiff.TotalDays <= _noteFreshDays)
{
alpha = 1f;
}
else if (_noteStaleDays == 0 || timeDiff.TotalDays > _noteStaleDays)
UpdateNoteLineAlpha(input);

if (input.Modulate.A == 0)
{
alpha = 0f;
input.Visible = false;
showMoreButtonVisible = true;
}
else
{
alpha = (float) (1 - Math.Clamp((timeDiff.TotalDays - _noteFreshDays) / (_noteStaleDays - _noteFreshDays), 0, 1));
}

input.Modulate = input.Modulate.WithAlpha(alpha);
Notes.AddChild(input);
Inputs[(note.Id, note.NoteType)] = input;
ShowMoreButton.Visible = showMoreButtonVisible;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using System.Text;
using Content.Client.Resources;
using Content.Shared.Administration.Notes;
using Content.Shared.Database;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
Expand Down Expand Up @@ -56,7 +53,7 @@ public AdminNotesLine(SpriteSystem sprites, SharedAdminNote note)
private void Refresh()
{
string? iconPath;
if(Note.NoteSeverity is not null)
if (Note.NoteSeverity is not null && !NoteTypeIcons.ContainsKey(Note.NoteType))
SeverityIcons.TryGetValue(Note.NoteSeverity.Value, out iconPath);
else
NoteTypeIcons.TryGetValue(Note.NoteType, out iconPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public AdminNotesLinePopup(SharedAdminNote note, string playerName, bool showDel
DeleteButton.OnPressed += DeletePressed;
}

private int NoteId { get; }
private NoteType NoteType { get; }
public int NoteId { get; }
public NoteType NoteType { get; }
private TimeSpan? DeleteResetOn { get; set; }

private void EditPressed(ButtonEventArgs args)
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Chemistry/UI/ReagentDispenserWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
Title="{Loc 'reagent-dispenser-bound-user-interface-title'}"
SetSize="590 450"
MinSize="590 450">
SetSize="620 450"
MinSize="620 450">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'reagent-dispenser-window-amount-to-dispense-label'}"/>
Expand Down
26 changes: 8 additions & 18 deletions Content.Client/UserInterface/Systems/Bwoink/AHelpUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Content.Client.Administration.Managers;
using Content.Client.Administration.Systems;
using Content.Client.Administration.UI.Bwoink;
using Content.Client.Gameplay;
using Content.Client.UserInterface.Controls;
using Content.Shared.Administration;
using Content.Shared.Input;
Expand All @@ -24,7 +23,7 @@
namespace Content.Client.UserInterface.Systems.Bwoink;

[UsedImplicitly]
public sealed class AHelpUIController: UIController, IOnStateChanged<GameplayState>, IOnSystemChanged<BwoinkSystem>
public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSystem>
{
[Dependency] private readonly IClientAdminManager _adminManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
Expand All @@ -42,16 +41,8 @@ public override void Initialize()

SubscribeNetworkEvent<BwoinkDiscordRelayUpdated>(DiscordRelayUpdated);
SubscribeNetworkEvent<BwoinkPlayerTypingUpdated>(PeopleTypingUpdated);
}

public void OnStateEntered(GameplayState state)
{
_adminManager.AdminStatusUpdated += OnAdminStatusUpdated;

CommandBinds.Builder
.Bind(ContentKeyFunctions.OpenAHelp,
InputCmdHandler.FromDelegate(_ => ToggleWindow()))
.Register<AHelpUIController>();
}

public void UnloadButton()
Expand Down Expand Up @@ -87,22 +78,21 @@ private void AHelpButtonPressed(BaseButton.ButtonEventArgs obj)
UIHelper!.ToggleWindow();
}

public void OnStateExited(GameplayState state)
{
SetAHelpPressed(false);
_adminManager.AdminStatusUpdated -= OnAdminStatusUpdated;
UIHelper?.Dispose();
UIHelper = null;
CommandBinds.Unregister<AHelpUIController>();
}
public void OnSystemLoaded(BwoinkSystem system)
{
_bwoinkSystem = system;
_bwoinkSystem.OnBwoinkTextMessageRecieved += RecievedBwoink;

CommandBinds.Builder
.Bind(ContentKeyFunctions.OpenAHelp,
InputCmdHandler.FromDelegate(_ => ToggleWindow()))
.Register<AHelpUIController>();
}

public void OnSystemUnloaded(BwoinkSystem system)
{
CommandBinds.Unregister<AHelpUIController>();

DebugTools.Assert(_bwoinkSystem != null);
_bwoinkSystem!.OnBwoinkTextMessageRecieved -= RecievedBwoink;
_bwoinkSystem = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ private void FireEmitter(EntityUid uid, ParticleAcceleratorPowerState strength,
{
ParticleAcceleratorPowerState.Standby => 0,
ParticleAcceleratorPowerState.Level0 => 1,
ParticleAcceleratorPowerState.Level1 => 3,
ParticleAcceleratorPowerState.Level2 => 6,
ParticleAcceleratorPowerState.Level1 => 2,
ParticleAcceleratorPowerState.Level2 => 3,
ParticleAcceleratorPowerState.Level3 => 10,
_ => 0,
} * 10;
Expand Down
10 changes: 5 additions & 5 deletions Content.Server/Singularity/EntitySystems/SingularitySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ public void SetEnergy(EntityUid uid, float value, SingularityComponent? singular

singularity.Energy = value;
SetLevel(uid, value switch {
>= 1500 => 6,
>= 1000 => 5,
>= 600 => 4,
>= 2400 => 6,
>= 1600 => 5,
>= 900 => 4,
>= 300 => 3,
>= 200 => 2,
> 0 => 1,
Expand Down Expand Up @@ -312,8 +312,8 @@ public void UpdateEnergyDrain(EntityUid uid, SingularityComponent comp, Singular
{
6 => 20,
5 => 15,
4 => 10,
3 => 6,
4 => 12,
3 => 8,
2 => 2,
1 => 1,
_ => 0
Expand Down
40 changes: 23 additions & 17 deletions Content.Server/Temperature/Systems/TemperatureSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
using Content.Server.Atmos.EntitySystems;
using Content.Server.Temperature.Components;
using Content.Shared.Alert;
using Content.Shared.Atmos;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.Inventory;
using Content.Shared.Rejuvenate;
using Content.Shared.Temperature;
using Robust.Server.GameObjects;

Expand Down Expand Up @@ -37,6 +39,7 @@ public override void Initialize()
{
SubscribeLocalEvent<TemperatureComponent, OnTemperatureChangeEvent>(EnqueueDamage);
SubscribeLocalEvent<TemperatureComponent, AtmosExposedUpdateEvent>(OnAtmosExposedUpdate);
SubscribeLocalEvent<TemperatureComponent, RejuvenateEvent>(OnRejuvenate);
SubscribeLocalEvent<AlertsComponent, OnTemperatureChangeEvent>(ServerAlert);
SubscribeLocalEvent<TemperatureProtectionComponent, InventoryRelayedEvent<ModifyChangedTemperatureEvent>>(
OnTemperatureChangeAttempt);
Expand Down Expand Up @@ -66,25 +69,26 @@ public override void Update(float frameTime)
{
MetaDataComponent? metaData = null;

if (Deleted(comp.Owner, metaData) || Paused(comp.Owner, metaData))
var uid = comp.Owner;
if (Deleted(uid, metaData) || Paused(uid, metaData))
continue;

ChangeDamage(comp.Owner, comp);
ChangeDamage(uid, comp);
}

ShouldUpdateDamage.Clear();
}

public void ForceChangeTemperature(EntityUid uid, float temp, TemperatureComponent? temperature = null)
{
if (Resolve(uid, ref temperature))
{
float lastTemp = temperature.CurrentTemperature;
float delta = temperature.CurrentTemperature - temp;
temperature.CurrentTemperature = temp;
RaiseLocalEvent(uid, new OnTemperatureChangeEvent(temperature.CurrentTemperature, lastTemp, delta),
true);
}
if (!Resolve(uid, ref temperature))
return;

float lastTemp = temperature.CurrentTemperature;
float delta = temperature.CurrentTemperature - temp;
temperature.CurrentTemperature = temp;
RaiseLocalEvent(uid, new OnTemperatureChangeEvent(temperature.CurrentTemperature, lastTemp, delta),
true);
}

public void ChangeHeat(EntityUid uid, float heatAmount, bool ignoreHeatResistance = false,
Expand Down Expand Up @@ -126,6 +130,11 @@ private void OnAtmosExposedUpdate(EntityUid uid, TemperatureComponent temperatur
ChangeHeat(uid, heat * temperature.AtmosTemperatureTransferEfficiency, temperature: temperature);
}

private void OnRejuvenate(EntityUid uid, TemperatureComponent comp, RejuvenateEvent args)
{
ForceChangeTemperature(uid, Atmospherics.T20C, comp);
}

private void ServerAlert(EntityUid uid, AlertsComponent status, OnTemperatureChangeEvent args)
{
switch (args.CurrentTemperature)
Expand Down Expand Up @@ -174,7 +183,7 @@ private void EnqueueDamage(EntityUid uid, TemperatureComponent component, OnTemp

private void ChangeDamage(EntityUid uid, TemperatureComponent temperature)
{
if (!EntityManager.HasComponent<DamageableComponent>(uid))
if (!HasComp<DamageableComponent>(uid))
return;

// See this link for where the scaling func comes from:
Expand All @@ -192,8 +201,7 @@ private void ChangeDamage(EntityUid uid, TemperatureComponent temperature)
{
if (!temperature.TakingDamage)
{
_adminLogger.Add(LogType.Temperature,
$"{ToPrettyString(temperature.Owner):entity} started taking high temperature damage");
_adminLogger.Add(LogType.Temperature, $"{ToPrettyString(uid):entity} started taking high temperature damage");
temperature.TakingDamage = true;
}

Expand All @@ -205,8 +213,7 @@ private void ChangeDamage(EntityUid uid, TemperatureComponent temperature)
{
if (!temperature.TakingDamage)
{
_adminLogger.Add(LogType.Temperature,
$"{ToPrettyString(temperature.Owner):entity} started taking low temperature damage");
_adminLogger.Add(LogType.Temperature, $"{ToPrettyString(uid):entity} started taking low temperature damage");
temperature.TakingDamage = true;
}

Expand All @@ -217,8 +224,7 @@ private void ChangeDamage(EntityUid uid, TemperatureComponent temperature)
}
else if (temperature.TakingDamage)
{
_adminLogger.Add(LogType.Temperature,
$"{ToPrettyString(temperature.Owner):entity} stopped taking temperature damage");
_adminLogger.Add(LogType.Temperature, $"{ToPrettyString(uid):entity} stopped taking temperature damage");
temperature.TakingDamage = false;
}
}
Expand Down
Loading

0 comments on commit 82eac4f

Please sign in to comment.