Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Уэээ #46

Merged
merged 2 commits into from
Jul 25, 2024
Merged
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
4 changes: 3 additions & 1 deletion Content.Client/Lobby/LobbyState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ protected override void Startup()

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

LayoutContainer.SetAnchorPreset(_lobby, LayoutContainer.LayoutPreset.Wide);
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 @@ -189,6 +189,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
187 changes: 187 additions & 0 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Content.Client.Message;
using Content.Client.Players.PlayTimeTracking;
using Content.Client.Roles;
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Systems.Guidebook;
using Content.Shared.CCVar;
using Content.Shared.Clothing.Loadouts.Prototypes;
Expand All @@ -18,6 +19,7 @@
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.Roles.Jobs;
using Content.Shared.StatusIcon;
using Content.Shared.Traits;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
Expand All @@ -33,6 +35,8 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
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 @@ -69,6 +73,9 @@ public sealed partial class HumanoidProfileEditor : BoxContainer

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 Label _traitPointsLabel => TraitPointsLabel;
private int _traitCount;
Expand All @@ -82,6 +89,7 @@ public sealed partial class HumanoidProfileEditor : BoxContainer
private BoxContainer _loadoutsTab => CLoadoutsTab;
private TabContainer _loadoutsTabs => CLoadoutsTabs;
private readonly List<JobPrioritySelector> _jobPriorities;
private readonly List<SpecialPrioritySelector> _specialPriorities; // Nuclear14 User special choice
private OptionButton _preferenceUnavailableButton => CPreferenceUnavailableButton;
private readonly Dictionary<string, BoxContainer> _jobCategories;
private readonly List<SpeciesPrototype> _speciesList;
Expand Down Expand Up @@ -490,6 +498,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 @@ -783,6 +801,56 @@ private void EnsureJobRequirementsValid()

Save();
}
// 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)
{
Expand Down Expand Up @@ -1317,6 +1385,7 @@ public void UpdateControls()
UpdateEyePickers();
UpdateSaveButton();
UpdateJobPriorities();
UpdateSpecialPriorities(); // Nuclear14 Special Priorities
UpdateAntagPreferences();
UpdateTraitPreferences();
UpdateLoadouts(_loadoutsShowUnusableButton.Pressed);
Expand Down Expand Up @@ -1344,6 +1413,124 @@ 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 void UpdateAntagPreferences()
{
foreach (var preferenceSelector in _antagPreferences)
Expand Down
21 changes: 19 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,25 @@ protected override void Draw(in OverlayDrawArgs args)
// (☞゚ヮ゚)☞
var maxSpread = gun.MaxAngleModified;
var minSpread = gun.MinAngleModified;
// Nuclear14 Shotting accuracy depends on Perception
var decay = gun.AngleDecayModified;
var timeSinceLastFire = (_timing.CurTime - gun.NextFire).TotalSeconds;
var currentAngle = new Angle(MathHelper.Clamp(gun.CurrentAngle.Theta - gun.AngleDecayModified.Theta * timeSinceLastFire,
gun.MinAngleModified.Theta, gun.MaxAngleModified.Theta));
Angle currentAngle;
if (_entManager.TryGetComponent<SpecialComponent>(player, out var special))
{
maxSpread += Angle.FromDegrees((40f - special.TotalPerception * 5));
minSpread += Angle.FromDegrees((10f - special.TotalPerception));
maxSpread *= 1.5 - special.TotalPerception / 10;
minSpread *= 1.5 - special.TotalPerception / 10;
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.AngleDecayModified.Theta * timeSinceLastFire,
gun.MinAngleModified.Theta, gun.MaxAngleModified.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 @@ -65,7 +66,17 @@ private static HumanoidCharacterProfile CharlieCharlieson()
PreferenceUnavailableMode.StayInLobby,
antagPreferences: new List<string>(),
traitPreferences: new List<string>(),
loadoutPreferences: new List<string>()
loadoutPreferences: new List<string>(),
specialPriorities: 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
Loading