Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into upstream_update_181123
Browse files Browse the repository at this point in the history
  • Loading branch information
Peptide90 committed Mar 14, 2024
2 parents d5bd4b2 + ccb405d commit 6d8fc12
Show file tree
Hide file tree
Showing 1,343 changed files with 20,981 additions and 993 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/Content.*/Nuclear14/* @Peptide90 @Partmedia @Cheackraze
/.github/ @Partmedia

/Resources/Prototypes/Nuclear14/* @Peptide90 @Just-a-Unity-Dev
/Resources/Prototypes/Nuclear14/* @Peptide90
/Resources/Textures/Nuclear14/* @Peptide90

# Sorting by path instead of by who added it one day :(
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Lobby/LobbyState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected override void Startup()

_characterSetup.SaveButton.OnPressed += _ =>
{
_characterSetup.Save();
// _characterSetup.Save(); //Nuclear14 workaround to prevent saving using this button, as I can't make it disable dependent on Special points
_lobby.CharacterPreview.UpdateUI();
};

Expand Down
8 changes: 8 additions & 0 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@
<humanoid:MarkingPicker Name="CMarkings" IgnoreCategories="Hair,FacialHair" />
</ScrollContainer>
</BoxContainer>
<BoxContainer Orientation="Vertical">
<!-- Specials -->
<Label Name="SpecialPointsLabel" HorizontalAlignment="Stretch" Align="Center" />
<ProgressBar Name="SpecialPointsBar" MaxValue="1" Value="1" MinHeight="20" MaxHeight="30" Margin="0 5 0 5" />
<ScrollContainer VerticalExpand="True">
<BoxContainer Name="CSpecialList" Orientation="Vertical" />
</ScrollContainer>
</BoxContainer>
</TabContainer>
</BoxContainer>
<!-- Right side -->
Expand Down
193 changes: 193 additions & 0 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
using Robust.Shared.Utility;
using static Robust.Client.UserInterface.Controls.BoxContainer;
using Direction = Robust.Shared.Maths.Direction;
using Content.Shared.Nuclear14.Special;
using Content.Shared.Nuclear14.CCVar;

namespace Content.Client.Preferences.UI
{
Expand Down Expand Up @@ -78,9 +80,13 @@ public sealed partial class HumanoidProfileEditor : Control

private TabContainer _tabContainer => CTabContainer;
private BoxContainer _jobList => CJobList;
private Label _specialPointsLabel => SpecialPointsLabel; // Nuclear14 special bar points label
private ProgressBar _specialPointsBar => SpecialPointsBar; // Nuclear14 The above labels' names are referencing their position relative to this element
private BoxContainer _specialList => CSpecialList; // Nuclear14 Special list
private BoxContainer _antagList => CAntagList;
private BoxContainer _traitsList => CTraitsList;
private readonly List<JobPrioritySelector> _jobPriorities;
private readonly List<SpecialPrioritySelector> _specialPriorities; // Nuclear14 User special choice
private OptionButton _preferenceUnavailableButton => CPreferenceUnavailableButton;
private readonly Dictionary<string, BoxContainer> _jobCategories;
// Mildly hacky, as I don't trust prototype order to stay consistent and don't want the UI to break should a new one get added mid-edit. --moony
Expand Down Expand Up @@ -384,6 +390,16 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt

#endregion Jobs

// Nuclear14 Special
#region Specials

_tabContainer.SetTabTitle(5, Loc.GetString("humanoid-profile-editor-specials-tab"));
_specialPriorities = new List<SpecialPrioritySelector>();
UpdateSpecialRequirements();

#endregion Specials
// Nuclear14 end

#region Antags

_tabContainer.SetTabTitle(2, Loc.GetString("humanoid-profile-editor-antags-tab"));
Expand Down Expand Up @@ -607,6 +623,57 @@ private void UpdateRoleRequirements()
}
}

// Nuclear14 update Special select requirments
private void UpdateSpecialRequirements()
{
_specialList.DisposeAllChildren();
_specialPriorities.Clear();

var points = _configurationManager.GetCVar(SpecialCCVars.MaxSpecial);
_specialPointsLabel.Text = Loc.GetString("humanoid-profile-editor-loadouts-points-label", ("points", points), ("max", points));
_specialPointsBar.MaxValue = points;
_specialPointsBar.Value = points;


foreach (var special in _prototypeManager.EnumeratePrototypes<SpecialPrototype>().OrderBy(a => a.Order))
{
var selector = new SpecialPrioritySelector(special, _prototypeManager);

_specialList.AddChild(selector);
_specialPriorities.Add(selector);

selector.PriorityChanged += priority =>
{
foreach (var specialSelector in _specialPriorities)
{

if(priority != 0)
{
var temp = _specialPointsBar.Value - (int) priority;
if (temp < 0){
}
else
{
_specialPointsLabel.Text = Loc.GetString("humanoid-profile-editor-special-points-label", ("points", _specialPointsBar.Value), ("max", _specialPointsBar.MaxValue));
_specialPointsBar.Value = temp;
}
}
else
{
_specialPointsLabel.Text = Loc.GetString("humanoid-profile-editor-special-points-label", ("points", _specialPointsBar.Value), ("max", _specialPointsBar.MaxValue));
_specialPointsBar.Value += (int) specialSelector.Priority;
}
Profile = Profile?.WithSpecialPriority(special.ID, priority);
IsDirty = true;

UpdateSpecialPriorities();
}
};

}
}
// Nuclear14 end

private void OnFlavorTextChange(string content)
{
if (Profile is null)
Expand Down Expand Up @@ -1104,6 +1171,7 @@ public void UpdateControls()
UpdateEyePickers();
UpdateSaveButton();
UpdateJobPriorities();
UpdateSpecialPriorities(); // Nuclear14 Special Priorities
UpdateAntagPreferences();
UpdateTraitPreferences();
UpdateMarkings();
Expand Down Expand Up @@ -1138,7 +1206,132 @@ private void UpdateJobPriorities()
}
}

// Nuclear14 Special
private void UpdateSpecialPriorities()
{
var points = _configurationManager.GetCVar(SpecialCCVars.MaxSpecial);
_specialPointsBar.Value = points;
_specialPointsLabel.Text = Loc.GetString("humanoid-profile-editor-special-points-label", ("points", _specialPointsBar.Value), ("max", _specialPointsBar.MaxValue));

foreach (var prioritySelector in _specialPriorities)
{
var specialId = prioritySelector.Special.ID;

var priority = Profile?.SpecialPriorities.GetValueOrDefault(specialId, SpecialPriority.Zero) ?? SpecialPriority.Zero;

prioritySelector.Priority = priority;

if (priority != SpecialPriority.Zero)
{
points -= (int) priority;
_specialPointsBar.Value = points;
_specialPointsLabel.Text = Loc.GetString("humanoid-profile-editor-special-points-label", ("points", points), ("max", _specialPointsBar.MaxValue));

}
}
if (points < 0)
_saveButton.Disabled = true;

}

private sealed class SpecialPrioritySelector : Control
{
public SpecialPrototype Special { get; }
private readonly RadioOptions<int> _optionButton;

public SpecialPriority Priority
{
get => (SpecialPriority) _optionButton.SelectedValue;
set => _optionButton.SelectByValue((int) value);
}

public event Action<SpecialPriority>? PriorityChanged;
private Label _specialTitle;

public SpecialPrioritySelector(SpecialPrototype special, IPrototypeManager prototypeManager)
{
Special = special;

_optionButton = new RadioOptions<int>(RadioOptionsLayout.Horizontal)
{
FirstButtonStyle = StyleBase.ButtonOpenRight,
ButtonStyle = StyleBase.ButtonOpenBoth,
LastButtonStyle = StyleBase.ButtonOpenLeft
};
//Override default radio option button width
_optionButton.GenerateItem = GenerateButton;
// Text, Value
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-one-button"), (int) SpecialPriority.One);
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-two-button"), (int) SpecialPriority.Two);
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-three-button"), (int) SpecialPriority.Three);
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-four-button"), (int) SpecialPriority.Four);
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-five-button"), (int) SpecialPriority.Five);
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-six-button"), (int) SpecialPriority.Six);
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-seven-button"), (int) SpecialPriority.Seven);
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-eight-button"), (int) SpecialPriority.Eight);
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-nine-button"), (int) SpecialPriority.Nine);
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-ten-button"), (int) SpecialPriority.Ten);

_optionButton.OnItemSelected += args =>
{
_optionButton.Select(args.Id);
PriorityChanged?.Invoke(Priority);
};

var icon = new TextureRect
{
TextureScale = new Vector2(2, 2),
Stretch = TextureRect.StretchMode.KeepCentered
};

var specialIcon = prototypeManager.Index<StatusIconPrototype>(special.Icon);
icon.Texture = specialIcon.Icon.Frame0();

_specialTitle = new Label()
{
Margin = new Thickness(5f,5f,5f,5f),
Text = special.LocalizedName,
MinSize = new Vector2(100, 0),
MouseFilter = MouseFilterMode.Stop
};

if (special.LocalizedDescription != null)
{
_specialTitle.ToolTip = special.LocalizedDescription;
_specialTitle.TooltipDelay = 0.2f;
}

AddChild(new BoxContainer
{
Orientation = LayoutOrientation.Horizontal,
Children =
{
icon,
_specialTitle,
_optionButton,
}
});
}
private Button GenerateButton(string text, int value)
{
var btn = new Button
{
Text = text,
MinWidth = 40
};
return btn;
}
}
// Nuclear14 end

private abstract class RequirementsSelector<T> : Control
{
public JobPrototype Job { get; }
private readonly RadioOptions<int> _optionButton;

public JobPriority Priority
{
get => (JobPriority) _optionButton.SelectedValue;
{
public T Proto { get; }
public bool Disabled => _lockStripe.Visible;
Expand Down
19 changes: 17 additions & 2 deletions Content.Client/Weapons/Ranged/GunSpreadOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Robust.Shared.Enums;
using Robust.Shared.Map;
using Robust.Shared.Timing;
using Content.Shared.Nuclear14.Special.Components;

namespace Content.Client.Weapons.Ranged;

Expand Down Expand Up @@ -58,9 +59,23 @@ protected override void Draw(in OverlayDrawArgs args)
// (☞゚ヮ゚)☞
var maxSpread = gun.MaxAngle;
var minSpread = gun.MinAngle;
// Nuclear14 Shotting accuracy depends on Perception
var decay = gun.AngleDecay;
var timeSinceLastFire = (_timing.CurTime - gun.NextFire).TotalSeconds;
var currentAngle = new Angle(MathHelper.Clamp(gun.CurrentAngle.Theta - gun.AngleDecay.Theta * timeSinceLastFire,
gun.MinAngle.Theta, gun.MaxAngle.Theta));
Angle currentAngle;
if (_entManager.TryGetComponent<SpecialComponent>(player, out var special))
{
maxSpread += Angle.FromDegrees((10f - special.TotalPerception));
minSpread += Angle.FromDegrees((10f - special.TotalPerception));
decay += Angle.FromDegrees((special.TotalPerception - 10f) / 5);

currentAngle = new Angle(MathHelper.Clamp(gun.CurrentAngle.Theta - decay.Theta * timeSinceLastFire,
minSpread.Theta, maxSpread.Theta));
}
else
currentAngle = new Angle(MathHelper.Clamp(gun.CurrentAngle.Theta - gun.AngleDecay.Theta * timeSinceLastFire,
gun.MinAngle.Theta, gun.MaxAngle.Theta));
// Nuclear14 end
var direction = (mousePos.Position - mapPos.Position);

worldHandle.DrawLine(mapPos.Position, mousePos.Position + direction, Color.Orange);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Shared.GameTicking;
using Content.Shared.Humanoid;
using Content.Shared.Preferences;
using Content.Shared.Nuclear14.Special;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Robust.Shared.Configuration;
Expand Down Expand Up @@ -60,7 +61,17 @@ private static HumanoidCharacterProfile CharlieCharlieson()
},
PreferenceUnavailableMode.StayInLobby,
new List<string> (),
new List<string>()
new List<string> (),
new Dictionary<string, SpecialPriority>
{
{"Strength", SpecialPriority.Five},
{"Perception", SpecialPriority.Five},
{"Endurance", SpecialPriority.Five},
{"Charisma", SpecialPriority.Five},
{"Intelligence", SpecialPriority.Five},
{"Agility", SpecialPriority.Five},
{"Luck", SpecialPriority.Five}
}
);
}

Expand Down
Loading

0 comments on commit 6d8fc12

Please sign in to comment.