Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into JaniLocker
Browse files Browse the repository at this point in the history
  • Loading branch information
dvir001 committed Dec 12, 2023
2 parents add9c82 + 6526d70 commit d2ba0f1
Show file tree
Hide file tree
Showing 697 changed files with 49,259 additions and 18,686 deletions.
7 changes: 6 additions & 1 deletion Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,16 @@ public void SubmitData(string newFullName, string newJobTitle, List<string> newA
if (newJobTitle.Length > MaxJobTitleLength)
newJobTitle = newJobTitle[..MaxJobTitleLength];

SendMessage(new WriteToTargetIdMessage(
SendMessage(new SharedIdCardSystem.WriteToTargetIdMessage(
newFullName,
newJobTitle,
newAccessList,
newJobPrototype));
}

public void SubmitShipData(string newShuttleName, string newShuttleSuffix)
{
SendMessage(new SharedIdCardSystem.WriteToShuttleDeedMessage(newShuttleName, newShuttleSuffix));
}
}
}
8 changes: 7 additions & 1 deletion Content.Client/Access/UI/IdCardConsoleWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@
<Label Name="JobTitleLabel" Text="{Loc 'id-card-console-window-job-title-label'}" />
<LineEdit Name="JobTitleLineEdit" HorizontalExpand="True" />
<Button Name="JobTitleSaveButton" Text="{Loc 'id-card-console-window-save-button'}" Disabled="True" />

<Label Name="ShipNameLabel" Text="{Loc 'id-card-console-window-ship-name-label'}" />
<GridContainer Columns="2" HSeparationOverride="4" HorizontalExpand="True">
<LineEdit Name="ShipNameLineEdit" HorizontalExpand="True" />
<LineEdit Name="ShipSuffixLineEdit" HorizontalExpand="True" />
</GridContainer>
<Button Name="ShipNameSaveButton" Text="{Loc 'id-card-console-window-save-button'}" Disabled="True" />
</GridContainer>
<Control MinSize="0 8" />
<GridContainer Columns="2">
<Label Text="{Loc 'id-card-console-window-job-selection-label'}" />
<OptionButton Name="JobPresetOptionButton" />
Expand Down
73 changes: 73 additions & 0 deletions Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using Content.Shared.Access;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Roles;
using Robust.Client.AutoGenerated;
Expand All @@ -8,6 +9,7 @@
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
using static Content.Shared.Access.Components.IdCardConsoleComponent;
using static Content.Shared.Shipyard.Components.ShuttleDeedComponent;

namespace Content.Client.Access.UI
{
Expand All @@ -25,7 +27,9 @@ public sealed partial class IdCardConsoleWindow : DefaultWindow

private string? _lastFullName;
private string? _lastJobTitle;
private string?[]? _lastShuttleName;
private string? _lastJobProto;
private bool _interfaceEnabled = false;

public IdCardConsoleWindow(IdCardConsoleBoundUserInterface owner, IPrototypeManager prototypeManager,
List<ProtoId<AccessLevelPrototype>> accessLevels)
Expand All @@ -50,6 +54,10 @@ public IdCardConsoleWindow(IdCardConsoleBoundUserInterface owner, IPrototypeMana
};
JobTitleSaveButton.OnPressed += _ => SubmitData();

ShipNameLineEdit.OnTextChanged += _ => EnsureValidShuttleName();
ShipSuffixLineEdit.OnTextChanged += _ => EnsureValidShuttleName();
ShipNameSaveButton.OnPressed += _ => SubmitShuttleData();

var jobs = _prototypeManager.EnumeratePrototypes<JobPrototype>().ToList();
jobs.Sort((x, y) => string.Compare(x.LocalizedName, y.LocalizedName, StringComparison.CurrentCulture));

Expand Down Expand Up @@ -182,6 +190,29 @@ public void UpdateState(IdCardConsoleBoundUserInterfaceState state)

JobTitleSaveButton.Disabled = !interfaceEnabled || !jobTitleDirty;

// Frontier - shuttle renaming support
ShipNameLabel.Modulate = interfaceEnabled ? Color.White : Color.Gray;

ShipNameLineEdit.Editable = interfaceEnabled && state.HasOwnedShuttle;
ShipSuffixLineEdit.Editable = false; // "Make sure you cannot change the suffix at all." - @dvir001, 2023.11.16

if (interfaceEnabled && state.HasOwnedShuttle)
{
var parts = state.TargetShuttleNameParts ?? new string?[] { null, null };
ShipNameLineEdit.Text = !interfaceEnabled ? string.Empty : parts[0] ?? string.Empty;
ShipSuffixLineEdit.Text = !interfaceEnabled ? string.Empty : parts[1] ?? string.Empty;

ShipNameSaveButton.Disabled = !interfaceEnabled || !state.HasOwnedShuttle;
}
else
{
ShipSuffixLineEdit.Text = string.Empty;
ShipNameLineEdit.Text = !state.HasOwnedShuttle
? Loc.GetString("id-card-console-window-shuttle-placeholder")
: string.Empty;
ShipNameSaveButton.Disabled = true;
}

JobPresetOptionButton.Disabled = !interfaceEnabled;

foreach (var (accessName, button) in _accessButtons)
Expand All @@ -203,6 +234,41 @@ public void UpdateState(IdCardConsoleBoundUserInterfaceState state)
_lastFullName = state.TargetIdFullName;
_lastJobTitle = state.TargetIdJobTitle;
_lastJobProto = state.TargetIdJobPrototype;
_lastShuttleName = state.TargetShuttleNameParts;
_interfaceEnabled = interfaceEnabled;

EnsureValidShuttleName();
}

// <summary>
// Invoked when a shuttle name field is edited.
// Checks whether the name is valid and, if it is, enabled the save button.
//
// The form of a valid name is: "<CORP> <NAME> <SUFFIX>"
// Where <CORP> is usually a 2-5 character string like NT14, KC, SL;
// <NAME> is the shuttle name like Construct;
// and <SUFFIX> is an immutable ID like QT-225.
// </summary>
private void EnsureValidShuttleName()
{
var name = ShipNameLineEdit.Text;
var suffix = ShipSuffixLineEdit.Text;

// We skip suffix validation because it's immutable and is ignored by the server
var valid = name.Length <= MaxNameLength
&& name.Trim().Length >= 3; // Arbitrary client-side number, should hopefully be long enough.

ShipNameSaveButton.Disabled = !_interfaceEnabled || !valid;

// If still enabled, check for dirtiness and disable it if the name is not dirty
if (!ShipNameSaveButton.Disabled)
{
var dirty = _lastShuttleName != null &&
((_lastShuttleName[0] ?? string.Empty) != name
|| (_lastShuttleName[1] ?? string.Empty) != suffix);

ShipNameSaveButton.Disabled = !dirty;
}
}

private void SubmitData()
Expand All @@ -218,5 +284,12 @@ private void SubmitData()
_accessButtons.Where(x => x.Value.Pressed).Select(x => x.Key).ToList(),
jobProtoDirty ? _jobPrototypeIds[JobPresetOptionButton.SelectedId] : string.Empty);
}

private void SubmitShuttleData()
{
_owner.SubmitShipData(
ShipNameLineEdit.Text,
ShipSuffixLineEdit.Text);
}
}
}
16 changes: 9 additions & 7 deletions Content.Client/Nyanotrasen/Mail/MailSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Robust.Client.GameObjects;
using Content.Shared.Mail;
using Content.Shared.StatusIcon;
using Robust.Client.Utility;
using Robust.Shared.Prototypes;

namespace Content.Client.Mail
Expand Down Expand Up @@ -30,17 +29,20 @@ namespace Content.Client.Mail
/// </remarks>
public sealed class MailJobVisualizerSystem : VisualizerSystem<MailComponent>
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SpriteSystem _spriteSystem = default!;

protected override void OnAppearanceChange(EntityUid uid, MailComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;

if (args.Component.TryGetData(MailVisuals.JobIcon, out string job))
{
var jobIcon = _prototype.Index<StatusIconPrototype>(job);
args.Sprite.LayerSetTexture(MailVisualLayers.JobStamp, jobIcon.Icon.Frame0());
}
args.Component.TryGetData(MailVisuals.JobIcon, out string job);

if (!_prototypeManager.TryIndex<StatusIconPrototype>(job, out var icon))
return;

args.Sprite.LayerSetTexture(MailVisualLayers.JobStamp, _spriteSystem.Frame0(icon.Icon));
}
}

Expand Down
69 changes: 56 additions & 13 deletions Content.Client/Salvage/UI/SalvageExpeditionWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Content.Client.UserInterface.Controls;
using Content.Shared.CCVar;
using Content.Shared.Parallax.Biomes;
using Content.Shared.Procedural;
using Content.Shared.Salvage;
using Content.Shared.Salvage.Expeditions;
using Content.Shared.Salvage.Expeditions.Modifiers;
Expand Down Expand Up @@ -54,10 +53,8 @@ public void UpdateState(SalvageExpeditionConsoleState state)
for (var i = 0; i < state.Missions.Count; i++)
{
var missionParams = state.Missions[i];
var difficultyId = "Moderate";
var difficultyProto = _prototype.Index<SalvageDifficultyPrototype>(difficultyId);
// TODO: Selectable difficulty soon.
var mission = _salvage.GetMission(difficultyProto, missionParams.Seed);
var config = missionParams.MissionType;
var mission = _salvage.GetMission(missionParams.MissionType, missionParams.Difficulty, missionParams.Seed);

// Mission title
var missionStripe = new StripeBack()
Expand All @@ -67,7 +64,7 @@ public void UpdateState(SalvageExpeditionConsoleState state)

missionStripe.AddChild(new Label()
{
Text = Loc.GetString($"salvage-expedition-type"),
Text = Loc.GetString($"salvage-expedition-type-{config.ToString()}"),
HorizontalAlignment = HAlignment.Center,
Margin = new Thickness(0f, 5f, 0f, 5f),
});
Expand All @@ -84,25 +81,48 @@ public void UpdateState(SalvageExpeditionConsoleState state)
Text = Loc.GetString("salvage-expedition-window-difficulty")
});

var difficultyColor = difficultyProto.Color;
Color difficultyColor;

switch (missionParams.Difficulty)
{
case DifficultyRating.Minimal:
difficultyColor = Color.FromHex("#52B4E996");
break;
case DifficultyRating.Minor:
difficultyColor = Color.FromHex("#9FED5896");
break;
case DifficultyRating.Moderate:
difficultyColor = Color.FromHex("#EFB34196");
break;
case DifficultyRating.Hazardous:
difficultyColor = Color.FromHex("#DE3A3A96");
break;
case DifficultyRating.Extreme:
difficultyColor = Color.FromHex("#D381C996");
break;
default:
throw new ArgumentOutOfRangeException();
}

lBox.AddChild(new Label
{
Text = Loc.GetString("salvage-expedition-difficulty-Moderate"),
Text = Loc.GetString($"salvage-expedition-difficulty-{missionParams.Difficulty.ToString()}"),
FontColorOverride = difficultyColor,
HorizontalAlignment = HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
});

// Details
var details = _salvage.GetMissionDescription(mission);

lBox.AddChild(new Label
{
Text = Loc.GetString("salvage-expedition-difficulty-players"),
HorizontalAlignment = HAlignment.Left,
Text = Loc.GetString("salvage-expedition-window-details")
});

lBox.AddChild(new Label
{
Text = difficultyProto.RecommendedPlayers.ToString(),
Text = details,
FontColorOverride = StyleNano.NanoGold,
HorizontalAlignment = HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
Expand Down Expand Up @@ -148,7 +168,7 @@ public void UpdateState(SalvageExpeditionConsoleState state)

lBox.AddChild(new Label
{
Text = Loc.GetString(_prototype.Index<SalvageBiomeModPrototype>(biome).ID),
Text = Loc.GetString(_prototype.Index<SalvageBiomeMod>(biome).ID),
FontColorOverride = StyleNano.NanoGold,
HorizontalAlignment = HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f),
Expand All @@ -170,6 +190,29 @@ public void UpdateState(SalvageExpeditionConsoleState state)
Margin = new Thickness(0f, 0f, 0f, 5f),
});

lBox.AddChild(new Label()
{
Text = Loc.GetString("salvage-expedition-window-rewards")
});

var rewards = new Dictionary<string, int>();
foreach (var reward in mission.Rewards)
{
var name = _prototype.Index<EntityPrototype>(reward).Name;
var count = rewards.GetOrNew(name);
count++;
rewards[name] = count;
}

// there will always be 3 or more rewards so no need for 0 check
lBox.AddChild(new Label()
{
Text = string.Join("\n", rewards.Select(o => "- " + o.Key + (o.Value > 1 ? $" x {o.Value}" : ""))).TrimEnd(),
FontColorOverride = StyleNano.ConcerningOrangeFore,
HorizontalAlignment = HAlignment.Left,
Margin = new Thickness(0f, 0f, 0f, 5f)
});

// Claim
var claimButton = new Button()
{
Expand Down Expand Up @@ -246,7 +289,7 @@ protected override void FrameUpdate(FrameEventArgs args)
else
{
var cooldown = _cooldown
? TimeSpan.FromSeconds(_cfgManager.GetCVar(CCVars.SalvageExpeditionCooldown))
? TimeSpan.FromSeconds(_cfgManager.GetCVar(CCVars.SalvageExpeditionFailedCooldown))
: TimeSpan.FromSeconds(_cfgManager.GetCVar(CCVars.SalvageExpeditionCooldown));

NextOfferBar.Value = 1f - (float) (remaining / cooldown);
Expand Down
Loading

0 comments on commit d2ba0f1

Please sign in to comment.