Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using Content.Client._DVA.DVCustomObjectiveSummary; // DeltaV
using Content.Client.CharacterInfo;
using Content.Client.Gameplay;
using Content.Client.Stylesheets;
Expand Down Expand Up @@ -27,17 +28,23 @@ namespace Content.Client.UserInterface.Systems.Character;
[UsedImplicitly]
public sealed partial class CharacterUIController : UIController, IOnStateEntered<GameplayState>, IOnStateExited<GameplayState>, IOnSystemChanged<CharacterInfoSystem>
{
[Dependency] private IEntityManager _ent = default!;
[Dependency] private IPlayerManager _player = default!;
[Dependency] private IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _ent = default!;
[Dependency] private readonly ILogManager _logMan = default!;
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly DVCustomObjectiveSummaryUIController _objective = default!; // DeltaV

[UISystemDependency] private readonly CharacterInfoSystem _characterInfo = default!;
[UISystemDependency] private readonly SpriteSystem _sprite = default!;

private ISawmill _sawmill = default!;

public override void Initialize()
{
base.Initialize();

_sawmill = _logMan.GetSawmill("character");

SubscribeNetworkEvent<MindRoleTypeChangedEvent>(OnRoleTypeChanged);
}

Expand Down Expand Up @@ -179,6 +186,19 @@ private void CharacterUpdated(CharacterData data)

_window.Objectives.AddChild(objectiveControl);
}
// Begin DeltaV Additions - Custom objective summary
if (objectives.Count > 0)
{
var button = new Button
{
Text = Loc.GetString("custom-objective-button-text"),
Margin = new Thickness(0, 10, 0, 10)
};
button.OnPressed += _ => _objective.OpenWindow();

_window.Objectives.AddChild(button);
}
// End DeltaV Additions

if (briefing != null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Content.Shared._DVA.DVCustomObjectiveSummary;
using Robust.Client.UserInterface.Controllers;
using Robust.Shared.Network;

namespace Content.Client._DVA.DVCustomObjectiveSummary;

public sealed class DVCustomObjectiveSummaryUIController : UIController
{
[Dependency] private readonly IClientNetManager _net = default!;

private DVCustomObjectiveSummaryWindow? _window;

public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<DVCustomObjectiveSummaryOpenMessage>(OnDVCustomObjectiveSummaryOpen);
}

private void OnDVCustomObjectiveSummaryOpen(DVCustomObjectiveSummaryOpenMessage msg, EntitySessionEventArgs args)
{
OpenWindow();
}

public void OpenWindow()
{
// If a window is already open, close it
_window?.Close();

_window = new DVCustomObjectiveSummaryWindow();
_window.OpenCentered();
_window.OnClose += () => _window = null;
_window.OnSubmitted += OnFeedbackSubmitted;
}

private void OnFeedbackSubmitted(string args)
{
var msg = new DVCustomObjectiveClientSetObjective
{
Summary = args,
};
_net.ClientSendMessage(msg);
_window?.Close();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Title="{Loc 'custom-objective-window-title'}"
MinSize="300 250"
SetSize="550 370">
<BoxContainer Orientation="Vertical" Margin="10 10 20 0">
<Label HorizontalAlignment="Center" Text="{Loc 'custom-objective-window-explain'}" />
<TextEdit Name="ObjectiveSummaryTextEdit" MaxHeight="500" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" MinHeight="200" />
<Label Name="CharacterLimitLabel" HorizontalAlignment="Center" StyleClasses="LabelSmall"/>
<Label HorizontalAlignment="Center" Text="{Loc 'custom-objective-window-explain-edit'}" />
<controls:ConfirmButton Name="SubmitButton" ConfirmationText="{Loc 'custom-objective-window-submit-button-text-confirm'}" Text="{Loc 'custom-objective-window-submit-button-text'}" Margin="0 10 0 10" />
</BoxContainer>
</controls:FancyWindow>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using Content.Client.UserInterface.Controls;
using Content.Shared._DVA.DCCVars;

Check failure on line 2 in Content.Client/_DVA/DVCustomObjectiveSummary/DVCustomObjectiveSummaryWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'DCCVars' does not exist in the namespace 'Content.Shared._DVA' (are you missing an assembly reference?)

Check failure on line 2 in Content.Client/_DVA/DVCustomObjectiveSummary/DVCustomObjectiveSummaryWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'DCCVars' does not exist in the namespace 'Content.Shared._DVA' (are you missing an assembly reference?)
using Content.Shared.Mind;
using Robust.Client.AutoGenerated;
using Robust.Client.Player;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Configuration;
using Robust.Shared.Utility;

namespace Content.Client._DVA.DVCustomObjectiveSummary;

[GenerateTypedNameReferences]
public sealed partial class DVCustomObjectiveSummaryWindow : FancyWindow
{
[Dependency] private readonly IPlayerManager _players = default!;
[Dependency] private readonly IEntityManager _entity = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;

private SharedMindSystem? _mind;

// Maximum length the summary can be in characters.
private int _maxLengthSummaryLength;

public event Action<string>? OnSubmitted;

public DVCustomObjectiveSummaryWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

_cfg.OnValueChanged(DCCVars.MaxObjectiveSummaryLength, len =>
{
_maxLengthSummaryLength = len;
UpdateWordCount();
},
invokeImmediately: true);


SubmitButton.OnPressed +=
_ => OnSubmitted?.Invoke(Rope.Collapse(ObjectiveSummaryTextEdit.TextRope));
ObjectiveSummaryTextEdit.OnTextChanged += _ => UpdateWordCount();

_mind ??= _entity.System<SharedMindSystem>();

_mind.TryGetMind(_players.LocalSession, out var mindUid, out _);

// This is only for if you quit the server then rejoin.
if (_entity.TryGetComponent<Shared._DVA.DVCustomObjectiveSummary.DVCustomObjectiveSummaryComponent>(mindUid, out var summary))
ObjectiveSummaryTextEdit.TextRope = new Rope.Leaf(summary.ObjectiveSummary);

UpdateWordCount();
}

private void UpdateWordCount()
{
var textLength = ObjectiveSummaryTextEdit.TextLength;
var overMax = textLength > _maxLengthSummaryLength;

// Disable the button if it's over the max length.
SubmitButton.Disabled = overMax;
CharacterLimitLabel.Text = textLength + "/" + _maxLengthSummaryLength;

CharacterLimitLabel.FontColorOverride = overMax ? Color.Red : null;
PlaceholderText.Visible = textLength == 0;
}
}
64 changes: 41 additions & 23 deletions Content.Server/Objectives/ObjectivesSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using System.Linq;
using System.Text;
using Content.Server.Objectives.Commands;
using Content.Shared._DVA.DCCVars; // DeltaV - Pinktext
using Content.Shared._DVA.DVCustomObjectiveSummary; // DeltaV Pinktext
using Content.Shared.CCVar;
using Content.Shared.Prototypes;
using Content.Shared.Roles.Jobs;
Expand All @@ -33,6 +35,8 @@ public sealed partial class ObjectivesSystem : SharedObjectivesSystem

private bool _showGreentext;

private int _maxLengthSummaryLength; // DeltaV

public override void Initialize()
{
base.Initialize();
Expand All @@ -41,6 +45,8 @@ public override void Initialize()

Subs.CVar(_cfg, CCVars.GameShowGreentext, value => _showGreentext = value, true);

Subs.CVar(_cfg, DCCVars.MaxObjectiveSummaryLength, len => _maxLengthSummaryLength = len, true); // DeltaV

ProtoMan.PrototypesReloaded += CreateCompletions;
}

Expand Down Expand Up @@ -170,47 +176,59 @@ private void AddSummary(StringBuilder result, string agent, List<(EntityUid, str
totalObjectives++;

agentSummary.Append("- ");
if (!_showGreentext)
{
agentSummary.AppendLine(objectiveTitle);
}
else if (progress > 0.99f)
/* Begin DeltaV removal - Removed greentext
if (progress > 0.99f)
{
agentSummary.AppendLine(Loc.GetString(
"objectives-objective-success",
("objective", objectiveTitle),
("progress", progress)
("markupColor", "green")
));
completedObjectives++;
}
else if (progress <= 0.99f && progress >= 0.5f)
{
agentSummary.AppendLine(Loc.GetString(
"objectives-objective-partial-success",
("objective", objectiveTitle),
("progress", progress)
));
}
else if (progress < 0.5f && progress > 0f)
{
agentSummary.AppendLine(Loc.GetString(
"objectives-objective-partial-failure",
("objective", objectiveTitle),
("progress", progress)
));
}
else
{
agentSummary.AppendLine(Loc.GetString(
"objectives-objective-fail",
("objective", objectiveTitle),
("progress", progress)
("progress", (int) (progress * 100)),
("markupColor", "red")
));
}
End DeltaV removal */
// Begin DeltaV Additions - Generic objective
agentSummary.AppendLine(Loc.GetString(
"objectives-objective",
("objective", objectiveTitle)
));
// End DeltaV Additions
}
}

var successRate = totalObjectives > 0 ? (float) completedObjectives / totalObjectives : 0f;
// Begin DeltaV Additions - custom objective response.
if (TryComp<CustomObjectiveSummaryComponent>(mindId, out var customComp) &&
customComp.ObjectiveSummary.Length <= _maxLengthSummaryLength)
{
// We have to spit it like this to make it readable. Yeah, it sucks but for some reason the entire thing
// is just one long string...
var words = customComp.ObjectiveSummary.Split(" ");
var currentLine = "";
foreach (var word in words)
{
currentLine += word + " ";

// magic number
if (currentLine.Length <= 50)
continue;

agentSummary.AppendLine(Loc.GetString("custom-objective-format", ("line", currentLine)));
currentLine = "";
}

agentSummary.AppendLine(Loc.GetString("custom-objective-format", ("line", currentLine)));
}
// End DeltaV Additions
agentSummaries.Add((agentSummary.ToString(), successRate, completedObjectives));
}

Expand Down
2 changes: 2 additions & 0 deletions Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Content.Server.Shuttles.Events;
using Content.Server.Station.Events;
using Content.Server.Station.Systems;
using Content.Shared._DVA.DVCustomObjectiveSummary; // DeltaV
using Content.Shared.Access.Systems;
using Content.Shared.CCVar;
using Content.Shared.Database;
Expand Down Expand Up @@ -221,6 +222,7 @@ private void OnEmergencyFTL(EntityUid uid, EmergencyShuttleComponent component,
};
_deviceNetworkSystem.QueuePacket(uid, null, payload, netComp.TransmitFrequency);
}
RaiseLocalEvent(new EvacShuttleLeftEvent()); // DeltaV
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Content.Server.Administration.Logs;
using Content.Shared._DVA.DVCustomObjectiveSummary;
using Content.Shared.Database;
using Content.Shared.Mind;
using Robust.Shared.Network;

namespace Content.Server._DVA.DVCustomObjectiveSummary;

public sealed class DVCustomObjectiveSummarySystem : EntitySystem
{
[Dependency] private readonly IServerNetManager _net = default!;
[Dependency] private readonly ISharedPlayerManager _player = default!;

Check failure on line 12 in Content.Server/_DVA/DVCustomObjectiveSummary/DVCustomObjectiveSummarySystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ISharedPlayerManager' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 12 in Content.Server/_DVA/DVCustomObjectiveSummary/DVCustomObjectiveSummarySystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ISharedPlayerManager' could not be found (are you missing a using directive or an assembly reference?)
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly IAdminLogManager _adminLog = default!;

public override void Initialize()
{
SubscribeLocalEvent<EvacShuttleLeftEvent>(OnEvacShuttleLeft);

_net.RegisterNetMessage<DVCustomObjectiveClientSetObjective>(OnDVCustomObjectiveFeedback);
}

private void OnDVCustomObjectiveFeedback(DVCustomObjectiveClientSetObjective msg)
{
if (!_mind.TryGetMind(msg.MsgChannel.UserId, out var mind))
return;

if (mind.Value.Comp.Objectives.Count == 0)
return;

var comp = EnsureComp<DVCustomObjectiveSummaryComponent>(mind.Value);

comp.ObjectiveSummary = msg.Summary;
Dirty(mind.Value.Owner, comp);

_adminLog.Add(LogType.ObjectiveSummary, $"{ToPrettyString(mind.Value.Comp.OwnedEntity)} wrote objective summery: {msg.Summary}");
}

private void OnEvacShuttleLeft(EvacShuttleLeftEvent args)
{
var allMinds = _mind.GetAliveHumans();

foreach (var mind in allMinds)
{
// Only send the popup to people with objectives.
if (mind.Comp.Objectives.Count == 0)
continue;

if (!_player.TryGetSessionById(mind.Comp.UserId, out var session))
continue;

RaiseNetworkEvent(new DVCustomObjectiveSummaryOpenMessage(), session);
}
}
}
3 changes: 3 additions & 0 deletions Content.Shared.Database/LogType.cs
Comment thread
Vapetastic-Gaming marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ public enum LogType
/// Tiles related interactions.
/// </summary>
Tile = 86,
BagOfHolding = 420, // DeltaV - Summary: adds bag of holding.
Psionics = 421, // DeltaV - Summary: adds psionic as a log type.
ObjectiveSummary = 422, // DeltaV

/// <summary>
/// A client has sent too many chat messages recently and is temporarily blocked from sending more.
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/_DVA/CCVars/DCCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ public sealed partial class DCCVars
/// </summary>
public static readonly CVarDef<float> SsdIndicatorRecentAfterSeconds =
CVarDef.Create("deltav.ssd.recent_after_seconds", 300f, CVar.SERVER | CVar.REPLICATED);

/// <summary>
/// Maximum number of characters in objective summaries.
/// </summary>
public static readonly CVarDef<int> MaxObjectiveSummaryLength =
CVarDef.Create("game.max_objective_summary_length", 256, CVar.SERVER | CVar.REPLICATED);
}
Comment thread
Vapetastic-Gaming marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Robust.Shared.GameStates;

namespace Content.Shared._DVA.DVCustomObjectiveSummary;

/// <summary>
/// Put on a players mind if the wrote a custom summary for their objectives.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class DVCustomObjectiveSummaryComponent : Component
{
/// <summary>
/// What the player wrote as their summary!
/// </summary>
[DataField, AutoNetworkedField]
public string ObjectiveSummary = "";
}
Loading
Loading