Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/sunrise_public/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
VigersRay committed Dec 24, 2024
2 parents 7adaa18 + d8547bf commit 80ca9e4
Show file tree
Hide file tree
Showing 41 changed files with 2,042 additions and 1,265 deletions.
19 changes: 10 additions & 9 deletions Content.Client/Lobby/UI/Loadouts/LoadoutContainer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@ public LoadoutContainer(ProtoId<LoadoutPrototype> proto, bool disabled, Formatte

if (_protoManager.TryIndex(proto, out var loadProto))
{
var ent = _entManager.System<LoadoutSystem>().GetFirstOrNull(loadProto);
var ent = loadProto.DummyEntity ?? _entManager.System<LoadoutSystem>().GetFirstOrNull(loadProto);

if (ent != null)
{
_entity = _entManager.SpawnEntity(ent, MapCoordinates.Nullspace);
Sprite.SetEntity(_entity);
if (ent == null)
return;

var spriteTooltip = new Tooltip();
spriteTooltip.SetMessage(FormattedMessage.FromUnformatted(_entManager.GetComponent<MetaDataComponent>(_entity.Value).EntityDescription));
TooltipSupplier = _ => spriteTooltip;
}
_entity = _entManager.SpawnEntity(ent, MapCoordinates.Nullspace);
Sprite.SetEntity(_entity);

var spriteTooltip = new Tooltip();
spriteTooltip.SetMessage(FormattedMessage.FromUnformatted(_entManager.GetComponent<MetaDataComponent>(_entity.Value).EntityDescription));

TooltipSupplier = _ => spriteTooltip;
}
}

Expand Down
12 changes: 12 additions & 0 deletions Content.Client/Lobby/UI/LobbyGui.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ public LobbyGui()

_configurationManager.OnValueChanged(SunriseCCVars.LobbyOpacity, OnLobbyOpacityChanged);
_configurationManager.OnValueChanged(SunriseCCVars.ServersHubEnable, OnServersHubEnableChanged);
_configurationManager.OnValueChanged(SunriseCCVars.ServiceAuthEnabled, OnServiceAuthEnableChanged);
_configurationManager.OnValueChanged(SunriseCCVars.ServerName, OnServerNameChanged, true);

SetLobbyOpacity(_configurationManager.GetCVar(SunriseCCVars.LobbyOpacity));
SetServersHubEnable(_configurationManager.GetCVar(SunriseCCVars.ServersHubEnable));
SetUserProfileEnable(_configurationManager.GetCVar(SunriseCCVars.ServiceAuthEnabled));

Chat.SetChatOpacity();

Expand Down Expand Up @@ -180,10 +182,20 @@ private void OnServersHubEnableChanged(bool enable)
SetServersHubEnable(enable);
}

private void OnServiceAuthEnableChanged(bool enable)
{
SetUserProfileEnable(enable);
}

private void SetServersHubEnable(bool enable)
{
ServersHubBox.Visible = enable;
}

private void SetUserProfileEnable(bool enable)
{
UserProfileBox.Visible = enable;
}
// Sunrise-End

private void OnLobbyOpacityChanged(float opacity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public sealed partial class SensorMonitoringWindow : FancyWindow, IComputerWindo
public SensorMonitoringWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
}

public void UpdateState(ConsoleUIState state)
Expand Down
168 changes: 96 additions & 72 deletions Content.Client/_Sunrise/SponsorTiers/SponsorTierEntry.xaml

Large diffs are not rendered by default.

126 changes: 80 additions & 46 deletions Content.Client/_Sunrise/SponsorTiers/SponsorTierEntry.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,23 @@ public sealed partial class SponsorTierEntry : Control
[Dependency] private readonly IPlayerManager _playerManager = default!;

private readonly LobbyUIController _lobbyUIController;
private ISharedSponsorsManager? _sponsorsManager; // Sunrise-Sponsors
private readonly ISharedSponsorsManager? _sponsorsManager;

private float AccumulatedTime;
private List<SpriteView> SpriteViews = new();
private SponsorInfo SponsorInfoTier;
private float _accumulatedTime;
private readonly List<SpriteView> _spriteViews = new();
private readonly SponsorInfo _sponsorInfoTier;

public int Index { get; }

public SponsorTierEntry(SponsorInfo sponsorTier, int index)
{
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);
IoCManager.Instance!.TryResolveType(out _sponsorsManager); // Sunrise-Sponsors
IoCManager.Instance!.TryResolveType(out _sponsorsManager);
_lobbyUIController = UserInterfaceManager.GetUIController<LobbyUIController>();
_preferencesManager.OnServerDataLoaded += PreferencesDataLoaded;

Index = index;
SponsorInfoTier = sponsorTier;
_sponsorInfoTier = sponsorTier;

LoadTierInfo(sponsorTier.Tier, sponsorTier.OOCColor, sponsorTier.ExtraSlots, sponsorTier.HavePriorityJoin, sponsorTier.AllowedRespawn);
LoadOpenAntags(sponsorTier.OpenAntags);
Expand All @@ -70,24 +69,23 @@ public SponsorTierEntry(SponsorInfo sponsorTier, int index)
LoadOpenGhostRoles(sponsorTier.OpenGhostRoles);
LoadAllowedVoices(sponsorTier.AllowedVoices);
LoadAllowedLoadouts(sponsorTier.AllowedLoadouts);
if (_preferencesManager.ServerDataLoaded)
{
LoadOpenRoles(_sponsorInfoTier.OpenRoles);
LoadPriorityRoles(_sponsorInfoTier.PriorityRoles);
LoadBypassRoles(_sponsorInfoTier.BypassRoles);
}
else
{
_preferencesManager.OnServerDataLoaded += PreferencesDataLoaded;
}
}

private void PreferencesDataLoaded()
{
LoadOpenRoles(SponsorInfoTier.OpenRoles);
LoadPriorityRoles(SponsorInfoTier.PriorityRoles);
LoadBypassRoles(SponsorInfoTier.BypassRoles);
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);

AccumulatedTime += args.DeltaSeconds;
foreach (var spriteView in SpriteViews)
{
spriteView.OverrideDirection = (Direction) ((int) AccumulatedTime % 4 * 2);
}
LoadOpenRoles(_sponsorInfoTier.OpenRoles);
LoadPriorityRoles(_sponsorInfoTier.PriorityRoles);
LoadBypassRoles(_sponsorInfoTier.BypassRoles);
}

private void LoadTierInfo(int tier, string? oocColor, int extraSlots, bool priorityJoin, bool allowedRespawn)
Expand All @@ -103,14 +101,14 @@ private void LoadTierInfo(int tier, string? oocColor, int extraSlots, bool prior
AllowedRespawnLabel.Text = allowedRespawn ? "Да" : "Нет";
}

private void LoadOpenGhostRoles(string[] openGhostRoles)
private void LoadOpenGhostRoles(IReadOnlyCollection<string> openGhostRoles)
{
foreach (var openGhostRole in openGhostRoles)
{
if (!_prototypeManager.TryIndex(openGhostRole, out EntityPrototype? ghostRolePrototype))
continue;

var dummyEnt = _entityManager.SpawnEntity(openGhostRole, MapCoordinates.Nullspace);
var dummyEnt = _entityManager.SpawnEntity(ghostRolePrototype.ID, MapCoordinates.Nullspace);

var view = new SpriteView
{
Expand All @@ -119,22 +117,24 @@ private void LoadOpenGhostRoles(string[] openGhostRoles)
};

view.SetEntity(dummyEnt);
SpriteViews.Add(view);
_spriteViews.Add(view);

var panel = CreateEntityIcon($"ent-{openGhostRole}", view);
var panel = CreateEntityIcon($"ent-{ghostRolePrototype.ID}", view);

OpenGhostRolesGrid.AddChild(panel);
}

OpenGhostRolesBox.Visible = OpenGhostRolesGrid.ChildCount > 0;
}

private void LoadPriorityGhostRoles(string[] priorityGhostRoles)
private void LoadPriorityGhostRoles(IReadOnlyCollection<string> priorityGhostRoles)
{
foreach (var priorityGhostRole in priorityGhostRoles)
{
if (!_prototypeManager.TryIndex(priorityGhostRole, out EntityPrototype? ghostRolePrototype))
continue;

var dummyEnt = _entityManager.SpawnEntity(priorityGhostRole, MapCoordinates.Nullspace);
var dummyEnt = _entityManager.SpawnEntity(ghostRolePrototype.ID, MapCoordinates.Nullspace);

var view = new SpriteView
{
Expand All @@ -143,15 +143,17 @@ private void LoadPriorityGhostRoles(string[] priorityGhostRoles)
};

view.SetEntity(dummyEnt);
SpriteViews.Add(view);
_spriteViews.Add(view);

var panel = CreateEntityIcon($"ent-{priorityGhostRole}", view);
var panel = CreateEntityIcon($"ent-{ghostRolePrototype.ID}", view);

PriorityGhostRolesGrid.AddChild(panel);
}

PriorityGhostRolesBox.Visible = PriorityGhostRolesGrid.ChildCount > 0;
}

private void LoadAllowedVoices(string[] allowedVoices)
private void LoadAllowedVoices(IReadOnlyCollection<string> allowedVoices)
{
foreach (var allowedVoice in allowedVoices)
{
Expand All @@ -173,9 +175,11 @@ private void LoadAllowedVoices(string[] allowedVoices)

TTSVoicesGrid.AddChild(button);
}

TTSVoicesBox.Visible = TTSVoicesGrid.ChildCount > 0;
}

private void LoadAllowedLoadouts(string[] allowedLoadouts)
private void LoadAllowedLoadouts(IReadOnlyCollection<string> allowedLoadouts)
{
foreach (var allowedLoadout in allowedLoadouts)
{
Expand All @@ -190,7 +194,7 @@ private void LoadAllowedLoadouts(string[] allowedLoadouts)
SetSize = new Vector2(128, 128),
Scale = new Vector2(6, 6)
};
SpriteViews.Add(view);
_spriteViews.Add(view);

if (entProtoId != null)
{
Expand All @@ -202,9 +206,11 @@ private void LoadAllowedLoadouts(string[] allowedLoadouts)

AllowedLoadoutsGrid.AddChild(panel);
}

AllowedLoadoutsBox.Visible = AllowedLoadoutsGrid.ChildCount > 0;
}

private void LoadGhostThemes(string[] ghostThemes)
private void LoadGhostThemes(IReadOnlyCollection<string> ghostThemes)
{
foreach (var ghostTheme in ghostThemes)
{
Expand All @@ -215,9 +221,11 @@ private void LoadGhostThemes(string[] ghostThemes)

GhostThemesGrid.AddChild(panel);
}

GhostThemesBox.Visible = GhostThemesGrid.ChildCount > 0;
}

private void LoadBypassRoles(string[] bypassRoles)
private void LoadBypassRoles(IReadOnlyCollection<string> bypassRoles)
{
foreach (var bypassRole in bypassRoles)
{
Expand Down Expand Up @@ -260,15 +268,17 @@ private void LoadBypassRoles(string[] bypassRoles)
};

view.SetEntity(dummyEnt);
SpriteViews.Add(view);
_spriteViews.Add(view);

var panel = CreateEntityIcon(roleProto.Name, view);

BypassRolesGrid.AddChild(panel);
}

BypassRolesBox.Visible = BypassRolesGrid.ChildCount > 0;
}

private void LoadAllowedSpecies(string[] speciesList)
private void LoadAllowedSpecies(IReadOnlyCollection<string> speciesList)
{
foreach (var species in speciesList)
{
Expand All @@ -283,17 +293,19 @@ private void LoadAllowedSpecies(string[] speciesList)
Scale = new Vector2(4, 4),
};
view.SetEntity(dummyEnt);
SpriteViews.Add(view);
_spriteViews.Add(view);

var panel = CreateEntityIcon(speciesPrototype.Name, view);

AllowedSpeciesGrid.AddChild(panel);
}

AllowedSpeciesBox.Visible = AllowedSpeciesGrid.ChildCount > 0;
}

private void LoadAllowedMarkings(string[] markings)
private void LoadAllowedMarkings(IReadOnlyCollection<string> markingsList)
{
foreach (var marking in markings)
foreach (var marking in markingsList)
{
if (!_prototypeManager.TryIndex(marking, out MarkingPrototype? markingProto))
continue;
Expand All @@ -319,15 +331,18 @@ private void LoadAllowedMarkings(string[] markings)
_entityManager.System<HumanoidAppearanceSystem>().ApplyMarking(markingProto, null, true, humanoidAppearance, spriteComponent);

view.SetEntity(dummyEnt);
SpriteViews.Add(view);
_spriteViews.Add(view);

var panel = CreateEntityIcon($"marking-{markingProto.ID}", view);

AllowedMarkingsGrid.AddChild(panel);
}

AllowedMarkingsBox.Visible = AllowedMarkingsGrid.ChildCount > 0;

}

private void LoadPriorityAntags(string[] priorityAntags)
private void LoadPriorityAntags(IReadOnlyCollection<string> priorityAntags)
{
foreach (var priorityAntag in priorityAntags)
{
Expand All @@ -338,9 +353,11 @@ private void LoadPriorityAntags(string[] priorityAntags)

PriorityAntagGrid.AddChild(panel);
}

PriorityAntagBox.Visible = PriorityAntagGrid.ChildCount > 0;
}

private void LoadOpenAntags(string[] openAntags)
private void LoadOpenAntags(IReadOnlyCollection<string> openAntags)
{
foreach (var openAntag in openAntags)
{
Expand All @@ -351,9 +368,11 @@ private void LoadOpenAntags(string[] openAntags)

OpenAntagGrid.AddChild(panel);
}

OpenAntagBox.Visible = OpenAntagGrid.ChildCount > 0;
}

private void LoadPriorityRoles(string[] priorityRoles)
private void LoadPriorityRoles(IReadOnlyCollection<string> priorityRoles)
{
foreach (var priorityRole in priorityRoles)
{
Expand Down Expand Up @@ -396,15 +415,17 @@ private void LoadPriorityRoles(string[] priorityRoles)
};

view.SetEntity(dummyEnt);
SpriteViews.Add(view);
_spriteViews.Add(view);

var panel = CreateEntityIcon(roleProto.Name, view);

PriorityRolesGrid.AddChild(panel);
}

PriorityRolesBox.Visible = PriorityRolesGrid.ChildCount > 0;
}

private void LoadOpenRoles(string[] openRoles)
private void LoadOpenRoles(IReadOnlyCollection<string> openRoles)
{
foreach (var openRole in openRoles)
{
Expand Down Expand Up @@ -447,12 +468,14 @@ private void LoadOpenRoles(string[] openRoles)
};

view.SetEntity(dummyEnt);
SpriteViews.Add(view);
_spriteViews.Add(view);

var panel = CreateEntityIcon(roleProto.Name, view);

OpenRolesGrid.AddChild(panel);
}

OpenRolesBox.Visible = OpenRolesGrid.ChildCount > 0;
}

private PanelContainer CreateEntityIcon(string name, SpriteView spriteView)
Expand Down Expand Up @@ -540,4 +563,15 @@ private PanelContainer CreateIcon(string name, SpriteSpecifier spriteSpecifier)

return panel;
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);

_accumulatedTime += args.DeltaSeconds;
foreach (var spriteView in _spriteViews)
{
spriteView.OverrideDirection = (Direction) ((int) _accumulatedTime % 4 * 2);
}
}
}
Loading

0 comments on commit 80ca9e4

Please sign in to comment.